From d816c7617cb3f7f3ac72cb33184bc8a07b49e6d2 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 27 Feb 2010 17:15:49 +0000 Subject: [PATCH 001/211] Report service status to the service manager. Patch is partially based on code by Dmitry Gorbachev. svn path=/trunk/; revision=45706 --- reactos/base/services/umpnpmgr/umpnpmgr.c | 91 +++++++++++++++++++++-- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/reactos/base/services/umpnpmgr/umpnpmgr.c b/reactos/base/services/umpnpmgr/umpnpmgr.c index 8dc8a16e031..2352efe703f 100644 --- a/reactos/base/services/umpnpmgr/umpnpmgr.c +++ b/reactos/base/services/umpnpmgr/umpnpmgr.c @@ -51,15 +51,17 @@ /* GLOBALS ******************************************************************/ -static VOID CALLBACK -ServiceMain(DWORD argc, LPTSTR *argv); - -static SERVICE_TABLE_ENTRY ServiceTable[2] = +static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv); +static WCHAR ServiceName[] = L"PlugPlay"; +static SERVICE_TABLE_ENTRYW ServiceTable[] = { - {TEXT("PlugPlay"), ServiceMain}, + {ServiceName, ServiceMain}, {NULL, NULL} }; +static SERVICE_STATUS_HANDLE ServiceStatusHandle; +static SERVICE_STATUS ServiceStatus; + static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0"; static HKEY hEnumKey = NULL; @@ -2446,6 +2448,72 @@ PnpEventThread(LPVOID lpParameter) } +static VOID +UpdateServiceStatus(DWORD dwState) +{ + ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + ServiceStatus.dwCurrentState = dwState; + ServiceStatus.dwControlsAccepted = 0; + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + + if (dwState == SERVICE_START_PENDING || + dwState == SERVICE_STOP_PENDING || + dwState == SERVICE_PAUSE_PENDING || + dwState == SERVICE_CONTINUE_PENDING) + ServiceStatus.dwWaitHint = 10000; + else + ServiceStatus.dwWaitHint = 0; + + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); +} + + +static DWORD WINAPI +ServiceControlHandler(DWORD dwControl, + DWORD dwEventType, + LPVOID lpEventData, + LPVOID lpContext) +{ + DPRINT1("ServiceControlHandler() called\n"); + + switch (dwControl) + { + case SERVICE_CONTROL_STOP: + DPRINT1(" SERVICE_CONTROL_STOP received\n"); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_PAUSE: + DPRINT1(" SERVICE_CONTROL_PAUSE received\n"); + UpdateServiceStatus(SERVICE_PAUSED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_CONTINUE: + DPRINT1(" SERVICE_CONTROL_CONTINUE received\n"); + UpdateServiceStatus(SERVICE_RUNNING); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_INTERROGATE: + DPRINT1(" SERVICE_CONTROL_INTERROGATE received\n"); + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_SHUTDOWN: + DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n"); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + default : + DPRINT1(" Control %lu received\n"); + return ERROR_CALL_NOT_IMPLEMENTED; + } +} + + static VOID CALLBACK ServiceMain(DWORD argc, LPTSTR *argv) { @@ -2457,6 +2525,17 @@ ServiceMain(DWORD argc, LPTSTR *argv) DPRINT("ServiceMain() called\n"); + ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName, + ServiceControlHandler, + NULL); + if (!ServiceStatusHandle) + { + DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError()); + return; + } + + UpdateServiceStatus(SERVICE_START_PENDING); + hThread = CreateThread(NULL, 0, PnpEventThread, @@ -2484,6 +2563,8 @@ ServiceMain(DWORD argc, LPTSTR *argv) if (hThread != NULL) CloseHandle(hThread); + UpdateServiceStatus(SERVICE_RUNNING); + DPRINT("ServiceMain() done\n"); } From 763962665e92d0c421df1455bed5acb5bce29d58 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sat, 27 Feb 2010 19:51:54 +0000 Subject: [PATCH 002/211] Don't use #pragma once for pch files. Fixes build. svn path=/trunk/; revision=45710 --- reactos/base/applications/charmap/precomp.h | 5 ++++- reactos/base/applications/mscutils/devmgmt/precomp.h | 5 ++++- reactos/base/applications/mscutils/servman/precomp.h | 5 ++++- reactos/base/applications/taskmgr/precomp.h | 5 ++++- reactos/base/shell/cmd/precomp.h | 5 ++++- reactos/base/system/smss/smss.h | 6 +++++- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/reactos/base/applications/charmap/precomp.h b/reactos/base/applications/charmap/precomp.h index a87f118d866..4e0324c3de5 100644 --- a/reactos/base/applications/charmap/precomp.h +++ b/reactos/base/applications/charmap/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __CHARMAP_PRECOMP_H +#define __CHARMAP_PRECOMP_H #include #include @@ -52,3 +53,5 @@ VOID ShowAboutDlg(HWND hWndParent); BOOL RegisterMapClasses(HINSTANCE hInstance); VOID UnregisterMapClasses(HINSTANCE hInstance); + +#endif /* __CHARMAP_PRECOMP_H */ diff --git a/reactos/base/applications/mscutils/devmgmt/precomp.h b/reactos/base/applications/mscutils/devmgmt/precomp.h index 8723d8d1d55..d9bdd425f85 100644 --- a/reactos/base/applications/mscutils/devmgmt/precomp.h +++ b/reactos/base/applications/mscutils/devmgmt/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __DEVMGMT_PRECOMP_H +#define __DEVMGMT_PRECOMP_H #define WIN32_LEAN_AND_MEAN #include @@ -92,3 +93,5 @@ HIMAGELIST InitImageList(UINT NumButtons, VOID GetError(VOID); VOID DisplayString(LPTSTR); + +#endif /* __DEVMGMT_PRECOMP_H */ diff --git a/reactos/base/applications/mscutils/servman/precomp.h b/reactos/base/applications/mscutils/servman/precomp.h index a81b984c7d3..9b829ad78df 100644 --- a/reactos/base/applications/mscutils/servman/precomp.h +++ b/reactos/base/applications/mscutils/servman/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __SERVMAN_PRECOMP_H +#define __SERVMAN_PRECOMP_H //#define WIN32_LEAN_AND_MEAN #include @@ -184,3 +185,5 @@ HIMAGELIST InitImageList(UINT StartResource, UINT Width, UINT Height, ULONG type); + +#endif /* __SERVMAN_PRECOMP_H */ diff --git a/reactos/base/applications/taskmgr/precomp.h b/reactos/base/applications/taskmgr/precomp.h index 67272472a48..c30856b3065 100644 --- a/reactos/base/applications/taskmgr/precomp.h +++ b/reactos/base/applications/taskmgr/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __PRECOMP_H +#define __PRECOMP_H #ifndef UNICODE #error Task-Manager uses NDK functions, so it can only be compiled with Unicode support enabled! @@ -35,3 +36,5 @@ #include "priority.h" #include "run.h" #include "trayicon.h" + +#endif /* __PRECOMP_H */ diff --git a/reactos/base/shell/cmd/precomp.h b/reactos/base/shell/cmd/precomp.h index f36368e1d59..915246cceb8 100644 --- a/reactos/base/shell/cmd/precomp.h +++ b/reactos/base/shell/cmd/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __CMD_PRECOMP_H +#define __CMD_PRECOMP_H #ifdef _MSC_VER #pragma warning ( disable : 4103 ) /* use #pragma pack to change alignment */ @@ -42,3 +43,5 @@ WINE_DEFAULT_DEBUG_CHANNEL(cmd); #else #define debugstr_aw debugstr_a #endif + +#endif /* __CMD_PRECOMP_H */ diff --git a/reactos/base/system/smss/smss.h b/reactos/base/system/smss/smss.h index 8c467e566dc..61f3b4bead4 100644 --- a/reactos/base/system/smss/smss.h +++ b/reactos/base/system/smss/smss.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _SMSS_H_INCLUDED_ +#define _SMSS_H_INCLUDED_ #include #include @@ -112,4 +113,7 @@ NTSTATUS SmInitializeDbgSs(VOID); VOID NTAPI DisplayString(LPCWSTR lpwString); VOID NTAPI PrintString (char* fmt, ...); +#endif /* _SMSS_H_INCLUDED_ */ + /* EOF */ + From 9e6714ef3bc2138e19bca606132e5be02d154b19 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 27 Feb 2010 21:47:59 +0000 Subject: [PATCH 003/211] [SERVICES] - Generate unique service status handles. Services could set the status information of another service because the status handles were not guaranteed to be unique for all services. - Lock and unlock the service database when getting or setting service status information. svn path=/trunk/; revision=45711 --- reactos/base/system/services/database.c | 61 ++++++-------- reactos/base/system/services/rpcserver.c | 9 +- reactos/base/system/services/services.h | 7 +- reactos/dll/win32/advapi32/service/sctrl.c | 92 ++++++++++----------- reactos/include/reactos/services/services.h | 4 +- 5 files changed, 85 insertions(+), 88 deletions(-) diff --git a/reactos/base/system/services/database.c b/reactos/base/system/services/database.c index 2a0ae9859f9..95bc302daac 100644 --- a/reactos/base/system/services/database.c +++ b/reactos/base/system/services/database.c @@ -121,37 +121,6 @@ ScmGetServiceEntryByResumeCount(DWORD dwResumeCount) } -PSERVICE -ScmGetServiceEntryByClientHandle(HANDLE Handle) -{ - PLIST_ENTRY ServiceEntry; - PSERVICE CurrentService; - - DPRINT("ScmGetServiceEntryByClientHandle() called\n"); - DPRINT("looking for %p\n", Handle); - - ServiceEntry = ServiceListHead.Flink; - while (ServiceEntry != &ServiceListHead) - { - CurrentService = CONTAINING_RECORD(ServiceEntry, - SERVICE, - ServiceListEntry); - - if (CurrentService->hClient == Handle) - { - DPRINT("Found service: '%S'\n", CurrentService->lpDisplayName); - return CurrentService; - } - - ServiceEntry = ServiceEntry->Flink; - } - - DPRINT("Couldn't find a matching service\n"); - - return NULL; -} - - DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName, PSERVICE *lpServiceRecord) @@ -728,8 +697,8 @@ ScmControlService(PSERVICE Service, return ERROR_NOT_ENOUGH_MEMORY; ControlPacket->dwControl = dwControl; - ControlPacket->hClient = Service->hClient; ControlPacket->dwSize = TotalLength; + ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service; wcscpy(&ControlPacket->szArguments[0], Service->lpServiceName); /* Send the control packet */ @@ -793,7 +762,7 @@ ScmSendStartCommand(PSERVICE Service, return ERROR_NOT_ENOUGH_MEMORY; ControlPacket->dwControl = SERVICE_CONTROL_START; - ControlPacket->hClient = Service->hClient; + ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service; ControlPacket->dwSize = TotalLength; Ptr = &ControlPacket->szArguments[0]; wcscpy(Ptr, Service->lpServiceName); @@ -850,6 +819,7 @@ ScmStartUserModeService(PSERVICE Service, WCHAR NtControlPipeName[MAX_PATH + 1]; HKEY hServiceCurrentKey = INVALID_HANDLE_VALUE; DWORD KeyDisposition; + DWORD dwProcessId; RtlInitUnicodeString(&ImagePath, NULL); @@ -991,7 +961,7 @@ ScmStartUserModeService(PSERVICE Service, /* Read SERVICE_STATUS_HANDLE from pipe */ if (!ReadFile(Service->ControlPipeHandle, - (LPVOID)&Service->hClient, + (LPVOID)&dwProcessId, sizeof(DWORD), &dwRead, NULL)) @@ -1002,7 +972,7 @@ ScmStartUserModeService(PSERVICE Service, } else { - DPRINT("Received service status %lu\n", Service->hClient); + DPRINT("Received service process ID %lu\n", dwProcessId); /* Send start command */ dwError = ScmSendStartCommand(Service, argc, argv); @@ -1244,4 +1214,25 @@ ScmAutoShutdownServices(VOID) DPRINT("ScmGetBootAndSystemDriverState() done\n"); } + +BOOL +ScmLockDatabaseExclusive(VOID) +{ + return RtlAcquireResourceExclusive(&DatabaseLock, TRUE); +} + + +BOOL +ScmLockDatabaseShared(VOID) +{ + return RtlAcquireResourceShared(&DatabaseLock, TRUE); +} + + +VOID +ScmUnlockDatabase(VOID) +{ + RtlReleaseResource(&DatabaseLock); +} + /* EOF */ diff --git a/reactos/base/system/services/rpcserver.c b/reactos/base/system/services/rpcserver.c index 2262aa55e71..a1085f05fe3 100644 --- a/reactos/base/system/services/rpcserver.c +++ b/reactos/base/system/services/rpcserver.c @@ -978,11 +978,15 @@ DWORD RQueryServiceStatus( return ERROR_INVALID_HANDLE; } + ScmLockDatabaseShared(); + /* Return service status information */ RtlCopyMemory(lpServiceStatus, &lpService->Status, sizeof(SERVICE_STATUS)); + ScmUnlockDatabase(); + return ERROR_SUCCESS; } @@ -1030,7 +1034,7 @@ DWORD RSetServiceStatus( return ERROR_INVALID_HANDLE; } - lpService = ScmGetServiceEntryByClientHandle((HANDLE)hServiceStatus); + lpService = (PSERVICE)hServiceStatus; if (lpService == NULL) { DPRINT("lpService == NULL!\n"); @@ -1059,11 +1063,14 @@ DWORD RSetServiceStatus( return ERROR_INVALID_DATA; } + ScmLockDatabaseExclusive(); RtlCopyMemory(&lpService->Status, lpServiceStatus, sizeof(SERVICE_STATUS)); + ScmUnlockDatabase(); + DPRINT("Set %S to %lu\n", lpService->lpDisplayName, lpService->Status.dwCurrentState); DPRINT("RSetServiceStatus() done\n"); diff --git a/reactos/base/system/services/services.h b/reactos/base/system/services/services.h index 23022dc2c92..811aa001e49 100644 --- a/reactos/base/system/services/services.h +++ b/reactos/base/system/services/services.h @@ -42,7 +42,6 @@ typedef struct _SERVICE DWORD dwResumeCount; DWORD dwRefCount; - CLIENT_HANDLE hClient; SERVICE_STATUS Status; DWORD dwStartType; DWORD dwErrorControl; @@ -112,7 +111,6 @@ DWORD ScmStartService(PSERVICE Service, PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName); PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName); PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount); -PSERVICE ScmGetServiceEntryByClientHandle(HANDLE Handle); DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName, PSERVICE *lpServiceRecord); VOID ScmDeleteServiceRecord(PSERVICE lpService); @@ -122,6 +120,11 @@ DWORD ScmControlService(PSERVICE Service, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus); +BOOL ScmLockDatabaseExclusive(VOID); +BOOL ScmLockDatabaseShared(VOID); +VOID ScmUnlockDatabase(VOID); + + /* driver.c */ DWORD ScmLoadDriver(PSERVICE lpService); diff --git a/reactos/dll/win32/advapi32/service/sctrl.c b/reactos/dll/win32/advapi32/service/sctrl.c index 3094951b911..a88fb2f11b0 100644 --- a/reactos/dll/win32/advapi32/service/sctrl.c +++ b/reactos/dll/win32/advapi32/service/sctrl.c @@ -22,7 +22,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi); typedef struct _ACTIVE_SERVICE { - CLIENT_HANDLE hService; + SERVICE_STATUS_HANDLE hServiceStatus; UNICODE_STRING ServiceName; union { @@ -32,7 +32,6 @@ typedef struct _ACTIVE_SERVICE LPHANDLER_FUNCTION HandlerFunction; LPHANDLER_FUNCTION_EX HandlerFunctionEx; LPVOID HandlerContext; - SERVICE_STATUS ServiceStatus; BOOL bUnicode; LPWSTR Arguments; } ACTIVE_SERVICE, *PACTIVE_SERVICE; @@ -199,6 +198,7 @@ ScConnectControlPipe(HANDLE *hPipe) NTSTATUS Status; WCHAR NtControlPipeName[MAX_PATH + 1]; RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + DWORD dwProcessId; /* Get the service number and create the named pipe */ RtlZeroMemory(&QueryTable, @@ -249,37 +249,34 @@ ScConnectControlPipe(HANDLE *hPipe) return ERROR_FAILED_SERVICE_CONTROLLER_CONNECT; } - /* Share the SERVICE_HANDLE handle with the SCM */ + /* Pass the ProcessId to the SCM */ + dwProcessId = GetCurrentProcessId(); WriteFile(*hPipe, - (DWORD *)&lpActiveServices->hService, - sizeof(CLIENT_HANDLE), + &dwProcessId, + sizeof(DWORD), &dwBytesWritten, NULL); - TRACE("Sent SERVICE_HANDLE %lu\n", lpActiveServices->hService); + TRACE("Sent Process ID %lu\n", dwProcessId); + return ERROR_SUCCESS; } static DWORD -ScStartService(PSCM_CONTROL_PACKET ControlPacket) +ScStartService(PACTIVE_SERVICE lpService, + PSCM_CONTROL_PACKET ControlPacket) { - PACTIVE_SERVICE lpService; HANDLE ThreadHandle; DWORD ThreadId; TRACE("ScStartService() called\n"); - TRACE("client handle: %lu\n", ControlPacket->hClient); TRACE("Size: %lu\n", ControlPacket->dwSize); TRACE("Service: %S\n", &ControlPacket->szArguments[0]); - lpService = (PACTIVE_SERVICE)ControlPacket->hClient; - if (lpService == NULL) - { - TRACE("Service not found\n"); - return ERROR_SERVICE_DOES_NOT_EXIST; - } + /* Set the service status handle */ + lpService->hServiceStatus = ControlPacket->hServiceStatus; lpService->Arguments = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, @@ -309,21 +306,13 @@ ScStartService(PSCM_CONTROL_PACKET ControlPacket) static DWORD -ScControlService(PSCM_CONTROL_PACKET ControlPacket) +ScControlService(PACTIVE_SERVICE lpService, + PSCM_CONTROL_PACKET ControlPacket) { - PACTIVE_SERVICE lpService; - TRACE("ScControlService() called\n"); TRACE("Size: %lu\n", ControlPacket->dwSize); TRACE("Service: %S\n", &ControlPacket->szArguments[0]); - lpService = (PACTIVE_SERVICE)ControlPacket->hClient; - if (lpService == NULL) - { - TRACE("Service not found\n"); - return ERROR_SERVICE_DOES_NOT_EXIST; - } - if (lpService->HandlerFunction) { (lpService->HandlerFunction)(ControlPacket->dwControl); @@ -356,6 +345,8 @@ ScServiceDispatcher(HANDLE hPipe, DWORD Count; BOOL bResult; DWORD dwRunningServices = 0; + LPWSTR lpServiceName; + PACTIVE_SERVICE lpService; TRACE("ScDispatcherLoop() called\n"); @@ -379,25 +370,32 @@ ScServiceDispatcher(HANDLE hPipe, return FALSE; } - /* Execute command */ - switch (ControlPacket->dwControl) + lpServiceName = &ControlPacket->szArguments[0]; + TRACE("Service: %S\n", lpServiceName); + + lpService = ScLookupServiceByServiceName(lpServiceName); + if (lpService != NULL) { - case SERVICE_CONTROL_START: - TRACE("Start command - recieved SERVICE_CONTROL_START\n"); - if (ScStartService(ControlPacket) == ERROR_SUCCESS) - dwRunningServices++; - break; + /* Execute command */ + switch (ControlPacket->dwControl) + { + case SERVICE_CONTROL_START: + TRACE("Start command - recieved SERVICE_CONTROL_START\n"); + if (ScStartService(lpService, ControlPacket) == ERROR_SUCCESS) + dwRunningServices++; + break; - case SERVICE_CONTROL_STOP: - TRACE("Stop command - recieved SERVICE_CONTROL_STOP\n"); - if (ScControlService(ControlPacket) == ERROR_SUCCESS) - dwRunningServices--; - break; + case SERVICE_CONTROL_STOP: + TRACE("Stop command - recieved SERVICE_CONTROL_STOP\n"); + if (ScControlService(lpService, ControlPacket) == ERROR_SUCCESS) + dwRunningServices--; + break; - default: - TRACE("Command %lu received", ControlPacket->dwControl); - ScControlService(ControlPacket); - continue; + default: + TRACE("Command %lu received", ControlPacket->dwControl); + ScControlService(lpService, ControlPacket); + continue; + } } if (dwRunningServices == 0) @@ -461,9 +459,9 @@ RegisterServiceCtrlHandlerW(LPCWSTR lpServiceName, Service->HandlerFunction = lpHandlerProc; Service->HandlerFunctionEx = NULL; - TRACE("RegisterServiceCtrlHandler returning %lu\n", Service->hService); + TRACE("RegisterServiceCtrlHandler returning %lu\n", Service->hServiceStatus); - return (SERVICE_STATUS_HANDLE)Service->hService; + return Service->hServiceStatus; } @@ -520,9 +518,9 @@ RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, Service->HandlerFunctionEx = lpHandlerProc; Service->HandlerContext = lpContext; - TRACE("RegisterServiceCtrlHandlerEx returning %lu\n", Service->hService); + TRACE("RegisterServiceCtrlHandlerEx returning %lu\n", Service->hServiceStatus); - return (SERVICE_STATUS_HANDLE)Service->hService; + return Service->hServiceStatus; } @@ -683,7 +681,7 @@ StartServiceCtrlDispatcherA(const SERVICE_TABLE_ENTRYA * lpServiceStartTable) RtlCreateUnicodeStringFromAsciiz(&lpActiveServices[i].ServiceName, lpServiceStartTable[i].lpServiceName); lpActiveServices[i].Main.lpFuncA = lpServiceStartTable[i].lpServiceProc; - lpActiveServices[i].hService = (CLIENT_HANDLE)&lpActiveServices[i]; + lpActiveServices[i].hServiceStatus = 0; lpActiveServices[i].bUnicode = FALSE; } @@ -773,7 +771,7 @@ StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW * lpServiceStartTable) RtlCreateUnicodeString(&lpActiveServices[i].ServiceName, lpServiceStartTable[i].lpServiceName); lpActiveServices[i].Main.lpFuncW = lpServiceStartTable[i].lpServiceProc; - lpActiveServices[i].hService = (CLIENT_HANDLE)&lpActiveServices[i]; + lpActiveServices[i].hServiceStatus = 0; lpActiveServices[i].bUnicode = TRUE; } diff --git a/reactos/include/reactos/services/services.h b/reactos/include/reactos/services/services.h index 21a6085bf6c..7c8a972b6e7 100644 --- a/reactos/include/reactos/services/services.h +++ b/reactos/include/reactos/services/services.h @@ -11,12 +11,10 @@ #define SERVICE_CONTROL_START 0 -DECLARE_HANDLE(CLIENT_HANDLE); - typedef struct _SCM_CONTROL_PACKET { DWORD dwControl; - CLIENT_HANDLE hClient; + SERVICE_STATUS_HANDLE hServiceStatus; DWORD dwSize; WCHAR szArguments[1]; } SCM_CONTROL_PACKET, *PSCM_CONTROL_PACKET; From 420940d94d835332875f77d603a323928141eb9b Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 28 Feb 2010 00:14:15 +0000 Subject: [PATCH 004/211] Report service status to the service manager. svn path=/trunk/; revision=45714 --- reactos/base/services/dhcp/dhclient.c | 101 ++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 8 deletions(-) diff --git a/reactos/base/services/dhcp/dhclient.c b/reactos/base/services/dhcp/dhclient.c index 8b18010735c..db263bc4ab5 100644 --- a/reactos/base/services/dhcp/dhclient.c +++ b/reactos/base/services/dhcp/dhclient.c @@ -57,6 +57,7 @@ #include #include "dhcpd.h" #include "privsep.h" +#include "debug.h" #define PERIOD 0x2e #define hyphenchar(c) ((c) == 0x2d) @@ -109,22 +110,106 @@ int check_arp( struct interface_info *ip, struct client_lease *lp ) time_t scripttime; + +static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv); +static WCHAR ServiceName[] = L"DHCP"; +static SERVICE_TABLE_ENTRYW ServiceTable[] = +{ + {ServiceName, ServiceMain}, + {NULL, NULL} +}; + +SERVICE_STATUS_HANDLE ServiceStatusHandle; +SERVICE_STATUS ServiceStatus; + + /* XXX Implement me */ int check_arp( struct interface_info *ip, struct client_lease *lp ) { return 1; } -static VOID CALLBACK -DispatchMain(DWORD argc, LPTSTR *argv) + +static VOID +UpdateServiceStatus(DWORD dwState) { - dispatch(); + ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + ServiceStatus.dwCurrentState = dwState; + + ServiceStatus.dwControlsAccepted = 0; + + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + + if (dwState == SERVICE_START_PENDING || + dwState == SERVICE_STOP_PENDING || + dwState == SERVICE_PAUSE_PENDING || + dwState == SERVICE_CONTINUE_PENDING) + ServiceStatus.dwWaitHint = 10000; + else + ServiceStatus.dwWaitHint = 0; + + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); } -static SERVICE_TABLE_ENTRY ServiceTable[2] = + +static DWORD WINAPI +ServiceControlHandler(DWORD dwControl, + DWORD dwEventType, + LPVOID lpEventData, + LPVOID lpContext) { - {TEXT("DHCP"), DispatchMain}, - {NULL, NULL} -}; + switch (dwControl) + { + case SERVICE_CONTROL_STOP: + UpdateServiceStatus(SERVICE_STOP_PENDING); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_PAUSE: + UpdateServiceStatus(SERVICE_PAUSED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_CONTINUE: + UpdateServiceStatus(SERVICE_START_PENDING); + UpdateServiceStatus(SERVICE_RUNNING); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_INTERROGATE: + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_SHUTDOWN: + UpdateServiceStatus(SERVICE_STOP_PENDING); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + default : + return ERROR_CALL_NOT_IMPLEMENTED; + } +} + + +static VOID CALLBACK +ServiceMain(DWORD argc, LPWSTR *argv) +{ + ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName, + ServiceControlHandler, + NULL); + if (!ServiceStatusHandle) + { + return; + } + + UpdateServiceStatus(SERVICE_START_PENDING); + + UpdateServiceStatus(SERVICE_RUNNING); + + dispatch(); +} + int main(int argc, char *argv[]) @@ -147,7 +232,7 @@ main(int argc, char *argv[]) DH_DbgPrint(MID_TRACE,("Going into dispatch()\n")); - StartServiceCtrlDispatcher(ServiceTable); + StartServiceCtrlDispatcherW(ServiceTable); /* not reached */ return (0); From 38e5930305af91a451753daefe46273f86c6bd2e Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 28 Feb 2010 00:27:28 +0000 Subject: [PATCH 005/211] [SERVICES] - Copy service status only once after a control packet has been sent to a service. - Send a reply packet to the service manager after a control packet has been sent to a service. svn path=/trunk/; revision=45715 --- reactos/base/system/services/database.c | 60 ++++++++++++++++-------- reactos/base/system/services/rpcserver.c | 12 ++--- reactos/base/system/services/services.h | 3 +- 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/reactos/base/system/services/database.c b/reactos/base/system/services/database.c index 95bc302daac..7a9819e4c8b 100644 --- a/reactos/base/system/services/database.c +++ b/reactos/base/system/services/database.c @@ -679,12 +679,15 @@ ScmGetBootAndSystemDriverState(VOID) DWORD ScmControlService(PSERVICE Service, - DWORD dwControl, - LPSERVICE_STATUS lpServiceStatus) + DWORD dwControl) { PSCM_CONTROL_PACKET ControlPacket; - DWORD Count; + SCM_REPLY_PACKET ReplyPacket; + + DWORD dwWriteCount = 0; + DWORD dwReadCount = 0; DWORD TotalLength; + DWORD dwError = ERROR_SUCCESS; DPRINT("ScmControlService() called\n"); @@ -705,23 +708,29 @@ ScmControlService(PSERVICE Service, WriteFile(Service->ControlPipeHandle, ControlPacket, sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)), - &Count, + &dwWriteCount, NULL); - /* FIXME: Read the reply */ + /* Read the reply */ + ReadFile(Service->ControlPipeHandle, + &ReplyPacket, + sizeof(SCM_REPLY_PACKET), + &dwReadCount, + NULL); /* Release the contol packet */ HeapFree(GetProcessHeap(), 0, ControlPacket); - RtlCopyMemory(lpServiceStatus, - &Service->Status, - sizeof(SERVICE_STATUS)); + if (dwReadCount == sizeof(SCM_REPLY_PACKET)) + { + dwError = ReplyPacket.dwError; + } - DPRINT("ScmControlService) done\n"); + DPRINT("ScmControlService() done\n"); - return ERROR_SUCCESS; + return dwError; } @@ -731,11 +740,15 @@ ScmSendStartCommand(PSERVICE Service, LPWSTR *argv) { PSCM_CONTROL_PACKET ControlPacket; + SCM_REPLY_PACKET ReplyPacket; DWORD TotalLength; DWORD ArgsLength = 0; DWORD Length; PWSTR Ptr; - DWORD Count; + DWORD dwWriteCount = 0; + DWORD dwReadCount = 0; + DWORD dwError = ERROR_SUCCESS; + DWORD i; DPRINT("ScmSendStartCommand() called\n"); @@ -743,10 +756,10 @@ ScmSendStartCommand(PSERVICE Service, TotalLength = wcslen(Service->lpServiceName) + 1; if (argc > 0) { - for (Count = 0; Count < argc; Count++) + for (i = 0; i < argc; i++) { - DPRINT("Arg: %S\n", argv[Count]); - Length = wcslen(argv[Count]) + 1; + DPRINT("Arg: %S\n", argv[i]); + Length = wcslen(argv[i]) + 1; TotalLength += Length; ArgsLength += Length; } @@ -786,19 +799,29 @@ ScmSendStartCommand(PSERVICE Service, WriteFile(Service->ControlPipeHandle, ControlPacket, sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR), - &Count, + &dwWriteCount, NULL); - /* FIXME: Read the reply */ + /* Read the reply */ + ReadFile(Service->ControlPipeHandle, + &ReplyPacket, + sizeof(SCM_REPLY_PACKET), + &dwReadCount, + NULL); /* Release the contol packet */ HeapFree(GetProcessHeap(), 0, ControlPacket); + if (dwReadCount == sizeof(SCM_REPLY_PACKET)) + { + dwError = ReplyPacket.dwError; + } + DPRINT("ScmSendStartCommand() done\n"); - return ERROR_SUCCESS; + return dwError; } @@ -1192,7 +1215,6 @@ ScmAutoShutdownServices(VOID) { PLIST_ENTRY ServiceEntry; PSERVICE CurrentService; - SERVICE_STATUS ServiceStatus; DPRINT("ScmAutoShutdownServices() called\n"); @@ -1205,7 +1227,7 @@ ScmAutoShutdownServices(VOID) CurrentService->Status.dwCurrentState == SERVICE_START_PENDING) { /* shutdown service */ - ScmControlService(CurrentService, SERVICE_CONTROL_STOP, &ServiceStatus); + ScmControlService(CurrentService, SERVICE_CONTROL_STOP); } ServiceEntry = ServiceEntry->Flink; diff --git a/reactos/base/system/services/rpcserver.c b/reactos/base/system/services/rpcserver.c index a1085f05fe3..914e013327b 100644 --- a/reactos/base/system/services/rpcserver.c +++ b/reactos/base/system/services/rpcserver.c @@ -637,8 +637,12 @@ DWORD RControlService( { /* Send control code to the service */ dwError = ScmControlService(lpService, - dwControl, - lpServiceStatus); + dwControl); + + /* Return service status information */ + RtlCopyMemory(lpServiceStatus, + &lpService->Status, + sizeof(SERVICE_STATUS)); } if ((dwError == ERROR_SUCCESS) && (pcbBytesNeeded)) @@ -652,10 +656,6 @@ DWORD RControlService( lpService->ThreadId = 0; } - /* Return service status information */ - RtlCopyMemory(lpServiceStatus, - &lpService->Status, - sizeof(SERVICE_STATUS)); return dwError; } diff --git a/reactos/base/system/services/services.h b/reactos/base/system/services/services.h index 811aa001e49..8371ad18b71 100644 --- a/reactos/base/system/services/services.h +++ b/reactos/base/system/services/services.h @@ -117,8 +117,7 @@ VOID ScmDeleteServiceRecord(PSERVICE lpService); DWORD ScmMarkServiceForDelete(PSERVICE pService); DWORD ScmControlService(PSERVICE Service, - DWORD dwControl, - LPSERVICE_STATUS lpServiceStatus); + DWORD dwControl); BOOL ScmLockDatabaseExclusive(VOID); BOOL ScmLockDatabaseShared(VOID); From 398f34f8cb0c90c16bf65137a85be83fb131ef5d Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 28 Feb 2010 00:50:47 +0000 Subject: [PATCH 006/211] [SERVICES] - Copy service status only once after a control packet has been sent to a service. - Send a reply packet to the service manager after a control packet has been sent to a service. svn path=/trunk/; revision=45716 --- reactos/include/reactos/services/services.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reactos/include/reactos/services/services.h b/reactos/include/reactos/services/services.h index 7c8a972b6e7..009c2506b7d 100644 --- a/reactos/include/reactos/services/services.h +++ b/reactos/include/reactos/services/services.h @@ -19,6 +19,11 @@ typedef struct _SCM_CONTROL_PACKET WCHAR szArguments[1]; } SCM_CONTROL_PACKET, *PSCM_CONTROL_PACKET; +typedef struct _SCM_REPLY_PACKET +{ + DWORD dwError; +} SCM_REPLY_PACKET, *PSCM_REPLY_PACKET; + #endif /* __SERVICES_SERVICES_H__ */ /* EOF */ From f22ab97f8ecea2120446ba80e572c4966c7878b7 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sun, 28 Feb 2010 00:53:59 +0000 Subject: [PATCH 007/211] [lib/rtl] - Replace commented out try block with SEH2. Patch by Samuel Serapion. svn path=/trunk/; revision=45717 --- reactos/lib/rtl/actctx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/lib/rtl/actctx.c b/reactos/lib/rtl/actctx.c index 4508876b4fe..f8536411dc4 100644 --- a/reactos/lib/rtl/actctx.c +++ b/reactos/lib/rtl/actctx.c @@ -551,14 +551,15 @@ static ACTIVATION_CONTEXT *check_actctx( HANDLE h ) ACTIVATION_CONTEXT *ret = NULL, *actctx = h; if (!h || h == INVALID_HANDLE_VALUE) return NULL; - //__TRY + _SEH2_TRY { if (actctx && actctx->magic == ACTCTX_MAGIC) ret = actctx; } - //__EXCEPT_PAGE_FAULT + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + DPRINT1("Invalid activation context handle!\n"); } - //__ENDTRY + _SEH2_END; return ret; } From f63c52ccf07b0b7e33cc42c82adab84be1478f0d Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sun, 28 Feb 2010 12:57:59 +0000 Subject: [PATCH 008/211] [PSDK] - Add axextendenums.h header - Add TVAudioMode enumeration - Add tuner.idl svn path=/trunk/; revision=45728 --- reactos/include/dxsdk/axextend.idl | 14 + reactos/include/dxsdk/axextendenums.h | 38 + reactos/include/psdk/psdk.rbuild | 1 + reactos/include/psdk/tuner.idl | 1817 +++++++++++++++++++++++++ 4 files changed, 1870 insertions(+) create mode 100644 reactos/include/dxsdk/axextendenums.h create mode 100644 reactos/include/psdk/tuner.idl diff --git a/reactos/include/dxsdk/axextend.idl b/reactos/include/dxsdk/axextend.idl index 71054e348a5..8b52d79d023 100644 --- a/reactos/include/dxsdk/axextend.idl +++ b/reactos/include/dxsdk/axextend.idl @@ -1066,6 +1066,7 @@ interface IAMFilterMiscFlags : IUnknown ULONG GetMiscFlags(); }; +#include [ object, @@ -1081,3 +1082,16 @@ interface IAMStreamControl : IUnknown [in] DWORD dwCookie ); HRESULT GetInfo( [out] AM_STREAM_INFO *pInfo); } + +typedef enum tagTVAudioMode +{ + AMTVAUDIO_MODE_MONO = 0x0001, + AMTVAUDIO_MODE_STEREO = 0x0002, + AMTVAUDIO_MODE_LANG_A = 0x0010, + AMTVAUDIO_MODE_LANG_B = 0x0020, + AMTVAUDIO_MODE_LANG_C = 0x0040, + AMTVAUDIO_PRESET_STEREO = 0x0200, + AMTVAUDIO_PRESET_LANG_A = 0x1000, + AMTVAUDIO_PRESET_LANG_B = 0x2000, + AMTVAUDIO_PRESET_LANG_C = 0x4000, +}TVAudioMode; diff --git a/reactos/include/dxsdk/axextendenums.h b/reactos/include/dxsdk/axextendenums.h new file mode 100644 index 00000000000..feb8b410a1a --- /dev/null +++ b/reactos/include/dxsdk/axextendenums.h @@ -0,0 +1,38 @@ +#ifndef AXEXTEND_ENUM_H +#define AXEXTEND_ENUM_H + +typedef enum tagAnalogVideoStandard +{ + AnalogVideo_None = 0x00000000, + AnalogVideo_NTSC_M = 0x00000001, + AnalogVideo_NTSC_M_J = 0x00000002, + AnalogVideo_NTSC_433 = 0x00000004, + AnalogVideo_PAL_B = 0x00000010, + AnalogVideo_PAL_D = 0x00000020, + AnalogVideo_PAL_G = 0x00000040, + AnalogVideo_PAL_H = 0x00000080, + AnalogVideo_PAL_I = 0x00000100, + AnalogVideo_PAL_M = 0x00000200, + AnalogVideo_PAL_N = 0x00000400, + AnalogVideo_PAL_60 = 0x00000800, + AnalogVideo_SECAM_B = 0x00001000, + AnalogVideo_SECAM_D = 0x00002000, + AnalogVideo_SECAM_G = 0x00004000, + AnalogVideo_SECAM_H = 0x00008000, + AnalogVideo_SECAM_K = 0x00010000, + AnalogVideo_SECAM_K1 = 0x00020000, + AnalogVideo_SECAM_L = 0x00040000, + AnalogVideo_SECAM_L1 = 0x00080000, + AnalogVideo_PAL_N_COMBO = 0x00100000, + AnalogVideoMask_MCE_NTSC = AnalogVideo_NTSC_M | AnalogVideo_NTSC_M_J | AnalogVideo_NTSC_433 | AnalogVideo_PAL_M | AnalogVideo_PAL_N | AnalogVideo_PAL_60 | AnalogVideo_PAL_N_COMBO, + AnalogVideoMask_MCE_PAL = AnalogVideo_PAL_B | AnalogVideo_PAL_D | AnalogVideo_PAL_G | AnalogVideo_PAL_H | AnalogVideo_PAL_I, + AnalogVideoMask_MCE_SECAM = AnalogVideo_SECAM_B | AnalogVideo_SECAM_D | AnalogVideo_SECAM_G |AnalogVideo_SECAM_H |AnalogVideo_SECAM_K | AnalogVideo_SECAM_K1 |AnalogVideo_SECAM_L | AnalogVideo_SECAM_L1, +}AnalogVideoStandard; + +typedef enum tagTunerInputType +{ + TunerInputCable, + TunerInputAntenna +} TunerInputType; + +#endif diff --git a/reactos/include/psdk/psdk.rbuild b/reactos/include/psdk/psdk.rbuild index 95981e1cde7..0816fd6058f 100644 --- a/reactos/include/psdk/psdk.rbuild +++ b/reactos/include/psdk/psdk.rbuild @@ -51,6 +51,7 @@ shtypes.idl strmif.idl textstor.idl + tuner.idl tom.idl unknwn.idl urlhist.idl diff --git a/reactos/include/psdk/tuner.idl b/reactos/include/psdk/tuner.idl new file mode 100644 index 00000000000..57f4de1fb3b --- /dev/null +++ b/reactos/include/psdk/tuner.idl @@ -0,0 +1,1817 @@ + + +cpp_quote("#pragma once") + +#include +#ifndef DO_NO_IMPORTS +import "oaidl.idl"; +import "comcat.idl"; +import "strmif.idl"; +import "bdaiface.idl"; +import "regbag.idl"; +#else +cpp_quote("#include ") +#endif + +interface ITuningSpaceContainer; +interface ITuningSpace; +interface IEnumTuningSpaces; +interface ITuneRequest; +interface ITuner; +interface ITunerCap; +interface IScanningTuner; +interface IEnumComponentTypes; +interface IComponentTypes; +interface IComponentType; +interface ILanguageComponentType; +interface IEnumComponents; +interface IComponents; +interface IComponent; +interface IMPEG2ComponentType; +interface IMPEG2Component; +interface ILocator; +interface IATSCLocator; +interface IDVBSLocator; +interface IDVBTLocator; +interface IDVBCLocator; +interface IDigitalCableLocator; +interface IAnalogLocator; +interface IDigitalCableTuneRequest; +interface IDigitalCableTuningSpace; + +[ + object, + uuid(901284E4-33FE-4b69-8D63-634A596F3756), + dual, + oleautomation, + nonextensible, + pointer_default(unique) +] +interface ITuningSpaces : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT** NewEnum); + + HRESULT get_Item( + [in] VARIANT varIndex, + [out] ITuningSpace** TuningSpace); + + HRESULT get_EnumTuningSpaces( + [out] IEnumTuningSpaces** NewEnum); +} + +[ + object, + uuid(5B692E84-E2F1-11d2-9493-00C04F72D980), + dual, + oleautomation, + hidden, + nonextensible, + pointer_default(unique) +] +interface ITuningSpaceContainer : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT** NewEnum); + + HRESULT get_Item( + [in] VARIANT varIndex, + [out] ITuningSpace** TuningSpace); + + HRESULT put_Item( + [in] VARIANT varIndex, + [in] ITuningSpace *TuningSpace); + + HRESULT TuningSpacesForCLSID( + [in] BSTR SpaceCLSID, + [out] ITuningSpaces** NewColl); + + HRESULT _TuningSpacesForCLSID( + [in] REFCLSID SpaceCLSID, + [out] ITuningSpaces** NewColl); + + HRESULT TuningSpacesForName( + [in] BSTR Name, + [out] ITuningSpaces** NewColl); + + HRESULT FindID( + [in] ITuningSpace *TuningSpace, + [out] long *ID); + + HRESULT Add( + [in] ITuningSpace* TuningSpace, + [out] VARIANT* NewIndex); + + HRESULT get_EnumTuningSpaces( + [out] IEnumTuningSpaces **ppEnum); + + HRESULT Remove( + [in] VARIANT Index); + + HRESULT get_MaxCount( + [out] long *MaxCount); + + HRESULT put_MaxCount( + [in] long MaxCount); +} + + +[ + object, + uuid(061C6E30-E622-11d2-9493-00C04F72D980), + dual, + oleautomation, + nonextensible, + pointer_default(unique) +] +interface ITuningSpace : IDispatch +{ + HRESULT get_UniqueName( + [out] BSTR *Name); + + HRESULT put_UniqueName( + [in] BSTR Name); + + HRESULT get_FriendlyName( + [out] BSTR *Name); + + HRESULT put_FriendlyName( + [in] BSTR Name); + + HRESULT get_CLSID( + [out] BSTR* SpaceCLSID); + + HRESULT get_NetworkType( + [out] BSTR *NetworkTypeGuid); + + HRESULT put_NetworkType( + [in] BSTR NetworkTypeGuid); + + HRESULT get__NetworkType( + [out] GUID* NetworkTypeGuid); + + HRESULT put__NetworkType( + [in] REFCLSID NetworkTypeGuid); + + HRESULT CreateTuneRequest( + [out] ITuneRequest **TuneRequest); + + HRESULT EnumCategoryGUIDs( + [out] IEnumGUID **ppEnum); + + HRESULT EnumDeviceMonikers( + [out] IEnumMoniker **ppEnum); + + HRESULT get_DefaultPreferredComponentTypes( + [out] IComponentTypes** ComponentTypes); + + HRESULT put_DefaultPreferredComponentTypes( + [in] IComponentTypes* NewComponentTypes); + + HRESULT get_FrequencyMapping( + [out] BSTR *pMapping); + + HRESULT put_FrequencyMapping( + BSTR Mapping); + + HRESULT get_DefaultLocator( + [out] ILocator **LocatorVal); + + HRESULT put_DefaultLocator( + [in]ILocator *LocatorVal); + + HRESULT Clone( + [out] ITuningSpace **NewTS); +} + +[ + hidden, + restricted, + object, + uuid(8B8EB248-FC2B-11d2-9D8C-00C04F72D980), + pointer_default(unique) +] +interface IEnumTuningSpaces : IUnknown +{ + HRESULT Next( + [in] ULONG celt, + [in, out]ITuningSpace** rgelt, + [out] ULONG* pceltFetched); + + HRESULT Skip( + [in] ULONG celt); + + HRESULT Reset(); + + HRESULT Clone( + [out] IEnumTuningSpaces** ppEnum); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(ADA0B268-3B19-4e5b-ACC4-49F852BE13BA), + pointer_default(unique) +] +interface IDVBTuningSpace : ITuningSpace +{ + HRESULT get_SystemType( + [out] DVBSystemType *SysType); + + HRESULT put_SystemType( + [in] DVBSystemType SysType); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(843188B4-CE62-43db-966B-8145A094E040), + pointer_default(unique) +] +interface IDVBTuningSpace2 : IDVBTuningSpace +{ + HRESULT get_NetworkID( + [out] long *NetworkID); + + HRESULT put_NetworkID( + [in] long NetworkID); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(CDF7BE60-D954-42fd-A972-78971958E470), + pointer_default(unique) +] +interface IDVBSTuningSpace : IDVBTuningSpace2 +{ + + HRESULT get_LowOscillator( + [out] long *LowOscillator); + + HRESULT put_LowOscillator( + [in] long LowOscillator); + + HRESULT get_HighOscillator( + [out] long *HighOscillator); + + HRESULT put_HighOscillator( + [in] long HighOscillator); + + HRESULT get_LNBSwitch( + [out] long *LNBSwitch); + + HRESULT put_LNBSwitch( + [in] long LNBSwitch); + + HRESULT get_InputRange( + [out] BSTR *InputRange); + + HRESULT put_InputRange( + [in] BSTR InputRange); + + HRESULT get_SpectralInversion( + [out] SpectralInversion *SpectralInversionVal); + + HRESULT put_SpectralInversion( + [in] SpectralInversion SpectralInversionVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(E48244B8-7E17-4f76-A763-5090FF1E2F30), + pointer_default(unique) +] +interface IAuxInTuningSpace : ITuningSpace +{ +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(B10931ED-8BFE-4AB0-9DCE-E469C29A9729), + pointer_default(unique) +] +interface IAuxInTuningSpace2 : IAuxInTuningSpace +{ + HRESULT get_CountryCode([out] long *CountryCodeVal); + + HRESULT put_CountryCode([in] long NewCountryCodeVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(2A6E293C-2595-11d3-B64C-00C04F79498E), + pointer_default(unique) +] +interface IAnalogTVTuningSpace : ITuningSpace +{ + HRESULT get_MinChannel( + [out] long *MinChannelVal); + + HRESULT put_MinChannel( + [in] long NewMinChannelVal); + + HRESULT get_MaxChannel( + [out] long *MaxChannelVal); + + HRESULT put_MaxChannel( + [in] long NewMaxChannelVal); + + HRESULT get_InputType( + [out] TunerInputType *InputTypeVal); + + HRESULT put_InputType( + [in] TunerInputType NewInputTypeVal); + + HRESULT get_CountryCode( + [out] long *CountryCodeVal); + + HRESULT put_CountryCode( + [in] long NewCountryCodeVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(0369B4E2-45B6-11d3-B650-00C04F79498E), + pointer_default(unique) +] +interface IATSCTuningSpace : IAnalogTVTuningSpace +{ + HRESULT get_MinMinorChannel( + [out] long *MinMinorChannelVal); + + HRESULT put_MinMinorChannel( + [in] long NewMinMinorChannelVal); + + HRESULT get_MaxMinorChannel( + [out] long *MaxMinorChannelVal); + + HRESULT put_MaxMinorChannel( + [in] long NewMaxMinorChannelVal); + + HRESULT get_MinPhysicalChannel( + [out] long *MinPhysicalChannelVal); + + HRESULT put_MinPhysicalChannel( + [in] long NewMinPhysicalChannelVal); + + HRESULT get_MaxPhysicalChannel( + [out] long *MaxPhysicalChannelVal); + + HRESULT put_MaxPhysicalChannel( + [in] long NewMaxPhysicalChannelVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(013F9F9C-B449-4ec7-A6D2-9D4F2FC70AE5), + pointer_default(unique) +] +interface IDigitalCableTuningSpace : IATSCTuningSpace +{ + HRESULT get_MinMajorChannel( + [out] long *MinMajorChannelVal); + + HRESULT put_MinMajorChannel( + [in] long NewMinMajorChannelVal); + + HRESULT get_MaxMajorChannel( + [out] long *MaxMajorChannelVal); + + HRESULT put_MaxMajorChannel( + [in] long NewMaxMajorChannelVal); + + HRESULT get_MinSourceID( + [out] long *MinSourceIDVal); + + HRESULT put_MinSourceID( + [in] long NewMinSourceIDVal); + + HRESULT get_MaxSourceID( + [out] long *MaxSourceIDVal); + + HRESULT put_MaxSourceID( + [in] long NewMaxSourceIDVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(2A6E293B-2595-11d3-B64C-00C04F79498E), + pointer_default(unique) +] +interface IAnalogRadioTuningSpace : ITuningSpace +{ + HRESULT get_MinFrequency( + [out] long *MinFrequencyVal); + + HRESULT put_MinFrequency( + [in] long NewMinFrequencyVal); + + HRESULT get_MaxFrequency( + [out] long *MaxFrequencyVal); + + HRESULT put_MaxFrequency( + [in] long NewMaxFrequencyVal); + + HRESULT get_Step( + [out] long *StepVal); + + HRESULT put_Step( + [in] long NewStepVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(39DD45DA-2DA8-46BA-8A8A-87E2B73D983A), + pointer_default(unique) +] +interface IAnalogRadioTuningSpace2 : IAnalogRadioTuningSpace { + HRESULT get_CountryCode([out] long *CountryCodeVal); + HRESULT put_CountryCode([in] long NewCountryCodeVal); +} +[ + object, + nonextensible, + uuid(07DDC146-FC3D-11d2-9D8C-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface ITuneRequest : IDispatch +{ + HRESULT get_TuningSpace( + [out] ITuningSpace **TuningSpace); + + HRESULT get_Components( + [out] IComponents **Components); + + HRESULT Clone( + [out] ITuneRequest **NewTuneRequest); + + HRESULT get_Locator( + [out] ILocator **Locator); + + HRESULT put_Locator( + [in] ILocator *Locator); +} + +[ + object, + nonextensible, + uuid(0369B4E0-45B6-11d3-B650-00C04F79498E), + dual, + oleautomation, + pointer_default(unique) +] +interface IChannelTuneRequest : ITuneRequest +{ + HRESULT get_Channel( + [out] long *Channel); + + HRESULT put_Channel( + [in] long Channel); +} + +[ + object, + nonextensible, + uuid(0369B4E1-45B6-11d3-B650-00C04F79498E), + dual, + oleautomation, + pointer_default(unique) +] +interface IATSCChannelTuneRequest : IChannelTuneRequest +{ + HRESULT get_MinorChannel( + [out] long *MinorChannel); + + HRESULT put_MinorChannel( + [in] long MinorChannel); +} + +[ + object, + nonextensible, + uuid(BAD7753B-6B37-4810-AE57-3CE0C4A9E6CB), + dual, + oleautomation, + pointer_default(unique) +] +interface IDigitalCableTuneRequest : IATSCChannelTuneRequest +{ + HRESULT get_MajorChannel( + [out] long *pMajorChannel); + + HRESULT put_MajorChannel( + [in] long MajorChannel); + + HRESULT get_SourceID( + [out] long *pSourceID); + + HRESULT put_SourceID( + [in] long SourceID); +} + + +[ + object, + nonextensible, + uuid(0D6F567E-A636-42bb-83BA-CE4C1704AFA2), + dual, + oleautomation, + pointer_default(unique) +] +interface IDVBTuneRequest : ITuneRequest +{ + HRESULT get_ONID( + [out] long *ONID); + + HRESULT put_ONID( + [in] long ONID); + + HRESULT get_TSID( + [out] long *TSID); + + HRESULT put_TSID( + [in] long TSID); + + HRESULT get_SID( + [out] long *SID); + + HRESULT put_SID( + [in] long SID); +} + +[ + object, + nonextensible, + uuid(EB7D987F-8A01-42ad-B8AE-574DEEE44D1A), + dual, + oleautomation, + pointer_default(unique) +] +interface IMPEG2TuneRequest : ITuneRequest +{ + HRESULT get_TSID( + [out] long *TSID); + + HRESULT put_TSID( + [in] long TSID); + + HRESULT get_ProgNo( + [out] long *ProgNo); + + HRESULT put_ProgNo( + [in] long ProgNo); +} + +[ + object, + nonextensible, + hidden, + uuid(14E11ABD-EE37-4893-9EA1-6964DE933E39), + dual, + oleautomation, + pointer_default(unique) +] +interface IMPEG2TuneRequestFactory : IDispatch +{ + HRESULT CreateTuneRequest( + [in] ITuningSpace *TuningSpace, + [out] IMPEG2TuneRequest **TuneRequest); +} + +[ + object, + hidden, + restricted, + nonextensible, + uuid(1B9D5FC3-5BBC-4b6c-BB18-B9D10E3EEEBF), + pointer_default(unique) +] +interface IMPEG2TuneRequestSupport : IUnknown +{ +} + +[ + object, + hidden, + nonextensible, + uuid(E60DFA45-8D56-4e65-A8AB-D6BE9412C249), + pointer_default(unique) +] +interface ITunerCap : IUnknown +{ + HRESULT get_SupportedNetworkTypes( + [in] ULONG ulcNetworkTypesMax, + [out] ULONG *pulcNetworkTypes, + [in, out] GUID *pguidNetworkTypes); + + HRESULT get_SupportedVideoFormats( + [out] ULONG *pulAMTunerModeType, + [out] ULONG *pulAnalogVideoStandard); + + HRESULT get_AuxInputCount( + [in, out] ULONG *pulCompositeCount, + [in, out] ULONG *pulSvideoCount); +} + +[ + object, + hidden, + nonextensible, + uuid(28C52640-018A-11d3-9D8E-00C04F72D980), + pointer_default(unique) +] +interface ITuner : IUnknown +{ + HRESULT get_TuningSpace( + [out] ITuningSpace **TuningSpace); + + HRESULT put_TuningSpace( + [in] ITuningSpace *TuningSpace); + + HRESULT EnumTuningSpaces( + [out] IEnumTuningSpaces **ppEnum); + + HRESULT get_TuneRequest( + [out] ITuneRequest **TuneRequest); + + HRESULT put_TuneRequest( + [in] ITuneRequest *TuneRequest); + + HRESULT Validate( + [in] ITuneRequest *TuneRequest); + + HRESULT get_PreferredComponentTypes( + [out] IComponentTypes **ComponentTypes); + + HRESULT put_PreferredComponentTypes( + [in] IComponentTypes *ComponentTypes); + + HRESULT get_SignalStrength( + [out] long *Strength); + + HRESULT TriggerSignalEvents( + [in] long Interval); +} + +[ + object, + hidden, + nonextensible, + uuid(1DFD0A5C-0284-11d3-9D8E-00C04F72D980), + pointer_default(unique) +] +interface IScanningTuner : ITuner +{ + HRESULT SeekUp(); + + HRESULT SeekDown(); + + HRESULT ScanUp( + [in] long MillisecondsPause); + + HRESULT ScanDown( + [in] long MillisecondsPause); + + HRESULT AutoProgram(); +}; + +[ + object, + hidden, + nonextensible, + uuid(04BBD195-0E2D-4593-9BD5-4F908BC33CF5), + pointer_default(unique) +] +interface IScanningTunerEx : IScanningTuner +{ + HRESULT GetCurrentLocator( + [in]ILocator **pILocator); + + HRESULT PerformExhaustiveScan( + [in] long dwLowerFreq, + [in] long dwHigherFreq, + [in] VARIANT_BOOL bFineTune, + [in] HEVENT hEvent); + + HRESULT TerminateCurrentScan( + [out] long *pcurrentFreq); + + HRESULT ResumeCurrentScan( + [in] HEVENT hEvent); + + HRESULT GetTunerScanningCapability( + [out] long *HardwareAssistedScanning, + [out] long *NumStandardsSupported, + [out] GUID *BroadcastStandards); + + HRESULT GetTunerStatus( + [out] long *SecondsLeft, + [out] long *CurrentLockType, + [out] long *AutoDetect, + [out] long *CurrentFreq); + + HRESULT GetCurrentTunerStandardCapability( + [in] GUID CurrentBroadcastStandard, + [out] long *SettlingTime, + [out] long *TvStandardsSupported); + + HRESULT SetScanSignalTypeFilter( + [in] long ScanModulationTypes, + [in] long AnalogVideoStandard); +}; + +[ + object, + hidden, + nonextensible, + uuid(6A340DC0-0311-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponentType : IDispatch +{ + HRESULT get_Category( + [out] ComponentCategory *Category); + + HRESULT put_Category( + [in] ComponentCategory Category); + + HRESULT get_MediaMajorType( + [out] BSTR *MediaMajorType); + + HRESULT put_MediaMajorType( + [in] BSTR MediaMajorType); + + HRESULT get__MediaMajorType( + [out] GUID* MediaMajorTypeGuid); + + HRESULT put__MediaMajorType( + [in] REFCLSID MediaMajorTypeGuid); + + HRESULT get_MediaSubType( + [out] BSTR *MediaSubType); + + HRESULT put_MediaSubType( + [in] BSTR MediaSubType); + + HRESULT get__MediaSubType( + [out] GUID* MediaSubTypeGuid); + + HRESULT put__MediaSubType( + [in] REFCLSID MediaSubTypeGuid); + + HRESULT get_MediaFormatType( + [out] BSTR *MediaFormatType); + + HRESULT put_MediaFormatType( + [in] BSTR MediaFormatType); + + HRESULT get__MediaFormatType( + [out] GUID* MediaFormatTypeGuid); + + HRESULT put__MediaFormatType( + [in] REFCLSID MediaFormatTypeGuid); + + HRESULT get_MediaType( + [out] AM_MEDIA_TYPE *MediaType); + + HRESULT put_MediaType( + [in] AM_MEDIA_TYPE *MediaType); + + HRESULT Clone( + [out] IComponentType **NewCT); +}; + +[ + object, + hidden, + nonextensible, + uuid(B874C8BA-0FA2-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface ILanguageComponentType : IComponentType +{ + HRESULT get_LangID( + [out] long *LangID); + + HRESULT put_LangID( + [in] long LangID); +}; + +[ + object, + hidden, + nonextensible, + uuid(2C073D84-B51C-48c9-AA9F-68971E1F6E38), + dual, + oleautomation, + pointer_default(unique) +] +interface IMPEG2ComponentType : ILanguageComponentType +{ + HRESULT get_StreamType( + [out] MPEG2StreamType *MP2StreamType); + + HRESULT put_StreamType( + [in] MPEG2StreamType MP2StreamType); +}; + + +[ + object, + hidden, + nonextensible, + uuid(FC189E4D-7BD4-4125-B3B3-3A76A332CC96), + dual, + oleautomation, + pointer_default(unique) +] +interface IATSCComponentType : IMPEG2ComponentType +{ + HRESULT get_Flags( + [out] long *Flags); + + HRESULT put_Flags( + [in] long flags); +}; + +[ + hidden, restricted, + object, + uuid(8A674B4A-1F63-11d3-B64C-00C04F79498E), + pointer_default(unique) +] +interface IEnumComponentTypes : IUnknown +{ + HRESULT Next( + [in] ULONG celt, + [in, out]IComponentType** rgelt, + [out] ULONG* pceltFetched); + + HRESULT Skip( + [in] ULONG celt); + + HRESULT Reset(void); + + HRESULT Clone( + [out] IEnumComponentTypes** ppEnum); +} + +[ + object, + hidden, + nonextensible, + uuid(0DC13D4A-0313-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponentTypes : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT **ppNewEnum); + + HRESULT EnumComponentTypes( + [out] IEnumComponentTypes **ppNewEnum); + + HRESULT get_Item( + [in] VARIANT Index, + [out] IComponentType **ComponentType); + + HRESULT put_Item( + [in] VARIANT Index, + [in] IComponentType *ComponentType); + + HRESULT Add( + [in] IComponentType *ComponentType, + [out] VARIANT *NewIndex); + + HRESULT Remove( + [in] VARIANT Index); + + HRESULT Clone([out] IComponentTypes **NewList); +}; + +[ + object, + nonextensible, + uuid(1A5576FC-0E19-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponent : IDispatch +{ + HRESULT get_Type( + [out] IComponentType** CT); + + HRESULT put_Type( + [in] IComponentType* CT); + + HRESULT get_DescLangID( + [out] long *LangID); + + HRESULT put_DescLangID( + [in] long LangID); + + HRESULT get_Status( + [out] ComponentStatus *Status); + + HRESULT put_Status( + [in] ComponentStatus Status); + + HRESULT get_Description( + [out] BSTR *Description); + + HRESULT put_Description( + [in] BSTR Description); + + HRESULT Clone( + [out] IComponent **NewComponent); + +}; + +[ + object, + nonextensible, + uuid(2CFEB2A8-1787-4A24-A941-C6EAEC39C842), + dual, + oleautomation, + pointer_default(unique) +] +interface IAnalogAudioComponentType : IComponentType +{ + HRESULT get_AnalogAudioMode( + [out] TVAudioMode *Mode); + + HRESULT put_AnalogAudioMode( + [in] TVAudioMode Mode); +} + +[ + object, + nonextensible, + uuid(1493E353-1EB6-473c-802D-8E6B8EC9D2A9), + dual, + oleautomation, + pointer_default(unique) +] +interface IMPEG2Component : IComponent +{ + HRESULT get_PID( + [out] long *PID); + + HRESULT put_PID( + [in] long PID); + + HRESULT get_PCRPID( + [out] long *PCRPID); + + HRESULT put_PCRPID( + [in] long PCRPID); + + HRESULT get_ProgramNumber( + [out] long *ProgramNumber); + + HRESULT put_ProgramNumber( + [in] long ProgramNumber); +}; + +[ + hidden, + restricted, + object, + uuid(2A6E2939-2595-11d3-B64C-00C04F79498E), + pointer_default(unique) +] +interface IEnumComponents : IUnknown +{ + HRESULT Next( + [in] ULONG celt, + [in, out]IComponent** rgelt, + [out] ULONG* pceltFetched); + + HRESULT Skip( + [in] ULONG celt); + + HRESULT Reset(void); + + HRESULT Clone( + [out] IEnumComponents** ppEnum); +} + + + +[ + object, + nonextensible, + uuid(39A48091-FFFE-4182-A161-3FF802640E26), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponents : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT **ppNewEnum); + + HRESULT EnumComponents( + [out] IEnumComponents **ppNewEnum); + + HRESULT get_Item( + [in] VARIANT Index, + [out] IComponent **ppComponent); + + HRESULT Add( + [in] IComponent *Component, + [out] VARIANT *NewIndex); + + HRESULT Remove( + [in] VARIANT Index); + + HRESULT Clone( + [out] IComponents **NewList); + + HRESULT put_Item( + [in] VARIANT Index, + [in] IComponent *ppComponent); + +}; + +[ + object, + nonextensible, + uuid(FCD01846-0E19-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponentsOld : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT **ppNewEnum); + + HRESULT EnumComponents( + [out] IEnumComponents **ppNewEnum); + + HRESULT get_Item( + [in] VARIANT Index, + [out] IComponent **ppComponent); + + HRESULT Add( + [in] IComponent *Component, + [out] VARIANT *NewIndex); + + HRESULT Remove( + [in] VARIANT Index); + + HRESULT Clone( + [out] IComponents **NewList); + +}; + +[ + object, + nonextensible, + uuid(286D7F89-760C-4F89-80C4-66841D2507AA), + dual, + oleautomation, + pointer_default(unique) +] +interface ILocator : IDispatch +{ + + HRESULT get_CarrierFrequency( + [out] long* Frequency); + + HRESULT put_CarrierFrequency( + [in] long Frequency); + + HRESULT get_InnerFEC( + [out] FECMethod* FEC); + + HRESULT put_InnerFEC( + [in] FECMethod FEC); + + HRESULT get_InnerFECRate( + [out] BinaryConvolutionCodeRate* FEC); + + HRESULT put_InnerFECRate( + [in] BinaryConvolutionCodeRate FEC); + + HRESULT get_OuterFEC( + [out] FECMethod* FEC); + + HRESULT put_OuterFEC( + [in] FECMethod FEC); + + HRESULT get_OuterFECRate( + [out] BinaryConvolutionCodeRate* FEC); + + HRESULT put_OuterFECRate( + [in] BinaryConvolutionCodeRate FEC); + + HRESULT get_Modulation( + [out] ModulationType* Modulation); + + HRESULT put_Modulation( + [in] ModulationType Modulation); + + HRESULT get_SymbolRate( + [out] long* Rate); + + HRESULT put_SymbolRate( + [in] long Rate); + + HRESULT Clone( + [out] ILocator **NewLocator); +}; + +[ + object, + nonextensible, + uuid(34D1F26B-E339-430D-ABCE-738CB48984DC), + dual, + oleautomation, + pointer_default(unique) +] +interface IAnalogLocator : ILocator +{ + HRESULT get_VideoStandard( + [out] AnalogVideoStandard* AVS); + + HRESULT put_VideoStandard( + [in] AnalogVideoStandard AVS); +} + +[ + object, + nonextensible, + uuid(19B595D8-839A-47F0-96DF-4F194F3C768C), + dual, + oleautomation, + pointer_default(unique) +] +interface IDigitalLocator : ILocator +{ +}; + +[ + object, + hidden, + nonextensible, + uuid(BF8D986F-8C2B-4131-94D7-4D3D9FCC21EF), + dual, + oleautomation, + pointer_default(unique) +] +interface IATSCLocator : IDigitalLocator +{ + HRESULT get_PhysicalChannel( + [out] long *PhysicalChannel); + + HRESULT put_PhysicalChannel( + [in] long PhysicalChannel); + + HRESULT get_TSID( + [out] long *TSID); + + HRESULT put_TSID( + [in] long TSID); +}; + +[ + object, + hidden, + nonextensible, + uuid(612AA885-66CF-4090-BA0A-566F5312E4CA), + dual, + oleautomation, + pointer_default(unique) +] +interface IATSCLocator2 : IATSCLocator +{ + HRESULT get_ProgramNumber( + [out] long *ProgramNumber); + + HRESULT put_ProgramNumber( + [in] long ProgramNumber); +}; + +[ + object, + hidden, + nonextensible, + uuid(48F66A11-171A-419A-9525-BEEECD51584C), + dual, + oleautomation, + pointer_default(unique) +] +interface IDigitalCableLocator : IATSCLocator2 +{ +} + +[ + object, + hidden, + nonextensible, + uuid(8664DA16-DDA2-42ac-926A-C18F9127C302), + dual, + oleautomation, + pointer_default(unique) +] +interface IDVBTLocator : IDigitalLocator +{ + HRESULT get_Bandwidth( + [out] long* BandWidthVal); + + HRESULT put_Bandwidth( + [in] long BandwidthVal); + + HRESULT get_LPInnerFEC( + [out] FECMethod* FEC); + + HRESULT put_LPInnerFEC( + [in] FECMethod FEC); + + HRESULT get_LPInnerFECRate( + [out] BinaryConvolutionCodeRate* FEC); + + HRESULT put_LPInnerFECRate( + [in] BinaryConvolutionCodeRate FEC); + + HRESULT get_HAlpha( + [out] HierarchyAlpha* Alpha); + + HRESULT put_HAlpha( + [in] HierarchyAlpha Alpha); + + HRESULT get_Guard( + [out] GuardInterval* GI); + + HRESULT put_Guard( + [in] GuardInterval GI); + + HRESULT get_Mode( + [out] TransmissionMode* mode); + + HRESULT put_Mode( + [in] TransmissionMode mode); + + HRESULT get_OtherFrequencyInUse( + [out] VARIANT_BOOL* OtherFrequencyInUseVal); + + HRESULT put_OtherFrequencyInUse( + [in] VARIANT_BOOL OtherFrequencyInUseVal); +}; + +[ + object, + hidden, + nonextensible, + uuid(3D7C353C-0D04-45f1-A742-F97CC1188DC8), + dual, + oleautomation, + pointer_default(unique) +] +interface IDVBSLocator : IDigitalLocator +{ + + HRESULT get_SignalPolarisation( + [out] Polarisation* PolarisationVal); + + HRESULT put_SignalPolarisation( + [in] Polarisation PolarisationVal); + + HRESULT get_WestPosition( + [out] VARIANT_BOOL* WestLongitude); + + HRESULT put_WestPosition( + [in] VARIANT_BOOL WestLongitude); + + HRESULT get_OrbitalPosition( + [out] long* longitude); + + HRESULT put_OrbitalPosition( + [in] long longitude); + + HRESULT get_Azimuth( + [out] long* Azimuth); + + HRESULT put_Azimuth( + [in] long Azimuth); + + HRESULT get_Elevation( + [out] long* Elevation); + + HRESULT put_Elevation( + [in] long Elevation); +}; + +[ + object, + hidden, + nonextensible, + uuid(6E42F36E-1DD2-43c4-9F78-69D25AE39034), + dual, + oleautomation, + pointer_default(unique) +] +interface IDVBCLocator : IDigitalLocator +{ +}; +[ + object, + hidden, + nonextensible, + uuid(3B21263F-26E8-489d-AAC4-924F7EFD9511), + pointer_default(unique) +] +interface IBroadcastEvent : IUnknown +{ + HRESULT Fire([in] GUID EventID); +}; + +[ + object, + hidden, + nonextensible, + uuid(3d9e3887-1929-423f-8021-43682de95448), + pointer_default(unique) +] +interface IBroadcastEventEx : IBroadcastEvent +{ + HRESULT FireEx( + [in] GUID EventID, + [in] ULONG Param1, + [in] ULONG Param2, + [in] ULONG Param3, + [in] ULONG Param4); +}; + +[ + object, + hidden, + nonextensible, + uuid(359B3901-572C-4854-BB49-CDEF66606A25), + pointer_default(unique) +] +interface IRegisterTuner : IUnknown +{ + HRESULT Register( + [in] ITuner* pTuner, + [in] IGraphBuilder* pGraph); + + HRESULT Unregister(); +}; + +[ + object, + hidden, + nonextensible, + uuid(B34505E0-2F0E-497b-80BC-D43F3B24ED7F), + pointer_default(unique) +] +interface IBDAComparable : IUnknown +{ + HRESULT CompareExact( + [in] IDispatch* CompareTo, + [out] long* Result); + + HRESULT CompareEquivalent( + [in] IDispatch* CompareTo, + [in] DWORD dwFlags, + [out] long* Result); + + HRESULT HashExact( + [out] __int64* Result); + + HRESULT HashExactIncremental( + [in] __int64 PartialResult, + [out] __int64* Result); + + HRESULT HashEquivalent( + [in] DWORD dwFlags, + [out] __int64* Result); + + HRESULT HashEquivalentIncremental( + [in] __int64 PartialResult, + [in] DWORD dwFlags, + [out] __int64* Result); +}; + +[ + uuid(9B085638-018E-11d3-9D8E-00C04F72D980), + version(1.0), +] +library TunerLib +{ + importlib("stdole2.tlb"); + +[ + uuid(D02AAC50-027E-11d3-9D8E-00C04F72D980) +] + + coclass SystemTuningSpaces +{ + [default] interface ITuningSpaceContainer; +}; + +[ + noncreatable, + hidden, + uuid(5FFDC5E6-B83A-4b55-B6E8-C69E765FE9DB) +] + coclass TuningSpace +{ + [default] interface ITuningSpace; + interface IBDAComparable; +}; + + +[ + uuid(A2E30750-6C3D-11d3-B653-00C04F79498E) +] + coclass ATSCTuningSpace +{ + [default] interface IATSCTuningSpace; + interface IBDAComparable; +}; + +[ + uuid(D9BB4CEE-B87A-47F1-AC92-B08D9C7813FC) +] + coclass DigitalCableTuningSpace +{ + [default] interface IDigitalCableTuningSpace; + interface IBDAComparable; +}; + + +[ + uuid(8A674B4C-1F63-11d3-B64C-00C04F79498E) +] + coclass AnalogRadioTuningSpace +{ + [default] interface IAnalogRadioTuningSpace2; + interface IAnalogRadioTuningSpace; + interface IBDAComparable; +}; + +[ + uuid(F9769A06-7ACA-4e39-9CFB-97BB35F0E77E) +] + coclass AuxInTuningSpace +{ + interface IAuxInTuningSpace; + [default] interface IAuxInTuningSpace2; + interface IBDAComparable; +}; + +[ + uuid(8A674B4D-1F63-11d3-B64C-00C04F79498E) +] + coclass AnalogTVTuningSpace +{ + [default] interface IAnalogTVTuningSpace; + interface IBDAComparable; +}; + +[ + uuid(C6B14B32-76AA-4a86-A7AC-5C79AAF58DA7) +] + coclass DVBTuningSpace +{ + [default] interface IDVBTuningSpace2; + interface IDVBTuningSpace; + interface IBDAComparable; +}; + +[ + uuid(B64016F3-C9A2-4066-96F0-BD9563314726) +] + coclass DVBSTuningSpace +{ + [default] interface IDVBSTuningSpace; + interface IBDAComparable; +}; + + +[ + uuid(A1A2B1C4-0E3A-11d3-9D8E-00C04F72D980) +] + coclass ComponentTypes +{ + [default] interface IComponentTypes; + }; + +[ + uuid(823535A0-0318-11d3-9D8E-00C04F72D980) +] + coclass ComponentType +{ + [default] interface IComponentType; + }; + +[ + uuid(1BE49F30-0E1B-11d3-9D8E-00C04F72D980) +] + coclass LanguageComponentType +{ + [default] interface ILanguageComponentType; + }; + +[ + uuid(418008F3-CF67-4668-9628-10DC52BE1D08) +] + coclass MPEG2ComponentType +{ + [default] interface IMPEG2ComponentType; + }; + +[ + uuid(A8DCF3D5-0780-4ef4-8A83-2CFFAACB8ACE) +] + coclass ATSCComponentType +{ + [default] interface IATSCComponentType; + }; + +[ + hidden, + uuid(809B6661-94C4-49e6-B6EC-3F0F862215AA) +] + coclass Components +{ + [default] interface IComponents; + interface IComponentsOld; +}; + +[ + hidden, + uuid(59DC47A8-116C-11d3-9D8E-00C04F72D980) +] + coclass Component +{ + [default] interface IComponent; + }; + +[ + hidden, + uuid(055CB2D7-2969-45cd-914B-76890722F112) +] + coclass MPEG2Component +{ + [default] interface IMPEG2Component; + }; + + +[ + hidden, + uuid(28AB0005-E845-4FFA-AA9B-F4665236141C) +] + coclass AnalogAudioComponentType +{ + [default] interface IAnalogAudioComponentType; + }; + +[ + noncreatable, + hidden, + uuid(B46E0D38-AB35-4a06-A137-70576B01B39F) +] + coclass TuneRequest +{ + [default] interface ITuneRequest; + interface IBDAComparable; +}; + + +[ + hidden, + uuid(0369B4E5-45B6-11d3-B650-00C04F79498E) +] + coclass ChannelTuneRequest +{ + [default] interface IChannelTuneRequest; + interface IBDAComparable; +}; + +[ + hidden, + uuid(0369B4E6-45B6-11d3-B650-00C04F79498E) +] + coclass ATSCChannelTuneRequest +{ + [default] interface IATSCChannelTuneRequest; + interface IBDAComparable; +}; + +[ + hidden, + uuid(26EC0B63-AA90-458A-8DF4-5659F2C8A18A) +] + coclass DigitalCableTuneRequest +{ + [default] interface IDigitalCableTuneRequest; + interface IBDAComparable; +}; + + +[ + hidden, + uuid(0955AC62-BF2E-4cba-A2B9-A63F772D46CF) +] + coclass MPEG2TuneRequest +{ + [default] interface IMPEG2TuneRequest; + interface IBDAComparable; +}; + +[ + uuid(2C63E4EB-4CEA-41b8-919C-E947EA19A77C) +] + coclass MPEG2TuneRequestFactory +{ + [default] interface IMPEG2TuneRequestFactory; +}; + + +[ + noncreatable, + hidden, + uuid(0888C883-AC4F-4943-B516-2C38D9B34562) +] + coclass Locator +{ + [default] interface ILocator; + interface IBDAComparable; +}; +[ + noncreatable, + hidden, + uuid(6E50CC0D-C19B-4BF6-810B-5BD60761F5CC) +] + coclass DigitalLocator +{ + [default] interface IDigitalLocator; + interface IBDAComparable; +}; + +[ + uuid(49638B91-48AB-48B7-A47A-7D0E75A08EDE) +] + coclass AnalogLocator +{ + [default] interface IAnalogLocator; + interface IBDAComparable; +}; + +[ + uuid(8872FF1B-98FA-4d7a-8D93-C9F1055F85BB) +] + coclass ATSCLocator +{ + [default] interface IATSCLocator2; + interface IATSCLocator; + interface IBDAComparable; +}; + +[ + uuid(03C06416-D127-407A-AB4C-FDD279ABBE5D) +] + coclass DigitalCableLocator +{ + [default] interface IDigitalCableLocator; + interface IBDAComparable; +}; + +[ + uuid(9CD64701-BDF3-4d14-8E03-F12983D86664) +] + coclass DVBTLocator +{ + [default] interface IDVBTLocator; + interface IBDAComparable; +}; + +[ + uuid(1DF7D126-4050-47f0-A7CF-4C4CA9241333) +] + coclass DVBSLocator +{ + [default] interface IDVBSLocator; + interface IBDAComparable; +}; + +[ + uuid(C531D9FD-9685-4028-8B68-6E1232079F1E) +] + coclass DVBCLocator +{ + [default] interface IDVBCLocator; + interface IBDAComparable; +}; + +[ + hidden, + uuid(15D6504A-5494-499c-886C-973C9E53B9F1) +] + coclass DVBTuneRequest +{ + [default] interface IDVBTuneRequest; + interface IBDAComparable; +}; + + +[ + hidden, + uuid(8A674B49-1F63-11d3-B64C-00C04F79498E) +] + coclass CreatePropBagOnRegKey +{ + interface ICreatePropBagOnRegKey; +}; + +[ + hidden, + uuid(0B3FFB92-0919-4934-9D5B-619C719D0202) +] + coclass BroadcastEventService +{ + interface IBroadcastEvent; +}; + +[ + hidden, + uuid(6438570B-0C08-4a25-9504-8012BB4D50CF) +] + coclass TunerMarshaler +{ + interface IRegisterTuner; + interface ITuner; +}; + +cpp_quote("#define SID_SBroadcastEventService CLSID_BroadcastEventService") +cpp_quote("#define SID_SContentTuneRequest IID_ITuner") +cpp_quote("#define SID_ScanningTuner IID_IScanningTuner") +cpp_quote("#define SID_ScanningTunerEx IID_IScanningTunerEx") +} From 141b8fafca1bc88c6ef5cdf7d757e35af2b6629a Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sun, 28 Feb 2010 13:18:23 +0000 Subject: [PATCH 009/211] [RTL] Use %S for unicode traces. svn path=/trunk/; revision=45729 --- reactos/lib/rtl/actctx.c | 80 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/reactos/lib/rtl/actctx.c b/reactos/lib/rtl/actctx.c index f8536411dc4..38cbbbf64c7 100644 --- a/reactos/lib/rtl/actctx.c +++ b/reactos/lib/rtl/actctx.c @@ -420,7 +420,7 @@ static BOOL add_dependent_assembly_id(struct actctx_loader* acl, for (i = 0; i < acl->actctx->num_assemblies; i++) if (is_matching_identity( ai, &acl->actctx->assemblies[i].id )) { - DPRINT( "reusing existing assembly for %s arch %s version %u.%u.%u.%u\n", + DPRINT( "reusing existing assembly for %S arch %S version %u.%u.%u.%u\n", ai->name, ai->arch, ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); return TRUE; @@ -429,7 +429,7 @@ static BOOL add_dependent_assembly_id(struct actctx_loader* acl, for (i = 0; i < acl->num_dependencies; i++) if (is_matching_identity( ai, &acl->dependencies[i] )) { - DPRINT( "reusing existing dependency for %s arch %s version %u.%u.%u.%u\n", + DPRINT( "reusing existing dependency for %S arch %S version %u.%u.%u.%u\n", ai->name, ai->arch, ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); return TRUE; @@ -755,7 +755,7 @@ static BOOL parse_version(const xmlstr_t *str, struct assembly_version *version) return TRUE; error: - DPRINT1( "Wrong version definition in manifest file (%s)\n", str->ptr ); + DPRINT1( "Wrong version definition in manifest file (%S)\n", str->ptr ); return FALSE; } @@ -764,7 +764,7 @@ static BOOL parse_expect_elem(xmlbuf_t* xmlbuf, const WCHAR* name) xmlstr_t elem; if (!next_xml_elem(xmlbuf, &elem)) return FALSE; if (xmlstr_cmp(&elem, name)) return TRUE; - DPRINT1( "unexpected element %s\n", elem.ptr ); + DPRINT1( "unexpected element %S\n", elem.ptr ); return FALSE; } @@ -775,7 +775,7 @@ static BOOL parse_expect_no_attr(xmlbuf_t* xmlbuf, BOOL* end) while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, end)) { - DPRINT1( "unexpected attr %s=%s\n", attr_name.ptr, + DPRINT1( "unexpected attr %S=%S\n", attr_name.ptr, attr_value.ptr); } return !error; @@ -793,7 +793,7 @@ static BOOL parse_expect_end_elem(xmlbuf_t *xmlbuf, const WCHAR *name) if (!next_xml_elem(xmlbuf, &elem)) return FALSE; if (!xmlstr_cmp_end(&elem, name)) { - DPRINT1( "unexpected element %s\n", elem.ptr ); + DPRINT1( "unexpected element %S\n", elem.ptr ); return FALSE; } return parse_end_element(xmlbuf); @@ -849,13 +849,13 @@ static BOOL parse_assembly_identity_elem(xmlbuf_t* xmlbuf, ACTIVATION_CONTEXT* a } else if (xmlstr_cmp(&attr_name, languageW)) { - DPRINT1("Unsupported yet language attribute (%s)\n", + DPRINT1("Unsupported yet language attribute (%S)\n", attr_value.ptr); if (!(ai->language = xmlstrdupW(&attr_value))) return FALSE; } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -881,7 +881,7 @@ static BOOL parse_com_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -896,7 +896,7 @@ static BOOL parse_com_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown elem %s\n", elem.ptr); + DPRINT1("unknown elem %S\n", elem.ptr); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -924,7 +924,7 @@ static BOOL parse_cominterface_proxy_stub_elem(xmlbuf_t* xmlbuf, struct dll_redi } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -957,7 +957,7 @@ static BOOL parse_typelib_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr , attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr , attr_value.ptr); } } @@ -990,7 +990,7 @@ static BOOL parse_window_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown elem %s\n", elem.ptr); + DPRINT1("unknown elem %S\n", elem.ptr); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1007,15 +1007,15 @@ static BOOL parse_binding_redirect_elem(xmlbuf_t* xmlbuf) { if (xmlstr_cmp(&attr_name, oldVersionW)) { - DPRINT1("Not stored yet oldVersion=%s\n", attr_value.ptr); + DPRINT1("Not stored yet oldVersion=%S\n", attr_value.ptr); } else if (xmlstr_cmp(&attr_name, newVersionW)) { - DPRINT1("Not stored yet newVersion=%s\n", attr_value.ptr); + DPRINT1("Not stored yet newVersion=%S\n", attr_value.ptr); } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -1032,7 +1032,7 @@ static BOOL parse_description_elem(xmlbuf_t* xmlbuf) !parse_text_content(xmlbuf, &content)) return FALSE; - DPRINT("Got description %s\n", content.ptr); + DPRINT("Got description %S\n", content.ptr); while (ret && (ret = next_xml_elem(xmlbuf, &elem))) { @@ -1043,7 +1043,7 @@ static BOOL parse_description_elem(xmlbuf_t* xmlbuf) } else { - DPRINT1("unknown elem %s\n", elem.ptr); + DPRINT1("unknown elem %S\n", elem.ptr); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1073,7 +1073,7 @@ static BOOL parse_com_interface_external_proxy_stub_elem(xmlbuf_t* xmlbuf, } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -1102,7 +1102,7 @@ static BOOL parse_clr_class_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -1131,7 +1131,7 @@ static BOOL parse_clr_surrogate_elem(xmlbuf_t* xmlbuf, struct assembly* assembly } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -1170,7 +1170,7 @@ static BOOL parse_dependent_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader } else { - DPRINT1("unknown elem %s\n", elem.ptr); + DPRINT1("unknown elem %S\n", elem.ptr); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1189,11 +1189,11 @@ static BOOL parse_dependency_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl) { static const WCHAR yesW[] = {'y','e','s',0}; optional = xmlstr_cmpi( &attr_value, yesW ); - DPRINT1("optional=%s\n", attr_value.ptr); + DPRINT1("optional=%S\n", attr_value.ptr); } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -1210,7 +1210,7 @@ static BOOL parse_dependency_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl) } else { - DPRINT1("unknown element %s\n", elem.ptr); + DPRINT1("unknown element %S\n", elem.ptr); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1247,7 +1247,7 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) if (xmlstr_cmp(&attr_name, nameW)) { if (!(dll->name = xmlstrdupW(&attr_value))) return FALSE; - DPRINT("name=%s\n", attr_value.ptr); + DPRINT("name=%S\n", attr_value.ptr); } else if (xmlstr_cmp(&attr_name, hashW)) { @@ -1257,11 +1257,11 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { static const WCHAR sha1W[] = {'S','H','A','1',0}; if (!xmlstr_cmpi(&attr_value, sha1W)) - DPRINT1("hashalg should be SHA1, got %s\n", attr_value.ptr); + DPRINT1("hashalg should be SHA1, got %S\n", attr_value.ptr); } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -1298,7 +1298,7 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) } else { - DPRINT1("unknown elem %s\n", elem.ptr); + DPRINT1("unknown elem %S\n", elem.ptr); ret = parse_unknown_elem( xmlbuf, &elem ); } } @@ -1320,7 +1320,7 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, static const WCHAR v10W[] = {'1','.','0',0}; if (!xmlstr_cmp(&attr_value, v10W)) { - DPRINT1("wrong version %s\n", attr_value.ptr); + DPRINT1("wrong version %S\n", attr_value.ptr); return FALSE; } version = TRUE; @@ -1329,14 +1329,14 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, { if (!xmlstr_cmp(&attr_value, manifestv1W) && !xmlstr_cmp(&attr_value, manifestv3W)) { - DPRINT1("wrong namespace %s\n", attr_value.ptr); + DPRINT1("wrong namespace %S\n", attr_value.ptr); return FALSE; } xmlns = TRUE; } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -1421,7 +1421,7 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, } else { - DPRINT1("unknown element %s\n", elem.ptr); + DPRINT1("unknown element %S\n", elem.ptr); ret = parse_unknown_elem(xmlbuf, &elem); } if (ret) ret = next_xml_elem(xmlbuf, &elem); @@ -1443,19 +1443,19 @@ static NTSTATUS parse_manifest_buffer( struct actctx_loader* acl, struct assembl if (!xmlstr_cmp(&elem, assemblyW)) { - DPRINT1("root element is %s, not \n", elem.ptr); + DPRINT1("root element is %S, not \n", elem.ptr); return STATUS_SXS_CANT_GEN_ACTCTX; } if (!parse_assembly_elem(xmlbuf, acl, assembly, ai)) { - DPRINT1("failed to parse manifest %s\n", assembly->manifest.info ); + DPRINT1("failed to parse manifest %S\n", assembly->manifest.info ); return STATUS_SXS_CANT_GEN_ACTCTX; } if (next_xml_elem(xmlbuf, &elem)) { - DPRINT1("unexpected element %s\n", elem.ptr); + DPRINT1("unexpected element %S\n", elem.ptr); return STATUS_SXS_CANT_GEN_ACTCTX; } @@ -1476,7 +1476,7 @@ static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_ident struct assembly *assembly; int unicode_tests; - DPRINT( "parsing manifest loaded from %s base dir %s\n", filename, directory ); + DPRINT( "parsing manifest loaded from %S base dir %S\n", filename, directory ); if (!(assembly = add_assembly(acl->actctx, shared ? ASSEMBLY_SHARED_MANIFEST : ASSEMBLY_MANIFEST))) return STATUS_SXS_CANT_GEN_ACTCTX; @@ -1655,7 +1655,7 @@ static NTSTATUS get_manifest_in_pe_file( struct actctx_loader* acl, struct assem SIZE_T count; void *base; - DPRINT( "looking for res %s in %s\n", resname, filename ); + DPRINT( "looking for res %S in %S\n", resname, filename ); attr.Length = sizeof(attr); attr.RootDirectory = 0; @@ -1748,7 +1748,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl, if (!((ULONG_PTR)resname >> 16)) resid = (ULONG_PTR)resname & 0xffff; - DPRINT( "looking for manifest associated with %s id %lu\n", filename, resid ); + DPRINT( "looking for manifest associated with %S id %lu\n", filename, resid ); if (module) /* use the module filename */ { @@ -1850,7 +1850,7 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai ) break; } } - else DPRINT1("no matching file for %s\n", lookup); + else DPRINT1("no matching file for %S\n", lookup); RtlFreeHeap( RtlGetProcessHeap(), 0, lookup ); return ret; } From dc4048eeead564d5b5a04cfb2386a395695daa3a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 28 Feb 2010 17:24:02 +0000 Subject: [PATCH 010/211] - Use the rappmgr.cab located on our server - Fixes rapps cab download svn path=/trunk/; revision=45730 --- reactos/base/applications/rapps/rapps.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/base/applications/rapps/rapps.h b/reactos/base/applications/rapps/rapps.h index 5401b37a317..cba76db823a 100644 --- a/reactos/base/applications/rapps/rapps.h +++ b/reactos/base/applications/rapps/rapps.h @@ -11,7 +11,7 @@ #include "resource.h" -#define APPLICATION_DATEBASE_URL L"http://opendn.org/rappmgr.cab" +#define APPLICATION_DATEBASE_URL L"http://svn.reactos.org/packages/rappmgr.cab" #define SPLIT_WIDTH 4 #define MAX_STR_LEN 256 From e21af25d5378eb461fd16a1ccab43db737e508d8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 28 Feb 2010 18:20:17 +0000 Subject: [PATCH 011/211] - Send the SCM reply packet with the final status after completing the requested actions - Fixes the hang during 2nd stage setup svn path=/trunk/; revision=45731 --- reactos/dll/win32/advapi32/service/sctrl.c | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/advapi32/service/sctrl.c b/reactos/dll/win32/advapi32/service/sctrl.c index a88fb2f11b0..60516cdfd89 100644 --- a/reactos/dll/win32/advapi32/service/sctrl.c +++ b/reactos/dll/win32/advapi32/service/sctrl.c @@ -347,6 +347,8 @@ ScServiceDispatcher(HANDLE hPipe, DWORD dwRunningServices = 0; LPWSTR lpServiceName; PACTIVE_SERVICE lpService; + SCM_REPLY_PACKET ReplyPacket; + DWORD dwError; TRACE("ScDispatcherLoop() called\n"); @@ -381,22 +383,42 @@ ScServiceDispatcher(HANDLE hPipe, { case SERVICE_CONTROL_START: TRACE("Start command - recieved SERVICE_CONTROL_START\n"); - if (ScStartService(lpService, ControlPacket) == ERROR_SUCCESS) + dwError = ScStartService(lpService, ControlPacket); + if (dwError == ERROR_SUCCESS) dwRunningServices++; break; case SERVICE_CONTROL_STOP: TRACE("Stop command - recieved SERVICE_CONTROL_STOP\n"); - if (ScControlService(lpService, ControlPacket) == ERROR_SUCCESS) + dwError = ScControlService(lpService, ControlPacket); + if (dwError == ERROR_SUCCESS) dwRunningServices--; break; default: TRACE("Command %lu received", ControlPacket->dwControl); - ScControlService(lpService, ControlPacket); - continue; + dwError = ScControlService(lpService, ControlPacket); + break; } } + else + { + dwError = ERROR_NOT_FOUND; + } + + ReplyPacket.dwError = dwError; + + /* Send the reply packet */ + bResult = WriteFile(hPipe, + &ReplyPacket, + sizeof(ReplyPacket), + &Count, + NULL); + if (bResult == FALSE) + { + ERR("Pipe write failed (Error: %lu)\n", GetLastError()); + return FALSE; + } if (dwRunningServices == 0) break; From 602acabdf9cff1c28364baf75f61f44d1e90e956 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 1 Mar 2010 00:16:13 +0000 Subject: [PATCH 012/211] - Update to new ACPI driver by Samuel Serapion (and fixes by me) - Part 1 of 2 svn path=/trunk/; revision=45732 --- reactos/drivers/bus/acpi/acpi.rbuild | 142 -- reactos/drivers/bus/acpi/acpi.rc | 7 - reactos/drivers/bus/acpi/changed.txt | 21 - reactos/drivers/bus/acpi/dispatcher/dsfield.c | 418 ------ .../drivers/bus/acpi/dispatcher/dsmethod.c | 489 ------- .../drivers/bus/acpi/dispatcher/dsmthdat.c | 687 --------- .../drivers/bus/acpi/dispatcher/dsobject.c | 636 --------- .../drivers/bus/acpi/dispatcher/dsopcode.c | 868 ------------ reactos/drivers/bus/acpi/dispatcher/dsutils.c | 744 ---------- reactos/drivers/bus/acpi/dispatcher/dswexec.c | 646 --------- reactos/drivers/bus/acpi/dispatcher/dswload.c | 672 --------- .../drivers/bus/acpi/dispatcher/dswscope.c | 158 --- .../drivers/bus/acpi/dispatcher/dswstate.c | 872 ------------ reactos/drivers/bus/acpi/events/evevent.c | 765 ----------- reactos/drivers/bus/acpi/events/evmisc.c | 439 ------ reactos/drivers/bus/acpi/events/evregion.c | 602 -------- reactos/drivers/bus/acpi/events/evrgnini.c | 413 ------ reactos/drivers/bus/acpi/events/evsci.c | 267 ---- reactos/drivers/bus/acpi/events/evxface.c | 604 -------- reactos/drivers/bus/acpi/events/evxfevnt.c | 480 ------- reactos/drivers/bus/acpi/events/evxfregn.c | 373 ----- reactos/drivers/bus/acpi/executer/amconfig.c | 297 ---- reactos/drivers/bus/acpi/executer/amconvrt.c | 511 ------- reactos/drivers/bus/acpi/executer/amcreate.c | 714 ---------- reactos/drivers/bus/acpi/executer/amdump.c | 37 - reactos/drivers/bus/acpi/executer/amdyadic.c | 870 ------------ reactos/drivers/bus/acpi/executer/amfield.c | 274 ---- reactos/drivers/bus/acpi/executer/amfldio.c | 668 --------- reactos/drivers/bus/acpi/executer/ammisc.c | 510 ------- reactos/drivers/bus/acpi/executer/ammonad.c | 957 ------------- reactos/drivers/bus/acpi/executer/ammutex.c | 278 ---- reactos/drivers/bus/acpi/executer/amnames.c | 387 ------ reactos/drivers/bus/acpi/executer/amprep.c | 400 ------ reactos/drivers/bus/acpi/executer/amregion.c | 405 ------ reactos/drivers/bus/acpi/executer/amresnte.c | 500 ------- reactos/drivers/bus/acpi/executer/amresolv.c | 420 ------ reactos/drivers/bus/acpi/executer/amresop.c | 475 ------- reactos/drivers/bus/acpi/executer/amstore.c | 563 -------- reactos/drivers/bus/acpi/executer/amstoren.c | 252 ---- reactos/drivers/bus/acpi/executer/amstorob.c | 427 ------ reactos/drivers/bus/acpi/executer/amsystem.c | 323 ----- reactos/drivers/bus/acpi/executer/amutils.c | 359 ----- reactos/drivers/bus/acpi/executer/amxface.c | 98 -- reactos/drivers/bus/acpi/hardware/hwacpi.c | 303 ---- reactos/drivers/bus/acpi/hardware/hwgpe.c | 204 --- reactos/drivers/bus/acpi/hardware/hwregs.c | 964 ------------- reactos/drivers/bus/acpi/hardware/hwsleep.c | 186 --- reactos/drivers/bus/acpi/hardware/hwtimer.c | 199 --- reactos/drivers/bus/acpi/include/accommon.h | 725 ---------- reactos/drivers/bus/acpi/include/acconfig.h | 152 -- reactos/drivers/bus/acpi/include/acdebug.h | 411 ------ reactos/drivers/bus/acpi/include/acdispat.h | 450 ------ reactos/drivers/bus/acpi/include/acevents.h | 203 --- reactos/drivers/bus/acpi/include/acexcep.h | 150 -- reactos/drivers/bus/acpi/include/acglobal.h | 301 ---- reactos/drivers/bus/acpi/include/achware.h | 149 -- reactos/drivers/bus/acpi/include/acinterp.h | 632 --------- reactos/drivers/bus/acpi/include/aclocal.h | 832 ----------- reactos/drivers/bus/acpi/include/acmacros.h | 507 ------- reactos/drivers/bus/acpi/include/acnamesp.h | 430 ------ reactos/drivers/bus/acpi/include/acobject.h | 425 ------ reactos/drivers/bus/acpi/include/acoutput.h | 132 -- reactos/drivers/bus/acpi/include/acparser.h | 346 ----- reactos/drivers/bus/acpi/include/acpi.h | 70 - reactos/drivers/bus/acpi/include/acpiosxf.h | 341 ----- reactos/drivers/bus/acpi/include/acpixf.h | 340 ----- reactos/drivers/bus/acpi/include/acresrc.h | 304 ---- reactos/drivers/bus/acpi/include/acstruct.h | 157 --- reactos/drivers/bus/acpi/include/actables.h | 185 --- reactos/drivers/bus/acpi/include/actbl.h | 217 --- reactos/drivers/bus/acpi/include/actbl1.h | 123 -- reactos/drivers/bus/acpi/include/actbl2.h | 189 --- reactos/drivers/bus/acpi/include/actbl71.h | 144 -- reactos/drivers/bus/acpi/include/actypes.h | 1077 --------------- reactos/drivers/bus/acpi/include/amlcode.h | 420 ------ .../drivers/bus/acpi/include/platform/acenv.h | 288 ---- .../drivers/bus/acpi/include/platform/acgcc.h | 147 -- .../bus/acpi/include/platform/aclinux.h | 66 - .../drivers/bus/acpi/include/platform/acmsc.h | 67 - .../drivers/bus/acpi/include/platform/acwin.h | 82 -- .../drivers/bus/acpi/include/platform/types.h | 19 - reactos/drivers/bus/acpi/namespace/nsaccess.c | 546 -------- reactos/drivers/bus/acpi/namespace/nsalloc.c | 563 -------- reactos/drivers/bus/acpi/namespace/nseval.c | 501 ------- reactos/drivers/bus/acpi/namespace/nsinit.c | 276 ---- reactos/drivers/bus/acpi/namespace/nsload.c | 521 ------- reactos/drivers/bus/acpi/namespace/nsnames.c | 245 ---- reactos/drivers/bus/acpi/namespace/nsobject.c | 356 ----- reactos/drivers/bus/acpi/namespace/nssearch.c | 342 ----- reactos/drivers/bus/acpi/namespace/nsutils.c | 811 ----------- reactos/drivers/bus/acpi/namespace/nswalk.c | 269 ---- reactos/drivers/bus/acpi/namespace/nsxfname.c | 294 ---- reactos/drivers/bus/acpi/namespace/nsxfobj.c | 690 ---------- reactos/drivers/bus/acpi/ospm/acpienum.c | 191 --- reactos/drivers/bus/acpi/ospm/acpisys.c | 183 --- reactos/drivers/bus/acpi/ospm/bn.c | 599 -------- reactos/drivers/bus/acpi/ospm/busmgr/bm.c | 1047 -------------- .../drivers/bus/acpi/ospm/busmgr/bmnotify.c | 310 ----- reactos/drivers/bus/acpi/ospm/busmgr/bmpm.c | 395 ------ .../drivers/bus/acpi/ospm/busmgr/bmpower.c | 666 --------- .../drivers/bus/acpi/ospm/busmgr/bmrequest.c | 163 --- .../drivers/bus/acpi/ospm/busmgr/bmsearch.c | 190 --- .../drivers/bus/acpi/ospm/busmgr/bmutils.c | 604 -------- .../drivers/bus/acpi/ospm/busmgr/bmxface.c | 330 ----- reactos/drivers/bus/acpi/ospm/fdo.c | 983 ------------- .../drivers/bus/acpi/ospm/include/acpisys.h | 127 -- reactos/drivers/bus/acpi/ospm/include/bm.h | 624 --------- .../drivers/bus/acpi/ospm/include/bmpower.h | 75 - reactos/drivers/bus/acpi/ospm/include/bn.h | 113 -- reactos/drivers/bus/acpi/ospm/osl.c | 706 ---------- reactos/drivers/bus/acpi/ospm/pdo.c | 385 ------ reactos/drivers/bus/acpi/parser/psargs.c | 730 ---------- reactos/drivers/bus/acpi/parser/psopcode.c | 648 --------- reactos/drivers/bus/acpi/parser/psparse.c | 1223 ----------------- reactos/drivers/bus/acpi/parser/psscope.c | 263 ---- reactos/drivers/bus/acpi/parser/pstree.c | 286 ---- reactos/drivers/bus/acpi/parser/psutils.c | 554 -------- reactos/drivers/bus/acpi/parser/pswalk.c | 278 ---- reactos/drivers/bus/acpi/parser/psxface.c | 157 --- reactos/drivers/bus/acpi/resource/rsaddr.c | 800 ----------- reactos/drivers/bus/acpi/resource/rscalc.c | 865 ------------ reactos/drivers/bus/acpi/resource/rscreate.c | 418 ------ reactos/drivers/bus/acpi/resource/rsdump.c | 928 ------------- reactos/drivers/bus/acpi/resource/rsio.c | 526 ------- reactos/drivers/bus/acpi/resource/rsirq.c | 555 -------- reactos/drivers/bus/acpi/resource/rslist.c | 499 ------- reactos/drivers/bus/acpi/resource/rsmemory.c | 556 -------- reactos/drivers/bus/acpi/resource/rsmisc.c | 605 -------- reactos/drivers/bus/acpi/resource/rsutils.c | 384 ------ reactos/drivers/bus/acpi/resource/rsxface.c | 218 --- reactos/drivers/bus/acpi/tables/tbconvrt.c | 547 -------- reactos/drivers/bus/acpi/tables/tbget.c | 608 -------- reactos/drivers/bus/acpi/tables/tbinstal.c | 531 ------- reactos/drivers/bus/acpi/tables/tbutils.c | 352 ----- reactos/drivers/bus/acpi/tables/tbxface.c | 383 ------ reactos/drivers/bus/acpi/tables/tbxfroot.c | 209 --- reactos/drivers/bus/acpi/utils/cmalloc.c | 166 --- reactos/drivers/bus/acpi/utils/cmclib.c | 810 ----------- reactos/drivers/bus/acpi/utils/cmcopy.c | 704 ---------- reactos/drivers/bus/acpi/utils/cmdebug.c | 555 -------- reactos/drivers/bus/acpi/utils/cmdelete.c | 585 -------- reactos/drivers/bus/acpi/utils/cmeval.c | 303 ---- reactos/drivers/bus/acpi/utils/cmglobal.c | 568 -------- reactos/drivers/bus/acpi/utils/cminit.c | 242 ---- reactos/drivers/bus/acpi/utils/cmobject.c | 618 --------- reactos/drivers/bus/acpi/utils/cmutils.c | 999 -------------- reactos/drivers/bus/acpi/utils/cmxface.c | 452 ------ 147 files changed, 64195 deletions(-) delete mode 100644 reactos/drivers/bus/acpi/acpi.rbuild delete mode 100644 reactos/drivers/bus/acpi/acpi.rc delete mode 100644 reactos/drivers/bus/acpi/changed.txt delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dsfield.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dsmethod.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dsmthdat.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dsobject.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dsopcode.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dsutils.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dswexec.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dswload.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dswscope.c delete mode 100644 reactos/drivers/bus/acpi/dispatcher/dswstate.c delete mode 100644 reactos/drivers/bus/acpi/events/evevent.c delete mode 100644 reactos/drivers/bus/acpi/events/evmisc.c delete mode 100644 reactos/drivers/bus/acpi/events/evregion.c delete mode 100644 reactos/drivers/bus/acpi/events/evrgnini.c delete mode 100644 reactos/drivers/bus/acpi/events/evsci.c delete mode 100644 reactos/drivers/bus/acpi/events/evxface.c delete mode 100644 reactos/drivers/bus/acpi/events/evxfevnt.c delete mode 100644 reactos/drivers/bus/acpi/events/evxfregn.c delete mode 100644 reactos/drivers/bus/acpi/executer/amconfig.c delete mode 100644 reactos/drivers/bus/acpi/executer/amconvrt.c delete mode 100644 reactos/drivers/bus/acpi/executer/amcreate.c delete mode 100644 reactos/drivers/bus/acpi/executer/amdump.c delete mode 100644 reactos/drivers/bus/acpi/executer/amdyadic.c delete mode 100644 reactos/drivers/bus/acpi/executer/amfield.c delete mode 100644 reactos/drivers/bus/acpi/executer/amfldio.c delete mode 100644 reactos/drivers/bus/acpi/executer/ammisc.c delete mode 100644 reactos/drivers/bus/acpi/executer/ammonad.c delete mode 100644 reactos/drivers/bus/acpi/executer/ammutex.c delete mode 100644 reactos/drivers/bus/acpi/executer/amnames.c delete mode 100644 reactos/drivers/bus/acpi/executer/amprep.c delete mode 100644 reactos/drivers/bus/acpi/executer/amregion.c delete mode 100644 reactos/drivers/bus/acpi/executer/amresnte.c delete mode 100644 reactos/drivers/bus/acpi/executer/amresolv.c delete mode 100644 reactos/drivers/bus/acpi/executer/amresop.c delete mode 100644 reactos/drivers/bus/acpi/executer/amstore.c delete mode 100644 reactos/drivers/bus/acpi/executer/amstoren.c delete mode 100644 reactos/drivers/bus/acpi/executer/amstorob.c delete mode 100644 reactos/drivers/bus/acpi/executer/amsystem.c delete mode 100644 reactos/drivers/bus/acpi/executer/amutils.c delete mode 100644 reactos/drivers/bus/acpi/executer/amxface.c delete mode 100644 reactos/drivers/bus/acpi/hardware/hwacpi.c delete mode 100644 reactos/drivers/bus/acpi/hardware/hwgpe.c delete mode 100644 reactos/drivers/bus/acpi/hardware/hwregs.c delete mode 100644 reactos/drivers/bus/acpi/hardware/hwsleep.c delete mode 100644 reactos/drivers/bus/acpi/hardware/hwtimer.c delete mode 100644 reactos/drivers/bus/acpi/include/accommon.h delete mode 100644 reactos/drivers/bus/acpi/include/acconfig.h delete mode 100644 reactos/drivers/bus/acpi/include/acdebug.h delete mode 100644 reactos/drivers/bus/acpi/include/acdispat.h delete mode 100644 reactos/drivers/bus/acpi/include/acevents.h delete mode 100644 reactos/drivers/bus/acpi/include/acexcep.h delete mode 100644 reactos/drivers/bus/acpi/include/acglobal.h delete mode 100644 reactos/drivers/bus/acpi/include/achware.h delete mode 100644 reactos/drivers/bus/acpi/include/acinterp.h delete mode 100644 reactos/drivers/bus/acpi/include/aclocal.h delete mode 100644 reactos/drivers/bus/acpi/include/acmacros.h delete mode 100644 reactos/drivers/bus/acpi/include/acnamesp.h delete mode 100644 reactos/drivers/bus/acpi/include/acobject.h delete mode 100644 reactos/drivers/bus/acpi/include/acoutput.h delete mode 100644 reactos/drivers/bus/acpi/include/acparser.h delete mode 100644 reactos/drivers/bus/acpi/include/acpi.h delete mode 100644 reactos/drivers/bus/acpi/include/acpiosxf.h delete mode 100644 reactos/drivers/bus/acpi/include/acpixf.h delete mode 100644 reactos/drivers/bus/acpi/include/acresrc.h delete mode 100644 reactos/drivers/bus/acpi/include/acstruct.h delete mode 100644 reactos/drivers/bus/acpi/include/actables.h delete mode 100644 reactos/drivers/bus/acpi/include/actbl.h delete mode 100644 reactos/drivers/bus/acpi/include/actbl1.h delete mode 100644 reactos/drivers/bus/acpi/include/actbl2.h delete mode 100644 reactos/drivers/bus/acpi/include/actbl71.h delete mode 100644 reactos/drivers/bus/acpi/include/actypes.h delete mode 100644 reactos/drivers/bus/acpi/include/amlcode.h delete mode 100644 reactos/drivers/bus/acpi/include/platform/acenv.h delete mode 100644 reactos/drivers/bus/acpi/include/platform/acgcc.h delete mode 100644 reactos/drivers/bus/acpi/include/platform/aclinux.h delete mode 100644 reactos/drivers/bus/acpi/include/platform/acmsc.h delete mode 100644 reactos/drivers/bus/acpi/include/platform/acwin.h delete mode 100644 reactos/drivers/bus/acpi/include/platform/types.h delete mode 100644 reactos/drivers/bus/acpi/namespace/nsaccess.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nsalloc.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nseval.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nsinit.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nsload.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nsnames.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nsobject.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nssearch.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nsutils.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nswalk.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nsxfname.c delete mode 100644 reactos/drivers/bus/acpi/namespace/nsxfobj.c delete mode 100644 reactos/drivers/bus/acpi/ospm/acpienum.c delete mode 100644 reactos/drivers/bus/acpi/ospm/acpisys.c delete mode 100644 reactos/drivers/bus/acpi/ospm/bn.c delete mode 100644 reactos/drivers/bus/acpi/ospm/busmgr/bm.c delete mode 100644 reactos/drivers/bus/acpi/ospm/busmgr/bmnotify.c delete mode 100644 reactos/drivers/bus/acpi/ospm/busmgr/bmpm.c delete mode 100644 reactos/drivers/bus/acpi/ospm/busmgr/bmpower.c delete mode 100644 reactos/drivers/bus/acpi/ospm/busmgr/bmrequest.c delete mode 100644 reactos/drivers/bus/acpi/ospm/busmgr/bmsearch.c delete mode 100644 reactos/drivers/bus/acpi/ospm/busmgr/bmutils.c delete mode 100644 reactos/drivers/bus/acpi/ospm/busmgr/bmxface.c delete mode 100644 reactos/drivers/bus/acpi/ospm/fdo.c delete mode 100644 reactos/drivers/bus/acpi/ospm/include/acpisys.h delete mode 100644 reactos/drivers/bus/acpi/ospm/include/bm.h delete mode 100644 reactos/drivers/bus/acpi/ospm/include/bmpower.h delete mode 100644 reactos/drivers/bus/acpi/ospm/include/bn.h delete mode 100644 reactos/drivers/bus/acpi/ospm/osl.c delete mode 100644 reactos/drivers/bus/acpi/ospm/pdo.c delete mode 100644 reactos/drivers/bus/acpi/parser/psargs.c delete mode 100644 reactos/drivers/bus/acpi/parser/psopcode.c delete mode 100644 reactos/drivers/bus/acpi/parser/psparse.c delete mode 100644 reactos/drivers/bus/acpi/parser/psscope.c delete mode 100644 reactos/drivers/bus/acpi/parser/pstree.c delete mode 100644 reactos/drivers/bus/acpi/parser/psutils.c delete mode 100644 reactos/drivers/bus/acpi/parser/pswalk.c delete mode 100644 reactos/drivers/bus/acpi/parser/psxface.c delete mode 100644 reactos/drivers/bus/acpi/resource/rsaddr.c delete mode 100644 reactos/drivers/bus/acpi/resource/rscalc.c delete mode 100644 reactos/drivers/bus/acpi/resource/rscreate.c delete mode 100644 reactos/drivers/bus/acpi/resource/rsdump.c delete mode 100644 reactos/drivers/bus/acpi/resource/rsio.c delete mode 100644 reactos/drivers/bus/acpi/resource/rsirq.c delete mode 100644 reactos/drivers/bus/acpi/resource/rslist.c delete mode 100644 reactos/drivers/bus/acpi/resource/rsmemory.c delete mode 100644 reactos/drivers/bus/acpi/resource/rsmisc.c delete mode 100644 reactos/drivers/bus/acpi/resource/rsutils.c delete mode 100644 reactos/drivers/bus/acpi/resource/rsxface.c delete mode 100644 reactos/drivers/bus/acpi/tables/tbconvrt.c delete mode 100644 reactos/drivers/bus/acpi/tables/tbget.c delete mode 100644 reactos/drivers/bus/acpi/tables/tbinstal.c delete mode 100644 reactos/drivers/bus/acpi/tables/tbutils.c delete mode 100644 reactos/drivers/bus/acpi/tables/tbxface.c delete mode 100644 reactos/drivers/bus/acpi/tables/tbxfroot.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmalloc.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmclib.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmcopy.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmdebug.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmdelete.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmeval.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmglobal.c delete mode 100644 reactos/drivers/bus/acpi/utils/cminit.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmobject.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmutils.c delete mode 100644 reactos/drivers/bus/acpi/utils/cmxface.c diff --git a/reactos/drivers/bus/acpi/acpi.rbuild b/reactos/drivers/bus/acpi/acpi.rbuild deleted file mode 100644 index 94b960a9b6f..00000000000 --- a/reactos/drivers/bus/acpi/acpi.rbuild +++ /dev/null @@ -1,142 +0,0 @@ - - - - - include - ospm/include - ntoskrnl - hal - - dsfield.c - dsmethod.c - dsmthdat.c - dsobject.c - dsopcode.c - dsutils.c - dswexec.c - dswload.c - dswscope.c - dswstate.c - - - evevent.c - evmisc.c - evregion.c - evrgnini.c - evsci.c - evxface.c - evxfevnt.c - evxfregn.c - - - amconfig.c - amconvrt.c - amcreate.c - amdump.c - amdyadic.c - amfield.c - amfldio.c - ammisc.c - ammonad.c - ammutex.c - amnames.c - amprep.c - amregion.c - amresnte.c - amresolv.c - amresop.c - amstore.c - amstoren.c - amstorob.c - amsystem.c - amutils.c - amxface.c - - - hwacpi.c - hwgpe.c - hwregs.c - hwsleep.c - hwtimer.c - - - nsaccess.c - nsalloc.c - nseval.c - nsinit.c - nsload.c - nsnames.c - nsobject.c - nssearch.c - nsutils.c - nswalk.c - nsxfname.c - nsxfobj.c - - - - bm.c - bmnotify.c - bmpm.c - bmpower.c - bmrequest.c - bmsearch.c - bmutils.c - bmxface.c - - acpienum.c - acpisys.c - bn.c - fdo.c - osl.c - pdo.c - - - psargs.c - psopcode.c - psparse.c - psscope.c - pstree.c - psutils.c - pswalk.c - psxface.c - - - rsaddr.c - rscalc.c - rscreate.c - rsdump.c - rsio.c - rsirq.c - rslist.c - rsmemory.c - rsmisc.c - rsutils.c - rsxface.c - - - tbconvrt.c - tbget.c - tbinstal.c - tbutils.c - tbxface.c - tbxfroot.c - - - cmalloc.c - cmclib.c - cmcopy.c - cmdebug.c - cmdelete.c - cmeval.c - cmglobal.c - cminit.c - cmobject.c - cmutils.c - cmxface.c - - acpi.rc - - acpi.h - - diff --git a/reactos/drivers/bus/acpi/acpi.rc b/reactos/drivers/bus/acpi/acpi.rc deleted file mode 100644 index 41b00065cb0..00000000000 --- a/reactos/drivers/bus/acpi/acpi.rc +++ /dev/null @@ -1,7 +0,0 @@ -/* $Id$ */ - -#define REACTOS_VERSION_DLL -#define REACTOS_STR_FILE_DESCRIPTION "ReactOS ACPI Driver\0" -#define REACTOS_STR_INTERNAL_NAME "acpi\0" -#define REACTOS_STR_ORIGINAL_FILENAME "acpi.sys\0" -#include diff --git a/reactos/drivers/bus/acpi/changed.txt b/reactos/drivers/bus/acpi/changed.txt deleted file mode 100644 index 571775163fd..00000000000 --- a/reactos/drivers/bus/acpi/changed.txt +++ /dev/null @@ -1,21 +0,0 @@ -Changes to ACPI CA ------------------- - -+ = Added -- = Removed -* = Altered - -+ include/platform/acwin.h -+ include/platform/types.h -- ospm/ac_adapter/* -- ospm/battery/* -- ospm/button/* -- ospm/ec/* -- ospm/include/* (except bm.h) -- ospm/processor/* -- ospm/system/* -- ospm/thermal/* -- ospm/busmgr/bm_module.c -- ospm/busmgr/bm_proc.c -- ospm/busmgr/bm_symbols.c -- ospm/busmgr/Makefile diff --git a/reactos/drivers/bus/acpi/dispatcher/dsfield.c b/reactos/drivers/bus/acpi/dispatcher/dsfield.c deleted file mode 100644 index 191a9e92cfe..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dsfield.c +++ /dev/null @@ -1,418 +0,0 @@ -/****************************************************************************** - * - * Module Name: dsfield - Dispatcher field routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsfield") - - -/* - * Field flags: Bits 00 - 03 : Access_type (Any_acc, Byte_acc, etc.) - * 04 : Lock_rule (1 == Lock) - * 05 - 06 : Update_rule - */ - -#define FIELD_ACCESS_TYPE_MASK 0x0F -#define FIELD_LOCK_RULE_MASK 0x10 -#define FIELD_UPDATE_RULE_MASK 0x60 - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_create_field - * - * PARAMETERS: Op - Op containing the Field definition and args - * Region_node - Object for the containing Operation Region - * - * RETURN: Status - * - * DESCRIPTION: Create a new field in the specified operation region - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_create_field ( - ACPI_PARSE_OBJECT *op, - ACPI_NAMESPACE_NODE *region_node, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_AML_ERROR; - ACPI_PARSE_OBJECT *arg; - ACPI_NAMESPACE_NODE *node; - u8 field_flags; - u8 access_attribute = 0; - u32 field_bit_position = 0; - - - /* First arg is the name of the parent Op_region */ - - arg = op->value.arg; - if (!region_node) { - status = acpi_ns_lookup (walk_state->scope_info, arg->value.name, - ACPI_TYPE_REGION, IMODE_EXECUTE, - NS_SEARCH_PARENT, walk_state, - ®ion_node); - - if (ACPI_FAILURE (status)) { - return (status); - } - } - - /* Second arg is the field flags */ - - arg = arg->next; - field_flags = (u8) arg->value.integer; - - /* Each remaining arg is a Named Field */ - - arg = arg->next; - while (arg) { - switch (arg->opcode) { - case AML_RESERVEDFIELD_OP: - - field_bit_position += arg->value.size; - break; - - - case AML_ACCESSFIELD_OP: - - /* - * Get a new Access_type and Access_attribute for all - * entries (until end or another Access_as keyword) - */ - - access_attribute = (u8) arg->value.integer; - field_flags = (u8) - ((field_flags & FIELD_ACCESS_TYPE_MASK) || - ((u8) (arg->value.integer >> 8))); - break; - - - case AML_NAMEDFIELD_OP: - - status = acpi_ns_lookup (walk_state->scope_info, - (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, - INTERNAL_TYPE_DEF_FIELD, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &node); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Initialize an object for the new Node that is on - * the object stack - */ - - status = acpi_aml_prep_def_field_value (node, region_node, field_flags, - access_attribute, field_bit_position, arg->value.size); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Keep track of bit position for *next* field */ - - field_bit_position += arg->value.size; - break; - } - - arg = arg->next; - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_create_bank_field - * - * PARAMETERS: Op - Op containing the Field definition and args - * Region_node - Object for the containing Operation Region - * - * RETURN: Status - * - * DESCRIPTION: Create a new bank field in the specified operation region - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_create_bank_field ( - ACPI_PARSE_OBJECT *op, - ACPI_NAMESPACE_NODE *region_node, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_AML_ERROR; - ACPI_PARSE_OBJECT *arg; - ACPI_NAMESPACE_NODE *register_node; - ACPI_NAMESPACE_NODE *node; - u32 bank_value; - u8 field_flags; - u8 access_attribute = 0; - u32 field_bit_position = 0; - - - /* First arg is the name of the parent Op_region */ - - arg = op->value.arg; - if (!region_node) { - status = acpi_ns_lookup (walk_state->scope_info, arg->value.name, - ACPI_TYPE_REGION, IMODE_EXECUTE, - NS_SEARCH_PARENT, walk_state, - ®ion_node); - - if (ACPI_FAILURE (status)) { - return (status); - } - } - - /* Second arg is the Bank Register */ - - arg = arg->next; - - status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, - INTERNAL_TYPE_BANK_FIELD_DEFN, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, ®ister_node); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Third arg is the Bank_value */ - - arg = arg->next; - bank_value = arg->value.integer; - - - /* Next arg is the field flags */ - - arg = arg->next; - field_flags = (u8) arg->value.integer; - - /* Each remaining arg is a Named Field */ - - arg = arg->next; - while (arg) { - switch (arg->opcode) { - case AML_RESERVEDFIELD_OP: - - field_bit_position += arg->value.size; - break; - - - case AML_ACCESSFIELD_OP: - - /* - * Get a new Access_type and Access_attribute for - * all entries (until end or another Access_as keyword) - */ - - access_attribute = (u8) arg->value.integer; - field_flags = (u8) - ((field_flags & FIELD_ACCESS_TYPE_MASK) || - ((u8) (arg->value.integer >> 8))); - break; - - - case AML_NAMEDFIELD_OP: - - status = acpi_ns_lookup (walk_state->scope_info, - (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, - INTERNAL_TYPE_DEF_FIELD, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &node); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Initialize an object for the new Node that is on - * the object stack - */ - - status = acpi_aml_prep_bank_field_value (node, region_node, register_node, - bank_value, field_flags, access_attribute, - field_bit_position, arg->value.size); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Keep track of bit position for the *next* field */ - - field_bit_position += arg->value.size; - break; - - } - - arg = arg->next; - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_create_index_field - * - * PARAMETERS: Op - Op containing the Field definition and args - * Region_node - Object for the containing Operation Region - * - * RETURN: Status - * - * DESCRIPTION: Create a new index field in the specified operation region - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_create_index_field ( - ACPI_PARSE_OBJECT *op, - ACPI_HANDLE region_node, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_PARSE_OBJECT *arg; - ACPI_NAMESPACE_NODE *node; - ACPI_NAMESPACE_NODE *index_register_node; - ACPI_NAMESPACE_NODE *data_register_node; - u8 field_flags; - u8 access_attribute = 0; - u32 field_bit_position = 0; - - - arg = op->value.arg; - - /* First arg is the name of the Index register */ - - status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, - ACPI_TYPE_ANY, IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &index_register_node); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Second arg is the data register */ - - arg = arg->next; - - status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, - INTERNAL_TYPE_INDEX_FIELD_DEFN, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &data_register_node); - - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* Next arg is the field flags */ - - arg = arg->next; - field_flags = (u8) arg->value.integer; - - - /* Each remaining arg is a Named Field */ - - arg = arg->next; - while (arg) { - switch (arg->opcode) { - case AML_RESERVEDFIELD_OP: - - field_bit_position += arg->value.size; - break; - - - case AML_ACCESSFIELD_OP: - - /* - * Get a new Access_type and Access_attribute for all - * entries (until end or another Access_as keyword) - */ - - access_attribute = (u8) arg->value.integer; - field_flags = (u8) - ((field_flags & FIELD_ACCESS_TYPE_MASK) || - ((u8) (arg->value.integer >> 8))); - break; - - - case AML_NAMEDFIELD_OP: - - status = acpi_ns_lookup (walk_state->scope_info, - (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, - INTERNAL_TYPE_INDEX_FIELD, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &node); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Initialize an object for the new Node that is on - * the object stack - */ - - status = acpi_aml_prep_index_field_value (node, index_register_node, data_register_node, - field_flags, access_attribute, - field_bit_position, arg->value.size); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Keep track of bit position for the *next* field */ - - field_bit_position += arg->value.size; - break; - - - default: - - status = AE_AML_ERROR; - break; - } - - arg = arg->next; - } - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/dispatcher/dsmethod.c b/reactos/drivers/bus/acpi/dispatcher/dsmethod.c deleted file mode 100644 index 70b2349ae68..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dsmethod.c +++ /dev/null @@ -1,489 +0,0 @@ -/****************************************************************************** - * - * Module Name: dsmethod - Parser/Interpreter interface - control method parsing - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsmethod") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_parse_method - * - * PARAMETERS: Obj_handle - Node of the method - * Level - Current nesting level - * Context - Points to a method counter - * Return_value - Not used - * - * RETURN: Status - * - * DESCRIPTION: Call the parser and parse the AML that is - * associated with the method. - * - * MUTEX: Assumes parser is locked - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_parse_method ( - ACPI_HANDLE obj_handle) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_PARSE_OBJECT *op; - ACPI_NAMESPACE_NODE *node; - ACPI_OWNER_ID owner_id; - - - /* Parameter Validation */ - - if (!obj_handle) { - return (AE_NULL_ENTRY); - } - - - /* Extract the method object from the method Node */ - - node = (ACPI_NAMESPACE_NODE *) obj_handle; - obj_desc = node->object; - if (!obj_desc) { - return (AE_NULL_OBJECT); - } - - /* Create a mutex for the method if there is a concurrency limit */ - - if ((obj_desc->method.concurrency != INFINITE_CONCURRENCY) && - (!obj_desc->method.semaphore)) { - status = acpi_os_create_semaphore (obj_desc->method.concurrency, - obj_desc->method.concurrency, - &obj_desc->method.semaphore); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - /* - * Allocate a new parser op to be the root of the parsed - * method tree - */ - op = acpi_ps_alloc_op (AML_METHOD_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - /* Init new op with the method name and pointer back to the Node */ - - acpi_ps_set_name (op, node->name); - op->node = node; - - - /* - * Parse the method, first pass - * - * The first pass load is - * where newly declared named objects are - * added into the namespace. Actual evaluation of - * the named objects (what would be called a "second - * pass") happens during the actual execution of the - * method so that operands to the named objects can - * take on dynamic run-time values. - */ - status = acpi_ps_parse_aml (op, obj_desc->method.pcode, - obj_desc->method.pcode_length, - ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, - node, NULL, NULL, - acpi_ds_load1_begin_op, acpi_ds_load1_end_op); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Get a new Owner_id for objects created by this method */ - - owner_id = acpi_cm_allocate_owner_id (OWNER_TYPE_METHOD); - obj_desc->method.owning_id = owner_id; - - /* Install the parsed tree in the method object */ - /* TBD: [Restructure] Obsolete field? */ - - acpi_ps_delete_parse_tree (op); - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_begin_method_execution - * - * PARAMETERS: Method_node - Node of the method - * Obj_desc - The method object - * Calling_method_node - Caller of this method (if non-null) - * - * RETURN: Status - * - * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, - * increments the thread count, and waits at the method semaphore - * for clearance to execute. - * - * MUTEX: Locks/unlocks parser. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_begin_method_execution ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_NAMESPACE_NODE *calling_method_node) -{ - ACPI_STATUS status = AE_OK; - - - if (!method_node) { - return (AE_NULL_ENTRY); - } - - - /* - * If there is a concurrency limit on this method, we need to - * obtain a unit from the method semaphore. - */ - if (obj_desc->method.semaphore) { - /* - * Allow recursive method calls, up to the reentrancy/concurrency - * limit imposed by the SERIALIZED rule and the Sync_level method - * parameter. - * - * The point of this code is to avoid permanently blocking a - * thread that is making recursive method calls. - */ - if (method_node == calling_method_node) { - if (obj_desc->method.thread_count >= obj_desc->method.concurrency) { - return (AE_AML_METHOD_LIMIT); - } - } - - /* - * Get a unit from the method semaphore. This releases the - * interpreter if we block - */ - status = acpi_aml_system_wait_semaphore (obj_desc->method.semaphore, - WAIT_FOREVER); - } - - - /* - * Increment the method parse tree thread count since it has been - * reentered one more time (even if it is the same thread) - */ - obj_desc->method.thread_count++; - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_call_control_method - * - * PARAMETERS: Walk_state - Current state of the walk - * Op - Current Op to be walked - * - * RETURN: Status - * - * DESCRIPTION: Transfer execution to a called control method - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_call_control_method ( - ACPI_WALK_LIST *walk_list, - ACPI_WALK_STATE *this_walk_state, - ACPI_PARSE_OBJECT *op) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *method_node; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_WALK_STATE *next_walk_state; - ACPI_PARSE_STATE *parser_state; - u32 i; - - - /* - * Get the namespace entry for the control method we are about to call - */ - method_node = this_walk_state->method_call_node; - if (!method_node) { - return (AE_NULL_ENTRY); - } - - obj_desc = acpi_ns_get_attached_object (method_node); - if (!obj_desc) { - return (AE_NULL_OBJECT); - } - - - /* Init for new method, wait on concurrency semaphore */ - - status = acpi_ds_begin_method_execution (method_node, obj_desc, - this_walk_state->method_node); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Create and initialize a new parser state */ - - parser_state = acpi_ps_create_state (obj_desc->method.pcode, - obj_desc->method.pcode_length); - if (!parser_state) { - return (AE_NO_MEMORY); - } - - acpi_ps_init_scope (parser_state, NULL); - parser_state->start_node = method_node; - - - /* Create a new state for the preempting walk */ - - next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, - NULL, obj_desc, walk_list); - if (!next_walk_state) { - /* TBD: delete parser state */ - - return (AE_NO_MEMORY); - } - - next_walk_state->walk_type = WALK_METHOD; - next_walk_state->method_node = method_node; - next_walk_state->parser_state = parser_state; - next_walk_state->parse_flags = this_walk_state->parse_flags; - next_walk_state->descending_callback = this_walk_state->descending_callback; - next_walk_state->ascending_callback = this_walk_state->ascending_callback; - - /* The Next_op of the Next_walk will be the beginning of the method */ - /* TBD: [Restructure] -- obsolete? */ - - next_walk_state->next_op = NULL; - - /* Open a new scope */ - - status = acpi_ds_scope_stack_push (method_node, - ACPI_TYPE_METHOD, next_walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* - * Initialize the arguments for the method. The resolved - * arguments were put on the previous walk state's operand - * stack. Operands on the previous walk state stack always - * start at index 0. - */ - status = acpi_ds_method_data_init_args (&this_walk_state->operands[0], - this_walk_state->num_operands, - next_walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* Create and init a Root Node */ - - op = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - status = acpi_ps_parse_aml (op, obj_desc->method.pcode, - obj_desc->method.pcode_length, - ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, - method_node, NULL, NULL, - acpi_ds_load1_begin_op, acpi_ds_load1_end_op); - acpi_ps_delete_parse_tree (op); - - - /* - * Delete the operands on the previous walkstate operand stack - * (they were copied to new objects) - */ - for (i = 0; i < obj_desc->method.param_count; i++) { - acpi_cm_remove_reference (this_walk_state->operands [i]); - this_walk_state->operands [i] = NULL; - } - - /* Clear the operand stack */ - - this_walk_state->num_operands = 0; - - - return (AE_OK); - - - /* On error, we must delete the new walk state */ - -cleanup: - acpi_ds_terminate_control_method (next_walk_state); - acpi_ds_delete_walk_state (next_walk_state); - return (status); - -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_restart_control_method - * - * PARAMETERS: Walk_state - State of the method when it was preempted - * Op - Pointer to new current op - * - * RETURN: Status - * - * DESCRIPTION: Restart a method that was preempted - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_restart_control_method ( - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT *return_desc) -{ - ACPI_STATUS status; - - - if (return_desc) { - if (walk_state->return_used) { - /* - * Get the return value (if any) from the previous method. - * NULL if no return value - */ - status = acpi_ds_result_push (return_desc, walk_state); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (return_desc); - return (status); - } - } - - else { - /* - * Delete the return value if it will not be used by the - * calling method - */ - acpi_cm_remove_reference (return_desc); - } - - } - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_terminate_control_method - * - * PARAMETERS: Walk_state - State of the method - * - * RETURN: Status - * - * DESCRIPTION: Terminate a control method. Delete everything that the method - * created, delete all locals and arguments, and delete the parse - * tree if requested. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_terminate_control_method ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_NAMESPACE_NODE *method_node; - - - /* The method object should be stored in the walk state */ - - obj_desc = walk_state->method_desc; - if (!obj_desc) { - return (AE_OK); - } - - /* Delete all arguments and locals */ - - acpi_ds_method_data_delete_all (walk_state); - - /* - * Lock the parser while we terminate this method. - * If this is the last thread executing the method, - * we have additional cleanup to perform - */ - acpi_cm_acquire_mutex (ACPI_MTX_PARSER); - - - /* Signal completion of the execution of this method if necessary */ - - if (walk_state->method_desc->method.semaphore) { - status = acpi_os_signal_semaphore ( - walk_state->method_desc->method.semaphore, 1); - } - - /* Decrement the thread count on the method parse tree */ - - walk_state->method_desc->method.thread_count--; - if (!walk_state->method_desc->method.thread_count) { - /* - * There are no more threads executing this method. Perform - * additional cleanup. - * - * The method Node is stored in the walk state - */ - method_node = walk_state->method_node; - - /* - * Delete any namespace entries created immediately underneath - * the method - */ - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - if (method_node->child) { - acpi_ns_delete_namespace_subtree (method_node); - } - - /* - * Delete any namespace entries created anywhere else within - * the namespace - */ - acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id); - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - } - - acpi_cm_release_mutex (ACPI_MTX_PARSER); - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/dispatcher/dsmthdat.c b/reactos/drivers/bus/acpi/dispatcher/dsmthdat.c deleted file mode 100644 index f51304017c5..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dsmthdat.c +++ /dev/null @@ -1,687 +0,0 @@ -/******************************************************************************* - * - * Module Name: dsmthdat - control method arguments and local variables - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsmthdat") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_init - * - * PARAMETERS: Walk_state - Current walk state object - * - * RETURN: Status - * - * DESCRIPTION: Initialize the data structures that hold the method's arguments - * and locals. The data struct is an array of NTEs for each. - * This allows Ref_of and De_ref_of to work properly for these - * special data types. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_method_data_init ( - ACPI_WALK_STATE *walk_state) -{ - u32 i; - - - /* - * Walk_state fields are initialized to zero by the - * Acpi_cm_callocate(). - * - * An Node is assigned to each argument and local so - * that Ref_of() can return a pointer to the Node. - */ - - /* Init the method arguments */ - - for (i = 0; i < MTH_NUM_ARGS; i++) { - MOVE_UNALIGNED32_TO_32 (&walk_state->arguments[i].name, - NAMEOF_ARG_NTE); - walk_state->arguments[i].name |= (i << 24); - walk_state->arguments[i].data_type = ACPI_DESC_TYPE_NAMED; - walk_state->arguments[i].type = ACPI_TYPE_ANY; - walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; - } - - /* Init the method locals */ - - for (i = 0; i < MTH_NUM_LOCALS; i++) { - MOVE_UNALIGNED32_TO_32 (&walk_state->local_variables[i].name, - NAMEOF_LOCAL_NTE); - - walk_state->local_variables[i].name |= (i << 24); - walk_state->local_variables[i].data_type = ACPI_DESC_TYPE_NAMED; - walk_state->local_variables[i].type = ACPI_TYPE_ANY; - walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_delete_all - * - * PARAMETERS: Walk_state - Current walk state object - * - * RETURN: Status - * - * DESCRIPTION: Delete method locals and arguments. Arguments are only - * deleted if this method was called from another method. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_method_data_delete_all ( - ACPI_WALK_STATE *walk_state) -{ - u32 index; - ACPI_OPERAND_OBJECT *object; - - - /* Delete the locals */ - - for (index = 0; index < MTH_NUM_LOCALS; index++) { - object = walk_state->local_variables[index].object; - if (object) { - /* Remove first */ - - walk_state->local_variables[index].object = NULL; - - /* Was given a ref when stored */ - - acpi_cm_remove_reference (object); - } - } - - - /* Delete the arguments */ - - for (index = 0; index < MTH_NUM_ARGS; index++) { - object = walk_state->arguments[index].object; - if (object) { - /* Remove first */ - - walk_state->arguments[index].object = NULL; - - /* Was given a ref when stored */ - - acpi_cm_remove_reference (object); - } - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_init_args - * - * PARAMETERS: *Params - Pointer to a parameter list for the method - * Max_param_count - The arg count for this method - * Walk_state - Current walk state object - * - * RETURN: Status - * - * DESCRIPTION: Initialize arguments for a method - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_method_data_init_args ( - ACPI_OPERAND_OBJECT **params, - u32 max_param_count, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - u32 mindex; - u32 pindex; - - - if (!params) { - return (AE_OK); - } - - /* Copy passed parameters into the new method stack frame */ - - for (pindex = mindex = 0; - (mindex < MTH_NUM_ARGS) && (pindex < max_param_count); - mindex++) { - if (params[pindex]) { - /* - * A valid parameter. - * Set the current method argument to the - * Params[Pindex++] argument object descriptor - */ - status = acpi_ds_store_object_to_local (AML_ARG_OP, mindex, - params[pindex], walk_state); - if (ACPI_FAILURE (status)) { - break; - } - - pindex++; - } - - else { - break; - } - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_get_entry - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which local_var or argument to get - * Entry - Pointer to where a pointer to the stack - * entry is returned. - * Walk_state - Current walk state object - * - * RETURN: Status - * - * DESCRIPTION: Get the address of the object entry given by Opcode:Index - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_method_data_get_entry ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT ***entry) -{ - - - /* - * Get the requested object. - * The stack "Opcode" is either a Local_variable or an Argument - */ - - switch (opcode) { - - case AML_LOCAL_OP: - - if (index > MTH_MAX_LOCAL) { - return (AE_BAD_PARAMETER); - } - - *entry = (ACPI_OPERAND_OBJECT **) - &walk_state->local_variables[index].object; - break; - - - case AML_ARG_OP: - - if (index > MTH_MAX_ARG) { - return (AE_BAD_PARAMETER); - } - - *entry = (ACPI_OPERAND_OBJECT **) - &walk_state->arguments[index].object; - break; - - - default: - return (AE_BAD_PARAMETER); - } - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_set_entry - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which local_var or argument to get - * Object - Object to be inserted into the stack entry - * Walk_state - Current walk state object - * - * RETURN: Status - * - * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_method_data_set_entry ( - u16 opcode, - u32 index, - ACPI_OPERAND_OBJECT *object, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; - - - /* Get a pointer to the stack entry to set */ - - status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Increment ref count so object can't be deleted while installed */ - - acpi_cm_add_reference (object); - - /* Install the object into the stack entry */ - - *entry = object; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_get_type - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which local_var or argument whose type - * to get - * Walk_state - Current walk state object - * - * RETURN: Data type of selected Arg or Local - * Used only in Exec_monadic2()/Type_op. - * - ******************************************************************************/ - -OBJECT_TYPE_INTERNAL -acpi_ds_method_data_get_type ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; - ACPI_OPERAND_OBJECT *object; - - - /* Get a pointer to the requested stack entry */ - - status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); - if (ACPI_FAILURE (status)) { - return ((ACPI_TYPE_NOT_FOUND)); - } - - /* Get the object from the method stack */ - - object = *entry; - - /* Get the object type */ - - if (!object) { - /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */ - return (ACPI_TYPE_ANY); - } - - return (object->common.type); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_get_node - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which local_var or argument whose type - * to get - * Walk_state - Current walk state object - * - * RETURN: Get the Node associated with a local or arg. - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -acpi_ds_method_data_get_node ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state) -{ - ACPI_NAMESPACE_NODE *node = NULL; - - - switch (opcode) { - - case AML_LOCAL_OP: - - if (index > MTH_MAX_LOCAL) { - return (node); - } - - node = &walk_state->local_variables[index]; - break; - - - case AML_ARG_OP: - - if (index > MTH_MAX_ARG) { - return (node); - } - - node = &walk_state->arguments[index]; - break; - - - default: - break; - } - - - return (node); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_get_value - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which local_var or argument to get - * Walk_state - Current walk state object - * *Dest_desc - Ptr to Descriptor into which selected Arg - * or Local value should be copied - * - * RETURN: Status - * - * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame - * at the current top of the method stack. - * Used only in Acpi_aml_resolve_to_value(). - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_method_data_get_value ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **dest_desc) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; - ACPI_OPERAND_OBJECT *object; - - - /* Validate the object descriptor */ - - if (!dest_desc) { - return (AE_BAD_PARAMETER); - } - - - /* Get a pointer to the requested method stack entry */ - - status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Get the object from the method stack */ - - object = *entry; - - - /* Examine the returned object, it must be valid. */ - - if (!object) { - /* - * Index points to uninitialized object stack value. - * This means that either 1) The expected argument was - * not passed to the method, or 2) A local variable - * was referenced by the method (via the ASL) - * before it was initialized. Either case is an error. - */ - - switch (opcode) { - case AML_ARG_OP: - - return (AE_AML_UNINITIALIZED_ARG); - break; - - case AML_LOCAL_OP: - - return (AE_AML_UNINITIALIZED_LOCAL); - break; - } - } - - - /* - * Index points to initialized and valid object stack value. - * Return an additional reference to the object - */ - - *dest_desc = object; - acpi_cm_add_reference (object); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_method_data_delete_value - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which local_var or argument to delete - * Walk_state - Current walk state object - * - * RETURN: Status - * - * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts - * a null into the stack slot after the object is deleted. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_method_data_delete_value ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; - ACPI_OPERAND_OBJECT *object; - - - /* Get a pointer to the requested entry */ - - status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Get the current entry in this slot k */ - - object = *entry; - - /* - * Undefine the Arg or Local by setting its descriptor - * pointer to NULL. Locals/Args can contain both - * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs - */ - *entry = NULL; - - - if ((object) && - (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL))) { - /* - * There is a valid object in this slot - * Decrement the reference count by one to balance the - * increment when the object was stored in the slot. - */ - acpi_cm_remove_reference (object); - } - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_store_object_to_local - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which local_var or argument to set - * Src_desc - Value to be stored - * Walk_state - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Store a value in an Arg or Local. The Src_desc is installed - * as the new value for the Arg or Local and the reference count - * for Src_desc is incremented. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_store_object_to_local ( - u16 opcode, - u32 index, - ACPI_OPERAND_OBJECT *src_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; - - - /* Parameter validation */ - - if (!src_desc) { - return (AE_BAD_PARAMETER); - } - - - /* Get a pointer to the requested method stack entry */ - - status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - if (*entry == src_desc) { - goto cleanup; - } - - - /* - * If there is an object already in this slot, we either - * have to delete it, or if this is an argument and there - * is an object reference stored there, we have to do - * an indirect store! - */ - - if (*entry) { - /* - * Check for an indirect store if an argument - * contains an object reference (stored as an Node). - * We don't allow this automatic dereferencing for - * locals, since a store to a local should overwrite - * anything there, including an object reference. - * - * If both Arg0 and Local0 contain Ref_of (Local4): - * - * Store (1, Arg0) - Causes indirect store to local4 - * Store (1, Local0) - Stores 1 in local0, overwriting - * the reference to local4 - * Store (1, De_refof (Local0)) - Causes indirect store to local4 - * - * Weird, but true. - */ - - if ((opcode == AML_ARG_OP) && - (VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) { - /* Detach an existing object from the Node */ - - acpi_ns_detach_object ((ACPI_NAMESPACE_NODE *) *entry); - - /* - * Store this object into the Node - * (do the indirect store) - */ - status = acpi_ns_attach_object ((ACPI_NAMESPACE_NODE *) *entry, src_desc, - src_desc->common.type); - return (status); - } - - -#ifdef ACPI_ENABLE_IMPLICIT_CONVERSION - /* - * Perform "Implicit conversion" of the new object to the type of the - * existing object - */ - status = acpi_aml_convert_to_target_type ((*entry)->common.type, &src_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } -#endif - - /* - * Delete the existing object - * before storing the new one - */ - acpi_ds_method_data_delete_value (opcode, index, walk_state); - } - - - /* - * Install the Obj_stack descriptor (*Src_desc) into - * the descriptor for the Arg or Local. - * Install the new object in the stack entry - * (increments the object reference count by one) - */ - status = acpi_ds_method_data_set_entry (opcode, index, src_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* Normal exit */ - - return (AE_OK); - - - /* Error exit */ - -cleanup: - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/dispatcher/dsobject.c b/reactos/drivers/bus/acpi/dispatcher/dsobject.c deleted file mode 100644 index 29f18fa9fb9..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dsobject.c +++ /dev/null @@ -1,636 +0,0 @@ -/****************************************************************************** - * - * Module Name: dsobject - Dispatcher object management routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsobject") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_init_one_object - * - * PARAMETERS: Obj_handle - Node - * Level - Current nesting level - * Context - Points to a init info struct - * Return_value - Not used - * - * RETURN: Status - * - * DESCRIPTION: Callback from Acpi_walk_namespace. Invoked for every object - * within the namespace. - * - * Currently, the only objects that require initialization are: - * 1) Methods - * 2) Op Regions - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_init_one_object ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value) -{ - OBJECT_TYPE_INTERNAL type; - ACPI_STATUS status; - ACPI_INIT_WALK_INFO *info = (ACPI_INIT_WALK_INFO *) context; - u8 table_revision; - - - info->object_count++; - table_revision = info->table_desc->pointer->revision; - - /* - * We are only interested in objects owned by the table that - * was just loaded - */ - - if (((ACPI_NAMESPACE_NODE *) obj_handle)->owner_id != - info->table_desc->table_id) { - return (AE_OK); - } - - - /* And even then, we are only interested in a few object types */ - - type = acpi_ns_get_type (obj_handle); - - switch (type) { - - case ACPI_TYPE_REGION: - - acpi_ds_initialize_region (obj_handle); - - info->op_region_count++; - break; - - - case ACPI_TYPE_METHOD: - - info->method_count++; - - - /* - * Set the execution data width (32 or 64) based upon the - * revision number of the parent ACPI table. - */ - - if (table_revision == 1) { - ((ACPI_NAMESPACE_NODE *)obj_handle)->flags |= ANOBJ_DATA_WIDTH_32; - } - - /* - * Always parse methods to detect errors, we may delete - * the parse tree below - */ - - status = acpi_ds_parse_method (obj_handle); - - /* TBD: [Errors] what do we do with an error? */ - - if (ACPI_FAILURE (status)) { - break; - } - - /* - * Delete the parse tree. We simple re-parse the method - * for every execution since there isn't much overhead - */ - acpi_ns_delete_namespace_subtree (obj_handle); - break; - - default: - break; - } - - /* - * We ignore errors from above, and always return OK, since - * we don't want to abort the walk on a single error. - */ - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_initialize_objects - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Walk the entire namespace and perform any necessary - * initialization on the objects found therein - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_initialize_objects ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMESPACE_NODE *start_node) -{ - ACPI_STATUS status; - ACPI_INIT_WALK_INFO info; - - - info.method_count = 0; - info.op_region_count = 0; - info.object_count = 0; - info.table_desc = table_desc; - - - /* Walk entire namespace from the supplied root */ - - status = acpi_walk_namespace (ACPI_TYPE_ANY, start_node, - ACPI_UINT32_MAX, acpi_ds_init_one_object, - &info, NULL); - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_init_object_from_op - * - * PARAMETERS: Op - Parser op used to init the internal object - * Opcode - AML opcode associated with the object - * Obj_desc - Namespace object to be initialized - * - * RETURN: Status - * - * DESCRIPTION: Initialize a namespace object from a parser Op and its - * associated arguments. The namespace object is a more compact - * representation of the Op and its arguments. - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_init_object_from_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - u16 opcode, - ACPI_OPERAND_OBJECT **obj_desc) -{ - ACPI_STATUS status; - ACPI_PARSE_OBJECT *arg; - ACPI_PARSE2_OBJECT *byte_list; - ACPI_OPERAND_OBJECT *arg_desc; - ACPI_OPCODE_INFO *op_info; - - - op_info = acpi_ps_get_opcode_info (opcode); - if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { - /* Unknown opcode */ - - return (AE_TYPE); - } - - - /* Get and prepare the first argument */ - - switch ((*obj_desc)->common.type) { - case ACPI_TYPE_BUFFER: - - /* First arg is a number */ - - acpi_ds_create_operand (walk_state, op->value.arg, 0); - arg_desc = walk_state->operands [walk_state->num_operands - 1]; - acpi_ds_obj_stack_pop (1, walk_state); - - /* Resolve the object (could be an arg or local) */ - - status = acpi_aml_resolve_to_value (&arg_desc, walk_state); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (arg_desc); - return (status); - } - - /* We are expecting a number */ - - if (arg_desc->common.type != ACPI_TYPE_INTEGER) { - acpi_cm_remove_reference (arg_desc); - return (AE_TYPE); - } - - /* Get the value, delete the internal object */ - - (*obj_desc)->buffer.length = (u32) arg_desc->integer.value; - acpi_cm_remove_reference (arg_desc); - - /* Allocate the buffer */ - - if ((*obj_desc)->buffer.length == 0) { - (*obj_desc)->buffer.pointer = NULL; - REPORT_WARNING (("Buffer created with zero length in AML\n")); - break; - } - - else { - (*obj_desc)->buffer.pointer = - acpi_cm_callocate ((*obj_desc)->buffer.length); - - if (!(*obj_desc)->buffer.pointer) { - return (AE_NO_MEMORY); - } - } - - /* - * Second arg is the buffer data (optional) - * Byte_list can be either individual bytes or a - * string initializer! - */ - - /* skip first arg */ - arg = op->value.arg; - byte_list = (ACPI_PARSE2_OBJECT *) arg->next; - if (byte_list) { - if (byte_list->opcode != AML_BYTELIST_OP) { - return (AE_TYPE); - } - - MEMCPY ((*obj_desc)->buffer.pointer, byte_list->data, - (*obj_desc)->buffer.length); - } - - break; - - - case ACPI_TYPE_PACKAGE: - - /* - * When called, an internal package object has already - * been built and is pointed to by *Obj_desc. - * Acpi_ds_build_internal_object build another internal - * package object, so remove reference to the original - * so that it is deleted. Error checking is done - * within the remove reference function. - */ - acpi_cm_remove_reference(*obj_desc); - - status = acpi_ds_build_internal_object (walk_state, op, obj_desc); - break; - - case ACPI_TYPE_INTEGER: - (*obj_desc)->integer.value = op->value.integer; - break; - - - case ACPI_TYPE_STRING: - (*obj_desc)->string.pointer = op->value.string; - (*obj_desc)->string.length = STRLEN (op->value.string); - break; - - - case ACPI_TYPE_METHOD: - break; - - - case INTERNAL_TYPE_REFERENCE: - - switch (ACPI_GET_OP_CLASS (op_info)) { - case OPTYPE_LOCAL_VARIABLE: - - /* Split the opcode into a base opcode + offset */ - - (*obj_desc)->reference.opcode = AML_LOCAL_OP; - (*obj_desc)->reference.offset = opcode - AML_LOCAL_OP; - break; - - case OPTYPE_METHOD_ARGUMENT: - - /* Split the opcode into a base opcode + offset */ - - (*obj_desc)->reference.opcode = AML_ARG_OP; - (*obj_desc)->reference.offset = opcode - AML_ARG_OP; - break; - - default: /* Constants, Literals, etc.. */ - - if (op->opcode == AML_NAMEPATH_OP) { - /* Node was saved in Op */ - - (*obj_desc)->reference.node = op->node; - } - - (*obj_desc)->reference.opcode = opcode; - break; - } - - break; - - - default: - - break; - } - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_build_internal_simple_obj - * - * PARAMETERS: Op - Parser object to be translated - * Obj_desc_ptr - Where the ACPI internal object is returned - * - * RETURN: Status - * - * DESCRIPTION: Translate a parser Op object to the equivalent namespace object - * Simple objects are any objects other than a package object! - * - ****************************************************************************/ - -static ACPI_STATUS -acpi_ds_build_internal_simple_obj ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - ACPI_OPERAND_OBJECT **obj_desc_ptr) -{ - ACPI_OPERAND_OBJECT *obj_desc; - OBJECT_TYPE_INTERNAL type; - ACPI_STATUS status; - u32 length; - char *name; - - - if (op->opcode == AML_NAMEPATH_OP) { - /* - * This is an object reference. If The name was - * previously looked up in the NS, it is stored in this op. - * Otherwise, go ahead and look it up now - */ - - if (!op->node) { - status = acpi_ns_lookup (walk_state->scope_info, - op->value.string, ACPI_TYPE_ANY, - IMODE_EXECUTE, - NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, - NULL, - (ACPI_NAMESPACE_NODE **)&(op->node)); - - if (ACPI_FAILURE (status)) { - if (status == AE_NOT_FOUND) { - name = NULL; - acpi_ns_externalize_name (ACPI_UINT32_MAX, op->value.string, &length, &name); - - if (name) { - REPORT_WARNING (("Reference %s at AML %X not found\n", - name, op->aml_offset)); - acpi_cm_free (name); - } - else { - REPORT_WARNING (("Reference %s at AML %X not found\n", - op->value.string, op->aml_offset)); - } - *obj_desc_ptr = NULL; - } - - else { - return (status); - } - } - } - - /* - * The reference will be a Reference - * TBD: [Restructure] unless we really need a separate - * type of INTERNAL_TYPE_REFERENCE change - * Acpi_ds_map_opcode_to_data_type to handle this case - */ - type = INTERNAL_TYPE_REFERENCE; - } - else { - type = acpi_ds_map_opcode_to_data_type (op->opcode, NULL); - } - - - /* Create and init the internal ACPI object */ - - obj_desc = acpi_cm_create_internal_object (type); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - status = acpi_ds_init_object_from_op (walk_state, op, - op->opcode, &obj_desc); - - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (obj_desc); - return (status); - } - - *obj_desc_ptr = obj_desc; - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_build_internal_package_obj - * - * PARAMETERS: Op - Parser object to be translated - * Obj_desc_ptr - Where the ACPI internal object is returned - * - * RETURN: Status - * - * DESCRIPTION: Translate a parser Op package object to the equivalent - * namespace object - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_build_internal_package_obj ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - ACPI_OPERAND_OBJECT **obj_desc_ptr) -{ - ACPI_PARSE_OBJECT *arg; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status = AE_OK; - - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_PACKAGE); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - /* The first argument must be the package length */ - - arg = op->value.arg; - obj_desc->package.count = arg->value.integer; - - /* - * Allocate the array of pointers (ptrs to the - * individual objects) Add an extra pointer slot so - * that the list is always null terminated. - */ - - obj_desc->package.elements = - acpi_cm_callocate ((obj_desc->package.count + 1) * - sizeof (void *)); - - if (!obj_desc->package.elements) { - /* Package vector allocation failure */ - - REPORT_ERROR (("Ds_build_internal_package_obj: Package vector allocation failure\n")); - - acpi_cm_delete_object_desc (obj_desc); - return (AE_NO_MEMORY); - } - - obj_desc->package.next_element = obj_desc->package.elements; - - /* - * Now init the elements of the package - */ - - arg = arg->next; - while (arg) { - if (arg->opcode == AML_PACKAGE_OP) { - status = acpi_ds_build_internal_package_obj (walk_state, arg, - obj_desc->package.next_element); - } - - else { - status = acpi_ds_build_internal_simple_obj (walk_state, arg, - obj_desc->package.next_element); - } - - obj_desc->package.next_element++; - arg = arg->next; - } - - *obj_desc_ptr = obj_desc; - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_build_internal_object - * - * PARAMETERS: Op - Parser object to be translated - * Obj_desc_ptr - Where the ACPI internal object is returned - * - * RETURN: Status - * - * DESCRIPTION: Translate a parser Op object to the equivalent namespace - * object - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_build_internal_object ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - ACPI_OPERAND_OBJECT **obj_desc_ptr) -{ - ACPI_STATUS status; - - - if (op->opcode == AML_PACKAGE_OP) { - status = acpi_ds_build_internal_package_obj (walk_state, op, - obj_desc_ptr); - } - - else { - status = acpi_ds_build_internal_simple_obj (walk_state, op, - obj_desc_ptr); - } - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_create_node - * - * PARAMETERS: Op - Parser object to be translated - * Obj_desc_ptr - Where the ACPI internal object is returned - * - * RETURN: Status - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_create_node ( - ACPI_WALK_STATE *walk_state, - ACPI_NAMESPACE_NODE *node, - ACPI_PARSE_OBJECT *op) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - - - if (!op->value.arg) { - /* No arguments, there is nothing to do */ - - return (AE_OK); - } - - - /* Build an internal object for the argument(s) */ - - status = acpi_ds_build_internal_object (walk_state, - op->value.arg, &obj_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* Re-type the object according to it's argument */ - - node->type = obj_desc->common.type; - - /* Init obj */ - - status = acpi_ns_attach_object ((ACPI_HANDLE) node, obj_desc, - (u8) node->type); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - return (status); - - -cleanup: - - acpi_cm_remove_reference (obj_desc); - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/dispatcher/dsopcode.c b/reactos/drivers/bus/acpi/dispatcher/dsopcode.c deleted file mode 100644 index 4a68ef8ac47..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dsopcode.c +++ /dev/null @@ -1,868 +0,0 @@ -/****************************************************************************** - * - * Module Name: dsopcode - Dispatcher Op Region support and handling of - * "control" opcodes - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsopcode") - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_get_field_unit_arguments - * - * PARAMETERS: Obj_desc - A valid Field_unit object - * - * RETURN: Status. - * - * DESCRIPTION: Get Field_unit Buffer and Index. This implements the late - * evaluation of these field attributes. - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_get_field_unit_arguments ( - ACPI_OPERAND_OBJECT *obj_desc) -{ - ACPI_OPERAND_OBJECT *extra_desc; - ACPI_NAMESPACE_NODE *node; - ACPI_PARSE_OBJECT *op; - ACPI_PARSE_OBJECT *field_op; - ACPI_STATUS status; - ACPI_TABLE_DESC *table_desc; - - - if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - return (AE_OK); - } - - - /* Get the AML pointer (method object) and Field_unit node */ - - extra_desc = obj_desc->field_unit.extra; - node = obj_desc->field_unit.node; - - /* - * Allocate a new parser op to be the root of the parsed - * Op_region tree - */ - - op = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - /* Save the Node for use in Acpi_ps_parse_aml */ - - op->node = acpi_ns_get_parent_object (node); - - /* Get a handle to the parent ACPI table */ - - status = acpi_tb_handle_to_object (node->owner_id, &table_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Pass1: Parse the entire Field_unit declaration */ - - status = acpi_ps_parse_aml (op, extra_desc->extra.pcode, - extra_desc->extra.pcode_length, 0, - NULL, NULL, NULL, acpi_ds_load1_begin_op, acpi_ds_load1_end_op); - if (ACPI_FAILURE (status)) { - acpi_ps_delete_parse_tree (op); - return (status); - } - - - /* Get and init the actual Fiel_unit_op created above */ - - field_op = op->value.arg; - op->node = node; - - - field_op = op->value.arg; - field_op->node = node; - acpi_ps_delete_parse_tree (op); - - /* Acpi_evaluate the address and length arguments for the Op_region */ - - op = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - op->node = acpi_ns_get_parent_object (node); - - status = acpi_ps_parse_aml (op, extra_desc->extra.pcode, - extra_desc->extra.pcode_length, - ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, - NULL /*Method_desc*/, NULL, NULL, - acpi_ds_exec_begin_op, acpi_ds_exec_end_op); - /* All done with the parse tree, delete it */ - - acpi_ps_delete_parse_tree (op); - - - /* - * The pseudo-method object is no longer needed since the region is - * now initialized - */ - acpi_cm_remove_reference (obj_desc->field_unit.extra); - obj_desc->field_unit.extra = NULL; - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_get_region_arguments - * - * PARAMETERS: Obj_desc - A valid region object - * - * RETURN: Status. - * - * DESCRIPTION: Get region address and length. This implements the late - * evaluation of these region attributes. - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_get_region_arguments ( - ACPI_OPERAND_OBJECT *obj_desc) -{ - ACPI_OPERAND_OBJECT *extra_desc = NULL; - ACPI_NAMESPACE_NODE *node; - ACPI_PARSE_OBJECT *op; - ACPI_PARSE_OBJECT *region_op; - ACPI_STATUS status; - ACPI_TABLE_DESC *table_desc; - - - if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { - return (AE_OK); - } - - - /* Get the AML pointer (method object) and region node */ - - extra_desc = obj_desc->region.extra; - node = obj_desc->region.node; - - /* - * Allocate a new parser op to be the root of the parsed - * Op_region tree - */ - - op = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - /* Save the Node for use in Acpi_ps_parse_aml */ - - op->node = acpi_ns_get_parent_object (node); - - /* Get a handle to the parent ACPI table */ - - status = acpi_tb_handle_to_object (node->owner_id, &table_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Parse the entire Op_region declaration, creating a parse tree */ - - status = acpi_ps_parse_aml (op, extra_desc->extra.pcode, - extra_desc->extra.pcode_length, 0, - NULL, NULL, NULL, acpi_ds_load1_begin_op, acpi_ds_load1_end_op); - - if (ACPI_FAILURE (status)) { - acpi_ps_delete_parse_tree (op); - return (status); - } - - - /* Get and init the actual Region_op created above */ - - region_op = op->value.arg; - op->node = node; - - - region_op = op->value.arg; - region_op->node = node; - acpi_ps_delete_parse_tree (op); - - /* Acpi_evaluate the address and length arguments for the Op_region */ - - op = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - op->node = acpi_ns_get_parent_object (node); - - status = acpi_ps_parse_aml (op, extra_desc->extra.pcode, - extra_desc->extra.pcode_length, - ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, - NULL /*Method_desc*/, NULL, NULL, - acpi_ds_exec_begin_op, acpi_ds_exec_end_op); - - /* All done with the parse tree, delete it */ - - acpi_ps_delete_parse_tree (op); - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_initialize_region - * - * PARAMETERS: Op - A valid region Op object - * - * RETURN: Status - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_initialize_region ( - ACPI_HANDLE obj_handle) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - obj_desc = acpi_ns_get_attached_object (obj_handle); - - /* Namespace is NOT locked */ - - status = acpi_ev_initialize_region (obj_desc, FALSE); - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_eval_field_unit_operands - * - * PARAMETERS: Op - A valid Field_unit Op object - * - * RETURN: Status - * - * DESCRIPTION: Get Field_unit Buffer and Index - * Called from Acpi_ds_exec_end_op during Field_unit parse tree walk - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_eval_field_unit_operands ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *field_desc; - ACPI_NAMESPACE_NODE *node; - ACPI_PARSE_OBJECT *next_op; - u32 offset; - u32 bit_offset; - u16 bit_count; - - - ACPI_OPERAND_OBJECT *res_desc = NULL; - ACPI_OPERAND_OBJECT *cnt_desc = NULL; - ACPI_OPERAND_OBJECT *off_desc = NULL; - ACPI_OPERAND_OBJECT *src_desc = NULL; - u32 num_operands = 3; - - - /* - * This is where we evaluate the address and length fields of the Op_field_unit declaration - */ - - node = op->node; - - /* Next_op points to the op that holds the Buffer */ - next_op = op->value.arg; - - /* Acpi_evaluate/create the address and length operands */ - - status = acpi_ds_create_operands (walk_state, next_op); - if (ACPI_FAILURE (status)) { - return (status); - } - - field_desc = acpi_ns_get_attached_object (node); - if (!field_desc) { - return (AE_NOT_EXIST); - } - - - /* Resolve the operands */ - - status = acpi_aml_resolve_operands (op->opcode, WALK_OPERANDS, walk_state); - - /* Get the operands */ - - status |= acpi_ds_obj_stack_pop_object (&res_desc, walk_state); - if (AML_CREATE_FIELD_OP == op->opcode) { - num_operands = 4; - status |= acpi_ds_obj_stack_pop_object (&cnt_desc, walk_state); - } - - status |= acpi_ds_obj_stack_pop_object (&off_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&src_desc, walk_state); - - if (ACPI_FAILURE (status)) { - /* Invalid parameters on object stack */ - - goto cleanup; - } - - - offset = (u32) off_desc->integer.value; - - - /* - * If Res_desc is a Name, it will be a direct name pointer after - * Acpi_aml_resolve_operands() - */ - - if (!VALID_DESCRIPTOR_TYPE (res_desc, ACPI_DESC_TYPE_NAMED)) { - status = AE_AML_OPERAND_TYPE; - goto cleanup; - } - - - /* - * Setup the Bit offsets and counts, according to the opcode - */ - - switch (op->opcode) { - - /* Def_create_bit_field */ - - case AML_BIT_FIELD_OP: - - /* Offset is in bits, Field is a bit */ - - bit_offset = offset; - bit_count = 1; - break; - - - /* Def_create_byte_field */ - - case AML_BYTE_FIELD_OP: - - /* Offset is in bytes, field is a byte */ - - bit_offset = 8 * offset; - bit_count = 8; - break; - - - /* Def_create_word_field */ - - case AML_WORD_FIELD_OP: - - /* Offset is in bytes, field is a word */ - - bit_offset = 8 * offset; - bit_count = 16; - break; - - - /* Def_create_dWord_field */ - - case AML_DWORD_FIELD_OP: - - /* Offset is in bytes, field is a dword */ - - bit_offset = 8 * offset; - bit_count = 32; - break; - - - /* Def_create_field */ - - case AML_CREATE_FIELD_OP: - - /* Offset is in bits, count is in bits */ - - bit_offset = offset; - bit_count = (u16) cnt_desc->integer.value; - break; - - - default: - - status = AE_AML_BAD_OPCODE; - goto cleanup; - } - - - /* - * Setup field according to the object type - */ - - switch (src_desc->common.type) { - - /* Source_buff := Term_arg=>Buffer */ - - case ACPI_TYPE_BUFFER: - - if (bit_offset + (u32) bit_count > - (8 * (u32) src_desc->buffer.length)) { - status = AE_AML_BUFFER_LIMIT; - goto cleanup; - } - - - /* Construct the remainder of the field object */ - - field_desc->field_unit.access = (u8) ACCESS_ANY_ACC; - field_desc->field_unit.lock_rule = (u8) GLOCK_NEVER_LOCK; - field_desc->field_unit.update_rule = (u8) UPDATE_PRESERVE; - field_desc->field_unit.length = bit_count; - field_desc->field_unit.bit_offset = (u8) (bit_offset % 8); - field_desc->field_unit.offset = DIV_8 (bit_offset); - field_desc->field_unit.container = src_desc; - - /* Reference count for Src_desc inherits Field_desc count */ - - src_desc->common.reference_count = (u16) (src_desc->common.reference_count + - field_desc->common.reference_count); - - break; - - - /* Improper object type */ - - default: - - - - status = AE_AML_OPERAND_TYPE; - goto cleanup; - } - - - if (AML_CREATE_FIELD_OP == op->opcode) { - /* Delete object descriptor unique to Create_field */ - - acpi_cm_remove_reference (cnt_desc); - cnt_desc = NULL; - } - - -cleanup: - - /* Always delete the operands */ - - acpi_cm_remove_reference (off_desc); - acpi_cm_remove_reference (src_desc); - - if (AML_CREATE_FIELD_OP == op->opcode) { - acpi_cm_remove_reference (cnt_desc); - } - - /* On failure, delete the result descriptor */ - - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (res_desc); /* Result descriptor */ - } - - else { - /* Now the address and length are valid for this op_field_unit */ - - field_desc->field_unit.flags |= AOPOBJ_DATA_VALID; - } - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_eval_region_operands - * - * PARAMETERS: Op - A valid region Op object - * - * RETURN: Status - * - * DESCRIPTION: Get region address and length - * Called from Acpi_ds_exec_end_op during Op_region parse tree walk - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_eval_region_operands ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *operand_desc; - ACPI_NAMESPACE_NODE *node; - ACPI_PARSE_OBJECT *next_op; - - - /* - * This is where we evaluate the address and length fields of the Op_region declaration - */ - - node = op->node; - - /* Next_op points to the op that holds the Space_iD */ - next_op = op->value.arg; - - /* Next_op points to address op */ - next_op = next_op->next; - - /* Acpi_evaluate/create the address and length operands */ - - status = acpi_ds_create_operands (walk_state, next_op); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Resolve the length and address operands to numbers */ - - status = acpi_aml_resolve_operands (op->opcode, WALK_OPERANDS, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - - obj_desc = acpi_ns_get_attached_object (node); - if (!obj_desc) { - return (AE_NOT_EXIST); - } - - /* - * Get the length operand and save it - * (at Top of stack) - */ - operand_desc = walk_state->operands[walk_state->num_operands - 1]; - - obj_desc->region.length = (u32) operand_desc->integer.value; - acpi_cm_remove_reference (operand_desc); - - /* - * Get the address and save it - * (at top of stack - 1) - */ - operand_desc = walk_state->operands[walk_state->num_operands - 2]; - - obj_desc->region.address = (ACPI_PHYSICAL_ADDRESS) operand_desc->integer.value; - acpi_cm_remove_reference (operand_desc); - - - /* Now the address and length are valid for this opregion */ - - obj_desc->region.flags |= AOPOBJ_DATA_VALID; - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_exec_begin_control_op - * - * PARAMETERS: Walk_list - The list that owns the walk stack - * Op - The control Op - * - * RETURN: Status - * - * DESCRIPTION: Handles all control ops encountered during control method - * execution. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_exec_begin_control_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op) -{ - ACPI_STATUS status = AE_OK; - ACPI_GENERIC_STATE *control_state; - - - switch (op->opcode) { - case AML_IF_OP: - case AML_WHILE_OP: - - /* - * IF/WHILE: Create a new control state to manage these - * constructs. We need to manage these as a stack, in order - * to handle nesting. - */ - - control_state = acpi_cm_create_control_state (); - if (!control_state) { - status = AE_NO_MEMORY; - break; - } - - acpi_cm_push_generic_state (&walk_state->control_state, control_state); - - /* - * Save a pointer to the predicate for multiple executions - * of a loop - */ - walk_state->control_state->control.aml_predicate_start = - walk_state->parser_state->aml - 1; - /* TBD: can this be removed? */ - /*Acpi_ps_pkg_length_encoding_size (GET8 (Walk_state->Parser_state->Aml));*/ - break; - - - case AML_ELSE_OP: - - /* Predicate is in the state object */ - /* If predicate is true, the IF was executed, ignore ELSE part */ - - if (walk_state->last_predicate) { - status = AE_CTRL_TRUE; - } - - break; - - - case AML_RETURN_OP: - - break; - - - default: - break; - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_exec_end_control_op - * - * PARAMETERS: Walk_list - The list that owns the walk stack - * Op - The control Op - * - * RETURN: Status - * - * DESCRIPTION: Handles all control ops encountered during control method - * execution. - * - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_exec_end_control_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op) -{ - ACPI_STATUS status = AE_OK; - ACPI_GENERIC_STATE *control_state; - - - switch (op->opcode) { - case AML_IF_OP: - - /* - * Save the result of the predicate in case there is an - * ELSE to come - */ - - walk_state->last_predicate = - (u8) walk_state->control_state->common.value; - - /* - * Pop the control state that was created at the start - * of the IF and free it - */ - - control_state = - acpi_cm_pop_generic_state (&walk_state->control_state); - - acpi_cm_delete_generic_state (control_state); - - break; - - - case AML_ELSE_OP: - - break; - - - case AML_WHILE_OP: - - if (walk_state->control_state->common.value) { - /* Predicate was true, go back and evaluate it again! */ - - status = AE_CTRL_PENDING; - } - - - /* Pop this control state and free it */ - - control_state = - acpi_cm_pop_generic_state (&walk_state->control_state); - - walk_state->aml_last_while = control_state->control.aml_predicate_start; - acpi_cm_delete_generic_state (control_state); - - break; - - - case AML_RETURN_OP: - - - /* - * One optional operand -- the return value - * It can be either an immediate operand or a result that - * has been bubbled up the tree - */ - if (op->value.arg) { - /* Return statement has an immediate operand */ - - status = acpi_ds_create_operands (walk_state, op->value.arg); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * If value being returned is a Reference (such as - * an arg or local), resolve it now because it may - * cease to exist at the end of the method. - */ - status = acpi_aml_resolve_to_value (&walk_state->operands [0], walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Get the return value and save as the last result - * value. This is the only place where Walk_state->Return_desc - * is set to anything other than zero! - */ - - walk_state->return_desc = walk_state->operands[0]; - } - - else if ((walk_state->results) && - (walk_state->results->results.num_results > 0)) { - /* - * The return value has come from a previous calculation. - * - * If value being returned is a Reference (such as - * an arg or local), resolve it now because it may - * cease to exist at the end of the method. - * - * Allow references created by the Index operator to return unchanged. - */ - - if (VALID_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc [0], ACPI_DESC_TYPE_INTERNAL) && - ((walk_state->results->results.obj_desc [0])->common.type == INTERNAL_TYPE_REFERENCE) && - ((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) { - status = acpi_aml_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - walk_state->return_desc = walk_state->results->results.obj_desc [0]; - } - - else { - /* No return operand */ - - if (walk_state->num_operands) { - acpi_cm_remove_reference (walk_state->operands [0]); - } - - walk_state->operands [0] = NULL; - walk_state->num_operands = 0; - walk_state->return_desc = NULL; - } - - - /* End the control method execution right now */ - status = AE_CTRL_TERMINATE; - break; - - - case AML_NOOP_OP: - - /* Just do nothing! */ - break; - - - case AML_BREAK_POINT_OP: - - /* Call up to the OS dependent layer to handle this */ - - acpi_os_breakpoint (NULL); - - /* If it returns, we are done! */ - - break; - - - case AML_BREAK_OP: - - /* - * As per the ACPI specification: - * "The break operation causes the current package - * execution to complete" - * "Break -- Stop executing the current code package - * at this point" - * - * Returning AE_FALSE here will cause termination of - * the current package, and execution will continue one - * level up, starting with the completion of the parent Op. - */ - - status = AE_CTRL_FALSE; - break; - - - default: - - status = AE_AML_BAD_OPCODE; - break; - } - - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/dispatcher/dsutils.c b/reactos/drivers/bus/acpi/dispatcher/dsutils.c deleted file mode 100644 index c87469493aa..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dsutils.c +++ /dev/null @@ -1,744 +0,0 @@ -/******************************************************************************* - * - * Module Name: dsutils - Dispatcher utilities - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsutils") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_is_result_used - * - * PARAMETERS: Op - * Result_obj - * Walk_state - * - * RETURN: Status - * - * DESCRIPTION: Check if a result object will be used by the parent - * - ******************************************************************************/ - -u8 -acpi_ds_is_result_used ( - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPCODE_INFO *parent_info; - - - /* Must have both an Op and a Result Object */ - - if (!op) { - return (TRUE); - } - - - /* - * If there is no parent, the result can't possibly be used! - * (An executing method typically has no parent, since each - * method is parsed separately) However, a method that is - * invoked from another method has a parent. - */ - if (!op->parent) { - return (FALSE); - } - - - /* - * Get info on the parent. The root Op is AML_SCOPE - */ - - parent_info = acpi_ps_get_opcode_info (op->parent->opcode); - if (ACPI_GET_OP_TYPE (parent_info) != ACPI_OP_TYPE_OPCODE) { - return (FALSE); - } - - - /* - * Decide what to do with the result based on the parent. If - * the parent opcode will not use the result, delete the object. - * Otherwise leave it as is, it will be deleted when it is used - * as an operand later. - */ - - switch (ACPI_GET_OP_CLASS (parent_info)) { - /* - * In these cases, the parent will never use the return object - */ - case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ - - switch (op->parent->opcode) { - case AML_RETURN_OP: - - /* Never delete the return value associated with a return opcode */ - - return (TRUE); - break; - - case AML_IF_OP: - case AML_WHILE_OP: - - /* - * If we are executing the predicate AND this is the predicate op, - * we will use the return value! - */ - - if ((walk_state->control_state->common.state == CONTROL_PREDICATE_EXECUTING) && - (walk_state->control_state->control.predicate_op == op)) { - return (TRUE); - } - - break; - } - - - /* Fall through to not used case below */ - - - case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ - - /* - * These opcodes allow Term_arg(s) as operands and therefore - * method calls. The result is used. - */ - if ((op->parent->opcode == AML_REGION_OP) || - (op->parent->opcode == AML_CREATE_FIELD_OP) || - (op->parent->opcode == AML_BIT_FIELD_OP) || - (op->parent->opcode == AML_BYTE_FIELD_OP) || - (op->parent->opcode == AML_WORD_FIELD_OP) || - (op->parent->opcode == AML_DWORD_FIELD_OP) || - (op->parent->opcode == AML_QWORD_FIELD_OP)) { - return (TRUE); - } - - return (FALSE); - break; - - /* - * In all other cases. the parent will actually use the return - * object, so keep it. - */ - default: - break; - } - - return (TRUE); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_delete_result_if_not_used - * - * PARAMETERS: Op - * Result_obj - * Walk_state - * - * RETURN: Status - * - * DESCRIPTION: Used after interpretation of an opcode. If there is an internal - * result descriptor, check if the parent opcode will actually use - * this result. If not, delete the result now so that it will - * not become orphaned. - * - ******************************************************************************/ - -void -acpi_ds_delete_result_if_not_used ( - ACPI_PARSE_OBJECT *op, - ACPI_OPERAND_OBJECT *result_obj, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - if (!op) { - return; - } - - if (!result_obj) { - return; - } - - - if (!acpi_ds_is_result_used (op, walk_state)) { - /* - * Must pop the result stack (Obj_desc should be equal - * to Result_obj) - */ - - status = acpi_ds_result_pop (&obj_desc, walk_state); - if (ACPI_SUCCESS (status)) { - acpi_cm_remove_reference (result_obj); - } - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_create_operand - * - * PARAMETERS: Walk_state - * Arg - * - * RETURN: Status - * - * DESCRIPTION: Translate a parse tree object that is an argument to an AML - * opcode to the equivalent interpreter object. This may include - * looking up a name or entering a new name into the internal - * namespace. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_create_operand ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *arg, - u32 arg_index) -{ - ACPI_STATUS status = AE_OK; - NATIVE_CHAR *name_string; - u32 name_length; - OBJECT_TYPE_INTERNAL data_type; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_PARSE_OBJECT *parent_op; - u16 opcode; - u32 flags = 0; - OPERATING_MODE interpreter_mode; - - - /* A valid name must be looked up in the namespace */ - - if ((arg->opcode == AML_NAMEPATH_OP) && - (arg->value.string)) { - /* Get the entire name string from the AML stream */ - - status = acpi_aml_get_name_string (ACPI_TYPE_ANY, - arg->value.buffer, - &name_string, - &name_length); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * All prefixes have been handled, and the name is - * in Name_string - */ - - /* - * Differentiate between a namespace "create" operation - * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. - * IMODE_EXECUTE) in order to support the creation of - * namespace objects during the execution of control methods. - */ - - parent_op = arg->parent; - if ((acpi_ps_is_node_op (parent_op->opcode)) && - (parent_op->opcode != AML_METHODCALL_OP) && - (parent_op->opcode != AML_REGION_OP) && - (parent_op->opcode != AML_NAMEPATH_OP)) { - /* Enter name into namespace if not found */ - - interpreter_mode = IMODE_LOAD_PASS2; - } - - else { - /* Return a failure if name not found */ - - interpreter_mode = IMODE_EXECUTE; - } - - status = acpi_ns_lookup (walk_state->scope_info, name_string, - ACPI_TYPE_ANY, interpreter_mode, - NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, - walk_state, - (ACPI_NAMESPACE_NODE **) &obj_desc); - - /* Free the namestring created above */ - - acpi_cm_free (name_string); - - /* - * The only case where we pass through (ignore) a NOT_FOUND - * error is for the Cond_ref_of opcode. - */ - - if (status == AE_NOT_FOUND) { - if (parent_op->opcode == AML_COND_REF_OF_OP) { - /* - * For the Conditional Reference op, it's OK if - * the name is not found; We just need a way to - * indicate this to the interpreter, set the - * object to the root - */ - obj_desc = (ACPI_OPERAND_OBJECT *) acpi_gbl_root_node; - status = AE_OK; - } - - else { - /* - * We just plain didn't find it -- which is a - * very serious error at this point - */ - status = AE_AML_NAME_NOT_FOUND; - } - } - - /* Check status from the lookup */ - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Put the resulting object onto the current object stack */ - - status = acpi_ds_obj_stack_push (obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state)); - } - - - else { - /* Check for null name case */ - - if (arg->opcode == AML_NAMEPATH_OP) { - /* - * If the name is null, this means that this is an - * optional result parameter that was not specified - * in the original ASL. Create an Reference for a - * placeholder - */ - opcode = AML_ZERO_OP; /* Has no arguments! */ - - /* - * TBD: [Investigate] anything else needed for the - * zero op lvalue? - */ - } - - else { - opcode = arg->opcode; - } - - - /* Get the data type of the argument */ - - data_type = acpi_ds_map_opcode_to_data_type (opcode, &flags); - if (data_type == INTERNAL_TYPE_INVALID) { - return (AE_NOT_IMPLEMENTED); - } - - if (flags & OP_HAS_RETURN_VALUE) { - DEBUGGER_EXEC (acpi_db_display_argument_object (walk_state->operands [walk_state->num_operands - 1], walk_state)); - - /* - * Use value that was already previously returned - * by the evaluation of this argument - */ - - status = acpi_ds_result_pop_from_bottom (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - /* - * Only error is underflow, and this indicates - * a missing or null operand! - */ - return (status); - } - - } - - else { - /* Create an ACPI_INTERNAL_OBJECT for the argument */ - - obj_desc = acpi_cm_create_internal_object (data_type); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - /* Initialize the new object */ - - status = acpi_ds_init_object_from_op (walk_state, arg, - opcode, &obj_desc); - if (ACPI_FAILURE (status)) { - acpi_cm_delete_object_desc (obj_desc); - return (status); - } - } - - /* Put the operand object on the object stack */ - - status = acpi_ds_obj_stack_push (obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state)); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_create_operands - * - * PARAMETERS: First_arg - First argument of a parser argument tree - * - * RETURN: Status - * - * DESCRIPTION: Convert an operator's arguments from a parse tree format to - * namespace objects and place those argument object on the object - * stack in preparation for evaluation by the interpreter. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_create_operands ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *first_arg) -{ - ACPI_STATUS status = AE_OK; - ACPI_PARSE_OBJECT *arg; - u32 arg_count = 0; - - - /* For all arguments in the list... */ - - arg = first_arg; - while (arg) { - status = acpi_ds_create_operand (walk_state, arg, arg_count); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* Move on to next argument, if any */ - - arg = arg->next; - arg_count++; - } - - return (status); - - -cleanup: - /* - * We must undo everything done above; meaning that we must - * pop everything off of the operand stack and delete those - * objects - */ - - acpi_ds_obj_stack_pop_and_delete (arg_count, walk_state); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_resolve_operands - * - * PARAMETERS: Walk_state - Current walk state with operands on stack - * - * RETURN: Status - * - * DESCRIPTION: Resolve all operands to their values. Used to prepare - * arguments to a control method invocation (a call from one - * method to another.) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_resolve_operands ( - ACPI_WALK_STATE *walk_state) -{ - u32 i; - ACPI_STATUS status = AE_OK; - - - /* - * Attempt to resolve each of the valid operands - * Method arguments are passed by value, not by reference - */ - - /* - * TBD: [Investigate] Note from previous parser: - * Ref_of problem with Acpi_aml_resolve_to_value() conversion. - */ - - for (i = 0; i < walk_state->num_operands; i++) { - status = acpi_aml_resolve_to_value (&walk_state->operands[i], walk_state); - if (ACPI_FAILURE (status)) { - break; - } - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_map_opcode_to_data_type - * - * PARAMETERS: Opcode - AML opcode to map - * Out_flags - Additional info about the opcode - * - * RETURN: The ACPI type associated with the opcode - * - * DESCRIPTION: Convert a raw AML opcode to the associated ACPI data type, - * if any. If the opcode returns a value as part of the - * intepreter execution, a flag is returned in Out_flags. - * - ******************************************************************************/ - -OBJECT_TYPE_INTERNAL -acpi_ds_map_opcode_to_data_type ( - u16 opcode, - u32 *out_flags) -{ - OBJECT_TYPE_INTERNAL data_type = INTERNAL_TYPE_INVALID; - ACPI_OPCODE_INFO *op_info; - u32 flags = 0; - - - op_info = acpi_ps_get_opcode_info (opcode); - if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { - /* Unknown opcode */ - - return (data_type); - } - - switch (ACPI_GET_OP_CLASS (op_info)) { - - case OPTYPE_LITERAL: - - switch (opcode) { - case AML_BYTE_OP: - case AML_WORD_OP: - case AML_DWORD_OP: - - data_type = ACPI_TYPE_INTEGER; - break; - - - case AML_STRING_OP: - - data_type = ACPI_TYPE_STRING; - break; - - case AML_NAMEPATH_OP: - data_type = INTERNAL_TYPE_REFERENCE; - break; - - default: - break; - } - break; - - - case OPTYPE_DATA_TERM: - - switch (opcode) { - case AML_BUFFER_OP: - - data_type = ACPI_TYPE_BUFFER; - break; - - case AML_PACKAGE_OP: - - data_type = ACPI_TYPE_PACKAGE; - break; - - default: - break; - } - break; - - - case OPTYPE_CONSTANT: - case OPTYPE_METHOD_ARGUMENT: - case OPTYPE_LOCAL_VARIABLE: - - data_type = INTERNAL_TYPE_REFERENCE; - break; - - - case OPTYPE_MONADIC2: - case OPTYPE_MONADIC2_r: - case OPTYPE_DYADIC2: - case OPTYPE_DYADIC2_r: - case OPTYPE_DYADIC2_s: - case OPTYPE_INDEX: - case OPTYPE_MATCH: - case OPTYPE_RETURN: - - flags = OP_HAS_RETURN_VALUE; - data_type = ACPI_TYPE_ANY; - break; - - case OPTYPE_METHOD_CALL: - - flags = OP_HAS_RETURN_VALUE; - data_type = ACPI_TYPE_METHOD; - break; - - - case OPTYPE_NAMED_OBJECT: - - data_type = acpi_ds_map_named_opcode_to_data_type (opcode); - break; - - - case OPTYPE_DYADIC1: - case OPTYPE_CONTROL: - - /* No mapping needed at this time */ - - break; - - - default: - - break; - } - - /* Return flags to caller if requested */ - - if (out_flags) { - *out_flags = flags; - } - - return (data_type); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_map_named_opcode_to_data_type - * - * PARAMETERS: Opcode - The Named AML opcode to map - * - * RETURN: The ACPI type associated with the named opcode - * - * DESCRIPTION: Convert a raw Named AML opcode to the associated data type. - * Named opcodes are a subsystem of the AML opcodes. - * - ******************************************************************************/ - -OBJECT_TYPE_INTERNAL -acpi_ds_map_named_opcode_to_data_type ( - u16 opcode) -{ - OBJECT_TYPE_INTERNAL data_type; - - - /* Decode Opcode */ - - switch (opcode) { - case AML_SCOPE_OP: - data_type = INTERNAL_TYPE_SCOPE; - break; - - case AML_DEVICE_OP: - data_type = ACPI_TYPE_DEVICE; - break; - - case AML_THERMAL_ZONE_OP: - data_type = ACPI_TYPE_THERMAL; - break; - - case AML_METHOD_OP: - data_type = ACPI_TYPE_METHOD; - break; - - case AML_POWER_RES_OP: - data_type = ACPI_TYPE_POWER; - break; - - case AML_PROCESSOR_OP: - data_type = ACPI_TYPE_PROCESSOR; - break; - - case AML_DEF_FIELD_OP: /* Def_field_op */ - data_type = INTERNAL_TYPE_DEF_FIELD_DEFN; - break; - - case AML_INDEX_FIELD_OP: /* Index_field_op */ - data_type = INTERNAL_TYPE_INDEX_FIELD_DEFN; - break; - - case AML_BANK_FIELD_OP: /* Bank_field_op */ - data_type = INTERNAL_TYPE_BANK_FIELD_DEFN; - break; - - case AML_NAMEDFIELD_OP: /* NO CASE IN ORIGINAL */ - data_type = ACPI_TYPE_ANY; - break; - - case AML_NAME_OP: /* Name_op - special code in original */ - case AML_NAMEPATH_OP: - data_type = ACPI_TYPE_ANY; - break; - - case AML_ALIAS_OP: - data_type = INTERNAL_TYPE_ALIAS; - break; - - case AML_MUTEX_OP: - data_type = ACPI_TYPE_MUTEX; - break; - - case AML_EVENT_OP: - data_type = ACPI_TYPE_EVENT; - break; - - case AML_REGION_OP: - data_type = ACPI_TYPE_REGION; - break; - - - default: - data_type = ACPI_TYPE_ANY; - break; - - } - - return (data_type); -} - - diff --git a/reactos/drivers/bus/acpi/dispatcher/dswexec.c b/reactos/drivers/bus/acpi/dispatcher/dswexec.c deleted file mode 100644 index b114cf9a800..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dswexec.c +++ /dev/null @@ -1,646 +0,0 @@ -/****************************************************************************** - * - * Module Name: dswexec - Dispatcher method execution callbacks; - * dispatch to interpreter. - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dswexec") - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_get_predicate_value - * - * PARAMETERS: Walk_state - Current state of the parse tree walk - * - * RETURN: Status - * - * DESCRIPTION: Get the result of a predicate evaluation - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_get_predicate_value ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - u32 has_result_obj) -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *obj_desc; - - - walk_state->control_state->common.state = 0; - - if (has_result_obj) { - status = acpi_ds_result_pop (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - else { - status = acpi_ds_create_operand (walk_state, op, 0); - if (ACPI_FAILURE (status)) { - return (status); - } - - status = acpi_aml_resolve_to_value (&walk_state->operands [0], walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - obj_desc = walk_state->operands [0]; - } - - if (!obj_desc) { - return (AE_AML_NO_OPERAND); - } - - - /* - * Result of predicate evaluation currently must - * be a number - */ - - if (obj_desc->common.type != ACPI_TYPE_INTEGER) { - status = AE_AML_OPERAND_TYPE; - goto cleanup; - } - - - /* Truncate the predicate to 32-bits if necessary */ - - acpi_aml_truncate_for32bit_table (obj_desc, walk_state); - - /* - * Save the result of the predicate evaluation on - * the control stack - */ - - if (obj_desc->integer.value) { - walk_state->control_state->common.value = TRUE; - } - - else { - /* - * Predicate is FALSE, we will just toss the - * rest of the package - */ - - walk_state->control_state->common.value = FALSE; - status = AE_CTRL_FALSE; - } - - -cleanup: - - /* Break to debugger to display result */ - - DEBUGGER_EXEC (acpi_db_display_result_object (obj_desc, walk_state)); - - /* - * Delete the predicate result object (we know that - * we don't need it anymore) - */ - - acpi_cm_remove_reference (obj_desc); - - walk_state->control_state->common.state = CONTROL_NORMAL; - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_exec_begin_op - * - * PARAMETERS: Walk_state - Current state of the parse tree walk - * Op - Op that has been just been reached in the - * walk; Arguments have not been evaluated yet. - * - * RETURN: Status - * - * DESCRIPTION: Descending callback used during the execution of control - * methods. This is where most operators and operands are - * dispatched to the interpreter. - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_exec_begin_op ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op) -{ - ACPI_OPCODE_INFO *op_info; - ACPI_STATUS status = AE_OK; - - - if (!op) { - status = acpi_ds_load2_begin_op (opcode, NULL, walk_state, out_op); - if (ACPI_FAILURE (status)) { - return (status); - } - - op = *out_op; - } - - if (op == walk_state->origin) { - if (out_op) { - *out_op = op; - } - - return (AE_OK); - } - - /* - * If the previous opcode was a conditional, this opcode - * must be the beginning of the associated predicate. - * Save this knowledge in the current scope descriptor - */ - - if ((walk_state->control_state) && - (walk_state->control_state->common.state == - CONTROL_CONDITIONAL_EXECUTING)) { - walk_state->control_state->common.state = CONTROL_PREDICATE_EXECUTING; - - /* Save start of predicate */ - - walk_state->control_state->control.predicate_op = op; - } - - - op_info = acpi_ps_get_opcode_info (op->opcode); - - /* We want to send namepaths to the load code */ - - if (op->opcode == AML_NAMEPATH_OP) { - op_info->flags = OPTYPE_NAMED_OBJECT; - } - - - /* - * Handle the opcode based upon the opcode type - */ - - switch (ACPI_GET_OP_CLASS (op_info)) { - case OPTYPE_CONTROL: - - status = acpi_ds_result_stack_push (walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - status = acpi_ds_exec_begin_control_op (walk_state, op); - break; - - - case OPTYPE_NAMED_OBJECT: - - if (walk_state->walk_type == WALK_METHOD) { - /* - * Found a named object declaration during method - * execution; we must enter this object into the - * namespace. The created object is temporary and - * will be deleted upon completion of the execution - * of this method. - */ - - status = acpi_ds_load2_begin_op (op->opcode, op, walk_state, NULL); - } - - - if (op->opcode == AML_REGION_OP) { - status = acpi_ds_result_stack_push (walk_state); - } - - break; - - - /* most operators with arguments */ - - case OPTYPE_MONADIC1: - case OPTYPE_DYADIC1: - case OPTYPE_MONADIC2: - case OPTYPE_MONADIC2_r: - case OPTYPE_DYADIC2: - case OPTYPE_DYADIC2_r: - case OPTYPE_DYADIC2_s: - case OPTYPE_RECONFIGURATION: - case OPTYPE_INDEX: - case OPTYPE_MATCH: - case OPTYPE_FATAL: - case OPTYPE_CREATE_FIELD: - - /* Start a new result/operand state */ - - status = acpi_ds_result_stack_push (walk_state); - break; - - - default: - break; - } - - /* Nothing to do here during method execution */ - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ds_exec_end_op - * - * PARAMETERS: Walk_state - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback used during the execution of control - * methods. The only thing we really need to do here is to - * notice the beginning of IF, ELSE, and WHILE blocks. - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ds_exec_end_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op) -{ - ACPI_STATUS status = AE_OK; - u16 opcode; - u8 optype; - ACPI_PARSE_OBJECT *next_op; - ACPI_NAMESPACE_NODE *node; - ACPI_PARSE_OBJECT *first_arg; - ACPI_OPERAND_OBJECT *result_obj = NULL; - ACPI_OPCODE_INFO *op_info; - u32 operand_index; - - - opcode = (u16) op->opcode; - - - op_info = acpi_ps_get_opcode_info (op->opcode); - if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { - return (AE_NOT_IMPLEMENTED); - } - - optype = (u8) ACPI_GET_OP_CLASS (op_info); - first_arg = op->value.arg; - - /* Init the walk state */ - - walk_state->num_operands = 0; - walk_state->return_desc = NULL; - walk_state->op_info = op_info; - walk_state->opcode = opcode; - - - /* Call debugger for single step support (DEBUG build only) */ - - DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, optype)); - DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return (status);}); - - - /* Decode the opcode */ - - switch (optype) { - case OPTYPE_UNDEFINED: - - return (AE_NOT_IMPLEMENTED); - break; - - - case OPTYPE_BOGUS: - break; - - case OPTYPE_CONSTANT: /* argument type only */ - case OPTYPE_LITERAL: /* argument type only */ - case OPTYPE_DATA_TERM: /* argument type only */ - case OPTYPE_LOCAL_VARIABLE: /* argument type only */ - case OPTYPE_METHOD_ARGUMENT: /* argument type only */ - break; - - - /* most operators with arguments */ - - case OPTYPE_MONADIC1: - case OPTYPE_DYADIC1: - case OPTYPE_MONADIC2: - case OPTYPE_MONADIC2_r: - case OPTYPE_DYADIC2: - case OPTYPE_DYADIC2_r: - case OPTYPE_DYADIC2_s: - case OPTYPE_RECONFIGURATION: - case OPTYPE_INDEX: - case OPTYPE_MATCH: - case OPTYPE_FATAL: - - - /* Build resolved operand stack */ - - status = acpi_ds_create_operands (walk_state, first_arg); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - operand_index = walk_state->num_operands - 1; - - - /* Done with this result state (Now that operand stack is built) */ - - status = acpi_ds_result_stack_pop (walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - switch (optype) { - case OPTYPE_MONADIC1: - - /* 1 Operand, 0 External_result, 0 Internal_result */ - - status = acpi_aml_exec_monadic1 (opcode, walk_state); - break; - - - case OPTYPE_MONADIC2: - - /* 1 Operand, 0 External_result, 1 Internal_result */ - - status = acpi_aml_exec_monadic2 (opcode, walk_state, &result_obj); - break; - - - case OPTYPE_MONADIC2_r: - - /* 1 Operand, 1 External_result, 1 Internal_result */ - - status = acpi_aml_exec_monadic2_r (opcode, walk_state, &result_obj); - break; - - - case OPTYPE_DYADIC1: - - /* 2 Operands, 0 External_result, 0 Internal_result */ - - status = acpi_aml_exec_dyadic1 (opcode, walk_state); - break; - - - case OPTYPE_DYADIC2: - - /* 2 Operands, 0 External_result, 1 Internal_result */ - - status = acpi_aml_exec_dyadic2 (opcode, walk_state, &result_obj); - break; - - - case OPTYPE_DYADIC2_r: - - /* 2 Operands, 1 or 2 External_results, 1 Internal_result */ - - status = acpi_aml_exec_dyadic2_r (opcode, walk_state, &result_obj); - break; - - - case OPTYPE_DYADIC2_s: /* Synchronization Operator */ - - /* 2 Operands, 0 External_result, 1 Internal_result */ - - status = acpi_aml_exec_dyadic2_s (opcode, walk_state, &result_obj); - break; - - - case OPTYPE_INDEX: /* Type 2 opcode with 3 operands */ - - /* 3 Operands, 1 External_result, 1 Internal_result */ - - status = acpi_aml_exec_index (walk_state, &result_obj); - break; - - - case OPTYPE_MATCH: /* Type 2 opcode with 6 operands */ - - /* 6 Operands, 0 External_result, 1 Internal_result */ - - status = acpi_aml_exec_match (walk_state, &result_obj); - break; - - - case OPTYPE_RECONFIGURATION: - - /* 1 or 2 operands, 0 Internal Result */ - - status = acpi_aml_exec_reconfiguration (opcode, walk_state); - break; - - - case OPTYPE_FATAL: - - /* 3 Operands, 0 External_result, 0 Internal_result */ - - status = acpi_aml_exec_fatal (walk_state); - break; - } - - /* - * If a result object was returned from above, push it on the - * current result stack - */ - if (ACPI_SUCCESS (status) && - result_obj) { - status = acpi_ds_result_push (result_obj, walk_state); - } - - break; - - - case OPTYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ - - /* 1 Operand, 0 External_result, 0 Internal_result */ - - status = acpi_ds_exec_end_control_op (walk_state, op); - - acpi_ds_result_stack_pop (walk_state); - break; - - - case OPTYPE_METHOD_CALL: - - /* - * (AML_METHODCALL) Op->Value->Arg->Node contains - * the method Node pointer - */ - /* Next_op points to the op that holds the method name */ - - next_op = first_arg; - node = next_op->node; - - /* Next_op points to first argument op */ - - next_op = next_op->next; - - /* - * Get the method's arguments and put them on the operand stack - */ - status = acpi_ds_create_operands (walk_state, next_op); - if (ACPI_FAILURE (status)) { - break; - } - - /* - * Since the operands will be passed to another - * control method, we must resolve all local - * references here (Local variables, arguments - * to *this* method, etc.) - */ - - status = acpi_ds_resolve_operands (walk_state); - if (ACPI_FAILURE (status)) { - break; - } - - /* - * Tell the walk loop to preempt this running method and - * execute the new method - */ - status = AE_CTRL_TRANSFER; - - /* - * Return now; we don't want to disturb anything, - * especially the operand count! - */ - return (status); - break; - - - case OPTYPE_CREATE_FIELD: - - status = acpi_ds_load2_end_op (walk_state, op); - if (ACPI_FAILURE (status)) { - break; - } - - status = acpi_ds_eval_field_unit_operands (walk_state, op); - break; - - - case OPTYPE_NAMED_OBJECT: - - status = acpi_ds_load2_end_op (walk_state, op); - if (ACPI_FAILURE (status)) { - break; - } - - switch (op->opcode) { - case AML_REGION_OP: - - status = acpi_ds_eval_region_operands (walk_state, op); - if (ACPI_FAILURE (status)) { - break; - } - - status = acpi_ds_result_stack_pop (walk_state); - break; - - - case AML_METHOD_OP: - break; - - - case AML_ALIAS_OP: - - /* Alias creation was already handled by call - to psxload above */ - break; - - - default: - /* Nothing needs to be done */ - - status = AE_OK; - break; - } - - break; - - default: - - status = AE_NOT_IMPLEMENTED; - break; - } - - - /* - * ACPI 2.0 support for 64-bit integers: - * Truncate numeric result value if we are executing from a 32-bit ACPI table - */ - acpi_aml_truncate_for32bit_table (result_obj, walk_state); - - /* - * Check if we just completed the evaluation of a - * conditional predicate - */ - - if ((walk_state->control_state) && - (walk_state->control_state->common.state == - CONTROL_PREDICATE_EXECUTING) && - (walk_state->control_state->control.predicate_op == op)) { - status = acpi_ds_get_predicate_value (walk_state, op, (u32) result_obj); - result_obj = NULL; - } - - -cleanup: - if (result_obj) { - /* Break to debugger to display result */ - - DEBUGGER_EXEC (acpi_db_display_result_object (result_obj, walk_state)); - - /* - * Delete the result op if and only if: - * Parent will not use the result -- such as any - * non-nested type2 op in a method (parent will be method) - */ - acpi_ds_delete_result_if_not_used (op, result_obj, walk_state); - } - - /* Always clear the object stack */ - - /* TBD: [Investigate] Clear stack of return value, - but don't delete it */ - walk_state->num_operands = 0; - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/dispatcher/dswload.c b/reactos/drivers/bus/acpi/dispatcher/dswload.c deleted file mode 100644 index b810d5f6b4a..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dswload.c +++ /dev/null @@ -1,672 +0,0 @@ -/****************************************************************************** - * - * Module Name: dswload - Dispatcher namespace load callbacks - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dswload") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_load1_begin_op - * - * PARAMETERS: Walk_state - Current state of the parse tree walk - * Op - Op that has been just been reached in the - * walk; Arguments have not been evaluated yet. - * - * RETURN: Status - * - * DESCRIPTION: Descending callback used during the loading of ACPI tables. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_load1_begin_op ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op) -{ - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status; - OBJECT_TYPE_INTERNAL data_type; - NATIVE_CHAR *path; - - - /* We are only interested in opcodes that have an associated name */ - - if (!acpi_ps_is_named_op (opcode)) { - *out_op = op; - return (AE_OK); - } - - - /* Check if this object has already been installed in the namespace */ - - if (op && op->node) { - *out_op = op; - return (AE_OK); - } - - path = acpi_ps_get_next_namestring (walk_state->parser_state); - - /* Map the raw opcode into an internal object type */ - - data_type = acpi_ds_map_named_opcode_to_data_type (opcode); - - - - /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that involve - * arguments to the opcode must be created as we go back up the parse tree later. - */ - status = acpi_ns_lookup (walk_state->scope_info, path, - data_type, IMODE_LOAD_PASS1, - NS_NO_UPSEARCH, walk_state, &(node)); - - if (ACPI_FAILURE (status)) { - return (status); - } - - if (!op) { - /* Create a new op */ - - op = acpi_ps_alloc_op (opcode); - if (!op) { - return (AE_NO_MEMORY); - } - } - - /* Initialize */ - - ((ACPI_PARSE2_OBJECT *)op)->name = node->name; - - /* - * Put the Node in the "op" object that the parser uses, so we - * can get it again quickly when this scope is closed - */ - op->node = node; - - - acpi_ps_append_arg (acpi_ps_get_parent_scope (walk_state->parser_state), op); - - *out_op = op; - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_load1_end_op - * - * PARAMETERS: Walk_state - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback used during the loading of the namespace, - * both control methods and everything else. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_load1_end_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op) -{ - OBJECT_TYPE_INTERNAL data_type; - - - /* We are only interested in opcodes that have an associated name */ - - if (!acpi_ps_is_named_op (op->opcode)) { - return (AE_OK); - } - - - /* Get the type to determine if we should pop the scope */ - - data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode); - - if (op->opcode == AML_NAME_OP) { - /* For Name opcode, check the argument */ - - if (op->value.arg) { - data_type = acpi_ds_map_opcode_to_data_type ( - (op->value.arg)->opcode, NULL); - ((ACPI_NAMESPACE_NODE *)op->node)->type = - (u8) data_type; - } - } - - - /* Pop the scope stack */ - - if (acpi_ns_opens_scope (data_type)) { - - acpi_ds_scope_stack_pop (walk_state); - } - - return (AE_OK); - -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_load2_begin_op - * - * PARAMETERS: Walk_state - Current state of the parse tree walk - * Op - Op that has been just been reached in the - * walk; Arguments have not been evaluated yet. - * - * RETURN: Status - * - * DESCRIPTION: Descending callback used during the loading of ACPI tables. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_load2_begin_op ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op) -{ - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status; - OBJECT_TYPE_INTERNAL data_type; - NATIVE_CHAR *buffer_ptr; - void *original = NULL; - - - /* We only care about Namespace opcodes here */ - - if (!acpi_ps_is_namespace_op (opcode) && - opcode != AML_NAMEPATH_OP) { - return (AE_OK); - } - - - /* Temp! same code as in psparse */ - - if (!acpi_ps_is_named_op (opcode)) { - return (AE_OK); - } - - if (op) { - /* - * Get the name we are going to enter or lookup in the namespace - */ - if (opcode == AML_NAMEPATH_OP) { - /* For Namepath op, get the path string */ - - buffer_ptr = op->value.string; - if (!buffer_ptr) { - /* No name, just exit */ - - return (AE_OK); - } - } - - else { - /* Get name from the op */ - - buffer_ptr = (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)op)->name; - } - } - - else { - buffer_ptr = acpi_ps_get_next_namestring (walk_state->parser_state); - } - - - /* Map the raw opcode into an internal object type */ - - data_type = acpi_ds_map_named_opcode_to_data_type (opcode); - - - if (opcode == AML_DEF_FIELD_OP || - opcode == AML_BANK_FIELD_OP || - opcode == AML_INDEX_FIELD_OP) { - node = NULL; - status = AE_OK; - } - - else if (opcode == AML_NAMEPATH_OP) { - /* - * The Name_path is an object reference to an existing object. Don't enter the - * name into the namespace, but look it up for use later - */ - status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, - data_type, IMODE_EXECUTE, - NS_SEARCH_PARENT, walk_state, - &(node)); - } - - else { - if (op && op->node) { - original = op->node; - node = op->node; - - if (acpi_ns_opens_scope (data_type)) { - status = acpi_ds_scope_stack_push (node, - data_type, - walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - } - return (AE_OK); - } - - /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that involve - * arguments to the opcode must be created as we go back up the parse tree later. - */ - status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, - data_type, IMODE_EXECUTE, - NS_NO_UPSEARCH, walk_state, - &(node)); - } - - if (ACPI_SUCCESS (status)) { - if (!op) { - /* Create a new op */ - - op = acpi_ps_alloc_op (opcode); - if (!op) { - return (AE_NO_MEMORY); - } - - /* Initialize */ - - ((ACPI_PARSE2_OBJECT *)op)->name = node->name; - *out_op = op; - } - - - /* - * Put the Node in the "op" object that the parser uses, so we - * can get it again quickly when this scope is closed - */ - op->node = node; - - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_load2_end_op - * - * PARAMETERS: Walk_state - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback used during the loading of the namespace, - * both control methods and everything else. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_load2_end_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op) -{ - ACPI_STATUS status = AE_OK; - OBJECT_TYPE_INTERNAL data_type; - ACPI_NAMESPACE_NODE *node; - ACPI_PARSE_OBJECT *arg; - ACPI_NAMESPACE_NODE *new_node; - - - if (!acpi_ps_is_namespace_object_op (op->opcode)) { - return (AE_OK); - } - - if (op->opcode == AML_SCOPE_OP) { - if (((ACPI_PARSE2_OBJECT *)op)->name == -1) { - return (AE_OK); - } - } - - - data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode); - - /* - * Get the Node/name from the earlier lookup - * (It was saved in the *op structure) - */ - node = op->node; - - /* - * Put the Node on the object stack (Contains the ACPI Name of - * this object) - */ - - walk_state->operands[0] = (void *) node; - walk_state->num_operands = 1; - - /* Pop the scope stack */ - - if (acpi_ns_opens_scope (data_type)) { - - acpi_ds_scope_stack_pop (walk_state); - } - - - /* - * Named operations are as follows: - * - * AML_SCOPE - * AML_DEVICE - * AML_THERMALZONE - * AML_METHOD - * AML_POWERRES - * AML_PROCESSOR - * AML_FIELD - * AML_INDEXFIELD - * AML_BANKFIELD - * AML_NAMEDFIELD - * AML_NAME - * AML_ALIAS - * AML_MUTEX - * AML_EVENT - * AML_OPREGION - * AML_CREATEFIELD - * AML_CREATEBITFIELD - * AML_CREATEBYTEFIELD - * AML_CREATEWORDFIELD - * AML_CREATEDWORDFIELD - * AML_METHODCALL - */ - - - /* Decode the opcode */ - - arg = op->value.arg; - - switch (op->opcode) { - - case AML_CREATE_FIELD_OP: - case AML_BIT_FIELD_OP: - case AML_BYTE_FIELD_OP: - case AML_WORD_FIELD_OP: - case AML_DWORD_FIELD_OP: - - /* - * Create the field object, but the field buffer and index must - * be evaluated later during the execution phase - */ - - /* Get the Name_string argument */ - - if (op->opcode == AML_CREATE_FIELD_OP) { - arg = acpi_ps_get_arg (op, 3); - } - else { - /* Create Bit/Byte/Word/Dword field */ - - arg = acpi_ps_get_arg (op, 2); - } - - /* - * Enter the Name_string into the namespace - */ - - status = acpi_ns_lookup (walk_state->scope_info, - arg->value.string, - INTERNAL_TYPE_DEF_ANY, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - walk_state, &(new_node)); - - if (ACPI_SUCCESS (status)) { - /* We could put the returned object (Node) on the object stack for later, but - * for now, we will put it in the "op" object that the parser uses, so we - * can get it again at the end of this scope - */ - op->node = new_node; - - /* - * If there is no object attached to the node, this node was just created and - * we need to create the field object. Otherwise, this was a lookup of an - * existing node and we don't want to create the field object again. - */ - if (!new_node->object) { - /* - * The Field definition is not fully parsed at this time. - * (We must save the address of the AML for the buffer and index operands) - */ - status = acpi_aml_exec_create_field (((ACPI_PARSE2_OBJECT *) op)->data, - ((ACPI_PARSE2_OBJECT *) op)->length, - new_node, walk_state); - } - } - - - break; - - - case AML_METHODCALL_OP: - - /* - * Lookup the method name and save the Node - */ - - status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, - ACPI_TYPE_ANY, IMODE_LOAD_PASS2, - NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, - walk_state, &(new_node)); - - if (ACPI_SUCCESS (status)) { - -/* has name already been resolved by here ??*/ - - /* TBD: [Restructure] Make sure that what we found is indeed a method! */ - /* We didn't search for a method on purpose, to see if the name would resolve! */ - - /* We could put the returned object (Node) on the object stack for later, but - * for now, we will put it in the "op" object that the parser uses, so we - * can get it again at the end of this scope - */ - op->node = new_node; - } - - - break; - - - case AML_PROCESSOR_OP: - - /* Nothing to do other than enter object into namespace */ - - status = acpi_aml_exec_create_processor (op, (ACPI_HANDLE) node); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - break; - - - case AML_POWER_RES_OP: - - /* Nothing to do other than enter object into namespace */ - - status = acpi_aml_exec_create_power_resource (op, (ACPI_HANDLE) node); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - break; - - - case AML_THERMAL_ZONE_OP: - - /* Nothing to do other than enter object into namespace */ - - break; - - - case AML_DEF_FIELD_OP: - - arg = op->value.arg; - - status = acpi_ds_create_field (op, arg->node, walk_state); - break; - - - case AML_INDEX_FIELD_OP: - - arg = op->value.arg; - - status = acpi_ds_create_index_field (op, (ACPI_HANDLE) arg->node, - walk_state); - break; - - - case AML_BANK_FIELD_OP: - - arg = op->value.arg; - status = acpi_ds_create_bank_field (op, arg->node, walk_state); - break; - - - /* - * Method_op Pkg_length Names_string Method_flags Term_list - */ - case AML_METHOD_OP: - - if (!node->object) { - status = acpi_aml_exec_create_method (((ACPI_PARSE2_OBJECT *) op)->data, - ((ACPI_PARSE2_OBJECT *) op)->length, - arg->value.integer, (ACPI_HANDLE) node); - } - - break; - - - case AML_MUTEX_OP: - - status = acpi_ds_create_operands (walk_state, arg); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - status = acpi_aml_exec_create_mutex (walk_state); - break; - - - case AML_EVENT_OP: - - status = acpi_ds_create_operands (walk_state, arg); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - status = acpi_aml_exec_create_event (walk_state); - break; - - - case AML_REGION_OP: - - if (node->object) { - break; - } - - - /* - * The Op_region is not fully parsed at this time. Only valid argument is the Space_id. - * (We must save the address of the AML of the address and length operands) - */ - - status = acpi_aml_exec_create_region (((ACPI_PARSE2_OBJECT *) op)->data, - ((ACPI_PARSE2_OBJECT *) op)->length, - (ACPI_ADDRESS_SPACE_TYPE) arg->value.integer, - walk_state); - - break; - - - /* Namespace Modifier Opcodes */ - - case AML_ALIAS_OP: - - status = acpi_ds_create_operands (walk_state, arg); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - status = acpi_aml_exec_create_alias (walk_state); - break; - - - case AML_NAME_OP: - - /* - * Because of the execution pass through the non-control-method - * parts of the table, we can arrive here twice. Only init - * the named object node the first time through - */ - - if (!node->object) { - status = acpi_ds_create_node (walk_state, node, op); - } - - break; - - - case AML_NAMEPATH_OP: - - break; - - - default: - break; - } - - -cleanup: - - /* Remove the Node pushed at the very beginning */ - - acpi_ds_obj_stack_pop (1, walk_state); - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/dispatcher/dswscope.c b/reactos/drivers/bus/acpi/dispatcher/dswscope.c deleted file mode 100644 index 87bdfd49bce..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dswscope.c +++ /dev/null @@ -1,158 +0,0 @@ -/****************************************************************************** - * - * Module Name: dswscope - Scope stack manipulation - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dswscope") - - -#define STACK_POP(head) head - - -/**************************************************************************** - * - * FUNCTION: Acpi_ds_scope_stack_clear - * - * PARAMETERS: None - * - * DESCRIPTION: Pop (and free) everything on the scope stack except the - * root scope object (which remains at the stack top.) - * - ***************************************************************************/ - -void -acpi_ds_scope_stack_clear ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *scope_info; - - - while (walk_state->scope_info) { - /* Pop a scope off the stack */ - - scope_info = walk_state->scope_info; - walk_state->scope_info = scope_info->scope.next; - - acpi_cm_delete_generic_state (scope_info); - } -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ds_scope_stack_push - * - * PARAMETERS: *Node, - Name to be made current - * Type, - Type of frame being pushed - * - * DESCRIPTION: Push the current scope on the scope stack, and make the - * passed Node current. - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ds_scope_stack_push ( - ACPI_NAMESPACE_NODE *node, - OBJECT_TYPE_INTERNAL type, - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *scope_info; - - - if (!node) { - /* invalid scope */ - - REPORT_ERROR (("Ds_scope_stack_push: null scope passed\n")); - return (AE_BAD_PARAMETER); - } - - /* Make sure object type is valid */ - - if (!acpi_aml_validate_object_type (type)) { - REPORT_WARNING (("Ds_scope_stack_push: type code out of range\n")); - } - - - /* Allocate a new scope object */ - - scope_info = acpi_cm_create_generic_state (); - if (!scope_info) { - return (AE_NO_MEMORY); - } - - /* Init new scope object */ - - scope_info->scope.node = node; - scope_info->common.value = (u16) type; - - /* Push new scope object onto stack */ - - acpi_cm_push_generic_state (&walk_state->scope_info, scope_info); - - return (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ds_scope_stack_pop - * - * PARAMETERS: Type - The type of frame to be found - * - * DESCRIPTION: Pop the scope stack until a frame of the requested type - * is found. - * - * RETURN: Count of frames popped. If no frame of the requested type - * was found, the count is returned as a negative number and - * the scope stack is emptied (which sets the current scope - * to the root). If the scope stack was empty at entry, the - * function is a no-op and returns 0. - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ds_scope_stack_pop ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *scope_info; - - - /* - * Pop scope info object off the stack. - */ - - scope_info = acpi_cm_pop_generic_state (&walk_state->scope_info); - if (!scope_info) { - return (AE_STACK_UNDERFLOW); - } - - acpi_cm_delete_generic_state (scope_info); - - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/dispatcher/dswstate.c b/reactos/drivers/bus/acpi/dispatcher/dswstate.c deleted file mode 100644 index 80e9933074a..00000000000 --- a/reactos/drivers/bus/acpi/dispatcher/dswstate.c +++ /dev/null @@ -1,872 +0,0 @@ -/****************************************************************************** - * - * Module Name: dswstate - Dispatcher parse tree walk management routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dswstate") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_result_insert - * - * PARAMETERS: Object - Object to push - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Push an object onto this walk's result stack - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_result_insert ( - void *object, - u32 index, - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *state; - - - state = walk_state->results; - if (!state) { - return (AE_NOT_EXIST); - } - - if (index >= OBJ_NUM_OPERANDS) { - return (AE_BAD_PARAMETER); - } - - if (!object) { - return (AE_BAD_PARAMETER); - } - - state->results.obj_desc [index] = object; - state->results.num_results++; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_result_remove - * - * PARAMETERS: Object - Where to return the popped object - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_result_remove ( - ACPI_OPERAND_OBJECT **object, - u32 index, - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *state; - - - state = walk_state->results; - if (!state) { - return (AE_NOT_EXIST); - } - - - - /* Check for a valid result object */ - - if (!state->results.obj_desc [index]) { - return (AE_AML_NO_RETURN_VALUE); - } - - /* Remove the object */ - - state->results.num_results--; - - *object = state->results.obj_desc [index]; - state->results.obj_desc [index] = NULL; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_result_pop - * - * PARAMETERS: Object - Where to return the popped object - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_result_pop ( - ACPI_OPERAND_OBJECT **object, - ACPI_WALK_STATE *walk_state) -{ - u32 index; - ACPI_GENERIC_STATE *state; - - - state = walk_state->results; - if (!state) { - return (AE_OK); - } - - - if (!state->results.num_results) { - return (AE_AML_NO_RETURN_VALUE); - } - - /* Remove top element */ - - state->results.num_results--; - - for (index = OBJ_NUM_OPERANDS; index; index--) { - /* Check for a valid result object */ - - if (state->results.obj_desc [index -1]) { - *object = state->results.obj_desc [index -1]; - state->results.obj_desc [index -1] = NULL; - - return (AE_OK); - } - } - - - return (AE_AML_NO_RETURN_VALUE); -} - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_result_pop_from_bottom - * - * PARAMETERS: Object - Where to return the popped object - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_result_pop_from_bottom ( - ACPI_OPERAND_OBJECT **object, - ACPI_WALK_STATE *walk_state) -{ - u32 index; - ACPI_GENERIC_STATE *state; - - - state = walk_state->results; - if (!state) { - return (AE_NOT_EXIST); - } - - - if (!state->results.num_results) { - return (AE_AML_NO_RETURN_VALUE); - } - - /* Remove Bottom element */ - - *object = state->results.obj_desc [0]; - - - /* Push entire stack down one element */ - - for (index = 0; index < state->results.num_results; index++) { - state->results.obj_desc [index] = state->results.obj_desc [index + 1]; - } - - state->results.num_results--; - - /* Check for a valid result object */ - - if (!*object) { - return (AE_AML_NO_RETURN_VALUE); - } - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_result_push - * - * PARAMETERS: Object - Where to return the popped object - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Push an object onto the current result stack - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_result_push ( - ACPI_OPERAND_OBJECT *object, - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *state; - - - state = walk_state->results; - if (!state) { - return (AE_AML_INTERNAL); - } - - if (state->results.num_results == OBJ_NUM_OPERANDS) { - return (AE_STACK_OVERFLOW); - } - - if (!object) { - return (AE_BAD_PARAMETER); - } - - - state->results.obj_desc [state->results.num_results] = object; - state->results.num_results++; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_result_stack_push - * - * PARAMETERS: Object - Object to push - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_result_stack_push ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *state; - - - state = acpi_cm_create_generic_state (); - if (!state) { - return (AE_NO_MEMORY); - } - - acpi_cm_push_generic_state (&walk_state->results, state); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_result_stack_pop - * - * PARAMETERS: Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_result_stack_pop ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *state; - - - /* Check for stack underflow */ - - if (walk_state->results == NULL) { - return (AE_AML_NO_OPERAND); - } - - - state = acpi_cm_pop_generic_state (&walk_state->results); - - acpi_cm_delete_generic_state (state); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_obj_stack_delete_all - * - * PARAMETERS: Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Clear the object stack by deleting all objects that are on it. - * Should be used with great care, if at all! - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_obj_stack_delete_all ( - ACPI_WALK_STATE *walk_state) -{ - u32 i; - - - /* The stack size is configurable, but fixed */ - - for (i = 0; i < OBJ_NUM_OPERANDS; i++) { - if (walk_state->operands[i]) { - acpi_cm_remove_reference (walk_state->operands[i]); - walk_state->operands[i] = NULL; - } - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_obj_stack_push - * - * PARAMETERS: Object - Object to push - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Push an object onto this walk's object/operand stack - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_obj_stack_push ( - void *object, - ACPI_WALK_STATE *walk_state) -{ - - - /* Check for stack overflow */ - - if (walk_state->num_operands >= OBJ_NUM_OPERANDS) { - return (AE_STACK_OVERFLOW); - } - - /* Put the object onto the stack */ - - walk_state->operands [walk_state->num_operands] = object; - walk_state->num_operands++; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_obj_stack_pop_object - * - * PARAMETERS: Pop_count - Number of objects/entries to pop - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT - * deleted by this routine. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_obj_stack_pop_object ( - ACPI_OPERAND_OBJECT **object, - ACPI_WALK_STATE *walk_state) -{ - - - /* Check for stack underflow */ - - if (walk_state->num_operands == 0) { - return (AE_AML_NO_OPERAND); - } - - - /* Pop the stack */ - - walk_state->num_operands--; - - /* Check for a valid operand */ - - if (!walk_state->operands [walk_state->num_operands]) { - return (AE_AML_NO_OPERAND); - } - - /* Get operand and set stack entry to null */ - - *object = walk_state->operands [walk_state->num_operands]; - walk_state->operands [walk_state->num_operands] = NULL; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_obj_stack_pop - * - * PARAMETERS: Pop_count - Number of objects/entries to pop - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT - * deleted by this routine. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_obj_stack_pop ( - u32 pop_count, - ACPI_WALK_STATE *walk_state) -{ - u32 i; - - - for (i = 0; i < pop_count; i++) { - /* Check for stack underflow */ - - if (walk_state->num_operands == 0) { - return (AE_STACK_UNDERFLOW); - } - - /* Just set the stack entry to null */ - - walk_state->num_operands--; - walk_state->operands [walk_state->num_operands] = NULL; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_obj_stack_pop_and_delete - * - * PARAMETERS: Pop_count - Number of objects/entries to pop - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop this walk's object stack and delete each object that is - * popped off. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ds_obj_stack_pop_and_delete ( - u32 pop_count, - ACPI_WALK_STATE *walk_state) -{ - u32 i; - ACPI_OPERAND_OBJECT *obj_desc; - - - for (i = 0; i < pop_count; i++) { - /* Check for stack underflow */ - - if (walk_state->num_operands == 0) { - return (AE_STACK_UNDERFLOW); - } - - /* Pop the stack and delete an object if present in this stack entry */ - - walk_state->num_operands--; - obj_desc = walk_state->operands [walk_state->num_operands]; - if (obj_desc) { - acpi_cm_remove_reference (walk_state->operands [walk_state->num_operands]); - walk_state->operands [walk_state->num_operands] = NULL; - } - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_obj_stack_get_value - * - * PARAMETERS: Index - Stack index whose value is desired. Based - * on the top of the stack (index=0 == top) - * Walk_state - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Retrieve an object from this walk's object stack. Index must - * be within the range of the current stack pointer. - * - ******************************************************************************/ - -void * -acpi_ds_obj_stack_get_value ( - u32 index, - ACPI_WALK_STATE *walk_state) -{ - - - /* Can't do it if the stack is empty */ - - if (walk_state->num_operands == 0) { - return (NULL); - } - - /* or if the index is past the top of the stack */ - - if (index > (walk_state->num_operands - (u32) 1)) { - return (NULL); - } - - - return (walk_state->operands[(NATIVE_UINT)(walk_state->num_operands - 1) - - index]); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_get_current_walk_state - * - * PARAMETERS: Walk_list - Get current active state for this walk list - * - * RETURN: Pointer to the current walk state - * - * DESCRIPTION: Get the walk state that is at the head of the list (the "current" - * walk state. - * - ******************************************************************************/ - -ACPI_WALK_STATE * -acpi_ds_get_current_walk_state ( - ACPI_WALK_LIST *walk_list) - -{ - - if (!walk_list) { - return (NULL); - } - - return (walk_list->walk_state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_push_walk_state - * - * PARAMETERS: Walk_state - State to push - * Walk_list - The list that owns the walk stack - * - * RETURN: None - * - * DESCRIPTION: Place the Walk_state at the head of the state list. - * - ******************************************************************************/ - -static void -acpi_ds_push_walk_state ( - ACPI_WALK_STATE *walk_state, - ACPI_WALK_LIST *walk_list) -{ - - - walk_state->next = walk_list->walk_state; - walk_list->walk_state = walk_state; - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_pop_walk_state - * - * PARAMETERS: Walk_list - The list that owns the walk stack - * - * RETURN: A Walk_state object popped from the stack - * - * DESCRIPTION: Remove and return the walkstate object that is at the head of - * the walk stack for the given walk list. NULL indicates that - * the list is empty. - * - ******************************************************************************/ - -ACPI_WALK_STATE * -acpi_ds_pop_walk_state ( - ACPI_WALK_LIST *walk_list) -{ - ACPI_WALK_STATE *walk_state; - - - walk_state = walk_list->walk_state; - - if (walk_state) { - /* Next walk state becomes the current walk state */ - - walk_list->walk_state = walk_state->next; - - /* - * Don't clear the NEXT field, this serves as an indicator - * that there is a parent WALK STATE - * Walk_state->Next = NULL; - */ - } - - return (walk_state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_create_walk_state - * - * PARAMETERS: Origin - Starting point for this walk - * Walk_list - Owning walk list - * - * RETURN: Pointer to the new walk state. - * - * DESCRIPTION: Allocate and initialize a new walk state. The current walk state - * is set to this new state. - * - ******************************************************************************/ - -ACPI_WALK_STATE * -acpi_ds_create_walk_state ( - ACPI_OWNER_ID owner_id, - ACPI_PARSE_OBJECT *origin, - ACPI_OPERAND_OBJECT *mth_desc, - ACPI_WALK_LIST *walk_list) -{ - ACPI_WALK_STATE *walk_state; - ACPI_STATUS status; - - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - acpi_gbl_walk_state_cache_requests++; - - /* Check the cache first */ - - if (acpi_gbl_walk_state_cache) { - /* There is an object available, use it */ - - walk_state = acpi_gbl_walk_state_cache; - acpi_gbl_walk_state_cache = walk_state->next; - - acpi_gbl_walk_state_cache_hits++; - acpi_gbl_walk_state_cache_depth--; - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - } - - else { - /* The cache is empty, create a new object */ - - /* Avoid deadlock with Acpi_cm_callocate */ - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - - walk_state = acpi_cm_callocate (sizeof (ACPI_WALK_STATE)); - if (!walk_state) { - return (NULL); - } - } - - walk_state->data_type = ACPI_DESC_TYPE_WALK; - walk_state->owner_id = owner_id; - walk_state->origin = origin; - walk_state->method_desc = mth_desc; - walk_state->walk_list = walk_list; - - /* Init the method args/local */ - -#ifndef _ACPI_ASL_COMPILER - acpi_ds_method_data_init (walk_state); -#endif - - /* Create an initial result stack entry */ - - status = acpi_ds_result_stack_push (walk_state); - if (ACPI_FAILURE (status)) { - return (NULL); - } - - - /* Put the new state at the head of the walk list */ - - acpi_ds_push_walk_state (walk_state, walk_list); - - return (walk_state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ds_delete_walk_state - * - * PARAMETERS: Walk_state - State to delete - * - * RETURN: Status - * - * DESCRIPTION: Delete a walk state including all internal data structures - * - ******************************************************************************/ - -void -acpi_ds_delete_walk_state ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_GENERIC_STATE *state; - - - if (!walk_state) { - return; - } - - if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { - return; - } - - - /* Always must free any linked control states */ - - while (walk_state->control_state) { - state = walk_state->control_state; - walk_state->control_state = state->common.next; - - acpi_cm_delete_generic_state (state); - } - - /* Always must free any linked parse states */ - - while (walk_state->scope_info) { - state = walk_state->scope_info; - walk_state->scope_info = state->common.next; - - acpi_cm_delete_generic_state (state); - } - - /* Always must free any stacked result states */ - - while (walk_state->results) { - state = walk_state->results; - walk_state->results = state->common.next; - - acpi_cm_delete_generic_state (state); - } - - - /* If walk cache is full, just free this wallkstate object */ - - if (acpi_gbl_walk_state_cache_depth >= MAX_WALK_CACHE_DEPTH) { - acpi_cm_free (walk_state); - } - - /* Otherwise put this object back into the cache */ - - else { - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - - /* Clear the state */ - - MEMSET (walk_state, 0, sizeof (ACPI_WALK_STATE)); - walk_state->data_type = ACPI_DESC_TYPE_WALK; - - /* Put the object at the head of the global cache list */ - - walk_state->next = acpi_gbl_walk_state_cache; - acpi_gbl_walk_state_cache = walk_state; - acpi_gbl_walk_state_cache_depth++; - - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - } - - return; -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ds_delete_walk_state_cache - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -acpi_ds_delete_walk_state_cache ( - void) -{ - ACPI_WALK_STATE *next; - - - /* Traverse the global cache list */ - - while (acpi_gbl_walk_state_cache) { - /* Delete one cached state object */ - - next = acpi_gbl_walk_state_cache->next; - acpi_cm_free (acpi_gbl_walk_state_cache); - acpi_gbl_walk_state_cache = next; - acpi_gbl_walk_state_cache_depth--; - } - - return; -} - - diff --git a/reactos/drivers/bus/acpi/events/evevent.c b/reactos/drivers/bus/acpi/events/evevent.c deleted file mode 100644 index 5eba361a758..00000000000 --- a/reactos/drivers/bus/acpi/events/evevent.c +++ /dev/null @@ -1,765 +0,0 @@ -/****************************************************************************** - * - * Module Name: evevent - Fixed and General Purpose Acpi_event - * handling and dispatch - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evevent") - - -/************************************************************************** - * - * FUNCTION: Acpi_ev_initialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Ensures that the system control interrupt (SCI) is properly - * configured, disables SCI event sources, installs the SCI - * handler - * - *************************************************************************/ - -ACPI_STATUS -acpi_ev_initialize ( - void) -{ - ACPI_STATUS status; - - - /* Make sure we have ACPI tables */ - - if (!acpi_gbl_DSDT) { - return (AE_NO_ACPI_TABLES); - } - - - /* Make sure the BIOS supports ACPI mode */ - - if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities()) { - return (AE_ERROR); - } - - - acpi_gbl_original_mode = acpi_hw_get_mode(); - - /* - * Initialize the Fixed and General Purpose Acpi_events prior. This is - * done prior to enabling SCIs to prevent interrupts from occuring - * before handers are installed. - */ - - status = acpi_ev_fixed_event_initialize (); - if (ACPI_FAILURE (status)) { - return (status); - } - - status = acpi_ev_gpe_initialize (); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Install the SCI handler */ - - status = acpi_ev_install_sci_handler (); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* Install handlers for control method GPE handlers (_Lxx, _Exx) */ - - status = acpi_ev_init_gpe_control_methods (); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Install the handler for the Global Lock */ - - status = acpi_ev_init_global_lock_handler (); - if (ACPI_FAILURE (status)) { - return (status); - } - - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_fixed_event_initialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize the Fixed Acpi_event data structures - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ev_fixed_event_initialize(void) -{ - int i = 0; - - /* Initialize the structure that keeps track of fixed event handlers */ - - for (i = 0; i < NUM_FIXED_EVENTS; i++) { - acpi_gbl_fixed_event_handlers[i].handler = NULL; - acpi_gbl_fixed_event_handlers[i].context = NULL; - } - - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, TMR_EN, 0); - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, GBL_EN, 0); - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, PWRBTN_EN, 0); - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, SLPBTN_EN, 0); - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, RTC_EN, 0); - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_fixed_event_detect - * - * PARAMETERS: None - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Checks the PM status register for fixed events - * - ******************************************************************************/ - -u32 -acpi_ev_fixed_event_detect(void) -{ - u32 int_status = INTERRUPT_NOT_HANDLED; - u32 status_register; - u32 enable_register; - - /* - * Read the fixed feature status and enable registers, as all the cases - * depend on their values. - */ - - status_register = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_STS); - enable_register = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_EN); - - - /* power management timer roll over */ - - if ((status_register & ACPI_STATUS_PMTIMER) && - (enable_register & ACPI_ENABLE_PMTIMER)) { - int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_PMTIMER); - } - - /* global event (BIOS want's the global lock) */ - - if ((status_register & ACPI_STATUS_GLOBAL) && - (enable_register & ACPI_ENABLE_GLOBAL)) { - int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_GLOBAL); - } - - /* power button event */ - - if ((status_register & ACPI_STATUS_POWER_BUTTON) && - (enable_register & ACPI_ENABLE_POWER_BUTTON)) { - int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_POWER_BUTTON); - } - - /* sleep button event */ - - if ((status_register & ACPI_STATUS_SLEEP_BUTTON) && - (enable_register & ACPI_ENABLE_SLEEP_BUTTON)) { - int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_SLEEP_BUTTON); - } - - return (int_status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_fixed_event_dispatch - * - * PARAMETERS: Event - Event type - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Clears the status bit for the requested event, calls the - * handler that previously registered for the event. - * - ******************************************************************************/ - -u32 -acpi_ev_fixed_event_dispatch ( - u32 event) -{ - u32 register_id; - - /* Clear the status bit */ - - switch (event) { - case ACPI_EVENT_PMTIMER: - register_id = TMR_STS; - break; - - case ACPI_EVENT_GLOBAL: - register_id = GBL_STS; - break; - - case ACPI_EVENT_POWER_BUTTON: - register_id = PWRBTN_STS; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - register_id = SLPBTN_STS; - break; - - case ACPI_EVENT_RTC: - register_id = RTC_STS; - break; - - default: - return 0; - break; - } - - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, register_id, 1); - - /* - * Make sure we've got a handler. If not, report an error. - * The event is disabled to prevent further interrupts. - */ - if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { - register_id = (PM1_EN | REGISTER_BIT_ID(register_id)); - - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, - register_id, 0); - - REPORT_ERROR ( - ("Ev_gpe_dispatch: No installed handler for fixed event [%08X]\n", - event)); - - return (INTERRUPT_NOT_HANDLED); - } - - /* Invoke the handler */ - - return ((acpi_gbl_fixed_event_handlers[event].handler)( - acpi_gbl_fixed_event_handlers[event].context)); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_gpe_initialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize the GPE data structures - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ev_gpe_initialize (void) -{ - u32 i; - u32 j; - u32 register_index; - u32 gpe_number; - u16 gpe0register_count; - u16 gpe1_register_count; - - - /* - * Set up various GPE counts - * - * You may ask,why are the GPE register block lengths divided by 2? - * From the ACPI 2.0 Spec, section, 4.7.1.6 General-Purpose Event - * Registers, we have, - * - * "Each register block contains two registers of equal length - * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the - * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN - * The length of the GPE1_STS and GPE1_EN registers is equal to - * half the GPE1_LEN. If a generic register block is not supported - * then its respective block pointer and block length values in the - * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need - * to be the same size." - */ - - gpe0register_count = (u16) DIV_2 (acpi_gbl_FADT->gpe0blk_len); - gpe1_register_count = (u16) DIV_2 (acpi_gbl_FADT->gpe1_blk_len); - acpi_gbl_gpe_register_count = gpe0register_count + gpe1_register_count; - - if (!acpi_gbl_gpe_register_count) { - REPORT_WARNING (("Zero GPEs are defined in the FADT\n")); - return (AE_OK); - } - - /* - * Allocate the Gpe information block - */ - - acpi_gbl_gpe_registers = acpi_cm_callocate (acpi_gbl_gpe_register_count * - sizeof (ACPI_GPE_REGISTERS)); - if (!acpi_gbl_gpe_registers) { - return (AE_NO_MEMORY); - } - - /* - * Allocate the Gpe dispatch handler block - * There are eight distinct GP events per register. - * Initialization to zeros is sufficient - */ - - acpi_gbl_gpe_info = acpi_cm_callocate (MUL_8 (acpi_gbl_gpe_register_count) * - sizeof (ACPI_GPE_LEVEL_INFO)); - if (!acpi_gbl_gpe_info) { - acpi_cm_free (acpi_gbl_gpe_registers); - return (AE_NO_MEMORY); - } - - /* Set the Gpe validation table to GPE_INVALID */ - - MEMSET (acpi_gbl_gpe_valid, (int) ACPI_GPE_INVALID, NUM_GPE); - - /* - * Initialize the Gpe information and validation blocks. A goal of these - * blocks is to hide the fact that there are two separate GPE register sets - * In a given block, the status registers occupy the first half, and - * the enable registers occupy the second half. - */ - - /* GPE Block 0 */ - - register_index = 0; - - for (i = 0; i < gpe0register_count; i++) { - acpi_gbl_gpe_registers[register_index].status_addr = - (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + i); - - acpi_gbl_gpe_registers[register_index].enable_addr = - (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + i + gpe0register_count); - - acpi_gbl_gpe_registers[register_index].gpe_base = (u8) MUL_8 (i); - - for (j = 0; j < 8; j++) { - gpe_number = acpi_gbl_gpe_registers[register_index].gpe_base + j; - acpi_gbl_gpe_valid[gpe_number] = (u8) register_index; - } - - /* - * Clear the status/enable registers. Note that status registers - * are cleared by writing a '1', while enable registers are cleared - * by writing a '0'. - */ - acpi_os_out8 (acpi_gbl_gpe_registers[register_index].enable_addr, 0x00); - acpi_os_out8 (acpi_gbl_gpe_registers[register_index].status_addr, 0xFF); - - register_index++; - } - - /* GPE Block 1 */ - - for (i = 0; i < gpe1_register_count; i++) { - acpi_gbl_gpe_registers[register_index].status_addr = - (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + i); - - acpi_gbl_gpe_registers[register_index].enable_addr = - (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + i + gpe1_register_count); - - acpi_gbl_gpe_registers[register_index].gpe_base = - (u8) (acpi_gbl_FADT->gpe1_base + MUL_8 (i)); - - for (j = 0; j < 8; j++) { - gpe_number = acpi_gbl_gpe_registers[register_index].gpe_base + j; - acpi_gbl_gpe_valid[gpe_number] = (u8) register_index; - } - - /* - * Clear the status/enable registers. Note that status registers - * are cleared by writing a '1', while enable registers are cleared - * by writing a '0'. - */ - acpi_os_out8 (acpi_gbl_gpe_registers[register_index].enable_addr, 0x00); - acpi_os_out8 (acpi_gbl_gpe_registers[register_index].status_addr, 0xFF); - - register_index++; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_save_method_info - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Called from Acpi_walk_namespace. Expects each object to be a - * control method under the _GPE portion of the namespace. - * Extract the name and GPE type from the object, saving this - * information for quick lookup during GPE dispatch - * - * The name of each GPE control method is of the form: - * "_Lnn" or "_Enn" - * Where: - * L - means that the GPE is level triggered - * E - means that the GPE is edge triggered - * nn - is the GPE number - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_ev_save_method_info ( - ACPI_HANDLE obj_handle, - u32 level, - void *obj_desc, - void **return_value) -{ - u32 gpe_number; - NATIVE_CHAR name[ACPI_NAME_SIZE + 1]; - u8 type; - - - /* Extract the name from the object and convert to a string */ - - MOVE_UNALIGNED32_TO_32 (name, &((ACPI_NAMESPACE_NODE *) obj_handle)->name); - name[ACPI_NAME_SIZE] = 0; - - /* - * Edge/Level determination is based on the 2nd s8 of the method name - */ - if (name[1] == 'L') { - type = ACPI_EVENT_LEVEL_TRIGGERED; - } - else if (name[1] == 'E') { - type = ACPI_EVENT_EDGE_TRIGGERED; - } - else { - /* Unknown method type, just ignore it! */ - - return (AE_OK); - } - - /* Convert the last two characters of the name to the Gpe Number */ - - gpe_number = STRTOUL (&name[2], NULL, 16); - if (gpe_number == ACPI_UINT32_MAX) { - /* Conversion failed; invalid method, just ignore it */ - - return (AE_OK); - } - - /* Ensure that we have a valid GPE number */ - - if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) { - /* Not valid, all we can do here is ignore it */ - - return (AE_OK); - } - - /* - * Now we can add this information to the Gpe_info block - * for use during dispatch of this GPE. - */ - - acpi_gbl_gpe_info [gpe_number].type = type; - acpi_gbl_gpe_info [gpe_number].method_handle = obj_handle; - - - /* - * Enable the GPE (SCIs should be disabled at this point) - */ - - acpi_hw_enable_gpe (gpe_number); - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_init_gpe_control_methods - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Obtain the control methods associated with the GPEs. - * - * NOTE: Must be called AFTER namespace initialization! - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ev_init_gpe_control_methods (void) -{ - ACPI_STATUS status; - - - /* Get a permanent handle to the _GPE object */ - - status = acpi_get_handle (NULL, "\\_GPE", &acpi_gbl_gpe_obj_handle); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Traverse the namespace under \_GPE to find all methods there */ - - status = acpi_walk_namespace (ACPI_TYPE_METHOD, acpi_gbl_gpe_obj_handle, - ACPI_UINT32_MAX, acpi_ev_save_method_info, - NULL, NULL); - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_gpe_detect - * - * PARAMETERS: None - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Detect if any GP events have occurred - * - ******************************************************************************/ - -u32 -acpi_ev_gpe_detect (void) -{ - u32 int_status = INTERRUPT_NOT_HANDLED; - u32 i; - u32 j; - u8 enabled_status_byte; - u8 bit_mask; - - - /* - * Read all of the 8-bit GPE status and enable registers - * in both of the register blocks, saving all of it. - * Find all currently active GP events. - */ - - for (i = 0; i < acpi_gbl_gpe_register_count; i++) { - acpi_gbl_gpe_registers[i].status = - acpi_os_in8 (acpi_gbl_gpe_registers[i].status_addr); - - acpi_gbl_gpe_registers[i].enable = - acpi_os_in8 (acpi_gbl_gpe_registers[i].enable_addr); - - /* First check if there is anything active at all in this register */ - - enabled_status_byte = (u8) (acpi_gbl_gpe_registers[i].status & - acpi_gbl_gpe_registers[i].enable); - - if (!enabled_status_byte) { - /* No active GPEs in this register, move on */ - - continue; - } - - /* Now look at the individual GPEs in this byte register */ - - for (j = 0, bit_mask = 1; j < 8; j++, bit_mask <<= 1) { - /* Examine one GPE bit */ - - if (enabled_status_byte & bit_mask) { - /* - * Found an active GPE. Dispatch the event to a handler - * or method. - */ - int_status |= - acpi_ev_gpe_dispatch (acpi_gbl_gpe_registers[i].gpe_base + j); - } - } - } - - return (int_status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_asynch_execute_gpe_method - * - * PARAMETERS: Gpe_number - The 0-based Gpe number - * - * RETURN: None - * - * DESCRIPTION: Perform the actual execution of a GPE control method. This - * function is called from an invocation of Acpi_os_queue_for_execution - * (and therefore does NOT execute at interrupt level) so that - * the control method itself is not executed in the context of - * the SCI interrupt handler. - * - ******************************************************************************/ - -static void -acpi_ev_asynch_execute_gpe_method ( - void *context) -{ - u32 gpe_number = (u32) context; - ACPI_GPE_LEVEL_INFO gpe_info; - - - /* - * Take a snapshot of the GPE info for this level - */ - acpi_cm_acquire_mutex (ACPI_MTX_EVENTS); - gpe_info = acpi_gbl_gpe_info [gpe_number]; - acpi_cm_release_mutex (ACPI_MTX_EVENTS); - - /* - * Method Handler (_Lxx, _Exx): - * ---------------------------- - * Evaluate the _Lxx/_Exx control method that corresponds to this GPE. - */ - if (gpe_info.method_handle) { - acpi_ns_evaluate_by_handle (gpe_info.method_handle, NULL, NULL); - } - - /* - * Level-Triggered? - * ---------------- - * If level-triggered we clear the GPE status bit after handling the event. - */ - if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) { - acpi_hw_clear_gpe (gpe_number); - } - - /* - * Enable the GPE. - */ - acpi_hw_enable_gpe (gpe_number); - - return; -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_gpe_dispatch - * - * PARAMETERS: Gpe_number - The 0-based Gpe number - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Handle and dispatch a General Purpose Acpi_event. - * Clears the status bit for the requested event. - * - * TBD: [Investigate] is this still valid or necessary: - * The Gpe handler differs from the fixed events in that it clears the enable - * bit rather than the status bit to clear the interrupt. This allows - * software outside of interrupt context to determine what caused the SCI and - * dispatch the correct AML. - * - ******************************************************************************/ - -u32 -acpi_ev_gpe_dispatch ( - u32 gpe_number) -{ - ACPI_GPE_LEVEL_INFO gpe_info; - - /* - * Valid GPE number? - */ - if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) { - return (INTERRUPT_NOT_HANDLED); - } - - /* - * Disable the GPE. - */ - acpi_hw_disable_gpe (gpe_number); - - gpe_info = acpi_gbl_gpe_info [gpe_number]; - - /* - * Edge-Triggered? - * --------------- - * If edge-triggered, clear the GPE status bit now. Note that - * level-triggered events are cleared after the GPE is serviced. - */ - if (gpe_info.type & ACPI_EVENT_EDGE_TRIGGERED) { - acpi_hw_clear_gpe (gpe_number); - } - /* - * Function Handler (e.g. EC)? - */ - if (gpe_info.handler) { - /* Invoke function handler (at interrupt level). */ - gpe_info.handler (gpe_info.context); - - /* Level-Triggered? */ - if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) { - acpi_hw_clear_gpe (gpe_number); - } - - /* Enable GPE */ - acpi_hw_enable_gpe (gpe_number); - } - /* - * Method Handler (e.g. _Exx/_Lxx)? - */ - else if (gpe_info.method_handle) { - if (ACPI_FAILURE(acpi_os_queue_for_execution (OSD_PRIORITY_GPE, - acpi_ev_asynch_execute_gpe_method, (void*)(NATIVE_UINT)gpe_number))) { - /* - * Shoudn't occur, but if it does report an error. Note that - * the GPE will remain disabled until the ACPI Core Subsystem - * is restarted, or the handler is removed/reinstalled. - */ - REPORT_ERROR (("Acpi_ev_gpe_dispatch: Unable to queue handler for GPE bit [%X]\n", gpe_number)); - } - } - /* - * No Handler? Report an error and leave the GPE disabled. - */ - else { - REPORT_ERROR (("Acpi_ev_gpe_dispatch: No installed handler for GPE [%X]\n", gpe_number)); - - /* Level-Triggered? */ - if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) { - acpi_hw_clear_gpe (gpe_number); - } - } - - return (INTERRUPT_HANDLED); -} diff --git a/reactos/drivers/bus/acpi/events/evmisc.c b/reactos/drivers/bus/acpi/events/evmisc.c deleted file mode 100644 index 7d137d1d48a..00000000000 --- a/reactos/drivers/bus/acpi/events/evmisc.c +++ /dev/null @@ -1,439 +0,0 @@ -/****************************************************************************** - * - * Module Name: evmisc - ACPI device notification handler dispatch - * and ACPI Global Lock support - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evmisc") - - -/************************************************************************** - * - * FUNCTION: Acpi_ev_queue_notify_request - * - * PARAMETERS: - * - * RETURN: None. - * - * DESCRIPTION: Dispatch a device notification event to a previously - * installed handler. - * - *************************************************************************/ - -ACPI_STATUS -acpi_ev_queue_notify_request ( - ACPI_NAMESPACE_NODE *node, - u32 notify_value) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *handler_obj = NULL; - ACPI_GENERIC_STATE *notify_info; - ACPI_STATUS status = AE_OK; - - - /* - * For value 1 (Ejection Request), some device method may need to be run. - * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run. - * For value 0x80 (Status Change) on the power button or sleep button, - * initiate soft-off or sleep operation? - */ - - switch (notify_value) { - case 0: - break; - - case 1: - break; - - case 2: - break; - - case 0x80: - break; - - default: - break; - } - - - /* - * Get the notify object attached to the device Node - */ - - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); - if (obj_desc) { - - /* We have the notify object, Get the right handler */ - - switch (node->type) { - case ACPI_TYPE_DEVICE: - if (notify_value <= MAX_SYS_NOTIFY) { - handler_obj = obj_desc->device.sys_handler; - } - else { - handler_obj = obj_desc->device.drv_handler; - } - break; - - case ACPI_TYPE_THERMAL: - if (notify_value <= MAX_SYS_NOTIFY) { - handler_obj = obj_desc->thermal_zone.sys_handler; - } - else { - handler_obj = obj_desc->thermal_zone.drv_handler; - } - break; - } - } - - - /* If there is any handler to run, schedule the dispatcher */ - - if ((acpi_gbl_sys_notify.handler && (notify_value <= MAX_SYS_NOTIFY)) || - (acpi_gbl_drv_notify.handler && (notify_value > MAX_SYS_NOTIFY)) || - handler_obj) { - - notify_info = acpi_cm_create_generic_state (); - if (!notify_info) { - return (AE_NO_MEMORY); - } - - notify_info->notify.node = node; - notify_info->notify.value = (u16) notify_value; - notify_info->notify.handler_obj = handler_obj; - - status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, - acpi_ev_notify_dispatch, notify_info); - if (ACPI_FAILURE (status)) { - acpi_cm_delete_generic_state (notify_info); - } - } - - if (!handler_obj) { - /* There is no per-device notify handler for this device */ - - } - - - return (status); -} - - -/************************************************************************** - * - * FUNCTION: Acpi_ev_notify_dispatch - * - * PARAMETERS: - * - * RETURN: None. - * - * DESCRIPTION: Dispatch a device notification event to a previously - * installed handler. - * - *************************************************************************/ - -void -acpi_ev_notify_dispatch ( - void *context) -{ - ACPI_GENERIC_STATE *notify_info = (ACPI_GENERIC_STATE *) context; - NOTIFY_HANDLER global_handler = NULL; - void *global_context = NULL; - ACPI_OPERAND_OBJECT *handler_obj; - - - /* - * We will invoke a global notify handler if installed. - * This is done _before_ we invoke the per-device handler attached to the device. - */ - - if (notify_info->notify.value <= MAX_SYS_NOTIFY) { - /* Global system notification handler */ - - if (acpi_gbl_sys_notify.handler) { - global_handler = acpi_gbl_sys_notify.handler; - global_context = acpi_gbl_sys_notify.context; - } - } - - else { - /* Global driver notification handler */ - - if (acpi_gbl_drv_notify.handler) { - global_handler = acpi_gbl_drv_notify.handler; - global_context = acpi_gbl_drv_notify.context; - } - } - - - /* Invoke the system handler first, if present */ - - if (global_handler) { - global_handler (notify_info->notify.node, notify_info->notify.value, global_context); - } - - /* Now invoke the per-device handler, if present */ - - handler_obj = notify_info->notify.handler_obj; - if (handler_obj) { - handler_obj->notify_handler.handler (notify_info->notify.node, notify_info->notify.value, - handler_obj->notify_handler.context); - } - - - /* All done with the info object */ - - acpi_cm_delete_generic_state (notify_info); -} - - -/*************************************************************************** - * - * FUNCTION: Acpi_ev_global_lock_thread - * - * RETURN: None - * - * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the - * Global Lock. Simply signal all threads that are waiting - * for the lock. - * - **************************************************************************/ - -static void -acpi_ev_global_lock_thread ( - void *context) -{ - - /* Signal threads that are waiting for the lock */ - - if (acpi_gbl_global_lock_thread_count) { - /* Send sufficient units to the semaphore */ - - acpi_os_signal_semaphore (acpi_gbl_global_lock_semaphore, - acpi_gbl_global_lock_thread_count); - } -} - - -/*************************************************************************** - * - * FUNCTION: Acpi_ev_global_lock_handler - * - * RETURN: Status - * - * DESCRIPTION: Invoked directly from the SCI handler when a global lock - * release interrupt occurs. Grab the global lock and queue - * the global lock thread for execution - * - **************************************************************************/ - -static u32 -acpi_ev_global_lock_handler ( - void *context) -{ - u8 acquired = FALSE; - void *global_lock; - - - /* - * Attempt to get the lock - * If we don't get it now, it will be marked pending and we will - * take another interrupt when it becomes free. - */ - - global_lock = acpi_gbl_FACS->global_lock; - ACPI_ACQUIRE_GLOBAL_LOCK (global_lock, acquired); - if (acquired) { - /* Got the lock, now wake all threads waiting for it */ - - acpi_gbl_global_lock_acquired = TRUE; - - /* Run the Global Lock thread which will signal all waiting threads */ - - acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, acpi_ev_global_lock_thread, - context); - } - - return (INTERRUPT_HANDLED); -} - - -/*************************************************************************** - * - * FUNCTION: Acpi_ev_init_global_lock_handler - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for the global lock release event - * - **************************************************************************/ - -ACPI_STATUS -acpi_ev_init_global_lock_handler (void) -{ - ACPI_STATUS status; - - - acpi_gbl_global_lock_present = TRUE; - status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL, - acpi_ev_global_lock_handler, NULL); - - /* - * If the global lock does not exist on this platform, the attempt - * to enable GBL_STS will fail (the GBL_EN bit will not stick) - * Map to AE_OK, but mark global lock as not present. - * Any attempt to actually use the global lock will be flagged - * with an error. - */ - if (status == AE_NO_HARDWARE_RESPONSE) { - acpi_gbl_global_lock_present = FALSE; - status = AE_OK; - } - - return (status); -} - - -/*************************************************************************** - * - * FUNCTION: Acpi_ev_acquire_global_lock - * - * RETURN: Status - * - * DESCRIPTION: Attempt to gain ownership of the Global Lock. - * - **************************************************************************/ - -ACPI_STATUS -acpi_ev_acquire_global_lock(void) -{ - ACPI_STATUS status = AE_OK; - u8 acquired = FALSE; - void *global_lock; - - - /* Make sure that we actually have a global lock */ - - if (!acpi_gbl_global_lock_present) { - return (AE_NO_GLOBAL_LOCK); - } - - /* One more thread wants the global lock */ - - acpi_gbl_global_lock_thread_count++; - - - /* If we (OS side) have the hardware lock already, we are done */ - - if (acpi_gbl_global_lock_acquired) { - return (AE_OK); - } - - /* Only if the FACS is valid */ - - if (!acpi_gbl_FACS) { - return (AE_OK); - } - - - /* We must acquire the actual hardware lock */ - - global_lock = acpi_gbl_FACS->global_lock; - ACPI_ACQUIRE_GLOBAL_LOCK (global_lock, acquired); - if (acquired) { - /* We got the lock */ - - acpi_gbl_global_lock_acquired = TRUE; - - return (AE_OK); - } - - - /* - * Did not get the lock. The pending bit was set above, and we must now - * wait until we get the global lock released interrupt. - */ - - /* - * Acquire the global lock semaphore first. - * Since this wait will block, we must release the interpreter - */ - - status = acpi_aml_system_wait_semaphore (acpi_gbl_global_lock_semaphore, - ACPI_UINT32_MAX); - - return (status); -} - - -/*************************************************************************** - * - * FUNCTION: Acpi_ev_release_global_lock - * - * DESCRIPTION: Releases ownership of the Global Lock. - * - **************************************************************************/ - -void -acpi_ev_release_global_lock (void) -{ - u8 pending = FALSE; - void *global_lock; - - - if (!acpi_gbl_global_lock_thread_count) { - REPORT_WARNING(("Global Lock has not be acquired, cannot release\n")); - return; - } - - /* One fewer thread has the global lock */ - - acpi_gbl_global_lock_thread_count--; - - /* Have all threads released the lock? */ - - if (!acpi_gbl_global_lock_thread_count) { - /* - * No more threads holding lock, we can do the actual hardware - * release - */ - - global_lock = acpi_gbl_FACS->global_lock; - ACPI_RELEASE_GLOBAL_LOCK (global_lock, pending); - acpi_gbl_global_lock_acquired = FALSE; - - /* - * If the pending bit was set, we must write GBL_RLS to the control - * register - */ - if (pending) { - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, - GBL_RLS, 1); - } - } - - return; -} diff --git a/reactos/drivers/bus/acpi/events/evregion.c b/reactos/drivers/bus/acpi/events/evregion.c deleted file mode 100644 index 61bb39269b4..00000000000 --- a/reactos/drivers/bus/acpi/events/evregion.c +++ /dev/null @@ -1,602 +0,0 @@ -/****************************************************************************** - * - * Module Name: evregion - ACPI Address_space (Op_region) handler dispatch - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evregion") - - -/************************************************************************** - * - * FUNCTION: Acpi_ev_install_default_address_space_handlers - * - * PARAMETERS: - * - * RETURN: Status - * - * DESCRIPTION: Installs the core subsystem address space handlers. - * - *************************************************************************/ - -ACPI_STATUS -acpi_ev_install_default_address_space_handlers ( - void) -{ - ACPI_STATUS status; - - - /* - * All address spaces (PCI Config, EC, SMBus) are scope dependent - * and registration must occur for a specific device. In the case - * system memory and IO address spaces there is currently no device - * associated with the address space. For these we use the root. - * We install the default PCI config space handler at the root so - * that this space is immediately available even though the we have - * not enumerated all the PCI Root Buses yet. This is to conform - * to the ACPI specification which states that the PCI config - * space must be always available -- even though we are nowhere - * near ready to find the PCI root buses at this point. - * - * NOTE: We ignore AE_EXIST because this means that a handler has - * already been installed (via Acpi_install_address_space_handler) - */ - - status = acpi_install_address_space_handler (acpi_gbl_root_node, - ADDRESS_SPACE_SYSTEM_MEMORY, - ACPI_DEFAULT_HANDLER, NULL, NULL); - if ((ACPI_FAILURE (status)) && - (status != AE_EXIST)) { - return (status); - } - - status = acpi_install_address_space_handler (acpi_gbl_root_node, - ADDRESS_SPACE_SYSTEM_IO, - ACPI_DEFAULT_HANDLER, NULL, NULL); - if ((ACPI_FAILURE (status)) && - (status != AE_EXIST)) { - return (status); - } - - status = acpi_install_address_space_handler (acpi_gbl_root_node, - ADDRESS_SPACE_PCI_CONFIG, - ACPI_DEFAULT_HANDLER, NULL, NULL); - if ((ACPI_FAILURE (status)) && - (status != AE_EXIST)) { - return (status); - } - - - return (AE_OK); -} - - -/* TBD: [Restructure] Move elsewhere */ - -/************************************************************************** - * - * FUNCTION: Acpi_ev_execute_reg_method - * - * PARAMETERS: Region_obj - Object structure - * Function - On (1) or Off (0) - * - * RETURN: Status - * - * DESCRIPTION: Execute _REG method for a region - * - *************************************************************************/ - -static ACPI_STATUS -acpi_ev_execute_reg_method ( - ACPI_OPERAND_OBJECT *region_obj, - u32 function) -{ - ACPI_OPERAND_OBJECT *params[3]; - ACPI_OPERAND_OBJECT space_id_desc; - ACPI_OPERAND_OBJECT function_desc; - ACPI_STATUS status; - - - if (region_obj->region.extra->extra.method_REG == NULL) { - return (AE_OK); - } - - /* - * _REG method has two arguments - * Arg0: Integer: Operation region space ID - * Same value as Region_obj->Region.Space_id - * Arg1: Integer: connection status - * 1 for connecting the handler, - * 0 for disconnecting the handler - * Passed as a parameter - */ - - acpi_cm_init_static_object (&space_id_desc); - acpi_cm_init_static_object (&function_desc); - - /* - * Method requires two parameters. - */ - params [0] = &space_id_desc; - params [1] = &function_desc; - params [2] = NULL; - - /* - * Set up the parameter objects - */ - space_id_desc.common.type = ACPI_TYPE_INTEGER; - space_id_desc.integer.value = region_obj->region.space_id; - - function_desc.common.type = ACPI_TYPE_INTEGER; - function_desc.integer.value = function; - - /* - * Execute the method, no return value - */ - status = acpi_ns_evaluate_by_handle (region_obj->region.extra->extra.method_REG, params, NULL); - return (status); -} - - -/************************************************************************** - * - * FUNCTION: Acpi_ev_address_space_dispatch - * - * PARAMETERS: Region_obj - internal region object - * Space_id - ID of the address space (0-255) - * Function - Read or Write operation - * Address - Where in the space to read or write - * Bit_width - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * - * RETURN: Status - * - * DESCRIPTION: Dispatch an address space or operation region access to - * a previously installed handler. - * - *************************************************************************/ - -ACPI_STATUS -acpi_ev_address_space_dispatch ( - ACPI_OPERAND_OBJECT *region_obj, - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value) -{ - ACPI_STATUS status; - ADDRESS_SPACE_HANDLER handler; - ADDRESS_SPACE_SETUP region_setup; - ACPI_OPERAND_OBJECT *handler_desc; - void *region_context = NULL; - - - /* - * Ensure that there is a handler associated with this region - */ - handler_desc = region_obj->region.addr_handler; - if (!handler_desc) { - return(AE_NOT_EXIST); - } - - /* - * It may be the case that the region has never been initialized - * Some types of regions require special init code - */ - if (!(region_obj->region.flags & AOPOBJ_INITIALIZED)) { - /* - * This region has not been initialized yet, do it - */ - region_setup = handler_desc->addr_handler.setup; - if (!region_setup) { - /* - * Bad news, no init routine and not init'd - */ - return (AE_UNKNOWN_STATUS); - } - - /* - * We must exit the interpreter because the region setup will potentially - * execute control methods - */ - acpi_aml_exit_interpreter (); - - status = region_setup (region_obj, ACPI_REGION_ACTIVATE, - handler_desc->addr_handler.context, - ®ion_context); - - /* Re-enter the interpreter */ - - acpi_aml_enter_interpreter (); - - /* - * Init routine may fail - */ - if (ACPI_FAILURE (status)) { - return(status); - } - - region_obj->region.flags |= AOPOBJ_INITIALIZED; - - /* - * Save the returned context for use in all accesses to - * this particular region. - */ - region_obj->region.extra->extra.region_context = region_context; - } - - /* - * We have everything we need, begin the process - */ - handler = handler_desc->addr_handler.handler; - - if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) { - /* - * For handlers other than the default (supplied) handlers, we must - * exit the interpreter because the handler *might* block -- we don't - * know what it will do, so we can't hold the lock on the intepreter. - */ - acpi_aml_exit_interpreter(); - } - - /* - * Invoke the handler. - */ - status = handler (function, address, bit_width, value, - handler_desc->addr_handler.context, - region_obj->region.extra->extra.region_context); - - - if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) { - /* We just returned from a non-default handler, we must re-enter the - interpreter */ - - acpi_aml_enter_interpreter (); - } - - return (status); -} - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_disassociate_region_from_handler - * - * PARAMETERS: Region_obj - Region Object - * Acpi_ns_is_locked - Namespace Region Already Locked? - * - * RETURN: None - * - * DESCRIPTION: Break the association between the handler and the region - * this is a two way association. - * - ******************************************************************************/ - -void -acpi_ev_disassociate_region_from_handler( - ACPI_OPERAND_OBJECT *region_obj, - u8 acpi_ns_is_locked) -{ - ACPI_OPERAND_OBJECT *handler_obj; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT **last_obj_ptr; - ADDRESS_SPACE_SETUP region_setup; - void *region_context; - ACPI_STATUS status; - - - region_context = region_obj->region.extra->extra.region_context; - - /* - * Get the address handler from the region object - */ - - handler_obj = region_obj->region.addr_handler; - if (!handler_obj) { - /* - * This region has no handler, all done - */ - return; - } - - - /* - * Find this region in the handler's list - */ - - obj_desc = handler_obj->addr_handler.region_list; - last_obj_ptr = &handler_obj->addr_handler.region_list; - - while (obj_desc) { - /* - * See if this is the one - */ - if (obj_desc == region_obj) { - /* - * This is it, remove it from the handler's list - */ - *last_obj_ptr = obj_desc->region.next; - obj_desc->region.next = NULL; /* Must clear field */ - - if (acpi_ns_is_locked) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - } - - /* - * Now stop region accesses by executing the _REG method - */ - acpi_ev_execute_reg_method (region_obj, 0); - - if (acpi_ns_is_locked) { - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - } - - /* - * Call the setup handler with the deactivate notification - */ - region_setup = handler_obj->addr_handler.setup; - status = region_setup (region_obj, ACPI_REGION_DEACTIVATE, - handler_obj->addr_handler.context, - ®ion_context); - - /* - * Init routine may fail, Just ignore errors - */ - - region_obj->region.flags &= ~(AOPOBJ_INITIALIZED); - - /* - * Remove handler reference in the region - * - * NOTE: this doesn't mean that the region goes away - * The region is just inaccessible as indicated to - * the _REG method - * - * If the region is on the handler's list - * this better be the region's handler - */ - ACPI_ASSERT (region_obj->region.addr_handler == handler_obj); - - region_obj->region.addr_handler = NULL; - - return; - - } /* found the right handler */ - - /* - * Move through the linked list of handlers - */ - last_obj_ptr = &obj_desc->region.next; - obj_desc = obj_desc->region.next; - } - - /* - * If we get here, the region was not in the handler's region list - */ - return; -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_associate_region_and_handler - * - * PARAMETERS: Handler_obj - Handler Object - * Region_obj - Region Object - * Acpi_ns_is_locked - Namespace Region Already Locked? - * - * RETURN: None - * - * DESCRIPTION: Create the association between the handler and the region - * this is a two way association. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ev_associate_region_and_handler ( - ACPI_OPERAND_OBJECT *handler_obj, - ACPI_OPERAND_OBJECT *region_obj, - u8 acpi_ns_is_locked) -{ - ACPI_STATUS status; - - - ACPI_ASSERT (region_obj->region.space_id == handler_obj->addr_handler.space_id); - ACPI_ASSERT (region_obj->region.addr_handler == 0); - - /* - * Link this region to the front of the handler's list - */ - - region_obj->region.next = handler_obj->addr_handler.region_list; - handler_obj->addr_handler.region_list = region_obj; - - /* - * set the region's handler - */ - -/* - Handler_obj->Common.Reference_count = - (u16) (Handler_obj->Common.Reference_count + - Region_obj->Common.Reference_count - 1); -*/ - region_obj->region.addr_handler = handler_obj; - - /* - * Last thing, tell all users that this region is usable - */ - if (acpi_ns_is_locked) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - } - - status = acpi_ev_execute_reg_method (region_obj, 1); - - if (acpi_ns_is_locked) { - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - } - - return (status); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ev_addr_handler_helper - * - * PARAMETERS: Handle - Node to be dumped - * Level - Nesting level of the handle - * Context - Passed into Acpi_ns_walk_namespace - * - * DESCRIPTION: This routine checks to see if the object is a Region if it - * is then the address handler is installed in it. - * - * If the Object is a Device, and the device has a handler of - * the same type then the search is terminated in that branch. - * - * This is because the existing handler is closer in proximity - * to any more regions than the one we are trying to install. - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ev_addr_handler_helper ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value) -{ - ACPI_OPERAND_OBJECT *handler_obj; - ACPI_OPERAND_OBJECT *tmp_obj; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status; - - - handler_obj = (ACPI_OPERAND_OBJECT *) context; - - /* Parameter validation */ - - if (!handler_obj) { - return (AE_OK); - } - - /* Convert and validate the device handle */ - - node = acpi_ns_convert_handle_to_entry (obj_handle); - if (!node) { - return (AE_BAD_PARAMETER); - } - - /* - * We only care about regions.and objects - * that can have address handlers - */ - - if ((node->type != ACPI_TYPE_DEVICE) && - (node->type != ACPI_TYPE_REGION) && - (node != acpi_gbl_root_node)) { - return (AE_OK); - } - - /* Check for an existing internal object */ - - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); - if (!obj_desc) { - /* - * The object DNE, we don't care about it - */ - return (AE_OK); - } - - /* - * Devices are handled different than regions - */ - if (IS_THIS_OBJECT_TYPE (obj_desc, ACPI_TYPE_DEVICE)) { - /* - * See if this guy has any handlers - */ - tmp_obj = obj_desc->device.addr_handler; - while (tmp_obj) { - /* - * Now let's see if it's for the same address space. - */ - if (tmp_obj->addr_handler.space_id == handler_obj->addr_handler.space_id) { - /* - * It's for the same address space - */ - /* - * Since the object we found it on was a device, then it - * means that someone has already installed a handler for - * the branch of the namespace from this device on. Just - * bail out telling the walk routine to not traverse this - * branch. This preserves the scoping rule for handlers. - */ - return (AE_CTRL_DEPTH); - } - - /* - * Move through the linked list of handlers - */ - tmp_obj = tmp_obj->addr_handler.next; - } - - /* - * As long as the device didn't have a handler for this - * space we don't care about it. We just ignore it and - * proceed. - */ - return (AE_OK); - } - - /* - * Only here if it was a region - */ - ACPI_ASSERT (obj_desc->common.type == ACPI_TYPE_REGION); - - if (obj_desc->region.space_id != handler_obj->addr_handler.space_id) { - /* - * This region is for a different address space - * ignore it - */ - return (AE_OK); - } - - /* - * Now we have a region and it is for the handler's address - * space type. - * - * First disconnect region for any previous handler (if any) - */ - acpi_ev_disassociate_region_from_handler (obj_desc, FALSE); - - /* - * Then connect the region to the new handler - */ - status = acpi_ev_associate_region_and_handler (handler_obj, obj_desc, FALSE); - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/events/evrgnini.c b/reactos/drivers/bus/acpi/events/evrgnini.c deleted file mode 100644 index e37e78a4c63..00000000000 --- a/reactos/drivers/bus/acpi/events/evrgnini.c +++ /dev/null @@ -1,413 +0,0 @@ -/****************************************************************************** - * - * Module Name: evrgnini- ACPI Address_space (Op_region) init - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evrgnini") - - -/***************************************************************************** - * - * FUNCTION: Acpi_ev_system_memory_region_setup - * - * PARAMETERS: Region_obj - region we are interested in - * Function - start or stop - * Handler_context - Address space handler context - * Region_context - Region specific context - * - * RETURN: Status - * - * DESCRIPTION: Do any prep work for region handling, a nop for now - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ev_system_memory_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **region_context) -{ - - if (function == ACPI_REGION_DEACTIVATE) { - if (*region_context) { - acpi_cm_free (*region_context); - *region_context = NULL; - } - return (AE_OK); - } - - - /* Activate. Create a new context */ - - *region_context = acpi_cm_callocate (sizeof (MEM_HANDLER_CONTEXT)); - if (!(*region_context)) { - return (AE_NO_MEMORY); - } - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ev_io_space_region_setup - * - * PARAMETERS: Region_obj - region we are interested in - * Function - start or stop - * Handler_context - Address space handler context - * Region_context - Region specific context - * - * RETURN: Status - * - * DESCRIPTION: Do any prep work for region handling - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ev_io_space_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **region_context) -{ - if (function == ACPI_REGION_DEACTIVATE) { - *region_context = NULL; - } - else { - *region_context = handler_context; - } - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ev_pci_config_region_setup - * - * PARAMETERS: Region_obj - region we are interested in - * Function - start or stop - * Handler_context - Address space handler context - * Region_context - Region specific context - * - * RETURN: Status - * - * DESCRIPTION: Do any prep work for region handling - * - * MUTEX: Assumes namespace is not locked - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ev_pci_config_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **region_context) -{ - ACPI_STATUS status = AE_OK; - ACPI_INTEGER temp; - PCI_HANDLER_CONTEXT *pci_context = *region_context; - ACPI_OPERAND_OBJECT *handler_obj; - ACPI_NAMESPACE_NODE *node; - ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle; - DEVICE_ID object_hID; - - handler_obj = region_obj->region.addr_handler; - - if (!handler_obj) { - /* - * No installed handler. This shouldn't happen because the dispatch - * routine checks before we get here, but we check again just in case. - */ - return(AE_NOT_EXIST); - } - - if (function == ACPI_REGION_DEACTIVATE) { - if (pci_context) { - acpi_cm_free (pci_context); - *region_context = NULL; - } - - return (status); - } - - - /* Create a new context */ - - pci_context = acpi_cm_callocate (sizeof(PCI_HANDLER_CONTEXT)); - if (!pci_context) { - return (AE_NO_MEMORY); - } - - /* - * For PCI Config space access, we have to pass the segment, bus, - * device and function numbers. This routine must acquire those. - */ - - /* - * First get device and function numbers from the _ADR object - * in the parent's scope. - */ - ACPI_ASSERT(region_obj->region.node); - - node = acpi_ns_get_parent_object (region_obj->region.node); - - - /* Acpi_evaluate the _ADR object */ - - status = acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR, node, &temp); - /* - * The default is zero, since the allocation above zeroed the data, just - * do nothing on failures. - */ - if (ACPI_SUCCESS (status)) { - /* - * Got it.. - */ - pci_context->dev_func = (u32) temp; - } - - /* - * Get the _SEG and _BBN values from the device upon which the handler - * is installed. - * - * We need to get the _SEG and _BBN objects relative to the PCI BUS device. - * This is the device the handler has been registered to handle. - */ - - /* - * If the Addr_handler.Node is still pointing to the root, we need - * to scan upward for a PCI Root bridge and re-associate the Op_region - * handlers with that device. - */ - if (handler_obj->addr_handler.node == acpi_gbl_root_node) { - /* - * Node is currently the parent object - */ - while (node != acpi_gbl_root_node) { - status = acpi_cm_execute_HID(node, &object_hID); - - if (ACPI_SUCCESS (status)) { - if (!(STRNCMP(object_hID.buffer, PCI_ROOT_HID_STRING, - sizeof (PCI_ROOT_HID_STRING)))) { - acpi_install_address_space_handler(node, - ADDRESS_SPACE_PCI_CONFIG, - ACPI_DEFAULT_HANDLER, NULL, NULL); - - break; - } - } - - node = acpi_ns_get_parent_object(node); - } - } - else { - node = handler_obj->addr_handler.node; - } - - status = acpi_cm_evaluate_numeric_object (METHOD_NAME__SEG, node, &temp); - if (ACPI_SUCCESS (status)) { - /* - * Got it.. - */ - pci_context->seg = (u32) temp; - } - - status = acpi_cm_evaluate_numeric_object (METHOD_NAME__BBN, node, &temp); - if (ACPI_SUCCESS (status)) { - /* - * Got it.. - */ - pci_context->bus = (u32) temp; - } - - *region_context = pci_context; - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_ev_default_region_setup - * - * PARAMETERS: Region_obj - region we are interested in - * Function - start or stop - * Handler_context - Address space handler context - * Region_context - Region specific context - * - * RETURN: Status - * - * DESCRIPTION: Do any prep work for region handling - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ev_default_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **region_context) -{ - if (function == ACPI_REGION_DEACTIVATE) { - *region_context = NULL; - } - else { - *region_context = handler_context; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_initialize_region - * - * PARAMETERS: Region_obj - Region we are initializing - * - * RETURN: Status - * - * DESCRIPTION: Initializes the region, finds any _REG methods and saves them - * for execution at a later time - * - * Get the appropriate address space handler for a newly - * created region. - * - * This also performs address space specific intialization. For - * example, PCI regions must have an _ADR object that contains - * a PCI address in the scope of the defintion. This address is - * required to perform an access to PCI config space. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ev_initialize_region ( - ACPI_OPERAND_OBJECT *region_obj, - u8 acpi_ns_locked) -{ - ACPI_OPERAND_OBJECT *handler_obj; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_ADDRESS_SPACE_TYPE space_id; - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *method_node; - ACPI_NAME *reg_name_ptr = (ACPI_NAME *) METHOD_NAME__REG; - - - if (!region_obj) { - return (AE_BAD_PARAMETER); - } - - ACPI_ASSERT(region_obj->region.node); - - node = acpi_ns_get_parent_object (region_obj->region.node); - space_id = region_obj->region.space_id; - - region_obj->region.addr_handler = NULL; - region_obj->region.extra->extra.method_REG = NULL; - region_obj->region.flags &= ~(AOPOBJ_INITIALIZED); - - /* - * Find any "_REG" associated with this region definition - */ - status = acpi_ns_search_node (*reg_name_ptr, node, - ACPI_TYPE_METHOD, &method_node); - if (ACPI_SUCCESS (status)) { - /* - * The _REG method is optional and there can be only one per region - * definition. This will be executed when the handler is attached - * or removed - */ - region_obj->region.extra->extra.method_REG = method_node; - } - - /* - * The following loop depends upon the root Node having no parent - * ie: Acpi_gbl_Root_node->Parent_entry being set to NULL - */ - while (node) { - /* - * Check to see if a handler exists - */ - handler_obj = NULL; - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); - if (obj_desc) { - /* - * can only be a handler if the object exists - */ - switch (node->type) { - case ACPI_TYPE_DEVICE: - - handler_obj = obj_desc->device.addr_handler; - break; - - case ACPI_TYPE_PROCESSOR: - - handler_obj = obj_desc->processor.addr_handler; - break; - - case ACPI_TYPE_THERMAL: - - handler_obj = obj_desc->thermal_zone.addr_handler; - break; - } - - while (handler_obj) { - /* - * This guy has at least one address handler - * see if it has the type we want - */ - if (handler_obj->addr_handler.space_id == space_id) { - /* - * Found it! Now update the region and the handler - */ - acpi_ev_associate_region_and_handler (handler_obj, region_obj, acpi_ns_locked); - return (AE_OK); - } - - handler_obj = handler_obj->addr_handler.next; - - } /* while handlerobj */ - } - - /* - * This one does not have the handler we need - * Pop up one level - */ - node = acpi_ns_get_parent_object (node); - - } /* while Node != ROOT */ - - /* - * If we get here, there is no handler for this region - */ - return (AE_NOT_EXIST); -} - diff --git a/reactos/drivers/bus/acpi/events/evsci.c b/reactos/drivers/bus/acpi/events/evsci.c deleted file mode 100644 index 748c5f73904..00000000000 --- a/reactos/drivers/bus/acpi/events/evsci.c +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * - * Module Name: evsci - System Control Interrupt configuration and - * legacy to ACPI mode state transition functions - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evsci") - - -/* - * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC, - * and GENERAL respectively. These counts are modified by the ACPI interrupt - * handler. - * - * TBD: [Investigate] Note that GENERAL should probably be split out into - * one element for each bit in the GPE registers - */ - - -/******************************************************************************* - * - * FUNCTION: Acpi_ev_sci_handler - * - * PARAMETERS: Context - Calling Context - * - * RETURN: Status code indicates whether interrupt was handled. - * - * DESCRIPTION: Interrupt handler that will figure out what function or - * control method to call to deal with a SCI. Installed - * using BU interrupt support. - * - ******************************************************************************/ - -static u32 -acpi_ev_sci_handler (void *context) -{ - u32 interrupt_handled = INTERRUPT_NOT_HANDLED; - - - /* - * Make sure that ACPI is enabled by checking SCI_EN. Note that we are - * required to treat the SCI interrupt as sharable, level, active low. - */ - if (!acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) { - /* ACPI is not enabled; this interrupt cannot be for us */ - - return (INTERRUPT_NOT_HANDLED); - } - - /* - * Fixed Acpi_events: - * ------------- - * Check for and dispatch any Fixed Acpi_events that have occurred - */ - interrupt_handled |= acpi_ev_fixed_event_detect (); - - /* - * GPEs: - * ----- - * Check for and dispatch any GPEs that have occurred - */ - interrupt_handled |= acpi_ev_gpe_detect (); - - return (interrupt_handled); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_install_sci_handler - * - * PARAMETERS: none - * - * RETURN: Status - * - * DESCRIPTION: Installs SCI handler. - * - ******************************************************************************/ - -u32 -acpi_ev_install_sci_handler (void) -{ - u32 except = AE_OK; - - - except = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, - acpi_ev_sci_handler, - NULL); - - return (except); -} - - -/****************************************************************************** - - * - * FUNCTION: Acpi_ev_remove_sci_handler - * - * PARAMETERS: none - * - * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not - * installed to begin with - * - * DESCRIPTION: Restores original status of all fixed event enable bits and - * removes SCI handler. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ev_remove_sci_handler (void) -{ -#if 0 - /* TBD:[Investigate] Figure this out!! Disable all events first ??? */ - - if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (TMR_FIXED_EVENT)) { - acpi_event_disable_event (TMR_FIXED_EVENT); - } - - if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (GBL_FIXED_EVENT)) { - acpi_event_disable_event (GBL_FIXED_EVENT); - } - - if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (PWR_BTN_FIXED_EVENT)) { - acpi_event_disable_event (PWR_BTN_FIXED_EVENT); - } - - if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (SLP_BTN_FIXED_EVENT)) { - acpi_event_disable_event (SLP_BTN_FIXED_EVENT); - } - - if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (RTC_FIXED_EVENT)) { - acpi_event_disable_event (RTC_FIXED_EVENT); - } - - original_fixed_enable_bit_status = 0; - -#endif - - acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, - acpi_ev_sci_handler); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ev_restore_acpi_state - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: Restore the original ACPI state of the machine - * - ******************************************************************************/ - -void -acpi_ev_restore_acpi_state (void) -{ - u32 index; - - - /* Restore the state of the chipset enable bits. */ - - if (acpi_gbl_restore_acpi_chipset == TRUE) { - /* Restore the fixed events */ - - if (acpi_hw_register_read (ACPI_MTX_LOCK, PM1_EN) != - acpi_gbl_pm1_enable_register_save) { - acpi_hw_register_write (ACPI_MTX_LOCK, PM1_EN, - acpi_gbl_pm1_enable_register_save); - } - - - /* Ensure that all status bits are clear */ - - acpi_hw_clear_acpi_status (); - - - /* Now restore the GPEs */ - - for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) { - if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index) != - acpi_gbl_gpe0enable_register_save[index]) { - acpi_hw_register_write (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index, - acpi_gbl_gpe0enable_register_save[index]); - } - } - - /* GPE 1 present? */ - - if (acpi_gbl_FADT->gpe1_blk_len) { - for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) { - if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index) != - acpi_gbl_gpe1_enable_register_save[index]) { - acpi_hw_register_write (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index, - acpi_gbl_gpe1_enable_register_save[index]); - } - } - } - - if (acpi_hw_get_mode() != acpi_gbl_original_mode) { - acpi_hw_set_mode (acpi_gbl_original_mode); - } - } - - return; -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ev_terminate - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: free memory allocated for table storage. - * - ******************************************************************************/ - -void -acpi_ev_terminate (void) -{ - - - /* - * Free global tables, etc. - */ - - if (acpi_gbl_gpe_registers) { - acpi_cm_free (acpi_gbl_gpe_registers); - } - - if (acpi_gbl_gpe_info) { - acpi_cm_free (acpi_gbl_gpe_info); - } - - return; -} - - diff --git a/reactos/drivers/bus/acpi/events/evxface.c b/reactos/drivers/bus/acpi/events/evxface.c deleted file mode 100644 index 3322616ed6c..00000000000 --- a/reactos/drivers/bus/acpi/events/evxface.c +++ /dev/null @@ -1,604 +0,0 @@ -/****************************************************************************** - * - * Module Name: evxface - External interfaces for ACPI events - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evxface") - - -/****************************************************************************** - * - * FUNCTION: Acpi_install_fixed_event_handler - * - * PARAMETERS: Event - Event type to enable. - * Handler - Pointer to the handler function for the - * event - * Context - Value passed to the handler on each GPE - * - * RETURN: Status - * - * DESCRIPTION: Saves the pointer to the handler function and then enables the - * event. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_install_fixed_event_handler ( - u32 event, - FIXED_EVENT_HANDLER handler, - void *context) -{ - ACPI_STATUS status; - - - /* Parameter validation */ - - if (event >= NUM_FIXED_EVENTS) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_EVENTS); - - /* Don't allow two handlers. */ - - if (NULL != acpi_gbl_fixed_event_handlers[event].handler) { - status = AE_EXIST; - goto cleanup; - } - - - /* Install the handler before enabling the event - just in case... */ - - acpi_gbl_fixed_event_handlers[event].handler = handler; - acpi_gbl_fixed_event_handlers[event].context = context; - - status = acpi_enable_event (event, ACPI_EVENT_FIXED); - if (!ACPI_SUCCESS (status)) { - /* Remove the handler */ - - acpi_gbl_fixed_event_handlers[event].handler = NULL; - acpi_gbl_fixed_event_handlers[event].context = NULL; - } - - - -cleanup: - acpi_cm_release_mutex (ACPI_MTX_EVENTS); - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_remove_fixed_event_handler - * - * PARAMETERS: Event - Event type to disable. - * Handler - Address of the handler - * - * RETURN: Status - * - * DESCRIPTION: Disables the event and unregisters the event handler. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_remove_fixed_event_handler ( - u32 event, - FIXED_EVENT_HANDLER handler) -{ - ACPI_STATUS status = AE_OK; - - - /* Parameter validation */ - - if (event >= NUM_FIXED_EVENTS) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_EVENTS); - - /* Disable the event before removing the handler - just in case... */ - - status = acpi_disable_event(event, ACPI_EVENT_FIXED); - - /* Always Remove the handler */ - - acpi_gbl_fixed_event_handlers[event].handler = NULL; - acpi_gbl_fixed_event_handlers[event].context = NULL; - - - - - acpi_cm_release_mutex (ACPI_MTX_EVENTS); - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_install_notify_handler - * - * PARAMETERS: Device - The device for which notifies will be handled - * Handler_type - The type of handler: - * ACPI_SYSTEM_NOTIFY: System_handler (00-7f) - * ACPI_DEVICE_NOTIFY: Driver_handler (80-ff) - * Handler - Address of the handler - * Context - Value passed to the handler on each GPE - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for notifies on an ACPI device - * - ******************************************************************************/ - -ACPI_STATUS -acpi_install_notify_handler ( - ACPI_HANDLE device, - u32 handler_type, - NOTIFY_HANDLER handler, - void *context) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *notify_obj; - ACPI_NAMESPACE_NODE *device_node; - ACPI_STATUS status = AE_OK; - - - /* Parameter validation */ - - if ((!handler) || - (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the device handle */ - - device_node = acpi_ns_convert_handle_to_entry (device); - if (!device_node) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - /* - * Root Object: - * ------------ - * Registering a notify handler on the root object indicates that the - * caller wishes to receive notifications for all objects. Note that - * only one global handler can be regsitered (per notify type). - */ - if (device == ACPI_ROOT_OBJECT) { - /* Make sure the handler is not already installed */ - - if (((handler_type == ACPI_SYSTEM_NOTIFY) && - acpi_gbl_sys_notify.handler) || - ((handler_type == ACPI_DEVICE_NOTIFY) && - acpi_gbl_drv_notify.handler)) { - status = AE_EXIST; - goto unlock_and_exit; - } - - if (handler_type == ACPI_SYSTEM_NOTIFY) { - acpi_gbl_sys_notify.node = device_node; - acpi_gbl_sys_notify.handler = handler; - acpi_gbl_sys_notify.context = context; - } - else /* ACPI_DEVICE_NOTIFY */ { - acpi_gbl_drv_notify.node = device_node; - acpi_gbl_drv_notify.handler = handler; - acpi_gbl_drv_notify.context = context; - } - - /* Global notify handler installed */ - } - - /* - * Other Objects: - * -------------- - * Caller will only receive notifications specific to the target object. - * Note that only certain object types can receive notifications. - */ - else { - /* - * These are the ONLY objects that can receive ACPI notifications - */ - if ((device_node->type != ACPI_TYPE_DEVICE) && - (device_node->type != ACPI_TYPE_PROCESSOR) && - (device_node->type != ACPI_TYPE_POWER) && - (device_node->type != ACPI_TYPE_THERMAL)) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - /* Check for an existing internal object */ - - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) device_node); - if (obj_desc) { - - /* Object exists - make sure there's no handler */ - - if (((handler_type == ACPI_SYSTEM_NOTIFY) && - obj_desc->device.sys_handler) || - ((handler_type == ACPI_DEVICE_NOTIFY) && - obj_desc->device.drv_handler)) { - status = AE_EXIST; - goto unlock_and_exit; - } - } - - else { - /* Create a new object */ - - obj_desc = acpi_cm_create_internal_object (device_node->type); - if (!obj_desc) { - status = AE_NO_MEMORY; - goto unlock_and_exit; - } - - /* Attach new object to the Node */ - - status = acpi_ns_attach_object (device, obj_desc, (u8) device_node->type); - - if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } - } - - /* Install the handler */ - - notify_obj = acpi_cm_create_internal_object (INTERNAL_TYPE_NOTIFY); - if (!notify_obj) { - status = AE_NO_MEMORY; - goto unlock_and_exit; - } - - notify_obj->notify_handler.node = device_node; - notify_obj->notify_handler.handler = handler; - notify_obj->notify_handler.context = context; - - - if (handler_type == ACPI_SYSTEM_NOTIFY) { - obj_desc->device.sys_handler = notify_obj; - } - else /* ACPI_DEVICE_NOTIFY */ { - obj_desc->device.drv_handler = notify_obj; - } - } - -unlock_and_exit: - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_remove_notify_handler - * - * PARAMETERS: Device - The device for which notifies will be handled - * Handler_type - The type of handler: - * ACPI_SYSTEM_NOTIFY: System_handler (00-7f) - * ACPI_DEVICE_NOTIFY: Driver_handler (80-ff) - * Handler - Address of the handler - * RETURN: Status - * - * DESCRIPTION: Remove a handler for notifies on an ACPI device - * - ******************************************************************************/ - -ACPI_STATUS -acpi_remove_notify_handler ( - ACPI_HANDLE device, - u32 handler_type, - NOTIFY_HANDLER handler) -{ - ACPI_OPERAND_OBJECT *notify_obj; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_NAMESPACE_NODE *device_node; - ACPI_STATUS status = AE_OK; - - /* Parameter validation */ - - if ((!handler) || - (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the device handle */ - - device_node = acpi_ns_convert_handle_to_entry (device); - if (!device_node) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - /* - * Root Object: - * ------------ - */ - if (device == ACPI_ROOT_OBJECT) { - - if (((handler_type == ACPI_SYSTEM_NOTIFY) && - !acpi_gbl_sys_notify.handler) || - ((handler_type == ACPI_DEVICE_NOTIFY) && - !acpi_gbl_drv_notify.handler)) { - status = AE_NOT_EXIST; - goto unlock_and_exit; - } - - if (handler_type == ACPI_SYSTEM_NOTIFY) { - acpi_gbl_sys_notify.node = NULL; - acpi_gbl_sys_notify.handler = NULL; - acpi_gbl_sys_notify.context = NULL; - } - else { - acpi_gbl_drv_notify.node = NULL; - acpi_gbl_drv_notify.handler = NULL; - acpi_gbl_drv_notify.context = NULL; - } - } - - /* - * Other Objects: - * -------------- - */ - else { - /* - * These are the ONLY objects that can receive ACPI notifications - */ - if ((device_node->type != ACPI_TYPE_DEVICE) && - (device_node->type != ACPI_TYPE_PROCESSOR) && - (device_node->type != ACPI_TYPE_POWER) && - (device_node->type != ACPI_TYPE_THERMAL)) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - /* Check for an existing internal object */ - - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) device_node); - if (!obj_desc) { - status = AE_NOT_EXIST; - goto unlock_and_exit; - } - - /* Object exists - make sure there's an existing handler */ - - if (handler_type == ACPI_SYSTEM_NOTIFY) { - notify_obj = obj_desc->device.sys_handler; - } - else { - notify_obj = obj_desc->device.drv_handler; - } - - if ((!notify_obj) || - (notify_obj->notify_handler.handler != handler)) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - /* Remove the handler */ - - if (handler_type == ACPI_SYSTEM_NOTIFY) { - obj_desc->device.sys_handler = NULL; - } - else { - obj_desc->device.drv_handler = NULL; - } - - acpi_cm_remove_reference (notify_obj); - } - - -unlock_and_exit: - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_install_gpe_handler - * - * PARAMETERS: Gpe_number - The GPE number. The numbering scheme is - * bank 0 first, then bank 1. - * Type - Whether this GPE should be treated as an - * edge- or level-triggered interrupt. - * Handler - Address of the handler - * Context - Value passed to the handler on each GPE - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for a General Purpose Event. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_install_gpe_handler ( - u32 gpe_number, - u32 type, - GPE_HANDLER handler, - void *context) -{ - ACPI_STATUS status = AE_OK; - - /* Parameter validation */ - - if (!handler || (gpe_number >= NUM_GPE)) { - return (AE_BAD_PARAMETER); - } - - /* Ensure that we have a valid GPE number */ - - if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_EVENTS); - - /* Make sure that there isn't a handler there already */ - - if (acpi_gbl_gpe_info[gpe_number].handler) { - status = AE_EXIST; - goto cleanup; - } - - /* Install the handler */ - - acpi_gbl_gpe_info[gpe_number].handler = handler; - acpi_gbl_gpe_info[gpe_number].context = context; - acpi_gbl_gpe_info[gpe_number].type = (u8) type; - - /* Clear the GPE (of stale events), the enable it */ - - acpi_hw_clear_gpe (gpe_number); - acpi_hw_enable_gpe (gpe_number); - -cleanup: - acpi_cm_release_mutex (ACPI_MTX_EVENTS); - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_remove_gpe_handler - * - * PARAMETERS: Gpe_number - The event to remove a handler - * Handler - Address of the handler - * - * RETURN: Status - * - * DESCRIPTION: Remove a handler for a General Purpose Acpi_event. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_remove_gpe_handler ( - u32 gpe_number, - GPE_HANDLER handler) -{ - ACPI_STATUS status = AE_OK; - - - /* Parameter validation */ - - if (!handler || (gpe_number >= NUM_GPE)) { - return (AE_BAD_PARAMETER); - } - - /* Ensure that we have a valid GPE number */ - - if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) { - return (AE_BAD_PARAMETER); - } - - /* Disable the GPE before removing the handler */ - - acpi_hw_disable_gpe (gpe_number); - - acpi_cm_acquire_mutex (ACPI_MTX_EVENTS); - - /* Make sure that the installed handler is the same */ - - if (acpi_gbl_gpe_info[gpe_number].handler != handler) { - acpi_hw_enable_gpe (gpe_number); - status = AE_BAD_PARAMETER; - goto cleanup; - } - - /* Remove the handler */ - - acpi_gbl_gpe_info[gpe_number].handler = NULL; - acpi_gbl_gpe_info[gpe_number].context = NULL; - -cleanup: - acpi_cm_release_mutex (ACPI_MTX_EVENTS); - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_acquire_global_lock - * - * PARAMETERS: Timeout - How long the caller is willing to wait - * Out_handle - A handle to the lock if acquired - * - * RETURN: Status - * - * DESCRIPTION: Acquire the ACPI Global Lock - * - ******************************************************************************/ -ACPI_STATUS -acpi_acquire_global_lock ( - void) -{ - ACPI_STATUS status; - - - status = acpi_aml_enter_interpreter (); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * TBD: [Restructure] add timeout param to internal interface, and - * perhaps INTERPRETER_LOCKED - */ - - status = acpi_ev_acquire_global_lock (); - acpi_aml_exit_interpreter (); - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_release_global_lock - * - * PARAMETERS: Handle - Returned from Acpi_acquire_global_lock - * - * RETURN: Status - * - * DESCRIPTION: Release the ACPI Global Lock - * - ******************************************************************************/ - -ACPI_STATUS -acpi_release_global_lock ( - void) -{ - acpi_ev_release_global_lock (); - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/events/evxfevnt.c b/reactos/drivers/bus/acpi/events/evxfevnt.c deleted file mode 100644 index 439f62e7931..00000000000 --- a/reactos/drivers/bus/acpi/events/evxfevnt.c +++ /dev/null @@ -1,480 +0,0 @@ -/****************************************************************************** - * - * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evxfevnt") - - -/************************************************************************** - * - * FUNCTION: Acpi_enable - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Transfers the system into ACPI mode. - * - *************************************************************************/ - -ACPI_STATUS -acpi_enable (void) -{ - ACPI_STATUS status; - - - /* Make sure we've got ACPI tables */ - - if (!acpi_gbl_DSDT) { - return (AE_NO_ACPI_TABLES); - } - - /* Make sure the BIOS supports ACPI mode */ - - if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities()) { - return (AE_ERROR); - } - - /* Transition to ACPI mode */ - - status = acpi_hw_set_mode (SYS_MODE_ACPI); - if (ACPI_FAILURE (status)) { - return (status); - } - - return (status); -} - - -/************************************************************************** - * - * FUNCTION: Acpi_disable - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Returns the system to original ACPI/legacy mode, and - * uninstalls the SCI interrupt handler. - * - *************************************************************************/ - -ACPI_STATUS -acpi_disable (void) -{ - ACPI_STATUS status; - - - /* Restore original mode */ - - status = acpi_hw_set_mode (acpi_gbl_original_mode); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Unload the SCI interrupt handler */ - - acpi_ev_remove_sci_handler (); - acpi_ev_restore_acpi_state (); - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_enable_event - * - * PARAMETERS: Event - The fixed event or GPE to be enabled - * Type - The type of event - * - * RETURN: Status - * - * DESCRIPTION: Enable an ACPI event (fixed and general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_enable_event ( - u32 event, - u32 type) -{ - ACPI_STATUS status = AE_OK; - u32 register_id; - - - /* The Type must be either Fixed Acpi_event or GPE */ - - switch (type) { - - case ACPI_EVENT_FIXED: - - /* Decode the Fixed Acpi_event */ - - switch (event) { - case ACPI_EVENT_PMTIMER: - register_id = TMR_EN; - break; - - case ACPI_EVENT_GLOBAL: - register_id = GBL_EN; - break; - - case ACPI_EVENT_POWER_BUTTON: - register_id = PWRBTN_EN; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - register_id = SLPBTN_EN; - break; - - case ACPI_EVENT_RTC: - register_id = RTC_EN; - break; - - default: - return (AE_BAD_PARAMETER); - break; - } - - /* - * Enable the requested fixed event (by writing a one to the - * enable register bit) - */ - - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 1); - - if (1 != acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_LOCK, register_id)) { - return (AE_NO_HARDWARE_RESPONSE); - } - - break; - - - case ACPI_EVENT_GPE: - - /* Ensure that we have a valid GPE number */ - - if ((event >= NUM_GPE) || - (acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) { - return (AE_BAD_PARAMETER); - } - - - /* Enable the requested GPE number */ - - acpi_hw_enable_gpe (event); - break; - - - default: - - status = AE_BAD_PARAMETER; - } - - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_disable_event - * - * PARAMETERS: Event - The fixed event or GPE to be enabled - * Type - The type of event - * - * RETURN: Status - * - * DESCRIPTION: Disable an ACPI event (fixed and general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_disable_event ( - u32 event, - u32 type) -{ - ACPI_STATUS status = AE_OK; - u32 register_id; - - - /* The Type must be either Fixed Acpi_event or GPE */ - - switch (type) { - - case ACPI_EVENT_FIXED: - - /* Decode the Fixed Acpi_event */ - - switch (event) { - case ACPI_EVENT_PMTIMER: - register_id = TMR_EN; - break; - - case ACPI_EVENT_GLOBAL: - register_id = GBL_EN; - break; - - case ACPI_EVENT_POWER_BUTTON: - register_id = PWRBTN_EN; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - register_id = SLPBTN_EN; - break; - - case ACPI_EVENT_RTC: - register_id = RTC_EN; - break; - - default: - return (AE_BAD_PARAMETER); - break; - } - - /* - * Disable the requested fixed event (by writing a zero to the - * enable register bit) - */ - - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 0); - - if (0 != acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_LOCK, register_id)) { - return (AE_NO_HARDWARE_RESPONSE); - } - - break; - - - case ACPI_EVENT_GPE: - - /* Ensure that we have a valid GPE number */ - - if ((event >= NUM_GPE) || - (acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) { - return (AE_BAD_PARAMETER); - } - - /* Disable the requested GPE number */ - - acpi_hw_disable_gpe (event); - break; - - - default: - status = AE_BAD_PARAMETER; - } - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_clear_event - * - * PARAMETERS: Event - The fixed event or GPE to be cleared - * Type - The type of event - * - * RETURN: Status - * - * DESCRIPTION: Clear an ACPI event (fixed and general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_clear_event ( - u32 event, - u32 type) -{ - ACPI_STATUS status = AE_OK; - u32 register_id; - - - /* The Type must be either Fixed Acpi_event or GPE */ - - switch (type) { - - case ACPI_EVENT_FIXED: - - /* Decode the Fixed Acpi_event */ - - switch (event) { - case ACPI_EVENT_PMTIMER: - register_id = TMR_STS; - break; - - case ACPI_EVENT_GLOBAL: - register_id = GBL_STS; - break; - - case ACPI_EVENT_POWER_BUTTON: - register_id = PWRBTN_STS; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - register_id = SLPBTN_STS; - break; - - case ACPI_EVENT_RTC: - register_id = RTC_STS; - break; - - default: - return (AE_BAD_PARAMETER); - break; - } - - /* - * Clear the requested fixed event (By writing a one to the - * status register bit) - */ - - acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 1); - break; - - - case ACPI_EVENT_GPE: - - /* Ensure that we have a valid GPE number */ - - if ((event >= NUM_GPE) || - (acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) { - return (AE_BAD_PARAMETER); - } - - - acpi_hw_clear_gpe (event); - break; - - - default: - - status = AE_BAD_PARAMETER; - } - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_get_event_status - * - * PARAMETERS: Event - The fixed event or GPE - * Type - The type of event - * Status - Where the current status of the event will - * be returned - * - * RETURN: Status - * - * DESCRIPTION: Obtains and returns the current status of the event - * - ******************************************************************************/ - - -ACPI_STATUS -acpi_get_event_status ( - u32 event, - u32 type, - ACPI_EVENT_STATUS *event_status) -{ - ACPI_STATUS status = AE_OK; - u32 register_id; - - - if (!event_status) { - return (AE_BAD_PARAMETER); - } - - - /* The Type must be either Fixed Acpi_event or GPE */ - - switch (type) { - - case ACPI_EVENT_FIXED: - - /* Decode the Fixed Acpi_event */ - - switch (event) { - case ACPI_EVENT_PMTIMER: - register_id = TMR_STS; - break; - - case ACPI_EVENT_GLOBAL: - register_id = GBL_STS; - break; - - case ACPI_EVENT_POWER_BUTTON: - register_id = PWRBTN_STS; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - register_id = SLPBTN_STS; - break; - - case ACPI_EVENT_RTC: - register_id = RTC_STS; - break; - - default: - return (AE_BAD_PARAMETER); - break; - } - - /* Get the status of the requested fixed event */ - - *event_status = acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, register_id); - break; - - - case ACPI_EVENT_GPE: - - /* Ensure that we have a valid GPE number */ - - if ((event >= NUM_GPE) || - (acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) { - return (AE_BAD_PARAMETER); - } - - - /* Obtain status on the requested GPE number */ - - acpi_hw_get_gpe_status (event, event_status); - break; - - - default: - status = AE_BAD_PARAMETER; - } - - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/events/evxfregn.c b/reactos/drivers/bus/acpi/events/evxfregn.c deleted file mode 100644 index e9d720e924a..00000000000 --- a/reactos/drivers/bus/acpi/events/evxfregn.c +++ /dev/null @@ -1,373 +0,0 @@ -/****************************************************************************** - * - * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and - * Address Spaces. - * $Revision: 1.2 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_EVENTS - MODULE_NAME ("evxfregn") - - -/****************************************************************************** - * - * FUNCTION: Acpi_install_address_space_handler - * - * PARAMETERS: Device - Handle for the device - * Space_id - The address space ID - * Handler - Address of the handler - * Setup - Address of the setup function - * Context - Value passed to the handler on each access - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for all Op_regions of a given Space_id. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_install_address_space_handler ( - ACPI_HANDLE device, - ACPI_ADDRESS_SPACE_TYPE space_id, - ADDRESS_SPACE_HANDLER handler, - ADDRESS_SPACE_SETUP setup, - void *context) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *handler_obj; - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status = AE_OK; - OBJECT_TYPE_INTERNAL type; - u16 flags = 0; - - - /* Parameter validation */ - - if ((!device) || - ((!handler) && (handler != ACPI_DEFAULT_HANDLER))) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the device handle */ - - node = acpi_ns_convert_handle_to_entry (device); - if (!node) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - /* - * This registration is valid for only the types below - * and the root. This is where the default handlers - * get placed. - */ - - if ((node->type != ACPI_TYPE_DEVICE) && - (node->type != ACPI_TYPE_PROCESSOR) && - (node->type != ACPI_TYPE_THERMAL) && - (node != acpi_gbl_root_node)) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - if (handler == ACPI_DEFAULT_HANDLER) { - flags = ADDR_HANDLER_DEFAULT_INSTALLED; - - switch (space_id) { - case ADDRESS_SPACE_SYSTEM_MEMORY: - handler = acpi_aml_system_memory_space_handler; - setup = acpi_ev_system_memory_region_setup; - break; - - case ADDRESS_SPACE_SYSTEM_IO: - handler = acpi_aml_system_io_space_handler; - setup = acpi_ev_io_space_region_setup; - break; - - case ADDRESS_SPACE_PCI_CONFIG: - handler = acpi_aml_pci_config_space_handler; - setup = acpi_ev_pci_config_region_setup; - break; - - default: - status = AE_NOT_EXIST; - goto unlock_and_exit; - break; - } - } - - /* - * If the caller hasn't specified a setup routine, use the default - */ - if (!setup) { - setup = acpi_ev_default_region_setup; - } - - /* - * Check for an existing internal object - */ - - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); - if (obj_desc) { - /* - * The object exists. - * Make sure the handler is not already installed. - */ - - /* check the address handler the user requested */ - - handler_obj = obj_desc->device.addr_handler; - while (handler_obj) { - /* - * We have an Address handler, see if user requested this - * address space. - */ - if(handler_obj->addr_handler.space_id == space_id) { - status = AE_EXIST; - goto unlock_and_exit; - } - - /* - * Move through the linked list of handlers - */ - handler_obj = handler_obj->addr_handler.next; - } - } - - else { - /* Obj_desc does not exist, create one */ - - if (node->type == ACPI_TYPE_ANY) { - type = ACPI_TYPE_DEVICE; - } - - else { - type = node->type; - } - - obj_desc = acpi_cm_create_internal_object (type); - if (!obj_desc) { - status = AE_NO_MEMORY; - goto unlock_and_exit; - } - - /* Init new descriptor */ - - obj_desc->common.type = (u8) type; - - /* Attach the new object to the Node */ - - status = acpi_ns_attach_object (node, obj_desc, (u8) type); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (obj_desc); - goto unlock_and_exit; - } - } - - /* - * Now we can install the handler - * - * At this point we know that there is no existing handler. - * So, we just allocate the object for the handler and link it - * into the list. - */ - handler_obj = acpi_cm_create_internal_object (INTERNAL_TYPE_ADDRESS_HANDLER); - if (!handler_obj) { - status = AE_NO_MEMORY; - goto unlock_and_exit; - } - - handler_obj->addr_handler.space_id = (u8) space_id; - handler_obj->addr_handler.hflags = flags; - handler_obj->addr_handler.next = obj_desc->device.addr_handler; - handler_obj->addr_handler.region_list = NULL; - handler_obj->addr_handler.node = node; - handler_obj->addr_handler.handler = handler; - handler_obj->addr_handler.context = context; - handler_obj->addr_handler.setup = setup; - - /* - * Now walk the namespace finding all of the regions this - * handler will manage. - * - * We start at the device and search the branch toward - * the leaf nodes until either the leaf is encountered or - * a device is detected that has an address handler of the - * same type. - * - * In either case we back up and search down the remainder - * of the branch - */ - status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, device, - ACPI_UINT32_MAX, NS_WALK_UNLOCK, - acpi_ev_addr_handler_helper, - handler_obj, NULL); - - /* - * Place this handler 1st on the list - */ - - handler_obj->common.reference_count = - (u16) (handler_obj->common.reference_count + - obj_desc->common.reference_count - 1); - obj_desc->device.addr_handler = handler_obj; - - -unlock_and_exit: - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_remove_address_space_handler - * - * PARAMETERS: Space_id - The address space ID - * Handler - Address of the handler - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for accesses on an Operation Region - * - ******************************************************************************/ - -ACPI_STATUS -acpi_remove_address_space_handler ( - ACPI_HANDLE device, - ACPI_ADDRESS_SPACE_TYPE space_id, - ADDRESS_SPACE_HANDLER handler) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *handler_obj; - ACPI_OPERAND_OBJECT *region_obj; - ACPI_OPERAND_OBJECT **last_obj_ptr; - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status = AE_OK; - - - /* Parameter validation */ - - if ((!device) || - ((!handler) && (handler != ACPI_DEFAULT_HANDLER))) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the device handle */ - - node = acpi_ns_convert_handle_to_entry (device); - if (!node) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - - /* Make sure the internal object exists */ - - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); - if (!obj_desc) { - /* - * The object DNE. - */ - status = AE_NOT_EXIST; - goto unlock_and_exit; - } - - /* - * find the address handler the user requested - */ - - handler_obj = obj_desc->device.addr_handler; - last_obj_ptr = &obj_desc->device.addr_handler; - while (handler_obj) { - /* - * We have a handler, see if user requested this one - */ - - if(handler_obj->addr_handler.space_id == space_id) { - /* - * Got it, first dereference this in the Regions - */ - region_obj = handler_obj->addr_handler.region_list; - - /* Walk the handler's region list */ - - while (region_obj) { - /* - * First disassociate the handler from the region. - * - * NOTE: this doesn't mean that the region goes away - * The region is just inaccessible as indicated to - * the _REG method - */ - acpi_ev_disassociate_region_from_handler(region_obj, FALSE); - - /* - * Walk the list, since we took the first region and it - * was removed from the list by the dissassociate call - * we just get the first item on the list again - */ - region_obj = handler_obj->addr_handler.region_list; - - } - - /* - * Remove this Handler object from the list - */ - *last_obj_ptr = handler_obj->addr_handler.next; - - /* - * Now we can delete the handler object - */ - acpi_cm_remove_reference (handler_obj); - acpi_cm_remove_reference (handler_obj); - - goto unlock_and_exit; - } - - /* - * Move through the linked list of handlers - */ - last_obj_ptr = &handler_obj->addr_handler.next; - handler_obj = handler_obj->addr_handler.next; - } - - - /* - * The handler does not exist - */ - status = AE_NOT_EXIST; - - -unlock_and_exit: - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amconfig.c b/reactos/drivers/bus/acpi/executer/amconfig.c deleted file mode 100644 index b2e8c55e0f2..00000000000 --- a/reactos/drivers/bus/acpi/executer/amconfig.c +++ /dev/null @@ -1,297 +0,0 @@ -/****************************************************************************** - * - * Module Name: amconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amconfig") - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_load_table - * - * PARAMETERS: Rgn_desc - Op region where the table will be obtained - * Ddb_handle - Where a handle to the table will be returned - * - * RETURN: Status - * - * DESCRIPTION: Load an ACPI table - * - ****************************************************************************/ - -static ACPI_STATUS -acpi_aml_exec_load_table ( - ACPI_OPERAND_OBJECT *rgn_desc, - ACPI_HANDLE *ddb_handle) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *table_desc = NULL; - u8 *table_ptr; - u8 *table_data_ptr; - ACPI_TABLE_HEADER table_header; - ACPI_TABLE_DESC table_info; - u32 i; - - - /* TBD: [Unhandled] Object can be either a field or an opregion */ - - - /* Get the table header */ - - table_header.length = 0; - for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) { - status = acpi_ev_address_space_dispatch (rgn_desc, ADDRESS_SPACE_READ, - (ACPI_PHYSICAL_ADDRESS) i, 8, - (u32 *) ((u8 *) &table_header + i)); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - /* Allocate a buffer for the entire table */ - - table_ptr = acpi_cm_allocate (table_header.length); - if (!table_ptr) { - return (AE_NO_MEMORY); - } - - /* Copy the header to the buffer */ - - MEMCPY (table_ptr, &table_header, sizeof (ACPI_TABLE_HEADER)); - table_data_ptr = table_ptr + sizeof (ACPI_TABLE_HEADER); - - - /* Get the table from the op region */ - - for (i = 0; i < table_header.length; i++) { - status = acpi_ev_address_space_dispatch (rgn_desc, ADDRESS_SPACE_READ, - (ACPI_PHYSICAL_ADDRESS)i, 8, - (u32 *) (table_data_ptr + i)); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - } - - - /* Table must be either an SSDT or a PSDT */ - - if ((!STRNCMP (table_header.signature, - acpi_gbl_acpi_table_data[ACPI_TABLE_PSDT].signature, - acpi_gbl_acpi_table_data[ACPI_TABLE_PSDT].sig_length)) && - (!STRNCMP (table_header.signature, - acpi_gbl_acpi_table_data[ACPI_TABLE_SSDT].signature, - acpi_gbl_acpi_table_data[ACPI_TABLE_SSDT].sig_length))) { - status = AE_BAD_SIGNATURE; - goto cleanup; - } - - /* Create an object to be the table handle */ - - table_desc = acpi_cm_create_internal_object (INTERNAL_TYPE_REFERENCE); - if (!table_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - - /* Install the new table into the local data structures */ - - table_info.pointer = (ACPI_TABLE_HEADER *) table_ptr; - table_info.length = table_header.length; - table_info.allocation = ACPI_MEM_ALLOCATED; - table_info.base_pointer = table_ptr; - - status = acpi_tb_install_table (NULL, &table_info); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* Add the table to the namespace */ - - /* TBD: [Restructure] - change to whatever new interface is appropriate */ -/* - Status = Acpi_load_namespace (); - if (ACPI_FAILURE (Status)) - { -*/ - /* TBD: [Errors] Unload the table on failure ? */ -/* - goto Cleanup; - } -*/ - - - /* TBD: [Investigate] we need a pointer to the table desc */ - - /* Init the table handle */ - - table_desc->reference.opcode = AML_LOAD_OP; - table_desc->reference.object = table_info.installed_desc; - - *ddb_handle = table_desc; - - return (status); - - -cleanup: - - acpi_cm_free (table_desc); - acpi_cm_free (table_ptr); - return (status); - -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_unload_table - * - * PARAMETERS: Ddb_handle - Handle to a previously loaded table - * - * RETURN: Status - * - * DESCRIPTION: Unload an ACPI table - * - ****************************************************************************/ - -static ACPI_STATUS -acpi_aml_exec_unload_table ( - ACPI_HANDLE ddb_handle) -{ - ACPI_STATUS status = AE_NOT_IMPLEMENTED; - ACPI_OPERAND_OBJECT *table_desc = (ACPI_OPERAND_OBJECT *) ddb_handle; - ACPI_TABLE_DESC *table_info; - - - /* Validate the handle */ - /* Although the handle is partially validated in Acpi_aml_exec_reconfiguration(), - * when it calls Acpi_aml_resolve_operands(), the handle is more completely - * validated here. - */ - - if ((!ddb_handle) || - (!VALID_DESCRIPTOR_TYPE (ddb_handle, ACPI_DESC_TYPE_INTERNAL)) || - (((ACPI_OPERAND_OBJECT *)ddb_handle)->common.type != - INTERNAL_TYPE_REFERENCE)) { - return (AE_BAD_PARAMETER); - } - - - /* Get the actual table descriptor from the Ddb_handle */ - - table_info = (ACPI_TABLE_DESC *) table_desc->reference.object; - - /* - * Delete the entire namespace under this table Node - * (Offset contains the Table_id) - */ - - status = acpi_ns_delete_namespace_by_owner (table_info->table_id); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Delete the table itself */ - - acpi_tb_uninstall_table (table_info->installed_desc); - - /* Delete the table descriptor (Ddb_handle) */ - - acpi_cm_remove_reference (table_desc); - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_reconfiguration - * - * PARAMETERS: Opcode - The opcode to be executed - * Walk_state - Current state of the parse tree walk - * - * RETURN: Status - * - * DESCRIPTION: Reconfiguration opcodes such as LOAD and UNLOAD - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_reconfiguration ( - u16 opcode, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *region_desc = NULL; - ACPI_HANDLE *ddb_handle; - - - /* Resolve the operands */ - - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); - /* Get the table handle, common for both opcodes */ - - status |= acpi_ds_obj_stack_pop_object ((ACPI_OPERAND_OBJECT **) &ddb_handle, - walk_state); - - switch (opcode) { - - case AML_LOAD_OP: - - /* Get the region or field descriptor */ - - status |= acpi_ds_obj_stack_pop_object (®ion_desc, walk_state); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (region_desc); - return (status); - } - - status = acpi_aml_exec_load_table (region_desc, ddb_handle); - break; - - - case AML_UNLOAD_OP: - - if (ACPI_FAILURE (status)) { - return (status); - } - - status = acpi_aml_exec_unload_table (ddb_handle); - break; - - - default: - - status = AE_AML_BAD_OPCODE; - break; - } - - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/executer/amconvrt.c b/reactos/drivers/bus/acpi/executer/amconvrt.c deleted file mode 100644 index cb53d1429a6..00000000000 --- a/reactos/drivers/bus/acpi/executer/amconvrt.c +++ /dev/null @@ -1,511 +0,0 @@ -/****************************************************************************** - * - * Module Name: amconvrt - Object conversion routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amconvrt") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_convert_to_integer - * - * PARAMETERS: *Obj_desc - Object to be converted. Must be an - * Integer, Buffer, or String - * Walk_state - Current method state - * - * RETURN: Status - * - * DESCRIPTION: Convert an ACPI Object to an integer. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_convert_to_integer ( - ACPI_OPERAND_OBJECT **obj_desc, - ACPI_WALK_STATE *walk_state) -{ - u32 i; - ACPI_OPERAND_OBJECT *ret_desc; - u32 count; - char *pointer; - ACPI_INTEGER result; - u32 integer_size = sizeof (ACPI_INTEGER); - - - switch ((*obj_desc)->common.type) { - case ACPI_TYPE_INTEGER: - return (AE_OK); - - case ACPI_TYPE_STRING: - pointer = (*obj_desc)->string.pointer; - count = (*obj_desc)->string.length; - break; - - case ACPI_TYPE_BUFFER: - pointer = (char *) (*obj_desc)->buffer.pointer; - count = (*obj_desc)->buffer.length; - break; - - default: - return (AE_TYPE); - } - - /* - * Create a new integer - */ - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - return (AE_NO_MEMORY); - } - - - /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ - - if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) { - /* - * We are running a method that exists in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper 32-bit field - */ - integer_size = sizeof (u32); - } - - - /* - * Convert the buffer/string to an integer. Note that both buffers and - * strings are treated as raw data - we don't convert ascii to hex for - * strings. - * - * There are two terminating conditions for the loop: - * 1) The size of an integer has been reached, or - * 2) The end of the buffer or string has been reached - */ - result = 0; - - /* Transfer no more than an integer's worth of data */ - - if (count > integer_size) { - count = integer_size; - } - - /* - * String conversion is different than Buffer conversion - */ - switch ((*obj_desc)->common.type) { - case ACPI_TYPE_STRING: - - /* TBD: Need to use 64-bit STRTOUL */ - - /* - * Convert string to an integer - * String must be hexadecimal as per the ACPI specification - */ - - result = STRTOUL (pointer, NULL, 16); - break; - - - case ACPI_TYPE_BUFFER: - - /* - * Buffer conversion - we simply grab enough raw data from the - * buffer to fill an integer - */ - for (i = 0; i < count; i++) { - /* - * Get next byte and shift it into the Result. - * Little endian is used, meaning that the first byte of the buffer - * is the LSB of the integer - */ - result |= (((ACPI_INTEGER) pointer[i]) << (i * 8)); - } - - break; - } - - /* Save the Result, delete original descriptor, store new descriptor */ - - ret_desc->integer.value = result; - - if (walk_state->opcode != AML_STORE_OP) { - acpi_cm_remove_reference (*obj_desc); - } - - *obj_desc = ret_desc; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_convert_to_buffer - * - * PARAMETERS: *Obj_desc - Object to be converted. Must be an - * Integer, Buffer, or String - * Walk_state - Current method state - * - * RETURN: Status - * - * DESCRIPTION: Convert an ACPI Object to an Buffer - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_convert_to_buffer ( - ACPI_OPERAND_OBJECT **obj_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *ret_desc; - u32 i; - u32 integer_size = sizeof (ACPI_INTEGER); - u8 *new_buf; - - - switch ((*obj_desc)->common.type) { - case ACPI_TYPE_INTEGER: - - /* - * Create a new Buffer - */ - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_BUFFER); - if (!ret_desc) { - return (AE_NO_MEMORY); - } - - /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ - - if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) { - /* - * We are running a method that exists in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper - * 32-bit field - */ - integer_size = sizeof (u32); - } - - /* Need enough space for one integers */ - - ret_desc->buffer.length = integer_size; - new_buf = acpi_cm_callocate (integer_size); - if (!new_buf) { - REPORT_ERROR - (("Aml_exec_dyadic2_r/Concat_op: Buffer allocation failure\n")); - acpi_cm_remove_reference (ret_desc); - return (AE_NO_MEMORY); - } - - /* Copy the integer to the buffer */ - - for (i = 0; i < integer_size; i++) { - new_buf[i] = (u8) ((*obj_desc)->integer.value >> (i * 8)); - } - ret_desc->buffer.pointer = new_buf; - - /* Return the new buffer descriptor */ - - if (walk_state->opcode != AML_STORE_OP) { - acpi_cm_remove_reference (*obj_desc); - } - *obj_desc = ret_desc; - break; - - - case ACPI_TYPE_STRING: - break; - - - case ACPI_TYPE_BUFFER: - break; - - - default: - return (AE_TYPE); - break; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_convert_to_string - * - * PARAMETERS: *Obj_desc - Object to be converted. Must be an - * Integer, Buffer, or String - * Walk_state - Current method state - * - * RETURN: Status - * - * DESCRIPTION: Convert an ACPI Object to a string - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_convert_to_string ( - ACPI_OPERAND_OBJECT **obj_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *ret_desc; - u32 i; - u32 index; - u32 integer_size = sizeof (ACPI_INTEGER); - u8 *new_buf; - u8 *pointer; - - - switch ((*obj_desc)->common.type) { - case ACPI_TYPE_INTEGER: - - /* - * Create a new String - */ - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_STRING); - if (!ret_desc) { - return (AE_NO_MEMORY); - } - - /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ - - if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) { - /* - * We are running a method that exists in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper - * 32-bit field - */ - integer_size = sizeof (u32); - } - - /* Need enough space for one ASCII integer plus null terminator */ - - ret_desc->string.length = (integer_size * 2) + 1; - new_buf = acpi_cm_callocate (ret_desc->string.length); - if (!new_buf) { - REPORT_ERROR - (("Aml_exec_dyadic2_r/Concat_op: Buffer allocation failure\n")); - acpi_cm_remove_reference (ret_desc); - return (AE_NO_MEMORY); - } - - /* Copy the integer to the buffer */ - - for (i = 0; i < (integer_size * 2); i++) { - new_buf[i] = acpi_gbl_hex_to_ascii [((*obj_desc)->integer.value >> (i * 4)) & 0xF]; - } - - /* Null terminate */ - - new_buf [i] = 0; - ret_desc->buffer.pointer = new_buf; - - /* Return the new buffer descriptor */ - - if (walk_state->opcode != AML_STORE_OP) { - acpi_cm_remove_reference (*obj_desc); - } - *obj_desc = ret_desc; - - return (AE_OK); - - - case ACPI_TYPE_BUFFER: - - if (((*obj_desc)->buffer.length * 3) > ACPI_MAX_STRING_CONVERSION) { - return (AE_AML_STRING_LIMIT); - } - - /* - * Create a new String - */ - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_STRING); - if (!ret_desc) { - return (AE_NO_MEMORY); - } - - /* Need enough space for one ASCII integer plus null terminator */ - - ret_desc->string.length = (*obj_desc)->buffer.length * 3; - new_buf = acpi_cm_callocate (ret_desc->string.length + 1); - if (!new_buf) { - REPORT_ERROR - (("Aml_exec_dyadic2_r/Concat_op: Buffer allocation failure\n")); - acpi_cm_remove_reference (ret_desc); - return (AE_NO_MEMORY); - } - - /* - * Convert each byte of the buffer to two ASCII characters plus a space. - */ - pointer = (*obj_desc)->buffer.pointer; - index = 0; - for (i = 0; i < (*obj_desc)->buffer.length; i++) { - new_buf[index + 0] = acpi_gbl_hex_to_ascii [pointer[i] & 0x0F]; - new_buf[index + 1] = acpi_gbl_hex_to_ascii [(pointer[i] >> 4) & 0x0F]; - new_buf[index + 2] = ' '; - index += 3; - } - - /* Null terminate */ - - new_buf [index] = 0; - ret_desc->buffer.pointer = new_buf; - - /* Return the new buffer descriptor */ - - if (walk_state->opcode != AML_STORE_OP) { - acpi_cm_remove_reference (*obj_desc); - } - *obj_desc = ret_desc; - break; - - - case ACPI_TYPE_STRING: - break; - - - default: - return (AE_TYPE); - break; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_convert_to_target_type - * - * PARAMETERS: *Obj_desc - Object to be converted. - * Walk_state - Current method state - * - * RETURN: Status - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_convert_to_target_type ( - OBJECT_TYPE_INTERNAL destination_type, - ACPI_OPERAND_OBJECT **obj_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - - - /* - * If required by the target, - * perform implicit conversion on the source before we store it. - */ - - switch (GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args)) { - case ARGI_SIMPLE_TARGET: - case ARGI_FIXED_TARGET: - case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ - - switch (destination_type) { - case INTERNAL_TYPE_DEF_FIELD: - /* - * Named field can always handle conversions - */ - break; - - default: - /* No conversion allowed for these types */ - - if (destination_type != (*obj_desc)->common.type) { - status = AE_TYPE; - } - } - break; - - - case ARGI_TARGETREF: - - switch (destination_type) { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_FIELD_UNIT: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: - /* - * These types require an Integer operand. We can convert - * a Buffer or a String to an Integer if necessary. - */ - status = acpi_aml_convert_to_integer (obj_desc, walk_state); - break; - - - case ACPI_TYPE_STRING: - - /* - * The operand must be a String. We can convert an - * Integer or Buffer if necessary - */ - status = acpi_aml_convert_to_string (obj_desc, walk_state); - break; - - - case ACPI_TYPE_BUFFER: - - /* - * The operand must be a String. We can convert an - * Integer or Buffer if necessary - */ - status = acpi_aml_convert_to_buffer (obj_desc, walk_state); - break; - } - break; - - - case ARGI_REFERENCE: - /* - * Create_xxxx_field cases - we are storing the field object into the name - */ - break; - - - default: - status = AE_AML_INTERNAL; - } - - - /* - * Source-to-Target conversion semantics: - * - * If conversion to the target type cannot be performed, then simply - * overwrite the target with the new object and type. - */ - if (status == AE_TYPE) { - status = AE_OK; - } - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amcreate.c b/reactos/drivers/bus/acpi/executer/amcreate.c deleted file mode 100644 index e8c5704546d..00000000000 --- a/reactos/drivers/bus/acpi/executer/amcreate.c +++ /dev/null @@ -1,714 +0,0 @@ -/****************************************************************************** - * - * Module Name: amcreate - Named object creation - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amcreate") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_create_field - * - * PARAMETERS: Opcode - The opcode to be executed - * Operands - List of operands for the opcode - * - * RETURN: Status - * - * DESCRIPTION: Execute Create_field operators: Create_bit_field_op, - * Create_byte_field_op, Create_word_field_op, Create_dWord_field_op, - * Create_field_op (which define fields in buffers) - * - * ALLOCATION: Deletes Create_field_op's count operand descriptor - * - * - * ACPI SPECIFICATION REFERENCES: - * Def_create_bit_field := Create_bit_field_op Src_buf Bit_idx Name_string - * Def_create_byte_field := Create_byte_field_op Src_buf Byte_idx Name_string - * Def_create_dWord_field := Create_dWord_field_op Src_buf Byte_idx Name_string - * Def_create_field := Create_field_op Src_buf Bit_idx Num_bits Name_string - * Def_create_word_field := Create_word_field_op Src_buf Byte_idx Name_string - * Bit_index := Term_arg=>Integer - * Byte_index := Term_arg=>Integer - * Num_bits := Term_arg=>Integer - * Source_buff := Term_arg=>Buffer - * - ******************************************************************************/ - - -ACPI_STATUS -acpi_aml_exec_create_field ( - u8 *aml_ptr, - u32 aml_length, - ACPI_NAMESPACE_NODE *node, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *tmp_desc; - - - /* Create the region descriptor */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_FIELD_UNIT); - if (!obj_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* Construct the field object */ - - obj_desc->field_unit.access = (u8) ACCESS_ANY_ACC; - obj_desc->field_unit.lock_rule = (u8) GLOCK_NEVER_LOCK; - obj_desc->field_unit.update_rule = (u8) UPDATE_PRESERVE; - - /* - * Allocate a method object for this field unit - */ - - obj_desc->field_unit.extra = acpi_cm_create_internal_object ( - INTERNAL_TYPE_EXTRA); - if (!obj_desc->field_unit.extra) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* - * Remember location in AML stream of the field unit - * opcode and operands -- since the buffer and index - * operands must be evaluated. - */ - - obj_desc->field_unit.extra->extra.pcode = aml_ptr; - obj_desc->field_unit.extra->extra.pcode_length = aml_length; - obj_desc->field_unit.node = node; - - - /* - * This operation is supposed to cause the destination Name to refer - * to the defined Field_unit -- it must not store the constructed - * Field_unit object (or its current value) in some location that the - * Name may already be pointing to. So, if the Name currently contains - * a reference which would cause Acpi_aml_exec_store() to perform an indirect - * store rather than setting the value of the Name itself, clobber that - * reference before calling Acpi_aml_exec_store(). - */ - - /* Type of Name's existing value */ - - switch (acpi_ns_get_type (node)) { - - case ACPI_TYPE_FIELD_UNIT: - - case INTERNAL_TYPE_ALIAS: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_DEF_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: - - tmp_desc = acpi_ns_get_attached_object (node); - if (tmp_desc) { - /* - * There is an existing object here; delete it and zero out the - * object field within the Node - */ - - acpi_cm_remove_reference (tmp_desc); - acpi_ns_attach_object ((ACPI_NAMESPACE_NODE *) node, NULL, - ACPI_TYPE_ANY); - } - - /* Set the type to ANY (or the store below will fail) */ - - ((ACPI_NAMESPACE_NODE *) node)->type = ACPI_TYPE_ANY; - - break; - - - default: - - break; - } - - - /* Store constructed field descriptor in result location */ - - status = acpi_aml_exec_store (obj_desc, (ACPI_OPERAND_OBJECT *) node, walk_state); - - /* - * If the field descriptor was not physically stored (or if a failure - * above), we must delete it - */ - if (obj_desc->common.reference_count <= 1) { - acpi_cm_remove_reference (obj_desc); - } - - - return (AE_OK); - - -cleanup: - - /* Delete region object and method subobject */ - - if (obj_desc) { - /* Remove deletes both objects! */ - - acpi_cm_remove_reference (obj_desc); - obj_desc = NULL; - } - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_create_alias - * - * PARAMETERS: Operands - List of operands for the opcode - * - * RETURN: Status - * - * DESCRIPTION: Create a new named alias - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_create_alias ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_NAMESPACE_NODE *source_node; - ACPI_NAMESPACE_NODE *alias_node; - ACPI_STATUS status; - - - /* Get the source/alias operands (both NTEs) */ - - status = acpi_ds_obj_stack_pop_object ((ACPI_OPERAND_OBJECT **) &source_node, - walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Don't pop it, it gets removed in the calling routine - */ - - alias_node = acpi_ds_obj_stack_get_value (0, walk_state); - - /* Add an additional reference to the object */ - - acpi_cm_add_reference (source_node->object); - - /* - * Attach the original source Node to the new Alias Node. - */ - status = acpi_ns_attach_object (alias_node, source_node->object, - source_node->type); - - - /* - * The new alias assumes the type of the source, but it points - * to the same object. The reference count of the object has two - * additional references to prevent deletion out from under either the - * source or the alias Node - */ - - /* Since both operands are NTEs, we don't need to delete them */ - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_create_event - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Create a new event object - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_create_event ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - - - BREAKPOINT3; - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_EVENT); - if (!obj_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* Create the actual OS semaphore */ - - /* TBD: [Investigate] should be created with 0 or 1 units? */ - - status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 1, - &obj_desc->event.semaphore); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (obj_desc); - goto cleanup; - } - - /* Attach object to the Node */ - - status = acpi_ns_attach_object (acpi_ds_obj_stack_get_value (0, walk_state), - obj_desc, (u8) ACPI_TYPE_EVENT); - if (ACPI_FAILURE (status)) { - acpi_os_delete_semaphore (obj_desc->event.semaphore); - acpi_cm_remove_reference (obj_desc); - goto cleanup; - } - - -cleanup: - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_create_mutex - * - * PARAMETERS: Interpreter_mode - Current running mode (load1/Load2/Exec) - * Operands - List of operands for the opcode - * - * RETURN: Status - * - * DESCRIPTION: Create a new mutex object - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_create_mutex ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *sync_desc; - ACPI_OPERAND_OBJECT *obj_desc; - - - /* Get the operand */ - - status = acpi_ds_obj_stack_pop_object (&sync_desc, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Attempt to allocate a new object */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_MUTEX); - if (!obj_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* Create the actual OS semaphore */ - - status = acpi_os_create_semaphore (1, 1, &obj_desc->mutex.semaphore); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (obj_desc); - goto cleanup; - } - - obj_desc->mutex.sync_level = (u8) sync_desc->integer.value; - - /* Obj_desc was on the stack top, and the name is below it */ - - status = acpi_ns_attach_object (acpi_ds_obj_stack_get_value (0, walk_state), - obj_desc, (u8) ACPI_TYPE_MUTEX); - if (ACPI_FAILURE (status)) { - acpi_os_delete_semaphore (obj_desc->mutex.semaphore); - acpi_cm_remove_reference (obj_desc); - goto cleanup; - } - - -cleanup: - - /* Always delete the operand */ - - acpi_cm_remove_reference (sync_desc); - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_create_region - * - * PARAMETERS: Aml_ptr - Pointer to the region declaration AML - * Aml_length - Max length of the declaration AML - * Operands - List of operands for the opcode - * Interpreter_mode - Load1/Load2/Execute - * - * RETURN: Status - * - * DESCRIPTION: Create a new operation region object - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_create_region ( - u8 *aml_ptr, - u32 aml_length, - u8 region_space, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_NAMESPACE_NODE *node; - - - /* - * Space ID must be one of the predefined IDs, or in the user-defined - * range - */ - if ((region_space >= NUM_REGION_TYPES) && - (region_space < USER_REGION_BEGIN)) { - REPORT_ERROR (("Invalid Address_space type %X\n", region_space)); - return (AE_AML_INVALID_SPACE_ID); - } - - - /* Get the Node from the object stack */ - - node = (ACPI_NAMESPACE_NODE *) acpi_ds_obj_stack_get_value (0, walk_state); - - /* Create the region descriptor */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_REGION); - if (!obj_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* - * Allocate a method object for this region. - */ - - obj_desc->region.extra = acpi_cm_create_internal_object ( - INTERNAL_TYPE_EXTRA); - if (!obj_desc->region.extra) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* - * Remember location in AML stream of address & length - * operands since they need to be evaluated at run time. - */ - - obj_desc->region.extra->extra.pcode = aml_ptr; - obj_desc->region.extra->extra.pcode_length = aml_length; - - /* Init the region from the operands */ - - obj_desc->region.space_id = region_space; - obj_desc->region.address = 0; - obj_desc->region.length = 0; - - - /* Install the new region object in the parent Node */ - - obj_desc->region.node = node; - - status = acpi_ns_attach_object (node, obj_desc, - (u8) ACPI_TYPE_REGION); - - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* - * If we have a valid region, initialize it - * Namespace is NOT locked at this point. - */ - - status = acpi_ev_initialize_region (obj_desc, FALSE); - - if (ACPI_FAILURE (status)) { - /* - * If AE_NOT_EXIST is returned, it is not fatal - * because many regions get created before a handler - * is installed for said region. - */ - if (AE_NOT_EXIST == status) { - status = AE_OK; - } - } - -cleanup: - - if (ACPI_FAILURE (status)) { - /* Delete region object and method subobject */ - - if (obj_desc) { - /* Remove deletes both objects! */ - - acpi_cm_remove_reference (obj_desc); - obj_desc = NULL; - } - } - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_create_processor - * - * PARAMETERS: Op - Op containing the Processor definition and - * args - * Processor_nTE - Node for the containing Node - * - * RETURN: Status - * - * DESCRIPTION: Create a new processor object and populate the fields - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_create_processor ( - ACPI_PARSE_OBJECT *op, - ACPI_HANDLE processor_nTE) -{ - ACPI_STATUS status; - ACPI_PARSE_OBJECT *arg; - ACPI_OPERAND_OBJECT *obj_desc; - - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_PROCESSOR); - if (!obj_desc) { - status = AE_NO_MEMORY; - return (status); - } - - /* Install the new processor object in the parent Node */ - - status = acpi_ns_attach_object (processor_nTE, obj_desc, - (u8) ACPI_TYPE_PROCESSOR); - if (ACPI_FAILURE (status)) { - return(status); - } - - arg = op->value.arg; - - /* check existence */ - - if (!arg) { - status = AE_AML_NO_OPERAND; - return (status); - } - - /* First arg is the Processor ID */ - - obj_desc->processor.proc_id = (u8) arg->value.integer; - - /* Move to next arg and check existence */ - - arg = arg->next; - if (!arg) { - status = AE_AML_NO_OPERAND; - return (status); - } - - /* Second arg is the PBlock Address */ - - obj_desc->processor.address = (ACPI_IO_ADDRESS) arg->value.integer; - - /* Move to next arg and check existence */ - - arg = arg->next; - if (!arg) { - status = AE_AML_NO_OPERAND; - return (status); - } - - /* Third arg is the PBlock Length */ - - obj_desc->processor.length = (u8) arg->value.integer; - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_create_power_resource - * - * PARAMETERS: Op - Op containing the Power_resource definition - * and args - * Power_res_nTE - Node for the containing Node - * - * RETURN: Status - * - * DESCRIPTION: Create a new Power_resource object and populate the fields - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_create_power_resource ( - ACPI_PARSE_OBJECT *op, - ACPI_HANDLE power_res_nTE) -{ - ACPI_STATUS status; - ACPI_PARSE_OBJECT *arg; - ACPI_OPERAND_OBJECT *obj_desc; - - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_POWER); - if (!obj_desc) { - status = AE_NO_MEMORY; - return (status); - } - - /* Install the new power resource object in the parent Node */ - - status = acpi_ns_attach_object (power_res_nTE, obj_desc, - (u8) ACPI_TYPE_POWER); - if (ACPI_FAILURE (status)) { - return(status); - } - - arg = op->value.arg; - - /* check existence */ - - if (!arg) { - status = AE_AML_NO_OPERAND; - return (status); - } - - /* First arg is the System_level */ - - obj_desc->power_resource.system_level = (u8) arg->value.integer; - - /* Move to next arg and check existence */ - - arg = arg->next; - if (!arg) { - status = AE_AML_NO_OPERAND; - return (status); - } - - /* Second arg is the PBlock Address */ - - obj_desc->power_resource.resource_order = (u16) arg->value.integer; - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_exec_create_method - * - * PARAMETERS: Aml_ptr - First byte of the method's AML - * Aml_length - AML byte count for this method - * Method_flags - AML method flag byte - * Method - Method Node - * - * RETURN: Status - * - * DESCRIPTION: Create a new method object - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_create_method ( - u8 *aml_ptr, - u32 aml_length, - u32 method_flags, - ACPI_HANDLE method) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - /* Create a new method object */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_METHOD); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - /* Get the method's AML pointer/length from the Op */ - - obj_desc->method.pcode = aml_ptr; - obj_desc->method.pcode_length = aml_length; - - /* - * First argument is the Method Flags (contains parameter count for the - * method) - */ - - obj_desc->method.method_flags = (u8) method_flags; - obj_desc->method.param_count = (u8) (method_flags & - METHOD_FLAGS_ARG_COUNT); - - /* - * Get the concurrency count. If required, a semaphore will be - * created for this method when it is parsed. - */ - if (method_flags & METHOD_FLAGS_SERIALIZED) { - /* - * ACPI 1.0: Concurrency = 1 - * ACPI 2.0: Concurrency = (Sync_level (in method declaration) + 1) - */ - obj_desc->method.concurrency = (u8) - (((method_flags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1); - } - - else { - obj_desc->method.concurrency = INFINITE_CONCURRENCY; - } - - /* Attach the new object to the method Node */ - - status = acpi_ns_attach_object (method, obj_desc, (u8) ACPI_TYPE_METHOD); - if (ACPI_FAILURE (status)) { - acpi_cm_delete_object_desc (obj_desc); - } - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amdump.c b/reactos/drivers/bus/acpi/executer/amdump.c deleted file mode 100644 index 4f04ee97033..00000000000 --- a/reactos/drivers/bus/acpi/executer/amdump.c +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * - * Module Name: amdump - Interpreter debug output routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amdump") - - -/* - * The following routines are used for debug output only - */ - - diff --git a/reactos/drivers/bus/acpi/executer/amdyadic.c b/reactos/drivers/bus/acpi/executer/amdyadic.c deleted file mode 100644 index 66744f89b6f..00000000000 --- a/reactos/drivers/bus/acpi/executer/amdyadic.c +++ /dev/null @@ -1,870 +0,0 @@ -/****************************************************************************** - * - * Module Name: amdyadic - ACPI AML (p-code) execution for dyadic operators - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amdyadic") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_do_concatenate - * - * PARAMETERS: *Obj_desc - Object to be converted. Must be an - * Integer, Buffer, or String - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_do_concatenate ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_OPERAND_OBJECT *obj_desc2, - ACPI_OPERAND_OBJECT **actual_ret_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - u32 i; - ACPI_INTEGER this_integer; - ACPI_OPERAND_OBJECT *ret_desc; - NATIVE_CHAR *new_buf; - u32 integer_size = sizeof (ACPI_INTEGER); - - - /* - * There are three cases to handle: - * 1) Two Integers concatenated to produce a buffer - * 2) Two Strings concatenated to produce a string - * 3) Two Buffers concatenated to produce a buffer - */ - switch (obj_desc->common.type) { - case ACPI_TYPE_INTEGER: - - /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ - - if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) { - /* - * We are running a method that exists in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper - * 32-bit field - */ - integer_size = sizeof (u32); - } - - /* Result of two integers is a buffer */ - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_BUFFER); - if (!ret_desc) { - return (AE_NO_MEMORY); - } - - /* Need enough space for two integers */ - - ret_desc->buffer.length = integer_size * 2; - new_buf = acpi_cm_callocate (ret_desc->buffer.length); - if (!new_buf) { - REPORT_ERROR - (("Aml_exec_dyadic2_r/Concat_op: Buffer allocation failure\n")); - status = AE_NO_MEMORY; - goto cleanup; - } - - ret_desc->buffer.pointer = (u8 *) new_buf; - - /* Convert the first integer */ - - this_integer = obj_desc->integer.value; - for (i = 0; i < integer_size; i++) { - new_buf[i] = (u8) this_integer; - this_integer >>= 8; - } - - /* Convert the second integer */ - - this_integer = obj_desc2->integer.value; - for (; i < (integer_size * 2); i++) { - new_buf[i] = (u8) this_integer; - this_integer >>= 8; - } - - break; - - - case ACPI_TYPE_STRING: - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_STRING); - if (!ret_desc) { - return (AE_NO_MEMORY); - } - - /* Operand1 is string */ - - new_buf = acpi_cm_allocate (obj_desc->string.length + - obj_desc2->string.length + 1); - if (!new_buf) { - REPORT_ERROR - (("Aml_exec_dyadic2_r/Concat_op: String allocation failure\n")); - status = AE_NO_MEMORY; - goto cleanup; - } - - STRCPY (new_buf, obj_desc->string.pointer); - STRCPY (new_buf + obj_desc->string.length, - obj_desc2->string.pointer); - - /* Point the return object to the new string */ - - ret_desc->string.pointer = new_buf; - ret_desc->string.length = obj_desc->string.length += - obj_desc2->string.length; - break; - - - case ACPI_TYPE_BUFFER: - - /* Operand1 is a buffer */ - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_BUFFER); - if (!ret_desc) { - return (AE_NO_MEMORY); - } - - new_buf = acpi_cm_allocate (obj_desc->buffer.length + - obj_desc2->buffer.length); - if (!new_buf) { - REPORT_ERROR - (("Aml_exec_dyadic2_r/Concat_op: Buffer allocation failure\n")); - status = AE_NO_MEMORY; - goto cleanup; - } - - MEMCPY (new_buf, obj_desc->buffer.pointer, - obj_desc->buffer.length); - MEMCPY (new_buf + obj_desc->buffer.length, obj_desc2->buffer.pointer, - obj_desc2->buffer.length); - - /* - * Point the return object to the new buffer - */ - - ret_desc->buffer.pointer = (u8 *) new_buf; - ret_desc->buffer.length = obj_desc->buffer.length + - obj_desc2->buffer.length; - break; - - default: - status = AE_AML_INTERNAL; - ret_desc = NULL; - } - - - *actual_ret_desc = ret_desc; - return (AE_OK); - - -cleanup: - - acpi_cm_remove_reference (ret_desc); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_dyadic1 - * - * PARAMETERS: Opcode - The opcode to be executed - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 1 dyadic operator with numeric operands: - * Notify_op - * - * ALLOCATION: Deletes both operands - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_dyadic1 ( - u16 opcode, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *obj_desc = NULL; - ACPI_OPERAND_OBJECT *val_desc = NULL; - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status = AE_OK; - - - /* Resolve all operands */ - - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); - /* Get the operands */ - - status |= acpi_ds_obj_stack_pop_object (&val_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - /* Invalid parameters on object stack */ - - goto cleanup; - } - - - /* Examine the opcode */ - - switch (opcode) { - - /* Def_notify := Notify_op Notify_object Notify_value */ - - case AML_NOTIFY_OP: - - /* The Obj_desc is actually an Node */ - - node = (ACPI_NAMESPACE_NODE *) obj_desc; - obj_desc = NULL; - - /* Object must be a device or thermal zone */ - - if (node && val_desc) { - switch (node->type) { - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_THERMAL: - - /* - * Dispatch the notify to the appropriate handler - * NOTE: the request is queued for execution after this method - * completes. The notify handlers are NOT invoked synchronously - * from this thread -- because handlers may in turn run other - * control methods. - */ - - status = acpi_ev_queue_notify_request (node, - (u32) val_desc->integer.value); - break; - - default: - status = AE_AML_OPERAND_TYPE; - break; - } - } - break; - - default: - - REPORT_ERROR (("Acpi_aml_exec_dyadic1: Unknown dyadic opcode %X\n", - opcode)); - status = AE_AML_BAD_OPCODE; - } - - -cleanup: - - /* Always delete both operands */ - - acpi_cm_remove_reference (val_desc); - acpi_cm_remove_reference (obj_desc); - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_dyadic2_r - * - * PARAMETERS: Opcode - The opcode to be executed - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and - * one or two result operands. - * - * ALLOCATION: Deletes one operand descriptor -- other remains on stack - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_dyadic2_r ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc) -{ - ACPI_OPERAND_OBJECT *obj_desc = NULL; - ACPI_OPERAND_OBJECT *obj_desc2 = NULL; - ACPI_OPERAND_OBJECT *res_desc = NULL; - ACPI_OPERAND_OBJECT *res_desc2 = NULL; - ACPI_OPERAND_OBJECT *ret_desc = NULL; - ACPI_OPERAND_OBJECT *ret_desc2 = NULL; - ACPI_STATUS status = AE_OK; - u32 num_operands = 3; - - - /* Resolve all operands */ - - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); - /* Get all operands */ - - if (AML_DIVIDE_OP == opcode) { - num_operands = 4; - status |= acpi_ds_obj_stack_pop_object (&res_desc2, walk_state); - } - - status |= acpi_ds_obj_stack_pop_object (&res_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&obj_desc2, walk_state); - status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* Create an internal return object if necessary */ - - switch (opcode) { - case AML_ADD_OP: - case AML_BIT_AND_OP: - case AML_BIT_NAND_OP: - case AML_BIT_OR_OP: - case AML_BIT_NOR_OP: - case AML_BIT_XOR_OP: - case AML_DIVIDE_OP: - case AML_MULTIPLY_OP: - case AML_SHIFT_LEFT_OP: - case AML_SHIFT_RIGHT_OP: - case AML_SUBTRACT_OP: - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - break; - } - - - /* - * Execute the opcode - */ - - switch (opcode) { - - /* Def_add := Add_op Operand1 Operand2 Result */ - - case AML_ADD_OP: - - ret_desc->integer.value = obj_desc->integer.value + - obj_desc2->integer.value; - break; - - - /* Def_and := And_op Operand1 Operand2 Result */ - - case AML_BIT_AND_OP: - - ret_desc->integer.value = obj_desc->integer.value & - obj_desc2->integer.value; - break; - - - /* Def_nAnd := NAnd_op Operand1 Operand2 Result */ - - case AML_BIT_NAND_OP: - - ret_desc->integer.value = ~(obj_desc->integer.value & - obj_desc2->integer.value); - break; - - - /* Def_or := Or_op Operand1 Operand2 Result */ - - case AML_BIT_OR_OP: - - ret_desc->integer.value = obj_desc->integer.value | - obj_desc2->integer.value; - break; - - - /* Def_nOr := NOr_op Operand1 Operand2 Result */ - - case AML_BIT_NOR_OP: - - ret_desc->integer.value = ~(obj_desc->integer.value | - obj_desc2->integer.value); - break; - - - /* Def_xOr := XOr_op Operand1 Operand2 Result */ - - case AML_BIT_XOR_OP: - - ret_desc->integer.value = obj_desc->integer.value ^ - obj_desc2->integer.value; - break; - - - /* Def_divide := Divide_op Dividend Divisor Remainder Quotient */ - - case AML_DIVIDE_OP: - - if (!obj_desc2->integer.value) { - REPORT_ERROR - (("Aml_exec_dyadic2_r/Divide_op: Divide by zero\n")); - - status = AE_AML_DIVIDE_BY_ZERO; - goto cleanup; - } - - ret_desc2 = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc2) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* Remainder (modulo) */ - - ret_desc->integer.value = ACPI_MODULO (obj_desc->integer.value, - obj_desc2->integer.value); - - /* Result (what we used to call the quotient) */ - - ret_desc2->integer.value = ACPI_DIVIDE (obj_desc->integer.value, - obj_desc2->integer.value); - break; - - - /* Def_multiply := Multiply_op Operand1 Operand2 Result */ - - case AML_MULTIPLY_OP: - - ret_desc->integer.value = obj_desc->integer.value * - obj_desc2->integer.value; - break; - - - /* Def_shift_left := Shift_left_op Operand Shift_count Result */ - - case AML_SHIFT_LEFT_OP: - - ret_desc->integer.value = obj_desc->integer.value << - obj_desc2->integer.value; - break; - - - /* Def_shift_right := Shift_right_op Operand Shift_count Result */ - - case AML_SHIFT_RIGHT_OP: - - ret_desc->integer.value = obj_desc->integer.value >> - obj_desc2->integer.value; - break; - - - /* Def_subtract := Subtract_op Operand1 Operand2 Result */ - - case AML_SUBTRACT_OP: - - ret_desc->integer.value = obj_desc->integer.value - - obj_desc2->integer.value; - break; - - - /* Def_concat := Concat_op Data1 Data2 Result */ - - case AML_CONCAT_OP: - - - /* - * Convert the second operand if necessary. The first operand - * determines the type of the second operand, (See the Data Types - * section of the ACPI specification.) Both object types are - * guaranteed to be either Integer/String/Buffer by the operand - * resolution mechanism above. - */ - - switch (obj_desc->common.type) { - case ACPI_TYPE_INTEGER: - status = acpi_aml_convert_to_integer (&obj_desc2, walk_state); - break; - - case ACPI_TYPE_STRING: - status = acpi_aml_convert_to_string (&obj_desc2, walk_state); - break; - - case ACPI_TYPE_BUFFER: - status = acpi_aml_convert_to_buffer (&obj_desc2, walk_state); - break; - - default: - status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* - * Both operands are now known to be the same object type - * (Both are Integer, String, or Buffer), and we can now perform the - * concatenation. - */ - status = acpi_aml_do_concatenate (obj_desc, obj_desc2, &ret_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - break; - - - default: - - REPORT_ERROR (("Acpi_aml_exec_dyadic2_r: Unknown dyadic opcode %X\n", - opcode)); - status = AE_AML_BAD_OPCODE; - goto cleanup; - } - - - /* - * Store the result of the operation (which is now in Obj_desc) into - * the result descriptor, or the location pointed to by the result - * descriptor (Res_desc). - */ - - status = acpi_aml_exec_store (ret_desc, res_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - if (AML_DIVIDE_OP == opcode) { - status = acpi_aml_exec_store (ret_desc2, res_desc2, walk_state); - - /* - * Since the remainder is not returned, remove a reference to - * the object we created earlier - */ - - acpi_cm_remove_reference (ret_desc2); - } - - -cleanup: - - /* Always delete the operands */ - - acpi_cm_remove_reference (obj_desc); - acpi_cm_remove_reference (obj_desc2); - - - /* Delete return object on error */ - - if (ACPI_FAILURE (status)) { - /* On failure, delete the result ops */ - - acpi_cm_remove_reference (res_desc); - acpi_cm_remove_reference (res_desc2); - - if (ret_desc) { - /* And delete the internal return object */ - - acpi_cm_remove_reference (ret_desc); - ret_desc = NULL; - } - } - - /* Set the return object and exit */ - - *return_desc = ret_desc; - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_dyadic2_s - * - * PARAMETERS: Opcode - The opcode to be executed - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 2 dyadic synchronization operator - * - * ALLOCATION: Deletes one operand descriptor -- other remains on stack - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_dyadic2_s ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *time_desc; - ACPI_OPERAND_OBJECT *ret_desc = NULL; - ACPI_STATUS status; - - - /* Resolve all operands */ - - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); - /* Get all operands */ - - status |= acpi_ds_obj_stack_pop_object (&time_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - /* Invalid parameters on object stack */ - - goto cleanup; - } - - - /* Create the internal return object */ - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* Default return value is FALSE, operation did not time out */ - - ret_desc->integer.value = 0; - - - /* Examine the opcode */ - - switch (opcode) { - - /* Def_acquire := Acquire_op Mutex_object Timeout */ - - case AML_ACQUIRE_OP: - - status = acpi_aml_acquire_mutex (time_desc, obj_desc, walk_state); - break; - - - /* Def_wait := Wait_op Acpi_event_object Timeout */ - - case AML_WAIT_OP: - - status = acpi_aml_system_wait_event (time_desc, obj_desc); - break; - - - default: - - REPORT_ERROR (("Acpi_aml_exec_dyadic2_s: Unknown dyadic synchronization opcode %X\n", opcode)); - status = AE_AML_BAD_OPCODE; - goto cleanup; - } - - - /* - * Return a boolean indicating if operation timed out - * (TRUE) or not (FALSE) - */ - - if (status == AE_TIME) { - ret_desc->integer.value = ACPI_INTEGER_MAX; /* TRUE, op timed out */ - status = AE_OK; - } - - -cleanup: - - /* Delete params */ - - acpi_cm_remove_reference (time_desc); - acpi_cm_remove_reference (obj_desc); - - /* Delete return object on error */ - - if (ACPI_FAILURE (status) && - (ret_desc)) { - acpi_cm_remove_reference (ret_desc); - ret_desc = NULL; - } - - - /* Set the return object and exit */ - - *return_desc = ret_desc; - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_dyadic2 - * - * PARAMETERS: Opcode - The opcode to be executed - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and - * no result operands - * - * ALLOCATION: Deletes one operand descriptor -- other remains on stack - * containing result value - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_dyadic2 ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *obj_desc2; - ACPI_OPERAND_OBJECT *ret_desc = NULL; - ACPI_STATUS status; - u8 lboolean; - - - /* Resolve all operands */ - - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); - /* Get all operands */ - - status |= acpi_ds_obj_stack_pop_object (&obj_desc2, walk_state); - status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - /* Invalid parameters on object stack */ - - goto cleanup; - } - - - /* Create the internal return object */ - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - /* - * Execute the Opcode - */ - - lboolean = FALSE; - switch (opcode) { - - /* Def_lAnd := LAnd_op Operand1 Operand2 */ - - case AML_LAND_OP: - - lboolean = (u8) (obj_desc->integer.value && - obj_desc2->integer.value); - break; - - - /* Def_lEqual := LEqual_op Operand1 Operand2 */ - - case AML_LEQUAL_OP: - - lboolean = (u8) (obj_desc->integer.value == - obj_desc2->integer.value); - break; - - - /* Def_lGreater := LGreater_op Operand1 Operand2 */ - - case AML_LGREATER_OP: - - lboolean = (u8) (obj_desc->integer.value > - obj_desc2->integer.value); - break; - - - /* Def_lLess := LLess_op Operand1 Operand2 */ - - case AML_LLESS_OP: - - lboolean = (u8) (obj_desc->integer.value < - obj_desc2->integer.value); - break; - - - /* Def_lOr := LOr_op Operand1 Operand2 */ - - case AML_LOR_OP: - - lboolean = (u8) (obj_desc->integer.value || - obj_desc2->integer.value); - break; - - - default: - - REPORT_ERROR (("Acpi_aml_exec_dyadic2: Unknown dyadic opcode %X\n", opcode)); - status = AE_AML_BAD_OPCODE; - goto cleanup; - break; - } - - - /* Set return value to logical TRUE (all ones) or FALSE (zero) */ - - if (lboolean) { - ret_desc->integer.value = ACPI_INTEGER_MAX; - } - else { - ret_desc->integer.value = 0; - } - - -cleanup: - - /* Always delete operands */ - - acpi_cm_remove_reference (obj_desc); - acpi_cm_remove_reference (obj_desc2); - - - /* Delete return object on error */ - - if (ACPI_FAILURE (status) && - (ret_desc)) { - acpi_cm_remove_reference (ret_desc); - ret_desc = NULL; - } - - - /* Set the return object and exit */ - - *return_desc = ret_desc; - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amfield.c b/reactos/drivers/bus/acpi/executer/amfield.c deleted file mode 100644 index cb3007c9b70..00000000000 --- a/reactos/drivers/bus/acpi/executer/amfield.c +++ /dev/null @@ -1,274 +0,0 @@ -/****************************************************************************** - * - * Module Name: amfield - ACPI AML (p-code) execution - field manipulation - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amfield") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_setup_field - * - * PARAMETERS: *Obj_desc - Field to be read or written - * *Rgn_desc - Region containing field - * Field_bit_width - Field Width in bits (8, 16, or 32) - * - * RETURN: Status - * - * DESCRIPTION: Common processing for Acpi_aml_read_field and Acpi_aml_write_field - * - * ACPI SPECIFICATION REFERENCES: - * Each of the Type1_opcodes is defined as specified in in-line - * comments below. For each one, use the following definitions. - * - * Def_bit_field := Bit_field_op Src_buf Bit_idx Destination - * Def_byte_field := Byte_field_op Src_buf Byte_idx Destination - * Def_create_field := Create_field_op Src_buf Bit_idx Num_bits Name_string - * Def_dWord_field := DWord_field_op Src_buf Byte_idx Destination - * Def_word_field := Word_field_op Src_buf Byte_idx Destination - * Bit_index := Term_arg=>Integer - * Byte_index := Term_arg=>Integer - * Destination := Name_string - * Num_bits := Term_arg=>Integer - * Source_buf := Term_arg=>Buffer - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_setup_field ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_OPERAND_OBJECT *rgn_desc, - u32 field_bit_width) -{ - ACPI_STATUS status = AE_OK; - u32 field_byte_width; - - - /* Parameter validation */ - - if (!obj_desc || !rgn_desc) { - return (AE_AML_NO_OPERAND); - } - - if (ACPI_TYPE_REGION != rgn_desc->common.type) { - return (AE_AML_OPERAND_TYPE); - } - - - /* - * TBD: [Future] Acpi 2.0 supports Qword fields - * - * Init and validate Field width - * Possible values are 1, 2, 4 - */ - - field_byte_width = DIV_8 (field_bit_width); - - if ((field_bit_width != 8) && - (field_bit_width != 16) && - (field_bit_width != 32)) { - return (AE_AML_OPERAND_VALUE); - } - - - /* - * If the Region Address and Length have not been previously evaluated, - * evaluate them and save the results. - */ - if (!(rgn_desc->region.flags & AOPOBJ_DATA_VALID)) { - - status = acpi_ds_get_region_arguments (rgn_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - - if ((obj_desc->common.type == ACPI_TYPE_FIELD_UNIT) && - (!(obj_desc->common.flags & AOPOBJ_DATA_VALID))) { - /* - * Field Buffer and Index have not been previously evaluated, - */ - return (AE_AML_INTERNAL); - } - - if (rgn_desc->region.length < - (obj_desc->field.offset & ~((u32) field_byte_width - 1)) + - field_byte_width) { - /* - * Offset rounded up to next multiple of field width - * exceeds region length, indicate an error - */ - - return (AE_AML_REGION_LIMIT); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_access_named_field - * - * PARAMETERS: Mode - ACPI_READ or ACPI_WRITE - * Named_field - Handle for field to be accessed - * *Buffer - Value(s) to be read or written - * Buffer_length - Number of bytes to transfer - * - * RETURN: Status - * - * DESCRIPTION: Read or write a named field - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_access_named_field ( - u32 mode, - ACPI_HANDLE named_field, - void *buffer, - u32 buffer_length) -{ - ACPI_OPERAND_OBJECT *obj_desc = NULL; - ACPI_STATUS status = AE_OK; - u8 locked = FALSE; - u32 bit_granularity = 0; - u32 byte_granularity; - u32 datum_length; - u32 actual_byte_length; - u32 byte_field_length; - - - /* Parameter validation */ - - if ((!named_field) || (ACPI_READ == mode && !buffer)) { - return (AE_AML_INTERNAL); - } - - /* Get the attached field object */ - - obj_desc = acpi_ns_get_attached_object (named_field); - if (!obj_desc) { - return (AE_AML_INTERNAL); - } - - /* Check the type */ - - if (INTERNAL_TYPE_DEF_FIELD != acpi_ns_get_type (named_field)) { - return (AE_AML_OPERAND_TYPE); - } - - /* Obj_desc valid and Named_field is a defined field */ - - - /* Double-check that the attached object is also a field */ - - if (INTERNAL_TYPE_DEF_FIELD != obj_desc->common.type) { - return (AE_AML_OPERAND_TYPE); - } - - - /* - * Granularity was decoded from the field access type - * (Any_acc will be the same as Byte_acc) - */ - - bit_granularity = obj_desc->field_unit.granularity; - byte_granularity = DIV_8 (bit_granularity); - - /* - * Check if request is too large for the field, and silently truncate - * if necessary - */ - - /* TBD: [Errors] should an error be returned in this case? */ - - byte_field_length = (u32) DIV_8 (obj_desc->field_unit.length + 7); - - - actual_byte_length = buffer_length; - if (buffer_length > byte_field_length) { - actual_byte_length = byte_field_length; - } - - /* TBD: should these round down to a power of 2? */ - - if (DIV_8 (bit_granularity) > byte_field_length) { - bit_granularity = MUL_8(byte_field_length); - } - - if (byte_granularity > byte_field_length) { - byte_granularity = byte_field_length; - } - - - /* Convert byte count to datum count, round up if necessary */ - - datum_length = (actual_byte_length + (byte_granularity-1)) / byte_granularity; - - - /* Get the global lock if needed */ - - locked = acpi_aml_acquire_global_lock (obj_desc->field_unit.lock_rule); - - - /* Perform the actual read or write of the buffer */ - - switch (mode) { - case ACPI_READ: - - status = acpi_aml_read_field (obj_desc, buffer, buffer_length, - actual_byte_length, datum_length, - bit_granularity, byte_granularity); - break; - - - case ACPI_WRITE: - - status = acpi_aml_write_field (obj_desc, buffer, buffer_length, - actual_byte_length, datum_length, - bit_granularity, byte_granularity); - break; - - - default: - - status = AE_BAD_PARAMETER; - break; - } - - - /* Release global lock if we acquired it earlier */ - - acpi_aml_release_global_lock (locked); - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/executer/amfldio.c b/reactos/drivers/bus/acpi/executer/amfldio.c deleted file mode 100644 index 6804692d6ed..00000000000 --- a/reactos/drivers/bus/acpi/executer/amfldio.c +++ /dev/null @@ -1,668 +0,0 @@ -/****************************************************************************** - * - * Module Name: amfldio - Aml Field I/O - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amfldio") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_read_field_data - * - * PARAMETERS: *Obj_desc - Field to be read - * *Value - Where to store value - * Field_bit_width - Field Width in bits (8, 16, or 32) - * - * RETURN: Status - * - * DESCRIPTION: Retrieve the value of the given field - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_read_field_data ( - ACPI_OPERAND_OBJECT *obj_desc, - u32 field_byte_offset, - u32 field_bit_width, - u32 *value) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *rgn_desc = NULL; - ACPI_PHYSICAL_ADDRESS address; - u32 local_value = 0; - u32 field_byte_width; - - - /* Obj_desc is validated by callers */ - - if (obj_desc) { - rgn_desc = obj_desc->field.container; - } - - - field_byte_width = DIV_8 (field_bit_width); - status = acpi_aml_setup_field (obj_desc, rgn_desc, field_bit_width); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Setup_field validated Rgn_desc and Field_bit_width */ - - if (!value) { - value = &local_value; /* support reads without saving value */ - } - - - /* - * Set offset to next multiple of field width, - * add region base address and offset within the field - */ - address = rgn_desc->region.address + - (obj_desc->field.offset * field_byte_width) + - field_byte_offset; - - - /* Invoke the appropriate Address_space/Op_region handler */ - - status = acpi_ev_address_space_dispatch (rgn_desc, ADDRESS_SPACE_READ, - address, field_bit_width, value); - - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_read_field - * - * PARAMETERS: *Obj_desc - Field to be read - * *Value - Where to store value - * Field_bit_width - Field Width in bits (8, 16, or 32) - * - * RETURN: Status - * - * DESCRIPTION: Retrieve the value of the given field - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_read_field ( - ACPI_OPERAND_OBJECT *obj_desc, - void *buffer, - u32 buffer_length, - u32 byte_length, - u32 datum_length, - u32 bit_granularity, - u32 byte_granularity) -{ - ACPI_STATUS status; - u32 this_field_byte_offset; - u32 this_field_datum_offset; - u32 previous_raw_datum; - u32 this_raw_datum = 0; - u32 valid_field_bits; - u32 mask; - u32 merged_datum = 0; - - - /* - * Clear the caller's buffer (the whole buffer length as given) - * This is very important, especially in the cases where a byte is read, - * but the buffer is really a u32 (4 bytes). - */ - - MEMSET (buffer, 0, buffer_length); - - /* Read the first raw datum to prime the loop */ - - this_field_byte_offset = 0; - this_field_datum_offset= 0; - - status = acpi_aml_read_field_data (obj_desc, this_field_byte_offset, bit_granularity, - &previous_raw_datum); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* We might actually be done if the request fits in one datum */ - - if ((datum_length == 1) && - ((obj_desc->field.bit_offset + obj_desc->field_unit.length) <= - (u16) bit_granularity)) { - merged_datum = previous_raw_datum; - - merged_datum = (merged_datum >> obj_desc->field.bit_offset); - - valid_field_bits = obj_desc->field_unit.length % bit_granularity; - if (valid_field_bits) { - mask = (((u32) 1 << valid_field_bits) - (u32) 1); - merged_datum &= mask; - } - - - /* - * Place the Merged_datum into the proper format and return buffer - * field - */ - - switch (byte_granularity) { - case 1: - ((u8 *) buffer) [this_field_datum_offset] = (u8) merged_datum; - break; - - case 2: - MOVE_UNALIGNED16_TO_16 (&(((u16 *) buffer)[this_field_datum_offset]), &merged_datum); - break; - - case 4: - MOVE_UNALIGNED32_TO_32 (&(((u32 *) buffer)[this_field_datum_offset]), &merged_datum); - break; - } - - this_field_byte_offset = 1; - this_field_datum_offset = 1; - } - - else { - /* We need to get more raw data to complete one or more field data */ - - while (this_field_datum_offset < datum_length) { - /* - * If the field is aligned on a byte boundary, we don't want - * to perform a final read, since this would potentially read - * past the end of the region. - * - * TBD: [Investigate] It may make more sense to just split the aligned - * and non-aligned cases since the aligned case is so very simple, - */ - if ((obj_desc->field.bit_offset != 0) || - ((obj_desc->field.bit_offset == 0) && - (this_field_datum_offset < (datum_length -1)))) { - /* - * Get the next raw datum, it contains some or all bits - * of the current field datum - */ - - status = acpi_aml_read_field_data (obj_desc, - this_field_byte_offset + byte_granularity, - bit_granularity, &this_raw_datum); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* Before merging the data, make sure the unused bits are clear */ - - switch (byte_granularity) { - case 1: - this_raw_datum &= 0x000000FF; - previous_raw_datum &= 0x000000FF; - break; - - case 2: - this_raw_datum &= 0x0000FFFF; - previous_raw_datum &= 0x0000FFFF; - break; - } - } - - - /* - * Put together bits of the two raw data to make a complete - * field datum - */ - - - if (obj_desc->field.bit_offset != 0) { - merged_datum = - (previous_raw_datum >> obj_desc->field.bit_offset) | - (this_raw_datum << (bit_granularity - obj_desc->field.bit_offset)); - } - - else { - merged_datum = previous_raw_datum; - } - - /* - * Prepare the merged datum for storing into the caller's - * buffer. It is possible to have a 32-bit buffer - * (Byte_granularity == 4), but a Obj_desc->Field.Length - * of 8 or 16, meaning that the upper bytes of merged data - * are undesired. This section fixes that. - */ - switch (obj_desc->field.length) { - case 8: - merged_datum &= 0x000000FF; - break; - - case 16: - merged_datum &= 0x0000FFFF; - break; - } - - /* - * Now store the datum in the caller's buffer, according to - * the data type - */ - switch (byte_granularity) { - case 1: - ((u8 *) buffer) [this_field_datum_offset] = (u8) merged_datum; - break; - - case 2: - MOVE_UNALIGNED16_TO_16 (&(((u16 *) buffer) [this_field_datum_offset]), &merged_datum); - break; - - case 4: - MOVE_UNALIGNED32_TO_32 (&(((u32 *) buffer) [this_field_datum_offset]), &merged_datum); - break; - } - - /* - * Save the most recent datum since it contains bits of - * the *next* field datum - */ - - previous_raw_datum = this_raw_datum; - - this_field_byte_offset += byte_granularity; - this_field_datum_offset++; - - } /* while */ - } - -cleanup: - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_write_field_data - * - * PARAMETERS: *Obj_desc - Field to be set - * Value - Value to store - * Field_bit_width - Field Width in bits (8, 16, or 32) - * - * RETURN: Status - * - * DESCRIPTION: Store the value into the given field - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_aml_write_field_data ( - ACPI_OPERAND_OBJECT *obj_desc, - u32 field_byte_offset, - u32 field_bit_width, - u32 value) -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *rgn_desc = NULL; - ACPI_PHYSICAL_ADDRESS address; - u32 field_byte_width; - - - /* Obj_desc is validated by callers */ - - if (obj_desc) { - rgn_desc = obj_desc->field.container; - } - - field_byte_width = DIV_8 (field_bit_width); - status = acpi_aml_setup_field (obj_desc, rgn_desc, field_bit_width); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* - * Set offset to next multiple of field width, - * add region base address and offset within the field - */ - address = rgn_desc->region.address + - (obj_desc->field.offset * field_byte_width) + - field_byte_offset; - - /* Invoke the appropriate Address_space/Op_region handler */ - - status = acpi_ev_address_space_dispatch (rgn_desc, ADDRESS_SPACE_WRITE, - address, field_bit_width, &value); - - - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_write_field_data_with_update_rule - * - * PARAMETERS: *Obj_desc - Field to be set - * Value - Value to store - * Field_bit_width - Field Width in bits (8, 16, or 32) - * - * RETURN: Status - * - * DESCRIPTION: Apply the field update rule to a field write - * - ****************************************************************************/ - -static ACPI_STATUS -acpi_aml_write_field_data_with_update_rule ( - ACPI_OPERAND_OBJECT *obj_desc, - u32 mask, - u32 field_value, - u32 this_field_byte_offset, - u32 bit_granularity) -{ - ACPI_STATUS status = AE_OK; - u32 merged_value; - u32 current_value; - - - /* Start with the new bits */ - - merged_value = field_value; - - - /* Decode the update rule */ - - switch (obj_desc->field.update_rule) { - - case UPDATE_PRESERVE: - - /* Check if update rule needs to be applied (not if mask is all ones) */ - - /* The left shift drops the bits we want to ignore. */ - if ((~mask << (sizeof(mask)*8 - bit_granularity)) != 0) { - /* - * Read the current contents of the byte/word/dword containing - * the field, and merge with the new field value. - */ - status = acpi_aml_read_field_data (obj_desc, this_field_byte_offset, - bit_granularity, ¤t_value); - merged_value |= (current_value & ~mask); - } - break; - - - case UPDATE_WRITE_AS_ONES: - - /* Set positions outside the field to all ones */ - - merged_value |= ~mask; - break; - - - case UPDATE_WRITE_AS_ZEROS: - - /* Set positions outside the field to all zeros */ - - merged_value &= mask; - break; - - - default: - status = AE_AML_OPERAND_VALUE; - } - - - /* Write the merged value */ - - if (ACPI_SUCCESS (status)) { - status = acpi_aml_write_field_data (obj_desc, this_field_byte_offset, - bit_granularity, merged_value); - } - - return (status); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_aml_write_field - * - * PARAMETERS: *Obj_desc - Field to be set - * Value - Value to store - * Field_bit_width - Field Width in bits (8, 16, or 32) - * - * RETURN: Status - * - * DESCRIPTION: Store the value into the given field - * - ****************************************************************************/ - -ACPI_STATUS -acpi_aml_write_field ( - ACPI_OPERAND_OBJECT *obj_desc, - void *buffer, - u32 buffer_length, - u32 byte_length, - u32 datum_length, - u32 bit_granularity, - u32 byte_granularity) -{ - ACPI_STATUS status; - u32 this_field_byte_offset; - u32 this_field_datum_offset; - u32 mask; - u32 merged_datum; - u32 previous_raw_datum; - u32 this_raw_datum; - u32 field_value; - u32 valid_field_bits; - - - /* - * Break the request into up to three parts: - * non-aligned part at start, aligned part in middle, non-aligned part - * at end --- Just like an I/O request --- - */ - - this_field_byte_offset = 0; - this_field_datum_offset= 0; - - /* Get a datum */ - - switch (byte_granularity) { - case 1: - previous_raw_datum = ((u8 *) buffer) [this_field_datum_offset]; - break; - - case 2: - MOVE_UNALIGNED16_TO_32 (&previous_raw_datum, &(((u16 *) buffer) [this_field_datum_offset])); - break; - - case 4: - MOVE_UNALIGNED32_TO_32 (&previous_raw_datum, &(((u32 *) buffer) [this_field_datum_offset])); - break; - - default: - status = AE_AML_OPERAND_VALUE; - goto cleanup; - } - - - /* - * Write a partial field datum if field does not begin on a datum boundary - * - * Construct Mask with 1 bits where the field is, 0 bits elsewhere - * - * 1) Bits above the field - */ - - mask = (((u32)(-1)) << (u32)obj_desc->field.bit_offset); - - /* 2) Only the bottom 5 bits are valid for a shift operation. */ - - if ((obj_desc->field.bit_offset + obj_desc->field_unit.length) < 32) { - /* Bits above the field */ - - mask &= (~(((u32)(-1)) << ((u32)obj_desc->field.bit_offset + - (u32)obj_desc->field_unit.length))); - } - - /* 3) Shift and mask the value into the field position */ - - field_value = (previous_raw_datum << obj_desc->field.bit_offset) & mask; - - status = acpi_aml_write_field_data_with_update_rule (obj_desc, mask, field_value, - this_field_byte_offset, - bit_granularity); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* If the field fits within one datum, we are done. */ - - if ((datum_length == 1) && - ((obj_desc->field.bit_offset + obj_desc->field_unit.length) <= - (u16) bit_granularity)) { - goto cleanup; - } - - /* - * We don't need to worry about the update rule for these data, because - * all of the bits are part of the field. - * - * Can't write the last datum, however, because it might contain bits that - * are not part of the field -- the update rule must be applied. - */ - - while (this_field_datum_offset < (datum_length - 1)) { - this_field_datum_offset++; - - /* Get the next raw datum, it contains bits of the current field datum... */ - - switch (byte_granularity) { - case 1: - this_raw_datum = ((u8 *) buffer) [this_field_datum_offset]; - break; - - case 2: - MOVE_UNALIGNED16_TO_32 (&this_raw_datum, &(((u16 *) buffer) [this_field_datum_offset])); - break; - - case 4: - MOVE_UNALIGNED32_TO_32 (&this_raw_datum, &(((u32 *) buffer) [this_field_datum_offset])); - break; - - default: - status = AE_AML_OPERAND_VALUE; - goto cleanup; - } - - /* - * Put together bits of the two raw data to make a complete field - * datum - */ - - if (obj_desc->field.bit_offset != 0) { - merged_datum = - (previous_raw_datum >> (bit_granularity - obj_desc->field.bit_offset)) | - (this_raw_datum << obj_desc->field.bit_offset); - } - - else { - merged_datum = this_raw_datum; - } - - /* Now write the completed datum */ - - - status = acpi_aml_write_field_data (obj_desc, - this_field_byte_offset + byte_granularity, - bit_granularity, merged_datum); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* - * Save the most recent datum since it contains bits of - * the *next* field datum - */ - - previous_raw_datum = this_raw_datum; - - this_field_byte_offset += byte_granularity; - - } /* while */ - - - /* Write a partial field datum if field does not end on a datum boundary */ - - if ((obj_desc->field_unit.length + obj_desc->field_unit.bit_offset) % - bit_granularity) { - switch (byte_granularity) { - case 1: - this_raw_datum = ((u8 *) buffer) [this_field_datum_offset]; - break; - - case 2: - MOVE_UNALIGNED16_TO_32 (&this_raw_datum, &(((u16 *) buffer) [this_field_datum_offset])); - break; - - case 4: - MOVE_UNALIGNED32_TO_32 (&this_raw_datum, &(((u32 *) buffer) [this_field_datum_offset])); - break; - } - - /* Construct Mask with 1 bits where the field is, 0 bits elsewhere */ - - valid_field_bits = ((obj_desc->field_unit.length % bit_granularity) + - obj_desc->field.bit_offset); - - mask = (((u32) 1 << valid_field_bits) - (u32) 1); - - /* Shift and mask the value into the field position */ - - field_value = (previous_raw_datum >> - (bit_granularity - obj_desc->field.bit_offset)) & mask; - - status = acpi_aml_write_field_data_with_update_rule (obj_desc, mask, field_value, - this_field_byte_offset + byte_granularity, - bit_granularity); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - } - - -cleanup: - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/ammisc.c b/reactos/drivers/bus/acpi/executer/ammisc.c deleted file mode 100644 index b4adaf1c0df..00000000000 --- a/reactos/drivers/bus/acpi/executer/ammisc.c +++ /dev/null @@ -1,510 +0,0 @@ - -/****************************************************************************** - * - * Module Name: ammisc - ACPI AML (p-code) execution - specific opcodes - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("ammisc") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_fatal - * - * PARAMETERS: none - * - * RETURN: Status. If the OS returns from the OSD call, we just keep - * on going. - * - * DESCRIPTION: Execute Fatal operator - * - * ACPI SPECIFICATION REFERENCES: - * Def_fatal := Fatal_op Fatal_type Fatal_code Fatal_arg - * Fatal_type := Byte_data - * Fatal_code := DWord_data - * Fatal_arg := Term_arg=>Integer - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_fatal ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *type_desc; - ACPI_OPERAND_OBJECT *code_desc; - ACPI_OPERAND_OBJECT *arg_desc; - ACPI_STATUS status; - - - /* Resolve operands */ - - status = acpi_aml_resolve_operands (AML_FATAL_OP, WALK_OPERANDS, walk_state); - /* Get operands */ - - status |= acpi_ds_obj_stack_pop_object (&arg_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&code_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&type_desc, walk_state); - if (ACPI_FAILURE (status)) { - /* Invalid parameters on object stack */ - - goto cleanup; - } - - - /* Def_fatal := Fatal_op Fatal_type Fatal_code Fatal_arg */ - - - /* - * TBD: [Unhandled] call OSD interface to notify OS of fatal error - * requiring shutdown! - */ - - -cleanup: - - /* Free the operands */ - - acpi_cm_remove_reference (arg_desc); - acpi_cm_remove_reference (code_desc); - acpi_cm_remove_reference (type_desc); - - - /* If we get back from the OS call, we might as well keep going. */ - - REPORT_WARNING (("An AML \"fatal\" Opcode (Fatal_op) was executed\n")); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_index - * - * PARAMETERS: none - * - * RETURN: Status - * - * DESCRIPTION: Execute Index operator - * - * ALLOCATION: Deletes one operand descriptor -- other remains on stack - * - * ACPI SPECIFICATION REFERENCES: - * Def_index := Index_op Buff_pkg_obj Index_value Result - * Index_value := Term_arg=>Integer - * Name_string := | - * Result := Super_name - * Super_name := Name_string | Arg_obj | Local_obj | Debug_obj | Def_index - * Local4_op | Local5_op | Local6_op | Local7_op - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_index ( - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *idx_desc; - ACPI_OPERAND_OBJECT *res_desc; - ACPI_OPERAND_OBJECT *ret_desc = NULL; - ACPI_OPERAND_OBJECT *tmp_desc; - ACPI_STATUS status; - - - /* Resolve operands */ - /* First operand can be either a package or a buffer */ - - status = acpi_aml_resolve_operands (AML_INDEX_OP, WALK_OPERANDS, walk_state); - /* Get all operands */ - - status |= acpi_ds_obj_stack_pop_object (&res_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&idx_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - /* Invalid parameters on object stack */ - - goto cleanup; - } - - - /* Create the internal return object */ - - ret_desc = acpi_cm_create_internal_object (INTERNAL_TYPE_REFERENCE); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - - /* - * At this point, the Obj_desc operand is either a Package or a Buffer - */ - - if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { - /* Object to be indexed is a Package */ - - if (idx_desc->integer.value >= obj_desc->package.count) { - status = AE_AML_PACKAGE_LIMIT; - goto cleanup; - } - - if ((res_desc->common.type == INTERNAL_TYPE_REFERENCE) && - (res_desc->reference.opcode == AML_ZERO_OP)) { - /* - * There is no actual result descriptor (the Zero_op Result - * descriptor is a placeholder), so just delete the placeholder and - * return a reference to the package element - */ - - acpi_cm_remove_reference (res_desc); - } - - else { - /* - * Each element of the package is an internal object. Get the one - * we are after. - */ - - tmp_desc = obj_desc->package.elements[idx_desc->integer.value]; - ret_desc->reference.opcode = AML_INDEX_OP; - ret_desc->reference.target_type = tmp_desc->common.type; - ret_desc->reference.object = tmp_desc; - - status = acpi_aml_exec_store (ret_desc, res_desc, walk_state); - ret_desc->reference.object = NULL; - } - - /* - * The local return object must always be a reference to the package element, - * not the element itself. - */ - ret_desc->reference.opcode = AML_INDEX_OP; - ret_desc->reference.target_type = ACPI_TYPE_PACKAGE; - ret_desc->reference.where = &obj_desc->package.elements[idx_desc->integer.value]; - } - - else { - /* Object to be indexed is a Buffer */ - - if (idx_desc->integer.value >= obj_desc->buffer.length) { - status = AE_AML_BUFFER_LIMIT; - goto cleanup; - } - - ret_desc->reference.opcode = AML_INDEX_OP; - ret_desc->reference.target_type = ACPI_TYPE_BUFFER_FIELD; - ret_desc->reference.object = obj_desc; - ret_desc->reference.offset = (u32) idx_desc->integer.value; - - status = acpi_aml_exec_store (ret_desc, res_desc, walk_state); - } - - -cleanup: - - /* Always delete operands */ - - acpi_cm_remove_reference (obj_desc); - acpi_cm_remove_reference (idx_desc); - - /* Delete return object on error */ - - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (res_desc); - - if (ret_desc) { - acpi_cm_remove_reference (ret_desc); - ret_desc = NULL; - } - } - - /* Set the return object and exit */ - - *return_desc = ret_desc; - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_match - * - * PARAMETERS: none - * - * RETURN: Status - * - * DESCRIPTION: Execute Match operator - * - * ACPI SPECIFICATION REFERENCES: - * Def_match := Match_op Search_pkg Opcode1 Operand1 - * Opcode2 Operand2 Start_index - * Opcode1 := Byte_data: MTR, MEQ, MLE, MLT, MGE, or MGT - * Opcode2 := Byte_data: MTR, MEQ, MLE, MLT, MGE, or MGT - * Operand1 := Term_arg=>Integer - * Operand2 := Term_arg=>Integer - * Search_pkg := Term_arg=>Package_object - * Start_index := Term_arg=>Integer - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_match ( - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc) -{ - ACPI_OPERAND_OBJECT *pkg_desc; - ACPI_OPERAND_OBJECT *op1_desc; - ACPI_OPERAND_OBJECT *V1_desc; - ACPI_OPERAND_OBJECT *op2_desc; - ACPI_OPERAND_OBJECT *V2_desc; - ACPI_OPERAND_OBJECT *start_desc; - ACPI_OPERAND_OBJECT *ret_desc = NULL; - ACPI_STATUS status; - u32 index; - u32 match_value = (u32) -1; - - - /* Resolve all operands */ - - status = acpi_aml_resolve_operands (AML_MATCH_OP, WALK_OPERANDS, walk_state); - /* Get all operands */ - - status |= acpi_ds_obj_stack_pop_object (&start_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&V2_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&op2_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&V1_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&op1_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&pkg_desc, walk_state); - - if (ACPI_FAILURE (status)) { - /* Invalid parameters on object stack */ - - goto cleanup; - } - - /* Validate match comparison sub-opcodes */ - - if ((op1_desc->integer.value > MAX_MATCH_OPERATOR) || - (op2_desc->integer.value > MAX_MATCH_OPERATOR)) { - status = AE_AML_OPERAND_VALUE; - goto cleanup; - } - - index = (u32) start_desc->integer.value; - if (index >= (u32) pkg_desc->package.count) { - status = AE_AML_PACKAGE_LIMIT; - goto cleanup; - } - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - - } - - /* - * Examine each element until a match is found. Within the loop, - * "continue" signifies that the current element does not match - * and the next should be examined. - * Upon finding a match, the loop will terminate via "break" at - * the bottom. If it terminates "normally", Match_value will be -1 - * (its initial value) indicating that no match was found. When - * returned as a Number, this will produce the Ones value as specified. - */ - - for ( ; index < pkg_desc->package.count; ++index) { - /* - * Treat any NULL or non-numeric elements as non-matching. - * TBD [Unhandled] - if an element is a Name, - * should we examine its value? - */ - if (!pkg_desc->package.elements[index] || - ACPI_TYPE_INTEGER != pkg_desc->package.elements[index]->common.type) { - continue; - } - - /* - * Within these switch statements: - * "break" (exit from the switch) signifies a match; - * "continue" (proceed to next iteration of enclosing - * "for" loop) signifies a non-match. - */ - switch (op1_desc->integer.value) { - - case MATCH_MTR: /* always true */ - - break; - - - case MATCH_MEQ: /* true if equal */ - - if (pkg_desc->package.elements[index]->integer.value - != V1_desc->integer.value) { - continue; - } - break; - - - case MATCH_MLE: /* true if less than or equal */ - - if (pkg_desc->package.elements[index]->integer.value - > V1_desc->integer.value) { - continue; - } - break; - - - case MATCH_MLT: /* true if less than */ - - if (pkg_desc->package.elements[index]->integer.value - >= V1_desc->integer.value) { - continue; - } - break; - - - case MATCH_MGE: /* true if greater than or equal */ - - if (pkg_desc->package.elements[index]->integer.value - < V1_desc->integer.value) { - continue; - } - break; - - - case MATCH_MGT: /* true if greater than */ - - if (pkg_desc->package.elements[index]->integer.value - <= V1_desc->integer.value) { - continue; - } - break; - - - default: /* undefined */ - - continue; - } - - - switch(op2_desc->integer.value) { - - case MATCH_MTR: - - break; - - - case MATCH_MEQ: - - if (pkg_desc->package.elements[index]->integer.value - != V2_desc->integer.value) { - continue; - } - break; - - - case MATCH_MLE: - - if (pkg_desc->package.elements[index]->integer.value - > V2_desc->integer.value) { - continue; - } - break; - - - case MATCH_MLT: - - if (pkg_desc->package.elements[index]->integer.value - >= V2_desc->integer.value) { - continue; - } - break; - - - case MATCH_MGE: - - if (pkg_desc->package.elements[index]->integer.value - < V2_desc->integer.value) { - continue; - } - break; - - - case MATCH_MGT: - - if (pkg_desc->package.elements[index]->integer.value - <= V2_desc->integer.value) { - continue; - } - break; - - - default: - - continue; - } - - /* Match found: exit from loop */ - - match_value = index; - break; - } - - /* Match_value is the return value */ - - ret_desc->integer.value = match_value; - - -cleanup: - - /* Free the operands */ - - acpi_cm_remove_reference (start_desc); - acpi_cm_remove_reference (V2_desc); - acpi_cm_remove_reference (op2_desc); - acpi_cm_remove_reference (V1_desc); - acpi_cm_remove_reference (op1_desc); - acpi_cm_remove_reference (pkg_desc); - - - /* Delete return object on error */ - - if (ACPI_FAILURE (status) && - (ret_desc)) { - acpi_cm_remove_reference (ret_desc); - ret_desc = NULL; - } - - - /* Set the return object and exit */ - - *return_desc = ret_desc; - return (status); -} diff --git a/reactos/drivers/bus/acpi/executer/ammonad.c b/reactos/drivers/bus/acpi/executer/ammonad.c deleted file mode 100644 index e37e27d6905..00000000000 --- a/reactos/drivers/bus/acpi/executer/ammonad.c +++ /dev/null @@ -1,957 +0,0 @@ - -/****************************************************************************** - * - * Module Name: ammonad - ACPI AML (p-code) execution for monadic operators - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("ammonad") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_get_object_reference - * - * PARAMETERS: Obj_desc - Create a reference to this object - * Ret_desc - Where to store the reference - * - * RETURN: Status - * - * DESCRIPTION: Obtain and return a "reference" to the target object - * Common code for the Ref_of_op and the Cond_ref_of_op. - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_aml_get_object_reference ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_OPERAND_OBJECT **ret_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - - - if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) { - if (obj_desc->common.type != INTERNAL_TYPE_REFERENCE) { - *ret_desc = NULL; - status = AE_TYPE; - goto cleanup; - } - - /* - * Not a Name -- an indirect name pointer would have - * been converted to a direct name pointer in Acpi_aml_resolve_operands - */ - switch (obj_desc->reference.opcode) { - case AML_LOCAL_OP: - case AML_ARG_OP: - - *ret_desc = (void *) acpi_ds_method_data_get_node (obj_desc->reference.opcode, - obj_desc->reference.offset, walk_state); - break; - - default: - - *ret_desc = NULL; - status = AE_AML_INTERNAL; - goto cleanup; - } - - } - - else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - /* Must be a named object; Just return the Node */ - - *ret_desc = obj_desc; - } - - else { - *ret_desc = NULL; - status = AE_TYPE; - } - - -cleanup: - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_monadic1 - * - * PARAMETERS: Opcode - The opcode to be executed - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on - * object stack - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_monadic1 ( - u16 opcode, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - /* Resolve all operands */ - - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); - /* Get all operands */ - - status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* Examine the opcode */ - - switch (opcode) { - - /* Def_release := Release_op Mutex_object */ - - case AML_RELEASE_OP: - - status = acpi_aml_release_mutex (obj_desc, walk_state); - break; - - - /* Def_reset := Reset_op Acpi_event_object */ - - case AML_RESET_OP: - - status = acpi_aml_system_reset_event (obj_desc); - break; - - - /* Def_signal := Signal_op Acpi_event_object */ - - case AML_SIGNAL_OP: - - status = acpi_aml_system_signal_event (obj_desc); - break; - - - /* Def_sleep := Sleep_op Msec_time */ - - case AML_SLEEP_OP: - - acpi_aml_system_do_suspend ((u32) obj_desc->integer.value); - break; - - - /* Def_stall := Stall_op Usec_time */ - - case AML_STALL_OP: - - acpi_aml_system_do_stall ((u32) obj_desc->integer.value); - break; - - - /* Unknown opcode */ - - default: - - REPORT_ERROR (("Acpi_aml_exec_monadic1: Unknown monadic opcode %X\n", - opcode)); - status = AE_AML_BAD_OPCODE; - break; - - } /* switch */ - - -cleanup: - - /* Always delete the operand */ - - acpi_cm_remove_reference (obj_desc); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_monadic2_r - * - * PARAMETERS: Opcode - The opcode to be executed - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 2 monadic operator with numeric operand and - * result operand on operand stack - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_monadic2_r ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *res_desc; - ACPI_OPERAND_OBJECT *ret_desc = NULL; - ACPI_OPERAND_OBJECT *ret_desc2 = NULL; - u32 res_val; - ACPI_STATUS status; - u32 i; - u32 j; - ACPI_INTEGER digit; - - - /* Resolve all operands */ - - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); - /* Get all operands */ - - status |= acpi_ds_obj_stack_pop_object (&res_desc, walk_state); - status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* Create a return object of type NUMBER for most opcodes */ - - switch (opcode) { - case AML_BIT_NOT_OP: - case AML_FIND_SET_LEFT_BIT_OP: - case AML_FIND_SET_RIGHT_BIT_OP: - case AML_FROM_BCD_OP: - case AML_TO_BCD_OP: - case AML_COND_REF_OF_OP: - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - break; - } - - - switch (opcode) { - /* Def_not := Not_op Operand Result */ - - case AML_BIT_NOT_OP: - - ret_desc->integer.value = ~obj_desc->integer.value; - break; - - - /* Def_find_set_left_bit := Find_set_left_bit_op Operand Result */ - - case AML_FIND_SET_LEFT_BIT_OP: - - ret_desc->integer.value = obj_desc->integer.value; - - /* - * Acpi specification describes Integer type as a little - * endian unsigned value, so this boundry condition is valid. - */ - for (res_val = 0; ret_desc->integer.value && res_val < ACPI_INTEGER_BIT_SIZE; ++res_val) { - ret_desc->integer.value >>= 1; - } - - ret_desc->integer.value = res_val; - break; - - - /* Def_find_set_right_bit := Find_set_right_bit_op Operand Result */ - - case AML_FIND_SET_RIGHT_BIT_OP: - - ret_desc->integer.value = obj_desc->integer.value; - - /* - * Acpi specification describes Integer type as a little - * endian unsigned value, so this boundry condition is valid. - */ - for (res_val = 0; ret_desc->integer.value && res_val < ACPI_INTEGER_BIT_SIZE; ++res_val) { - ret_desc->integer.value <<= 1; - } - - /* Since returns must be 1-based, subtract from 33 (65) */ - - ret_desc->integer.value = res_val == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - res_val; - break; - - - /* Def_from_bDC := From_bCDOp BCDValue Result */ - - case AML_FROM_BCD_OP: - - /* - * The 64-bit ACPI integer can hold 16 4-bit BCD integers - */ - ret_desc->integer.value = 0; - for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) { - /* Get one BCD digit */ - - digit = (ACPI_INTEGER) ((obj_desc->integer.value >> (i * 4)) & 0xF); - - /* Check the range of the digit */ - - if (digit > 9) { - status = AE_AML_NUMERIC_OVERFLOW; - goto cleanup; - } - - if (digit > 0) { - /* Sum into the result with the appropriate power of 10 */ - - for (j = 0; j < i; j++) { - digit *= 10; - } - - ret_desc->integer.value += digit; - } - } - break; - - - /* Def_to_bDC := To_bCDOp Operand Result */ - - case AML_TO_BCD_OP: - - - if (obj_desc->integer.value > ACPI_MAX_BCD_VALUE) { - status = AE_AML_NUMERIC_OVERFLOW; - goto cleanup; - } - - ret_desc->integer.value = 0; - for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) { - /* Divide by nth factor of 10 */ - - digit = obj_desc->integer.value; - for (j = 0; j < i; j++) { - digit /= 10; - } - - /* Create the BCD digit */ - - if (digit > 0) { - ret_desc->integer.value += (ACPI_MODULO (digit, 10) << (i * 4)); - } - } - break; - - - /* Def_cond_ref_of := Cond_ref_of_op Source_object Result */ - - case AML_COND_REF_OF_OP: - - /* - * This op is a little strange because the internal return value is - * different than the return value stored in the result descriptor - * (There are really two return values) - */ - - if ((ACPI_NAMESPACE_NODE *) obj_desc == acpi_gbl_root_node) { - /* - * This means that the object does not exist in the namespace, - * return FALSE - */ - - ret_desc->integer.value = 0; - - /* - * Must delete the result descriptor since there is no reference - * being returned - */ - - acpi_cm_remove_reference (res_desc); - goto cleanup; - } - - /* Get the object reference and store it */ - - status = acpi_aml_get_object_reference (obj_desc, &ret_desc2, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - status = acpi_aml_exec_store (ret_desc2, res_desc, walk_state); - - /* The object exists in the namespace, return TRUE */ - - ret_desc->integer.value = ACPI_INTEGER_MAX; - goto cleanup; - break; - - - case AML_STORE_OP: - - /* - * A store operand is typically a number, string, buffer or lvalue - * TBD: [Unhandled] What about a store to a package? - */ - - /* - * Do the store, and be careful about deleting the source object, - * since the object itself may have been stored. - */ - - status = acpi_aml_exec_store (obj_desc, res_desc, walk_state); - if (ACPI_FAILURE (status)) { - /* On failure, just delete the Obj_desc */ - - acpi_cm_remove_reference (obj_desc); - } - - else { - /* - * Normally, we would remove a reference on the Obj_desc parameter; - * But since it is being used as the internal return object - * (meaning we would normally increment it), the two cancel out, - * and we simply don't do anything. - */ - *return_desc = obj_desc; - } - - obj_desc = NULL; - return (status); - - break; - - - case AML_DEBUG_OP: - - /* Reference, returning an Reference */ - - return (AE_OK); - break; - - - /* - * These are obsolete opcodes - */ - - /* Def_shift_left_bit := Shift_left_bit_op Source Bit_num */ - /* Def_shift_right_bit := Shift_right_bit_op Source Bit_num */ - - case AML_SHIFT_LEFT_BIT_OP: - case AML_SHIFT_RIGHT_BIT_OP: - - status = AE_SUPPORT; - goto cleanup; - break; - - - default: - - REPORT_ERROR (("Acpi_aml_exec_monadic2_r: Unknown monadic opcode %X\n", - opcode)); - status = AE_AML_BAD_OPCODE; - goto cleanup; - } - - - status = acpi_aml_exec_store (ret_desc, res_desc, walk_state); - - -cleanup: - /* Always delete the operand object */ - - acpi_cm_remove_reference (obj_desc); - - /* Delete return object(s) on error */ - - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (res_desc); /* Result descriptor */ - if (ret_desc) { - acpi_cm_remove_reference (ret_desc); - ret_desc = NULL; - } - } - - /* Set the return object and exit */ - - *return_desc = ret_desc; - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_monadic2 - * - * PARAMETERS: Opcode - The opcode to be executed - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 2 monadic operator with numeric operand: - * Deref_of_op, Ref_of_op, Size_of_op, Type_op, Increment_op, - * Decrement_op, LNot_op, - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_monadic2 ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *tmp_desc; - ACPI_OPERAND_OBJECT *ret_desc = NULL; - ACPI_STATUS resolve_status; - ACPI_STATUS status; - u32 type; - ACPI_INTEGER value; - - - /* Attempt to resolve the operands */ - - resolve_status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); - /* Always get all operands */ - - status = acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - - - /* Now we can check the status codes */ - - if (ACPI_FAILURE (resolve_status)) { - goto cleanup; - } - - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* Get the operand and decode the opcode */ - - - switch (opcode) { - - /* Def_lNot := LNot_op Operand */ - - case AML_LNOT_OP: - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - ret_desc->integer.value = !obj_desc->integer.value; - break; - - - /* Def_decrement := Decrement_op Target */ - /* Def_increment := Increment_op Target */ - - case AML_DECREMENT_OP: - case AML_INCREMENT_OP: - - /* - * Since we are expecting an Reference on the top of the stack, it - * can be either an Node or an internal object. - * - * TBD: [Future] This may be the prototype code for all cases where - * an Reference is expected!! 10/99 - */ - - if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - ret_desc = obj_desc; - } - - else { - /* - * Duplicate the Reference in a new object so that we can resolve it - * without destroying the original Reference object - */ - - ret_desc = acpi_cm_create_internal_object (INTERNAL_TYPE_REFERENCE); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - ret_desc->reference.opcode = obj_desc->reference.opcode; - ret_desc->reference.offset = obj_desc->reference.offset; - ret_desc->reference.object = obj_desc->reference.object; - } - - - /* - * Convert the Ret_desc Reference to a Number - * (This deletes the original Ret_desc) - */ - - status = acpi_aml_resolve_operands (AML_LNOT_OP, &ret_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* Do the actual increment or decrement */ - - if (AML_INCREMENT_OP == opcode) { - ret_desc->integer.value++; - } - else { - ret_desc->integer.value--; - } - - /* Store the result back in the original descriptor */ - - status = acpi_aml_exec_store (ret_desc, obj_desc, walk_state); - - /* Objdesc was just deleted (because it is an Reference) */ - - obj_desc = NULL; - - break; - - - /* Def_object_type := Object_type_op Source_object */ - - case AML_TYPE_OP: - - if (INTERNAL_TYPE_REFERENCE == obj_desc->common.type) { - /* - * Not a Name -- an indirect name pointer would have - * been converted to a direct name pointer in Resolve_operands - */ - switch (obj_desc->reference.opcode) { - case AML_ZERO_OP: - case AML_ONE_OP: - case AML_ONES_OP: - - /* Constants are of type Number */ - - type = ACPI_TYPE_INTEGER; - break; - - - case AML_DEBUG_OP: - - /* Per 1.0b spec, Debug object is of type Debug_object */ - - type = ACPI_TYPE_DEBUG_OBJECT; - break; - - - case AML_INDEX_OP: - - /* Get the type of this reference (index into another object) */ - - type = obj_desc->reference.target_type; - if (type == ACPI_TYPE_PACKAGE) { - /* - * The main object is a package, we want to get the type - * of the individual package element that is referenced by - * the index. - */ - type = (*(obj_desc->reference.where))->common.type; - } - - break; - - - case AML_LOCAL_OP: - case AML_ARG_OP: - - type = acpi_ds_method_data_get_type (obj_desc->reference.opcode, - obj_desc->reference.offset, walk_state); - break; - - - default: - - REPORT_ERROR (("Acpi_aml_exec_monadic2/Type_op: Internal error - Unknown Reference subtype %X\n", - obj_desc->reference.opcode)); - status = AE_AML_INTERNAL; - goto cleanup; - } - } - - else { - /* - * It's not a Reference, so it must be a direct name pointer. - */ - type = acpi_ns_get_type ((ACPI_HANDLE) obj_desc); - } - - /* Allocate a descriptor to hold the type. */ - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - ret_desc->integer.value = type; - break; - - - /* Def_size_of := Size_of_op Source_object */ - - case AML_SIZE_OF_OP: - - if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - obj_desc = acpi_ns_get_attached_object (obj_desc); - } - - if (!obj_desc) { - value = 0; - } - - else { - switch (obj_desc->common.type) { - - case ACPI_TYPE_BUFFER: - - value = obj_desc->buffer.length; - break; - - - case ACPI_TYPE_STRING: - - value = obj_desc->string.length; - break; - - - case ACPI_TYPE_PACKAGE: - - value = obj_desc->package.count; - break; - - case INTERNAL_TYPE_REFERENCE: - - value = 4; - break; - - default: - - status = AE_AML_OPERAND_TYPE; - goto cleanup; - } - } - - /* - * Now that we have the size of the object, create a result - * object to hold the value - */ - - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - ret_desc->integer.value = value; - break; - - - /* Def_ref_of := Ref_of_op Source_object */ - - case AML_REF_OF_OP: - - status = acpi_aml_get_object_reference (obj_desc, &ret_desc, walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - break; - - - /* Def_deref_of := Deref_of_op Obj_reference */ - - case AML_DEREF_OF_OP: - - - /* Check for a method local or argument */ - - if (!VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - /* - * Must resolve/dereference the local/arg reference first - */ - switch (obj_desc->reference.opcode) { - /* Set Obj_desc to the value of the local/arg */ - - case AML_LOCAL_OP: - case AML_ARG_OP: - - acpi_ds_method_data_get_value (obj_desc->reference.opcode, - obj_desc->reference.offset, walk_state, &tmp_desc); - - /* - * Delete our reference to the input object and - * point to the object just retrieved - */ - acpi_cm_remove_reference (obj_desc); - obj_desc = tmp_desc; - break; - - default: - - /* Index op - handled below */ - break; - } - } - - - /* Obj_desc may have changed from the code above */ - - if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - /* Get the actual object from the Node (This is the dereference) */ - - ret_desc = ((ACPI_NAMESPACE_NODE *) obj_desc)->object; - - /* Returning a pointer to the object, add another reference! */ - - acpi_cm_add_reference (ret_desc); - } - - else { - /* - * This must be a reference object produced by the Index - * ASL operation -- check internal opcode - */ - - if ((obj_desc->reference.opcode != AML_INDEX_OP) && - (obj_desc->reference.opcode != AML_REF_OF_OP)) { - status = AE_TYPE; - goto cleanup; - } - - - switch (obj_desc->reference.opcode) { - case AML_INDEX_OP: - - /* - * Supported target types for the Index operator are - * 1) A Buffer - * 2) A Package - */ - - if (obj_desc->reference.target_type == ACPI_TYPE_BUFFER_FIELD) { - /* - * The target is a buffer, we must create a new object that - * contains one element of the buffer, the element pointed - * to by the index. - * - * NOTE: index into a buffer is NOT a pointer to a - * sub-buffer of the main buffer, it is only a pointer to a - * single element (byte) of the buffer! - */ - ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!ret_desc) { - status = AE_NO_MEMORY; - goto cleanup; - } - - tmp_desc = obj_desc->reference.object; - ret_desc->integer.value = - tmp_desc->buffer.pointer[obj_desc->reference.offset]; - - /* TBD: [Investigate] (see below) Don't add an additional - * ref! - */ - } - - else if (obj_desc->reference.target_type == ACPI_TYPE_PACKAGE) { - /* - * The target is a package, we want to return the referenced - * element of the package. We must add another reference to - * this object, however. - */ - - ret_desc = *(obj_desc->reference.where); - if (!ret_desc) { - /* - * We can't return a NULL dereferenced value. This is - * an uninitialized package element and is thus a - * severe error. - */ - - status = AE_AML_UNINITIALIZED_ELEMENT; - goto cleanup; - } - - acpi_cm_add_reference (ret_desc); - } - - else { - status = AE_AML_OPERAND_TYPE; - goto cleanup; - } - - break; - - - case AML_REF_OF_OP: - - ret_desc = obj_desc->reference.object; - - /* Add another reference to the object! */ - - acpi_cm_add_reference (ret_desc); - break; - } - } - - break; - - - default: - - REPORT_ERROR (("Acpi_aml_exec_monadic2: Unknown monadic opcode %X\n", - opcode)); - status = AE_AML_BAD_OPCODE; - goto cleanup; - } - - -cleanup: - - if (obj_desc) { - acpi_cm_remove_reference (obj_desc); - } - - /* Delete return object on error */ - - if (ACPI_FAILURE (status) && - (ret_desc)) { - acpi_cm_remove_reference (ret_desc); - ret_desc = NULL; - } - - *return_desc = ret_desc; - return (status); -} - diff --git a/reactos/drivers/bus/acpi/executer/ammutex.c b/reactos/drivers/bus/acpi/executer/ammutex.c deleted file mode 100644 index 2a4091083b5..00000000000 --- a/reactos/drivers/bus/acpi/executer/ammutex.c +++ /dev/null @@ -1,278 +0,0 @@ - -/****************************************************************************** - * - * Module Name: ammutex - ASL Mutex Acquire/Release functions - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("ammutex") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_unlink_mutex - * - * PARAMETERS: *Obj_desc - The mutex to be unlinked - * - * RETURN: Status - * - * DESCRIPTION: Remove a mutex from the "Acquired_mutex" list - * - ******************************************************************************/ - -void -acpi_aml_unlink_mutex ( - ACPI_OPERAND_OBJECT *obj_desc) -{ - - if (obj_desc->mutex.next) { - (obj_desc->mutex.next)->mutex.prev = obj_desc->mutex.prev; - } - if (obj_desc->mutex.prev) { - (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next; - } -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_link_mutex - * - * PARAMETERS: *Obj_desc - The mutex to be linked - * *List_head - head of the "Acquired_mutex" list - * - * RETURN: Status - * - * DESCRIPTION: Add a mutex to the "Acquired_mutex" list for this walk - * - ******************************************************************************/ - -static void -acpi_aml_link_mutex ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_OPERAND_OBJECT *list_head) -{ - - /* This object will be the first object in the list */ - - obj_desc->mutex.prev = list_head; - obj_desc->mutex.next = list_head->mutex.next; - - /* Update old first object to point back to this object */ - - if (list_head->mutex.next) { - (list_head->mutex.next)->mutex.prev = obj_desc; - } - - /* Update list head */ - - list_head->mutex.next = obj_desc; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_acquire_mutex - * - * PARAMETERS: *Time_desc - The 'time to delay' object descriptor - * *Obj_desc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Acquire an AML mutex - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_acquire_mutex ( - ACPI_OPERAND_OBJECT *time_desc, - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - - - if (!obj_desc) { - return (AE_BAD_PARAMETER); - } - - /* - * Current Sync must be less than or equal to the sync level of the - * mutex. This mechanism provides some deadlock prevention - */ - if (walk_state->current_sync_level > obj_desc->mutex.sync_level) { - return (AE_AML_MUTEX_ORDER); - } - - /* - * If the mutex is already owned by this thread, - * just increment the acquisition depth - */ - if (obj_desc->mutex.owner == walk_state) { - obj_desc->mutex.acquisition_depth++; - return (AE_OK); - } - - /* Acquire the mutex, wait if necessary */ - - status = acpi_aml_system_acquire_mutex (time_desc, obj_desc); - if (ACPI_FAILURE (status)) { - /* Includes failure from a timeout on Time_desc */ - - return (status); - } - - /* Have the mutex, update mutex and walk info */ - - obj_desc->mutex.owner = walk_state; - obj_desc->mutex.acquisition_depth = 1; - walk_state->current_sync_level = obj_desc->mutex.sync_level; - - /* Link the mutex to the walk state for force-unlock at method exit */ - - acpi_aml_link_mutex (obj_desc, (ACPI_OPERAND_OBJECT *) - &(walk_state->walk_list->acquired_mutex_list)); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_release_mutex - * - * PARAMETERS: *Obj_desc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Release a previously acquired Mutex. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_release_mutex ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status; - - - if (!obj_desc) { - return (AE_BAD_PARAMETER); - } - - /* The mutex must have been previously acquired in order to release it */ - - if (!obj_desc->mutex.owner) { - return (AE_AML_MUTEX_NOT_ACQUIRED); - } - - /* The Mutex is owned, but this thread must be the owner */ - - if (obj_desc->mutex.owner != walk_state) { - return (AE_AML_NOT_OWNER); - } - - /* - * The sync level of the mutex must be less than or - * equal to the current sync level - */ - if (obj_desc->mutex.sync_level > walk_state->current_sync_level) { - return (AE_AML_MUTEX_ORDER); - } - - /* - * Match multiple Acquires with multiple Releases - */ - obj_desc->mutex.acquisition_depth--; - if (obj_desc->mutex.acquisition_depth != 0) { - /* Just decrement the depth and return */ - - return (AE_OK); - } - - - /* Release the mutex */ - - status = acpi_aml_system_release_mutex (obj_desc); - - /* Update the mutex and walk state */ - - obj_desc->mutex.owner = NULL; - walk_state->current_sync_level = obj_desc->mutex.sync_level; - - /* Unlink the mutex from the owner's list */ - - acpi_aml_unlink_mutex (obj_desc); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_release_all_mutexes - * - * PARAMETERS: *Mutex_list - Head of the mutex list - * - * RETURN: Status - * - * DESCRIPTION: Release all mutexes in the list - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_release_all_mutexes ( - ACPI_OPERAND_OBJECT *list_head) -{ - ACPI_OPERAND_OBJECT *next = list_head->mutex.next; - ACPI_OPERAND_OBJECT *this; - - - /* - * Traverse the list of owned mutexes, releasing each one. - */ - while (next) { - this = next; - next = this->mutex.next; - - /* Mark mutex un-owned */ - - this->mutex.owner = NULL; - this->mutex.prev = NULL; - this->mutex.next = NULL; - this->mutex.acquisition_depth = 0; - - /* Release the mutex */ - - acpi_aml_system_release_mutex (this); - } - - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amnames.c b/reactos/drivers/bus/acpi/executer/amnames.c deleted file mode 100644 index 269631f49f0..00000000000 --- a/reactos/drivers/bus/acpi/executer/amnames.c +++ /dev/null @@ -1,387 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amnames - interpreter/scanner name load/execute - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amnames") - - -/* AML Package Length encodings */ - -#define ACPI_AML_PACKAGE_TYPE1 0x40 -#define ACPI_AML_PACKAGE_TYPE2 0x4000 -#define ACPI_AML_PACKAGE_TYPE3 0x400000 -#define ACPI_AML_PACKAGE_TYPE4 0x40000000 - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_allocate_name_string - * - * PARAMETERS: Prefix_count - Count of parent levels. Special cases: - * (-1) = root, 0 = none - * Num_name_segs - count of 4-character name segments - * - * RETURN: A pointer to the allocated string segment. This segment must - * be deleted by the caller. - * - * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name - * string is long enough, and set up prefix if any. - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_aml_allocate_name_string ( - u32 prefix_count, - u32 num_name_segs) -{ - NATIVE_CHAR *temp_ptr; - NATIVE_CHAR *name_string; - u32 size_needed; - - - /* - * Allow room for all \ and ^ prefixes, all segments, and a Multi_name_prefix. - * Also, one byte for the null terminator. - * This may actually be somewhat longer than needed. - */ - - if (prefix_count == (u32) -1) { - /* Special case for root */ - - size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; - } - else { - size_needed = prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; - } - - /* - * Allocate a buffer for the name. - * This buffer must be deleted by the caller! - */ - - name_string = acpi_cm_allocate (size_needed); - if (!name_string) { - REPORT_ERROR (("Aml_allocate_name_string: name allocation failure\n")); - return (NULL); - } - - temp_ptr = name_string; - - /* Set up Root or Parent prefixes if needed */ - - if (prefix_count == (u32) -1) { - *temp_ptr++ = AML_ROOT_PREFIX; - } - - else { - while (prefix_count--) { - *temp_ptr++ = AML_PARENT_PREFIX; - } - } - - - /* Set up Dual or Multi prefixes if needed */ - - if (num_name_segs > 2) { - /* Set up multi prefixes */ - - *temp_ptr++ = AML_MULTI_NAME_PREFIX_OP; - *temp_ptr++ = (char) num_name_segs; - } - - else if (2 == num_name_segs) { - /* Set up dual prefixes */ - - *temp_ptr++ = AML_DUAL_NAME_PREFIX; - } - - /* - * Terminate string following prefixes. Acpi_aml_exec_name_segment() will - * append the segment(s) - */ - - *temp_ptr = 0; - - return (name_string); -} - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_name_segment - * - * PARAMETERS: Interpreter_mode - Current running mode (load1/Load2/Exec) - * - * RETURN: Status - * - * DESCRIPTION: Execute a name segment (4 bytes) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_name_segment ( - u8 **in_aml_address, - NATIVE_CHAR *name_string) -{ - u8 *aml_address = *in_aml_address; - ACPI_STATUS status = AE_OK; - u32 index; - NATIVE_CHAR char_buf[5]; - - - /* - * If first character is a digit, then we know that we aren't looking at a - * valid name segment - */ - - char_buf[0] = *aml_address; - - if ('0' <= char_buf[0] && char_buf[0] <= '9') { - return (AE_CTRL_PENDING); - } - - for (index = 4; - (index > 0) && (acpi_cm_valid_acpi_character (*aml_address)); - --index) { - char_buf[4 - index] = *aml_address++; - } - - - /* Valid name segment */ - - if (0 == index) { - /* Found 4 valid characters */ - - char_buf[4] = '\0'; - - if (name_string) { - STRCAT (name_string, char_buf); - } - - } - - else if (4 == index) { - /* - * First character was not a valid name character, - * so we are looking at something other than a name. - */ - status = AE_CTRL_PENDING; - } - - else { - /* Segment started with one or more valid characters, but fewer than 4 */ - - status = AE_AML_BAD_NAME; - } - - *in_aml_address = aml_address; - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_get_name_string - * - * PARAMETERS: Data_type - Data type to be associated with this name - * - * RETURN: Status - * - * DESCRIPTION: Get a name, including any prefixes. - * - ******************************************************************************/ - - -ACPI_STATUS -acpi_aml_get_name_string ( - OBJECT_TYPE_INTERNAL data_type, - u8 *in_aml_address, - NATIVE_CHAR **out_name_string, - u32 *out_name_length) -{ - ACPI_STATUS status = AE_OK; - u8 *aml_address = in_aml_address; - NATIVE_CHAR *name_string = NULL; - u32 num_segments; - u32 prefix_count = 0; - u8 prefix = 0; - u8 has_prefix = FALSE; - - - if (INTERNAL_TYPE_DEF_FIELD == data_type || - INTERNAL_TYPE_BANK_FIELD == data_type || - INTERNAL_TYPE_INDEX_FIELD == data_type) { - /* Disallow prefixes for types associated with field names */ - - name_string = acpi_aml_allocate_name_string (0, 1); - if (!name_string) { - status = AE_NO_MEMORY; - } - else { - status = acpi_aml_exec_name_segment (&aml_address, name_string); - } - } - - else { - /* - * Data_type is not a field name. - * Examine first character of name for root or parent prefix operators - */ - - switch (*aml_address) { - - case AML_ROOT_PREFIX: - - prefix = *aml_address++; - /* - * Remember that we have a Root_prefix -- - * see comment in Acpi_aml_allocate_name_string() - */ - prefix_count = (u32) -1; - has_prefix = TRUE; - break; - - - case AML_PARENT_PREFIX: - - /* Increment past possibly multiple parent prefixes */ - - do { - prefix = *aml_address++; - ++prefix_count; - - } while (*aml_address == AML_PARENT_PREFIX); - has_prefix = TRUE; - break; - - - default: - - break; - } - - - /* Examine first character of name for name segment prefix operator */ - - switch (*aml_address) { - - case AML_DUAL_NAME_PREFIX: - - prefix = *aml_address++; - name_string = acpi_aml_allocate_name_string (prefix_count, 2); - if (!name_string) { - status = AE_NO_MEMORY; - break; - } - - /* Indicate that we processed a prefix */ - has_prefix = TRUE; - - status = acpi_aml_exec_name_segment (&aml_address, name_string); - if (ACPI_SUCCESS (status)) { - status = acpi_aml_exec_name_segment (&aml_address, name_string); - } - break; - - - case AML_MULTI_NAME_PREFIX_OP: - - prefix = *aml_address++; - /* Fetch count of segments remaining in name path */ - - num_segments = *aml_address++; - - name_string = acpi_aml_allocate_name_string (prefix_count, num_segments); - if (!name_string) { - status = AE_NO_MEMORY; - break; - } - - /* Indicate that we processed a prefix */ - has_prefix = TRUE; - - while (num_segments && - (status = acpi_aml_exec_name_segment (&aml_address, name_string)) == AE_OK) { - --num_segments; - } - - break; - - - case 0: - - /* Null_name valid as of 8-12-98 ASL/AML Grammar Update */ - - - /* Consume the NULL byte */ - - aml_address++; - name_string = acpi_aml_allocate_name_string (prefix_count, 0); - if (!name_string) { - status = AE_NO_MEMORY; - break; - } - - break; - - - default: - - /* Name segment string */ - - name_string = acpi_aml_allocate_name_string (prefix_count, 1); - if (!name_string) { - status = AE_NO_MEMORY; - break; - } - - status = acpi_aml_exec_name_segment (&aml_address, name_string); - break; - - } /* Switch (Peek_op ()) */ - } - - - if (AE_CTRL_PENDING == status && has_prefix) { - /* Ran out of segments after processing a prefix */ - - REPORT_ERROR ( - ("Aml_do_name: Malformed Name at %p\n", name_string)); - status = AE_AML_BAD_NAME; - } - - - *out_name_string = name_string; - *out_name_length = (u32) (aml_address - in_aml_address); - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amprep.c b/reactos/drivers/bus/acpi/executer/amprep.c deleted file mode 100644 index 351fb2bffe1..00000000000 --- a/reactos/drivers/bus/acpi/executer/amprep.c +++ /dev/null @@ -1,400 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amprep - ACPI AML (p-code) execution - field prep utilities - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amprep") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_decode_field_access_type - * - * PARAMETERS: Access - Encoded field access bits - * - * RETURN: Field granularity (8, 16, or 32) - * - * DESCRIPTION: Decode the Access_type bits of a field definition. - * - ******************************************************************************/ - -static u32 -acpi_aml_decode_field_access_type ( - u32 access, - u16 length) -{ - - switch (access) { - case ACCESS_ANY_ACC: - if (length <= 8) { - return (8); - } - else if (length <= 16) { - return (16); - } - else if (length <= 32) { - return (32); - } - else { - return (8); - } - break; - - case ACCESS_BYTE_ACC: - return (8); - break; - - case ACCESS_WORD_ACC: - return (16); - break; - - case ACCESS_DWORD_ACC: - return (32); - break; - - default: - /* Invalid field access type */ - - return (0); - } -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_prep_common_field_objec - * - * PARAMETERS: Obj_desc - The field object - * Field_flags - Access, Lock_rule, or Update_rule. - * The format of a Field_flag is described - * in the ACPI specification - * Field_position - Field position - * Field_length - Field length - * - * RETURN: Status - * - * DESCRIPTION: Initialize the areas of the field object that are common - * to the various types of fields. - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_aml_prep_common_field_object ( - ACPI_OPERAND_OBJECT *obj_desc, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length) -{ - u32 granularity; - - - /* - * Note: the structure being initialized is the - * ACPI_COMMON_FIELD_INFO; Therefore, we can just use the Field union to - * access this common area. No structure fields outside of the common area - * are initialized by this procedure. - */ - - /* Decode the Field_flags */ - - obj_desc->field.access = (u8) ((field_flags & ACCESS_TYPE_MASK) - >> ACCESS_TYPE_SHIFT); - obj_desc->field.lock_rule = (u8) ((field_flags & LOCK_RULE_MASK) - >> LOCK_RULE_SHIFT); - obj_desc->field.update_rule = (u8) ((field_flags & UPDATE_RULE_MASK) - >> UPDATE_RULE_SHIFT); - - /* Other misc fields */ - - obj_desc->field.length = (u16) field_length; - obj_desc->field.access_attribute = field_attribute; - - /* Decode the access type so we can compute offsets */ - - granularity = acpi_aml_decode_field_access_type (obj_desc->field.access, obj_desc->field.length); - if (!granularity) { - return (AE_AML_OPERAND_VALUE); - } - - /* Access granularity based fields */ - - obj_desc->field.granularity = (u8) granularity; - obj_desc->field.bit_offset = (u8) (field_position % granularity); - obj_desc->field.offset = (u32) field_position / granularity; - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_prep_def_field_value - * - * PARAMETERS: Node - Owning Node - * Region - Region in which field is being defined - * Field_flags - Access, Lock_rule, or Update_rule. - * The format of a Field_flag is described - * in the ACPI specification - * Field_position - Field position - * Field_length - Field length - * - * RETURN: Status - * - * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type Def_field and - * connect it to the parent Node. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_prep_def_field_value ( - ACPI_NAMESPACE_NODE *node, - ACPI_HANDLE region, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length) -{ - ACPI_OPERAND_OBJECT *obj_desc; - u32 type; - ACPI_STATUS status; - - - /* Parameter validation */ - - if (!region) { - return (AE_AML_NO_OPERAND); - } - - type = acpi_ns_get_type (region); - if (type != ACPI_TYPE_REGION) { - return (AE_AML_OPERAND_TYPE); - } - - /* Allocate a new object */ - - obj_desc = acpi_cm_create_internal_object (INTERNAL_TYPE_DEF_FIELD); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - - /* Obj_desc and Region valid */ - - /* Initialize areas of the object that are common to all fields */ - - status = acpi_aml_prep_common_field_object (obj_desc, field_flags, field_attribute, - field_position, field_length); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Initialize areas of the object that are specific to this field type */ - - obj_desc->field.container = acpi_ns_get_attached_object (region); - - /* An additional reference for the container */ - - acpi_cm_add_reference (obj_desc->field.container); - - - /* Debug info */ - - /* - * Store the constructed descriptor (Obj_desc) into the Named_obj whose - * handle is on TOS, preserving the current type of that Named_obj. - */ - status = acpi_ns_attach_object ((ACPI_HANDLE) node, obj_desc, - (u8) acpi_ns_get_type ((ACPI_HANDLE) node)); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_prep_bank_field_value - * - * PARAMETERS: Node - Owning Node - * Region - Region in which field is being defined - * Bank_reg - Bank selection register - * Bank_val - Value to store in selection register - * Field_flags - Access, Lock_rule, or Update_rule - * Field_position - Field position - * Field_length - Field length - * - * RETURN: Status - * - * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type Bank_field and - * connect it to the parent Node. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_prep_bank_field_value ( - ACPI_NAMESPACE_NODE *node, - ACPI_HANDLE region, - ACPI_HANDLE bank_reg, - u32 bank_val, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length) -{ - ACPI_OPERAND_OBJECT *obj_desc; - u32 type; - ACPI_STATUS status; - - - /* Parameter validation */ - - if (!region) { - return (AE_AML_NO_OPERAND); - } - - type = acpi_ns_get_type (region); - if (type != ACPI_TYPE_REGION) { - return (AE_AML_OPERAND_TYPE); - } - - /* Allocate a new object */ - - obj_desc = acpi_cm_create_internal_object (INTERNAL_TYPE_BANK_FIELD); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - /* Obj_desc and Region valid */ - - /* Initialize areas of the object that are common to all fields */ - - status = acpi_aml_prep_common_field_object (obj_desc, field_flags, field_attribute, - field_position, field_length); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Initialize areas of the object that are specific to this field type */ - - obj_desc->bank_field.value = bank_val; - obj_desc->bank_field.container = acpi_ns_get_attached_object (region); - obj_desc->bank_field.bank_select = acpi_ns_get_attached_object (bank_reg); - - /* An additional reference for the container and bank select */ - /* TBD: [Restructure] is "Bank_select" ever a real internal object?? */ - - acpi_cm_add_reference (obj_desc->bank_field.container); - acpi_cm_add_reference (obj_desc->bank_field.bank_select); - - /* Debug info */ - - /* - * Store the constructed descriptor (Obj_desc) into the Named_obj whose - * handle is on TOS, preserving the current type of that Named_obj. - */ - status = acpi_ns_attach_object ((ACPI_HANDLE) node, obj_desc, - (u8) acpi_ns_get_type ((ACPI_HANDLE) node)); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_prep_index_field_value - * - * PARAMETERS: Node - Owning Node - * Index_reg - Index register - * Data_reg - Data register - * Field_flags - Access, Lock_rule, or Update_rule - * Field_position - Field position - * Field_length - Field length - * - * RETURN: Status - * - * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type Index_field and - * connect it to the parent Node. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_prep_index_field_value ( - ACPI_NAMESPACE_NODE *node, - ACPI_HANDLE index_reg, - ACPI_HANDLE data_reg, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - /* Parameter validation */ - - if (!index_reg || !data_reg) { - return (AE_AML_NO_OPERAND); - } - - /* Allocate a new object descriptor */ - - obj_desc = acpi_cm_create_internal_object (INTERNAL_TYPE_INDEX_FIELD); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - /* Initialize areas of the object that are common to all fields */ - - status = acpi_aml_prep_common_field_object (obj_desc, field_flags, field_attribute, - field_position, field_length); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Initialize areas of the object that are specific to this field type */ - - obj_desc->index_field.value = (u32) (field_position / - obj_desc->field.granularity); - obj_desc->index_field.index = index_reg; - obj_desc->index_field.data = data_reg; - - /* Debug info */ - - /* - * Store the constructed descriptor (Obj_desc) into the Named_obj whose - * handle is on TOS, preserving the current type of that Named_obj. - */ - status = acpi_ns_attach_object ((ACPI_HANDLE) node, obj_desc, - (u8) acpi_ns_get_type ((ACPI_HANDLE) node)); - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/executer/amregion.c b/reactos/drivers/bus/acpi/executer/amregion.c deleted file mode 100644 index a3e9e0a4a5f..00000000000 --- a/reactos/drivers/bus/acpi/executer/amregion.c +++ /dev/null @@ -1,405 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amregion - ACPI default Op_region (address space) handlers - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amregion") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_memory_space_handler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * Bit_width - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * Handler_context - Pointer to Handler's context - * Region_context - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the System Memory address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_system_memory_space_handler ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context) -{ - ACPI_STATUS status = AE_OK; - void *logical_addr_ptr = NULL; - MEM_HANDLER_CONTEXT *mem_info = region_context; - u32 length; - - - /* Validate and translate the bit width */ - - switch (bit_width) { - case 8: - length = 1; - break; - - case 16: - length = 2; - break; - - case 32: - length = 4; - break; - - default: - return (AE_AML_OPERAND_VALUE); - break; - } - - - /* - * Does the request fit into the cached memory mapping? - * Is 1) Address below the current mapping? OR - * 2) Address beyond the current mapping? - */ - - if ((address < mem_info->mapped_physical_address) || - (((ACPI_INTEGER) address + length) > - ((ACPI_INTEGER) mem_info->mapped_physical_address + mem_info->mapped_length))) { - /* - * The request cannot be resolved by the current memory mapping; - * Delete the existing mapping and create a new one. - */ - - if (mem_info->mapped_length) { - /* Valid mapping, delete it */ - - acpi_os_unmap_memory (mem_info->mapped_logical_address, - mem_info->mapped_length); - } - - mem_info->mapped_length = 0; /* In case of failure below */ - - /* Create a new mapping starting at the address given */ - - status = acpi_os_map_memory (address, SYSMEM_REGION_WINDOW_SIZE, - (void **) &mem_info->mapped_logical_address); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* TBD: should these pointers go to 64-bit in all cases ? */ - - mem_info->mapped_physical_address = address; - mem_info->mapped_length = SYSMEM_REGION_WINDOW_SIZE; - } - - - /* - * Generate a logical pointer corresponding to the address we want to - * access - */ - - /* TBD: should these pointers go to 64-bit in all cases ? */ - - logical_addr_ptr = mem_info->mapped_logical_address + - ((ACPI_INTEGER) address - (ACPI_INTEGER) mem_info->mapped_physical_address); - - /* Perform the memory read or write */ - - switch (function) { - - case ADDRESS_SPACE_READ: - - switch (bit_width) { - case 8: - *value = (u32)* (u8 *) logical_addr_ptr; - break; - - case 16: - MOVE_UNALIGNED16_TO_32 (value, logical_addr_ptr); - break; - - case 32: - MOVE_UNALIGNED32_TO_32 (value, logical_addr_ptr); - break; - } - - break; - - - case ADDRESS_SPACE_WRITE: - - switch (bit_width) { - case 8: - *(u8 *) logical_addr_ptr = (u8) *value; - break; - - case 16: - MOVE_UNALIGNED16_TO_16 (logical_addr_ptr, value); - break; - - case 32: - MOVE_UNALIGNED32_TO_32 (logical_addr_ptr, value); - break; - } - - break; - - - default: - status = AE_BAD_PARAMETER; - break; - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_io_space_handler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * Bit_width - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * Handler_context - Pointer to Handler's context - * Region_context - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the System IO address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_system_io_space_handler ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context) -{ - ACPI_STATUS status = AE_OK; - - - /* Decode the function parameter */ - - switch (function) { - - case ADDRESS_SPACE_READ: - - switch (bit_width) { - /* I/O Port width */ - - case 8: - *value = (u32) acpi_os_in8 ((ACPI_IO_ADDRESS) address); - break; - - case 16: - *value = (u32) acpi_os_in16 ((ACPI_IO_ADDRESS) address); - break; - - case 32: - *value = acpi_os_in32 ((ACPI_IO_ADDRESS) address); - break; - - default: - status = AE_AML_OPERAND_VALUE; - } - - break; - - - case ADDRESS_SPACE_WRITE: - - switch (bit_width) { - /* I/O Port width */ - case 8: - acpi_os_out8 ((ACPI_IO_ADDRESS) address, (u8) *value); - break; - - case 16: - acpi_os_out16 ((ACPI_IO_ADDRESS) address, (u16) *value); - break; - - case 32: - acpi_os_out32 ((ACPI_IO_ADDRESS) address, *value); - break; - - default: - status = AE_AML_OPERAND_VALUE; - } - - break; - - - default: - status = AE_BAD_PARAMETER; - break; - } - - return (status); -} - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_pci_config_space_handler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * Bit_width - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * Handler_context - Pointer to Handler's context - * Region_context - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the PCI Config address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_pci_config_space_handler ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context) -{ - ACPI_STATUS status = AE_OK; - u32 pci_bus; - u32 dev_func; - u8 pci_reg; - PCI_HANDLER_CONTEXT *PCIcontext; - - - /* - * The arguments to Acpi_os(Read|Write)Pci_cfg(Byte|Word|Dword) are: - * - * Seg_bus - 0xSSSSBBBB - SSSS is the PCI bus segment - * BBBB is the PCI bus number - * - * Dev_func - 0xDDDDFFFF - DDDD is the PCI device number - * FFFF is the PCI device function number - * - * Reg_num - Config space register must be < 40h - * - * Value - input value for write, output for read - * - */ - - PCIcontext = (PCI_HANDLER_CONTEXT *) region_context; - - pci_bus = LOWORD(PCIcontext->seg) << 16; - pci_bus |= LOWORD(PCIcontext->bus); - - dev_func = PCIcontext->dev_func; - - pci_reg = (u8) address; - - switch (function) { - - case ADDRESS_SPACE_READ: - - *value = 0; - - switch (bit_width) { - /* PCI Register width */ - - case 8: - status = acpi_os_read_pci_cfg_byte (pci_bus, dev_func, pci_reg, - (u8 *) value); - break; - - case 16: - status = acpi_os_read_pci_cfg_word (pci_bus, dev_func, pci_reg, - (u16 *) value); - break; - - case 32: - status = acpi_os_read_pci_cfg_dword (pci_bus, dev_func, pci_reg, - value); - break; - - default: - status = AE_AML_OPERAND_VALUE; - - } /* Switch bit_width */ - - break; - - - case ADDRESS_SPACE_WRITE: - - switch (bit_width) { - /* PCI Register width */ - - case 8: - status = acpi_os_write_pci_cfg_byte (pci_bus, dev_func, pci_reg, - *(u8 *) value); - break; - - case 16: - status = acpi_os_write_pci_cfg_word (pci_bus, dev_func, pci_reg, - *(u16 *) value); - break; - - case 32: - status = acpi_os_write_pci_cfg_dword (pci_bus, dev_func, pci_reg, - *value); - break; - - default: - status = AE_AML_OPERAND_VALUE; - - } /* Switch bit_width */ - - break; - - - default: - - status = AE_BAD_PARAMETER; - break; - - } - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/executer/amresnte.c b/reactos/drivers/bus/acpi/executer/amresnte.c deleted file mode 100644 index 9ddbc841728..00000000000 --- a/reactos/drivers/bus/acpi/executer/amresnte.c +++ /dev/null @@ -1,500 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amresnte - AML Interpreter object resolution - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amresnte") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_resolve_node_to_value - * - * PARAMETERS: Stack_ptr - Pointer to a location on a stack that contains - * a pointer to an Node - * - * RETURN: Status - * - * DESCRIPTION: Resolve a ACPI_NAMESPACE_NODE (Node, - * A.K.A. a "direct name pointer") - * - * Note: for some of the data types, the pointer attached to the Node - * can be either a pointer to an actual internal object or a pointer into the - * AML stream itself. These types are currently: - * - * ACPI_TYPE_INTEGER - * ACPI_TYPE_STRING - * ACPI_TYPE_BUFFER - * ACPI_TYPE_MUTEX - * ACPI_TYPE_PACKAGE - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_resolve_node_to_value ( - ACPI_NAMESPACE_NODE **stack_ptr, - ACPI_WALK_STATE *walk_state) - -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *val_desc = NULL; - ACPI_OPERAND_OBJECT *obj_desc = NULL; - ACPI_NAMESPACE_NODE *node; - u8 *aml_pointer = NULL; - OBJECT_TYPE_INTERNAL entry_type; - u8 locked; - u8 attached_aml_pointer = FALSE; - u8 aml_opcode = 0; - ACPI_INTEGER temp_val; - OBJECT_TYPE_INTERNAL object_type; - - - node = *stack_ptr; - - - /* - * The stack pointer is a "Direct name ptr", and points to a - * a ACPI_NAMESPACE_NODE (Node). Get the pointer that is attached to - * the Node. - */ - - val_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); - entry_type = acpi_ns_get_type ((ACPI_HANDLE) node); - - /* - * The Val_desc attached to the Node can be either: - * 1) An internal ACPI object - * 2) A pointer into the AML stream (into one of the ACPI system tables) - */ - - if (acpi_tb_system_table_pointer (val_desc)) { - attached_aml_pointer = TRUE; - aml_opcode = *((u8 *) val_desc); - aml_pointer = ((u8 *) val_desc) + 1; - - } - - - /* - * Several Entry_types do not require further processing, so - * we will return immediately - */ - /* Devices rarely have an attached object, return the Node - * and Method locals and arguments have a pseudo-Node - */ - if (entry_type == ACPI_TYPE_DEVICE || - (node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) { - return (AE_OK); - } - - if (!val_desc) { - return (AE_AML_NO_OPERAND); - } - - /* - * Action is based on the type of the Node, which indicates the type - * of the attached object or pointer - */ - switch (entry_type) { - - case ACPI_TYPE_PACKAGE: - - if (attached_aml_pointer) { - /* - * This means that the package initialization is not parsed - * -- should not happen - */ - return (AE_NOT_IMPLEMENTED); - } - - /* Val_desc is an internal object in all cases by the time we get here */ - - if (ACPI_TYPE_PACKAGE != val_desc->common.type) { - return (AE_AML_OPERAND_TYPE); - } - - /* Return an additional reference to the object */ - - obj_desc = val_desc; - acpi_cm_add_reference (obj_desc); - break; - - - case ACPI_TYPE_BUFFER: - - if (attached_aml_pointer) { - /* - * This means that the buffer initialization is not parsed - * -- should not happen - */ - return (AE_NOT_IMPLEMENTED); - } - - /* Val_desc is an internal object in all cases by the time we get here */ - - if (ACPI_TYPE_BUFFER != val_desc->common.type) { - return (AE_AML_OPERAND_TYPE); - } - - /* Return an additional reference to the object */ - - obj_desc = val_desc; - acpi_cm_add_reference (obj_desc); - break; - - - case ACPI_TYPE_STRING: - - if (attached_aml_pointer) { - /* Allocate a new string object */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_STRING); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - /* Init the internal object */ - - obj_desc->string.pointer = (NATIVE_CHAR *) aml_pointer; - obj_desc->string.length = STRLEN (obj_desc->string.pointer); - } - - else { - if (ACPI_TYPE_STRING != val_desc->common.type) { - return (AE_AML_OPERAND_TYPE); - } - - /* Return an additional reference to the object */ - - obj_desc = val_desc; - acpi_cm_add_reference (obj_desc); - } - - break; - - - case ACPI_TYPE_INTEGER: - - /* - * The Node has an attached internal object, make sure that it's a - * number - */ - - if (ACPI_TYPE_INTEGER != val_desc->common.type) { - return (AE_AML_OPERAND_TYPE); - } - - /* Return an additional reference to the object */ - - obj_desc = val_desc; - acpi_cm_add_reference (obj_desc); - break; - - - case INTERNAL_TYPE_DEF_FIELD: - - /* - * TBD: [Investigate] Is this the correct solution? - * - * This section was extended to convert to generic buffer if - * the return length is greater than 32 bits, but still allows - * for returning a type Number for smaller values because the - * caller can then apply arithmetic operators on those fields. - * - * XXX - Implementation limitation: Fields are implemented as type - * XXX - Number, but they really are supposed to be type Buffer. - * XXX - The two are interchangeable only for lengths <= 32 bits. - */ - if(val_desc->field.length > 32) { - object_type = ACPI_TYPE_BUFFER; - } - else { - object_type = ACPI_TYPE_INTEGER; - } - - /* - * Create the destination buffer object and the buffer space. - */ - obj_desc = acpi_cm_create_internal_object (object_type); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - /* - * Fill in the object specific details - */ - if (ACPI_TYPE_BUFFER == object_type) { - obj_desc->buffer.pointer = acpi_cm_callocate (val_desc->field.length); - if (!obj_desc->buffer.pointer) { - acpi_cm_remove_reference(obj_desc); - return (AE_NO_MEMORY); - } - - obj_desc->buffer.length = val_desc->field.length; - - status = acpi_aml_access_named_field (ACPI_READ, (ACPI_HANDLE) node, - obj_desc->buffer.pointer, obj_desc->buffer.length); - - if (ACPI_FAILURE (status)) { - return (status); - } - } - else { - status = acpi_aml_access_named_field (ACPI_READ, (ACPI_HANDLE) node, - &temp_val, sizeof (temp_val)); - - if (ACPI_FAILURE (status)) { - return (status); - } - - obj_desc->integer.value = temp_val; - } - - - break; - - - case INTERNAL_TYPE_BANK_FIELD: - - if (attached_aml_pointer) { - return (AE_AML_OPERAND_TYPE); - } - - if (INTERNAL_TYPE_BANK_FIELD != val_desc->common.type) { - return (AE_AML_OPERAND_TYPE); - } - - - /* Get the global lock if needed */ - - obj_desc = (ACPI_OPERAND_OBJECT *) *stack_ptr; - locked = acpi_aml_acquire_global_lock (obj_desc->field_unit.lock_rule); - - /* Set Index value to select proper Data register */ - /* perform the update */ - - status = acpi_aml_access_named_field (ACPI_WRITE, - val_desc->bank_field.bank_select, &val_desc->bank_field.value, - sizeof (val_desc->bank_field.value)); - - acpi_aml_release_global_lock (locked); - - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Read Data value */ - - status = acpi_aml_access_named_field (ACPI_READ, - (ACPI_HANDLE) val_desc->bank_field.container, - &temp_val, sizeof (temp_val)); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Create an object for the result */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - obj_desc->integer.value = temp_val; - break; - - - case INTERNAL_TYPE_INDEX_FIELD: - - if (attached_aml_pointer) { - return (AE_AML_OPERAND_TYPE); - } - - if (INTERNAL_TYPE_INDEX_FIELD != val_desc->common.type) { - return (AE_AML_OPERAND_TYPE); - } - - - /* Set Index value to select proper Data register */ - /* Get the global lock if needed */ - - obj_desc = (ACPI_OPERAND_OBJECT *) *stack_ptr; - locked = acpi_aml_acquire_global_lock (obj_desc->field_unit.lock_rule); - - /* Perform the update */ - - status = acpi_aml_access_named_field (ACPI_WRITE, - val_desc->index_field.index, &val_desc->index_field.value, - sizeof (val_desc->index_field.value)); - - acpi_aml_release_global_lock (locked); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Read Data value */ - - status = acpi_aml_access_named_field (ACPI_READ, val_desc->index_field.data, - &temp_val, sizeof (temp_val)); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Create an object for the result */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - obj_desc->integer.value = temp_val; - break; - - - case ACPI_TYPE_FIELD_UNIT: - - if (attached_aml_pointer) { - return (AE_AML_OPERAND_TYPE); - } - - if (val_desc->common.type != (u8) entry_type) { - return (AE_AML_OPERAND_TYPE); - break; - } - - /* Create object for result */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_ANY); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - status = acpi_aml_get_field_unit_value (val_desc, obj_desc); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (obj_desc); - return (status); - } - - break; - - - /* - * For these objects, just return the object attached to the Node - */ - - case ACPI_TYPE_MUTEX: - case ACPI_TYPE_METHOD: - case ACPI_TYPE_POWER: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_THERMAL: - case ACPI_TYPE_EVENT: - case ACPI_TYPE_REGION: - - - /* Return an additional reference to the object */ - - obj_desc = val_desc; - acpi_cm_add_reference (obj_desc); - break; - - - /* TYPE_Any is untyped, and thus there is no object associated with it */ - - case ACPI_TYPE_ANY: - - return (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ - break; - - - /* - * The only named references allowed are named constants - * - * e.g. Name (\OSFL, Ones) - */ - case INTERNAL_TYPE_REFERENCE: - - switch (val_desc->reference.opcode) { - - case AML_ZERO_OP: - - temp_val = 0; - break; - - - case AML_ONE_OP: - - temp_val = 1; - break; - - - case AML_ONES_OP: - - temp_val = ACPI_INTEGER_MAX; - break; - - - default: - - return (AE_AML_BAD_OPCODE); - } - - /* Create object for result */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_INTEGER); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - obj_desc->integer.value = temp_val; - - /* Truncate value if we are executing from a 32-bit ACPI table */ - - acpi_aml_truncate_for32bit_table (obj_desc, walk_state); - break; - - - /* Default case is for unknown types */ - - default: - - return (AE_AML_OPERAND_TYPE); - - } /* switch (Entry_type) */ - - - /* Put the object descriptor on the stack */ - - *stack_ptr = (void *) obj_desc; - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amresolv.c b/reactos/drivers/bus/acpi/executer/amresolv.c deleted file mode 100644 index bdbaed6c3a6..00000000000 --- a/reactos/drivers/bus/acpi/executer/amresolv.c +++ /dev/null @@ -1,420 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amresolv - AML Interpreter object resolution - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amresolv") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_get_field_unit_value - * - * PARAMETERS: *Field_desc - Pointer to a Field_unit - * *Result_desc - Pointer to an empty descriptor - * which will become a Number - * containing the field's value. - * - * RETURN: Status - * - * DESCRIPTION: Retrieve the value from a Field_unit - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_get_field_unit_value ( - ACPI_OPERAND_OBJECT *field_desc, - ACPI_OPERAND_OBJECT *result_desc) -{ - ACPI_STATUS status = AE_OK; - u32 mask; - u8 *location = NULL; - u8 locked = FALSE; - - - if (!field_desc) { - status = AE_AML_NO_OPERAND; - } - - if (!(field_desc->common.flags & AOPOBJ_DATA_VALID)) { - status = acpi_ds_get_field_unit_arguments (field_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - if (!field_desc->field_unit.container) { - status = AE_AML_INTERNAL; - } - - else if (ACPI_TYPE_BUFFER != field_desc->field_unit.container->common.type) { - status = AE_AML_OPERAND_TYPE; - } - - else if (!result_desc) { - status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* Get the global lock if needed */ - - locked = acpi_aml_acquire_global_lock (field_desc->field_unit.lock_rule); - - /* Field location is (base of buffer) + (byte offset) */ - - location = field_desc->field_unit.container->buffer.pointer - + field_desc->field_unit.offset; - - /* - * Construct Mask with as many 1 bits as the field width - * - * NOTE: Only the bottom 5 bits are valid for a shift operation, so - * special care must be taken for any shift greater than 31 bits. - * - * TBD: [Unhandled] Fields greater than 32-bits will not work. - */ - - if (field_desc->field_unit.length < 32) { - mask = ((u32) 1 << field_desc->field_unit.length) - (u32) 1; - } - else { - mask = ACPI_UINT32_MAX; - } - - result_desc->integer.type = (u8) ACPI_TYPE_INTEGER; - - /* Get the 32 bit value at the location */ - - MOVE_UNALIGNED32_TO_32 (&result_desc->integer.value, location); - - /* - * Shift the 32-bit word containing the field, and mask off the - * resulting value - */ - - result_desc->integer.value = - (result_desc->integer.value >> field_desc->field_unit.bit_offset) & mask; - - /* Release global lock if we acquired it earlier */ - - acpi_aml_release_global_lock (locked); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_resolve_to_value - * - * PARAMETERS: **Stack_ptr - Points to entry on Obj_stack, which can - * be either an (ACPI_OPERAND_OBJECT *) - * or an ACPI_HANDLE. - * - * RETURN: Status - * - * DESCRIPTION: Convert Reference objects to values - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_resolve_to_value ( - ACPI_OPERAND_OBJECT **stack_ptr, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - - - if (!stack_ptr || !*stack_ptr) { - return (AE_AML_NO_OPERAND); - } - - - /* - * The entity pointed to by the Stack_ptr can be either - * 1) A valid ACPI_OPERAND_OBJECT, or - * 2) A ACPI_NAMESPACE_NODE (Named_obj) - */ - - if (VALID_DESCRIPTOR_TYPE (*stack_ptr, ACPI_DESC_TYPE_INTERNAL)) { - - status = acpi_aml_resolve_object_to_value (stack_ptr, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - /* - * Object on the stack may have changed if Acpi_aml_resolve_object_to_value() - * was called (i.e., we can't use an _else_ here.) - */ - - if (VALID_DESCRIPTOR_TYPE (*stack_ptr, ACPI_DESC_TYPE_NAMED)) { - status = acpi_aml_resolve_node_to_value ((ACPI_NAMESPACE_NODE **) stack_ptr, walk_state); - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_resolve_object_to_value - * - * PARAMETERS: Stack_ptr - Pointer to a stack location that contains a - * ptr to an internal object. - * - * RETURN: Status - * - * DESCRIPTION: Retrieve the value from an internal object. The Reference type - * uses the associated AML opcode to determine the value. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_resolve_object_to_value ( - ACPI_OPERAND_OBJECT **stack_ptr, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *stack_desc; - ACPI_STATUS status = AE_OK; - ACPI_HANDLE temp_handle = NULL; - ACPI_OPERAND_OBJECT *obj_desc = NULL; - u32 index = 0; - u16 opcode; - - - stack_desc = *stack_ptr; - - /* This is an ACPI_OPERAND_OBJECT */ - - switch (stack_desc->common.type) { - - case INTERNAL_TYPE_REFERENCE: - - opcode = stack_desc->reference.opcode; - - switch (opcode) { - - case AML_NAME_OP: - - /* - * Convert indirect name ptr to a direct name ptr. - * Then, Acpi_aml_resolve_node_to_value can be used to get the value - */ - - temp_handle = stack_desc->reference.object; - - /* Delete the Reference Object */ - - acpi_cm_remove_reference (stack_desc); - - /* Put direct name pointer onto stack and exit */ - - (*stack_ptr) = temp_handle; - status = AE_OK; - break; - - - case AML_LOCAL_OP: - case AML_ARG_OP: - - index = stack_desc->reference.offset; - - /* - * Get the local from the method's state info - * Note: this increments the local's object reference count - */ - - status = acpi_ds_method_data_get_value (opcode, index, - walk_state, &obj_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Now we can delete the original Reference Object and - * replace it with the resolve value - */ - - acpi_cm_remove_reference (stack_desc); - *stack_ptr = obj_desc; - - break; - - - /* - * TBD: [Restructure] These next three opcodes change the type of - * the object, which is actually a no-no. - */ - - case AML_ZERO_OP: - - stack_desc->common.type = (u8) ACPI_TYPE_INTEGER; - stack_desc->integer.value = 0; - break; - - - case AML_ONE_OP: - - stack_desc->common.type = (u8) ACPI_TYPE_INTEGER; - stack_desc->integer.value = 1; - break; - - - case AML_ONES_OP: - - stack_desc->common.type = (u8) ACPI_TYPE_INTEGER; - stack_desc->integer.value = ACPI_INTEGER_MAX; - - /* Truncate value if we are executing from a 32-bit ACPI table */ - - acpi_aml_truncate_for32bit_table (stack_desc, walk_state); - break; - - - case AML_INDEX_OP: - - switch (stack_desc->reference.target_type) { - case ACPI_TYPE_BUFFER_FIELD: - - /* Just return - leave the Reference on the stack */ - break; - - - case ACPI_TYPE_PACKAGE: - obj_desc = *stack_desc->reference.where; - if (obj_desc) { - /* - * Valid obj descriptor, copy pointer to return value - * (i.e., dereference the package index) - * Delete the ref object, increment the returned object - */ - acpi_cm_remove_reference (stack_desc); - acpi_cm_add_reference (obj_desc); - *stack_ptr = obj_desc; - } - - else { - /* - * A NULL object descriptor means an unitialized element of - * the package, can't deref it - */ - - status = AE_AML_UNINITIALIZED_ELEMENT; - } - break; - - default: - /* Invalid reference OBJ*/ - - status = AE_AML_INTERNAL; - break; - } - - break; - - - case AML_DEBUG_OP: - - /* Just leave the object as-is */ - break; - - - default: - - status = AE_AML_INTERNAL; - - } /* switch (Opcode) */ - - - if (ACPI_FAILURE (status)) { - return (status); - } - - break; /* case INTERNAL_TYPE_REFERENCE */ - - - case ACPI_TYPE_FIELD_UNIT: - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_ANY); - if (!obj_desc) { - /* Descriptor allocation failure */ - - return (AE_NO_MEMORY); - } - - status = acpi_aml_get_field_unit_value (stack_desc, obj_desc); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (obj_desc); - obj_desc = NULL; - } - - *stack_ptr = (void *) obj_desc; - break; - - - case INTERNAL_TYPE_BANK_FIELD: - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_ANY); - if (!obj_desc) { - /* Descriptor allocation failure */ - - return (AE_NO_MEMORY); - } - - status = acpi_aml_get_field_unit_value (stack_desc, obj_desc); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (obj_desc); - obj_desc = NULL; - } - - *stack_ptr = (void *) obj_desc; - break; - - - /* TBD: [Future] - may need to handle Index_field, and Def_field someday */ - - default: - - break; - - } /* switch (Stack_desc->Common.Type) */ - - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amresop.c b/reactos/drivers/bus/acpi/executer/amresop.c deleted file mode 100644 index 58e9feb94de..00000000000 --- a/reactos/drivers/bus/acpi/executer/amresop.c +++ /dev/null @@ -1,475 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amresop - AML Interpreter operand/object resolution - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amresop") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_check_object_type - * - * PARAMETERS: Type_needed Object type needed - * This_type Actual object type - * Object Object pointer - * - * RETURN: Status - * - * DESCRIPTION: Check required type against actual type - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_aml_check_object_type ( - ACPI_OBJECT_TYPE type_needed, - ACPI_OBJECT_TYPE this_type, - void *object) -{ - - - if (type_needed == ACPI_TYPE_ANY) { - /* All types OK, so we don't perform any typechecks */ - - return (AE_OK); - } - - - if (type_needed != this_type) { - return (AE_AML_OPERAND_TYPE); - } - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_resolve_operands - * - * PARAMETERS: Opcode Opcode being interpreted - * Stack_ptr Top of operand stack - * - * RETURN: Status - * - * DESCRIPTION: Convert stack entries to required types - * - * Each nibble in Arg_types represents one required operand - * and indicates the required Type: - * - * The corresponding stack entry will be converted to the - * required type if possible, else return an exception - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_resolve_operands ( - u16 opcode, - ACPI_OPERAND_OBJECT **stack_ptr, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status = AE_OK; - u8 object_type; - ACPI_HANDLE temp_handle; - u32 arg_types; - ACPI_OPCODE_INFO *op_info; - u32 this_arg_type; - ACPI_OBJECT_TYPE type_needed; - - - op_info = acpi_ps_get_opcode_info (opcode); - if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { - return (AE_AML_BAD_OPCODE); - } - - - arg_types = op_info->runtime_args; - if (arg_types == ARGI_INVALID_OPCODE) { - return (AE_AML_INTERNAL); - } - - - /* - * Normal exit is with *Types == '\0' at end of string. - * Function will return an exception from within the loop upon - * finding an entry which is not, and cannot be converted - * to, the required type; if stack underflows; or upon - * finding a NULL stack entry (which "should never happen"). - */ - - while (GET_CURRENT_ARG_TYPE (arg_types)) { - if (!stack_ptr || !*stack_ptr) { - return (AE_AML_INTERNAL); - } - - /* Extract useful items */ - - obj_desc = *stack_ptr; - - /* Decode the descriptor type */ - - if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - /* Node */ - - object_type = ((ACPI_NAMESPACE_NODE *) obj_desc)->type; - } - - else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) { - /* ACPI internal object */ - - object_type = obj_desc->common.type; - - /* Check for bad ACPI_OBJECT_TYPE */ - - if (!acpi_aml_validate_object_type (object_type)) { - return (AE_AML_OPERAND_TYPE); - } - - if (object_type == (u8) INTERNAL_TYPE_REFERENCE) { - /* - * Decode the Reference - */ - - op_info = acpi_ps_get_opcode_info (opcode); - if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { - return (AE_AML_BAD_OPCODE); - } - - - switch (obj_desc->reference.opcode) { - case AML_ZERO_OP: - case AML_ONE_OP: - case AML_ONES_OP: - case AML_DEBUG_OP: - case AML_NAME_OP: - case AML_INDEX_OP: - case AML_ARG_OP: - case AML_LOCAL_OP: - - break; - - default: - return (AE_AML_OPERAND_TYPE); - break; - } - } - } - - else { - /* Invalid descriptor */ - - return (AE_AML_OPERAND_TYPE); - } - - - /* - * Get one argument type, point to the next - */ - - this_arg_type = GET_CURRENT_ARG_TYPE (arg_types); - INCREMENT_ARG_LIST (arg_types); - - - /* - * Handle cases where the object does not need to be - * resolved to a value - */ - - switch (this_arg_type) { - - case ARGI_REFERENCE: /* References */ - case ARGI_INTEGER_REF: - case ARGI_OBJECT_REF: - case ARGI_DEVICE_REF: - case ARGI_TARGETREF: /* TBD: must implement implicit conversion rules before store */ - case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ - case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ - - /* Need an operand of type INTERNAL_TYPE_REFERENCE */ - - if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) /* direct name ptr OK as-is */ { - goto next_operand; - } - - status = acpi_aml_check_object_type (INTERNAL_TYPE_REFERENCE, - object_type, obj_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - - - if (AML_NAME_OP == obj_desc->reference.opcode) { - /* - * Convert an indirect name ptr to direct name ptr and put - * it on the stack - */ - - temp_handle = obj_desc->reference.object; - acpi_cm_remove_reference (obj_desc); - (*stack_ptr) = temp_handle; - } - - goto next_operand; - break; - - - case ARGI_ANYTYPE: - - /* - * We don't want to resolve Index_op reference objects during - * a store because this would be an implicit De_ref_of operation. - * Instead, we just want to store the reference object. - * -- All others must be resolved below. - */ - - if ((opcode == AML_STORE_OP) && - ((*stack_ptr)->common.type == INTERNAL_TYPE_REFERENCE) && - ((*stack_ptr)->reference.opcode == AML_INDEX_OP)) { - goto next_operand; - } - break; - } - - - /* - * Resolve this object to a value - */ - - status = acpi_aml_resolve_to_value (stack_ptr, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* - * Check the resulting object (value) type - */ - switch (this_arg_type) { - /* - * For the simple cases, only one type of resolved object - * is allowed - */ - case ARGI_MUTEX: - - /* Need an operand of type ACPI_TYPE_MUTEX */ - - type_needed = ACPI_TYPE_MUTEX; - break; - - case ARGI_EVENT: - - /* Need an operand of type ACPI_TYPE_EVENT */ - - type_needed = ACPI_TYPE_EVENT; - break; - - case ARGI_REGION: - - /* Need an operand of type ACPI_TYPE_REGION */ - - type_needed = ACPI_TYPE_REGION; - break; - - case ARGI_IF: /* If */ - - /* Need an operand of type INTERNAL_TYPE_IF */ - - type_needed = INTERNAL_TYPE_IF; - break; - - case ARGI_PACKAGE: /* Package */ - - /* Need an operand of type ACPI_TYPE_PACKAGE */ - - type_needed = ACPI_TYPE_PACKAGE; - break; - - case ARGI_ANYTYPE: - - /* Any operand type will do */ - - type_needed = ACPI_TYPE_ANY; - break; - - - /* - * The more complex cases allow multiple resolved object types - */ - - case ARGI_INTEGER: /* Number */ - - /* - * Need an operand of type ACPI_TYPE_INTEGER, - * But we can implicitly convert from a STRING or BUFFER - */ - status = acpi_aml_convert_to_integer (stack_ptr, walk_state); - if (ACPI_FAILURE (status)) { - if (status == AE_TYPE) { - return (AE_AML_OPERAND_TYPE); - } - - return (status); - } - - goto next_operand; - break; - - - case ARGI_BUFFER: - - /* - * Need an operand of type ACPI_TYPE_BUFFER, - * But we can implicitly convert from a STRING or INTEGER - */ - status = acpi_aml_convert_to_buffer (stack_ptr, walk_state); - if (ACPI_FAILURE (status)) { - if (status == AE_TYPE) { - return (AE_AML_OPERAND_TYPE); - } - - return (status); - } - - goto next_operand; - break; - - - case ARGI_STRING: - - /* - * Need an operand of type ACPI_TYPE_STRING, - * But we can implicitly convert from a BUFFER or INTEGER - */ - status = acpi_aml_convert_to_string (stack_ptr, walk_state); - if (ACPI_FAILURE (status)) { - if (status == AE_TYPE) { - return (AE_AML_OPERAND_TYPE); - } - - return (status); - } - - goto next_operand; - break; - - - case ARGI_COMPUTEDATA: - - /* Need an operand of type INTEGER, STRING or BUFFER */ - - if ((ACPI_TYPE_INTEGER != (*stack_ptr)->common.type) && - (ACPI_TYPE_STRING != (*stack_ptr)->common.type) && - (ACPI_TYPE_BUFFER != (*stack_ptr)->common.type)) { - return (AE_AML_OPERAND_TYPE); - } - goto next_operand; - break; - - - case ARGI_DATAOBJECT: - /* - * ARGI_DATAOBJECT is only used by the Size_of operator. - * - * The ACPI specification allows Size_of to return the size of - * a Buffer, String or Package. However, the MS ACPI.SYS AML - * Interpreter also allows an Node reference to return without - * error with a size of 4. - */ - - /* Need a buffer, string, package or Node reference */ - - if (((*stack_ptr)->common.type != ACPI_TYPE_BUFFER) && - ((*stack_ptr)->common.type != ACPI_TYPE_STRING) && - ((*stack_ptr)->common.type != ACPI_TYPE_PACKAGE) && - ((*stack_ptr)->common.type != INTERNAL_TYPE_REFERENCE)) { - return (AE_AML_OPERAND_TYPE); - } - - /* - * If this is a reference, only allow a reference to an Node. - */ - if ((*stack_ptr)->common.type == INTERNAL_TYPE_REFERENCE) { - if (!(*stack_ptr)->reference.node) { - return (AE_AML_OPERAND_TYPE); - } - } - goto next_operand; - break; - - - case ARGI_COMPLEXOBJ: - - /* Need a buffer or package */ - - if (((*stack_ptr)->common.type != ACPI_TYPE_BUFFER) && - ((*stack_ptr)->common.type != ACPI_TYPE_PACKAGE)) { - return (AE_AML_OPERAND_TYPE); - } - goto next_operand; - break; - - - default: - - /* Unknown type */ - - return (AE_BAD_PARAMETER); - } - - - /* - * Make sure that the original object was resolved to the - * required object type (Simple cases only). - */ - status = acpi_aml_check_object_type (type_needed, - (*stack_ptr)->common.type, *stack_ptr); - if (ACPI_FAILURE (status)) { - return (status); - } - - -next_operand: - /* - * If more operands needed, decrement Stack_ptr to point - * to next operand on stack - */ - if (GET_CURRENT_ARG_TYPE (arg_types)) { - stack_ptr--; - } - - } /* while (*Types) */ - - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amstore.c b/reactos/drivers/bus/acpi/executer/amstore.c deleted file mode 100644 index 136373a0c63..00000000000 --- a/reactos/drivers/bus/acpi/executer/amstore.c +++ /dev/null @@ -1,563 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amstore - AML Interpreter object store support - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amstore") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exec_store - * - * PARAMETERS: *Val_desc - Value to be stored - * *Dest_desc - Where to store it 0 Must be (ACPI_HANDLE) - * or an ACPI_OPERAND_OBJECT of type - * Reference; if the latter the descriptor - * will be either reused or deleted. - * - * RETURN: Status - * - * DESCRIPTION: Store the value described by Val_desc into the location - * described by Dest_desc. Called by various interpreter - * functions to store the result of an operation into - * the destination operand. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_exec_store ( - ACPI_OPERAND_OBJECT *val_desc, - ACPI_OPERAND_OBJECT *dest_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *ref_desc = dest_desc; - - - /* Validate parameters */ - - if (!val_desc || !dest_desc) { - return (AE_AML_NO_OPERAND); - } - - /* Dest_desc can be either a namespace node or an ACPI object */ - - if (VALID_DESCRIPTOR_TYPE (dest_desc, ACPI_DESC_TYPE_NAMED)) { - /* - * Dest is a namespace node, - * Storing an object into a Name "container" - */ - status = acpi_aml_store_object_to_node (val_desc, - (ACPI_NAMESPACE_NODE *) dest_desc, walk_state); - - /* All done, that's it */ - - return (status); - } - - - /* Destination object must be an object of type Reference */ - - if (dest_desc->common.type != INTERNAL_TYPE_REFERENCE) { - /* Destination is not an Reference */ - - return (AE_AML_OPERAND_TYPE); - } - - - /* - * Examine the Reference opcode. These cases are handled: - * - * 1) Store to Name (Change the object associated with a name) - * 2) Store to an indexed area of a Buffer or Package - * 3) Store to a Method Local or Arg - * 4) Store to the debug object - * 5) Store to a constant -- a noop - */ - - switch (ref_desc->reference.opcode) { - - case AML_NAME_OP: - - /* Storing an object into a Name "container" */ - - status = acpi_aml_store_object_to_node (val_desc, ref_desc->reference.object, - walk_state); - break; - - - case AML_INDEX_OP: - - /* Storing to an Index (pointer into a packager or buffer) */ - - status = acpi_aml_store_object_to_index (val_desc, ref_desc, walk_state); - break; - - - case AML_LOCAL_OP: - case AML_ARG_OP: - - /* Store to a method local/arg */ - - status = acpi_ds_store_object_to_local (ref_desc->reference.opcode, - ref_desc->reference.offset, val_desc, walk_state); - break; - - - case AML_DEBUG_OP: - - /* - * Storing to the Debug object causes the value stored to be - * displayed and otherwise has no effect -- see ACPI Specification - * - * TBD: print known object types "prettier". - */ - - break; - - - case AML_ZERO_OP: - case AML_ONE_OP: - case AML_ONES_OP: - - /* - * Storing to a constant is a no-op -- see ACPI Specification - * Delete the reference descriptor, however - */ - break; - - - default: - - /* TBD: [Restructure] use object dump routine !! */ - - status = AE_AML_INTERNAL; - break; - - } /* switch (Ref_desc->Reference.Opcode) */ - - - /* Always delete the reference descriptor object */ - - if (ref_desc) { - acpi_cm_remove_reference (ref_desc); - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_store_object_to_index - * - * PARAMETERS: *Val_desc - Value to be stored - * *Node - Named object to receive the value - * - * RETURN: Status - * - * DESCRIPTION: Store the object to the named object. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_store_object_to_index ( - ACPI_OPERAND_OBJECT *val_desc, - ACPI_OPERAND_OBJECT *dest_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *obj_desc; - u32 length; - u32 i; - u8 value = 0; - - - /* - * Destination must be a reference pointer, and - * must point to either a buffer or a package - */ - - switch (dest_desc->reference.target_type) { - case ACPI_TYPE_PACKAGE: - /* - * Storing to a package element is not simple. The source must be - * evaluated and converted to the type of the destination and then the - * source is copied into the destination - we can't just point to the - * source object. - */ - if (dest_desc->reference.target_type == ACPI_TYPE_PACKAGE) { - /* - * The object at *(Dest_desc->Reference.Where) is the - * element within the package that is to be modified. - */ - obj_desc = *(dest_desc->reference.where); - if (obj_desc) { - /* - * If the Destination element is a package, we will delete - * that object and construct a new one. - * - * TBD: [Investigate] Should both the src and dest be required - * to be packages? - * && (Val_desc->Common.Type == ACPI_TYPE_PACKAGE) - */ - if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { - /* - * Take away the reference for being part of a package and - * delete - */ - acpi_cm_remove_reference (obj_desc); - acpi_cm_remove_reference (obj_desc); - - obj_desc = NULL; - } - } - - if (!obj_desc) { - /* - * If the Obj_desc is NULL, it means that an uninitialized package - * element has been used as a destination (this is OK), therefore, - * we must create the destination element to match the type of the - * source element NOTE: Val_desc can be of any type. - */ - obj_desc = acpi_cm_create_internal_object (val_desc->common.type); - if (!obj_desc) { - return (AE_NO_MEMORY); - } - - /* - * If the source is a package, copy the source to the new dest - */ - if (ACPI_TYPE_PACKAGE == obj_desc->common.type) { - status = acpi_cm_copy_ipackage_to_ipackage (val_desc, obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (obj_desc); - return (status); - } - } - - /* - * Install the new descriptor into the package and add a - * reference to the newly created descriptor for now being - * part of the parent package - */ - - *(dest_desc->reference.where) = obj_desc; - acpi_cm_add_reference (obj_desc); - } - - if (ACPI_TYPE_PACKAGE != obj_desc->common.type) { - /* - * The destination element is not a package, so we need to - * convert the contents of the source (Val_desc) and copy into - * the destination (Obj_desc) - */ - status = acpi_aml_store_object_to_object (val_desc, obj_desc, - walk_state); - if (ACPI_FAILURE (status)) { - /* - * An error occurrered when copying the internal object - * so delete the reference. - */ - return (AE_AML_OPERAND_TYPE); - } - } - } - break; - - - case ACPI_TYPE_BUFFER_FIELD: - /* - * Storing into a buffer at a location defined by an Index. - * - * Each 8-bit element of the source object is written to the - * 8-bit Buffer Field of the Index destination object. - */ - - /* - * Set the Obj_desc to the destination object and type check. - */ - obj_desc = dest_desc->reference.object; - if (obj_desc->common.type != ACPI_TYPE_BUFFER) { - return (AE_AML_OPERAND_TYPE); - } - - /* - * The assignment of the individual elements will be slightly - * different for each source type. - */ - - switch (val_desc->common.type) { - /* - * If the type is Integer, assign bytewise - * This loop to assign each of the elements is somewhat - * backward because of the Big Endian-ness of IA-64 - */ - case ACPI_TYPE_INTEGER: - length = sizeof (ACPI_INTEGER); - for (i = length; i != 0; i--) { - value = (u8)(val_desc->integer.value >> (MUL_8 (i - 1))); - obj_desc->buffer.pointer[dest_desc->reference.offset] = value; - } - break; - - /* - * If the type is Buffer, the Length is in the structure. - * Just loop through the elements and assign each one in turn. - */ - case ACPI_TYPE_BUFFER: - length = val_desc->buffer.length; - for (i = 0; i < length; i++) { - value = *(val_desc->buffer.pointer + i); - obj_desc->buffer.pointer[dest_desc->reference.offset] = value; - } - break; - - /* - * If the type is String, the Length is in the structure. - * Just loop through the elements and assign each one in turn. - */ - case ACPI_TYPE_STRING: - length = val_desc->string.length; - for (i = 0; i < length; i++) { - value = *(val_desc->string.pointer + i); - obj_desc->buffer.pointer[dest_desc->reference.offset] = value; - } - break; - - /* - * If source is not a valid type so return an error. - */ - default: - status = AE_AML_OPERAND_TYPE; - break; - } - break; - - - default: - status = AE_AML_OPERAND_TYPE; - break; - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_store_object_to_node - * - * PARAMETERS: *Source_desc - Value to be stored - * *Node - Named object to receive the value - * - * RETURN: Status - * - * DESCRIPTION: Store the object to the named object. - * - * The Assignment of an object to a named object is handled here - * The val passed in will replace the current value (if any) - * with the input value. - * - * When storing into an object the data is converted to the - * target object type then stored in the object. This means - * that the target object type (for an initialized target) will - * not be changed by a store operation. - * - * NOTE: the global lock is acquired early. This will result - * in the global lock being held a bit longer. Also, if the - * function fails during set up we may get the lock when we - * don't really need it. I don't think we care. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_store_object_to_node ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_NAMESPACE_NODE *node, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *target_desc; - OBJECT_TYPE_INTERNAL target_type = ACPI_TYPE_ANY; - - - /* - * Assuming the parameters were already validated - */ - ACPI_ASSERT((node) && (source_desc)); - - - /* - * Get current type of the node, and object attached to Node - */ - target_type = acpi_ns_get_type (node); - target_desc = acpi_ns_get_attached_object (node); - - - /* - * Resolve the source object to an actual value - * (If it is a reference object) - */ - status = acpi_aml_resolve_object (&source_desc, target_type, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* - * Do the actual store operation - */ - switch (target_type) { - case INTERNAL_TYPE_DEF_FIELD: - - /* Raw data copy for target types Integer/String/Buffer */ - - status = acpi_aml_copy_data_to_named_field (source_desc, node); - break; - - - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: - case ACPI_TYPE_FIELD_UNIT: - - /* - * These target types are all of type Integer/String/Buffer, and - * therefore support implicit conversion before the store. - * - * Copy and/or convert the source object to a new target object - */ - status = acpi_aml_store_object (source_desc, target_type, &target_desc, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Store the new Target_desc as the new value of the Name, and set - * the Name's type to that of the value being stored in it. - * Source_desc reference count is incremented by Attach_object. - */ - status = acpi_ns_attach_object (node, target_desc, target_type); - break; - - - default: - - /* No conversions for all other types. Just attach the source object */ - - status = acpi_ns_attach_object (node, source_desc, source_desc->common.type); - - break; - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_store_object_to_object - * - * PARAMETERS: *Source_desc - Value to be stored - * *Dest_desc - Object to receive the value - * - * RETURN: Status - * - * DESCRIPTION: Store an object to another object. - * - * The Assignment of an object to another (not named) object - * is handled here. - * The val passed in will replace the current value (if any) - * with the input value. - * - * When storing into an object the data is converted to the - * target object type then stored in the object. This means - * that the target object type (for an initialized target) will - * not be changed by a store operation. - * - * This module allows destination types of Number, String, - * and Buffer. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_store_object_to_object ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *dest_desc, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - OBJECT_TYPE_INTERNAL destination_type = dest_desc->common.type; - - - /* - * Assuming the parameters are valid! - */ - ACPI_ASSERT((dest_desc) && (source_desc)); - - - /* - * From this interface, we only support Integers/Strings/Buffers - */ - switch (destination_type) { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - break; - - default: - return (AE_NOT_IMPLEMENTED); - } - - - /* - * Resolve the source object to an actual value - * (If it is a reference object) - */ - status = acpi_aml_resolve_object (&source_desc, destination_type, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* - * Copy and/or convert the source object to the destination object - */ - status = acpi_aml_store_object (source_desc, destination_type, &dest_desc, walk_state); - - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/executer/amstoren.c b/reactos/drivers/bus/acpi/executer/amstoren.c deleted file mode 100644 index aacf99e24f4..00000000000 --- a/reactos/drivers/bus/acpi/executer/amstoren.c +++ /dev/null @@ -1,252 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amstoren - AML Interpreter object store support, - * Store to Node (namespace object) - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amstoren") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_resolve_object - * - * PARAMETERS: Source_desc_ptr - Pointer to the source object - * Target_type - Current type of the target - * Walk_state - Current walk state - * - * RETURN: Status, resolved object in Source_desc_ptr. - * - * DESCRIPTION: Resolve an object. If the object is a reference, dereference - * it and return the actual object in the Source_desc_ptr. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_resolve_object ( - ACPI_OPERAND_OBJECT **source_desc_ptr, - OBJECT_TYPE_INTERNAL target_type, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *source_desc = *source_desc_ptr; - ACPI_STATUS status = AE_OK; - - - /* - * Ensure we have a Source that can be stored in the target - */ - switch (target_type) { - - /* This case handles the "interchangeable" types Integer, String, and Buffer. */ - - /* - * These cases all require only Integers or values that - * can be converted to Integers (Strings or Buffers) - */ - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_FIELD_UNIT: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: - - /* - * Stores into a Field/Region or into a Buffer/String - * are all essentially the same. - */ - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - case INTERNAL_TYPE_DEF_FIELD: - - /* - * If Source_desc is not a valid type, try to resolve it to one. - */ - if ((source_desc->common.type != ACPI_TYPE_INTEGER) && - (source_desc->common.type != ACPI_TYPE_BUFFER) && - (source_desc->common.type != ACPI_TYPE_STRING)) { - /* - * Initially not a valid type, convert - */ - status = acpi_aml_resolve_to_value (source_desc_ptr, walk_state); - if (ACPI_SUCCESS (status) && - (source_desc->common.type != ACPI_TYPE_INTEGER) && - (source_desc->common.type != ACPI_TYPE_BUFFER) && - (source_desc->common.type != ACPI_TYPE_STRING)) { - /* - * Conversion successful but still not a valid type - */ - status = AE_AML_OPERAND_TYPE; - } - } - break; - - - case INTERNAL_TYPE_ALIAS: - - /* - * Aliases are resolved by Acpi_aml_prep_operands - */ - status = AE_AML_INTERNAL; - break; - - - case ACPI_TYPE_PACKAGE: - default: - - /* - * All other types than Alias and the various Fields come here, - * including the untyped case - ACPI_TYPE_ANY. - */ - break; - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_store_object - * - * PARAMETERS: Source_desc - Object to store - * Target_type - Current type of the target - * Target_desc_ptr - Pointer to the target - * Walk_state - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: "Store" an object to another object. This may include - * converting the source type to the target type (implicit - * conversion), and a copy of the value of the source to - * the target. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_store_object ( - ACPI_OPERAND_OBJECT *source_desc, - OBJECT_TYPE_INTERNAL target_type, - ACPI_OPERAND_OBJECT **target_desc_ptr, - ACPI_WALK_STATE *walk_state) -{ - ACPI_OPERAND_OBJECT *target_desc = *target_desc_ptr; - ACPI_STATUS status = AE_OK; - - - /* - * Perform the "implicit conversion" of the source to the current type - * of the target - As per the ACPI specification. - * - * If no conversion performed, Source_desc is left alone, otherwise it - * is updated with a new object. - */ - status = acpi_aml_convert_to_target_type (target_type, &source_desc, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * We now have two objects of identical types, and we can perform a - * copy of the *value* of the source object. - */ - switch (target_type) { - case ACPI_TYPE_ANY: - case INTERNAL_TYPE_DEF_ANY: - - /* - * The target namespace node is uninitialized (has no target object), - * and will take on the type of the source object - */ - - *target_desc_ptr = source_desc; - break; - - - case ACPI_TYPE_INTEGER: - - target_desc->integer.value = source_desc->integer.value; - - /* Truncate value if we are executing from a 32-bit ACPI table */ - - acpi_aml_truncate_for32bit_table (target_desc, walk_state); - break; - - - case ACPI_TYPE_FIELD_UNIT: - - status = acpi_aml_copy_integer_to_field_unit (source_desc, target_desc); - break; - - - case INTERNAL_TYPE_BANK_FIELD: - - status = acpi_aml_copy_integer_to_bank_field (source_desc, target_desc); - break; - - - case INTERNAL_TYPE_INDEX_FIELD: - - status = acpi_aml_copy_integer_to_index_field (source_desc, target_desc); - break; - - - case ACPI_TYPE_STRING: - - status = acpi_aml_copy_string_to_string (source_desc, target_desc); - break; - - - case ACPI_TYPE_BUFFER: - - status = acpi_aml_copy_buffer_to_buffer (source_desc, target_desc); - break; - - - case ACPI_TYPE_PACKAGE: - - /* - * TBD: [Unhandled] Not real sure what to do here - */ - status = AE_NOT_IMPLEMENTED; - break; - - - default: - - /* - * All other types come here. - */ - status = AE_NOT_IMPLEMENTED; - break; - } - - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amstorob.c b/reactos/drivers/bus/acpi/executer/amstorob.c deleted file mode 100644 index a0d25c731e4..00000000000 --- a/reactos/drivers/bus/acpi/executer/amstorob.c +++ /dev/null @@ -1,427 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amstorob - AML Interpreter object store support, store to object - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amstorob") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_copy_buffer_to_buffer - * - * PARAMETERS: Source_desc - Source object to copy - * Target_desc - Destination object of the copy - * - * RETURN: Status - * - * DESCRIPTION: Copy a buffer object to another buffer object. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_copy_buffer_to_buffer ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc) -{ - u32 length; - u8 *buffer; - - - /* - * We know that Source_desc is a buffer by now - */ - buffer = (u8 *) source_desc->buffer.pointer; - length = source_desc->buffer.length; - - /* - * If target is a buffer of length zero, allocate a new - * buffer of the proper length - */ - if (target_desc->buffer.length == 0) { - target_desc->buffer.pointer = acpi_cm_allocate (length); - if (!target_desc->buffer.pointer) { - return (AE_NO_MEMORY); - } - - target_desc->buffer.length = length; - } - - /* - * Buffer is a static allocation, - * only place what will fit in the buffer. - */ - if (length <= target_desc->buffer.length) { - /* Clear existing buffer and copy in the new one */ - - MEMSET(target_desc->buffer.pointer, 0, target_desc->buffer.length); - MEMCPY(target_desc->buffer.pointer, buffer, length); - } - - else { - /* - * Truncate the source, copy only what will fit - */ - MEMCPY(target_desc->buffer.pointer, buffer, target_desc->buffer.length); - - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_copy_string_to_string - * - * PARAMETERS: Source_desc - Source object to copy - * Target_desc - Destination object of the copy - * - * RETURN: Status - * - * DESCRIPTION: Copy a String object to another String object - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_copy_string_to_string ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc) -{ - u32 length; - u8 *buffer; - - - /* - * We know that Source_desc is a string by now. - */ - buffer = (u8 *) source_desc->string.pointer; - length = source_desc->string.length; - - /* - * Setting a string value replaces the old string - */ - if (length < target_desc->string.length) { - /* Clear old string and copy in the new one */ - - MEMSET(target_desc->string.pointer, 0, target_desc->string.length); - MEMCPY(target_desc->string.pointer, buffer, length); - } - - else { - /* - * Free the current buffer, then allocate a buffer - * large enough to hold the value - */ - if (target_desc->string.pointer && - !acpi_tb_system_table_pointer (target_desc->string.pointer)) { - /* - * Only free if not a pointer into the DSDT - */ - acpi_cm_free(target_desc->string.pointer); - } - - target_desc->string.pointer = acpi_cm_allocate (length + 1); - if (!target_desc->string.pointer) { - return (AE_NO_MEMORY); - } - target_desc->string.length = length; - - - MEMCPY(target_desc->string.pointer, buffer, length); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_copy_integer_to_index_field - * - * PARAMETERS: Source_desc - Source object to copy - * Target_desc - Destination object of the copy - * - * RETURN: Status - * - * DESCRIPTION: Write an Integer to an Index Field - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_copy_integer_to_index_field ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc) -{ - ACPI_STATUS status; - u8 locked; - - - /* - * Get the global lock if needed - */ - locked = acpi_aml_acquire_global_lock (target_desc->index_field.lock_rule); - - /* - * Set Index value to select proper Data register - * perform the update (Set index) - */ - status = acpi_aml_access_named_field (ACPI_WRITE, - target_desc->index_field.index, - &target_desc->index_field.value, - sizeof (target_desc->index_field.value)); - if (ACPI_SUCCESS (status)) { - /* Set_index was successful, next set Data value */ - - status = acpi_aml_access_named_field (ACPI_WRITE, - target_desc->index_field.data, - &source_desc->integer.value, - sizeof (source_desc->integer.value)); - - } - - - - /* - * Release global lock if we acquired it earlier - */ - acpi_aml_release_global_lock (locked); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_copy_integer_to_bank_field - * - * PARAMETERS: Source_desc - Source object to copy - * Target_desc - Destination object of the copy - * - * RETURN: Status - * - * DESCRIPTION: Write an Integer to a Bank Field - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_copy_integer_to_bank_field ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc) -{ - ACPI_STATUS status; - u8 locked; - - - /* - * Get the global lock if needed - */ - locked = acpi_aml_acquire_global_lock (target_desc->index_field.lock_rule); - - - /* - * Set Bank value to select proper Bank - * Perform the update (Set Bank Select) - */ - - status = acpi_aml_access_named_field (ACPI_WRITE, - target_desc->bank_field.bank_select, - &target_desc->bank_field.value, - sizeof (target_desc->bank_field.value)); - if (ACPI_SUCCESS (status)) { - /* Set bank select successful, set data value */ - - status = acpi_aml_access_named_field (ACPI_WRITE, - target_desc->bank_field.bank_select, - &source_desc->bank_field.value, - sizeof (source_desc->bank_field.value)); - } - - - - /* - * Release global lock if we acquired it earlier - */ - acpi_aml_release_global_lock (locked); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_copy_data_to_named_field - * - * PARAMETERS: Source_desc - Source object to copy - * Node - Destination Namespace node - * - * RETURN: Status - * - * DESCRIPTION: Copy raw data to a Named Field. No implicit conversion - * is performed on the source object - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_copy_data_to_named_field ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_NAMESPACE_NODE *node) -{ - ACPI_STATUS status; - u8 locked; - u32 length; - u8 *buffer; - - - /* - * Named fields (Create_xxx_field) - We don't perform any conversions on the - * source operand, just use the raw data - */ - switch (source_desc->common.type) { - case ACPI_TYPE_INTEGER: - buffer = (u8 *) &source_desc->integer.value; - length = sizeof (source_desc->integer.value); - break; - - case ACPI_TYPE_BUFFER: - buffer = (u8 *) source_desc->buffer.pointer; - length = source_desc->buffer.length; - break; - - case ACPI_TYPE_STRING: - buffer = (u8 *) source_desc->string.pointer; - length = source_desc->string.length; - break; - - default: - return (AE_TYPE); - } - - /* - * Get the global lock if needed before the update - * TBD: not needed! - */ - locked = acpi_aml_acquire_global_lock (source_desc->field.lock_rule); - - status = acpi_aml_access_named_field (ACPI_WRITE, - node, buffer, length); - - acpi_aml_release_global_lock (locked); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_copy_integer_to_field_unit - * - * PARAMETERS: Source_desc - Source object to copy - * Target_desc - Destination object of the copy - * - * RETURN: Status - * - * DESCRIPTION: Write an Integer to a Field Unit. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_copy_integer_to_field_unit ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc) -{ - ACPI_STATUS status = AE_OK; - u8 *location = NULL; - u32 mask; - u32 new_value; - u8 locked = FALSE; - - - /* - * If the Field Buffer and Index have not been previously evaluated, - * evaluate them and save the results. - */ - if (!(target_desc->common.flags & AOPOBJ_DATA_VALID)) { - status = acpi_ds_get_field_unit_arguments (target_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - if ((!target_desc->field_unit.container || - ACPI_TYPE_BUFFER != target_desc->field_unit.container->common.type)) { - return (AE_AML_INTERNAL); - } - - /* - * Get the global lock if needed - */ - locked = acpi_aml_acquire_global_lock (target_desc->field_unit.lock_rule); - - /* - * TBD: [Unhandled] REMOVE this limitation - * Make sure the operation is within the limits of our implementation - * this is not a Spec limitation!! - */ - if (target_desc->field_unit.length + target_desc->field_unit.bit_offset > 32) { - return (AE_NOT_IMPLEMENTED); - } - - /* Field location is (base of buffer) + (byte offset) */ - - location = target_desc->field_unit.container->buffer.pointer - + target_desc->field_unit.offset; - - /* - * Construct Mask with 1 bits where the field is, - * 0 bits elsewhere - */ - mask = ((u32) 1 << target_desc->field_unit.length) - ((u32)1 - << target_desc->field_unit.bit_offset); - - /* Zero out the field in the buffer */ - - MOVE_UNALIGNED32_TO_32 (&new_value, location); - new_value &= ~mask; - - /* - * Shift and mask the new value into position, - * and or it into the buffer. - */ - new_value |= (source_desc->integer.value << target_desc->field_unit.bit_offset) & - mask; - - /* Store back the value */ - - MOVE_UNALIGNED32_TO_32 (location, &new_value); - - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amsystem.c b/reactos/drivers/bus/acpi/executer/amsystem.c deleted file mode 100644 index aff86885139..00000000000 --- a/reactos/drivers/bus/acpi/executer/amsystem.c +++ /dev/null @@ -1,323 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amsystem - Interface to OS services - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amsystem") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_wait_semaphore - * - * PARAMETERS: Semaphore - OSD semaphore to wait on - * Timeout - Max time to wait - * - * RETURN: Status - * - * DESCRIPTION: Implements a semaphore wait with a check to see if the - * semaphore is available immediately. If it is not, the - * interpreter is released. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_system_wait_semaphore ( - ACPI_HANDLE semaphore, - u32 timeout) -{ - ACPI_STATUS status; - - - status = acpi_os_wait_semaphore (semaphore, 1, 0); - if (ACPI_SUCCESS (status)) { - return (status); - } - - if (status == AE_TIME) { - /* We must wait, so unlock the interpreter */ - - acpi_aml_exit_interpreter (); - - status = acpi_os_wait_semaphore (semaphore, 1, timeout); - - /* Reacquire the interpreter */ - - status = acpi_aml_enter_interpreter (); - if (ACPI_SUCCESS (status)) { - /* Restore the timeout exception */ - - status = AE_TIME; - } - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_do_stall - * - * PARAMETERS: How_long - The amount of time to stall - * - * RETURN: None - * - * DESCRIPTION: Suspend running thread for specified amount of time. - * - ******************************************************************************/ - -void -acpi_aml_system_do_stall ( - u32 how_long) -{ - - if (how_long > 1000) /* 1 millisecond */ { - /* Since this thread will sleep, we must release the interpreter */ - - acpi_aml_exit_interpreter (); - - acpi_os_sleep_usec (how_long); - - /* And now we must get the interpreter again */ - - acpi_aml_enter_interpreter (); - } - - else { - acpi_os_sleep_usec (how_long); - } -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_do_suspend - * - * PARAMETERS: How_long - The amount of time to suspend - * - * RETURN: None - * - * DESCRIPTION: Suspend running thread for specified amount of time. - * - ******************************************************************************/ - -void -acpi_aml_system_do_suspend ( - u32 how_long) -{ - /* Since this thread will sleep, we must release the interpreter */ - - acpi_aml_exit_interpreter (); - - acpi_os_sleep ((u16) (how_long / (u32) 1000), - (u16) (how_long % (u32) 1000)); - - /* And now we must get the interpreter again */ - - acpi_aml_enter_interpreter (); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_acquire_mutex - * - * PARAMETERS: *Time_desc - The 'time to delay' object descriptor - * *Obj_desc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Provides an access point to perform synchronization operations - * within the AML. This function will cause a lock to be generated - * for the Mutex pointed to by Obj_desc. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_system_acquire_mutex ( - ACPI_OPERAND_OBJECT *time_desc, - ACPI_OPERAND_OBJECT *obj_desc) -{ - ACPI_STATUS status = AE_OK; - - - if (!obj_desc) { - return (AE_BAD_PARAMETER); - } - - /* - * Support for the _GL_ Mutex object -- go get the global lock - */ - - if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { - status = acpi_ev_acquire_global_lock (); - return (status); - } - - status = acpi_aml_system_wait_semaphore (obj_desc->mutex.semaphore, - (u32) time_desc->integer.value); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_release_mutex - * - * PARAMETERS: *Obj_desc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Provides an access point to perform synchronization operations - * within the AML. This operation is a request to release a - * previously acquired Mutex. If the Mutex variable is set then - * it will be decremented. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_system_release_mutex ( - ACPI_OPERAND_OBJECT *obj_desc) -{ - ACPI_STATUS status = AE_OK; - - - if (!obj_desc) { - return (AE_BAD_PARAMETER); - } - - /* - * Support for the _GL_ Mutex object -- release the global lock - */ - if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { - acpi_ev_release_global_lock (); - return (AE_OK); - } - - status = acpi_os_signal_semaphore (obj_desc->mutex.semaphore, 1); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_signal_event - * - * PARAMETERS: *Obj_desc - The object descriptor for this op - * - * RETURN: AE_OK - * - * DESCRIPTION: Provides an access point to perform synchronization operations - * within the AML. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_system_signal_event ( - ACPI_OPERAND_OBJECT *obj_desc) -{ - ACPI_STATUS status = AE_OK; - - - if (obj_desc) { - status = acpi_os_signal_semaphore (obj_desc->event.semaphore, 1); - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_wait_event - * - * PARAMETERS: *Time_desc - The 'time to delay' object descriptor - * *Obj_desc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Provides an access point to perform synchronization operations - * within the AML. This operation is a request to wait for an - * event. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_system_wait_event ( - ACPI_OPERAND_OBJECT *time_desc, - ACPI_OPERAND_OBJECT *obj_desc) -{ - ACPI_STATUS status = AE_OK; - - - if (obj_desc) { - status = acpi_aml_system_wait_semaphore (obj_desc->event.semaphore, - (u32) time_desc->integer.value); - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_system_reset_event - * - * PARAMETERS: *Obj_desc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Reset an event to a known state. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_system_reset_event ( - ACPI_OPERAND_OBJECT *obj_desc) -{ - ACPI_STATUS status = AE_OK; - void *temp_semaphore; - - - /* - * We are going to simply delete the existing semaphore and - * create a new one! - */ - - status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore); - if (ACPI_SUCCESS (status)) { - acpi_os_delete_semaphore (obj_desc->event.semaphore); - obj_desc->event.semaphore = temp_semaphore; - } - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/executer/amutils.c b/reactos/drivers/bus/acpi/executer/amutils.c deleted file mode 100644 index 28333f8c1d9..00000000000 --- a/reactos/drivers/bus/acpi/executer/amutils.c +++ /dev/null @@ -1,359 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amutils - interpreter/scanner utilities - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amutils") - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_enter_interpreter - * - * PARAMETERS: None - * - * DESCRIPTION: Enter the interpreter execution region - * TBD: should be a macro - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_enter_interpreter (void) -{ - ACPI_STATUS status; - - - status = acpi_cm_acquire_mutex (ACPI_MTX_EXECUTE); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_exit_interpreter - * - * PARAMETERS: None - * - * DESCRIPTION: Exit the interpreter execution region - * - * Cases where the interpreter is unlocked: - * 1) Completion of the execution of a control method - * 2) Method blocked on a Sleep() AML opcode - * 3) Method blocked on an Acquire() AML opcode - * 4) Method blocked on a Wait() AML opcode - * 5) Method blocked to acquire the global lock - * 6) Method blocked to execute a serialized control method that is - * already executing - * 7) About to invoke a user-installed opregion handler - * - * TBD: should be a macro - * - ******************************************************************************/ - -void -acpi_aml_exit_interpreter (void) -{ - - acpi_cm_release_mutex (ACPI_MTX_EXECUTE); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_validate_object_type - * - * PARAMETERS: Type Object type to validate - * - * DESCRIPTION: Determine if a type is a valid ACPI object type - * - ******************************************************************************/ - -u8 -acpi_aml_validate_object_type ( - ACPI_OBJECT_TYPE type) -{ - - if ((type > ACPI_TYPE_MAX && type < INTERNAL_TYPE_BEGIN) || - (type > INTERNAL_TYPE_MAX)) { - return (FALSE); - } - - return (TRUE); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_truncate_for32bit_table - * - * PARAMETERS: Obj_desc - Object to be truncated - * Walk_state - Current walk state - * (A method must be executing) - * - * RETURN: none - * - * DESCRIPTION: Truncate a number to 32-bits if the currently executing method - * belongs to a 32-bit ACPI table. - * - ******************************************************************************/ - -void -acpi_aml_truncate_for32bit_table ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state) -{ - - /* - * Object must be a valid number and we must be executing - * a control method - */ - - if ((!obj_desc) || - (obj_desc->common.type != ACPI_TYPE_INTEGER) || - (!walk_state->method_node)) { - return; - } - - if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) { - /* - * We are running a method that exists in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper 32-bit field - */ - obj_desc->integer.value &= (ACPI_INTEGER) ACPI_UINT32_MAX; - } -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_acquire_global_lock - * - * PARAMETERS: Rule - Lock rule: Always_lock, Never_lock - * - * RETURN: TRUE/FALSE indicating whether the lock was actually acquired - * - * DESCRIPTION: Obtain the global lock and keep track of this fact via two - * methods. A global variable keeps the state of the lock, and - * the state is returned to the caller. - * - ******************************************************************************/ - -u8 -acpi_aml_acquire_global_lock ( - u32 rule) -{ - u8 locked = FALSE; - ACPI_STATUS status; - - - /* Only attempt lock if the Rule says so */ - - if (rule == (u32) GLOCK_ALWAYS_LOCK) { - /* We should attempt to get the lock */ - - status = acpi_ev_acquire_global_lock (); - if (ACPI_SUCCESS (status)) { - locked = TRUE; - } - - } - - return (locked); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_release_global_lock - * - * PARAMETERS: Locked_by_me - Return value from corresponding call to - * Acquire_global_lock. - * - * RETURN: Status - * - * DESCRIPTION: Release the global lock if it is locked. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_release_global_lock ( - u8 locked_by_me) -{ - - - /* Only attempt unlock if the caller locked it */ - - if (locked_by_me) { - /* OK, now release the lock */ - - acpi_ev_release_global_lock (); - } - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_digits_needed - * - * PARAMETERS: val - Value to be represented - * base - Base of representation - * - * RETURN: the number of digits needed to represent val in base - * - ******************************************************************************/ - -u32 -acpi_aml_digits_needed ( - ACPI_INTEGER val, - u32 base) -{ - u32 num_digits = 0; - - - if (base < 1) { - REPORT_ERROR (("Aml_digits_needed: Internal error - Invalid base\n")); - } - - else { - for (num_digits = 1; (val = ACPI_DIVIDE (val,base)); ++num_digits) { ; } - } - - return (num_digits); -} - - -/******************************************************************************* - * - * FUNCTION: ntohl - * - * PARAMETERS: Value - Value to be converted - * - * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) - * - ******************************************************************************/ - -static u32 -_ntohl ( - u32 value) -{ - union { - u32 value; - u8 bytes[4]; - } out; - - union { - u32 value; - u8 bytes[4]; - } in; - - - in.value = value; - - out.bytes[0] = in.bytes[3]; - out.bytes[1] = in.bytes[2]; - out.bytes[2] = in.bytes[1]; - out.bytes[3] = in.bytes[0]; - - return (out.value); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_eisa_id_to_string - * - * PARAMETERS: Numeric_id - EISA ID to be converted - * Out_string - Where to put the converted string (8 bytes) - * - * DESCRIPTION: Convert a numeric EISA ID to string representation - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_eisa_id_to_string ( - u32 numeric_id, - NATIVE_CHAR *out_string) -{ - u32 id; - - /* swap to big-endian to get contiguous bits */ - - id = _ntohl (numeric_id); - - out_string[0] = (char) ('@' + ((id >> 26) & 0x1f)); - out_string[1] = (char) ('@' + ((id >> 21) & 0x1f)); - out_string[2] = (char) ('@' + ((id >> 16) & 0x1f)); - out_string[3] = acpi_gbl_hex_to_ascii[(id >> 12) & 0xf]; - out_string[4] = acpi_gbl_hex_to_ascii[(id >> 8) & 0xf]; - out_string[5] = acpi_gbl_hex_to_ascii[(id >> 4) & 0xf]; - out_string[6] = acpi_gbl_hex_to_ascii[id & 0xf]; - out_string[7] = 0; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_unsigned_integer_to_string - * - * PARAMETERS: Value - Value to be converted - * Out_string - Where to put the converted string (8 bytes) - * - * RETURN: Convert a number to string representation - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_unsigned_integer_to_string ( - ACPI_INTEGER value, - NATIVE_CHAR *out_string) -{ - u32 count; - u32 digits_needed; - - - digits_needed = acpi_aml_digits_needed (value, 10); - - out_string[digits_needed] = '\0'; - - for (count = digits_needed; count > 0; count--) { - out_string[count-1] = (NATIVE_CHAR) ('0' + (ACPI_MODULO (value, 10))); - value = ACPI_DIVIDE (value, 10); - } - - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/executer/amxface.c b/reactos/drivers/bus/acpi/executer/amxface.c deleted file mode 100644 index 7ce20ddd6b4..00000000000 --- a/reactos/drivers/bus/acpi/executer/amxface.c +++ /dev/null @@ -1,98 +0,0 @@ - -/****************************************************************************** - * - * Module Name: amxface - External interpreter interfaces - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amxface") - - -/* - * DEFINE_AML_GLOBALS is tested in amlcode.h - * to determine whether certain global names should be "defined" or only - * "declared" in the current compilation. This enhances maintainability - * by enabling a single header file to embody all knowledge of the names - * in question. - * - * Exactly one module of any executable should #define DEFINE_GLOBALS - * before #including the header files which use this convention. The - * names in question will be defined and initialized in that module, - * and declared as extern in all other modules which #include those - * header files. - */ - -#define DEFINE_AML_GLOBALS -#include "amlcode.h" -#include "acparser.h" -#include "acnamesp.h" - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_execute_method - * - * PARAMETERS: Pcode - Pointer to the pcode stream - * Pcode_length - Length of pcode that comprises the method - * **Params - List of parameters to pass to method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * - * RETURN: Status - * - * DESCRIPTION: Execute a control method - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_execute_method ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_obj_desc) -{ - ACPI_STATUS status; - - - /* - * The point here is to lock the interpreter and call the low - * level execute. - */ - - status = acpi_aml_enter_interpreter (); - if (ACPI_FAILURE (status)) { - return (status); - } - - status = acpi_psx_execute (method_node, params, return_obj_desc); - - acpi_aml_exit_interpreter (); - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/hardware/hwacpi.c b/reactos/drivers/bus/acpi/hardware/hwacpi.c deleted file mode 100644 index b1504fa17c6..00000000000 --- a/reactos/drivers/bus/acpi/hardware/hwacpi.c +++ /dev/null @@ -1,303 +0,0 @@ - -/****************************************************************************** - * - * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_HARDWARE - MODULE_NAME ("hwacpi") - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_initialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize and validate various ACPI registers - * - ******************************************************************************/ - -ACPI_STATUS -acpi_hw_initialize ( - void) -{ - ACPI_STATUS status = AE_OK; - u32 index; - - - /* We must have the ACPI tables by the time we get here */ - - if (!acpi_gbl_FADT) { - acpi_gbl_restore_acpi_chipset = FALSE; - - return (AE_NO_ACPI_TABLES); - } - - /* Must support *some* mode! */ -/* - if (!(System_flags & SYS_MODES_MASK)) - { - Restore_acpi_chipset = FALSE; - - return (AE_ERROR); - } - -*/ - - - switch (acpi_gbl_system_flags & SYS_MODES_MASK) { - /* Identify current ACPI/legacy mode */ - - case (SYS_MODE_ACPI): - - acpi_gbl_original_mode = SYS_MODE_ACPI; - break; - - - case (SYS_MODE_LEGACY): - - acpi_gbl_original_mode = SYS_MODE_LEGACY; - break; - - - case (SYS_MODE_ACPI | SYS_MODE_LEGACY): - - if (acpi_hw_get_mode () == SYS_MODE_ACPI) { - acpi_gbl_original_mode = SYS_MODE_ACPI; - } - else { - acpi_gbl_original_mode = SYS_MODE_LEGACY; - } - - break; - } - - - if (acpi_gbl_system_flags & SYS_MODE_ACPI) { - /* Target system supports ACPI mode */ - - /* - * The purpose of this code is to save the initial state - * of the ACPI event enable registers. An exit function will be - * registered which will restore this state when the application - * exits. The exit function will also clear all of the ACPI event - * status bits prior to restoring the original mode. - * - * The location of the PM1a_evt_blk enable registers is defined as the - * base of PM1a_evt_blk + DIV_2(PM1a_evt_blk_length). Since the spec further - * fully defines the PM1a_evt_blk to be a total of 4 bytes, the offset - * for the enable registers is always 2 from the base. It is hard - * coded here. If this changes in the spec, this code will need to - * be modified. The PM1b_evt_blk behaves as expected. - */ - - acpi_gbl_pm1_enable_register_save = (u16) acpi_hw_register_read (ACPI_MTX_LOCK, PM1_EN); - - - /* - * The GPEs behave similarly, except that the length of the register - * block is not fixed, so the buffer must be allocated with malloc - */ - - if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) && - acpi_gbl_FADT->gpe0blk_len) { - /* GPE0 specified in FADT */ - - acpi_gbl_gpe0enable_register_save = - acpi_cm_allocate (DIV_2 (acpi_gbl_FADT->gpe0blk_len)); - if (!acpi_gbl_gpe0enable_register_save) { - return (AE_NO_MEMORY); - } - - /* Save state of GPE0 enable bits */ - - for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) { - acpi_gbl_gpe0enable_register_save[index] = - (u8) acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index); - } - } - - else { - acpi_gbl_gpe0enable_register_save = NULL; - } - - if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) && - acpi_gbl_FADT->gpe1_blk_len) { - /* GPE1 defined */ - - acpi_gbl_gpe1_enable_register_save = - acpi_cm_allocate (DIV_2 (acpi_gbl_FADT->gpe1_blk_len)); - if (!acpi_gbl_gpe1_enable_register_save) { - return (AE_NO_MEMORY); - } - - /* save state of GPE1 enable bits */ - - for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) { - acpi_gbl_gpe1_enable_register_save[index] = - (u8) acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index); - } - } - - else { - acpi_gbl_gpe1_enable_register_save = NULL; - } - } - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_set_mode - * - * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY - * - * RETURN: Status - * - * DESCRIPTION: Transitions the system into the requested mode or does nothing - * if the system is already in that mode. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_hw_set_mode ( - u32 mode) -{ - - ACPI_STATUS status = AE_NO_HARDWARE_RESPONSE; - - - if (mode == SYS_MODE_ACPI) { - /* BIOS should have disabled ALL fixed and GP events */ - - acpi_os_out8 (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_enable); - } - - else if (mode == SYS_MODE_LEGACY) { - /* - * BIOS should clear all fixed status bits and restore fixed event - * enable bits to default - */ - - acpi_os_out8 (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_disable); - } - - if (acpi_hw_get_mode () == mode) { - status = AE_OK; - } - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_get_mode - * - * PARAMETERS: none - * - * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY - * - * DESCRIPTION: Return current operating state of system. Determined by - * querying the SCI_EN bit. - * - ******************************************************************************/ - -u32 -acpi_hw_get_mode (void) -{ - - - if (acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, SCI_EN)) { - return (SYS_MODE_ACPI); - } - else { - return (SYS_MODE_LEGACY); - } -} - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_get_mode_capabilities - * - * PARAMETERS: none - * - * RETURN: logical OR of SYS_MODE_ACPI and SYS_MODE_LEGACY determined at initial - * system state. - * - * DESCRIPTION: Returns capablities of system - * - ******************************************************************************/ - -u32 -acpi_hw_get_mode_capabilities (void) -{ - - - if (!(acpi_gbl_system_flags & SYS_MODES_MASK)) { - if (acpi_hw_get_mode () == SYS_MODE_LEGACY) { - /* - * Assume that if this call is being made, Acpi_init has been called - * and ACPI support has been established by the presence of the - * tables. Therefore since we're in SYS_MODE_LEGACY, the system - * must support both modes - */ - - acpi_gbl_system_flags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY); - } - - else { - /* TBD: [Investigate] !!! this may be unsafe... */ - /* - * system is is ACPI mode, so try to switch back to LEGACY to see if - * it is supported - */ - acpi_hw_set_mode (SYS_MODE_LEGACY); - - if (acpi_hw_get_mode () == SYS_MODE_LEGACY) { - /* Now in SYS_MODE_LEGACY, so both are supported */ - - acpi_gbl_system_flags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY); - acpi_hw_set_mode (SYS_MODE_ACPI); - } - - else { - /* Still in SYS_MODE_ACPI so this must be an ACPI only system */ - - acpi_gbl_system_flags |= SYS_MODE_ACPI; - } - } - } - - return (acpi_gbl_system_flags & SYS_MODES_MASK); -} - - diff --git a/reactos/drivers/bus/acpi/hardware/hwgpe.c b/reactos/drivers/bus/acpi/hardware/hwgpe.c deleted file mode 100644 index 9d7ed9e6ebd..00000000000 --- a/reactos/drivers/bus/acpi/hardware/hwgpe.c +++ /dev/null @@ -1,204 +0,0 @@ - -/****************************************************************************** - * - * Module Name: hwgpe - Low level GPE enable/disable/clear functions - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define _COMPONENT ACPI_HARDWARE - MODULE_NAME ("hwgpe") - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_enable_gpe - * - * PARAMETERS: Gpe_number - The GPE - * - * RETURN: None - * - * DESCRIPTION: Enable a single GPE. - * - ******************************************************************************/ - -void -acpi_hw_enable_gpe ( - u32 gpe_number) -{ - u8 in_byte; - u32 register_index; - u8 bit_mask; - - /* - * Translate GPE number to index into global registers array. - */ - register_index = acpi_gbl_gpe_valid[gpe_number]; - - /* - * Figure out the bit offset for this GPE within the target register. - */ - bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)]; - - /* - * Read the current value of the register, set the appropriate bit - * to enable the GPE, and write out the new register. - */ - in_byte = acpi_os_in8 (acpi_gbl_gpe_registers[register_index].enable_addr); - acpi_os_out8 (acpi_gbl_gpe_registers[register_index].enable_addr, - (u8)(in_byte | bit_mask)); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_disable_gpe - * - * PARAMETERS: Gpe_number - The GPE - * - * RETURN: None - * - * DESCRIPTION: Disable a single GPE. - * - ******************************************************************************/ - -void -acpi_hw_disable_gpe ( - u32 gpe_number) -{ - u8 in_byte; - u32 register_index; - u8 bit_mask; - - /* - * Translate GPE number to index into global registers array. - */ - register_index = acpi_gbl_gpe_valid[gpe_number]; - - /* - * Figure out the bit offset for this GPE within the target register. - */ - bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)]; - - /* - * Read the current value of the register, clear the appropriate bit, - * and write out the new register value to disable the GPE. - */ - in_byte = acpi_os_in8 (acpi_gbl_gpe_registers[register_index].enable_addr); - acpi_os_out8 (acpi_gbl_gpe_registers[register_index].enable_addr, - (u8)(in_byte & ~bit_mask)); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_clear_gpe - * - * PARAMETERS: Gpe_number - The GPE - * - * RETURN: None - * - * DESCRIPTION: Clear a single GPE. - * - ******************************************************************************/ - -void -acpi_hw_clear_gpe ( - u32 gpe_number) -{ - u32 register_index; - u8 bit_mask; - - /* - * Translate GPE number to index into global registers array. - */ - register_index = acpi_gbl_gpe_valid[gpe_number]; - - /* - * Figure out the bit offset for this GPE within the target register. - */ - bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)]; - - /* - * Write a one to the appropriate bit in the status register to - * clear this GPE. - */ - acpi_os_out8 (acpi_gbl_gpe_registers[register_index].status_addr, bit_mask); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_get_gpe_status - * - * PARAMETERS: Gpe_number - The GPE - * - * RETURN: None - * - * DESCRIPTION: Return the status of a single GPE. - * - ******************************************************************************/ - -void -acpi_hw_get_gpe_status ( - u32 gpe_number, - ACPI_EVENT_STATUS *event_status) -{ - u8 in_byte = 0; - u32 register_index = 0; - u8 bit_mask = 0; - - if (!event_status) { - return; - } - - (*event_status) = 0; - - /* - * Translate GPE number to index into global registers array. - */ - register_index = acpi_gbl_gpe_valid[gpe_number]; - - /* - * Figure out the bit offset for this GPE within the target register. - */ - bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)]; - - /* - * Enabled?: - */ - in_byte = acpi_os_in8 (acpi_gbl_gpe_registers[register_index].enable_addr); - - if (bit_mask & in_byte) { - (*event_status) |= ACPI_EVENT_FLAG_ENABLED; - } - - /* - * Set? - */ - in_byte = acpi_os_in8 (acpi_gbl_gpe_registers[register_index].status_addr); - - if (bit_mask & in_byte) { - (*event_status) |= ACPI_EVENT_FLAG_SET; - } -} diff --git a/reactos/drivers/bus/acpi/hardware/hwregs.c b/reactos/drivers/bus/acpi/hardware/hwregs.c deleted file mode 100644 index 658d5c8167d..00000000000 --- a/reactos/drivers/bus/acpi/hardware/hwregs.c +++ /dev/null @@ -1,964 +0,0 @@ - -/******************************************************************************* - * - * Module Name: hwregs - Read/write access functions for the various ACPI - * control and status registers. - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_HARDWARE - MODULE_NAME ("hwregs") - - -/* This matches the #defines in actypes.h. */ - -NATIVE_CHAR *sleep_state_table[] = {"\\_S0_","\\_S1_","\\_S2_","\\_S3_", - "\\_S4_","\\_S5_","\\_S4_b"}; - - -/******************************************************************************* - * - * FUNCTION: Acpi_hw_get_bit_shift - * - * PARAMETERS: Mask - Input mask to determine bit shift from. - * Must have at least 1 bit set. - * - * RETURN: Bit location of the lsb of the mask - * - * DESCRIPTION: Returns the bit number for the low order bit that's set. - * - ******************************************************************************/ - -u32 -acpi_hw_get_bit_shift ( - u32 mask) { - u32 shift; - - - for (shift = 0; ((mask >> shift) & 1) == 0; shift++) { ; } - - return (shift); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_hw_clear_acpi_status - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: Clears all fixed and general purpose status bits - * - ******************************************************************************/ - -void -acpi_hw_clear_acpi_status (void) -{ - u16 gpe_length; - u16 index; - - - acpi_cm_acquire_mutex (ACPI_MTX_HARDWARE); - - acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_STS, ALL_FIXED_STS_BITS); - - - if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1b_evt_blk.address)) { - acpi_os_out16 ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xpm1b_evt_blk.address), - (u16) ALL_FIXED_STS_BITS); - } - - /* now clear the GPE Bits */ - - if (acpi_gbl_FADT->gpe0blk_len) { - gpe_length = (u16) DIV_2 (acpi_gbl_FADT->gpe0blk_len); - - for (index = 0; index < gpe_length; index++) { - acpi_os_out8 ((ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + index), - (u8) 0xff); - } - } - - if (acpi_gbl_FADT->gpe1_blk_len) { - gpe_length = (u16) DIV_2 (acpi_gbl_FADT->gpe1_blk_len); - - for (index = 0; index < gpe_length; index++) { - acpi_os_out8 ((ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + index), - (u8) 0xff); - } - } - - acpi_cm_release_mutex (ACPI_MTX_HARDWARE); - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_hw_obtain_sleep_type_register_data - * - * PARAMETERS: Sleep_state - Numeric state requested - * *Slp_Typ_a - Pointer to byte to receive SLP_TYPa value - * *Slp_Typ_b - Pointer to byte to receive SLP_TYPb value - * - * RETURN: Status - ACPI status - * - * DESCRIPTION: Acpi_hw_obtain_sleep_type_register_data() obtains the SLP_TYP and - * SLP_TYPb values for the sleep state requested. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_hw_obtain_sleep_type_register_data ( - u8 sleep_state, - u8 *slp_typ_a, - u8 *slp_typ_b) -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *obj_desc; - - - /* - * Validate parameters - */ - - if ((sleep_state > ACPI_S_STATES_MAX) || - !slp_typ_a || !slp_typ_b) { - return (AE_BAD_PARAMETER); - } - - /* - * Acpi_evaluate the namespace object containing the values for this state - */ - - status = acpi_ns_evaluate_by_name (sleep_state_table[sleep_state], NULL, &obj_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - - if (!obj_desc) { - REPORT_ERROR (("Missing Sleep State object\n")); - return (AE_NOT_EXIST); - } - - /* - * We got something, now ensure it is correct. The object must - * be a package and must have at least 2 numeric values as the - * two elements - */ - - /* Even though Acpi_evaluate_object resolves package references, - * Ns_evaluate dpesn't. So, we do it here. - */ - status = acpi_cm_resolve_package_references(obj_desc); - - if (obj_desc->package.count < 2) { - /* Must have at least two elements */ - - REPORT_ERROR (("Sleep State package does not have at least two elements\n")); - status = AE_ERROR; - } - - else if (((obj_desc->package.elements[0])->common.type != - ACPI_TYPE_INTEGER) || - ((obj_desc->package.elements[1])->common.type != - ACPI_TYPE_INTEGER)) { - /* Must have two */ - - REPORT_ERROR (("Sleep State package elements are not both of type Number\n")); - status = AE_ERROR; - } - - else { - /* - * Valid _Sx_ package size, type, and value - */ - *slp_typ_a = (u8) (obj_desc->package.elements[0])->integer.value; - - *slp_typ_b = (u8) (obj_desc->package.elements[1])->integer.value; - } - - - - acpi_cm_remove_reference (obj_desc); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_hw_register_bit_access - * - * PARAMETERS: Read_write - Either ACPI_READ or ACPI_WRITE. - * Use_lock - Lock the hardware - * Register_id - index of ACPI Register to access - * Value - (only used on write) value to write to the - * Register. Shifted all the way right. - * - * RETURN: Value written to or read from specified Register. This value - * is shifted all the way right. - * - * DESCRIPTION: Generic ACPI Register read/write function. - * - ******************************************************************************/ - -u32 -acpi_hw_register_bit_access ( - NATIVE_UINT read_write, - u8 use_lock, - u32 register_id, - ...) /* Value (only used on write) */ -{ - u32 register_value = 0; - u32 mask = 0; - u32 value = 0; - - - if (read_write == ACPI_WRITE) { - va_list marker; - - va_start (marker, register_id); - value = va_arg (marker, u32); - va_end (marker); - } - - if (ACPI_MTX_LOCK == use_lock) { - acpi_cm_acquire_mutex (ACPI_MTX_HARDWARE); - } - - /* - * Decode the Register ID - * Register id = Register block id | bit id - * - * Check bit id to fine locate Register offset. - * check Mask to determine Register offset, and then read-write. - */ - - switch (REGISTER_BLOCK_ID(register_id)) { - case PM1_STS: - - switch (register_id) { - case TMR_STS: - mask = TMR_STS_MASK; - break; - - case BM_STS: - mask = BM_STS_MASK; - break; - - case GBL_STS: - mask = GBL_STS_MASK; - break; - - case PWRBTN_STS: - mask = PWRBTN_STS_MASK; - break; - - case SLPBTN_STS: - mask = SLPBTN_STS_MASK; - break; - - case RTC_STS: - mask = RTC_STS_MASK; - break; - - case WAK_STS: - mask = WAK_STS_MASK; - break; - - default: - mask = 0; - break; - } - - register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_STS); - - if (read_write == ACPI_WRITE) { - /* - * Status Registers are different from the rest. Clear by - * writing 1, writing 0 has no effect. So, the only relevent - * information is the single bit we're interested in, all - * others should be written as 0 so they will be left - * unchanged - */ - - value <<= acpi_hw_get_bit_shift (mask); - value &= mask; - - if (value) { - acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_STS, (u16) value); - - register_value = 0; - } - } - - break; - - - case PM1_EN: - - switch (register_id) { - case TMR_EN: - mask = TMR_EN_MASK; - break; - - case GBL_EN: - mask = GBL_EN_MASK; - break; - - case PWRBTN_EN: - mask = PWRBTN_EN_MASK; - break; - - case SLPBTN_EN: - mask = SLPBTN_EN_MASK; - break; - - case RTC_EN: - mask = RTC_EN_MASK; - break; - - default: - mask = 0; - break; - } - - register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_EN); - - if (read_write == ACPI_WRITE) { - register_value &= ~mask; - value <<= acpi_hw_get_bit_shift (mask); - value &= mask; - register_value |= value; - - acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_EN, (u16) register_value); - } - - break; - - - case PM1_CONTROL: - - switch (register_id) { - case SCI_EN: - mask = SCI_EN_MASK; - break; - - case BM_RLD: - mask = BM_RLD_MASK; - break; - - case GBL_RLS: - mask = GBL_RLS_MASK; - break; - - case SLP_TYPE_A: - case SLP_TYPE_B: - mask = SLP_TYPE_X_MASK; - break; - - case SLP_EN: - mask = SLP_EN_MASK; - break; - - default: - mask = 0; - break; - } - - - /* - * Read the PM1 Control register. - * Note that at this level, the fact that there are actually TWO - * registers (A and B) and that B may not exist, are abstracted. - */ - register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_CONTROL); - - if (read_write == ACPI_WRITE) { - register_value &= ~mask; - value <<= acpi_hw_get_bit_shift (mask); - value &= mask; - register_value |= value; - - /* - * SLP_TYPE_x Registers are written differently - * than any other control Registers with - * respect to A and B Registers. The value - * for A may be different than the value for B - * - * Therefore, pass the Register_id, not just generic PM1_CONTROL, - * because we need to do different things. Yuck. - */ - - acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - register_id, (u16) register_value); - } - break; - - - case PM2_CONTROL: - - switch (register_id) { - case ARB_DIS: - mask = ARB_DIS_MASK; - break; - - default: - mask = 0; - break; - } - - register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM2_CONTROL); - - if (read_write == ACPI_WRITE) { - register_value &= ~mask; - value <<= acpi_hw_get_bit_shift (mask); - value &= mask; - register_value |= value; - - acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - PM2_CONTROL, (u8) (register_value)); - } - break; - - - case PM_TIMER: - - mask = TMR_VAL_MASK; - register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, - PM_TIMER); - break; - - - case GPE1_EN_BLOCK: - case GPE1_STS_BLOCK: - case GPE0_EN_BLOCK: - case GPE0_STS_BLOCK: - - /* Determine the bit to be accessed - * - * (u32) Register_id: - * 31 24 16 8 0 - * +--------+--------+--------+--------+ - * | gpe_block_id | gpe_bit_number | - * +--------+--------+--------+--------+ - * - * gpe_block_id is one of GPE[01]_EN_BLOCK and GPE[01]_STS_BLOCK - * gpe_bit_number is relative from the gpe_block (0x00~0xFF) - */ - - mask = REGISTER_BIT_ID(register_id); /* gpe_bit_number */ - register_id = REGISTER_BLOCK_ID(register_id) | (mask >> 3); - mask = acpi_gbl_decode_to8bit [mask % 8]; - - /* - * The base address of the GPE 0 Register Block - * Plus 1/2 the length of the GPE 0 Register Block - * The enable Register is the Register following the Status Register - * and each Register is defined as 1/2 of the total Register Block - */ - - /* - * This sets the bit within Enable_bit that needs to be written to - * the Register indicated in Mask to a 1, all others are 0 - */ - - /* Now get the current Enable Bits in the selected Reg */ - - register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, register_id); - if (read_write == ACPI_WRITE) { - register_value &= ~mask; - value <<= acpi_hw_get_bit_shift (mask); - value &= mask; - register_value |= value; - - /* This write will put the Action state into the General Purpose */ - /* Enable Register indexed by the value in Mask */ - - acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, - register_id, (u8) register_value); - register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, register_id); - } - break; - - - case SMI_CMD_BLOCK: - case PROCESSOR_BLOCK: - /* not used */ - default: - - mask = 0; - break; - } - - if (ACPI_MTX_LOCK == use_lock) { - acpi_cm_release_mutex (ACPI_MTX_HARDWARE); - } - - - register_value &= mask; - register_value >>= acpi_hw_get_bit_shift (mask); - - return (register_value); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_register_read - * - * PARAMETERS: Use_lock - Mutex hw access. - * Register_id - Register_iD + Offset. - * - * RETURN: Value read or written. - * - * DESCRIPTION: Acpi register read function. Registers are read at the - * given offset. - * - ******************************************************************************/ - -u32 -acpi_hw_register_read ( - u8 use_lock, - u32 register_id) -{ - u32 value = 0; - u32 bank_offset; - - if (ACPI_MTX_LOCK == use_lock) { - acpi_cm_acquire_mutex (ACPI_MTX_HARDWARE); - } - - - switch (REGISTER_BLOCK_ID(register_id)) { - case PM1_STS: /* 16-bit access */ - - value = acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_evt_blk, 0); - value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_evt_blk, 0); - break; - - - case PM1_EN: /* 16-bit access*/ - - bank_offset = DIV_2 (acpi_gbl_FADT->pm1_evt_len); - value = acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_evt_blk, bank_offset); - value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_evt_blk, bank_offset); - break; - - - case PM1_CONTROL: /* 16-bit access */ - - value = acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0); - value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0); - break; - - - case PM2_CONTROL: /* 8-bit access */ - - value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xpm2_cnt_blk, 0); - break; - - - case PM_TIMER: /* 32-bit access */ - - value = acpi_hw_low_level_read (32, &acpi_gbl_FADT->Xpm_tmr_blk, 0); - break; - - - case GPE0_STS_BLOCK: /* 8-bit access */ - - value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe0blk, 0); - break; - - - case GPE0_EN_BLOCK: /* 8-bit access */ - - bank_offset = DIV_2 (acpi_gbl_FADT->gpe0blk_len); - value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe0blk, bank_offset); - break; - - - case GPE1_STS_BLOCK: /* 8-bit access */ - - value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe1_blk, 0); - break; - - - case GPE1_EN_BLOCK: /* 8-bit access */ - - bank_offset = DIV_2 (acpi_gbl_FADT->gpe1_blk_len); - value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe1_blk, bank_offset); - break; - - - case SMI_CMD_BLOCK: /* 8bit */ - - value = (u32) acpi_os_in8 (acpi_gbl_FADT->smi_cmd); - break; - - - default: - value = 0; - break; - } - - - if (ACPI_MTX_LOCK == use_lock) { - acpi_cm_release_mutex (ACPI_MTX_HARDWARE); - } - - return (value); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_register_write - * - * PARAMETERS: Use_lock - Mutex hw access. - * Register_id - Register_iD + Offset. - * - * RETURN: Value read or written. - * - * DESCRIPTION: Acpi register Write function. Registers are written at the - * given offset. - * - ******************************************************************************/ - -void -acpi_hw_register_write ( - u8 use_lock, - u32 register_id, - u32 value) -{ - u32 bank_offset; - - - if (ACPI_MTX_LOCK == use_lock) { - acpi_cm_acquire_mutex (ACPI_MTX_HARDWARE); - } - - - switch (REGISTER_BLOCK_ID (register_id)) { - case PM1_STS: /* 16-bit access */ - - acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_evt_blk, 0); - acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_evt_blk, 0); - break; - - - case PM1_EN: /* 16-bit access*/ - - bank_offset = DIV_2 (acpi_gbl_FADT->pm1_evt_len); - acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_evt_blk, bank_offset); - acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_evt_blk, bank_offset); - break; - - - case PM1_CONTROL: /* 16-bit access */ - - acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0); - acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0); - break; - - - case PM1_a_CONTROL: /* 16-bit access */ - - acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0); - break; - - - case PM1_b_CONTROL: /* 16-bit access */ - - acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0); - break; - - - case PM2_CONTROL: /* 8-bit access */ - - acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xpm2_cnt_blk, 0); - break; - - - case PM_TIMER: /* 32-bit access */ - - acpi_hw_low_level_write (32, value, &acpi_gbl_FADT->Xpm_tmr_blk, 0); - break; - - - case GPE0_STS_BLOCK: /* 8-bit access */ - - acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe0blk, 0); - break; - - - case GPE0_EN_BLOCK: /* 8-bit access */ - - bank_offset = DIV_2 (acpi_gbl_FADT->gpe0blk_len); - acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe0blk, bank_offset); - break; - - - case GPE1_STS_BLOCK: /* 8-bit access */ - - acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe1_blk, 0); - break; - - - case GPE1_EN_BLOCK: /* 8-bit access */ - - bank_offset = DIV_2 (acpi_gbl_FADT->gpe1_blk_len); - acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe1_blk, bank_offset); - break; - - - case SMI_CMD_BLOCK: /* 8bit */ - - /* For 2.0, SMI_CMD is always in IO space */ - /* TBD: what about 1.0? 0.71? */ - - acpi_os_out8 (acpi_gbl_FADT->smi_cmd, (u8) value); - break; - - - default: - value = 0; - break; - } - - - if (ACPI_MTX_LOCK == use_lock) { - acpi_cm_release_mutex (ACPI_MTX_HARDWARE); - } - - return; -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_low_level_read - * - * PARAMETERS: Register - GAS register structure - * Offset - Offset from the base address in the GAS - * Width - 8, 16, or 32 - * - * RETURN: Value read - * - * DESCRIPTION: Read from either memory, IO, or PCI config space. - * - ******************************************************************************/ - -u32 -acpi_hw_low_level_read ( - u32 width, - ACPI_GAS *reg, - u32 offset) -{ - u32 value = 0; - ACPI_PHYSICAL_ADDRESS mem_address; - ACPI_IO_ADDRESS io_address; - u32 pci_register; - u32 pci_dev_func; - - - /* - * Must have a valid pointer to a GAS structure, and - * a non-zero address within - */ - if ((!reg) || - (!ACPI_VALID_ADDRESS (reg->address))) { - return 0; - } - - - /* - * Three address spaces supported: - * Memory, Io, or PCI config. - */ - - switch (reg->address_space_id) { - case ADDRESS_SPACE_SYSTEM_MEMORY: - - mem_address = (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (reg->address) + offset); - - switch (width) { - case 8: - value = acpi_os_mem_in8 (mem_address); - break; - case 16: - value = acpi_os_mem_in16 (mem_address); - break; - case 32: - value = acpi_os_mem_in32 (mem_address); - break; - } - break; - - - case ADDRESS_SPACE_SYSTEM_IO: - - io_address = (ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (reg->address) + offset); - - switch (width) { - case 8: - value = acpi_os_in8 (io_address); - break; - case 16: - value = acpi_os_in16 (io_address); - break; - case 32: - value = acpi_os_in32 (io_address); - break; - } - break; - - - case ADDRESS_SPACE_PCI_CONFIG: - - pci_dev_func = ACPI_PCI_DEVFUN (ACPI_GET_ADDRESS (reg->address)); - pci_register = ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (reg->address)) + offset; - - switch (width) { - case 8: - acpi_os_read_pci_cfg_byte (0, pci_dev_func, pci_register, (u8 *) &value); - break; - case 16: - acpi_os_read_pci_cfg_word (0, pci_dev_func, pci_register, (u16 *) &value); - break; - case 32: - acpi_os_read_pci_cfg_dword (0, pci_dev_func, pci_register, (u32 *) &value); - break; - } - break; - } - - return value; -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_hw_low_level_write - * - * PARAMETERS: Width - 8, 16, or 32 - * Value - To be written - * Register - GAS register structure - * Offset - Offset from the base address in the GAS - * - * - * RETURN: Value read - * - * DESCRIPTION: Read from either memory, IO, or PCI config space. - * - ******************************************************************************/ - -void -acpi_hw_low_level_write ( - u32 width, - u32 value, - ACPI_GAS *reg, - u32 offset) -{ - ACPI_PHYSICAL_ADDRESS mem_address; - ACPI_IO_ADDRESS io_address; - u32 pci_register; - u32 pci_dev_func; - - - /* - * Must have a valid pointer to a GAS structure, and - * a non-zero address within - */ - if ((!reg) || - (!ACPI_VALID_ADDRESS (reg->address))) { - return; - } - - - /* - * Three address spaces supported: - * Memory, Io, or PCI config. - */ - - switch (reg->address_space_id) { - case ADDRESS_SPACE_SYSTEM_MEMORY: - - mem_address = (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (reg->address) + offset); - - switch (width) { - case 8: - acpi_os_mem_out8 (mem_address, (u8) value); - break; - case 16: - acpi_os_mem_out16 (mem_address, (u16) value); - break; - case 32: - acpi_os_mem_out32 (mem_address, (u32) value); - break; - } - break; - - - case ADDRESS_SPACE_SYSTEM_IO: - - io_address = (ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (reg->address) + offset); - - switch (width) { - case 8: - acpi_os_out8 (io_address, (u8) value); - break; - case 16: - acpi_os_out16 (io_address, (u16) value); - break; - case 32: - acpi_os_out32 (io_address, (u32) value); - break; - } - break; - - - case ADDRESS_SPACE_PCI_CONFIG: - - pci_dev_func = ACPI_PCI_DEVFUN (ACPI_GET_ADDRESS (reg->address)); - pci_register = ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (reg->address)) + offset; - - switch (width) { - case 8: - acpi_os_write_pci_cfg_byte (0, pci_dev_func, pci_register, (u8) value); - break; - case 16: - acpi_os_write_pci_cfg_word (0, pci_dev_func, pci_register, (u16) value); - break; - case 32: - acpi_os_write_pci_cfg_dword (0, pci_dev_func, pci_register, (u32) value); - break; - } - break; - } -} diff --git a/reactos/drivers/bus/acpi/hardware/hwsleep.c b/reactos/drivers/bus/acpi/hardware/hwsleep.c deleted file mode 100644 index a30fbe624a3..00000000000 --- a/reactos/drivers/bus/acpi/hardware/hwsleep.c +++ /dev/null @@ -1,186 +0,0 @@ - -/****************************************************************************** - * - * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define _COMPONENT ACPI_HARDWARE - MODULE_NAME ("hwsleep") - - -/****************************************************************************** - * - * FUNCTION: Acpi_set_firmware_waking_vector - * - * PARAMETERS: Physical_address - Physical address of ACPI real mode - * entry point. - * - * RETURN: AE_OK or AE_ERROR - * - * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS - * - ******************************************************************************/ - -ACPI_STATUS -acpi_set_firmware_waking_vector ( - ACPI_PHYSICAL_ADDRESS physical_address) -{ - - - /* Make sure that we have an FACS */ - - if (!acpi_gbl_FACS) { - return (AE_NO_ACPI_TABLES); - } - - /* Set the vector */ - - if (acpi_gbl_FACS->vector_width == 32) { - * (u32 *) acpi_gbl_FACS->firmware_waking_vector = (u32) physical_address; - } - else { - *acpi_gbl_FACS->firmware_waking_vector = physical_address; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_get_firmware_waking_vector - * - * PARAMETERS: *Physical_address - Output buffer where contents of - * the Firmware_waking_vector field of - * the FACS will be stored. - * - * RETURN: Status - * - * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_firmware_waking_vector ( - ACPI_PHYSICAL_ADDRESS *physical_address) -{ - - - if (!physical_address) { - return (AE_BAD_PARAMETER); - } - - /* Make sure that we have an FACS */ - - if (!acpi_gbl_FACS) { - return (AE_NO_ACPI_TABLES); - } - - /* Get the vector */ - - if (acpi_gbl_FACS->vector_width == 32) { - *physical_address = * (u32 *) acpi_gbl_FACS->firmware_waking_vector; - } - else { - *physical_address = *acpi_gbl_FACS->firmware_waking_vector; - } - - return (AE_OK); -} - -/****************************************************************************** - * - * FUNCTION: Acpi_enter_sleep_state - * - * PARAMETERS: Sleep_state - Which sleep state to enter - * - * RETURN: Status - * - * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_enter_sleep_state ( - u8 sleep_state) -{ - ACPI_STATUS status; - ACPI_OBJECT_LIST arg_list; - ACPI_OBJECT arg; - u8 type_a; - u8 type_b; - u16 PM1_acontrol; - u16 PM1_bcontrol; - - /* - * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. - */ - - status = acpi_hw_obtain_sleep_type_register_data(sleep_state, &type_a, &type_b); - - if (!ACPI_SUCCESS(status)) { - return status; - } - - /* run the _PTS and _GTS methods */ - MEMSET(&arg_list, 0, sizeof(arg_list)); - arg_list.count = 1; - arg_list.pointer = &arg; - - MEMSET(&arg, 0, sizeof(arg)); - arg.type = ACPI_TYPE_INTEGER; - arg.integer.value = sleep_state; - - acpi_evaluate_object(NULL, "\\_PTS", &arg_list, NULL); - acpi_evaluate_object(NULL, "\\_GTS", &arg_list, NULL); - - /* clear wake status */ - acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_LOCK, WAK_STS, 1); - - PM1_acontrol = (u16) acpi_hw_register_read(ACPI_MTX_LOCK, PM1_CONTROL); - - /* mask off SLP_EN and SLP_TYP fields */ - PM1_acontrol &= 0xC3FF; - - /* mask in SLP_EN */ - PM1_acontrol |= (1 << acpi_hw_get_bit_shift (SLP_EN_MASK)); - - PM1_bcontrol = PM1_acontrol; - - /* mask in SLP_TYP */ - PM1_acontrol |= (type_a << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK)); - PM1_bcontrol |= (type_b << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK)); - - disable(); - - acpi_hw_register_write(ACPI_MTX_LOCK, PM1_a_CONTROL, PM1_acontrol); - acpi_hw_register_write(ACPI_MTX_LOCK, PM1_b_CONTROL, PM1_bcontrol); - acpi_hw_register_write(ACPI_MTX_LOCK, PM1_CONTROL, - (1 << acpi_hw_get_bit_shift (SLP_EN_MASK))); - - enable(); - - return (AE_OK); -} diff --git a/reactos/drivers/bus/acpi/hardware/hwtimer.c b/reactos/drivers/bus/acpi/hardware/hwtimer.c deleted file mode 100644 index 06dfbbee535..00000000000 --- a/reactos/drivers/bus/acpi/hardware/hwtimer.c +++ /dev/null @@ -1,199 +0,0 @@ - -/****************************************************************************** - * - * Name: hwtimer.c - ACPI Power Management Timer Interface - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define _COMPONENT ACPI_HARDWARE - MODULE_NAME ("hwtimer") - - -/****************************************************************************** - * - * FUNCTION: Acpi_get_timer_resolution - * - * PARAMETERS: none - * - * RETURN: Number of bits of resolution in the PM Timer (24 or 32). - * - * DESCRIPTION: Obtains resolution of the ACPI PM Timer. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_timer_resolution ( - u32 *resolution) -{ - if (!resolution) { - return (AE_BAD_PARAMETER); - } - - if (0 == acpi_gbl_FADT->tmr_val_ext) { - *resolution = 24; - } - else { - *resolution = 32; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_get_timer - * - * PARAMETERS: none - * - * RETURN: Current value of the ACPI PM Timer (in ticks). - * - * DESCRIPTION: Obtains current value of ACPI PM Timer. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_timer ( - u32 *ticks) -{ - if (!ticks) { - return (AE_BAD_PARAMETER); - } - - *ticks = acpi_os_in32 ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xpm_tmr_blk.address)); - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_get_timer_duration - * - * PARAMETERS: Start_ticks - * End_ticks - * Time_elapsed - * - * RETURN: Time_elapsed - * - * DESCRIPTION: Computes the time elapsed (in microseconds) between two - * PM Timer time stamps, taking into account the possibility of - * rollovers, the timer resolution, and timer frequency. - * - * The PM Timer's clock ticks at roughly 3.6 times per - * _microsecond_, and its clock continues through Cx state - * transitions (unlike many CPU timestamp counters) -- making it - * a versatile and accurate timer. - * - * Note that this function accomodates only a single timer - * rollover. Thus for 24-bit timers, this function should only - * be used for calculating durations less than ~4.6 seconds - * (~20 hours for 32-bit timers). - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_timer_duration ( - u32 start_ticks, - u32 end_ticks, - u32 *time_elapsed) -{ - u32 delta_ticks = 0; - u32 seconds = 0; - u32 milliseconds = 0; - u32 microseconds = 0; - u32 remainder = 0; - - if (!time_elapsed) { - return (AE_BAD_PARAMETER); - } - - /* - * Compute Tick Delta: - * ------------------- - * Handle (max one) timer rollovers on 24- versus 32-bit timers. - */ - if (start_ticks < end_ticks) { - delta_ticks = end_ticks - start_ticks; - } - else if (start_ticks > end_ticks) { - /* 24-bit Timer */ - if (0 == acpi_gbl_FADT->tmr_val_ext) { - delta_ticks = (((0x00FFFFFF - start_ticks) + end_ticks) & 0x00FFFFFF); - } - /* 32-bit Timer */ - else { - delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks; - } - } - else { - *time_elapsed = 0; - return (AE_OK); - } - - /* - * Compute Duration: - * ----------------- - * Since certain compilers (gcc/Linux, argh!) don't support 64-bit - * divides in kernel-space we have to do some trickery to preserve - * accuracy while using 32-bit math. - * - * TODO: Change to use 64-bit math when supported. - * - * The process is as follows: - * 1. Compute the number of seconds by dividing Delta Ticks by - * the timer frequency. - * 2. Compute the number of milliseconds in the remainder from step #1 - * by multiplying by 1000 and then dividing by the timer frequency. - * 3. Compute the number of microseconds in the remainder from step #2 - * by multiplying by 1000 and then dividing by the timer frequency. - * 4. Add the results from steps 1, 2, and 3 to get the total duration. - * - * Example: The time elapsed for Delta_ticks = 0xFFFFFFFF should be - * 1199864031 microseconds. This is computed as follows: - * Step #1: Seconds = 1199; Remainder = 3092840 - * Step #2: Milliseconds = 864; Remainder = 113120 - * Step #3: Microseconds = 31; Remainder = - */ - - /* Step #1 */ - seconds = delta_ticks / PM_TIMER_FREQUENCY; - remainder = delta_ticks % PM_TIMER_FREQUENCY; - - /* Step #2 */ - milliseconds = (remainder * 1000) / PM_TIMER_FREQUENCY; - remainder = (remainder * 1000) % PM_TIMER_FREQUENCY; - - /* Step #3 */ - microseconds = (remainder * 1000) / PM_TIMER_FREQUENCY; - - /* Step #4 */ - *time_elapsed = seconds * 1000000; - *time_elapsed += milliseconds * 1000; - *time_elapsed += microseconds; - - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/include/accommon.h b/reactos/drivers/bus/acpi/include/accommon.h deleted file mode 100644 index 56bdf49cebd..00000000000 --- a/reactos/drivers/bus/acpi/include/accommon.h +++ /dev/null @@ -1,725 +0,0 @@ -/****************************************************************************** - * - * Name: accommon.h -- prototypes for the common (subsystem-wide) procedures - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _ACCOMMON_H -#define _ACCOMMON_H - - -typedef -ACPI_STATUS (*ACPI_PKG_CALLBACK) ( - u8 object_type, - ACPI_OPERAND_OBJECT *source_object, - ACPI_GENERIC_STATE *state, - void *context); - - -ACPI_STATUS -acpi_cm_walk_package_tree ( - ACPI_OPERAND_OBJECT *source_object, - void *target_object, - ACPI_PKG_CALLBACK walk_callback, - void *context); - - -typedef struct acpi_pkg_info -{ - u8 *free_space; - u32 length; - u32 object_space; - u32 num_packages; -} ACPI_PKG_INFO; - -#define REF_INCREMENT (u16) 0 -#define REF_DECREMENT (u16) 1 -#define REF_FORCE_DELETE (u16) 2 - -/* Acpi_cm_dump_buffer */ - -#define DB_BYTE_DISPLAY 1 -#define DB_WORD_DISPLAY 2 -#define DB_DWORD_DISPLAY 4 -#define DB_QWORD_DISPLAY 8 - - -/* Global initialization interfaces */ - -void -acpi_cm_init_globals ( - void); - -void -acpi_cm_terminate ( - void); - - -/* - * Cm_init - miscellaneous initialization and shutdown - */ - -ACPI_STATUS -acpi_cm_hardware_initialize ( - void); - -ACPI_STATUS -acpi_cm_subsystem_shutdown ( - void); - -ACPI_STATUS -acpi_cm_validate_fadt ( - void); - -/* - * Cm_global - Global data structures and procedures - */ - -#ifdef ACPI_DEBUG - -NATIVE_CHAR * -acpi_cm_get_mutex_name ( - u32 mutex_id); - -NATIVE_CHAR * -acpi_cm_get_type_name ( - u32 type); - -NATIVE_CHAR * -acpi_cm_get_region_name ( - u8 space_id); - -#endif - - -u8 -acpi_cm_valid_object_type ( - u32 type); - -ACPI_OWNER_ID -acpi_cm_allocate_owner_id ( - u32 id_type); - - -/* - * Cm_clib - Local implementations of C library functions - */ - -#ifndef ACPI_USE_SYSTEM_CLIBRARY - -u32 -acpi_cm_strlen ( - const NATIVE_CHAR *string); - -NATIVE_CHAR * -acpi_cm_strcpy ( - NATIVE_CHAR *dst_string, - const NATIVE_CHAR *src_string); - -NATIVE_CHAR * -acpi_cm_strncpy ( - NATIVE_CHAR *dst_string, - const NATIVE_CHAR *src_string, - NATIVE_UINT count); - -u32 -acpi_cm_strncmp ( - const NATIVE_CHAR *string1, - const NATIVE_CHAR *string2, - NATIVE_UINT count); - -u32 -acpi_cm_strcmp ( - const NATIVE_CHAR *string1, - const NATIVE_CHAR *string2); - -NATIVE_CHAR * -acpi_cm_strcat ( - NATIVE_CHAR *dst_string, - const NATIVE_CHAR *src_string); - -NATIVE_CHAR * -acpi_cm_strncat ( - NATIVE_CHAR *dst_string, - const NATIVE_CHAR *src_string, - NATIVE_UINT count); - -NATIVE_UINT -acpi_cm_strtoul ( - const NATIVE_CHAR *string, - NATIVE_CHAR **terminator, - NATIVE_UINT base); - -NATIVE_CHAR * -acpi_cm_strstr ( - NATIVE_CHAR *string1, - NATIVE_CHAR *string2); - -NATIVE_CHAR * -acpi_cm_strupr ( - NATIVE_CHAR *src_string); - -void * -acpi_cm_memcpy ( - void *dest, - const void *src, - NATIVE_UINT count); - -void * -acpi_cm_memset ( - void *dest, - NATIVE_UINT value, - NATIVE_UINT count); - -u32 -acpi_cm_to_upper ( - u32 c); - -u32 -acpi_cm_to_lower ( - u32 c); - -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ - -/* - * Cm_copy - Object construction and conversion interfaces - */ - -ACPI_STATUS -acpi_cm_build_simple_object( - ACPI_OPERAND_OBJECT *obj, - ACPI_OBJECT *user_obj, - u8 *data_space, - u32 *buffer_space_used); - -ACPI_STATUS -acpi_cm_build_package_object ( - ACPI_OPERAND_OBJECT *obj, - u8 *buffer, - u32 *space_used); - -ACPI_STATUS -acpi_cm_copy_iobject_to_eobject ( - ACPI_OPERAND_OBJECT *obj, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_cm_copy_esimple_to_isimple( - ACPI_OBJECT *user_obj, - ACPI_OPERAND_OBJECT *obj); - -ACPI_STATUS -acpi_cm_copy_eobject_to_iobject ( - ACPI_OBJECT *obj, - ACPI_OPERAND_OBJECT *internal_obj); - -ACPI_STATUS -acpi_cm_copy_isimple_to_isimple ( - ACPI_OPERAND_OBJECT *source_obj, - ACPI_OPERAND_OBJECT *dest_obj); - -ACPI_STATUS -acpi_cm_copy_ipackage_to_ipackage ( - ACPI_OPERAND_OBJECT *source_obj, - ACPI_OPERAND_OBJECT *dest_obj, - ACPI_WALK_STATE *walk_state); - - -/* - * Cm_create - Object creation - */ - -ACPI_STATUS -acpi_cm_update_object_reference ( - ACPI_OPERAND_OBJECT *object, - u16 action); - -ACPI_OPERAND_OBJECT * -_cm_create_internal_object ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - OBJECT_TYPE_INTERNAL type); - - -/* - * Cm_debug - Debug interfaces - */ - -u32 -get_debug_level ( - void); - -void -set_debug_level ( - u32 level); - -void -function_trace ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name); - -void -function_trace_ptr ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - void *pointer); - -void -function_trace_u32 ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - u32 integer); - -void -function_trace_str ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - NATIVE_CHAR *string); - -void -function_exit ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name); - -void -function_status_exit ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - ACPI_STATUS status); - -void -function_value_exit ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - ACPI_INTEGER value); - -void -function_ptr_exit ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - u8 *ptr); - -void -debug_print_prefix ( - NATIVE_CHAR *module_name, - u32 line_number); - -void -debug_print ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - u32 print_level, - NATIVE_CHAR *format, ...); - -void -debug_print_raw ( - NATIVE_CHAR *format, ...); - -void -_report_info ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id); - -void -_report_error ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id); - -void -_report_warning ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id); - -void -acpi_cm_dump_buffer ( - u8 *buffer, - u32 count, - u32 display, - u32 component_id); - - -/* - * Cm_delete - Object deletion - */ - -void -acpi_cm_delete_internal_obj ( - ACPI_OPERAND_OBJECT *object); - -void -acpi_cm_delete_internal_package_object ( - ACPI_OPERAND_OBJECT *object); - -void -acpi_cm_delete_internal_simple_object ( - ACPI_OPERAND_OBJECT *object); - -ACPI_STATUS -acpi_cm_delete_internal_object_list ( - ACPI_OPERAND_OBJECT **obj_list); - - -/* - * Cm_eval - object evaluation - */ - -/* Method name strings */ - -#define METHOD_NAME__HID "_HID" -#define METHOD_NAME__UID "_UID" -#define METHOD_NAME__ADR "_ADR" -#define METHOD_NAME__STA "_STA" -#define METHOD_NAME__REG "_REG" -#define METHOD_NAME__SEG "_SEG" -#define METHOD_NAME__BBN "_BBN" - - -ACPI_STATUS -acpi_cm_evaluate_numeric_object ( - NATIVE_CHAR *object_name, - ACPI_NAMESPACE_NODE *device_node, - ACPI_INTEGER *address); - -ACPI_STATUS -acpi_cm_execute_HID ( - ACPI_NAMESPACE_NODE *device_node, - DEVICE_ID *hid); - -ACPI_STATUS -acpi_cm_execute_STA ( - ACPI_NAMESPACE_NODE *device_node, - u32 *status_flags); - -ACPI_STATUS -acpi_cm_execute_UID ( - ACPI_NAMESPACE_NODE *device_node, - DEVICE_ID *uid); - - -/* - * Cm_error - exception interfaces - */ - -NATIVE_CHAR * -acpi_cm_format_exception ( - ACPI_STATUS status); - - -/* - * Cm_mutex - mutual exclusion interfaces - */ - -ACPI_STATUS -acpi_cm_mutex_initialize ( - void); - -void -acpi_cm_mutex_terminate ( - void); - -ACPI_STATUS -acpi_cm_create_mutex ( - ACPI_MUTEX_HANDLE mutex_id); - -ACPI_STATUS -acpi_cm_delete_mutex ( - ACPI_MUTEX_HANDLE mutex_id); - -ACPI_STATUS -acpi_cm_acquire_mutex ( - ACPI_MUTEX_HANDLE mutex_id); - -ACPI_STATUS -acpi_cm_release_mutex ( - ACPI_MUTEX_HANDLE mutex_id); - - -/* - * Cm_object - internal object create/delete/cache routines - */ - -void * -_cm_allocate_object_desc ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id); - -#define acpi_cm_create_internal_object(t) _cm_create_internal_object(_THIS_MODULE,__LINE__,_COMPONENT,t) -#define acpi_cm_allocate_object_desc() _cm_allocate_object_desc(_THIS_MODULE,__LINE__,_COMPONENT) - -void -acpi_cm_delete_object_desc ( - ACPI_OPERAND_OBJECT *object); - -u8 -acpi_cm_valid_internal_object ( - void *object); - - -/* - * Cm_ref_cnt - Object reference count management - */ - -void -acpi_cm_add_reference ( - ACPI_OPERAND_OBJECT *object); - -void -acpi_cm_remove_reference ( - ACPI_OPERAND_OBJECT *object); - -/* - * Cm_size - Object size routines - */ - -ACPI_STATUS -acpi_cm_get_simple_object_size ( - ACPI_OPERAND_OBJECT *obj, - u32 *obj_length); - -ACPI_STATUS -acpi_cm_get_package_object_size ( - ACPI_OPERAND_OBJECT *obj, - u32 *obj_length); - -ACPI_STATUS -acpi_cm_get_object_size( - ACPI_OPERAND_OBJECT *obj, - u32 *obj_length); - - -/* - * Cm_state - Generic state creation/cache routines - */ - -void -acpi_cm_push_generic_state ( - ACPI_GENERIC_STATE **list_head, - ACPI_GENERIC_STATE *state); - -ACPI_GENERIC_STATE * -acpi_cm_pop_generic_state ( - ACPI_GENERIC_STATE **list_head); - - -ACPI_GENERIC_STATE * -acpi_cm_create_generic_state ( - void); - -ACPI_GENERIC_STATE * -acpi_cm_create_update_state ( - ACPI_OPERAND_OBJECT *object, - u16 action); - -ACPI_GENERIC_STATE * -acpi_cm_create_pkg_state ( - void *internal_object, - void *external_object, - u16 index); - -ACPI_STATUS -acpi_cm_create_update_state_and_push ( - ACPI_OPERAND_OBJECT *object, - u16 action, - ACPI_GENERIC_STATE **state_list); - -ACPI_STATUS -acpi_cm_create_pkg_state_and_push ( - void *internal_object, - void *external_object, - u16 index, - ACPI_GENERIC_STATE **state_list); - -ACPI_GENERIC_STATE * -acpi_cm_create_control_state ( - void); - -void -acpi_cm_delete_generic_state ( - ACPI_GENERIC_STATE *state); - -void -acpi_cm_delete_generic_state_cache ( - void); - -void -acpi_cm_delete_object_cache ( - void); - -/* - * Cmutils - */ - -u8 -acpi_cm_valid_acpi_name ( - u32 name); - -u8 -acpi_cm_valid_acpi_character ( - NATIVE_CHAR character); - -ACPI_STATUS -acpi_cm_resolve_package_references ( - ACPI_OPERAND_OBJECT *obj_desc); - -#ifdef ACPI_DEBUG - -void -acpi_cm_display_init_pathname ( - ACPI_HANDLE obj_handle, - char *path); - -#endif - - -/* - * Memory allocation functions and related macros. - * Macros that expand to include filename and line number - */ - -void * -_cm_allocate ( - u32 size, - u32 component, - NATIVE_CHAR *module, - u32 line); - -void * -_cm_callocate ( - u32 size, - u32 component, - NATIVE_CHAR *module, - u32 line); - -void -_cm_free ( - void *address, - u32 component, - NATIVE_CHAR *module, - u32 line); - -void -acpi_cm_init_static_object ( - ACPI_OPERAND_OBJECT *obj_desc); - -#define acpi_cm_allocate(a) _cm_allocate(a,_COMPONENT,_THIS_MODULE,__LINE__) -#define acpi_cm_callocate(a) _cm_callocate(a, _COMPONENT,_THIS_MODULE,__LINE__) -#define acpi_cm_free(a) _cm_free(a,_COMPONENT,_THIS_MODULE,__LINE__) - -#ifndef ACPI_DEBUG_TRACK_ALLOCATIONS - -#define acpi_cm_add_element_to_alloc_list(a,b,c,d,e,f) -#define acpi_cm_delete_element_from_alloc_list(a,b,c,d) -#define acpi_cm_dump_current_allocations(a,b) -#define acpi_cm_dump_allocation_info() - -#define DECREMENT_OBJECT_METRICS(a) -#define INCREMENT_OBJECT_METRICS(a) -#define INITIALIZE_ALLOCATION_METRICS() -#define DECREMENT_NAME_TABLE_METRICS(a) -#define INCREMENT_NAME_TABLE_METRICS(a) - -#else - -#define INITIALIZE_ALLOCATION_METRICS() \ - acpi_gbl_current_object_count = 0; \ - acpi_gbl_current_object_size = 0; \ - acpi_gbl_running_object_count = 0; \ - acpi_gbl_running_object_size = 0; \ - acpi_gbl_max_concurrent_object_count = 0; \ - acpi_gbl_max_concurrent_object_size = 0; \ - acpi_gbl_current_alloc_size = 0; \ - acpi_gbl_current_alloc_count = 0; \ - acpi_gbl_running_alloc_size = 0; \ - acpi_gbl_running_alloc_count = 0; \ - acpi_gbl_max_concurrent_alloc_size = 0; \ - acpi_gbl_max_concurrent_alloc_count = 0; \ - acpi_gbl_current_node_count = 0; \ - acpi_gbl_current_node_size = 0; \ - acpi_gbl_max_concurrent_node_count = 0 - - -#define DECREMENT_OBJECT_METRICS(a) \ - acpi_gbl_current_object_count--; \ - acpi_gbl_current_object_size -= a - -#define INCREMENT_OBJECT_METRICS(a) \ - acpi_gbl_current_object_count++; \ - acpi_gbl_running_object_count++; \ - if (acpi_gbl_max_concurrent_object_count < acpi_gbl_current_object_count) \ - { \ - acpi_gbl_max_concurrent_object_count = acpi_gbl_current_object_count; \ - } \ - acpi_gbl_running_object_size += a; \ - acpi_gbl_current_object_size += a; \ - if (acpi_gbl_max_concurrent_object_size < acpi_gbl_current_object_size) \ - { \ - acpi_gbl_max_concurrent_object_size = acpi_gbl_current_object_size; \ - } - -#define DECREMENT_NAME_TABLE_METRICS(a) \ - acpi_gbl_current_node_count--; \ - acpi_gbl_current_node_size -= (a) - -#define INCREMENT_NAME_TABLE_METRICS(a) \ - acpi_gbl_current_node_count++; \ - acpi_gbl_current_node_size+= (a); \ - if (acpi_gbl_max_concurrent_node_count < acpi_gbl_current_node_count) \ - { \ - acpi_gbl_max_concurrent_node_count = acpi_gbl_current_node_count; \ - } \ - - -void -acpi_cm_dump_allocation_info ( - void); - -void -acpi_cm_dump_current_allocations ( - u32 component, - NATIVE_CHAR *module); - -#endif - - -#endif /* _ACCOMMON_H */ diff --git a/reactos/drivers/bus/acpi/include/acconfig.h b/reactos/drivers/bus/acpi/include/acconfig.h deleted file mode 100644 index c31e16f7dd9..00000000000 --- a/reactos/drivers/bus/acpi/include/acconfig.h +++ /dev/null @@ -1,152 +0,0 @@ -/****************************************************************************** - * - * Name: acconfig.h - Global configuration constants - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _ACCONFIG_H -#define _ACCONFIG_H - - -/****************************************************************************** - * - * Compile-time options - * - *****************************************************************************/ - -/* - * ACPI_DEBUG - This switch enables all the debug facilities of the ACPI - * subsystem. This includes the DEBUG_PRINT output statements - * When disabled, all DEBUG_PRINT statements are compiled out. - * - * ACPI_APPLICATION - Use this switch if the subsystem is going to be run - * at the application level. - * - */ - - -/****************************************************************************** - * - * Subsystem Constants - * - *****************************************************************************/ - - -/* Version string */ - -#define ACPI_CA_VERSION 0x20010313 - - -/* Maximum objects in the various object caches */ - -#define MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */ -#define MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ -#define MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ -#define MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ -#define MAX_WALK_CACHE_DEPTH 2 /* Objects for parse tree walks (method execution) */ - - -/* String size constants */ - -#define MAX_STRING_LENGTH 512 -#define PATHNAME_MAX 256 /* A full namespace pathname */ - - -/* Maximum count for a semaphore object */ - -#define MAX_SEMAPHORE_COUNT 256 - - -/* Max reference count (for debug only) */ - -#define MAX_REFERENCE_COUNT 0x200 - - -/* Size of cached memory mapping for system memory operation region */ - -#define SYSMEM_REGION_WINDOW_SIZE 4096 - - -/* - * Debugger threading model - * Use single threaded if the entire subsystem is contained in an application - * Use multiple threaded when the subsystem is running in the kernel. - * - * By default the model is single threaded if ACPI_APPLICATION is set, - * multi-threaded if ACPI_APPLICATION is not set. - */ - -#define DEBUGGER_SINGLE_THREADED 0 -#define DEBUGGER_MULTI_THREADED 1 - -#ifdef ACPI_APPLICATION -#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED - -#else -#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED -#endif - - -/****************************************************************************** - * - * ACPI Specification constants (Do not change unless the specification changes) - * - *****************************************************************************/ - -/* - * Method info (in WALK_STATE), containing local variables and argumetns - */ - -#define MTH_NUM_LOCALS 8 -#define MTH_MAX_LOCAL 7 - -#define MTH_NUM_ARGS 7 -#define MTH_MAX_ARG 6 - -/* Maximum length of resulting string when converting from a buffer */ - -#define ACPI_MAX_STRING_CONVERSION 200 - -/* - * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG - */ - -#define OBJ_NUM_OPERANDS 8 -#define OBJ_MAX_OPERAND 7 - -/* Names within the namespace are 4 bytes long */ - -#define ACPI_NAME_SIZE 4 -#define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 s8 for separator */ -#define PATH_SEPARATOR '.' - - -/* Constants used in searching for the RSDP in low memory */ - -#define LO_RSDP_WINDOW_BASE 0 /* Physical Address */ -#define HI_RSDP_WINDOW_BASE 0xE0000 /* Physical Address */ -#define LO_RSDP_WINDOW_SIZE 0x400 -#define HI_RSDP_WINDOW_SIZE 0x20000 -#define RSDP_SCAN_STEP 16 - -#endif /* _ACCONFIG_H */ - diff --git a/reactos/drivers/bus/acpi/include/acdebug.h b/reactos/drivers/bus/acpi/include/acdebug.h deleted file mode 100644 index 3694f51b691..00000000000 --- a/reactos/drivers/bus/acpi/include/acdebug.h +++ /dev/null @@ -1,411 +0,0 @@ -/****************************************************************************** - * - * Name: acdebug.h - ACPI/AML debugger - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACDEBUG_H__ -#define __ACDEBUG_H__ - - -#define DB_MAX_ARGS 8 /* Must be max method args + 1 */ - -#define DB_COMMAND_PROMPT '-' -#define DB_EXECUTE_PROMPT '%' - - -extern int optind; -extern NATIVE_CHAR *optarg; -extern u8 *aml_ptr; -extern u32 acpi_aml_length; - -extern u8 opt_tables; -extern u8 opt_disasm; -extern u8 opt_stats; -extern u8 opt_parse_jit; -extern u8 opt_verbose; -extern u8 opt_ini_methods; - - -extern NATIVE_CHAR *args[DB_MAX_ARGS]; -extern NATIVE_CHAR line_buf[80]; -extern NATIVE_CHAR scope_buf[40]; -extern NATIVE_CHAR debug_filename[40]; -extern u8 output_to_file; -extern NATIVE_CHAR *buffer; -extern NATIVE_CHAR *filename; -extern NATIVE_CHAR *INDENT_STRING; -extern u8 acpi_gbl_db_output_flags; -extern u32 acpi_gbl_db_debug_level; -extern u32 acpi_gbl_db_console_debug_level; - -extern u32 num_names; -extern u32 num_methods; -extern u32 num_regions; -extern u32 num_packages; -extern u32 num_aliases; -extern u32 num_devices; -extern u32 num_field_defs; -extern u32 num_thermal_zones; -extern u32 num_nodes; -extern u32 num_grammar_elements; -extern u32 num_method_elements ; -extern u32 num_mutexes; -extern u32 num_power_resources; -extern u32 num_bank_fields ; -extern u32 num_index_fields; -extern u32 num_events; - -extern u32 size_of_parse_tree; -extern u32 size_of_method_trees; -extern u32 size_of_nTes; -extern u32 size_of_acpi_objects; - - -#define BUFFER_SIZE 4196 - -#define DB_REDIRECTABLE_OUTPUT 0x01 -#define DB_CONSOLE_OUTPUT 0x02 -#define DB_DUPLICATE_OUTPUT 0x03 - - -typedef struct command_info -{ - NATIVE_CHAR *name; /* Command Name */ - u8 min_args; /* Minimum arguments required */ - -} COMMAND_INFO; - - -typedef struct argument_info -{ - NATIVE_CHAR *name; /* Argument Name */ - -} ARGUMENT_INFO; - - -#define PARAM_LIST(pl) pl - -#define DBTEST_OUTPUT_LEVEL(lvl) if (opt_verbose) - -#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ - acpi_os_printf PARAM_LIST(fp);} - -#define EX_NO_SINGLE_STEP 1 -#define EX_SINGLE_STEP 2 - - -/* Prototypes */ - - -/* - * dbapi - external debugger interfaces - */ - -int -acpi_db_initialize ( - void); - -ACPI_STATUS -acpi_db_single_step ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - u8 op_type); - - -/* - * dbcmds - debug commands and output routines - */ - - -void -acpi_db_display_table_info ( - NATIVE_CHAR *table_arg); - -void -acpi_db_unload_acpi_table ( - NATIVE_CHAR *table_arg, - NATIVE_CHAR *instance_arg); - -void -acpi_db_set_method_breakpoint ( - NATIVE_CHAR *location, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - -void -acpi_db_set_method_call_breakpoint ( - ACPI_PARSE_OBJECT *op); - -void -acpi_db_disassemble_aml ( - NATIVE_CHAR *statements, - ACPI_PARSE_OBJECT *op); - -void -acpi_db_dump_namespace ( - NATIVE_CHAR *start_arg, - NATIVE_CHAR *depth_arg); - -void -acpi_db_dump_namespace_by_owner ( - NATIVE_CHAR *owner_arg, - NATIVE_CHAR *depth_arg); - -void -acpi_db_send_notify ( - NATIVE_CHAR *name, - u32 value); - -void -acpi_db_set_method_data ( - NATIVE_CHAR *type_arg, - NATIVE_CHAR *index_arg, - NATIVE_CHAR *value_arg); - -ACPI_STATUS -acpi_db_display_objects ( - NATIVE_CHAR *obj_type_arg, - NATIVE_CHAR *display_count_arg); - -ACPI_STATUS -acpi_db_find_name_in_namespace ( - NATIVE_CHAR *name_arg); - -void -acpi_db_set_scope ( - NATIVE_CHAR *name); - -void -acpi_db_find_references ( - NATIVE_CHAR *object_arg); - -void -acpi_db_display_locks (void); - - -void -acpi_db_display_resources ( - NATIVE_CHAR *object_arg); - - -/* - * dbdisasm - AML disassembler - */ - -void -acpi_db_display_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *origin, - u32 num_opcodes); - -void -acpi_db_display_namestring ( - NATIVE_CHAR *name); - -void -acpi_db_display_path ( - ACPI_PARSE_OBJECT *op); - -void -acpi_db_display_opcode ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - -void -acpi_db_decode_internal_object ( - ACPI_OPERAND_OBJECT *obj_desc); - - -/* - * dbdisply - debug display commands - */ - - -void -acpi_db_display_method_info ( - ACPI_PARSE_OBJECT *op); - -void -acpi_db_decode_and_display_object ( - NATIVE_CHAR *target, - NATIVE_CHAR *output_type); - -void -acpi_db_display_result_object ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_db_display_all_methods ( - NATIVE_CHAR *display_count_arg); - -void -acpi_db_display_internal_object ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state); - -void -acpi_db_display_arguments ( - void); - -void -acpi_db_display_locals ( - void); - -void -acpi_db_display_results ( - void); - -void -acpi_db_display_calling_tree ( - void); - -void -acpi_db_display_argument_object ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state); - - -/* - * dbexec - debugger control method execution - */ - -void -acpi_db_execute ( - NATIVE_CHAR *name, - NATIVE_CHAR **args, - u32 flags); - -void -acpi_db_create_execution_threads ( - NATIVE_CHAR *num_threads_arg, - NATIVE_CHAR *num_loops_arg, - NATIVE_CHAR *method_name_arg); - - -/* - * dbfileio - Debugger file I/O commands - */ - -OBJECT_TYPE_INTERNAL -acpi_db_match_argument ( - NATIVE_CHAR *user_argument, - ARGUMENT_INFO *arguments); - - -void -acpi_db_close_debug_file ( - void); - -void -acpi_db_open_debug_file ( - NATIVE_CHAR *name); - -ACPI_STATUS -acpi_db_load_acpi_table ( - NATIVE_CHAR *filename); - - -/* - * dbhistry - debugger HISTORY command - */ - -void -acpi_db_add_to_history ( - NATIVE_CHAR *command_line); - -void -acpi_db_display_history (void); - -NATIVE_CHAR * -acpi_db_get_from_history ( - NATIVE_CHAR *command_num_arg); - - -/* - * dbinput - user front-end to the AML debugger - */ - -ACPI_STATUS -acpi_db_command_dispatch ( - NATIVE_CHAR *input_buffer, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - -void -acpi_db_execute_thread ( - void *context); - -ACPI_STATUS -acpi_db_user_commands ( - NATIVE_CHAR prompt, - ACPI_PARSE_OBJECT *op); - - -/* - * dbstats - Generation and display of ACPI table statistics - */ - -void -acpi_db_generate_statistics ( - ACPI_PARSE_OBJECT *root, - u8 is_method); - - -ACPI_STATUS -acpi_db_display_statistics ( - NATIVE_CHAR *type_arg); - - -/* - * dbutils - AML debugger utilities - */ - -void -acpi_db_set_output_destination ( - u32 where); - -void -acpi_db_dump_buffer ( - u32 address); - -void -acpi_db_dump_object ( - ACPI_OBJECT *obj_desc, - u32 level); - -void -acpi_db_prep_namestring ( - NATIVE_CHAR *name); - - -ACPI_STATUS -acpi_db_second_pass_parse ( - ACPI_PARSE_OBJECT *root); - -ACPI_NAMESPACE_NODE * -acpi_db_local_ns_lookup ( - NATIVE_CHAR *name); - - -#endif /* __ACDEBUG_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acdispat.h b/reactos/drivers/bus/acpi/include/acdispat.h deleted file mode 100644 index 456d88ced62..00000000000 --- a/reactos/drivers/bus/acpi/include/acdispat.h +++ /dev/null @@ -1,450 +0,0 @@ -/****************************************************************************** - * - * Name: acdispat.h - dispatcher (parser to interpreter interface) - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef _ACDISPAT_H_ -#define _ACDISPAT_H_ - - -#define NAMEOF_LOCAL_NTE "__L0" -#define NAMEOF_ARG_NTE "__A0" - - -/* Common interfaces */ - -ACPI_STATUS -acpi_ds_obj_stack_push ( - void *object, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_obj_stack_pop ( - u32 pop_count, - ACPI_WALK_STATE *walk_state); - -void * -acpi_ds_obj_stack_get_value ( - u32 index, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_obj_stack_pop_object ( - ACPI_OPERAND_OBJECT **object, - ACPI_WALK_STATE *walk_state); - - -/* dsopcode - support for late evaluation */ - -ACPI_STATUS -acpi_ds_get_field_unit_arguments ( - ACPI_OPERAND_OBJECT *obj_desc); - -ACPI_STATUS -acpi_ds_get_region_arguments ( - ACPI_OPERAND_OBJECT *rgn_desc); - - -/* dsctrl - Parser/Interpreter interface, control stack routines */ - - -ACPI_STATUS -acpi_ds_exec_begin_control_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - -ACPI_STATUS -acpi_ds_exec_end_control_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - - -/* dsexec - Parser/Interpreter interface, method execution callbacks */ - - -ACPI_STATUS -acpi_ds_get_predicate_value ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - u32 has_result_obj); - -ACPI_STATUS -acpi_ds_exec_begin_op ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op); - -ACPI_STATUS -acpi_ds_exec_end_op ( - ACPI_WALK_STATE *state, - ACPI_PARSE_OBJECT *op); - - -/* dsfield - Parser/Interpreter interface for AML fields */ - - -ACPI_STATUS -acpi_ds_create_field ( - ACPI_PARSE_OBJECT *op, - ACPI_NAMESPACE_NODE *region_node, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_create_bank_field ( - ACPI_PARSE_OBJECT *op, - ACPI_NAMESPACE_NODE *region_node, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_create_index_field ( - ACPI_PARSE_OBJECT *op, - ACPI_HANDLE region_node, - ACPI_WALK_STATE *walk_state); - - -/* dsload - Parser/Interpreter interface, namespace load callbacks */ - -ACPI_STATUS -acpi_ds_load1_begin_op ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op); - -ACPI_STATUS -acpi_ds_load1_end_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - -ACPI_STATUS -acpi_ds_load2_begin_op ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op); - -ACPI_STATUS -acpi_ds_load2_end_op ( - ACPI_WALK_STATE *state, - ACPI_PARSE_OBJECT *op); - -ACPI_STATUS -acpi_ds_load3_begin_op ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op); - -ACPI_STATUS -acpi_ds_load3_end_op ( - ACPI_WALK_STATE *state, - ACPI_PARSE_OBJECT *op); - - -/* dsmthdat - method data (locals/args) */ - - -ACPI_STATUS -acpi_ds_store_object_to_local ( - u16 opcode, - u32 index, - ACPI_OPERAND_OBJECT *src_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_method_data_get_entry ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT ***node); - -ACPI_STATUS -acpi_ds_method_data_delete_all ( - ACPI_WALK_STATE *walk_state); - -u8 -acpi_ds_is_method_value ( - ACPI_OPERAND_OBJECT *obj_desc); - -OBJECT_TYPE_INTERNAL -acpi_ds_method_data_get_type ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_method_data_get_value ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **dest_desc); - -ACPI_STATUS -acpi_ds_method_data_delete_value ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_method_data_init_args ( - ACPI_OPERAND_OBJECT **params, - u32 max_param_count, - ACPI_WALK_STATE *walk_state); - -ACPI_NAMESPACE_NODE * -acpi_ds_method_data_get_node ( - u16 opcode, - u32 index, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_method_data_init ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_method_data_set_entry ( - u16 opcode, - u32 index, - ACPI_OPERAND_OBJECT *object, - ACPI_WALK_STATE *walk_state); - - -/* dsmethod - Parser/Interpreter interface - control method parsing */ - -ACPI_STATUS -acpi_ds_parse_method ( - ACPI_HANDLE obj_handle); - -ACPI_STATUS -acpi_ds_call_control_method ( - ACPI_WALK_LIST *walk_list, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - -ACPI_STATUS -acpi_ds_restart_control_method ( - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT *return_desc); - -ACPI_STATUS -acpi_ds_terminate_control_method ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_begin_method_execution ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_NAMESPACE_NODE *calling_method_node); - - -/* dsobj - Parser/Interpreter interface - object initialization and conversion */ - -ACPI_STATUS -acpi_ds_init_one_object ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value); - -ACPI_STATUS -acpi_ds_initialize_objects ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMESPACE_NODE *start_node); - -ACPI_STATUS -acpi_ds_build_internal_package_obj ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - ACPI_OPERAND_OBJECT **obj_desc); - -ACPI_STATUS -acpi_ds_build_internal_object ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - ACPI_OPERAND_OBJECT **obj_desc_ptr); - -ACPI_STATUS -acpi_ds_init_object_from_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - u16 opcode, - ACPI_OPERAND_OBJECT **obj_desc); - -ACPI_STATUS -acpi_ds_create_node ( - ACPI_WALK_STATE *walk_state, - ACPI_NAMESPACE_NODE *node, - ACPI_PARSE_OBJECT *op); - - -/* dsregn - Parser/Interpreter interface - Op Region parsing */ - -ACPI_STATUS -acpi_ds_eval_field_unit_operands ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - -ACPI_STATUS -acpi_ds_eval_region_operands ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op); - -ACPI_STATUS -acpi_ds_initialize_region ( - ACPI_HANDLE obj_handle); - - -/* dsutils - Parser/Interpreter interface utility routines */ - -u8 -acpi_ds_is_result_used ( - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state); - -void -acpi_ds_delete_result_if_not_used ( - ACPI_PARSE_OBJECT *op, - ACPI_OPERAND_OBJECT *result_obj, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_create_operand ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *arg, - u32 args_remaining); - -ACPI_STATUS -acpi_ds_create_operands ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *first_arg); - -ACPI_STATUS -acpi_ds_resolve_operands ( - ACPI_WALK_STATE *walk_state); - -OBJECT_TYPE_INTERNAL -acpi_ds_map_opcode_to_data_type ( - u16 opcode, - u32 *out_flags); - -OBJECT_TYPE_INTERNAL -acpi_ds_map_named_opcode_to_data_type ( - u16 opcode); - - -/* - * dswscope - Scope Stack manipulation - */ - -ACPI_STATUS -acpi_ds_scope_stack_push ( - ACPI_NAMESPACE_NODE *node, - OBJECT_TYPE_INTERNAL type, - ACPI_WALK_STATE *walk_state); - - -ACPI_STATUS -acpi_ds_scope_stack_pop ( - ACPI_WALK_STATE *walk_state); - -void -acpi_ds_scope_stack_clear ( - ACPI_WALK_STATE *walk_state); - - -/* Acpi_dswstate - parser WALK_STATE management routines */ - -ACPI_WALK_STATE * -acpi_ds_create_walk_state ( - ACPI_OWNER_ID owner_id, - ACPI_PARSE_OBJECT *origin, - ACPI_OPERAND_OBJECT *mth_desc, - ACPI_WALK_LIST *walk_list); - -ACPI_STATUS -acpi_ds_obj_stack_delete_all ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_obj_stack_pop_and_delete ( - u32 pop_count, - ACPI_WALK_STATE *walk_state); - -void -acpi_ds_delete_walk_state ( - ACPI_WALK_STATE *walk_state); - -ACPI_WALK_STATE * -acpi_ds_pop_walk_state ( - ACPI_WALK_LIST *walk_list); - -ACPI_STATUS -acpi_ds_result_stack_pop ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_result_stack_push ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_result_stack_clear ( - ACPI_WALK_STATE *walk_state); - -ACPI_WALK_STATE * -acpi_ds_get_current_walk_state ( - ACPI_WALK_LIST *walk_list); - -void -acpi_ds_delete_walk_state_cache ( - void); - -ACPI_STATUS -acpi_ds_result_insert ( - void *object, - u32 index, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_result_remove ( - ACPI_OPERAND_OBJECT **object, - u32 index, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_result_pop ( - ACPI_OPERAND_OBJECT **object, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_result_push ( - ACPI_OPERAND_OBJECT *object, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_result_pop_from_bottom ( - ACPI_OPERAND_OBJECT **object, - ACPI_WALK_STATE *walk_state); - -#endif /* _ACDISPAT_H_ */ diff --git a/reactos/drivers/bus/acpi/include/acevents.h b/reactos/drivers/bus/acpi/include/acevents.h deleted file mode 100644 index 4f54d645a4c..00000000000 --- a/reactos/drivers/bus/acpi/include/acevents.h +++ /dev/null @@ -1,203 +0,0 @@ -/****************************************************************************** - * - * Name: acevents.h - Event subcomponent prototypes and defines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACEVENTS_H__ -#define __ACEVENTS_H__ - - -ACPI_STATUS -acpi_ev_initialize ( - void); - - -/* - * Acpi_evfixed - Fixed event handling - */ - -ACPI_STATUS -acpi_ev_fixed_event_initialize ( - void); - -u32 -acpi_ev_fixed_event_detect ( - void); - -u32 -acpi_ev_fixed_event_dispatch ( - u32 acpi_event); - - -/* - * Acpi_evglock - Global Lock support - */ - -ACPI_STATUS -acpi_ev_acquire_global_lock( - void); - -void -acpi_ev_release_global_lock( - void); - -ACPI_STATUS -acpi_ev_init_global_lock_handler ( - void); - - -/* - * Acpi_evgpe - GPE handling and dispatch - */ - -ACPI_STATUS -acpi_ev_gpe_initialize ( - void); - -ACPI_STATUS -acpi_ev_init_gpe_control_methods ( - void); - -u32 -acpi_ev_gpe_dispatch ( - u32 gpe_number); - -u32 -acpi_ev_gpe_detect ( - void); - - -/* - * Acpi_evnotify - Device Notify handling and dispatch - */ - -ACPI_STATUS -acpi_ev_queue_notify_request ( - ACPI_NAMESPACE_NODE *node, - u32 notify_value); - -void -acpi_ev_notify_dispatch ( - void *context); - -/* - * Acpi_evregion - Address Space handling - */ - -ACPI_STATUS -acpi_ev_install_default_address_space_handlers ( - void); - -ACPI_STATUS -acpi_ev_address_space_dispatch ( - ACPI_OPERAND_OBJECT *region_obj, - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value); - - -ACPI_STATUS -acpi_ev_addr_handler_helper ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value); - -void -acpi_ev_disassociate_region_from_handler( - ACPI_OPERAND_OBJECT *region_obj, - u8 acpi_ns_is_locked); - - -ACPI_STATUS -acpi_ev_associate_region_and_handler ( - ACPI_OPERAND_OBJECT *handler_obj, - ACPI_OPERAND_OBJECT *region_obj, - u8 acpi_ns_is_locked); - - -/* - * Acpi_evregini - Region initialization and setup - */ - -ACPI_STATUS -acpi_ev_system_memory_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **region_context); - -ACPI_STATUS -acpi_ev_io_space_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **region_context); - -ACPI_STATUS -acpi_ev_pci_config_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **region_context); - -ACPI_STATUS -acpi_ev_default_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **region_context); - -ACPI_STATUS -acpi_ev_initialize_region ( - ACPI_OPERAND_OBJECT *region_obj, - u8 acpi_ns_locked); - - -/* - * Evsci - SCI (System Control Interrupt) handling/dispatch - */ - -u32 -acpi_ev_install_sci_handler ( - void); - -ACPI_STATUS -acpi_ev_remove_sci_handler ( - void); - -u32 -acpi_ev_initialize_sCI ( - u32 program_sCI); - -void -acpi_ev_restore_acpi_state ( - void); - -void -acpi_ev_terminate ( - void); - - -#endif /* __ACEVENTS_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acexcep.h b/reactos/drivers/bus/acpi/include/acexcep.h deleted file mode 100644 index 82089e31079..00000000000 --- a/reactos/drivers/bus/acpi/include/acexcep.h +++ /dev/null @@ -1,150 +0,0 @@ -/****************************************************************************** - * - * Name: acexcep.h - Exception codes returned by the ACPI subsystem - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACEXCEP_H__ -#define __ACEXCEP_H__ - - -/* - * Exceptions returned by external ACPI interfaces - */ - -#define AE_CODE_ENVIRONMENTAL 0x0000 -#define AE_CODE_PROGRAMMER 0x1000 -#define AE_CODE_ACPI_TABLES 0x2000 -#define AE_CODE_AML 0x3000 -#define AE_CODE_CONTROL 0x4000 -#define AE_CODE_MASK 0xF000 - - -#define ACPI_SUCCESS(a) (!(a)) -#define ACPI_FAILURE(a) (a) - - -#define AE_OK (ACPI_STATUS) 0x0000 - -/* - * Environmental exceptions - */ -#define AE_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_ENVIRONMENTAL) -#define AE_NO_ACPI_TABLES (ACPI_STATUS) (0x0002 | AE_CODE_ENVIRONMENTAL) -#define AE_NO_NAMESPACE (ACPI_STATUS) (0x0003 | AE_CODE_ENVIRONMENTAL) -#define AE_NO_MEMORY (ACPI_STATUS) (0x0004 | AE_CODE_ENVIRONMENTAL) -#define AE_NOT_FOUND (ACPI_STATUS) (0x0005 | AE_CODE_ENVIRONMENTAL) -#define AE_NOT_EXIST (ACPI_STATUS) (0x0006 | AE_CODE_ENVIRONMENTAL) -#define AE_EXIST (ACPI_STATUS) (0x0007 | AE_CODE_ENVIRONMENTAL) -#define AE_TYPE (ACPI_STATUS) (0x0008 | AE_CODE_ENVIRONMENTAL) -#define AE_NULL_OBJECT (ACPI_STATUS) (0x0009 | AE_CODE_ENVIRONMENTAL) -#define AE_NULL_ENTRY (ACPI_STATUS) (0x000A | AE_CODE_ENVIRONMENTAL) -#define AE_BUFFER_OVERFLOW (ACPI_STATUS) (0x000B | AE_CODE_ENVIRONMENTAL) -#define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL) -#define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL) -#define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL) -#define AE_VERSION_MISMATCH (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) -#define AE_SUPPORT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) -#define AE_SHARE (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) -#define AE_LIMIT (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) -#define AE_TIME (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) -#define AE_UNKNOWN_STATUS (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) -#define AE_ACQUIRE_DEADLOCK (ACPI_STATUS) (0x0015 | AE_CODE_ENVIRONMENTAL) -#define AE_RELEASE_DEADLOCK (ACPI_STATUS) (0x0016 | AE_CODE_ENVIRONMENTAL) -#define AE_NOT_ACQUIRED (ACPI_STATUS) (0x0017 | AE_CODE_ENVIRONMENTAL) -#define AE_ALREADY_ACQUIRED (ACPI_STATUS) (0x0018 | AE_CODE_ENVIRONMENTAL) -#define AE_NO_HARDWARE_RESPONSE (ACPI_STATUS) (0x0019 | AE_CODE_ENVIRONMENTAL) -#define AE_NO_GLOBAL_LOCK (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL) - -#define AE_CODE_ENV_MAX 0x001A - -/* - * Programmer exceptions - */ -#define AE_BAD_PARAMETER (ACPI_STATUS) (0x0001 | AE_CODE_PROGRAMMER) -#define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER) -#define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER) -#define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER) -#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) - -#define AE_CODE_PGM_MAX 0x0005 - - -/* - * Acpi table exceptions - */ -#define AE_BAD_SIGNATURE (ACPI_STATUS) (0x0001 | AE_CODE_ACPI_TABLES) -#define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES) -#define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES) -#define AE_BAD_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_ACPI_TABLES) - -#define AE_CODE_TBL_MAX 0x0003 - - -/* - * AML exceptions. These are caused by problems with - * the actual AML byte stream - */ -#define AE_AML_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_AML) -#define AE_AML_PARSE (ACPI_STATUS) (0x0002 | AE_CODE_AML) -#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0003 | AE_CODE_AML) -#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0004 | AE_CODE_AML) -#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0005 | AE_CODE_AML) -#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0006 | AE_CODE_AML) -#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0007 | AE_CODE_AML) -#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0008 | AE_CODE_AML) -#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0009 | AE_CODE_AML) -#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x000A | AE_CODE_AML) -#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) -#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000C | AE_CODE_AML) -#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000D | AE_CODE_AML) -#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000E | AE_CODE_AML) -#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000F | AE_CODE_AML) -#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x0010 | AE_CODE_AML) -#define AE_AML_INTERNAL (ACPI_STATUS) (0x0011 | AE_CODE_AML) -#define AE_AML_INVALID_SPACE_ID (ACPI_STATUS) (0x0012 | AE_CODE_AML) -#define AE_AML_STRING_LIMIT (ACPI_STATUS) (0x0013 | AE_CODE_AML) -#define AE_AML_NO_RETURN_VALUE (ACPI_STATUS) (0x0014 | AE_CODE_AML) -#define AE_AML_METHOD_LIMIT (ACPI_STATUS) (0x0015 | AE_CODE_AML) -#define AE_AML_NOT_OWNER (ACPI_STATUS) (0x0016 | AE_CODE_AML) -#define AE_AML_MUTEX_ORDER (ACPI_STATUS) (0x0017 | AE_CODE_AML) -#define AE_AML_MUTEX_NOT_ACQUIRED (ACPI_STATUS) (0x0018 | AE_CODE_AML) - -#define AE_CODE_AML_MAX 0x0018 - -/* - * Internal exceptions used for control - */ -#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) (0x0001 | AE_CODE_CONTROL) -#define AE_CTRL_PENDING (ACPI_STATUS) (0x0002 | AE_CODE_CONTROL) -#define AE_CTRL_TERMINATE (ACPI_STATUS) (0x0003 | AE_CODE_CONTROL) -#define AE_CTRL_TRUE (ACPI_STATUS) (0x0004 | AE_CODE_CONTROL) -#define AE_CTRL_FALSE (ACPI_STATUS) (0x0005 | AE_CODE_CONTROL) -#define AE_CTRL_DEPTH (ACPI_STATUS) (0x0006 | AE_CODE_CONTROL) -#define AE_CTRL_END (ACPI_STATUS) (0x0007 | AE_CODE_CONTROL) -#define AE_CTRL_TRANSFER (ACPI_STATUS) (0x0008 | AE_CODE_CONTROL) - -#define AE_CODE_CTRL_MAX 0x0008 - - - -#endif /* __ACEXCEP_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acglobal.h b/reactos/drivers/bus/acpi/include/acglobal.h deleted file mode 100644 index 92446bef0e5..00000000000 --- a/reactos/drivers/bus/acpi/include/acglobal.h +++ /dev/null @@ -1,301 +0,0 @@ -/****************************************************************************** - * - * Name: acglobal.h - Declarations for global variables - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACGLOBAL_H__ -#define __ACGLOBAL_H__ - - -/* - * Ensure that the globals are actually defined only once. - * - * The use of these defines allows a single list of globals (here) in order - * to simplify maintenance of the code. - */ -#ifdef DEFINE_ACPI_GLOBALS -#define ACPI_EXTERN -#else -#define ACPI_EXTERN extern -#endif - - -extern NATIVE_CHAR *msg_acpi_error_break; - -/***************************************************************************** - * - * Debug support - * - ****************************************************************************/ - -/* Runtime configuration of debug print levels */ - -extern u32 acpi_dbg_level; -extern u32 acpi_dbg_layer; - - -/* Procedure nesting level for debug output */ - -extern u32 acpi_gbl_nesting_level; - - -/***************************************************************************** - * - * ACPI Table globals - * - ****************************************************************************/ - -/* - * Table pointers. - * Although these pointers are somewhat redundant with the global Acpi_table, - * they are convenient because they are typed pointers. - * - * These tables are single-table only; meaning that there can be at most one - * of each in the system. Each global points to the actual table. - * - */ -ACPI_EXTERN RSDP_DESCRIPTOR *acpi_gbl_RSDP; -ACPI_EXTERN XSDT_DESCRIPTOR *acpi_gbl_XSDT; -ACPI_EXTERN FADT_DESCRIPTOR *acpi_gbl_FADT; -ACPI_EXTERN ACPI_TABLE_HEADER *acpi_gbl_DSDT; -ACPI_EXTERN ACPI_COMMON_FACS *acpi_gbl_FACS; - -/* - * Since there may be multiple SSDTs and PSDTS, a single pointer is not - * sufficient; Therefore, there isn't one! - */ - - -/* - * ACPI Table info arrays - */ -extern ACPI_TABLE_DESC acpi_gbl_acpi_tables[NUM_ACPI_TABLES]; -extern ACPI_TABLE_SUPPORT acpi_gbl_acpi_table_data[NUM_ACPI_TABLES]; - -/* - * Predefined mutex objects. This array contains the - * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. - * (The table maps local handles to the real OS handles) - */ -ACPI_EXTERN ACPI_MUTEX_INFO acpi_gbl_acpi_mutex_info [NUM_MTX]; - - -/***************************************************************************** - * - * Miscellaneous globals - * - ****************************************************************************/ - - -ACPI_EXTERN u8 *acpi_gbl_gpe0enable_register_save; -ACPI_EXTERN u8 *acpi_gbl_gpe1_enable_register_save; -ACPI_EXTERN ACPI_WALK_STATE *acpi_gbl_breakpoint_walk; -ACPI_EXTERN ACPI_GENERIC_STATE *acpi_gbl_generic_state_cache; -ACPI_EXTERN ACPI_PARSE_OBJECT *acpi_gbl_parse_cache; -ACPI_EXTERN ACPI_PARSE2_OBJECT *acpi_gbl_ext_parse_cache; -ACPI_EXTERN ACPI_OPERAND_OBJECT *acpi_gbl_object_cache; -ACPI_EXTERN ACPI_WALK_STATE *acpi_gbl_walk_state_cache; -ACPI_EXTERN ACPI_HANDLE acpi_gbl_global_lock_semaphore; - - -ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count; -ACPI_EXTERN u32 acpi_gbl_restore_acpi_chipset; -ACPI_EXTERN u32 acpi_gbl_original_mode; -ACPI_EXTERN u32 acpi_gbl_edge_level_save; -ACPI_EXTERN u32 acpi_gbl_irq_enable_save; -ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; - -ACPI_EXTERN u32 acpi_gbl_state_cache_requests; -ACPI_EXTERN u32 acpi_gbl_state_cache_hits; -ACPI_EXTERN u32 acpi_gbl_parse_cache_requests; -ACPI_EXTERN u32 acpi_gbl_parse_cache_hits; -ACPI_EXTERN u32 acpi_gbl_ext_parse_cache_requests; -ACPI_EXTERN u32 acpi_gbl_ext_parse_cache_hits; -ACPI_EXTERN u32 acpi_gbl_object_cache_requests; -ACPI_EXTERN u32 acpi_gbl_object_cache_hits; -ACPI_EXTERN u32 acpi_gbl_walk_state_cache_requests; -ACPI_EXTERN u32 acpi_gbl_walk_state_cache_hits; -ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; -ACPI_EXTERN u32 acpi_gbl_ps_find_count; - - -ACPI_EXTERN u16 acpi_gbl_generic_state_cache_depth; -ACPI_EXTERN u16 acpi_gbl_parse_cache_depth; -ACPI_EXTERN u16 acpi_gbl_ext_parse_cache_depth; -ACPI_EXTERN u16 acpi_gbl_object_cache_depth; -ACPI_EXTERN u16 acpi_gbl_walk_state_cache_depth; -ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; -ACPI_EXTERN u16 acpi_gbl_next_table_owner_id; -ACPI_EXTERN u16 acpi_gbl_next_method_owner_id; - -ACPI_EXTERN u8 acpi_gbl_debugger_configuration; -ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; -ACPI_EXTERN u8 acpi_gbl_step_to_next_call; -ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; -ACPI_EXTERN u8 acpi_gbl_global_lock_present; - -ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER acpi_gbl_drv_notify; -ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER acpi_gbl_sys_notify; - - -extern u8 acpi_gbl_shutdown; -extern u32 acpi_gbl_system_flags; -extern u32 acpi_gbl_startup_flags; -extern u8 acpi_gbl_decode_to8bit[8]; -extern NATIVE_CHAR acpi_gbl_hex_to_ascii[16]; - - -/***************************************************************************** - * - * Namespace globals - * - ****************************************************************************/ - -#define NUM_NS_TYPES INTERNAL_TYPE_INVALID+1 -#define NUM_PREDEFINED_NAMES 9 - - -ACPI_EXTERN ACPI_NAMESPACE_NODE acpi_gbl_root_node_struct; -ACPI_EXTERN ACPI_NAMESPACE_NODE *acpi_gbl_root_node; - -extern u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; -extern PREDEFINED_NAMES acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES]; - - -/* Used to detect memory leaks (DEBUG ONLY) */ - -#ifdef ACPI_DEBUG -ACPI_EXTERN ALLOCATION_INFO *acpi_gbl_head_alloc_ptr; -ACPI_EXTERN ALLOCATION_INFO *acpi_gbl_tail_alloc_ptr; -#endif - - -/***************************************************************************** - * - * Interpreter globals - * - ****************************************************************************/ - - -ACPI_EXTERN ACPI_WALK_LIST *acpi_gbl_current_walk_list; - -/* - * Handle to the last method found - used during pass1 of load - */ -ACPI_EXTERN ACPI_HANDLE acpi_gbl_last_method; - -/* - * Table of Address Space handlers - */ - -ACPI_EXTERN ACPI_ADDRESS_SPACE_INFO acpi_gbl_address_spaces[ACPI_NUM_ADDRESS_SPACES]; - - -/* Control method single step flag */ - -ACPI_EXTERN u8 acpi_gbl_cm_single_step; - - -/***************************************************************************** - * - * Parser globals - * - ****************************************************************************/ - -ACPI_EXTERN ACPI_PARSE_OBJECT *acpi_gbl_parsed_namespace_root; - -/***************************************************************************** - * - * Hardware globals - * - ****************************************************************************/ - -extern ACPI_C_STATE_HANDLER acpi_hw_cx_handlers[MAX_CX_STATES]; -extern u32 acpi_hw_active_cx_state; - - -/***************************************************************************** - * - * Event globals - * - ****************************************************************************/ - -ACPI_EXTERN ACPI_FIXED_EVENT_INFO acpi_gbl_fixed_event_handlers[NUM_FIXED_EVENTS]; - -ACPI_EXTERN ACPI_HANDLE acpi_gbl_gpe_obj_handle; -ACPI_EXTERN u32 acpi_gbl_gpe_register_count; -ACPI_EXTERN ACPI_GPE_REGISTERS *acpi_gbl_gpe_registers; -ACPI_EXTERN ACPI_GPE_LEVEL_INFO *acpi_gbl_gpe_info; - -/* - * Gpe validation and translation table - * Indexed by the GPE number, returns GPE_INVALID if the GPE is not supported. - * Otherwise, returns a valid index into the global GPE table. - * - * This table is needed because the GPE numbers supported by block 1 do not - * have to be contiguous with the GPE numbers supported by block 0. - */ -ACPI_EXTERN u8 acpi_gbl_gpe_valid [NUM_GPE]; - -/* Acpi_event counter for debug only */ - -#ifdef ACPI_DEBUG -ACPI_EXTERN u32 acpi_gbl_event_count[NUM_FIXED_EVENTS]; -#endif - - -/***************************************************************************** - * - * Debugger globals - * - ****************************************************************************/ - -#ifdef ENABLE_DEBUGGER -ACPI_EXTERN u8 acpi_gbl_method_executing; -ACPI_EXTERN u8 acpi_gbl_db_terminate_threads; -#endif - -/* Memory allocation metrics - Debug Only! */ - -#ifdef ACPI_DEBUG - -ACPI_EXTERN u32 acpi_gbl_current_alloc_size; -ACPI_EXTERN u32 acpi_gbl_current_alloc_count; -ACPI_EXTERN u32 acpi_gbl_running_alloc_size; -ACPI_EXTERN u32 acpi_gbl_running_alloc_count; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_alloc_size; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_alloc_count; -ACPI_EXTERN u32 acpi_gbl_current_object_count; -ACPI_EXTERN u32 acpi_gbl_current_object_size; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_object_count; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_object_size; -ACPI_EXTERN u32 acpi_gbl_running_object_count; -ACPI_EXTERN u32 acpi_gbl_running_object_size; -ACPI_EXTERN u32 acpi_gbl_current_node_count; -ACPI_EXTERN u32 acpi_gbl_current_node_size; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count; - -#endif - - -#endif /* __ACGLOBAL_H__ */ diff --git a/reactos/drivers/bus/acpi/include/achware.h b/reactos/drivers/bus/acpi/include/achware.h deleted file mode 100644 index 412b91eb6a0..00000000000 --- a/reactos/drivers/bus/acpi/include/achware.h +++ /dev/null @@ -1,149 +0,0 @@ -/****************************************************************************** - * - * Name: achware.h -- hardware specific interfaces - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACHWARE_H__ -#define __ACHWARE_H__ - - -/* PM Timer ticks per second (HZ) */ -#define PM_TIMER_FREQUENCY 3579545 - - -/* Prototypes */ - - -ACPI_STATUS -acpi_hw_initialize ( - void); - -ACPI_STATUS -acpi_hw_shutdown ( - void); - -ACPI_STATUS -acpi_hw_initialize_system_info ( - void); - -ACPI_STATUS -acpi_hw_set_mode ( - u32 mode); - -u32 -acpi_hw_get_mode ( - void); - -u32 -acpi_hw_get_mode_capabilities ( - void); - -/* Register I/O Prototypes */ - - -u32 -acpi_hw_register_bit_access ( - NATIVE_UINT read_write, - u8 use_lock, - u32 register_id, - ... /* DWORD Write Value */); - -u32 -acpi_hw_register_read ( - u8 use_lock, - u32 register_id); - -void -acpi_hw_register_write ( - u8 use_lock, - u32 register_id, - u32 value); - -u32 -acpi_hw_low_level_read ( - u32 width, - ACPI_GAS *reg, - u32 offset); - -void -acpi_hw_low_level_write ( - u32 width, - u32 value, - ACPI_GAS *reg, - u32 offset); - -void -acpi_hw_clear_acpi_status ( - void); - -u32 -acpi_hw_get_bit_shift ( - u32 mask); - - -/* GPE support */ - -void -acpi_hw_enable_gpe ( - u32 gpe_index); - -void -acpi_hw_disable_gpe ( - u32 gpe_index); - -void -acpi_hw_clear_gpe ( - u32 gpe_index); - -void -acpi_hw_get_gpe_status ( - u32 gpe_number, - ACPI_EVENT_STATUS *event_status); - -/* Sleep Prototypes */ - -ACPI_STATUS -acpi_hw_obtain_sleep_type_register_data ( - u8 sleep_state, - u8 *slp_typ_a, - u8 *slp_typ_b); - - -/* ACPI Timer prototypes */ - -ACPI_STATUS -acpi_get_timer_resolution ( - u32 *resolution); - -ACPI_STATUS -acpi_get_timer ( - u32 *ticks); - -ACPI_STATUS -acpi_get_timer_duration ( - u32 start_ticks, - u32 end_ticks, - u32 *time_elapsed); - - -#endif /* __ACHWARE_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acinterp.h b/reactos/drivers/bus/acpi/include/acinterp.h deleted file mode 100644 index 177dd3f2c87..00000000000 --- a/reactos/drivers/bus/acpi/include/acinterp.h +++ /dev/null @@ -1,632 +0,0 @@ -/****************************************************************************** - * - * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACINTERP_H__ -#define __ACINTERP_H__ - - -#define WALK_OPERANDS &(walk_state->operands [walk_state->num_operands -1]) - - -/* Interpreter constants */ - -#define AML_END_OF_BLOCK -1 -#define PUSH_PKG_LENGTH 1 -#define DO_NOT_PUSH_PKG_LENGTH 0 - - -#define STACK_TOP 0 -#define STACK_BOTTOM (u32) -1 - -/* Constants for global "When_to_parse_methods" */ - -#define METHOD_PARSE_AT_INIT 0x0 -#define METHOD_PARSE_JUST_IN_TIME 0x1 -#define METHOD_DELETE_AT_COMPLETION 0x2 - - -ACPI_STATUS -acpi_aml_resolve_operands ( - u16 opcode, - ACPI_OPERAND_OBJECT **stack_ptr, - ACPI_WALK_STATE *walk_state); - - -/* - * amxface - External interpreter interfaces - */ - -ACPI_STATUS -acpi_aml_load_table ( - ACPI_TABLE_TYPE table_id); - -ACPI_STATUS -acpi_aml_execute_method ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_obj_desc); - - -/* - * amconvrt - object conversion - */ - -ACPI_STATUS -acpi_aml_convert_to_integer ( - ACPI_OPERAND_OBJECT **obj_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_convert_to_buffer ( - ACPI_OPERAND_OBJECT **obj_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_convert_to_string ( - ACPI_OPERAND_OBJECT **obj_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_convert_to_target_type ( - OBJECT_TYPE_INTERNAL destination_type, - ACPI_OPERAND_OBJECT **obj_desc, - ACPI_WALK_STATE *walk_state); - - -/* - * amfield - ACPI AML (p-code) execution - field manipulation - */ - -ACPI_STATUS -acpi_aml_read_field ( - ACPI_OPERAND_OBJECT *obj_desc, - void *buffer, - u32 buffer_length, - u32 byte_length, - u32 datum_length, - u32 bit_granularity, - u32 byte_granularity); - -ACPI_STATUS -acpi_aml_write_field ( - ACPI_OPERAND_OBJECT *obj_desc, - void *buffer, - u32 buffer_length, - u32 byte_length, - u32 datum_length, - u32 bit_granularity, - u32 byte_granularity); - -ACPI_STATUS -acpi_aml_setup_field ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_OPERAND_OBJECT *rgn_desc, - u32 field_bit_width); - -ACPI_STATUS -acpi_aml_read_field_data ( - ACPI_OPERAND_OBJECT *obj_desc, - u32 field_byte_offset, - u32 field_bit_width, - u32 *value); - -ACPI_STATUS -acpi_aml_access_named_field ( - u32 mode, - ACPI_HANDLE named_field, - void *buffer, - u32 length); - -/* - * ammisc - ACPI AML (p-code) execution - specific opcodes - */ - -ACPI_STATUS -acpi_aml_exec_create_field ( - u8 *aml_ptr, - u32 aml_length, - ACPI_NAMESPACE_NODE *node, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_reconfiguration ( - u16 opcode, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_fatal ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_index ( - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc); - -ACPI_STATUS -acpi_aml_exec_match ( - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc); - -ACPI_STATUS -acpi_aml_exec_create_mutex ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_create_processor ( - ACPI_PARSE_OBJECT *op, - ACPI_HANDLE processor_nTE); - -ACPI_STATUS -acpi_aml_exec_create_power_resource ( - ACPI_PARSE_OBJECT *op, - ACPI_HANDLE processor_nTE); - -ACPI_STATUS -acpi_aml_exec_create_region ( - u8 *aml_ptr, - u32 acpi_aml_length, - u8 region_space, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_create_event ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_create_alias ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_create_method ( - u8 *aml_ptr, - u32 acpi_aml_length, - u32 method_flags, - ACPI_HANDLE method); - - -/* - * ammutex - mutex support - */ - -ACPI_STATUS -acpi_aml_acquire_mutex ( - ACPI_OPERAND_OBJECT *time_desc, - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_release_mutex ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_release_all_mutexes ( - ACPI_OPERAND_OBJECT *mutex_list); - -void -acpi_aml_unlink_mutex ( - ACPI_OPERAND_OBJECT *obj_desc); - - -/* - * amprep - ACPI AML (p-code) execution - prep utilities - */ - -ACPI_STATUS -acpi_aml_prep_def_field_value ( - ACPI_NAMESPACE_NODE *node, - ACPI_HANDLE region, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length); - -ACPI_STATUS -acpi_aml_prep_bank_field_value ( - ACPI_NAMESPACE_NODE *node, - ACPI_HANDLE region, - ACPI_HANDLE bank_reg, - u32 bank_val, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length); - -ACPI_STATUS -acpi_aml_prep_index_field_value ( - ACPI_NAMESPACE_NODE *node, - ACPI_HANDLE index_reg, - ACPI_HANDLE data_reg, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length); - - -/* - * amsystem - Interface to OS services - */ - -ACPI_STATUS -acpi_aml_system_do_notify_op ( - ACPI_OPERAND_OBJECT *value, - ACPI_OPERAND_OBJECT *obj_desc); - -void -acpi_aml_system_do_suspend( - u32 time); - -void -acpi_aml_system_do_stall ( - u32 time); - -ACPI_STATUS -acpi_aml_system_acquire_mutex( - ACPI_OPERAND_OBJECT *time, - ACPI_OPERAND_OBJECT *obj_desc); - -ACPI_STATUS -acpi_aml_system_release_mutex( - ACPI_OPERAND_OBJECT *obj_desc); - -ACPI_STATUS -acpi_aml_system_signal_event( - ACPI_OPERAND_OBJECT *obj_desc); - -ACPI_STATUS -acpi_aml_system_wait_event( - ACPI_OPERAND_OBJECT *time, - ACPI_OPERAND_OBJECT *obj_desc); - -ACPI_STATUS -acpi_aml_system_reset_event( - ACPI_OPERAND_OBJECT *obj_desc); - -ACPI_STATUS -acpi_aml_system_wait_semaphore ( - ACPI_HANDLE semaphore, - u32 timeout); - - -/* - * ammonadic - ACPI AML (p-code) execution, monadic operators - */ - -ACPI_STATUS -acpi_aml_exec_monadic1 ( - u16 opcode, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_monadic2 ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc); - -ACPI_STATUS -acpi_aml_exec_monadic2_r ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc); - - -/* - * amdyadic - ACPI AML (p-code) execution, dyadic operators - */ - -ACPI_STATUS -acpi_aml_exec_dyadic1 ( - u16 opcode, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_dyadic2 ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc); - -ACPI_STATUS -acpi_aml_exec_dyadic2_r ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc); - -ACPI_STATUS -acpi_aml_exec_dyadic2_s ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **return_desc); - - -/* - * amresolv - Object resolution and get value functions - */ - -ACPI_STATUS -acpi_aml_resolve_to_value ( - ACPI_OPERAND_OBJECT **stack_ptr, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_resolve_node_to_value ( - ACPI_NAMESPACE_NODE **stack_ptr, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_resolve_object_to_value ( - ACPI_OPERAND_OBJECT **stack_ptr, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_get_field_unit_value ( - ACPI_OPERAND_OBJECT *field_desc, - ACPI_OPERAND_OBJECT *result_desc); - - -/* - * amdump - Scanner debug output routines - */ - -void -acpi_aml_show_hex_value ( - u32 byte_count, - u8 *aml_ptr, - u32 lead_space); - - -ACPI_STATUS -acpi_aml_dump_operand ( - ACPI_OPERAND_OBJECT *entry_desc); - -void -acpi_aml_dump_operands ( - ACPI_OPERAND_OBJECT **operands, - OPERATING_MODE interpreter_mode, - NATIVE_CHAR *ident, - u32 num_levels, - NATIVE_CHAR *note, - NATIVE_CHAR *module_name, - u32 line_number); - -void -acpi_aml_dump_object_descriptor ( - ACPI_OPERAND_OBJECT *object, - u32 flags); - - -void -acpi_aml_dump_node ( - ACPI_NAMESPACE_NODE *node, - u32 flags); - - -/* - * amnames - interpreter/scanner name load/execute - */ - -NATIVE_CHAR * -acpi_aml_allocate_name_string ( - u32 prefix_count, - u32 num_name_segs); - -u32 -acpi_aml_good_char ( - u32 character); - -ACPI_STATUS -acpi_aml_exec_name_segment ( - u8 **in_aml_address, - NATIVE_CHAR *name_string); - -ACPI_STATUS -acpi_aml_get_name_string ( - OBJECT_TYPE_INTERNAL data_type, - u8 *in_aml_address, - NATIVE_CHAR **out_name_string, - u32 *out_name_length); - -ACPI_STATUS -acpi_aml_do_name ( - ACPI_OBJECT_TYPE data_type, - OPERATING_MODE load_exec_mode); - - -/* - * amstore - Object store support - */ - -ACPI_STATUS -acpi_aml_exec_store ( - ACPI_OPERAND_OBJECT *val_desc, - ACPI_OPERAND_OBJECT *dest_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_store_object_to_index ( - ACPI_OPERAND_OBJECT *val_desc, - ACPI_OPERAND_OBJECT *dest_desc, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_store_object_to_node ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_NAMESPACE_NODE *node, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_store_object_to_object ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *dest_desc, - ACPI_WALK_STATE *walk_state); - - -/* - * - */ - -ACPI_STATUS -acpi_aml_resolve_object ( - ACPI_OPERAND_OBJECT **source_desc_ptr, - OBJECT_TYPE_INTERNAL target_type, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_store_object ( - ACPI_OPERAND_OBJECT *source_desc, - OBJECT_TYPE_INTERNAL target_type, - ACPI_OPERAND_OBJECT **target_desc_ptr, - ACPI_WALK_STATE *walk_state); - - -/* - * amcopy - object copy - */ - -ACPI_STATUS -acpi_aml_copy_buffer_to_buffer ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc); - -ACPI_STATUS -acpi_aml_copy_string_to_string ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc); - -ACPI_STATUS -acpi_aml_copy_integer_to_index_field ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc); - -ACPI_STATUS -acpi_aml_copy_integer_to_bank_field ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc); - -ACPI_STATUS -acpi_aml_copy_data_to_named_field ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_NAMESPACE_NODE *node); - -ACPI_STATUS -acpi_aml_copy_integer_to_field_unit ( - ACPI_OPERAND_OBJECT *source_desc, - ACPI_OPERAND_OBJECT *target_desc); - -/* - * amutils - interpreter/scanner utilities - */ - -ACPI_STATUS -acpi_aml_enter_interpreter ( - void); - -void -acpi_aml_exit_interpreter ( - void); - -void -acpi_aml_truncate_for32bit_table ( - ACPI_OPERAND_OBJECT *obj_desc, - ACPI_WALK_STATE *walk_state); - -u8 -acpi_aml_validate_object_type ( - ACPI_OBJECT_TYPE type); - -u8 -acpi_aml_acquire_global_lock ( - u32 rule); - -ACPI_STATUS -acpi_aml_release_global_lock ( - u8 locked); - -u32 -acpi_aml_digits_needed ( - ACPI_INTEGER value, - u32 base); - -ACPI_STATUS -acpi_aml_eisa_id_to_string ( - u32 numeric_id, - NATIVE_CHAR *out_string); - -ACPI_STATUS -acpi_aml_unsigned_integer_to_string ( - ACPI_INTEGER value, - NATIVE_CHAR *out_string); - - -/* - * amregion - default Op_region handlers - */ - -ACPI_STATUS -acpi_aml_system_memory_space_handler ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context); - -ACPI_STATUS -acpi_aml_system_io_space_handler ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context); - -ACPI_STATUS -acpi_aml_pci_config_space_handler ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context); - -ACPI_STATUS -acpi_aml_embedded_controller_space_handler ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context); - -ACPI_STATUS -acpi_aml_sm_bus_space_handler ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context); - - -#endif /* __INTERP_H__ */ diff --git a/reactos/drivers/bus/acpi/include/aclocal.h b/reactos/drivers/bus/acpi/include/aclocal.h deleted file mode 100644 index 3eac5d5af3a..00000000000 --- a/reactos/drivers/bus/acpi/include/aclocal.h +++ /dev/null @@ -1,832 +0,0 @@ -/****************************************************************************** - * - * Name: aclocal.h - Internal data types used across the ACPI subsystem - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACLOCAL_H__ -#define __ACLOCAL_H__ - - -#define WAIT_FOREVER ((u32) -1) - -typedef void* ACPI_MUTEX; -typedef u32 ACPI_MUTEX_HANDLE; - - -/* Object descriptor types */ - -#define ACPI_CACHED_OBJECT 0x11 /* ORed in when object is cached */ -#define ACPI_DESC_TYPE_STATE 0x22 -#define ACPI_DESC_TYPE_WALK 0x44 -#define ACPI_DESC_TYPE_PARSER 0x66 -#define ACPI_DESC_TYPE_INTERNAL 0x88 -#define ACPI_DESC_TYPE_NAMED 0xAA - - -/***************************************************************************** - * - * Mutex typedefs and structs - * - ****************************************************************************/ - - -/* - * Predefined handles for the mutex objects used within the subsystem - * All mutex objects are automatically created by Acpi_cm_mutex_initialize. - * - * The acquire/release ordering protocol is implied via this list. Mutexes - * with a lower value must be acquired before mutexes with a higher value. - * - * NOTE: any changes here must be reflected in the Acpi_gbl_Mutex_names table also! - */ - -#define ACPI_MTX_EXECUTE 0 -#define ACPI_MTX_INTERPRETER 1 -#define ACPI_MTX_PARSER 2 -#define ACPI_MTX_DISPATCHER 3 -#define ACPI_MTX_TABLES 4 -#define ACPI_MTX_OP_REGIONS 5 -#define ACPI_MTX_NAMESPACE 6 -#define ACPI_MTX_EVENTS 7 -#define ACPI_MTX_HARDWARE 8 -#define ACPI_MTX_CACHES 9 -#define ACPI_MTX_MEMORY 10 -#define ACPI_MTX_DEBUG_CMD_COMPLETE 11 -#define ACPI_MTX_DEBUG_CMD_READY 12 - -#define MAX_MTX 12 -#define NUM_MTX MAX_MTX+1 - - -#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER) -#ifdef DEFINE_ACPI_GLOBALS - -/* Names for the mutexes used in the subsystem */ - -static NATIVE_CHAR *acpi_gbl_mutex_names[] = -{ - "ACPI_MTX_Execute", - "ACPI_MTX_Interpreter", - "ACPI_MTX_Parser", - "ACPI_MTX_Dispatcher", - "ACPI_MTX_Tables", - "ACPI_MTX_Op_regions", - "ACPI_MTX_Namespace", - "ACPI_MTX_Events", - "ACPI_MTX_Hardware", - "ACPI_MTX_Caches", - "ACPI_MTX_Memory", - "ACPI_MTX_Debug_cmd_complete" - "ACPI_MTX_Debug_cmd_ready", -}; - -#endif -#endif - - -/* Table for the global mutexes */ - -typedef struct acpi_mutex_info -{ - ACPI_MUTEX mutex; - u32 use_count; - u32 owner_id; - u8 locked; - -} ACPI_MUTEX_INFO; - - -/* Lock flag parameter for various interfaces */ - -#define ACPI_MTX_DO_NOT_LOCK 0 -#define ACPI_MTX_LOCK 1 - - -typedef u16 ACPI_OWNER_ID; -#define OWNER_TYPE_TABLE 0x0 -#define OWNER_TYPE_METHOD 0x1 -#define FIRST_METHOD_ID 0x0000 -#define FIRST_TABLE_ID 0x8000 - -/* TBD: [Restructure] get rid of the need for this! */ - -#define TABLE_ID_DSDT (ACPI_OWNER_ID) 0x8000 - - -/***************************************************************************** - * - * Namespace typedefs and structs - * - ****************************************************************************/ - - -/* Operational modes of the AML interpreter/scanner */ - -typedef enum -{ - IMODE_LOAD_PASS1 = 0x01, - IMODE_LOAD_PASS2 = 0x02, - IMODE_EXECUTE = 0x0E - -} OPERATING_MODE; - - -/* - * The Node describes a named object that appears in the AML - * An Acpi_node is used to store Nodes. - * - * Data_type is used to differentiate between internal descriptors, and MUST - * be the first byte in this structure. - */ - -typedef struct acpi_node -{ - u8 data_type; - u8 type; /* Type associated with this name */ - u16 owner_id; - u32 name; /* ACPI Name, always 4 chars per ACPI spec */ - - - void *object; /* Pointer to attached ACPI object (optional) */ - struct acpi_node *child; /* first child */ - struct acpi_node *peer; /* Next peer*/ - u16 reference_count; /* Current count of references and children */ - u8 flags; - -} ACPI_NAMESPACE_NODE; - - -#define ENTRY_NOT_FOUND NULL - - -/* Node flags */ - -#define ANOBJ_AML_ATTACHMENT 0x01 -#define ANOBJ_END_OF_PEER_LIST 0x02 -#define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */ -#define ANOBJ_METHOD_ARG 0x08 -#define ANOBJ_METHOD_LOCAL 0x10 -#define ANOBJ_METHOD_NO_RETVAL 0x20 -#define ANOBJ_METHOD_SOME_NO_RETVAL 0x40 - - -/* - * ACPI Table Descriptor. One per ACPI table - */ -typedef struct acpi_table_desc -{ - struct acpi_table_desc *prev; - struct acpi_table_desc *next; - struct acpi_table_desc *installed_desc; - ACPI_TABLE_HEADER *pointer; - void *base_pointer; - u8 *aml_pointer; - UINT64 physical_address; - u32 aml_length; - u32 length; - u32 count; - ACPI_OWNER_ID table_id; - u8 type; - u8 allocation; - u8 loaded_into_namespace; - -} ACPI_TABLE_DESC; - - -typedef struct -{ - NATIVE_CHAR *search_for; - ACPI_HANDLE *list; - u32 *count; - -} FIND_CONTEXT; - - -typedef struct -{ - ACPI_NAMESPACE_NODE *node; -} NS_SEARCH_DATA; - - -/* - * Predefined Namespace items - */ -#define ACPI_MAX_ADDRESS_SPACE 255 -#define ACPI_NUM_ADDRESS_SPACES 256 - - -typedef struct -{ - NATIVE_CHAR *name; - ACPI_OBJECT_TYPE type; - NATIVE_CHAR *val; - -} PREDEFINED_NAMES; - - -/* Object types used during package copies */ - - -#define ACPI_COPY_TYPE_SIMPLE 0 -#define ACPI_COPY_TYPE_PACKAGE 1 - - -/***************************************************************************** - * - * Event typedefs and structs - * - ****************************************************************************/ - - -/* Status bits. */ - -#define ACPI_STATUS_PMTIMER 0x0001 -#define ACPI_STATUS_GLOBAL 0x0020 -#define ACPI_STATUS_POWER_BUTTON 0x0100 -#define ACPI_STATUS_SLEEP_BUTTON 0x0200 -#define ACPI_STATUS_RTC_ALARM 0x0400 - -/* Enable bits. */ - -#define ACPI_ENABLE_PMTIMER 0x0001 -#define ACPI_ENABLE_GLOBAL 0x0020 -#define ACPI_ENABLE_POWER_BUTTON 0x0100 -#define ACPI_ENABLE_SLEEP_BUTTON 0x0200 -#define ACPI_ENABLE_RTC_ALARM 0x0400 - - -/* - * Entry in the Address_space (AKA Operation Region) table - */ - -typedef struct -{ - ADDRESS_SPACE_HANDLER handler; - void *context; - -} ACPI_ADDRESS_SPACE_INFO; - - -/* Values and addresses of the GPE registers (both banks) */ - -typedef struct -{ - u8 status; /* Current value of status reg */ - u8 enable; /* Current value of enable reg */ - u16 status_addr; /* Address of status reg */ - u16 enable_addr; /* Address of enable reg */ - u8 gpe_base; /* Base GPE number */ - -} ACPI_GPE_REGISTERS; - - -#define ACPI_GPE_LEVEL_TRIGGERED 1 -#define ACPI_GPE_EDGE_TRIGGERED 2 - - -/* Information about each particular GPE level */ - -typedef struct -{ - u8 type; /* Level or Edge */ - - ACPI_HANDLE method_handle; /* Method handle for direct (fast) execution */ - GPE_HANDLER handler; /* Address of handler, if any */ - void *context; /* Context to be passed to handler */ - -} ACPI_GPE_LEVEL_INFO; - - -/* Information about each particular fixed event */ - -typedef struct -{ - FIXED_EVENT_HANDLER handler; /* Address of handler. */ - void *context; /* Context to be passed to handler */ - -} ACPI_FIXED_EVENT_INFO; - - -/* Information used during field processing */ - -typedef struct -{ - u8 skip_field; - u8 field_flag; - u32 pkg_length; - -} ACPI_FIELD_INFO; - - -/***************************************************************************** - * - * Generic "state" object for stacks - * - ****************************************************************************/ - - -#define CONTROL_NORMAL 0xC0 -#define CONTROL_CONDITIONAL_EXECUTING 0xC1 -#define CONTROL_PREDICATE_EXECUTING 0xC2 -#define CONTROL_PREDICATE_FALSE 0xC3 -#define CONTROL_PREDICATE_TRUE 0xC4 - - -/* Forward declarations */ -struct acpi_walk_state; -struct acpi_walk_list; -struct acpi_parse_obj; -struct acpi_obj_mutex; - - -#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ - u8 data_type; /* To differentiate various internal objs */\ - u8 flags; \ - u16 value; \ - u16 state; \ - u16 acpi_eval; \ - void *next; \ - -typedef struct acpi_common_state -{ - ACPI_STATE_COMMON -} ACPI_COMMON_STATE; - - -/* - * Update state - used to traverse complex objects such as packages - */ -typedef struct acpi_update_state -{ - ACPI_STATE_COMMON - union acpi_operand_obj *object; - -} ACPI_UPDATE_STATE; - - -/* - * Pkg state - used to traverse nested package structures - */ -typedef struct acpi_pkg_state -{ - ACPI_STATE_COMMON - union acpi_operand_obj *source_object; - union acpi_operand_obj *dest_object; - struct acpi_walk_state *walk_state; - void *this_target_obj; - u32 num_packages; - u16 index; - -} ACPI_PKG_STATE; - - -/* - * Control state - one per if/else and while constructs. - * Allows nesting of these constructs - */ -typedef struct acpi_control_state -{ - ACPI_STATE_COMMON - struct acpi_parse_obj *predicate_op; - u8 *aml_predicate_start; /* Start of if/while predicate */ - -} ACPI_CONTROL_STATE; - - -/* - * Scope state - current scope during namespace lookups - */ - -typedef struct acpi_scope_state -{ - ACPI_STATE_COMMON - ACPI_NAMESPACE_NODE *node; - -} ACPI_SCOPE_STATE; - - -typedef struct acpi_pscope_state -{ - ACPI_STATE_COMMON - struct acpi_parse_obj *op; /* current op being parsed */ - u8 *arg_end; /* current argument end */ - u8 *pkg_end; /* current package end */ - u32 arg_list; /* next argument to parse */ - u32 arg_count; /* Number of fixed arguments */ - -} ACPI_PSCOPE_STATE; - - -/* - * Result values - used to accumulate the results of nested - * AML arguments - */ -typedef struct acpi_result_values -{ - ACPI_STATE_COMMON - union acpi_operand_obj *obj_desc [OBJ_NUM_OPERANDS]; - u8 num_results; - u8 last_insert; - -} ACPI_RESULT_VALUES; - - -/* - * Notify info - used to pass info to the deferred notify - * handler/dispatcher. - */ - -typedef struct acpi_notify_info -{ - ACPI_STATE_COMMON - ACPI_NAMESPACE_NODE *node; - union acpi_operand_obj *handler_obj; - -} ACPI_NOTIFY_INFO; - - -/* Generic state is union of structs above */ - -typedef union acpi_gen_state -{ - ACPI_COMMON_STATE common; - ACPI_CONTROL_STATE control; - ACPI_UPDATE_STATE update; - ACPI_SCOPE_STATE scope; - ACPI_PSCOPE_STATE parse_scope; - ACPI_PKG_STATE pkg; - ACPI_RESULT_VALUES results; - ACPI_NOTIFY_INFO notify; - -} ACPI_GENERIC_STATE; - - -typedef -ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( - u16 opcode, - struct acpi_parse_obj *op, - struct acpi_walk_state *walk_state, - struct acpi_parse_obj **out_op); - -typedef -ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( - struct acpi_walk_state *walk_state, - struct acpi_parse_obj *op); - - -/***************************************************************************** - * - * Parser typedefs and structs - * - ****************************************************************************/ - - -#define ACPI_OP_CLASS_MASK 0x1F -#define ACPI_OP_ARGS_MASK 0x20 -#define ACPI_OP_TYPE_MASK 0xC0 - -#define ACPI_OP_TYPE_OPCODE 0x00 -#define ACPI_OP_TYPE_ASCII 0x40 -#define ACPI_OP_TYPE_PREFIX 0x80 -#define ACPI_OP_TYPE_UNKNOWN 0xC0 - -#define ACPI_GET_OP_CLASS(a) ((a)->flags & ACPI_OP_CLASS_MASK) -#define ACPI_GET_OP_ARGS(a) ((a)->flags & ACPI_OP_ARGS_MASK) -#define ACPI_GET_OP_TYPE(a) ((a)->flags & ACPI_OP_TYPE_MASK) - - -/* - * AML opcode, name, and argument layout - */ -typedef struct acpi_opcode_info -{ - u8 flags; /* Opcode type, Has_args flag */ - u32 parse_args; /* Grammar/Parse time arguments */ - u32 runtime_args; /* Interpret time arguments */ - -#ifdef _OPCODE_NAMES - NATIVE_CHAR *name; /* op name (debug only) */ -#endif - -} ACPI_OPCODE_INFO; - - -typedef union acpi_parse_val -{ - u32 integer; /* integer constant */ - u32 size; /* bytelist or field size */ - NATIVE_CHAR *string; /* NULL terminated string */ - u8 *buffer; /* buffer or string */ - NATIVE_CHAR *name; /* NULL terminated string */ - struct acpi_parse_obj *arg; /* arguments and contained ops */ - -} ACPI_PARSE_VALUE; - - -#define ACPI_PARSE_COMMON \ - u8 data_type; /* To differentiate various internal objs */\ - u8 flags; /* Type of Op */\ - u16 opcode; /* AML opcode */\ - u32 aml_offset; /* offset of declaration in AML */\ - struct acpi_parse_obj *parent; /* parent op */\ - struct acpi_parse_obj *next; /* next op */\ - DEBUG_ONLY_MEMBERS (\ - NATIVE_CHAR op_name[16]) /* op name (debug only) */\ - /* NON-DEBUG members below: */\ - ACPI_NAMESPACE_NODE *node; /* for use by interpreter */\ - ACPI_PARSE_VALUE value; /* Value or args associated with the opcode */\ - - -/* - * generic operation (eg. If, While, Store) - */ -typedef struct acpi_parse_obj -{ - ACPI_PARSE_COMMON -} ACPI_PARSE_OBJECT; - - -/* - * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and Op_regions), - * and bytelists. - */ -typedef struct acpi_parse2_obj -{ - ACPI_PARSE_COMMON - u8 *data; /* AML body or bytelist data */ - u32 length; /* AML length */ - u32 name; /* 4-byte name or zero if no name */ - -} ACPI_PARSE2_OBJECT; - - -/* - * Parse state - one state per parser invocation and each control - * method. - */ - -typedef struct acpi_parse_state -{ - u8 *aml_start; /* first AML byte */ - u8 *aml; /* next AML byte */ - u8 *aml_end; /* (last + 1) AML byte */ - u8 *pkg_start; /* current package begin */ - u8 *pkg_end; /* current package end */ - ACPI_PARSE_OBJECT *start_op; /* root of parse tree */ - struct acpi_node *start_node; - ACPI_GENERIC_STATE *scope; /* current scope */ - struct acpi_parse_state *next; - -} ACPI_PARSE_STATE; - - -/***************************************************************************** - * - * Hardware and PNP - * - ****************************************************************************/ - - -/* PCI */ - -#define PCI_ROOT_HID_STRING "PNP0A03" -#define PCI_ROOT_HID_VALUE 0x030AD041 /* EISAID("PNP0A03") */ - - -/* Sleep states */ - -#define SLWA_DEBUG_LEVEL 4 -#define GTS_CALL 0 -#define GTS_WAKE 1 - -/* Cx States */ - -#define MAX_CX_STATE_LATENCY 0xFFFFFFFF -#define MAX_CX_STATES 4 - - -/* - * The #define's and enum below establish an abstract way of identifying what - * register block and register is to be accessed. Do not change any of the - * values as they are used in switch statements and offset calculations. - */ - -#define REGISTER_BLOCK_MASK 0xFF00 /* Register Block Id */ -#define BIT_IN_REGISTER_MASK 0x00FF /* Bit Id in the Register Block Id */ -#define BYTE_IN_REGISTER_MASK 0x00FF /* Register Offset in the Register Block */ - -#define REGISTER_BLOCK_ID(reg_id) (reg_id & REGISTER_BLOCK_MASK) -#define REGISTER_BIT_ID(reg_id) (reg_id & BIT_IN_REGISTER_MASK) -#define REGISTER_OFFSET(reg_id) (reg_id & BYTE_IN_REGISTER_MASK) - -/* - * Access Rule - * To access a Register Bit: - * -> Use Bit Name (= Register Block Id | Bit Id) defined in the enum. - * - * To access a Register: - * -> Use Register Id (= Register Block Id | Register Offset) - */ - - -/* - * Register Block Id - */ -#define PM1_STS 0x0100 -#define PM1_EN 0x0200 -#define PM1_CONTROL 0x0300 -#define PM1_a_CONTROL 0x0400 -#define PM1_b_CONTROL 0x0500 -#define PM2_CONTROL 0x0600 -#define PM_TIMER 0x0700 -#define PROCESSOR_BLOCK 0x0800 -#define GPE0_STS_BLOCK 0x0900 -#define GPE0_EN_BLOCK 0x0A00 -#define GPE1_STS_BLOCK 0x0B00 -#define GPE1_EN_BLOCK 0x0C00 -#define SMI_CMD_BLOCK 0x0D00 - -/* - * Address space bitmasks for mmio or io spaces - */ - -#define SMI_CMD_ADDRESS_SPACE 0x01 -#define PM1_BLK_ADDRESS_SPACE 0x02 -#define PM2_CNT_BLK_ADDRESS_SPACE 0x04 -#define PM_TMR_BLK_ADDRESS_SPACE 0x08 -#define GPE0_BLK_ADDRESS_SPACE 0x10 -#define GPE1_BLK_ADDRESS_SPACE 0x20 - -/* - * Control bit definitions - */ -#define TMR_STS (PM1_STS | 0x01) -#define BM_STS (PM1_STS | 0x02) -#define GBL_STS (PM1_STS | 0x03) -#define PWRBTN_STS (PM1_STS | 0x04) -#define SLPBTN_STS (PM1_STS | 0x05) -#define RTC_STS (PM1_STS | 0x06) -#define WAK_STS (PM1_STS | 0x07) - -#define TMR_EN (PM1_EN | 0x01) - /* no BM_EN */ -#define GBL_EN (PM1_EN | 0x03) -#define PWRBTN_EN (PM1_EN | 0x04) -#define SLPBTN_EN (PM1_EN | 0x05) -#define RTC_EN (PM1_EN | 0x06) -#define WAK_EN (PM1_EN | 0x07) - -#define SCI_EN (PM1_CONTROL | 0x01) -#define BM_RLD (PM1_CONTROL | 0x02) -#define GBL_RLS (PM1_CONTROL | 0x03) -#define SLP_TYPE_A (PM1_CONTROL | 0x04) -#define SLP_TYPE_B (PM1_CONTROL | 0x05) -#define SLP_EN (PM1_CONTROL | 0x06) - -#define ARB_DIS (PM2_CONTROL | 0x01) - -#define TMR_VAL (PM_TIMER | 0x01) - -#define GPE0_STS (GPE0_STS_BLOCK | 0x01) -#define GPE0_EN (GPE0_EN_BLOCK | 0x01) - -#define GPE1_STS (GPE1_STS_BLOCK | 0x01) -#define GPE1_EN (GPE1_EN_BLOCK | 0x01) - - -#define TMR_STS_MASK 0x0001 -#define BM_STS_MASK 0x0010 -#define GBL_STS_MASK 0x0020 -#define PWRBTN_STS_MASK 0x0100 -#define SLPBTN_STS_MASK 0x0200 -#define RTC_STS_MASK 0x0400 -#define WAK_STS_MASK 0x8000 - -#define ALL_FIXED_STS_BITS (TMR_STS_MASK | BM_STS_MASK | GBL_STS_MASK \ - | PWRBTN_STS_MASK | SLPBTN_STS_MASK \ - | RTC_STS_MASK | WAK_STS_MASK) - -#define TMR_EN_MASK 0x0001 -#define GBL_EN_MASK 0x0020 -#define PWRBTN_EN_MASK 0x0100 -#define SLPBTN_EN_MASK 0x0200 -#define RTC_EN_MASK 0x0400 - -#define SCI_EN_MASK 0x0001 -#define BM_RLD_MASK 0x0002 -#define GBL_RLS_MASK 0x0004 -#define SLP_TYPE_X_MASK 0x1C00 -#define SLP_EN_MASK 0x2000 - -#define ARB_DIS_MASK 0x0001 -#define TMR_VAL_MASK 0xFFFFFFFF - -#define GPE0_STS_MASK -#define GPE0_EN_MASK - -#define GPE1_STS_MASK -#define GPE1_EN_MASK - - -#define ACPI_READ 1 -#define ACPI_WRITE 2 - - -/* Plug and play */ - -/* Pnp and ACPI data */ - -#define VERSION_NO 0x01 -#define LOGICAL_DEVICE_ID 0x02 -#define COMPATIBLE_DEVICE_ID 0x03 -#define IRQ_FORMAT 0x04 -#define DMA_FORMAT 0x05 -#define START_DEPENDENT_TAG 0x06 -#define END_DEPENDENT_TAG 0x07 -#define IO_PORT_DESCRIPTOR 0x08 -#define FIXED_LOCATION_IO_DESCRIPTOR 0x09 -#define RESERVED_TYPE0 0x0A -#define RESERVED_TYPE1 0x0B -#define RESERVED_TYPE2 0x0C -#define RESERVED_TYPE3 0x0D -#define SMALL_VENDOR_DEFINED 0x0E -#define END_TAG 0x0F - -/* Pnp and ACPI data */ - -#define MEMORY_RANGE_24 0x81 -#define ISA_MEMORY_RANGE 0x81 -#define LARGE_VENDOR_DEFINED 0x84 -#define EISA_MEMORY_RANGE 0x85 -#define MEMORY_RANGE_32 0x85 -#define FIXED_EISA_MEMORY_RANGE 0x86 -#define FIXED_MEMORY_RANGE_32 0x86 - -/* ACPI only data */ - -#define DWORD_ADDRESS_SPACE 0x87 -#define WORD_ADDRESS_SPACE 0x88 -#define EXTENDED_IRQ 0x89 - -/* MUST HAVES */ - -#define DEVICE_ID_LENGTH 0x09 - -typedef struct -{ - NATIVE_CHAR buffer[DEVICE_ID_LENGTH]; - -} DEVICE_ID; - - -/***************************************************************************** - * - * Debug - * - ****************************************************************************/ - - -/* Entry for a memory allocation (debug only) */ - -#ifdef ACPI_DEBUG - -#define MEM_MALLOC 0 -#define MEM_CALLOC 1 -#define MAX_MODULE_NAME 16 - -typedef struct allocation_info -{ - struct allocation_info *previous; - struct allocation_info *next; - void *address; - u32 size; - u32 component; - u32 line; - NATIVE_CHAR module[MAX_MODULE_NAME]; - u8 alloc_type; - -} ALLOCATION_INFO; - -#endif - -#endif /* __ACLOCAL_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acmacros.h b/reactos/drivers/bus/acpi/include/acmacros.h deleted file mode 100644 index 6a386b67846..00000000000 --- a/reactos/drivers/bus/acpi/include/acmacros.h +++ /dev/null @@ -1,507 +0,0 @@ -/****************************************************************************** - * - * Name: acmacros.h - C macros for the entire subsystem. - * $Revision: 1.4 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACMACROS_H__ -#define __ACMACROS_H__ - -/* - * Data manipulation macros - */ - -#ifndef LODWORD -#define LODWORD(l) ((u32)(UINT64)(l)) -#endif - -#ifndef HIDWORD -#define HIDWORD(l) ((u32)((((UINT64)(l)) >> 32) & 0xFFFFFFFF)) -#endif - -#ifndef LOWORD -#define LOWORD(l) ((u16)(NATIVE_UINT)(l)) -#endif - -#ifndef HIWORD -#define HIWORD(l) ((u16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF)) -#endif - -#ifndef LOBYTE -#define LOBYTE(l) ((u8)(u16)(l)) -#endif - -#ifndef HIBYTE -#define HIBYTE(l) ((u8)((((u16)(l)) >> 8) & 0xFF)) -#endif - -#define BIT0(x) ((((x) & 0x01) > 0) ? 1 : 0) -#define BIT1(x) ((((x) & 0x02) > 0) ? 1 : 0) -#define BIT2(x) ((((x) & 0x04) > 0) ? 1 : 0) - -#define BIT3(x) ((((x) & 0x08) > 0) ? 1 : 0) -#define BIT4(x) ((((x) & 0x10) > 0) ? 1 : 0) -#define BIT5(x) ((((x) & 0x20) > 0) ? 1 : 0) -#define BIT6(x) ((((x) & 0x40) > 0) ? 1 : 0) -#define BIT7(x) ((((x) & 0x80) > 0) ? 1 : 0) - -#define LOW_BASE(w) ((u16) ((w) & 0x0000FFFF)) -#define MID_BASE(b) ((u8) (((b) & 0x00FF0000) >> 16)) -#define HI_BASE(b) ((u8) (((b) & 0xFF000000) >> 24)) -#define LOW_LIMIT(w) ((u16) ((w) & 0x0000FFFF)) -#define HI_LIMIT(b) ((u8) (((b) & 0x00FF0000) >> 16)) - - -#ifdef _IA16 -/* - * For 16-bit addresses, we have to assume that the upper 32 bits - * are zero. - */ -#define ACPI_GET_ADDRESS(a) ((a).lo) -#define ACPI_STORE_ADDRESS(a,b) {(a).hi=0;(a).lo=(b);} -#define ACPI_VALID_ADDRESS(a) ((a).hi | (a).lo) - -#else -/* - * Full 64-bit address on 32-bit and 64-bit platforms - */ -#define ACPI_GET_ADDRESS(a) (a) -#define ACPI_STORE_ADDRESS(a,b) ((a)=(b)) -#define ACPI_VALID_ADDRESS(a) (a) -#endif - /* - * Extract a byte of data using a pointer. Any more than a byte and we - * get into potential aligment issues -- see the STORE macros below - */ -#define GET8(addr) (*(u8*)(addr)) - - -/* - * Macros for moving data around to/from buffers that are possibly unaligned. - * If the hardware supports the transfer of unaligned data, just do the store. - * Otherwise, we have to move one byte at a time. - */ - -#ifdef _HW_ALIGNMENT_SUPPORT - -/* The hardware supports unaligned transfers, just do the move */ - -#define MOVE_UNALIGNED16_TO_16(d,s) *(u16*)(d) = *(u16*)(s) -#define MOVE_UNALIGNED32_TO_32(d,s) *(u32*)(d) = *(u32*)(s) -#define MOVE_UNALIGNED16_TO_32(d,s) *(u32*)(d) = *(u16*)(s) - -#else -/* - * The hardware does not support unaligned transfers. We must move the - * data one byte at a time. These macros work whether the source or - * the destination (or both) is/are unaligned. - */ - -#define MOVE_UNALIGNED16_TO_16(d,s) {((u8 *)(d))[0] = ((u8 *)(s))[0];\ - ((u8 *)(d))[1] = ((u8 *)(s))[1];} - -#define MOVE_UNALIGNED32_TO_32(d,s) {((u8 *)(d))[0] = ((u8 *)(s))[0];\ - ((u8 *)(d))[1] = ((u8 *)(s))[1];\ - ((u8 *)(d))[2] = ((u8 *)(s))[2];\ - ((u8 *)(d))[3] = ((u8 *)(s))[3];} - -#define MOVE_UNALIGNED16_TO_32(d,s) {(*(u32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);} - -#endif - - -/* - * Fast power-of-two math macros for non-optimized compilers - */ - -#define _DIV(value,power_of2) ((u32) ((value) >> (power_of2))) -#define _MUL(value,power_of2) ((u32) ((value) << (power_of2))) -#define _MOD(value,divisor) ((u32) ((value) & ((divisor) -1))) - -#define DIV_2(a) _DIV(a,1) -#define MUL_2(a) _MUL(a,1) -#define MOD_2(a) _MOD(a,2) - -#define DIV_4(a) _DIV(a,2) -#define MUL_4(a) _MUL(a,2) -#define MOD_4(a) _MOD(a,4) - -#define DIV_8(a) _DIV(a,3) -#define MUL_8(a) _MUL(a,3) -#define MOD_8(a) _MOD(a,8) - -#define DIV_16(a) _DIV(a,4) -#define MUL_16(a) _MUL(a,4) -#define MOD_16(a) _MOD(a,16) - -/* - * Divide and Modulo - */ -#define ACPI_DIVIDE(n,d) ((n) / (d)) -#define ACPI_MODULO(n,d) ((n) % (d)) - -/* - * Rounding macros (Power of two boundaries only) - */ - -#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) -#define ROUND_UP(value,boundary) (((value) + ((boundary)-1)) & (~((boundary)-1))) - -#define ROUND_DOWN_TO_32_BITS(a) ROUND_DOWN(a,4) -#define ROUND_DOWN_TO_64_BITS(a) ROUND_DOWN(a,8) -#define ROUND_DOWN_TO_NATIVE_WORD(a) ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) - -#define ROUND_UP_TO_32_bITS(a) ROUND_UP(a,4) -#define ROUND_UP_TO_64_bITS(a) ROUND_UP(a,8) -#define ROUND_UP_TO_NATIVE_WORD(a) ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) - -#define ROUND_PTR_UP_TO_4(a,b) ((b *)(((NATIVE_UINT)(a) + 3) & ~3)) -#define ROUND_PTR_UP_TO_8(a,b) ((b *)(((NATIVE_UINT)(a) + 7) & ~7)) - -#define ROUND_UP_TO_1_k(a) (((a) + 1023) >> 10) - -#ifdef DEBUG_ASSERT -#undef DEBUG_ASSERT -#endif - - -/* Macros for GAS addressing */ - -#ifdef __GNUC__ -#define ACPI_PCI_DEVICE_MASK (UINT64) 0x0000FFFF00000000ULL -#define ACPI_PCI_FUNCTION_MASK (UINT64) 0x00000000FFFF0000ULL -#define ACPI_PCI_REGISTER_MASK (UINT64) 0x000000000000FFFFULL -#else -#define ACPI_PCI_DEVICE_MASK (UINT64) 0x0000FFFF00000000 -#define ACPI_PCI_FUNCTION_MASK (UINT64) 0x00000000FFFF0000 -#define ACPI_PCI_REGISTER_MASK (UINT64) 0x000000000000FFFF -#endif - -#define ACPI_PCI_FUNCTION(a) (u32) ((((a) & ACPI_PCI_FUNCTION_MASK) >> 16)) -#define ACPI_PCI_DEVICE(a) (u32) ((((a) & ACPI_PCI_DEVICE_MASK) >> 32)) - -#ifndef _IA16 -#define ACPI_PCI_REGISTER(a) (u32) (((a) & ACPI_PCI_REGISTER_MASK)) -#define ACPI_PCI_DEVFUN(a) (u32) ((ACPI_PCI_DEVICE(a) << 16) | ACPI_PCI_FUNCTION(a)) - -#else -#define ACPI_PCI_REGISTER(a) (u32) (((a) & 0x0000FFFF)) -#define ACPI_PCI_DEVFUN(a) (u32) ((((a) & 0xFFFF0000) >> 16)) - -#endif - -/* - * An ACPI_HANDLE (which is actually an ACPI_NAMESPACE_NODE *) can appear in some contexts, - * such as on ap_obj_stack, where a pointer to an ACPI_OPERAND_OBJECT can also - * appear. This macro is used to distinguish them. - * - * The Data_type field is the first field in both structures. - */ - -#define VALID_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMESPACE_NODE *)d)->data_type == t) - - -/* Macro to test the object type */ - -#define IS_THIS_OBJECT_TYPE(d,t) (((ACPI_OPERAND_OBJECT *)d)->common.type == (u8)t) - -/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */ - -#define IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0) - -/* - * Macro to check if a pointer is within an ACPI table. - * Parameter (a) is the pointer to check. Parameter (b) must be defined - * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, - * and ((u8 *)b+b->Length) points one byte past the end of the table. - */ - -#ifndef _IA16 -#define IS_IN_ACPI_TABLE(a,b) (((u8 *)(a) >= (u8 *)(b + 1)) &&\ - ((u8 *)(a) < ((u8 *)b + b->length))) - -#else -#define IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\ - (((u8 *)(a) >= (u8 *)(b + 1)) &&\ - ((u8 *)(a) < ((u8 *)b + b->length))) -#endif - -/* - * Macros for the master AML opcode table - */ - -#ifdef ACPI_DEBUG -#define OP_INFO_ENTRY(flags,name,Pargs,Iargs) {flags,Pargs,Iargs,name} -#else -#define OP_INFO_ENTRY(flags,name,Pargs,Iargs) {flags,Pargs,Iargs} -#endif - -#define ARG_TYPE_WIDTH 5 -#define ARG_1(x) ((u32)(x)) -#define ARG_2(x) ((u32)(x) << (1 * ARG_TYPE_WIDTH)) -#define ARG_3(x) ((u32)(x) << (2 * ARG_TYPE_WIDTH)) -#define ARG_4(x) ((u32)(x) << (3 * ARG_TYPE_WIDTH)) -#define ARG_5(x) ((u32)(x) << (4 * ARG_TYPE_WIDTH)) -#define ARG_6(x) ((u32)(x) << (5 * ARG_TYPE_WIDTH)) - -#define ARGI_LIST1(a) (ARG_1(a)) -#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) -#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) -#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) -#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) -#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) - -#define ARGP_LIST1(a) (ARG_1(a)) -#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) -#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) -#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) -#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) -#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) - -#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F)) -#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH)) - - -/* - * Reporting macros that are never compiled out - */ - -#define PARAM_LIST(pl) pl - -/* - * Error reporting. These versions add callers module and line#. Since - * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only - * use it in debug mode. - */ - -#ifdef ACPI_DEBUG - -#define REPORT_INFO(fp) {_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \ - debug_print_raw PARAM_LIST(fp);} -#define REPORT_ERROR(fp) {_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \ - debug_print_raw PARAM_LIST(fp);} -#define REPORT_WARNING(fp) {_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \ - debug_print_raw PARAM_LIST(fp);} - -#else - -#define REPORT_INFO(fp) {_report_info("ACPI",__LINE__,_COMPONENT); \ - debug_print_raw PARAM_LIST(fp);} -#define REPORT_ERROR(fp) {_report_error("ACPI",__LINE__,_COMPONENT); \ - debug_print_raw PARAM_LIST(fp);} -#define REPORT_WARNING(fp) {_report_warning("ACPI",__LINE__,_COMPONENT); \ - debug_print_raw PARAM_LIST(fp);} - -#endif - -/* Error reporting. These versions pass thru the module and line# */ - -#define _REPORT_INFO(a,b,c,fp) {_report_info(a,b,c); \ - debug_print_raw PARAM_LIST(fp);} -#define _REPORT_ERROR(a,b,c,fp) {_report_error(a,b,c); \ - debug_print_raw PARAM_LIST(fp);} -#define _REPORT_WARNING(a,b,c,fp) {_report_warning(a,b,c); \ - debug_print_raw PARAM_LIST(fp);} - -/* Buffer dump macros */ - -#define DUMP_BUFFER(a,b) acpi_cm_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) - -/* - * Debug macros that are conditionally compiled - */ - -#ifdef ACPI_DEBUG - -#define MODULE_NAME(name) static char *_THIS_MODULE = name; - -/* - * Function entry tracing. - * The first parameter should be the procedure name as a quoted string. This is declared - * as a local string ("_Proc_name) so that it can be also used by the function exit macros below. - */ - -#define FUNCTION_TRACE(a) char * _proc_name = a;\ - function_trace(_THIS_MODULE,__LINE__,_COMPONENT,a) -#define FUNCTION_TRACE_PTR(a,b) char * _proc_name = a;\ - function_trace_ptr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b) -#define FUNCTION_TRACE_U32(a,b) char * _proc_name = a;\ - function_trace_u32(_THIS_MODULE,__LINE__,_COMPONENT,a,(u32)b) -#define FUNCTION_TRACE_STR(a,b) char * _proc_name = a;\ - function_trace_str(_THIS_MODULE,__LINE__,_COMPONENT,a,(NATIVE_CHAR *)b) -/* - * Function exit tracing. - * WARNING: These macros include a return statement. This is usually considered - * bad form, but having a separate exit macro is very ugly and difficult to maintain. - * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros - * so that "_Proc_name" is defined. - */ -#define return_VOID {function_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name);return;} -#define return_ACPI_STATUS(s) {function_status_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,s);return(s);} -#define return_VALUE(s) {function_value_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,(ACPI_INTEGER)s);return(s);} -#define return_PTR(s) {function_ptr_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,(u8 *)s);return(s);} - - -/* Conditional execution */ - -#define DEBUG_EXEC(a) a -#define NORMAL_EXEC(a) - -#define DEBUG_DEFINE(a) a; -#define DEBUG_ONLY_MEMBERS(a) a; -#define _OPCODE_NAMES -#define _VERBOSE_STRUCTURES - - -/* Stack and buffer dumping */ - -#define DUMP_STACK_ENTRY(a) acpi_aml_dump_operand(a) -#define DUMP_OPERANDS(a,b,c,d,e) acpi_aml_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__) - - -#define DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) -#define DUMP_TABLES(a,b) acpi_ns_dump_tables(a,b) -#define DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) -#define DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) -#define BREAK_MSG(a) acpi_os_breakpoint (a) - -/* - * Generate INT3 on ACPI_ERROR (Debug only!) - */ - -#define ERROR_BREAK -#ifdef ERROR_BREAK -#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) acpi_os_breakpoint("Fatal error encountered\n") -#else -#define BREAK_ON_ERROR(lvl) -#endif - -/* - * Master debug print macros - * Print iff: - * 1) Debug print for the current component is enabled - * 2) Debug error level or trace level for the print statement is enabled - * - */ - -#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer)) - -#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ - debug_print_prefix (_THIS_MODULE,__LINE__);\ - debug_print_raw PARAM_LIST(fp);\ - BREAK_ON_ERROR(lvl);} - -#define DEBUG_PRINT_RAW(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ - debug_print_raw PARAM_LIST(fp);} - - -/* Assert macros */ - -#define ACPI_ASSERT(exp) if(!(exp)) \ - acpi_os_dbg_assert(#exp, __FILE__, __LINE__, "Failed Assertion") - -#define DEBUG_ASSERT(msg, exp) if(!(exp)) \ - acpi_os_dbg_assert(#exp, __FILE__, __LINE__, msg) - - -#else -/* - * This is the non-debug case -- make everything go away, - * leaving no executable debug code! - */ - -#define MODULE_NAME(name) -#define _THIS_MODULE "" - -#define DEBUG_EXEC(a) -#define NORMAL_EXEC(a) a; - -#define DEBUG_DEFINE(a) -#define DEBUG_ONLY_MEMBERS(a) -#define FUNCTION_TRACE(a) -#define FUNCTION_TRACE_PTR(a,b) -#define FUNCTION_TRACE_U32(a,b) -#define FUNCTION_TRACE_STR(a,b) -#define FUNCTION_EXIT -#define FUNCTION_STATUS_EXIT(s) -#define FUNCTION_VALUE_EXIT(s) -#define DUMP_STACK_ENTRY(a) -#define DUMP_OPERANDS(a,b,c,d,e) -#define DUMP_ENTRY(a,b) -#define DUMP_TABLES(a,b) -#define DUMP_PATHNAME(a,b,c,d) -#define DUMP_RESOURCE_LIST(a) -#define DEBUG_PRINT(l,f) -#define DEBUG_PRINT_RAW(l,f) -#define BREAK_MSG(a) - -#define return_VOID return -#define return_ACPI_STATUS(s) return(s) -#define return_VALUE(s) return(s) -#define return_PTR(s) return(s) - -#define ACPI_ASSERT(exp) -#define DEBUG_ASSERT(msg, exp) - -#endif - -/* - * Some code only gets executed when the debugger is built in. - * Note that this is entirely independent of whether the - * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not. - */ -#ifdef ENABLE_DEBUGGER -#define DEBUGGER_EXEC(a) a -#else -#define DEBUGGER_EXEC(a) -#endif - - -/* - * For 16-bit code, we want to shrink some things even though - * we are using ACPI_DEBUG to get the debug output - */ -#ifdef _IA16 -#undef DEBUG_ONLY_MEMBERS -#undef _VERBOSE_STRUCTURES -#define DEBUG_ONLY_MEMBERS(a) -#endif - - -#ifdef ACPI_DEBUG - -/* - * 1) Set name to blanks - * 2) Copy the object name - */ - -#define ADD_OBJECT_NAME(a,b) MEMSET (a->common.name, ' ', sizeof (a->common.name));\ - STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name)) - -#else - -#define ADD_OBJECT_NAME(a,b) - -#endif - - -#endif /* ACMACROS_H */ diff --git a/reactos/drivers/bus/acpi/include/acnamesp.h b/reactos/drivers/bus/acpi/include/acnamesp.h deleted file mode 100644 index ad1d0a60f88..00000000000 --- a/reactos/drivers/bus/acpi/include/acnamesp.h +++ /dev/null @@ -1,430 +0,0 @@ -/****************************************************************************** - * - * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACNAMESP_H__ -#define __ACNAMESP_H__ - - -/* To search the entire name space, pass this as Search_base */ - -#define NS_ALL ((ACPI_HANDLE)0) - -/* - * Elements of Acpi_ns_properties are bit significant - * and should be one-to-one with values of ACPI_OBJECT_TYPE - */ -#define NSP_NORMAL 0 -#define NSP_NEWSCOPE 1 /* a definition of this type opens a name scope */ -#define NSP_LOCAL 2 /* suppress search of enclosing scopes */ - - -/* Definitions of the predefined namespace names */ - -#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ -#define ACPI_ROOT_NAME (u32) 0x2F202020 /* Root name is "/ " */ -#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */ - -#define NS_ROOT_PATH "/" -#define NS_SYSTEM_BUS "_SB_" - - -/* Flags for Acpi_ns_lookup, Acpi_ns_search_and_enter */ - -#define NS_NO_UPSEARCH 0 -#define NS_SEARCH_PARENT 0x01 -#define NS_DONT_OPEN_SCOPE 0x02 -#define NS_NO_PEER_SEARCH 0x04 -#define NS_ERROR_IF_FOUND 0x08 - -#define NS_WALK_UNLOCK TRUE -#define NS_WALK_NO_UNLOCK FALSE - - -ACPI_STATUS -acpi_ns_load_namespace ( - void); - -ACPI_STATUS -acpi_ns_initialize_objects ( - void); - -ACPI_STATUS -acpi_ns_initialize_devices ( - void); - - -/* Namespace init - nsxfinit */ - -ACPI_STATUS -acpi_ns_init_one_device ( - ACPI_HANDLE obj_handle, - u32 nesting_level, - void *context, - void **return_value); - -ACPI_STATUS -acpi_ns_init_one_object ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value); - - -ACPI_STATUS -acpi_ns_walk_namespace ( - OBJECT_TYPE_INTERNAL type, - ACPI_HANDLE start_object, - u32 max_depth, - u8 unlock_before_callback, - WALK_CALLBACK user_function, - void *context, - void **return_value); - - -ACPI_NAMESPACE_NODE * -acpi_ns_get_next_object ( - OBJECT_TYPE_INTERNAL type, - ACPI_NAMESPACE_NODE *parent, - ACPI_NAMESPACE_NODE *child); - - -ACPI_STATUS -acpi_ns_delete_namespace_by_owner ( - u16 table_id); - - -/* Namespace loading - nsload */ - -ACPI_STATUS -acpi_ns_one_complete_parse ( - u32 pass_number, - ACPI_TABLE_DESC *table_desc); - -ACPI_STATUS -acpi_ns_parse_table ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMESPACE_NODE *scope); - -ACPI_STATUS -acpi_ns_load_table ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMESPACE_NODE *node); - -ACPI_STATUS -acpi_ns_load_table_by_type ( - ACPI_TABLE_TYPE table_type); - - -/* - * Top-level namespace access - nsaccess - */ - - -ACPI_STATUS -acpi_ns_root_initialize ( - void); - -ACPI_STATUS -acpi_ns_lookup ( - ACPI_GENERIC_STATE *scope_info, - NATIVE_CHAR *name, - OBJECT_TYPE_INTERNAL type, - OPERATING_MODE interpreter_mode, - u32 flags, - ACPI_WALK_STATE *walk_state, - ACPI_NAMESPACE_NODE **ret_node); - - -/* - * Named object allocation/deallocation - nsalloc - */ - - -ACPI_NAMESPACE_NODE * -acpi_ns_create_node ( - u32 acpi_name); - -void -acpi_ns_delete_node ( - ACPI_NAMESPACE_NODE *node); - -ACPI_STATUS -acpi_ns_delete_namespace_subtree ( - ACPI_NAMESPACE_NODE *parent_handle); - -void -acpi_ns_detach_object ( - ACPI_NAMESPACE_NODE *node); - -void -acpi_ns_delete_children ( - ACPI_NAMESPACE_NODE *parent); - - -/* - * Namespace modification - nsmodify - */ - -ACPI_STATUS -acpi_ns_unload_namespace ( - ACPI_HANDLE handle); - -ACPI_STATUS -acpi_ns_delete_subtree ( - ACPI_HANDLE start_handle); - - -/* - * Namespace dump/print utilities - nsdump - */ - -void -acpi_ns_dump_tables ( - ACPI_HANDLE search_base, - u32 max_depth); - -void -acpi_ns_dump_entry ( - ACPI_HANDLE handle, - u32 debug_level); - -ACPI_STATUS -acpi_ns_dump_pathname ( - ACPI_HANDLE handle, - NATIVE_CHAR *msg, - u32 level, - u32 component); - -void -acpi_ns_dump_root_devices ( - void); - -void -acpi_ns_dump_objects ( - OBJECT_TYPE_INTERNAL type, - u32 max_depth, - u32 ownder_id, - ACPI_HANDLE start_handle); - - -/* - * Namespace evaluation functions - nseval - */ - -ACPI_STATUS -acpi_ns_evaluate_by_handle ( - ACPI_NAMESPACE_NODE *prefix_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_object); - -ACPI_STATUS -acpi_ns_evaluate_by_name ( - NATIVE_CHAR *pathname, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_object); - -ACPI_STATUS -acpi_ns_evaluate_relative ( - ACPI_NAMESPACE_NODE *prefix_node, - NATIVE_CHAR *pathname, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_object); - -ACPI_STATUS -acpi_ns_execute_control_method ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_obj_desc); - -ACPI_STATUS -acpi_ns_get_object_value ( - ACPI_NAMESPACE_NODE *object_node, - ACPI_OPERAND_OBJECT **return_obj_desc); - - -/* - * Parent/Child/Peer utility functions - nsfamily - */ - -ACPI_NAME -acpi_ns_find_parent_name ( - ACPI_NAMESPACE_NODE *node_to_search); - -u8 -acpi_ns_exist_downstream_sibling ( - ACPI_NAMESPACE_NODE *this_node); - - -/* - * Scope manipulation - nsscope - */ - -u32 -acpi_ns_opens_scope ( - OBJECT_TYPE_INTERNAL type); - -NATIVE_CHAR * -acpi_ns_get_table_pathname ( - ACPI_NAMESPACE_NODE *node); - -NATIVE_CHAR * -acpi_ns_name_of_current_scope ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ns_handle_to_pathname ( - ACPI_HANDLE obj_handle, - u32 *buf_size, - NATIVE_CHAR *user_buffer); - -u8 -acpi_ns_pattern_match ( - ACPI_NAMESPACE_NODE *obj_node, - NATIVE_CHAR *search_for); - -ACPI_STATUS -acpi_ns_name_compare ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value); - -ACPI_STATUS -acpi_ns_get_node ( - NATIVE_CHAR *pathname, - ACPI_NAMESPACE_NODE *in_prefix_node, - ACPI_NAMESPACE_NODE **out_node); - -u32 -acpi_ns_get_pathname_length ( - ACPI_NAMESPACE_NODE *node); - - -/* - * Object management for NTEs - nsobject - */ - -ACPI_STATUS -acpi_ns_attach_object ( - ACPI_NAMESPACE_NODE *node, - ACPI_OPERAND_OBJECT *object, - OBJECT_TYPE_INTERNAL type); - - -void * -acpi_ns_compare_value ( - ACPI_HANDLE obj_handle, - u32 level, - void *obj_desc); - - -/* - * Namespace searching and entry - nssearch - */ - -ACPI_STATUS -acpi_ns_search_and_enter ( - u32 entry_name, - ACPI_WALK_STATE *walk_state, - ACPI_NAMESPACE_NODE *node, - OPERATING_MODE interpreter_mode, - OBJECT_TYPE_INTERNAL type, - u32 flags, - ACPI_NAMESPACE_NODE **ret_node); - -ACPI_STATUS -acpi_ns_search_node ( - u32 entry_name, - ACPI_NAMESPACE_NODE *node, - OBJECT_TYPE_INTERNAL type, - ACPI_NAMESPACE_NODE **ret_node); - -void -acpi_ns_install_node ( - ACPI_WALK_STATE *walk_state, - ACPI_NAMESPACE_NODE *parent_node, /* Parent */ - ACPI_NAMESPACE_NODE *node, /* New Child*/ - OBJECT_TYPE_INTERNAL type); - - -/* - * Utility functions - nsutils - */ - -u8 -acpi_ns_valid_root_prefix ( - NATIVE_CHAR prefix); - -u8 -acpi_ns_valid_path_separator ( - NATIVE_CHAR sep); - -OBJECT_TYPE_INTERNAL -acpi_ns_get_type ( - ACPI_HANDLE obj_handle); - -void * -acpi_ns_get_attached_object ( - ACPI_HANDLE obj_handle); - -u32 -acpi_ns_local ( - OBJECT_TYPE_INTERNAL type); - -ACPI_STATUS -acpi_ns_internalize_name ( - NATIVE_CHAR *dotted_name, - NATIVE_CHAR **converted_name); - -ACPI_STATUS -acpi_ns_externalize_name ( - u32 internal_name_length, - NATIVE_CHAR *internal_name, - u32 *converted_name_length, - NATIVE_CHAR **converted_name); - -ACPI_NAMESPACE_NODE * -acpi_ns_convert_handle_to_entry ( - ACPI_HANDLE handle); - -ACPI_HANDLE -acpi_ns_convert_entry_to_handle( - ACPI_NAMESPACE_NODE *node); - -void -acpi_ns_terminate ( - void); - -ACPI_NAMESPACE_NODE * -acpi_ns_get_parent_object ( - ACPI_NAMESPACE_NODE *node); - - -ACPI_NAMESPACE_NODE * -acpi_ns_get_next_valid_object ( - ACPI_NAMESPACE_NODE *node); - - -#endif /* __ACNAMESP_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acobject.h b/reactos/drivers/bus/acpi/include/acobject.h deleted file mode 100644 index 5996628dcf8..00000000000 --- a/reactos/drivers/bus/acpi/include/acobject.h +++ /dev/null @@ -1,425 +0,0 @@ - -/****************************************************************************** - * - * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _ACOBJECT_H -#define _ACOBJECT_H - - -/* - * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher - * to the interpreter, and to keep track of the various handlers such as - * address space handlers and notify handlers. The object is a constant - * size in order to allow them to be cached and reused. - * - * All variants of the ACPI_OPERAND_OBJECT are defined with the same - * sequence of field types, with fields that are not used in a particular - * variant being named "Reserved". This is not strictly necessary, but - * may in some circumstances simplify understanding if these structures - * need to be displayed in a debugger having limited (or no) support for - * union types. It also simplifies some debug code in Dump_table() which - * dumps multi-level values: fetching Buffer.Pointer suffices to pick up - * the value or next level for any of several types. - */ - -/****************************************************************************** - * - * Common Descriptors - * - *****************************************************************************/ - -/* - * Common area for all objects. - * - * Data_type is used to differentiate between internal descriptors, and MUST - * be the first byte in this structure. - */ - - -#define ACPI_OBJECT_COMMON_HEADER /* 32-bits plus 8-bit flag */\ - u8 data_type; /* To differentiate various internal objs */\ - u8 type; /* ACPI_OBJECT_TYPE */\ - u16 reference_count; /* For object deletion management */\ - u8 flags; \ - -/* Defines for flag byte above */ - -#define AOPOBJ_STATIC_ALLOCATION 0x1 -#define AOPOBJ_DATA_VALID 0x2 -#define AOPOBJ_INITIALIZED 0x4 - - -/* - * Common bitfield for the field objects - */ -#define ACPI_COMMON_FIELD_INFO /* Three 32-bit values plus 8*/\ - u8 granularity;\ - u16 length; \ - u32 offset; /* Byte offset within containing object */\ - u8 bit_offset; /* Bit offset within min read/write data unit */\ - u8 access; /* Access_type */\ - u8 lock_rule;\ - u8 update_rule;\ - u8 access_attribute; - - -/****************************************************************************** - * - * Individual Object Descriptors - * - *****************************************************************************/ - - -typedef struct /* COMMON */ -{ - ACPI_OBJECT_COMMON_HEADER - -} ACPI_OBJECT_COMMON; - - -typedef struct /* CACHE_LIST */ -{ - ACPI_OBJECT_COMMON_HEADER - union acpi_operand_obj *next; /* Link for object cache and internal lists*/ - -} ACPI_OBJECT_CACHE_LIST; - - -typedef struct /* NUMBER - has value */ -{ - ACPI_OBJECT_COMMON_HEADER - - ACPI_INTEGER value; - -} ACPI_OBJECT_INTEGER; - - -typedef struct /* STRING - has length and pointer - Null terminated, ASCII characters only */ -{ - ACPI_OBJECT_COMMON_HEADER - - u32 length; - NATIVE_CHAR *pointer; /* String value in AML stream or in allocated space */ - -} ACPI_OBJECT_STRING; - - -typedef struct /* BUFFER - has length and pointer - not null terminated */ -{ - ACPI_OBJECT_COMMON_HEADER - - u32 length; - u8 *pointer; /* points to the buffer in allocated space */ - -} ACPI_OBJECT_BUFFER; - - -typedef struct /* PACKAGE - has count, elements, next element */ -{ - ACPI_OBJECT_COMMON_HEADER - - u32 count; /* # of elements in package */ - - union acpi_operand_obj **elements; /* Array of pointers to Acpi_objects */ - union acpi_operand_obj **next_element; /* used only while initializing */ - -} ACPI_OBJECT_PACKAGE; - - -typedef struct /* FIELD UNIT */ -{ - ACPI_OBJECT_COMMON_HEADER - - ACPI_COMMON_FIELD_INFO - - union acpi_operand_obj *extra; /* Pointer to executable AML (in field definition) */ - ACPI_NAMESPACE_NODE *node; /* containing object */ - union acpi_operand_obj *container; /* Containing object (Buffer) */ - -} ACPI_OBJECT_FIELD_UNIT; - - -typedef struct /* DEVICE - has handle and notification handler/context */ -{ - ACPI_OBJECT_COMMON_HEADER - - union acpi_operand_obj *sys_handler; /* Handler for system notifies */ - union acpi_operand_obj *drv_handler; /* Handler for driver notifies */ - union acpi_operand_obj *addr_handler; /* Handler for Address space */ - -} ACPI_OBJECT_DEVICE; - - -typedef struct /* EVENT */ -{ - ACPI_OBJECT_COMMON_HEADER - void *semaphore; - -} ACPI_OBJECT_EVENT; - - -#define INFINITE_CONCURRENCY 0xFF - -typedef struct /* METHOD */ -{ - ACPI_OBJECT_COMMON_HEADER - u8 method_flags; - u8 param_count; - - u32 pcode_length; - - void *semaphore; - u8 *pcode; - - u8 concurrency; - u8 thread_count; - ACPI_OWNER_ID owning_id; - -} ACPI_OBJECT_METHOD; - - -typedef struct acpi_obj_mutex /* MUTEX */ -{ - ACPI_OBJECT_COMMON_HEADER - u16 sync_level; - u16 acquisition_depth; - - void *semaphore; - void *owner; - union acpi_operand_obj *prev; /* Link for list of acquired mutexes */ - union acpi_operand_obj *next; /* Link for list of acquired mutexes */ - -} ACPI_OBJECT_MUTEX; - - -typedef struct /* REGION */ -{ - ACPI_OBJECT_COMMON_HEADER - - u8 space_id; - u32 length; - ACPI_PHYSICAL_ADDRESS address; - union acpi_operand_obj *extra; /* Pointer to executable AML (in region definition) */ - - union acpi_operand_obj *addr_handler; /* Handler for system notifies */ - ACPI_NAMESPACE_NODE *node; /* containing object */ - union acpi_operand_obj *next; - -} ACPI_OBJECT_REGION; - - -typedef struct /* POWER RESOURCE - has Handle and notification handler/context*/ -{ - ACPI_OBJECT_COMMON_HEADER - - u32 system_level; - u32 resource_order; - - union acpi_operand_obj *sys_handler; /* Handler for system notifies */ - union acpi_operand_obj *drv_handler; /* Handler for driver notifies */ - -} ACPI_OBJECT_POWER_RESOURCE; - - -typedef struct /* PROCESSOR - has Handle and notification handler/context*/ -{ - ACPI_OBJECT_COMMON_HEADER - - u32 proc_id; - u32 length; - ACPI_IO_ADDRESS address; - - union acpi_operand_obj *sys_handler; /* Handler for system notifies */ - union acpi_operand_obj *drv_handler; /* Handler for driver notifies */ - union acpi_operand_obj *addr_handler; /* Handler for Address space */ - -} ACPI_OBJECT_PROCESSOR; - - -typedef struct /* THERMAL ZONE - has Handle and Handler/Context */ -{ - ACPI_OBJECT_COMMON_HEADER - - union acpi_operand_obj *sys_handler; /* Handler for system notifies */ - union acpi_operand_obj *drv_handler; /* Handler for driver notifies */ - union acpi_operand_obj *addr_handler; /* Handler for Address space */ - -} ACPI_OBJECT_THERMAL_ZONE; - - -/* - * Internal types - */ - - -typedef struct /* FIELD */ -{ - ACPI_OBJECT_COMMON_HEADER - - ACPI_COMMON_FIELD_INFO - - union acpi_operand_obj *container; /* Containing object */ - -} ACPI_OBJECT_FIELD; - - -typedef struct /* BANK FIELD */ -{ - ACPI_OBJECT_COMMON_HEADER - - ACPI_COMMON_FIELD_INFO - u32 value; /* Value to store into Bank_select */ - - ACPI_HANDLE bank_select; /* Bank select register */ - union acpi_operand_obj *container; /* Containing object */ - -} ACPI_OBJECT_BANK_FIELD; - - -typedef struct /* INDEX FIELD */ -{ - /* - * No container pointer needed since the index and data register definitions - * will define how to access the respective registers - */ - ACPI_OBJECT_COMMON_HEADER - - ACPI_COMMON_FIELD_INFO - u32 value; /* Value to store into Index register */ - - ACPI_HANDLE index; /* Index register */ - ACPI_HANDLE data; /* Data register */ - -} ACPI_OBJECT_INDEX_FIELD; - - -typedef struct /* NOTIFY HANDLER */ -{ - ACPI_OBJECT_COMMON_HEADER - - ACPI_NAMESPACE_NODE *node; /* Parent device */ - NOTIFY_HANDLER handler; - void *context; - -} ACPI_OBJECT_NOTIFY_HANDLER; - - -/* Flags for address handler */ - -#define ADDR_HANDLER_DEFAULT_INSTALLED 0x1 - - -typedef struct /* ADDRESS HANDLER */ -{ - ACPI_OBJECT_COMMON_HEADER - - u8 space_id; - u16 hflags; - ADDRESS_SPACE_HANDLER handler; - - ACPI_NAMESPACE_NODE *node; /* Parent device */ - void *context; - ADDRESS_SPACE_SETUP setup; - union acpi_operand_obj *region_list; /* regions using this handler */ - union acpi_operand_obj *next; - -} ACPI_OBJECT_ADDR_HANDLER; - - -/* - * The Reference object type is used for these opcodes: - * Arg[0-6], Local[0-7], Index_op, Name_op, Zero_op, One_op, Ones_op, Debug_op - */ - -typedef struct /* Reference - Local object type */ -{ - ACPI_OBJECT_COMMON_HEADER - - u8 target_type; /* Used for Index_op */ - u16 opcode; - u32 offset; /* Used for Arg_op, Local_op, and Index_op */ - - void *object; /* Name_op=>HANDLE to obj, Index_op=>ACPI_OPERAND_OBJECT */ - ACPI_NAMESPACE_NODE *node; - union acpi_operand_obj **where; - -} ACPI_OBJECT_REFERENCE; - - -/* - * Extra object is used as additional storage for types that - * have AML code in their declarations (Term_args) that must be - * evaluated at run time. - * - * Currently: Region and Field_unit types - */ - -typedef struct /* EXTRA */ -{ - ACPI_OBJECT_COMMON_HEADER - u8 byte_fill1; - u16 word_fill1; - u32 pcode_length; - u8 *pcode; - ACPI_NAMESPACE_NODE *method_REG; /* _REG method for this region (if any) */ - void *region_context; /* Region-specific data */ - -} ACPI_OBJECT_EXTRA; - - -/****************************************************************************** - * - * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above - * - *****************************************************************************/ - -typedef union acpi_operand_obj -{ - ACPI_OBJECT_COMMON common; - ACPI_OBJECT_CACHE_LIST cache; - ACPI_OBJECT_INTEGER integer; - ACPI_OBJECT_STRING string; - ACPI_OBJECT_BUFFER buffer; - ACPI_OBJECT_PACKAGE package; - ACPI_OBJECT_FIELD_UNIT field_unit; - ACPI_OBJECT_DEVICE device; - ACPI_OBJECT_EVENT event; - ACPI_OBJECT_METHOD method; - ACPI_OBJECT_MUTEX mutex; - ACPI_OBJECT_REGION region; - ACPI_OBJECT_POWER_RESOURCE power_resource; - ACPI_OBJECT_PROCESSOR processor; - ACPI_OBJECT_THERMAL_ZONE thermal_zone; - ACPI_OBJECT_FIELD field; - ACPI_OBJECT_BANK_FIELD bank_field; - ACPI_OBJECT_INDEX_FIELD index_field; - ACPI_OBJECT_REFERENCE reference; - ACPI_OBJECT_NOTIFY_HANDLER notify_handler; - ACPI_OBJECT_ADDR_HANDLER addr_handler; - ACPI_OBJECT_EXTRA extra; - -} ACPI_OPERAND_OBJECT; - -#endif /* _ACOBJECT_H */ diff --git a/reactos/drivers/bus/acpi/include/acoutput.h b/reactos/drivers/bus/acpi/include/acoutput.h deleted file mode 100644 index 82d137bb5b7..00000000000 --- a/reactos/drivers/bus/acpi/include/acoutput.h +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - * - * Name: acoutput.h -- debug output - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACOUTPUT_H__ -#define __ACOUTPUT_H__ - -/* - * Debug levels and component IDs. These are used to control the - * granularity of the output of the DEBUG_PRINT macro -- on a per- - * component basis and a per-exception-type basis. - */ - -/* Component IDs -- used in the global "Debug_layer" */ - -#define ACPI_UTILITIES 0x00000001 -#define ACPI_HARDWARE 0x00000002 -#define ACPI_EVENTS 0x00000003 -#define ACPI_TABLES 0x00000008 -#define ACPI_NAMESPACE 0x00000010 -#define ACPI_PARSER 0x00000020 -#define ACPI_DISPATCHER 0x00000040 -#define ACPI_EXECUTER 0x00000080 -#define ACPI_RESOURCES 0x00000100 -#define ACPI_DEVICES 0x00000200 -#define ACPI_POWER 0x00000400 - - -#define ACPI_BUS_MANAGER 0x00001000 -#define ACPI_POWER_CONTROL 0x00002000 -#define ACPI_EMBEDDED_CONTROLLER 0x00004000 -#define ACPI_PROCESSOR_CONTROL 0x00008000 -#define ACPI_AC_ADAPTER 0x00010000 -#define ACPI_BATTERY 0x00020000 -#define ACPI_BUTTON 0x00040000 -#define ACPI_SYSTEM 0x00080000 -#define ACPI_THERMAL_ZONE 0x00100000 - -#define ACPI_DEBUGGER 0x01000000 -#define ACPI_OS_SERVICES 0x02000000 -#define ACPI_ALL_COMPONENTS 0x01FFFFFF - -#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) - - -#define ACPI_COMPILER 0x10000000 -#define ACPI_TOOLS 0x20000000 - - -/* Exception level -- used in the global "Debug_level" */ - -#define ACPI_OK 0x00000001 -#define ACPI_INFO 0x00000002 -#define ACPI_WARN 0x00000004 -#define ACPI_ERROR 0x00000008 -#define ACPI_FATAL 0x00000010 -#define ACPI_DEBUG_OBJECT 0x00000020 -#define ACPI_ALL 0x0000003F - - -/* Trace level -- also used in the global "Debug_level" */ - -#define TRACE_PARSE 0x00000100 -#define TRACE_DISPATCH 0x00000200 -#define TRACE_LOAD 0x00000400 -#define TRACE_EXEC 0x00000800 -#define TRACE_NAMES 0x00001000 -#define TRACE_OPREGION 0x00002000 -#define TRACE_BFIELD 0x00004000 -#define TRACE_TRASH 0x00008000 -#define TRACE_TABLES 0x00010000 -#define TRACE_FUNCTIONS 0x00020000 -#define TRACE_VALUES 0x00040000 -#define TRACE_OBJECTS 0x00080000 -#define TRACE_ALLOCATIONS 0x00100000 -#define TRACE_RESOURCES 0x00200000 -#define TRACE_IO 0x00400000 -#define TRACE_INTERRUPTS 0x00800000 -#define TRACE_USER_REQUESTS 0x01000000 -#define TRACE_PACKAGE 0x02000000 -#define TRACE_MUTEX 0x04000000 -#define TRACE_INIT 0x08000000 - -#define TRACE_ALL 0x0FFFFF00 - - -/* Exceptionally verbose output -- also used in the global "Debug_level" */ - -#define VERBOSE_AML_DISASSEMBLE 0x10000000 -#define VERBOSE_INFO 0x20000000 -#define VERBOSE_TABLES 0x40000000 -#define VERBOSE_EVENTS 0x80000000 - -#define VERBOSE_ALL 0xF0000000 - - -/* Defaults for Debug_level, debug and normal */ - -#define DEBUG_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) -#define NORMAL_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) -#define DEBUG_ALL (VERBOSE_AML_DISASSEMBLE | TRACE_ALL | ACPI_ALL) - -/* Misc defines */ - -#define HEX 0x01 -#define ASCII 0x02 -#define FULL_ADDRESS 0x04 -#define CHARS_PER_LINE 16 /* used in Dump_buf function */ - - -#endif /* __ACOUTPUT_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acparser.h b/reactos/drivers/bus/acpi/include/acparser.h deleted file mode 100644 index 83a6c6761d6..00000000000 --- a/reactos/drivers/bus/acpi/include/acparser.h +++ /dev/null @@ -1,346 +0,0 @@ -/****************************************************************************** - * - * Module Name: acparser.h - AML Parser subcomponent prototypes and defines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef __ACPARSER_H__ -#define __ACPARSER_H__ - - -#define OP_HAS_RETURN_VALUE 1 - -/* variable # arguments */ - -#define ACPI_VAR_ARGS ACPI_UINT32_MAX - -/* maximum virtual address */ - -#define ACPI_MAX_AML ((u8 *)(~0UL)) - - -#define ACPI_PARSE_DELETE_TREE 0x0001 -#define ACPI_PARSE_NO_TREE_DELETE 0x0000 -#define ACPI_PARSE_TREE_MASK 0x0001 - -#define ACPI_PARSE_LOAD_PASS1 0x0010 -#define ACPI_PARSE_LOAD_PASS2 0x0020 -#define ACPI_PARSE_EXECUTE 0x0030 -#define ACPI_PARSE_MODE_MASK 0x0030 - -/* psapi - Parser external interfaces */ - -ACPI_STATUS -acpi_psx_load_table ( - u8 *pcode_addr, - u32 pcode_length); - -ACPI_STATUS -acpi_psx_execute ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_obj_desc); - - -u8 -acpi_ps_is_namespace_object_op ( - u16 opcode); -u8 -acpi_ps_is_namespace_op ( - u16 opcode); - - -/****************************************************************************** - * - * Parser interfaces - * - *****************************************************************************/ - - -/* psargs - Parse AML opcode arguments */ - -u8 * -acpi_ps_get_next_package_end ( - ACPI_PARSE_STATE *parser_state); - -u32 -acpi_ps_get_next_package_length ( - ACPI_PARSE_STATE *parser_state); - -NATIVE_CHAR * -acpi_ps_get_next_namestring ( - ACPI_PARSE_STATE *parser_state); - -void -acpi_ps_get_next_simple_arg ( - ACPI_PARSE_STATE *parser_state, - u32 arg_type, /* type of argument */ - ACPI_PARSE_OBJECT *arg); /* (OUT) argument data */ - -void -acpi_ps_get_next_namepath ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT *arg, - u32 *arg_count, - u8 method_call); - -ACPI_PARSE_OBJECT * -acpi_ps_get_next_field ( - ACPI_PARSE_STATE *parser_state); - -ACPI_PARSE_OBJECT * -acpi_ps_get_next_arg ( - ACPI_PARSE_STATE *parser_state, - u32 arg_type, - u32 *arg_count); - - -/* psopcode - AML Opcode information */ - -ACPI_OPCODE_INFO * -acpi_ps_get_opcode_info ( - u16 opcode); - -NATIVE_CHAR * -acpi_ps_get_opcode_name ( - u16 opcode); - - -/* psparse - top level parsing routines */ - -ACPI_STATUS -acpi_ps_find_object ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op); - -void -acpi_ps_delete_parse_tree ( - ACPI_PARSE_OBJECT *root); - -ACPI_STATUS -acpi_ps_parse_loop ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ps_parse_aml ( - ACPI_PARSE_OBJECT *start_scope, - u8 *aml, - u32 aml_size, - u32 parse_flags, - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **caller_return_desc, - ACPI_PARSE_DOWNWARDS descending_callback, - ACPI_PARSE_UPWARDS ascending_callback); - -ACPI_STATUS -acpi_ps_parse_table ( - u8 *aml, - u32 aml_size, - ACPI_PARSE_DOWNWARDS descending_callback, - ACPI_PARSE_UPWARDS ascending_callback, - ACPI_PARSE_OBJECT **root_object); - -u16 -acpi_ps_peek_opcode ( - ACPI_PARSE_STATE *state); - - -/* psscope - Scope stack management routines */ - - -ACPI_STATUS -acpi_ps_init_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT *root); - -ACPI_PARSE_OBJECT * -acpi_ps_get_parent_scope ( - ACPI_PARSE_STATE *state); - -u8 -acpi_ps_has_completed_scope ( - ACPI_PARSE_STATE *parser_state); - -void -acpi_ps_pop_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT **op, - u32 *arg_list, - u32 *arg_count); - -ACPI_STATUS -acpi_ps_push_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT *op, - u32 remaining_args, - u32 arg_count); - -void -acpi_ps_cleanup_scope ( - ACPI_PARSE_STATE *state); - - -/* pstree - parse tree manipulation routines */ - -void -acpi_ps_append_arg( - ACPI_PARSE_OBJECT *op, - ACPI_PARSE_OBJECT *arg); - -ACPI_PARSE_OBJECT* -acpi_ps_find ( - ACPI_PARSE_OBJECT *scope, - NATIVE_CHAR *path, - u16 opcode, - u32 create); - -ACPI_PARSE_OBJECT * -acpi_ps_get_arg( - ACPI_PARSE_OBJECT *op, - u32 argn); - -ACPI_PARSE_OBJECT * -acpi_ps_get_child ( - ACPI_PARSE_OBJECT *op); - -ACPI_PARSE_OBJECT * -acpi_ps_get_depth_next ( - ACPI_PARSE_OBJECT *origin, - ACPI_PARSE_OBJECT *op); - - -/* pswalk - parse tree walk routines */ - -ACPI_STATUS -acpi_ps_walk_parsed_aml ( - ACPI_PARSE_OBJECT *start_op, - ACPI_PARSE_OBJECT *end_op, - ACPI_OPERAND_OBJECT *mth_desc, - ACPI_NAMESPACE_NODE *start_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **caller_return_desc, - ACPI_OWNER_ID owner_id, - ACPI_PARSE_DOWNWARDS descending_callback, - ACPI_PARSE_UPWARDS ascending_callback); - -ACPI_STATUS -acpi_ps_get_next_walk_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - ACPI_PARSE_UPWARDS ascending_callback); - - -/* psutils - parser utilities */ - - -ACPI_PARSE_STATE * -acpi_ps_create_state ( - u8 *aml, - u32 aml_size); - -void -acpi_ps_init_op ( - ACPI_PARSE_OBJECT *op, - u16 opcode); - -ACPI_PARSE_OBJECT * -acpi_ps_alloc_op ( - u16 opcode); - -void -acpi_ps_free_op ( - ACPI_PARSE_OBJECT *op); - -void -acpi_ps_delete_parse_cache ( - void); - -u8 -acpi_ps_is_leading_char ( - u32 c); - -u8 -acpi_ps_is_prefix_char ( - u32 c); - -u8 -acpi_ps_is_named_op ( - u16 opcode); - -u8 -acpi_ps_is_node_op ( - u16 opcode); - -u8 -acpi_ps_is_deferred_op ( - u16 opcode); - -u8 -acpi_ps_is_bytelist_op( - u16 opcode); - -u8 -acpi_ps_is_field_op( - u16 opcode); - -u8 -acpi_ps_is_create_field_op ( - u16 opcode); - -ACPI_PARSE2_OBJECT* -acpi_ps_to_extended_op( - ACPI_PARSE_OBJECT *op); - -u32 -acpi_ps_get_name( - ACPI_PARSE_OBJECT *op); - -void -acpi_ps_set_name( - ACPI_PARSE_OBJECT *op, - u32 name); - - -/* psdump - display parser tree */ - -u32 -acpi_ps_sprint_path ( - NATIVE_CHAR *buffer_start, - u32 buffer_size, - ACPI_PARSE_OBJECT *op); - -u32 -acpi_ps_sprint_op ( - NATIVE_CHAR *buffer_start, - u32 buffer_size, - ACPI_PARSE_OBJECT *op); - -void -acpi_ps_show ( - ACPI_PARSE_OBJECT *op); - - -#endif /* __ACPARSER_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acpi.h b/reactos/drivers/bus/acpi/include/acpi.h deleted file mode 100644 index c1226f84659..00000000000 --- a/reactos/drivers/bus/acpi/include/acpi.h +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************************** - * - * Name: acpi.h - Master include file, Publics and external data. - * $Revision: 1.2 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACPI_H__ -#define __ACPI_H__ - -#include "platform/types.h" -#undef ROUND_DOWN -#undef ROUND_UP -#define DEFINE_ACPI_GLOBALS - -/* - * Common includes for all ACPI driver files - * We put them here because we don't want to duplicate them - * in the rest of the source code again and again. - */ -#include "acconfig.h" /* Configuration constants */ -#include "platform/acenv.h" /* Target environment specific items */ -#include "actypes.h" /* Fundamental common data types */ -#include "acexcep.h" /* ACPI exception codes */ -#include "acmacros.h" /* C macros */ -#include "actbl.h" /* ACPI table definitions */ -#include "aclocal.h" /* Internal data types */ -#include "acoutput.h" /* Error output and Debug macros */ -#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer*/ -#include "acpixf.h" /* ACPI core subsystem external interfaces */ -#include "acobject.h" /* ACPI internal object */ -#include "acstruct.h" /* Common structures */ -#include "acglobal.h" /* All global variables */ -#include "achware.h" /* Hardware defines and interfaces */ -#include "accommon.h" /* Common interfaces */ -#include "acresrc.h" /* Resource Manager function prototypes */ -#include "acparser.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acevents.h" -#include "actables.h" -#include "acdispat.h" -#include -#include -#include -#include -#include -#include -#include - -#endif /* __ACPI_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acpiosxf.h b/reactos/drivers/bus/acpi/include/acpiosxf.h deleted file mode 100644 index f65e03846b1..00000000000 --- a/reactos/drivers/bus/acpi/include/acpiosxf.h +++ /dev/null @@ -1,341 +0,0 @@ - -/****************************************************************************** - * - * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These - * interfaces must be implemented by OSL to interface the - * ACPI components to the host operating system. - * - *****************************************************************************/ - - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACPIOSXF_H__ -#define __ACPIOSXF_H__ - -#include "platform/acenv.h" -#include "actypes.h" - - -/* Priorities for Acpi_os_queue_for_execution */ - -#define OSD_PRIORITY_GPE 1 -#define OSD_PRIORITY_HIGH 2 -#define OSD_PRIORITY_MED 3 -#define OSD_PRIORITY_LO 4 - -#define ACPI_NO_UNIT_LIMIT ((u32) -1) -#define ACPI_MUTEX_SEM 1 - - -/* - * Types specific to the OS service interfaces - */ - -typedef -u32 (*OSD_HANDLER) ( - void *context); - -typedef -void (*OSD_EXECUTION_CALLBACK) ( - void *context); - - -/* - * OSL Initialization and shutdown primitives - */ - -ACPI_STATUS -acpi_os_initialize ( - void); - -ACPI_STATUS -acpi_os_terminate ( - void); - - -/* - * Synchronization primitives - */ - -ACPI_STATUS -acpi_os_create_semaphore ( - u32 max_units, - u32 initial_units, - ACPI_HANDLE *out_handle); - -ACPI_STATUS -acpi_os_delete_semaphore ( - ACPI_HANDLE handle); - -ACPI_STATUS -acpi_os_wait_semaphore ( - ACPI_HANDLE handle, - u32 units, - u32 timeout); - -ACPI_STATUS -acpi_os_signal_semaphore ( - ACPI_HANDLE handle, - u32 units); - - -/* - * Memory allocation and mapping - */ - -void * -acpi_os_allocate ( - u32 size); - -void * -acpi_os_callocate ( - u32 size); - -void -acpi_os_free ( - void * memory); - -ACPI_STATUS -acpi_os_map_memory ( - ACPI_PHYSICAL_ADDRESS physical_address, - u32 length, - void **logical_address); - -void -acpi_os_unmap_memory ( - void *logical_address, - u32 length); - -ACPI_STATUS -acpi_os_get_physical_address ( - void *logical_address, - ACPI_PHYSICAL_ADDRESS *physical_address); - - -/* - * Interrupt handlers - */ - -ACPI_STATUS -acpi_os_install_interrupt_handler ( - u32 interrupt_number, - OSD_HANDLER service_routine, - void *context); - -ACPI_STATUS -acpi_os_remove_interrupt_handler ( - u32 interrupt_number, - OSD_HANDLER service_routine); - - -/* - * Threads and Scheduling - */ - -u32 -acpi_os_get_thread_id ( - void); - -ACPI_STATUS -acpi_os_queue_for_execution ( - u32 priority, - OSD_EXECUTION_CALLBACK function, - void *context); - -void -acpi_os_sleep ( - u32 seconds, - u32 milliseconds); - -void -acpi_os_sleep_usec ( - u32 microseconds); - - -/* - * Platform/Hardware independent I/O interfaces - */ - -u8 -acpi_os_in8 ( - ACPI_IO_ADDRESS in_port); - - -u16 -acpi_os_in16 ( - ACPI_IO_ADDRESS in_port); - -u32 -acpi_os_in32 ( - ACPI_IO_ADDRESS in_port); - -void -acpi_os_out8 ( - ACPI_IO_ADDRESS out_port, - u8 value); - -void -acpi_os_out16 ( - ACPI_IO_ADDRESS out_port, - u16 value); - -void -acpi_os_out32 ( - ACPI_IO_ADDRESS out_port, - u32 value); - - -/* - * Platform/Hardware independent physical memory interfaces - */ - -u8 -acpi_os_mem_in8 ( - ACPI_PHYSICAL_ADDRESS in_addr); - -u16 -acpi_os_mem_in16 ( - ACPI_PHYSICAL_ADDRESS in_addr); - -u32 -acpi_os_mem_in32 ( - ACPI_PHYSICAL_ADDRESS in_addr); - -void -acpi_os_mem_out8 ( - ACPI_PHYSICAL_ADDRESS out_addr, - u8 value); - -void -acpi_os_mem_out16 ( - ACPI_PHYSICAL_ADDRESS out_addr, - u16 value); - -void -acpi_os_mem_out32 ( - ACPI_PHYSICAL_ADDRESS out_addr, - u32 value); - - -/* - * Standard access to PCI configuration space - */ - -ACPI_STATUS -acpi_os_read_pci_cfg_byte ( - u32 bus, - u32 device_function, - u32 register, - u8 *value); - -ACPI_STATUS -acpi_os_read_pci_cfg_word ( - u32 bus, - u32 device_function, - u32 register, - u16 *value); - -ACPI_STATUS -acpi_os_read_pci_cfg_dword ( - u32 bus, - u32 device_function, - u32 register, - u32 *value); - -ACPI_STATUS -acpi_os_write_pci_cfg_byte ( - u32 bus, - u32 device_function, - u32 register, - u8 value); - -ACPI_STATUS -acpi_os_write_pci_cfg_word ( - u32 bus, - u32 device_function, - u32 register, - u16 value); - - -ACPI_STATUS -acpi_os_write_pci_cfg_dword ( - u32 bus, - u32 device_function, - u32 register, - u32 value); - - -/* - * Miscellaneous - */ - -ACPI_STATUS -acpi_os_breakpoint ( - NATIVE_CHAR *message); - -u8 -acpi_os_readable ( - void *pointer, - u32 length); - - -u8 -acpi_os_writable ( - void *pointer, - u32 length); - - -/* - * Debug print routines - */ - -s32 -acpi_os_printf ( - const NATIVE_CHAR *format, - ...); - -s32 -acpi_os_vprintf ( - const NATIVE_CHAR *format, - va_list args); - - -/* - * Debug input - */ - -u32 -acpi_os_get_line ( - NATIVE_CHAR *buffer); - - -/* - * Debug - */ - -void -acpi_os_dbg_assert( - void *failed_assertion, - void *file_name, - u32 line_number, - NATIVE_CHAR *message); - - -#endif /* __ACPIOSXF_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acpixf.h b/reactos/drivers/bus/acpi/include/acpixf.h deleted file mode 100644 index ef4b1dca32c..00000000000 --- a/reactos/drivers/bus/acpi/include/acpixf.h +++ /dev/null @@ -1,340 +0,0 @@ - -/****************************************************************************** - * - * Name: acpixf.h - External interfaces to the ACPI subsystem - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef __ACXFACE_H__ -#define __ACXFACE_H__ - -#include "actypes.h" -#include "actbl.h" - - -/* - * Global interfaces - */ - -ACPI_STATUS -acpi_initialize_subsystem ( - void); - -ACPI_STATUS -acpi_enable_subsystem ( - u32 flags); - -ACPI_STATUS -acpi_terminate ( - void); - -ACPI_STATUS -acpi_enable ( - void); - -ACPI_STATUS -acpi_disable ( - void); - -ACPI_STATUS -acpi_get_system_info( - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_format_exception ( - ACPI_STATUS exception, - ACPI_BUFFER *out_buffer); - - -/* - * ACPI Memory manager - */ - -void * -acpi_allocate ( - u32 size); - -void * -acpi_callocate ( - u32 size); - -void -acpi_free ( - void *address); - - -/* - * ACPI table manipulation interfaces - */ - -ACPI_STATUS -acpi_find_root_pointer ( - ACPI_PHYSICAL_ADDRESS *rsdp_physical_address); - -ACPI_STATUS -acpi_load_tables ( - ACPI_PHYSICAL_ADDRESS rsdp_physical_address); - -ACPI_STATUS -acpi_load_table ( - ACPI_TABLE_HEADER *table_ptr); - -ACPI_STATUS -acpi_unload_table ( - ACPI_TABLE_TYPE table_type); - -ACPI_STATUS -acpi_get_table_header ( - ACPI_TABLE_TYPE table_type, - u32 instance, - ACPI_TABLE_HEADER *out_table_header); - -ACPI_STATUS -acpi_get_table ( - ACPI_TABLE_TYPE table_type, - u32 instance, - ACPI_BUFFER *ret_buffer); - - -/* - * Namespace and name interfaces - */ - -ACPI_STATUS -acpi_walk_namespace ( - ACPI_OBJECT_TYPE type, - ACPI_HANDLE start_object, - u32 max_depth, - WALK_CALLBACK user_function, - void *context, - void * *return_value); - -ACPI_STATUS -acpi_get_devices ( - NATIVE_CHAR *HID, - WALK_CALLBACK user_function, - void *context, - void **return_value); - -ACPI_STATUS -acpi_get_name ( - ACPI_HANDLE handle, - u32 name_type, - ACPI_BUFFER *ret_path_ptr); - -ACPI_STATUS -acpi_get_handle ( - ACPI_HANDLE parent, - ACPI_STRING pathname, - ACPI_HANDLE *ret_handle); - - -/* - * Object manipulation and enumeration - */ - -ACPI_STATUS -acpi_evaluate_object ( - ACPI_HANDLE object, - ACPI_STRING pathname, - ACPI_OBJECT_LIST *parameter_objects, - ACPI_BUFFER *return_object_buffer); - -ACPI_STATUS -acpi_get_object_info ( - ACPI_HANDLE device, - ACPI_DEVICE_INFO *info); - -ACPI_STATUS -acpi_get_next_object ( - ACPI_OBJECT_TYPE type, - ACPI_HANDLE parent, - ACPI_HANDLE child, - ACPI_HANDLE *out_handle); - -ACPI_STATUS -acpi_get_type ( - ACPI_HANDLE object, - ACPI_OBJECT_TYPE *out_type); - -ACPI_STATUS -acpi_get_parent ( - ACPI_HANDLE object, - ACPI_HANDLE *out_handle); - - -/* - * Event handler interfaces - */ - -ACPI_STATUS -acpi_install_fixed_event_handler ( - u32 acpi_event, - FIXED_EVENT_HANDLER handler, - void *context); - -ACPI_STATUS -acpi_remove_fixed_event_handler ( - u32 acpi_event, - FIXED_EVENT_HANDLER handler); - -ACPI_STATUS -acpi_install_notify_handler ( - ACPI_HANDLE device, - u32 handler_type, - NOTIFY_HANDLER handler, - void *context); - -ACPI_STATUS -acpi_remove_notify_handler ( - ACPI_HANDLE device, - u32 handler_type, - NOTIFY_HANDLER handler); - -ACPI_STATUS -acpi_install_address_space_handler ( - ACPI_HANDLE device, - ACPI_ADDRESS_SPACE_TYPE space_id, - ADDRESS_SPACE_HANDLER handler, - ADDRESS_SPACE_SETUP setup, - void *context); - -ACPI_STATUS -acpi_remove_address_space_handler ( - ACPI_HANDLE device, - ACPI_ADDRESS_SPACE_TYPE space_id, - ADDRESS_SPACE_HANDLER handler); - -ACPI_STATUS -acpi_install_gpe_handler ( - u32 gpe_number, - u32 type, - GPE_HANDLER handler, - void *context); - -ACPI_STATUS -acpi_acquire_global_lock ( - void); - -ACPI_STATUS -acpi_release_global_lock ( - void); - -ACPI_STATUS -acpi_remove_gpe_handler ( - u32 gpe_number, - GPE_HANDLER handler); - -ACPI_STATUS -acpi_enable_event ( - u32 acpi_event, - u32 type); - -ACPI_STATUS -acpi_disable_event ( - u32 acpi_event, - u32 type); - -ACPI_STATUS -acpi_clear_event ( - u32 acpi_event, - u32 type); - -ACPI_STATUS -acpi_get_event_status ( - u32 acpi_event, - u32 type, - ACPI_EVENT_STATUS *event_status); - -/* - * Resource interfaces - */ - -ACPI_STATUS -acpi_get_current_resources( - ACPI_HANDLE device_handle, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_get_possible_resources( - ACPI_HANDLE device_handle, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_set_current_resources ( - ACPI_HANDLE device_handle, - ACPI_BUFFER *in_buffer); - -ACPI_STATUS -acpi_get_irq_routing_table ( - ACPI_HANDLE bus_device_handle, - ACPI_BUFFER *ret_buffer); - - -/* - * Hardware (ACPI device) interfaces - */ - -ACPI_STATUS -acpi_set_firmware_waking_vector ( - ACPI_PHYSICAL_ADDRESS physical_address); - -ACPI_STATUS -acpi_get_firmware_waking_vector ( - ACPI_PHYSICAL_ADDRESS *physical_address); - -ACPI_STATUS -acpi_enter_sleep_state ( - u8 sleep_state); - -ACPI_STATUS -acpi_get_processor_throttling_info ( - ACPI_HANDLE processor_handle, - ACPI_BUFFER *user_buffer); - -ACPI_STATUS -acpi_set_processor_throttling_state ( - ACPI_HANDLE processor_handle, - u32 throttle_state); - -ACPI_STATUS -acpi_get_processor_throttling_state ( - ACPI_HANDLE processor_handle, - u32 *throttle_state); - -ACPI_STATUS -acpi_get_processor_cx_info ( - ACPI_HANDLE processor_handle, - ACPI_BUFFER *user_buffer); - -ACPI_STATUS -acpi_set_processor_sleep_state ( - ACPI_HANDLE processor_handle, - u32 cx_state); - -ACPI_STATUS -acpi_processor_sleep ( - ACPI_HANDLE processor_handle, - u32 *pm_timer_ticks); - - -#endif /* __ACXFACE_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acresrc.h b/reactos/drivers/bus/acpi/include/acresrc.h deleted file mode 100644 index 239d1f989c9..00000000000 --- a/reactos/drivers/bus/acpi/include/acresrc.h +++ /dev/null @@ -1,304 +0,0 @@ -/****************************************************************************** - * - * Name: acresrc.h - Resource Manager function prototypes - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACRESRC_H__ -#define __ACRESRC_H__ - - -/* - * Function prototypes called from Acpi* APIs - */ - -ACPI_STATUS -acpi_rs_get_prt_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer); - - -ACPI_STATUS -acpi_rs_get_crs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_rs_get_prs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_rs_set_srs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_rs_create_resource_list ( - ACPI_OPERAND_OBJECT *byte_stream_buffer, - u8 *output_buffer, - u32 *output_buffer_length); - -ACPI_STATUS -acpi_rs_create_byte_stream ( - RESOURCE *linked_list_buffer, - u8 *output_buffer, - u32 *output_buffer_length); - -ACPI_STATUS -acpi_rs_create_pci_routing_table ( - ACPI_OPERAND_OBJECT *method_return_object, - u8 *output_buffer, - u32 *output_buffer_length); - - -/* - *Function prototypes called from Acpi_rs_create*APIs - */ - -void -acpi_rs_dump_resource_list ( - RESOURCE *resource); - -void -acpi_rs_dump_irq_list ( - u8 *route_table); - -ACPI_STATUS -acpi_rs_get_byte_stream_start ( - u8 *byte_stream_buffer, - u8 **byte_stream_start, - u32 *size); - -ACPI_STATUS -acpi_rs_calculate_list_length ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - u32 *size_needed); - -ACPI_STATUS -acpi_rs_calculate_byte_stream_length ( - RESOURCE *linked_list_buffer, - u32 *size_needed); - -ACPI_STATUS -acpi_rs_calculate_pci_routing_table_length ( - ACPI_OPERAND_OBJECT *package_object, - u32 *buffer_size_needed); - -ACPI_STATUS -acpi_rs_byte_stream_to_list ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - u8 **output_buffer); - -ACPI_STATUS -acpi_rs_list_to_byte_stream ( - RESOURCE *linked_list, - u32 byte_stream_size_needed, - u8 **output_buffer); - -ACPI_STATUS -acpi_rs_io_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_fixed_io_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_io_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_fixed_io_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_irq_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_irq_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_dma_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_dma_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_address16_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_address16_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_address32_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_address32_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_start_dependent_functions_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_end_dependent_functions_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_start_dependent_functions_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_end_dependent_functions_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_memory24_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_memory24_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_memory32_range_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size -); - -ACPI_STATUS -acpi_rs_fixed_memory32_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_memory32_range_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_fixed_memory32_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_extended_irq_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_extended_irq_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_end_tag_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_end_tag_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_vendor_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_vendor_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - - -#endif /* __ACRESRC_H__ */ diff --git a/reactos/drivers/bus/acpi/include/acstruct.h b/reactos/drivers/bus/acpi/include/acstruct.h deleted file mode 100644 index c8abf99cbed..00000000000 --- a/reactos/drivers/bus/acpi/include/acstruct.h +++ /dev/null @@ -1,157 +0,0 @@ -/****************************************************************************** - * - * Name: acstruct.h - Internal structs - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACSTRUCT_H__ -#define __ACSTRUCT_H__ - - -/***************************************************************************** - * - * Tree walking typedefs and structs - * - ****************************************************************************/ - - -/* - * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through - * the tree (for whatever reason), and for control method execution. - */ - -#define NEXT_OP_DOWNWARD 1 -#define NEXT_OP_UPWARD 2 - -#define WALK_NON_METHOD 0 -#define WALK_METHOD 1 -#define WALK_METHOD_RESTART 2 - -typedef struct acpi_walk_state -{ - u8 data_type; /* To differentiate various internal objs */\ - ACPI_OWNER_ID owner_id; /* Owner of objects created during the walk */ - u8 last_predicate; /* Result of last predicate */ - u8 next_op_info; /* Info about Next_op */ - u8 num_operands; /* Stack pointer for Operands[] array */ - u8 current_result; /* */ - - struct acpi_walk_state *next; /* Next Walk_state in list */ - ACPI_PARSE_OBJECT *origin; /* Start of walk [Obsolete] */ - -/* TBD: Obsolete with removal of WALK procedure ? */ - ACPI_PARSE_OBJECT *prev_op; /* Last op that was processed */ - ACPI_PARSE_OBJECT *next_op; /* next op to be processed */ - - - ACPI_GENERIC_STATE *results; /* Stack of accumulated results */ - ACPI_GENERIC_STATE *control_state; /* List of control states (nested IFs) */ - ACPI_GENERIC_STATE *scope_info; /* Stack of nested scopes */ - ACPI_PARSE_STATE *parser_state; /* Current state of parser */ - u8 *aml_last_while; - ACPI_OPCODE_INFO *op_info; /* Info on current opcode */ - ACPI_PARSE_DOWNWARDS descending_callback; - ACPI_PARSE_UPWARDS ascending_callback; - - union acpi_operand_obj *return_desc; /* Return object, if any */ - union acpi_operand_obj *method_desc; /* Method descriptor if running a method */ - struct acpi_node *method_node; /* Method Node if running a method */ - ACPI_PARSE_OBJECT *method_call_op; /* Method_call Op if running a method */ - struct acpi_node *method_call_node; /* Called method Node*/ - union acpi_operand_obj *operands[OBJ_NUM_OPERANDS]; /* Operands passed to the interpreter */ - struct acpi_node arguments[MTH_NUM_ARGS]; /* Control method arguments */ - struct acpi_node local_variables[MTH_NUM_LOCALS]; /* Control method locals */ - struct acpi_walk_list *walk_list; - u32 parse_flags; - u8 walk_type; - u8 return_used; - u16 opcode; /* Current AML opcode */ - u32 prev_arg_types; - u16 current_sync_level; /* Mutex Sync (nested acquire) level */ - - /* Debug support */ - - u32 method_breakpoint; - - -} ACPI_WALK_STATE; - - -/* - * Walk list - head of a tree of walk states. Multiple walk states are created when there - * are nested control methods executing. - */ -typedef struct acpi_walk_list -{ - - ACPI_WALK_STATE *walk_state; - ACPI_OBJECT_MUTEX acquired_mutex_list; /* List of all currently acquired mutexes */ - -} ACPI_WALK_LIST; - - -/* Info used by Acpi_ps_init_objects */ - -typedef struct acpi_init_walk_info -{ - u16 method_count; - u16 op_region_count; - u16 field_count; - u16 op_region_init; - u16 field_init; - u16 object_count; - ACPI_TABLE_DESC *table_desc; - -} ACPI_INIT_WALK_INFO; - - -/* Info used by TBD */ - -typedef struct acpi_device_walk_info -{ - u16 device_count; - u16 num_STA; - u16 num_INI; - ACPI_TABLE_DESC *table_desc; - -} ACPI_DEVICE_WALK_INFO; - - -/* TBD: [Restructure] Merge with struct above */ - -typedef struct acpi_walk_info -{ - u32 debug_level; - u32 owner_id; - -} ACPI_WALK_INFO; - -typedef struct acpi_get_devices_info -{ - WALK_CALLBACK user_function; - void *context; - NATIVE_CHAR *hid; - -} ACPI_GET_DEVICES_INFO; - - -#endif diff --git a/reactos/drivers/bus/acpi/include/actables.h b/reactos/drivers/bus/acpi/include/actables.h deleted file mode 100644 index c70208485be..00000000000 --- a/reactos/drivers/bus/acpi/include/actables.h +++ /dev/null @@ -1,185 +0,0 @@ -/****************************************************************************** - * - * Name: actables.h - ACPI table management - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACTABLES_H__ -#define __ACTABLES_H__ - - -/* Used in Acpi_tb_map_acpi_table for size parameter if table header is to be used */ - -#define SIZE_IN_HEADER 0 - - -ACPI_STATUS -acpi_tb_handle_to_object ( - u16 table_id, - ACPI_TABLE_DESC **table_desc); - -/* - * tbconvrt - Table conversion routines - */ - -ACPI_STATUS -acpi_tb_convert_to_xsdt ( - ACPI_TABLE_DESC *table_info, - u32 *number_of_tables); - -ACPI_STATUS -acpi_tb_convert_table_fadt ( - void); - -ACPI_STATUS -acpi_tb_build_common_facs ( - ACPI_TABLE_DESC *table_info); - - -/* - * tbget - Table "get" routines - */ - -ACPI_STATUS -acpi_tb_get_table_ptr ( - ACPI_TABLE_TYPE table_type, - u32 instance, - ACPI_TABLE_HEADER **table_ptr_loc); - -ACPI_STATUS -acpi_tb_get_table ( - ACPI_PHYSICAL_ADDRESS physical_address, - ACPI_TABLE_HEADER *buffer_ptr, - ACPI_TABLE_DESC *table_info); - -ACPI_STATUS -acpi_tb_verify_rsdp ( - ACPI_PHYSICAL_ADDRESS RSDP_physical_address); - -ACPI_STATUS -acpi_tb_get_table_facs ( - ACPI_TABLE_HEADER *buffer_ptr, - ACPI_TABLE_DESC *table_info); - - -/* - * tbgetall - Get all firmware ACPI tables - */ - -ACPI_STATUS -acpi_tb_get_all_tables ( - u32 number_of_tables, - ACPI_TABLE_HEADER *buffer_ptr); - - -/* - * tbinstall - Table installation - */ - -ACPI_STATUS -acpi_tb_install_table ( - ACPI_TABLE_HEADER *table_ptr, - ACPI_TABLE_DESC *table_info); - -ACPI_STATUS -acpi_tb_recognize_table ( - ACPI_TABLE_HEADER *table_ptr, - ACPI_TABLE_DESC *table_info); - -ACPI_STATUS -acpi_tb_init_table_descriptor ( - ACPI_TABLE_TYPE table_type, - ACPI_TABLE_DESC *table_info); - - -/* - * tbremove - Table removal and deletion - */ - -void -acpi_tb_delete_acpi_tables ( - void); - -void -acpi_tb_delete_acpi_table ( - ACPI_TABLE_TYPE type); - -void -acpi_tb_delete_single_table ( - ACPI_TABLE_DESC *table_desc); - -ACPI_TABLE_DESC * -acpi_tb_uninstall_table ( - ACPI_TABLE_DESC *table_desc); - -void -acpi_tb_free_acpi_tables_of_type ( - ACPI_TABLE_DESC *table_info); - - -/* - * tbrsd - RSDP, RSDT utilities - */ - -ACPI_STATUS -acpi_tb_get_table_rsdt ( - u32 *number_of_tables); - -u8 * -acpi_tb_scan_memory_for_rsdp ( - u8 *start_address, - u32 length); - -ACPI_STATUS -acpi_tb_find_rsdp ( - ACPI_TABLE_DESC *table_info); - - -/* - * tbutils - common table utilities - */ - -u8 -acpi_tb_system_table_pointer ( - void *where); - -ACPI_STATUS -acpi_tb_map_acpi_table ( - ACPI_PHYSICAL_ADDRESS physical_address, - u32 *size, - void **logical_address); - -ACPI_STATUS -acpi_tb_verify_table_checksum ( - ACPI_TABLE_HEADER *table_header); - -u8 -acpi_tb_checksum ( - void *buffer, - u32 length); - -ACPI_STATUS -acpi_tb_validate_table_header ( - ACPI_TABLE_HEADER *table_header); - - -#endif /* __ACTABLES_H__ */ diff --git a/reactos/drivers/bus/acpi/include/actbl.h b/reactos/drivers/bus/acpi/include/actbl.h deleted file mode 100644 index 7472372e9fd..00000000000 --- a/reactos/drivers/bus/acpi/include/actbl.h +++ /dev/null @@ -1,217 +0,0 @@ -/****************************************************************************** - * - * Name: actbl.h - Table data structures defined in ACPI specification - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACTBL_H__ -#define __ACTBL_H__ - - -/* - * Values for description table header signatures - */ - -#define RSDP_NAME "RSDP" -#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ -#define APIC_SIG "APIC" /* Multiple APIC Description Table */ -#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ -#define FADT_SIG "FACP" /* Fixed ACPI Description Table */ -#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ -#define PSDT_SIG "PSDT" /* Persistent System Description Table */ -#define RSDT_SIG "RSDT" /* Root System Description Table */ -#define XSDT_SIG "XSDT" /* Extended System Description Table */ -#define SSDT_SIG "SSDT" /* Secondary System Description Table */ -#define SBST_SIG "SBST" /* Smart Battery Specification Table */ -#define SPIC_SIG "SPIC" /* iosapic table */ -#define BOOT_SIG "BOOT" /* Boot table */ - - -#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ - -/* values of Mapic.Model */ - -#define DUAL_PIC 0 -#define MULTIPLE_APIC 1 - -/* values of Type in APIC_HEADER */ - -#define APIC_PROC 0 -#define APIC_IO 1 - - -/* - * Common table types. The base code can remain - * constant if the underlying tables are changed - */ -#define RSDT_DESCRIPTOR RSDT_DESCRIPTOR_REV2 -#define XSDT_DESCRIPTOR XSDT_DESCRIPTOR_REV2 -#define FACS_DESCRIPTOR FACS_DESCRIPTOR_REV2 -#define FADT_DESCRIPTOR FADT_DESCRIPTOR_REV2 - - -#pragma pack(1) - -/* - * Architecture-independent tables - * The architecture dependent tables are in separate files - */ - -typedef struct /* Root System Descriptor Pointer */ -{ - NATIVE_CHAR signature [8]; /* contains "RSD PTR " */ - u8 checksum; /* to make sum of struct == 0 */ - NATIVE_CHAR oem_id [6]; /* OEM identification */ - u8 revision; /* Must be 0 for 1.0, 2 for 2.0 */ - u32 rsdt_physical_address; /* 32-bit physical address of RSDT */ - u32 length; /* XSDT Length in bytes including hdr */ - UINT64 xsdt_physical_address; /* 64-bit physical address of XSDT */ - u8 extended_checksum; /* Checksum of entire table */ - NATIVE_CHAR reserved [3]; /* reserved field must be 0 */ - -} RSDP_DESCRIPTOR; - - -typedef struct /* ACPI common table header */ -{ - NATIVE_CHAR signature [4]; /* identifies type of table */ - u32 length; /* length of table, in bytes, - * including header */ - u8 revision; /* specification minor version # */ - u8 checksum; /* to make sum of entire table == 0 */ - NATIVE_CHAR oem_id [6]; /* OEM identification */ - NATIVE_CHAR oem_table_id [8]; /* OEM table identification */ - u32 oem_revision; /* OEM revision number */ - NATIVE_CHAR asl_compiler_id [4]; /* ASL compiler vendor ID */ - u32 asl_compiler_revision; /* ASL compiler revision number */ - -} ACPI_TABLE_HEADER; - - -typedef struct /* Common FACS for internal use */ -{ - u32 *global_lock; - UINT64 *firmware_waking_vector; - u8 vector_width; - -} ACPI_COMMON_FACS; - - -typedef struct /* APIC Table */ -{ - ACPI_TABLE_HEADER header; /* table header */ - u32 local_apic_address; /* Physical address for accessing local APICs */ - u32 PCATcompat : 1; /* a one indicates system also has dual 8259s */ - u32 reserved1 : 31; - -} APIC_TABLE; - - -typedef struct /* APIC Header */ -{ - u8 type; /* APIC type. Either APIC_PROC or APIC_IO */ - u8 length; /* Length of APIC structure */ - -} APIC_HEADER; - - -typedef struct /* Processor APIC */ -{ - APIC_HEADER header; - u8 processor_apic_id; /* ACPI processor id */ - u8 local_apic_id; /* processor's local APIC id */ - u32 processor_enabled: 1; /* Processor is usable if set */ - u32 reserved1 : 32; - -} PROCESSOR_APIC; - - -typedef struct /* IO APIC */ -{ - APIC_HEADER header; - u8 io_apic_id; /* I/O APIC ID */ - u8 reserved; /* reserved - must be zero */ - u32 io_apic_address; /* APIC's physical address */ - u32 vector; /* interrupt vector index where INTI - * lines start */ -} IO_APIC; - - -/* -** IA64 TODO: Add SAPIC Tables -*/ - -/* -** IA64 TODO: Modify Smart Battery Description to comply with ACPI IA64 -** extensions. -*/ -typedef struct /* Smart Battery Description Table */ -{ - ACPI_TABLE_HEADER header; - u32 warning_level; - u32 low_level; - u32 critical_level; - -} SMART_BATTERY_DESCRIPTION_TABLE; - - -#pragma pack() - - -/* - * ACPI Table information. We save the table address, length, - * and type of memory allocation (mapped or allocated) for each - * table for 1) when we exit, and 2) if a new table is installed - */ - -#define ACPI_MEM_NOT_ALLOCATED 0 -#define ACPI_MEM_ALLOCATED 1 -#define ACPI_MEM_MAPPED 2 - -/* Definitions for the Flags bitfield member of ACPI_TABLE_SUPPORT */ - -#define ACPI_TABLE_SINGLE 0 -#define ACPI_TABLE_MULTIPLE 1 - - -/* Data about each known table type */ - -typedef struct _acpi_table_support -{ - NATIVE_CHAR *name; - NATIVE_CHAR *signature; - u8 sig_length; - u8 flags; - u16 status; - void **global_ptr; - -} ACPI_TABLE_SUPPORT; - -/* - * Get the architecture-specific tables - */ - -#include "actbl1.h" /* Acpi 1.0 table defintions */ -#include "actbl71.h" /* Acpi 0.71 IA-64 Extension table defintions */ -#include "actbl2.h" /* Acpi 2.0 table definitions */ - -#endif /* __ACTBL_H__ */ diff --git a/reactos/drivers/bus/acpi/include/actbl1.h b/reactos/drivers/bus/acpi/include/actbl1.h deleted file mode 100644 index 8cb88b459dc..00000000000 --- a/reactos/drivers/bus/acpi/include/actbl1.h +++ /dev/null @@ -1,123 +0,0 @@ -/****************************************************************************** - * - * Name: actbl1.h - ACPI 1.0 tables - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACTBL1_H__ -#define __ACTBL1_H__ - -#pragma pack(1) - -/*************************************/ -/* ACPI Specification Rev 1.0 for */ -/* the Root System Description Table */ -/*************************************/ -typedef struct -{ - ACPI_TABLE_HEADER header; /* Table header */ - u32 table_offset_entry [1]; /* Array of pointers to other */ - /* ACPI tables */ -} RSDT_DESCRIPTOR_REV1; - - -/***************************************/ -/* ACPI Specification Rev 1.0 for */ -/* the Firmware ACPI Control Structure */ -/***************************************/ -typedef struct -{ - NATIVE_CHAR signature[4]; /* signature "FACS" */ - u32 length; /* length of structure, in bytes */ - u32 hardware_signature; /* hardware configuration signature */ - u32 firmware_waking_vector; /* ACPI OS waking vector */ - u32 global_lock; /* Global Lock */ - u32 S4_bios_f : 1; /* Indicates if S4_bIOS support is present */ - u32 reserved1 : 31; /* must be 0 */ - u8 resverved3 [40]; /* reserved - must be zero */ - -} FACS_DESCRIPTOR_REV1; - - -/************************************/ -/* ACPI Specification Rev 1.0 for */ -/* the Fixed ACPI Description Table */ -/************************************/ -typedef struct -{ - ACPI_TABLE_HEADER header; /* table header */ - u32 firmware_ctrl; /* Physical address of FACS */ - u32 dsdt; /* Physical address of DSDT */ - u8 model; /* System Interrupt Model */ - u8 reserved1; /* reserved */ - u16 sci_int; /* System vector of SCI interrupt */ - u32 smi_cmd; /* Port address of SMI command port */ - u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ - u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ - u8 S4_bios_req; /* Value to write to SMI CMD to enter S4_bIOS state */ - u8 reserved2; /* reserved - must be zero */ - u32 pm1a_evt_blk; /* Port address of Power Mgt 1a Acpi_event Reg Blk */ - u32 pm1b_evt_blk; /* Port address of Power Mgt 1b Acpi_event Reg Blk */ - u32 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ - u32 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ - u32 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ - u32 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ - u32 gpe0blk; /* Port addr of General Purpose Acpi_event 0 Reg Blk */ - u32 gpe1_blk; /* Port addr of General Purpose Acpi_event 1 Reg Blk */ - u8 pm1_evt_len; /* Byte Length of ports at pm1_x_evt_blk */ - u8 pm1_cnt_len; /* Byte Length of ports at pm1_x_cnt_blk */ - u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ - u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ - u8 gpe0blk_len; /* Byte Length of ports at gpe0_blk */ - u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ - u8 gpe1_base; /* offset in gpe model where gpe1 events start */ - u8 reserved3; /* reserved */ - u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ - u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ - u16 flush_size; /* Size of area read to flush caches */ - u16 flush_stride; /* Stride used in flushing caches */ - u8 duty_offset; /* bit location of duty cycle field in p_cnt reg */ - u8 duty_width; /* bit width of duty cycle field in p_cnt reg */ - u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ - u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ - u8 century; /* index to century in RTC CMOS RAM */ - u8 reserved4; /* reserved */ - u8 reserved4a; /* reserved */ - u8 reserved4b; /* reserved */ - u32 wb_invd : 1; /* wbinvd instruction works properly */ - u32 wb_invd_flush : 1; /* wbinvd flushes but does not invalidate */ - u32 proc_c1 : 1; /* all processors support C1 state */ - u32 plvl2_up : 1; /* C2 state works on MP system */ - u32 pwr_button : 1; /* Power button is handled as a generic feature */ - u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ - u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ - u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ - u32 reserved5 : 23; /* reserved - must be zero */ - -} FADT_DESCRIPTOR_REV1; - -#pragma pack() - -#endif /* __ACTBL1_H__ */ - - diff --git a/reactos/drivers/bus/acpi/include/actbl2.h b/reactos/drivers/bus/acpi/include/actbl2.h deleted file mode 100644 index 8b6fe8f6e32..00000000000 --- a/reactos/drivers/bus/acpi/include/actbl2.h +++ /dev/null @@ -1,189 +0,0 @@ -/****************************************************************************** - * - * Name: actbl2.h - ACPI Specification Revision 2.0 Tables - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACTBL2_H__ -#define __ACTBL2_H__ - -/**************************************/ -/* Prefered Power Management Profiles */ -/**************************************/ -#define PM_UNSPECIFIED 0 -#define PM_DESKTOP 1 -#define PM_MOBILE 2 -#define PM_WORKSTATION 3 -#define PM_ENTERPRISE_SERVER 4 -#define PM_SOHO_SERVER 5 -#define PM_APPLIANCE_PC 6 - -/*********************************************/ -/* ACPI Boot Arch Flags, See spec Table 5-10 */ -/*********************************************/ -#define BAF_LEGACY_DEVICES 0x0001 -#define BAF_8042_KEYBOARD_CONTROLLER 0x0002 - -#define FADT2_REVISION_ID 3 - -#pragma pack(1) - -/*************************************/ -/* ACPI Specification Rev 2.0 for */ -/* the Root System Description Table */ -/*************************************/ -typedef struct -{ - ACPI_TABLE_HEADER header; /* Table header */ - u32 table_offset_entry [1]; /* Array of pointers to */ - /* other tables' headers */ -} RSDT_DESCRIPTOR_REV2; - - -/********************************************/ -/* ACPI Specification Rev 2.0 for the */ -/* Extended System Description Table (XSDT) */ -/********************************************/ -typedef struct -{ - ACPI_TABLE_HEADER header; /* Table header */ - UINT64 table_offset_entry [1]; /* Array of pointers to */ - /* other tables' headers */ -} XSDT_DESCRIPTOR_REV2; - -/***************************************/ -/* ACPI Specification Rev 2.0 for */ -/* the Firmware ACPI Control Structure */ -/***************************************/ -typedef struct -{ - NATIVE_CHAR signature[4]; /* signature "FACS" */ - u32 length; /* length of structure, in bytes */ - u32 hardware_signature; /* hardware configuration signature */ - u32 firmware_waking_vector; /* 32bit physical address of the Firmware Waking Vector. */ - u32 global_lock; /* Global Lock used to synchronize access to shared hardware resources */ - u32 S4_bios_f : 1; /* Indicates if S4_bIOS support is present */ - u32 reserved1 : 31; /* must be 0 */ - UINT64 Xfirmware_waking_vector; /* 64bit physical address of the Firmware Waking Vector. */ - u8 version; /* Version of this table */ - u8 reserved3 [31]; /* reserved - must be zero */ - -} FACS_DESCRIPTOR_REV2; - - -/***************************************/ -/* ACPI Specification Rev 2.0 for */ -/* the Generic Address Structure (GAS) */ -/***************************************/ -typedef struct -{ - u8 address_space_id; /* Address space where struct or register exists. */ - u8 register_bit_width; /* Size in bits of given register */ - u8 register_bit_offset; /* Bit offset within the register */ - u8 reserved; /* Must be 0 */ - UINT64 address; /* 64-bit address of struct or register */ - -} ACPI_GAS; - - -/************************************/ -/* ACPI Specification Rev 2.0 for */ -/* the Fixed ACPI Description Table */ -/************************************/ -typedef struct -{ - ACPI_TABLE_HEADER header; /* table header */ - u32 V1_firmware_ctrl; /* 32-bit physical address of FACS */ - u32 V1_dsdt; /* 32-bit physical address of DSDT */ - u8 reserved1; /* System Interrupt Model isn't used in ACPI 2.0*/ - u8 prefer_PM_profile; /* Conveys preferred power management profile to OSPM. */ - u16 sci_int; /* System vector of SCI interrupt */ - u32 smi_cmd; /* Port address of SMI command port */ - u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ - u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ - u8 S4_bios_req; /* Value to write to SMI CMD to enter S4_bIOS state */ - u8 pstate_cnt; /* processor performance state control*/ - u32 V1_pm1a_evt_blk; /* Port address of Power Mgt 1a Acpi_event Reg Blk */ - u32 V1_pm1b_evt_blk; /* Port address of Power Mgt 1b Acpi_event Reg Blk */ - u32 V1_pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ - u32 V1_pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ - u32 V1_pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ - u32 V1_pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ - u32 V1_gpe0blk; /* Port addr of General Purpose Acpi_event 0 Reg Blk */ - u32 V1_gpe1_blk; /* Port addr of General Purpose Acpi_event 1 Reg Blk */ - u8 pm1_evt_len; /* Byte Length of ports at pm1_x_evt_blk */ - u8 pm1_cnt_len; /* Byte Length of ports at pm1_x_cnt_blk */ - u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ - u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ - u8 gpe0blk_len; /* Byte Length of ports at gpe0_blk */ - u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ - u8 gpe1_base; /* offset in gpe model where gpe1 events start */ - u8 cst_cnt; /* Support for the _CST object and C States change notification.*/ - u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ - u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ - u16 flush_size; /* number of flush strides that need to be read */ - u16 flush_stride; /* Processor's memory cache line width, in bytes */ - u8 duty_offset; /* Processor_’s duty cycle index in processor's P_CNT reg*/ - u8 duty_width; /* Processor_’s duty cycle value bit width in P_CNT register.*/ - u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ - u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ - u8 century; /* index to century in RTC CMOS RAM */ - u16 iapc_boot_arch; /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/ - u8 reserved2; /* reserved */ - u32 wb_invd : 1; /* wbinvd instruction works properly */ - u32 wb_invd_flush : 1; /* wbinvd flushes but does not invalidate */ - u32 proc_c1 : 1; /* all processors support C1 state */ - u32 plvl2_up : 1; /* C2 state works on MP system */ - u32 pwr_button : 1; /* Power button is handled as a generic feature */ - u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ - u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ - u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ - u32 dock_cap : 1; /* Supports Docking */ - u32 reset_reg_sup : 1; /* Indicates system supports system reset via the FADT RESET_REG*/ - u32 sealed_case : 1; /* Indicates system has no internal expansion capabilities and case is sealed. */ - u32 headless : 1; /* Indicates system does not have local video capabilities or local input devices.*/ - u32 cpu_sw_sleep : 1; /* Indicates to OSPM that a processor native instruction */ - /* must be executed after writing the SLP_TYPx register. */ - u32 reserved6 : 18; /* reserved - must be zero */ - - ACPI_GAS reset_register; /* Reset register address in GAS format */ - u8 reset_value; /* Value to write to the Reset_register port to reset the system. */ - u8 reserved7[3]; /* These three bytes must be zero */ - UINT64 Xfirmware_ctrl; /* 64-bit physical address of FACS */ - UINT64 Xdsdt; /* 64-bit physical address of DSDT */ - ACPI_GAS Xpm1a_evt_blk; /* Extended Power Mgt 1a Acpi_event Reg Blk address */ - ACPI_GAS Xpm1b_evt_blk; /* Extended Power Mgt 1b Acpi_event Reg Blk address */ - ACPI_GAS Xpm1a_cnt_blk; /* Extended Power Mgt 1a Control Reg Blk address */ - ACPI_GAS Xpm1b_cnt_blk; /* Extended Power Mgt 1b Control Reg Blk address */ - ACPI_GAS Xpm2_cnt_blk; /* Extended Power Mgt 2 Control Reg Blk address */ - ACPI_GAS Xpm_tmr_blk; /* Extended Power Mgt Timer Ctrl Reg Blk address */ - ACPI_GAS Xgpe0blk; /* Extended General Purpose Acpi_event 0 Reg Blk address */ - ACPI_GAS Xgpe1_blk; /* Extended General Purpose Acpi_event 1 Reg Blk address */ - -} FADT_DESCRIPTOR_REV2; - - -#pragma pack() - -#endif /* __ACTBL2_H__ */ - diff --git a/reactos/drivers/bus/acpi/include/actbl71.h b/reactos/drivers/bus/acpi/include/actbl71.h deleted file mode 100644 index 0390d6f8de6..00000000000 --- a/reactos/drivers/bus/acpi/include/actbl71.h +++ /dev/null @@ -1,144 +0,0 @@ -/****************************************************************************** - * - * Name: actbl71.h - IA-64 Extensions to the ACPI Spec Rev. 0.71 - * This file includes tables specific to this - * specification revision. - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACTBL71_H__ -#define __ACTBL71_H__ - -/* 0.71 FADT Address_space data item bitmasks defines */ -/* If the associated bit is zero then it is in memory space else in io space */ -#define SMI_CMD_ADDRESS_SPACE 0x01 -#define PM1_BLK_ADDRESS_SPACE 0x02 -#define PM2_CNT_BLK_ADDRESS_SPACE 0x04 -#define PM_TMR_BLK_ADDRESS_SPACE 0x08 -#define GPE0_BLK_ADDRESS_SPACE 0x10 -#define GPE1_BLK_ADDRESS_SPACE 0x20 - -/* Only for clarity in declarations */ -typedef UINT64 IO_ADDRESS; - -#pragma pack(1) - -typedef struct /* Root System Descriptor Pointer */ -{ - NATIVE_CHAR signature [8]; /* contains "RSD PTR " */ - u8 checksum; /* to make sum of struct == 0 */ - NATIVE_CHAR oem_id [6]; /* OEM identification */ - u8 reserved; /* Must be 0 for 1.0, 2 for 2.0 */ - UINT64 rsdt_physical_address; /* 64-bit physical address of RSDT */ -} RSDP_DESCRIPTOR_REV071; - - -/*****************************************/ -/* IA64 Extensions to ACPI Spec Rev 0.71 */ -/* for the Root System Description Table */ -/*****************************************/ -typedef struct -{ - ACPI_TABLE_HEADER header; /* Table header */ - u32 reserved_pad; /* IA64 alignment, must be 0 */ - UINT64 table_offset_entry [1]; /* Array of pointers to other */ - /* tables' headers */ -} RSDT_DESCRIPTOR_REV071; - - -/*******************************************/ -/* IA64 Extensions to ACPI Spec Rev 0.71 */ -/* for the Firmware ACPI Control Structure */ -/*******************************************/ -typedef struct -{ - NATIVE_CHAR signature[4]; /* signature "FACS" */ - u32 length; /* length of structure, in bytes */ - u32 hardware_signature; /* hardware configuration signature */ - u32 reserved4; /* must be 0 */ - UINT64 firmware_waking_vector; /* ACPI OS waking vector */ - UINT64 global_lock; /* Global Lock */ - u32 S4_bios_f : 1; /* Indicates if S4_bIOS support is present */ - u32 reserved1 : 31; /* must be 0 */ - u8 reserved3 [28]; /* reserved - must be zero */ - -} FACS_DESCRIPTOR_REV071; - - -/******************************************/ -/* IA64 Extensions to ACPI Spec Rev 0.71 */ -/* for the Fixed ACPI Description Table */ -/******************************************/ -typedef struct -{ - ACPI_TABLE_HEADER header; /* table header */ - u32 reserved_pad; /* IA64 alignment, must be 0 */ - UINT64 firmware_ctrl; /* 64-bit Physical address of FACS */ - UINT64 dsdt; /* 64-bit Physical address of DSDT */ - u8 model; /* System Interrupt Model */ - u8 address_space; /* Address Space Bitmask */ - u16 sci_int; /* System vector of SCI interrupt */ - u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ - u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ - u8 S4_bios_req; /* Value to write to SMI CMD to enter S4_bIOS state */ - u8 reserved2; /* reserved - must be zero */ - UINT64 smi_cmd; /* Port address of SMI command port */ - UINT64 pm1a_evt_blk; /* Port address of Power Mgt 1a Acpi_event Reg Blk */ - UINT64 pm1b_evt_blk; /* Port address of Power Mgt 1b Acpi_event Reg Blk */ - UINT64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ - UINT64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ - UINT64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ - UINT64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ - UINT64 gpe0blk; /* Port addr of General Purpose Acpi_event 0 Reg Blk */ - UINT64 gpe1_blk; /* Port addr of General Purpose Acpi_event 1 Reg Blk */ - u8 pm1_evt_len; /* Byte Length of ports at pm1_x_evt_blk */ - u8 pm1_cnt_len; /* Byte Length of ports at pm1_x_cnt_blk */ - u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ - u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ - u8 gpe0blk_len; /* Byte Length of ports at gpe0_blk */ - u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ - u8 gpe1_base; /* offset in gpe model where gpe1 events start */ - u8 reserved3; /* reserved */ - u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ - u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ - u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ - u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ - u8 century; /* index to century in RTC CMOS RAM */ - u8 reserved4; /* reserved */ - u32 flush_cash : 1; /* PAL_FLUSH_CACHE is correctly supported */ - u32 reserved5 : 1; /* reserved - must be zero */ - u32 proc_c1 : 1; /* all processors support C1 state */ - u32 plvl2_up : 1; /* C2 state works on MP system */ - u32 pwr_button : 1; /* Power button is handled as a generic feature */ - u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ - u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ - u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ - u32 dock_cap : 1; /* Supports Docking */ - u32 reserved6 : 22; /* reserved - must be zero */ - -} FADT_DESCRIPTOR_REV071; - -#pragma pack() - -#endif /* __ACTBL71_H__ */ - diff --git a/reactos/drivers/bus/acpi/include/actypes.h b/reactos/drivers/bus/acpi/include/actypes.h deleted file mode 100644 index c2cc1125ebc..00000000000 --- a/reactos/drivers/bus/acpi/include/actypes.h +++ /dev/null @@ -1,1077 +0,0 @@ -/****************************************************************************** - * - * Name: actypes.h - Common data types for the entire ACPI subsystem - * $Revision: 1.5 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACTYPES_H__ -#define __ACTYPES_H__ - -/*! [Begin] no source code translation (keep the typedefs) */ - -/* - * Data types - Fixed across all compilation models - * - * BOOLEAN Logical Boolean. - * 1 byte value containing a 0 for FALSE or a 1 for TRUE. - * Other values are undefined. - * - * INT8 8-bit (1 byte) signed value - * UINT8 8-bit (1 byte) unsigned value - * INT16 16-bit (2 byte) signed value - * UINT16 16-bit (2 byte) unsigned value - * INT32 32-bit (4 byte) signed value - * UINT32 32-bit (4 byte) unsigned value - * INT64 64-bit (8 byte) signed value - * UINT64 64-bit (8 byte) unsigned value - * NATIVE_INT 32-bit on IA-32, 64-bit on IA-64 signed value - * NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value - * UCHAR Character. 1 byte unsigned value. - */ - - -#ifdef _IA64 -/* - * 64-bit type definitions - */ -typedef unsigned char UINT8; -typedef unsigned char BOOLEAN; -typedef unsigned char UCHAR; -typedef unsigned short UINT16; -typedef int INT32; -typedef unsigned int UINT32; -typedef COMPILER_DEPENDENT_UINT64 UINT64; - -typedef UINT64 NATIVE_UINT; -typedef INT64 NATIVE_INT; - -typedef NATIVE_UINT ACPI_TBLPTR; -typedef UINT64 ACPI_IO_ADDRESS; -typedef UINT64 ACPI_PHYSICAL_ADDRESS; - -#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 - -/* (No hardware alignment support in IA64) */ - - -#elif _IA16 -/* - * 16-bit type definitions - */ -typedef unsigned char UINT8; -typedef unsigned char BOOLEAN; -typedef unsigned char UCHAR; -typedef unsigned int UINT16; -typedef long INT32; -typedef int INT16; -typedef unsigned long UINT32; - -typedef struct -{ - UINT32 Lo; - UINT32 Hi; - -} UINT64; - -typedef UINT16 NATIVE_UINT; -typedef INT16 NATIVE_INT; - -typedef UINT32 ACPI_TBLPTR; -typedef UINT32 ACPI_IO_ADDRESS; -typedef char *ACPI_PHYSICAL_ADDRESS; - -#define ALIGNED_ADDRESS_BOUNDARY 0x00000002 -#define _HW_ALIGNMENT_SUPPORT - -/* - * (16-bit only) internal integers must be 32-bits, so - * 64-bit integers cannot be supported - */ -#define ACPI_NO_INTEGER64_SUPPORT - - -#else -/* - * 32-bit type definitions (default) - */ -//typedef unsigned char UINT8; -//typedef unsigned char BOOLEAN; -//typedef unsigned char UCHAR; -//typedef unsigned short UINT16; -//typedef int INT32; -//typedef unsigned int UINT32; -//typedef COMPILER_DEPENDENT_UINT64 UINT64; - -typedef UINT32 NATIVE_UINT; -typedef INT32 NATIVE_INT; - -typedef NATIVE_UINT ACPI_TBLPTR; -typedef UINT32 ACPI_IO_ADDRESS; -typedef UINT64 ACPI_PHYSICAL_ADDRESS; - -#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 -#define _HW_ALIGNMENT_SUPPORT -#endif - - - -/* - * Miscellaneous common types - */ - -typedef UINT32 UINT32_BIT; -typedef NATIVE_UINT ACPI_PTRDIFF; -typedef char NATIVE_CHAR; - - -/* - * Data type ranges - */ - -#define ACPI_UINT8_MAX (UINT8) 0xFF -#define ACPI_UINT16_MAX (UINT16) 0xFFFF -#define ACPI_UINT32_MAX (UINT32) 0xFFFFFFFF -#ifdef __GNUC__ -#define ACPI_UINT64_MAX (UINT64) 0xFFFFFFFFFFFFFFFFULL -#else -#define ACPI_UINT64_MAX (UINT64) 0xFFFFFFFFFFFFFFFF -#endif - -#ifdef DEFINE_ALTERNATE_TYPES -/* - * Types used only in translated source - */ -typedef INT32 s32; -typedef UINT8 u8; -typedef UINT16 u16; -typedef UINT32 u32; -typedef UINT64 u64; -#endif -/*! [End] no source code translation !*/ - - -/* - * Useful defines - */ - -#ifdef FALSE -#undef FALSE -#endif -#define FALSE (1 == 0) - -#ifdef TRUE -#undef TRUE -#endif -#define TRUE (1 == 1) - -#ifndef NULL -#define NULL (void *) 0 -#endif - - -/* - * Local datatypes - */ -#ifdef _MSC_VER -typedef ULONGLONG u64; -typedef ULONG u32; -typedef USHORT u16; -typedef UCHAR u8; -typedef LONGLONG s64; -typedef LONG s32; -typedef SHORT s16; -typedef CHAR s8; -#endif - -typedef u32 ACPI_STATUS; /* All ACPI Exceptions */ -typedef u32 ACPI_NAME; /* 4-s8 ACPI name */ -typedef char* ACPI_STRING; /* Null terminated ASCII string */ -typedef void* ACPI_HANDLE; /* Actually a ptr to an Node */ - - -/* - * Acpi integer width. In ACPI version 1, integers are - * 32 bits. In ACPI version 2, integers are 64 bits. - * Note that this pertains to the ACPI integer type only, not - * other integers used in the implementation of the ACPI CA - * subsystem. - */ -#ifdef ACPI_NO_INTEGER64_SUPPORT - -/* 32-bit integers only, no 64-bit support */ - -typedef u32 ACPI_INTEGER; -#define ACPI_INTEGER_MAX ACPI_UINT32_MAX -#define ACPI_INTEGER_BIT_SIZE 32 -#define ACPI_MAX_BCD_VALUE 99999999 -#define ACPI_MAX_BCD_DIGITS 8 - -#else - -/* 64-bit integers */ - -typedef UINT64 ACPI_INTEGER; -#define ACPI_INTEGER_MAX ACPI_UINT64_MAX -#define ACPI_INTEGER_BIT_SIZE 64 -#ifdef __GNUC__ -#define ACPI_MAX_BCD_VALUE 9999999999999999ULL -#else -#define ACPI_MAX_BCD_VALUE 9999999999999999 -#endif -#define ACPI_MAX_BCD_DIGITS 16 - -#endif - - -/* - * Constants with special meanings - */ - -#define ACPI_ROOT_OBJECT (ACPI_HANDLE)(-1) - -#define ACPI_FULL_INITIALIZATION 0x00 -#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 -#define ACPI_NO_HARDWARE_INIT 0x02 -#define ACPI_NO_EVENT_INIT 0x04 -#define ACPI_NO_ACPI_ENABLE 0x08 -#define ACPI_NO_DEVICE_INIT 0x10 -#define ACPI_NO_OBJECT_INIT 0x20 - - -/* - * System states - */ -#define ACPI_STATE_S0 (u8) 0 -#define ACPI_STATE_S1 (u8) 1 -#define ACPI_STATE_S2 (u8) 2 -#define ACPI_STATE_S3 (u8) 3 -#define ACPI_STATE_S4 (u8) 4 -#define ACPI_STATE_S5 (u8) 5 -/* let's pretend S4_bIOS didn't exist for now. ASG */ -#define ACPI_STATE_S4_bIOS (u8) 6 -#define ACPI_S_STATES_MAX ACPI_STATE_S5 -#define ACPI_S_STATE_COUNT 6 - -/* - * Device power states - */ -#define ACPI_STATE_D0 (u8) 0 -#define ACPI_STATE_D1 (u8) 1 -#define ACPI_STATE_D2 (u8) 2 -#define ACPI_STATE_D3 (u8) 3 -#define ACPI_D_STATES_MAX ACPI_STATE_D3 -#define ACPI_D_STATE_COUNT 4 - -#define ACPI_STATE_UNKNOWN (u8) 0xFF - - -/* - * Table types. These values are passed to the table related APIs - */ - -typedef u32 ACPI_TABLE_TYPE; - -#define ACPI_TABLE_RSDP (ACPI_TABLE_TYPE) 0 -#define ACPI_TABLE_DSDT (ACPI_TABLE_TYPE) 1 -#define ACPI_TABLE_FADT (ACPI_TABLE_TYPE) 2 -#define ACPI_TABLE_FACS (ACPI_TABLE_TYPE) 3 -#define ACPI_TABLE_PSDT (ACPI_TABLE_TYPE) 4 -#define ACPI_TABLE_SSDT (ACPI_TABLE_TYPE) 5 -#define ACPI_TABLE_XSDT (ACPI_TABLE_TYPE) 6 -#define ACPI_TABLE_MAX 6 -#define NUM_ACPI_TABLES (ACPI_TABLE_MAX+1) - - -/* - * Types associated with names. The first group of - * values correspond to the definition of the ACPI - * Object_type operator (See the ACPI Spec). Therefore, - * only add to the first group if the spec changes! - * - * Types must be kept in sync with the Acpi_ns_properties - * and Acpi_ns_type_names arrays - */ - -typedef u32 ACPI_OBJECT_TYPE; -typedef u8 OBJECT_TYPE_INTERNAL; - -#define ACPI_BTYPE_ANY 0x00000000 -#define ACPI_BTYPE_INTEGER 0x00000001 -#define ACPI_BTYPE_STRING 0x00000002 -#define ACPI_BTYPE_BUFFER 0x00000004 -#define ACPI_BTYPE_PACKAGE 0x00000008 -#define ACPI_BTYPE_FIELD_UNIT 0x00000010 -#define ACPI_BTYPE_DEVICE 0x00000020 -#define ACPI_BTYPE_EVENT 0x00000040 -#define ACPI_BTYPE_METHOD 0x00000080 -#define ACPI_BTYPE_MUTEX 0x00000100 -#define ACPI_BTYPE_REGION 0x00000200 -#define ACPI_BTYPE_POWER 0x00000400 -#define ACPI_BTYPE_PROCESSOR 0x00000800 -#define ACPI_BTYPE_THERMAL 0x00001000 -#define ACPI_BTYPE_BUFFER_FIELD 0x00002000 -#define ACPI_BTYPE_DDB_HANDLE 0x00004000 -#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 -#define ACPI_BTYPE_REFERENCE 0x00010000 -#define ACPI_BTYPE_RESOURCE 0x00020000 - -#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) - -#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) -#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) -#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) -#define ACPI_BTYPE_OBJECTS_AND_REFS 0x00017FFF /* ARG or LOCAL */ -#define ACPI_BTYPE_ALL_OBJECTS 0x00007FFF - - -#define ACPI_TYPE_ANY 0 /* 0x00 */ -#define ACPI_TYPE_INTEGER 1 /* 0x01 Byte/Word/Dword/Zero/One/Ones */ -#define ACPI_TYPE_STRING 2 /* 0x02 */ -#define ACPI_TYPE_BUFFER 3 /* 0x03 */ -#define ACPI_TYPE_PACKAGE 4 /* 0x04 Byte_const, multiple Data_term/Constant/Super_name */ -#define ACPI_TYPE_FIELD_UNIT 5 /* 0x05 */ -#define ACPI_TYPE_DEVICE 6 /* 0x06 Name, multiple Node */ -#define ACPI_TYPE_EVENT 7 /* 0x07 */ -#define ACPI_TYPE_METHOD 8 /* 0x08 Name, Byte_const, multiple Code */ -#define ACPI_TYPE_MUTEX 9 /* 0x09 */ -#define ACPI_TYPE_REGION 10 /* 0x0A */ -#define ACPI_TYPE_POWER 11 /* 0x0B Name,Byte_const,Word_const,multi Node */ -#define ACPI_TYPE_PROCESSOR 12 /* 0x0C Name,Byte_const,DWord_const,Byte_const,multi Nm_o */ -#define ACPI_TYPE_THERMAL 13 /* 0x0D Name, multiple Node */ -#define ACPI_TYPE_BUFFER_FIELD 14 /* 0x0E */ -#define ACPI_TYPE_DDB_HANDLE 15 /* 0x0F */ -#define ACPI_TYPE_DEBUG_OBJECT 16 /* 0x10 */ - -#define ACPI_TYPE_MAX 16 - -/* - * This section contains object types that do not relate to the ACPI Object_type operator. - * They are used for various internal purposes only. If new predefined ACPI_TYPEs are - * added (via the ACPI specification), these internal types must move upwards. - * Also, values exceeding the largest official ACPI Object_type must not overlap with - * defined AML opcodes. - */ -#define INTERNAL_TYPE_BEGIN 17 - -#define INTERNAL_TYPE_DEF_FIELD 17 /* 0x11 */ -#define INTERNAL_TYPE_BANK_FIELD 18 /* 0x12 */ -#define INTERNAL_TYPE_INDEX_FIELD 19 /* 0x13 */ -#define INTERNAL_TYPE_REFERENCE 20 /* 0x14 Arg#, Local#, Name, Debug; used only in descriptors */ -#define INTERNAL_TYPE_ALIAS 21 /* 0x15 */ -#define INTERNAL_TYPE_NOTIFY 22 /* 0x16 */ -#define INTERNAL_TYPE_ADDRESS_HANDLER 23 /* 0x17 */ -#define INTERNAL_TYPE_RESOURCE 24 /* 0x18 */ - - -#define INTERNAL_TYPE_NODE_MAX 24 - -/* These are pseudo-types because there are never any namespace nodes with these types */ - -#define INTERNAL_TYPE_DEF_FIELD_DEFN 25 /* 0x19 Name, Byte_const, multiple Field_element */ -#define INTERNAL_TYPE_BANK_FIELD_DEFN 26 /* 0x1A 2 Name,DWord_const,Byte_const,multi Field_element */ -#define INTERNAL_TYPE_INDEX_FIELD_DEFN 27 /* 0x1B 2 Name, Byte_const, multiple Field_element */ -#define INTERNAL_TYPE_IF 28 /* 0x1C */ -#define INTERNAL_TYPE_ELSE 29 /* 0x1D */ -#define INTERNAL_TYPE_WHILE 30 /* 0x1E */ -#define INTERNAL_TYPE_SCOPE 31 /* 0x1F Name, multiple Node */ -#define INTERNAL_TYPE_DEF_ANY 32 /* 0x20 type is Any, suppress search of enclosing scopes */ -#define INTERNAL_TYPE_EXTRA 33 /* 0x21 */ - -#define INTERNAL_TYPE_MAX 33 - -#define INTERNAL_TYPE_INVALID 34 -#define ACPI_TYPE_NOT_FOUND 0xFF - -/* - * Acpi_event Types: - * ------------ - * Fixed & general purpose... - */ - -typedef u32 ACPI_EVENT_TYPE; - -#define ACPI_EVENT_FIXED (ACPI_EVENT_TYPE) 0 -#define ACPI_EVENT_GPE (ACPI_EVENT_TYPE) 1 - -/* - * Fixed events - */ - -#define ACPI_EVENT_PMTIMER (ACPI_EVENT_TYPE) 0 - /* - * There's no bus master event so index 1 is used for IRQ's that are not - * handled by the SCI handler - */ -#define ACPI_EVENT_NOT_USED (ACPI_EVENT_TYPE) 1 -#define ACPI_EVENT_GLOBAL (ACPI_EVENT_TYPE) 2 -#define ACPI_EVENT_POWER_BUTTON (ACPI_EVENT_TYPE) 3 -#define ACPI_EVENT_SLEEP_BUTTON (ACPI_EVENT_TYPE) 4 -#define ACPI_EVENT_RTC (ACPI_EVENT_TYPE) 5 -#define ACPI_EVENT_GENERAL (ACPI_EVENT_TYPE) 6 -#define ACPI_EVENT_MAX 6 -#define NUM_FIXED_EVENTS (ACPI_EVENT_TYPE) 7 - -#define ACPI_GPE_INVALID 0xFF -#define ACPI_GPE_MAX 0xFF -#define NUM_GPE 256 - -#define ACPI_EVENT_LEVEL_TRIGGERED (ACPI_EVENT_TYPE) 1 -#define ACPI_EVENT_EDGE_TRIGGERED (ACPI_EVENT_TYPE) 2 - -/* - * Acpi_event Status: - * ------------- - * The encoding of ACPI_EVENT_STATUS is illustrated below. - * Note that a set bit (1) indicates the property is TRUE - * (e.g. if bit 0 is set then the event is enabled). - * +---------------+-+-+ - * | Bits 31:2 |1|0| - * +---------------+-+-+ - * | | | - * | | +- Enabled? - * | +--- Set? - * +----------- - */ -typedef u32 ACPI_EVENT_STATUS; - -#define ACPI_EVENT_FLAG_DISABLED (ACPI_EVENT_STATUS) 0x00 -#define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 -#define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x02 - - -/* Notify types */ - -#define ACPI_SYSTEM_NOTIFY 0 -#define ACPI_DEVICE_NOTIFY 1 -#define ACPI_MAX_NOTIFY_HANDLER_TYPE 1 - -#define MAX_SYS_NOTIFY 0x7f - - -/* Address Space (Operation Region) Types */ - -typedef u8 ACPI_ADDRESS_SPACE_TYPE; - -#define ADDRESS_SPACE_SYSTEM_MEMORY (ACPI_ADDRESS_SPACE_TYPE) 0 -#define ADDRESS_SPACE_SYSTEM_IO (ACPI_ADDRESS_SPACE_TYPE) 1 -#define ADDRESS_SPACE_PCI_CONFIG (ACPI_ADDRESS_SPACE_TYPE) 2 -#define ADDRESS_SPACE_EC (ACPI_ADDRESS_SPACE_TYPE) 3 -#define ADDRESS_SPACE_SMBUS (ACPI_ADDRESS_SPACE_TYPE) 4 -#define ADDRESS_SPACE_CMOS (ACPI_ADDRESS_SPACE_TYPE) 5 -#define ADDRESS_SPACE_PCI_BAR_TARGET (ACPI_ADDRESS_SPACE_TYPE) 6 - - -/* - * External ACPI object definition - */ - -typedef union acpi_obj -{ - ACPI_OBJECT_TYPE type; /* See definition of Acpi_ns_type for values */ - struct - { - ACPI_OBJECT_TYPE type; - ACPI_INTEGER value; /* The actual number */ - } integer; - - struct - { - ACPI_OBJECT_TYPE type; - u32 length; /* # of bytes in string, excluding trailing null */ - NATIVE_CHAR *pointer; /* points to the string value */ - } string; - - struct - { - ACPI_OBJECT_TYPE type; - u32 length; /* # of bytes in buffer */ - u8 *pointer; /* points to the buffer */ - } buffer; - - struct - { - ACPI_OBJECT_TYPE type; - u32 fill1; - ACPI_HANDLE handle; /* object reference */ - } reference; - - struct - { - ACPI_OBJECT_TYPE type; - u32 count; /* # of elements in package */ - union acpi_obj *elements; /* Pointer to an array of ACPI_OBJECTs */ - } package; - - struct - { - ACPI_OBJECT_TYPE type; - u32 proc_id; - ACPI_IO_ADDRESS pblk_address; - u32 pblk_length; - } processor; - - struct - { - ACPI_OBJECT_TYPE type; - u32 system_level; - u32 resource_order; - } power_resource; - -} ACPI_OBJECT, *PACPI_OBJECT; - - -/* - * List of objects, used as a parameter list for control method evaluation - */ - -typedef struct acpi_obj_list -{ - u32 count; - ACPI_OBJECT *pointer; - -} ACPI_OBJECT_LIST, *PACPI_OBJECT_LIST; - - -/* - * Miscellaneous common Data Structures used by the interfaces - */ - -typedef struct -{ - u32 length; /* Length in bytes of the buffer */ - void *pointer; /* pointer to buffer */ - -} ACPI_BUFFER; - - -/* - * Name_type for Acpi_get_name - */ - -#define ACPI_FULL_PATHNAME 0 -#define ACPI_SINGLE_NAME 1 -#define ACPI_NAME_TYPE_MAX 1 - - -/* - * Structure and flags for Acpi_get_system_info - */ - -#define SYS_MODE_UNKNOWN 0x0000 -#define SYS_MODE_ACPI 0x0001 -#define SYS_MODE_LEGACY 0x0002 -#define SYS_MODES_MASK 0x0003 - -/* - * ACPI CPU Cx state handler - */ -typedef -ACPI_STATUS (*ACPI_SET_C_STATE_HANDLER) ( - NATIVE_UINT pblk_address); - -/* - * ACPI Cx State info - */ -typedef struct -{ - u32 state_number; - u32 latency; -} ACPI_CX_STATE; - -/* - * ACPI CPU throttling info - */ -typedef struct -{ - u32 state_number; - u32 percent_of_clock; -} ACPI_CPU_THROTTLING_STATE; - -/* - * ACPI Table Info. One per ACPI table _type_ - */ -typedef struct acpi_table_info -{ - u32 count; - -} ACPI_TABLE_INFO; - - -/* - * System info returned by Acpi_get_system_info() - */ - -typedef struct _acpi_sys_info -{ - u32 acpi_ca_version; - u32 flags; - u32 timer_resolution; - u32 reserved1; - u32 reserved2; - u32 debug_level; - u32 debug_layer; - u32 num_table_types; - ACPI_TABLE_INFO table_info [NUM_ACPI_TABLES]; - -} ACPI_SYSTEM_INFO; - - -/* - * System Initiailization data. This data is passed to ACPIInitialize - * copyied to global data and retained by ACPI CA - */ - -typedef struct _acpi_init_data -{ - void *RSDP_physical_address; /* Address of RSDP, needed it it is */ - /* not found in the IA32 manner */ -} ACPI_INIT_DATA; - -/* - * Various handlers and callback procedures - */ - -typedef -u32 (*FIXED_EVENT_HANDLER) ( - void *context); - -typedef -void (*GPE_HANDLER) ( - void *context); - -typedef -void (*NOTIFY_HANDLER) ( - ACPI_HANDLE device, - u32 value, - void *context); - -#define ADDRESS_SPACE_READ 1 -#define ADDRESS_SPACE_WRITE 2 - -typedef -ACPI_STATUS (*ADDRESS_SPACE_HANDLER) ( - u32 function, - ACPI_PHYSICAL_ADDRESS address, - u32 bit_width, - u32 *value, - void *handler_context, - void *region_context); - -#define ACPI_DEFAULT_HANDLER ((ADDRESS_SPACE_HANDLER) NULL) - - -typedef -ACPI_STATUS (*ADDRESS_SPACE_SETUP) ( - ACPI_HANDLE region_handle, - u32 function, - void *handler_context, - void **region_context); - -#define ACPI_REGION_ACTIVATE 0 -#define ACPI_REGION_DEACTIVATE 1 - -typedef -ACPI_STATUS (*WALK_CALLBACK) ( - ACPI_HANDLE obj_handle, - u32 nesting_level, - void *context, - void **return_value); - - -/* Interrupt handler return values */ - -#define INTERRUPT_NOT_HANDLED 0x00 -#define INTERRUPT_HANDLED 0x01 - - -/* Structure and flags for Acpi_get_device_info */ - -#define ACPI_VALID_HID 0x1 -#define ACPI_VALID_UID 0x2 -#define ACPI_VALID_ADR 0x4 -#define ACPI_VALID_STA 0x8 - - -#define ACPI_COMMON_OBJ_INFO \ - ACPI_OBJECT_TYPE type; /* ACPI object type */ \ - ACPI_NAME name /* ACPI object Name */ - - -typedef struct -{ - ACPI_COMMON_OBJ_INFO; -} ACPI_OBJ_INFO_HEADER; - - -typedef struct -{ - ACPI_COMMON_OBJ_INFO; - - u32 valid; /* Are the next bits legit? */ - NATIVE_CHAR hardware_id [9]; /* _HID value if any */ - NATIVE_CHAR unique_id[9]; /* _UID value if any */ - ACPI_INTEGER address; /* _ADR value if any */ - u32 current_status; /* _STA value */ -} ACPI_DEVICE_INFO; - - -/* Context structs for address space handlers */ - -typedef struct -{ - u32 seg; - u32 bus; - u32 dev_func; -} PCI_HANDLER_CONTEXT; - - -typedef struct -{ - ACPI_PHYSICAL_ADDRESS mapped_physical_address; - u8 *mapped_logical_address; - u32 mapped_length; -} MEM_HANDLER_CONTEXT; - - -/* - * C-state handler - */ - -typedef ACPI_STATUS (*ACPI_C_STATE_HANDLER) (ACPI_IO_ADDRESS, u32*); - - -/* - * Definitions for Resource Attributes - */ - -/* - * Memory Attributes - */ -#define READ_ONLY_MEMORY (u8) 0x00 -#define READ_WRITE_MEMORY (u8) 0x01 - -#define NON_CACHEABLE_MEMORY (u8) 0x00 -#define CACHABLE_MEMORY (u8) 0x01 -#define WRITE_COMBINING_MEMORY (u8) 0x02 -#define PREFETCHABLE_MEMORY (u8) 0x03 - -/* - * IO Attributes - * The ISA IO ranges are: n000-n0FFh, n400-n4_fFh, n800-n8_fFh, n_c00-n_cFFh. - * The non-ISA IO ranges are: n100-n3_fFh, n500-n7_fFh, n900-n_bFFh, n_cD0-n_fFFh. - */ -#define NON_ISA_ONLY_RANGES (u8) 0x01 -#define ISA_ONLY_RANGES (u8) 0x02 -#define ENTIRE_RANGE (NON_ISA_ONLY_RANGES | ISA_ONLY_RANGES) - -/* - * IO Port Descriptor Decode - */ -#define DECODE_10 (u8) 0x00 /* 10-bit IO address decode */ -#define DECODE_16 (u8) 0x01 /* 16-bit IO address decode */ - -/* - * IRQ Attributes - */ -#define EDGE_SENSITIVE (u8) 0x00 -#define LEVEL_SENSITIVE (u8) 0x01 - -#define ACTIVE_HIGH (u8) 0x00 -#define ACTIVE_LOW (u8) 0x01 - -#define EXCLUSIVE (u8) 0x00 -#define SHARED (u8) 0x01 - -/* - * DMA Attributes - */ -#define COMPATIBILITY (u8) 0x00 -#define TYPE_A (u8) 0x01 -#define TYPE_B (u8) 0x02 -#define TYPE_F (u8) 0x03 - -#define NOT_BUS_MASTER (u8) 0x00 -#define BUS_MASTER (u8) 0x01 - -#define TRANSFER_8 (u8) 0x00 -#define TRANSFER_8_16 (u8) 0x01 -#define TRANSFER_16 (u8) 0x02 - -/* - * Start Dependent Functions Priority definitions - */ -#define GOOD_CONFIGURATION (u8) 0x00 -#define ACCEPTABLE_CONFIGURATION (u8) 0x01 -#define SUB_OPTIMAL_CONFIGURATION (u8) 0x02 - -/* - * 16, 32 and 64-bit Address Descriptor resource types - */ -#define MEMORY_RANGE (u8) 0x00 -#define IO_RANGE (u8) 0x01 -#define BUS_NUMBER_RANGE (u8) 0x02 - -#define ADDRESS_NOT_FIXED (u8) 0x00 -#define ADDRESS_FIXED (u8) 0x01 - -#define POS_DECODE (u8) 0x00 -#define SUB_DECODE (u8) 0x01 - -#define PRODUCER (u8) 0x00 -#define CONSUMER (u8) 0x01 - - -/* - * Structures used to describe device resources - */ -typedef struct -{ - u32 edge_level; - u32 active_high_low; - u32 shared_exclusive; - u32 number_of_interrupts; - u32 interrupts[1]; - -} IRQ_RESOURCE; - -typedef struct -{ - u32 type; - u32 bus_master; - u32 transfer; - u32 number_of_channels; - u32 channels[1]; - -} DMA_RESOURCE; - -typedef struct -{ - u32 compatibility_priority; - u32 performance_robustness; - -} START_DEPENDENT_FUNCTIONS_RESOURCE; - -/* - * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not - * needed because it has no fields - */ - -typedef struct -{ - u32 io_decode; - u32 min_base_address; - u32 max_base_address; - u32 alignment; - u32 range_length; - -} IO_RESOURCE; - -typedef struct -{ - u32 base_address; - u32 range_length; - -} FIXED_IO_RESOURCE; - -typedef struct -{ - u32 length; - u8 reserved[1]; - -} VENDOR_RESOURCE; - -typedef struct -{ - u32 read_write_attribute; - u32 min_base_address; - u32 max_base_address; - u32 alignment; - u32 range_length; - -} MEMORY24_RESOURCE; - -typedef struct -{ - u32 read_write_attribute; - u32 min_base_address; - u32 max_base_address; - u32 alignment; - u32 range_length; - -} MEMORY32_RESOURCE; - -typedef struct -{ - u32 read_write_attribute; - u32 range_base_address; - u32 range_length; - -} FIXED_MEMORY32_RESOURCE; - -typedef struct -{ - u16 cache_attribute; - u16 read_write_attribute; - -} MEMORY_ATTRIBUTE; - -typedef struct -{ - u16 range_attribute; - u16 reserved; - -} IO_ATTRIBUTE; - -typedef struct -{ - u16 reserved1; - u16 reserved2; - -} BUS_ATTRIBUTE; - -typedef union -{ - MEMORY_ATTRIBUTE memory; - IO_ATTRIBUTE io; - BUS_ATTRIBUTE bus; - -} ATTRIBUTE_DATA; - -typedef struct -{ - u32 resource_type; - u32 producer_consumer; - u32 decode; - u32 min_address_fixed; - u32 max_address_fixed; - ATTRIBUTE_DATA attribute; - u32 granularity; - u32 min_address_range; - u32 max_address_range; - u32 address_translation_offset; - u32 address_length; - u32 resource_source_index; - u32 resource_source_string_length; - NATIVE_CHAR resource_source[1]; - -} ADDRESS16_RESOURCE; - -typedef struct -{ - u32 resource_type; - u32 producer_consumer; - u32 decode; - u32 min_address_fixed; - u32 max_address_fixed; - ATTRIBUTE_DATA attribute; - u32 granularity; - u32 min_address_range; - u32 max_address_range; - u32 address_translation_offset; - u32 address_length; - u32 resource_source_index; - u32 resource_source_string_length; - NATIVE_CHAR resource_source[1]; - -} ADDRESS32_RESOURCE; - -typedef struct -{ - u32 producer_consumer; - u32 edge_level; - u32 active_high_low; - u32 shared_exclusive; - u32 number_of_interrupts; - u32 interrupts[1]; - u32 resource_source_index; - u32 resource_source_string_length; - NATIVE_CHAR resource_source[1]; - -} EXTENDED_IRQ_RESOURCE; - -typedef enum -{ - irq, - dma, - start_dependent_functions, - end_dependent_functions, - io, - fixed_io, - vendor_specific, - end_tag, - memory24, - memory32, - fixed_memory32, - address16, - address32, - extended_irq -} RESOURCE_TYPE; - -typedef union -{ - IRQ_RESOURCE irq; - DMA_RESOURCE dma; - START_DEPENDENT_FUNCTIONS_RESOURCE start_dependent_functions; - IO_RESOURCE io; - FIXED_IO_RESOURCE fixed_io; - VENDOR_RESOURCE vendor_specific; - MEMORY24_RESOURCE memory24; - MEMORY32_RESOURCE memory32; - FIXED_MEMORY32_RESOURCE fixed_memory32; - ADDRESS16_RESOURCE address16; - ADDRESS32_RESOURCE address32; - EXTENDED_IRQ_RESOURCE extended_irq; -} RESOURCE_DATA; - -typedef struct _resource_tag -{ - RESOURCE_TYPE id; - u32 length; - RESOURCE_DATA data; -} RESOURCE; - -#define RESOURCE_LENGTH 12 -#define RESOURCE_LENGTH_NO_DATA 8 - -#define NEXT_RESOURCE(res) (RESOURCE*)((u8*) res + res->length) - -/* - * END: Definitions for Resource Attributes - */ - - -typedef struct pci_routing_table -{ - u32 length; - u32 pin; - ACPI_INTEGER address; /* here for 64-bit alignment */ - u32 source_index; - NATIVE_CHAR source[4]; /* pad to 64 bits so sizeof() works in all cases */ - -} PCI_ROUTING_TABLE; - - -/* - * END: Definitions for PCI Routing tables - */ - -#endif /* __ACTYPES_H__ */ diff --git a/reactos/drivers/bus/acpi/include/amlcode.h b/reactos/drivers/bus/acpi/include/amlcode.h deleted file mode 100644 index 917722d897d..00000000000 --- a/reactos/drivers/bus/acpi/include/amlcode.h +++ /dev/null @@ -1,420 +0,0 @@ -/****************************************************************************** - * - * Name: amlcode.h - Definitions for AML, as included in "definition blocks" - * Declarations and definitions contained herein are derived - * directly from the ACPI specification. - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __AMLCODE_H__ -#define __AMLCODE_H__ - - -/* primary opcodes */ - -#define AML_NULL_CHAR (u16) 0x00 - -#define AML_ZERO_OP (u16) 0x00 -#define AML_ONE_OP (u16) 0x01 -#define AML_UNASSIGNED (u16) 0x02 -#define AML_ALIAS_OP (u16) 0x06 -#define AML_NAME_OP (u16) 0x08 -#define AML_BYTE_OP (u16) 0x0a -#define AML_WORD_OP (u16) 0x0b -#define AML_DWORD_OP (u16) 0x0c -#define AML_STRING_OP (u16) 0x0d -#define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */ -#define AML_SCOPE_OP (u16) 0x10 -#define AML_BUFFER_OP (u16) 0x11 -#define AML_PACKAGE_OP (u16) 0x12 -#define AML_VAR_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */ -#define AML_METHOD_OP (u16) 0x14 -#define AML_DUAL_NAME_PREFIX (u16) 0x2e -#define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f -#define AML_NAME_CHAR_SUBSEQ (u16) 0x30 -#define AML_NAME_CHAR_FIRST (u16) 0x41 -#define AML_OP_PREFIX (u16) 0x5b -#define AML_ROOT_PREFIX (u16) 0x5c -#define AML_PARENT_PREFIX (u16) 0x5e -#define AML_LOCAL_OP (u16) 0x60 -#define AML_LOCAL0 (u16) 0x60 -#define AML_LOCAL1 (u16) 0x61 -#define AML_LOCAL2 (u16) 0x62 -#define AML_LOCAL3 (u16) 0x63 -#define AML_LOCAL4 (u16) 0x64 -#define AML_LOCAL5 (u16) 0x65 -#define AML_LOCAL6 (u16) 0x66 -#define AML_LOCAL7 (u16) 0x67 -#define AML_ARG_OP (u16) 0x68 -#define AML_ARG0 (u16) 0x68 -#define AML_ARG1 (u16) 0x69 -#define AML_ARG2 (u16) 0x6a -#define AML_ARG3 (u16) 0x6b -#define AML_ARG4 (u16) 0x6c -#define AML_ARG5 (u16) 0x6d -#define AML_ARG6 (u16) 0x6e -#define AML_STORE_OP (u16) 0x70 -#define AML_REF_OF_OP (u16) 0x71 -#define AML_ADD_OP (u16) 0x72 -#define AML_CONCAT_OP (u16) 0x73 -#define AML_SUBTRACT_OP (u16) 0x74 -#define AML_INCREMENT_OP (u16) 0x75 -#define AML_DECREMENT_OP (u16) 0x76 -#define AML_MULTIPLY_OP (u16) 0x77 -#define AML_DIVIDE_OP (u16) 0x78 -#define AML_SHIFT_LEFT_OP (u16) 0x79 -#define AML_SHIFT_RIGHT_OP (u16) 0x7a -#define AML_BIT_AND_OP (u16) 0x7b -#define AML_BIT_NAND_OP (u16) 0x7c -#define AML_BIT_OR_OP (u16) 0x7d -#define AML_BIT_NOR_OP (u16) 0x7e -#define AML_BIT_XOR_OP (u16) 0x7f -#define AML_BIT_NOT_OP (u16) 0x80 -#define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81 -#define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82 -#define AML_DEREF_OF_OP (u16) 0x83 -#define AML_CONCAT_RES_OP (u16) 0x84 /* ACPI 2.0 */ -#define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */ -#define AML_NOTIFY_OP (u16) 0x86 -#define AML_SIZE_OF_OP (u16) 0x87 -#define AML_INDEX_OP (u16) 0x88 -#define AML_MATCH_OP (u16) 0x89 -#define AML_DWORD_FIELD_OP (u16) 0x8a -#define AML_WORD_FIELD_OP (u16) 0x8b -#define AML_BYTE_FIELD_OP (u16) 0x8c -#define AML_BIT_FIELD_OP (u16) 0x8d -#define AML_TYPE_OP (u16) 0x8e -#define AML_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */ -#define AML_LAND_OP (u16) 0x90 -#define AML_LOR_OP (u16) 0x91 -#define AML_LNOT_OP (u16) 0x92 -#define AML_LEQUAL_OP (u16) 0x93 -#define AML_LGREATER_OP (u16) 0x94 -#define AML_LLESS_OP (u16) 0x95 -#define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */ -#define AML_TO_DECSTRING_OP (u16) 0x97 /* ACPI 2.0 */ -#define AML_TO_HEXSTRING_OP (u16) 0x98 /* ACPI 2.0 */ -#define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */ -#define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */ -#define AML_COPY_OP (u16) 0x9d /* ACPI 2.0 */ -#define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */ -#define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */ -#define AML_IF_OP (u16) 0xa0 -#define AML_ELSE_OP (u16) 0xa1 -#define AML_WHILE_OP (u16) 0xa2 -#define AML_NOOP_OP (u16) 0xa3 -#define AML_RETURN_OP (u16) 0xa4 -#define AML_BREAK_OP (u16) 0xa5 -#define AML_BREAK_POINT_OP (u16) 0xcc -#define AML_ONES_OP (u16) 0xff - -/* prefixed opcodes */ - -#define AML_EXTOP (u16) 0x005b - - -#define AML_MUTEX_OP (u16) 0x5b01 -#define AML_EVENT_OP (u16) 0x5b02 -#define AML_SHIFT_RIGHT_BIT_OP (u16) 0x5b10 -#define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11 -#define AML_COND_REF_OF_OP (u16) 0x5b12 -#define AML_CREATE_FIELD_OP (u16) 0x5b13 -#define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */ -#define AML_LOAD_OP (u16) 0x5b20 -#define AML_STALL_OP (u16) 0x5b21 -#define AML_SLEEP_OP (u16) 0x5b22 -#define AML_ACQUIRE_OP (u16) 0x5b23 -#define AML_SIGNAL_OP (u16) 0x5b24 -#define AML_WAIT_OP (u16) 0x5b25 -#define AML_RESET_OP (u16) 0x5b26 -#define AML_RELEASE_OP (u16) 0x5b27 -#define AML_FROM_BCD_OP (u16) 0x5b28 -#define AML_TO_BCD_OP (u16) 0x5b29 -#define AML_UNLOAD_OP (u16) 0x5b2a -#define AML_REVISION_OP (u16) 0x5b30 -#define AML_DEBUG_OP (u16) 0x5b31 -#define AML_FATAL_OP (u16) 0x5b32 -#define AML_REGION_OP (u16) 0x5b80 -#define AML_DEF_FIELD_OP (u16) 0x5b81 -#define AML_DEVICE_OP (u16) 0x5b82 -#define AML_PROCESSOR_OP (u16) 0x5b83 -#define AML_POWER_RES_OP (u16) 0x5b84 -#define AML_THERMAL_ZONE_OP (u16) 0x5b85 -#define AML_INDEX_FIELD_OP (u16) 0x5b86 -#define AML_BANK_FIELD_OP (u16) 0x5b87 -#define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */ - - -/* Bogus opcodes (they are actually two separate opcodes) */ - -#define AML_LGREATEREQUAL_OP (u16) 0x9295 -#define AML_LLESSEQUAL_OP (u16) 0x9294 -#define AML_LNOTEQUAL_OP (u16) 0x9293 - - -/* - * Internal opcodes - * Use only "Unknown" AML opcodes, don't attempt to use - * any valid ACPI ASCII values (A-Z, 0-9, '-') - */ - -#define AML_NAMEPATH_OP (u16) 0x002d -#define AML_NAMEDFIELD_OP (u16) 0x0030 -#define AML_RESERVEDFIELD_OP (u16) 0x0031 -#define AML_ACCESSFIELD_OP (u16) 0x0032 -#define AML_BYTELIST_OP (u16) 0x0033 -#define AML_STATICSTRING_OP (u16) 0x0034 -#define AML_METHODCALL_OP (u16) 0x0035 -#define AML_RETURN_VALUE_OP (u16) 0x0036 - - -#define ARG_NONE 0x0 - -/* - * Argument types for the AML Parser - * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments. - * There can be up to 31 unique argument types - */ - -#define ARGP_BYTEDATA 0x01 -#define ARGP_BYTELIST 0x02 -#define ARGP_CHARLIST 0x03 -#define ARGP_DATAOBJ 0x04 -#define ARGP_DATAOBJLIST 0x05 -#define ARGP_DWORDDATA 0x06 -#define ARGP_FIELDLIST 0x07 -#define ARGP_NAME 0x08 -#define ARGP_NAMESTRING 0x09 -#define ARGP_OBJLIST 0x0A -#define ARGP_PKGLENGTH 0x0B -#define ARGP_SUPERNAME 0x0C -#define ARGP_TARGET 0x0D -#define ARGP_TERMARG 0x0E -#define ARGP_TERMLIST 0x0F -#define ARGP_WORDDATA 0x10 -#define ARGP_QWORDDATA 0x11 -#define ARGP_SIMPLENAME 0x12 - -/* - * Resolved argument types for the AML Interpreter - * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments. - * There can be up to 31 unique argument types (0 is end-of-arg-list indicator) - */ - -/* "Standard" ACPI types are 1-15 (0x0F) */ - -#define ARGI_INTEGER ACPI_TYPE_INTEGER /* 1 */ -#define ARGI_STRING ACPI_TYPE_STRING /* 2 */ -#define ARGI_BUFFER ACPI_TYPE_BUFFER /* 3 */ -#define ARGI_PACKAGE ACPI_TYPE_PACKAGE /* 4 */ -#define ARGI_EVENT ACPI_TYPE_EVENT -#define ARGI_MUTEX ACPI_TYPE_MUTEX -#define ARGI_REGION ACPI_TYPE_REGION -#define ARGI_DDBHANDLE ACPI_TYPE_DDB_HANDLE - -/* Custom types are 0x10 through 0x1F */ - -#define ARGI_IF 0x10 -#define ARGI_ANYOBJECT 0x11 -#define ARGI_ANYTYPE 0x12 -#define ARGI_COMPUTEDATA 0x13 /* Buffer, String, or Integer */ -#define ARGI_DATAOBJECT 0x14 /* Buffer, string, package or reference to a Node - Used only by Size_of operator*/ -#define ARGI_COMPLEXOBJ 0x15 /* Buffer or package */ -#define ARGI_INTEGER_REF 0x16 -#define ARGI_OBJECT_REF 0x17 -#define ARGI_DEVICE_REF 0x18 -#define ARGI_REFERENCE 0x19 -#define ARGI_TARGETREF 0x1A /* Target, subject to implicit conversion */ -#define ARGI_FIXED_TARGET 0x1B /* Target, no implicit conversion */ -#define ARGI_SIMPLE_TARGET 0x1C /* Name, Local, Arg -- no implicit conversion */ -#define ARGI_BUFFERSTRING 0x1D - -#define ARGI_INVALID_OPCODE 0xFFFFFFFF - - -/* - * hash offsets - */ -#define AML_EXTOP_HASH_OFFSET 22 -#define AML_LNOT_HASH_OFFSET 19 - - -/* - * opcode groups and types - */ - -#define OPGRP_NAMED 0x01 -#define OPGRP_FIELD 0x02 -#define OPGRP_BYTELIST 0x04 - -#define OPTYPE_UNDEFINED 0 - - -#define OPTYPE_LITERAL 1 -#define OPTYPE_CONSTANT 2 -#define OPTYPE_METHOD_ARGUMENT 3 -#define OPTYPE_LOCAL_VARIABLE 4 -#define OPTYPE_DATA_TERM 5 - -/* Type 1 opcodes */ - -#define OPTYPE_MONADIC1 6 -#define OPTYPE_DYADIC1 7 - - -/* Type 2 opcodes */ - -#define OPTYPE_MONADIC2 8 -#define OPTYPE_MONADIC2_r 9 -#define OPTYPE_DYADIC2 10 -#define OPTYPE_DYADIC2_r 11 -#define OPTYPE_DYADIC2_s 12 -#define OPTYPE_INDEX 13 -#define OPTYPE_MATCH 14 - -/* Generic for an op that returns a value */ - -#define OPTYPE_METHOD_CALL 15 - - -/* Misc */ - -#define OPTYPE_CREATE_FIELD 16 -#define OPTYPE_FATAL 17 -#define OPTYPE_CONTROL 18 -#define OPTYPE_RECONFIGURATION 19 -#define OPTYPE_NAMED_OBJECT 20 -#define OPTYPE_RETURN 21 - -#define OPTYPE_BOGUS 22 - - -/* Predefined Operation Region Space_iDs */ - -typedef enum -{ - REGION_MEMORY = 0, - REGION_IO, - REGION_PCI_CONFIG, - REGION_EC, - REGION_SMBUS, - REGION_CMOS, - REGION_PCI_BAR - -} AML_REGION_TYPES; - - -/* Comparison operation codes for Match_op operator */ - -typedef enum -{ - MATCH_MTR = 0, - MATCH_MEQ = 1, - MATCH_MLE = 2, - MATCH_MLT = 3, - MATCH_MGE = 4, - MATCH_MGT = 5 - -} AML_MATCH_OPERATOR; - -#define MAX_MATCH_OPERATOR 5 - - -/* Field Access Types */ - -#define ACCESS_TYPE_MASK 0x0f -#define ACCESS_TYPE_SHIFT 0 - -typedef enum -{ - ACCESS_ANY_ACC = 0, - ACCESS_BYTE_ACC = 1, - ACCESS_WORD_ACC = 2, - ACCESS_DWORD_ACC = 3, - ACCESS_BLOCK_ACC = 4, - ACCESS_SMBSEND_RECV_ACC = 5, - ACCESS_SMBQUICK_ACC = 6 - -} AML_ACCESS_TYPE; - - -/* Field Lock Rules */ - -#define LOCK_RULE_MASK 0x10 -#define LOCK_RULE_SHIFT 4 - -typedef enum -{ - GLOCK_NEVER_LOCK = 0, - GLOCK_ALWAYS_LOCK = 1 - -} AML_LOCK_RULE; - - -/* Field Update Rules */ - -#define UPDATE_RULE_MASK 0x060 -#define UPDATE_RULE_SHIFT 5 - -typedef enum -{ - UPDATE_PRESERVE = 0, - UPDATE_WRITE_AS_ONES = 1, - UPDATE_WRITE_AS_ZEROS = 2 - -} AML_UPDATE_RULE; - - -/* bit fields in Method_flags byte */ - -#define METHOD_FLAGS_ARG_COUNT 0x07 -#define METHOD_FLAGS_SERIALIZED 0x08 -#define METHOD_FLAGS_SYNCH_LEVEL 0xF0 - - -/* Array sizes. Used for range checking also */ - -#define NUM_REGION_TYPES 7 -#define NUM_ACCESS_TYPES 7 -#define NUM_UPDATE_RULES 3 -#define NUM_MATCH_OPS 7 -#define NUM_OPCODES 256 -#define NUM_FIELD_NAMES 2 - - -#define USER_REGION_BEGIN 0x80 - -/* - * AML tables - */ - -#ifdef DEFINE_AML_GLOBALS - -/* External declarations of the AML tables */ - -extern u8 acpi_gbl_aml [NUM_OPCODES]; -extern u16 acpi_gbl_pfx [NUM_OPCODES]; - - -#endif /* DEFINE_AML_GLOBALS */ - -#endif /* __AMLCODE_H__ */ diff --git a/reactos/drivers/bus/acpi/include/platform/acenv.h b/reactos/drivers/bus/acpi/include/platform/acenv.h deleted file mode 100644 index 9679222de8d..00000000000 --- a/reactos/drivers/bus/acpi/include/platform/acenv.h +++ /dev/null @@ -1,288 +0,0 @@ -/****************************************************************************** - * - * Name: acenv.h - Generation environment specific items - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACENV_H__ -#define __ACENV_H__ - - -/* - * Configuration for ACPI tools and utilities - */ - -#ifdef _ACPI_DUMP_APP -#define ACPI_DEBUG -#define ACPI_APPLICATION -#define ENABLE_DEBUGGER -#define ACPI_USE_SYSTEM_CLIBRARY -#define PARSER_ONLY -#endif - -#ifdef _ACPI_EXEC_APP -#undef DEBUGGER_THREADING -#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED -#define ACPI_DEBUG -#define ACPI_APPLICATION -#define ENABLE_DEBUGGER -#define ACPI_USE_SYSTEM_CLIBRARY -#endif - -#ifdef _ACPI_ASL_COMPILER -#define ACPI_DEBUG -#define ACPI_APPLICATION -#define ENABLE_DEBUGGER -#define ACPI_USE_SYSTEM_CLIBRARY -#endif - -/* - * Memory allocation tracking. Used only if - * 1) This is the debug version - * 2) This is NOT a 16-bit version of the code (not enough real-mode memory) - */ -#ifdef ACPI_DEBUG -#ifndef _IA16 -#define ACPI_DEBUG_TRACK_ALLOCATIONS -#endif -#endif - -/* - * Environment configuration. The purpose of this file is to interface to the - * local generation environment. - * - * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. - * Otherwise, local versions of string/memory functions will be used. - * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and - * the standard header files may be used. - * - * The ACPI subsystem only uses low level C library functions that do not call - * operating system services and may therefore be inlined in the code. - * - * It may be necessary to tailor these include files to the target - * generation environment. - * - * - * Functions and constants used from each header: - * - * string.h: memcpy - * memset - * strcat - * strcmp - * strcpy - * strlen - * strncmp - * strncat - * strncpy - * - * stdlib.h: strtoul - * - * stdarg.h: va_list - * va_arg - * va_start - * va_end - * - */ - -/*! [Begin] no source code translation */ - -#ifdef _LINUX -#include "aclinux.h" - -#elif _AED_EFI -#include "acefi.h" - -#elif WIN32 -#include "acwin.h" - -#elif __FreeBSD__ -#include "acfreebsd.h" - -#else - -/* All other environments */ - -#define ACPI_USE_STANDARD_HEADERS - -/* Name of host operating system (returned by the _OS_ namespace object) */ - -#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem" - -#endif - - -/*! [End] no source code translation !*/ - -/****************************************************************************** - * - * C library configuration - * - *****************************************************************************/ - -#ifdef ACPI_USE_SYSTEM_CLIBRARY -/* - * Use the standard C library headers. - * We want to keep these to a minimum. - * - */ - -#ifdef ACPI_USE_STANDARD_HEADERS -/* - * Use the standard headers from the standard locations - */ -#include -#include -#include -#include - -#endif /* ACPI_USE_STANDARD_HEADERS */ - -/* - * We will be linking to the standard Clib functions - */ - -#define STRSTR(s1,s2) strstr((s1), (s2)) -#define STRUPR(s) strupr((s)) -#define STRLEN(s) (u32) strlen((s)) -#define STRCPY(d,s) strcpy((d), (s)) -#define STRNCPY(d,s,n) strncpy((d), (s), (NATIVE_INT)(n)) -#define STRNCMP(d,s,n) strncmp((d), (s), (NATIVE_INT)(n)) -#define STRCMP(d,s) strcmp((d), (s)) -#define STRCAT(d,s) strcat((d), (s)) -#define STRNCAT(d,s,n) strncat((d), (s), (NATIVE_INT)(n)) -#define STRTOUL(d,s,n) strtoul((d), (s), (NATIVE_INT)(n)) -#define MEMCPY(d,s,n) memcpy((d), (s), (NATIVE_INT)(n)) -#define MEMSET(d,s,n) memset((d), (s), (NATIVE_INT)(n)) -#define TOUPPER toupper -#define TOLOWER tolower -#define IS_XDIGIT isxdigit - -/****************************************************************************** - * - * Not using native C library, use local implementations - * - *****************************************************************************/ -#else - -/* - * Use local definitions of C library macros and functions - * NOTE: The function implementations may not be as efficient - * as an inline or assembly code implementation provided by a - * native C library. - */ - -#ifndef va_arg - -#ifndef _VALIST -#define _VALIST -typedef char *va_list; -#endif /* _VALIST */ - -/* - * Storage alignment properties - */ - -#define _AUPBND (sizeof (NATIVE_INT) - 1) -#define _ADNBND (sizeof (NATIVE_INT) - 1) - -/* - * Variable argument list macro definitions - */ - -#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) -#define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND)))) -#define va_end(ap) (void) 0 -#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND)))) - -#endif /* va_arg */ - - -#define STRSTR(s1,s2) acpi_cm_strstr ((s1), (s2)) -#define STRUPR(s) acpi_cm_strupr ((s)) -#define STRLEN(s) acpi_cm_strlen ((s)) -#define STRCPY(d,s) acpi_cm_strcpy ((d), (s)) -#define STRNCPY(d,s,n) acpi_cm_strncpy ((d), (s), (n)) -#define STRNCMP(d,s,n) acpi_cm_strncmp ((d), (s), (n)) -#define STRCMP(d,s) acpi_cm_strcmp ((d), (s)) -#define STRCAT(d,s) acpi_cm_strcat ((d), (s)) -#define STRNCAT(d,s,n) acpi_cm_strncat ((d), (s), (n)) -#define STRTOUL(d,s,n) acpi_cm_strtoul ((d), (s),(n)) -#define MEMCPY(d,s,n) acpi_cm_memcpy ((d), (s), (n)) -#define MEMSET(d,v,n) acpi_cm_memset ((d), (v), (n)) -#define TOUPPER acpi_cm_to_upper -#define TOLOWER acpi_cm_to_lower - -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ - - -/****************************************************************************** - * - * Assembly code macros - * - *****************************************************************************/ - -/* - * Handle platform- and compiler-specific assembly language differences. - * These should already have been defined by the platform includes above. - * - * Notes: - * 1) Interrupt 3 is used to break into a debugger - * 2) Interrupts are turned off during ACPI register setup - */ - -/* Unrecognized compiler, use defaults */ -#ifndef ACPI_ASM_MACROS - -#define ACPI_ASM_MACROS -#define causeinterrupt(level) -#define BREAKPOINT3 -#define disable() -#define enable() -#define halt() -#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq) -#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq) - -#endif /* ACPI_ASM_MACROS */ - - -#ifdef ACPI_APPLICATION - -/* Don't want software interrupts within a ring3 application */ - -#undef causeinterrupt -#undef BREAKPOINT3 -#define causeinterrupt(level) -#define BREAKPOINT3 -#endif - - -/****************************************************************************** - * - * Compiler-specific - * - *****************************************************************************/ - -/* this has been moved to compiler-specific headers, which are included from the - platform header. */ - - -#endif /* __ACENV_H__ */ diff --git a/reactos/drivers/bus/acpi/include/platform/acgcc.h b/reactos/drivers/bus/acpi/include/platform/acgcc.h deleted file mode 100644 index 5b41e72d732..00000000000 --- a/reactos/drivers/bus/acpi/include/platform/acgcc.h +++ /dev/null @@ -1,147 +0,0 @@ -/****************************************************************************** - * - * Name: acgcc.h - GCC specific defines, etc. - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACGCC_H__ -#define __ACGCC_H__ - - -#ifdef __ia64__ -#define _IA64 - -#define COMPILER_DEPENDENT_UINT64 unsigned long -/* Single threaded */ -#define ACPI_APPLICATION - -#define ACPI_ASM_MACROS -#define causeinterrupt(level) -#define BREAKPOINT3 -#define disable() __cli() -#define enable() __sti() -#define wbinvd() - -/*! [Begin] no source code translation */ - -#include - -#define halt() ia64_pal_halt_light() /* PAL_HALT[_LIGHT] */ -#define safe_halt() ia64_pal_halt(1) /* PAL_HALT */ - - -#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ - do { \ - __asm__ volatile ("1: ld4 r29=%1\n" \ - ";;\n" \ - "mov ar.ccv=r29\n" \ - "mov r2=r29\n" \ - "shr.u r30=r29,1\n" \ - "and r29=-4,r29\n" \ - ";;\n" \ - "add r29=2,r29\n" \ - "and r30=1,r30\n" \ - ";;\n" \ - "add r29=r29,r30\n" \ - ";;\n" \ - "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ - ";;\n" \ - "cmp.eq p6,p7=r2,r30\n" \ - "(p7) br.dpnt.few 1b\n" \ - "cmp.gt p8,p9=3,r29\n" \ - ";;\n" \ - "(p8) mov %0=-1\n" \ - "(p9) mov %0=r0\n" \ - :"=r"(Acq):"m"(GLptr):"r2","r29","r30","memory"); \ - } while (0) - -#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ - do { \ - __asm__ volatile ("1: ld4 r29=%1\n" \ - ";;\n" \ - "mov ar.ccv=r29\n" \ - "mov r2=r29\n" \ - "and r29=-4,r29\n" \ - ";;\n" \ - "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ - ";;\n" \ - "cmp.eq p6,p7=r2,r30\n" \ - "(p7) br.dpnt.few 1b\n" \ - "and %0=1,r2\n" \ - ";;\n" \ - :"=r"(Acq):"m"(GLptr):"r2","r29","r30","memory"); \ - } while (0) -/*! [End] no source code translation !*/ - - -#else /* DO IA32 */ -#define COMPILER_DEPENDENT_UINT64 unsigned long long -#define ACPI_ASM_MACROS -#define causeinterrupt(level) -#define BREAKPOINT3 -#define disable() __cli() -#define enable() __sti() -#define halt() __asm__ __volatile__ ("sti; hlt":::"memory") -#define wbinvd() - -/*! [Begin] no source code translation - * - * A brief explanation as GNU inline assembly is a bit hairy - * %0 is the output parameter in EAX ("=a") - * %1 and %2 are the input parameters in ECX ("c") - * and an immediate value ("i") respectively - * All actual register references are preceded with "%%" as in "%%edx" - * Immediate values in the assembly are preceded by "$" as in "$0x1" - * The final asm parameter are the operation altered non-output registers. - */ -#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ - do { \ - int dummy; \ - asm("1: movl (%1),%%eax;" \ - "movl %%eax,%%edx;" \ - "andl %2,%%edx;" \ - "btsl $0x1,%%edx;" \ - "adcl $0x0,%%edx;" \ - "lock; cmpxchgl %%edx,(%1);" \ - "jnz 1b;" \ - "cmpb $0x3,%%dl;" \ - "sbbl %%eax,%%eax" \ - :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ - } while(0) - -#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ - do { \ - int dummy; \ - asm("1: movl (%1),%%eax;" \ - "movl %%eax,%%edx;" \ - "andl %2,%%edx;" \ - "lock; cmpxchgl %%edx,(%1);" \ - "jnz 1b;" \ - "andl $0x1,%%eax" \ - :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ - } while(0) - -/*! [End] no source code translation !*/ - -#endif /* IA 32 */ - -#endif /* __ACGCC_H__ */ diff --git a/reactos/drivers/bus/acpi/include/platform/aclinux.h b/reactos/drivers/bus/acpi/include/platform/aclinux.h deleted file mode 100644 index 81a6775f714..00000000000 --- a/reactos/drivers/bus/acpi/include/platform/aclinux.h +++ /dev/null @@ -1,66 +0,0 @@ -/****************************************************************************** - * - * Name: aclinux.h - OS specific defines, etc. - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACLINUX_H__ -#define __ACLINUX_H__ - -#define ACPI_OS_NAME "Linux" - -#undef ACPI_USE_SYSTEM_CLIBRARY - -#ifdef __KERNEL__ - -#include -#include -#include -#include -#include -#include -#include - -#else - -#include - -#endif - -/* Linux uses GCC */ - -#include "acgcc.h" - -#undef DEBUGGER_THREADING -#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED - -#ifndef _IA64 -/* Linux ia32 can't do int64 well */ -#define ACPI_NO_INTEGER64_SUPPORT -/* And the ia32 kernel doesn't include 64-bit divide support */ -#define ACPI_DIV64(dividend, divisor) do_div(dividend, divisor) -#else -#define ACPI_DIV64(dividend, divisor) ACPI_DIVIDE(dividend, divisor) -#endif - - -#endif /* __ACLINUX_H__ */ diff --git a/reactos/drivers/bus/acpi/include/platform/acmsc.h b/reactos/drivers/bus/acpi/include/platform/acmsc.h deleted file mode 100644 index 612edf938c2..00000000000 --- a/reactos/drivers/bus/acpi/include/platform/acmsc.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __ACMSC_H__ -#define __ACMSC_H__ - -#define COMPILER_DEPENDENT_UINT64 unsigned __int64 - -#if defined(_M_IX86) - -#define ACPI_ASM_MACROS -#define causeinterrupt(level) -#define BREAKPOINT3 -#define halt() { __asm { sti } __asm { hlt } } -#define wbinvd() - -__forceinline void _ACPI_ACQUIRE_GLOBAL_LOCK(void * GLptr, unsigned char * Acq_) -{ - unsigned char Acq; - - __asm - { - mov ecx, [GLptr] - - L1: mov eax, [ecx] - mov edx, eax - and edx, ecx - bts edx, 1 - adc edx, 0 - lock cmpxchg [ecx], edx - jne L1 - cmp dl, 3 - sbb eax, eax - - mov [Acq], al - }; - - *Acq_ = Acq; -} - -#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ - _ACPI_ACQUIRE_GLOBAL_LOCK((GLptr), (unsigned char *)&(Acq)) - -__forceinline void _ACPI_RELEASE_GLOBAL_LOCK(void * GLptr, unsigned char * Acq_) -{ - unsigned char Acq; - - __asm - { - mov ecx, [GLptr] - - L1: mov eax, [ecx] - mov edx, eax - and edx, ecx - lock cmpxchg [ecx], edx - jnz L1 - and eax, 1 - - mov [Acq], al - }; - - *Acq_ = Acq; -} - -#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ - _ACPI_RELEASE_GLOBAL_LOCK((GLptr), (unsigned char *)&(Acq)) - -#endif - -#endif /* __ACMSC_H__ */ diff --git a/reactos/drivers/bus/acpi/include/platform/acwin.h b/reactos/drivers/bus/acpi/include/platform/acwin.h deleted file mode 100644 index cfab7728f6f..00000000000 --- a/reactos/drivers/bus/acpi/include/platform/acwin.h +++ /dev/null @@ -1,82 +0,0 @@ -/****************************************************************************** - * - * Name: aclinux.h - OS specific defines, etc. - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ACWIN_H__ -#define __ACWIN_H__ - -#define ACPI_OS_NAME "ReactOS" -#define DEFINE_ALTERNATE_TYPES - -#undef ACPI_USE_SYSTEM_CLIBRARY - -#ifdef __KERNEL__ - -#include -#include -#include -#include -#include -#include -#include - -#else - -#include - -#endif - -#if defined(__GNUC__) - -#include "acgcc.h" - -#undef disable -#define disable() __asm__("cli\n\t") -#undef enable -#define enable() __asm__("sti\n\t") - -#elif defined(_MSC_VER) - -#include "acmsc.h" - -#undef disable -#define disable() __asm { cli } -#undef enable -#define enable() __asm { sti } - -#endif - -#undef DEBUGGER_THREADING -#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED - -#ifndef _IA64 -/* Linux ia32 can't do int64 well */ -#define ACPI_NO_INTEGER64_SUPPORT -/* And the ia32 kernel doesn't include 64-bit divide support */ -#define ACPI_DIV64(dividend, divisor) do_div(dividend, divisor) -#else -#define ACPI_DIV64(dividend, divisor) ACPI_DIVIDE(dividend, divisor) -#endif - -#endif /* __ACWIN_H__ */ diff --git a/reactos/drivers/bus/acpi/include/platform/types.h b/reactos/drivers/bus/acpi/include/platform/types.h deleted file mode 100644 index e823dda3bf8..00000000000 --- a/reactos/drivers/bus/acpi/include/platform/types.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: include/types.h - * PURPOSE: Types used by all the parts of the system - * PROGRAMMER: David Welch - * DEFINES: _WIN64: 64-bit architecture - * _WIN32: 32-bit architecture (default) - * UPDATE HISTORY: - * 27/06/00: Created - * 01/05/01: Portabillity changes - */ -#ifndef __INCLUDE_ACPI_TYPES_H -#define __INCLUDE_ACPI_TYPES_H - -#include -#include - -#endif /* __INCLUDE_ACPI_TYPES_H */ diff --git a/reactos/drivers/bus/acpi/namespace/nsaccess.c b/reactos/drivers/bus/acpi/namespace/nsaccess.c deleted file mode 100644 index 4da6b907bf7..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsaccess.c +++ /dev/null @@ -1,546 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsaccess") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_root_initialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Allocate and initialize the default root named objects - * - * MUTEX: Locks namespace for entire execution - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_root_initialize (void) -{ - ACPI_STATUS status = AE_OK; - PREDEFINED_NAMES *init_val = NULL; - ACPI_NAMESPACE_NODE *new_node; - ACPI_OPERAND_OBJECT *obj_desc; - - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* - * The global root ptr is initially NULL, so a non-NULL value indicates - * that Acpi_ns_root_initialize() has already been called; just return. - */ - - if (acpi_gbl_root_node) { - status = AE_OK; - goto unlock_and_exit; - } - - - /* - * Tell the rest of the subsystem that the root is initialized - * (This is OK because the namespace is locked) - */ - - acpi_gbl_root_node = &acpi_gbl_root_node_struct; - - - /* Enter the pre-defined names in the name table */ - - for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) { - status = acpi_ns_lookup (NULL, init_val->name, - (OBJECT_TYPE_INTERNAL) init_val->type, - IMODE_LOAD_PASS2, NS_NO_UPSEARCH, - NULL, &new_node); - - - /* - * Name entered successfully. - * If entry in Pre_defined_names[] specifies an - * initial value, create the initial value. - */ - - if (init_val->val) { - /* - * Entry requests an initial value, allocate a - * descriptor for it. - */ - - obj_desc = acpi_cm_create_internal_object ( - (OBJECT_TYPE_INTERNAL) init_val->type); - - if (!obj_desc) { - status = AE_NO_MEMORY; - goto unlock_and_exit; - } - - /* - * Convert value string from table entry to - * internal representation. Only types actually - * used for initial values are implemented here. - */ - - switch (init_val->type) { - - case ACPI_TYPE_INTEGER: - - obj_desc->integer.value = - (ACPI_INTEGER) STRTOUL (init_val->val, NULL, 10); - break; - - - case ACPI_TYPE_STRING: - - obj_desc->string.length = STRLEN (init_val->val); - - /* - * Allocate a buffer for the string. All - * String.Pointers must be allocated buffers! - * (makes deletion simpler) - */ - obj_desc->string.pointer = acpi_cm_allocate ( - (obj_desc->string.length + 1)); - if (!obj_desc->string.pointer) { - acpi_cm_remove_reference (obj_desc); - status = AE_NO_MEMORY; - goto unlock_and_exit; - } - - STRCPY (obj_desc->string.pointer, init_val->val); - break; - - - case ACPI_TYPE_MUTEX: - - obj_desc->mutex.sync_level = - (u16) STRTOUL (init_val->val, NULL, 10); - - if (STRCMP (init_val->name, "_GL_") == 0) { - /* - * Create a counting semaphore for the - * global lock - */ - status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, - 1, &obj_desc->mutex.semaphore); - - if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } - /* - * We just created the mutex for the - * global lock, save it - */ - - acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore; - } - - else { - /* Create a mutex */ - - status = acpi_os_create_semaphore (1, 1, - &obj_desc->mutex.semaphore); - - if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } - } - break; - - - default: - REPORT_ERROR (("Unsupported initial type value %X\n", - init_val->type)); - acpi_cm_remove_reference (obj_desc); - obj_desc = NULL; - continue; - } - - /* Store pointer to value descriptor in the Node */ - - acpi_ns_attach_object (new_node, obj_desc, obj_desc->common.type); - } - } - - -unlock_and_exit: - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_lookup - * - * PARAMETERS: Prefix_node - Search scope if name is not fully qualified - * Pathname - Search pathname, in internal format - * (as represented in the AML stream) - * Type - Type associated with name - * Interpreter_mode - IMODE_LOAD_PASS2 => add name if not found - * Flags - Flags describing the search restrictions - * Walk_state - Current state of the walk - * Return_node - Where the Node is placed (if found - * or created successfully) - * - * RETURN: Status - * - * DESCRIPTION: Find or enter the passed name in the name space. - * Log an error if name not found in Exec mode. - * - * MUTEX: Assumes namespace is locked. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_lookup ( - ACPI_GENERIC_STATE *scope_info, - NATIVE_CHAR *pathname, - OBJECT_TYPE_INTERNAL type, - OPERATING_MODE interpreter_mode, - u32 flags, - ACPI_WALK_STATE *walk_state, - ACPI_NAMESPACE_NODE **return_node) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *prefix_node; - ACPI_NAMESPACE_NODE *current_node = NULL; - ACPI_NAMESPACE_NODE *scope_to_push = NULL; - ACPI_NAMESPACE_NODE *this_node = NULL; - u32 num_segments; - ACPI_NAME simple_name; - u8 null_name_path = FALSE; - OBJECT_TYPE_INTERNAL type_to_check_for; - OBJECT_TYPE_INTERNAL this_search_type; - u32 local_flags = flags & ~NS_ERROR_IF_FOUND; - - - if (!return_node) { - return (AE_BAD_PARAMETER); - } - - - acpi_gbl_ns_lookup_count++; - - *return_node = ENTRY_NOT_FOUND; - - - if (!acpi_gbl_root_node) { - return (AE_NO_NAMESPACE); - } - - /* - * Get the prefix scope. - * A null scope means use the root scope - */ - - if ((!scope_info) || - (!scope_info->scope.node)) { - prefix_node = acpi_gbl_root_node; - } - else { - prefix_node = scope_info->scope.node; - } - - - /* - * This check is explicitly split provide relax the Type_to_check_for - * conditions for Bank_field_defn. Originally, both Bank_field_defn and - * Def_field_defn caused Type_to_check_for to be set to ACPI_TYPE_REGION, - * but the Bank_field_defn may also check for a Field definition as well - * as an Operation_region. - */ - - if (INTERNAL_TYPE_DEF_FIELD_DEFN == type) { - /* Def_field_defn defines fields in a Region */ - - type_to_check_for = ACPI_TYPE_REGION; - } - - else if (INTERNAL_TYPE_BANK_FIELD_DEFN == type) { - /* Bank_field_defn defines data fields in a Field Object */ - - type_to_check_for = ACPI_TYPE_ANY; - } - - else { - type_to_check_for = type; - } - - - /* TBD: [Restructure] - Move the pathname stuff into a new procedure */ - - /* Examine the name pointer */ - - if (!pathname) { - /* 8-12-98 ASL Grammar Update supports null Name_path */ - - null_name_path = TRUE; - num_segments = 0; - this_node = acpi_gbl_root_node; - - } - - else { - /* - * Valid name pointer (Internal name format) - * - * Check for prefixes. As represented in the AML stream, a - * Pathname consists of an optional scope prefix followed by - * a segment part. - * - * If present, the scope prefix is either a Root_prefix (in - * which case the name is fully qualified), or zero or more - * Parent_prefixes (in which case the name's scope is relative - * to the current scope). - * - * The segment part consists of either: - * - A single 4-byte name segment, or - * - A Dual_name_prefix followed by two 4-byte name segments, or - * - A Multi_name_prefix_op, followed by a byte indicating the - * number of segments and the segments themselves. - */ - - if (*pathname == AML_ROOT_PREFIX) { - /* Pathname is fully qualified, look in root name table */ - - current_node = acpi_gbl_root_node; - - /* point to segment part */ - - pathname++; - - /* Direct reference to root, "\" */ - - if (!(*pathname)) { - this_node = acpi_gbl_root_node; - goto check_for_new_scope_and_exit; - } - } - - else { - /* Pathname is relative to current scope, start there */ - - current_node = prefix_node; - - /* - * Handle up-prefix (carat). More than one prefix - * is supported - */ - - while (*pathname == AML_PARENT_PREFIX) { - /* Point to segment part or next Parent_prefix */ - - pathname++; - - /* Backup to the parent's scope */ - - this_node = acpi_ns_get_parent_object (current_node); - if (!this_node) { - /* Current scope has no parent scope */ - - REPORT_ERROR ( - ("Too many parent prefixes (^) - reached root\n")); - return (AE_NOT_FOUND); - } - - current_node = this_node; - } - } - - - /* - * Examine the name prefix opcode, if any, - * to determine the number of segments - */ - - if (*pathname == AML_DUAL_NAME_PREFIX) { - num_segments = 2; - - /* point to first segment */ - - pathname++; - - } - - else if (*pathname == AML_MULTI_NAME_PREFIX_OP) { - num_segments = (u32)* (u8 *) ++pathname; - - /* point to first segment */ - - pathname++; - - } - - else { - /* - * No Dual or Multi prefix, hence there is only one - * segment and Pathname is already pointing to it. - */ - num_segments = 1; - - } - - } - - - /* - * Search namespace for each segment of the name. - * Loop through and verify/add each name segment. - */ - - - while (num_segments-- && current_node) { - /* - * Search for the current name segment under the current - * named object. The Type is significant only at the last (topmost) - * level. (We don't care about the types along the path, only - * the type of the final target object.) - */ - this_search_type = ACPI_TYPE_ANY; - if (!num_segments) { - this_search_type = type; - local_flags = flags; - } - - /* Pluck one ACPI name from the front of the pathname */ - - MOVE_UNALIGNED32_TO_32 (&simple_name, pathname); - - /* Try to find the ACPI name */ - - status = acpi_ns_search_and_enter (simple_name, walk_state, - current_node, interpreter_mode, - this_search_type, local_flags, - &this_node); - - if (ACPI_FAILURE (status)) { - if (status == AE_NOT_FOUND) { - /* Name not found in ACPI namespace */ - - } - - return (status); - } - - - /* - * If 1) This is the last segment (Num_segments == 0) - * 2) and looking for a specific type - * (Not checking for TYPE_ANY) - * 3) Which is not an alias - * 4) which is not a local type (TYPE_DEF_ANY) - * 5) which is not a local type (TYPE_SCOPE) - * 6) which is not a local type (TYPE_INDEX_FIELD_DEFN) - * 7) and type of object is known (not TYPE_ANY) - * 8) and object does not match request - * - * Then we have a type mismatch. Just warn and ignore it. - */ - if ((num_segments == 0) && - (type_to_check_for != ACPI_TYPE_ANY) && - (type_to_check_for != INTERNAL_TYPE_ALIAS) && - (type_to_check_for != INTERNAL_TYPE_DEF_ANY) && - (type_to_check_for != INTERNAL_TYPE_SCOPE) && - (type_to_check_for != INTERNAL_TYPE_INDEX_FIELD_DEFN) && - (this_node->type != ACPI_TYPE_ANY) && - (this_node->type != type_to_check_for)) { - /* Complain about a type mismatch */ - - REPORT_WARNING ( - ("Ns_lookup: %4.4s, type %X, checking for type %X\n", - &simple_name, this_node->type, type_to_check_for)); - } - - /* - * If this is the last name segment and we are not looking for a - * specific type, but the type of found object is known, use that type - * to see if it opens a scope. - */ - - if ((0 == num_segments) && (ACPI_TYPE_ANY == type)) { - type = this_node->type; - } - - if ((num_segments || acpi_ns_opens_scope (type)) && - (this_node->child == NULL)) { - /* - * More segments or the type implies enclosed scope, - * and the next scope has not been allocated. - */ - - } - - current_node = this_node; - - /* point to next name segment */ - - pathname += ACPI_NAME_SIZE; - } - - - /* - * Always check if we need to open a new scope - */ - -check_for_new_scope_and_exit: - - if (!(flags & NS_DONT_OPEN_SCOPE) && (walk_state)) { - /* - * If entry is a type which opens a scope, - * push the new scope on the scope stack. - */ - - if (acpi_ns_opens_scope (type_to_check_for)) { - /* 8-12-98 ASL Grammar Update supports null Name_path */ - - if (null_name_path) { - /* TBD: [Investigate] - is this the correct thing to do? */ - - scope_to_push = NULL; - } - else { - scope_to_push = this_node; - } - - status = acpi_ds_scope_stack_push (scope_to_push, type, - walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - } - } - - *return_node = this_node; - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/namespace/nsalloc.c b/reactos/drivers/bus/acpi/namespace/nsalloc.c deleted file mode 100644 index 00f79882669..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsalloc.c +++ /dev/null @@ -1,563 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsalloc - Namespace allocation and deletion utilities - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsalloc") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_create_node - * - * PARAMETERS: - * - * RETURN: None - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -acpi_ns_create_node ( - u32 acpi_name) -{ - ACPI_NAMESPACE_NODE *node; - - - node = acpi_cm_callocate (sizeof (ACPI_NAMESPACE_NODE)); - if (!node) { - return (NULL); - } - - INCREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); - - node->data_type = ACPI_DESC_TYPE_NAMED; - node->name = acpi_name; - node->reference_count = 1; - - return (node); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_delete_node - * - * PARAMETERS: - * - * RETURN: None - * - * DESCRIPTION: - * - ******************************************************************************/ - -void -acpi_ns_delete_node ( - ACPI_NAMESPACE_NODE *node) -{ - ACPI_NAMESPACE_NODE *parent_node; - ACPI_NAMESPACE_NODE *prev_node; - ACPI_NAMESPACE_NODE *next_node; - - - parent_node = acpi_ns_get_parent_object (node); - - prev_node = NULL; - next_node = parent_node->child; - - while (next_node != node) { - prev_node = next_node; - next_node = prev_node->peer; - } - - if (prev_node) { - prev_node->peer = next_node->peer; - if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { - prev_node->flags |= ANOBJ_END_OF_PEER_LIST; - } - } - else { - parent_node->child = next_node->peer; - } - - - DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); - - /* - * Detach an object if there is one - */ - - if (node->object) { - acpi_ns_detach_object (node); - } - - acpi_cm_free (node); - - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_install_node - * - * PARAMETERS: Walk_state - Current state of the walk - * Parent_node - The parent of the new Node - * Node - The new Node to install - * Type - ACPI object type of the new Node - * - * RETURN: None - * - * DESCRIPTION: Initialize a new entry within a namespace table. - * - ******************************************************************************/ - -void -acpi_ns_install_node ( - ACPI_WALK_STATE *walk_state, - ACPI_NAMESPACE_NODE *parent_node, /* Parent */ - ACPI_NAMESPACE_NODE *node, /* New Child*/ - OBJECT_TYPE_INTERNAL type) -{ - u16 owner_id = TABLE_ID_DSDT; - ACPI_NAMESPACE_NODE *child_node; - - - /* - * Get the owner ID from the Walk state - * The owner ID is used to track table deletion and - * deletion of objects created by methods - */ - if (walk_state) { - owner_id = walk_state->owner_id; - } - - - /* link the new entry into the parent and existing children */ - - /* TBD: Could be first, last, or alphabetic */ - - child_node = parent_node->child; - if (!child_node) { - parent_node->child = node; - } - - else { - while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) { - child_node = child_node->peer; - } - - child_node->peer = node; - - /* Clear end-of-list flag */ - - child_node->flags &= ~ANOBJ_END_OF_PEER_LIST; - } - - /* Init the new entry */ - - node->owner_id = owner_id; - node->flags |= ANOBJ_END_OF_PEER_LIST; - node->peer = parent_node; - - - /* - * If adding a name with unknown type, or having to - * add the region in order to define fields in it, we - * have a forward reference. - */ - - if ((ACPI_TYPE_ANY == type) || - (INTERNAL_TYPE_DEF_FIELD_DEFN == type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) { - /* - * We don't want to abort here, however! - * We will fill in the actual type when the - * real definition is found later. - */ - - } - - /* - * The Def_field_defn and Bank_field_defn cases are actually - * looking up the Region in which the field will be defined - */ - - if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) { - type = ACPI_TYPE_REGION; - } - - /* - * Scope, Def_any, and Index_field_defn are bogus "types" which do - * not actually have anything to do with the type of the name - * being looked up. Save any other value of Type as the type of - * the entry. - */ - - if ((type != INTERNAL_TYPE_SCOPE) && - (type != INTERNAL_TYPE_DEF_ANY) && - (type != INTERNAL_TYPE_INDEX_FIELD_DEFN)) { - node->type = (u8) type; - } - - /* - * Increment the reference count(s) of all parents up to - * the root! - */ - - while ((node = acpi_ns_get_parent_object (node)) != NULL) { - node->reference_count++; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_delete_children - * - * PARAMETERS: Parent_node - Delete this objects children - * - * RETURN: None. - * - * DESCRIPTION: Delete all children of the parent object. Deletes a - * "scope". - * - ******************************************************************************/ - -void -acpi_ns_delete_children ( - ACPI_NAMESPACE_NODE *parent_node) -{ - ACPI_NAMESPACE_NODE *child_node; - ACPI_NAMESPACE_NODE *next_node; - u8 flags; - - - if (!parent_node) { - return; - } - - /* If no children, all done! */ - - child_node = parent_node->child; - if (!child_node) { - return; - } - - /* - * Deallocate all children at this level - */ - do { - /* Get the things we need */ - - next_node = child_node->peer; - flags = child_node->flags; - - /* Grandchildren should have all been deleted already */ - - - /* Now we can free this child object */ - - DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); - - /* - * Detach an object if there is one - */ - - if (child_node->object) { - acpi_ns_detach_object (child_node); - } - - acpi_cm_free (child_node); - - /* And move on to the next child in the list */ - - child_node = next_node; - - } while (!(flags & ANOBJ_END_OF_PEER_LIST)); - - - /* Clear the parent's child pointer */ - - parent_node->child = NULL; - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_delete_namespace_subtree - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete a subtree of the namespace. This includes all objects - * stored within the subtree. Scope tables are deleted also - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_delete_namespace_subtree ( - ACPI_NAMESPACE_NODE *parent_node) -{ - ACPI_NAMESPACE_NODE *child_node; - ACPI_OPERAND_OBJECT *obj_desc; - u32 level; - - - if (!parent_node) { - return (AE_OK); - } - - - child_node = 0; - level = 1; - - /* - * Traverse the tree of objects until we bubble back up - * to where we started. - */ - - while (level > 0) { - /* - * Get the next typed object in this scope. - * Null returned if not found - */ - - child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY, parent_node, - child_node); - if (child_node) { - /* - * Found an object - delete the object within - * the Value field - */ - - obj_desc = acpi_ns_get_attached_object (child_node); - if (obj_desc) { - acpi_ns_detach_object (child_node); - acpi_cm_remove_reference (obj_desc); - } - - - /* Check if this object has any children */ - - if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_node, 0)) { - /* - * There is at least one child of this object, - * visit the object - */ - - level++; - parent_node = child_node; - child_node = 0; - } - } - - else { - /* - * No more children in this object. - * We will move up to the grandparent. - */ - level--; - - /* - * Now delete all of the children of this parent - * all at the same time. - */ - acpi_ns_delete_children (parent_node); - - /* New "last child" is this parent object */ - - child_node = parent_node; - - /* Now we can move up the tree to the grandparent */ - - parent_node = acpi_ns_get_parent_object (parent_node); - } - } - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_remove_reference - * - * PARAMETERS: Node - Named object whose reference count is to be - * decremented - * - * RETURN: None. - * - * DESCRIPTION: Remove a Node reference. Decrements the reference count - * of all parent Nodes up to the root. Any object along - * the way that reaches zero references is freed. - * - ******************************************************************************/ - -static void -acpi_ns_remove_reference ( - ACPI_NAMESPACE_NODE *node) -{ - ACPI_NAMESPACE_NODE *next_node; - - - /* - * Decrement the reference count(s) of this object and all - * objects up to the root, Delete anything with zero remaining references. - */ - next_node = node; - while (next_node) { - /* Decrement the reference count on this object*/ - - next_node->reference_count--; - - /* Delete the object if no more references */ - - if (!next_node->reference_count) { - /* Delete all children and delete the object */ - - acpi_ns_delete_children (next_node); - acpi_ns_delete_node (next_node); - } - - /* Move up to parent */ - - next_node = acpi_ns_get_parent_object (next_node); - } -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_delete_namespace_by_owner - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete entries within the namespace that are owned by a - * specific ID. Used to delete entire ACPI tables. All - * reference counts are updated. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_delete_namespace_by_owner ( - u16 owner_id) -{ - ACPI_NAMESPACE_NODE *child_node; - u32 level; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_NAMESPACE_NODE *parent_node; - - - parent_node = acpi_gbl_root_node; - child_node = 0; - level = 1; - - /* - * Traverse the tree of objects until we bubble back up - * to where we started. - */ - - while (level > 0) { - /* - * Get the next typed object in this scope. - * Null returned if not found - */ - - child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY, parent_node, - child_node); - - if (child_node) { - if (child_node->owner_id == owner_id) { - /* - * Found an object - delete the object within - * the Value field - */ - - obj_desc = acpi_ns_get_attached_object (child_node); - if (obj_desc) { - acpi_ns_detach_object (child_node); - acpi_cm_remove_reference (obj_desc); - } - } - - /* Check if this object has any children */ - - if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_node, 0)) { - /* - * There is at least one child of this object, - * visit the object - */ - - level++; - parent_node = child_node; - child_node = 0; - } - - else if (child_node->owner_id == owner_id) { - acpi_ns_remove_reference (child_node); - } - } - - else { - /* - * No more children in this object. Move up to grandparent. - */ - level--; - - if (level != 0) { - if (parent_node->owner_id == owner_id) { - acpi_ns_remove_reference (parent_node); - } - } - - /* New "last child" is this parent object */ - - child_node = parent_node; - - /* Now we can move up the tree to the grandparent */ - - parent_node = acpi_ns_get_parent_object (parent_node); - } - } - - - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/namespace/nseval.c b/reactos/drivers/bus/acpi/namespace/nseval.c deleted file mode 100644 index 63647e0d92e..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nseval.c +++ /dev/null @@ -1,501 +0,0 @@ -/******************************************************************************* - * - * Module Name: nseval - Object evaluation interfaces -- includes control - * method lookup and execution. - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nseval") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_evaluate_relative - * - * PARAMETERS: Handle - The relative containing object - * *Pathname - Name of method to execute, If NULL, the - * handle is the object to execute - * **Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * *Return_object - Where to put method's return value (if - * any). If NULL, no value is returned. - * - * RETURN: Status - * - * DESCRIPTION: Find and execute the requested method using the handle as a - * scope - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_evaluate_relative ( - ACPI_NAMESPACE_NODE *handle, - NATIVE_CHAR *pathname, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_object) -{ - ACPI_NAMESPACE_NODE *prefix_node; - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *node = NULL; - NATIVE_CHAR *internal_path = NULL; - ACPI_GENERIC_STATE scope_info; - - - /* - * Must have a valid object handle - */ - if (!handle) { - return (AE_BAD_PARAMETER); - } - - /* Build an internal name string for the method */ - - status = acpi_ns_internalize_name (pathname, &internal_path); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Get the prefix handle and Node */ - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - prefix_node = acpi_ns_convert_handle_to_entry (handle); - if (!prefix_node) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - status = AE_BAD_PARAMETER; - goto cleanup; - } - - /* Lookup the name in the namespace */ - - scope_info.scope.node = prefix_node; - status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY, - IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, - &node); - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* - * Now that we have a handle to the object, we can attempt - * to evaluate it. - */ - - status = acpi_ns_evaluate_by_handle (node, params, return_object); - -cleanup: - - /* Cleanup */ - - acpi_cm_free (internal_path); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_evaluate_by_name - * - * PARAMETERS: Pathname - Fully qualified pathname to the object - * *Return_object - Where to put method's return value (if - * any). If NULL, no value is returned. - * **Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * - * RETURN: Status - * - * DESCRIPTION: Find and execute the requested method passing the given - * parameters - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_evaluate_by_name ( - NATIVE_CHAR *pathname, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_object) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *node = NULL; - NATIVE_CHAR *internal_path = NULL; - - - /* Build an internal name string for the method */ - - status = acpi_ns_internalize_name (pathname, &internal_path); - if (ACPI_FAILURE (status)) { - return (status); - } - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* Lookup the name in the namespace */ - - status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, - IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, - &node); - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* - * Now that we have a handle to the object, we can attempt - * to evaluate it. - */ - - status = acpi_ns_evaluate_by_handle (node, params, return_object); - - -cleanup: - - /* Cleanup */ - - if (internal_path) { - acpi_cm_free (internal_path); - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_evaluate_by_handle - * - * PARAMETERS: Handle - Method Node to execute - * **Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * *Return_object - Where to put method's return value (if - * any). If NULL, no value is returned. - * - * RETURN: Status - * - * DESCRIPTION: Execute the requested method passing the given parameters - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_evaluate_by_handle ( - ACPI_NAMESPACE_NODE *handle, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_object) -{ - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *local_return_object; - - - /* Check if namespace has been initialized */ - - if (!acpi_gbl_root_node) { - return (AE_NO_NAMESPACE); - } - - /* Parameter Validation */ - - if (!handle) { - return (AE_BAD_PARAMETER); - } - - if (return_object) { - /* Initialize the return value to an invalid object */ - - *return_object = NULL; - } - - /* Get the prefix handle and Node */ - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - node = acpi_ns_convert_handle_to_entry (handle); - if (!node) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - - /* - * Two major cases here: - * 1) The object is an actual control method -- execute it. - * 2) The object is not a method -- just return it's current - * value - * - * In both cases, the namespace is unlocked by the - * Acpi_ns* procedure - */ - if (acpi_ns_get_type (node) == ACPI_TYPE_METHOD) { - /* - * Case 1) We have an actual control method to execute - */ - status = acpi_ns_execute_control_method (node, params, - &local_return_object); - } - - else { - /* - * Case 2) Object is NOT a method, just return its - * current value - */ - status = acpi_ns_get_object_value (node, &local_return_object); - } - - - /* - * Check if there is a return value on the stack that must - * be dealt with - */ - if (status == AE_CTRL_RETURN_VALUE) { - /* - * If the Method returned a value and the caller - * provided a place to store a returned value, Copy - * the returned value to the object descriptor provided - * by the caller. - */ - if (return_object) { - /* - * Valid return object, copy the pointer to - * the returned object - */ - *return_object = local_return_object; - } - - - /* Map AE_RETURN_VALUE to AE_OK, we are done with it */ - - if (status == AE_CTRL_RETURN_VALUE) { - status = AE_OK; - } - } - - /* - * Namespace was unlocked by the handling Acpi_ns* function, - * so we just return - */ - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_execute_control_method - * - * PARAMETERS: Method_node - The object/method - * **Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * **Return_obj_desc - List of result objects to be returned - * from the method. - * - * RETURN: Status - * - * DESCRIPTION: Execute the requested method passing the given parameters - * - * MUTEX: Assumes namespace is locked - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_execute_control_method ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_obj_desc) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - - - /* Verify that there is a method associated with this object */ - - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) method_node); - if (!obj_desc) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (AE_ERROR); - } - - - /* - * Unlock the namespace before execution. This allows namespace access - * via the external Acpi* interfaces while a method is being executed. - * However, any namespace deletion must acquire both the namespace and - * interpreter locks to ensure that no thread is using the portion of the - * namespace that is being deleted. - */ - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - /* - * Execute the method via the interpreter - */ - status = acpi_aml_execute_method (method_node, params, return_obj_desc); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_get_object_value - * - * PARAMETERS: Node - The object - * - * RETURN: Status - * - * DESCRIPTION: Return the current value of the object - * - * MUTEX: Assumes namespace is locked - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_get_object_value ( - ACPI_NAMESPACE_NODE *node, - ACPI_OPERAND_OBJECT **return_obj_desc) -{ - ACPI_STATUS status = AE_OK; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *val_desc; - - - /* - * We take the value from certain objects directly - */ - - if ((node->type == ACPI_TYPE_PROCESSOR) || - (node->type == ACPI_TYPE_POWER)) { - /* - * Create a Reference object to contain the object - */ - obj_desc = acpi_cm_create_internal_object (node->type); - if (!obj_desc) { - status = AE_NO_MEMORY; - goto unlock_and_exit; - } - - /* - * Get the attached object - */ - - val_desc = acpi_ns_get_attached_object (node); - if (!val_desc) { - status = AE_NULL_OBJECT; - goto unlock_and_exit; - } - - /* - * Just copy from the original to the return object - * - * TBD: [Future] - need a low-level object copy that handles - * the reference count automatically. (Don't want to copy it) - */ - - MEMCPY (obj_desc, val_desc, sizeof (ACPI_OPERAND_OBJECT)); - obj_desc->common.reference_count = 1; - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - } - - - /* - * Other objects require a reference object wrapper which we - * then attempt to resolve. - */ - else { - /* Create an Reference object to contain the object */ - - obj_desc = acpi_cm_create_internal_object (INTERNAL_TYPE_REFERENCE); - if (!obj_desc) { - status = AE_NO_MEMORY; - goto unlock_and_exit; - } - - /* Construct a descriptor pointing to the name */ - - obj_desc->reference.opcode = (u8) AML_NAME_OP; - obj_desc->reference.object = (void *) node; - - /* - * Use Resolve_to_value() to get the associated value. This call - * always deletes Obj_desc (allocated above). - * - * NOTE: we can get away with passing in NULL for a walk state - * because Obj_desc is guaranteed to not be a reference to either - * a method local or a method argument - * - * Even though we do not directly invoke the interpreter - * for this, we must enter it because we could access an opregion. - * The opregion access code assumes that the interpreter - * is locked. - * - * We must release the namespace lock before entering the - * intepreter. - */ - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - status = acpi_aml_enter_interpreter (); - if (ACPI_SUCCESS (status)) { - status = acpi_aml_resolve_to_value (&obj_desc, NULL); - - acpi_aml_exit_interpreter (); - } - } - - /* - * If Acpi_aml_resolve_to_value() succeeded, the return value was - * placed in Obj_desc. - */ - - if (ACPI_SUCCESS (status)) { - status = AE_CTRL_RETURN_VALUE; - - *return_obj_desc = obj_desc; - } - - /* Namespace is unlocked */ - - return (status); - - -unlock_and_exit: - - /* Unlock the namespace */ - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} diff --git a/reactos/drivers/bus/acpi/namespace/nsinit.c b/reactos/drivers/bus/acpi/namespace/nsinit.c deleted file mode 100644 index 81ed0fe3c2c..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsinit.c +++ /dev/null @@ -1,276 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsinit - namespace initialization - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsinit") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_initialize_objects - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Walk the entire namespace and perform any necessary - * initialization on the objects found therein - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_initialize_objects ( - void) -{ - ACPI_STATUS status; - ACPI_INIT_WALK_INFO info; - - - info.field_count = 0; - info.field_init = 0; - info.op_region_count = 0; - info.op_region_init = 0; - info.object_count = 0; - - - /* Walk entire namespace from the supplied root */ - - status = acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, acpi_ns_init_one_object, - &info, NULL); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_initialize_devices - * - * PARAMETERS: None - * - * RETURN: ACPI_STATUS - * - * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices. - * This means running _INI on all present devices. - * - * Note: We install PCI config space handler on region access, - * not here. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_initialize_devices ( - void) -{ - ACPI_STATUS status; - ACPI_DEVICE_WALK_INFO info; - - - info.device_count = 0; - info.num_STA = 0; - info.num_INI = 0; - - - status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, acpi_ns_init_one_device, &info, NULL); - - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_init_one_object - * - * PARAMETERS: Obj_handle - Node - * Level - Current nesting level - * Context - Points to a init info struct - * Return_value - Not used - * - * RETURN: Status - * - * DESCRIPTION: Callback from Acpi_walk_namespace. Invoked for every object - * within the namespace. - * - * Currently, the only objects that require initialization are: - * 1) Methods - * 2) Op Regions - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_init_one_object ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value) -{ - OBJECT_TYPE_INTERNAL type; - ACPI_STATUS status; - ACPI_INIT_WALK_INFO *info = (ACPI_INIT_WALK_INFO *) context; - ACPI_NAMESPACE_NODE *node = (ACPI_NAMESPACE_NODE *) obj_handle; - ACPI_OPERAND_OBJECT *obj_desc; - - - info->object_count++; - - - /* And even then, we are only interested in a few object types */ - - type = acpi_ns_get_type (obj_handle); - obj_desc = node->object; - if (!obj_desc) { - return (AE_OK); - } - - switch (type) { - - case ACPI_TYPE_REGION: - - info->op_region_count++; - if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - break; - } - - info->op_region_init++; - status = acpi_ds_get_region_arguments (obj_desc); - - - break; - - - case ACPI_TYPE_FIELD_UNIT: - - info->field_count++; - if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - break; - } - - info->field_init++; - status = acpi_ds_get_field_unit_arguments (obj_desc); - - - break; - - default: - break; - } - - /* - * We ignore errors from above, and always return OK, since - * we don't want to abort the walk on a single error. - */ - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_init_one_device - * - * PARAMETERS: WALK_CALLBACK - * - * RETURN: ACPI_STATUS - * - * DESCRIPTION: This is called once per device soon after ACPI is enabled - * to initialize each device. It determines if the device is - * present, and if so, calls _INI. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_init_one_device ( - ACPI_HANDLE obj_handle, - u32 nesting_level, - void *context, - void **return_value) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *node; - u32 flags; - ACPI_DEVICE_WALK_INFO *info = (ACPI_DEVICE_WALK_INFO *) context; - - - - info->device_count++; - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - node = acpi_ns_convert_handle_to_entry (obj_handle); - if (!node) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - /* - * Run _STA to determine if we can run _INI on the device. - */ - - status = acpi_cm_execute_STA (node, &flags); - if (ACPI_FAILURE (status)) { - /* Ignore error and move on to next device */ - - return (AE_OK); - } - - info->num_STA++; - - if (!(flags & 0x01)) { - /* don't look at children of a not present device */ - return(AE_CTRL_DEPTH); - } - - - /* - * The device is present. Run _INI. - */ - - status = acpi_ns_evaluate_relative (obj_handle, "_INI", NULL, NULL); - if (AE_NOT_FOUND == status) { - /* No _INI means device requires no initialization */ - status = AE_OK; - } - - else if (ACPI_FAILURE (status)) { - /* Ignore error and move on to next device */ - - } - - else { - /* Count of successful INIs */ - - info->num_INI++; - } - - return (AE_OK); -} diff --git a/reactos/drivers/bus/acpi/namespace/nsload.c b/reactos/drivers/bus/acpi/namespace/nsload.c deleted file mode 100644 index a74bf573d40..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsload.c +++ /dev/null @@ -1,521 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsload - namespace loading/expanding/contracting procedures - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsload") - - -/******************************************************************************* - * - * FUNCTION: Acpi_load_namespace - * - * PARAMETERS: Display_aml_during_load - * - * RETURN: Status - * - * DESCRIPTION: Load the name space from what ever is pointed to by DSDT. - * (DSDT points to either the BIOS or a buffer.) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_load_namespace ( - void) -{ - ACPI_STATUS status; - - - /* There must be at least a DSDT installed */ - - if (acpi_gbl_DSDT == NULL) { - return (AE_NO_ACPI_TABLES); - } - - - /* - * Load the namespace. The DSDT is required, - * but the SSDT and PSDT tables are optional. - */ - - status = acpi_ns_load_table_by_type (ACPI_TABLE_DSDT); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Ignore exceptions from these */ - - acpi_ns_load_table_by_type (ACPI_TABLE_SSDT); - acpi_ns_load_table_by_type (ACPI_TABLE_PSDT); - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_one_parse_pass - * - * PARAMETERS: - * - * RETURN: Status - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_one_complete_parse ( - u32 pass_number, - ACPI_TABLE_DESC *table_desc) -{ - ACPI_PARSE_DOWNWARDS descending_callback; - ACPI_PARSE_UPWARDS ascending_callback; - ACPI_PARSE_OBJECT *parse_root; - ACPI_STATUS status; - - - switch (pass_number) { - case 1: - descending_callback = acpi_ds_load1_begin_op; - ascending_callback = acpi_ds_load1_end_op; - break; - - case 2: - descending_callback = acpi_ds_load2_begin_op; - ascending_callback = acpi_ds_load2_end_op; - break; - - case 3: - descending_callback = acpi_ds_exec_begin_op; - ascending_callback = acpi_ds_exec_end_op; - break; - - default: - return (AE_BAD_PARAMETER); - } - - /* Create and init a Root Node */ - - parse_root = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!parse_root) { - return (AE_NO_MEMORY); - } - - ((ACPI_PARSE2_OBJECT *) parse_root)->name = ACPI_ROOT_NAME; - - - /* Pass 1: Parse everything except control method bodies */ - - status = acpi_ps_parse_aml (parse_root, table_desc->aml_pointer, - table_desc->aml_length, - ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, - NULL, NULL, NULL, descending_callback, - ascending_callback); - - acpi_ps_delete_parse_tree (parse_root); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_parse_table - * - * PARAMETERS: Table_desc - An ACPI table descriptor for table to parse - * Start_node - Where to enter the table into the namespace - * - * RETURN: Status - * - * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_parse_table ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMESPACE_NODE *start_node) -{ - ACPI_STATUS status; - - - /* - * AML Parse, pass 1 - * - * In this pass, we load most of the namespace. Control methods - * are not parsed until later. A parse tree is not created. Instead, - * each Parser Op subtree is deleted when it is finished. This saves - * a great deal of memory, and allows a small cache of parse objects - * to service the entire parse. The second pass of the parse then - * performs another complete parse of the AML.. - */ - - status = acpi_ns_one_complete_parse (1, table_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* - * AML Parse, pass 2 - * - * In this pass, we resolve forward references and other things - * that could not be completed during the first pass. - * Another complete parse of the AML is performed, but the - * overhead of this is compensated for by the fact that the - * parse objects are all cached. - */ - - status = acpi_ns_one_complete_parse (2, table_desc); - if (ACPI_FAILURE (status)) { - return (status); - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_load_table - * - * PARAMETERS: *Pcode_addr - Address of pcode block - * Pcode_length - Length of pcode block - * - * RETURN: Status - * - * DESCRIPTION: Load one ACPI table into the namespace - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_load_table ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMESPACE_NODE *node) -{ - ACPI_STATUS status; - - - if (!table_desc->aml_pointer) { - return (AE_BAD_PARAMETER); - } - - - if (!table_desc->aml_length) { - return (AE_BAD_PARAMETER); - } - - - /* - * Parse the table and load the namespace with all named - * objects found within. Control methods are NOT parsed - * at this time. In fact, the control methods cannot be - * parsed until the entire namespace is loaded, because - * if a control method makes a forward reference (call) - * to another control method, we can't continue parsing - * because we don't know how many arguments to parse next! - */ - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - status = acpi_ns_parse_table (table_desc, node->child); - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Now we can parse the control methods. We always parse - * them here for a sanity check, and if configured for - * just-in-time parsing, we delete the control method - * parse trees. - */ - - status = acpi_ds_initialize_objects (table_desc, node); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_load_table_by_type - * - * PARAMETERS: Table_type - Id of the table type to load - * - * RETURN: Status - * - * DESCRIPTION: Load an ACPI table or tables into the namespace. All tables - * of the given type are loaded. The mechanism allows this - * routine to be called repeatedly. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_load_table_by_type ( - ACPI_TABLE_TYPE table_type) -{ - u32 i; - ACPI_STATUS status = AE_OK; - ACPI_TABLE_HEADER *table_ptr; - ACPI_TABLE_DESC *table_desc; - - - acpi_cm_acquire_mutex (ACPI_MTX_TABLES); - - - /* - * Table types supported are: - * DSDT (one), SSDT/PSDT (multiple) - */ - - switch (table_type) { - - case ACPI_TABLE_DSDT: - - table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_DSDT]; - - /* If table already loaded into namespace, just return */ - - if (table_desc->loaded_into_namespace) { - goto unlock_and_exit; - } - - table_desc->table_id = TABLE_ID_DSDT; - - /* Now load the single DSDT */ - - status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); - if (ACPI_SUCCESS (status)) { - table_desc->loaded_into_namespace = TRUE; - } - - break; - - - case ACPI_TABLE_SSDT: - - /* - * Traverse list of SSDT tables - */ - - table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_SSDT]; - for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_SSDT].count; i++) { - table_ptr = table_desc->pointer; - - /* - * Only attempt to load table if it is not - * already loaded! - */ - - if (!table_desc->loaded_into_namespace) { - status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); - if (ACPI_FAILURE (status)) { - break; - } - - table_desc->loaded_into_namespace = TRUE; - } - - table_desc = table_desc->next; - } - break; - - - case ACPI_TABLE_PSDT: - - /* - * Traverse list of PSDT tables - */ - - table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_PSDT]; - - for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_PSDT].count; i++) { - table_ptr = table_desc->pointer; - - /* Only attempt to load table if it is not already loaded! */ - - if (!table_desc->loaded_into_namespace) { - status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); - if (ACPI_FAILURE (status)) { - break; - } - - table_desc->loaded_into_namespace = TRUE; - } - - table_desc = table_desc->next; - } - - break; - - - default: - status = AE_SUPPORT; - break; - } - - -unlock_and_exit: - - acpi_cm_release_mutex (ACPI_MTX_TABLES); - - return (status); - -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_delete_subtree - * - * PARAMETERS: Start_handle - Handle in namespace where search begins - * - * RETURNS Status - * - * DESCRIPTION: Walks the namespace starting at the given handle and deletes - * all objects, entries, and scopes in the entire subtree. - * - * TBD: [Investigate] What if any part of this subtree is in use? - * (i.e. on one of the object stacks?) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_delete_subtree ( - ACPI_HANDLE start_handle) -{ - ACPI_STATUS status; - ACPI_HANDLE child_handle; - ACPI_HANDLE parent_handle; - ACPI_HANDLE next_child_handle; - ACPI_HANDLE dummy; - u32 level; - - - parent_handle = start_handle; - child_handle = 0; - level = 1; - - /* - * Traverse the tree of objects until we bubble back up - * to where we started. - */ - - while (level > 0) { - /* Attempt to get the next object in this scope */ - - status = acpi_get_next_object (ACPI_TYPE_ANY, parent_handle, - child_handle, &next_child_handle); - - child_handle = next_child_handle; - - - /* Did we get a new object? */ - - if (ACPI_SUCCESS (status)) { - /* Check if this object has any children */ - - if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle, - 0, &dummy))) { - /* - * There is at least one child of this object, - * visit the object - */ - - level++; - parent_handle = child_handle; - child_handle = 0; - } - } - - else { - /* - * No more children in this object, go back up to - * the object's parent - */ - level--; - - /* Delete all children now */ - - acpi_ns_delete_children (child_handle); - - child_handle = parent_handle; - acpi_get_parent (parent_handle, &parent_handle); - } - } - - /* Now delete the starting object, and we are done */ - - acpi_ns_delete_node (child_handle); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_unload_name_space - * - * PARAMETERS: Handle - Root of namespace subtree to be deleted - * - * RETURN: Status - * - * DESCRIPTION: Shrinks the namespace, typically in response to an undocking - * event. Deletes an entire subtree starting from (and - * including) the given handle. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_unload_namespace ( - ACPI_HANDLE handle) -{ - ACPI_STATUS status; - - - /* Parameter validation */ - - if (!acpi_gbl_root_node) { - return (AE_NO_NAMESPACE); - } - - if (!handle) { - return (AE_BAD_PARAMETER); - } - - - /* This function does the real work */ - - status = acpi_ns_delete_subtree (handle); - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/namespace/nsnames.c b/reactos/drivers/bus/acpi/namespace/nsnames.c deleted file mode 100644 index e39a344ff5d..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsnames.c +++ /dev/null @@ -1,245 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsnames - Name manipulation and search - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsnames") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_get_table_pathname - * - * PARAMETERS: Node - Scope whose name is needed - * - * RETURN: Pointer to storage containing the fully qualified name of - * the scope, in Label format (all segments strung together - * with no separators) - * - * DESCRIPTION: Used for debug printing in Acpi_ns_search_table(). - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_ns_get_table_pathname ( - ACPI_NAMESPACE_NODE *node) -{ - NATIVE_CHAR *name_buffer; - u32 size; - ACPI_NAME name; - ACPI_NAMESPACE_NODE *child_node; - ACPI_NAMESPACE_NODE *parent_node; - - - if (!acpi_gbl_root_node || !node) { - /* - * If the name space has not been initialized, - * this function should not have been called. - */ - return (NULL); - } - - child_node = node->child; - - - /* Calculate required buffer size based on depth below root */ - - size = 1; - parent_node = child_node; - while (parent_node) { - parent_node = acpi_ns_get_parent_object (parent_node); - if (parent_node) { - size += ACPI_NAME_SIZE; - } - } - - - /* Allocate a buffer to be returned to caller */ - - name_buffer = acpi_cm_callocate (size + 1); - if (!name_buffer) { - REPORT_ERROR (("Ns_get_table_pathname: allocation failure\n")); - return (NULL); - } - - - /* Store terminator byte, then build name backwards */ - - name_buffer[size] = '\0'; - while ((size > ACPI_NAME_SIZE) && - acpi_ns_get_parent_object (child_node)) { - size -= ACPI_NAME_SIZE; - name = acpi_ns_find_parent_name (child_node); - - /* Put the name into the buffer */ - - MOVE_UNALIGNED32_TO_32 ((name_buffer + size), &name); - child_node = acpi_ns_get_parent_object (child_node); - } - - name_buffer[--size] = AML_ROOT_PREFIX; - - - return (name_buffer); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_get_pathname_length - * - * PARAMETERS: Node - Namespace node - * - * RETURN: Length of path, including prefix - * - * DESCRIPTION: Get the length of the pathname string for this node - * - ******************************************************************************/ - -u32 -acpi_ns_get_pathname_length ( - ACPI_NAMESPACE_NODE *node) -{ - u32 size; - ACPI_NAMESPACE_NODE *next_node; - - /* - * Compute length of pathname as 5 * number of name segments. - * Go back up the parent tree to the root - */ - for (size = 0, next_node = node; - acpi_ns_get_parent_object (next_node); - next_node = acpi_ns_get_parent_object (next_node)) { - size += PATH_SEGMENT_LENGTH; - } - - /* Special case for size still 0 - no parent for "special" nodes */ - - if (!size) { - size = PATH_SEGMENT_LENGTH; - } - - return (size + 1); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_handle_to_pathname - * - * PARAMETERS: Target_handle - Handle of named object whose name is - * to be found - * Buf_size - Size of the buffer provided - * User_buffer - Where the pathname is returned - * - * RETURN: Status, Buffer is filled with pathname if status is AE_OK - * - * DESCRIPTION: Build and return a full namespace pathname - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_handle_to_pathname ( - ACPI_HANDLE target_handle, - u32 *buf_size, - NATIVE_CHAR *user_buffer) -{ - ACPI_STATUS status = AE_OK; - ACPI_NAMESPACE_NODE *node; - u32 path_length; - u32 user_buf_size; - ACPI_NAME name; - u32 size; - - - if (!acpi_gbl_root_node || !target_handle) { - /* - * If the name space has not been initialized, - * this function should not have been called. - */ - - return (AE_NO_NAMESPACE); - } - - node = acpi_ns_convert_handle_to_entry (target_handle); - if (!node) { - return (AE_BAD_PARAMETER); - } - - - /* Set return length to the required path length */ - - path_length = acpi_ns_get_pathname_length (node); - size = path_length - 1; - - user_buf_size = *buf_size; - *buf_size = path_length; - - /* Check if the user buffer is sufficiently large */ - - if (path_length > user_buf_size) { - status = AE_BUFFER_OVERFLOW; - goto exit; - } - - /* Store null terminator */ - - user_buffer[size] = 0; - size -= ACPI_NAME_SIZE; - - /* Put the original ACPI name at the end of the path */ - - MOVE_UNALIGNED32_TO_32 ((user_buffer + size), - &node->name); - - user_buffer[--size] = PATH_SEPARATOR; - - /* Build name backwards, putting "." between segments */ - - while ((size > ACPI_NAME_SIZE) && node) { - size -= ACPI_NAME_SIZE; - name = acpi_ns_find_parent_name (node); - MOVE_UNALIGNED32_TO_32 ((user_buffer + size), &name); - - user_buffer[--size] = PATH_SEPARATOR; - node = acpi_ns_get_parent_object (node); - } - - /* - * Overlay the "." preceding the first segment with - * the root name "\" - */ - - user_buffer[size] = '\\'; - -exit: - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/namespace/nsobject.c b/reactos/drivers/bus/acpi/namespace/nsobject.c deleted file mode 100644 index 0a114f6e903..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsobject.c +++ /dev/null @@ -1,356 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsobject - Utilities for objects attached to namespace - * table entries - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsobject") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_attach_object - * - * PARAMETERS: Node - Parent Node - * Object - Object to be attached - * Type - Type of object, or ACPI_TYPE_ANY if not - * known - * - * DESCRIPTION: Record the given object as the value associated with the - * name whose ACPI_HANDLE is passed. If Object is NULL - * and Type is ACPI_TYPE_ANY, set the name as having no value. - * - * MUTEX: Assumes namespace is locked - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_attach_object ( - ACPI_NAMESPACE_NODE *node, - ACPI_OPERAND_OBJECT *object, - OBJECT_TYPE_INTERNAL type) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_OPERAND_OBJECT *previous_obj_desc; - OBJECT_TYPE_INTERNAL obj_type = ACPI_TYPE_ANY; - u8 flags; - u16 opcode; - - - /* - * Parameter validation - */ - - if (!acpi_gbl_root_node) { - /* Name space not initialized */ - - REPORT_ERROR (("Ns_attach_object: Namespace not initialized\n")); - return (AE_NO_NAMESPACE); - } - - if (!node) { - /* Invalid handle */ - - REPORT_ERROR (("Ns_attach_object: Null Named_obj handle\n")); - return (AE_BAD_PARAMETER); - } - - if (!object && (ACPI_TYPE_ANY != type)) { - /* Null object */ - - REPORT_ERROR (("Ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); - return (AE_BAD_PARAMETER); - } - - if (!VALID_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED)) { - /* Not a name handle */ - - REPORT_ERROR (("Ns_attach_object: Invalid handle\n")); - return (AE_BAD_PARAMETER); - } - - /* Check if this object is already attached */ - - if (node->object == object) { - return (AE_OK); - } - - - /* Get the current flags field of the Node */ - - flags = node->flags; - flags &= ~ANOBJ_AML_ATTACHMENT; - - - /* If null object, we will just install it */ - - if (!object) { - obj_desc = NULL; - obj_type = ACPI_TYPE_ANY; - } - - /* - * If the object is an Node with an attached object, - * we will use that (attached) object - */ - - else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED) && - ((ACPI_NAMESPACE_NODE *) object)->object) { - /* - * Value passed is a name handle and that name has a - * non-null value. Use that name's value and type. - */ - - obj_desc = ((ACPI_NAMESPACE_NODE *) object)->object; - obj_type = ((ACPI_NAMESPACE_NODE *) object)->type; - - /* - * Copy appropriate flags - */ - - if (((ACPI_NAMESPACE_NODE *) object)->flags & ANOBJ_AML_ATTACHMENT) { - flags |= ANOBJ_AML_ATTACHMENT; - } - } - - - /* - * Otherwise, we will use the parameter object, but we must type - * it first - */ - - else { - obj_desc = (ACPI_OPERAND_OBJECT *) object; - - - /* If a valid type (non-ANY) was given, just use it */ - - if (ACPI_TYPE_ANY != type) { - obj_type = type; - } - - - /* - * Type is TYPE_Any, we must try to determinte the - * actual type of the object - */ - - /* - * Check if value points into the AML code - */ - else if (acpi_tb_system_table_pointer (object)) { - /* - * Object points into the AML stream. - * Set a flag bit in the Node to indicate this - */ - - flags |= ANOBJ_AML_ATTACHMENT; - - /* - * The next byte (perhaps the next two bytes) - * will be the AML opcode - */ - - MOVE_UNALIGNED16_TO_16 (&opcode, object); - - /* Check for a recognized Opcode */ - - switch (opcode) { - - case AML_OP_PREFIX: - - if (opcode != AML_REVISION_OP) { - /* - * Op_prefix is unrecognized unless part - * of Revision_op - */ - - break; - } - - /* Else fall through to set type as Number */ - - - case AML_ZERO_OP: case AML_ONES_OP: case AML_ONE_OP: - case AML_BYTE_OP: case AML_WORD_OP: case AML_DWORD_OP: - - obj_type = ACPI_TYPE_INTEGER; - break; - - - case AML_STRING_OP: - - obj_type = ACPI_TYPE_STRING; - break; - - - case AML_BUFFER_OP: - - obj_type = ACPI_TYPE_BUFFER; - break; - - - case AML_MUTEX_OP: - - obj_type = ACPI_TYPE_MUTEX; - break; - - - case AML_PACKAGE_OP: - - obj_type = ACPI_TYPE_PACKAGE; - break; - - - default: - - return (AE_TYPE); - break; - } - } - - else { - /* - * Cannot figure out the type -- set to Def_any which - * will print as an error in the name table dump - */ - - - obj_type = INTERNAL_TYPE_DEF_ANY; - } - } - - - /* - * Must increment the new value's reference count - * (if it is an internal object) - */ - - acpi_cm_add_reference (obj_desc); - - /* Save the existing object (if any) for deletion later */ - - previous_obj_desc = node->object; - - /* Install the object and set the type, flags */ - - node->object = obj_desc; - node->type = (u8) obj_type; - node->flags |= flags; - - - /* - * Delete an existing attached object. - */ - - if (previous_obj_desc) { - /* One for the attach to the Node */ - - acpi_cm_remove_reference (previous_obj_desc); - - /* Now delete */ - - acpi_cm_remove_reference (previous_obj_desc); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_detach_object - * - * PARAMETERS: Node - An object whose Value will be deleted - * - * RETURN: None. - * - * DESCRIPTION: Delete the Value associated with a namespace object. If the - * Value is an allocated object, it is freed. Otherwise, the - * field is simply cleared. - * - ******************************************************************************/ - -void -acpi_ns_detach_object ( - ACPI_NAMESPACE_NODE *node) -{ - ACPI_OPERAND_OBJECT *obj_desc; - - - obj_desc = node->object; - if (!obj_desc) { - return; - } - - /* Clear the entry in all cases */ - - node->object = NULL; - - /* Found a valid value */ - - /* - * Not every value is an object allocated via Acpi_cm_callocate, - * - must check - */ - - if (!acpi_tb_system_table_pointer (obj_desc)) { - /* Attempt to delete the object (and all subobjects) */ - - acpi_cm_remove_reference (obj_desc); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_get_attached_object - * - * PARAMETERS: Handle - Parent Node to be examined - * - * RETURN: Current value of the object field from the Node whose - * handle is passed - * - ******************************************************************************/ - -void * -acpi_ns_get_attached_object ( - ACPI_HANDLE handle) -{ - - if (!handle) { - /* handle invalid */ - - return (NULL); - } - - return (((ACPI_NAMESPACE_NODE *) handle)->object); -} - - diff --git a/reactos/drivers/bus/acpi/namespace/nssearch.c b/reactos/drivers/bus/acpi/namespace/nssearch.c deleted file mode 100644 index 53d6f19568b..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nssearch.c +++ /dev/null @@ -1,342 +0,0 @@ -/******************************************************************************* - * - * Module Name: nssearch - Namespace search - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nssearch") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_search_node - * - * PARAMETERS: *Target_name - Ascii ACPI name to search for - * *Node - Starting table where search will begin - * Type - Object type to match - * **Return_node - Where the matched Named obj is returned - * - * RETURN: Status - * - * DESCRIPTION: Search a single namespace table. Performs a simple search, - * does not add entries or search parents. - * - * - * Named object lists are built (and subsequently dumped) in the - * order in which the names are encountered during the namespace load; - * - * All namespace searching is linear in this implementation, but - * could be easily modified to support any improved search - * algorithm. However, the linear search was chosen for simplicity - * and because the trees are small and the other interpreter - * execution overhead is relatively high. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_search_node ( - u32 target_name, - ACPI_NAMESPACE_NODE *node, - OBJECT_TYPE_INTERNAL type, - ACPI_NAMESPACE_NODE **return_node) -{ - ACPI_NAMESPACE_NODE *next_node; - - - /* - * Search for name in this table, which is to say that we must search - * for the name among the children of this object - */ - - next_node = node->child; - while (next_node) { - /* Check for match against the name */ - - if (next_node->name == target_name) { - /* - * Found matching entry. Capture the type if appropriate, before - * returning the entry. - * - * The Def_field_defn and Bank_field_defn cases are actually looking up - * the Region in which the field will be defined - */ - - if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) { - type = ACPI_TYPE_REGION; - } - - /* - * Scope, Def_any, and Index_field_defn are bogus "types" which do not - * actually have anything to do with the type of the name being - * looked up. For any other value of Type, if the type stored in - * the entry is Any (i.e. unknown), save the actual type. - */ - - if (type != INTERNAL_TYPE_SCOPE && - type != INTERNAL_TYPE_DEF_ANY && - type != INTERNAL_TYPE_INDEX_FIELD_DEFN && - next_node->type == ACPI_TYPE_ANY) { - next_node->type = (u8) type; - } - - *return_node = next_node; - return (AE_OK); - } - - - /* - * The last entry in the list points back to the parent, - * so a flag is used to indicate the end-of-list - */ - if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { - /* Searched entire list, we are done */ - - break; - } - - /* Didn't match name, move on to the next peer object */ - - next_node = next_node->peer; - } - - - /* Searched entire table, not found */ - - - return (AE_NOT_FOUND); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_search_parent_tree - * - * PARAMETERS: *Target_name - Ascii ACPI name to search for - * *Node - Starting table where search will begin - * Type - Object type to match - * **Return_node - Where the matched Named Obj is returned - * - * RETURN: Status - * - * DESCRIPTION: Called when a name has not been found in the current namespace - * table. Before adding it or giving up, ACPI scope rules require - * searching enclosing scopes in cases identified by Acpi_ns_local(). - * - * "A name is located by finding the matching name in the current - * name space, and then in the parent name space. If the parent - * name space does not contain the name, the search continues - * recursively until either the name is found or the name space - * does not have a parent (the root of the name space). This - * indicates that the name is not found" (From ACPI Specification, - * section 5.3) - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_ns_search_parent_tree ( - u32 target_name, - ACPI_NAMESPACE_NODE *node, - OBJECT_TYPE_INTERNAL type, - ACPI_NAMESPACE_NODE **return_node) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *parent_node; - - - parent_node = acpi_ns_get_parent_object (node); - - /* - * If there is no parent (at the root) or type is "local", we won't be - * searching the parent tree. - */ - if ((acpi_ns_local (type)) || - (!parent_node)) { - - - return (AE_NOT_FOUND); - } - - - /* Search the parent tree */ - - /* - * Search parents until found the target or we have backed up to - * the root - */ - - while (parent_node) { - /* Search parent scope */ - /* TBD: [Investigate] Why ACPI_TYPE_ANY? */ - - status = acpi_ns_search_node (target_name, parent_node, - ACPI_TYPE_ANY, return_node); - - if (ACPI_SUCCESS (status)) { - return (status); - } - - /* - * Not found here, go up another level - * (until we reach the root) - */ - - parent_node = acpi_ns_get_parent_object (parent_node); - } - - - /* Not found in parent tree */ - - return (AE_NOT_FOUND); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_search_and_enter - * - * PARAMETERS: Target_name - Ascii ACPI name to search for (4 chars) - * Walk_state - Current state of the walk - * *Node - Starting table where search will begin - * Interpreter_mode - Add names only in MODE_Load_pass_x. - * Otherwise,search only. - * Type - Object type to match - * Flags - Flags describing the search restrictions - * **Return_node - Where the Node is returned - * - * RETURN: Status - * - * DESCRIPTION: Search for a name segment in a single name table, - * optionally adding it if it is not found. If the passed - * Type is not Any and the type previously stored in the - * entry was Any (i.e. unknown), update the stored type. - * - * In IMODE_EXECUTE, search only. - * In other modes, search and add if not found. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_search_and_enter ( - u32 target_name, - ACPI_WALK_STATE *walk_state, - ACPI_NAMESPACE_NODE *node, - OPERATING_MODE interpreter_mode, - OBJECT_TYPE_INTERNAL type, - u32 flags, - ACPI_NAMESPACE_NODE **return_node) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *new_node; - - - /* Parameter validation */ - - if (!node || !target_name || !return_node) { - REPORT_ERROR (("Ns_search_and_enter: bad (null) parameter\n")); - return (AE_BAD_PARAMETER); - } - - - /* Name must consist of printable characters */ - - if (!acpi_cm_valid_acpi_name (target_name)) { - REPORT_ERROR (("Ns_search_and_enter: Bad character in ACPI Name\n")); - return (AE_BAD_CHARACTER); - } - - - /* Try to find the name in the table specified by the caller */ - - *return_node = ENTRY_NOT_FOUND; - status = acpi_ns_search_node (target_name, node, - type, return_node); - if (status != AE_NOT_FOUND) { - /* - * If we found it AND the request specifies that a find is an error, - * return the error - */ - if ((status == AE_OK) && - (flags & NS_ERROR_IF_FOUND)) { - status = AE_EXIST; - } - - /* - * Either found it or there was an error - * -- finished either way - */ - return (status); - } - - - /* - * Not found in the table. If we are NOT performing the - * first pass (name entry) of loading the namespace, search - * the parent tree (all the way to the root if necessary.) - * We don't want to perform the parent search when the - * namespace is actually being loaded. We want to perform - * the search when namespace references are being resolved - * (load pass 2) and during the execution phase. - */ - - if ((interpreter_mode != IMODE_LOAD_PASS1) && - (flags & NS_SEARCH_PARENT)) { - /* - * Not found in table - search parent tree according - * to ACPI specification - */ - - status = acpi_ns_search_parent_tree (target_name, node, - type, return_node); - if (ACPI_SUCCESS (status)) { - return (status); - } - } - - - /* - * In execute mode, just search, never add names. Exit now. - */ - if (interpreter_mode == IMODE_EXECUTE) { - return (AE_NOT_FOUND); - } - - - /* Create the new named object */ - - new_node = acpi_ns_create_node (target_name); - if (!new_node) { - return (AE_NO_MEMORY); - } - - /* Install the new object into the parent's list of children */ - - acpi_ns_install_node (walk_state, node, new_node, type); - *return_node = new_node; - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/namespace/nsutils.c b/reactos/drivers/bus/acpi/namespace/nsutils.c deleted file mode 100644 index 268352075b8..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsutils.c +++ /dev/null @@ -1,811 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing - * parents and siblings and Scope manipulation - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsutils") - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_valid_root_prefix - * - * PARAMETERS: Prefix - Character to be checked - * - * RETURN: TRUE if a valid prefix - * - * DESCRIPTION: Check if a character is a valid ACPI Root prefix - * - ***************************************************************************/ - -u8 -acpi_ns_valid_root_prefix ( - NATIVE_CHAR prefix) -{ - - return ((u8) (prefix == '\\')); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_valid_path_separator - * - * PARAMETERS: Sep - Character to be checked - * - * RETURN: TRUE if a valid path separator - * - * DESCRIPTION: Check if a character is a valid ACPI path separator - * - ***************************************************************************/ - -u8 -acpi_ns_valid_path_separator ( - NATIVE_CHAR sep) -{ - - return ((u8) (sep == '.')); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_get_type - * - * PARAMETERS: Handle - Parent Node to be examined - * - * RETURN: Type field from Node whose handle is passed - * - ***************************************************************************/ - -OBJECT_TYPE_INTERNAL -acpi_ns_get_type ( - ACPI_HANDLE handle) -{ - - if (!handle) { - REPORT_WARNING (("Ns_get_type: Null handle\n")); - return (ACPI_TYPE_ANY); - } - - return (((ACPI_NAMESPACE_NODE *) handle)->type); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_local - * - * PARAMETERS: Type - A namespace object type - * - * RETURN: LOCAL if names must be found locally in objects of the - * passed type, 0 if enclosing scopes should be searched - * - ***************************************************************************/ - -u32 -acpi_ns_local ( - OBJECT_TYPE_INTERNAL type) -{ - - if (!acpi_cm_valid_object_type (type)) { - /* Type code out of range */ - - REPORT_WARNING (("Ns_local: Invalid Object Type\n")); - return (NSP_NORMAL); - } - - return ((u32) acpi_gbl_ns_properties[type] & NSP_LOCAL); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_internalize_name - * - * PARAMETERS: *External_name - External representation of name - * **Converted Name - Where to return the resulting - * internal represention of the name - * - * RETURN: Status - * - * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0") - * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ns_internalize_name ( - NATIVE_CHAR *external_name, - NATIVE_CHAR **converted_name) -{ - NATIVE_CHAR *result = NULL; - NATIVE_CHAR *internal_name; - u32 num_segments = 0; - u8 fully_qualified = FALSE; - u32 i; - u32 num_carats = 0; - - - if ((!external_name) || - (*external_name == 0) || - (!converted_name)) { - return (AE_BAD_PARAMETER); - } - - - /* - * For the internal name, the required length is 4 bytes - * per segment, plus 1 each for Root_prefix, Multi_name_prefix_op, - * segment count, trailing null (which is not really needed, - * but no there's harm in putting it there) - * - * strlen() + 1 covers the first Name_seg, which has no - * path separator - */ - - if (acpi_ns_valid_root_prefix (external_name[0])) { - fully_qualified = TRUE; - external_name++; - } - - else { - /* - * Handle Carat prefixes - */ - - while (*external_name == '^') { - num_carats++; - external_name++; - } - } - - /* - * Determine the number of ACPI name "segments" by counting - * the number of path separators within the string. Start - * with one segment since the segment count is (# separators) - * + 1, and zero separators is ok. - */ - - if (*external_name) { - num_segments = 1; - for (i = 0; external_name[i]; i++) { - if (acpi_ns_valid_path_separator (external_name[i])) { - num_segments++; - } - } - } - - - /* We need a segment to store the internal version of the name */ - - internal_name = acpi_cm_callocate ((ACPI_NAME_SIZE * num_segments) + 4 + num_carats); - if (!internal_name) { - return (AE_NO_MEMORY); - } - - - /* Setup the correct prefixes, counts, and pointers */ - - if (fully_qualified) { - internal_name[0] = '\\'; - - if (num_segments <= 1) { - result = &internal_name[1]; - } - else if (num_segments == 2) { - internal_name[1] = AML_DUAL_NAME_PREFIX; - result = &internal_name[2]; - } - else { - internal_name[1] = AML_MULTI_NAME_PREFIX_OP; - internal_name[2] = (char) num_segments; - result = &internal_name[3]; - } - - } - - else { - /* - * Not fully qualified. - * Handle Carats first, then append the name segments - */ - - i = 0; - if (num_carats) { - for (i = 0; i < num_carats; i++) { - internal_name[i] = '^'; - } - } - - if (num_segments == 1) { - result = &internal_name[i]; - } - - else if (num_segments == 2) { - internal_name[i] = AML_DUAL_NAME_PREFIX; - result = &internal_name[i+1]; - } - - else { - internal_name[i] = AML_MULTI_NAME_PREFIX_OP; - internal_name[i+1] = (char) num_segments; - result = &internal_name[i+2]; - } - } - - - /* Build the name (minus path separators) */ - - for (; num_segments; num_segments--) { - for (i = 0; i < ACPI_NAME_SIZE; i++) { - if (acpi_ns_valid_path_separator (*external_name) || - (*external_name == 0)) { - /* - * Pad the segment with underscore(s) if - * segment is short - */ - - result[i] = '_'; - } - - else { - /* Convert s8 to uppercase and save it */ - - result[i] = (char) TOUPPER (*external_name); - external_name++; - } - - } - - /* Now we must have a path separator, or the pathname is bad */ - - if (!acpi_ns_valid_path_separator (*external_name) && - (*external_name != 0)) { - acpi_cm_free (internal_name); - return (AE_BAD_PARAMETER); - } - - /* Move on the next segment */ - - external_name++; - result += ACPI_NAME_SIZE; - } - - - /* Return the completed name */ - - /* Terminate the string! */ - *result = 0; - *converted_name = internal_name; - - - - return (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_externalize_name - * - * PARAMETERS: *Internal_name - Internal representation of name - * **Converted_name - Where to return the resulting - * external representation of name - * - * RETURN: Status - * - * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) - * to its external form (e.g. "\_PR_.CPU0") - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ns_externalize_name ( - u32 internal_name_length, - char *internal_name, - u32 *converted_name_length, - char **converted_name) -{ - u32 prefix_length = 0; - u32 names_index = 0; - u32 names_count = 0; - u32 i = 0; - u32 j = 0; - - - if (!internal_name_length || - !internal_name || - !converted_name_length || - !converted_name) { - return (AE_BAD_PARAMETER); - } - - - /* - * Check for a prefix (one '\' | one or more '^'). - */ - switch (internal_name[0]) { - case '\\': - prefix_length = 1; - break; - - case '^': - for (i = 0; i < internal_name_length; i++) { - if (internal_name[i] != '^') { - prefix_length = i + 1; - } - } - - if (i == internal_name_length) { - prefix_length = i; - } - - break; - } - - /* - * Check for object names. Note that there could be 0-255 of these - * 4-byte elements. - */ - if (prefix_length < internal_name_length) { - switch (internal_name[prefix_length]) { - - /* 4-byte names */ - - case AML_MULTI_NAME_PREFIX_OP: - names_index = prefix_length + 2; - names_count = (u32) internal_name[prefix_length + 1]; - break; - - - /* two 4-byte names */ - - case AML_DUAL_NAME_PREFIX: - names_index = prefix_length + 1; - names_count = 2; - break; - - - /* Null_name */ - - case 0: - names_index = 0; - names_count = 0; - break; - - - /* one 4-byte name */ - - default: - names_index = prefix_length; - names_count = 1; - break; - } - } - - /* - * Calculate the length of Converted_name, which equals the length - * of the prefix, length of all object names, length of any required - * punctuation ('.') between object names, plus the NULL terminator. - */ - *converted_name_length = prefix_length + (4 * names_count) + - ((names_count > 0) ? (names_count - 1) : 0) + 1; - - /* - * Check to see if we're still in bounds. If not, there's a problem - * with Internal_name (invalid format). - */ - if (*converted_name_length > internal_name_length) { - REPORT_ERROR (("Ns_externalize_name: Invalid internal name\n")); - return (AE_BAD_PATHNAME); - } - - /* - * Build Converted_name... - */ - - (*converted_name) = acpi_cm_callocate (*converted_name_length); - if (!(*converted_name)) { - return (AE_NO_MEMORY); - } - - j = 0; - - for (i = 0; i < prefix_length; i++) { - (*converted_name)[j++] = internal_name[i]; - } - - if (names_count > 0) { - for (i = 0; i < names_count; i++) { - if (i > 0) { - (*converted_name)[j++] = '.'; - } - - (*converted_name)[j++] = internal_name[names_index++]; - (*converted_name)[j++] = internal_name[names_index++]; - (*converted_name)[j++] = internal_name[names_index++]; - (*converted_name)[j++] = internal_name[names_index++]; - } - } - - return (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_convert_handle_to_entry - * - * PARAMETERS: Handle - Handle to be converted to an Node - * - * RETURN: A Name table entry pointer - * - * DESCRIPTION: Convert a namespace handle to a real Node - * - ****************************************************************************/ - -ACPI_NAMESPACE_NODE * -acpi_ns_convert_handle_to_entry ( - ACPI_HANDLE handle) -{ - - /* - * Simple implementation for now; - * TBD: [Future] Real integer handles allow for more verification - * and keep all pointers within this subsystem! - */ - - if (!handle) { - return (NULL); - } - - if (handle == ACPI_ROOT_OBJECT) { - return (acpi_gbl_root_node); - } - - - /* We can at least attempt to verify the handle */ - - if (!VALID_DESCRIPTOR_TYPE (handle, ACPI_DESC_TYPE_NAMED)) { - return (NULL); - } - - return ((ACPI_NAMESPACE_NODE *) handle); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_convert_entry_to_handle - * - * PARAMETERS: Node - Node to be converted to a Handle - * - * RETURN: An USER ACPI_HANDLE - * - * DESCRIPTION: Convert a real Node to a namespace handle - * - ****************************************************************************/ - -ACPI_HANDLE -acpi_ns_convert_entry_to_handle ( - ACPI_NAMESPACE_NODE *node) -{ - - - /* - * Simple implementation for now; - * TBD: [Future] Real integer handles allow for more verification - * and keep all pointers within this subsystem! - */ - - return ((ACPI_HANDLE) node); - - -/* --------------------------------------------------- - - if (!Node) - { - return (NULL); - } - - if (Node == Acpi_gbl_Root_node) - { - return (ACPI_ROOT_OBJECT); - } - - - return ((ACPI_HANDLE) Node); -------------------------------------------------------*/ -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ns_terminate - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: free memory allocated for table storage. - * - ******************************************************************************/ - -void -acpi_ns_terminate (void) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_NAMESPACE_NODE *this_node; - - - this_node = acpi_gbl_root_node; - - /* - * 1) Free the entire namespace -- all objects, tables, and stacks - */ - /* - * Delete all objects linked to the root - * (additional table descriptors) - */ - - acpi_ns_delete_namespace_subtree (this_node); - - /* Detach any object(s) attached to the root */ - - obj_desc = acpi_ns_get_attached_object (this_node); - if (obj_desc) { - acpi_ns_detach_object (this_node); - acpi_cm_remove_reference (obj_desc); - } - - acpi_ns_delete_children (this_node); - - - /* - * 2) Now we can delete the ACPI tables - */ - - acpi_tb_delete_acpi_tables (); - - return; -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_opens_scope - * - * PARAMETERS: Type - A valid namespace type - * - * RETURN: NEWSCOPE if the passed type "opens a name scope" according - * to the ACPI specification, else 0 - * - ***************************************************************************/ - -u32 -acpi_ns_opens_scope ( - OBJECT_TYPE_INTERNAL type) -{ - - if (!acpi_cm_valid_object_type (type)) { - /* type code out of range */ - - REPORT_WARNING (("Ns_opens_scope: Invalid Object Type\n")); - return (NSP_NORMAL); - } - - return (((u32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_get_node - * - * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The - * \ (backslash) and ^ (carat) prefixes, and the - * . (period) to separate segments are supported. - * Start_node - Root of subtree to be searched, or NS_ALL for the - * root of the name space. If Name is fully - * qualified (first s8 is '\'), the passed value - * of Scope will not be accessed. - * Return_node - Where the Node is returned - * - * DESCRIPTION: Look up a name relative to a given scope and return the - * corresponding Node. NOTE: Scope can be null. - * - * MUTEX: Locks namespace - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ns_get_node ( - NATIVE_CHAR *pathname, - ACPI_NAMESPACE_NODE *start_node, - ACPI_NAMESPACE_NODE **return_node) -{ - ACPI_GENERIC_STATE scope_info; - ACPI_STATUS status; - NATIVE_CHAR *internal_path = NULL; - - - /* Ensure that the namespace has been initialized */ - - if (!acpi_gbl_root_node) { - return (AE_NO_NAMESPACE); - } - - if (!pathname) { - return (AE_BAD_PARAMETER); - } - - - /* Convert path to internal representation */ - - status = acpi_ns_internalize_name (pathname, &internal_path); - if (ACPI_FAILURE (status)) { - return (status); - } - - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* Setup lookup scope (search starting point) */ - - scope_info.scope.node = start_node; - - /* Lookup the name in the namespace */ - - status = acpi_ns_lookup (&scope_info, internal_path, - ACPI_TYPE_ANY, IMODE_EXECUTE, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, return_node); - - - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - /* Cleanup */ - - acpi_cm_free (internal_path); - - return (status); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_find_parent_name - * - * PARAMETERS: *Child_node - Named Obj whose name is to be found - * - * RETURN: The ACPI name - * - * DESCRIPTION: Search for the given obj in its parent scope and return the - * name segment, or "????" if the parent name can't be found - * (which "should not happen"). - * - ***************************************************************************/ - -ACPI_NAME -acpi_ns_find_parent_name ( - ACPI_NAMESPACE_NODE *child_node) -{ - ACPI_NAMESPACE_NODE *parent_node; - - - if (child_node) { - /* Valid entry. Get the parent Node */ - - parent_node = acpi_ns_get_parent_object (child_node); - if (parent_node) { - if (parent_node->name) { - return (parent_node->name); - } - } - - } - - - return (ACPI_UNKNOWN_NAME); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_get_parent_object - * - * PARAMETERS: Node - Current table entry - * - * RETURN: Parent entry of the given entry - * - * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. - * - ***************************************************************************/ - - -ACPI_NAMESPACE_NODE * -acpi_ns_get_parent_object ( - ACPI_NAMESPACE_NODE *node) -{ - - - if (!node) { - return (NULL); - } - - /* - * Walk to the end of this peer list. - * The last entry is marked with a flag and the peer - * pointer is really a pointer back to the parent. - * This saves putting a parent back pointer in each and - * every named object! - */ - - while (!(node->flags & ANOBJ_END_OF_PEER_LIST)) { - node = node->peer; - } - - - return (node->peer); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_get_next_valid_object - * - * PARAMETERS: Node - Current table entry - * - * RETURN: Next valid object in the table. NULL if no more valid - * objects - * - * DESCRIPTION: Find the next valid object within a name table. - * Useful for implementing NULL-end-of-list loops. - * - ***************************************************************************/ - - -ACPI_NAMESPACE_NODE * -acpi_ns_get_next_valid_object ( - ACPI_NAMESPACE_NODE *node) -{ - - /* If we are at the end of this peer list, return NULL */ - - if (node->flags & ANOBJ_END_OF_PEER_LIST) { - return NULL; - } - - /* Otherwise just return the next peer */ - - return (node->peer); -} - - diff --git a/reactos/drivers/bus/acpi/namespace/nswalk.c b/reactos/drivers/bus/acpi/namespace/nswalk.c deleted file mode 100644 index ddfdecdc97c..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nswalk.c +++ /dev/null @@ -1,269 +0,0 @@ -/****************************************************************************** - * - * Module Name: nswalk - Functions for walking the APCI namespace - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nswalk") - - -/**************************************************************************** - * - * FUNCTION: Acpi_get_next_object - * - * PARAMETERS: Type - Type of object to be searched for - * Parent - Parent object whose children we are - * getting - * Last_child - Previous child that was found. - * The NEXT child will be returned - * - * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if - * none is found. - * - * DESCRIPTION: Return the next peer object within the namespace. If Handle - * is valid, Scope is ignored. Otherwise, the first object - * within Scope is returned. - * - ****************************************************************************/ - -ACPI_NAMESPACE_NODE * -acpi_ns_get_next_object ( - OBJECT_TYPE_INTERNAL type, - ACPI_NAMESPACE_NODE *parent_node, - ACPI_NAMESPACE_NODE *child_node) -{ - ACPI_NAMESPACE_NODE *next_node = NULL; - - - if (!child_node) { - - /* It's really the parent's _scope_ that we want */ - - if (parent_node->child) { - next_node = parent_node->child; - } - } - - else { - /* Start search at the NEXT object */ - - next_node = acpi_ns_get_next_valid_object (child_node); - } - - - /* If any type is OK, we are done */ - - if (type == ACPI_TYPE_ANY) { - /* Next_node is NULL if we are at the end-of-list */ - - return (next_node); - } - - - /* Must search for the object -- but within this scope only */ - - while (next_node) { - /* If type matches, we are done */ - - if (next_node->type == type) { - return (next_node); - } - - /* Otherwise, move on to the next object */ - - next_node = acpi_ns_get_next_valid_object (next_node); - } - - - /* Not found */ - - return (NULL); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_ns_walk_namespace - * - * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for - * Start_node - Handle in namespace where search begins - * Max_depth - Depth to which search is to reach - * Unlock_before_callback- Whether to unlock the NS before invoking - * the callback routine - * User_function - Called when an object of "Type" is found - * Context - Passed to user function - * - * RETURNS Return value from the User_function if terminated early. - * Otherwise, returns NULL. - * - * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, - * starting (and ending) at the object specified by Start_handle. - * The User_function is called whenever an object that matches - * the type parameter is found. If the user function returns - * a non-zero value, the search is terminated immediately and this - * value is returned to the caller. - * - * The point of this procedure is to provide a generic namespace - * walk routine that can be called from multiple places to - * provide multiple services; the User Function can be tailored - * to each task, whether it is a print function, a compare - * function, etc. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ns_walk_namespace ( - OBJECT_TYPE_INTERNAL type, - ACPI_HANDLE start_node, - u32 max_depth, - u8 unlock_before_callback, - WALK_CALLBACK user_function, - void *context, - void **return_value) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *child_node; - ACPI_NAMESPACE_NODE *parent_node; - OBJECT_TYPE_INTERNAL child_type; - u32 level; - - - /* Special case for the namespace Root Node */ - - if (start_node == ACPI_ROOT_OBJECT) { - start_node = acpi_gbl_root_node; - } - - - /* Null child means "get first object" */ - - parent_node = start_node; - child_node = 0; - child_type = ACPI_TYPE_ANY; - level = 1; - - /* - * Traverse the tree of objects until we bubble back up to where we - * started. When Level is zero, the loop is done because we have - * bubbled up to (and passed) the original parent handle (Start_entry) - */ - - while (level > 0) { - /* - * Get the next typed object in this scope. Null returned - * if not found - */ - - status = AE_OK; - child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY, - parent_node, - child_node); - - if (child_node) { - /* - * Found an object, Get the type if we are not - * searching for ANY - */ - - if (type != ACPI_TYPE_ANY) { - child_type = child_node->type; - } - - if (child_type == type) { - /* - * Found a matching object, invoke the user - * callback function - */ - - if (unlock_before_callback) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - } - - status = user_function (child_node, level, - context, return_value); - - if (unlock_before_callback) { - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - } - - switch (status) { - case AE_OK: - case AE_CTRL_DEPTH: - /* Just keep going */ - break; - - case AE_CTRL_TERMINATE: - /* Exit now, with OK status */ - return (AE_OK); - break; - - default: - /* All others are valid exceptions */ - return (status); - break; - } - } - - /* - * Depth first search: - * Attempt to go down another level in the namespace - * if we are allowed to. Don't go any further if we - * have reached the caller specified maximum depth - * or if the user function has specified that the - * maximum depth has been reached. - */ - - if ((level < max_depth) && (status != AE_CTRL_DEPTH)) { - if (acpi_ns_get_next_object (ACPI_TYPE_ANY, - child_node, 0)) { - /* - * There is at least one child of this - * object, visit the object - */ - level++; - parent_node = child_node; - child_node = 0; - } - } - } - - else { - /* - * No more children in this object (Acpi_ns_get_next_object - * failed), go back upwards in the namespace tree to - * the object's parent. - */ - level--; - child_node = parent_node; - parent_node = acpi_ns_get_parent_object (parent_node); - } - } - - /* Complete walk, not terminated by user function */ - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/namespace/nsxfname.c b/reactos/drivers/bus/acpi/namespace/nsxfname.c deleted file mode 100644 index 780919c4a63..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsxfname.c +++ /dev/null @@ -1,294 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsxfname - Public interfaces to the ACPI subsystem - * ACPI Namespace oriented interfaces - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsxfname") - - -/**************************************************************************** - * - * FUNCTION: Acpi_get_handle - * - * PARAMETERS: Parent - Object to search under (search scope). - * Path_name - Pointer to an asciiz string containing the - * name - * Ret_handle - Where the return handle is placed - * - * RETURN: Status - * - * DESCRIPTION: This routine will search for a caller specified name in the - * name space. The caller can restrict the search region by - * specifying a non NULL parent. The parent value is itself a - * namespace handle. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_handle ( - ACPI_HANDLE parent, - ACPI_STRING pathname, - ACPI_HANDLE *ret_handle) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *node = NULL; - ACPI_NAMESPACE_NODE *prefix_node = NULL; - - - if (!ret_handle || !pathname) { - return (AE_BAD_PARAMETER); - } - - /* Convert a parent handle to a prefix node */ - - if (parent) { - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - prefix_node = acpi_ns_convert_handle_to_entry (parent); - if (!prefix_node) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - } - - /* Special case for root, since we can't search for it */ - - if (STRCMP (pathname, NS_ROOT_PATH) == 0) { - *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node); - return (AE_OK); - } - - /* - * Find the Node and convert to a handle - */ - status = acpi_ns_get_node (pathname, prefix_node, &node); - - *ret_handle = NULL; - if (ACPI_SUCCESS (status)) { - *ret_handle = acpi_ns_convert_entry_to_handle (node); - } - - return (status); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_get_pathname - * - * PARAMETERS: Handle - Handle to be converted to a pathname - * Name_type - Full pathname or single segment - * Ret_path_ptr - Buffer for returned path - * - * RETURN: Pointer to a string containing the fully qualified Name. - * - * DESCRIPTION: This routine returns the fully qualified name associated with - * the Handle parameter. This and the Acpi_pathname_to_handle are - * complementary functions. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_name ( - ACPI_HANDLE handle, - u32 name_type, - ACPI_BUFFER *ret_path_ptr) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *node; - - - /* Buffer pointer must be valid always */ - - if (!ret_path_ptr || (name_type > ACPI_NAME_TYPE_MAX)) { - return (AE_BAD_PARAMETER); - } - - /* Allow length to be zero and ignore the pointer */ - - if ((ret_path_ptr->length) && - (!ret_path_ptr->pointer)) { - return (AE_BAD_PARAMETER); - } - - if (name_type == ACPI_FULL_PATHNAME) { - /* Get the full pathname (From the namespace root) */ - - status = acpi_ns_handle_to_pathname (handle, &ret_path_ptr->length, - ret_path_ptr->pointer); - return (status); - } - - /* - * Wants the single segment ACPI name. - * Validate handle and convert to an Node - */ - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - node = acpi_ns_convert_handle_to_entry (handle); - if (!node) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - /* Check if name will fit in buffer */ - - if (ret_path_ptr->length < PATH_SEGMENT_LENGTH) { - ret_path_ptr->length = PATH_SEGMENT_LENGTH; - status = AE_BUFFER_OVERFLOW; - goto unlock_and_exit; - } - - /* Just copy the ACPI name from the Node and zero terminate it */ - - STRNCPY (ret_path_ptr->pointer, (NATIVE_CHAR *) &node->name, - ACPI_NAME_SIZE); - ((NATIVE_CHAR *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0; - status = AE_OK; - - -unlock_and_exit: - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_get_object_info - * - * PARAMETERS: Handle - Object Handle - * Info - Where the info is returned - * - * RETURN: Status - * - * DESCRIPTION: Returns information about an object as gleaned from the - * namespace node and possibly by running several standard - * control methods (Such as in the case of a device.) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_object_info ( - ACPI_HANDLE handle, - ACPI_DEVICE_INFO *info) -{ - DEVICE_ID hid; - DEVICE_ID uid; - ACPI_STATUS status; - u32 device_status = 0; - ACPI_INTEGER address = 0; - ACPI_NAMESPACE_NODE *node; - - - /* Parameter validation */ - - if (!handle || !info) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - node = acpi_ns_convert_handle_to_entry (handle); - if (!node) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - info->type = node->type; - info->name = node->name; - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - /* - * If not a device, we are all done. - */ - if (info->type != ACPI_TYPE_DEVICE) { - return (AE_OK); - } - - - /* - * Get extra info for ACPI devices only. Run the - * _HID, _UID, _STA, and _ADR methods. Note: none - * of these methods are required, so they may or may - * not be present. The Info->Valid bits are used - * to indicate which methods ran successfully. - */ - - info->valid = 0; - - /* Execute the _HID method and save the result */ - - status = acpi_cm_execute_HID (node, &hid); - if (ACPI_SUCCESS (status)) { - STRNCPY (info->hardware_id, hid.buffer, sizeof(info->hardware_id)); - - info->valid |= ACPI_VALID_HID; - } - - /* Execute the _UID method and save the result */ - - status = acpi_cm_execute_UID (node, &uid); - if (ACPI_SUCCESS (status)) { - STRCPY (info->unique_id, uid.buffer); - - info->valid |= ACPI_VALID_UID; - } - - /* - * Execute the _STA method and save the result - * _STA is not always present - */ - - status = acpi_cm_execute_STA (node, &device_status); - if (ACPI_SUCCESS (status)) { - info->current_status = device_status; - info->valid |= ACPI_VALID_STA; - } - - /* - * Execute the _ADR method and save result if successful - * _ADR is not always present - */ - - status = acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR, - node, &address); - - if (ACPI_SUCCESS (status)) { - info->address = address; - info->valid |= ACPI_VALID_ADR; - } - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/namespace/nsxfobj.c b/reactos/drivers/bus/acpi/namespace/nsxfobj.c deleted file mode 100644 index 1eaaedfbf7c..00000000000 --- a/reactos/drivers/bus/acpi/namespace/nsxfobj.c +++ /dev/null @@ -1,690 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsxfobj - Public interfaces to the ACPI subsystem - * ACPI Object oriented interfaces - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsxfobj") - - -/******************************************************************************* - * - * FUNCTION: Acpi_evaluate_object - * - * PARAMETERS: Handle - Object handle (optional) - * *Pathname - Object pathname (optional) - * **Params - List of parameters to pass to - * method, terminated by NULL. - * Params itself may be NULL - * if no parameters are being - * passed. - * *Return_object - Where to put method's return value (if - * any). If NULL, no value is returned. - * - * RETURN: Status - * - * DESCRIPTION: Find and evaluate the given object, passing the given - * parameters if necessary. One of "Handle" or "Pathname" must - * be valid (non-null) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_evaluate_object ( - ACPI_HANDLE handle, - ACPI_STRING pathname, - ACPI_OBJECT_LIST *param_objects, - ACPI_BUFFER *return_buffer) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **param_ptr = NULL; - ACPI_OPERAND_OBJECT *return_obj = NULL; - ACPI_OPERAND_OBJECT *object_ptr = NULL; - u32 buffer_space_needed; - u32 user_buffer_length; - u32 count; - u32 i; - u32 param_length; - u32 object_length; - - - /* - * If there are parameters to be passed to the object - * (which must be a control method), the external objects - * must be converted to internal objects - */ - - if (param_objects && param_objects->count) { - /* - * Allocate a new parameter block for the internal objects - * Add 1 to count to allow for null terminated internal list - */ - - count = param_objects->count; - param_length = (count + 1) * sizeof (void *); - object_length = count * sizeof (ACPI_OPERAND_OBJECT); - - param_ptr = acpi_cm_callocate (param_length + /* Parameter List part */ - object_length); /* Actual objects */ - if (!param_ptr) { - return (AE_NO_MEMORY); - } - - object_ptr = (ACPI_OPERAND_OBJECT *) ((u8 *) param_ptr + - param_length); - - /* - * Init the param array of pointers and NULL terminate - * the list - */ - - for (i = 0; i < count; i++) { - param_ptr[i] = &object_ptr[i]; - acpi_cm_init_static_object (&object_ptr[i]); - } - param_ptr[count] = NULL; - - /* - * Convert each external object in the list to an - * internal object - */ - for (i = 0; i < count; i++) { - status = acpi_cm_copy_eobject_to_iobject (¶m_objects->pointer[i], - param_ptr[i]); - - if (ACPI_FAILURE (status)) { - acpi_cm_delete_internal_object_list (param_ptr); - return (status); - } - } - } - - - /* - * Three major cases: - * 1) Fully qualified pathname - * 2) No handle, not fully qualified pathname (error) - * 3) Valid handle - */ - - if ((pathname) && - (acpi_ns_valid_root_prefix (pathname[0]))) { - /* - * The path is fully qualified, just evaluate by name - */ - status = acpi_ns_evaluate_by_name (pathname, param_ptr, &return_obj); - } - - else if (!handle) { - /* - * A handle is optional iff a fully qualified pathname - * is specified. Since we've already handled fully - * qualified names above, this is an error - */ - - - - status = AE_BAD_PARAMETER; - } - - else { - /* - * We get here if we have a handle -- and if we have a - * pathname it is relative. The handle will be validated - * in the lower procedures - */ - - if (!pathname) { - /* - * The null pathname case means the handle is for - * the actual object to be evaluated - */ - status = acpi_ns_evaluate_by_handle (handle, param_ptr, &return_obj); - } - - else { - /* - * Both a Handle and a relative Pathname - */ - status = acpi_ns_evaluate_relative (handle, pathname, param_ptr, - &return_obj); - } - } - - - /* - * If we are expecting a return value, and all went well above, - * copy the return value to an external object. - */ - - if (return_buffer) { - user_buffer_length = return_buffer->length; - return_buffer->length = 0; - - if (return_obj) { - if (VALID_DESCRIPTOR_TYPE (return_obj, ACPI_DESC_TYPE_NAMED)) { - /* - * If we got an Node as a return object, - * this means the object we are evaluating - * has nothing interesting to return (such - * as a mutex, etc.) We return an error - * because these types are essentially - * unsupported by this interface. We - * don't check up front because this makes - * it easier to add support for various - * types at a later date if necessary. - */ - status = AE_TYPE; - return_obj = NULL; /* No need to delete an Node */ - } - - if (ACPI_SUCCESS (status)) { - /* - * Find out how large a buffer is needed - * to contain the returned object - */ - status = acpi_cm_get_object_size (return_obj, - &buffer_space_needed); - if (ACPI_SUCCESS (status)) { - /* - * Check if there is enough room in the - * caller's buffer - */ - - if (user_buffer_length < buffer_space_needed) { - /* - * Caller's buffer is too small, can't - * give him partial results fail the call - * but return the buffer size needed - */ - - return_buffer->length = buffer_space_needed; - status = AE_BUFFER_OVERFLOW; - } - - else { - /* - * We have enough space for the object, build it - */ - status = acpi_cm_copy_iobject_to_eobject (return_obj, - return_buffer); - return_buffer->length = buffer_space_needed; - } - } - } - } - } - - - /* Delete the return and parameter objects */ - - if (return_obj) { - /* - * Delete the internal return object. (Or at least - * decrement the reference count by one) - */ - acpi_cm_remove_reference (return_obj); - } - - /* - * Free the input parameter list (if we created one), - */ - - if (param_ptr) { - /* Free the allocated parameter block */ - - acpi_cm_delete_internal_object_list (param_ptr); - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_next_object - * - * PARAMETERS: Type - Type of object to be searched for - * Parent - Parent object whose children we are getting - * Last_child - Previous child that was found. - * The NEXT child will be returned - * Ret_handle - Where handle to the next object is placed - * - * RETURN: Status - * - * DESCRIPTION: Return the next peer object within the namespace. If Handle is - * valid, Scope is ignored. Otherwise, the first object within - * Scope is returned. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_next_object ( - ACPI_OBJECT_TYPE type, - ACPI_HANDLE parent, - ACPI_HANDLE child, - ACPI_HANDLE *ret_handle) -{ - ACPI_STATUS status = AE_OK; - ACPI_NAMESPACE_NODE *node; - ACPI_NAMESPACE_NODE *parent_node = NULL; - ACPI_NAMESPACE_NODE *child_node = NULL; - - - /* Parameter validation */ - - if (type > ACPI_TYPE_MAX) { - return (AE_BAD_PARAMETER); - } - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* If null handle, use the parent */ - - if (!child) { - /* Start search at the beginning of the specified scope */ - - parent_node = acpi_ns_convert_handle_to_entry (parent); - if (!parent_node) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - } - - /* Non-null handle, ignore the parent */ - - else { - /* Convert and validate the handle */ - - child_node = acpi_ns_convert_handle_to_entry (child); - if (!child_node) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - } - - - /* Internal function does the real work */ - - node = acpi_ns_get_next_object ((OBJECT_TYPE_INTERNAL) type, - parent_node, child_node); - if (!node) { - status = AE_NOT_FOUND; - goto unlock_and_exit; - } - - if (ret_handle) { - *ret_handle = acpi_ns_convert_entry_to_handle (node); - } - - -unlock_and_exit: - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_type - * - * PARAMETERS: Handle - Handle of object whose type is desired - * *Ret_type - Where the type will be placed - * - * RETURN: Status - * - * DESCRIPTION: This routine returns the type associatd with a particular handle - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_type ( - ACPI_HANDLE handle, - ACPI_OBJECT_TYPE *ret_type) -{ - ACPI_NAMESPACE_NODE *node; - - - /* Parameter Validation */ - - if (!ret_type) { - return (AE_BAD_PARAMETER); - } - - /* - * Special case for the predefined Root Node - * (return type ANY) - */ - if (handle == ACPI_ROOT_OBJECT) { - *ret_type = ACPI_TYPE_ANY; - return (AE_OK); - } - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the handle */ - - node = acpi_ns_convert_handle_to_entry (handle); - if (!node) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - *ret_type = node->type; - - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_parent - * - * PARAMETERS: Handle - Handle of object whose parent is desired - * Ret_handle - Where the parent handle will be placed - * - * RETURN: Status - * - * DESCRIPTION: Returns a handle to the parent of the object represented by - * Handle. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_parent ( - ACPI_HANDLE handle, - ACPI_HANDLE *ret_handle) -{ - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status = AE_OK; - - - /* No trace macro, too verbose */ - - - if (!ret_handle) { - return (AE_BAD_PARAMETER); - } - - /* Special case for the predefined Root Node (no parent) */ - - if (handle == ACPI_ROOT_OBJECT) { - return (AE_NULL_ENTRY); - } - - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the handle */ - - node = acpi_ns_convert_handle_to_entry (handle); - if (!node) { - status = AE_BAD_PARAMETER; - goto unlock_and_exit; - } - - - /* Get the parent entry */ - - *ret_handle = - acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_object (node)); - - /* Return exeption if parent is null */ - - if (!acpi_ns_get_parent_object (node)) { - status = AE_NULL_ENTRY; - } - - -unlock_and_exit: - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_walk_namespace - * - * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for - * Start_object - Handle in namespace where search begins - * Max_depth - Depth to which search is to reach - * User_function - Called when an object of "Type" is found - * Context - Passed to user function - * Return_value - Location where return value of - * User_function is put if terminated early - * - * RETURNS Return value from the User_function if terminated early. - * Otherwise, returns NULL. - * - * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, - * starting (and ending) at the object specified by Start_handle. - * The User_function is called whenever an object that matches - * the type parameter is found. If the user function returns - * a non-zero value, the search is terminated immediately and this - * value is returned to the caller. - * - * The point of this procedure is to provide a generic namespace - * walk routine that can be called from multiple places to - * provide multiple services; the User Function can be tailored - * to each task, whether it is a print function, a compare - * function, etc. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_walk_namespace ( - ACPI_OBJECT_TYPE type, - ACPI_HANDLE start_object, - u32 max_depth, - WALK_CALLBACK user_function, - void *context, - void **return_value) -{ - ACPI_STATUS status; - - - /* Parameter validation */ - - if ((type > ACPI_TYPE_MAX) || - (!max_depth) || - (!user_function)) { - return (AE_BAD_PARAMETER); - } - - /* - * Lock the namespace around the walk. - * The namespace will be unlocked/locked around each call - * to the user function - since this function - * must be allowed to make Acpi calls itself. - */ - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - status = acpi_ns_walk_namespace ((OBJECT_TYPE_INTERNAL) type, - start_object, max_depth, - NS_WALK_UNLOCK, - user_function, context, - return_value); - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ns_get_device_callback - * - * PARAMETERS: Callback from Acpi_get_device - * - * RETURN: Status - * - * DESCRIPTION: Takes callbacks from Walk_namespace and filters out all non- - * present devices, or if they specified a HID, it filters based - * on that. - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_ns_get_device_callback ( - ACPI_HANDLE obj_handle, - u32 nesting_level, - void *context, - void **return_value) -{ - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *node; - u32 flags; - DEVICE_ID device_id; - ACPI_GET_DEVICES_INFO *info; - - - info = context; - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - - node = acpi_ns_convert_handle_to_entry (obj_handle); - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - if (!node) { - return (AE_BAD_PARAMETER); - } - - /* - * Run _STA to determine if device is present - */ - - status = acpi_cm_execute_STA (node, &flags); - if (ACPI_FAILURE (status)) { - return (status); - } - - if (!(flags & 0x01)) { - /* don't return at the device or children of the device if not there */ - - return (AE_CTRL_DEPTH); - } - - /* - * Filter based on device HID - */ - if (info->hid != NULL) { - status = acpi_cm_execute_HID (node, &device_id); - - if (status == AE_NOT_FOUND) { - return (AE_OK); - } - - else if (ACPI_FAILURE (status)) { - return (status); - } - - if (STRNCMP (device_id.buffer, info->hid, sizeof (device_id.buffer)) != 0) { - return (AE_OK); - } - } - - info->user_function (obj_handle, nesting_level, info->context, return_value); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_devices - * - * PARAMETERS: HID - HID to search for. Can be NULL. - * User_function - Called when a matching object is found - * Context - Passed to user function - * Return_value - Location where return value of - * User_function is put if terminated early - * - * RETURNS Return value from the User_function if terminated early. - * Otherwise, returns NULL. - * - * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, - * starting (and ending) at the object specified by Start_handle. - * The User_function is called whenever an object that matches - * the type parameter is found. If the user function returns - * a non-zero value, the search is terminated immediately and this - * value is returned to the caller. - * - * This is a wrapper for Walk_namespace, but the callback performs - * additional filtering. Please see Acpi_get_device_callback. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_devices ( - NATIVE_CHAR *HID, - WALK_CALLBACK user_function, - void *context, - void **return_value) -{ - ACPI_STATUS status; - ACPI_GET_DEVICES_INFO info; - - - /* Parameter validation */ - - if (!user_function) { - return (AE_BAD_PARAMETER); - } - - /* - * We're going to call their callback from OUR callback, so we need - * to know what it is, and their context parameter. - */ - info.context = context; - info.user_function = user_function; - info.hid = HID; - - /* - * Lock the namespace around the walk. - * The namespace will be unlocked/locked around each call - * to the user function - since this function - * must be allowed to make Acpi calls itself. - */ - - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, - ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - NS_WALK_UNLOCK, - acpi_ns_get_device_callback, &info, - return_value); - - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - return (status); -} diff --git a/reactos/drivers/bus/acpi/ospm/acpienum.c b/reactos/drivers/bus/acpi/ospm/acpienum.c deleted file mode 100644 index 6edac4e1d44..00000000000 --- a/reactos/drivers/bus/acpi/ospm/acpienum.c +++ /dev/null @@ -1,191 +0,0 @@ -/* $Id$ - * - * PROJECT: ReactOS ACPI bus driver - * FILE: acpi/ospm/acpienum.c - * PURPOSE: ACPI namespace enumerator - * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) - * UPDATE HISTORY: - * 01-05-2001 CSH Created - */ -#include - -#define NDEBUG -#include - - -#ifndef NDEBUG -static void -bm_print1 ( - BM_NODE *node, - u32 flags) -{ - ACPI_BUFFER buffer; - BM_DEVICE *device = NULL; - char *type_string = NULL; - - if (!node) - { - return; - } - - device = &(node->device); - - if (flags & BM_PRINT_PRESENT) - { - if (!BM_DEVICE_PRESENT(device)) - { - return; - } - } - - buffer.length = 256; - buffer.pointer = acpi_os_callocate(buffer.length); - if (!buffer.pointer) - { - return; - } - - acpi_get_name(device->acpi_handle, ACPI_FULL_PATHNAME, &buffer); - - switch(device->id.type) - { - case BM_TYPE_SYSTEM: - type_string = "System"; - break; - - case BM_TYPE_SCOPE: - type_string = "Scope"; - break; - - case BM_TYPE_PROCESSOR: - type_string = "Processor"; - break; - - case BM_TYPE_THERMAL_ZONE: - type_string = "ThermalZone"; - break; - - case BM_TYPE_POWER_RESOURCE: - type_string = "PowerResource"; - break; - - case BM_TYPE_FIXED_BUTTON: - type_string = "Button"; - break; - - case BM_TYPE_DEVICE: - type_string = "Device"; - break; - - default: - type_string = "Unknown"; - break; - } - - if (!(flags & BM_PRINT_GROUP)) - { - DbgPrint("+------------------------------------------------------------\n"); - } - - DbgPrint("%s[0x%02x] hid[%s] %s\n", type_string, device->handle, device->id.hid, buffer.pointer); - DbgPrint(" acpi_handle[0x%08x] flags[0x%02x] status[0x%02x]\n", device->acpi_handle, device->flags, device->status); - - if (flags & BM_PRINT_IDENTIFICATION) - { - DbgPrint(" identification: uid[%s] adr[0x%08x]\n", device->id.uid, device->id.adr); - } - - if (flags & BM_PRINT_LINKAGE) - { - DbgPrint(" linkage: this[%p] parent[%p] next[%p]\n", node, node->parent, node->next); - DbgPrint(" scope.head[%p] scope.tail[%p]\n", node->scope.head, node->scope.tail); - } - - if (flags & BM_PRINT_POWER) - { - DbgPrint(" power: state[D%d] flags[0x%08X]\n", device->power.state, device->power.flags); - DbgPrint(" S0[0x%02x] S1[0x%02x] S2[0x%02x]\n", device->power.dx_supported[0], device->power.dx_supported[1], device->power.dx_supported[2]); - DbgPrint(" S3[0x%02x] S4[0x%02x] S5[0x%02x]\n", device->power.dx_supported[3], device->power.dx_supported[4], device->power.dx_supported[5]); - } - - if (!(flags & BM_PRINT_GROUP)) - { - DbgPrint("+------------------------------------------------------------\n"); - } - - acpi_os_free(buffer.pointer); - - return; -} -#endif - - -NTSTATUS -ACPIEnumerateDevices(PFDO_DEVICE_EXTENSION DeviceExtension) -{ - BM_HANDLE_LIST HandleList; - PACPI_DEVICE AcpiDevice; - ACPI_STATUS AcpiStatus; - BM_DEVICE_ID Criteria; - BM_NODE *Node; - KIRQL OldIrql; - ULONG i; - - DPRINT("Called\n"); - - RtlZeroMemory(&Criteria, sizeof(BM_DEVICE_ID)); - Criteria.type = BM_TYPE_ALL; - - AcpiStatus = bm_search(BM_HANDLE_ROOT, &Criteria, &HandleList); - if (ACPI_SUCCESS(AcpiStatus)) - { - DPRINT("Got %d devices\n", HandleList.count); - - for (i = 0; i < HandleList.count; i++) - { - AcpiStatus = bm_get_node(HandleList.handles[i], 0, &Node); - if (ACPI_SUCCESS(AcpiStatus)) - { - DPRINT("Got BM node information: (Node 0x%X)\n", Node); - - if ((Node->device.flags & BM_FLAGS_IDENTIFIABLE) && - (Node->device.id.hid[0] != 0)) - { -#ifndef NDEBUG - bm_print1(Node, BM_PRINT_ALL - BM_PRINT_PRESENT); -#endif - - AcpiDevice = (PACPI_DEVICE)ExAllocatePool(NonPagedPool, - sizeof(ACPI_DEVICE)); - if (AcpiDevice == NULL) - { - return STATUS_INSUFFICIENT_RESOURCES; - } - - RtlZeroMemory(AcpiDevice, sizeof(ACPI_DEVICE)); - - AcpiDevice->Pdo = NULL; - AcpiDevice->BmHandle = HandleList.handles[i]; - - KeAcquireSpinLock(&DeviceExtension->DeviceListLock, &OldIrql); - InsertHeadList(&DeviceExtension->DeviceListHead, - &AcpiDevice->DeviceListEntry); - DeviceExtension->DeviceListCount++; - KeReleaseSpinLock(&DeviceExtension->DeviceListLock, OldIrql); - } - } - else - { - DPRINT("Could not get BM node\n"); - } - } - } - else - { - DPRINT("Got no devices (Status 0x%X)\n", AcpiStatus); - } - - return STATUS_SUCCESS; -} - -/* EOF */ diff --git a/reactos/drivers/bus/acpi/ospm/acpisys.c b/reactos/drivers/bus/acpi/ospm/acpisys.c deleted file mode 100644 index 148209dc233..00000000000 --- a/reactos/drivers/bus/acpi/ospm/acpisys.c +++ /dev/null @@ -1,183 +0,0 @@ -/* $Id$ - * - * PROJECT: ReactOS ACPI bus driver - * FILE: acpi/ospm/acpisys.c - * PURPOSE: Driver entry - * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) - * UPDATE HISTORY: - * 01-05-2001 CSH Created - */ -#include - -#define NDEBUG -#include - -NTSTATUS -NTAPI -DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath -); - -#ifdef ALLOC_PRAGMA - -// Make the initialization routines discardable, so that they -// don't waste space - -#pragma alloc_text(init, DriverEntry) - -#endif /* ALLOC_PRAGMA */ - - -NTSTATUS -NTAPI -ACPIDispatchDeviceControl( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) -{ - PIO_STACK_LOCATION IrpSp; - NTSTATUS Status; - - DPRINT("Called. IRP is at (0x%X)\n", Irp); - - Irp->IoStatus.Information = 0; - - IrpSp = IoGetCurrentIrpStackLocation(Irp); - switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) { - default: - DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode); - Status = STATUS_NOT_IMPLEMENTED; - break; - } - - if (Status != STATUS_PENDING) { - Irp->IoStatus.Status = Status; - - DPRINT("Completing IRP at 0x%X\n", Irp); - - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } - - DPRINT("Leaving. Status 0x%X\n", Status); - - return Status; -} - - -NTSTATUS -NTAPI -ACPIPnpControl( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) -/* - * FUNCTION: Handle Plug and Play IRPs - * ARGUMENTS: - * DeviceObject = Pointer to PDO or FDO - * Irp = Pointer to IRP that should be handled - * RETURNS: - * Status - */ -{ - PCOMMON_DEVICE_EXTENSION DeviceExtension; - NTSTATUS Status; - - DPRINT("Called\n"); - - DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - if (DeviceExtension->IsFDO) { - Status = FdoPnpControl(DeviceObject, Irp); - } else { - Status = PdoPnpControl(DeviceObject, Irp); - } - - return Status; -} - - -NTSTATUS -NTAPI -ACPIPowerControl( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) -{ - PCOMMON_DEVICE_EXTENSION DeviceExtension; - NTSTATUS Status; - - DPRINT("Called\n"); - - DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - if (DeviceExtension->IsFDO) { - Status = FdoPowerControl(DeviceObject, Irp); - } else { - Status = PdoPowerControl(DeviceObject, Irp); - } - - return Status; -} - - -NTSTATUS -NTAPI -ACPIAddDevice( - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT PhysicalDeviceObject) -{ - PFDO_DEVICE_EXTENSION DeviceExtension; - PDEVICE_OBJECT Fdo; - NTSTATUS Status; - - DPRINT("Called\n"); - - if (PhysicalDeviceObject == NULL) - return STATUS_SUCCESS; - - Status = IoCreateDevice(DriverObject, - sizeof(FDO_DEVICE_EXTENSION), - NULL, - FILE_DEVICE_ACPI, - FILE_DEVICE_SECURE_OPEN, - TRUE, - &Fdo); - if (!NT_SUCCESS(Status)) - { - DPRINT("IoCreateDevice() failed with status 0x%X\n", Status); - return Status; - } - - DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension; - - DeviceExtension->Pdo = PhysicalDeviceObject; - DeviceExtension->Common.IsFDO = TRUE; - - DeviceExtension->Common.Ldo = - IoAttachDeviceToDeviceStack(Fdo, PhysicalDeviceObject); - - DeviceExtension->State = dsStopped; - - Fdo->Flags &= ~DO_DEVICE_INITIALIZING; - - DPRINT("Done AddDevice\n"); - - return STATUS_SUCCESS; -} - - -NTSTATUS -NTAPI -DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath) -{ - DPRINT("Advanced Configuration and Power Interface Bus Driver\n"); - - DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = (PDRIVER_DISPATCH) ACPIDispatchDeviceControl; - DriverObject->MajorFunction[IRP_MJ_PNP] = (PDRIVER_DISPATCH) ACPIPnpControl; - DriverObject->MajorFunction[IRP_MJ_POWER] = (PDRIVER_DISPATCH) ACPIPowerControl; - DriverObject->DriverExtension->AddDevice = ACPIAddDevice; - - return STATUS_SUCCESS; -} - -/* EOF */ diff --git a/reactos/drivers/bus/acpi/ospm/bn.c b/reactos/drivers/bus/acpi/ospm/bn.c deleted file mode 100644 index 6df7113a533..00000000000 --- a/reactos/drivers/bus/acpi/ospm/bn.c +++ /dev/null @@ -1,599 +0,0 @@ -/***************************************************************************** - * - * Module Name: bn.c - * $Revision: 1.2 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Plxxe, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define _COMPONENT ACPI_BUTTON - MODULE_NAME ("bn") - - -static struct proc_dir_entry *bn_proc_root = NULL; - - -/***************************************************************************** - * Internal Functions - *****************************************************************************/ - -/***************************************************************************** - * - * FUNCTION: bn_print - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Prints out information on a specific button. - * - ****************************************************************************/ - -void -bn_print ( - BN_CONTEXT *button) -{ -#ifdef ACPI_DEBUG - ACPI_BUFFER buffer; -#endif /*ACPI_DEBUG*/ - - if (!button) { - return; - } - - switch (button->type) { - - case BN_TYPE_POWER_BUTTON: - case BN_TYPE_POWER_BUTTON_FIXED: - acpi_os_printf("Power Button: found\n"); - break; - - case BN_TYPE_SLEEP_BUTTON: - case BN_TYPE_SLEEP_BUTTON_FIXED: - acpi_os_printf("Sleep Button: found\n"); - break; - - case BN_TYPE_LID_SWITCH: - acpi_os_printf("Lid Switch: found\n"); - break; - } - -#ifdef ACPI_DEBUG - buffer.length = 256; - buffer.pointer = acpi_os_callocate(buffer.length); - if (!buffer.pointer) { - return; - } - - /* - * Get the full pathname for this ACPI object. - */ - acpi_get_name(button->acpi_handle, ACPI_FULL_PATHNAME, &buffer); - - /* - * Print out basic button information. - */ - DEBUG_PRINT(ACPI_INFO, ("+------------------------------------------------------------\n")); - - switch (button->type) { - - case BN_TYPE_POWER_BUTTON: - case BN_TYPE_POWER_BUTTON_FIXED: - DEBUG_PRINT(ACPI_INFO, ("| PowerButton[0x%02x]|[%p] %s\n", button->device_handle, button->acpi_handle, buffer.pointer)); - break; - - case BN_TYPE_SLEEP_BUTTON: - case BN_TYPE_SLEEP_BUTTON_FIXED: - DEBUG_PRINT(ACPI_INFO, ("| SleepButton[0x%02x]|[%p] %s\n", button->device_handle, button->acpi_handle, buffer.pointer)); - break; - - case BN_TYPE_LID_SWITCH: - DEBUG_PRINT(ACPI_INFO, ("| LidSwitch[0x%02x]|[%p] %s\n", button->device_handle, button->acpi_handle, buffer.pointer)); - break; - } - - DEBUG_PRINT(ACPI_INFO, ("+------------------------------------------------------------\n")); - - acpi_os_free(buffer.pointer); -#endif /*ACPI_DEBUG*/ - - return; -} - - -/**************************************************************************** - * - * FUNCTION: bn_add_device - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bn_add_device( - BM_HANDLE device_handle, - void **context) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE *device = NULL; - BN_CONTEXT *button = NULL; - - FUNCTION_TRACE("bn_add_device"); - - DEBUG_PRINT(ACPI_INFO, ("Adding button device [0x%02x].\n", device_handle)); - - if (!context || *context) { - DEBUG_PRINT(ACPI_ERROR, ("Invalid context.\n")); - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - /* - * Get information on this device. - */ - status = bm_get_device_info( device_handle, &device ); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* - * Allocate a new BN_CONTEXT structure. - */ - button = acpi_os_callocate(sizeof(BN_CONTEXT)); - if (!button) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - button->device_handle = device->handle; - button->acpi_handle = device->acpi_handle; - - /* - * Power Button? - * ------------- - * Either fixed-feature or generic (namespace) types. - */ - if (strncmp(device->id.hid, BN_HID_POWER_BUTTON, - sizeof(BM_DEVICE_HID)) == 0) { - - if (device->id.type == BM_TYPE_FIXED_BUTTON) { - - button->type = BN_TYPE_POWER_BUTTON_FIXED; - - /* Register for fixed-feature events. */ - status = acpi_install_fixed_event_handler( - ACPI_EVENT_POWER_BUTTON, bn_notify_fixed, - (void*)button); - } - else { - button->type = BN_TYPE_POWER_BUTTON; - } - - //proc_mkdir(BN_PROC_POWER_BUTTON, bn_proc_root); - - } - - /* - * Sleep Button? - * ------------- - * Either fixed-feature or generic (namespace) types. - */ - else if (strncmp( device->id.hid, BN_HID_SLEEP_BUTTON, - sizeof(BM_DEVICE_HID)) == 0) { - - if (device->id.type == BM_TYPE_FIXED_BUTTON) { - - button->type = BN_TYPE_SLEEP_BUTTON_FIXED; - - /* Register for fixed-feature events. */ - status = acpi_install_fixed_event_handler( - ACPI_EVENT_SLEEP_BUTTON, bn_notify_fixed, - (void*)button); - } - else { - button->type = BN_TYPE_SLEEP_BUTTON; - } - - //proc_mkdir(BN_PROC_SLEEP_BUTTON, bn_proc_root); - } - - /* - * LID Switch? - * ----------- - */ - else if (strncmp( device->id.hid, BN_HID_LID_SWITCH, - sizeof(BM_DEVICE_HID)) == 0) { - - button->type = BN_TYPE_LID_SWITCH; - - //proc_mkdir(BN_PROC_LID_SWITCH, bn_proc_root); - } - - *context = button; - - bn_print(button); - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bn_remove_device - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bn_remove_device( - void **context) -{ - ACPI_STATUS status = AE_OK; - BN_CONTEXT *button = NULL; - - FUNCTION_TRACE("bn_remove_device"); - - if (!context || !*context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - button = (BN_CONTEXT*)*context; - - DEBUG_PRINT(ACPI_INFO, ("Removing button device [0x%02x].\n", button->device_handle)); - - /* - * Remove the /proc entry for this button. - */ - switch (button->type) { - - case BN_TYPE_POWER_BUTTON: - case BN_TYPE_POWER_BUTTON_FIXED: - /* Unregister for fixed-feature events. */ - status = acpi_remove_fixed_event_handler( - ACPI_EVENT_POWER_BUTTON, bn_notify_fixed); - //remove_proc_entry(BN_PROC_POWER_BUTTON, bn_proc_root); - break; - - case BN_TYPE_SLEEP_BUTTON: - case BN_TYPE_SLEEP_BUTTON_FIXED: - /* Unregister for fixed-feature events. */ - status = acpi_remove_fixed_event_handler( - ACPI_EVENT_SLEEP_BUTTON, bn_notify_fixed); - //remove_proc_entry(BN_PROC_SLEEP_BUTTON, bn_proc_root); - break; - - case BN_TYPE_LID_SWITCH: - //remove_proc_entry(BN_PROC_LID_SWITCH, bn_proc_root); - break; - } - - acpi_os_free(button); - - *context = NULL; - - return_ACPI_STATUS(status); -} - - -/***************************************************************************** - * External Functions - *****************************************************************************/ - -/***************************************************************************** - * - * FUNCTION: bn_initialize - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - - ****************************************************************************/ - -ACPI_STATUS -bn_initialize (void) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE_ID criteria; - BM_DRIVER driver; - - FUNCTION_TRACE("bn_initialize"); - - MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID)); - MEMSET(&driver, 0, sizeof(BM_DRIVER)); - - driver.notify = &bn_notify; - driver.request = &bn_request; - - /* - * Create button's root /proc entry. - */ - //bn_proc_root = proc_mkdir(BN_PROC_ROOT, bm_proc_root); - //if (!bn_proc_root) { -// return_ACPI_STATUS(AE_ERROR); -// } - - /* - * Register for power buttons. - */ - MEMCPY(criteria.hid, BN_HID_POWER_BUTTON, sizeof(BN_HID_POWER_BUTTON)); - status = bm_register_driver(&criteria, &driver); - - /* - * Register for sleep buttons. - */ - MEMCPY(criteria.hid, BN_HID_SLEEP_BUTTON, sizeof(BN_HID_SLEEP_BUTTON)); - status = bm_register_driver(&criteria, &driver); - - /* - * Register for LID switches. - */ - MEMCPY(criteria.hid, BN_HID_LID_SWITCH, sizeof(BN_HID_LID_SWITCH)); - status = bm_register_driver(&criteria, &driver); - - if (status == AE_NOT_FOUND) - status = AE_OK; - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bn_terminate - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bn_terminate (void) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE_ID criteria; - BM_DRIVER driver; - - FUNCTION_TRACE("bn_terminate"); - - MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID)); - MEMSET(&driver, 0, sizeof(BM_DRIVER)); - - driver.notify = &bn_notify; - driver.request = &bn_request; - - /* - * Unregister for power buttons. - */ - MEMCPY(criteria.hid, BN_HID_POWER_BUTTON, sizeof(BN_HID_POWER_BUTTON)); - status = bm_unregister_driver(&criteria, &driver); - - /* - * Unregister for sleep buttons. - */ - MEMCPY(criteria.hid, BN_HID_SLEEP_BUTTON, sizeof(BN_HID_SLEEP_BUTTON)); - status = bm_unregister_driver(&criteria, &driver); - - /* - * Unregister for LID switches. - */ - MEMCPY(criteria.hid, BN_HID_LID_SWITCH, sizeof(BN_HID_LID_SWITCH)); - status = bm_unregister_driver(&criteria, &driver); - - /* - * Remove button's root /proc entry. - */ - if (bn_proc_root) { - //remove_proc_entry(BN_PROC_ROOT, bm_proc_root); - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bn_notify_fixed - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bn_notify_fixed ( - void *context) -{ - ACPI_STATUS status = AE_OK; - BN_CONTEXT *button = NULL; - - FUNCTION_TRACE("bn_notify_fixed"); - - if (!context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - button = (BN_CONTEXT*)context; - - DbgPrint("Fixed button status change event detected.\n"); - - switch (button->type) { - - case BN_TYPE_POWER_BUTTON_FIXED: - DEBUG_PRINT(ACPI_INFO, ("Fixed-feature button status change event detected.\n")); - /*bm_generate_event(button->device_handle, BN_PROC_ROOT, - BN_PROC_POWER_BUTTON, BN_NOTIFY_STATUS_CHANGE, 0);*/ - break; - - case BN_TYPE_SLEEP_BUTTON_FIXED: - DEBUG_PRINT(ACPI_INFO, ("Fixed-feature button status change event detected.\n")); - /*bm_generate_event(button->device_handle, BN_PROC_ROOT, - BN_PROC_SLEEP_BUTTON, BN_NOTIFY_STATUS_CHANGE, 0);*/ - break; - - default: - DEBUG_PRINT(ACPI_INFO, ("Unsupported fixed-feature event detected.\n")); - status = AE_SUPPORT; - break; - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bn_notify - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bn_notify ( - BM_NOTIFY notify_type, - BM_HANDLE device_handle, - void **context) -{ - ACPI_STATUS status = AE_OK; - - FUNCTION_TRACE("bn_notify"); - - if (!context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - switch (notify_type) { - case BM_NOTIFY_DEVICE_ADDED: - status = bn_add_device(device_handle, context); - break; - - case BM_NOTIFY_DEVICE_REMOVED: - status = bn_remove_device(context); - break; - - case BN_NOTIFY_STATUS_CHANGE: - DEBUG_PRINT(ACPI_INFO, ("Button status change event detected.\n")); - - DbgPrint("Button status change event detected.\n"); - - if (!context || !*context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - switch(((BN_CONTEXT*)*context)->type) { - - case BN_TYPE_POWER_BUTTON: - case BN_TYPE_POWER_BUTTON_FIXED: - /*bm_generate_event(device_handle, BN_PROC_ROOT, - BN_PROC_POWER_BUTTON, notify_type, 0);*/ - break; - - case BN_TYPE_SLEEP_BUTTON: - case BN_TYPE_SLEEP_BUTTON_FIXED: - /*bm_generate_event(device_handle, BN_PROC_ROOT, - BN_PROC_SLEEP_BUTTON, notify_type, 0);*/ - break; - - case BN_TYPE_LID_SWITCH: - /*bm_generate_event(device_handle, BN_PROC_ROOT, - BN_PROC_LID_SWITCH, notify_type, 0);*/ - break; - - default: - status = AE_SUPPORT; - break; - } - - break; - - default: - status = AE_SUPPORT; - break; - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bn_request - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bn_request ( - BM_REQUEST *request, - void *context) -{ - ACPI_STATUS status = AE_OK; - - FUNCTION_TRACE("bn_request"); - - /* - * Must have a valid request structure and context. - */ - if (!request || !context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - /* - * Handle Request: - * --------------- - */ - switch (request->command) { - - default: - status = AE_SUPPORT; - break; - } - - request->status = status; - - return_ACPI_STATUS(status); -} diff --git a/reactos/drivers/bus/acpi/ospm/busmgr/bm.c b/reactos/drivers/bus/acpi/ospm/busmgr/bm.c deleted file mode 100644 index 42253ae36dc..00000000000 --- a/reactos/drivers/bus/acpi/ospm/busmgr/bm.c +++ /dev/null @@ -1,1047 +0,0 @@ -/****************************************************************************** - * - * Module Name: bm.c - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_BUS_MANAGER - MODULE_NAME ("bm") - - -/**************************************************************************** - * Globals - ****************************************************************************/ - -extern FADT_DESCRIPTOR_REV2 acpi_fadt; -/* TODO: Make dynamically sizeable. */ -static BM_NODE_LIST node_list; - - -/**************************************************************************** - * Internal Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_print - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -void -bm_print ( - BM_NODE *node, - u32 flags) -{ - ACPI_BUFFER buffer; - BM_DEVICE *device = NULL; - char *type_string = NULL; - - if (!node) { - return; - } - - device = &(node->device); - - if (flags & BM_PRINT_PRESENT) { - if (!BM_DEVICE_PRESENT(device)) { - return; - } - } - - buffer.length = 256; - buffer.pointer = acpi_os_callocate(buffer.length); - if (!buffer.pointer) { - return; - } - - acpi_get_name(device->acpi_handle, ACPI_FULL_PATHNAME, &buffer); - - switch(device->id.type) { - case BM_TYPE_SYSTEM: - type_string = "System"; - break; - case BM_TYPE_SCOPE: - type_string = "Scope"; - break; - case BM_TYPE_PROCESSOR: - type_string = "Processor"; - break; - case BM_TYPE_THERMAL_ZONE: - type_string = "ThermalZone"; - break; - case BM_TYPE_POWER_RESOURCE: - type_string = "PowerResource"; - break; - case BM_TYPE_FIXED_BUTTON: - type_string = "Button"; - break; - case BM_TYPE_DEVICE: - type_string = "Device"; - break; - default: - type_string = "Unknown"; - break; - } - - if (!(flags & BM_PRINT_GROUP)) { - DEBUG_PRINT(ACPI_INFO, ("+------------------------------------------------------------\n")); - } - - DEBUG_PRINT(ACPI_INFO, ("%s[0x%02x] hid[%s] %s\n", type_string, device->handle, device->id.hid, buffer.pointer)); - DEBUG_PRINT(ACPI_INFO, (" acpi_handle[0x%08x] flags[0x%02x] status[0x%02x]\n", device->acpi_handle, device->flags, device->status)); - - if (flags & BM_PRINT_IDENTIFICATION) { - DEBUG_PRINT(ACPI_INFO, (" identification: uid[%s] adr[0x%08x]\n", device->id.uid, device->id.adr)); - } - - if (flags & BM_PRINT_LINKAGE) { - DEBUG_PRINT(ACPI_INFO, (" linkage: this[%p] parent[%p] next[%p]\n", node, node->parent, node->next)); - DEBUG_PRINT(ACPI_INFO, (" scope.head[%p] scope.tail[%p]\n", node->scope.head, node->scope.tail)); - } - - if (flags & BM_PRINT_POWER) { - DEBUG_PRINT(ACPI_INFO, (" power: state[D%d] flags[0x%08X]\n", device->power.state, device->power.flags)); - DEBUG_PRINT(ACPI_INFO, (" S0[0x%02x] S1[0x%02x] S2[0x%02x]\n", device->power.dx_supported[0], device->power.dx_supported[1], device->power.dx_supported[2])); - DEBUG_PRINT(ACPI_INFO, (" S3[0x%02x] S4[0x%02x] S5[0x%02x]\n", device->power.dx_supported[3], device->power.dx_supported[4], device->power.dx_supported[5])); - } - - if (!(flags & BM_PRINT_GROUP)) { - DEBUG_PRINT(ACPI_INFO, ("+------------------------------------------------------------\n")); - } - - acpi_os_free(buffer.pointer); - - return; -} - - -/**************************************************************************** - * - * FUNCTION: bm_print_hierarchy - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -void -bm_print_hierarchy (void) -{ - u32 i = 0; - - FUNCTION_TRACE("bm_print_hierarchy"); - - DEBUG_PRINT(ACPI_INFO, ("+------------------------------------------------------------\n")); - - for (i = 0; i < node_list.count; i++) { - bm_print(node_list.nodes[i], BM_PRINT_GROUP | BM_PRINT_PRESENT); - } - - DEBUG_PRINT(ACPI_INFO, ("+------------------------------------------------------------\n")); - - return_VOID; -} - - -/**************************************************************************** - * - * FUNCTION: bm_get_status - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_get_status ( - BM_DEVICE *device) -{ - ACPI_STATUS status = AE_OK; - - if (!device) { - return AE_BAD_PARAMETER; - } - - device->status = BM_STATUS_UNKNOWN; - - /* - * Dynamic Status? - * --------------- - * If _STA isn't present we just return the default status. - */ - if (!(device->flags & BM_FLAGS_DYNAMIC_STATUS)) { - device->status = BM_STATUS_DEFAULT; - return AE_OK; - } - - /* - * Evaluate _STA: - * -------------- - */ - status = bm_evaluate_simple_integer(device->acpi_handle, "_STA", - &(device->status)); - - return status; -} - - -/**************************************************************************** - * - * FUNCTION: bm_get_identification - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_get_identification ( - BM_DEVICE *device) -{ - ACPI_STATUS status = AE_OK; - ACPI_DEVICE_INFO info; - - if (!device) { - return AE_BAD_PARAMETER; - } - - if (!(device->flags & BM_FLAGS_IDENTIFIABLE)) { - return AE_OK; - } - - MEMSET(&(device->id.uid), 0, sizeof(device->id.uid)); - MEMSET(&(device->id.hid), 0, sizeof(device->id.hid)); - device->id.adr = BM_ADDRESS_UNKNOWN; - - /* - * Get Object Info: - * ---------------- - * Evalute _UID, _HID, _ADR, and _STA... - */ - status = acpi_get_object_info(device->acpi_handle, &info); - if (ACPI_FAILURE(status)) { - return status; - } - - if (info.valid & ACPI_VALID_UID) { - MEMCPY((void*)device->id.uid, (void*)info.unique_id, - sizeof(BM_DEVICE_UID)); - } - - if (info.valid & ACPI_VALID_HID) { - MEMCPY((void*)device->id.hid, (void*)info.hardware_id, - sizeof(BM_DEVICE_HID)); - } - - if (info.valid & ACPI_VALID_ADR) { - device->id.adr = info.address; - } - - return status; -} - - -/**************************************************************************** - * - * FUNCTION: bm_get_flags - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_get_flags ( - BM_DEVICE *device) -{ - ACPI_HANDLE acpi_handle = NULL; - - if (!device) { - return AE_BAD_PARAMETER; - } - - device->flags = BM_FLAGS_UNKNOWN; - - switch (device->id.type) { - - case BM_TYPE_DEVICE: - - /* - * Presence of _DCK indicates a docking station. - */ - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, - "_DCK", &acpi_handle))) { - device->flags |= BM_FLAGS_DOCKING_STATION; - } - - /* - * Presence of _EJD and/or _EJx indicates 'ejectable'. - * TODO: _EJx... - */ - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, - "_EJD", &acpi_handle))) { - device->flags |= BM_FLAGS_EJECTABLE; - } - - /* - * Presence of _PR0 or _PS0 indicates 'power manageable'. - */ - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, - "_PR0", &acpi_handle)) || - ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, - "_PS0", &acpi_handle))) { - device->flags |= BM_FLAGS_POWER_CONTROL; - } - - /* - * Presence of _CRS indicates 'configurable'. - */ - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, - "_CRS", &acpi_handle))) { - device->flags |= BM_FLAGS_CONFIGURABLE; - } - - /* Fall through to next case statement. */ - - case BM_TYPE_PROCESSOR: - case BM_TYPE_THERMAL_ZONE: - case BM_TYPE_POWER_RESOURCE: - /* - * Presence of _HID or _ADR indicates 'identifiable'. - */ - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, - "_HID", &acpi_handle)) || - ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, - "_ADR", &acpi_handle))) { - device->flags |= BM_FLAGS_IDENTIFIABLE; - } - - /* - * Presence of _STA indicates 'dynamic status'. - */ - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, - "_STA", &acpi_handle))) { - device->flags |= BM_FLAGS_DYNAMIC_STATUS; - } - - break; - } - - return AE_OK; -} - - -/**************************************************************************** - * - * FUNCTION: bm_add_namespace_device - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_add_namespace_device ( - ACPI_HANDLE acpi_handle, - ACPI_OBJECT_TYPE acpi_type, - BM_NODE *parent, - BM_NODE **child) -{ - ACPI_STATUS status = AE_OK; - BM_NODE *node = NULL; - BM_DEVICE *device = NULL; - - FUNCTION_TRACE("bm_add_namespace_device"); - - if (!parent || !child) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - if (node_list.count > BM_HANDLES_MAX) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - (*child) = NULL; - - /* - * Create Node: - * ------------ - */ - node = acpi_os_callocate(sizeof(BM_NODE)); - if (!node) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - node->parent = parent; - node->next = NULL; - - device = &(node->device); - - device->handle = node_list.count; - device->acpi_handle = acpi_handle; - - /* - * Device Type: - * ------------ - */ - switch (acpi_type) { - case INTERNAL_TYPE_SCOPE: - device->id.type = BM_TYPE_SCOPE; - break; - case ACPI_TYPE_PROCESSOR: - device->id.type = BM_TYPE_PROCESSOR; - break; - case ACPI_TYPE_THERMAL: - device->id.type = BM_TYPE_THERMAL_ZONE; - break; - case ACPI_TYPE_POWER: - device->id.type = BM_TYPE_POWER_RESOURCE; - break; - case ACPI_TYPE_DEVICE: - device->id.type = BM_TYPE_DEVICE; - break; - } - - /* - * Get Other Device Info: - * ---------------------- - * But only if this device's parent is present (which implies - * this device MAY be present). - */ - if (BM_NODE_PRESENT(node->parent)) { - /* - * Device Flags - */ - status = bm_get_flags(device); - if (ACPI_FAILURE(status)) { - goto end; - } - - /* - * Device Identification - */ - status = bm_get_identification(device); - if (ACPI_FAILURE(status)) { - goto end; - } - - /* - * Device Status - */ - status = bm_get_status(device); - if (ACPI_FAILURE(status)) { - goto end; - } - - /* - * Power Management: - * ----------------- - * If this node doesn't provide direct power control - * then we inherit PM capabilities from its parent. - * - * TODO: Inherit! - */ - if (device->flags & BM_FLAGS_POWER_CONTROL) { - status = bm_get_pm_capabilities(node); - if (ACPI_FAILURE(status)) { - goto end; - } - } - } - -end: - if (ACPI_FAILURE(status)) { - acpi_os_free(node); - } - else { - /* - * Add to the node_list. - */ - node_list.nodes[node_list.count++] = node; - - /* - * Formulate Hierarchy: - * -------------------- - * Arrange within the namespace by assigning the parent and - * adding to the parent device's list of children (scope). - */ - if (!parent->scope.head) { - parent->scope.head = node; - } - else { - if (!parent->scope.tail) { - (parent->scope.head)->next = node; - } - else { - (parent->scope.tail)->next = node; - } - } - parent->scope.tail = node; - - (*child) = node; - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_enumerate_namespace - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_enumerate_namespace (void) -{ - ACPI_STATUS status = AE_OK; - ACPI_HANDLE parent_handle = ACPI_ROOT_OBJECT; - ACPI_HANDLE child_handle = NULL; - BM_NODE *parent = NULL; - BM_NODE *child = NULL; - ACPI_OBJECT_TYPE acpi_type = 0; - u32 level = 1; - - FUNCTION_TRACE("bm_enumerate_namespace"); - - parent = node_list.nodes[0]; - - /* - * Enumerate ACPI Namespace: - * ------------------------- - * Parse through the ACPI namespace, identify all 'devices', - * and create a new entry for each in our collection. - */ - while (level > 0) { - - /* - * Get the next object at this level. - */ - status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle, child_handle, &child_handle); - if (ACPI_SUCCESS(status)) { - - /* - * TODO: This is a hack to get around the problem - * identifying scope objects. Scopes - * somehow need to be uniquely identified. - */ - status = acpi_get_type(child_handle, &acpi_type); - if (ACPI_SUCCESS(status) && (acpi_type == ACPI_TYPE_ANY)) { - status = acpi_get_next_object(ACPI_TYPE_ANY, child_handle, 0, NULL); - if (ACPI_SUCCESS(status)) { - acpi_type = INTERNAL_TYPE_SCOPE; - } - } - - /* - * Device? - * ------- - * If this object is a 'device', insert into the - * ACPI Bus Manager's local hierarchy and search - * the object's scope for any child devices (a - * depth-first search). - */ - switch (acpi_type) { - case INTERNAL_TYPE_SCOPE: - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_THERMAL: - case ACPI_TYPE_POWER: - status = bm_add_namespace_device(child_handle, acpi_type, parent, &child); - if (ACPI_SUCCESS(status)) { - status = acpi_get_next_object(ACPI_TYPE_ANY, child_handle, 0, NULL); - if (ACPI_SUCCESS(status)) { - level++; - parent_handle = child_handle; - child_handle = 0; - parent = child; - } - } - break; - } - } - - /* - * Scope Exhausted: - * ---------------- - * No more children in this object's scope, Go back up - * in the namespace tree to the object's parent. - */ - else { - level--; - child_handle = parent_handle; - acpi_get_parent(parent_handle, - &parent_handle); - - if (parent) { - parent = parent->parent; - } - else { - return_ACPI_STATUS(AE_NULL_ENTRY); - } - } - } - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_add_fixed_feature_device - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_add_fixed_feature_device ( - BM_NODE *parent, - BM_DEVICE_TYPE device_type, - char *device_hid) -{ - ACPI_STATUS status = AE_OK; - BM_NODE *node = NULL; - - FUNCTION_TRACE("bm_add_fixed_feature_device"); - - if (!parent) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - if (node_list.count > BM_HANDLES_MAX) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - /* - * Allocate the new device and add to the device array. - */ - node = acpi_os_callocate(sizeof(BM_NODE)); - if (!node) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - /* - * Get device info. - */ - node->device.handle = node_list.count; - node->device.acpi_handle = ACPI_ROOT_OBJECT; - node->device.id.type = BM_TYPE_FIXED_BUTTON; - if (device_hid) { - MEMCPY((void*)node->device.id.hid, device_hid, - sizeof(node->device.id.hid)); - } - node->device.flags = BM_FLAGS_FIXED_FEATURE; - node->device.status = BM_STATUS_DEFAULT; - /* TODO: Device PM capabilities */ - - /* - * Add to the node_list. - */ - node_list.nodes[node_list.count++] = node; - - /* - * Formulate Hierarchy: - * -------------------- - * Arrange within the namespace by assigning the parent and - * adding to the parent device's list of children (scope). - */ - node->parent = parent; - node->next = NULL; - - if (parent) { - if (!parent->scope.head) { - parent->scope.head = node; - } - else { - if (!parent->scope.tail) { - (parent->scope.head)->next = node; - } - else { - (parent->scope.tail)->next = node; - } - } - parent->scope.tail = node; - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_enumerate_fixed_features - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_enumerate_fixed_features (void) -{ - FUNCTION_TRACE("bm_enumerate_fixed_features"); - - /* - * Root Object: - * ------------ - * Fabricate the root object, which happens to always get a - * device_handle of zero. - */ - node_list.nodes[0] = acpi_os_callocate(sizeof(BM_NODE)); - if (NULL == (node_list.nodes[0])) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - node_list.nodes[0]->device.handle = BM_HANDLE_ROOT; - node_list.nodes[0]->device.acpi_handle = ACPI_ROOT_OBJECT; - node_list.nodes[0]->device.flags = BM_FLAGS_UNKNOWN; - node_list.nodes[0]->device.status = BM_STATUS_DEFAULT; - node_list.nodes[0]->device.id.type = BM_TYPE_SYSTEM; - /* TODO: Get system PM capabilities (Sx states?) */ - - node_list.count++; - - /* - * Fixed Features: - * --------------- - * Enumerate fixed-feature devices (e.g. power and sleep buttons). - */ - if (acpi_fadt.pwr_button == 0) { - bm_add_fixed_feature_device(node_list.nodes[0], - BM_TYPE_FIXED_BUTTON, BM_HID_POWER_BUTTON); - } - - if (acpi_fadt.sleep_button == 0) { - bm_add_fixed_feature_device(node_list.nodes[0], - BM_TYPE_FIXED_BUTTON, BM_HID_SLEEP_BUTTON); - } - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_get_handle - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_get_handle ( - ACPI_HANDLE acpi_handle, - BM_HANDLE *device_handle) -{ - ACPI_STATUS status = AE_OK; - u32 i = 0; - - FUNCTION_TRACE("bm_get_handle"); - - if (!device_handle) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - *device_handle = BM_HANDLE_UNKNOWN; - - /* - * Search all devices for a match on the ACPI handle. - */ - for (i=0; idevice.acpi_handle == acpi_handle) { - *device_handle = node_list.nodes[i]->device.handle; - break; - } - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_get_node - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_get_node ( - BM_HANDLE device_handle, - ACPI_HANDLE acpi_handle, - BM_NODE **node) -{ - ACPI_STATUS status = AE_OK; - - FUNCTION_TRACE("bm_get_node"); - - if (!node) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - /* - * If no device handle, resolve acpi handle to device handle. - */ - if (!device_handle && acpi_handle) { - status = bm_get_handle(acpi_handle, &device_handle); - if (ACPI_FAILURE(status)) - return_ACPI_STATUS(status); - } - - /* - * Valid device handle? - */ - if (device_handle > BM_HANDLES_MAX) { - DEBUG_PRINT(ACPI_ERROR, ("Invalid node handle [0x%02x] detected.\n", device_handle)); - return_ACPI_STATUS(AE_ERROR); - } - - *node = node_list.nodes[device_handle]; - - /* - * Valid node? - */ - if (!(*node)) { - DEBUG_PRINT(ACPI_ERROR, ("Invalid (NULL) node entry [0x%02x] detected.\n", device_handle)); - return_ACPI_STATUS(AE_NULL_ENTRY); - } - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_initialize - * - * PARAMETERS: - * - * RETURN: Exception code. - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_initialize (void) -{ - ACPI_STATUS status = AE_OK; - u32 start = 0; - u32 stop = 0; - u32 elapsed = 0; - - FUNCTION_TRACE("bm_initialize"); - - MEMSET(&node_list, 0, sizeof(BM_HANDLE_LIST)); - - acpi_get_timer(&start); - - DEBUG_PRINT(ACPI_INFO, ("Building device hierarchy.\n")); - - /* - * Enumerate ACPI fixed-feature devices. - */ - status = bm_enumerate_fixed_features(); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* - * Enumerate the ACPI namespace. - */ - status = bm_enumerate_namespace(); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - acpi_get_timer(&stop); - acpi_get_timer_duration(start, stop, &elapsed); - - DEBUG_PRINT(ACPI_INFO, ("Device heirarchy build took [%d] microseconds.\n", elapsed)); - - /* - * Display hierarchy. - */ -#ifdef ACPI_DEBUG - bm_print_hierarchy(); -#endif /*ACPI_DEBUG*/ - - /* - * Register for all standard and device-specific notifications. - */ - DEBUG_PRINT(ACPI_INFO, ("Registering for all device notifications.\n")); - - status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, - ACPI_SYSTEM_NOTIFY, &bm_notify, NULL); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_ERROR, ("Unable to register for standard notifications.\n")); - return_ACPI_STATUS(status); - } - - status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, - ACPI_DEVICE_NOTIFY, &bm_notify, NULL); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_ERROR, ("Unable to register for device-specific notifications.\n")); - return_ACPI_STATUS(status); - } - - /* - * Initialize /proc interface. - */ - //DEBUG_PRINT(ACPI_INFO, ("Initializing /proc interface.\n")); - //status = bm_proc_initialize(); - - DEBUG_PRINT(ACPI_INFO, ("ACPI Bus Manager enabled.\n")); - - /* - * Initialize built-in power resource driver. - */ - bm_pr_initialize(); - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_terminate - * - * PARAMETERS: - * - * RETURN: Exception code. - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_terminate (void) -{ - ACPI_STATUS status = AE_OK; - u32 i = 0; - - FUNCTION_TRACE("bm_terminate"); - - /* - * Terminate built-in power resource driver. - */ - bm_pr_terminate(); - - /* - * Remove the /proc interface. - */ - //DEBUG_PRINT(ACPI_INFO, ("Removing /proc interface.\n")); - //status = bm_proc_terminate(); - - - /* - * Unregister for all notifications. - */ - - DEBUG_PRINT(ACPI_INFO, ("Unregistering for device notifications.\n")); - - status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT, - ACPI_SYSTEM_NOTIFY, &bm_notify); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_ERROR, ("Unable to un-register for standard notifications.\n")); - } - - status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT, - ACPI_DEVICE_NOTIFY, &bm_notify); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_ERROR, ("Unable to un-register for device-specific notifications.\n")); - } - - /* - * Parse through the device array, freeing all entries. - */ - DEBUG_PRINT(ACPI_INFO, ("Removing device hierarchy.\n")); - for (i = 0; i < node_list.count; i++) { - if (node_list.nodes[i]) { - acpi_os_free(node_list.nodes[i]); - } - } - - DEBUG_PRINT(ACPI_INFO, ("ACPI Bus Manager disabled.\n")); - - return_ACPI_STATUS(AE_OK); -} diff --git a/reactos/drivers/bus/acpi/ospm/busmgr/bmnotify.c b/reactos/drivers/bus/acpi/ospm/busmgr/bmnotify.c deleted file mode 100644 index 1f6e4176061..00000000000 --- a/reactos/drivers/bus/acpi/ospm/busmgr/bmnotify.c +++ /dev/null @@ -1,310 +0,0 @@ -/***************************************************************************** - * - * Module Name: bmnotify.c - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - - -#define _COMPONENT ACPI_BUS_MANAGER - MODULE_NAME ("bmnotify") - - -/**************************************************************************** - * Internal Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_generate_notify - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_generate_notify ( - BM_NODE *node, - u32 notify_type) -{ - ACPI_STATUS status = AE_OK; - - FUNCTION_TRACE("bm_generate_notify"); - - if (!node) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - DEBUG_PRINT(ACPI_INFO, ("Sending notify [0x%02x] to device [0x%02x].\n", notify_type, node->device.handle)); - - if (!(node->device.flags & BM_FLAGS_DRIVER_CONTROL) || - !(node->driver.notify)) { - DEBUG_PRINT(ACPI_WARN, ("No driver installed for device [0x%02x].\n", node->device.handle)); - return_ACPI_STATUS(AE_NOT_EXIST); - } - - status = node->driver.notify(notify_type, node->device.handle, - &(node->driver.context)); - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_device_check - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_device_check ( - BM_NODE *node, - u32 *status_change) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE *device = NULL; - BM_DEVICE_STATUS old_status = BM_STATUS_UNKNOWN; - - FUNCTION_TRACE("bm_device_check"); - - if (!node) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - device = &(node->device); - - if (status_change) { - *status_change = FALSE; - } - - old_status = device->status; - - /* - * Parent Present? - * --------------- - * Only check this device if its parent is present (which implies - * this device MAY be present). - */ - if (!BM_NODE_PRESENT(node->parent)) { - return_ACPI_STATUS(AE_OK); - } - - /* - * Get Status: - * ----------- - * And see if the status has changed. - */ - status = bm_get_status(device); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - if (old_status == node->device.status) { - return_ACPI_STATUS(AE_OK); - } - - if (status_change) { - *status_change = TRUE; - } - - /* - * Device Insertion? - * ----------------- - */ - if ((device->status & BM_STATUS_PRESENT) && - !(old_status & BM_STATUS_PRESENT)) { - /* TODO: Make sure driver is loaded, and if not, load. */ - status = bm_generate_notify(node, BM_NOTIFY_DEVICE_ADDED); - } - - /* - * Device Removal? - * --------------- - */ - else if (!(device->status & BM_STATUS_PRESENT) && - (old_status & BM_STATUS_PRESENT)) { - /* TODO: Unload driver if last device instance. */ - status = bm_generate_notify(node, BM_NOTIFY_DEVICE_REMOVED); - } - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_bus_check - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_bus_check ( - BM_NODE *parent_node) -{ - ACPI_STATUS status = AE_OK; - u32 status_change = FALSE; - - FUNCTION_TRACE("bm_bus_check"); - - if (!parent_node) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - /* - * Status Change? - * -------------- - */ - status = bm_device_check(parent_node, &status_change); - if (ACPI_FAILURE(status) || !status_change) { - return_ACPI_STATUS(status); - } - - /* - * Enumerate Scope: - * ---------------- - * TODO: Enumerate child devices within this device's scope and - * run bm_device_check()'s on them... - */ - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_notify - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -void -bm_notify ( - ACPI_HANDLE acpi_handle, - u32 notify_value, - void *context) -{ - ACPI_STATUS status = AE_OK; - BM_NODE *node = NULL; - - FUNCTION_TRACE("bm_notify"); - - /* - * Resolve the ACPI handle. - */ - status = bm_get_node(0, acpi_handle, &node); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_INFO, ("Recieved notify [0x%02x] for unknown device [%p].\n", notify_value, acpi_handle)); - return_VOID; - } - - /* - * Device-Specific or Standard? - * ---------------------------- - * Device-specific notifies are forwarded to the control module's - * notify() function for processing. Standard notifies are handled - * internally. - */ - if (notify_value > 0x7F) { - status = bm_generate_notify(node, notify_value); - } - else { - switch (notify_value) { - - case BM_NOTIFY_BUS_CHECK: - DEBUG_PRINT(ACPI_INFO, ("Received BUS CHECK notification.\n")); - status = bm_bus_check(node); - break; - - case BM_NOTIFY_DEVICE_CHECK: - DEBUG_PRINT(ACPI_INFO, ("Received DEVICE CHECK notification.\n")); - status = bm_device_check(node, NULL); - break; - - case BM_NOTIFY_DEVICE_WAKE: - DEBUG_PRINT(ACPI_INFO, ("Received DEVICE WAKE notification.\n")); - /* TODO */ - break; - - case BM_NOTIFY_EJECT_REQUEST: - DEBUG_PRINT(ACPI_INFO, ("Received EJECT REQUEST notification.\n")); - /* TODO */ - break; - - case BM_NOTIFY_DEVICE_CHECK_LIGHT: - DEBUG_PRINT(ACPI_INFO, ("Received DEVICE CHECK LIGHT notification.\n")); - /* TODO: Exactly what does the 'light' mean? */ - status = bm_device_check(node, NULL); - break; - - case BM_NOTIFY_FREQUENCY_MISMATCH: - DEBUG_PRINT(ACPI_INFO, ("Received FREQUENCY MISMATCH notification.\n")); - /* TODO */ - break; - - case BM_NOTIFY_BUS_MODE_MISMATCH: - DEBUG_PRINT(ACPI_INFO, ("Received BUS MODE MISMATCH notification.\n")); - /* TODO */ - break; - - case BM_NOTIFY_POWER_FAULT: - DEBUG_PRINT(ACPI_INFO, ("Received POWER FAULT notification.\n")); - /* TODO */ - break; - - default: - DEBUG_PRINT(ACPI_INFO, ("Received unknown/unsupported notification.\n")); - break; - } - } - - return_VOID; -} - - diff --git a/reactos/drivers/bus/acpi/ospm/busmgr/bmpm.c b/reactos/drivers/bus/acpi/ospm/busmgr/bmpm.c deleted file mode 100644 index 61d65aef58e..00000000000 --- a/reactos/drivers/bus/acpi/ospm/busmgr/bmpm.c +++ /dev/null @@ -1,395 +0,0 @@ -/***************************************************************************** - * - * Module Name: bmpm.c - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_POWER_CONTROL - MODULE_NAME ("bmpm") - - -/**************************************************************************** - * Internal Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_get_inferred_power_state - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_get_inferred_power_state ( - BM_DEVICE *device) -{ - ACPI_STATUS status = AE_OK; - BM_HANDLE_LIST pr_list; - BM_POWER_STATE list_state = ACPI_STATE_UNKNOWN; - char object_name[5] = {'_','P','R','0','\0'}; - u32 i = 0; - - FUNCTION_TRACE("bm_get_inferred_power_state"); - - if (!device) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - MEMSET(&pr_list, 0, sizeof(BM_HANDLE_LIST)); - - device->power.state = ACPI_STATE_D3; - - /* - * Calculate Power State: - * ---------------------- - * Try to infer the devices's power state by checking the state of - * the devices's power resources. We start by evaluating _PR0 - * (resource requirements at D0) and work through _PR1 and _PR2. - * We know the current devices power state when all resources (for - * a give Dx state) are ON. If no power resources are on then the - * device is assumed to be off (D3). - */ - for (i=ACPI_STATE_D0; iacpi_handle, - object_name, &pr_list); - - if (ACPI_SUCCESS(status)) { - - status = bm_pr_list_get_state(&pr_list, - &list_state); - - if (ACPI_SUCCESS(status)) { - - if (list_state == ACPI_STATE_D0) { - device->power.state = i; - break; - } - } - } - } - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_get_power_state - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_get_power_state ( - BM_NODE *node) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE *device = NULL; - - FUNCTION_TRACE("bm_get_power_state"); - - if (!node) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - device = &(node->device); - - device->power.state = ACPI_STATE_UNKNOWN; - - if (device->flags & BM_FLAGS_POWER_STATE) { - status = bm_evaluate_simple_integer(device->acpi_handle, - "_PSC", &(device->power.state)); - } - else { - status = bm_get_inferred_power_state(device); - } - - if (ACPI_SUCCESS(status)) { - DEBUG_PRINT(ACPI_INFO, ("Device [0x%02x] is at power state [D%d].\n", device->handle, device->power.state)); - } - else { - DEBUG_PRINT(ACPI_INFO, ("Error getting power state for device [0x%02x]\n", device->handle)); - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_set_power_state - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_set_power_state ( - BM_NODE *node, - BM_POWER_STATE state) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE *device = NULL; - BM_DEVICE *parent_device = NULL; - BM_HANDLE_LIST current_list; - BM_HANDLE_LIST target_list; - char object_name[5] = {'_','P','R','0','\0'}; - - FUNCTION_TRACE("bm_set_power_state"); - - if (!node || !node->parent || (state > ACPI_STATE_D3)) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - MEMSET(¤t_list, 0, sizeof(BM_HANDLE_LIST)); - MEMSET(&target_list, 0, sizeof(BM_HANDLE_LIST)); - - device = &(node->device); - parent_device = &(node->parent->device); - - /* - * Check Parent's Power State: - * --------------------------- - * Can't be in a higher power state (lower Dx value) than parent. - */ - if (state < parent_device->power.state) { - DEBUG_PRINT(ACPI_WARN, ("Cannot set device [0x%02x] to a higher-powered state than parent_device.\n", device->handle)); - return_ACPI_STATUS(AE_ERROR); - } - - /* - * Get Resources: - * -------------- - * Get the power resources associated with the device's current - * and target power states. - */ - if (device->power.state != ACPI_STATE_UNKNOWN) { - object_name[3] = '0' + device->power.state; - bm_evaluate_reference_list(device->acpi_handle, - object_name, ¤t_list); - } - - object_name[3] = '0' + state; - bm_evaluate_reference_list(device->acpi_handle, object_name, - &target_list); - - /* - * Transition Resources: - * --------------------- - * Transition all power resources referenced by this device to - * the correct power state (taking into consideration sequencing - * and dependencies to other devices). - */ - if (current_list.count || target_list.count) { - status = bm_pr_list_transition(¤t_list, &target_list); - } - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* - * Execute _PSx: - * ------------- - * Execute the _PSx method corresponding to the target Dx state, - * if it exists. - */ - object_name[2] = 'S'; - object_name[3] = '0' + state; - bm_evaluate_object(device->acpi_handle, object_name, NULL, NULL); - - if (ACPI_SUCCESS(status)) { - DEBUG_PRINT(ACPI_INFO, ("Device [0x%02x] is now at [D%d].\n", device->handle, state)); - device->power.state = state; - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_get_pm_capabilities - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_get_pm_capabilities ( - BM_NODE *node) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE *device = NULL; - BM_DEVICE *parent_device = NULL; - ACPI_HANDLE acpi_handle = NULL; - BM_POWER_STATE dx_supported = ACPI_STATE_UNKNOWN; - char object_name[5] = {'_','S','0','D','\0'}; - u32 i = 0; - - FUNCTION_TRACE("bm_get_pm_capabilities"); - - if (!node || !node->parent) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - device = &(node->device); - parent_device = &(node->parent->device); - - /* - * Power Management Flags: - * ----------------------- - */ - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PSC", - &acpi_handle))) { - device->power.flags |= BM_FLAGS_POWER_STATE; - } - - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_IRC", - &acpi_handle))) { - device->power.flags |= BM_FLAGS_INRUSH_CURRENT; - } - - if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PRW", - &acpi_handle))) { - device->power.flags |= BM_FLAGS_WAKE_CAPABLE; - } - - /* - * Device Power State: - * ------------------- - * Note that we can't get the device's power state until we've - * initialized all power resources, so for now we just set to - * unknown. - */ - device->power.state = ACPI_STATE_UNKNOWN; - - /* - * Dx Supported in S0: - * ------------------- - * Figure out which Dx states are supported by this device for the - * S0 (working) state. Note that D0 and D3 are required (assumed). - */ - device->power.dx_supported[ACPI_STATE_S0] = BM_FLAGS_D0_SUPPORT | - BM_FLAGS_D3_SUPPORT; - - if ((ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PR1", - &acpi_handle))) || - (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PS1", - &acpi_handle)))) { - device->power.dx_supported[ACPI_STATE_S0] |= - BM_FLAGS_D1_SUPPORT; - } - - if ((ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PR2", - &acpi_handle))) || - (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PS2", - &acpi_handle)))) { - device->power.dx_supported[ACPI_STATE_S0] |= - BM_FLAGS_D2_SUPPORT; - } - - /* - * Dx Supported in S1-S5: - * ---------------------- - * Figure out which Dx states are supported by this device for - * all other Sx states. - */ - for (i = ACPI_STATE_S1; i <= ACPI_STATE_S5; i++) { - - /* - * D3 support is assumed (off is always possible!). - */ - device->power.dx_supported[i] = BM_FLAGS_D3_SUPPORT; - - /* - * Evalute _SxD: - * ------------- - * Which returns the highest (power) Dx state supported in - * this system (Sx) state. We convert this value to a bit - * mask of supported states (conceptually simpler). - */ - status = bm_evaluate_simple_integer(device->acpi_handle, - object_name, &dx_supported); - if (ACPI_SUCCESS(status)) { - switch (dx_supported) { - case 0: - device->power.dx_supported[i] |= - BM_FLAGS_D0_SUPPORT; - /* fall through */ - case 1: - device->power.dx_supported[i] |= - BM_FLAGS_D1_SUPPORT; - /* fall through */ - case 2: - device->power.dx_supported[i] |= - BM_FLAGS_D2_SUPPORT; - /* fall through */ - case 3: - device->power.dx_supported[i] |= - BM_FLAGS_D3_SUPPORT; - break; - } - - /* - * Validate: - * --------- - * Mask of any states that _Sx_d falsely advertises - * (e.g.claims D1 support but neither _PR2 or _PS2 - * exist). In other words, S1-S5 can't offer a Dx - * state that isn't supported by S0. - */ - device->power.dx_supported[i] &= - device->power.dx_supported[ACPI_STATE_S0]; - } - - object_name[2]++; - } - - return_ACPI_STATUS(status); -} diff --git a/reactos/drivers/bus/acpi/ospm/busmgr/bmpower.c b/reactos/drivers/bus/acpi/ospm/busmgr/bmpower.c deleted file mode 100644 index 759c6d7cf0f..00000000000 --- a/reactos/drivers/bus/acpi/ospm/busmgr/bmpower.c +++ /dev/null @@ -1,666 +0,0 @@ -/**************************************************************************** - * - * Module Name: bmpower.c - Driver for ACPI Power Resource 'devices' - * $Revision: 1.1 $ - * - ****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * TODO: - * ----- - * 1. Sequencing of power resource list transitions. - * 2. Global serialization of power resource transtions (see ACPI - * spec section 7.1.2/7.1.3). - * 3. Better error handling. - */ - - -#include - -#define _COMPONENT ACPI_POWER_CONTROL - MODULE_NAME ("bmpower") - - -/**************************************************************************** - * Function Prototypes - ****************************************************************************/ - -ACPI_STATUS -bm_pr_notify ( - BM_NOTIFY notify_type, - BM_HANDLE device_handle, - void **context); - -ACPI_STATUS -bm_pr_request ( - BM_REQUEST *request, - void *context); - - -/**************************************************************************** - * Internal Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_pr_print - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_print ( - BM_POWER_RESOURCE *pr) -{ - ACPI_BUFFER buffer; - - if (!pr) { - return(AE_BAD_PARAMETER); - } - - buffer.length = 256; - buffer.pointer = acpi_os_callocate(buffer.length); - if (!buffer.pointer) { - return(AE_NO_MEMORY); - } - - acpi_get_name(pr->acpi_handle, ACPI_FULL_PATHNAME, &buffer); - - acpi_os_printf("Power Resource: found\n"); - - DEBUG_PRINT(ACPI_INFO, ("+------------------------------------------------------------\n")); - DEBUG_PRINT(ACPI_INFO, ("PowerResource[0x%02X]|[0x%08X] %s\n", pr->device_handle, pr->acpi_handle, buffer.pointer)); - DEBUG_PRINT(ACPI_INFO, (" system_level[S%d] resource_order[%d]\n", pr->system_level, pr->resource_order)); - DEBUG_PRINT(ACPI_INFO, (" state[D%d] reference_count[%d]\n", pr->state, pr->reference_count)); - DEBUG_PRINT(ACPI_INFO, ("+------------------------------------------------------------\n")); - - acpi_os_free(buffer.pointer); - - return(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_get_state - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_get_state ( - BM_POWER_RESOURCE *pr) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE_STATUS device_status = BM_STATUS_UNKNOWN; - - FUNCTION_TRACE("bm_pr_get_state"); - - if (!pr) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - pr->state = ACPI_STATE_UNKNOWN; - - /* - * Evaluate _STA: - * -------------- - * Evalute _STA to determine whether the power resource is ON or OFF. - * Note that if the power resource isn't present we'll get AE_OK but - * an unknown status. - */ - status = bm_get_device_status(pr->device_handle, &device_status); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_ERROR, ("Error reading status for power resource [0x%02x].\n", pr->device_handle)); - return_ACPI_STATUS(status); - } - if (device_status == BM_STATUS_UNKNOWN) { - DEBUG_PRINT(ACPI_ERROR, ("Error reading status for power resource [0x%02x].\n", pr->device_handle)); - return_ACPI_STATUS(AE_NOT_EXIST); - } - - /* - * Mask off all bits but the first as some systems return non-standard - * values (e.g. 0x51). - */ - switch (device_status & 0x01) { - case 0: - DEBUG_PRINT(ACPI_INFO, ("Power resource [0x%02x] is OFF.\n", pr->device_handle)); - pr->state = ACPI_STATE_D3; - break; - case 1: - DEBUG_PRINT(ACPI_INFO, ("Power resource [0x%02x] is ON.\n", pr->device_handle)); - pr->state = ACPI_STATE_D0; - break; - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_set_state - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_set_state ( - BM_POWER_RESOURCE *pr, - BM_POWER_STATE target_state) -{ - ACPI_STATUS status = AE_OK; - - FUNCTION_TRACE("bm_pr_set_state"); - - if (!pr) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - status = bm_pr_get_state(pr); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - if (target_state == pr->state) { - DEBUG_PRINT(ACPI_INFO, ("Power resource [0x%02X] already at target power state [D%d].\n", pr->device_handle, pr->state)); - return_ACPI_STATUS(AE_OK); - } - - switch (target_state) { - - case ACPI_STATE_D0: - DEBUG_PRINT(ACPI_INFO, ("Turning power resource [0x%02X] ON.\n", pr->device_handle)); - status = bm_evaluate_object(pr->acpi_handle, "_ON", NULL, NULL); - break; - - case ACPI_STATE_D3: - DEBUG_PRINT(ACPI_INFO, ("Turning power resource [0x%02X] OFF.\n", pr->device_handle)); - status = bm_evaluate_object(pr->acpi_handle, "_OFF", NULL, NULL); - break; - - default: - status = AE_BAD_PARAMETER; - break; - } - - status = bm_pr_get_state(pr); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_list_get_state - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_list_get_state ( - BM_HANDLE_LIST *pr_list, - BM_POWER_STATE *power_state) -{ - ACPI_STATUS status = AE_OK; - BM_POWER_RESOURCE *pr = NULL; - u32 i = 0; - - FUNCTION_TRACE("bm_pr_list_get_state"); - - if (!pr_list || !power_state) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - if (pr_list->count < 1) { - pr->state = ACPI_STATE_UNKNOWN; - return_ACPI_STATUS(AE_ERROR); - } - - (*power_state) = ACPI_STATE_D0; - - /* - * Calculate Current power_state: - * ----------------------------- - * The current state of a list of power resources is ON if all - * power resources are currently in the ON state. In other words, - * if any power resource in the list is OFF then the collection - * isn't fully ON. - */ - for (i = 0; i < pr_list->count; i++) { - - status = bm_get_device_context(pr_list->handles[i], - (BM_DRIVER_CONTEXT*)(&pr)); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_WARN, ("Invalid reference to power resource [0x%02X].\n", pr_list->handles[i])); - (*power_state) = ACPI_STATE_UNKNOWN; - break; - } - - status = bm_pr_get_state(pr); - if (ACPI_FAILURE(status)) { - (*power_state) = ACPI_STATE_UNKNOWN; - break; - } - - if (pr->state != ACPI_STATE_D0) { - (*power_state) = pr->state; - break; - } - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_list_transition - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_list_transition ( - BM_HANDLE_LIST *current_list, - BM_HANDLE_LIST *target_list) -{ - ACPI_STATUS status = AE_OK; - BM_POWER_RESOURCE *pr = NULL; - u32 i = 0; - - FUNCTION_TRACE("bm_pr_list_transition"); - - if (!current_list || !target_list) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - /* - * Reference Target: - * ----------------- - * Reference all resources for the target power state first (so - * the device doesn't get turned off while transitioning). Power - * resources that aren't on (new reference count of 1) are turned on. - */ - for (i = 0; i < target_list->count; i++) { - - status = bm_get_device_context(target_list->handles[i], - (BM_DRIVER_CONTEXT*)(&pr)); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_WARN, ("Invalid reference to power resource [0x%02X].\n", target_list->handles[i])); - continue; - } - - if (++pr->reference_count == 1) { - /* TODO: Need ordering based upon resource_order */ - status = bm_pr_set_state(pr, ACPI_STATE_D0); - if (ACPI_FAILURE(status)) { - /* TODO: How do we handle this? */ - DEBUG_PRINT(ACPI_WARN, ("Unable to change power state for power resource [0x%02X].\n", target_list->handles[i])); - } - } - } - - /* - * Dereference Current: - * -------------------- - * Dereference all resources for the current power state. Power - * resources no longer referenced (new reference count of 0) are - * turned off. - */ - for (i = 0; i < current_list->count; i++) { - - status = bm_get_device_context(current_list->handles[i], - (BM_DRIVER_CONTEXT*)(&pr)); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(ACPI_WARN, ("Invalid reference to power resource [0x%02X].\n", target_list->handles[i])); - continue; - } - - if (--pr->reference_count == 0) { - /* TODO: Need ordering based upon resource_order */ - status = bm_pr_set_state(pr, ACPI_STATE_D3); - if (ACPI_FAILURE(status)) { - /* TODO: How do we handle this? */ - DEBUG_PRINT(ACPI_ERROR, ("Unable to change power state for power resource [0x%02X].\n", current_list->handles[i])); - } - } - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_add_device - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_add_device ( - BM_HANDLE device_handle, - void **context) -{ - ACPI_STATUS status = AE_OK; - BM_POWER_RESOURCE *pr = NULL; - BM_DEVICE *device = NULL; - ACPI_BUFFER buffer; - ACPI_OBJECT acpi_object; - - FUNCTION_TRACE("bm_pr_add_device"); - - DEBUG_PRINT(ACPI_INFO, ("Adding power resource [0x%02X].\n", device_handle)); - - if (!context || *context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - buffer.length = sizeof(ACPI_OBJECT); - buffer.pointer = &acpi_object; - - /* - * Get information on this device. - */ - status = bm_get_device_info(device_handle, &device); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* - * Allocate a new BM_POWER_RESOURCE structure. - */ - pr = acpi_os_callocate(sizeof(BM_POWER_RESOURCE)); - if (!pr) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - pr->device_handle = device->handle; - pr->acpi_handle = device->acpi_handle; - - /* - * Get information on this power resource. - */ - status = acpi_evaluate_object(pr->acpi_handle, NULL, NULL, &buffer); - if (ACPI_FAILURE(status)) { - goto end; - } - - pr->system_level = acpi_object.power_resource.system_level; - pr->resource_order = acpi_object.power_resource.resource_order; - pr->state = ACPI_STATE_UNKNOWN; - pr->reference_count = 0; - - /* - * Get the power resource's current state (ON|OFF). - */ - status = bm_pr_get_state(pr); - -end: - if (ACPI_FAILURE(status)) { - acpi_os_free(pr); - } - else { - *context = pr; - bm_pr_print(pr); - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_remove_device - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_remove_device ( - void **context) -{ - ACPI_STATUS status = AE_OK; - BM_POWER_RESOURCE *pr = NULL; - - FUNCTION_TRACE("bm_pr_remove_device"); - - if (!context || !*context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - pr = (BM_POWER_RESOURCE*)*context; - - DEBUG_PRINT(ACPI_INFO, ("Removing power resource [0x%02X].\n", pr->device_handle)); - - acpi_os_free(pr); - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_pr_initialize - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_initialize (void) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE_ID criteria; - BM_DRIVER driver; - - FUNCTION_TRACE("bm_pr_initialize"); - - MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID)); - MEMSET(&driver, 0, sizeof(BM_DRIVER)); - - criteria.type = BM_TYPE_POWER_RESOURCE; - - driver.notify = &bm_pr_notify; - driver.request = &bm_pr_request; - - status = bm_register_driver(&criteria, &driver); - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_terminate - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_terminate (void) -{ - ACPI_STATUS status = AE_OK; - BM_DEVICE_ID criteria; - BM_DRIVER driver; - - FUNCTION_TRACE("bm_pr_terminate"); - - MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID)); - MEMSET(&driver, 0, sizeof(BM_DRIVER)); - - criteria.type = BM_TYPE_POWER_RESOURCE; - - driver.notify = &bm_pr_notify; - driver.request = &bm_pr_request; - - status = bm_unregister_driver(&criteria, &driver); - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_notify - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_notify ( - BM_NOTIFY notify_type, - BM_HANDLE device_handle, - void **context) -{ - ACPI_STATUS status = AE_OK; - - FUNCTION_TRACE("bm_pr_notify"); - - switch (notify_type) { - - case BM_NOTIFY_DEVICE_ADDED: - status = bm_pr_add_device(device_handle, context); - break; - - case BM_NOTIFY_DEVICE_REMOVED: - status = bm_pr_remove_device(context); - break; - - default: - status = AE_SUPPORT; - break; - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_pr_request - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_pr_request ( - BM_REQUEST *request, - void *context) -{ - ACPI_STATUS status = AE_OK; - BM_POWER_RESOURCE *pr = NULL; - - FUNCTION_TRACE("bm_pr_request"); - - /* - * Must have a valid request structure and context. - */ - if (!request || !context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - /* - * context contains information specific to this power resource. - */ - pr = (BM_POWER_RESOURCE*)context; - - /* - * Handle request: - * --------------- - */ - switch (request->command) { - - default: - status = AE_SUPPORT; - break; - } - - request->status = status; - - return_ACPI_STATUS(status); -} - - - diff --git a/reactos/drivers/bus/acpi/ospm/busmgr/bmrequest.c b/reactos/drivers/bus/acpi/ospm/busmgr/bmrequest.c deleted file mode 100644 index d02ee941bef..00000000000 --- a/reactos/drivers/bus/acpi/ospm/busmgr/bmrequest.c +++ /dev/null @@ -1,163 +0,0 @@ -/****************************************************************************** - * - * Module Name: bmrequest.c - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_BUS_MANAGER - MODULE_NAME ("bmrequest") - - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_generate_request - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_generate_request ( - BM_NODE *node, - BM_REQUEST *request) -{ - ACPI_STATUS status = AE_OK; - - FUNCTION_TRACE("bm_generate_request"); - - if (!node || !request) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - DEBUG_PRINT(ACPI_INFO, ("Sending request [0x%02x] to device [0x%02x].\n", request->command, node->device.handle)); - - if (!(node->device.flags & BM_FLAGS_DRIVER_CONTROL) || - !(node->driver.request)) { - DEBUG_PRINT(ACPI_WARN, ("No driver installed for device [0x%02x].\n", node->device.handle)); - return_ACPI_STATUS(AE_NOT_EXIST); - } - - status = node->driver.request(request, node->driver.context); - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_request - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_request ( - BM_REQUEST *request) -{ - ACPI_STATUS status = AE_OK; - BM_NODE *node = NULL; - BM_DEVICE *device = NULL; - - FUNCTION_TRACE("bm_request"); - - /* - * Must have a valid request structure. - */ - if (!request) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - DEBUG_PRINT(ACPI_INFO, ("Received request for device [0x%02x] command [0x%08x].\n", request->handle, request->command)); - - /* - * Resolve the node. - */ - status = bm_get_node(request->handle, 0, &node); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - device = &(node->device); - - /* - * Device-Specific Request? - * ------------------------ - * If a device-specific command (>=0x80) forward this request to - * the appropriate driver. - */ - if (request->command & BM_COMMAND_DEVICE_SPECIFIC) { - status = bm_generate_request(node, request); - return_ACPI_STATUS(status); - } - - /* - * Bus-Specific Requests: - * ---------------------- - */ - switch (request->command) { - - case BM_COMMAND_GET_POWER_STATE: - status = bm_get_power_state(node); - if (ACPI_FAILURE(status)) { - break; - } - status = bm_copy_to_buffer(&(request->buffer), - &(device->power.state), sizeof(BM_POWER_STATE)); - break; - - case BM_COMMAND_SET_POWER_STATE: - { - BM_POWER_STATE *power_state = NULL; - - status = bm_cast_buffer(&(request->buffer), - (void**)&power_state, sizeof(BM_POWER_STATE)); - if (ACPI_FAILURE(status)) { - break; - } - status = bm_set_power_state(node, *power_state); - } - break; - - default: - status = AE_SUPPORT; - request->status = AE_SUPPORT; - break; - } - - return_ACPI_STATUS(status); -} diff --git a/reactos/drivers/bus/acpi/ospm/busmgr/bmsearch.c b/reactos/drivers/bus/acpi/ospm/busmgr/bmsearch.c deleted file mode 100644 index ed3714938fd..00000000000 --- a/reactos/drivers/bus/acpi/ospm/busmgr/bmsearch.c +++ /dev/null @@ -1,190 +0,0 @@ -/****************************************************************************** - * - * Module Name: bmsearch.c - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_BUS_MANAGER - MODULE_NAME ("bmsearch") - - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_compare - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_compare ( - BM_DEVICE *device, - BM_DEVICE_ID *criteria) -{ - if (!device || !criteria) { - return AE_BAD_PARAMETER; - } - - /* - * Present? - * -------- - * We're only going to match on devices that are present. - * TODO: Optimize in bm_search (don't have to call here). - */ - if (!BM_DEVICE_PRESENT(device)) { - return AE_NOT_FOUND; - } - - /* - * type? - */ - if (criteria->type && !(criteria->type & device->id.type)) { - return AE_NOT_FOUND; - } - - /* - * hid? - */ - if ((criteria->hid[0]) && (0 != STRNCMP(criteria->hid, - device->id.hid, sizeof(BM_DEVICE_HID)))) { - return AE_NOT_FOUND; - } - - /* - * adr? - */ - if ((criteria->adr) && (criteria->adr != device->id.adr)) { - return AE_NOT_FOUND; - } - - return AE_OK; -} - - -/**************************************************************************** - * - * FUNCTION: bm_search - * - * PARAMETERS: - * - * RETURN: AE_BAD_PARAMETER- invalid input parameter - * AE_NOT_EXIST - start_device_handle doesn't exist - * AE_NOT_FOUND - no matches to Search_info.criteria found - * AE_OK - success - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_search( - BM_HANDLE device_handle, - BM_DEVICE_ID *criteria, - BM_HANDLE_LIST *results) -{ - ACPI_STATUS status = AE_OK; - BM_NODE *node = NULL; - - FUNCTION_TRACE("bm_search"); - - if (!criteria || !results) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - results->count = 0; - - /* - * Locate Starting Point: - * ---------------------- - * Locate the node in the hierarchy where we'll begin our search. - */ - status = bm_get_node(device_handle, 0, &node); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* - * Parse Hierarchy: - * ---------------- - * Parse through the node hierarchy looking for matches. - */ - while (node && (results->count<=BM_HANDLES_MAX)) { - /* - * Depth-first: - * ------------ - * Searches are always performed depth-first. - */ - if (node->scope.head) { - status = bm_compare(&(node->device), criteria); - if (ACPI_SUCCESS(status)) { - results->handles[results->count++] = - node->device.handle; - } - node = node->scope.head; - } - - /* - * Now Breadth: - * ------------ - * Search all peers until scope is exhausted. - */ - else { - status = bm_compare(&(node->device), criteria); - if (ACPI_SUCCESS(status)) { - results->handles[results->count++] = - node->device.handle; - } - - /* - * Locate Next Device: - * ------------------- - * The next node is either a peer at this level - * (node->next is valid), or we work are way back - * up the tree until we either find a non-parsed - * peer or hit the top (node->parent is NULL). - */ - while (!node->next && node->parent) { - node = node->parent; - } - node = node->next; - } - } - - if (results->count == 0) { - return_ACPI_STATUS(AE_NOT_FOUND); - } - else { - return_ACPI_STATUS(AE_OK); - } -} diff --git a/reactos/drivers/bus/acpi/ospm/busmgr/bmutils.c b/reactos/drivers/bus/acpi/ospm/busmgr/bmutils.c deleted file mode 100644 index 5eda0703f58..00000000000 --- a/reactos/drivers/bus/acpi/ospm/busmgr/bmutils.c +++ /dev/null @@ -1,604 +0,0 @@ -/***************************************************************************** - * - * Module Name: bmutils.c - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_BUS_MANAGER - MODULE_NAME ("bmutils") - - -#ifdef ACPI_DEBUG -#define DEBUG_EVAL_ERROR(l,h,p,s) bm_print_eval_error(l,h,p,s) -#else -#define DEBUG_EVAL_ERROR(l,h,p,s) -#endif - - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_print_eval_error - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -void -bm_print_eval_error ( - u32 debug_level, - ACPI_HANDLE acpi_handle, - ACPI_STRING pathname, - ACPI_STATUS status) -{ - ACPI_BUFFER buffer; - ACPI_STRING status_string = NULL; - - buffer.length = 256; - buffer.pointer = acpi_os_callocate(buffer.length); - if (!buffer.pointer) { - return; - } - - status_string = acpi_cm_format_exception(status); - - status = acpi_get_name(acpi_handle, ACPI_FULL_PATHNAME, &buffer); - if (ACPI_FAILURE(status)) { - DEBUG_PRINT(debug_level, ("Evaluate object [0x%08x], %s\n", acpi_handle, status_string)); - return; - } - - if (pathname) { - DEBUG_PRINT(ACPI_INFO, ("Evaluate object [%s.%s], %s\n", buffer.pointer, pathname, status_string)); - } - else { - DEBUG_PRINT(ACPI_INFO, ("Evaluate object [%s], %s\n", buffer.pointer, status_string)); - } - - acpi_os_free(buffer.pointer); -} - - -/**************************************************************************** - * - * FUNCTION: bm_copy_to_buffer - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_copy_to_buffer ( - ACPI_BUFFER *buffer, - void *data, - u32 length) -{ - FUNCTION_TRACE("bm_copy_to_buffer"); - - if (!buffer || (!buffer->pointer) || !data || (length == 0)) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - if (length > buffer->length) { - buffer->length = length; - return_ACPI_STATUS(AE_BUFFER_OVERFLOW); - } - - buffer->length = length; - MEMCPY(buffer->pointer, data, length); - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_cast_buffer - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_cast_buffer ( - ACPI_BUFFER *buffer, - void **pointer, - u32 length) -{ - FUNCTION_TRACE("bm_cast_buffer"); - - if (!buffer || !buffer->pointer || !pointer || length == 0) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - if (length > buffer->length) { - return_ACPI_STATUS(AE_BAD_DATA); - } - - *pointer = buffer->pointer; - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_extract_package_data - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -/* - TODO: Don't assume numbers (in ASL) are 32-bit values!!!! (IA64) - TODO: Issue with 'assumed' types coming out of interpreter... - (e.g. toshiba _BIF) -*/ - -ACPI_STATUS -bm_extract_package_data ( - ACPI_OBJECT *package, - ACPI_BUFFER *package_format, - ACPI_BUFFER *buffer) -{ - ACPI_STATUS status = AE_OK; - u8 *head = NULL; - u8 *tail = NULL; - u8 **pointer = NULL; - u32 tail_offset = 0; - ACPI_OBJECT *element = NULL; - u32 size_required = 0; - char* format = NULL; - u32 format_count = 0; - u32 i = 0; - - FUNCTION_TRACE("bm_extract_package_data"); - - if (!package || (package->type != ACPI_TYPE_PACKAGE) || - (package->package.count == 0) || !package_format || - (package_format->length < 1) || - (!package_format->pointer) || !buffer) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - format_count = package_format->length - 1; - - if (format_count > package->package.count) { - DEBUG_PRINT(ACPI_WARN, ("Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count)); - return_ACPI_STATUS(AE_BAD_DATA); - } - - format = (char*)package_format->pointer; - - /* - * Calculate size_required. - */ - for (i=0; ipackage.elements[i]); - - switch (element->type) { - - case ACPI_TYPE_INTEGER: - switch (format[i]) { - case 'N': - size_required += sizeof(ACPI_INTEGER); - tail_offset += sizeof(ACPI_INTEGER); - break; - case 'S': - size_required += sizeof(u8*) + - sizeof(ACPI_INTEGER) + 1; - tail_offset += sizeof(ACPI_INTEGER); - break; - default: - DEBUG_PRINT(ACPI_WARN, ("Invalid package element [%d]: got number, expecing [%c].\n", i, format[i])); - return_ACPI_STATUS(AE_BAD_DATA); - break; - } - break; - - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - switch (format[i]) { - case 'S': - size_required += sizeof(u8*) + - element->string.length + 1; - tail_offset += sizeof(u8*); - break; - case 'B': - size_required += sizeof(u8*) + - element->buffer.length; - tail_offset += sizeof(u8*); - break; - default: - DEBUG_PRINT(ACPI_WARN, ("Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format[i])); - return_ACPI_STATUS(AE_BAD_DATA); - break; - } - break; - - case ACPI_TYPE_PACKAGE: - default: - /* TODO: handle nested packages... */ - return_ACPI_STATUS(AE_SUPPORT); - break; - } - } - - if (size_required > buffer->length) { - buffer->length = size_required; - return_ACPI_STATUS(AE_BUFFER_OVERFLOW); - } - - buffer->length = size_required; - - if (!buffer->pointer) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - head = buffer->pointer; - tail = head + tail_offset; - - /* - * Extract package data: - */ - for (i=0; ipackage.elements[i]); - - switch (element->type) { - - case ACPI_TYPE_INTEGER: - switch (format[i]) { - case 'N': - *((ACPI_INTEGER*)head) = - element->integer.value; - head += sizeof(ACPI_INTEGER); - break; - case 'S': - pointer = (u8**)head; - *pointer = tail; - *((ACPI_INTEGER*)tail) = - element->integer.value; - head += sizeof(ACPI_INTEGER*); - tail += sizeof(ACPI_INTEGER); - /* NULL terminate string */ - *tail = 0; - tail++; - break; - default: - /* Should never get here */ - break; - } - break; - - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - switch (format[i]) { - case 'S': - pointer = (u8**)head; - *pointer = tail; - memcpy(tail, element->string.pointer, - element->string.length); - head += sizeof(u8*); - tail += element->string.length; - /* NULL terminate string */ - *tail = 0; - tail++; - break; - case 'B': - pointer = (u8**)head; - *pointer = tail; - memcpy(tail, element->buffer.pointer, - element->buffer.length); - head += sizeof(u8*); - tail += element->buffer.length; - break; - default: - /* Should never get here */ - break; - } - break; - - case ACPI_TYPE_PACKAGE: - /* TODO: handle nested packages... */ - default: - /* Should never get here */ - break; - } - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_evaluate_object - * - * PARAMETERS: - * - * RETURN: AE_OK - * AE_BUFFER_OVERFLOW Evaluated object returned data, but - * caller did not provide buffer. - * - * DESCRIPTION: Helper for acpi_evaluate_object that handles buffer - * allocation. Note that the caller is responsible for - * freeing buffer->pointer! - * - ****************************************************************************/ - -ACPI_STATUS -bm_evaluate_object ( - ACPI_HANDLE acpi_handle, - ACPI_STRING pathname, - ACPI_OBJECT_LIST *arguments, - ACPI_BUFFER *buffer) -{ - ACPI_STATUS status = AE_OK; - - FUNCTION_TRACE("bm_evaluate_object"); - - /* If caller provided a buffer it must be unallocated/zero'd. */ - if ((buffer) && (buffer->length != 0 || buffer->pointer)) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - /* - * Evalute Object: - * --------------- - * The first attempt is just to get the size of the object data - * (that is unless there's no return data, e.g. _INI); the second - * gets the data. - */ - status = acpi_evaluate_object(acpi_handle, pathname, arguments, buffer); - if (ACPI_SUCCESS(status)) { - return_ACPI_STATUS(status); - } - - else if ((buffer) && (status == AE_BUFFER_OVERFLOW)) { - - /* Gotta allocate -- CALLER MUST FREE! */ - buffer->pointer = acpi_os_callocate(buffer->length); - if (!buffer->pointer) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - /* Re-evaluate -- this time it should work */ - status = acpi_evaluate_object(acpi_handle, pathname, - arguments, buffer); - } - - if (ACPI_FAILURE(status)) { - DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status); - if (buffer && buffer->pointer) { - acpi_os_free(buffer->pointer); - buffer->pointer = NULL; - buffer->length = 0; - } - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_evaluate_simple_integer - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_evaluate_simple_integer ( - ACPI_HANDLE acpi_handle, - ACPI_STRING pathname, - u32 *data) -{ - ACPI_STATUS status = AE_OK; - ACPI_OBJECT *element = NULL; - ACPI_BUFFER buffer; - - FUNCTION_TRACE("bm_evaluate_simple_integer"); - - if (!data) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - MEMSET(&buffer, 0, sizeof(ACPI_BUFFER)); - - /* - * Evaluate Object: - * ---------------- - */ - status = bm_evaluate_object(acpi_handle, pathname, NULL, &buffer); - if (ACPI_FAILURE(status)) { - goto end; - } - - /* - * Validate Data: - * -------------- - */ - status = bm_cast_buffer(&buffer, (void**)&element, - sizeof(ACPI_OBJECT)); - if (ACPI_FAILURE(status)) { - DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status); - goto end; - } - - if (element->type != ACPI_TYPE_INTEGER) { - status = AE_BAD_DATA; - DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status); - goto end; - } - - *data = element->integer.value; - -end: - acpi_os_free(buffer.pointer); - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_evaluate_reference_list - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_evaluate_reference_list ( - ACPI_HANDLE acpi_handle, - ACPI_STRING pathname, - BM_HANDLE_LIST *reference_list) -{ - ACPI_STATUS status = AE_OK; - ACPI_OBJECT *package = NULL; - ACPI_OBJECT *element = NULL; - ACPI_HANDLE reference_handle = NULL; - ACPI_BUFFER buffer; - u32 i = 0; - - FUNCTION_TRACE("bm_evaluate_reference_list"); - - if (!reference_list) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - MEMSET(&buffer, 0, sizeof(ACPI_BUFFER)); - - /* - * Evaluate Object: - * ---------------- - */ - status = bm_evaluate_object(acpi_handle, pathname, NULL, &buffer); - if (ACPI_FAILURE(status)) { - goto end; - } - - /* - * Validate Package: - * ----------------- - */ - status = bm_cast_buffer(&buffer, (void**)&package, - sizeof(ACPI_OBJECT)); - if (ACPI_FAILURE(status)) { - DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status); - goto end; - } - - if (package->type != ACPI_TYPE_PACKAGE) { - status = AE_BAD_DATA; - DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status); - goto end; - } - - if (package->package.count > BM_HANDLES_MAX) { - package->package.count = BM_HANDLES_MAX; - } - - /* - * Parse Package Data: - * ------------------- - */ - for (i = 0; i < package->package.count; i++) { - - element = &(package->package.elements[i]); - - if (!element || (element->type != ACPI_TYPE_STRING)) { - status = AE_BAD_DATA; - DEBUG_PRINT(ACPI_WARN, ("Invalid element in package (not a device reference).\n")); - DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status); - break; - } - - /* - * Resolve reference string (e.g. "\_PR_.CPU_") to an - * ACPI_HANDLE. - */ - status = acpi_get_handle(acpi_handle, - element->string.pointer, &reference_handle); - if (ACPI_FAILURE(status)) { - status = AE_BAD_DATA; - DEBUG_PRINT(ACPI_WARN, ("Unable to resolve device reference [%s].\n", element->string.pointer)); - DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status); - break; - } - - /* - * Resolve ACPI_HANDLE to BM_HANDLE. - */ - status = bm_get_handle(reference_handle, - &(reference_list->handles[i])); - if (ACPI_FAILURE(status)) { - status = AE_BAD_DATA; - DEBUG_PRINT(ACPI_WARN, ("Unable to resolve device reference for [0x%08x].\n", reference_handle)); - DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status); - break; - } - - DEBUG_PRINT(ACPI_INFO, ("Resolved reference [%s]->[0x%08x]->[0x%02x]\n", element->string.pointer, reference_handle, reference_list->handles[i])); - - (reference_list->count)++; - } - -end: - acpi_os_free(buffer.pointer); - - return_ACPI_STATUS(status); -} - - diff --git a/reactos/drivers/bus/acpi/ospm/busmgr/bmxface.c b/reactos/drivers/bus/acpi/ospm/busmgr/bmxface.c deleted file mode 100644 index 34b86fad4e8..00000000000 --- a/reactos/drivers/bus/acpi/ospm/busmgr/bmxface.c +++ /dev/null @@ -1,330 +0,0 @@ -/***************************************************************************** - * - * Module Name: bmxface.c - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_BUS_MANAGER - MODULE_NAME ("bmxface") - - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * - * FUNCTION: bm_get_device_status - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ -ACPI_STATUS -bm_get_device_status ( - BM_HANDLE device_handle, - BM_DEVICE_STATUS *device_status) -{ - ACPI_STATUS status = AE_OK; - BM_NODE *node = NULL; - - FUNCTION_TRACE("bm_get_device_status"); - - if (!device_status) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - *device_status = BM_STATUS_UNKNOWN; - - /* - * Resolve device handle to node. - */ - status = bm_get_node(device_handle, 0, &node); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* - * Parent Present? - * --------------- - * If the parent isn't present we can't evalute _STA on the child. - * Return an unknown status. - */ - if (!BM_NODE_PRESENT(node->parent)) { - return_ACPI_STATUS(AE_OK); - } - - /* - * Dynamic Status? - * --------------- - * If _STA isn't present we just return the default status. - */ - if (!(node->device.flags & BM_FLAGS_DYNAMIC_STATUS)) { - *device_status = BM_STATUS_DEFAULT; - return_ACPI_STATUS(AE_OK); - } - - /* - * Evaluate _STA: - * -------------- - */ - status = bm_evaluate_simple_integer(node->device.acpi_handle, "_STA", - &(node->device.status)); - if (ACPI_SUCCESS(status)) { - *device_status = node->device.status; - } - - return_ACPI_STATUS(status); -} - - -/**************************************************************************** - * - * FUNCTION: bm_get_device_info - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ -ACPI_STATUS -bm_get_device_info ( - BM_HANDLE device_handle, - BM_DEVICE **device) -{ - ACPI_STATUS status = AE_OK; - BM_NODE *node = NULL; - - FUNCTION_TRACE("bm_get_device_info"); - - if (!device) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - /* - * Resolve device handle to internal device. - */ - status = bm_get_node(device_handle, 0, &node); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - *device = &(node->device); - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_get_device_context - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ -ACPI_STATUS -bm_get_device_context ( - BM_HANDLE device_handle, - BM_DRIVER_CONTEXT *context) -{ - ACPI_STATUS status = AE_OK; - BM_NODE *node = NULL; - - FUNCTION_TRACE("bm_get_device_context"); - - if (!context) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - *context = NULL; - - /* - * Resolve device handle to internal device. - */ - status = bm_get_node(device_handle, 0, &node); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - if (!node->driver.context) { - return_ACPI_STATUS(AE_NULL_ENTRY); - } - - *context = node->driver.context; - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_register_driver - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_register_driver ( - BM_DEVICE_ID *criteria, - BM_DRIVER *driver) -{ - ACPI_STATUS status = AE_NOT_FOUND; - BM_HANDLE_LIST device_list; - BM_NODE *node = NULL; - u32 i = 0; - - FUNCTION_TRACE("bm_register_driver"); - - if (!criteria || !driver || !driver->notify || !driver->request) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - MEMSET(&device_list, 0, sizeof(BM_HANDLE_LIST)); - - /* - * Find Matches: - * ------------- - * Search through the entire device hierarchy for matches against - * the given device criteria. - */ - status = bm_search(BM_HANDLE_ROOT, criteria, &device_list); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* - * Install driver: - * ---------------- - * For each match, record the driver information and execute the - * driver's Notify() funciton (if present) to notify the driver - * of the device's presence. - */ - for (i = 0; i < device_list.count; i++) { - - /* Resolve the device handle. */ - status = bm_get_node(device_list.handles[i], 0, &node); - if (ACPI_FAILURE(status)) { - continue; - } - - DEBUG_PRINT(ACPI_INFO, ("Registering driver for device [0x%02x].\n", node->device.handle)); - - /* Notify driver of new device. */ - status = driver->notify(BM_NOTIFY_DEVICE_ADDED, - node->device.handle, &(node->driver.context)); - if (ACPI_SUCCESS(status)) { - node->driver.notify = driver->notify; - node->driver.request = driver->request; - node->device.flags |= BM_FLAGS_DRIVER_CONTROL; - } - } - - return_ACPI_STATUS(AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: bm_unregister_driver - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ****************************************************************************/ - -ACPI_STATUS -bm_unregister_driver ( - BM_DEVICE_ID *criteria, - BM_DRIVER *driver) -{ - ACPI_STATUS status = AE_NOT_FOUND; - BM_HANDLE_LIST device_list; - BM_NODE *node = NULL; - u32 i = 0; - - FUNCTION_TRACE("bm_unregister_driver"); - - if (!criteria || !driver || !driver->notify || !driver->request) { - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - MEMSET(&device_list, 0, sizeof(BM_HANDLE_LIST)); - - /* - * Find Matches: - * ------------- - * Search through the entire device hierarchy for matches against - * the given device criteria. - */ - status = bm_search(BM_HANDLE_ROOT, criteria, &device_list); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* - * Remove driver: - * --------------- - * For each match, execute the driver's Notify() function to allow - * the driver to cleanup each device instance. - */ - for (i = 0; i < device_list.count; i++) { - /* - * Resolve the device handle. - */ - status = bm_get_node(device_list.handles[i], 0, &node); - if (ACPI_FAILURE(status)) { - continue; - } - - DEBUG_PRINT(ACPI_INFO, ("Unregistering driver for device [0x%02x].\n", node->device.handle)); - - /* Notify driver of device removal. */ - status = node->driver.notify(BM_NOTIFY_DEVICE_REMOVED, - node->device.handle, &(node->driver.context)); - - node->device.flags &= ~BM_FLAGS_DRIVER_CONTROL; - - MEMSET(&(node->driver), 0, sizeof(BM_DRIVER)); - } - - return_ACPI_STATUS(AE_OK); -} diff --git a/reactos/drivers/bus/acpi/ospm/fdo.c b/reactos/drivers/bus/acpi/ospm/fdo.c deleted file mode 100644 index 5bf4ef74305..00000000000 --- a/reactos/drivers/bus/acpi/ospm/fdo.c +++ /dev/null @@ -1,983 +0,0 @@ -/* $Id$ - * - * PROJECT: ReactOS ACPI bus driver - * FILE: acpi/ospm/fdo.c - * PURPOSE: ACPI device object dispatch routines - * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) - * Hervé Poussineau (hpoussin@reactos.com) - * UPDATE HISTORY: - * 08-08-2001 CSH Created - */ -#include - -#define NDEBUG -#include - -FADT_DESCRIPTOR_REV2 acpi_fadt; - -/*** PRIVATE *****************************************************************/ - - -BOOLEAN -AcpiCreateUnicodeString( - PUNICODE_STRING Destination, - PWSTR Source, - POOL_TYPE PoolType) -{ - ULONG Length; - - if (!Source) - { - RtlInitUnicodeString(Destination, NULL); - return TRUE; - } - - Length = (wcslen(Source) + 1) * sizeof(WCHAR); - - Destination->Buffer = ExAllocatePool(PoolType, Length); - if (Destination->Buffer == NULL) - { - return FALSE; - } - - RtlCopyMemory(Destination->Buffer, Source, Length); - - Destination->MaximumLength = Length; - - Destination->Length = Length - sizeof(WCHAR); - - return TRUE; -} - -BOOLEAN -AcpiCreateDeviceIDString(PUNICODE_STRING DeviceID, - BM_NODE *Node) -{ - WCHAR Buffer[256]; - - swprintf(Buffer, - L"ACPI\\%S", - Node->device.id.hid); - - return AcpiCreateUnicodeString(DeviceID, Buffer, PagedPool); -} - - -BOOLEAN -AcpiCreateHardwareIDsString(PUNICODE_STRING HardwareIDs, - BM_NODE *Node) -{ - WCHAR Buffer[256]; - ULONG Length; - ULONG Index; - - Index = 0; - Index += swprintf(&Buffer[Index], - L"ACPI\\%S", - Node->device.id.hid); - Index++; - - Index += swprintf(&Buffer[Index], - L"*%S", - Node->device.id.hid); - Index++; - Buffer[Index] = UNICODE_NULL; - - Length = (Index + 1) * sizeof(WCHAR); - HardwareIDs->Buffer = ExAllocatePool(PagedPool, Length); - if (HardwareIDs->Buffer == NULL) - { - return FALSE; - } - - HardwareIDs->Length = Length - sizeof(WCHAR); - HardwareIDs->MaximumLength = Length; - RtlCopyMemory(HardwareIDs->Buffer, Buffer, Length); - - return TRUE; -} - - -BOOLEAN -AcpiCreateInstanceIDString(PUNICODE_STRING InstanceID, - BM_NODE *Node) -{ - WCHAR Buffer[10]; - - if (Node->device.id.uid[0]) - swprintf(Buffer, L"%S", Node->device.id.uid); - else - /* FIXME: Generate unique id! */ - swprintf(Buffer, L"%S", L"0000"); - - return AcpiCreateUnicodeString(InstanceID, Buffer, PagedPool); -} - - -BOOLEAN -AcpiCreateDeviceDescriptionString(PUNICODE_STRING DeviceDescription, - BM_NODE *Node) -{ - PWSTR Buffer; - - if (RtlCompareMemory(Node->device.id.hid, "PNP000", 6) == 6) - Buffer = L"Programmable interrupt controller"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP010", 6) == 6) - Buffer = L"System timer"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP020", 6) == 6) - Buffer = L"DMA controller"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP03", 5) == 5) - Buffer = L"Keyboard"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP040", 6) == 6) - Buffer = L"Parallel port"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP05", 5) == 5) - Buffer = L"Serial port"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP06", 5) ==5) - Buffer = L"Disk controller"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP07", 5) == 5) - Buffer = L"Disk controller"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP09", 5) == 5) - Buffer = L"Display adapter"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP0A0", 6) == 6) - Buffer = L"Bus controller"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP0E0", 6) == 6) - Buffer = L"PCMCIA controller"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP0F", 5) == 5) - Buffer = L"Mouse device"; - else if (RtlCompareMemory(Node->device.id.hid, "PNP8", 4) == 4) - Buffer = L"Network adapter"; - else if (RtlCompareMemory(Node->device.id.hid, "PNPA0", 5) == 5) - Buffer = L"SCSI controller"; - else if (RtlCompareMemory(Node->device.id.hid, "PNPB0", 5) == 5) - Buffer = L"Multimedia device"; - else if (RtlCompareMemory(Node->device.id.hid, "PNPC00", 6) == 6) - Buffer = L"Modem"; - else - Buffer = L"Other ACPI device"; - - return AcpiCreateUnicodeString(DeviceDescription, Buffer, PagedPool); -} - - -static BOOLEAN -AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList, - PULONG ResourceListSize, - PIO_RESOURCE_REQUIREMENTS_LIST* pRequirementsList, - PULONG RequirementsListSize, - RESOURCE* resources) -{ - BOOLEAN Done; - ULONG NumberOfResources = 0; - PCM_RESOURCE_LIST ResourceList; - PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; - PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor; - PIO_RESOURCE_DESCRIPTOR RequirementDescriptor; - RESOURCE* resource; - ULONG i; - - /* Count number of resources */ - Done = FALSE; - resource = resources; - while (!Done) - { - switch (resource->id) - { - case irq: - { - IRQ_RESOURCE *irq_data = (IRQ_RESOURCE*) &resource->data; - NumberOfResources += irq_data->number_of_interrupts; - break; - } - case dma: - { - DMA_RESOURCE *dma_data = (DMA_RESOURCE*) &resource->data; - NumberOfResources += dma_data->number_of_channels; - break; - } - case io: - { - NumberOfResources++; - break; - } - case end_tag: - { - Done = TRUE; - break; - } - default: - { - break; - } - } - resource = NEXT_RESOURCE(resource); - } - - /* Allocate memory */ - *ResourceListSize = sizeof(CM_RESOURCE_LIST) + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); - ResourceList = (PCM_RESOURCE_LIST)ExAllocatePool(PagedPool, *ResourceListSize); - *pResourceList = ResourceList; - if (!ResourceList) - return FALSE; - ResourceList->Count = 1; - ResourceList->List[0].InterfaceType = Internal; /* FIXME */ - ResourceList->List[0].BusNumber = 0; /* We're the only ACPI bus device in the system */ - ResourceList->List[0].PartialResourceList.Version = 1; - ResourceList->List[0].PartialResourceList.Revision = 1; - ResourceList->List[0].PartialResourceList.Count = NumberOfResources; - ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors; - - *RequirementsListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); - RequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)ExAllocatePool(PagedPool, *RequirementsListSize); - *pRequirementsList = RequirementsList; - if (!RequirementsList) - { - ExFreePool(ResourceList); - return FALSE; - } - RequirementsList->ListSize = *RequirementsListSize; - RequirementsList->InterfaceType = ResourceList->List[0].InterfaceType; - RequirementsList->BusNumber = ResourceList->List[0].BusNumber; - RequirementsList->SlotNumber = 0; /* Not used by WDM drivers */ - RequirementsList->AlternativeLists = 1; - RequirementsList->List[0].Version = 1; - RequirementsList->List[0].Revision = 1; - RequirementsList->List[0].Count = NumberOfResources; - RequirementDescriptor = RequirementsList->List[0].Descriptors; - - /* Fill resources list structure */ - Done = FALSE; - resource = resources; - while (!Done) - { - switch (resource->id) - { - case irq: - { - IRQ_RESOURCE *irq_data = (IRQ_RESOURCE*) &resource->data; - for (i = 0; i < irq_data->number_of_interrupts; i++) - { - ResourceDescriptor->Type = CmResourceTypeInterrupt; - - ResourceDescriptor->ShareDisposition = - (irq_data->shared_exclusive == SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); - ResourceDescriptor->Flags = - (irq_data->edge_level == LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); - ResourceDescriptor->u.Interrupt.Level = irq_data->interrupts[i]; - ResourceDescriptor->u.Interrupt.Vector = 0; - ResourceDescriptor->u.Interrupt.Affinity = (KAFFINITY)(-1); - - RequirementDescriptor->Option = 0; /* Required */ - RequirementDescriptor->Type = ResourceDescriptor->Type; - RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; - RequirementDescriptor->Flags = ResourceDescriptor->Flags; - RequirementDescriptor->u.Interrupt.MinimumVector = RequirementDescriptor->u.Interrupt.MaximumVector - = irq_data->interrupts[i]; - - ResourceDescriptor++; - RequirementDescriptor++; - } - break; - } - case dma: - { - DMA_RESOURCE *dma_data = (DMA_RESOURCE*) &resource->data; - for (i = 0; i < dma_data->number_of_channels; i++) - { - ResourceDescriptor->Type = CmResourceTypeDma; - ResourceDescriptor->Flags = 0; - switch (dma_data->type) - { - case TYPE_A: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_A; break; - case TYPE_B: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_B; break; - case TYPE_F: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_F; break; - } - if (dma_data->bus_master == BUS_MASTER) - ResourceDescriptor->Flags |= CM_RESOURCE_DMA_BUS_MASTER; - switch (dma_data->transfer) - { - case TRANSFER_8: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8; break; - case TRANSFER_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_16; break; - case TRANSFER_8_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break; - } - ResourceDescriptor->u.Dma.Channel = dma_data->channels[i]; - - RequirementDescriptor->Option = 0; /* Required */ - RequirementDescriptor->Type = ResourceDescriptor->Type; - RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; - RequirementDescriptor->Flags = ResourceDescriptor->Flags; - RequirementDescriptor->u.Dma.MinimumChannel = RequirementDescriptor->u.Dma.MaximumChannel - = ResourceDescriptor->u.Dma.Channel; - - ResourceDescriptor++; - RequirementDescriptor++; - } - break; - } - case io: - { - IO_RESOURCE *io_data = (IO_RESOURCE*) &resource->data; - ResourceDescriptor->Type = CmResourceTypePort; - ResourceDescriptor->ShareDisposition = CmResourceShareDriverExclusive; - ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO; - if (io_data->io_decode == DECODE_16) - ResourceDescriptor->Flags |= CM_RESOURCE_PORT_16_BIT_DECODE; - else - ResourceDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE; - ResourceDescriptor->u.Port.Start.u.HighPart = 0; - ResourceDescriptor->u.Port.Start.u.LowPart = io_data->min_base_address; - ResourceDescriptor->u.Port.Length = io_data->range_length; - - RequirementDescriptor->Option = 0; /* Required */ - RequirementDescriptor->Type = ResourceDescriptor->Type; - RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; - RequirementDescriptor->Flags = ResourceDescriptor->Flags; - RequirementDescriptor->u.Port.Length = ResourceDescriptor->u.Port.Length; - RequirementDescriptor->u.Port.Alignment = 1; /* Start address is specified, so it doesn't matter */ - RequirementDescriptor->u.Port.MinimumAddress = RequirementDescriptor->u.Port.MaximumAddress - = ResourceDescriptor->u.Port.Start; - - ResourceDescriptor++; - RequirementDescriptor++; - break; - } - case end_tag: - { - Done = TRUE; - break; - } - default: - { - break; - } - } - resource = NEXT_RESOURCE(resource); - } - - acpi_rs_dump_resource_list(resource); - return TRUE; -} - - -static BOOLEAN -AcpiCheckIfIsSerialDebugPort( - IN PACPI_DEVICE Device) -{ - ACPI_STATUS AcpiStatus; - BM_NODE *Node; - ACPI_BUFFER Buffer; - BOOLEAN Done; - RESOURCE* resource; - - AcpiStatus = bm_get_node(Device->BmHandle, 0, &Node); - if (!ACPI_SUCCESS(AcpiStatus)) - return FALSE; - - /* Get current resources */ - Buffer.length = 0; - AcpiStatus = acpi_get_current_resources(Node->device.acpi_handle, &Buffer); - if ((AcpiStatus & ACPI_OK) == 0) - return FALSE; - if (Buffer.length == 0) - return FALSE; - - Buffer.pointer = ExAllocatePool(PagedPool, Buffer.length); - if (!Buffer.pointer) - return FALSE; - AcpiStatus = acpi_get_current_resources(Node->device.acpi_handle, &Buffer); - if (!ACPI_SUCCESS(AcpiStatus)) - { - ExFreePool(Buffer.pointer); - return FALSE; - } - - /* Loop through the list of resources to see if the - * device is using the serial port address - */ - Done = FALSE; - resource = (RESOURCE*)Buffer.pointer; - while (!Done) - { - switch (resource->id) - { - case io: - { - IO_RESOURCE *io_data = (IO_RESOURCE*) &resource->data; - if (KdComPortInUse == (PUCHAR)io_data->min_base_address) - { - ExFreePool(Buffer.pointer); - return TRUE; - } - break; - } - case end_tag: - { - Done = TRUE; - break; - } - default: - { - break; - } - } - resource = (RESOURCE *) ((NATIVE_UINT) resource + (NATIVE_UINT) resource->length); - } - - ExFreePool(Buffer.pointer); - return FALSE; -} - -static NTSTATUS -FdoQueryBusRelations( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - PPDO_DEVICE_EXTENSION PdoDeviceExtension; - PFDO_DEVICE_EXTENSION DeviceExtension; - PDEVICE_RELATIONS Relations; - PLIST_ENTRY CurrentEntry; - ACPI_STATUS AcpiStatus; - PACPI_DEVICE Device; - NTSTATUS Status = STATUS_SUCCESS; - BM_NODE *Node; - ULONG Size; - ULONG i; - - DPRINT("Called\n"); - - DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - Size = sizeof(DEVICE_RELATIONS) + sizeof(Relations->Objects) * - (DeviceExtension->DeviceListCount - 1); - Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size); - if (!Relations) - return STATUS_INSUFFICIENT_RESOURCES; - - Relations->Count = DeviceExtension->DeviceListCount; - - i = 0; - CurrentEntry = DeviceExtension->DeviceListHead.Flink; - while (CurrentEntry != &DeviceExtension->DeviceListHead) - { - ACPI_BUFFER Buffer; - Device = CONTAINING_RECORD(CurrentEntry, ACPI_DEVICE, DeviceListEntry); - - if (AcpiCheckIfIsSerialDebugPort(Device)) - { - /* Skip this device */ - DPRINT("Found debug serial port ; skipping it\n"); - Relations->Count--; - CurrentEntry = CurrentEntry->Flink; - continue; - } - - /* FIXME: For ACPI namespace devices on the motherboard create filter DOs - and attach them just above the ACPI bus device object (PDO) */ - - /* FIXME: For other devices in ACPI namespace, but not on motherboard, - create PDOs */ - - if (!Device->Pdo) - { - /* Create a physical device object for the - device as it does not already have one */ - Status = IoCreateDevice(DeviceObject->DriverObject, - sizeof(PDO_DEVICE_EXTENSION), - NULL, - FILE_DEVICE_CONTROLLER, - FILE_AUTOGENERATED_DEVICE_NAME, - FALSE, - &Device->Pdo); - if (!NT_SUCCESS(Status)) - { - DPRINT("IoCreateDevice() failed with status 0x%X\n", Status); - /* FIXME: Cleanup all new PDOs created in this call */ - ExFreePool(Relations); - return Status; - } - - PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Device->Pdo->DeviceExtension; - - RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION)); - - Device->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE; - - Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING; - - //Device->Pdo->Flags |= DO_POWER_PAGABLE; - - PdoDeviceExtension->Common.DeviceObject = Device->Pdo; - - PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0; - -// PdoDeviceExtension->Common.Ldo = IoAttachDeviceToDeviceStack(DeviceObject, -// Device->Pdo); - - RtlInitUnicodeString(&PdoDeviceExtension->DeviceID, NULL); - RtlInitUnicodeString(&PdoDeviceExtension->InstanceID, NULL); - RtlInitUnicodeString(&PdoDeviceExtension->HardwareIDs, NULL); - - AcpiStatus = bm_get_node(Device->BmHandle, 0, &Node); - if (ACPI_SUCCESS(AcpiStatus)) - { - /* Get current resources */ - Buffer.length = 0; - Status = acpi_get_current_resources(Node->device.acpi_handle, &Buffer); - if ((Status & ACPI_OK) == 0) - { - ASSERT(FALSE); - } - if (Buffer.length > 0) - { - Buffer.pointer = ExAllocatePool(PagedPool, Buffer.length); - if (!Buffer.pointer) - { - ASSERT(FALSE); - } - Status = acpi_get_current_resources(Node->device.acpi_handle, &Buffer); - if (ACPI_FAILURE(Status)) - { - ASSERT(FALSE); - } - if (!AcpiCreateResourceList(&PdoDeviceExtension->ResourceList, - &PdoDeviceExtension->ResourceListSize, - &PdoDeviceExtension->ResourceRequirementsList, - &PdoDeviceExtension->ResourceRequirementsListSize, - (RESOURCE*)Buffer.pointer)) - { - ASSERT(FALSE); - } - ExFreePool(Buffer.pointer); - } - - /* Add Device ID string */ - if (!AcpiCreateDeviceIDString(&PdoDeviceExtension->DeviceID, - Node)) - { - ASSERT(FALSE); -// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES; -// ErrorOccurred = TRUE; -// break; - } - - if (!AcpiCreateInstanceIDString(&PdoDeviceExtension->InstanceID, - Node)) - { - ASSERT(FALSE); -// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES; -// ErrorOccurred = TRUE; -// break; - } - - if (!AcpiCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs, - Node)) - { - ASSERT(FALSE); -// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES; -// ErrorOccurred = TRUE; -// break; - } - - if (!AcpiCreateDeviceDescriptionString(&PdoDeviceExtension->DeviceDescription, - Node)) - { - ASSERT(FALSE); -// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES; -// ErrorOccurred = TRUE; -// break; - } - } - } - - /* Reference the physical device object. The PnP manager - will dereference it again when it is no longer needed */ - ObReferenceObject(Device->Pdo); - - Relations->Objects[i] = Device->Pdo; - - i++; - - CurrentEntry = CurrentEntry->Flink; - } - - Irp->IoStatus.Information = (ULONG)Relations; - - return Status; -} - -#ifndef NDEBUG -static VOID -ACPIPrintInfo( - PFDO_DEVICE_EXTENSION DeviceExtension) -{ - DbgPrint("ACPI: System firmware supports:\n"); - - /* - * Print out basic system information - */ - DbgPrint("+------------------------------------------------------------\n"); - DbgPrint("| Sx states: %cS0 %cS1 %cS2 %cS3 %cS4 %cS5\n", - (DeviceExtension->SystemStates[0]?'+':'-'), - (DeviceExtension->SystemStates[1]?'+':'-'), - (DeviceExtension->SystemStates[2]?'+':'-'), - (DeviceExtension->SystemStates[3]?'+':'-'), - (DeviceExtension->SystemStates[4]?'+':'-'), - (DeviceExtension->SystemStates[5]?'+':'-')); - DbgPrint("+------------------------------------------------------------\n"); -} -#endif - -static NTSTATUS -ACPIInitializeInternalDriver( - PFDO_DEVICE_EXTENSION DeviceExtension, - ACPI_DRIVER_FUNCTION Initialize, - ACPI_DRIVER_FUNCTION Terminate) -{ - ACPI_STATUS AcpiStatus; - - AcpiStatus = Initialize(); - if (!ACPI_SUCCESS(AcpiStatus)) { - DPRINT("BN init status 0x%X\n", AcpiStatus); - return STATUS_UNSUCCESSFUL; - } -#if 0 - AcpiDevice = (PACPI_DEVICE)ExAllocatePool( - NonPagedPool, sizeof(ACPI_DEVICE)); - if (!AcpiDevice) { - return STATUS_INSUFFICIENT_RESOURCES; - } - - AcpiDevice->Initialize = Initialize; - AcpiDevice->Terminate = Terminate; - - /* FIXME: Create PDO */ - - AcpiDevice->Pdo = NULL; - //AcpiDevice->BmHandle = HandleList.handles[i]; - - ExInterlockedInsertHeadList(&DeviceExtension->DeviceListHead, - &AcpiDevice->ListEntry, &DeviceExtension->DeviceListLock); -#endif - return STATUS_SUCCESS; -} - - -static NTSTATUS -ACPIInitializeInternalDrivers( - PFDO_DEVICE_EXTENSION DeviceExtension) -{ - NTSTATUS Status; - - Status = ACPIInitializeInternalDriver(DeviceExtension, - bn_initialize, bn_terminate); - - return STATUS_SUCCESS; -} - - -static NTSTATUS -FdoStartDevice( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) -{ - PFDO_DEVICE_EXTENSION DeviceExtension; - ACPI_PHYSICAL_ADDRESS rsdp; - ACPI_SYSTEM_INFO SysInfo; - ACPI_STATUS AcpiStatus; - ACPI_BUFFER Buffer; - UCHAR TypeA, TypeB; - ULONG i; - - DPRINT("Called\n"); - - DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - ASSERT(DeviceExtension->State == dsStopped); - - AcpiStatus = acpi_initialize_subsystem(); - if (!ACPI_SUCCESS(AcpiStatus)) { - DPRINT("acpi_initialize_subsystem() failed with status 0x%X\n", AcpiStatus); - return STATUS_UNSUCCESSFUL; - } - - AcpiStatus = acpi_find_root_pointer(&rsdp); - if (!ACPI_SUCCESS(AcpiStatus)) { - DPRINT("acpi_find_root_pointer() failed with status 0x%X\n", AcpiStatus); - return STATUS_UNSUCCESSFUL; - } - - /* From this point on, on error we must call acpi_terminate() */ - - AcpiStatus = acpi_load_tables(rsdp); - if (!ACPI_SUCCESS(AcpiStatus)) { - DPRINT("acpi_load_tables() failed with status 0x%X\n", AcpiStatus); - acpi_terminate(); - return STATUS_UNSUCCESSFUL; - } - - Buffer.length = sizeof(SysInfo); - Buffer.pointer = &SysInfo; - - AcpiStatus = acpi_get_system_info(&Buffer); - if (!ACPI_SUCCESS(AcpiStatus)) { - DPRINT("acpi_get_system_info() failed with status 0x%X\n", AcpiStatus); - acpi_terminate(); - return STATUS_UNSUCCESSFUL; - } - - DPRINT("ACPI CA Core Subsystem version 0x%X\n", SysInfo.acpi_ca_version); - - ASSERT(SysInfo.num_table_types > ACPI_TABLE_FADT); - - RtlMoveMemory(&acpi_fadt, - &SysInfo.table_info[ACPI_TABLE_FADT], - sizeof(FADT_DESCRIPTOR_REV2)); - - AcpiStatus = acpi_enable_subsystem(ACPI_FULL_INITIALIZATION); - if (!ACPI_SUCCESS(AcpiStatus)) { - DPRINT("acpi_enable_subsystem() failed with status 0x%X\n", AcpiStatus); - acpi_terminate(); - return STATUS_UNSUCCESSFUL; - } - - DPRINT("ACPI CA Core Subsystem enabled\n"); - - /* - * Sx States: - * ---------- - * Figure out which Sx states are supported - */ - for (i=0; i<=ACPI_S_STATES_MAX; i++) { - AcpiStatus = acpi_hw_obtain_sleep_type_register_data( - i, - &TypeA, - &TypeB); - DPRINT("acpi_hw_obtain_sleep_type_register_data (%d) status 0x%X\n", - i, AcpiStatus); - if (ACPI_SUCCESS(AcpiStatus)) { - DeviceExtension->SystemStates[i] = TRUE; - } - } - -#ifndef NDEBUG - ACPIPrintInfo(DeviceExtension); -#endif - - /* Initialize ACPI bus manager */ - AcpiStatus = bm_initialize(); - if (!ACPI_SUCCESS(AcpiStatus)) { - DPRINT("bm_initialize() failed with status 0x%X\n", AcpiStatus); - acpi_terminate(); - return STATUS_UNSUCCESSFUL; - } - - InitializeListHead(&DeviceExtension->DeviceListHead); - KeInitializeSpinLock(&DeviceExtension->DeviceListLock); - DeviceExtension->DeviceListCount = 0; - -#if 0 - ACPIEnumerateDevices(DeviceExtension); -#endif - - ACPIInitializeInternalDrivers(DeviceExtension); - - DeviceExtension->State = dsStarted; - - return STATUS_SUCCESS; -} - - -static NTSTATUS -FdoSetPower( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - PFDO_DEVICE_EXTENSION DeviceExtension; - ACPI_STATUS AcpiStatus; - NTSTATUS Status; - ULONG AcpiState; - - DPRINT("Called\n"); - - DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - if (IrpSp->Parameters.Power.Type == SystemPowerState) { - Status = STATUS_SUCCESS; - switch (IrpSp->Parameters.Power.State.SystemState) { - case PowerSystemSleeping1: - AcpiState = ACPI_STATE_S1; - break; - case PowerSystemSleeping2: - AcpiState = ACPI_STATE_S2; - break; - case PowerSystemSleeping3: - AcpiState = ACPI_STATE_S3; - break; - case PowerSystemHibernate: - AcpiState = ACPI_STATE_S4; - break; - case PowerSystemShutdown: - AcpiState = ACPI_STATE_S5; - break; - default: - Status = STATUS_UNSUCCESSFUL; - return Status; - } - if (!DeviceExtension->SystemStates[AcpiState]) { - DPRINT("System sleep state S%d is not supported by hardware\n", AcpiState); - Status = STATUS_UNSUCCESSFUL; - } - - if (NT_SUCCESS(Status)) { - DPRINT("Trying to enter sleep state %d\n", AcpiState); - - AcpiStatus = acpi_enter_sleep_state(AcpiState); - if (!ACPI_SUCCESS(AcpiStatus)) { - DPRINT("Failed to enter sleep state %d (Status 0x%X)\n", - AcpiState, AcpiStatus); - Status = STATUS_UNSUCCESSFUL; - } - } - } else { - Status = STATUS_UNSUCCESSFUL; - } - - return Status; -} - - -/*** PUBLIC ******************************************************************/ - -NTSTATUS -NTAPI -FdoPnpControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp) -/* - * FUNCTION: Handle Plug and Play IRPs for the ACPI device - * ARGUMENTS: - * DeviceObject = Pointer to functional device object of the ACPI driver - * Irp = Pointer to IRP that should be handled - * RETURNS: - * Status - */ -{ - PIO_STACK_LOCATION IrpSp; - NTSTATUS Status; - - DPRINT("Called\n"); - - IrpSp = IoGetCurrentIrpStackLocation(Irp); - switch (IrpSp->MinorFunction) { - //case IRP_MN_CANCEL_REMOVE_DEVICE: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - //case IRP_MN_CANCEL_STOP_DEVICE: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - //case IRP_MN_DEVICE_USAGE_NOTIFICATION: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - //case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - case IRP_MN_QUERY_DEVICE_RELATIONS: - Status = FdoQueryBusRelations(DeviceObject, Irp, IrpSp); - break; - - //case IRP_MN_QUERY_PNP_DEVICE_STATE: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - //case IRP_MN_QUERY_REMOVE_DEVICE: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - //case IRP_MN_QUERY_STOP_DEVICE: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - //case IRP_MN_REMOVE_DEVICE: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - case IRP_MN_START_DEVICE: - DPRINT("IRP_MN_START_DEVICE received\n"); - Status = FdoStartDevice(DeviceObject, Irp); - break; - - case IRP_MN_STOP_DEVICE: - /* Currently not supported */ - //bm_terminate(); - Status = STATUS_UNSUCCESSFUL; - break; - - //case IRP_MN_SURPRISE_REMOVAL: - // Status = STATUS_NOT_IMPLEMENTED; - // break; - - default: - DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction); - Status = Irp->IoStatus.Status; - break; - } - - if (Status != STATUS_PENDING) { - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } - - DPRINT("Leaving. Status 0x%X\n", Status); - - return Status; -} - - -NTSTATUS -NTAPI -FdoPowerControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp) -/* - * FUNCTION: Handle power management IRPs for the ACPI device - * ARGUMENTS: - * DeviceObject = Pointer to functional device object of the ACPI driver - * Irp = Pointer to IRP that should be handled - * RETURNS: - * Status - */ -{ - PIO_STACK_LOCATION IrpSp; - NTSTATUS Status; - - DPRINT("Called\n"); - - IrpSp = IoGetCurrentIrpStackLocation(Irp); - - switch (IrpSp->MinorFunction) { - case IRP_MN_SET_POWER: - Status = FdoSetPower(DeviceObject, Irp, IrpSp); - break; - - default: - DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction); - Status = STATUS_NOT_IMPLEMENTED; - break; - } - - if (Status != STATUS_PENDING) { - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } - - DPRINT("Leaving. Status 0x%X\n", Status); - - return Status; -} - -/* EOF */ diff --git a/reactos/drivers/bus/acpi/ospm/include/acpisys.h b/reactos/drivers/bus/acpi/ospm/include/acpisys.h deleted file mode 100644 index 5e21d6ae1b9..00000000000 --- a/reactos/drivers/bus/acpi/ospm/include/acpisys.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * PROJECT: ReactOS ACPI bus driver - * FILE: acpi/ospm/include/acpisys.h - * PURPOSE: ACPI bus driver definitions - */ -#define ACPI_DEBUG - -typedef ACPI_STATUS (*ACPI_DRIVER_FUNCTION)(VOID); - - -typedef enum -{ - dsStopped, - dsStarted, - dsPaused, - dsRemoved, - dsSurpriseRemoved -} ACPI_DEVICE_STATE; - - -typedef struct _COMMON_DEVICE_EXTENSION -{ - // Pointer to device object, this device extension is associated with - PDEVICE_OBJECT DeviceObject; - // Wether this device extension is for an FDO or PDO - BOOLEAN IsFDO; - // Wether the device is removed - BOOLEAN Removed; - // Current device power state for the device - DEVICE_POWER_STATE DevicePowerState; - // Lower device object - PDEVICE_OBJECT Ldo; -} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION; - - -/* Physical Device Object device extension for a child device */ -typedef struct _PDO_DEVICE_EXTENSION -{ - // Common device data - COMMON_DEVICE_EXTENSION Common; - // Device ID - UNICODE_STRING DeviceID; - // Instance ID - UNICODE_STRING InstanceID; - // Hardware IDs - UNICODE_STRING HardwareIDs; - // Textual description of device - UNICODE_STRING DeviceDescription; - // Resource list - PCM_RESOURCE_LIST ResourceList; - ULONG ResourceListSize; - // Requirement list - PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList; - ULONG ResourceRequirementsListSize; -} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION; - - -typedef struct _FDO_DEVICE_EXTENSION -{ - // Common device data - COMMON_DEVICE_EXTENSION Common; - // Physical Device Object - PDEVICE_OBJECT Pdo; - // Current state of the driver - ACPI_DEVICE_STATE State; - // Supported system states - BOOLEAN SystemStates[ACPI_S_STATE_COUNT]; - // Namespace device list - LIST_ENTRY DeviceListHead; - // Number of devices in device list - ULONG DeviceListCount; - // Lock for namespace device list - KSPIN_LOCK DeviceListLock; -} FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION; - - -typedef struct _ACPI_DEVICE -{ - // Entry on device list - LIST_ENTRY DeviceListEntry; - // Bus manager handle - BM_HANDLE BmHandle; - // Physical Device Object - PDEVICE_OBJECT Pdo; - // Initialization function - ACPI_DRIVER_FUNCTION Initialize; - // Cleanup function - ACPI_DRIVER_FUNCTION Terminate; -} ACPI_DEVICE, *PACPI_DEVICE; - - -/* acpienum.c */ - -NTSTATUS -ACPIEnumerateDevices( - PFDO_DEVICE_EXTENSION DeviceExtension); - - -/* fdo.c */ - -NTSTATUS -NTAPI -FdoPnpControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp); - -NTSTATUS -NTAPI -FdoPowerControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp); - -/* pdo.c */ - -NTSTATUS -NTAPI -PdoPnpControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp); - -NTSTATUS -NTAPI -PdoPowerControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp); - -/* EOF */ diff --git a/reactos/drivers/bus/acpi/ospm/include/bm.h b/reactos/drivers/bus/acpi/ospm/include/bm.h deleted file mode 100644 index 342e6288f62..00000000000 --- a/reactos/drivers/bus/acpi/ospm/include/bm.h +++ /dev/null @@ -1,624 +0,0 @@ -/***************************************************************************** - * - * Module name: bm.h - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __BM_H__ -#define __BM_H__ - -#include -#include - - -/***************************************************************************** - * Types & Defines - *****************************************************************************/ - -/* - * Output Flags (Debug): - * --------------------- - */ -#define BM_PRINT_ALL (0x00000000) -#define BM_PRINT_GROUP (0x00000001) -#define BM_PRINT_LINKAGE (0x00000002) -#define BM_PRINT_IDENTIFICATION (0x00000004) -#define BM_PRINT_POWER (0x00000008) -#define BM_PRINT_PRESENT (0x00000010) - - -/* - * /proc Interface: - * ---------------- - */ -#define BM_PROC_ROOT "acpi" -#define BM_PROC_EVENT "event" - -extern struct proc_dir_entry *bm_proc_root; - - -/* - * BM_COMMAND: - * ----------- - */ -typedef u32 BM_COMMAND; - -#define BM_COMMAND_UNKNOWN ((BM_COMMAND) 0x00) - -#define BM_COMMAND_GET_POWER_STATE ((BM_COMMAND) 0x01) -#define BM_COMMAND_SET_POWER_STATE ((BM_COMMAND) 0x02) - -#define BM_COMMAND_DEVICE_SPECIFIC ((BM_COMMAND) 0x80) - -/* - * BM_NOTIFY: - * ---------- - * Standard ACPI notification values, from section 5.6.3 of the ACPI 2.0 - * specification. Note that the Bus Manager internally handles all - * standard ACPI notifications -- driver modules are never sent these - * values (see "Bus Manager Notifications", below). - */ -typedef u32 BM_NOTIFY; - -#define BM_NOTIFY_BUS_CHECK ((BM_NOTIFY) 0x00) -#define BM_NOTIFY_DEVICE_CHECK ((BM_NOTIFY) 0x01) -#define BM_NOTIFY_DEVICE_WAKE ((BM_NOTIFY) 0x02) -#define BM_NOTIFY_EJECT_REQUEST ((BM_NOTIFY) 0x03) -#define BM_NOTIFY_DEVICE_CHECK_LIGHT ((BM_NOTIFY) 0x04) -#define BM_NOTIFY_FREQUENCY_MISMATCH ((BM_NOTIFY) 0x05) -#define BM_NOTIFY_BUS_MODE_MISMATCH ((BM_NOTIFY) 0x06) -#define BM_NOTIFY_POWER_FAULT ((BM_NOTIFY) 0x07) - -/* - * These are a higher-level abstraction of ACPI notifications, intended - * for consumption by driver modules to facilitate PnP. - */ -#define BM_NOTIFY_UNKNOWN ((BM_NOTIFY) 0x00) -#define BM_NOTIFY_DEVICE_ADDED ((BM_NOTIFY) 0x01) -#define BM_NOTIFY_DEVICE_REMOVED ((BM_NOTIFY) 0x02) - - -/* - * BM_HANDLE: - * ---------- - */ -typedef u32 BM_HANDLE; - -#define BM_HANDLE_UNKNOWN ((BM_HANDLE) 0x00) -#define BM_HANDLE_ROOT ((BM_HANDLE) 0x00) -#define BM_HANDLES_MAX 256 - - - -/* - * BM_HANDLE_LIST: - * --------------- - */ -typedef struct -{ - u32 count; - BM_HANDLE handles[BM_HANDLES_MAX]; -} BM_HANDLE_LIST; - - -/* - * BM_DEVICE_TYPE: - * --------------- - */ -typedef u32 BM_DEVICE_TYPE; - -#define BM_TYPE_UNKNOWN ((BM_DEVICE_TYPE) 0x00000000) - -#define BM_TYPE_SCOPE ((BM_DEVICE_TYPE) 0x00000001) -#define BM_TYPE_PROCESSOR ((BM_DEVICE_TYPE) 0x00000002) -#define BM_TYPE_THERMAL_ZONE ((BM_DEVICE_TYPE) 0x00000004) -#define BM_TYPE_POWER_RESOURCE ((BM_DEVICE_TYPE) 0x00000008) -#define BM_TYPE_DEVICE ((BM_DEVICE_TYPE) 0x00000010) -#define BM_TYPE_FIXED_BUTTON ((BM_DEVICE_TYPE) 0x00000020) -#define BM_TYPE_SYSTEM ((BM_DEVICE_TYPE) 0x80000000) -#define BM_TYPE_ALL ((BM_DEVICE_TYPE) 0xFFFFFFFF) - - -/* - * BM_DEVICE_UID: - * -------------- - */ -typedef char BM_DEVICE_UID[9]; - -#define BM_UID_UNKNOWN '0' - - -/* - * BM_DEVICE_HID: - * -------------- - */ -typedef char BM_DEVICE_HID[9]; - -#define BM_HID_UNKNOWN '\0' -#define BM_HID_POWER_BUTTON "PNP0C0C" -#define BM_HID_SLEEP_BUTTON "PNP0C0E" - -/* - * BM_DEVICE_CID: - * The compatibility ID can be a string with 44 characters - * The extra pad is in case there is a change. It also - * provides 8 byte alignment for the BM_DEVICE_ID structure. - * ------------------------------------------------------------- - */ -typedef char BM_DEVICE_CID[46]; - - -/* - * BM_DEVICE_ADR: - * -------------- - */ -typedef u32 BM_DEVICE_ADR; - -#define BM_ADDRESS_UNKNOWN 0 - - -/* - * BM_DEVICE_FLAGS: - * ---------------- - * The encoding of BM_DEVICE_FLAGS is illustrated below. - * Note that a set bit (1) indicates the property is TRUE - * (e.g. if bit 0 is set then the device has dynamic status). - * +--+------------+-+-+-+-+-+-+-+ - * |31| Bits 31:11 |6|5|4|3|2|1|0| - * +--+------------+-+-+-+-+-+-+-+ - * | | | | | | | | | - * | | | | | | | | +- Dynamic status? - * | | | | | | | +--- Identifiable? - * | | | | | | +----- Configurable? - * | | | | | +------- Power Manageable? - * | | | | +--------- Ejectable? - * | | | +----------- Docking Station? - * | | +------------- Fixed-Feature? - * | +-------------------- - * +---------------------------- Driver Control? - * - * Dynamic status: Device has a _STA object. - * Identifiable: Device has a _HID and/or _ADR and possibly other - * identification objects defined. - * Configurable: Device has a _CRS and possibly other configuration - * objects defined. - * Power Control: Device has a _PR0 and/or _PS0 and possibly other - * power management objects defined. - * Ejectable: Device has an _EJD and/or _EJx and possibly other - * dynamic insertion/removal objects defined. - * Docking Station: Device has a _DCK object defined. - * Fixed-Feature: Device does not exist in the namespace; was - * enumerated as a fixed-feature (e.g. power button). - * Power Manageable:Can change device's power consumption behavior. - * Has a HID: In the BIOS ASL this device has a hardware ID as - * defined in section 6.1.4 of ACPI Spec 2.0 - * Has a CID: In the BIOS ASL this device has a compatible ID as - * defined in section 6.1.2 of ACPI Spec 2.0 - * Has a ADR: In the BIOS ASL this device has an address ID as - * defined in section 6.1.1 of ACPI Spec 2.0 - * Is a bridge: This device is recognized as a bridge to another bus. - * Is on PCI bus: This device is on a PCI bus or within PCI configuration - * address space. - * Is on USB bus: This device is on or within USB address space. - * Is on SCSI bus: This device is on or within SCSI address space. - * Driver Control: A driver has been installed for this device. - */ -typedef u32 BM_DEVICE_FLAGS; - -#define BM_FLAGS_UNKNOWN ((BM_DEVICE_FLAGS) 0x00000000) - -#define BM_FLAGS_DYNAMIC_STATUS ((BM_DEVICE_FLAGS) 0x00000001) -#define BM_FLAGS_IDENTIFIABLE ((BM_DEVICE_FLAGS) 0x00000002) -#define BM_FLAGS_CONFIGURABLE ((BM_DEVICE_FLAGS) 0x00000004) -#define BM_FLAGS_POWER_CONTROL ((BM_DEVICE_FLAGS) 0x00000008) -#define BM_FLAGS_EJECTABLE ((BM_DEVICE_FLAGS) 0x00000010) -#define BM_FLAGS_DOCKING_STATION ((BM_DEVICE_FLAGS) 0x00000020) -#define BM_FLAGS_FIXED_FEATURE ((BM_DEVICE_FLAGS) 0x00000040) -#define BM_FLAGS_IS_POWER_MANAGEABLE ((BM_DEVICE_FLAGS) 0x00000080) -#define BM_FLAGS_HAS_A_HID ((BM_DEVICE_FLAGS) 0x00000100) -#define BM_FLAGS_HAS_A_CID ((BM_DEVICE_FLAGS) 0x00000200) -#define BM_FLAGS_HAS_A_ADR ((BM_DEVICE_FLAGS) 0x00000400) -#define BM_FLAGS_IS_A_BRIDGE ((BM_DEVICE_FLAGS) 0x00000800) -#define BM_FLAGS_IS_ON_PCI_BUS ((BM_DEVICE_FLAGS) 0x00001000) -#define BM_FLAGS_IS_ON_USB_BUS ((BM_DEVICE_FLAGS) 0x00002000) -#define BM_FLAGS_IS_ON_SCSI_BUS ((BM_DEVICE_FLAGS) 0x00004000) -#define BM_FLAGS_DRIVER_CONTROL ((BM_DEVICE_FLAGS) 0x80000000) - -/* - * Device PM Flags: - * ---------------- - * +-----------+-+-+-+-+-+-+-+ - * | Bits 31:7 |6|5|4|3|2|1|0| - * +-----------+-+-+-+-+-+-+-+ - * | | | | | | | | - * | | | | | | | +- D0 Support? - * | | | | | | +--- D1 Support? - * | | | | | +----- D2 Support? - * | | | | +------- D3 Support? - * | | | +--------- Power State Queriable? - * | | +----------- Inrush Current? - * | +------------- Wake Capable? - * +-------------------- - * - * D0-D3 Support: Device supports corresponding Dx state. - * Power State: Device has a _PSC (current power state) object defined. - * Inrush Current: Device has an _IRC (inrush current) object defined. - * Wake Capable: Device has a _PRW (wake-capable) object defined. - */ -#define BM_FLAGS_D0_SUPPORT ((BM_DEVICE_FLAGS) 0x00000001) -#define BM_FLAGS_D1_SUPPORT ((BM_DEVICE_FLAGS) 0x00000002) -#define BM_FLAGS_D2_SUPPORT ((BM_DEVICE_FLAGS) 0x00000004) -#define BM_FLAGS_D3_SUPPORT ((BM_DEVICE_FLAGS) 0x00000008) -#define BM_FLAGS_POWER_STATE ((BM_DEVICE_FLAGS) 0x00000010) -#define BM_FLAGS_INRUSH_CURRENT ((BM_DEVICE_FLAGS) 0x00000020) -#define BM_FLAGS_WAKE_CAPABLE ((BM_DEVICE_FLAGS) 0x00000040) - - -/* - * BM_DEVICE_STATUS: - * ----------------- - * The encoding of BM_DEVICE_STATUS is illustrated below. - * Note that a set bit (1) indicates the property is TRUE - * (e.g. if bit 0 is set then the device is present). - * +-----------+-+-+-+-+-+ - * | Bits 31:4 |4|3|2|1|0| - * +-----------+-+-+-+-+-+ - * | | | | | | - * | | | | | +- Present? - * | | | | +--- Enabled? - * | | | +----- Show in UI? - * | | +------- Functioning? - * | +--------- Battery Present? - * +---------------- - */ -typedef u32 BM_DEVICE_STATUS; - -#define BM_STATUS_UNKNOWN ((BM_DEVICE_STATUS) 0x00000000) -#define BM_STATUS_PRESENT ((BM_DEVICE_STATUS) 0x00000001) -#define BM_STATUS_ENABLED ((BM_DEVICE_STATUS) 0x00000002) -#define BM_STATUS_SHOW_UI ((BM_DEVICE_STATUS) 0x00000004) -#define BM_STATUS_FUNCTIONING ((BM_DEVICE_STATUS) 0x00000008) -#define BM_STATUS_BATTERY_PRESENT ((BM_DEVICE_STATUS) 0x00000010) -#define BM_STATUS_DEFAULT ((BM_DEVICE_STATUS) 0x0000000F) - - -typedef u32 BM_POWER_STATE; - -typedef u8 BM_PCI_BUS_NUM; -typedef u8 BM_PCI_DEVICE_NUM; -typedef u8 BM_PCI_FUNCTION_NUM; -typedef u8 BM_U8_RESERVED; -typedef u8 BM_PCI_DEVICE_CLASS_ID; -typedef u8 BM_PCI_DEVICE_SUBCLASS_ID; -typedef u8 BM_PCI_DEVICE_PROG_IF; -typedef u8 BM_PCI_DEVICE_REVISION; -typedef u16 BM_PCI_VENDOR_ID; -typedef u16 BM_PCI_DEVICE_ID; -typedef u32 BM_U32_RESERVED; - - -/* - * BM_DEVICE_ID: - * This structure, when filled in for a device, provides - * an "association" between hardware space and ACPI. - * ----------------------------------------------------------- - */ -typedef struct -{ - BM_DEVICE_CID cid; - BM_DEVICE_HID hid; - BM_DEVICE_UID uid; - BM_DEVICE_TYPE type; - BM_DEVICE_ADR adr; - BM_PCI_BUS_NUM pci_bus_num; - BM_PCI_DEVICE_NUM pci_device_num; - BM_PCI_FUNCTION_NUM pci_func_num; - BM_U8_RESERVED u8_reserved; - BM_PCI_DEVICE_CLASS_ID pci_device_class_id; - BM_PCI_DEVICE_SUBCLASS_ID pci_device_subclass_id; - BM_PCI_DEVICE_PROG_IF pci_device_prog_if; - BM_PCI_DEVICE_REVISION pci_device_rev_num; - BM_PCI_VENDOR_ID pci_vendor_id; - BM_PCI_DEVICE_ID pci_device_id; - BM_U32_RESERVED u32_reserved; -} BM_DEVICE_ID; - - -/* - * BM_DEVICE_POWER: - * ---------------- - * Structure containing basic device power management information. - */ -typedef struct -{ - BM_DEVICE_FLAGS flags; - BM_POWER_STATE state; - BM_DEVICE_FLAGS dx_supported[ACPI_S_STATE_COUNT]; -} BM_DEVICE_POWER; - - -/* - * BM_DEVICE: - * ---------- - */ -typedef struct -{ - BM_HANDLE handle; - ACPI_HANDLE acpi_handle; - BM_DEVICE_FLAGS flags; - BM_DEVICE_STATUS status; - BM_DEVICE_ID id; - BM_DEVICE_POWER power; -} BM_DEVICE; - - -/* - * BM_SEARCH: - * ---------- - * Structure used for searching the ACPI Bus Manager's device hierarchy. - */ -typedef struct -{ - BM_DEVICE_ID criteria; - BM_HANDLE_LIST results; -} BM_SEARCH; - - -/* - * BM_REQUEST: - * ----------- - * Structure used for sending requests to/through the ACPI Bus Manager. - */ -typedef struct -{ - ACPI_STATUS status; - BM_COMMAND command; - BM_HANDLE handle; - ACPI_BUFFER buffer; -} BM_REQUEST; - - -/* - * Driver Registration: - * -------------------- - */ - -/* Driver Context */ -typedef void * BM_DRIVER_CONTEXT; - -/* Notification Callback Function */ -typedef -ACPI_STATUS (*BM_DRIVER_NOTIFY) ( - BM_NOTIFY notify_type, - BM_HANDLE device_handle, - BM_DRIVER_CONTEXT *context); - -/* Request Callback Function */ -typedef -ACPI_STATUS (*BM_DRIVER_REQUEST) ( - BM_REQUEST *request, - BM_DRIVER_CONTEXT context); - -/* Driver Registration */ -typedef struct -{ - BM_DRIVER_NOTIFY notify; - BM_DRIVER_REQUEST request; - BM_DRIVER_CONTEXT context; -} BM_DRIVER; - - -/* - * BM_NODE: - * -------- - * Structure used to maintain the device hierarchy. - */ -typedef struct _BM_NODE -{ - BM_DEVICE device; - BM_DRIVER driver; - struct _BM_NODE *parent; - struct _BM_NODE *next; - struct - { - struct _BM_NODE *head; - struct _BM_NODE *tail; - } scope; -} BM_NODE; - - -/* - * BM_NODE_LIST: - * ------------- - * Structure used to maintain an array of node pointers. - */ -typedef struct -{ - u32 count; - BM_NODE *nodes[BM_HANDLES_MAX]; -} BM_NODE_LIST; - - -/***************************************************************************** - * Macros - *****************************************************************************/ - -#define BM_DEVICE_PRESENT(d) (d->status & BM_STATUS_PRESENT) -#define BM_NODE_PRESENT(n) (n->device.status & BM_STATUS_PRESENT) - - -/***************************************************************************** - * Function Prototypes - *****************************************************************************/ - -/* bm.c */ - -ACPI_STATUS -bm_initialize (void); - -ACPI_STATUS -bm_terminate (void); - -ACPI_STATUS -bm_get_status ( - BM_DEVICE *device); - -ACPI_STATUS -bm_get_handle ( - ACPI_HANDLE acpi_handle, - BM_HANDLE *device_handle); - -ACPI_STATUS -bm_get_node ( - BM_HANDLE device_handle, - ACPI_HANDLE acpi_handle, - BM_NODE **node); - -/* bmsearch.c */ - -ACPI_STATUS -bm_search( - BM_HANDLE device_handle, - BM_DEVICE_ID *criteria, - BM_HANDLE_LIST *results); - -/* bmnotify.c */ - -void -bm_notify ( - ACPI_HANDLE acpi_handle, - u32 notify_value, - void *context); - -/* bm_request.c */ - -ACPI_STATUS -bm_request ( - BM_REQUEST *request_info); - -/* bmxface.c */ - -ACPI_STATUS -bm_get_device_status ( - BM_HANDLE device_handle, - BM_DEVICE_STATUS *device_status); - -ACPI_STATUS -bm_get_device_info ( - BM_HANDLE device_handle, - BM_DEVICE **device_info); - -ACPI_STATUS -bm_get_device_context ( - BM_HANDLE device_handle, - BM_DRIVER_CONTEXT *context); - -ACPI_STATUS -bm_register_driver ( - BM_DEVICE_ID *criteria, - BM_DRIVER *driver); - -ACPI_STATUS -bm_unregister_driver ( - BM_DEVICE_ID *criteria, - BM_DRIVER *driver); - -/* bmpm.c */ - -ACPI_STATUS -bm_get_pm_capabilities ( - BM_NODE *node); - -ACPI_STATUS -bm_get_power_state ( - BM_NODE *node); - -ACPI_STATUS -bm_set_power_state ( - BM_NODE *node, - BM_POWER_STATE target_state); - -/* bmpower.c */ - -ACPI_STATUS -bm_pr_initialize (void); - -ACPI_STATUS -bm_pr_terminate (void); - -/* bmutils.c */ - -ACPI_STATUS -bm_cast_buffer ( - ACPI_BUFFER *buffer, - void **pointer, - u32 length); - -ACPI_STATUS -bm_copy_to_buffer ( - ACPI_BUFFER *buffer, - void *data, - u32 length); - -ACPI_STATUS -bm_extract_package_data ( - ACPI_OBJECT *package, - ACPI_BUFFER *format, - ACPI_BUFFER *buffer); - -ACPI_STATUS -bm_evaluate_object ( - ACPI_HANDLE acpi_handle, - ACPI_STRING pathname, - ACPI_OBJECT_LIST *arguments, - ACPI_BUFFER *buffer); - -ACPI_STATUS -bm_evaluate_simple_integer ( - ACPI_HANDLE acpi_handle, - ACPI_STRING pathname, - u32 *data); - -ACPI_STATUS -bm_evaluate_reference_list ( - ACPI_HANDLE acpi_handle, - ACPI_STRING pathname, - BM_HANDLE_LIST *reference_list); - -/* bm_proc.c */ - -ACPI_STATUS -bm_proc_initialize (void); - -ACPI_STATUS -bm_proc_terminate (void); - -ACPI_STATUS -bm_generate_event ( - BM_HANDLE device_handle, - char *device_type, - char *device_instance, - u32 event_type, - u32 event_data); - - -#endif /* __BM_H__ */ diff --git a/reactos/drivers/bus/acpi/ospm/include/bmpower.h b/reactos/drivers/bus/acpi/ospm/include/bmpower.h deleted file mode 100644 index 2fcbedfa217..00000000000 --- a/reactos/drivers/bus/acpi/ospm/include/bmpower.h +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * - * Module name: bmpower.h - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __BMPOWER_H__ -#define __BMPOWER_H__ - -#include "bm.h" - - -/***************************************************************************** - * Types & Defines - *****************************************************************************/ - - -/* - * BM_POWER_RESOURCE: - * ------------------ - */ -typedef struct -{ - BM_HANDLE device_handle; - ACPI_HANDLE acpi_handle; - BM_POWER_STATE system_level; - u32 resource_order; - BM_POWER_STATE state; - u32 reference_count; -} BM_POWER_RESOURCE; - - -/***************************************************************************** - * Function Prototypes - *****************************************************************************/ - -/* bmpower.c */ - -ACPI_STATUS -bm_pr_initialize (void); - -ACPI_STATUS -bm_pr_terminate (void); - -ACPI_STATUS -bm_pr_list_get_state ( - BM_HANDLE_LIST *resource_list, - BM_POWER_STATE *power_state); - -ACPI_STATUS -bm_pr_list_transition ( - BM_HANDLE_LIST *current_list, - BM_HANDLE_LIST *target_list); - - -#endif /* __BMPOWER_H__ */ diff --git a/reactos/drivers/bus/acpi/ospm/include/bn.h b/reactos/drivers/bus/acpi/ospm/include/bn.h deleted file mode 100644 index 94f0e8b16a1..00000000000 --- a/reactos/drivers/bus/acpi/ospm/include/bn.h +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * - * Module Name: bn.h - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef __BN_H__ -#define __BN_H__ - -#include -#include -#include - - -/***************************************************************************** - * Types & Other Defines - *****************************************************************************/ - -/* - * Notifications: - * --------------------- - */ -#define BN_NOTIFY_STATUS_CHANGE ((BM_NOTIFY) 0x80) - -/* - * Types: - * ------ - */ -#define BN_TYPE_POWER_BUTTON (0x01) -#define BN_TYPE_POWER_BUTTON_FIXED (0x02) -#define BN_TYPE_SLEEP_BUTTON (0x03) -#define BN_TYPE_SLEEP_BUTTON_FIXED (0x04) -#define BN_TYPE_LID_SWITCH (0x05) - -/* - * Hardware IDs: - * ------------- - * TODO: Power and Sleep button HIDs also exist in . Should all - * HIDs (ACPI well-known devices) exist in one place (e.g. - * acpi_hid.h)? - */ -#define BN_HID_POWER_BUTTON "PNP0C0C" -#define BN_HID_SLEEP_BUTTON "PNP0C0E" -#define BN_HID_LID_SWITCH "PNP0C0D" - -/* - * /proc Entries: - * -------------- - */ -#define BN_PROC_ROOT "button" -#define BN_PROC_POWER_BUTTON "power" -#define BN_PROC_SLEEP_BUTTON "sleep" -#define BN_PROC_LID_SWITCH "lid" - -/* - * Device Context: - * --------------- - */ -typedef struct -{ - BM_HANDLE device_handle; - ACPI_HANDLE acpi_handle; - u32 type; -} BN_CONTEXT; - - -/****************************************************************************** - * Function Prototypes - *****************************************************************************/ - -ACPI_STATUS -bn_initialize (void); - -ACPI_STATUS -bn_terminate (void); - -ACPI_STATUS -bn_notify_fixed ( - void *context); - -ACPI_STATUS -bn_notify ( - u32 notify_type, - u32 device, - void **context); - -ACPI_STATUS -bn_request( - BM_REQUEST *request_info, - void *context); - - -#endif /* __BN_H__ */ diff --git a/reactos/drivers/bus/acpi/ospm/osl.c b/reactos/drivers/bus/acpi/ospm/osl.c deleted file mode 100644 index e07be93e574..00000000000 --- a/reactos/drivers/bus/acpi/ospm/osl.c +++ /dev/null @@ -1,706 +0,0 @@ -/******************************************************************************* -* * -* ACPI Component Architecture Operating System Layer (OSL) for ReactOS * -* * -*******************************************************************************/ - -/* - * Copyright (C) 2000 Andrew Henroid - * Copyright (C) 2001 Andrew Grover - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include - -#define NDEBUG -#include - -static PKINTERRUPT AcpiInterrupt; -static BOOLEAN AcpiInterruptHandlerRegistered = FALSE; -static OSD_HANDLER AcpiIrqHandler = NULL; -static PVOID AcpiIrqContext = NULL; -static ULONG AcpiIrqNumber = 0; -static KDPC AcpiDpc; -static PVOID IVTVirtualAddress = NULL; - - -VOID NTAPI -OslDpcStub( - IN PKDPC Dpc, - IN PVOID DeferredContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2) -{ - OSD_EXECUTION_CALLBACK Routine = (OSD_EXECUTION_CALLBACK)SystemArgument1; - - DPRINT("OslDpcStub()\n"); - - DPRINT("Calling [%p]([%p])\n", Routine, SystemArgument2); - - (*Routine)(SystemArgument2); -} - - -ACPI_STATUS -acpi_os_remove_interrupt_handler( - u32 irq, - OSD_HANDLER handler); - - -ACPI_STATUS -acpi_os_initialize(void) -{ - DPRINT("acpi_os_initialize()\n"); - - KeInitializeDpc(&AcpiDpc, OslDpcStub, NULL); - - return AE_OK; -} - -ACPI_STATUS -acpi_os_terminate(void) -{ - DPRINT("acpi_os_terminate()\n"); - - if (AcpiInterruptHandlerRegistered) { - acpi_os_remove_interrupt_handler(AcpiIrqNumber, AcpiIrqHandler); - } - - return AE_OK; -} - -s32 -acpi_os_printf(const NATIVE_CHAR *fmt,...) -{ - LONG Size; - va_list args; - va_start(args, fmt); - Size = acpi_os_vprintf(fmt, args); - va_end(args); - return Size; -} - -s32 -acpi_os_vprintf(const NATIVE_CHAR *fmt, va_list args) -{ - static char Buffer[512]; - LONG Size = vsprintf(Buffer, fmt, args); - - DPRINT("%s", Buffer); - return Size; -} - -void * -acpi_os_allocate(u32 size) -{ - return ExAllocatePool(NonPagedPool, size); -} - -void * -acpi_os_callocate(u32 size) -{ - PVOID ptr = ExAllocatePool(NonPagedPool, size); - if (ptr) - memset(ptr, 0, size); - return ptr; -} - -void -acpi_os_free(void *ptr) -{ - if (ptr) { - /* FIXME: There is at least one bug somewhere that - results in an attempt to release a null pointer */ - ExFreePool(ptr); - } -} - -ACPI_STATUS -acpi_os_map_memory(ACPI_PHYSICAL_ADDRESS phys, u32 size, void **virt) -{ - PHYSICAL_ADDRESS Address; - PVOID Virtual; - - DPRINT("acpi_os_map_memory(phys 0x%X size 0x%X)\n", (ULONG)phys, size); - - if (phys == 0x0) { - /* Real mode Interrupt Vector Table */ - Virtual = ExAllocatePool(NonPagedPool, size); - IVTVirtualAddress = Virtual; - *virt = Virtual; - return AE_OK; - } - - Address.QuadPart = (ULONG)phys; - *virt = MmMapIoSpace(Address, size, MmNonCached); - if (!*virt) - return AE_ERROR; - - return AE_OK; -} - -void -acpi_os_unmap_memory(void *virt, u32 size) -{ - DPRINT("acpi_os_unmap_memory()\n"); - - if (virt == IVTVirtualAddress) { - /* Real mode Interrupt Vector Table */ - ExFreePool(IVTVirtualAddress); - IVTVirtualAddress = NULL; - return; - } - MmUnmapIoSpace(virt, size); -} - -ACPI_STATUS -acpi_os_get_physical_address(void *virt, ACPI_PHYSICAL_ADDRESS *phys) -{ - PHYSICAL_ADDRESS Address; - - DPRINT("acpi_os_get_physical_address()\n"); - - if (!phys || !virt) - return AE_BAD_PARAMETER; - - Address = MmGetPhysicalAddress(virt); - - *phys = (ULONG)Address.QuadPart; - - return AE_OK; -} - -BOOLEAN NTAPI -OslIsrStub( - PKINTERRUPT Interrupt, - PVOID ServiceContext) -{ - INT32 Status; - - Status = (*AcpiIrqHandler)(AcpiIrqContext); - - if (Status == INTERRUPT_HANDLED) - return TRUE; - else - return FALSE; -} - -ACPI_STATUS -acpi_os_install_interrupt_handler(u32 irq, OSD_HANDLER handler, void *context) -{ - ULONG Vector; - KIRQL DIrql; - KAFFINITY Affinity; - NTSTATUS Status; - - DPRINT("acpi_os_install_interrupt_handler()\n"); - - Vector = HalGetInterruptVector( - Internal, - 0, - irq, - 0, - &DIrql, - &Affinity); - - AcpiIrqNumber = irq; - AcpiIrqHandler = handler; - AcpiIrqContext = context; - AcpiInterruptHandlerRegistered = TRUE; - - Status = IoConnectInterrupt( - &AcpiInterrupt, - OslIsrStub, - NULL, - NULL, - Vector, - DIrql, - DIrql, - LevelSensitive, /* FIXME: LevelSensitive or Latched? */ - TRUE, - Affinity, - FALSE); - if (!NT_SUCCESS(Status)) { - DPRINT("Could not connect to interrupt %d\n", Vector); - return AE_ERROR; - } - - return AE_OK; -} - -ACPI_STATUS -acpi_os_remove_interrupt_handler(u32 irq, OSD_HANDLER handler) -{ - DPRINT("acpi_os_remove_interrupt_handler()\n"); - - if (AcpiInterruptHandlerRegistered) { - IoDisconnectInterrupt(AcpiInterrupt); - AcpiInterrupt = NULL; - AcpiInterruptHandlerRegistered = FALSE; - } - - return AE_OK; -} - -void -acpi_os_sleep(u32 sec, u32 ms) -{ - /* FIXME: Wait */ -} - -void -acpi_os_sleep_usec(u32 us) -{ - KeStallExecutionProcessor(us); -} - -u8 -acpi_os_in8(ACPI_IO_ADDRESS port) -{ - return READ_PORT_UCHAR((PUCHAR)port); -} - -u16 -acpi_os_in16(ACPI_IO_ADDRESS port) -{ - return READ_PORT_USHORT((PUSHORT)port); -} - -u32 -acpi_os_in32(ACPI_IO_ADDRESS port) -{ - return READ_PORT_ULONG((PULONG)port); -} - -void -acpi_os_out8(ACPI_IO_ADDRESS port, u8 val) -{ - WRITE_PORT_UCHAR((PUCHAR)port, val); -} - -void -acpi_os_out16(ACPI_IO_ADDRESS port, u16 val) -{ - WRITE_PORT_USHORT((PUSHORT)port, val); -} - -void -acpi_os_out32(ACPI_IO_ADDRESS port, u32 val) -{ - WRITE_PORT_ULONG((PULONG)port, val); -} - -u8 -acpi_os_mem_in8 (ACPI_PHYSICAL_ADDRESS phys_addr) -{ - return (*(PUCHAR)(ULONG)phys_addr); -} - -u16 -acpi_os_mem_in16 (ACPI_PHYSICAL_ADDRESS phys_addr) -{ - return (*(PUSHORT)(ULONG)phys_addr); -} - -u32 -acpi_os_mem_in32 (ACPI_PHYSICAL_ADDRESS phys_addr) -{ - return (*(PULONG)(ULONG)phys_addr); -} - -void -acpi_os_mem_out8 (ACPI_PHYSICAL_ADDRESS phys_addr, u8 value) -{ - *(PUCHAR)(ULONG)phys_addr = value; -} - -void -acpi_os_mem_out16 (ACPI_PHYSICAL_ADDRESS phys_addr, u16 value) -{ - *(PUSHORT)(ULONG)phys_addr = value; -} - -void -acpi_os_mem_out32 (ACPI_PHYSICAL_ADDRESS phys_addr, u32 value) -{ - *(PULONG)(ULONG)phys_addr = value; -} - -ACPI_STATUS -acpi_os_read_pci_cfg_byte( - u32 bus, - u32 func, - u32 addr, - u8 * val) -{ - NTSTATUS ret; - PCI_SLOT_NUMBER slot; - - if (func == 0) - return AE_ERROR; - - slot.u.AsULONG = 0; - slot.u.bits.DeviceNumber = (func >> 16) & 0xFFFF; - slot.u.bits.FunctionNumber = func & 0xFFFF; - - DPRINT("acpi_os_read_pci_cfg_byte, slot=0x%X, func=0x%X\n", slot.u.AsULONG, func); - ret = HalGetBusDataByOffset(PCIConfiguration, - bus, - slot.u.AsULONG, - val, - addr, - sizeof(UCHAR)); - - if (NT_SUCCESS(ret)) - return AE_OK; - else - return AE_ERROR; -} - -ACPI_STATUS -acpi_os_read_pci_cfg_word( - u32 bus, - u32 func, - u32 addr, - u16 * val) -{ - NTSTATUS ret; - PCI_SLOT_NUMBER slot; - - if (func == 0) - return AE_ERROR; - - slot.u.AsULONG = 0; - slot.u.bits.DeviceNumber = (func >> 16) & 0xFFFF; - slot.u.bits.FunctionNumber = func & 0xFFFF; - - DPRINT("acpi_os_read_pci_cfg_word, slot=0x%x\n", slot.u.AsULONG); - ret = HalGetBusDataByOffset(PCIConfiguration, - bus, - slot.u.AsULONG, - val, - addr, - sizeof(USHORT)); - - if (NT_SUCCESS(ret)) - return AE_OK; - else - return AE_ERROR; -} - -ACPI_STATUS -acpi_os_read_pci_cfg_dword( - u32 bus, - u32 func, - u32 addr, - u32 * val) -{ - NTSTATUS ret; - PCI_SLOT_NUMBER slot; - - if (func == 0) - return AE_ERROR; - - slot.u.AsULONG = 0; - slot.u.bits.DeviceNumber = (func >> 16) & 0xFFFF; - slot.u.bits.FunctionNumber = func & 0xFFFF; - - DPRINT("acpi_os_read_pci_cfg_dword, slot=0x%x\n", slot.u.AsULONG); - ret = HalGetBusDataByOffset(PCIConfiguration, - bus, - slot.u.AsULONG, - val, - addr, - sizeof(ULONG)); - - if (NT_SUCCESS(ret)) - return AE_OK; - else - return AE_ERROR; -} - -ACPI_STATUS -acpi_os_write_pci_cfg_byte( - u32 bus, - u32 func, - u32 addr, - u8 val) -{ - NTSTATUS ret; - UCHAR buf = val; - PCI_SLOT_NUMBER slot; - - if (func == 0) - return AE_ERROR; - - slot.u.AsULONG = 0; - slot.u.bits.DeviceNumber = (func >> 16) & 0xFFFF; - slot.u.bits.FunctionNumber = func & 0xFFFF; - - DPRINT("acpi_os_write_pci_cfg_byte, slot=0x%x\n", slot.u.AsULONG); - ret = HalSetBusDataByOffset(PCIConfiguration, - bus, - slot.u.AsULONG, - &buf, - addr, - sizeof(UCHAR)); - - if (NT_SUCCESS(ret)) - return AE_OK; - else - return AE_ERROR; -} - -ACPI_STATUS -acpi_os_write_pci_cfg_word( - u32 bus, - u32 func, - u32 addr, - u16 val) -{ - NTSTATUS ret; - USHORT buf = val; - PCI_SLOT_NUMBER slot; - - if (func == 0) - return AE_ERROR; - - slot.u.AsULONG = 0; - slot.u.bits.DeviceNumber = (func >> 16) & 0xFFFF; - slot.u.bits.FunctionNumber = func & 0xFFFF; - - DPRINT("acpi_os_write_pci_cfg_byte, slot=0x%x\n", slot.u.AsULONG); - ret = HalSetBusDataByOffset(PCIConfiguration, - bus, - slot.u.AsULONG, - &buf, - addr, - sizeof(USHORT)); - - if (NT_SUCCESS(ret)) - return AE_OK; - else - return AE_ERROR; -} - -ACPI_STATUS -acpi_os_write_pci_cfg_dword( - u32 bus, - u32 func, - u32 addr, - u32 val) -{ - NTSTATUS ret; - ULONG buf = val; - PCI_SLOT_NUMBER slot; - - if (func == 0) - return AE_ERROR; - - slot.u.AsULONG = 0; - slot.u.bits.DeviceNumber = (func >> 16) & 0xFFFF; - slot.u.bits.FunctionNumber = func & 0xFFFF; - - DPRINT("acpi_os_write_pci_cfg_byte, slot=0x%x\n", slot.u.AsULONG); - ret = HalSetBusDataByOffset(PCIConfiguration, - bus, - slot.u.AsULONG, - &buf, - addr, - sizeof(ULONG)); - - if (NT_SUCCESS(ret)) - return AE_OK; - else - return AE_ERROR; -} - -ACPI_STATUS -acpi_os_load_module ( - char *module_name) -{ - DPRINT("acpi_os_load_module()\n"); - - if (!module_name) - return AE_BAD_PARAMETER; - - return AE_OK; -} - -ACPI_STATUS -acpi_os_unload_module ( - char *module_name) -{ - DPRINT("acpi_os_unload_module()\n"); - - if (!module_name) - return AE_BAD_PARAMETER; - - return AE_OK; -} - -ACPI_STATUS -acpi_os_queue_for_execution( - u32 priority, - OSD_EXECUTION_CALLBACK function, - void *context) -{ - ACPI_STATUS Status = AE_OK; - - DPRINT("acpi_os_queue_for_execution()\n"); - - if (!function) - return AE_BAD_PARAMETER; - - DPRINT("Scheduling task [%p](%p) for execution.\n", function, context); - -#if 0 - switch (priority) { - case OSD_PRIORITY_MED: - KeSetImportanceDpc(&AcpiDpc, MediumImportance); - case OSD_PRIORITY_LO: - KeSetImportanceDpc(&AcpiDpc, LowImportance); - case OSD_PRIORITY_HIGH: - default: - KeSetImportanceDpc(&AcpiDpc, HighImportance); - } -#endif - - KeInsertQueueDpc(&AcpiDpc, (PVOID)function, (PVOID)context); - - return Status; -} - -ACPI_STATUS -acpi_os_create_semaphore( - u32 max_units, - u32 initial_units, - ACPI_HANDLE *handle) -{ - PFAST_MUTEX Mutex; - - Mutex = ExAllocatePool(NonPagedPool, sizeof(FAST_MUTEX)); - if (!Mutex) - return AE_NO_MEMORY; - - DPRINT("acpi_os_create_semaphore() at 0x%X\n", Mutex); - - ExInitializeFastMutex(Mutex); - - *handle = Mutex; - return AE_OK; -} - -ACPI_STATUS -acpi_os_delete_semaphore( - ACPI_HANDLE handle) -{ - PFAST_MUTEX Mutex = (PFAST_MUTEX)handle; - - DPRINT("acpi_os_delete_semaphore(handle 0x%X)\n", handle); - - if (!Mutex) - return AE_BAD_PARAMETER; - - ExFreePool(Mutex); - - return AE_OK; -} - -ACPI_STATUS -acpi_os_wait_semaphore( - ACPI_HANDLE handle, - u32 units, - u32 timeout) -{ - PFAST_MUTEX Mutex = (PFAST_MUTEX)handle; - - if (!Mutex || (units < 1)) { - DPRINT("acpi_os_wait_semaphore(handle 0x%X, units %d) Bad parameters\n", - handle, units); - return AE_BAD_PARAMETER; - } - - DPRINT("Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout); - - ExAcquireFastMutex(Mutex); - - return AE_OK; -} - -ACPI_STATUS -acpi_os_signal_semaphore( - ACPI_HANDLE handle, - u32 units) -{ - PFAST_MUTEX Mutex = (PFAST_MUTEX)handle; - - if (!Mutex || (units < 1)) { - DPRINT("acpi_os_signal_semaphore(handle 0x%X) Bad parameter\n", handle); - return AE_BAD_PARAMETER; - } - - DPRINT("Signaling semaphore[%p|%d]\n", handle, units); - - ExReleaseFastMutex(Mutex); - - return AE_OK; -} - -ACPI_STATUS -acpi_os_breakpoint(NATIVE_CHAR *msg) -{ - DPRINT1("BREAKPOINT: %s", msg); - return AE_OK; -} - -void -acpi_os_dbg_trap(char *msg) - -{ - DPRINT1("TRAP: %s", msg); -} - -void -acpi_os_dbg_assert(void *failure, void *file, u32 line, NATIVE_CHAR *msg) -{ - DPRINT1("ASSERT: %s\n", msg); -} - -u32 -acpi_os_get_line(NATIVE_CHAR *buffer) -{ - return 0; -} - -u8 -acpi_os_readable(void *ptr, u32 len) -{ - /* Always readable */ - return TRUE; -} - -u8 -acpi_os_writable(void *ptr, u32 len) -{ - /* Always writable */ - return TRUE; -} - -u32 -acpi_os_get_thread_id (void) -{ - return (ULONG)PsGetCurrentThreadId() + 1; -} diff --git a/reactos/drivers/bus/acpi/ospm/pdo.c b/reactos/drivers/bus/acpi/ospm/pdo.c deleted file mode 100644 index 9834ee05c28..00000000000 --- a/reactos/drivers/bus/acpi/ospm/pdo.c +++ /dev/null @@ -1,385 +0,0 @@ -/* $Id$ - * - * PROJECT: ReactOS ACPI bus driver - * FILE: acpi/ospm/pdo.c - * PURPOSE: Child device object dispatch routines - * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) - * UPDATE HISTORY: - * 08-08-2001 CSH Created - */ -#include - -#define NDEBUG -#include - -/*** PRIVATE *****************************************************************/ - -static NTSTATUS -AcpiDuplicateUnicodeString( - PUNICODE_STRING Destination, - PUNICODE_STRING Source, - POOL_TYPE PoolType) -{ - if (Source == NULL) - { - RtlInitUnicodeString(Destination, NULL); - return STATUS_SUCCESS; - } - - Destination->Buffer = ExAllocatePool(PoolType, Source->MaximumLength); - if (Destination->Buffer == NULL) - { - return STATUS_INSUFFICIENT_RESOURCES; - } - - Destination->MaximumLength = Source->MaximumLength; - Destination->Length = Source->Length; - RtlCopyMemory(Destination->Buffer, Source->Buffer, Source->MaximumLength); - - return STATUS_SUCCESS; -} - - -static NTSTATUS -PdoQueryDeviceText( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - PPDO_DEVICE_EXTENSION DeviceExtension; - PWSTR Buffer; - NTSTATUS Status; - - DPRINT("Called\n"); - - DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - Status = STATUS_SUCCESS; - - switch (IrpSp->Parameters.QueryDeviceText.DeviceTextType) - { - case DeviceTextDescription: - DPRINT("DeviceTextDescription\n"); - Buffer = (PWSTR)ExAllocatePool(PagedPool, DeviceExtension->DeviceDescription.Length + sizeof(UNICODE_NULL)); - if (Buffer == NULL) - Status = STATUS_INSUFFICIENT_RESOURCES; - else - { - RtlCopyMemory(Buffer, DeviceExtension->DeviceDescription.Buffer, DeviceExtension->DeviceDescription.Length); - Buffer[DeviceExtension->DeviceDescription.Length / sizeof(WCHAR)] = UNICODE_NULL; - Irp->IoStatus.Information = (ULONG_PTR)Buffer; - } - break; - - default: - Irp->IoStatus.Information = 0; - Status = STATUS_INVALID_PARAMETER; - } - - return Status; -} - - -static NTSTATUS -PdoQueryId( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - PPDO_DEVICE_EXTENSION DeviceExtension; - UNICODE_STRING String; - NTSTATUS Status; - - DPRINT("Called\n"); - - DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - RtlInitUnicodeString(&String, NULL); - -// Irp->IoStatus.Information = 0; - - switch (IrpSp->Parameters.QueryId.IdType) - { - case BusQueryDeviceID: - DPRINT("BusQueryDeviceID\n"); - Status = AcpiDuplicateUnicodeString(&String, - &DeviceExtension->DeviceID, - PagedPool); - DPRINT("DeviceID: %S\n", String.Buffer); - Irp->IoStatus.Information = (ULONG_PTR)String.Buffer; - break; - - case BusQueryHardwareIDs: - DPRINT("BusQueryHardwareIDs\n"); - Status = AcpiDuplicateUnicodeString(&String, - &DeviceExtension->HardwareIDs, - PagedPool); - Irp->IoStatus.Information = (ULONG_PTR)String.Buffer; - break; - - case BusQueryCompatibleIDs: - DPRINT("BusQueryCompatibleIDs\n"); - Status = STATUS_NOT_IMPLEMENTED; - break; - - case BusQueryInstanceID: - DPRINT("BusQueryInstanceID\n"); - Status = AcpiDuplicateUnicodeString(&String, - &DeviceExtension->InstanceID, - PagedPool); - DPRINT("InstanceID: %S\n", String.Buffer); - Irp->IoStatus.Information = (ULONG_PTR)String.Buffer; - break; - - case BusQueryDeviceSerialNumber: - DPRINT("BusQueryDeviceSerialNumber\n"); - Status = STATUS_NOT_IMPLEMENTED; - break; - - default: - DPRINT("Unknown id type: %lx\n", IrpSp->Parameters.QueryId.IdType); - Status = STATUS_NOT_IMPLEMENTED; - } - - return Status; -} - - -static NTSTATUS -PdoQueryResourceRequirements( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - PPDO_DEVICE_EXTENSION DeviceExtension; - PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList; - - DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - if (DeviceExtension->ResourceRequirementsListSize == 0) - { - return Irp->IoStatus.Status; - } - - ResourceRequirementsList = ExAllocatePool(PagedPool, DeviceExtension->ResourceRequirementsListSize); - if (!ResourceRequirementsList) - { - Irp->IoStatus.Information = 0; - return STATUS_INSUFFICIENT_RESOURCES; - } - - RtlCopyMemory(ResourceRequirementsList, DeviceExtension->ResourceRequirementsList, DeviceExtension->ResourceRequirementsListSize); - Irp->IoStatus.Information = (ULONG_PTR)ResourceRequirementsList; - return STATUS_SUCCESS; -} - - -static NTSTATUS -PdoQueryResources( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - PPDO_DEVICE_EXTENSION DeviceExtension; - PCM_RESOURCE_LIST ResourceList; - - DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - if (DeviceExtension->ResourceListSize == 0) - { - return Irp->IoStatus.Status; - } - - ResourceList = ExAllocatePool(PagedPool, DeviceExtension->ResourceListSize); - if (!ResourceList) - { - Irp->IoStatus.Information = 0; - return STATUS_INSUFFICIENT_RESOURCES; - } - - RtlCopyMemory(ResourceList, DeviceExtension->ResourceList, DeviceExtension->ResourceListSize); - Irp->IoStatus.Information = (ULONG_PTR)ResourceList; - return STATUS_SUCCESS; -} - - -static NTSTATUS -PdoSetPower( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - PPDO_DEVICE_EXTENSION DeviceExtension; - NTSTATUS Status; - - DPRINT("Called\n"); - - DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - if (IrpSp->Parameters.Power.Type == DevicePowerState) { - Status = STATUS_SUCCESS; - switch (IrpSp->Parameters.Power.State.SystemState) { - default: - Status = STATUS_UNSUCCESSFUL; - } - } else { - Status = STATUS_UNSUCCESSFUL; - } - - return Status; -} - - -/*** PUBLIC ******************************************************************/ - -NTSTATUS -NTAPI -PdoPnpControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp) -/* - * FUNCTION: Handle Plug and Play IRPs for the child device - * ARGUMENTS: - * DeviceObject = Pointer to physical device object of the child device - * Irp = Pointer to IRP that should be handled - * RETURNS: - * Status - */ -{ - PIO_STACK_LOCATION IrpSp; - NTSTATUS Status; - - DPRINT("Called\n"); - - Status = Irp->IoStatus.Status; - - IrpSp = IoGetCurrentIrpStackLocation(Irp); - - switch (IrpSp->MinorFunction) { - case IRP_MN_CANCEL_REMOVE_DEVICE: - break; - - case IRP_MN_CANCEL_STOP_DEVICE: - break; - - case IRP_MN_DEVICE_USAGE_NOTIFICATION: - break; - - case IRP_MN_EJECT: - break; - - case IRP_MN_QUERY_BUS_INFORMATION: - break; - - case IRP_MN_QUERY_CAPABILITIES: - break; - - case IRP_MN_QUERY_DEVICE_RELATIONS: - /* FIXME: Possibly handle for RemovalRelations */ - break; - - case IRP_MN_QUERY_DEVICE_TEXT: - Status = PdoQueryDeviceText(DeviceObject, Irp, IrpSp); - break; - - case IRP_MN_QUERY_ID: - Status = PdoQueryId(DeviceObject, - Irp, - IrpSp); - break; - - case IRP_MN_QUERY_PNP_DEVICE_STATE: - break; - - case IRP_MN_QUERY_REMOVE_DEVICE: - break; - - case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: - Status = PdoQueryResourceRequirements(DeviceObject, - Irp, - IrpSp); - break; - - case IRP_MN_QUERY_RESOURCES: - Status = PdoQueryResources(DeviceObject, - Irp, - IrpSp); - break; - - case IRP_MN_QUERY_STOP_DEVICE: - break; - - case IRP_MN_REMOVE_DEVICE: - break; - - case IRP_MN_SET_LOCK: - break; - - case IRP_MN_START_DEVICE: - Status = STATUS_SUCCESS; - break; - - case IRP_MN_STOP_DEVICE: - break; - - case IRP_MN_SURPRISE_REMOVAL: - break; - - default: - DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction); - break; - } - - if (Status != STATUS_PENDING) { - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } - - DPRINT("Leaving. Status 0x%X\n", Status); - - return Status; -} - -NTSTATUS -NTAPI -PdoPowerControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp) -/* - * FUNCTION: Handle power management IRPs for the child device - * ARGUMENTS: - * DeviceObject = Pointer to physical device object of the child device - * Irp = Pointer to IRP that should be handled - * RETURNS: - * Status - */ -{ - PIO_STACK_LOCATION IrpSp; - NTSTATUS Status; - - DPRINT("Called\n"); - - IrpSp = IoGetCurrentIrpStackLocation(Irp); - - switch (IrpSp->MinorFunction) { - case IRP_MN_SET_POWER: - Status = PdoSetPower(DeviceObject, Irp, IrpSp); - break; - - default: - DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction); - Status = STATUS_NOT_IMPLEMENTED; - break; - } - - if (Status != STATUS_PENDING) { - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } - - DPRINT("Leaving. Status 0x%X\n", Status); - - return Status; -} - -/* EOF */ diff --git a/reactos/drivers/bus/acpi/parser/psargs.c b/reactos/drivers/bus/acpi/parser/psargs.c deleted file mode 100644 index 1eaa016c0a4..00000000000 --- a/reactos/drivers/bus/acpi/parser/psargs.c +++ /dev/null @@ -1,730 +0,0 @@ -/****************************************************************************** - * - * Module Name: psargs - Parse AML opcode arguments - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_PARSER - MODULE_NAME ("psargs") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_next_package_length - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: Decoded package length. On completion, the AML pointer points - * past the length byte or bytes. - * - * DESCRIPTION: Decode and return a package length field - * - ******************************************************************************/ - -u32 -acpi_ps_get_next_package_length ( - ACPI_PARSE_STATE *parser_state) -{ - u32 encoded_length; - u32 length = 0; - - - encoded_length = (u32) GET8 (parser_state->aml); - parser_state->aml++; - - - switch (encoded_length >> 6) /* bits 6-7 contain encoding scheme */ { - case 0: /* 1-byte encoding (bits 0-5) */ - - length = (encoded_length & 0x3F); - break; - - - case 1: /* 2-byte encoding (next byte + bits 0-3) */ - - length = ((GET8 (parser_state->aml) << 04) | - (encoded_length & 0x0F)); - parser_state->aml++; - break; - - - case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ - - length = ((GET8 (parser_state->aml + 1) << 12) | - (GET8 (parser_state->aml) << 04) | - (encoded_length & 0x0F)); - parser_state->aml += 2; - break; - - - case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ - - length = ((GET8 (parser_state->aml + 2) << 20) | - (GET8 (parser_state->aml + 1) << 12) | - (GET8 (parser_state->aml) << 04) | - (encoded_length & 0x0F)); - parser_state->aml += 3; - break; - } - - return (length); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_next_package_end - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: Pointer to end-of-package +1 - * - * DESCRIPTION: Get next package length and return a pointer past the end of - * the package. Consumes the package length field - * - ******************************************************************************/ - -u8 * -acpi_ps_get_next_package_end ( - ACPI_PARSE_STATE *parser_state) -{ - u8 *start = parser_state->aml; - NATIVE_UINT length; - - - length = (NATIVE_UINT) acpi_ps_get_next_package_length (parser_state); - - return (start + length); /* end of package */ -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_next_namestring - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: Pointer to the start of the name string (pointer points into - * the AML. - * - * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name - * prefix characters. Set parser state to point past the string. - * (Name is consumed from the AML.) - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_ps_get_next_namestring ( - ACPI_PARSE_STATE *parser_state) -{ - u8 *start = parser_state->aml; - u8 *end = parser_state->aml; - u32 length; - - - /* Handle multiple prefix characters */ - - while (acpi_ps_is_prefix_char (GET8 (end))) { - /* include prefix '\\' or '^' */ - - end++; - } - - /* Decode the path */ - - switch (GET8 (end)) { - case 0: - - /* Null_name */ - - if (end == start) { - start = NULL; - } - end++; - break; - - - case AML_DUAL_NAME_PREFIX: - - /* two name segments */ - - end += 9; - break; - - - case AML_MULTI_NAME_PREFIX_OP: - - /* multiple name segments */ - - length = (u32) GET8 (end + 1) * 4; - end += 2 + length; - break; - - - default: - - /* single name segment */ - /* assert (Acpi_ps_is_lead (GET8 (End))); */ - - end += 4; - break; - } - - parser_state->aml = (u8*) end; - - return ((NATIVE_CHAR *) start); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_next_namepath - * - * PARAMETERS: Parser_state - Current parser state object - * Arg - Where the namepath will be stored - * Arg_count - If the namepath points to a control method - * the method's argument is returned here. - * Method_call - Whether the namepath can be the start - * of a method call - * - * RETURN: None - * - * DESCRIPTION: Get next name (if method call, push appropriate # args). Names - * are looked up in either the parsed or internal namespace to - * determine if the name represents a control method. If a method - * is found, the number of arguments to the method is returned. - * This information is critical for parsing to continue correctly. - * - ******************************************************************************/ - - -#ifdef PARSER_ONLY - -void -acpi_ps_get_next_namepath ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT *arg, - u32 *arg_count, - u8 method_call) -{ - NATIVE_CHAR *path; - ACPI_PARSE_OBJECT *name_op; - ACPI_PARSE_OBJECT *op; - ACPI_PARSE_OBJECT *count; - - - path = acpi_ps_get_next_namestring (parser_state); - if (!path || !method_call) { - /* Null name case, create a null namepath object */ - - acpi_ps_init_op (arg, AML_NAMEPATH_OP); - arg->value.name = path; - return; - } - - - if (acpi_gbl_parsed_namespace_root) { - /* - * Lookup the name in the parsed namespace - */ - - op = NULL; - if (method_call) { - op = acpi_ps_find (acpi_ps_get_parent_scope (parser_state), - path, AML_METHOD_OP, 0); - } - - if (op) { - if (op->opcode == AML_METHOD_OP) { - /* - * The name refers to a control method, so this namepath is a - * method invocation. We need to 1) Get the number of arguments - * associated with this method, and 2) Change the NAMEPATH - * object into a METHODCALL object. - */ - - count = acpi_ps_get_arg (op, 0); - if (count && count->opcode == AML_BYTE_OP) { - name_op = acpi_ps_alloc_op (AML_NAMEPATH_OP); - if (name_op) { - /* Change arg into a METHOD CALL and attach the name */ - - acpi_ps_init_op (arg, AML_METHODCALL_OP); - - name_op->value.name = path; - - /* Point METHODCALL/NAME to the METHOD Node */ - - name_op->node = (ACPI_NAMESPACE_NODE *) op; - acpi_ps_append_arg (arg, name_op); - - *arg_count = count->value.integer & - METHOD_FLAGS_ARG_COUNT; - } - } - - return; - } - - /* - * Else this is normal named object reference. - * Just init the NAMEPATH object with the pathname. - * (See code below) - */ - } - } - - - /* - * Either we didn't find the object in the namespace, or the object is - * something other than a control method. Just initialize the Op with the - * pathname - */ - - acpi_ps_init_op (arg, AML_NAMEPATH_OP); - arg->value.name = path; - - - return; -} - - -#else - - -void -acpi_ps_get_next_namepath ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT *arg, - u32 *arg_count, - u8 method_call) -{ - NATIVE_CHAR *path; - ACPI_PARSE_OBJECT *name_op; - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *method_node = NULL; - ACPI_NAMESPACE_NODE *node; - ACPI_GENERIC_STATE scope_info; - - - path = acpi_ps_get_next_namestring (parser_state); - if (!path || !method_call) { - /* Null name case, create a null namepath object */ - - acpi_ps_init_op (arg, AML_NAMEPATH_OP); - arg->value.name = path; - return; - } - - - if (method_call) { - /* - * Lookup the name in the internal namespace - */ - scope_info.scope.node = NULL; - node = parser_state->start_node; - if (node) { - scope_info.scope.node = node; - } - - /* - * Lookup object. We don't want to add anything new to the namespace - * here, however. So we use MODE_EXECUTE. Allow searching of the - * parent tree, but don't open a new scope -- we just want to lookup the - * object (MUST BE mode EXECUTE to perform upsearch) - */ - - status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, IMODE_EXECUTE, - NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL, - &node); - if (ACPI_SUCCESS (status)) { - if (node->type == ACPI_TYPE_METHOD) { - method_node = node; - name_op = acpi_ps_alloc_op (AML_NAMEPATH_OP); - if (name_op) { - /* Change arg into a METHOD CALL and attach name to it */ - - acpi_ps_init_op (arg, AML_METHODCALL_OP); - - name_op->value.name = path; - - /* Point METHODCALL/NAME to the METHOD Node */ - - name_op->node = method_node; - acpi_ps_append_arg (arg, name_op); - - if (!(ACPI_OPERAND_OBJECT *) method_node->object) { - return; - } - - *arg_count = ((ACPI_OPERAND_OBJECT *) method_node->object)->method.param_count; - } - - return; - } - - /* - * Else this is normal named object reference. - * Just init the NAMEPATH object with the pathname. - * (See code below) - */ - } - } - - /* - * Either we didn't find the object in the namespace, or the object is - * something other than a control method. Just initialize the Op with the - * pathname. - */ - - acpi_ps_init_op (arg, AML_NAMEPATH_OP); - arg->value.name = path; - - - return; -} - -#endif - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_next_simple_arg - * - * PARAMETERS: Parser_state - Current parser state object - * Arg_type - The argument type (AML_*_ARG) - * Arg - Where the argument is returned - * - * RETURN: None - * - * DESCRIPTION: Get the next simple argument (constant, string, or namestring) - * - ******************************************************************************/ - -void -acpi_ps_get_next_simple_arg ( - ACPI_PARSE_STATE *parser_state, - u32 arg_type, - ACPI_PARSE_OBJECT *arg) -{ - - - switch (arg_type) { - - case ARGP_BYTEDATA: - - acpi_ps_init_op (arg, AML_BYTE_OP); - arg->value.integer = (u32) GET8 (parser_state->aml); - parser_state->aml++; - break; - - - case ARGP_WORDDATA: - - acpi_ps_init_op (arg, AML_WORD_OP); - - /* Get 2 bytes from the AML stream */ - - MOVE_UNALIGNED16_TO_32 (&arg->value.integer, parser_state->aml); - parser_state->aml += 2; - break; - - - case ARGP_DWORDDATA: - - acpi_ps_init_op (arg, AML_DWORD_OP); - - /* Get 4 bytes from the AML stream */ - - MOVE_UNALIGNED32_TO_32 (&arg->value.integer, parser_state->aml); - parser_state->aml += 4; - break; - - - case ARGP_CHARLIST: - - acpi_ps_init_op (arg, AML_STRING_OP); - arg->value.string = (char*) parser_state->aml; - - while (GET8 (parser_state->aml) != '\0') { - parser_state->aml++; - } - parser_state->aml++; - break; - - - case ARGP_NAME: - case ARGP_NAMESTRING: - - acpi_ps_init_op (arg, AML_NAMEPATH_OP); - arg->value.name = acpi_ps_get_next_namestring (parser_state); - break; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_next_field - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: A newly allocated FIELD op - * - * DESCRIPTION: Get next field (Named_field, Reserved_field, or Access_field) - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT * -acpi_ps_get_next_field ( - ACPI_PARSE_STATE *parser_state) -{ - ACPI_PTRDIFF aml_offset = parser_state->aml - - parser_state->aml_start; - ACPI_PARSE_OBJECT *field; - u16 opcode; - u32 name; - - - /* determine field type */ - - switch (GET8 (parser_state->aml)) { - - default: - - opcode = AML_NAMEDFIELD_OP; - break; - - - case 0x00: - - opcode = AML_RESERVEDFIELD_OP; - parser_state->aml++; - break; - - - case 0x01: - - opcode = AML_ACCESSFIELD_OP; - parser_state->aml++; - break; - } - - - /* Allocate a new field op */ - - field = acpi_ps_alloc_op (opcode); - if (field) { - field->aml_offset = aml_offset; - - /* Decode the field type */ - - switch (opcode) { - case AML_NAMEDFIELD_OP: - - /* Get the 4-character name */ - - MOVE_UNALIGNED32_TO_32 (&name, parser_state->aml); - acpi_ps_set_name (field, name); - parser_state->aml += 4; - - /* Get the length which is encoded as a package length */ - - field->value.size = acpi_ps_get_next_package_length (parser_state); - break; - - - case AML_RESERVEDFIELD_OP: - - /* Get the length which is encoded as a package length */ - - field->value.size = acpi_ps_get_next_package_length (parser_state); - break; - - - case AML_ACCESSFIELD_OP: - - /* Get Access_type and Access_atrib and merge into the field Op */ - - field->value.integer = ((GET8 (parser_state->aml) << 8) | - GET8 (parser_state->aml)); - parser_state->aml += 2; - break; - } - } - - return (field); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_next_arg - * - * PARAMETERS: Parser_state - Current parser state object - * Arg_type - The argument type (AML_*_ARG) - * Arg_count - If the argument points to a control method - * the method's argument is returned here. - * - * RETURN: An op object containing the next argument. - * - * DESCRIPTION: Get next argument (including complex list arguments that require - * pushing the parser stack) - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT * -acpi_ps_get_next_arg ( - ACPI_PARSE_STATE *parser_state, - u32 arg_type, - u32 *arg_count) -{ - ACPI_PARSE_OBJECT *arg = NULL; - ACPI_PARSE_OBJECT *prev = NULL; - ACPI_PARSE_OBJECT *field; - u32 subop; - - - switch (arg_type) { - case ARGP_BYTEDATA: - case ARGP_WORDDATA: - case ARGP_DWORDDATA: - case ARGP_CHARLIST: - case ARGP_NAME: - case ARGP_NAMESTRING: - - /* constants, strings, and namestrings are all the same size */ - - arg = acpi_ps_alloc_op (AML_BYTE_OP); - if (arg) { - acpi_ps_get_next_simple_arg (parser_state, arg_type, arg); - } - break; - - - case ARGP_PKGLENGTH: - - /* package length, nothing returned */ - - parser_state->pkg_end = acpi_ps_get_next_package_end (parser_state); - break; - - - case ARGP_FIELDLIST: - - if (parser_state->aml < parser_state->pkg_end) { - /* non-empty list */ - - while (parser_state->aml < parser_state->pkg_end) { - field = acpi_ps_get_next_field (parser_state); - if (!field) { - break; - } - - if (prev) { - prev->next = field; - } - - else { - arg = field; - } - - prev = field; - } - - /* skip to End of byte data */ - - parser_state->aml = parser_state->pkg_end; - } - break; - - - case ARGP_BYTELIST: - - if (parser_state->aml < parser_state->pkg_end) { - /* non-empty list */ - - arg = acpi_ps_alloc_op (AML_BYTELIST_OP); - if (arg) { - /* fill in bytelist data */ - - arg->value.size = (parser_state->pkg_end - parser_state->aml); - ((ACPI_PARSE2_OBJECT *) arg)->data = parser_state->aml; - } - - /* skip to End of byte data */ - - parser_state->aml = parser_state->pkg_end; - } - break; - - - case ARGP_TARGET: - case ARGP_SUPERNAME: { - subop = acpi_ps_peek_opcode (parser_state); - if (subop == 0 || - acpi_ps_is_leading_char (subop) || - acpi_ps_is_prefix_char (subop)) { - /* Null_name or Name_string */ - - arg = acpi_ps_alloc_op (AML_NAMEPATH_OP); - if (arg) { - acpi_ps_get_next_namepath (parser_state, arg, arg_count, 0); - } - } - - else { - /* single complex argument, nothing returned */ - - *arg_count = 1; - } - } - break; - - - case ARGP_DATAOBJ: - case ARGP_TERMARG: - - /* single complex argument, nothing returned */ - - *arg_count = 1; - break; - - - case ARGP_DATAOBJLIST: - case ARGP_TERMLIST: - case ARGP_OBJLIST: - - if (parser_state->aml < parser_state->pkg_end) { - /* non-empty list of variable arguments, nothing returned */ - - *arg_count = ACPI_VAR_ARGS; - } - break; - } - - return (arg); -} diff --git a/reactos/drivers/bus/acpi/parser/psopcode.c b/reactos/drivers/bus/acpi/parser/psopcode.c deleted file mode 100644 index 5620157e779..00000000000 --- a/reactos/drivers/bus/acpi/parser/psopcode.c +++ /dev/null @@ -1,648 +0,0 @@ -/****************************************************************************** - * - * Module Name: psopcode - Parser opcode information table - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_PARSER - MODULE_NAME ("psopcode") - - -#define _UNK 0x6B -/* - * Reserved ASCII characters. Do not use any of these for - * internal opcodes, since they are used to differentiate - * name strings from AML opcodes - */ -#define _ASC 0x6C -#define _NAM 0x6C -#define _PFX 0x6D -#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */ - -#define MAX_EXTENDED_OPCODE 0x88 -#define NUM_EXTENDED_OPCODE MAX_EXTENDED_OPCODE + 1 -#define MAX_INTERNAL_OPCODE -#define NUM_INTERNAL_OPCODE MAX_INTERNAL_OPCODE + 1 - - -/******************************************************************************* - * - * NAME: Acpi_gbl_Aml_op_info - * - * DESCRIPTION: Opcode table. Each entry contains - * The name is a simple ascii string, the operand specifier is an - * ascii string with one letter per operand. The letter specifies - * the operand type. - * - ******************************************************************************/ - - -/* - * Flags byte: 0-4 (5 bits) = Opcode Type - * 5 (1 bit) = Has arguments flag - * 6-7 (2 bits) = Reserved - */ -#define AML_NO_ARGS 0 -#define AML_HAS_ARGS ACPI_OP_ARGS_MASK - -/* - * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed - * into a 32-bit number and stored in the master opcode table at the end of this file. - */ - -#define ARGP_ZERO_OP ARG_NONE -#define ARGP_ONE_OP ARG_NONE -#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) -#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) -#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) -#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) -#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) -#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) -#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) -#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) -#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) -#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) -#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) -#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) -#define ARGP_LOCAL0 ARG_NONE -#define ARGP_LOCAL1 ARG_NONE -#define ARGP_LOCAL2 ARG_NONE -#define ARGP_LOCAL3 ARG_NONE -#define ARGP_LOCAL4 ARG_NONE -#define ARGP_LOCAL5 ARG_NONE -#define ARGP_LOCAL6 ARG_NONE -#define ARGP_LOCAL7 ARG_NONE -#define ARGP_ARG0 ARG_NONE -#define ARGP_ARG1 ARG_NONE -#define ARGP_ARG2 ARG_NONE -#define ARGP_ARG3 ARG_NONE -#define ARGP_ARG4 ARG_NONE -#define ARGP_ARG5 ARG_NONE -#define ARGP_ARG6 ARG_NONE -#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) -#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) -#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) -#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME) -#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_CONTINUE_OP ARG_NONE -#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) -#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) -#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) -#define ARGP_NOOP_OP ARG_NONE -#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_BREAK_OP ARG_NONE -#define ARGP_BREAK_POINT_OP ARG_NONE -#define ARGP_ONES_OP ARG_NONE -#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) -#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) -#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) -#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) -#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) -#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) -#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_REVISION_OP ARG_NONE -#define ARGP_DEBUG_OP ARG_NONE -#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) -#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_DEF_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) -#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) -#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) -#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) -#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAMESTRING, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) - - -/* - * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed - * into a 32-bit number and stored in the master opcode table at the end of this file. - * - * (Used by Acpi_aml_prep_operands procedure and the ASL Compiler) - */ - -#define ARGI_ZERO_OP ARG_NONE -#define ARGI_ONE_OP ARG_NONE -#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE -#define ARGI_NAME_OP ARGI_INVALID_OPCODE -#define ARGI_BYTE_OP ARGI_INVALID_OPCODE -#define ARGI_WORD_OP ARGI_INVALID_OPCODE -#define ARGI_DWORD_OP ARGI_INVALID_OPCODE -#define ARGI_STRING_OP ARGI_INVALID_OPCODE -#define ARGI_QWORD_OP ARGI_INVALID_OPCODE -#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE -#define ARGI_BUFFER_OP ARGI_INVALID_OPCODE -#define ARGI_PACKAGE_OP ARGI_INVALID_OPCODE -#define ARGI_VAR_PACKAGE_OP ARGI_INVALID_OPCODE -#define ARGI_METHOD_OP ARGI_INVALID_OPCODE -#define ARGI_LOCAL0 ARG_NONE -#define ARGI_LOCAL1 ARG_NONE -#define ARGI_LOCAL2 ARG_NONE -#define ARGI_LOCAL3 ARG_NONE -#define ARGI_LOCAL4 ARG_NONE -#define ARGI_LOCAL5 ARG_NONE -#define ARGI_LOCAL6 ARG_NONE -#define ARGI_LOCAL7 ARG_NONE -#define ARGI_ARG0 ARG_NONE -#define ARGI_ARG1 ARG_NONE -#define ARGI_ARG2 ARG_NONE -#define ARGI_ARG3 ARG_NONE -#define ARGI_ARG4 ARG_NONE -#define ARGI_ARG5 ARG_NONE -#define ARGI_ARG6 ARG_NONE -#define ARGI_STORE_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_TARGETREF) -#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF) -#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) -#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) -#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) -#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF) -#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REFERENCE) -#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) -#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER) -#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) -#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) -#define ARGI_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) -#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET) -#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFERSTRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE -#define ARGI_IF_OP ARGI_INVALID_OPCODE -#define ARGI_ELSE_OP ARGI_INVALID_OPCODE -#define ARGI_WHILE_OP ARGI_INVALID_OPCODE -#define ARGI_NOOP_OP ARG_NONE -#define ARGI_RETURN_OP ARGI_INVALID_OPCODE -#define ARGI_BREAK_OP ARG_NONE -#define ARGI_BREAK_POINT_OP ARG_NONE -#define ARGI_ONES_OP ARG_NONE -#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE -#define ARGI_EVENT_OP ARGI_INVALID_OPCODE -#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) -#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_TARGETREF) -#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION, ARGI_TARGETREF) -#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER) -#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) -#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) -#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) -#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) -#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) -#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) -#define ARGI_REVISION_OP ARG_NONE -#define ARGI_DEBUG_OP ARG_NONE -#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_DEF_FIELD_OP ARGI_INVALID_OPCODE -#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE -#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE -#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE -#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE -#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE -#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE -#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING) -#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE -#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE -#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE -#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE -#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE -#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE -#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE - - -/* - * Master Opcode information table. A summary of everything we know about each opcode, all in one place. - */ - - -static ACPI_OPCODE_INFO aml_op_info[] = -{ -/* Index Opcode Type Class Has Arguments? Name Parser Args Interpreter Args */ - -/* 00 */ /* AML_ZERO_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Zero", ARGP_ZERO_OP, ARGI_ZERO_OP), -/* 01 */ /* AML_ONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "One", ARGP_ONE_OP, ARGI_ONE_OP), -/* 02 */ /* AML_ALIAS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP), -/* 03 */ /* AML_NAME_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Name", ARGP_NAME_OP, ARGI_NAME_OP), -/* 04 */ /* AML_BYTE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Byte_const", ARGP_BYTE_OP, ARGI_BYTE_OP), -/* 05 */ /* AML_WORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Word_const", ARGP_WORD_OP, ARGI_WORD_OP), -/* 06 */ /* AML_DWORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Dword_const", ARGP_DWORD_OP, ARGI_DWORD_OP), -/* 07 */ /* AML_STRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "String", ARGP_STRING_OP, ARGI_STRING_OP), -/* 08 */ /* AML_SCOPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP), -/* 09 */ /* AML_BUFFER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP), -/* 0A */ /* AML_PACKAGE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP), -/* 0B */ /* AML_METHOD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Method", ARGP_METHOD_OP, ARGI_METHOD_OP), -/* 0C */ /* AML_LOCAL0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local0", ARGP_LOCAL0, ARGI_LOCAL0), -/* 0D */ /* AML_LOCAL1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local1", ARGP_LOCAL1, ARGI_LOCAL1), -/* 0E */ /* AML_LOCAL2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local2", ARGP_LOCAL2, ARGI_LOCAL2), -/* 0F */ /* AML_LOCAL3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local3", ARGP_LOCAL3, ARGI_LOCAL3), -/* 10 */ /* AML_LOCAL4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local4", ARGP_LOCAL4, ARGI_LOCAL4), -/* 11 */ /* AML_LOCAL5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local5", ARGP_LOCAL5, ARGI_LOCAL5), -/* 12 */ /* AML_LOCAL6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local6", ARGP_LOCAL6, ARGI_LOCAL6), -/* 13 */ /* AML_LOCAL7 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local7", ARGP_LOCAL7, ARGI_LOCAL7), -/* 14 */ /* AML_ARG0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg0", ARGP_ARG0, ARGI_ARG0), -/* 15 */ /* AML_ARG1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg1", ARGP_ARG1, ARGI_ARG1), -/* 16 */ /* AML_ARG2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg2", ARGP_ARG2, ARGI_ARG2), -/* 17 */ /* AML_ARG3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg3", ARGP_ARG3, ARGI_ARG3), -/* 18 */ /* AML_ARG4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg4", ARGP_ARG4, ARGI_ARG4), -/* 19 */ /* AML_ARG5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg5", ARGP_ARG5, ARGI_ARG5), -/* 1_a */ /* AML_ARG6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg6", ARGP_ARG6, ARGI_ARG6), -/* 1_b */ /* AML_STORE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Store", ARGP_STORE_OP, ARGI_STORE_OP), -/* 1_c */ /* AML_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Ref_of", ARGP_REF_OF_OP, ARGI_REF_OF_OP), -/* 1_d */ /* AML_ADD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Add", ARGP_ADD_OP, ARGI_ADD_OP), -/* 1_e */ /* AML_CONCAT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP), -/* 1_f */ /* AML_SUBTRACT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP), -/* 20 */ /* AML_INCREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP), -/* 21 */ /* AML_DECREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP), -/* 22 */ /* AML_MULTIPLY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP), -/* 23 */ /* AML_DIVIDE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP), -/* 24 */ /* AML_SHIFT_LEFT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Shift_left", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP), -/* 25 */ /* AML_SHIFT_RIGHT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Shift_right", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP), -/* 26 */ /* AML_BIT_AND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP), -/* 27 */ /* AML_BIT_NAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP), -/* 28 */ /* AML_BIT_OR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP), -/* 29 */ /* AML_BIT_NOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP), -/* 2_a */ /* AML_BIT_XOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP), -/* 2_b */ /* AML_BIT_NOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP), -/* 2_c */ /* AML_FIND_SET_LEFT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Find_set_left_bit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP), -/* 2_d */ /* AML_FIND_SET_RIGHT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Find_set_right_bit", ARGP_FIND_SET_RIGHT_BIT_OP, ARGI_FIND_SET_RIGHT_BIT_OP), -/* 2_e */ /* AML_DEREF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Deref_of", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP), -/* 2_f */ /* AML_NOTIFY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC1| AML_HAS_ARGS, "Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP), -/* 30 */ /* AML_SIZE_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Size_of", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP), -/* 31 */ /* AML_INDEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_INDEX| AML_HAS_ARGS, "Index", ARGP_INDEX_OP, ARGI_INDEX_OP), -/* 32 */ /* AML_MATCH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MATCH| AML_HAS_ARGS, "Match", ARGP_MATCH_OP, ARGI_MATCH_OP), -/* 33 */ /* AML_DWORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_dWord_field", ARGP_DWORD_FIELD_OP, ARGI_DWORD_FIELD_OP), -/* 34 */ /* AML_WORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_word_field", ARGP_WORD_FIELD_OP, ARGI_WORD_FIELD_OP), -/* 35 */ /* AML_BYTE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_byte_field", ARGP_BYTE_FIELD_OP, ARGI_BYTE_FIELD_OP), -/* 36 */ /* AML_BIT_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_bit_field", ARGP_BIT_FIELD_OP, ARGI_BIT_FIELD_OP), -/* 37 */ /* AML_TYPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Object_type", ARGP_TYPE_OP, ARGI_TYPE_OP), -/* 38 */ /* AML_LAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LAnd", ARGP_LAND_OP, ARGI_LAND_OP), -/* 39 */ /* AML_LOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LOr", ARGP_LOR_OP, ARGI_LOR_OP), -/* 3_a */ /* AML_LNOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "LNot", ARGP_LNOT_OP, ARGI_LNOT_OP), -/* 3_b */ /* AML_LEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP), -/* 3_c */ /* AML_LGREATER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP), -/* 3_d */ /* AML_LLESS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LLess", ARGP_LLESS_OP, ARGI_LLESS_OP), -/* 3_e */ /* AML_IF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "If", ARGP_IF_OP, ARGI_IF_OP), -/* 3_f */ /* AML_ELSE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Else", ARGP_ELSE_OP, ARGI_ELSE_OP), -/* 40 */ /* AML_WHILE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "While", ARGP_WHILE_OP, ARGI_WHILE_OP), -/* 41 */ /* AML_NOOP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Noop", ARGP_NOOP_OP, ARGI_NOOP_OP), -/* 42 */ /* AML_RETURN_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Return", ARGP_RETURN_OP, ARGI_RETURN_OP), -/* 43 */ /* AML_BREAK_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Break", ARGP_BREAK_OP, ARGI_BREAK_OP), -/* 44 */ /* AML_BREAK_POINT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Break_point", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP), -/* 45 */ /* AML_ONES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Ones", ARGP_ONES_OP, ARGI_ONES_OP), - -/* Prefixed opcodes (Two-byte opcodes with a prefix op) */ - -/* 46 */ /* AML_MUTEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP), -/* 47 */ /* AML_EVENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_NO_ARGS, "Event", ARGP_EVENT_OP, ARGI_EVENT_OP), -/* 48 */ /* AML_COND_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Cond_ref_of", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP), -/* 49 */ /* AML_CREATE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_field", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP), -/* 4_a */ /* AML_LOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Load", ARGP_LOAD_OP, ARGI_LOAD_OP), -/* 4_b */ /* AML_STALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Stall", ARGP_STALL_OP, ARGI_STALL_OP), -/* 4_c */ /* AML_SLEEP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP), -/* 4_d */ /* AML_ACQUIRE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_s| AML_HAS_ARGS, "Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP), -/* 4_e */ /* AML_SIGNAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP), -/* 4_f */ /* AML_WAIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_s| AML_HAS_ARGS, "Wait", ARGP_WAIT_OP, ARGI_WAIT_OP), -/* 50 */ /* AML_RESET_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Reset", ARGP_RESET_OP, ARGI_RESET_OP), -/* 51 */ /* AML_RELEASE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP), -/* 52 */ /* AML_FROM_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "From_bCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP), -/* 53 */ /* AML_TO_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "To_bCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP), -/* 54 */ /* AML_UNLOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP), -/* 55 */ /* AML_REVISION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Revision", ARGP_REVISION_OP, ARGI_REVISION_OP), -/* 56 */ /* AML_DEBUG_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP), -/* 57 */ /* AML_FATAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_FATAL| AML_HAS_ARGS, "Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP), -/* 58 */ /* AML_REGION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Op_region", ARGP_REGION_OP, ARGI_REGION_OP), -/* 59 */ /* AML_DEF_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Field", ARGP_DEF_FIELD_OP, ARGI_DEF_FIELD_OP), -/* 5_a */ /* AML_DEVICE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP), -/* 5_b */ /* AML_PROCESSOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP), -/* 5_c */ /* AML_POWER_RES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Power_resource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP), -/* 5_d */ /* AML_THERMAL_ZONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Thermal_zone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP), -/* 5_e */ /* AML_INDEX_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Index_field", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP), -/* 5_f */ /* AML_BANK_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Bank_field", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP), - -/* Internal opcodes that map to invalid AML opcodes */ - -/* 60 */ /* AML_LNOTEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LNot_equal", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP), -/* 61 */ /* AML_LLESSEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LLess_equal", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP), -/* 62 */ /* AML_LGREATEREQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LGreater_equal", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP), -/* 63 */ /* AML_NAMEPATH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Name_path", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP), -/* 64 */ /* AML_METHODCALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_CALL| AML_HAS_ARGS, "Method_call", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP), -/* 65 */ /* AML_BYTELIST_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Byte_list", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP), -/* 66 */ /* AML_RESERVEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "Reserved_field", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP), -/* 67 */ /* AML_NAMEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "Named_field", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP), -/* 68 */ /* AML_ACCESSFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "Access_field", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP), -/* 69 */ /* AML_STATICSTRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "Static_string", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP), -/* 6_a */ /* AML_RETURN_VALUE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RETURN| AML_HAS_ARGS, "[Return Value]", ARG_NONE, ARG_NONE), -/* 6_b */ /* UNKNOWN OPCODES */ OP_INFO_ENTRY (ACPI_OP_TYPE_UNKNOWN | OPTYPE_BOGUS| AML_HAS_ARGS, "UNKNOWN_OP!", ARG_NONE, ARG_NONE), -/* 6_c */ /* ASCII CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_ASCII | OPTYPE_BOGUS| AML_HAS_ARGS, "ASCII_ONLY!", ARG_NONE, ARG_NONE), -/* 6_d */ /* PREFIX CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_PREFIX | OPTYPE_BOGUS| AML_HAS_ARGS, "PREFIX_ONLY!", ARG_NONE, ARG_NONE), - - -/* ACPI 2.0 (new) opcodes */ - -/* 6_e */ /* AML_QWORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Qword_const", ARGP_QWORD_OP, ARGI_QWORD_OP), -/* 6_f */ /* AML_VAR_PACKAGE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Var_package", ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP), -/* 70 */ /* AML_CONCAT_RES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Concat_res", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP), -/* 71 */ /* AML_MOD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Mod", ARGP_MOD_OP, ARGI_MOD_OP), -/* 72 */ /* AML_QWORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_qWord_field", ARGP_QWORD_FIELD_OP, ARGI_QWORD_FIELD_OP), -/* 73 */ /* AML_TO_BUFFER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "To_buffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP), -/* 74 */ /* AML_TO_DEC_STR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "To_dec_string", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP), -/* 75 */ /* AML_TO_HEX_STR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "To_hex_string", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP), -/* 76 */ /* AML_TO_INTEGER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "To_integer", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP), -/* 77 */ /* AML_TO_STRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "To_string", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP), -/* 78 */ /* AML_COPY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Copy", ARGP_COPY_OP, ARGI_COPY_OP), -/* 79 */ /* AML_MID_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Mid", ARGP_MID_OP, ARGI_MID_OP), -/* 7_a */ /* AML_CONTINUE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP), -/* 7_b */ /* AML_LOAD_TABLE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Load_table", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP), -/* 7_c */ /* AML_DATA_REGION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Data_op_region", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP), - -}; - -/* - * This table is directly indexed by the opcodes, and returns an - * index into the table above - */ - -static u8 aml_short_op_info_index[256] = -{ -/* 0 1 2 3 4 5 6 7 */ -/* 8 9 A B C D E F */ -/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, -/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, -/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, -/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, -/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, _UNK, -/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, -/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, -/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, -/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, -/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, -/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, -/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, -/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, -/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, -/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, -/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, -/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, -/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, -/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, -/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, -}; - - -static u8 aml_long_op_info_index[NUM_EXTENDED_OPCODE] = -{ -/* 0 1 2 3 4 5 6 7 */ -/* 8 9 A B C D E F */ -/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, -/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, -/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, -/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x30 */ 0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, -/* 0x88 */ 0x7C, -}; - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_opcode_info - * - * PARAMETERS: Opcode - The AML opcode - * - * RETURN: A pointer to the info about the opcode. NULL if the opcode was - * not found in the table. - * - * DESCRIPTION: Find AML opcode description based on the opcode. - * NOTE: This procedure must ALWAYS return a valid pointer! - * - ******************************************************************************/ - -ACPI_OPCODE_INFO * -acpi_ps_get_opcode_info ( - u16 opcode) -{ - ACPI_OPCODE_INFO *op_info; - u8 upper_opcode; - u8 lower_opcode; - - - /* Split the 16-bit opcode into separate bytes */ - - upper_opcode = (u8) (opcode >> 8); - lower_opcode = (u8) opcode; - - /* Default is "unknown opcode" */ - - op_info = &aml_op_info [_UNK]; - - - /* - * Detect normal 8-bit opcode or extended 16-bit opcode - */ - - switch (upper_opcode) { - case 0: - - /* Simple (8-bit) opcode: 0-255, can't index beyond table */ - - op_info = &aml_op_info [aml_short_op_info_index [lower_opcode]]; - break; - - - case AML_EXTOP: - - /* Extended (16-bit, prefix+opcode) opcode */ - - if (lower_opcode <= MAX_EXTENDED_OPCODE) { - op_info = &aml_op_info [aml_long_op_info_index [lower_opcode]]; - } - break; - - - case AML_LNOT_OP: - - /* This case is for the bogus opcodes LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL */ - /* TBD: [Investigate] remove this case? */ - - break; - - - default: - - break; - } - - - /* Get the Op info pointer for this opcode */ - - return (op_info); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_opcode_name - * - * PARAMETERS: Opcode - The AML opcode - * - * RETURN: A pointer to the name of the opcode (ASCII String) - * Note: Never returns NULL. - * - * DESCRIPTION: Translate an opcode into a human-readable string - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_ps_get_opcode_name ( - u16 opcode) -{ - ACPI_OPCODE_INFO *op; - - - op = acpi_ps_get_opcode_info (opcode); - - /* Always guaranteed to return a valid pointer */ - - return ("AE_NOT_CONFIGURED"); -} - - diff --git a/reactos/drivers/bus/acpi/parser/psparse.c b/reactos/drivers/bus/acpi/parser/psparse.c deleted file mode 100644 index 479756ad487..00000000000 --- a/reactos/drivers/bus/acpi/parser/psparse.c +++ /dev/null @@ -1,1223 +0,0 @@ -/****************************************************************************** - * - * Module Name: psparse - Parser top level AML parse routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -/* - * Parse the AML and build an operation tree as most interpreters, - * like Perl, do. Parsing is done by hand rather than with a YACC - * generated parser to tightly constrain stack and dynamic memory - * usage. At the same time, parsing is kept flexible and the code - * fairly compact by parsing based on a list of AML opcode - * templates in Aml_op_info[] - */ - -#include - -#define _COMPONENT ACPI_PARSER - MODULE_NAME ("psparse") - - -u32 acpi_gbl_depth = 0; -extern u32 acpi_gbl_scope_depth; - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_peek_opcode - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) - * - ******************************************************************************/ - -static u32 -acpi_ps_get_opcode_size ( - u32 opcode) -{ - - /* Extended (2-byte) opcode if > 255 */ - - if (opcode > 0x00FF) { - return (2); - } - - /* Otherwise, just a single byte opcode */ - - return (1); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_peek_opcode - * - * PARAMETERS: Parser_state - A parser state object - * - * RETURN: Status - * - * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) - * - ******************************************************************************/ - -u16 -acpi_ps_peek_opcode ( - ACPI_PARSE_STATE *parser_state) -{ - u8 *aml; - u16 opcode; - - - aml = parser_state->aml; - opcode = (u16) GET8 (aml); - - aml++; - - - /* - * Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL. - * These opcodes are no longer recognized. Instead, they are broken into - * two opcodes. - * - * - * if (Opcode == AML_EXTOP - * || (Opcode == AML_LNOT - * && (GET8 (Acpi_aml) == AML_LEQUAL - * || GET8 (Acpi_aml) == AML_LGREATER - * || GET8 (Acpi_aml) == AML_LLESS))) - * - * extended Opcode, !=, <=, or >= - */ - - if (opcode == AML_EXTOP) { - /* Extended opcode */ - - opcode = (u16) ((opcode << 8) | GET8 (aml)); - aml++; - } - - /* don't convert bare name to a namepath */ - - return (opcode); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_create_state - * - * PARAMETERS: Acpi_aml - Acpi_aml code pointer - * Acpi_aml_size - Length of AML code - * - * RETURN: A new parser state object - * - * DESCRIPTION: Create and initialize a new parser state object - * - ******************************************************************************/ - -ACPI_PARSE_STATE * -acpi_ps_create_state ( - u8 *aml, - u32 aml_size) -{ - ACPI_PARSE_STATE *parser_state; - - - parser_state = acpi_cm_callocate (sizeof (ACPI_PARSE_STATE)); - if (!parser_state) { - return (NULL); - } - - parser_state->aml = aml; - parser_state->aml_end = aml + aml_size; - parser_state->pkg_end = parser_state->aml_end; - parser_state->aml_start = aml; - - - return (parser_state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_find_object - * - * PARAMETERS: Opcode - Current opcode - * Parser_state - Current state - * Walk_state - Current state - * *Op - Where found/new op is returned - * - * RETURN: Status - * - * DESCRIPTION: Find a named object. Two versions - one to search the parse - * tree (for parser-only applications such as acpidump), another - * to search the ACPI internal namespace (the parse tree may no - * longer exist) - * - ******************************************************************************/ - -#ifdef PARSER_ONLY - -ACPI_STATUS -acpi_ps_find_object ( - u16 opcode, - ACPI_PARSE_OBJECT *op, - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT **out_op) -{ - NATIVE_CHAR *path; - - - /* We are only interested in opcodes that have an associated name */ - - if (!acpi_ps_is_named_op (opcode)) { - *out_op = op; - return (AE_OK); - } - - /* Find the name in the parse tree */ - - path = acpi_ps_get_next_namestring (walk_state->parser_state); - - *out_op = acpi_ps_find (acpi_ps_get_parent_scope (walk_state->parser_state), - path, opcode, 1); - - if (!(*out_op)) { - return (AE_NOT_FOUND); - } - - return (AE_OK); -} - -#endif - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_complete_this_op - * - * PARAMETERS: Walk_state - Current State - * Op - Op to complete - * - * RETURN: TRUE if Op and subtree was deleted - * - * DESCRIPTION: Perform any cleanup at the completion of an Op. - * - ******************************************************************************/ - -static u8 -acpi_ps_complete_this_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op) -{ -#ifndef PARSER_ONLY - ACPI_PARSE_OBJECT *prev; - ACPI_PARSE_OBJECT *next; - ACPI_OPCODE_INFO *op_info; - ACPI_OPCODE_INFO *parent_info; - u32 opcode_class; - ACPI_PARSE_OBJECT *replacement_op = NULL; - - - op_info = acpi_ps_get_opcode_info (op->opcode); - opcode_class = ACPI_GET_OP_CLASS (op_info); - - - /* Delete this op and the subtree below it if asked to */ - - if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) && - (opcode_class != OPTYPE_CONSTANT) && - (opcode_class != OPTYPE_LITERAL) && - (opcode_class != OPTYPE_LOCAL_VARIABLE) && - (opcode_class != OPTYPE_METHOD_ARGUMENT) && - (opcode_class != OPTYPE_DATA_TERM) && - (op->opcode != AML_NAMEPATH_OP)) { - /* Make sure that we only delete this subtree */ - - if (op->parent) { - /* - * Check if we need to replace the operator and its subtree - * with a return value op (placeholder op) - */ - - parent_info = acpi_ps_get_opcode_info (op->parent->opcode); - - switch (ACPI_GET_OP_CLASS (parent_info)) { - case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ - break; - - case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ - - /* - * These opcodes contain Term_arg operands. The current - * op must be replace by a placeholder return op - */ - - if ((op->parent->opcode == AML_REGION_OP) || - (op->parent->opcode == AML_CREATE_FIELD_OP) || - (op->parent->opcode == AML_BIT_FIELD_OP) || - (op->parent->opcode == AML_BYTE_FIELD_OP) || - (op->parent->opcode == AML_WORD_FIELD_OP) || - (op->parent->opcode == AML_DWORD_FIELD_OP) || - (op->parent->opcode == AML_QWORD_FIELD_OP)) { - replacement_op = acpi_ps_alloc_op (AML_RETURN_VALUE_OP); - if (!replacement_op) { - return (FALSE); - } - } - - break; - - default: - replacement_op = acpi_ps_alloc_op (AML_RETURN_VALUE_OP); - if (!replacement_op) { - return (FALSE); - } - } - - /* We must unlink this op from the parent tree */ - - prev = op->parent->value.arg; - if (prev == op) { - /* This op is the first in the list */ - - if (replacement_op) { - replacement_op->parent = op->parent; - replacement_op->value.arg = NULL; - op->parent->value.arg = replacement_op; - replacement_op->next = op->next; - } - else { - op->parent->value.arg = op->next; - } - } - - /* Search the parent list */ - - else while (prev) { - /* Traverse all siblings in the parent's argument list */ - - next = prev->next; - if (next == op) { - if (replacement_op) { - replacement_op->parent = op->parent; - replacement_op->value.arg = NULL; - prev->next = replacement_op; - replacement_op->next = op->next; - next = NULL; - } - else { - prev->next = op->next; - next = NULL; - } - } - - prev = next; - } - - } - - /* Now we can actually delete the subtree rooted at op */ - - acpi_ps_delete_parse_tree (op); - - return (TRUE); - } - - return (FALSE); - -#else - return (FALSE); -#endif -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_next_parse_state - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: - * - * DESCRIPTION: - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_ps_next_parse_state ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - ACPI_STATUS callback_status) -{ - ACPI_PARSE_STATE *parser_state = walk_state->parser_state; - ACPI_STATUS status = AE_CTRL_PENDING; - u8 *start; - u32 package_length; - - - switch (callback_status) { - case AE_CTRL_TERMINATE: - - /* - * A control method was terminated via a RETURN statement. - * The walk of this method is complete. - */ - - parser_state->aml = parser_state->aml_end; - status = AE_CTRL_TERMINATE; - break; - - - case AE_CTRL_PENDING: - - /* - * Predicate of a WHILE was true and the loop just completed an - * execution. Go back to the start of the loop and reevaluate the - * predicate. - */ -/* Walk_state->Control_state->Common.State = - CONTROL_PREDICATE_EXECUTING;*/ - - /* TBD: How to handle a break within a while. */ - /* This code attempts it */ - - parser_state->aml = walk_state->aml_last_while; - break; - - - case AE_CTRL_TRUE: - /* - * Predicate of an IF was true, and we are at the matching ELSE. - * Just close out this package - * - * Note: Parser_state->Aml is modified by the package length procedure - * TBD: [Investigate] perhaps it shouldn't, too much trouble - */ - start = parser_state->aml; - package_length = acpi_ps_get_next_package_length (parser_state); - parser_state->aml = start + package_length; - break; - - - case AE_CTRL_FALSE: - - /* - * Either an IF/WHILE Predicate was false or we encountered a BREAK - * opcode. In both cases, we do not execute the rest of the - * package; We simply close out the parent (finishing the walk of - * this branch of the tree) and continue execution at the parent - * level. - */ - - parser_state->aml = parser_state->scope->parse_scope.pkg_end; - - /* In the case of a BREAK, just force a predicate (if any) to FALSE */ - - walk_state->control_state->common.value = FALSE; - status = AE_CTRL_END; - break; - - - case AE_CTRL_TRANSFER: - - /* - * A method call (invocation) -- transfer control - */ - status = AE_CTRL_TRANSFER; - walk_state->prev_op = op; - walk_state->method_call_op = op; - walk_state->method_call_node = (op->value.arg)->node; - - /* Will return value (if any) be used by the caller? */ - - walk_state->return_used = acpi_ds_is_result_used (op, walk_state); - break; - - - default: - status = callback_status; - if ((callback_status & AE_CODE_MASK) == AE_CODE_CONTROL) { - status = AE_OK; - } - break; - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_parse_loop - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: Status - * - * DESCRIPTION: Parse AML (pointed to by the current parser state) and return - * a tree of ops. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ps_parse_loop ( - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - ACPI_PARSE_OBJECT *op = NULL; /* current op */ - ACPI_OPCODE_INFO *op_info; - ACPI_PARSE_OBJECT *arg = NULL; - ACPI_PARSE2_OBJECT *deferred_op; - u32 arg_count; /* push for fixed or var args */ - u32 arg_types = 0; - ACPI_PTRDIFF aml_offset; - u16 opcode; - ACPI_PARSE_OBJECT pre_op; - ACPI_PARSE_STATE *parser_state; - u8 *aml_op_start; - - - parser_state = walk_state->parser_state; - -#ifndef PARSER_ONLY - if (walk_state->walk_type & WALK_METHOD_RESTART) { - /* We are restarting a preempted control method */ - - if (acpi_ps_has_completed_scope (parser_state)) { - /* - * We must check if a predicate to an IF or WHILE statement - * was just completed - */ - if ((parser_state->scope->parse_scope.op) && - ((parser_state->scope->parse_scope.op->opcode == AML_IF_OP) || - (parser_state->scope->parse_scope.op->opcode == AML_WHILE_OP)) && - (walk_state->control_state) && - (walk_state->control_state->common.state == - CONTROL_PREDICATE_EXECUTING)) { - - /* - * A predicate was just completed, get the value of the - * predicate and branch based on that value - */ - - status = acpi_ds_get_predicate_value (walk_state, NULL, TRUE); - if (ACPI_FAILURE (status) && - ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { - return (status); - } - - status = acpi_ps_next_parse_state (walk_state, op, status); - } - - acpi_ps_pop_scope (parser_state, &op, &arg_types, &arg_count); - } - - else if (walk_state->prev_op) { - /* We were in the middle of an op */ - - op = walk_state->prev_op; - arg_types = walk_state->prev_arg_types; - } - } -#endif - - /* - * Iterative parsing loop, while there is more aml to process: - */ - while ((parser_state->aml < parser_state->aml_end) || (op)) { - if (!op) { - /* Get the next opcode from the AML stream */ - - aml_op_start = parser_state->aml; - aml_offset = parser_state->aml - parser_state->aml_start; - opcode = acpi_ps_peek_opcode (parser_state); - - /* - * First cut to determine what we have found: - * 1) A valid AML opcode - * 2) A name string - * 3) An unknown/invalid opcode - */ - - op_info = acpi_ps_get_opcode_info (opcode); - switch (ACPI_GET_OP_TYPE (op_info)) { - case ACPI_OP_TYPE_OPCODE: - - /* Found opcode info, this is a normal opcode */ - - parser_state->aml += acpi_ps_get_opcode_size (opcode); - arg_types = op_info->parse_args; - break; - - case ACPI_OP_TYPE_ASCII: - case ACPI_OP_TYPE_PREFIX: - /* - * Starts with a valid prefix or ASCII char, this is a name - * string. Convert the bare name string to a namepath. - */ - - opcode = AML_NAMEPATH_OP; - arg_types = ARGP_NAMESTRING; - break; - - case ACPI_OP_TYPE_UNKNOWN: - - /* The opcode is unrecognized. Just skip unknown opcodes */ - - /* Assume one-byte bad opcode */ - - parser_state->aml++; - continue; - } - - - /* Create Op structure and append to parent's argument list */ - - if (acpi_ps_is_named_op (opcode)) { - pre_op.value.arg = NULL; - pre_op.opcode = opcode; - - while (GET_CURRENT_ARG_TYPE (arg_types) != ARGP_NAME) { - arg = acpi_ps_get_next_arg (parser_state, - GET_CURRENT_ARG_TYPE (arg_types), - &arg_count); - acpi_ps_append_arg (&pre_op, arg); - INCREMENT_ARG_LIST (arg_types); - } - - - /* We know that this arg is a name, move to next arg */ - - INCREMENT_ARG_LIST (arg_types); - - if (walk_state->descending_callback != NULL) { - /* - * Find the object. This will either insert the object into - * the namespace or simply look it up - */ - status = walk_state->descending_callback (opcode, NULL, walk_state, &op); - if (op == NULL) { - continue; - } - status = acpi_ps_next_parse_state (walk_state, op, status); - if (status == AE_CTRL_PENDING) { - status = AE_OK; - goto close_this_op; - } - - if (ACPI_FAILURE (status)) { - goto close_this_op; - } - } - - acpi_ps_append_arg (op, pre_op.value.arg); - acpi_gbl_depth++; - - - if (op->opcode == AML_REGION_OP) { - deferred_op = acpi_ps_to_extended_op (op); - if (deferred_op) { - /* - * Defer final parsing of an Operation_region body, - * because we don't have enough info in the first pass - * to parse it correctly (i.e., there may be method - * calls within the Term_arg elements of the body. - * - * However, we must continue parsing because - * the opregion is not a standalone package -- - * we don't know where the end is at this point. - * - * (Length is unknown until parse of the body complete) - */ - - deferred_op->data = aml_op_start; - deferred_op->length = 0; - } - } - } - - - else { - /* Not a named opcode, just allocate Op and append to parent */ - - op = acpi_ps_alloc_op (opcode); - if (!op) { - return (AE_NO_MEMORY); - } - - - if ((op->opcode == AML_CREATE_FIELD_OP) || - (op->opcode == AML_BIT_FIELD_OP) || - (op->opcode == AML_BYTE_FIELD_OP) || - (op->opcode == AML_WORD_FIELD_OP) || - (op->opcode == AML_DWORD_FIELD_OP)) { - /* - * Backup to beginning of Create_xXXfield declaration - * Body_length is unknown until we parse the body - */ - deferred_op = (ACPI_PARSE2_OBJECT *) op; - - deferred_op->data = aml_op_start; - deferred_op->length = 0; - } - - acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); - - if ((walk_state->descending_callback != NULL)) { - /* - * Find the object. This will either insert the object into - * the namespace or simply look it up - */ - status = walk_state->descending_callback (opcode, op, walk_state, &op); - status = acpi_ps_next_parse_state (walk_state, op, status); - if (status == AE_CTRL_PENDING) { - status = AE_OK; - goto close_this_op; - } - - if (ACPI_FAILURE (status)) { - goto close_this_op; - } - } - } - - op->aml_offset = aml_offset; - - } - - - /* Start Arg_count at zero because we don't know if there are any args yet */ - - arg_count = 0; - - - if (arg_types) /* Are there any arguments that must be processed? */ { - /* get arguments */ - - switch (op->opcode) { - case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ - case AML_WORD_OP: /* AML_WORDDATA_ARG */ - case AML_DWORD_OP: /* AML_DWORDATA_ARG */ - case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ - - /* fill in constant or string argument directly */ - - acpi_ps_get_next_simple_arg (parser_state, - GET_CURRENT_ARG_TYPE (arg_types), op); - break; - - case AML_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ - - acpi_ps_get_next_namepath (parser_state, op, &arg_count, 1); - arg_types = 0; - break; - - - default: - - /* Op is not a constant or string, append each argument */ - - while (GET_CURRENT_ARG_TYPE (arg_types) && !arg_count) { - aml_offset = parser_state->aml - parser_state->aml_start; - arg = acpi_ps_get_next_arg (parser_state, - GET_CURRENT_ARG_TYPE (arg_types), - &arg_count); - if (arg) { - arg->aml_offset = aml_offset; - acpi_ps_append_arg (op, arg); - } - - INCREMENT_ARG_LIST (arg_types); - } - - - /* For a method, save the length and address of the body */ - - if (op->opcode == AML_METHOD_OP) { - deferred_op = acpi_ps_to_extended_op (op); - if (deferred_op) { - /* - * Skip parsing of control method or opregion body, - * because we don't have enough info in the first pass - * to parse them correctly. - */ - - deferred_op->data = parser_state->aml; - deferred_op->length = parser_state->pkg_end - - parser_state->aml; - - /* - * Skip body of method. For Op_regions, we must continue - * parsing because the opregion is not a standalone - * package (We don't know where the end is). - */ - parser_state->aml = parser_state->pkg_end; - arg_count = 0; - } - } - - break; - } - } - - - /* - * Zero Arg_count means that all arguments for this op have been processed - */ - if (!arg_count) { - /* completed Op, prepare for next */ - - if (acpi_ps_is_named_op (op->opcode)) { - if (acpi_gbl_depth) { - acpi_gbl_depth--; - } - - if (op->opcode == AML_REGION_OP) { - deferred_op = acpi_ps_to_extended_op (op); - if (deferred_op) { - /* - * Skip parsing of control method or opregion body, - * because we don't have enough info in the first pass - * to parse them correctly. - * - * Completed parsing an Op_region declaration, we now - * know the length. - */ - - deferred_op->length = parser_state->aml - - deferred_op->data; - } - } - } - - if ((op->opcode == AML_CREATE_FIELD_OP) || - (op->opcode == AML_BIT_FIELD_OP) || - (op->opcode == AML_BYTE_FIELD_OP) || - (op->opcode == AML_WORD_FIELD_OP) || - (op->opcode == AML_DWORD_FIELD_OP) || - (op->opcode == AML_QWORD_FIELD_OP)) { - /* - * Backup to beginning of Create_xXXfield declaration (1 for - * Opcode) - * - * Body_length is unknown until we parse the body - */ - deferred_op = (ACPI_PARSE2_OBJECT *) op; - deferred_op->length = parser_state->aml - deferred_op->data; - } - - /* This op complete, notify the dispatcher */ - - if (walk_state->ascending_callback != NULL) { - status = walk_state->ascending_callback (walk_state, op); - status = acpi_ps_next_parse_state (walk_state, op, status); - if (status == AE_CTRL_PENDING) { - status = AE_OK; - goto close_this_op; - } - } - - -close_this_op: - - /* - * Finished one argument of the containing scope - */ - parser_state->scope->parse_scope.arg_count--; - - /* Close this Op (may result in parse subtree deletion) */ - - if (acpi_ps_complete_this_op (walk_state, op)) { - op = NULL; - } - - - switch (status) { - case AE_OK: - break; - - - case AE_CTRL_TRANSFER: - - /* - * We are about to transfer to a called method. - */ - walk_state->prev_op = op; - walk_state->prev_arg_types = arg_types; - return (status); - break; - - - case AE_CTRL_END: - - acpi_ps_pop_scope (parser_state, &op, &arg_types, &arg_count); - - status = walk_state->ascending_callback (walk_state, op); - status = acpi_ps_next_parse_state (walk_state, op, status); - - acpi_ps_complete_this_op (walk_state, op); - op = NULL; - status = AE_OK; - break; - - - case AE_CTRL_TERMINATE: - - status = AE_OK; - - /* Clean up */ - do { - if (op) { - acpi_ps_complete_this_op (walk_state, op); - } - - acpi_ps_pop_scope (parser_state, &op, &arg_types, &arg_count); - } while (op); - - return (status); - break; - - - default: /* All other non-AE_OK status */ - - if (op == NULL) { - acpi_ps_pop_scope (parser_state, &op, &arg_types, &arg_count); - } - walk_state->prev_op = op; - walk_state->prev_arg_types = arg_types; - - /* - * TEMP: - */ - - return (status); - break; - } - - - /* This scope complete? */ - - if (acpi_ps_has_completed_scope (parser_state)) { - acpi_ps_pop_scope (parser_state, &op, &arg_types, &arg_count); - } - - else { - op = NULL; - } - - } - - - /* Arg_count is non-zero */ - - else { - /* complex argument, push Op and prepare for argument */ - - acpi_ps_push_scope (parser_state, op, arg_types, arg_count); - op = NULL; - } - - } /* while Parser_state->Aml */ - - - /* - * Complete the last Op (if not completed), and clear the scope stack. - * It is easily possible to end an AML "package" with an unbounded number - * of open scopes (such as when several AML blocks are closed with - * sequential closing braces). We want to terminate each one cleanly. - */ - - do { - if (op) { - if (walk_state->ascending_callback != NULL) { - status = walk_state->ascending_callback (walk_state, op); - status = acpi_ps_next_parse_state (walk_state, op, status); - if (status == AE_CTRL_PENDING) { - status = AE_OK; - goto close_this_op; - } - - if (status == AE_CTRL_TERMINATE) { - status = AE_OK; - - /* Clean up */ - do { - if (op) { - acpi_ps_complete_this_op (walk_state, op); - } - - acpi_ps_pop_scope (parser_state, &op, &arg_types, &arg_count); - - } while (op); - - return (status); - } - - else if (ACPI_FAILURE (status)) { - acpi_ps_complete_this_op (walk_state, op); - return (status); - } - } - - acpi_ps_complete_this_op (walk_state, op); - } - - acpi_ps_pop_scope (parser_state, &op, &arg_types, &arg_count); - - } while (op); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_parse_aml - * - * PARAMETERS: Start_scope - The starting point of the parse. Becomes the - * root of the parsed op tree. - * Aml - Pointer to the raw AML code to parse - * Aml_size - Length of the AML to parse - * - * RETURN: Status - * - * DESCRIPTION: Parse raw AML and return a tree of ops - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ps_parse_aml ( - ACPI_PARSE_OBJECT *start_scope, - u8 *aml, - u32 aml_size, - u32 parse_flags, - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **caller_return_desc, - ACPI_PARSE_DOWNWARDS descending_callback, - ACPI_PARSE_UPWARDS ascending_callback) -{ - ACPI_STATUS status; - ACPI_PARSE_STATE *parser_state; - ACPI_WALK_STATE *walk_state; - ACPI_WALK_LIST walk_list; - ACPI_NAMESPACE_NODE *node = NULL; - ACPI_WALK_LIST *prev_walk_list = acpi_gbl_current_walk_list; - ACPI_OPERAND_OBJECT *return_desc; - ACPI_OPERAND_OBJECT *mth_desc = NULL; - - - /* Create and initialize a new parser state */ - - parser_state = acpi_ps_create_state (aml, aml_size); - if (!parser_state) { - return (AE_NO_MEMORY); - } - - acpi_ps_init_scope (parser_state, start_scope); - - if (method_node) { - mth_desc = acpi_ns_get_attached_object (method_node); - } - - /* Create and initialize a new walk list */ - - walk_list.walk_state = NULL; - walk_list.acquired_mutex_list.prev = NULL; - walk_list.acquired_mutex_list.next = NULL; - - walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, parser_state->start_op, mth_desc, &walk_list); - if (!walk_state) { - status = AE_NO_MEMORY; - goto cleanup; - } - - walk_state->method_node = method_node; - walk_state->parser_state = parser_state; - walk_state->parse_flags = parse_flags; - walk_state->descending_callback = descending_callback; - walk_state->ascending_callback = ascending_callback; - - /* TBD: [Restructure] TEMP until we pass Walk_state to the interpreter - */ - acpi_gbl_current_walk_list = &walk_list; - - - if (method_node) { - parser_state->start_node = method_node; - walk_state->walk_type = WALK_METHOD; - - /* Push start scope on scope stack and make it current */ - - status = acpi_ds_scope_stack_push (method_node, ACPI_TYPE_METHOD, walk_state); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Init arguments if this is a control method */ - /* TBD: [Restructure] add walkstate as a param */ - - acpi_ds_method_data_init_args (params, MTH_NUM_ARGS, walk_state); - } - - else { - /* Setup the current scope */ - - node = parser_state->start_op->node; - parser_state->start_node = node; - - if (node) { - /* Push start scope on scope stack and make it current */ - - status = acpi_ds_scope_stack_push (node, node->type, - walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - } - } - - - status = AE_OK; - - /* - * Execute the walk loop as long as there is a valid Walk State. This - * handles nested control method invocations without recursion. - */ - - while (walk_state) { - if (ACPI_SUCCESS (status)) { - status = acpi_ps_parse_loop (walk_state); - } - - if (status == AE_CTRL_TRANSFER) { - /* - * A method call was detected. - * Transfer control to the called control method - */ - - status = acpi_ds_call_control_method (&walk_list, walk_state, NULL); - - /* - * If the transfer to the new method method call worked, a new walk - * state was created -- get it - */ - - walk_state = acpi_ds_get_current_walk_state (&walk_list); - continue; - } - - else if (status == AE_CTRL_TERMINATE) { - status = AE_OK; - } - - /* We are done with this walk, move on to the parent if any */ - - - walk_state = acpi_ds_pop_walk_state (&walk_list); - - /* Extract return value before we delete Walk_state */ - - return_desc = walk_state->return_desc; - - /* Reset the current scope to the beginning of scope stack */ - - acpi_ds_scope_stack_clear (walk_state); - - /* - * If we just returned from the execution of a control method, - * there's lots of cleanup to do - */ - - if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { - acpi_ds_terminate_control_method (walk_state); - } - - /* Delete this walk state and all linked control states */ - - acpi_ps_cleanup_scope (walk_state->parser_state); - acpi_cm_free (walk_state->parser_state); - acpi_ds_delete_walk_state (walk_state); - - /* Check if we have restarted a preempted walk */ - - walk_state = acpi_ds_get_current_walk_state (&walk_list); - if (walk_state && - ACPI_SUCCESS (status)) { - /* There is another walk state, restart it */ - - /* - * If the method returned value is not used by the parent, - * The object is deleted - */ - - acpi_ds_restart_control_method (walk_state, return_desc); - walk_state->walk_type |= WALK_METHOD_RESTART; - } - - /* - * Just completed a 1st-level method, save the final internal return - * value (if any) - */ - - else if (caller_return_desc) { - *caller_return_desc = return_desc; /* NULL if no return value */ - } - - else if (return_desc) { - /* Caller doesn't want it, must delete it */ - - acpi_cm_remove_reference (return_desc); - } - } - - - /* Normal exit */ - - acpi_aml_release_all_mutexes ((ACPI_OPERAND_OBJECT *) &walk_list.acquired_mutex_list); - acpi_gbl_current_walk_list = prev_walk_list; - return (status); - - -cleanup: - - /* Cleanup */ - - acpi_ds_delete_walk_state (walk_state); - acpi_ps_cleanup_scope (parser_state); - acpi_cm_free (parser_state); - - acpi_aml_release_all_mutexes ((ACPI_OPERAND_OBJECT *)&walk_list.acquired_mutex_list); - acpi_gbl_current_walk_list = prev_walk_list; - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/parser/psscope.c b/reactos/drivers/bus/acpi/parser/psscope.c deleted file mode 100644 index 77ff1b43f3f..00000000000 --- a/reactos/drivers/bus/acpi/parser/psscope.c +++ /dev/null @@ -1,263 +0,0 @@ -/****************************************************************************** - * - * Module Name: psscope - Parser scope stack management routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_PARSER - MODULE_NAME ("psscope") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_parent_scope - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: Pointer to an Op object - * - * DESCRIPTION: Get parent of current op being parsed - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT * -acpi_ps_get_parent_scope ( - ACPI_PARSE_STATE *parser_state) -{ - return (parser_state->scope->parse_scope.op); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_has_completed_scope - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: Boolean, TRUE = scope completed. - * - * DESCRIPTION: Is parsing of current argument complete? Determined by - * 1) AML pointer is at or beyond the end of the scope - * 2) The scope argument count has reached zero. - * - ******************************************************************************/ - -u8 -acpi_ps_has_completed_scope ( - ACPI_PARSE_STATE *parser_state) -{ - return ((u8) ((parser_state->aml >= parser_state->scope->parse_scope.arg_end || - !parser_state->scope->parse_scope.arg_count))); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_init_scope - * - * PARAMETERS: Parser_state - Current parser state object - * Root - the Root Node of this new scope - * - * RETURN: Status - * - * DESCRIPTION: Allocate and init a new scope object - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ps_init_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT *root_op) -{ - ACPI_GENERIC_STATE *scope; - - - scope = acpi_cm_create_generic_state (); - if (!scope) { - return (AE_NO_MEMORY); - } - - scope->parse_scope.op = root_op; - scope->parse_scope.arg_count = ACPI_VAR_ARGS; - scope->parse_scope.arg_end = parser_state->aml_end; - scope->parse_scope.pkg_end = parser_state->aml_end; - - parser_state->scope = scope; - parser_state->start_op = root_op; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_push_scope - * - * PARAMETERS: Parser_state - Current parser state object - * Op - Current op to be pushed - * Remaining_args - List of args remaining - * Arg_count - Fixed or variable number of args - * - * RETURN: Status - * - * DESCRIPTION: Push current op to begin parsing its argument - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ps_push_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT *op, - u32 remaining_args, - u32 arg_count) -{ - ACPI_GENERIC_STATE *scope; - - - scope = acpi_cm_create_generic_state (); - if (!scope) { - return (AE_NO_MEMORY); - } - - - scope->parse_scope.op = op; - scope->parse_scope.arg_list = remaining_args; - scope->parse_scope.arg_count = arg_count; - scope->parse_scope.pkg_end = parser_state->pkg_end; - - /* Push onto scope stack */ - - acpi_cm_push_generic_state (&parser_state->scope, scope); - - - if (arg_count == ACPI_VAR_ARGS) { - /* multiple arguments */ - - scope->parse_scope.arg_end = parser_state->pkg_end; - } - - else { - /* single argument */ - - scope->parse_scope.arg_end = ACPI_MAX_AML; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_pop_scope - * - * PARAMETERS: Parser_state - Current parser state object - * Op - Where the popped op is returned - * Arg_list - Where the popped "next argument" is - * returned - * Arg_count - Count of objects in Arg_list - * - * RETURN: Status - * - * DESCRIPTION: Return to parsing a previous op - * - ******************************************************************************/ - -void -acpi_ps_pop_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_PARSE_OBJECT **op, - u32 *arg_list, - u32 *arg_count) -{ - ACPI_GENERIC_STATE *scope = parser_state->scope; - - - /* - * Only pop the scope if there is in fact a next scope - */ - if (scope->common.next) { - scope = acpi_cm_pop_generic_state (&parser_state->scope); - - - /* return to parsing previous op */ - - *op = scope->parse_scope.op; - *arg_list = scope->parse_scope.arg_list; - *arg_count = scope->parse_scope.arg_count; - parser_state->pkg_end = scope->parse_scope.pkg_end; - - /* All done with this scope state structure */ - - acpi_cm_delete_generic_state (scope); - } - - else { - /* empty parse stack, prepare to fetch next opcode */ - - *op = NULL; - *arg_list = 0; - *arg_count = 0; - } - - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_cleanup_scope - * - * PARAMETERS: Parser_state - Current parser state object - * - * RETURN: Status - * - * DESCRIPTION: Destroy available list, remaining stack levels, and return - * root scope - * - ******************************************************************************/ - -void -acpi_ps_cleanup_scope ( - ACPI_PARSE_STATE *parser_state) -{ - ACPI_GENERIC_STATE *scope; - - - if (!parser_state) { - return; - } - - - /* Delete anything on the scope stack */ - - while (parser_state->scope) { - scope = acpi_cm_pop_generic_state (&parser_state->scope); - acpi_cm_delete_generic_state (scope); - } - - return; -} - diff --git a/reactos/drivers/bus/acpi/parser/pstree.c b/reactos/drivers/bus/acpi/parser/pstree.c deleted file mode 100644 index 9260fca5263..00000000000 --- a/reactos/drivers/bus/acpi/parser/pstree.c +++ /dev/null @@ -1,286 +0,0 @@ -/****************************************************************************** - * - * Module Name: pstree - Parser op tree manipulation/traversal/search - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_PARSER - MODULE_NAME ("pstree") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_arg - * - * PARAMETERS: Op - Get an argument for this op - * Argn - Nth argument to get - * - * RETURN: The argument (as an Op object). NULL if argument does not exist - * - * DESCRIPTION: Get the specified op's argument. - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT * -acpi_ps_get_arg ( - ACPI_PARSE_OBJECT *op, - u32 argn) -{ - ACPI_PARSE_OBJECT *arg = NULL; - ACPI_OPCODE_INFO *op_info; - - - /* Get the info structure for this opcode */ - - op_info = acpi_ps_get_opcode_info (op->opcode); - if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { - /* Invalid opcode or ASCII character */ - - return (NULL); - } - - /* Check if this opcode requires argument sub-objects */ - - if (!(ACPI_GET_OP_ARGS (op_info))) { - /* Has no linked argument objects */ - - return (NULL); - } - - /* Get the requested argument object */ - - arg = op->value.arg; - while (arg && argn) { - argn--; - arg = arg->next; - } - - return (arg); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_append_arg - * - * PARAMETERS: Op - Append an argument to this Op. - * Arg - Argument Op to append - * - * RETURN: None. - * - * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK) - * - ******************************************************************************/ - -void -acpi_ps_append_arg ( - ACPI_PARSE_OBJECT *op, - ACPI_PARSE_OBJECT *arg) -{ - ACPI_PARSE_OBJECT *prev_arg; - ACPI_OPCODE_INFO *op_info; - - - if (!op) { - return; - } - - /* Get the info structure for this opcode */ - - op_info = acpi_ps_get_opcode_info (op->opcode); - if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { - /* Invalid opcode */ - - return; - } - - /* Check if this opcode requires argument sub-objects */ - - if (!(ACPI_GET_OP_ARGS (op_info))) { - /* Has no linked argument objects */ - - return; - } - - - /* Append the argument to the linked argument list */ - - if (op->value.arg) { - /* Append to existing argument list */ - - prev_arg = op->value.arg; - while (prev_arg->next) { - prev_arg = prev_arg->next; - } - prev_arg->next = arg; - } - - else { - /* No argument list, this will be the first argument */ - - op->value.arg = arg; - } - - - /* Set the parent in this arg and any args linked after it */ - - while (arg) { - arg->parent = op; - arg = arg->next; - } -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_child - * - * PARAMETERS: Op - Get the child of this Op - * - * RETURN: Child Op, Null if none is found. - * - * DESCRIPTION: Get op's children or NULL if none - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT * -acpi_ps_get_child ( - ACPI_PARSE_OBJECT *op) -{ - ACPI_PARSE_OBJECT *child = NULL; - - - switch (op->opcode) { - case AML_SCOPE_OP: - case AML_ELSE_OP: - case AML_DEVICE_OP: - case AML_THERMAL_ZONE_OP: - case AML_METHODCALL_OP: - - child = acpi_ps_get_arg (op, 0); - break; - - - case AML_BUFFER_OP: - case AML_PACKAGE_OP: - case AML_METHOD_OP: - case AML_IF_OP: - case AML_WHILE_OP: - case AML_DEF_FIELD_OP: - - child = acpi_ps_get_arg (op, 1); - break; - - - case AML_POWER_RES_OP: - case AML_INDEX_FIELD_OP: - - child = acpi_ps_get_arg (op, 2); - break; - - - case AML_PROCESSOR_OP: - case AML_BANK_FIELD_OP: - - child = acpi_ps_get_arg (op, 3); - break; - - } - - return (child); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_depth_next - * - * PARAMETERS: Origin - Root of subtree to search - * Op - Last (previous) Op that was found - * - * RETURN: Next Op found in the search. - * - * DESCRIPTION: Get next op in tree (walking the tree in depth-first order) - * Return NULL when reaching "origin" or when walking up from root - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT * -acpi_ps_get_depth_next ( - ACPI_PARSE_OBJECT *origin, - ACPI_PARSE_OBJECT *op) -{ - ACPI_PARSE_OBJECT *next = NULL; - ACPI_PARSE_OBJECT *parent; - ACPI_PARSE_OBJECT *arg; - - - if (!op) { - return (NULL); - } - - /* look for an argument or child */ - - next = acpi_ps_get_arg (op, 0); - if (next) { - return (next); - } - - /* look for a sibling */ - - next = op->next; - if (next) { - return (next); - } - - /* look for a sibling of parent */ - - parent = op->parent; - - while (parent) { - arg = acpi_ps_get_arg (parent, 0); - while (arg && (arg != origin) && (arg != op)) { - arg = arg->next; - } - - if (arg == origin) { - /* reached parent of origin, end search */ - - return (NULL); - } - - if (parent->next) { - /* found sibling of parent */ - return (parent->next); - } - - op = parent; - parent = parent->parent; - } - - return (next); -} - - diff --git a/reactos/drivers/bus/acpi/parser/psutils.c b/reactos/drivers/bus/acpi/parser/psutils.c deleted file mode 100644 index 6b331a5f277..00000000000 --- a/reactos/drivers/bus/acpi/parser/psutils.c +++ /dev/null @@ -1,554 +0,0 @@ -/****************************************************************************** - * - * Module Name: psutils - Parser miscellaneous utilities (Parser only) - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_PARSER - MODULE_NAME ("psutils") - - -#define PARSEOP_GENERIC 0x01 -#define PARSEOP_NAMED 0x02 -#define PARSEOP_DEFERRED 0x03 -#define PARSEOP_BYTELIST 0x04 -#define PARSEOP_IN_CACHE 0x80 - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_init_op - * - * PARAMETERS: Op - A newly allocated Op object - * Opcode - Opcode to store in the Op - * - * RETURN: Status - * - * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on - * opcode - * - ******************************************************************************/ - -void -acpi_ps_init_op ( - ACPI_PARSE_OBJECT *op, - u16 opcode) -{ - ACPI_OPCODE_INFO *aml_op; - - - op->data_type = ACPI_DESC_TYPE_PARSER; - op->opcode = opcode; - - aml_op = acpi_ps_get_opcode_info (opcode); - - DEBUG_ONLY_MEMBERS (STRNCPY (op->op_name, aml_op->name, - sizeof (op->op_name))); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_alloc_op - * - * PARAMETERS: Opcode - Opcode that will be stored in the new Op - * - * RETURN: Pointer to the new Op. - * - * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on - * opcode. A cache of opcodes is available for the pure - * GENERIC_OP, since this is by far the most commonly used. - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT* -acpi_ps_alloc_op ( - u16 opcode) -{ - ACPI_PARSE_OBJECT *op = NULL; - u32 size; - u8 flags; - - - /* Allocate the minimum required size object */ - - if (acpi_ps_is_deferred_op (opcode)) { - size = sizeof (ACPI_PARSE2_OBJECT); - flags = PARSEOP_DEFERRED; - } - - else if (acpi_ps_is_named_op (opcode)) { - size = sizeof (ACPI_PARSE2_OBJECT); - flags = PARSEOP_NAMED; - } - - else if (acpi_ps_is_bytelist_op (opcode)) { - size = sizeof (ACPI_PARSE2_OBJECT); - flags = PARSEOP_BYTELIST; - } - - else { - size = sizeof (ACPI_PARSE_OBJECT); - flags = PARSEOP_GENERIC; - } - - - if (size == sizeof (ACPI_PARSE_OBJECT)) { - /* - * The generic op is by far the most common (16 to 1), and therefore - * the op cache is implemented with this type. - * - * Check if there is an Op already available in the cache - */ - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - acpi_gbl_parse_cache_requests++; - if (acpi_gbl_parse_cache) { - /* Extract an op from the front of the cache list */ - - acpi_gbl_parse_cache_depth--; - acpi_gbl_parse_cache_hits++; - - op = acpi_gbl_parse_cache; - acpi_gbl_parse_cache = op->next; - - - /* Clear the previously used Op */ - - MEMSET (op, 0, sizeof (ACPI_PARSE_OBJECT)); - - } - acpi_cm_release_mutex (ACPI_MTX_CACHES); - } - - else { - /* - * The generic op is by far the most common (16 to 1), and therefore - * the op cache is implemented with this type. - * - * Check if there is an Op already available in the cache - */ - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - acpi_gbl_ext_parse_cache_requests++; - if (acpi_gbl_ext_parse_cache) { - /* Extract an op from the front of the cache list */ - - acpi_gbl_ext_parse_cache_depth--; - acpi_gbl_ext_parse_cache_hits++; - - op = (ACPI_PARSE_OBJECT *) acpi_gbl_ext_parse_cache; - acpi_gbl_ext_parse_cache = (ACPI_PARSE2_OBJECT *) op->next; - - - /* Clear the previously used Op */ - - MEMSET (op, 0, sizeof (ACPI_PARSE2_OBJECT)); - - } - acpi_cm_release_mutex (ACPI_MTX_CACHES); - } - - - /* Allocate a new Op if necessary */ - - if (!op) { - op = acpi_cm_callocate (size); - } - - /* Initialize the Op */ - if (op) { - acpi_ps_init_op (op, opcode); - op->flags = flags; - } - - return (op); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_free_op - * - * PARAMETERS: Op - Op to be freed - * - * RETURN: None. - * - * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list - * or actually free it. - * - ******************************************************************************/ - -void -acpi_ps_free_op ( - ACPI_PARSE_OBJECT *op) -{ - - - - if (op->flags == PARSEOP_GENERIC) { - /* Is the cache full? */ - - if (acpi_gbl_parse_cache_depth < MAX_PARSE_CACHE_DEPTH) { - /* Put a GENERIC_OP back into the cache */ - - /* Clear the previously used Op */ - - MEMSET (op, 0, sizeof (ACPI_PARSE_OBJECT)); - op->flags = PARSEOP_IN_CACHE; - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - acpi_gbl_parse_cache_depth++; - - op->next = acpi_gbl_parse_cache; - acpi_gbl_parse_cache = op; - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - return; - } - } - - else { - /* Is the cache full? */ - - if (acpi_gbl_ext_parse_cache_depth < MAX_EXTPARSE_CACHE_DEPTH) { - /* Put a GENERIC_OP back into the cache */ - - /* Clear the previously used Op */ - - MEMSET (op, 0, sizeof (ACPI_PARSE2_OBJECT)); - op->flags = PARSEOP_IN_CACHE; - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - acpi_gbl_ext_parse_cache_depth++; - - op->next = (ACPI_PARSE_OBJECT *) acpi_gbl_ext_parse_cache; - acpi_gbl_ext_parse_cache = (ACPI_PARSE2_OBJECT *) op; - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - return; - } - } - - - /* - * Not a GENERIC OP, or the cache is full, just free the Op - */ - - acpi_cm_free (op); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_delete_parse_cache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Free all objects that are on the parse cache list. - * - ******************************************************************************/ - -void -acpi_ps_delete_parse_cache ( - void) -{ - ACPI_PARSE_OBJECT *next; - - - /* Traverse the global cache list */ - - while (acpi_gbl_parse_cache) { - /* Delete one cached state object */ - - next = acpi_gbl_parse_cache->next; - acpi_cm_free (acpi_gbl_parse_cache); - acpi_gbl_parse_cache = next; - acpi_gbl_parse_cache_depth--; - } - - /* Traverse the global cache list */ - - while (acpi_gbl_ext_parse_cache) { - /* Delete one cached state object */ - - next = acpi_gbl_ext_parse_cache->next; - acpi_cm_free (acpi_gbl_ext_parse_cache); - acpi_gbl_ext_parse_cache = (ACPI_PARSE2_OBJECT *) next; - acpi_gbl_ext_parse_cache_depth--; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Utility functions - * - * DESCRIPTION: Low level functions - * - * TBD: [Restructure] - * 1) Some of these functions should be macros - * 2) Some can be simplified - * - ******************************************************************************/ - - -/* - * Is "c" a namestring lead character? - */ - - -u8 -acpi_ps_is_leading_char ( - u32 c) -{ - return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); -} - - -/* - * Is "c" a namestring prefix character? - */ -u8 -acpi_ps_is_prefix_char ( - u32 c) -{ - return ((u8) (c == '\\' || c == '^')); -} - - -u8 -acpi_ps_is_namespace_object_op ( - u16 opcode) -{ - return ((u8) - (opcode == AML_SCOPE_OP || - opcode == AML_DEVICE_OP || - opcode == AML_THERMAL_ZONE_OP || - opcode == AML_METHOD_OP || - opcode == AML_POWER_RES_OP || - opcode == AML_PROCESSOR_OP || - opcode == AML_DEF_FIELD_OP || - opcode == AML_INDEX_FIELD_OP || - opcode == AML_BANK_FIELD_OP || - opcode == AML_NAMEDFIELD_OP || - opcode == AML_NAME_OP || - opcode == AML_ALIAS_OP || - opcode == AML_MUTEX_OP || - opcode == AML_EVENT_OP || - opcode == AML_REGION_OP || - opcode == AML_CREATE_FIELD_OP || - opcode == AML_BIT_FIELD_OP || - opcode == AML_BYTE_FIELD_OP || - opcode == AML_WORD_FIELD_OP || - opcode == AML_DWORD_FIELD_OP || - opcode == AML_METHODCALL_OP || - opcode == AML_NAMEPATH_OP)); -} - -u8 -acpi_ps_is_namespace_op ( - u16 opcode) -{ - return ((u8) - (opcode == AML_SCOPE_OP || - opcode == AML_DEVICE_OP || - opcode == AML_THERMAL_ZONE_OP || - opcode == AML_METHOD_OP || - opcode == AML_POWER_RES_OP || - opcode == AML_PROCESSOR_OP || - opcode == AML_DEF_FIELD_OP || - opcode == AML_INDEX_FIELD_OP || - opcode == AML_BANK_FIELD_OP || - opcode == AML_NAME_OP || - opcode == AML_ALIAS_OP || - opcode == AML_MUTEX_OP || - opcode == AML_EVENT_OP || - opcode == AML_REGION_OP || - opcode == AML_NAMEDFIELD_OP)); -} - - -/* - * Is opcode for a named object Op? - * (Includes all named object opcodes) - * - * TBD: [Restructure] Need a better way than this brute force approach! - */ -u8 -acpi_ps_is_node_op ( - u16 opcode) -{ - return ((u8) - (opcode == AML_SCOPE_OP || - opcode == AML_DEVICE_OP || - opcode == AML_THERMAL_ZONE_OP || - opcode == AML_METHOD_OP || - opcode == AML_POWER_RES_OP || - opcode == AML_PROCESSOR_OP || - opcode == AML_NAMEDFIELD_OP || - opcode == AML_NAME_OP || - opcode == AML_ALIAS_OP || - opcode == AML_MUTEX_OP || - opcode == AML_EVENT_OP || - opcode == AML_REGION_OP || - - - opcode == AML_CREATE_FIELD_OP || - opcode == AML_BIT_FIELD_OP || - opcode == AML_BYTE_FIELD_OP || - opcode == AML_WORD_FIELD_OP || - opcode == AML_DWORD_FIELD_OP || - opcode == AML_METHODCALL_OP || - opcode == AML_NAMEPATH_OP)); -} - - -/* - * Is opcode for a named Op? - */ -u8 -acpi_ps_is_named_op ( - u16 opcode) -{ - return ((u8) - (opcode == AML_SCOPE_OP || - opcode == AML_DEVICE_OP || - opcode == AML_THERMAL_ZONE_OP || - opcode == AML_METHOD_OP || - opcode == AML_POWER_RES_OP || - opcode == AML_PROCESSOR_OP || - opcode == AML_NAME_OP || - opcode == AML_ALIAS_OP || - opcode == AML_MUTEX_OP || - opcode == AML_EVENT_OP || - opcode == AML_REGION_OP || - opcode == AML_NAMEDFIELD_OP)); -} - - -u8 -acpi_ps_is_deferred_op ( - u16 opcode) -{ - return ((u8) - (opcode == AML_METHOD_OP || - opcode == AML_CREATE_FIELD_OP || - opcode == AML_BIT_FIELD_OP || - opcode == AML_BYTE_FIELD_OP || - opcode == AML_WORD_FIELD_OP || - opcode == AML_DWORD_FIELD_OP || - opcode == AML_REGION_OP)); -} - - -/* - * Is opcode for a bytelist? - */ -u8 -acpi_ps_is_bytelist_op ( - u16 opcode) -{ - return ((u8) (opcode == AML_BYTELIST_OP)); -} - - -/* - * Is opcode for a Field, Index_field, or Bank_field - */ -u8 -acpi_ps_is_field_op ( - u16 opcode) -{ - return ((u8) - (opcode == AML_CREATE_FIELD_OP - || opcode == AML_DEF_FIELD_OP - || opcode == AML_INDEX_FIELD_OP - || opcode == AML_BANK_FIELD_OP)); -} - - -/* - * Is field creation op - */ -u8 -acpi_ps_is_create_field_op ( - u16 opcode) -{ - return ((u8) - (opcode == AML_CREATE_FIELD_OP || - opcode == AML_BIT_FIELD_OP || - opcode == AML_BYTE_FIELD_OP || - opcode == AML_WORD_FIELD_OP || - opcode == AML_DWORD_FIELD_OP)); -} - - -/* - * Cast an acpi_op to an acpi_extended_op if possible - */ - -/* TBD: This is very inefficient, fix */ -ACPI_PARSE2_OBJECT * -acpi_ps_to_extended_op ( - ACPI_PARSE_OBJECT *op) -{ - return ((acpi_ps_is_deferred_op (op->opcode) || acpi_ps_is_named_op (op->opcode) || acpi_ps_is_bytelist_op (op->opcode)) - ? ( (ACPI_PARSE2_OBJECT *) op) : NULL); -} - - -/* - * Get op's name (4-byte name segment) or 0 if unnamed - */ -u32 -acpi_ps_get_name ( - ACPI_PARSE_OBJECT *op) -{ - ACPI_PARSE2_OBJECT *named = acpi_ps_to_extended_op (op); - - return (named ? named->name : 0); -} - - -/* - * Set op's name - */ -void -acpi_ps_set_name ( - ACPI_PARSE_OBJECT *op, - u32 name) -{ - ACPI_PARSE2_OBJECT *named = acpi_ps_to_extended_op (op); - - if (named) { - named->name = name; - } -} - diff --git a/reactos/drivers/bus/acpi/parser/pswalk.c b/reactos/drivers/bus/acpi/parser/pswalk.c deleted file mode 100644 index f2a90dd6e1d..00000000000 --- a/reactos/drivers/bus/acpi/parser/pswalk.c +++ /dev/null @@ -1,278 +0,0 @@ -/****************************************************************************** - * - * Module Name: pswalk - Parser routines to walk parsed op tree(s) - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_PARSER - MODULE_NAME ("pswalk") - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_get_next_walk_op - * - * PARAMETERS: Walk_state - Current state of the walk - * Op - Current Op to be walked - * Ascending_callback - Procedure called when Op is complete - * - * RETURN: Status - * - * DESCRIPTION: Get the next Op in a walk of the parse tree. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_ps_get_next_walk_op ( - ACPI_WALK_STATE *walk_state, - ACPI_PARSE_OBJECT *op, - ACPI_PARSE_UPWARDS ascending_callback) -{ - ACPI_PARSE_OBJECT *next; - ACPI_PARSE_OBJECT *parent; - ACPI_PARSE_OBJECT *grand_parent; - ACPI_STATUS status; - - - /* Check for a argument only if we are descending in the tree */ - - if (walk_state->next_op_info != NEXT_OP_UPWARD) { - /* Look for an argument or child of the current op */ - - next = acpi_ps_get_arg (op, 0); - if (next) { - /* Still going downward in tree (Op is not completed yet) */ - - walk_state->prev_op = op; - walk_state->next_op = next; - walk_state->next_op_info = NEXT_OP_DOWNWARD; - - return (AE_OK); - } - - - /* - * No more children, this Op is complete. Save Next and Parent - * in case the Op object gets deleted by the callback routine - */ - - next = op->next; - parent = op->parent; - - status = ascending_callback (walk_state, op); - - /* - * If we are back to the starting point, the walk is complete. - */ - if (op == walk_state->origin) { - /* Reached the point of origin, the walk is complete */ - - walk_state->prev_op = op; - walk_state->next_op = NULL; - - return (status); - } - - /* - * Check for a sibling to the current op. A sibling means - * we are still going "downward" in the tree. - */ - - if (next) { - /* There is a sibling, it will be next */ - - walk_state->prev_op = op; - walk_state->next_op = next; - walk_state->next_op_info = NEXT_OP_DOWNWARD; - - /* Continue downward */ - - return (status); - } - - - /* - * Drop into the loop below because we are moving upwards in - * the tree - */ - } - - else { - /* - * We are resuming a walk, and we were (are) going upward in the tree. - * So, we want to drop into the parent loop below. - */ - - parent = op; - } - - - /* - * Look for a sibling of the current Op's parent - * Continue moving up the tree until we find a node that has not been - * visited, or we get back to where we started. - */ - while (parent) { - /* We are moving up the tree, therefore this parent Op is complete */ - - grand_parent = parent->parent; - next = parent->next; - - status = ascending_callback (walk_state, parent); - - /* - * If we are back to the starting point, the walk is complete. - */ - if (parent == walk_state->origin) { - /* Reached the point of origin, the walk is complete */ - - walk_state->prev_op = parent; - walk_state->next_op = NULL; - - return (status); - } - - /* - * If there is a sibling to this parent (it is not the starting point - * Op), then we will visit it. - */ - if (next) { - /* found sibling of parent */ - - walk_state->prev_op = parent; - walk_state->next_op = next; - walk_state->next_op_info = NEXT_OP_DOWNWARD; - - return (status); - } - - /* No siblings, no errors, just move up one more level in the tree */ - - op = parent; - parent = grand_parent; - walk_state->prev_op = op; - } - - - /* Got all the way to the top of the tree, we must be done! */ - /* However, the code should have terminated in the loop above */ - - walk_state->next_op = NULL; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_delete_completed_op - * - * PARAMETERS: State - Walk state - * Op - Completed op - * - * RETURN: AE_OK - * - * DESCRIPTION: Callback function for Acpi_ps_get_next_walk_op(). Used during - * Acpi_ps_delete_parse tree to delete Op objects when all sub-objects - * have been visited (and deleted.) - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_ps_delete_completed_op ( - ACPI_WALK_STATE *state, - ACPI_PARSE_OBJECT *op) -{ - - acpi_ps_free_op (op); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_ps_delete_parse_tree - * - * PARAMETERS: Subtree_root - Root of tree (or subtree) to delete - * - * RETURN: None - * - * DESCRIPTION: Delete a portion of or an entire parse tree. - * - ******************************************************************************/ - -void -acpi_ps_delete_parse_tree ( - ACPI_PARSE_OBJECT *subtree_root) -{ - ACPI_WALK_STATE *walk_state; - ACPI_WALK_LIST walk_list; - - - if (!subtree_root) { - return; - } - - /* Create and initialize a new walk list */ - - walk_list.walk_state = NULL; - walk_list.acquired_mutex_list.prev = NULL; - walk_list.acquired_mutex_list.next = NULL; - - walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, NULL, NULL, &walk_list); - if (!walk_state) { - return; - } - - walk_state->parser_state = NULL; - walk_state->parse_flags = 0; - walk_state->descending_callback = NULL; - walk_state->ascending_callback = NULL; - - - walk_state->origin = subtree_root; - walk_state->next_op = subtree_root; - - - /* Head downward in the tree */ - - walk_state->next_op_info = NEXT_OP_DOWNWARD; - - /* Visit all nodes in the subtree */ - - while (walk_state->next_op) { - acpi_ps_get_next_walk_op (walk_state, walk_state->next_op, - acpi_ps_delete_completed_op); - } - - /* We are done with this walk */ - - acpi_aml_release_all_mutexes ((ACPI_OPERAND_OBJECT *) &walk_list.acquired_mutex_list); - acpi_ds_delete_walk_state (walk_state); - - return; -} - - diff --git a/reactos/drivers/bus/acpi/parser/psxface.c b/reactos/drivers/bus/acpi/parser/psxface.c deleted file mode 100644 index ee25e842993..00000000000 --- a/reactos/drivers/bus/acpi/parser/psxface.c +++ /dev/null @@ -1,157 +0,0 @@ -/****************************************************************************** - * - * Module Name: psxface - Parser external interfaces - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_PARSER - MODULE_NAME ("psxface") - - -/***************************************************************************** - * - * FUNCTION: Acpi_psx_execute - * - * PARAMETERS: Method_node - A method object containing both the AML - * address and length. - * **Params - List of parameters to pass to method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * **Return_obj_desc - Return object from execution of the - * method. - * - * RETURN: Status - * - * DESCRIPTION: Execute a control method - * - ****************************************************************************/ - -ACPI_STATUS -acpi_psx_execute ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT **params, - ACPI_OPERAND_OBJECT **return_obj_desc) -{ - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - u32 i; - ACPI_PARSE_OBJECT *op; - - - /* Validate the Node and get the attached object */ - - if (!method_node) { - return (AE_NULL_ENTRY); - } - - obj_desc = acpi_ns_get_attached_object (method_node); - if (!obj_desc) { - return (AE_NULL_OBJECT); - } - - /* Init for new method, wait on concurrency semaphore */ - - status = acpi_ds_begin_method_execution (method_node, obj_desc, NULL); - if (ACPI_FAILURE (status)) { - return (status); - } - - if (params) { - /* - * The caller "owns" the parameters, so give each one an extra - * reference - */ - - for (i = 0; params[i]; i++) { - acpi_cm_add_reference (params[i]); - } - } - - /* - * Perform the first pass parse of the method to enter any - * named objects that it creates into the namespace - */ - - /* Create and init a Root Node */ - - op = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - status = acpi_ps_parse_aml (op, obj_desc->method.pcode, - obj_desc->method.pcode_length, - ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, - method_node, params, return_obj_desc, - acpi_ds_load1_begin_op, acpi_ds_load1_end_op); - acpi_ps_delete_parse_tree (op); - - /* Create and init a Root Node */ - - op = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - - /* Init new op with the method name and pointer back to the NS node */ - - acpi_ps_set_name (op, method_node->name); - op->node = method_node; - - /* - * The walk of the parse tree is where we actually execute the method - */ - status = acpi_ps_parse_aml (op, obj_desc->method.pcode, - obj_desc->method.pcode_length, - ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, - method_node, params, return_obj_desc, - acpi_ds_exec_begin_op, acpi_ds_exec_end_op); - acpi_ps_delete_parse_tree (op); - - if (params) { - /* Take away the extra reference that we gave the parameters above */ - - for (i = 0; params[i]; i++) { - acpi_cm_update_object_reference (params[i], REF_DECREMENT); - } - } - - - /* - * Normal exit is with Status == AE_RETURN_VALUE when a Return_op has been - * executed, or with Status == AE_PENDING at end of AML block (end of - * Method code) - */ - - if (*return_obj_desc) { - status = AE_CTRL_RETURN_VALUE; - } - - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/resource/rsaddr.c b/reactos/drivers/bus/acpi/resource/rsaddr.c deleted file mode 100644 index 5fdb6387eca..00000000000 --- a/reactos/drivers/bus/acpi/resource/rsaddr.c +++ /dev/null @@ -1,800 +0,0 @@ -/******************************************************************************* - * - * Module Name: rsaddr - Acpi_rs_address16_resource - * Acpi_rs_address16_stream - * Acpi_rs_address32_resource - * Acpi_rs_address32_stream - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rsaddr") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_address16_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_address16_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16; - u8 temp8; - u32 index; - u32 struct_size = sizeof(ADDRESS16_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - buffer += 1; - - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - *bytes_consumed = temp16 + 3; - - output_struct->id = address16; - - output_struct->length = struct_size; - - /* - * Get the Resource Type (Byte3) - */ - buffer += 2; - temp8 = *buffer; - - /* Values 0-2 are valid */ - if (temp8 > 2) { - return (AE_AML_ERROR); - } - - output_struct->data.address16.resource_type = temp8 & 0x03; - - /* - * Get the General Flags (Byte4) - */ - buffer += 1; - temp8 = *buffer; - - /* - * Producer / Consumer - */ - output_struct->data.address16.producer_consumer = temp8 & 0x01; - - /* - * Decode - */ - output_struct->data.address16.decode = (temp8 >> 1) & 0x01; - - /* - * Min Address Fixed - */ - output_struct->data.address16.min_address_fixed = (temp8 >> 2) & 0x01; - - /* - * Max Address Fixed - */ - output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01; - - /* - * Get the Type Specific Flags (Byte5) - */ - buffer += 1; - temp8 = *buffer; - - if (MEMORY_RANGE == output_struct->data.address16.resource_type) { - output_struct->data.address16.attribute.memory.read_write_attribute = - (u16) (temp8 & 0x01); - output_struct->data.address16.attribute.memory.cache_attribute = - (u16) ((temp8 >> 1) & 0x0F); - } - - else { - if (IO_RANGE == output_struct->data.address16.resource_type) { - output_struct->data.address16.attribute.io.range_attribute = - (u16) (temp8 & 0x03); - } - - else { - /* BUS_NUMBER_RANGE == Address32_data->Resource_type */ - /* Nothing needs to be filled in */ - } - } - - /* - * Get Granularity (Bytes 6-7) - */ - buffer += 1; - MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.granularity, - buffer); - - /* - * Get Min_address_range (Bytes 8-9) - */ - buffer += 2; - MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.min_address_range, - buffer); - - /* - * Get Max_address_range (Bytes 10-11) - */ - buffer += 2; - MOVE_UNALIGNED16_TO_16 - (&output_struct->data.address16.max_address_range, - buffer); - - /* - * Get Address_translation_offset (Bytes 12-13) - */ - buffer += 2; - MOVE_UNALIGNED16_TO_16 - (&output_struct->data.address16.address_translation_offset, - buffer); - - /* - * Get Address_length (Bytes 14-15) - */ - buffer += 2; - MOVE_UNALIGNED16_TO_16 - (&output_struct->data.address16.address_length, - buffer); - - /* - * Resource Source Index (if present) - */ - buffer += 2; - - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - */ - if (*bytes_consumed > 16) { - /* Dereference the Index */ - - temp8 = *buffer; - output_struct->data.address16.resource_source_index = - (u32) temp8; - - /* Point to the String */ - - buffer += 1; - - /* Copy the string into the buffer */ - - index = 0; - - while (0x00 != *buffer) { - output_struct->data.address16.resource_source[index] = - *buffer; - - buffer += 1; - index += 1; - } - - /* - * Add the terminating null - */ - output_struct->data.address16.resource_source[index] = 0x00; - - output_struct->data.address16.resource_source_string_length = - index + 1; - - /* - * In order for the Struct_size to fall on a 32-bit boundry, - * calculate the length of the string and expand the - * Struct_size to the next 32-bit boundry. - */ - temp8 = (u8) (index + 1); - struct_size += ROUND_UP_TO_32_bITS (temp8); - output_struct->length = struct_size; - } - else { - output_struct->data.address16.resource_source_index = 0x00; - output_struct->data.address16.resource_source_string_length = 0; - output_struct->data.address16.resource_source[0] = 0x00; - } - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_address16_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_address16_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u8 *length_field; - u8 temp8; - NATIVE_CHAR *temp_pointer = NULL; - u32 actual_bytes; - - - /* - * The descriptor field is static - */ - *buffer = 0x88; - buffer += 1; - - /* - * Save a pointer to the Length field - to be filled in later - */ - length_field = buffer; - buffer += 2; - - /* - * Set the Resource Type (Memory, Io, Bus_number) - */ - temp8 = (u8) (linked_list->data.address16.resource_type & 0x03); - *buffer = temp8; - buffer += 1; - - /* - * Set the general flags - */ - temp8 = (u8) (linked_list->data.address16.producer_consumer & 0x01); - - temp8 |= (linked_list->data.address16.decode & 0x01) << 1; - temp8 |= (linked_list->data.address16.min_address_fixed & 0x01) << 2; - temp8 |= (linked_list->data.address16.max_address_fixed & 0x01) << 3; - - *buffer = temp8; - buffer += 1; - - /* - * Set the type specific flags - */ - temp8 = 0; - - if (MEMORY_RANGE == linked_list->data.address16.resource_type) { - temp8 = (u8) - (linked_list->data.address16.attribute.memory.read_write_attribute & - 0x01); - - temp8 |= - (linked_list->data.address16.attribute.memory.cache_attribute & - 0x0F) << 1; - } - - else if (IO_RANGE == linked_list->data.address16.resource_type) { - temp8 = (u8) - (linked_list->data.address16.attribute.io.range_attribute & - 0x03); - } - - *buffer = temp8; - buffer += 1; - - /* - * Set the address space granularity - */ - MOVE_UNALIGNED16_TO_16 (buffer, - &linked_list->data.address16.granularity); - buffer += 2; - - /* - * Set the address range minimum - */ - MOVE_UNALIGNED16_TO_16 (buffer, - &linked_list->data.address16.min_address_range); - buffer += 2; - - /* - * Set the address range maximum - */ - MOVE_UNALIGNED16_TO_16 (buffer, - &linked_list->data.address16.max_address_range); - buffer += 2; - - /* - * Set the address translation offset - */ - MOVE_UNALIGNED16_TO_16 (buffer, - &linked_list->data.address16.address_translation_offset); - buffer += 2; - - /* - * Set the address length - */ - MOVE_UNALIGNED16_TO_16 (buffer, - &linked_list->data.address16.address_length); - buffer += 2; - - /* - * Resource Source Index and Resource Source are optional - */ - if (0 != linked_list->data.address16.resource_source_string_length) { - temp8 = (u8) linked_list->data.address16.resource_source_index; - - *buffer = temp8; - buffer += 1; - - temp_pointer = (NATIVE_CHAR *) buffer; - - /* - * Copy the string - */ - STRCPY (temp_pointer, linked_list->data.address16.resource_source); - - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - buffer += (STRLEN (linked_list->data.address16.resource_source) + 1); - } - - /* - * Return the number of bytes consumed in this operation - */ - actual_bytes = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - *bytes_consumed = actual_bytes; - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - actual_bytes -= 3; - MOVE_UNALIGNED16_TO_16 (length_field, &actual_bytes); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_address32_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_address32_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer; - RESOURCE *output_struct; - u16 temp16; - u8 temp8; - u32 struct_size; - u32 index; - - - buffer = byte_stream_buffer; - - output_struct = (RESOURCE *) *output_buffer; - - struct_size = sizeof (ADDRESS32_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - buffer += 1; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - *bytes_consumed = temp16 + 3; - - output_struct->id = address32; - - /* - * Get the Resource Type (Byte3) - */ - buffer += 2; - temp8 = *buffer; - - /* Values 0-2 are valid */ - if(temp8 > 2) { - return (AE_AML_ERROR); - } - - output_struct->data.address32.resource_type = temp8 & 0x03; - - /* - * Get the General Flags (Byte4) - */ - buffer += 1; - temp8 = *buffer; - - /* - * Producer / Consumer - */ - output_struct->data.address32.producer_consumer = temp8 & 0x01; - - /* - * Decode - */ - output_struct->data.address32.decode = (temp8 >> 1) & 0x01; - - /* - * Min Address Fixed - */ - output_struct->data.address32.min_address_fixed = (temp8 >> 2) & 0x01; - - /* - * Max Address Fixed - */ - output_struct->data.address32.max_address_fixed = (temp8 >> 3) & 0x01; - - /* - * Get the Type Specific Flags (Byte5) - */ - buffer += 1; - temp8 = *buffer; - - if (MEMORY_RANGE == output_struct->data.address32.resource_type) { - output_struct->data.address32.attribute.memory.read_write_attribute = - (u16) (temp8 & 0x01); - - output_struct->data.address32.attribute.memory.cache_attribute = - (u16) ((temp8 >> 1) & 0x0F); - } - - else { - if (IO_RANGE == output_struct->data.address32.resource_type) { - output_struct->data.address32.attribute.io.range_attribute = - (u16) (temp8 & 0x03); - } - - else { - /* BUS_NUMBER_RANGE == Output_struct->Data.Address32.Resource_type */ - /* Nothing needs to be filled in */ - } - } - - /* - * Get Granularity (Bytes 6-9) - */ - buffer += 1; - MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.granularity, - buffer); - - /* - * Get Min_address_range (Bytes 10-13) - */ - buffer += 4; - MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.min_address_range, - buffer); - - /* - * Get Max_address_range (Bytes 14-17) - */ - buffer += 4; - MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.max_address_range, - buffer); - - /* - * Get Address_translation_offset (Bytes 18-21) - */ - buffer += 4; - MOVE_UNALIGNED32_TO_32 - (&output_struct->data.address32.address_translation_offset, - buffer); - - /* - * Get Address_length (Bytes 22-25) - */ - buffer += 4; - MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_length, - buffer); - - /* - * Resource Source Index (if present) - */ - buffer += 4; - - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - */ - if (*bytes_consumed > 26) { - /* Dereference the Index */ - - temp8 = *buffer; - output_struct->data.address32.resource_source_index = (u32)temp8; - - /* Point to the String */ - - buffer += 1; - - /* Copy the string into the buffer */ - - index = 0; - - while (0x00 != *buffer) { - output_struct->data.address32.resource_source[index] = *buffer; - buffer += 1; - index += 1; - } - - /* - * Add the terminating null - */ - output_struct->data.address32.resource_source[index] = 0x00; - - output_struct->data.address32.resource_source_string_length = index + 1; - - /* - * In order for the Struct_size to fall on a 32-bit boundry, - * calculate the length of the string and expand the - * Struct_size to the next 32-bit boundry. - */ - temp8 = (u8) (index + 1); - struct_size += ROUND_UP_TO_32_bITS (temp8); - } - - else { - output_struct->data.address32.resource_source_index = 0x00; - output_struct->data.address32.resource_source_string_length = 0; - output_struct->data.address32.resource_source[0] = 0x00; - } - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_address32_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_address32_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer; - u16 *length_field; - u8 temp8; - NATIVE_CHAR *temp_pointer; - - - buffer = *output_buffer; - - /* - * The descriptor field is static - */ - *buffer = 0x87; - buffer += 1; - - /* - * Set a pointer to the Length field - to be filled in later - */ - - length_field = (u16 *)buffer; - buffer += 2; - - /* - * Set the Resource Type (Memory, Io, Bus_number) - */ - temp8 = (u8) (linked_list->data.address32.resource_type & 0x03); - - *buffer = temp8; - buffer += 1; - - /* - * Set the general flags - */ - temp8 = (u8) (linked_list->data.address32.producer_consumer & 0x01); - temp8 |= (linked_list->data.address32.decode & 0x01) << 1; - temp8 |= (linked_list->data.address32.min_address_fixed & 0x01) << 2; - temp8 |= (linked_list->data.address32.max_address_fixed & 0x01) << 3; - - *buffer = temp8; - buffer += 1; - - /* - * Set the type specific flags - */ - temp8 = 0; - - if(MEMORY_RANGE == linked_list->data.address32.resource_type) { - temp8 = (u8) - (linked_list->data.address32.attribute.memory.read_write_attribute & - 0x01); - - temp8 |= - (linked_list->data.address32.attribute.memory.cache_attribute & - 0x0F) << 1; - } - - else if (IO_RANGE == linked_list->data.address32.resource_type) { - temp8 = (u8) - (linked_list->data.address32.attribute.io.range_attribute & - 0x03); - } - - *buffer = temp8; - buffer += 1; - - /* - * Set the address space granularity - */ - MOVE_UNALIGNED32_TO_32 (buffer, - &linked_list->data.address32.granularity); - buffer += 4; - - /* - * Set the address range minimum - */ - MOVE_UNALIGNED32_TO_32 (buffer, - &linked_list->data.address32.min_address_range); - buffer += 4; - - /* - * Set the address range maximum - */ - MOVE_UNALIGNED32_TO_32 (buffer, - &linked_list->data.address32.max_address_range); - buffer += 4; - - /* - * Set the address translation offset - */ - MOVE_UNALIGNED32_TO_32 (buffer, - &linked_list->data.address32.address_translation_offset); - buffer += 4; - - /* - * Set the address length - */ - MOVE_UNALIGNED32_TO_32 (buffer, - &linked_list->data.address32.address_length); - buffer += 4; - - /* - * Resource Source Index and Resource Source are optional - */ - if (0 != linked_list->data.address32.resource_source_string_length) { - temp8 = (u8) linked_list->data.address32.resource_source_index; - - *buffer = temp8; - buffer += 1; - - temp_pointer = (NATIVE_CHAR *) buffer; - - /* - * Copy the string - */ - STRCPY (temp_pointer, linked_list->data.address32.resource_source); - - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - buffer += (STRLEN (linked_list->data.address32.resource_source) + 1); - } - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - *length_field = (u16) (*bytes_consumed - 3); - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/resource/rscalc.c b/reactos/drivers/bus/acpi/resource/rscalc.c deleted file mode 100644 index 28236e86c55..00000000000 --- a/reactos/drivers/bus/acpi/resource/rscalc.c +++ /dev/null @@ -1,865 +0,0 @@ -/******************************************************************************* - * - * Module Name: rscalc - Acpi_rs_calculate_byte_stream_length - * Acpi_rs_calculate_list_length - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rscalc") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_calculate_byte_stream_length - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Size_needed - u32 pointer of the size buffer needed - * to properly return the parsed data - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Takes the resource byte stream and parses it once, calculating - * the size buffer needed to hold the linked list that conveys - * the resource data. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_calculate_byte_stream_length ( - RESOURCE *linked_list, - u32 *size_needed) -{ - u32 byte_stream_size_needed = 0; - u32 segment_size; - EXTENDED_IRQ_RESOURCE *ex_irq = NULL; - u8 done = FALSE; - - - while (!done) { - - /* - * Init the variable that will hold the size to add to the - * total. - */ - segment_size = 0; - - switch (linked_list->id) { - case irq: - /* - * IRQ Resource - */ - /* - * For an IRQ Resource, Byte 3, although optional, will - * always be created - it holds IRQ information. - */ - segment_size = 4; - break; - - case dma: - /* - * DMA Resource - */ - /* - * For this resource the size is static - */ - segment_size = 3; - break; - - case start_dependent_functions: - /* - * Start Dependent Functions Resource - */ - /* - * For a Start_dependent_functions Resource, Byte 1, - * although optional, will always be created. - */ - segment_size = 2; - break; - - case end_dependent_functions: - /* - * End Dependent Functions Resource - */ - /* - * For this resource the size is static - */ - segment_size = 1; - break; - - case io: - /* - * IO Port Resource - */ - /* - * For this resource the size is static - */ - segment_size = 8; - break; - - case fixed_io: - /* - * Fixed IO Port Resource - */ - /* - * For this resource the size is static - */ - segment_size = 4; - break; - - case vendor_specific: - /* - * Vendor Defined Resource - */ - /* - * For a Vendor Specific resource, if the Length is - * between 1 and 7 it will be created as a Small - * Resource data type, otherwise it is a Large - * Resource data type. - */ - if(linked_list->data.vendor_specific.length > 7) { - segment_size = 3; - } - else { - segment_size = 1; - } - segment_size += - linked_list->data.vendor_specific.length; - break; - - case end_tag: - /* - * End Tag - */ - /* - * For this resource the size is static - */ - segment_size = 2; - done = TRUE; - break; - - case memory24: - /* - * 24-Bit Memory Resource - */ - /* - * For this resource the size is static - */ - segment_size = 12; - break; - - case memory32: - /* - * 32-Bit Memory Range Resource - */ - /* - * For this resource the size is static - */ - segment_size = 20; - break; - - case fixed_memory32: - /* - * 32-Bit Fixed Memory Resource - */ - /* - * For this resource the size is static - */ - segment_size = 12; - break; - - case address16: - /* - * 16-Bit Address Resource - */ - /* - * The base size of this byte stream is 16. If a - * Resource Source string is not NULL, add 1 for - * the Index + the length of the null terminated - * string Resource Source + 1 for the null. - */ - segment_size = 16; - - if(NULL != linked_list->data.address16.resource_source) { - segment_size += (1 + - linked_list->data.address16.resource_source_string_length); - } - break; - - case address32: - /* - * 32-Bit Address Resource - */ - /* - * The base size of this byte stream is 26. If a Resource - * Source string is not NULL, add 1 for the Index + the - * length of the null terminated string Resource Source + - * 1 for the null. - */ - segment_size = 26; - - if(NULL != linked_list->data.address16.resource_source) { - segment_size += (1 + - linked_list->data.address16.resource_source_string_length); - } - break; - - case extended_irq: - /* - * Extended IRQ Resource - */ - /* - * The base size of this byte stream is 9. This is for an - * Interrupt table length of 1. For each additional - * interrupt, add 4. - * If a Resource Source string is not NULL, add 1 for the - * Index + the length of the null terminated string - * Resource Source + 1 for the null. - */ - segment_size = 9; - - segment_size += - (linked_list->data.extended_irq.number_of_interrupts - - 1) * 4; - - if(NULL != ex_irq->resource_source) { - segment_size += (1 + - linked_list->data.extended_irq.resource_source_string_length); - } - break; - - default: - /* - * If we get here, everything is out of sync, - * so exit with an error - */ - return (AE_AML_ERROR); - break; - - } /* switch (Linked_list->Id) */ - - /* - * Update the total - */ - byte_stream_size_needed += segment_size; - - /* - * Point to the next object - */ - linked_list = (RESOURCE *) ((NATIVE_UINT) linked_list + - (NATIVE_UINT) linked_list->length); - } - - /* - * This is the data the caller needs - */ - *size_needed = byte_stream_size_needed; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_calculate_list_length - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource byte stream - * Byte_stream_buffer_length - Size of Byte_stream_buffer - * Size_needed - u32 pointer of the size buffer - * needed to properly return the - * parsed data - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Takes the resource byte stream and parses it once, calculating - * the size buffer needed to hold the linked list that conveys - * the resource data. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_calculate_list_length ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - u32 *size_needed) -{ - u32 buffer_size = 0; - u32 bytes_parsed = 0; - u8 number_of_interrupts = 0; - u8 number_of_channels = 0; - u8 resource_type; - u32 structure_size; - u32 bytes_consumed; - u8 *buffer; - u8 temp8; - u16 temp16; - u8 index; - u8 additional_bytes; - - - while (bytes_parsed < byte_stream_buffer_length) { - /* - * Look at the next byte in the stream - */ - resource_type = *byte_stream_buffer; - - /* - * See if this is a small or large resource - */ - if(resource_type & 0x80) { - /* - * Large Resource Type - */ - switch (resource_type) { - case MEMORY_RANGE_24: - /* - * 24-Bit Memory Resource - */ - bytes_consumed = 12; - - structure_size = sizeof (MEMORY24_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - break; - - case LARGE_VENDOR_DEFINED: - /* - * Vendor Defined Resource - */ - buffer = byte_stream_buffer; - ++buffer; - - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - bytes_consumed = temp16 + 3; - - /* - * Ensure a 32-bit boundary for the structure - */ - temp16 = (u16) ROUND_UP_TO_32_bITS (temp16); - - structure_size = sizeof (VENDOR_RESOURCE) + - RESOURCE_LENGTH_NO_DATA + - (temp16 * sizeof (u8)); - break; - - case MEMORY_RANGE_32: - /* - * 32-Bit Memory Range Resource - */ - - bytes_consumed = 20; - - structure_size = sizeof (MEMORY32_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - break; - - case FIXED_MEMORY_RANGE_32: - /* - * 32-Bit Fixed Memory Resource - */ - bytes_consumed = 12; - - structure_size = sizeof(FIXED_MEMORY32_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - break; - - case DWORD_ADDRESS_SPACE: - /* - * 32-Bit Address Resource - */ - buffer = byte_stream_buffer; - - ++buffer; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - bytes_consumed = temp16 + 3; - - /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 23, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. - */ - if (23 < temp16) { - temp8 = (u8) (temp16 - 24); - } - else { - temp8 = 0; - } - - /* - * Ensure a 32-bit boundary for the structure - */ - temp8 = (u8) ROUND_UP_TO_32_bITS (temp8); - - structure_size = sizeof (ADDRESS32_RESOURCE) + - RESOURCE_LENGTH_NO_DATA + - (temp8 * sizeof (u8)); - break; - - case WORD_ADDRESS_SPACE: - /* - * 16-Bit Address Resource - */ - buffer = byte_stream_buffer; - - ++buffer; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - bytes_consumed = temp16 + 3; - - /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 13, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. - */ - if (13 < temp16) { - temp8 = (u8) (temp16 - 14); - } - else { - temp8 = 0; - } - - /* - * Ensure a 32-bit boundry for the structure - */ - temp8 = (u8) ROUND_UP_TO_32_bITS (temp8); - - structure_size = sizeof (ADDRESS16_RESOURCE) + - RESOURCE_LENGTH_NO_DATA + - (temp8 * sizeof (u8)); - break; - - case EXTENDED_IRQ: - /* - * Extended IRQ - */ - buffer = byte_stream_buffer; - - ++buffer; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - bytes_consumed = temp16 + 3; - - /* - * Point past the length field and the - * Interrupt vector flags to save off the - * Interrupt table length to the Temp8 variable. - */ - buffer += 3; - temp8 = *buffer; - - /* - * To compensate for multiple interrupt numbers, - * Add 4 bytes for each additional interrupts - * greater than 1 - */ - additional_bytes = (u8) ((temp8 - 1) * 4); - - /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 9, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. - */ - if (9 + additional_bytes < temp16) { - temp8 = (u8) (temp16 - (9 + additional_bytes)); - } - - else { - temp8 = 0; - } - - /* - * Ensure a 32-bit boundry for the structure - */ - temp8 = (u8) ROUND_UP_TO_32_bITS (temp8); - - structure_size = sizeof (EXTENDED_IRQ_RESOURCE) + - RESOURCE_LENGTH_NO_DATA + - (additional_bytes * sizeof (u8)) + - (temp8 * sizeof (u8)); - - break; - -/* TBD: [Future] 64-bit not currently supported */ -/* - case 0x8A: - break; -*/ - - default: - /* - * If we get here, everything is out of sync, - * so exit with an error - */ - return (AE_AML_ERROR); - break; - } - } - - else { - /* - * Small Resource Type - * Only bits 7:3 are valid - */ - resource_type >>= 3; - - switch (resource_type) { - case IRQ_FORMAT: - /* - * IRQ Resource - */ - /* - * Determine if it there are two or three - * trailing bytes - */ - buffer = byte_stream_buffer; - temp8 = *buffer; - - if(temp8 & 0x01) { - bytes_consumed = 4; - } - - else { - bytes_consumed = 3; - } - - /* - * Point past the descriptor - */ - ++buffer; - - /* - * Look at the number of bits set - */ - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - for (index = 0; index < 16; index++) { - if (temp16 & 0x1) { - ++number_of_interrupts; - } - - temp16 >>= 1; - } - - structure_size = sizeof (IO_RESOURCE) + - RESOURCE_LENGTH_NO_DATA + - (number_of_interrupts * sizeof (u32)); - break; - - - case DMA_FORMAT: - - /* - * DMA Resource - */ - buffer = byte_stream_buffer; - - bytes_consumed = 3; - - /* - * Point past the descriptor - */ - ++buffer; - - /* - * Look at the number of bits set - */ - temp8 = *buffer; - - for(index = 0; index < 8; index++) { - if(temp8 & 0x1) { - ++number_of_channels; - } - - temp8 >>= 1; - } - - structure_size = sizeof (DMA_RESOURCE) + - RESOURCE_LENGTH_NO_DATA + - (number_of_channels * sizeof (u32)); - break; - - - case START_DEPENDENT_TAG: - - /* - * Start Dependent Functions Resource - */ - /* - * Determine if it there are two or three trailing bytes - */ - buffer = byte_stream_buffer; - temp8 = *buffer; - - if(temp8 & 0x01) { - bytes_consumed = 2; - } - else { - bytes_consumed = 1; - } - - - structure_size = - sizeof (START_DEPENDENT_FUNCTIONS_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - break; - - - case END_DEPENDENT_TAG: - - /* - * End Dependent Functions Resource - */ - bytes_consumed = 1; - structure_size = RESOURCE_LENGTH; - break; - - - case IO_PORT_DESCRIPTOR: - /* - * IO Port Resource - */ - bytes_consumed = 8; - structure_size = sizeof (IO_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - break; - - - case FIXED_LOCATION_IO_DESCRIPTOR: - - /* - * Fixed IO Port Resource - */ - bytes_consumed = 4; - structure_size = sizeof (FIXED_IO_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - break; - - - case SMALL_VENDOR_DEFINED: - - /* - * Vendor Specific Resource - */ - buffer = byte_stream_buffer; - - temp8 = *buffer; - temp8 = (u8) (temp8 & 0x7); - bytes_consumed = temp8 + 1; - - /* - * Ensure a 32-bit boundry for the structure - */ - temp8 = (u8) ROUND_UP_TO_32_bITS (temp8); - structure_size = sizeof (VENDOR_RESOURCE) + - RESOURCE_LENGTH_NO_DATA + - (temp8 * sizeof (u8)); - break; - - - case END_TAG: - - /* - * End Tag - */ - bytes_consumed = 2; - structure_size = RESOURCE_LENGTH; - byte_stream_buffer_length = bytes_parsed; - break; - - - default: - /* - * If we get here, everything is out of sync, - * so exit with an error - */ - return (AE_AML_ERROR); - break; - - } /* switch */ - - } /* if(Resource_type & 0x80) */ - - /* - * Update the return value and counter - */ - buffer_size += structure_size; - bytes_parsed += bytes_consumed; - - /* - * Set the byte stream to point to the next resource - */ - byte_stream_buffer += bytes_consumed; - - } - - /* - * This is the data the caller needs - */ - *size_needed = buffer_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_calculate_pci_routing_table_length - * - * PARAMETERS: Package_object - Pointer to the package object - * Buffer_size_needed - u32 pointer of the size buffer - * needed to properly return the - * parsed data - * - * RETURN: Status AE_OK - * - * DESCRIPTION: Given a package representing a PCI routing table, this - * calculates the size of the corresponding linked list of - * descriptions. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_calculate_pci_routing_table_length ( - ACPI_OPERAND_OBJECT *package_object, - u32 *buffer_size_needed) -{ - u32 number_of_elements; - u32 temp_size_needed = 0; - ACPI_OPERAND_OBJECT **top_object_list; - u32 index; - ACPI_OPERAND_OBJECT *package_element; - ACPI_OPERAND_OBJECT **sub_object_list; - u8 name_found; - u32 table_index; - - - number_of_elements = package_object->package.count; - - /* - * Calculate the size of the return buffer. - * The base size is the number of elements * the sizes of the - * structures. Additional space for the strings is added below. - * The minus one is to subtract the size of the u8 Source[1] - * member because it is added below. - */ - - /* - * But each PRT_ENTRY structure has a pointer to a string and - * the size of that string must be found. - */ - top_object_list = package_object->package.elements; - - for (index = 0; index < number_of_elements; index++) { - /* - * Dereference the sub-package - */ - package_element = *top_object_list; - - /* - * The Sub_object_list will now point to an array of the - * four IRQ elements: Address, Pin, Source and Source_index - */ - sub_object_list = package_element->package.elements; - - /* - * Scan the Irq_table_elements for the Source Name String - */ - name_found = FALSE; - - for (table_index = 0; table_index < 4 && !name_found; table_index++) { - if ((ACPI_TYPE_STRING == (*sub_object_list)->common.type) || - ((INTERNAL_TYPE_REFERENCE == (*sub_object_list)->common.type) && - ((*sub_object_list)->reference.opcode == AML_NAMEPATH_OP))) { - name_found = TRUE; - } - - else { - /* - * Look at the next element - */ - sub_object_list++; - } - } - - temp_size_needed += (sizeof (PCI_ROUTING_TABLE) - 4); - - /* - * Was a String type found? - */ - if (TRUE == name_found) { - if (ACPI_TYPE_STRING == (*sub_object_list)->common.type) { - /* - * The length String.Length field includes the - * terminating NULL - */ - temp_size_needed += (*sub_object_list)->string.length; - } - else { - temp_size_needed += acpi_ns_get_pathname_length ((*sub_object_list)->reference.node); - } - } - - else { - /* - * If no name was found, then this is a NULL, which is - * translated as a u32 zero. - */ - temp_size_needed += sizeof(u32); - } - - - /* Round up the size since each element must be aligned */ - - temp_size_needed = ROUND_UP_TO_64_bITS (temp_size_needed); - - /* - * Point to the next ACPI_OPERAND_OBJECT - */ - top_object_list++; - } - - - /* - * Adding an extra element to the end of the list, essentially a NULL terminator - */ - *buffer_size_needed = temp_size_needed + sizeof (PCI_ROUTING_TABLE); - - return (AE_OK); -} diff --git a/reactos/drivers/bus/acpi/resource/rscreate.c b/reactos/drivers/bus/acpi/resource/rscreate.c deleted file mode 100644 index a856093d6a9..00000000000 --- a/reactos/drivers/bus/acpi/resource/rscreate.c +++ /dev/null @@ -1,418 +0,0 @@ -/******************************************************************************* - * - * Module Name: rscreate - Acpi_rs_create_resource_list - * Acpi_rs_create_pci_routing_table - * Acpi_rs_create_byte_stream - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rscreate") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_create_resource_list - * - * PARAMETERS: - * Byte_stream_buffer - Pointer to the resource byte stream - * Output_buffer - Pointer to the user's buffer - * Output_buffer_length - Pointer to the size of Output_buffer - * - * RETURN: Status - AE_OK if okay, else a valid ACPI_STATUS code - * If Output_buffer is not large enough, Output_buffer_length - * indicates how large Output_buffer should be, else it - * indicates how may u8 elements of Output_buffer are valid. - * - * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method - * execution and parses the stream to create a linked list - * of device resources. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_create_resource_list ( - ACPI_OPERAND_OBJECT *byte_stream_buffer, - u8 *output_buffer, - u32 *output_buffer_length) -{ - - ACPI_STATUS status; - u8 *byte_stream_start = NULL; - u32 list_size_needed = 0; - u32 byte_stream_buffer_length = 0; - - - /* - * Params already validated, so we don't re-validate here - */ - - byte_stream_buffer_length = byte_stream_buffer->buffer.length; - byte_stream_start = byte_stream_buffer->buffer.pointer; - - /* - * Pass the Byte_stream_buffer into a module that can calculate - * the buffer size needed for the linked list - */ - status = acpi_rs_calculate_list_length (byte_stream_start, - byte_stream_buffer_length, - &list_size_needed); - - /* - * Exit with the error passed back - */ - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * If the linked list will fit into the available buffer - * call to fill in the list - */ - - if (list_size_needed <= *output_buffer_length) { - /* - * Zero out the return buffer before proceeding - */ - MEMSET (output_buffer, 0x00, *output_buffer_length); - - status = acpi_rs_byte_stream_to_list (byte_stream_start, - byte_stream_buffer_length, - &output_buffer); - - /* - * Exit with the error passed back - */ - if (ACPI_FAILURE (status)) { - return (status); - } - - } - - else { - *output_buffer_length = list_size_needed; - return (AE_BUFFER_OVERFLOW); - } - - *output_buffer_length = list_size_needed; - return (AE_OK); - -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_create_pci_routing_table - * - * PARAMETERS: - * Package_object - Pointer to an ACPI_OPERAND_OBJECT - * package - * Output_buffer - Pointer to the user's buffer - * Output_buffer_length - Size of Output_buffer - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. - * If the Output_buffer is too small, the error will be - * AE_BUFFER_OVERFLOW and Output_buffer_length will point - * to the size buffer needed. - * - * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a - * linked list of PCI interrupt descriptions - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_create_pci_routing_table ( - ACPI_OPERAND_OBJECT *package_object, - u8 *output_buffer, - u32 *output_buffer_length) -{ - u8 *buffer = output_buffer; - ACPI_OPERAND_OBJECT **top_object_list = NULL; - ACPI_OPERAND_OBJECT **sub_object_list = NULL; - ACPI_OPERAND_OBJECT *package_element = NULL; - u32 buffer_size_needed = 0; - u32 number_of_elements = 0; - u32 index = 0; - PCI_ROUTING_TABLE *user_prt = NULL; - ACPI_NAMESPACE_NODE *node; - ACPI_STATUS status; - - - /* - * Params already validated, so we don't re-validate here - */ - - status = acpi_rs_calculate_pci_routing_table_length(package_object, - &buffer_size_needed); - - /* - * If the data will fit into the available buffer - * call to fill in the list - */ - if (buffer_size_needed <= *output_buffer_length) { - /* - * Zero out the return buffer before proceeding - */ - MEMSET (output_buffer, 0x00, *output_buffer_length); - - /* - * Loop through the ACPI_INTERNAL_OBJECTS - Each object should - * contain a u32 Address, a u8 Pin, a Name and a u8 - * Source_index. - */ - top_object_list = package_object->package.elements; - number_of_elements = package_object->package.count; - user_prt = (PCI_ROUTING_TABLE *) buffer; - - - buffer = ROUND_PTR_UP_TO_8 (buffer, u8); - - for (index = 0; index < number_of_elements; index++) { - /* - * Point User_prt past this current structure - * - * NOTE: On the first iteration, User_prt->Length will - * be zero because we cleared the return buffer earlier - */ - buffer += user_prt->length; - user_prt = (PCI_ROUTING_TABLE *) buffer; - - - /* - * Fill in the Length field with the information we - * have at this point. - * The minus four is to subtract the size of the - * u8 Source[4] member because it is added below. - */ - user_prt->length = (sizeof (PCI_ROUTING_TABLE) -4); - - /* - * Dereference the sub-package - */ - package_element = *top_object_list; - - /* - * The Sub_object_list will now point to an array of - * the four IRQ elements: Address, Pin, Source and - * Source_index - */ - sub_object_list = package_element->package.elements; - - /* - * 1) First subobject: Dereference the Address - */ - if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) { - user_prt->address = (*sub_object_list)->integer.value; - } - - else { - return (AE_BAD_DATA); - } - - /* - * 2) Second subobject: Dereference the Pin - */ - sub_object_list++; - - if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) { - user_prt->pin = - (u32) (*sub_object_list)->integer.value; - } - - else { - return (AE_BAD_DATA); - } - - /* - * 3) Third subobject: Dereference the Source Name - */ - sub_object_list++; - - switch ((*sub_object_list)->common.type) { - case INTERNAL_TYPE_REFERENCE: - if ((*sub_object_list)->reference.opcode != AML_NAMEPATH_OP) { - return (AE_BAD_DATA); - } - - node = (*sub_object_list)->reference.node; - - /* TBD: use *remaining* length of the buffer! */ - - status = acpi_ns_handle_to_pathname ((ACPI_HANDLE *) node, - output_buffer_length, user_prt->source); - - user_prt->length += STRLEN (user_prt->source) + 1; /* include null terminator */ - break; - - - case ACPI_TYPE_STRING: - - STRCPY (user_prt->source, - (*sub_object_list)->string.pointer); - - /* - * Add to the Length field the length of the string - */ - user_prt->length += (*sub_object_list)->string.length; - break; - - - case ACPI_TYPE_INTEGER: - /* - * If this is a number, then the Source Name - * is NULL, since the entire buffer was zeroed - * out, we can leave this alone. - */ - /* - * Add to the Length field the length of - * the u32 NULL - */ - user_prt->length += sizeof (u32); - break; - - - default: - return (AE_BAD_DATA); - break; - } - - /* Now align the current length */ - - user_prt->length = ROUND_UP_TO_64_bITS (user_prt->length); - - /* - * 4) Fourth subobject: Dereference the Source Index - */ - sub_object_list++; - - if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) { - user_prt->source_index = - (u32) (*sub_object_list)->integer.value; - } - - else { - return (AE_BAD_DATA); - } - - /* - * Point to the next ACPI_OPERAND_OBJECT - */ - top_object_list++; - } - - } - - else { - *output_buffer_length = buffer_size_needed; - - return (AE_BUFFER_OVERFLOW); - } - - /* - * Report the amount of buffer used - */ - *output_buffer_length = buffer_size_needed; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_create_byte_stream - * - * PARAMETERS: - * Linked_list_buffer - Pointer to the resource linked list - * Output_buffer - Pointer to the user's buffer - * Output_buffer_length - Size of Output_buffer - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. - * If the Output_buffer is too small, the error will be - * AE_BUFFER_OVERFLOW and Output_buffer_length will point - * to the size buffer needed. - * - * DESCRIPTION: Takes the linked list of device resources and - * creates a bytestream to be used as input for the - * _SRS control method. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_create_byte_stream ( - RESOURCE *linked_list_buffer, - u8 *output_buffer, - u32 *output_buffer_length) -{ - ACPI_STATUS status; - u32 byte_stream_size_needed = 0; - - - /* - * Params already validated, so we don't re-validate here - * - * Pass the Linked_list_buffer into a module that can calculate - * the buffer size needed for the byte stream. - */ - status = acpi_rs_calculate_byte_stream_length (linked_list_buffer, - &byte_stream_size_needed); - - /* - * Exit with the error passed back - */ - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * If the linked list will fit into the available buffer - * call to fill in the list - */ - - if (byte_stream_size_needed <= *output_buffer_length) { - /* - * Zero out the return buffer before proceeding - */ - MEMSET (output_buffer, 0x00, *output_buffer_length); - - status = acpi_rs_list_to_byte_stream (linked_list_buffer, - byte_stream_size_needed, - &output_buffer); - - /* - * Exit with the error passed back - */ - if (ACPI_FAILURE (status)) { - return (status); - } - - } - else { - *output_buffer_length = byte_stream_size_needed; - return (AE_BUFFER_OVERFLOW); - } - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/resource/rsdump.c b/reactos/drivers/bus/acpi/resource/rsdump.c deleted file mode 100644 index d28061352e8..00000000000 --- a/reactos/drivers/bus/acpi/resource/rsdump.c +++ /dev/null @@ -1,928 +0,0 @@ -/******************************************************************************* - * - * Module Name: rsdump - Functions do dump out the resource structures. - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rsdump") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_irq - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_irq ( - RESOURCE_DATA *data) -{ - IRQ_RESOURCE *irq_data = (IRQ_RESOURCE*) data; - u8 index = 0; - - - acpi_os_printf ("\t_iRQ Resource\n"); - - acpi_os_printf ("\t\t%s Triggered\n", - LEVEL_SENSITIVE == irq_data->edge_level ? - "Level" : "Edge"); - - acpi_os_printf ("\t\t_active %s\n", - ACTIVE_LOW == irq_data->active_high_low ? - "Low" : "High"); - - acpi_os_printf ("\t\t%s\n", - SHARED == irq_data->shared_exclusive ? - "Shared" : "Exclusive"); - - acpi_os_printf ("\t\t%X Interrupts ( ", - irq_data->number_of_interrupts); - - for (index = 0; index < irq_data->number_of_interrupts; index++) { - acpi_os_printf ("%X ", irq_data->interrupts[index]); - } - - acpi_os_printf (")\n"); - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_dma - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_dma ( - RESOURCE_DATA *data) -{ - DMA_RESOURCE *dma_data = (DMA_RESOURCE*) data; - u8 index = 0; - - - acpi_os_printf ("\t_dMA Resource\n"); - - switch (dma_data->type) { - case COMPATIBILITY: - acpi_os_printf ("\t\t_compatibility mode\n"); - break; - - case TYPE_A: - acpi_os_printf ("\t\t_type A\n"); - break; - - case TYPE_B: - acpi_os_printf ("\t\t_type B\n"); - break; - - case TYPE_F: - acpi_os_printf ("\t\t_type F\n"); - break; - - default: - acpi_os_printf ("\t\t_invalid DMA type\n"); - break; - } - - acpi_os_printf ("\t\t%sBus Master\n", - BUS_MASTER == dma_data->bus_master ? - "" : "Not a "); - - switch (dma_data->transfer) { - case TRANSFER_8: - acpi_os_printf ("\t\t8-bit only transfer\n"); - break; - - case TRANSFER_8_16: - acpi_os_printf ("\t\t8 and 16-bit transfer\n"); - break; - - case TRANSFER_16: - acpi_os_printf ("\t\t16 bit only transfer\n"); - break; - - default: - acpi_os_printf ("\t\t_invalid transfer preference\n"); - break; - } - - acpi_os_printf ("\t\t_number of Channels: %X ( ", - dma_data->number_of_channels); - - for (index = 0; index < dma_data->number_of_channels; index++) { - acpi_os_printf ("%X ", dma_data->channels[index]); - } - - acpi_os_printf (")\n"); - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_start_dependent_functions - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_start_dependent_functions ( - RESOURCE_DATA *data) -{ - START_DEPENDENT_FUNCTIONS_RESOURCE *sdf_data = - (START_DEPENDENT_FUNCTIONS_RESOURCE*) data; - - - acpi_os_printf ("\t_start Dependent Functions Resource\n"); - - switch (sdf_data->compatibility_priority) { - case GOOD_CONFIGURATION: - acpi_os_printf ("\t\t_good configuration\n"); - break; - - case ACCEPTABLE_CONFIGURATION: - acpi_os_printf ("\t\t_acceptable configuration\n"); - break; - - case SUB_OPTIMAL_CONFIGURATION: - acpi_os_printf ("\t\t_sub-optimal configuration\n"); - break; - - default: - acpi_os_printf ("\t\t_invalid compatibility priority\n"); - break; - } - - switch(sdf_data->performance_robustness) { - case GOOD_CONFIGURATION: - acpi_os_printf ("\t\t_good configuration\n"); - break; - - case ACCEPTABLE_CONFIGURATION: - acpi_os_printf ("\t\t_acceptable configuration\n"); - break; - - case SUB_OPTIMAL_CONFIGURATION: - acpi_os_printf ("\t\t_sub-optimal configuration\n"); - break; - - default: - acpi_os_printf ("\t\t_invalid performance " - "robustness preference\n"); - break; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_io - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_io ( - RESOURCE_DATA *data) -{ - IO_RESOURCE *io_data = (IO_RESOURCE*) data; - - - acpi_os_printf ("\t_io Resource\n"); - - acpi_os_printf ("\t\t%d bit decode\n", - DECODE_16 == io_data->io_decode ? 16 : 10); - - acpi_os_printf ("\t\t_range minimum base: %08X\n", - io_data->min_base_address); - - acpi_os_printf ("\t\t_range maximum base: %08X\n", - io_data->max_base_address); - - acpi_os_printf ("\t\t_alignment: %08X\n", - io_data->alignment); - - acpi_os_printf ("\t\t_range Length: %08X\n", - io_data->range_length); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_fixed_io - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_fixed_io ( - RESOURCE_DATA *data) -{ - FIXED_IO_RESOURCE *fixed_io_data = (FIXED_IO_RESOURCE*) data; - - - acpi_os_printf ("\t_fixed Io Resource\n"); - acpi_os_printf ("\t\t_range base address: %08X", - fixed_io_data->base_address); - - acpi_os_printf ("\t\t_range length: %08X", - fixed_io_data->range_length); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_vendor_specific - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_vendor_specific ( - RESOURCE_DATA *data) -{ - VENDOR_RESOURCE *vendor_data = (VENDOR_RESOURCE*) data; - u16 index = 0; - - - acpi_os_printf ("\t_vendor Specific Resource\n"); - - acpi_os_printf ("\t\t_length: %08X\n", vendor_data->length); - - for (index = 0; index < vendor_data->length; index++) { - acpi_os_printf ("\t\t_byte %X: %08X\n", - index, vendor_data->reserved[index]); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_memory24 - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_memory24 ( - RESOURCE_DATA *data) -{ - MEMORY24_RESOURCE *memory24_data = (MEMORY24_RESOURCE*) data; - - - acpi_os_printf ("\t24-Bit Memory Range Resource\n"); - - acpi_os_printf ("\t\t_read%s\n", - READ_WRITE_MEMORY == - memory24_data->read_write_attribute ? - "/Write" : " only"); - - acpi_os_printf ("\t\t_range minimum base: %08X\n", - memory24_data->min_base_address); - - acpi_os_printf ("\t\t_range maximum base: %08X\n", - memory24_data->max_base_address); - - acpi_os_printf ("\t\t_alignment: %08X\n", - memory24_data->alignment); - - acpi_os_printf ("\t\t_range length: %08X\n", - memory24_data->range_length); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_memory32 - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_memory32 ( - RESOURCE_DATA *data) -{ - MEMORY32_RESOURCE *memory32_data = (MEMORY32_RESOURCE*) data; - - - acpi_os_printf ("\t32-Bit Memory Range Resource\n"); - - acpi_os_printf ("\t\t_read%s\n", - READ_WRITE_MEMORY == - memory32_data->read_write_attribute ? - "/Write" : " only"); - - acpi_os_printf ("\t\t_range minimum base: %08X\n", - memory32_data->min_base_address); - - acpi_os_printf ("\t\t_range maximum base: %08X\n", - memory32_data->max_base_address); - - acpi_os_printf ("\t\t_alignment: %08X\n", - memory32_data->alignment); - - acpi_os_printf ("\t\t_range length: %08X\n", - memory32_data->range_length); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_fixed_memory32 - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_fixed_memory32 ( - RESOURCE_DATA *data) -{ - FIXED_MEMORY32_RESOURCE *fixed_memory32_data = (FIXED_MEMORY32_RESOURCE*) data; - - - acpi_os_printf ("\t32-Bit Fixed Location Memory Range Resource\n"); - - acpi_os_printf ("\t\t_read%s\n", - READ_WRITE_MEMORY == - fixed_memory32_data->read_write_attribute ? - "/Write" : " Only"); - - acpi_os_printf ("\t\t_range base address: %08X\n", - fixed_memory32_data->range_base_address); - - acpi_os_printf ("\t\t_range length: %08X\n", - fixed_memory32_data->range_length); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_address16 - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_address16 ( - RESOURCE_DATA *data) -{ - ADDRESS16_RESOURCE *address16_data = (ADDRESS16_RESOURCE*) data; - - - acpi_os_printf ("\t16-Bit Address Space Resource\n"); - acpi_os_printf ("\t\t_resource Type: "); - - switch (address16_data->resource_type) { - case MEMORY_RANGE: - - acpi_os_printf ("Memory Range\n"); - - switch (address16_data->attribute.memory.cache_attribute) { - case NON_CACHEABLE_MEMORY: - acpi_os_printf ("\t\t_type Specific: " - "Noncacheable memory\n"); - break; - - case CACHABLE_MEMORY: - acpi_os_printf ("\t\t_type Specific: " - "Cacheable memory\n"); - break; - - case WRITE_COMBINING_MEMORY: - acpi_os_printf ("\t\t_type Specific: " - "Write-combining memory\n"); - break; - - case PREFETCHABLE_MEMORY: - acpi_os_printf ("\t\t_type Specific: " - "Prefetchable memory\n"); - break; - - default: - acpi_os_printf ("\t\t_type Specific: " - "Invalid cache attribute\n"); - break; - } - - acpi_os_printf ("\t\t_type Specific: Read%s\n", - READ_WRITE_MEMORY == - address16_data->attribute.memory.read_write_attribute ? - "/Write" : " Only"); - break; - - case IO_RANGE: - - acpi_os_printf ("I/O Range\n"); - - switch (address16_data->attribute.io.range_attribute) { - case NON_ISA_ONLY_RANGES: - acpi_os_printf ("\t\t_type Specific: " - "Non-ISA Io Addresses\n"); - break; - - case ISA_ONLY_RANGES: - acpi_os_printf ("\t\t_type Specific: " - "ISA Io Addresses\n"); - break; - - case ENTIRE_RANGE: - acpi_os_printf ("\t\t_type Specific: " - "ISA and non-ISA Io Addresses\n"); - break; - - default: - acpi_os_printf ("\t\t_type Specific: " - "Invalid range attribute\n"); - break; - } - break; - - case BUS_NUMBER_RANGE: - - acpi_os_printf ("Bus Number Range\n"); - break; - - default: - - acpi_os_printf ("Invalid resource type. Exiting.\n"); - return; - } - - acpi_os_printf ("\t\t_resource %s\n", - CONSUMER == address16_data->producer_consumer ? - "Consumer" : "Producer"); - - acpi_os_printf ("\t\t%s decode\n", - SUB_DECODE == address16_data->decode ? - "Subtractive" : "Positive"); - - acpi_os_printf ("\t\t_min address is %s fixed\n", - ADDRESS_FIXED == address16_data->min_address_fixed ? - "" : "not"); - - acpi_os_printf ("\t\t_max address is %s fixed\n", - ADDRESS_FIXED == address16_data->max_address_fixed ? - "" : "not"); - - acpi_os_printf ("\t\t_granularity: %08X\n", - address16_data->granularity); - - acpi_os_printf ("\t\t_address range min: %08X\n", - address16_data->min_address_range); - - acpi_os_printf ("\t\t_address range max: %08X\n", - address16_data->max_address_range); - - acpi_os_printf ("\t\t_address translation offset: %08X\n", - address16_data->address_translation_offset); - - acpi_os_printf ("\t\t_address Length: %08X\n", - address16_data->address_length); - - if (0xFF != address16_data->resource_source_index) { - acpi_os_printf ("\t\t_resource Source Index: %X\n", - address16_data->resource_source_index); - acpi_os_printf ("\t\t_resource Source: %s\n", - address16_data->resource_source); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_address32 - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_address32 ( - RESOURCE_DATA *data) -{ - ADDRESS32_RESOURCE *address32_data = (ADDRESS32_RESOURCE*) data; - - - acpi_os_printf ("\t32-Bit Address Space Resource\n"); - - switch (address32_data->resource_type) { - case MEMORY_RANGE: - - acpi_os_printf ("\t\t_resource Type: Memory Range\n"); - - switch (address32_data->attribute.memory.cache_attribute) { - case NON_CACHEABLE_MEMORY: - acpi_os_printf ("\t\t_type Specific: " - "Noncacheable memory\n"); - break; - - case CACHABLE_MEMORY: - acpi_os_printf ("\t\t_type Specific: " - "Cacheable memory\n"); - break; - - case WRITE_COMBINING_MEMORY: - acpi_os_printf ("\t\t_type Specific: " - "Write-combining memory\n"); - break; - - case PREFETCHABLE_MEMORY: - acpi_os_printf ("\t\t_type Specific: " - "Prefetchable memory\n"); - break; - - default: - acpi_os_printf ("\t\t_type Specific: " - "Invalid cache attribute\n"); - break; - } - - acpi_os_printf ("\t\t_type Specific: Read%s\n", - READ_WRITE_MEMORY == - address32_data->attribute.memory.read_write_attribute ? - "/Write" : " Only"); - break; - - case IO_RANGE: - - acpi_os_printf ("\t\t_resource Type: Io Range\n"); - - switch (address32_data->attribute.io.range_attribute) { - case NON_ISA_ONLY_RANGES: - acpi_os_printf ("\t\t_type Specific: " - "Non-ISA Io Addresses\n"); - break; - - case ISA_ONLY_RANGES: - acpi_os_printf ("\t\t_type Specific: " - "ISA Io Addresses\n"); - break; - - case ENTIRE_RANGE: - acpi_os_printf ("\t\t_type Specific: " - "ISA and non-ISA Io Addresses\n"); - break; - - default: - acpi_os_printf ("\t\t_type Specific: " - "Invalid Range attribute"); - break; - } - break; - - case BUS_NUMBER_RANGE: - - acpi_os_printf ("\t\t_resource Type: Bus Number Range\n"); - break; - - default: - - acpi_os_printf ("\t\t_invalid Resource Type..exiting.\n"); - return; - } - - acpi_os_printf ("\t\t_resource %s\n", - CONSUMER == address32_data->producer_consumer ? - "Consumer" : "Producer"); - - acpi_os_printf ("\t\t%s decode\n", - SUB_DECODE == address32_data->decode ? - "Subtractive" : "Positive"); - - acpi_os_printf ("\t\t_min address is %s fixed\n", - ADDRESS_FIXED == address32_data->min_address_fixed ? - "" : "not "); - - acpi_os_printf ("\t\t_max address is %s fixed\n", - ADDRESS_FIXED == address32_data->max_address_fixed ? - "" : "not "); - - acpi_os_printf ("\t\t_granularity: %08X\n", - address32_data->granularity); - - acpi_os_printf ("\t\t_address range min: %08X\n", - address32_data->min_address_range); - - acpi_os_printf ("\t\t_address range max: %08X\n", - address32_data->max_address_range); - - acpi_os_printf ("\t\t_address translation offset: %08X\n", - address32_data->address_translation_offset); - - acpi_os_printf ("\t\t_address Length: %08X\n", - address32_data->address_length); - - if(0xFF != address32_data->resource_source_index) { - acpi_os_printf ("\t\t_resource Source Index: %X\n", - address32_data->resource_source_index); - acpi_os_printf ("\t\t_resource Source: %s\n", - address32_data->resource_source); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_extended_irq - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -acpi_rs_dump_extended_irq ( - RESOURCE_DATA *data) -{ - EXTENDED_IRQ_RESOURCE *ext_irq_data = (EXTENDED_IRQ_RESOURCE*) data; - u8 index = 0; - - - acpi_os_printf ("\t_extended IRQ Resource\n"); - - acpi_os_printf ("\t\t_resource %s\n", - CONSUMER == ext_irq_data->producer_consumer ? - "Consumer" : "Producer"); - - acpi_os_printf ("\t\t%s\n", - LEVEL_SENSITIVE == ext_irq_data->edge_level ? - "Level" : "Edge"); - - acpi_os_printf ("\t\t_active %s\n", - ACTIVE_LOW == ext_irq_data->active_high_low ? - "low" : "high"); - - acpi_os_printf ("\t\t%s\n", - SHARED == ext_irq_data->shared_exclusive ? - "Shared" : "Exclusive"); - - acpi_os_printf ("\t\t_interrupts : %X ( ", - ext_irq_data->number_of_interrupts); - - for (index = 0; index < ext_irq_data->number_of_interrupts; index++) { - acpi_os_printf ("%X ", ext_irq_data->interrupts[index]); - } - - acpi_os_printf (")\n"); - - if(0xFF != ext_irq_data->resource_source_index) { - acpi_os_printf ("\t\t_resource Source Index: %X", - ext_irq_data->resource_source_index); - acpi_os_printf ("\t\t_resource Source: %s", - ext_irq_data->resource_source); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_resource_list - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: - * - * DESCRIPTION: Dispatches the structure to the correct dump routine. - * - ******************************************************************************/ - -void -acpi_rs_dump_resource_list ( - RESOURCE *resource) -{ - u8 count = 0; - u8 done = FALSE; - - - if (acpi_dbg_level & TRACE_RESOURCES && _COMPONENT & acpi_dbg_layer) { - while (!done) { - acpi_os_printf ("\t_resource structure %x.\n", count++); - - switch (resource->id) { - case irq: - acpi_rs_dump_irq (&resource->data); - break; - - case dma: - acpi_rs_dump_dma (&resource->data); - break; - - case start_dependent_functions: - acpi_rs_dump_start_dependent_functions (&resource->data); - break; - - case end_dependent_functions: - acpi_os_printf ("\t_end_dependent_functions Resource\n"); - /* Acpi_rs_dump_end_dependent_functions (Resource->Data);*/ - break; - - case io: - acpi_rs_dump_io (&resource->data); - break; - - case fixed_io: - acpi_rs_dump_fixed_io (&resource->data); - break; - - case vendor_specific: - acpi_rs_dump_vendor_specific (&resource->data); - break; - - case end_tag: - /*Rs_dump_end_tag (Resource->Data);*/ - acpi_os_printf ("\t_end_tag Resource\n"); - done = TRUE; - break; - - case memory24: - acpi_rs_dump_memory24 (&resource->data); - break; - - case memory32: - acpi_rs_dump_memory32 (&resource->data); - break; - - case fixed_memory32: - acpi_rs_dump_fixed_memory32 (&resource->data); - break; - - case address16: - acpi_rs_dump_address16 (&resource->data); - break; - - case address32: - acpi_rs_dump_address32 (&resource->data); - break; - - case extended_irq: - acpi_rs_dump_extended_irq (&resource->data); - break; - - default: - acpi_os_printf ("Invalid resource type\n"); - break; - - } - - resource = (RESOURCE *) ((NATIVE_UINT) resource + - (NATIVE_UINT) resource->length); - } - } - - return; -} - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dump_irq_list - * - * PARAMETERS: Data - pointer to the routing table to dump. - * - * RETURN: - * - * DESCRIPTION: Dispatches the structures to the correct dump routine. - * - ******************************************************************************/ - -void -acpi_rs_dump_irq_list ( - u8 *route_table) -{ - u8 *buffer = route_table; - u8 count = 0; - u8 done = FALSE; - PCI_ROUTING_TABLE *prt_element; - - - if (acpi_dbg_level & TRACE_RESOURCES && _COMPONENT & acpi_dbg_layer) { - prt_element = (PCI_ROUTING_TABLE *) buffer; - - while (!done) { - acpi_os_printf ("\t_pCI IRQ Routing Table structure %X.\n", count++); - - acpi_os_printf ("\t\t_address: %X\n", - prt_element->address); - - acpi_os_printf ("\t\t_pin: %X\n", prt_element->pin); - - acpi_os_printf ("\t\t_source: %s\n", prt_element->source); - - acpi_os_printf ("\t\t_source_index: %X\n", - prt_element->source_index); - - buffer += prt_element->length; - - prt_element = (PCI_ROUTING_TABLE *) buffer; - - if(0 == prt_element->length) { - done = TRUE; - } - } - } - - return; -} - diff --git a/reactos/drivers/bus/acpi/resource/rsio.c b/reactos/drivers/bus/acpi/resource/rsio.c deleted file mode 100644 index a84b2a26b93..00000000000 --- a/reactos/drivers/bus/acpi/resource/rsio.c +++ /dev/null @@ -1,526 +0,0 @@ -/******************************************************************************* - * - * Module Name: rsio - Acpi_rs_io_resource - * Acpi_rs_fixed_io_resource - * Acpi_rs_io_stream - * Acpi_rs_fixed_io_stream - * Acpi_rs_dma_resource - * Acpi_rs_dma_stream - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rsio") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_io_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_io_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u32 struct_size = sizeof (IO_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * The number of bytes consumed are Constant - */ - *bytes_consumed = 8; - - output_struct->id = io; - - /* - * Check Decode - */ - buffer += 1; - temp8 = *buffer; - - output_struct->data.io.io_decode = temp8 & 0x01; - - /* - * Check Min_base Address - */ - buffer += 1; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - output_struct->data.io.min_base_address = temp16; - - /* - * Check Max_base Address - */ - buffer += 2; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - output_struct->data.io.max_base_address = temp16; - - /* - * Check Base alignment - */ - buffer += 2; - temp8 = *buffer; - - output_struct->data.io.alignment = temp8; - - /* - * Check Range_length - */ - buffer += 1; - temp8 = *buffer; - - output_struct->data.io.range_length = temp8; - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_fixed_io_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_fixed_io_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u32 struct_size = sizeof (FIXED_IO_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * The number of bytes consumed are Constant - */ - *bytes_consumed = 4; - - output_struct->id = fixed_io; - - /* - * Check Range Base Address - */ - buffer += 1; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - output_struct->data.fixed_io.base_address = temp16; - - /* - * Check Range_length - */ - buffer += 2; - temp8 = *buffer; - - output_struct->data.fixed_io.range_length = temp8; - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_io_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_io_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - /* - * The descriptor field is static - */ - *buffer = 0x47; - buffer += 1; - - /* - * Io Information Byte - */ - temp8 = (u8) (linked_list->data.io.io_decode & 0x01); - - *buffer = temp8; - buffer += 1; - - /* - * Set the Range minimum base address - */ - temp16 = (u16) linked_list->data.io.min_base_address; - - MOVE_UNALIGNED16_TO_16 (buffer, &temp16); - buffer += 2; - - /* - * Set the Range maximum base address - */ - temp16 = (u16) linked_list->data.io.max_base_address; - - MOVE_UNALIGNED16_TO_16 (buffer, &temp16); - buffer += 2; - - /* - * Set the base alignment - */ - temp8 = (u8) linked_list->data.io.alignment; - - *buffer = temp8; - buffer += 1; - - /* - * Set the range length - */ - temp8 = (u8) linked_list->data.io.range_length; - - *buffer = temp8; - buffer += 1; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_fixed_io_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_fixed_io_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - /* - * The descriptor field is static - */ - *buffer = 0x4B; - - buffer += 1; - - /* - * Set the Range base address - */ - temp16 = (u16) linked_list->data.fixed_io.base_address; - - MOVE_UNALIGNED16_TO_16 (buffer, &temp16); - buffer += 2; - - /* - * Set the range length - */ - temp8 = (u8) linked_list->data.fixed_io.range_length; - - *buffer = temp8; - buffer += 1; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dma_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_dma_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u8 temp8 = 0; - u8 index; - u8 i; - u32 struct_size = sizeof(DMA_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * The number of bytes consumed are Constant - */ - *bytes_consumed = 3; - output_struct->id = dma; - - /* - * Point to the 8-bits of Byte 1 - */ - buffer += 1; - temp8 = *buffer; - - /* Decode the IRQ bits */ - - for (i = 0, index = 0; index < 8; index++) { - if ((temp8 >> index) & 0x01) { - output_struct->data.dma.channels[i] = index; - i++; - } - } - output_struct->data.dma.number_of_channels = i; - - - /* - * Calculate the structure size based upon the number of interrupts - */ - struct_size += (output_struct->data.dma.number_of_channels - 1) * 4; - - /* - * Point to Byte 2 - */ - buffer += 1; - temp8 = *buffer; - - /* - * Check for transfer preference (Bits[1:0]) - */ - output_struct->data.dma.transfer = temp8 & 0x03; - - if (0x03 == output_struct->data.dma.transfer) { - return (AE_BAD_DATA); - } - - /* - * Get bus master preference (Bit[2]) - */ - output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01; - - /* - * Get channel speed support (Bits[6:5]) - */ - output_struct->data.dma.type = (temp8 >> 5) & 0x03; - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_dma_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_dma_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - - - /* - * The descriptor field is static - */ - *buffer = 0x2A; - buffer += 1; - temp8 = 0; - - /* - * Loop through all of the Channels and set the mask bits - */ - for (index = 0; - index < linked_list->data.dma.number_of_channels; - index++) { - temp16 = (u16) linked_list->data.dma.channels[index]; - temp8 |= 0x1 << temp16; - } - - *buffer = temp8; - buffer += 1; - - /* - * Set the DMA Info - */ - temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5); - temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2); - temp8 |= (linked_list->data.dma.transfer & 0x03); - - *buffer = temp8; - buffer += 1; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/resource/rsirq.c b/reactos/drivers/bus/acpi/resource/rsirq.c deleted file mode 100644 index b5dccbbd599..00000000000 --- a/reactos/drivers/bus/acpi/resource/rsirq.c +++ /dev/null @@ -1,555 +0,0 @@ -/******************************************************************************* - * - * Module Name: rsirq - Acpi_rs_irq_resource, - * Acpi_rs_irq_stream - * Acpi_rs_extended_irq_resource - * Acpi_rs_extended_irq_stream - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rsirq") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_irq_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_irq_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - u8 i; - u32 struct_size = sizeof (IRQ_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * The number of bytes consumed are contained in the descriptor - * (Bits:0-1) - */ - temp8 = *buffer; - *bytes_consumed = (temp8 & 0x03) + 1; - output_struct->id = irq; - - /* - * Point to the 16-bits of Bytes 1 and 2 - */ - buffer += 1; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - output_struct->data.irq.number_of_interrupts = 0; - - /* Decode the IRQ bits */ - - for (i = 0, index = 0; index < 16; index++) { - if((temp16 >> index) & 0x01) { - output_struct->data.irq.interrupts[i] = index; - i++; - } - } - output_struct->data.irq.number_of_interrupts = i; - - /* - * Calculate the structure size based upon the number of interrupts - */ - struct_size += (output_struct->data.irq.number_of_interrupts - 1) * 4; - - /* - * Point to Byte 3 if it is used - */ - if (4 == *bytes_consumed) { - buffer += 2; - temp8 = *buffer; - - /* - * Check for HE, LL or HL - */ - if (temp8 & 0x01) { - output_struct->data.irq.edge_level = EDGE_SENSITIVE; - output_struct->data.irq.active_high_low = ACTIVE_HIGH; - } - - else { - if (temp8 & 0x8) { - output_struct->data.irq.edge_level = LEVEL_SENSITIVE; - output_struct->data.irq.active_high_low = ACTIVE_LOW; - } - - else { - /* - * Only _LL and _HE polarity/trigger interrupts - * are allowed (ACPI spec v1.0b ection 6.4.2.1), - * so an error will occur if we reach this point - */ - return (AE_BAD_DATA); - } - } - - /* - * Check for sharable - */ - output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; - } - - else { - /* - * Assume Edge Sensitive, Active High, Non-Sharable - * per ACPI Specification - */ - output_struct->data.irq.edge_level = EDGE_SENSITIVE; - output_struct->data.irq.active_high_low = ACTIVE_HIGH; - output_struct->data.irq.shared_exclusive = EXCLUSIVE; - } - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_irq_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_irq_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - u8 IRQinfo_byte_needed; - - - /* - * The descriptor field is set based upon whether a third byte is - * needed to contain the IRQ Information. - */ - if (EDGE_SENSITIVE == linked_list->data.irq.edge_level && - ACTIVE_HIGH == linked_list->data.irq.active_high_low && - EXCLUSIVE == linked_list->data.irq.shared_exclusive) { - *buffer = 0x22; - IRQinfo_byte_needed = FALSE; - } - else { - *buffer = 0x23; - IRQinfo_byte_needed = TRUE; - } - - buffer += 1; - temp16 = 0; - - /* - * Loop through all of the interrupts and set the mask bits - */ - for(index = 0; - index < linked_list->data.irq.number_of_interrupts; - index++) { - temp8 = (u8) linked_list->data.irq.interrupts[index]; - temp16 |= 0x1 << temp8; - } - - MOVE_UNALIGNED16_TO_16 (buffer, &temp16); - buffer += 2; - - /* - * Set the IRQ Info byte if needed. - */ - if (IRQinfo_byte_needed) { - temp8 = 0; - temp8 = (u8) ((linked_list->data.irq.shared_exclusive & - 0x01) << 4); - - if (LEVEL_SENSITIVE == linked_list->data.irq.edge_level && - ACTIVE_LOW == linked_list->data.irq.active_high_low) { - temp8 |= 0x08; - } - - else { - temp8 |= 0x01; - } - - *buffer = temp8; - buffer += 1; - } - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_extended_irq_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_extended_irq_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - u32 struct_size = sizeof (EXTENDED_IRQ_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - buffer += 1; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - *bytes_consumed = temp16 + 3; - output_struct->id = extended_irq; - - /* - * Point to the Byte3 - */ - buffer += 2; - temp8 = *buffer; - - output_struct->data.extended_irq.producer_consumer = temp8 & 0x01; - - /* - * Check for HE, LL or HL - */ - if(temp8 & 0x02) { - output_struct->data.extended_irq.edge_level = EDGE_SENSITIVE; - output_struct->data.extended_irq.active_high_low = ACTIVE_HIGH; - } - - else { - if(temp8 & 0x4) { - output_struct->data.extended_irq.edge_level = LEVEL_SENSITIVE; - output_struct->data.extended_irq.active_high_low = ACTIVE_LOW; - } - - else { - /* - * Only _LL and _HE polarity/trigger interrupts - * are allowed (ACPI spec v1.0b ection 6.4.2.1), - * so an error will occur if we reach this point - */ - return (AE_BAD_DATA); - } - } - - /* - * Check for sharable - */ - output_struct->data.extended_irq.shared_exclusive = - (temp8 >> 3) & 0x01; - - /* - * Point to Byte4 (IRQ Table length) - */ - buffer += 1; - temp8 = *buffer; - - output_struct->data.extended_irq.number_of_interrupts = temp8; - - /* - * Add any additional structure size to properly calculate - * the next pointer at the end of this function - */ - struct_size += (temp8 - 1) * 4; - - /* - * Point to Byte5 (First IRQ Number) - */ - buffer += 1; - - /* - * Cycle through every IRQ in the table - */ - for (index = 0; index < temp8; index++) { - output_struct->data.extended_irq.interrupts[index] = - (u32)*buffer; - - /* Point to the next IRQ */ - - buffer += 4; - } - - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - */ - if (*bytes_consumed > - (u32)(output_struct->data.extended_irq.number_of_interrupts * - 4) + 5) { - /* Dereference the Index */ - - temp8 = *buffer; - output_struct->data.extended_irq.resource_source_index = - (u32)temp8; - - /* Point to the String */ - - buffer += 1; - - /* Copy the string into the buffer */ - - index = 0; - - while (0x00 != *buffer) { - output_struct->data.extended_irq.resource_source[index] = - *buffer; - - buffer += 1; - index += 1; - } - - /* - * Add the terminating null - */ - output_struct->data.extended_irq.resource_source[index] = 0x00; - output_struct->data.extended_irq.resource_source_string_length = - index + 1; - - /* - * In order for the Struct_size to fall on a 32-bit boundry, - * calculate the length of the string and expand the - * Struct_size to the next 32-bit boundry. - */ - temp8 = (u8) (index + 1); - temp8 = (u8) ROUND_UP_TO_32_bITS (temp8); - } - - else { - output_struct->data.extended_irq.resource_source_index = 0x00; - output_struct->data.extended_irq.resource_source_string_length = 0; - output_struct->data.extended_irq.resource_source[0] = 0x00; - } - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_extended_irq_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_extended_irq_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 *length_field; - u8 temp8 = 0; - u8 index; - NATIVE_CHAR *temp_pointer = NULL; - - - /* - * The descriptor field is static - */ - *buffer = 0x89; - buffer += 1; - - /* - * Set a pointer to the Length field - to be filled in later - */ - - length_field = (u16 *)buffer; - buffer += 2; - - /* - * Set the Interrupt vector flags - */ - temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01); - - temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); - - if (LEVEL_SENSITIVE == linked_list->data.extended_irq.edge_level && - ACTIVE_LOW == linked_list->data.extended_irq.active_high_low) { - temp8 |= 0x04; - } - else { - temp8 |= 0x02; - } - - *buffer = temp8; - buffer += 1; - - /* - * Set the Interrupt table length - */ - temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts; - - *buffer = temp8; - buffer += 1; - - for (index = 0; - index < linked_list->data.extended_irq.number_of_interrupts; - index++) { - MOVE_UNALIGNED32_TO_32 (buffer, - &linked_list->data.extended_irq.interrupts[index]); - buffer += 4; - } - - /* - * Resource Source Index and Resource Source are optional - */ - if (0 != linked_list->data.extended_irq.resource_source_string_length) { - *buffer = (u8) linked_list->data.extended_irq.resource_source_index; - buffer += 1; - - temp_pointer = (NATIVE_CHAR *) buffer; - - /* - * Copy the string - */ - STRCPY (temp_pointer, linked_list->data.extended_irq.resource_source); - - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - buffer += (STRLEN (linked_list->data.extended_irq.resource_source) + 1); - } - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - *length_field = (u16) (*bytes_consumed - 3); - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/resource/rslist.c b/reactos/drivers/bus/acpi/resource/rslist.c deleted file mode 100644 index 9c255d10846..00000000000 --- a/reactos/drivers/bus/acpi/resource/rslist.c +++ /dev/null @@ -1,499 +0,0 @@ -/******************************************************************************* - * - * Module Name: rslist - Acpi_rs_byte_stream_to_list - * Acpi_list_to_byte_stream - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rslist") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_byte_stream_to_list - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource byte stream - * Byte_stream_buffer_length - Length of Byte_stream_buffer - * Output_buffer - Pointer to the buffer that will - * contain the output structures - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Takes the resource byte stream and parses it, creating a - * linked list of resources in the caller's output buffer - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_byte_stream_to_list ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - u8 **output_buffer) -{ - ACPI_STATUS status; - u32 bytes_parsed = 0; - u8 resource_type = 0; - u32 bytes_consumed = 0; - u8 **buffer = output_buffer; - u32 structure_size = 0; - u8 end_tag_processed = FALSE; - - - while (bytes_parsed < byte_stream_buffer_length && - FALSE == end_tag_processed) { - /* - * Look at the next byte in the stream - */ - resource_type = *byte_stream_buffer; - - /* - * See if this is a small or large resource - */ - if(resource_type & 0x80) { - /* - * Large Resource Type - */ - switch (resource_type) { - case MEMORY_RANGE_24: - /* - * 24-Bit Memory Resource - */ - status = acpi_rs_memory24_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case LARGE_VENDOR_DEFINED: - /* - * Vendor Defined Resource - */ - status = acpi_rs_vendor_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case MEMORY_RANGE_32: - /* - * 32-Bit Memory Range Resource - */ - status = acpi_rs_memory32_range_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case FIXED_MEMORY_RANGE_32: - /* - * 32-Bit Fixed Memory Resource - */ - status = acpi_rs_fixed_memory32_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case DWORD_ADDRESS_SPACE: - /* - * 32-Bit Address Resource - */ - status = acpi_rs_address32_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case WORD_ADDRESS_SPACE: - /* - * 16-Bit Address Resource - */ - status = acpi_rs_address16_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case EXTENDED_IRQ: - /* - * Extended IRQ - */ - status = acpi_rs_extended_irq_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - -/* TBD: [Future] 64-bit not currently supported */ -/* - case 0x8A: - break; -*/ - - default: - /* - * If we get here, everything is out of sync, - * so exit with an error - */ - return (AE_AML_ERROR); - break; - } - } - - else { - /* - * Small Resource Type - * Only bits 7:3 are valid - */ - resource_type >>= 3; - - switch(resource_type) { - case IRQ_FORMAT: - /* - * IRQ Resource - */ - status = acpi_rs_irq_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case DMA_FORMAT: - /* - * DMA Resource - */ - status = acpi_rs_dma_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case START_DEPENDENT_TAG: - /* - * Start Dependent Functions Resource - */ - status = acpi_rs_start_dependent_functions_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case END_DEPENDENT_TAG: - /* - * End Dependent Functions Resource - */ - status = acpi_rs_end_dependent_functions_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case IO_PORT_DESCRIPTOR: - /* - * IO Port Resource - */ - status = acpi_rs_io_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case FIXED_LOCATION_IO_DESCRIPTOR: - /* - * Fixed IO Port Resource - */ - status = acpi_rs_fixed_io_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case SMALL_VENDOR_DEFINED: - /* - * Vendor Specific Resource - */ - status = acpi_rs_vendor_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - - break; - - case END_TAG: - /* - * End Tag - */ - status = acpi_rs_end_tag_resource(byte_stream_buffer, - &bytes_consumed, - buffer, - &structure_size); - end_tag_processed = TRUE; - - break; - - default: - /* - * If we get here, everything is out of sync, - * so exit with an error - */ - return (AE_AML_ERROR); - break; - - } /* switch */ - } /* end else */ - - /* - * Update the return value and counter - */ - bytes_parsed += bytes_consumed; - - /* - * Set the byte stream to point to the next resource - */ - byte_stream_buffer += bytes_consumed; - - /* - * Set the Buffer to the next structure - */ - *buffer += structure_size; - - } /* end while */ - - /* - * Check the reason for exiting the while loop - */ - if (TRUE != end_tag_processed) { - return (AE_AML_ERROR); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_list_to_byte_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Byte_steam_size_needed - Calculated size of the byte stream - * needed from calling - * Acpi_rs_calculate_byte_stream_length() - * The size of the Output_buffer is - * guaranteed to be >= - * Byte_stream_size_needed - * Output_buffer - Pointer to the buffer that will - * contain the byte stream - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Takes the resource linked list and parses it, creating a - * byte stream of resources in the caller's output buffer - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_list_to_byte_stream ( - RESOURCE *linked_list, - u32 byte_stream_size_needed, - u8 **output_buffer) -{ - ACPI_STATUS status; - u8 *buffer = *output_buffer; - u32 bytes_consumed = 0; - u8 done = FALSE; - - - while (!done) { - switch (linked_list->id) { - case irq: - /* - * IRQ Resource - */ - status = acpi_rs_irq_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case dma: - /* - * DMA Resource - */ - status = acpi_rs_dma_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case start_dependent_functions: - /* - * Start Dependent Functions Resource - */ - status = acpi_rs_start_dependent_functions_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case end_dependent_functions: - /* - * End Dependent Functions Resource - */ - status = acpi_rs_end_dependent_functions_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case io: - /* - * IO Port Resource - */ - status = acpi_rs_io_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case fixed_io: - /* - * Fixed IO Port Resource - */ - status = acpi_rs_fixed_io_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case vendor_specific: - /* - * Vendor Defined Resource - */ - status = acpi_rs_vendor_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case end_tag: - /* - * End Tag - */ - status = acpi_rs_end_tag_stream (linked_list, - &buffer, - &bytes_consumed); - - /* - * An End Tag indicates the end of the Resource Template - */ - done = TRUE; - break; - - case memory24: - /* - * 24-Bit Memory Resource - */ - status = acpi_rs_memory24_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case memory32: - /* - * 32-Bit Memory Range Resource - */ - status = acpi_rs_memory32_range_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case fixed_memory32: - /* - * 32-Bit Fixed Memory Resource - */ - status = acpi_rs_fixed_memory32_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case address16: - /* - * 16-Bit Address Descriptor Resource - */ - status = acpi_rs_address16_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case address32: - /* - * 32-Bit Address Descriptor Resource - */ - status = acpi_rs_address32_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - case extended_irq: - /* - * Extended IRQ Resource - */ - status = acpi_rs_extended_irq_stream (linked_list, - &buffer, - &bytes_consumed); - break; - - default: - /* - * If we get here, everything is out of sync, - * so exit with an error - */ - return (AE_BAD_DATA); - break; - - } /* switch (Linked_list->Id) */ - - /* - * Set the Buffer to point to the open byte - */ - buffer += bytes_consumed; - - /* - * Point to the next object - */ - linked_list = (RESOURCE *) ((NATIVE_UINT) linked_list + - (NATIVE_UINT) linked_list->length); - } - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/resource/rsmemory.c b/reactos/drivers/bus/acpi/resource/rsmemory.c deleted file mode 100644 index 3efab7d0695..00000000000 --- a/reactos/drivers/bus/acpi/resource/rsmemory.c +++ /dev/null @@ -1,556 +0,0 @@ -/******************************************************************************* - * - * Module Name: rsmem24 - Acpi_rs_memory24_resource - * Acpi_rs_memory24_stream - * Acpi_rs_memory32_range_resource - * Acpi_rs_fixed_memory32_resource - * Acpi_rs_memory32_range_stream - * Acpi_rs_fixed_memory32_stream - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rsmemory") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_memory24_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_memory24_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u32 struct_size = sizeof (MEMORY24_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - buffer += 1; - - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - buffer += 2; - *bytes_consumed = temp16 + 3; - output_struct->id = memory24; - - /* - * Check Byte 3 the Read/Write bit - */ - temp8 = *buffer; - buffer += 1; - output_struct->data.memory24.read_write_attribute = temp8 & 0x01; - - /* - * Get Min_base_address (Bytes 4-5) - */ - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - buffer += 2; - output_struct->data.memory24.min_base_address = temp16; - - /* - * Get Max_base_address (Bytes 6-7) - */ - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - buffer += 2; - output_struct->data.memory24.max_base_address = temp16; - - /* - * Get Alignment (Bytes 8-9) - */ - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - buffer += 2; - output_struct->data.memory24.alignment = temp16; - - /* - * Get Range_length (Bytes 10-11) - */ - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - output_struct->data.memory24.range_length = temp16; - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_memory24_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_memory24_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - /* - * The descriptor field is static - */ - *buffer = 0x81; - buffer += 1; - - /* - * The length field is static - */ - temp16 = 0x09; - MOVE_UNALIGNED16_TO_16 (buffer, &temp16); - buffer += 2; - - /* - * Set the Information Byte - */ - temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01); - *buffer = temp8; - buffer += 1; - - /* - * Set the Range minimum base address - */ - MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.min_base_address); - buffer += 2; - - /* - * Set the Range maximum base address - */ - MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.max_base_address); - buffer += 2; - - /* - * Set the base alignment - */ - MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.alignment); - buffer += 2; - - /* - * Set the range length - */ - MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.range_length); - buffer += 2; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_memory32_range_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_memory32_range_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u32 struct_size = sizeof (MEMORY32_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - buffer += 1; - - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - buffer += 2; - *bytes_consumed = temp16 + 3; - - output_struct->id = memory32; - - /* - * Point to the place in the output buffer where the data portion will - * begin. - * 1. Set the RESOURCE_DATA * Data to point to it's own address, then - * 2. Set the pointer to the next address. - * - * NOTE: Output_struct->Data is cast to u8, otherwise, this addition adds - * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8) - */ - - /* - * Check Byte 3 the Read/Write bit - */ - temp8 = *buffer; - buffer += 1; - - output_struct->data.memory32.read_write_attribute = temp8 & 0x01; - - /* - * Get Min_base_address (Bytes 4-7) - */ - MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.min_base_address, - buffer); - buffer += 4; - - /* - * Get Max_base_address (Bytes 8-11) - */ - MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.max_base_address, - buffer); - buffer += 4; - - /* - * Get Alignment (Bytes 12-15) - */ - MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.alignment, buffer); - buffer += 4; - - /* - * Get Range_length (Bytes 16-19) - */ - MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.range_length, buffer); - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_fixed_memory32_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_fixed_memory32_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u32 struct_size = sizeof (FIXED_MEMORY32_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - buffer += 1; - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - buffer += 2; - *bytes_consumed = temp16 + 3; - - output_struct->id = fixed_memory32; - - /* - * Check Byte 3 the Read/Write bit - */ - temp8 = *buffer; - buffer += 1; - output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01; - - /* - * Get Range_base_address (Bytes 4-7) - */ - MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, - buffer); - buffer += 4; - - /* - * Get Range_length (Bytes 8-11) - */ - MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_length, - buffer); - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_memory32_range_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_memory32_range_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - /* - * The descriptor field is static - */ - *buffer = 0x85; - buffer += 1; - - /* - * The length field is static - */ - temp16 = 0x11; - - MOVE_UNALIGNED16_TO_16 (buffer, &temp16); - buffer += 2; - - /* - * Set the Information Byte - */ - temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01); - *buffer = temp8; - buffer += 1; - - /* - * Set the Range minimum base address - */ - MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.min_base_address); - buffer += 4; - - /* - * Set the Range maximum base address - */ - MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.max_base_address); - buffer += 4; - - /* - * Set the base alignment - */ - MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.alignment); - buffer += 4; - - /* - * Set the range length - */ - MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.range_length); - buffer += 4; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_fixed_memory32_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_fixed_memory32_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - - /* - * The descriptor field is static - */ - *buffer = 0x86; - buffer += 1; - - /* - * The length field is static - */ - temp16 = 0x09; - - MOVE_UNALIGNED16_TO_16 (buffer, &temp16); - buffer += 2; - - /* - * Set the Information Byte - */ - temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01); - *buffer = temp8; - buffer += 1; - - /* - * Set the Range base address - */ - MOVE_UNALIGNED32_TO_32 (buffer, - &linked_list->data.fixed_memory32.range_base_address); - buffer += 4; - - /* - * Set the range length - */ - MOVE_UNALIGNED32_TO_32 (buffer, - &linked_list->data.fixed_memory32.range_length); - buffer += 4; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/resource/rsmisc.c b/reactos/drivers/bus/acpi/resource/rsmisc.c deleted file mode 100644 index 134ca94012b..00000000000 --- a/reactos/drivers/bus/acpi/resource/rsmisc.c +++ /dev/null @@ -1,605 +0,0 @@ -/******************************************************************************* - * - * Module Name: rsmisc - Acpi_rs_end_tag_resource - * Acpi_rs_end_tag_stream - * Acpi_rs_vendor_resource - * Acpi_rs_vendor_stream - * Acpi_rs_start_dependent_functions_resource - * Acpi_rs_end_dependent_functions_resource - * Acpi_rs_start_dependent_functions_stream - * Acpi_rs_end_dependent_functions_stream - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rsmisc") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_end_tag_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_end_tag_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u32 struct_size = RESOURCE_LENGTH; - - - /* - * The number of bytes consumed is static - */ - *bytes_consumed = 2; - - /* - * Fill out the structure - */ - output_struct->id = end_tag; - - /* - * Set the Length parameter - */ - output_struct->length = 0; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_end_tag_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_end_tag_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u8 temp8 = 0; - - - /* - * The descriptor field is static - */ - *buffer = 0x79; - buffer += 1; - - /* - * Set the Checksum - zero means that the resource data is treated as if - * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) - */ - temp8 = 0; - - *buffer = temp8; - buffer += 1; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_vendor_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_vendor_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - u32 struct_size = sizeof (VENDOR_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * Dereference the Descriptor to find if this is a large or small item. - */ - temp8 = *buffer; - - if (temp8 & 0x80) { - /* - * Large Item - */ - /* Point to the length field */ - - buffer += 1; - - /* Dereference */ - - MOVE_UNALIGNED16_TO_16 (&temp16, buffer); - - /* Calculate bytes consumed */ - - *bytes_consumed = temp16 + 3; - - /* Point to the first vendor byte */ - - buffer += 2; - } - - else { - /* - * Small Item - */ - - /* Dereference the size */ - - temp16 = (u8)(*buffer & 0x07); - - /* Calculate bytes consumed */ - - *bytes_consumed = temp16 + 1; - - /* Point to the first vendor byte */ - - buffer += 1; - } - - output_struct->id = vendor_specific; - output_struct->data.vendor_specific.length = temp16; - - for (index = 0; index < temp16; index++) { - output_struct->data.vendor_specific.reserved[index] = *buffer; - buffer += 1; - } - - /* - * In order for the Struct_size to fall on a 32-bit boundry, - * calculate the length of the vendor string and expand the - * Struct_size to the next 32-bit boundry. - */ - struct_size += ROUND_UP_TO_32_bITS (temp16); - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_vendor_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_vendor_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - - - /* - * Dereference the length to find if this is a large or small item. - */ - - if(linked_list->data.vendor_specific.length > 7) { - /* - * Large Item - */ - /* - * Set the descriptor field and length bytes - */ - *buffer = 0x84; - buffer += 1; - - temp16 = (u16) linked_list->data.vendor_specific.length; - - MOVE_UNALIGNED16_TO_16 (buffer, &temp16); - buffer += 2; - } - - else { - /* - * Small Item - */ - - /* - * Set the descriptor field - */ - temp8 = 0x70; - temp8 |= linked_list->data.vendor_specific.length; - - *buffer = temp8; - buffer += 1; - } - - /* - * Loop through all of the Vendor Specific fields - */ - for (index = 0; index < linked_list->data.vendor_specific.length; index++) { - temp8 = linked_list->data.vendor_specific.reserved[index]; - - *buffer = temp8; - buffer += 1; - } - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_start_dependent_functions_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_start_dependent_functions_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u8 temp8 = 0; - u32 struct_size = - sizeof(START_DEPENDENT_FUNCTIONS_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; - - - /* - * The number of bytes consumed are contained in the descriptor (Bits:0-1) - */ - temp8 = *buffer; - - *bytes_consumed = (temp8 & 0x01) + 1; - - output_struct->id = start_dependent_functions; - - /* - * Point to Byte 1 if it is used - */ - if (2 == *bytes_consumed) { - buffer += 1; - temp8 = *buffer; - - /* - * Check Compatibility priority - */ - output_struct->data.start_dependent_functions.compatibility_priority = - temp8 & 0x03; - - if (3 == output_struct->data.start_dependent_functions.compatibility_priority) { - return (AE_AML_ERROR); - } - - /* - * Check Performance/Robustness preference - */ - output_struct->data.start_dependent_functions.performance_robustness = - (temp8 >> 2) & 0x03; - - if (3 == output_struct->data.start_dependent_functions.performance_robustness) { - return (AE_AML_ERROR); - } - } - - else { - output_struct->data.start_dependent_functions.compatibility_priority = - ACCEPTABLE_CONFIGURATION; - - output_struct->data.start_dependent_functions.performance_robustness = - ACCEPTABLE_CONFIGURATION; - } - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_end_dependent_functions_resource - * - * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte - * stream - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes consumed from - * the Byte_stream_buffer - * Output_buffer - Pointer to the user's return buffer - * Structure_size - u32 pointer that is filled with - * the number of bytes in the filled - * in structure - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the Output_buffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_end_dependent_functions_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size) -{ - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u32 struct_size = RESOURCE_LENGTH; - - - /* - * The number of bytes consumed is static - */ - *bytes_consumed = 1; - - /* - * Fill out the structure - */ - output_struct->id = end_dependent_functions; - - /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* - * Return the final size of the structure - */ - *structure_size = struct_size; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_start_dependent_functions_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_start_dependent_functions_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed) -{ - u8 *buffer = *output_buffer; - u8 temp8 = 0; - - - /* - * The descriptor field is set based upon whether a byte is needed - * to contain Priority data. - */ - if (ACCEPTABLE_CONFIGURATION == - linked_list->data.start_dependent_functions.compatibility_priority && - ACCEPTABLE_CONFIGURATION == - linked_list->data.start_dependent_functions.performance_robustness) { - *buffer = 0x30; - } - else { - *buffer = 0x31; - buffer += 1; - - /* - * Set the Priority Byte Definition - */ - temp8 = 0; - temp8 = (u8) - ((linked_list->data.start_dependent_functions.performance_robustness & - 0x03) << 2); - temp8 |= - (linked_list->data.start_dependent_functions.compatibility_priority & - 0x03); - - *buffer = temp8; - } - - buffer += 1; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_end_dependent_functions_stream - * - * PARAMETERS: Linked_list - Pointer to the resource linked list - * Output_buffer - Pointer to the user's return buffer - * Bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * Output_buffer used - * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_end_dependent_functions_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed - ) -{ - u8 *buffer = *output_buffer; - - - /* - * The descriptor field is static - */ - *buffer = 0x38; - buffer += 1; - - /* - * Return the number of bytes consumed in this operation - */ - *bytes_consumed = (u32) ((NATIVE_UINT) buffer - - (NATIVE_UINT) *output_buffer); - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/resource/rsutils.c b/reactos/drivers/bus/acpi/resource/rsutils.c deleted file mode 100644 index a71b856d32a..00000000000 --- a/reactos/drivers/bus/acpi/resource/rsutils.c +++ /dev/null @@ -1,384 +0,0 @@ -/******************************************************************************* - * - * Module Name: rsutils - Utilities for the resource manager - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rsutils") - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_get_prt_method_data - * - * PARAMETERS: Handle - a handle to the containing object - * Ret_buffer - a pointer to a buffer structure for the - * results - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to get the _PRT value of an object - * contained in an object specified by the handle passed in - * - * If the function fails an appropriate status will be returned - * and the contents of the callers buffer is undefined. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_get_prt_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer) -{ - ACPI_OPERAND_OBJECT *ret_obj; - ACPI_STATUS status; - u32 buffer_space_needed; - - - /* already validated params, so we won't repeat here */ - - buffer_space_needed = ret_buffer->length; - - /* - * Execute the method, no parameters - */ - status = acpi_ns_evaluate_relative (handle, "_PRT", NULL, &ret_obj); - if (ACPI_FAILURE (status)) { - return (status); - } - - if (!ret_obj) { - /* Return object is required */ - - return (AE_TYPE); - } - - - /* - * The return object will be a package, so check the - * parameters. If the return object is not a package, - * then the underlying AML code is corrupt or improperly - * written. - */ - if (ACPI_TYPE_PACKAGE != ret_obj->common.type) { - status = AE_AML_OPERAND_TYPE; - goto cleanup; - } - - /* - * Make the call to create a resource linked list from the - * byte stream buffer that comes back from the _CRS method - * execution. - */ - status = acpi_rs_create_pci_routing_table (ret_obj, - ret_buffer->pointer, - &buffer_space_needed); - - /* - * Tell the user how much of the buffer we have used or is needed - * and return the final status. - */ - ret_buffer->length = buffer_space_needed; - - - /* On exit, we must delete the object returned by evaluate_object */ - -cleanup: - - acpi_cm_remove_reference (ret_obj); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_get_crs_method_data - * - * PARAMETERS: Handle - a handle to the containing object - * Ret_buffer - a pointer to a buffer structure for the - * results - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to get the _CRS value of an object - * contained in an object specified by the handle passed in - * - * If the function fails an appropriate status will be returned - * and the contents of the callers buffer is undefined. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_get_crs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer) -{ - ACPI_OPERAND_OBJECT *ret_obj; - ACPI_STATUS status; - u32 buffer_space_needed = ret_buffer->length; - - - /* already validated params, so we won't repeat here */ - - /* - * Execute the method, no parameters - */ - status = acpi_ns_evaluate_relative (handle, "_CRS", NULL, &ret_obj); - if (ACPI_FAILURE (status)) { - return (status); - } - - if (!ret_obj) { - /* Return object is required */ - - return (AE_TYPE); - } - - /* - * The return object will be a buffer, but check the - * parameters. If the return object is not a buffer, - * then the underlying AML code is corrupt or improperly - * written. - */ - if (ACPI_TYPE_BUFFER != ret_obj->common.type) { - status = AE_AML_OPERAND_TYPE; - goto cleanup; - } - - /* - * Make the call to create a resource linked list from the - * byte stream buffer that comes back from the _CRS method - * execution. - */ - status = acpi_rs_create_resource_list (ret_obj, - ret_buffer->pointer, - &buffer_space_needed); - - - - /* - * Tell the user how much of the buffer we have used or is needed - * and return the final status. - */ - ret_buffer->length = buffer_space_needed; - - - /* On exit, we must delete the object returned by evaluate_object */ - -cleanup: - - acpi_cm_remove_reference (ret_obj); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_get_prs_method_data - * - * PARAMETERS: Handle - a handle to the containing object - * Ret_buffer - a pointer to a buffer structure for the - * results - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to get the _PRS value of an object - * contained in an object specified by the handle passed in - * - * If the function fails an appropriate status will be returned - * and the contents of the callers buffer is undefined. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_get_prs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer) -{ - ACPI_OPERAND_OBJECT *ret_obj; - ACPI_STATUS status; - u32 buffer_space_needed = ret_buffer->length; - - - /* already validated params, so we won't repeat here */ - - /* - * Execute the method, no parameters - */ - status = acpi_ns_evaluate_relative (handle, "_PRS", NULL, &ret_obj); - if (ACPI_FAILURE (status)) { - return (status); - } - - if (!ret_obj) { - /* Return object is required */ - - return (AE_TYPE); - } - - /* - * The return object will be a buffer, but check the - * parameters. If the return object is not a buffer, - * then the underlying AML code is corrupt or improperly - * written.. - */ - if (ACPI_TYPE_BUFFER != ret_obj->common.type) { - status = AE_AML_OPERAND_TYPE; - goto cleanup; - } - - /* - * Make the call to create a resource linked list from the - * byte stream buffer that comes back from the _CRS method - * execution. - */ - status = acpi_rs_create_resource_list (ret_obj, - ret_buffer->pointer, - &buffer_space_needed); - - /* - * Tell the user how much of the buffer we have used or is needed - * and return the final status. - */ - ret_buffer->length = buffer_space_needed; - - - /* On exit, we must delete the object returned by evaluate_object */ - -cleanup: - - acpi_cm_remove_reference (ret_obj); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_rs_set_srs_method_data - * - * PARAMETERS: Handle - a handle to the containing object - * In_buffer - a pointer to a buffer structure of the - * parameter - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to set the _SRS of an object contained - * in an object specified by the handle passed in - * - * If the function fails an appropriate status will be returned - * and the contents of the callers buffer is undefined. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_rs_set_srs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *in_buffer) -{ - ACPI_OPERAND_OBJECT *params[2]; - ACPI_OPERAND_OBJECT param_obj; - ACPI_STATUS status; - u8 *byte_stream = NULL; - u32 buffer_size_needed = 0; - - - /* already validated params, so we won't repeat here */ - - /* - * The In_buffer parameter will point to a linked list of - * resource parameters. It needs to be formatted into a - * byte stream to be sent in as an input parameter. - */ - buffer_size_needed = 0; - - /* - * First call is to get the buffer size needed - */ - status = acpi_rs_create_byte_stream (in_buffer->pointer, - byte_stream, - &buffer_size_needed); - /* - * We expect a return of AE_BUFFER_OVERFLOW - * if not, exit with the error - */ - if (AE_BUFFER_OVERFLOW != status) { - return (status); - } - - /* - * Allocate the buffer needed - */ - byte_stream = acpi_cm_callocate(buffer_size_needed); - if (NULL == byte_stream) { - return (AE_NO_MEMORY); - } - - /* - * Now call to convert the linked list into a byte stream - */ - status = acpi_rs_create_byte_stream (in_buffer->pointer, - byte_stream, - &buffer_size_needed); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - /* - * Init the param object - */ - acpi_cm_init_static_object (¶m_obj); - - /* - * Method requires one parameter. Set it up - */ - params [0] = ¶m_obj; - params [1] = NULL; - - /* - * Set up the parameter object - */ - param_obj.common.type = ACPI_TYPE_BUFFER; - param_obj.buffer.length = buffer_size_needed; - param_obj.buffer.pointer = byte_stream; - - /* - * Execute the method, no return value - */ - status = acpi_ns_evaluate_relative (handle, "_SRS", params, NULL); - - /* - * Clean up and return the status from Acpi_ns_evaluate_relative - */ - -cleanup: - - acpi_cm_free (byte_stream); - return (status); -} - diff --git a/reactos/drivers/bus/acpi/resource/rsxface.c b/reactos/drivers/bus/acpi/resource/rsxface.c deleted file mode 100644 index b19536e9a3b..00000000000 --- a/reactos/drivers/bus/acpi/resource/rsxface.c +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * - * Module Name: rsxface - Public interfaces to the ACPI subsystem - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rsxface") - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_irq_routing_table - * - * PARAMETERS: Device_handle - a handle to the Bus device we are querying - * Ret_buffer - a pointer to a buffer to receive the - * current resources for the device - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to get the IRQ routing table for a - * specific bus. The caller must first acquire a handle for the - * desired bus. The routine table is placed in the buffer pointed - * to by the Ret_buffer variable parameter. - * - * If the function fails an appropriate status will be returned - * and the value of Ret_buffer is undefined. - * - * This function attempts to execute the _PRT method contained in - * the object indicated by the passed Device_handle. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_irq_routing_table ( - ACPI_HANDLE device_handle, - ACPI_BUFFER *ret_buffer) -{ - ACPI_STATUS status; - - - /* - * Must have a valid handle and buffer, So we have to have a handle - * and a return buffer structure, and if there is a non-zero buffer length - * we also need a valid pointer in the buffer. If it's a zero buffer length, - * we'll be returning the needed buffer size, so keep going. - */ - if ((!device_handle) || - (!ret_buffer) || - ((!ret_buffer->pointer) && (ret_buffer->length))) { - return (AE_BAD_PARAMETER); - } - - status = acpi_rs_get_prt_method_data (device_handle, ret_buffer); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_current_resources - * - * PARAMETERS: Device_handle - a handle to the device object for the - * device we are querying - * Ret_buffer - a pointer to a buffer to receive the - * current resources for the device - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to get the current resources for a - * specific device. The caller must first acquire a handle for - * the desired device. The resource data is placed in the buffer - * pointed to by the Ret_buffer variable parameter. - * - * If the function fails an appropriate status will be returned - * and the value of Ret_buffer is undefined. - * - * This function attempts to execute the _CRS method contained in - * the object indicated by the passed Device_handle. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_current_resources ( - ACPI_HANDLE device_handle, - ACPI_BUFFER *ret_buffer) -{ - ACPI_STATUS status; - - - /* - * Must have a valid handle and buffer, So we have to have a handle - * and a return buffer structure, and if there is a non-zero buffer length - * we also need a valid pointer in the buffer. If it's a zero buffer length, - * we'll be returning the needed buffer size, so keep going. - */ - if ((!device_handle) || - (!ret_buffer) || - ((ret_buffer->length) && (!ret_buffer->pointer))) { - return (AE_BAD_PARAMETER); - } - - status = acpi_rs_get_crs_method_data (device_handle, ret_buffer); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_possible_resources - * - * PARAMETERS: Device_handle - a handle to the device object for the - * device we are querying - * Ret_buffer - a pointer to a buffer to receive the - * resources for the device - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to get a list of the possible resources - * for a specific device. The caller must first acquire a handle - * for the desired device. The resource data is placed in the - * buffer pointed to by the Ret_buffer variable. - * - * If the function fails an appropriate status will be returned - * and the value of Ret_buffer is undefined. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_possible_resources ( - ACPI_HANDLE device_handle, - ACPI_BUFFER *ret_buffer) -{ - ACPI_STATUS status; - - - /* - * Must have a valid handle and buffer, So we have to have a handle - * and a return buffer structure, and if there is a non-zero buffer length - * we also need a valid pointer in the buffer. If it's a zero buffer length, - * we'll be returning the needed buffer size, so keep going. - */ - if ((!device_handle) || - (!ret_buffer) || - ((ret_buffer->length) && (!ret_buffer->pointer))) { - return (AE_BAD_PARAMETER); - } - - status = acpi_rs_get_prs_method_data (device_handle, ret_buffer); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_set_current_resources - * - * PARAMETERS: Device_handle - a handle to the device object for the - * device we are changing the resources of - * In_buffer - a pointer to a buffer containing the - * resources to be set for the device - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to set the current resources for a - * specific device. The caller must first acquire a handle for - * the desired device. The resource data is passed to the routine - * the buffer pointed to by the In_buffer variable. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_set_current_resources ( - ACPI_HANDLE device_handle, - ACPI_BUFFER *in_buffer) -{ - ACPI_STATUS status; - - - /* - * Must have a valid handle and buffer - */ - if ((!device_handle) || - (!in_buffer) || - (!in_buffer->pointer) || - (!in_buffer->length)) { - return (AE_BAD_PARAMETER); - } - - status = acpi_rs_set_srs_method_data (device_handle, in_buffer); - - return (status); -} diff --git a/reactos/drivers/bus/acpi/tables/tbconvrt.c b/reactos/drivers/bus/acpi/tables/tbconvrt.c deleted file mode 100644 index 77ece2ae07a..00000000000 --- a/reactos/drivers/bus/acpi/tables/tbconvrt.c +++ /dev/null @@ -1,547 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbconvrt - ACPI Table conversion utilities - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbconvrt") - - -/* - * Build a GAS structure from earlier ACPI table entries (V1.0 and 0.71 extensions) - * - * 1) Address space - * 2) Length in bytes -- convert to length in bits - * 3) Bit offset is zero - * 4) Reserved field is zero - * 5) Expand address to 64 bits - */ -#define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d) {a.address_space_id = (u8) d;\ - a.register_bit_width = (u8) MUL_8 (b);\ - a.register_bit_offset = 0;\ - a.reserved = 0;\ - ACPI_STORE_ADDRESS (a.address,c);} - - -/* ACPI V1.0 entries -- address space is always I/O */ - -#define ASL_BUILD_GAS_FROM_V1_ENTRY(a,b,c) ASL_BUILD_GAS_FROM_ENTRY(a,b,c,ADDRESS_SPACE_SYSTEM_IO) - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_convert_to_xsdt - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_convert_to_xsdt ( - ACPI_TABLE_DESC *table_info, - u32 *number_of_tables) { - u32 table_size; - u32 pointer_size; - u32 i; - XSDT_DESCRIPTOR *new_table; - - -#ifndef _IA64 - - if (acpi_gbl_RSDP->revision < 2) { - pointer_size = sizeof (u32); - } - - else -#endif - { - pointer_size = 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. - */ - - table_size = table_info->pointer->length; - *number_of_tables = (table_size - - sizeof (ACPI_TABLE_HEADER)) / pointer_size; - - /* Compute size of the converted XSDT */ - - table_size = (*number_of_tables * sizeof (UINT64)) + sizeof (ACPI_TABLE_HEADER); - - - /* Allocate an XSDT */ - - new_table = acpi_cm_callocate (table_size); - if (!new_table) { - return (AE_NO_MEMORY); - } - - /* Copy the header and set the length */ - - MEMCPY (new_table, table_info->pointer, sizeof (ACPI_TABLE_HEADER)); - new_table->header.length = table_size; - - /* Copy the table pointers */ - - for (i = 0; i < *number_of_tables; i++) { - if (acpi_gbl_RSDP->revision < 2) { -#ifdef _IA64 - new_table->table_offset_entry[i] = - ((RSDT_DESCRIPTOR_REV071 *) table_info->pointer)->table_offset_entry[i]; -#else - ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], - ((RSDT_DESCRIPTOR_REV1 *) table_info->pointer)->table_offset_entry[i]); -#endif - } - else { - new_table->table_offset_entry[i] = - ((XSDT_DESCRIPTOR *) table_info->pointer)->table_offset_entry[i]; - } - } - - - /* Delete the original table (either mapped or in a buffer) */ - - acpi_tb_delete_single_table (table_info); - - - /* Point the table descriptor to the new table */ - - table_info->pointer = (ACPI_TABLE_HEADER *) new_table; - table_info->base_pointer = (ACPI_TABLE_HEADER *) new_table; - table_info->length = table_size; - table_info->allocation = ACPI_MEM_ALLOCATED; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_convert_table_fadt - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * Converts BIOS supplied 1.0 and 0.71 ACPI FADT to an intermediate - * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply - * copied to the intermediate FADT. The ACPI CA software uses this - * intermediate FADT. Thus a significant amount of special #ifdef - * type codeing is saved. This intermediate FADT will need to be - * freed at some point. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_convert_table_fadt (void) -{ - -#ifdef _IA64 - FADT_DESCRIPTOR_REV071 *FADT71; - u8 pm1_address_space; - u8 pm2_address_space; - u8 pm_timer_address_space; - u8 gpe0address_space; - u8 gpe1_address_space; -#else - FADT_DESCRIPTOR_REV1 *FADT1; -#endif - - FADT_DESCRIPTOR_REV2 *FADT2; - ACPI_TABLE_DESC *table_desc; - - - /* Acpi_gbl_FADT is valid */ - /* Allocate and zero the 2.0 buffer */ - - FADT2 = acpi_cm_callocate (sizeof (FADT_DESCRIPTOR_REV2)); - if (FADT2 == NULL) { - return (AE_NO_MEMORY); - } - - - /* The ACPI FADT revision number is FADT2_REVISION_ID=3 */ - /* So, if the current table revision is less than 3 it is type 1.0 or 0.71 */ - - if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) { - /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ - - *FADT2 = *((FADT_DESCRIPTOR_REV2*) acpi_gbl_FADT); - - } - - else { - -#ifdef _IA64 - /* - * For the 64-bit case only, a revision ID less than V2.0 means the - * tables are the 0.71 extensions - */ - - /* The BIOS stored FADT should agree with Revision 0.71 */ - - FADT71 = (FADT_DESCRIPTOR_REV071 *) acpi_gbl_FADT; - - /* Copy the table header*/ - - FADT2->header = FADT71->header; - - /* Copy the common fields */ - - FADT2->sci_int = FADT71->sci_int; - FADT2->acpi_enable = FADT71->acpi_enable; - FADT2->acpi_disable = FADT71->acpi_disable; - FADT2->S4_bios_req = FADT71->S4_bios_req; - FADT2->plvl2_lat = FADT71->plvl2_lat; - FADT2->plvl3_lat = FADT71->plvl3_lat; - FADT2->day_alrm = FADT71->day_alrm; - FADT2->mon_alrm = FADT71->mon_alrm; - FADT2->century = FADT71->century; - FADT2->gpe1_base = FADT71->gpe1_base; - - /* - * We still use the block length registers even though - * the GAS structure should obsolete them. This is because - * these registers are byte lengths versus the GAS which - * contains a bit width - */ - FADT2->pm1_evt_len = FADT71->pm1_evt_len; - FADT2->pm1_cnt_len = FADT71->pm1_cnt_len; - FADT2->pm2_cnt_len = FADT71->pm2_cnt_len; - FADT2->pm_tm_len = FADT71->pm_tm_len; - FADT2->gpe0blk_len = FADT71->gpe0blk_len; - FADT2->gpe1_blk_len = FADT71->gpe1_blk_len; - FADT2->gpe1_base = FADT71->gpe1_base; - - /* Copy the existing 0.71 flags to 2.0. The other bits are zero.*/ - - FADT2->wb_invd = FADT71->flush_cash; - FADT2->proc_c1 = FADT71->proc_c1; - FADT2->plvl2_up = FADT71->plvl2_up; - FADT2->pwr_button = FADT71->pwr_button; - FADT2->sleep_button = FADT71->sleep_button; - FADT2->fixed_rTC = FADT71->fixed_rTC; - FADT2->rtcs4 = FADT71->rtcs4; - FADT2->tmr_val_ext = FADT71->tmr_val_ext; - FADT2->dock_cap = FADT71->dock_cap; - - - /* We should not use these next two addresses */ - /* Since our buffer is pre-zeroed nothing to do for */ - /* the next three data items in the structure */ - /* FADT2->Firmware_ctrl = 0; */ - /* FADT2->Dsdt = 0; */ - - /* System Interrupt Model isn't used in ACPI 2.0*/ - /* FADT2->Reserved1 = 0; */ - - /* This field is set by the OEM to convey the preferred */ - /* power management profile to OSPM. It doesn't have any*/ - /* 0.71 equivalence. Since we don't know what kind of */ - /* 64-bit system this is, we will pick unspecified. */ - - FADT2->prefer_PM_profile = PM_UNSPECIFIED; - - - /* Port address of SMI command port */ - /* We shouldn't use this port because IA64 doesn't */ - /* have or use SMI. It has PMI. */ - - FADT2->smi_cmd = (u32)(FADT71->smi_cmd & 0xFFFFFFFF); - - - /* processor performance state control*/ - /* The value OSPM writes to the SMI_CMD register to assume */ - /* processor performance state control responsibility. */ - /* There isn't any equivalence in 0.71 */ - /* Again this should be meaningless for IA64 */ - /* FADT2->Pstate_cnt = 0; */ - - /* The 32-bit Power management and GPE registers are */ - /* not valid in IA-64 and we are not going to use them */ - /* so leaving them pre-zeroed. */ - - /* Support for the _CST object and C States change notification.*/ - /* This data item hasn't any 0.71 equivalence so leaving it zero.*/ - /* FADT2->Cst_cnt = 0; */ - - /* number of flush strides that need to be read */ - /* No 0.71 equivalence. Leave pre-zeroed. */ - /* FADT2->Flush_size = 0; */ - - /* Processor's memory cache line width, in bytes */ - /* No 0.71 equivalence. Leave pre-zeroed. */ - /* FADT2->Flush_stride = 0; */ - - /* Processor's duty cycle index in processor's P_CNT reg*/ - /* No 0.71 equivalence. Leave pre-zeroed. */ - /* FADT2->Duty_offset = 0; */ - - /* Processor's duty cycle value bit width in P_CNT register.*/ - /* No 0.71 equivalence. Leave pre-zeroed. */ - /* FADT2->Duty_width = 0; */ - - - /* Since there isn't any equivalence in 0.71 */ - /* and since Big_sur had to support legacy */ - - FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES; - - /* Copy to ACPI 2.0 64-BIT Extended Addresses */ - - FADT2->Xfirmware_ctrl = FADT71->firmware_ctrl; - FADT2->Xdsdt = FADT71->dsdt; - - - /* Extract the address space IDs */ - - pm1_address_space = (u8)((FADT71->address_space & PM1_BLK_ADDRESS_SPACE) >> 1); - pm2_address_space = (u8)((FADT71->address_space & PM2_CNT_BLK_ADDRESS_SPACE) >> 2); - pm_timer_address_space = (u8)((FADT71->address_space & PM_TMR_BLK_ADDRESS_SPACE) >> 3); - gpe0address_space = (u8)((FADT71->address_space & GPE0_BLK_ADDRESS_SPACE) >> 4); - gpe1_address_space = (u8)((FADT71->address_space & GPE1_BLK_ADDRESS_SPACE) >> 5); - - /* - * Convert the 0.71 (non-GAS style) Block addresses to V2.0 GAS structures, - * in this order: - * - * PM 1_a Events - * PM 1_b Events - * PM 1_a Control - * PM 1_b Control - * PM 2 Control - * PM Timer Control - * GPE Block 0 - * GPE Block 1 - */ - - ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_evt_blk, FADT71->pm1_evt_len, FADT71->pm1a_evt_blk, pm1_address_space); - ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_evt_blk, FADT71->pm1_evt_len, FADT71->pm1b_evt_blk, pm1_address_space); - ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1a_cnt_blk, pm1_address_space); - ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1b_cnt_blk, pm1_address_space); - ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm2_cnt_blk, FADT71->pm2_cnt_len, FADT71->pm2_cnt_blk, pm2_address_space); - ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm_tmr_blk, FADT71->pm_tm_len, FADT71->pm_tmr_blk, pm_timer_address_space); - ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe0blk, FADT71->gpe0blk_len, FADT71->gpe0blk, gpe0address_space); - ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe1_blk, FADT71->gpe1_blk_len, FADT71->gpe1_blk, gpe1_address_space); - -#else - - /* ACPI 1.0 FACS */ - - - /* The BIOS stored FADT should agree with Revision 1.0 */ - - FADT1 = (FADT_DESCRIPTOR_REV1*) acpi_gbl_FADT; - - /* - * Copy the table header and the common part of the tables - * The 2.0 table is an extension of the 1.0 table, so the - * entire 1.0 table can be copied first, then expand some - * fields to 64 bits. - */ - - MEMCPY (FADT2, FADT1, sizeof (FADT_DESCRIPTOR_REV1)); - - - /* Convert table pointers to 64-bit fields */ - - ACPI_STORE_ADDRESS (FADT2->Xfirmware_ctrl, FADT1->firmware_ctrl); - ACPI_STORE_ADDRESS (FADT2->Xdsdt, FADT1->dsdt); - - /* System Interrupt Model isn't used in ACPI 2.0*/ - /* FADT2->Reserved1 = 0; */ - - /* This field is set by the OEM to convey the preferred */ - /* power management profile to OSPM. It doesn't have any*/ - /* 1.0 equivalence. Since we don't know what kind of */ - /* 32-bit system this is, we will pick unspecified. */ - - FADT2->prefer_PM_profile = PM_UNSPECIFIED; - - - /* Processor Performance State Control. This is the value */ - /* OSPM writes to the SMI_CMD register to assume processor */ - /* performance state control responsibility. There isn't */ - /* any equivalence in 1.0. So leave it zeroed. */ - - FADT2->pstate_cnt = 0; - - - /* Support for the _CST object and C States change notification.*/ - /* This data item hasn't any 1.0 equivalence so leaving it zero.*/ - - FADT2->cst_cnt = 0; - - - /* Since there isn't any equivalence in 1.0 and since it */ - /* is highly likely that a 1.0 system has legacy support. */ - - FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES; - - - /* - * Convert the V1.0 Block addresses to V2.0 GAS structures - * in this order: - * - * PM 1_a Events - * PM 1_b Events - * PM 1_a Control - * PM 1_b Control - * PM 2 Control - * PM Timer Control - * GPE Block 0 - * GPE Block 1 - */ - - ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_evt_blk, FADT1->pm1_evt_len, FADT1->pm1a_evt_blk); - ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_evt_blk, FADT1->pm1_evt_len, FADT1->pm1b_evt_blk); - ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1a_cnt_blk); - ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1b_cnt_blk); - ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm2_cnt_blk, FADT1->pm2_cnt_len, FADT1->pm2_cnt_blk); - ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm_tmr_blk, FADT1->pm_tm_len, FADT1->pm_tmr_blk); - ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe0blk, FADT1->gpe0blk_len, FADT1->gpe0blk); - ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe1_blk, FADT1->gpe1_blk_len, FADT1->gpe1_blk); -#endif - } - - - /* - * Global FADT pointer will point to the common V2.0 FADT - */ - acpi_gbl_FADT = FADT2; - acpi_gbl_FADT->header.length = sizeof (FADT_DESCRIPTOR); - - - /* Free the original table */ - - table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_FADT]; - acpi_tb_delete_single_table (table_desc); - - - /* Install the new table */ - - table_desc->pointer = (ACPI_TABLE_HEADER *) acpi_gbl_FADT; - table_desc->base_pointer = acpi_gbl_FADT; - table_desc->allocation = ACPI_MEM_ALLOCATED; - table_desc->length = sizeof (FADT_DESCRIPTOR_REV2); - - - /* Dump the entire FADT */ - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_convert_table_facs - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_build_common_facs ( - ACPI_TABLE_DESC *table_info) -{ - ACPI_COMMON_FACS *common_facs; - -#ifdef _IA64 - FACS_DESCRIPTOR_REV071 *FACS71; -#else - FACS_DESCRIPTOR_REV1 *FACS1; -#endif - - FACS_DESCRIPTOR_REV2 *FACS2; - - - /* Allocate a common FACS */ - - common_facs = acpi_cm_callocate (sizeof (ACPI_COMMON_FACS)); - if (!common_facs) { - return (AE_NO_MEMORY); - } - - - /* Copy fields to the new FACS */ - - if (acpi_gbl_RSDP->revision < 2) { -#ifdef _IA64 - /* 0.71 FACS */ - - FACS71 = (FACS_DESCRIPTOR_REV071 *) acpi_gbl_FACS; - - common_facs->global_lock = (u32 *) &(FACS71->global_lock); - common_facs->firmware_waking_vector = &FACS71->firmware_waking_vector; - common_facs->vector_width = 64; -#else - /* ACPI 1.0 FACS */ - - FACS1 = (FACS_DESCRIPTOR_REV1 *) acpi_gbl_FACS; - - common_facs->global_lock = &(FACS1->global_lock); - common_facs->firmware_waking_vector = (UINT64 *) &FACS1->firmware_waking_vector; - common_facs->vector_width = 32; - -#endif - } - - else { - /* ACPI 2.0 FACS */ - - FACS2 = (FACS_DESCRIPTOR_REV2 *) acpi_gbl_FACS; - - common_facs->global_lock = &(FACS2->global_lock); - common_facs->firmware_waking_vector = &FACS2->Xfirmware_waking_vector; - common_facs->vector_width = 64; - } - - - /* Set the global FACS pointer to point to the common FACS */ - - - acpi_gbl_FACS = common_facs; - - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/tables/tbget.c b/reactos/drivers/bus/acpi/tables/tbget.c deleted file mode 100644 index e16db9d26b3..00000000000 --- a/reactos/drivers/bus/acpi/tables/tbget.c +++ /dev/null @@ -1,608 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbget - ACPI Table get* routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbget") - -#define RSDP_CHECKSUM_LENGTH 20 - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_get_table_ptr - * - * PARAMETERS: Table_type - one of the defined table types - * Instance - Which table of this type - * Table_ptr_loc - pointer to location to place the pointer for - * return - * - * RETURN: Status - * - * DESCRIPTION: This function is called to get the pointer to an ACPI table. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_get_table_ptr ( - ACPI_TABLE_TYPE table_type, - u32 instance, - ACPI_TABLE_HEADER **table_ptr_loc) -{ - ACPI_TABLE_DESC *table_desc; - u32 i; - - - if (!acpi_gbl_DSDT) { - return (AE_NO_ACPI_TABLES); - } - - if (table_type > ACPI_TABLE_MAX) { - return (AE_BAD_PARAMETER); - } - - - /* - * For all table types (Single/Multiple), the first - * instance is always in the list head. - */ - - if (instance == 1) { - /* - * Just pluck the pointer out of the global table! - * Will be null if no table is present - */ - - *table_ptr_loc = acpi_gbl_acpi_tables[table_type].pointer; - return (AE_OK); - } - - - /* - * Check for instance out of range - */ - if (instance > acpi_gbl_acpi_tables[table_type].count) { - return (AE_NOT_EXIST); - } - - /* Walk the list to get the desired table - * Since the if (Instance == 1) check above checked for the - * first table, setting Table_desc equal to the .Next member - * is actually pointing to the second table. Therefore, we - * need to walk from the 2nd table until we reach the Instance - * that the user is looking for and return its table pointer. - */ - table_desc = acpi_gbl_acpi_tables[table_type].next; - for (i = 2; i < instance; i++) { - table_desc = table_desc->next; - } - - /* We are now pointing to the requested table's descriptor */ - - *table_ptr_loc = table_desc->pointer; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_get_table - * - * PARAMETERS: Physical_address - Physical address of table to retrieve - * *Buffer_ptr - If Buffer_ptr is valid, read data from - * buffer rather than searching memory - * *Table_info - Where the table info is returned - * - * RETURN: Status - * - * DESCRIPTION: Maps the physical address of table into a logical address - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_get_table ( - ACPI_PHYSICAL_ADDRESS physical_address, - ACPI_TABLE_HEADER *buffer_ptr, - ACPI_TABLE_DESC *table_info) -{ - ACPI_TABLE_HEADER *table_header = NULL; - ACPI_TABLE_HEADER *full_table = NULL; - u32 size; - u8 allocation; - ACPI_STATUS status = AE_OK; - - - if (!table_info) { - return (AE_BAD_PARAMETER); - } - - - if (buffer_ptr) { - /* - * Getting data from a buffer, not BIOS tables - */ - - table_header = buffer_ptr; - status = acpi_tb_validate_table_header (table_header); - if (ACPI_FAILURE (status)) { - /* Table failed verification, map all errors to BAD_DATA */ - - return (AE_BAD_DATA); - } - - /* Allocate buffer for the entire table */ - - full_table = acpi_cm_allocate (table_header->length); - if (!full_table) { - return (AE_NO_MEMORY); - } - - /* Copy the entire table (including header) to the local buffer */ - - size = table_header->length; - MEMCPY (full_table, buffer_ptr, size); - - /* Save allocation type */ - - allocation = ACPI_MEM_ALLOCATED; - } - - - /* - * Not reading from a buffer, just map the table's physical memory - * into our address space. - */ - else { - size = SIZE_IN_HEADER; - - status = acpi_tb_map_acpi_table (physical_address, &size, - (void **) &full_table); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Save allocation type */ - - allocation = ACPI_MEM_MAPPED; - } - - - /* Return values */ - - table_info->pointer = full_table; - table_info->length = size; - table_info->allocation = allocation; - table_info->base_pointer = full_table; - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_get_all_tables - * - * PARAMETERS: Number_of_tables - Number of tables to get - * Table_ptr - Input buffer pointer, optional - * - * RETURN: Status - * - * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must - * already be loaded and validated. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_get_all_tables ( - u32 number_of_tables, - ACPI_TABLE_HEADER *table_ptr) -{ - ACPI_STATUS status = AE_OK; - u32 index; - ACPI_TABLE_DESC table_info; - - - /* - * Loop through all table pointers found in RSDT. - * This will NOT include the FACS and DSDT - we must get - * them after the loop - */ - - for (index = 0; index < number_of_tables; index++) { - /* Clear the Table_info each time */ - - MEMSET (&table_info, 0, sizeof (ACPI_TABLE_DESC)); - - /* Get the table via the XSDT */ - - status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) - ACPI_GET_ADDRESS (acpi_gbl_XSDT->table_offset_entry[index]), - table_ptr, &table_info); - - /* Ignore a table that failed verification */ - - if (status == AE_BAD_DATA) { - continue; - } - - /* However, abort on serious errors */ - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Recognize and install the table */ - - status = acpi_tb_install_table (table_ptr, &table_info); - if (ACPI_FAILURE (status)) { - /* - * Unrecognized or unsupported table, delete it and ignore the - * error. Just get as many tables as we can, later we will - * determine if there are enough tables to continue. - */ - - acpi_tb_uninstall_table (&table_info); - } - } - - - /* - * Convert the FADT to a common format. This allows earlier revisions of the - * table to coexist with newer versions, using common access code. - */ - status = acpi_tb_convert_table_fadt (); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* - * Get the minimum set of ACPI tables, namely: - * - * 1) FADT (via RSDT in loop above) - * 2) FACS - * 3) DSDT - * - */ - - - /* - * Get the FACS (must have the FADT first, from loop above) - * Acpi_tb_get_table_facs will fail if FADT pointer is not valid - */ - - status = acpi_tb_get_table_facs (table_ptr, &table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* Install the FACS */ - - status = acpi_tb_install_table (table_ptr, &table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Create the common FACS pointer table - * (Contains pointers to the original table) - */ - - status = acpi_tb_build_common_facs (&table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* - * Get the DSDT (We know that the FADT is valid now) - */ - - status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xdsdt), - table_ptr, &table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Install the DSDT */ - - status = acpi_tb_install_table (table_ptr, &table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Dump the DSDT Header */ - - /* Dump the entire DSDT */ - - /* - * Initialize the capabilities flags. - * Assumes that platform supports ACPI_MODE since we have tables! - */ - acpi_gbl_system_flags |= acpi_hw_get_mode_capabilities (); - - - /* Always delete the RSDP mapping, we are done with it */ - - acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_verify_rsdp - * - * PARAMETERS: Number_of_tables - Where the table count is placed - * - * RETURN: Status - * - * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_verify_rsdp ( - ACPI_PHYSICAL_ADDRESS rsdp_physical_address) -{ - ACPI_TABLE_DESC table_info; - ACPI_STATUS status; - u8 *table_ptr; - - - /* - * Obtain access to the RSDP structure - */ - status = acpi_os_map_memory (rsdp_physical_address, - sizeof (RSDP_DESCRIPTOR), - (void **) &table_ptr); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * The signature and checksum must both be correct - */ - if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { - /* Nope, BAD Signature */ - - status = AE_BAD_SIGNATURE; - goto cleanup; - } - - if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) { - /* Nope, BAD Checksum */ - - status = AE_BAD_CHECKSUM; - goto cleanup; - } - - /* TBD: Check extended checksum if table version >= 2 */ - - /* The RSDP supplied is OK */ - - table_info.pointer = (ACPI_TABLE_HEADER *) table_ptr; - table_info.length = sizeof (RSDP_DESCRIPTOR); - table_info.allocation = ACPI_MEM_MAPPED; - table_info.base_pointer = table_ptr; - - /* Save the table pointers and allocation info */ - - status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); - if (ACPI_FAILURE (status)) { - goto cleanup; - } - - - /* Save the RSDP in a global for easy access */ - - acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer; - return (status); - - - /* Error exit */ -cleanup: - - acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR)); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_get_table_rsdt - * - * PARAMETERS: Number_of_tables - Where the table count is placed - * - * RETURN: Status - * - * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_get_table_rsdt ( - u32 *number_of_tables) -{ - ACPI_TABLE_DESC table_info; - ACPI_STATUS status = AE_OK; - ACPI_PHYSICAL_ADDRESS physical_address; - u32 signature_length; - char *table_signature; - - - /* - * Get the RSDT from the RSDP - */ - - /* - * For RSDP revision 0 or 1, we use the RSDT. - * For RSDP revision 2 (and above), we use the XSDT - */ - if (acpi_gbl_RSDP->revision < 2) { -#ifdef _IA64 - /* 0.71 RSDP has 64bit Rsdt address field */ - physical_address = ((RSDP_DESCRIPTOR_REV071 *)acpi_gbl_RSDP)->rsdt_physical_address; -#else - physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->rsdt_physical_address; -#endif - table_signature = RSDT_SIG; - signature_length = sizeof (RSDT_SIG) -1; - } - else { - physical_address = (ACPI_PHYSICAL_ADDRESS) - ACPI_GET_ADDRESS (acpi_gbl_RSDP->xsdt_physical_address); - table_signature = XSDT_SIG; - signature_length = sizeof (XSDT_SIG) -1; - } - - - /* Get the RSDT/XSDT */ - - status = acpi_tb_get_table (physical_address, NULL, &table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - - /* Check the RSDT or XSDT signature */ - - if (STRNCMP ((char *) table_info.pointer, table_signature, - signature_length)) { - /* Invalid RSDT or XSDT signature */ - - REPORT_ERROR (("Invalid signature where RSDP indicates %s should be located\n", - table_signature)); - - return (AE_NO_ACPI_TABLES); - } - - - /* Valid RSDT signature, verify the checksum */ - - status = acpi_tb_verify_table_checksum (table_info.pointer); - - - /* Convert and/or copy to an XSDT structure */ - - status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Save the table pointers and allocation info */ - - status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - acpi_gbl_XSDT = (XSDT_DESCRIPTOR *) table_info.pointer; - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_tb_get_table_facs - * - * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from - * buffer rather than searching memory - * *Table_info - Where the table info is returned - * - * RETURN: Status - * - * DESCRIPTION: Returns a pointer to the FACS as defined in FADT. This - * function assumes the global variable FADT has been - * correctly initialized. The value of FADT->Firmware_ctrl - * into a far pointer which is returned. - * - *****************************************************************************/ - -ACPI_STATUS -acpi_tb_get_table_facs ( - ACPI_TABLE_HEADER *buffer_ptr, - ACPI_TABLE_DESC *table_info) -{ - void *table_ptr = NULL; - u32 size; - u8 allocation; - ACPI_STATUS status = AE_OK; - - - /* Must have a valid FADT pointer */ - - if (!acpi_gbl_FADT) { - return (AE_NO_ACPI_TABLES); - } - - size = sizeof (FACS_DESCRIPTOR); - if (buffer_ptr) { - /* - * Getting table from a file -- allocate a buffer and - * read the table. - */ - table_ptr = acpi_cm_allocate (size); - if(!table_ptr) { - return (AE_NO_MEMORY); - } - - MEMCPY (table_ptr, buffer_ptr, size); - - /* Save allocation type */ - - allocation = ACPI_MEM_ALLOCATED; - } - - else { - /* Just map the physical memory to our address space */ - - status = acpi_tb_map_acpi_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xfirmware_ctrl), - &size, &table_ptr); - if (ACPI_FAILURE(status)) { - return (status); - } - - /* Save allocation type */ - - allocation = ACPI_MEM_MAPPED; - } - - - /* Return values */ - - table_info->pointer = table_ptr; - table_info->length = size; - table_info->allocation = allocation; - table_info->base_pointer = table_ptr; - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/tables/tbinstal.c b/reactos/drivers/bus/acpi/tables/tbinstal.c deleted file mode 100644 index 91c176f81a8..00000000000 --- a/reactos/drivers/bus/acpi/tables/tbinstal.c +++ /dev/null @@ -1,531 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbinstal - ACPI table installation and removal - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbinstal") - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_install_table - * - * PARAMETERS: Table_ptr - Input buffer pointer, optional - * Table_info - Return value from Acpi_tb_get_table - * - * RETURN: Status - * - * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must - * already be loaded and validated. - * Install the table into the global data structs. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_install_table ( - ACPI_TABLE_HEADER *table_ptr, - ACPI_TABLE_DESC *table_info) -{ - ACPI_STATUS status; - - - /* - * Check the table signature and make sure it is recognized - * Also checks the header checksum - */ - - status = acpi_tb_recognize_table (table_ptr, table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Lock tables while installing */ - - acpi_cm_acquire_mutex (ACPI_MTX_TABLES); - - /* Install the table into the global data structure */ - - status = acpi_tb_init_table_descriptor (table_info->type, table_info); - - acpi_cm_release_mutex (ACPI_MTX_TABLES); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_recognize_table - * - * PARAMETERS: Table_ptr - Input buffer pointer, optional - * Table_info - Return value from Acpi_tb_get_table - * - * RETURN: Status - * - * DESCRIPTION: Check a table signature for a match against known table types - * - * NOTE: All table pointers are validated as follows: - * 1) Table pointer must point to valid physical memory - * 2) Signature must be 4 ASCII chars, even if we don't recognize the - * name - * 3) Table must be readable for length specified in the header - * 4) Table checksum must be valid (with the exception of the FACS - * which has no checksum for some odd reason) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_recognize_table ( - ACPI_TABLE_HEADER *table_ptr, - ACPI_TABLE_DESC *table_info) -{ - ACPI_TABLE_HEADER *table_header; - ACPI_STATUS status; - ACPI_TABLE_TYPE table_type = 0; - u32 i; - - - /* Ensure that we have a valid table pointer */ - - table_header = (ACPI_TABLE_HEADER *) table_info->pointer; - if (!table_header) { - return (AE_BAD_PARAMETER); - } - - /* - * Search for a signature match among the known table types - * Start at index one -> Skip the RSDP - */ - - status = AE_SUPPORT; - for (i = 1; i < NUM_ACPI_TABLES; i++) { - if (!STRNCMP (table_header->signature, - acpi_gbl_acpi_table_data[i].signature, - acpi_gbl_acpi_table_data[i].sig_length)) { - /* - * Found a signature match, get the pertinent info from the - * Table_data structure - */ - - table_type = i; - status = acpi_gbl_acpi_table_data[i].status; - - break; - } - } - - /* Return the table type and length via the info struct */ - - table_info->type = (u8) table_type; - table_info->length = table_header->length; - - - /* - * Validate checksum for _most_ tables, - * even the ones whose signature we don't recognize - */ - - if (table_type != ACPI_TABLE_FACS) { - /* But don't abort if the checksum is wrong */ - /* TBD: [Future] make this a configuration option? */ - - acpi_tb_verify_table_checksum (table_header); - } - - /* - * An AE_SUPPORT means that the table was not recognized. - * We basically ignore this; just print a debug message - */ - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_init_table_descriptor - * - * PARAMETERS: Table_type - The type of the table - * Table_info - A table info struct - * - * RETURN: None. - * - * DESCRIPTION: Install a table into the global data structs. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_init_table_descriptor ( - ACPI_TABLE_TYPE table_type, - ACPI_TABLE_DESC *table_info) -{ - ACPI_TABLE_DESC *list_head; - ACPI_TABLE_DESC *table_desc; - - - /* - * Install the table into the global data structure - */ - - list_head = &acpi_gbl_acpi_tables[table_type]; - table_desc = list_head; - - - /* - * Two major types of tables: 1) Only one instance is allowed. This - * includes most ACPI tables such as the DSDT. 2) Multiple instances of - * the table are allowed. This includes SSDT and PSDTs. - */ - - if (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags)) { - /* - * Only one table allowed, and a table has alread been installed - * at this location, so return an error. - */ - - if (list_head->pointer) { - return (AE_EXIST); - } - - table_desc->count = 1; - } - - - else { - /* - * Multiple tables allowed for this table type, we must link - * the new table in to the list of tables of this type. - */ - - if (list_head->pointer) { - table_desc = acpi_cm_callocate (sizeof (ACPI_TABLE_DESC)); - if (!table_desc) { - return (AE_NO_MEMORY); - } - - list_head->count++; - - /* Update the original previous */ - - list_head->prev->next = table_desc; - - /* Update new entry */ - - table_desc->prev = list_head->prev; - table_desc->next = list_head; - - /* Update list head */ - - list_head->prev = table_desc; - } - - else { - table_desc->count = 1; - } - } - - - /* Common initialization of the table descriptor */ - - table_desc->pointer = table_info->pointer; - table_desc->base_pointer = table_info->base_pointer; - table_desc->length = table_info->length; - table_desc->allocation = table_info->allocation; - table_desc->aml_pointer = (u8 *) (table_desc->pointer + 1), - table_desc->aml_length = (u32) (table_desc->length - - (u32) sizeof (ACPI_TABLE_HEADER)); - table_desc->table_id = acpi_cm_allocate_owner_id (OWNER_TYPE_TABLE); - table_desc->loaded_into_namespace = FALSE; - - /* - * Set the appropriate global pointer (if there is one) to point to the - * newly installed table - */ - - if (acpi_gbl_acpi_table_data[table_type].global_ptr) { - *(acpi_gbl_acpi_table_data[table_type].global_ptr) = table_info->pointer; - } - - - /* Return Data */ - - table_info->table_id = table_desc->table_id; - table_info->installed_desc = table_desc; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_delete_acpi_tables - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete all internal ACPI tables - * - ******************************************************************************/ - -void -acpi_tb_delete_acpi_tables (void) -{ - ACPI_TABLE_TYPE type; - - - /* - * Free memory allocated for ACPI tables - * Memory can either be mapped or allocated - */ - - for (type = 0; type < NUM_ACPI_TABLES; type++) { - acpi_tb_delete_acpi_table (type); - } - -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_delete_acpi_table - * - * PARAMETERS: Type - The table type to be deleted - * - * RETURN: None. - * - * DESCRIPTION: Delete an internal ACPI table - * Locks the ACPI table mutex - * - ******************************************************************************/ - -void -acpi_tb_delete_acpi_table ( - ACPI_TABLE_TYPE type) -{ - - if (type > ACPI_TABLE_MAX) { - return; - } - - - acpi_cm_acquire_mutex (ACPI_MTX_TABLES); - - /* Free the table */ - - acpi_tb_free_acpi_tables_of_type (&acpi_gbl_acpi_tables[type]); - - - /* Clear the appropriate "typed" global table pointer */ - - switch (type) { - case ACPI_TABLE_RSDP: - acpi_gbl_RSDP = NULL; - break; - - case ACPI_TABLE_DSDT: - acpi_gbl_DSDT = NULL; - break; - - case ACPI_TABLE_FADT: - acpi_gbl_FADT = NULL; - break; - - case ACPI_TABLE_FACS: - acpi_gbl_FACS = NULL; - break; - - case ACPI_TABLE_XSDT: - acpi_gbl_XSDT = NULL; - break; - - case ACPI_TABLE_SSDT: - case ACPI_TABLE_PSDT: - default: - break; - } - - acpi_cm_release_mutex (ACPI_MTX_TABLES); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_free_acpi_tables_of_type - * - * PARAMETERS: Table_info - A table info struct - * - * RETURN: None. - * - * DESCRIPTION: Free the memory associated with an internal ACPI table - * Table mutex should be locked. - * - ******************************************************************************/ - -void -acpi_tb_free_acpi_tables_of_type ( - ACPI_TABLE_DESC *list_head) -{ - ACPI_TABLE_DESC *table_desc; - u32 count; - u32 i; - - - /* Get the head of the list */ - - table_desc = list_head; - count = list_head->count; - - /* - * Walk the entire list, deleting both the allocated tables - * and the table descriptors - */ - - for (i = 0; i < count; i++) { - table_desc = acpi_tb_uninstall_table (table_desc); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_delete_single_table - * - * PARAMETERS: Table_info - A table info struct - * - * RETURN: None. - * - * DESCRIPTION: Low-level free for a single ACPI table. Handles cases where - * the table was allocated a buffer or was mapped. - * - ******************************************************************************/ - -void -acpi_tb_delete_single_table ( - ACPI_TABLE_DESC *table_desc) -{ - - if (!table_desc) { - return; - } - - if (table_desc->pointer) { - /* Valid table, determine type of memory allocation */ - - switch (table_desc->allocation) { - - case ACPI_MEM_NOT_ALLOCATED: - break; - - - case ACPI_MEM_ALLOCATED: - - acpi_cm_free (table_desc->base_pointer); - break; - - - case ACPI_MEM_MAPPED: - - acpi_os_unmap_memory (table_desc->base_pointer, table_desc->length); - break; - } - } -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_uninstall_table - * - * PARAMETERS: Table_info - A table info struct - * - * RETURN: None. - * - * DESCRIPTION: Free the memory associated with an internal ACPI table that - * is either installed or has never been installed. - * Table mutex should be locked. - * - ******************************************************************************/ - -ACPI_TABLE_DESC * -acpi_tb_uninstall_table ( - ACPI_TABLE_DESC *table_desc) -{ - ACPI_TABLE_DESC *next_desc; - - - if (!table_desc) { - return (NULL); - } - - - /* Unlink the descriptor */ - - if (table_desc->prev) { - table_desc->prev->next = table_desc->next; - } - - if (table_desc->next) { - table_desc->next->prev = table_desc->prev; - } - - - /* Free the memory allocated for the table itself */ - - acpi_tb_delete_single_table (table_desc); - - - /* Free the table descriptor (Don't delete the list head, tho) */ - - if ((table_desc->prev) == (table_desc->next)) { - - next_desc = NULL; - - /* Clear the list head */ - - table_desc->pointer = NULL; - table_desc->length = 0; - table_desc->count = 0; - - } - - else { - /* Free the table descriptor */ - - next_desc = table_desc->next; - acpi_cm_free (table_desc); - } - - - return (next_desc); -} - - diff --git a/reactos/drivers/bus/acpi/tables/tbutils.c b/reactos/drivers/bus/acpi/tables/tbutils.c deleted file mode 100644 index 4d1cbbf3a2a..00000000000 --- a/reactos/drivers/bus/acpi/tables/tbutils.c +++ /dev/null @@ -1,352 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbutils - Table manipulation utilities - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbutils") - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_handle_to_object - * - * PARAMETERS: Table_id - Id for which the function is searching - * Table_desc - Pointer to return the matching table - * descriptor. - * - * RETURN: Search the tables to find one with a matching Table_id and - * return a pointer to that table descriptor. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_handle_to_object ( - u16 table_id, - ACPI_TABLE_DESC **table_desc) -{ - u32 i; - ACPI_TABLE_DESC *list_head; - - - for (i = 0; i < ACPI_TABLE_MAX; i++) { - list_head = &acpi_gbl_acpi_tables[i]; - do { - if (list_head->table_id == table_id) { - *table_desc = list_head; - return (AE_OK); - } - - list_head = list_head->next; - - } while (list_head != &acpi_gbl_acpi_tables[i]); - } - - - return (AE_BAD_PARAMETER); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_system_table_pointer - * - * PARAMETERS: *Where - Pointer to be examined - * - * RETURN: TRUE if Where is within the AML stream (in one of the ACPI - * system tables such as the DSDT or an SSDT.) - * FALSE otherwise - * - ******************************************************************************/ - -u8 -acpi_tb_system_table_pointer ( - void *where) -{ - u32 i; - ACPI_TABLE_DESC *table_desc; - ACPI_TABLE_HEADER *table; - - - /* No function trace, called too often! */ - - - /* Ignore null pointer */ - - if (!where) { - return (FALSE); - } - - - /* Check for a pointer within the DSDT */ - - if ((acpi_gbl_DSDT) && - (IS_IN_ACPI_TABLE (where, acpi_gbl_DSDT))) { - return (TRUE); - } - - - /* Check each of the loaded SSDTs (if any)*/ - - table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_SSDT]; - - for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_SSDT].count; i++) { - table = table_desc->pointer; - - if (IS_IN_ACPI_TABLE (where, table)) { - return (TRUE); - } - - table_desc = table_desc->next; - } - - - /* Check each of the loaded PSDTs (if any)*/ - - table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_PSDT]; - - for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_PSDT].count; i++) { - table = table_desc->pointer; - - if (IS_IN_ACPI_TABLE (where, table)) { - return (TRUE); - } - - table_desc = table_desc->next; - } - - - /* Pointer does not point into any system table */ - - return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_validate_table_header - * - * PARAMETERS: Table_header - Logical pointer to the table - * - * RETURN: Status - * - * DESCRIPTION: Check an ACPI table header for validity - * - * NOTE: Table pointers are validated as follows: - * 1) Table pointer must point to valid physical memory - * 2) Signature must be 4 ASCII chars, even if we don't recognize the - * name - * 3) Table must be readable for length specified in the header - * 4) Table checksum must be valid (with the exception of the FACS - * which has no checksum for some odd reason) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_validate_table_header ( - ACPI_TABLE_HEADER *table_header) -{ - ACPI_NAME signature; - - - /* Verify that this is a valid address */ - - if (!acpi_os_readable (table_header, sizeof (ACPI_TABLE_HEADER))) { - return (AE_BAD_ADDRESS); - } - - - /* Ensure that the signature is 4 ASCII characters */ - - MOVE_UNALIGNED32_TO_32 (&signature, &table_header->signature); - if (!acpi_cm_valid_acpi_name (signature)) { - REPORT_WARNING (("Invalid table signature found\n")); - return (AE_BAD_SIGNATURE); - } - - - /* Validate the table length */ - - if (table_header->length < sizeof (ACPI_TABLE_HEADER)) { - REPORT_WARNING (("Invalid table header length found\n")); - return (AE_BAD_HEADER); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_map_acpi_table - * - * PARAMETERS: Physical_address - Physical address of table to map - * *Size - Size of the table. If zero, the size - * from the table header is used. - * Actual size is returned here. - * **Logical_address - Logical address of mapped table - * - * RETURN: Logical address of the mapped table. - * - * DESCRIPTION: Maps the physical address of table into a logical address - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_map_acpi_table ( - ACPI_PHYSICAL_ADDRESS physical_address, - u32 *size, - void **logical_address) -{ - ACPI_TABLE_HEADER *table; - u32 table_size = *size; - ACPI_STATUS status = AE_OK; - - - /* If size is zero, look at the table header to get the actual size */ - - if ((*size) == 0) { - /* Get the table header so we can extract the table length */ - - status = acpi_os_map_memory (physical_address, sizeof (ACPI_TABLE_HEADER), - (void **) &table); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Extract the full table length before we delete the mapping */ - - table_size = table->length; - - /* - * Validate the header and delete the mapping. - * We will create a mapping for the full table below. - */ - - status = acpi_tb_validate_table_header (table); - - /* Always unmap the memory for the header */ - - acpi_os_unmap_memory (table, sizeof (ACPI_TABLE_HEADER)); - - /* Exit if header invalid */ - - if (ACPI_FAILURE (status)) { - return (status); - } - } - - - /* Map the physical memory for the correct length */ - - status = acpi_os_map_memory (physical_address, table_size, (void **) &table); - if (ACPI_FAILURE (status)) { - return (status); - } - - *size = table_size; - *logical_address = table; - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_verify_table_checksum - * - * PARAMETERS: *Table_header - ACPI table to verify - * - * RETURN: 8 bit checksum of table - * - * DESCRIPTION: Does an 8 bit checksum of table and returns status. A correct - * table should have a checksum of 0. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_verify_table_checksum ( - ACPI_TABLE_HEADER *table_header) -{ - u8 checksum; - ACPI_STATUS status = AE_OK; - - - /* Compute the checksum on the table */ - - checksum = acpi_tb_checksum (table_header, table_header->length); - - /* Return the appropriate exception */ - - if (checksum) { - REPORT_WARNING (("Invalid checksum (%X) in table %4.4s\n", - checksum, &table_header->signature)); - - status = AE_BAD_CHECKSUM; - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_checksum - * - * 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. - * - ******************************************************************************/ - -u8 -acpi_tb_checksum ( - void *buffer, - u32 length) -{ - u8 *limit; - u8 *rover; - u8 sum = 0; - - - if (buffer && length) { - /* Buffer and Length are valid */ - - limit = (u8 *) buffer + length; - - for (rover = buffer; rover < limit; rover++) { - sum = (u8) (sum + *rover); - } - } - - return (sum); -} - - diff --git a/reactos/drivers/bus/acpi/tables/tbxface.c b/reactos/drivers/bus/acpi/tables/tbxface.c deleted file mode 100644 index ff44010c4df..00000000000 --- a/reactos/drivers/bus/acpi/tables/tbxface.c +++ /dev/null @@ -1,383 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbxface - Public interfaces to the ACPI subsystem - * ACPI table oriented interfaces - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbxface") - - -/******************************************************************************* - * - * FUNCTION: Acpi_load_tables - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: This function is called to load the ACPI tables from the - * provided RSDT - * - ******************************************************************************/ - -ACPI_STATUS -acpi_load_tables ( - ACPI_PHYSICAL_ADDRESS rsdp_physical_address) -{ - ACPI_STATUS status = AE_OK; - u32 number_of_tables = 0; - - - /* Map and validate the RSDP */ - - status = acpi_tb_verify_rsdp (rsdp_physical_address); - if (ACPI_FAILURE (status)) { - REPORT_ERROR (("Acpi_load_tables: RSDP Failed validation: %s\n", - acpi_cm_format_exception (status))); - goto error_exit; - } - - /* Get the RSDT via the RSDP */ - - status = acpi_tb_get_table_rsdt (&number_of_tables); - if (ACPI_FAILURE (status)) { - REPORT_ERROR (("Acpi_load_tables: Could not load RSDT: %s\n", - acpi_cm_format_exception (status))); - goto error_exit; - } - - /* Now get the rest of the tables */ - - status = acpi_tb_get_all_tables (number_of_tables, NULL); - if (ACPI_FAILURE (status)) { - REPORT_ERROR (("Acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", - acpi_cm_format_exception (status))); - goto error_exit; - } - - - /* Load the namespace from the tables */ - - status = acpi_ns_load_namespace (); - if (ACPI_FAILURE (status)) { - REPORT_ERROR (("Acpi_load_tables: Could not load namespace: %s\n", - acpi_cm_format_exception (status))); - goto error_exit; - } - - return (AE_OK); - - -error_exit: - REPORT_ERROR (("Acpi_load_tables: Could not load tables: %s\n", - acpi_cm_format_exception (status))); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_load_table - * - * PARAMETERS: Table_ptr - pointer to a buffer containing the entire - * table to be loaded - * - * RETURN: Status - * - * DESCRIPTION: This function is called to load a table from the caller's - * buffer. The buffer must contain an entire ACPI Table including - * a valid header. The header fields will be verified, and if it - * is determined that the table is invalid, the call will fail. - * - * If the call fails an appropriate status will be returned. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_load_table ( - ACPI_TABLE_HEADER *table_ptr) -{ - ACPI_STATUS status; - ACPI_TABLE_DESC table_info; - - - if (!table_ptr) { - return (AE_BAD_PARAMETER); - } - - /* Copy the table to a local buffer */ - - status = acpi_tb_get_table (0, table_ptr, &table_info); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Install the new table into the local data structures */ - - status = acpi_tb_install_table (NULL, &table_info); - if (ACPI_FAILURE (status)) { - /* Free table allocated by Acpi_tb_get_table */ - - acpi_tb_delete_single_table (&table_info); - return (status); - } - - - status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node); - if (ACPI_FAILURE (status)) { - /* Uninstall table and free the buffer */ - - acpi_tb_uninstall_table (table_info.installed_desc); - return (status); - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_unload_table - * - * PARAMETERS: Table_type - Type of table to be unloaded - * - * RETURN: Status - * - * DESCRIPTION: This routine is used to force the unload of a table - * - ******************************************************************************/ - -ACPI_STATUS -acpi_unload_table ( - ACPI_TABLE_TYPE table_type) -{ - ACPI_TABLE_DESC *list_head; - - - /* Parameter validation */ - - if (table_type > ACPI_TABLE_MAX) { - return (AE_BAD_PARAMETER); - } - - - /* Find all tables of the requested type */ - - list_head = &acpi_gbl_acpi_tables[table_type]; - do { - /* - * Delete all namespace entries owned by this table. Note that these - * entries can appear anywhere in the namespace by virtue of the AML - * "Scope" operator. Thus, we need to track ownership by an ID, not - * simply a position within the hierarchy - */ - - acpi_ns_delete_namespace_by_owner (list_head->table_id); - - /* Delete (or unmap) the actual table */ - - acpi_tb_delete_acpi_table (table_type); - - } while (list_head != &acpi_gbl_acpi_tables[table_type]); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_table_header - * - * PARAMETERS: Table_type - one of the defined table types - * Instance - the non zero instance of the table, allows - * support for multiple tables of the same type - * see Acpi_gbl_Acpi_table_flag - * Out_table_header - pointer to the ACPI_TABLE_HEADER if successful - * - * DESCRIPTION: This function is called to get an ACPI table header. The caller - * supplies an pointer to a data area sufficient to contain an ACPI - * ACPI_TABLE_HEADER structure. - * - * The header contains a length field that can be used to determine - * the size of the buffer needed to contain the entire table. This - * function is not valid for the RSD PTR table since it does not - * have a standard header and is fixed length. - * - * If the operation fails for any reason an appropriate status will - * be returned and the contents of Out_table_header are undefined. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_table_header ( - ACPI_TABLE_TYPE table_type, - u32 instance, - ACPI_TABLE_HEADER *out_table_header) -{ - ACPI_TABLE_HEADER *tbl_ptr; - ACPI_STATUS status; - - - if ((instance == 0) || - (table_type == ACPI_TABLE_RSDP) || - (!out_table_header)) { - return (AE_BAD_PARAMETER); - } - - /* Check the table type and instance */ - - if ((table_type > ACPI_TABLE_MAX) || - (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) && - instance > 1)) { - return (AE_BAD_PARAMETER); - } - - - /* Get a pointer to the entire table */ - - status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * The function will return a NULL pointer if the table is not loaded - */ - if (tbl_ptr == NULL) { - return (AE_NOT_EXIST); - } - - /* - * Copy the header to the caller's buffer - */ - MEMCPY ((void *) out_table_header, (void *) tbl_ptr, - sizeof (ACPI_TABLE_HEADER)); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_get_table - * - * PARAMETERS: Table_type - one of the defined table types - * Instance - the non zero instance of the table, allows - * support for multiple tables of the same type - * see Acpi_gbl_Acpi_table_flag - * Ret_buffer - pointer to a structure containing a buffer to - * receive the table - * - * RETURN: Status - * - * DESCRIPTION: This function is called to get an ACPI table. The caller - * supplies an Out_buffer large enough to contain the entire ACPI - * table. The caller should call the Acpi_get_table_header function - * first to determine the buffer size needed. Upon completion - * the Out_buffer->Length field will indicate the number of bytes - * copied into the Out_buffer->Buf_ptr buffer. This table will be - * a complete table including the header. - * - * If the operation fails an appropriate status will be returned - * and the contents of Out_buffer are undefined. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_table ( - ACPI_TABLE_TYPE table_type, - u32 instance, - ACPI_BUFFER *ret_buffer) -{ - ACPI_TABLE_HEADER *tbl_ptr; - ACPI_STATUS status; - u32 ret_buf_len; - - - /* - * If we have a buffer, we must have a length too - */ - if ((instance == 0) || - (!ret_buffer) || - ((!ret_buffer->pointer) && (ret_buffer->length))) { - return (AE_BAD_PARAMETER); - } - - /* Check the table type and instance */ - - if ((table_type > ACPI_TABLE_MAX) || - (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) && - instance > 1)) { - return (AE_BAD_PARAMETER); - } - - - /* Get a pointer to the entire table */ - - status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Acpi_tb_get_table_ptr will return a NULL pointer if the - * table is not loaded. - */ - if (tbl_ptr == NULL) { - return (AE_NOT_EXIST); - } - - /* - * Got a table ptr, assume it's ok and copy it to the user's buffer - */ - if (table_type == ACPI_TABLE_RSDP) { - /* - * RSD PTR is the only "table" without a header - */ - ret_buf_len = sizeof (RSDP_DESCRIPTOR); - } - else { - ret_buf_len = tbl_ptr->length; - } - - /* - * Verify we have space in the caller's buffer for the table - */ - if (ret_buffer->length < ret_buf_len) { - ret_buffer->length = ret_buf_len; - return (AE_BUFFER_OVERFLOW); - } - - ret_buffer->length = ret_buf_len; - - MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, ret_buf_len); - - return (AE_OK); -} - diff --git a/reactos/drivers/bus/acpi/tables/tbxfroot.c b/reactos/drivers/bus/acpi/tables/tbxfroot.c deleted file mode 100644 index c15bf6d3a9c..00000000000 --- a/reactos/drivers/bus/acpi/tables/tbxfroot.c +++ /dev/null @@ -1,209 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbxfroot - Find the root ACPI table (RSDT) - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbxfroot") - -#define RSDP_CHECKSUM_LENGTH 20 - - -/******************************************************************************* - * - * FUNCTION: Acpi_find_root_pointer - * - * PARAMETERS: **Rsdp_physical_address - Where to place the RSDP address - * - * RETURN: Status, Physical address of the RSDP - * - * DESCRIPTION: Find the RSDP - * - ******************************************************************************/ - -ACPI_STATUS -acpi_find_root_pointer ( - ACPI_PHYSICAL_ADDRESS *rsdp_physical_address) -{ - ACPI_TABLE_DESC table_info; - ACPI_STATUS status; - - - /* Get the RSDP */ - - status = acpi_tb_find_rsdp (&table_info); - if (ACPI_FAILURE (status)) { - return (AE_NO_ACPI_TABLES); - } - - *rsdp_physical_address = table_info.physical_address; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_scan_memory_for_rsdp - * - * PARAMETERS: Start_address - Starting pointer for search - * Length - Maximum length to search - * - * RETURN: Pointer to the RSDP if found, otherwise NULL. - * - * DESCRIPTION: Search a block of memory for the RSDP signature - * - ******************************************************************************/ - -u8 * -acpi_tb_scan_memory_for_rsdp ( - u8 *start_address, - u32 length) -{ - u32 offset; - u8 *mem_rover; - - - /* Search from given start addr for the requested length */ - - for (offset = 0, mem_rover = start_address; - offset < length; - offset += RSDP_SCAN_STEP, mem_rover += RSDP_SCAN_STEP) { - - /* The signature and checksum must both be correct */ - - if (STRNCMP ((NATIVE_CHAR *) mem_rover, - RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && - acpi_tb_checksum (mem_rover, RSDP_CHECKSUM_LENGTH) == 0) { - /* If so, we have found the RSDP */ - - return (mem_rover); - } - } - - /* Searched entire block, no RSDP was found */ - - return (NULL); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_find_rsdp - * - * PARAMETERS: *Buffer_ptr - If == NULL, read data from buffer - * rather than searching memory - * *Table_info - Where the table info is returned - * - * RETURN: Status - * - * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor - * pointer structure. If it is found, set *RSDP to point to it. - * - * NOTE: The RSDP must be either in the first 1_k of the Extended - * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section - * 5.2.2; assertion #421). - * - ******************************************************************************/ - -ACPI_STATUS -acpi_tb_find_rsdp ( - ACPI_TABLE_DESC *table_info) -{ - u8 *table_ptr; - u8 *mem_rover; - UINT64 phys_addr; - ACPI_STATUS status = AE_OK; - - - /* - * Search memory for RSDP. First map low physical memory. - */ - - status = acpi_os_map_memory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE, - (void **)&table_ptr); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * 1) Search EBDA (low memory) paragraphs - */ - - mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, LO_RSDP_WINDOW_SIZE); - - /* This mapping is no longer needed */ - - acpi_os_unmap_memory (table_ptr, LO_RSDP_WINDOW_SIZE); - - if (mem_rover) { - /* Found it, return the physical address */ - - phys_addr = LO_RSDP_WINDOW_BASE; - phys_addr += (mem_rover - table_ptr); - - table_info->physical_address = phys_addr; - - return (AE_OK); - } - - - /* - * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h - */ - - status = acpi_os_map_memory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE, - (void **)&table_ptr); - - if (ACPI_FAILURE (status)) { - return (status); - } - - mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, HI_RSDP_WINDOW_SIZE); - - /* This mapping is no longer needed */ - - acpi_os_unmap_memory (table_ptr, HI_RSDP_WINDOW_SIZE); - - if (mem_rover) { - /* Found it, return the physical address */ - - phys_addr = HI_RSDP_WINDOW_BASE; - phys_addr += (mem_rover - table_ptr); - - table_info->physical_address = phys_addr; - - return (AE_OK); - } - - - /* RSDP signature was not found */ - - return (AE_NOT_FOUND); -} - - diff --git a/reactos/drivers/bus/acpi/utils/cmalloc.c b/reactos/drivers/bus/acpi/utils/cmalloc.c deleted file mode 100644 index 03e743fb19d..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmalloc.c +++ /dev/null @@ -1,166 +0,0 @@ -/****************************************************************************** - * - * Module Name: cmalloc - local memory allocation routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmalloc") - - -/***************************************************************************** - * - * FUNCTION: _Cm_allocate - * - * PARAMETERS: Size - Size of the allocation - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: Address of the allocated memory on success, NULL on failure. - * - * DESCRIPTION: The subsystem's equivalent of malloc. - * - ****************************************************************************/ - -void * -_cm_allocate ( - u32 size, - u32 component, - NATIVE_CHAR *module, - u32 line) -{ - void *address = NULL; - - - /* Check for an inadvertent size of zero bytes */ - - if (!size) { - _REPORT_ERROR (module, line, component, - ("Cm_allocate: Attempt to allocate zero bytes\n")); - size = 1; - } - - address = acpi_os_allocate (size); - if (!address) { - /* Report allocation error */ - - _REPORT_ERROR (module, line, component, - ("Cm_allocate: Could not allocate size %X\n", size)); - - return (NULL); - } - - - return (address); -} - - -/***************************************************************************** - * - * FUNCTION: _Cm_callocate - * - * PARAMETERS: Size - Size of the allocation - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: Address of the allocated memory on success, NULL on failure. - * - * DESCRIPTION: Subsystem equivalent of calloc. - * - ****************************************************************************/ - -void * -_cm_callocate ( - u32 size, - u32 component, - NATIVE_CHAR *module, - u32 line) -{ - void *address = NULL; - - - /* Check for an inadvertent size of zero bytes */ - - if (!size) { - _REPORT_ERROR (module, line, component, - ("Cm_callocate: Attempt to allocate zero bytes\n")); - return (NULL); - } - - - address = acpi_os_callocate (size); - - if (!address) { - /* Report allocation error */ - - _REPORT_ERROR (module, line, component, - ("Cm_callocate: Could not allocate size %X\n", size)); - return (NULL); - } - - - return (address); -} - - -/***************************************************************************** - * - * FUNCTION: _Cm_free - * - * PARAMETERS: Address - Address of the memory to deallocate - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: None - * - * DESCRIPTION: Frees the memory at Address - * - ****************************************************************************/ - -void -_cm_free ( - void *address, - u32 component, - NATIVE_CHAR *module, - u32 line) -{ - - if (NULL == address) { - _REPORT_ERROR (module, line, component, - ("_Cm_free: Trying to delete a NULL address\n")); - - return; - } - - - acpi_os_free (address); - - return; -} - - diff --git a/reactos/drivers/bus/acpi/utils/cmclib.c b/reactos/drivers/bus/acpi/utils/cmclib.c deleted file mode 100644 index 29f1d4f6f7f..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmclib.c +++ /dev/null @@ -1,810 +0,0 @@ -/****************************************************************************** - * - * Module Name: cmclib - Local implementation of C library functions - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -/* - * These implementations of standard C Library routines can optionally be - * used if a C library is not available. In general, they are less efficient - * than an inline or assembly implementation - */ - -#define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmclib") - - -#ifndef ACPI_USE_SYSTEM_CLIBRARY - -/******************************************************************************* - * - * FUNCTION: strlen - * - * PARAMETERS: String - Null terminated string - * - * RETURN: Length - * - * DESCRIPTION: Returns the length of the input string - * - ******************************************************************************/ - - -u32 -acpi_cm_strlen ( - const NATIVE_CHAR *string) -{ - u32 length = 0; - - - /* Count the string until a null is encountered */ - - while (*string) { - length++; - string++; - } - - return (length); -} - - -/******************************************************************************* - * - * FUNCTION: strcpy - * - * PARAMETERS: Dst_string - Target of the copy - * Src_string - The source string to copy - * - * RETURN: Dst_string - * - * DESCRIPTION: Copy a null terminated string - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_cm_strcpy ( - NATIVE_CHAR *dst_string, - const NATIVE_CHAR *src_string) -{ - NATIVE_CHAR *string = dst_string; - - - /* Move bytes brute force */ - - while (*src_string) { - *string = *src_string; - - string++; - src_string++; - } - - /* Null terminate */ - - *string = 0; - - return (dst_string); -} - - -/******************************************************************************* - * - * FUNCTION: strncpy - * - * PARAMETERS: Dst_string - Target of the copy - * Src_string - The source string to copy - * Count - Maximum # of bytes to copy - * - * RETURN: Dst_string - * - * DESCRIPTION: Copy a null terminated string, with a maximum length - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_cm_strncpy ( - NATIVE_CHAR *dst_string, - const NATIVE_CHAR *src_string, - NATIVE_UINT count) -{ - NATIVE_CHAR *string = dst_string; - - - /* Copy the string */ - - for (string = dst_string; - count && (count--, (*string++ = *src_string++)); ) {;} - - /* Pad with nulls if necessary */ - - while (count--) { - *string = 0; - string++; - } - - /* Return original pointer */ - - return (dst_string); -} - - -/******************************************************************************* - * - * FUNCTION: strcmp - * - * PARAMETERS: String1 - First string - * String2 - Second string - * - * RETURN: Index where strings mismatched, or 0 if strings matched - * - * DESCRIPTION: Compare two null terminated strings - * - ******************************************************************************/ - -u32 -acpi_cm_strcmp ( - const NATIVE_CHAR *string1, - const NATIVE_CHAR *string2) -{ - - - for ( ; (*string1 == *string2); string2++) { - if (!*string1++) { - return (0); - } - } - - - return ((unsigned char) *string1 - (unsigned char) *string2); -} - - -/******************************************************************************* - * - * FUNCTION: strncmp - * - * PARAMETERS: String1 - First string - * String2 - Second string - * Count - Maximum # of bytes to compare - * - * RETURN: Index where strings mismatched, or 0 if strings matched - * - * DESCRIPTION: Compare two null terminated strings, with a maximum length - * - ******************************************************************************/ - -u32 -acpi_cm_strncmp ( - const NATIVE_CHAR *string1, - const NATIVE_CHAR *string2, - NATIVE_UINT count) -{ - - - for ( ; count-- && (*string1 == *string2); string2++) { - if (!*string1++) { - return (0); - } - } - - return ((count == -1) ? 0 : ((unsigned char) *string1 - - (unsigned char) *string2)); -} - - -/******************************************************************************* - * - * FUNCTION: Strcat - * - * PARAMETERS: Dst_string - Target of the copy - * Src_string - The source string to copy - * - * RETURN: Dst_string - * - * DESCRIPTION: Append a null terminated string to a null terminated string - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_cm_strcat ( - NATIVE_CHAR *dst_string, - const NATIVE_CHAR *src_string) -{ - NATIVE_CHAR *string; - - - /* Find end of the destination string */ - - for (string = dst_string; *string++; ) { ; } - - /* Concatinate the string */ - - for (--string; (*string++ = *src_string++); ) { ; } - - return (dst_string); -} - - -/******************************************************************************* - * - * FUNCTION: strncat - * - * PARAMETERS: Dst_string - Target of the copy - * Src_string - The source string to copy - * Count - Maximum # of bytes to copy - * - * RETURN: Dst_string - * - * DESCRIPTION: Append a null terminated string to a null terminated string, - * with a maximum count. - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_cm_strncat ( - NATIVE_CHAR *dst_string, - const NATIVE_CHAR *src_string, - NATIVE_UINT count) -{ - NATIVE_CHAR *string; - - - if (count) { - /* Find end of the destination string */ - - for (string = dst_string; *string++; ) { ; } - - /* Concatinate the string */ - - for (--string; (*string++ = *src_string++) && --count; ) { ; } - - /* Null terminate if necessary */ - - if (!count) { - *string = 0; - } - } - - return (dst_string); -} - - -/******************************************************************************* - * - * FUNCTION: memcpy - * - * PARAMETERS: Dest - Target of the copy - * Src - Source buffer to copy - * Count - Number of bytes to copy - * - * RETURN: Dest - * - * DESCRIPTION: Copy arbitrary bytes of memory - * - ******************************************************************************/ - -void * -acpi_cm_memcpy ( - void *dest, - const void *src, - NATIVE_UINT count) -{ - NATIVE_CHAR *new = (NATIVE_CHAR *) dest; - NATIVE_CHAR *old = (NATIVE_CHAR *) src; - - - while (count) { - *new = *old; - new++; - old++; - count--; - } - - return (dest); -} - - -/******************************************************************************* - * - * FUNCTION: memset - * - * PARAMETERS: Dest - Buffer to set - * Value - Value to set each byte of memory - * Count - Number of bytes to set - * - * RETURN: Dest - * - * DESCRIPTION: Initialize a buffer to a known value. - * - ******************************************************************************/ - -void * -acpi_cm_memset ( - void *dest, - NATIVE_UINT value, - NATIVE_UINT count) -{ - NATIVE_CHAR *new = (NATIVE_CHAR *) dest; - - - while (count) { - *new = (char) value; - new++; - count--; - } - - return (dest); -} - - -#define NEGATIVE 1 -#define POSITIVE 0 - - -#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ -#define _ACPI_XS 0x40 /* extra space */ -#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ -#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ -#define _ACPI_DI 0x04 /* '0'-'9' */ -#define _ACPI_LO 0x02 /* 'a'-'z' */ -#define _ACPI_PU 0x10 /* punctuation */ -#define _ACPI_SP 0x08 /* space */ -#define _ACPI_UP 0x01 /* 'A'-'Z' */ -#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ - -static const u8 _acpi_ctype[257] = { - _ACPI_CN, /* 0x0 0. */ - _ACPI_CN, /* 0x1 1. */ - _ACPI_CN, /* 0x2 2. */ - _ACPI_CN, /* 0x3 3. */ - _ACPI_CN, /* 0x4 4. */ - _ACPI_CN, /* 0x5 5. */ - _ACPI_CN, /* 0x6 6. */ - _ACPI_CN, /* 0x7 7. */ - _ACPI_CN, /* 0x8 8. */ - _ACPI_CN|_ACPI_SP, /* 0x9 9. */ - _ACPI_CN|_ACPI_SP, /* 0xA 10. */ - _ACPI_CN|_ACPI_SP, /* 0xB 11. */ - _ACPI_CN|_ACPI_SP, /* 0xC 12. */ - _ACPI_CN|_ACPI_SP, /* 0xD 13. */ - _ACPI_CN, /* 0xE 14. */ - _ACPI_CN, /* 0xF 15. */ - _ACPI_CN, /* 0x10 16. */ - _ACPI_CN, /* 0x11 17. */ - _ACPI_CN, /* 0x12 18. */ - _ACPI_CN, /* 0x13 19. */ - _ACPI_CN, /* 0x14 20. */ - _ACPI_CN, /* 0x15 21. */ - _ACPI_CN, /* 0x16 22. */ - _ACPI_CN, /* 0x17 23. */ - _ACPI_CN, /* 0x18 24. */ - _ACPI_CN, /* 0x19 25. */ - _ACPI_CN, /* 0x1A 26. */ - _ACPI_CN, /* 0x1B 27. */ - _ACPI_CN, /* 0x1C 28. */ - _ACPI_CN, /* 0x1D 29. */ - _ACPI_CN, /* 0x1E 30. */ - _ACPI_CN, /* 0x1F 31. */ - _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ - _ACPI_PU, /* 0x21 33. '!' */ - _ACPI_PU, /* 0x22 34. '"' */ - _ACPI_PU, /* 0x23 35. '#' */ - _ACPI_PU, /* 0x24 36. '$' */ - _ACPI_PU, /* 0x25 37. '%' */ - _ACPI_PU, /* 0x26 38. '&' */ - _ACPI_PU, /* 0x27 39. ''' */ - _ACPI_PU, /* 0x28 40. '(' */ - _ACPI_PU, /* 0x29 41. ')' */ - _ACPI_PU, /* 0x2A 42. '*' */ - _ACPI_PU, /* 0x2B 43. '+' */ - _ACPI_PU, /* 0x2C 44. ',' */ - _ACPI_PU, /* 0x2D 45. '-' */ - _ACPI_PU, /* 0x2E 46. '.' */ - _ACPI_PU, /* 0x2F 47. '/' */ - _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ - _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ - _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ - _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ - _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ - _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ - _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ - _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ - _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ - _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ - _ACPI_PU, /* 0x3A 58. ':' */ - _ACPI_PU, /* 0x3B 59. ';' */ - _ACPI_PU, /* 0x3C 60. '<' */ - _ACPI_PU, /* 0x3D 61. '=' */ - _ACPI_PU, /* 0x3E 62. '>' */ - _ACPI_PU, /* 0x3F 63. '?' */ - _ACPI_PU, /* 0x40 64. '@' */ - _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ - _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ - _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ - _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ - _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ - _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ - _ACPI_UP, /* 0x47 71. 'G' */ - _ACPI_UP, /* 0x48 72. 'H' */ - _ACPI_UP, /* 0x49 73. 'I' */ - _ACPI_UP, /* 0x4A 74. 'J' */ - _ACPI_UP, /* 0x4B 75. 'K' */ - _ACPI_UP, /* 0x4C 76. 'L' */ - _ACPI_UP, /* 0x4D 77. 'M' */ - _ACPI_UP, /* 0x4E 78. 'N' */ - _ACPI_UP, /* 0x4F 79. 'O' */ - _ACPI_UP, /* 0x50 80. 'P' */ - _ACPI_UP, /* 0x51 81. 'Q' */ - _ACPI_UP, /* 0x52 82. 'R' */ - _ACPI_UP, /* 0x53 83. 'S' */ - _ACPI_UP, /* 0x54 84. 'T' */ - _ACPI_UP, /* 0x55 85. 'U' */ - _ACPI_UP, /* 0x56 86. 'V' */ - _ACPI_UP, /* 0x57 87. 'W' */ - _ACPI_UP, /* 0x58 88. 'X' */ - _ACPI_UP, /* 0x59 89. 'Y' */ - _ACPI_UP, /* 0x5A 90. 'Z' */ - _ACPI_PU, /* 0x5B 91. '[' */ - _ACPI_PU, /* 0x5C 92. '\' */ - _ACPI_PU, /* 0x5D 93. ']' */ - _ACPI_PU, /* 0x5E 94. '^' */ - _ACPI_PU, /* 0x5F 95. '_' */ - _ACPI_PU, /* 0x60 96. '`' */ - _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ - _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ - _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ - _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ - _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ - _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ - _ACPI_LO, /* 0x67 103. 'g' */ - _ACPI_LO, /* 0x68 104. 'h' */ - _ACPI_LO, /* 0x69 105. 'i' */ - _ACPI_LO, /* 0x6A 106. 'j' */ - _ACPI_LO, /* 0x6B 107. 'k' */ - _ACPI_LO, /* 0x6C 108. 'l' */ - _ACPI_LO, /* 0x6D 109. 'm' */ - _ACPI_LO, /* 0x6E 110. 'n' */ - _ACPI_LO, /* 0x6F 111. 'o' */ - _ACPI_LO, /* 0x70 112. 'p' */ - _ACPI_LO, /* 0x71 113. 'q' */ - _ACPI_LO, /* 0x72 114. 'r' */ - _ACPI_LO, /* 0x73 115. 's' */ - _ACPI_LO, /* 0x74 116. 't' */ - _ACPI_LO, /* 0x75 117. 'u' */ - _ACPI_LO, /* 0x76 118. 'v' */ - _ACPI_LO, /* 0x77 119. 'w' */ - _ACPI_LO, /* 0x78 120. 'x' */ - _ACPI_LO, /* 0x79 121. 'y' */ - _ACPI_LO, /* 0x7A 122. 'z' */ - _ACPI_PU, /* 0x7B 123. '{' */ - _ACPI_PU, /* 0x7C 124. '|' */ - _ACPI_PU, /* 0x7D 125. '}' */ - _ACPI_PU, /* 0x7E 126. '~' */ - _ACPI_CN, /* 0x7F 127. */ - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ -}; - -#define IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) -#define IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) -#define IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) -#define IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) -#define IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_to_upper - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Convert character to uppercase - * - ******************************************************************************/ - -u32 -acpi_cm_to_upper ( - u32 c) -{ - - return (IS_LOWER(c) ? ((c)-0x20) : (c)); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_to_lower - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Convert character to lowercase - * - ******************************************************************************/ - -u32 -acpi_cm_to_lower ( - u32 c) -{ - - return (IS_UPPER(c) ? ((c)+0x20) : (c)); -} - - -/******************************************************************************* - * - * FUNCTION: strupr - * - * PARAMETERS: Src_string - The source string to convert to - * - * RETURN: Src_string - * - * DESCRIPTION: Convert string to uppercase - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_cm_strupr ( - NATIVE_CHAR *src_string) -{ - NATIVE_CHAR *string; - - - /* Walk entire string, uppercasing the letters */ - - for (string = src_string; *string; ) { - *string = (char) acpi_cm_to_upper (*string); - string++; - } - - - return (src_string); -} - - -/******************************************************************************* - * - * FUNCTION: strstr - * - * PARAMETERS: String1 - - * String2 - * - * RETURN: - * - * DESCRIPTION: Checks if String2 occurs in String1. This is not really a - * full implementation of strstr, only sufficient for command - * matching - * - ******************************************************************************/ - -NATIVE_CHAR * -acpi_cm_strstr ( - NATIVE_CHAR *string1, - NATIVE_CHAR *string2) -{ - NATIVE_CHAR *string; - - - if (acpi_cm_strlen (string2) > acpi_cm_strlen (string1)) { - return (NULL); - } - - /* Walk entire string, comparing the letters */ - - for (string = string1; *string2; ) { - if (*string2 != *string) { - return (NULL); - } - - string2++; - string++; - } - - - return (string1); -} - - -/******************************************************************************* - * - * FUNCTION: strtoul - * - * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte is returned - * Base - Radix of the string - * - * RETURN: Converted value - * - * DESCRIPTION: Convert a string into an unsigned value. - * - ******************************************************************************/ - -NATIVE_UINT -acpi_cm_strtoul ( - const NATIVE_CHAR *string, - NATIVE_CHAR **terminator, - NATIVE_UINT base) -{ - u32 converted = 0; - u32 index; - u32 sign; - const NATIVE_CHAR *string_start; - NATIVE_UINT return_value = 0; - ACPI_STATUS status = AE_OK; - - - /* - * Save the value of the pointer to the buffer's first - * character, save the current errno value, and then - * skip over any white space in the buffer: - */ - string_start = string; - while (IS_SPACE (*string) || *string == '\t') { - ++string; - } - - /* - * The buffer may contain an optional plus or minus sign. - * If it does, then skip over it but remember what is was: - */ - if (*string == '-') { - sign = NEGATIVE; - ++string; - } - - else if (*string == '+') { - ++string; - sign = POSITIVE; - } - - else { - sign = POSITIVE; - } - - /* - * If the input parameter Base is zero, then we need to - * determine if it is octal, decimal, or hexadecimal: - */ - if (base == 0) { - if (*string == '0') { - if (acpi_cm_to_lower (*(++string)) == 'x') { - base = 16; - ++string; - } - - else { - base = 8; - } - } - - else { - base = 10; - } - } - - else if (base < 2 || base > 36) { - /* - * The specified Base parameter is not in the domain of - * this function: - */ - goto done; - } - - /* - * For octal and hexadecimal bases, skip over the leading - * 0 or 0x, if they are present. - */ - if (base == 8 && *string == '0') { - string++; - } - - if (base == 16 && - *string == '0' && - acpi_cm_to_lower (*(++string)) == 'x') { - string++; - } - - - /* - * Main loop: convert the string to an unsigned long: - */ - while (*string) { - if (IS_DIGIT (*string)) { - index = *string - '0'; - } - - else { - index = acpi_cm_to_upper (*string); - if (IS_UPPER (index)) { - index = index - 'A' + 10; - } - - else { - goto done; - } - } - - if (index >= base) { - goto done; - } - - /* - * Check to see if value is out of range: - */ - - if (return_value > ((ACPI_UINT32_MAX - (u32) index) / - (u32) base)) { - status = AE_ERROR; - return_value = 0L; /* reset */ - } - - else { - return_value *= base; - return_value += index; - converted = 1; - } - - ++string; - } - -done: - /* - * If appropriate, update the caller's pointer to the next - * unconverted character in the buffer. - */ - if (terminator) { - if (converted == 0 && return_value == 0L && string != NULL) { - *terminator = (NATIVE_CHAR *) string_start; - } - - else { - *terminator = (NATIVE_CHAR *) string; - } - } - - if (status == AE_ERROR) { - return_value = ACPI_UINT32_MAX; - } - - /* - * If a minus sign was present, then "the conversion is negated": - */ - if (sign == NEGATIVE) { - return_value = (ACPI_UINT32_MAX - return_value) + 1; - } - - return (return_value); -} - -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ - diff --git a/reactos/drivers/bus/acpi/utils/cmcopy.c b/reactos/drivers/bus/acpi/utils/cmcopy.c deleted file mode 100644 index f09c35c7505..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmcopy.c +++ /dev/null @@ -1,704 +0,0 @@ -/****************************************************************************** - * - * Module Name: cmcopy - Internal to external object translation utilities - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmcopy") - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_isimple_to_esimple - * - * PARAMETERS: *Internal_object - Pointer to the object we are examining - * *Buffer - Where the object is returned - * *Space_used - Where the data length is returned - * - * RETURN: Status - * - * DESCRIPTION: This function is called to place a simple object in a user - * buffer. - * - * The buffer is assumed to have sufficient space for the object. - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_cm_copy_isimple_to_esimple ( - ACPI_OPERAND_OBJECT *internal_object, - ACPI_OBJECT *external_object, - u8 *data_space, - u32 *buffer_space_used) -{ - u32 length = 0; - ACPI_STATUS status = AE_OK; - - - /* - * Check for NULL object case (could be an uninitialized - * package element - */ - - if (!internal_object) { - *buffer_space_used = 0; - return (AE_OK); - } - - /* Always clear the external object */ - - MEMSET (external_object, 0, sizeof (ACPI_OBJECT)); - - /* - * In general, the external object will be the same type as - * the internal object - */ - - external_object->type = internal_object->common.type; - - /* However, only a limited number of external types are supported */ - - switch (internal_object->common.type) { - - case ACPI_TYPE_STRING: - - length = internal_object->string.length + 1; - external_object->string.length = internal_object->string.length; - external_object->string.pointer = (NATIVE_CHAR *) data_space; - MEMCPY ((void *) data_space, (void *) internal_object->string.pointer, length); - break; - - - case ACPI_TYPE_BUFFER: - - length = internal_object->buffer.length; - external_object->buffer.length = internal_object->buffer.length; - external_object->buffer.pointer = data_space; - MEMCPY ((void *) data_space, (void *) internal_object->buffer.pointer, length); - break; - - - case ACPI_TYPE_INTEGER: - - external_object->integer.value= internal_object->integer.value; - break; - - - case INTERNAL_TYPE_REFERENCE: - - /* - * This is an object reference. Attempt to dereference it. - */ - - switch (internal_object->reference.opcode) { - case AML_ZERO_OP: - external_object->type = ACPI_TYPE_INTEGER; - external_object->integer.value = 0; - break; - - case AML_ONE_OP: - external_object->type = ACPI_TYPE_INTEGER; - external_object->integer.value = 1; - break; - - case AML_ONES_OP: - external_object->type = ACPI_TYPE_INTEGER; - external_object->integer.value = ACPI_INTEGER_MAX; - break; - - case AML_NAMEPATH_OP: - /* - * This is a named reference, get the string. We already know that - * we have room for it, use max length - */ - length = MAX_STRING_LENGTH; - external_object->type = ACPI_TYPE_STRING; - external_object->string.pointer = (NATIVE_CHAR *) data_space; - status = acpi_ns_handle_to_pathname ((ACPI_HANDLE *) internal_object->reference.node, - &length, (char *) data_space); - - /* Converted (external) string length is returned from above */ - - external_object->string.length = length; - break; - - default: - /* - * Use the object type of "Any" to indicate a reference - * to object containing a handle to an ACPI named object. - */ - external_object->type = ACPI_TYPE_ANY; - external_object->reference.handle = internal_object->reference.node; - break; - } - break; - - - case ACPI_TYPE_PROCESSOR: - - external_object->processor.proc_id = internal_object->processor.proc_id; - external_object->processor.pblk_address = internal_object->processor.address; - external_object->processor.pblk_length = internal_object->processor.length; - break; - - - case ACPI_TYPE_POWER: - - external_object->power_resource.system_level = - internal_object->power_resource.system_level; - - external_object->power_resource.resource_order = - internal_object->power_resource.resource_order; - break; - - - default: - /* - * There is no corresponding external object type - */ - return (AE_SUPPORT); - break; - } - - - *buffer_space_used = (u32) ROUND_UP_TO_NATIVE_WORD (length); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_ielement_to_eelement - * - * PARAMETERS: ACPI_PKG_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Copy one package element to another package element - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_copy_ielement_to_eelement ( - u8 object_type, - ACPI_OPERAND_OBJECT *source_object, - ACPI_GENERIC_STATE *state, - void *context) -{ - ACPI_STATUS status = AE_OK; - ACPI_PKG_INFO *info = (ACPI_PKG_INFO *) context; - u32 object_space; - u32 this_index; - ACPI_OBJECT *target_object; - - - this_index = state->pkg.index; - target_object = (ACPI_OBJECT *) - &((ACPI_OBJECT *)(state->pkg.dest_object))->package.elements[this_index]; - - - switch (object_type) { - case ACPI_COPY_TYPE_SIMPLE: - - /* - * This is a simple or null object -- get the size - */ - - status = acpi_cm_copy_isimple_to_esimple (source_object, - target_object, info->free_space, &object_space); - if (ACPI_FAILURE (status)) { - return (status); - } - - break; - - case ACPI_COPY_TYPE_PACKAGE: - - /* - * Build the package object - */ - target_object->type = ACPI_TYPE_PACKAGE; - target_object->package.count = source_object->package.count; - target_object->package.elements = (ACPI_OBJECT *) info->free_space; - - /* - * Pass the new package object back to the package walk routine - */ - state->pkg.this_target_obj = target_object; - - /* - * Save space for the array of objects (Package elements) - * update the buffer length counter - */ - object_space = (u32) ROUND_UP_TO_NATIVE_WORD ( - target_object->package.count * sizeof (ACPI_OBJECT)); - break; - - default: - return (AE_BAD_PARAMETER); - } - - - info->free_space += object_space; - info->length += object_space; - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_ipackage_to_epackage - * - * PARAMETERS: *Internal_object - Pointer to the object we are returning - * *Buffer - Where the object is returned - * *Space_used - Where the object length is returned - * - * RETURN: Status - * - * DESCRIPTION: This function is called to place a package object in a user - * buffer. A package object by definition contains other objects. - * - * The buffer is assumed to have sufficient space for the object. - * The caller must have verified the buffer length needed using the - * Acpi_cm_get_object_size function before calling this function. - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_cm_copy_ipackage_to_epackage ( - ACPI_OPERAND_OBJECT *internal_object, - u8 *buffer, - u32 *space_used) -{ - ACPI_OBJECT *external_object; - ACPI_STATUS status; - ACPI_PKG_INFO info; - - - /* - * First package at head of the buffer - */ - external_object = (ACPI_OBJECT *) buffer; - - /* - * Free space begins right after the first package - */ - info.length = 0; - info.object_space = 0; - info.num_packages = 1; - info.free_space = buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - - - external_object->type = internal_object->common.type; - external_object->package.count = internal_object->package.count; - external_object->package.elements = (ACPI_OBJECT *) info.free_space; - - - /* - * Build an array of ACPI_OBJECTS in the buffer - * and move the free space past it - */ - - info.free_space += external_object->package.count * - ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - - - status = acpi_cm_walk_package_tree (internal_object, external_object, - acpi_cm_copy_ielement_to_eelement, &info); - - *space_used = info.length; - - return (status); - -} - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_iobject_to_eobject - * - * PARAMETERS: *Internal_object - The internal object to be converted - * *Buffer_ptr - Where the object is returned - * - * RETURN: Status - * - * DESCRIPTION: This function is called to build an API object to be returned to - * the caller. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_copy_iobject_to_eobject ( - ACPI_OPERAND_OBJECT *internal_object, - ACPI_BUFFER *ret_buffer) -{ - ACPI_STATUS status; - - - if (IS_THIS_OBJECT_TYPE (internal_object, ACPI_TYPE_PACKAGE)) { - /* - * Package object: Copy all subobjects (including - * nested packages) - */ - status = acpi_cm_copy_ipackage_to_epackage (internal_object, - ret_buffer->pointer, &ret_buffer->length); - } - - else { - /* - * Build a simple object (no nested objects) - */ - status = acpi_cm_copy_isimple_to_esimple (internal_object, - (ACPI_OBJECT *) ret_buffer->pointer, - ((u8 *) ret_buffer->pointer + - ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), - &ret_buffer->length); - /* - * build simple does not include the object size in the length - * so we add it in here - */ - ret_buffer->length += sizeof (ACPI_OBJECT); - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_esimple_to_isimple - * - * PARAMETERS: *External_object - The external object to be converted - * *Internal_object - Where the internal object is returned - * - * RETURN: Status - * - * DESCRIPTION: This function copies an external object to an internal one. - * NOTE: Pointers can be copied, we don't need to copy data. - * (The pointers have to be valid in our address space no matter - * what we do with them!) - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_copy_esimple_to_isimple ( - ACPI_OBJECT *external_object, - ACPI_OPERAND_OBJECT *internal_object) -{ - - - internal_object->common.type = (u8) external_object->type; - - switch (external_object->type) { - - case ACPI_TYPE_STRING: - - internal_object->string.length = external_object->string.length; - internal_object->string.pointer = external_object->string.pointer; - break; - - - case ACPI_TYPE_BUFFER: - - internal_object->buffer.length = external_object->buffer.length; - internal_object->buffer.pointer = external_object->buffer.pointer; - break; - - - case ACPI_TYPE_INTEGER: - /* - * Number is included in the object itself - */ - internal_object->integer.value = external_object->integer.value; - break; - - - default: - return (AE_CTRL_RETURN_VALUE); - break; - } - - - return (AE_OK); -} - - -#ifdef ACPI_FUTURE_IMPLEMENTATION - -/* Code to convert packages that are parameters to control methods */ - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_epackage_to_ipackage - * - * PARAMETERS: *Internal_object - Pointer to the object we are returning - * *Buffer - Where the object is returned - * *Space_used - Where the length of the object is returned - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to place a package object in a user - * buffer. A package object by definition contains other objects. - * - * The buffer is assumed to have sufficient space for the object. - * The caller must have verified the buffer length needed using the - * Acpi_cm_get_object_size function before calling this function. - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_cm_copy_epackage_to_ipackage ( - ACPI_OPERAND_OBJECT *internal_object, - u8 *buffer, - u32 *space_used) -{ - u8 *free_space; - ACPI_OBJECT *external_object; - u32 length = 0; - u32 this_index; - u32 object_space = 0; - ACPI_OPERAND_OBJECT *this_internal_obj; - ACPI_OBJECT *this_external_obj; - - - /* - * First package at head of the buffer - */ - external_object = (ACPI_OBJECT *)buffer; - - /* - * Free space begins right after the first package - */ - free_space = buffer + sizeof(ACPI_OBJECT); - - - external_object->type = internal_object->common.type; - external_object->package.count = internal_object->package.count; - external_object->package.elements = (ACPI_OBJECT *)free_space; - - - /* - * Build an array of ACPI_OBJECTS in the buffer - * and move the free space past it - */ - - free_space += external_object->package.count * sizeof(ACPI_OBJECT); - - - /* Call Walk_package */ - -} - -#endif /* Future implementation */ - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_eobject_to_iobject - * - * PARAMETERS: *Internal_object - The external object to be converted - * *Buffer_ptr - Where the internal object is returned - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: Converts an external object to an internal object. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_copy_eobject_to_iobject ( - ACPI_OBJECT *external_object, - ACPI_OPERAND_OBJECT *internal_object) -{ - ACPI_STATUS status; - - - if (external_object->type == ACPI_TYPE_PACKAGE) { - /* - * Package objects contain other objects (which can be objects) - * buildpackage does it all - * - * TBD: Package conversion must be completed and tested - * NOTE: this code converts packages as input parameters to - * control methods only. This is a very, very rare case. - */ -/* - Status = Acpi_cm_copy_epackage_to_ipackage(Internal_object, - Ret_buffer->Pointer, - &Ret_buffer->Length); -*/ - return (AE_NOT_IMPLEMENTED); - } - - else { - /* - * Build a simple object (no nested objects) - */ - status = acpi_cm_copy_esimple_to_isimple (external_object, internal_object); - /* - * build simple does not include the object size in the length - * so we add it in here - */ - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_ielement_to_ielement - * - * PARAMETERS: ACPI_PKG_CALLBACK - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: Copy one package element to another package element - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_copy_ielement_to_ielement ( - u8 object_type, - ACPI_OPERAND_OBJECT *source_object, - ACPI_GENERIC_STATE *state, - void *context) -{ - ACPI_STATUS status = AE_OK; - u32 this_index; - ACPI_OPERAND_OBJECT **this_target_ptr; - ACPI_OPERAND_OBJECT *target_object; - - - this_index = state->pkg.index; - this_target_ptr = (ACPI_OPERAND_OBJECT **) - &state->pkg.dest_object->package.elements[this_index]; - - switch (object_type) { - case 0: - - /* - * This is a simple object, just copy it - */ - target_object = acpi_cm_create_internal_object (source_object->common.type); - if (!target_object) { - return (AE_NO_MEMORY); - } - - status = acpi_aml_store_object_to_object (source_object, target_object, - (ACPI_WALK_STATE *) context); - if (ACPI_FAILURE (status)) { - return (status); - } - - *this_target_ptr = target_object; - break; - - - case 1: - /* - * This object is a package - go down another nesting level - * Create and build the package object - */ - target_object = acpi_cm_create_internal_object (ACPI_TYPE_PACKAGE); - if (!target_object) { - /* TBD: must delete package created up to this point */ - - return (AE_NO_MEMORY); - } - - target_object->package.count = source_object->package.count; - - /* - * Pass the new package object back to the package walk routine - */ - state->pkg.this_target_obj = target_object; - - /* - * Store the object pointer in the parent package object - */ - *this_target_ptr = target_object; - break; - - default: - return (AE_BAD_PARAMETER); - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_copy_ipackage_to_ipackage - * - * PARAMETERS: *Source_obj - Pointer to the source package object - * *Dest_obj - Where the internal object is returned - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to copy an internal package object - * into another internal package object. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_copy_ipackage_to_ipackage ( - ACPI_OPERAND_OBJECT *source_obj, - ACPI_OPERAND_OBJECT *dest_obj, - ACPI_WALK_STATE *walk_state) -{ - ACPI_STATUS status = AE_OK; - - - dest_obj->common.type = source_obj->common.type; - dest_obj->package.count = source_obj->package.count; - - - /* - * Create the object array and walk the source package tree - */ - - dest_obj->package.elements = acpi_cm_callocate ((source_obj->package.count + 1) * - sizeof (void *)); - dest_obj->package.next_element = dest_obj->package.elements; - - if (!dest_obj->package.elements) { - REPORT_ERROR ( - ("Aml_build_copy_internal_package_object: Package allocation failure\n")); - return (AE_NO_MEMORY); - } - - - status = acpi_cm_walk_package_tree (source_obj, dest_obj, - acpi_cm_copy_ielement_to_ielement, walk_state); - - return (status); -} - diff --git a/reactos/drivers/bus/acpi/utils/cmdebug.c b/reactos/drivers/bus/acpi/utils/cmdebug.c deleted file mode 100644 index afcb0ece698..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmdebug.c +++ /dev/null @@ -1,555 +0,0 @@ -/****************************************************************************** - * - * Module Name: cmdebug - Debug print routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmdebug") - - -/***************************************************************************** - * - * FUNCTION: Get/Set debug level - * - * DESCRIPTION: Get or set value of the debug flag - * - * These are used to allow user's to get/set the debug level - * - ****************************************************************************/ - - -u32 -get_debug_level (void) -{ - - return (acpi_dbg_level); -} - -void -set_debug_level ( - u32 new_debug_level) -{ - - acpi_dbg_level = new_debug_level; -} - - -/***************************************************************************** - * - * FUNCTION: Function_trace - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Function_name - Name of Caller's function - * - * RETURN: None - * - * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is - * set in Debug_level - * - ****************************************************************************/ - -void -function_trace ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name) -{ - - acpi_gbl_nesting_level++; - - debug_print (module_name, line_number, component_id, - TRACE_FUNCTIONS, - " %2.2ld Entered Function: %s\n", - acpi_gbl_nesting_level, function_name); -} - - -/***************************************************************************** - * - * FUNCTION: Function_trace_ptr - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Function_name - Name of Caller's function - * Pointer - Pointer to display - * - * RETURN: None - * - * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is - * set in Debug_level - * - ****************************************************************************/ - -void -function_trace_ptr ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - void *pointer) -{ - - acpi_gbl_nesting_level++; - debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, - " %2.2ld Entered Function: %s, %p\n", - acpi_gbl_nesting_level, function_name, pointer); -} - - -/***************************************************************************** - * - * FUNCTION: Function_trace_str - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Function_name - Name of Caller's function - * String - Additional string to display - * - * RETURN: None - * - * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is - * set in Debug_level - * - ****************************************************************************/ - -void -function_trace_str ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - NATIVE_CHAR *string) -{ - - acpi_gbl_nesting_level++; - debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, - " %2.2ld Entered Function: %s, %s\n", - acpi_gbl_nesting_level, function_name, string); -} - - -/***************************************************************************** - * - * FUNCTION: Function_trace_u32 - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Function_name - Name of Caller's function - * Integer - Integer to display - * - * RETURN: None - * - * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is - * set in Debug_level - * - ****************************************************************************/ - -void -function_trace_u32 ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - u32 integer) -{ - - acpi_gbl_nesting_level++; - debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, - " %2.2ld Entered Function: %s, %lX\n", - acpi_gbl_nesting_level, function_name, integer); -} - - -/***************************************************************************** - * - * FUNCTION: Function_exit - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Function_name - Name of Caller's function - * - * RETURN: None - * - * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is - * set in Debug_level - * - ****************************************************************************/ - -void -function_exit ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name) -{ - - debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, - " %2.2ld Exiting Function: %s\n", - acpi_gbl_nesting_level, function_name); - - acpi_gbl_nesting_level--; -} - - -/***************************************************************************** - * - * FUNCTION: Function_status_exit - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Function_name - Name of Caller's function - * Status - Exit status code - * - * RETURN: None - * - * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is - * set in Debug_level. Prints exit status also. - * - ****************************************************************************/ - -void -function_status_exit ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - ACPI_STATUS status) -{ - - debug_print (module_name, line_number, component_id, - TRACE_FUNCTIONS, - " %2.2ld Exiting Function: %s, %s\n", - acpi_gbl_nesting_level, - function_name, - acpi_cm_format_exception (status)); - - acpi_gbl_nesting_level--; -} - - -/***************************************************************************** - * - * FUNCTION: Function_value_exit - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Function_name - Name of Caller's function - * Value - Value to be printed with exit msg - * - * RETURN: None - * - * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is - * set in Debug_level. Prints exit value also. - * - ****************************************************************************/ - -void -function_value_exit ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - ACPI_INTEGER value) -{ - - debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, - " %2.2ld Exiting Function: %s, %X\n", - acpi_gbl_nesting_level, function_name, value); - - acpi_gbl_nesting_level--; -} - - -/***************************************************************************** - * - * FUNCTION: Function_ptr_exit - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Function_name - Name of Caller's function - * Value - Value to be printed with exit msg - * - * RETURN: None - * - * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is - * set in Debug_level. Prints exit value also. - * - ****************************************************************************/ - -void -function_ptr_exit ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - NATIVE_CHAR *function_name, - u8 *ptr) -{ - - debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, - " %2.2ld Exiting Function: %s, %p\n", - acpi_gbl_nesting_level, function_name, ptr); - - acpi_gbl_nesting_level--; -} - - -/***************************************************************************** - * - * FUNCTION: Debug_print - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Print_level - Requested debug print level - * Format - Printf format field - * ... - Optional printf arguments - * - * RETURN: None - * - * DESCRIPTION: Print error message with prefix consisting of the module name, - * line number, and component ID. - * - ****************************************************************************/ - -void -debug_print ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - u32 print_level, - NATIVE_CHAR *format, - ...) -{ - va_list args; - - - /* Both the level and the component must be enabled */ - - if ((print_level & acpi_dbg_level) && - (component_id & acpi_dbg_layer)) { - va_start (args, format); - - acpi_os_printf ("%8s-%04d: ", module_name, line_number); - acpi_os_vprintf (format, args); - } -} - - -/***************************************************************************** - * - * FUNCTION: Debug_print_prefix - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * - * RETURN: None - * - * DESCRIPTION: Print the prefix part of an error message, consisting of the - * module name, and line number - * - ****************************************************************************/ - -void -debug_print_prefix ( - NATIVE_CHAR *module_name, - u32 line_number) -{ - - - acpi_os_printf ("%8s-%04d: ", module_name, line_number); -} - - -/***************************************************************************** - * - * FUNCTION: Debug_print_raw - * - * PARAMETERS: Format - Printf format field - * ... - Optional printf arguments - * - * RETURN: None - * - * DESCRIPTION: Print error message -- without module/line indentifiers - * - ****************************************************************************/ - -void -debug_print_raw ( - NATIVE_CHAR *format, - ...) -{ - va_list args; - - - va_start (args, format); - - acpi_os_vprintf (format, args); - - va_end (args); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_cm_dump_buffer - * - * PARAMETERS: Buffer - Buffer to dump - * Count - Amount to dump, in bytes - * Component_iD - Caller's component ID - * - * RETURN: None - * - * DESCRIPTION: Generic dump buffer in both hex and ascii. - * - ****************************************************************************/ - -void -acpi_cm_dump_buffer ( - u8 *buffer, - u32 count, - u32 display, - u32 component_id) -{ - u32 i = 0; - u32 j; - u32 temp32; - u8 buf_char; - - - /* Only dump the buffer if tracing is enabled */ - - if (!((TRACE_TABLES & acpi_dbg_level) && - (component_id & acpi_dbg_layer))) { - return; - } - - - /* - * Nasty little dump buffer routine! - */ - while (i < count) { - /* Print current offset */ - - acpi_os_printf ("%05X ", i); - - - /* Print 16 hex chars */ - - for (j = 0; j < 16;) { - if (i + j >= count) { - acpi_os_printf ("\n"); - return; - } - - /* Make sure that the s8 doesn't get sign-extended! */ - - switch (display) { - /* Default is BYTE display */ - - default: - - acpi_os_printf ("%02X ", - *((u8 *) &buffer[i + j])); - j += 1; - break; - - - case DB_WORD_DISPLAY: - - MOVE_UNALIGNED16_TO_32 (&temp32, - &buffer[i + j]); - acpi_os_printf ("%04X ", temp32); - j += 2; - break; - - - case DB_DWORD_DISPLAY: - - MOVE_UNALIGNED32_TO_32 (&temp32, - &buffer[i + j]); - acpi_os_printf ("%08X ", temp32); - j += 4; - break; - - - case DB_QWORD_DISPLAY: - - MOVE_UNALIGNED32_TO_32 (&temp32, - &buffer[i + j]); - acpi_os_printf ("%08X", temp32); - - MOVE_UNALIGNED32_TO_32 (&temp32, - &buffer[i + j + 4]); - acpi_os_printf ("%08X ", temp32); - j += 8; - break; - } - } - - - /* - * Print the ASCII equivalent characters - * But watch out for the bad unprintable ones... - */ - - for (j = 0; j < 16; j++) { - if (i + j >= count) { - acpi_os_printf ("\n"); - return; - } - - buf_char = buffer[i + j]; - if ((buf_char > 0x1F && buf_char < 0x2E) || - (buf_char > 0x2F && buf_char < 0x61) || - (buf_char > 0x60 && buf_char < 0x7F)) { - acpi_os_printf ("%c", buf_char); - } - else { - acpi_os_printf ("."); - } - } - - /* Done with that line. */ - - acpi_os_printf ("\n"); - i += 16; - } - - return; -} - - diff --git a/reactos/drivers/bus/acpi/utils/cmdelete.c b/reactos/drivers/bus/acpi/utils/cmdelete.c deleted file mode 100644 index a0fc962944a..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmdelete.c +++ /dev/null @@ -1,585 +0,0 @@ -/******************************************************************************* - * - * Module Name: cmdelete - object deletion and reference count utilities - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmdelete") - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_delete_internal_obj - * - * PARAMETERS: *Object - Pointer to the list to be deleted - * - * RETURN: None - * - * DESCRIPTION: Low level object deletion, after reference counts have been - * updated (All reference counts, including sub-objects!) - * - ******************************************************************************/ - -void -acpi_cm_delete_internal_obj ( - ACPI_OPERAND_OBJECT *object) -{ - void *obj_pointer = NULL; - ACPI_OPERAND_OBJECT *handler_desc; - - - if (!object) { - return; - } - - /* - * Must delete or free any pointers within the object that are not - * actual ACPI objects (for example, a raw buffer pointer). - */ - - switch (object->common.type) { - - case ACPI_TYPE_STRING: - - /* Free the actual string buffer */ - - obj_pointer = object->string.pointer; - break; - - - case ACPI_TYPE_BUFFER: - - /* Free the actual buffer */ - - obj_pointer = object->buffer.pointer; - break; - - - case ACPI_TYPE_PACKAGE: - - /* - * Elements of the package are not handled here, they are deleted - * separately - */ - - /* Free the (variable length) element pointer array */ - - obj_pointer = object->package.elements; - break; - - - case ACPI_TYPE_MUTEX: - - acpi_aml_unlink_mutex (object); - acpi_os_delete_semaphore (object->mutex.semaphore); - break; - - - case ACPI_TYPE_EVENT: - - acpi_os_delete_semaphore (object->event.semaphore); - object->event.semaphore = NULL; - break; - - - case ACPI_TYPE_METHOD: - - /* Delete the method semaphore if it exists */ - - if (object->method.semaphore) { - acpi_os_delete_semaphore (object->method.semaphore); - object->method.semaphore = NULL; - } - - break; - - - case ACPI_TYPE_REGION: - - - if (object->region.extra) { - /* - * Free the Region_context if and only if the handler is one of the - * default handlers -- and therefore, we created the context object - * locally, it was not created by an external caller. - */ - handler_desc = object->region.addr_handler; - if ((handler_desc) && - (handler_desc->addr_handler.hflags == ADDR_HANDLER_DEFAULT_INSTALLED)) { - obj_pointer = object->region.extra->extra.region_context; - } - - /* Now we can free the Extra object */ - - acpi_cm_delete_object_desc (object->region.extra); - } - break; - - - case ACPI_TYPE_FIELD_UNIT: - - if (object->field_unit.extra) { - acpi_cm_delete_object_desc (object->field_unit.extra); - } - break; - - default: - break; - } - - - /* - * Delete any allocated memory found above - */ - - if (obj_pointer) { - if (!acpi_tb_system_table_pointer (obj_pointer)) { - acpi_cm_free (obj_pointer); - } - } - - - /* Only delete the object if it was dynamically allocated */ - - - if (!(object->common.flags & AOPOBJ_STATIC_ALLOCATION)) { - acpi_cm_delete_object_desc (object); - - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_delete_internal_object_list - * - * PARAMETERS: *Obj_list - Pointer to the list to be deleted - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function deletes an internal object list, including both - * simple objects and package objects - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_delete_internal_object_list ( - ACPI_OPERAND_OBJECT **obj_list) -{ - ACPI_OPERAND_OBJECT **internal_obj; - - - /* Walk the null-terminated internal list */ - - for (internal_obj = obj_list; *internal_obj; internal_obj++) { - /* - * Check for a package - * Simple objects are simply stored in the array and do not - * need to be deleted separately. - */ - - if (IS_THIS_OBJECT_TYPE ((*internal_obj), ACPI_TYPE_PACKAGE)) { - /* Delete the package */ - - /* - * TBD: [Investigate] This might not be the right thing to do, - * depending on how the internal package object was allocated!!! - */ - acpi_cm_delete_internal_obj (*internal_obj); - } - - } - - /* Free the combined parameter pointer list and object array */ - - acpi_cm_free (obj_list); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_update_ref_count - * - * PARAMETERS: *Object - Object whose ref count is to be updated - * Action - What to do - * - * RETURN: New ref count - * - * DESCRIPTION: Modify the ref count and return it. - * - ******************************************************************************/ - -static void -acpi_cm_update_ref_count ( - ACPI_OPERAND_OBJECT *object, - u32 action) -{ - u16 count; - u16 new_count; - - - if (!object) { - return; - } - - - count = object->common.reference_count; - new_count = count; - - /* - * Reference count action (increment, decrement, or force delete) - */ - - switch (action) { - - case REF_INCREMENT: - - new_count++; - object->common.reference_count = new_count; - - break; - - - case REF_DECREMENT: - - if (count < 1) { - new_count = 0; - } - - else { - new_count--; - - } - - - object->common.reference_count = new_count; - if (new_count == 0) { - acpi_cm_delete_internal_obj (object); - } - - break; - - - case REF_FORCE_DELETE: - - new_count = 0; - object->common.reference_count = new_count; - acpi_cm_delete_internal_obj (object); - break; - - - default: - - break; - } - - - /* - * Sanity check the reference count, for debug purposes only. - * (A deleted object will have a huge reference count) - */ - - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_update_object_reference - * - * PARAMETERS: *Object - Increment ref count for this object - * and all sub-objects - * Action - Either REF_INCREMENT or REF_DECREMENT or - * REF_FORCE_DELETE - * - * RETURN: Status - * - * DESCRIPTION: Increment the object reference count - * - * Object references are incremented when: - * 1) An object is attached to a Node (namespace object) - * 2) An object is copied (all subobjects must be incremented) - * - * Object references are decremented when: - * 1) An object is detached from an Node - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_update_object_reference ( - ACPI_OPERAND_OBJECT *object, - u16 action) -{ - ACPI_STATUS status; - u32 i; - ACPI_OPERAND_OBJECT *next; - ACPI_OPERAND_OBJECT *new; - ACPI_GENERIC_STATE *state_list = NULL; - ACPI_GENERIC_STATE *state; - - - /* Ignore a null object ptr */ - - if (!object) { - return (AE_OK); - } - - - /* - * Make sure that this isn't a namespace handle or an AML pointer - */ - - if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED)) { - return (AE_OK); - } - - if (acpi_tb_system_table_pointer (object)) { - return (AE_OK); - } - - - state = acpi_cm_create_update_state (object, action); - - while (state) { - - object = state->update.object; - action = state->update.value; - acpi_cm_delete_generic_state (state); - - /* - * All sub-objects must have their reference count incremented also. - * Different object types have different subobjects. - */ - switch (object->common.type) { - - case ACPI_TYPE_DEVICE: - - status = acpi_cm_create_update_state_and_push (object->device.addr_handler, - action, &state_list); - if (ACPI_FAILURE (status)) { - return (status); - } - - acpi_cm_update_ref_count (object->device.sys_handler, action); - acpi_cm_update_ref_count (object->device.drv_handler, action); - break; - - - case INTERNAL_TYPE_ADDRESS_HANDLER: - - /* Must walk list of address handlers */ - - next = object->addr_handler.next; - while (next) { - new = next->addr_handler.next; - acpi_cm_update_ref_count (next, action); - - next = new; - } - break; - - - case ACPI_TYPE_PACKAGE: - - /* - * We must update all the sub-objects of the package - * (Each of whom may have their own sub-objects, etc. - */ - for (i = 0; i < object->package.count; i++) { - /* - * Push each element onto the stack for later processing. - * Note: There can be null elements within the package, - * these are simply ignored - */ - - status = acpi_cm_create_update_state_and_push ( - object->package.elements[i], action, &state_list); - if (ACPI_FAILURE (status)) { - return (status); - } - } - break; - - - case ACPI_TYPE_FIELD_UNIT: - - status = acpi_cm_create_update_state_and_push ( - object->field_unit.container, action, &state_list); - - if (ACPI_FAILURE (status)) { - return (status); - } - break; - - - case INTERNAL_TYPE_DEF_FIELD: - - status = acpi_cm_create_update_state_and_push ( - object->field.container, action, &state_list); - if (ACPI_FAILURE (status)) { - return (status); - } - break; - - - case INTERNAL_TYPE_BANK_FIELD: - - status = acpi_cm_create_update_state_and_push ( - object->bank_field.bank_select, action, &state_list); - if (ACPI_FAILURE (status)) { - return (status); - } - - status = acpi_cm_create_update_state_and_push ( - object->bank_field.container, action, &state_list); - if (ACPI_FAILURE (status)) { - return (status); - } - break; - - - case ACPI_TYPE_REGION: - - /* TBD: [Investigate] - Acpi_cm_update_ref_count (Object->Region.Addr_handler, Action); - */ -/* - Status = - Acpi_cm_create_update_state_and_push (Object->Region.Addr_handler, - Action, &State_list); - if (ACPI_FAILURE (Status)) - { - return (Status); - } -*/ - break; - - - case INTERNAL_TYPE_REFERENCE: - - break; - } - - - /* - * Now we can update the count in the main object. This can only - * happen after we update the sub-objects in case this causes the - * main object to be deleted. - */ - - acpi_cm_update_ref_count (object, action); - - - /* Move on to the next object to be updated */ - - state = acpi_cm_pop_generic_state (&state_list); - } - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_add_reference - * - * PARAMETERS: *Object - Object whose reference count is to be - * incremented - * - * RETURN: None - * - * DESCRIPTION: Add one reference to an ACPI object - * - ******************************************************************************/ - -void -acpi_cm_add_reference ( - ACPI_OPERAND_OBJECT *object) -{ - - - /* - * Ensure that we have a valid object - */ - - if (!acpi_cm_valid_internal_object (object)) { - return; - } - - /* - * We have a valid ACPI internal object, now increment the reference count - */ - - acpi_cm_update_object_reference (object, REF_INCREMENT); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_remove_reference - * - * PARAMETERS: *Object - Object whose ref count will be decremented - * - * RETURN: None - * - * DESCRIPTION: Decrement the reference count of an ACPI internal object - * - ******************************************************************************/ - -void -acpi_cm_remove_reference ( - ACPI_OPERAND_OBJECT *object) -{ - - - /* - * Ensure that we have a valid object - */ - - if (!acpi_cm_valid_internal_object (object)) { - return; - } - - /* - * Decrement the reference count, and only actually delete the object - * if the reference count becomes 0. (Must also decrement the ref count - * of all subobjects!) - */ - - acpi_cm_update_object_reference (object, REF_DECREMENT); - - return; -} - - diff --git a/reactos/drivers/bus/acpi/utils/cmeval.c b/reactos/drivers/bus/acpi/utils/cmeval.c deleted file mode 100644 index 0ad04066dd0..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmeval.c +++ /dev/null @@ -1,303 +0,0 @@ -/****************************************************************************** - * - * Module Name: cmeval - Object evaluation - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmeval") - - -/**************************************************************************** - * - * FUNCTION: Acpi_cm_evaluate_numeric_object - * - * PARAMETERS: *Object_name - Object name to be evaluated - * Device_node - Node for the device - * *Address - Where the value is returned - * - * RETURN: Status - * - * DESCRIPTION: evaluates a numeric namespace object for a selected device - * and stores results in *Address. - * - * NOTE: Internal function, no parameter validation - * - ***************************************************************************/ - -ACPI_STATUS -acpi_cm_evaluate_numeric_object ( - NATIVE_CHAR *object_name, - ACPI_NAMESPACE_NODE *device_node, - ACPI_INTEGER *address) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - /* Execute the method */ - - status = acpi_ns_evaluate_relative (device_node, object_name, NULL, &obj_desc); - if (ACPI_FAILURE (status)) { - - return (status); - } - - - /* Did we get a return object? */ - - if (!obj_desc) { - return (AE_TYPE); - } - - /* Is the return object of the correct type? */ - - if (obj_desc->common.type != ACPI_TYPE_INTEGER) { - status = AE_TYPE; - } - else { - /* - * Since the structure is a union, setting any field will set all - * of the variables in the union - */ - *address = obj_desc->integer.value; - } - - /* On exit, we must delete the return object */ - - acpi_cm_remove_reference (obj_desc); - - return (status); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_cm_execute_HID - * - * PARAMETERS: Device_node - Node for the device - * *Hid - Where the HID is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _HID control method that returns the hardware - * ID of the device. - * - * NOTE: Internal function, no parameter validation - * - ***************************************************************************/ - -ACPI_STATUS -acpi_cm_execute_HID ( - ACPI_NAMESPACE_NODE *device_node, - DEVICE_ID *hid) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - /* Execute the method */ - - status = acpi_ns_evaluate_relative (device_node, - METHOD_NAME__HID, NULL, &obj_desc); - if (ACPI_FAILURE (status)) { - - - return (status); - } - - /* Did we get a return object? */ - - if (!obj_desc) { - return (AE_TYPE); - } - - /* - * A _HID can return either a Number (32 bit compressed EISA ID) or - * a string - */ - - if ((obj_desc->common.type != ACPI_TYPE_INTEGER) && - (obj_desc->common.type != ACPI_TYPE_STRING)) { - status = AE_TYPE; - } - - else { - if (obj_desc->common.type == ACPI_TYPE_INTEGER) { - /* Convert the Numeric HID to string */ - - acpi_aml_eisa_id_to_string ((u32) obj_desc->integer.value, hid->buffer); - } - - else { - /* Copy the String HID from the returned object */ - - STRNCPY(hid->buffer, obj_desc->string.pointer, sizeof(hid->buffer)); - } - } - - - /* On exit, we must delete the return object */ - - acpi_cm_remove_reference (obj_desc); - - return (status); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_cm_execute_UID - * - * PARAMETERS: Device_node - Node for the device - * *Uid - Where the UID is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _UID control method that returns the hardware - * ID of the device. - * - * NOTE: Internal function, no parameter validation - * - ***************************************************************************/ - -ACPI_STATUS -acpi_cm_execute_UID ( - ACPI_NAMESPACE_NODE *device_node, - DEVICE_ID *uid) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - /* Execute the method */ - - status = acpi_ns_evaluate_relative (device_node, - METHOD_NAME__UID, NULL, &obj_desc); - if (ACPI_FAILURE (status)) { - - - return (status); - } - - /* Did we get a return object? */ - - if (!obj_desc) { - return (AE_TYPE); - } - - /* - * A _UID can return either a Number (32 bit compressed EISA ID) or - * a string - */ - - if ((obj_desc->common.type != ACPI_TYPE_INTEGER) && - (obj_desc->common.type != ACPI_TYPE_STRING)) { - status = AE_TYPE; - } - - else { - if (obj_desc->common.type == ACPI_TYPE_INTEGER) { - /* Convert the Numeric UID to string */ - - acpi_aml_unsigned_integer_to_string (obj_desc->integer.value, uid->buffer); - } - - else { - /* Copy the String UID from the returned object */ - - STRNCPY(uid->buffer, obj_desc->string.pointer, sizeof(uid->buffer)); - } - } - - - /* On exit, we must delete the return object */ - - acpi_cm_remove_reference (obj_desc); - - return (status); -} - -/**************************************************************************** - * - * FUNCTION: Acpi_cm_execute_STA - * - * PARAMETERS: Device_node - Node for the device - * *Flags - Where the status flags are returned - * - * RETURN: Status - * - * DESCRIPTION: Executes _STA for selected device and stores results in - * *Flags. - * - * NOTE: Internal function, no parameter validation - * - ***************************************************************************/ - -ACPI_STATUS -acpi_cm_execute_STA ( - ACPI_NAMESPACE_NODE *device_node, - u32 *flags) -{ - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_STATUS status; - - - /* Execute the method */ - - status = acpi_ns_evaluate_relative (device_node, - METHOD_NAME__STA, NULL, &obj_desc); - if (AE_NOT_FOUND == status) { - *flags = 0x0F; - status = AE_OK; - } - - - else /* success */ { - /* Did we get a return object? */ - - if (!obj_desc) { - return (AE_TYPE); - } - - /* Is the return object of the correct type? */ - - if (obj_desc->common.type != ACPI_TYPE_INTEGER) { - status = AE_TYPE; - } - - else { - /* Extract the status flags */ - - *flags = (u32) obj_desc->integer.value; - } - - /* On exit, we must delete the return object */ - - acpi_cm_remove_reference (obj_desc); - } - - return (status); -} diff --git a/reactos/drivers/bus/acpi/utils/cmglobal.c b/reactos/drivers/bus/acpi/utils/cmglobal.c deleted file mode 100644 index a66677ea394..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmglobal.c +++ /dev/null @@ -1,568 +0,0 @@ -/****************************************************************************** - * - * Module Name: cmglobal - Global variables for the ACPI subsystem - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmglobal") - - -/****************************************************************************** - * - * Static global variable initialization. - * - ******************************************************************************/ - -/* - * We want the debug switches statically initialized so they - * are already set when the debugger is entered. - */ - -/* Debug switch - level and trace mask */ - -u32 acpi_dbg_level = NORMAL_DEFAULT; - -/* Debug switch - layer (component) mask */ - -u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT; -u32 acpi_gbl_nesting_level = 0; - - -/* Debugger globals */ - -u8 acpi_gbl_db_terminate_threads = FALSE; -u8 acpi_gbl_method_executing = FALSE; - -/* System flags */ - -u32 acpi_gbl_system_flags = 0; -u32 acpi_gbl_startup_flags = 0; - -/* System starts unitialized! */ -u8 acpi_gbl_shutdown = TRUE; - - -u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128}; - - -/****************************************************************************** - * - * Namespace globals - * - ******************************************************************************/ - - -/* - * Names built-in to the interpreter - * - * Initial values are currently supported only for types String and Number. - * To avoid type punning, both are specified as strings in this table. - * - * NOTES: - * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run - * during the initialization sequence. - */ - -PREDEFINED_NAMES acpi_gbl_pre_defined_names[] = -{ {"_GPE", INTERNAL_TYPE_DEF_ANY}, - {"_PR_", INTERNAL_TYPE_DEF_ANY}, - {"_SB_", ACPI_TYPE_DEVICE}, - {"_SI_", INTERNAL_TYPE_DEF_ANY}, - {"_TZ_", INTERNAL_TYPE_DEF_ANY}, - {"_REV", ACPI_TYPE_INTEGER, "2"}, - {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, - {"_GL_", ACPI_TYPE_MUTEX, "0"}, - {NULL, ACPI_TYPE_ANY} /* Table terminator */ -}; - - -/* - * Properties of the ACPI Object Types, both internal and external. - * - * Elements of Acpi_ns_properties are bit significant - * and the table is indexed by values of ACPI_OBJECT_TYPE - */ - -u8 acpi_gbl_ns_properties[] = -{ - NSP_NORMAL, /* 00 Any */ - NSP_NORMAL, /* 01 Number */ - NSP_NORMAL, /* 02 String */ - NSP_NORMAL, /* 03 Buffer */ - NSP_LOCAL, /* 04 Package */ - NSP_NORMAL, /* 05 Field_unit */ - NSP_NEWSCOPE | NSP_LOCAL, /* 06 Device */ - NSP_LOCAL, /* 07 Acpi_event */ - NSP_NEWSCOPE | NSP_LOCAL, /* 08 Method */ - NSP_LOCAL, /* 09 Mutex */ - NSP_LOCAL, /* 10 Region */ - NSP_NEWSCOPE | NSP_LOCAL, /* 11 Power */ - NSP_NEWSCOPE | NSP_LOCAL, /* 12 Processor */ - NSP_NEWSCOPE | NSP_LOCAL, /* 13 Thermal */ - NSP_NORMAL, /* 14 Buffer_field */ - NSP_NORMAL, /* 15 Ddb_handle */ - NSP_NORMAL, /* 16 Debug Object */ - NSP_NORMAL, /* 17 Def_field */ - NSP_NORMAL, /* 18 Bank_field */ - NSP_NORMAL, /* 19 Index_field */ - NSP_NORMAL, /* 20 Reference */ - NSP_NORMAL, /* 21 Alias */ - NSP_NORMAL, /* 22 Notify */ - NSP_NORMAL, /* 23 Address Handler */ - NSP_NEWSCOPE | NSP_LOCAL, /* 24 Resource */ - NSP_NORMAL, /* 25 Def_field_defn */ - NSP_NORMAL, /* 26 Bank_field_defn */ - NSP_NORMAL, /* 27 Index_field_defn */ - NSP_NORMAL, /* 28 If */ - NSP_NORMAL, /* 29 Else */ - NSP_NORMAL, /* 30 While */ - NSP_NEWSCOPE, /* 31 Scope */ - NSP_LOCAL, /* 32 Def_any */ - NSP_NORMAL, /* 33 Extra */ - NSP_NORMAL /* 34 Invalid */ -}; - - -/* Hex to ASCII conversion table */ - -NATIVE_CHAR acpi_gbl_hex_to_ascii[] = - {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; - - -/****************************************************************************** - * - * Table globals - * - * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes. - * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables - * that are not used by the subsystem are simply ignored. - * - ******************************************************************************/ - - -ACPI_TABLE_DESC acpi_gbl_acpi_tables[NUM_ACPI_TABLES]; - - -ACPI_TABLE_SUPPORT acpi_gbl_acpi_table_data[NUM_ACPI_TABLES] = -{ - /*********** Name, Signature, Signature size, How many allowed?, Supported? Global typed pointer */ - - /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL}, - /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &acpi_gbl_DSDT}, - /* FADT 2 */ {FADT_SIG, FADT_SIG, sizeof (FADT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &acpi_gbl_FADT}, - /* FACS 3 */ {FACS_SIG, FACS_SIG, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &acpi_gbl_FACS}, - /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL}, - /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL}, - /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL}, -}; - -/* - * String versions of the exception codes above - * These strings must match the corresponding defines exactly - */ -NATIVE_CHAR *acpi_gbl_exception_names_env[] = -{ - "AE_OK", - "AE_ERROR", - "AE_NO_ACPI_TABLES", - "AE_NO_NAMESPACE", - "AE_NO_MEMORY", - "AE_NOT_FOUND", - "AE_NOT_EXIST", - "AE_EXIST", - "AE_TYPE", - "AE_NULL_OBJECT", - "AE_NULL_ENTRY", - "AE_BUFFER_OVERFLOW", - "AE_STACK_OVERFLOW", - "AE_STACK_UNDERFLOW", - "AE_NOT_IMPLEMENTED", - "AE_VERSION_MISMATCH", - "AE_SUPPORT", - "AE_SHARE", - "AE_LIMIT", - "AE_TIME", - "AE_UNKNOWN_STATUS", - "AE_ACQUIRE_DEADLOCK", - "AE_RELEASE_DEADLOCK", - "AE_NOT_ACQUIRED", - "AE_ALREADY_ACQUIRED", - "AE_NO_HARDWARE_RESPONSE", - "AE_NO_GLOBAL_LOCK", -}; - -static NATIVE_CHAR *acpi_gbl_exception_names_pgm[] = -{ - "AE_BAD_PARAMETER", - "AE_BAD_CHARACTER", - "AE_BAD_PATHNAME", - "AE_BAD_DATA", - "AE_BAD_ADDRESS", -}; - -static NATIVE_CHAR *acpi_gbl_exception_names_tbl[] = -{ - "AE_BAD_SIGNATURE", - "AE_BAD_HEADER", - "AE_BAD_CHECKSUM", - "AE_BAD_VALUE", -}; - -static NATIVE_CHAR *acpi_gbl_exception_names_aml[] = -{ - "AE_AML_ERROR", - "AE_AML_PARSE", - "AE_AML_BAD_OPCODE", - "AE_AML_NO_OPERAND", - "AE_AML_OPERAND_TYPE", - "AE_AML_OPERAND_VALUE", - "AE_AML_UNINITIALIZED_LOCAL", - "AE_AML_UNINITIALIZED_ARG", - "AE_AML_UNINITIALIZED_ELEMENT", - "AE_AML_NUMERIC_OVERFLOW", - "AE_AML_REGION_LIMIT", - "AE_AML_BUFFER_LIMIT", - "AE_AML_PACKAGE_LIMIT", - "AE_AML_DIVIDE_BY_ZERO", - "AE_AML_BAD_NAME", - "AE_AML_NAME_NOT_FOUND", - "AE_AML_INTERNAL", - "AE_AML_INVALID_SPACE_ID", - "AE_AML_STRING_LIMIT", - "AE_AML_NO_RETURN_VALUE", - "AE_AML_METHOD_LIMIT", - "AE_AML_NOT_OWNER", - "AE_AML_MUTEX_ORDER", - "AE_AML_MUTEX_NOT_ACQUIRED", -}; - -static NATIVE_CHAR *acpi_gbl_exception_names_ctrl[] = -{ - "AE_CTRL_RETURN_VALUE", - "AE_CTRL_PENDING", - "AE_CTRL_TERMINATE", - "AE_CTRL_TRUE", - "AE_CTRL_FALSE", - "AE_CTRL_DEPTH", - "AE_CTRL_END", - "AE_CTRL_TRANSFER", -}; - -/***************************************************************************** - * - * FUNCTION: Acpi_cm_valid_object_type - * - * PARAMETERS: None. - * - * RETURN: TRUE if valid object type - * - * DESCRIPTION: Validate an object type - * - ****************************************************************************/ - -u8 -acpi_cm_valid_object_type ( - u32 type) -{ - - if (type > ACPI_TYPE_MAX) - { - if ((type < INTERNAL_TYPE_BEGIN) || - (type > INTERNAL_TYPE_MAX)) - { - return (FALSE); - } - } - - return (TRUE); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_cm_format_exception - * - * PARAMETERS: Status - Acpi status to be formatted - * - * RETURN: Formatted status string - * - * DESCRIPTION: Convert an ACPI exception to a string - * - ****************************************************************************/ - -NATIVE_CHAR * -acpi_cm_format_exception ( - ACPI_STATUS status) -{ - NATIVE_CHAR *exception = "UNKNOWN_STATUS"; - ACPI_STATUS sub_status; - - - sub_status = (status & ~AE_CODE_MASK); - - - switch (status & AE_CODE_MASK) - { - case AE_CODE_ENVIRONMENTAL: - - if (sub_status <= AE_CODE_ENV_MAX) - { - exception = acpi_gbl_exception_names_env [sub_status]; - } - break; - - case AE_CODE_PROGRAMMER: - - if (sub_status <= AE_CODE_PGM_MAX) - { - exception = acpi_gbl_exception_names_pgm [sub_status -1]; - } - break; - - case AE_CODE_ACPI_TABLES: - - if (sub_status <= AE_CODE_TBL_MAX) - { - exception = acpi_gbl_exception_names_tbl [sub_status -1]; - } - break; - - case AE_CODE_AML: - - if (sub_status <= AE_CODE_AML_MAX) - { - exception = acpi_gbl_exception_names_aml [sub_status -1]; - } - break; - - case AE_CODE_CONTROL: - - if (sub_status <= AE_CODE_CTRL_MAX) - { - exception = acpi_gbl_exception_names_ctrl [sub_status -1]; - } - break; - - default: - break; - } - - - return (exception); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_cm_allocate_owner_id - * - * PARAMETERS: Id_type - Type of ID (method or table) - * - * DESCRIPTION: Allocate a table or method owner id - * - ***************************************************************************/ - -ACPI_OWNER_ID -acpi_cm_allocate_owner_id ( - u32 id_type) -{ - ACPI_OWNER_ID owner_id = 0xFFFF; - - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - - switch (id_type) - { - case OWNER_TYPE_TABLE: - - owner_id = acpi_gbl_next_table_owner_id; - acpi_gbl_next_table_owner_id++; - - if (acpi_gbl_next_table_owner_id == FIRST_METHOD_ID) - { - acpi_gbl_next_table_owner_id = FIRST_TABLE_ID; - } - break; - - - case OWNER_TYPE_METHOD: - - owner_id = acpi_gbl_next_method_owner_id; - acpi_gbl_next_method_owner_id++; - - if (acpi_gbl_next_method_owner_id == FIRST_TABLE_ID) - { - acpi_gbl_next_method_owner_id = FIRST_METHOD_ID; - } - break; - } - - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - - return (owner_id); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_cm_init_globals - * - * PARAMETERS: none - * - * DESCRIPTION: Init library globals. All globals that require specific - * initialization should be initialized here! - * - ***************************************************************************/ - -void -acpi_cm_init_globals ( - void) -{ - u32 i; - - - /* ACPI table structure */ - - for (i = 0; i < NUM_ACPI_TABLES; i++) - { - acpi_gbl_acpi_tables[i].prev = &acpi_gbl_acpi_tables[i]; - acpi_gbl_acpi_tables[i].next = &acpi_gbl_acpi_tables[i]; - acpi_gbl_acpi_tables[i].pointer = NULL; - acpi_gbl_acpi_tables[i].length = 0; - acpi_gbl_acpi_tables[i].allocation = ACPI_MEM_NOT_ALLOCATED; - acpi_gbl_acpi_tables[i].count = 0; - } - - - /* Address Space handler array */ - - for (i = 0; i < ACPI_NUM_ADDRESS_SPACES; i++) - { - acpi_gbl_address_spaces[i].handler = NULL; - acpi_gbl_address_spaces[i].context = NULL; - } - - /* Mutex locked flags */ - - for (i = 0; i < NUM_MTX; i++) - { - acpi_gbl_acpi_mutex_info[i].mutex = NULL; - acpi_gbl_acpi_mutex_info[i].locked = FALSE; - acpi_gbl_acpi_mutex_info[i].use_count = 0; - acpi_gbl_acpi_mutex_info[i].owner_id = 0; - } - - /* Global notify handlers */ - - acpi_gbl_sys_notify.handler = NULL; - acpi_gbl_drv_notify.handler = NULL; - - /* Global "typed" ACPI table pointers */ - - acpi_gbl_RSDP = NULL; - acpi_gbl_XSDT = NULL; - acpi_gbl_FACS = NULL; - acpi_gbl_FADT = NULL; - acpi_gbl_DSDT = NULL; - - - /* Global Lock support */ - - acpi_gbl_global_lock_acquired = FALSE; - acpi_gbl_global_lock_thread_count = 0; - - /* Miscellaneous variables */ - - acpi_gbl_system_flags = 0; - acpi_gbl_startup_flags = 0; - acpi_gbl_rsdp_original_location = 0; - acpi_gbl_cm_single_step = FALSE; - acpi_gbl_db_terminate_threads = FALSE; - acpi_gbl_shutdown = FALSE; - acpi_gbl_ns_lookup_count = 0; - acpi_gbl_ps_find_count = 0; - acpi_gbl_acpi_hardware_present = TRUE; - acpi_gbl_next_table_owner_id = FIRST_TABLE_ID; - acpi_gbl_next_method_owner_id = FIRST_METHOD_ID; - acpi_gbl_debugger_configuration = DEBUGGER_THREADING; - - /* Cache of small "state" objects */ - - acpi_gbl_generic_state_cache = NULL; - acpi_gbl_generic_state_cache_depth = 0; - acpi_gbl_state_cache_requests = 0; - acpi_gbl_state_cache_hits = 0; - - acpi_gbl_parse_cache = NULL; - acpi_gbl_parse_cache_depth = 0; - acpi_gbl_parse_cache_requests = 0; - acpi_gbl_parse_cache_hits = 0; - - acpi_gbl_ext_parse_cache = NULL; - acpi_gbl_ext_parse_cache_depth = 0; - acpi_gbl_ext_parse_cache_requests = 0; - acpi_gbl_ext_parse_cache_hits = 0; - - acpi_gbl_object_cache = NULL; - acpi_gbl_object_cache_depth = 0; - acpi_gbl_object_cache_requests = 0; - acpi_gbl_object_cache_hits = 0; - - acpi_gbl_walk_state_cache = NULL; - acpi_gbl_walk_state_cache_depth = 0; - acpi_gbl_walk_state_cache_requests = 0; - acpi_gbl_walk_state_cache_hits = 0; - - /* Hardware oriented */ - - acpi_gbl_gpe0enable_register_save = NULL; - acpi_gbl_gpe1_enable_register_save = NULL; - acpi_gbl_original_mode = SYS_MODE_UNKNOWN; /* original ACPI/legacy mode */ - acpi_gbl_gpe_registers = NULL; - acpi_gbl_gpe_info = NULL; - - /* Namespace */ - - acpi_gbl_root_node = NULL; - - acpi_gbl_root_node_struct.name = ACPI_ROOT_NAME; - acpi_gbl_root_node_struct.data_type = ACPI_DESC_TYPE_NAMED; - acpi_gbl_root_node_struct.type = ACPI_TYPE_ANY; - acpi_gbl_root_node_struct.child = NULL; - acpi_gbl_root_node_struct.peer = NULL; - acpi_gbl_root_node_struct.object = NULL; - acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; - - /* Memory allocation metrics - compiled out in non-debug mode. */ - - INITIALIZE_ALLOCATION_METRICS(); - - return; -} - - diff --git a/reactos/drivers/bus/acpi/utils/cminit.c b/reactos/drivers/bus/acpi/utils/cminit.c deleted file mode 100644 index 72708c615d6..00000000000 --- a/reactos/drivers/bus/acpi/utils/cminit.c +++ /dev/null @@ -1,242 +0,0 @@ -/****************************************************************************** - * - * Module Name: cminit - Common ACPI subsystem initialization - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cminit") - - -#define ACPI_OFFSET(d,o) ((u32) &(((d *)0)->o)) -#define ACPI_FADT_OFFSET(o) ACPI_OFFSET (FADT_DESCRIPTOR, o) - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_fadt_register_error - * - * PARAMETERS: *Register_name - Pointer to string identifying register - * Value - Actual register contents value - * Acpi_test_spec_section - TDS section containing assertion - * Acpi_assertion - Assertion number being tested - * - * RETURN: AE_BAD_VALUE - * - * DESCRIPTION: Display failure message and link failure to TDS assertion - * - ******************************************************************************/ - -static ACPI_STATUS -acpi_cm_fadt_register_error ( - NATIVE_CHAR *register_name, - u32 value, - u32 offset) -{ - - REPORT_ERROR ( - ("Invalid FADT value %s=%lX at offset %lX FADT=%p\n", - register_name, value, offset, acpi_gbl_FADT)); - - - return (AE_BAD_VALUE); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_cm_validate_fadt - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Validate various ACPI registers in the FADT - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_validate_fadt ( - void) -{ - ACPI_STATUS status = AE_OK; - - - /* - * Verify Fixed ACPI Description Table fields, - * but don't abort on any problems, just display error - */ - - if (acpi_gbl_FADT->pm1_evt_len < 4) { - status = acpi_cm_fadt_register_error ("PM1_EVT_LEN", - (u32) acpi_gbl_FADT->pm1_evt_len, - ACPI_FADT_OFFSET (pm1_evt_len)); - } - - if (!acpi_gbl_FADT->pm1_cnt_len) { - status = acpi_cm_fadt_register_error ("PM1_CNT_LEN", 0, - ACPI_FADT_OFFSET (pm1_cnt_len)); - } - - if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1a_evt_blk.address)) { - status = acpi_cm_fadt_register_error ("X_PM1a_EVT_BLK", 0, - ACPI_FADT_OFFSET (Xpm1a_evt_blk.address)); - } - - if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1a_cnt_blk.address)) { - status = acpi_cm_fadt_register_error ("X_PM1a_CNT_BLK", 0, - ACPI_FADT_OFFSET (Xpm1a_cnt_blk.address)); - } - - if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm_tmr_blk.address)) { - status = acpi_cm_fadt_register_error ("X_PM_TMR_BLK", 0, - ACPI_FADT_OFFSET (Xpm_tmr_blk.address)); - } - - if ((ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm2_cnt_blk.address) && - !acpi_gbl_FADT->pm2_cnt_len)) { - status = acpi_cm_fadt_register_error ("PM2_CNT_LEN", - (u32) acpi_gbl_FADT->pm2_cnt_len, - ACPI_FADT_OFFSET (pm2_cnt_len)); - } - - if (acpi_gbl_FADT->pm_tm_len < 4) { - status = acpi_cm_fadt_register_error ("PM_TM_LEN", - (u32) acpi_gbl_FADT->pm_tm_len, - ACPI_FADT_OFFSET (pm_tm_len)); - } - - /* length of GPE blocks must be a multiple of 2 */ - - - if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) && - (acpi_gbl_FADT->gpe0blk_len & 1)) { - status = acpi_cm_fadt_register_error ("(x)GPE0_BLK_LEN", - (u32) acpi_gbl_FADT->gpe0blk_len, - ACPI_FADT_OFFSET (gpe0blk_len)); - } - - if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) && - (acpi_gbl_FADT->gpe1_blk_len & 1)) { - status = acpi_cm_fadt_register_error ("(x)GPE1_BLK_LEN", - (u32) acpi_gbl_FADT->gpe1_blk_len, - ACPI_FADT_OFFSET (gpe1_blk_len)); - } - - return (status); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_cm_terminate - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: free memory allocated for table storage. - * - ******************************************************************************/ - -void -acpi_cm_terminate (void) -{ - - - /* Free global tables, etc. */ - - if (acpi_gbl_gpe0enable_register_save) { - acpi_cm_free (acpi_gbl_gpe0enable_register_save); - } - - if (acpi_gbl_gpe1_enable_register_save) { - acpi_cm_free (acpi_gbl_gpe1_enable_register_save); - } - - - return; -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_cm_subsystem_shutdown - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex - * objects here -- because the AML debugger may be still running. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_subsystem_shutdown (void) -{ - - /* Just exit if subsystem is already shutdown */ - - if (acpi_gbl_shutdown) { - return (AE_OK); - } - - /* Subsystem appears active, go ahead and shut it down */ - - acpi_gbl_shutdown = TRUE; - - /* Close the Namespace */ - - acpi_ns_terminate (); - - /* Close the Acpi_event Handling */ - - acpi_ev_terminate (); - - /* Close the globals */ - - acpi_cm_terminate (); - - /* Flush the local cache(s) */ - - acpi_cm_delete_generic_state_cache (); - acpi_cm_delete_object_cache (); - acpi_ds_delete_walk_state_cache (); - - /* Close the Parser */ - - /* TBD: [Restructure] Acpi_ps_terminate () */ - - acpi_ps_delete_parse_cache (); - - /* Debug only - display leftover memory allocation, if any */ -#ifdef ENABLE_DEBUGGER - acpi_cm_dump_current_allocations (ACPI_UINT32_MAX, NULL); -#endif - - return (AE_OK); -} - - diff --git a/reactos/drivers/bus/acpi/utils/cmobject.c b/reactos/drivers/bus/acpi/utils/cmobject.c deleted file mode 100644 index cab18b546a4..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmobject.c +++ /dev/null @@ -1,618 +0,0 @@ -/****************************************************************************** - * - * Module Name: cmobject - ACPI object create/delete/size/cache routines - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmobject") - - -/******************************************************************************* - * - * FUNCTION: _Cm_create_internal_object - * - * PARAMETERS: Address - Address of the memory to deallocate - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * Type - ACPI Type of the new object - * - * RETURN: Object - The new object. Null on failure - * - * DESCRIPTION: Create and initialize a new internal object. - * - * NOTE: We always allocate the worst-case object descriptor because - * these objects are cached, and we want them to be - * one-size-satisifies-any-request. This in itself may not be - * the most memory efficient, but the efficiency of the object - * cache should more than make up for this! - * - ******************************************************************************/ - -ACPI_OPERAND_OBJECT * -_cm_create_internal_object ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id, - OBJECT_TYPE_INTERNAL type) -{ - ACPI_OPERAND_OBJECT *object; - - - /* Allocate the raw object descriptor */ - - object = _cm_allocate_object_desc (module_name, line_number, component_id); - if (!object) { - /* Allocation failure */ - - return (NULL); - } - - /* Save the object type in the object descriptor */ - - object->common.type = type; - - /* Init the reference count */ - - object->common.reference_count = 1; - - /* Any per-type initialization should go here */ - - - return (object); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_valid_internal_object - * - * PARAMETERS: Operand - Object to be validated - * - * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT - * - ******************************************************************************/ - -u8 -acpi_cm_valid_internal_object ( - void *object) -{ - - /* Check for a null pointer */ - - if (!object) { - return (FALSE); - } - - /* Check for a pointer within one of the ACPI tables */ - - if (acpi_tb_system_table_pointer (object)) { - return (FALSE); - } - - /* Check the descriptor type field */ - - if (!VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL)) { - /* Not an ACPI internal object, do some further checking */ - - - - - return (FALSE); - } - - - /* The object appears to be a valid ACPI_OPERAND_OBJECT */ - - return (TRUE); -} - - -/******************************************************************************* - * - * FUNCTION: _Cm_allocate_object_desc - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Message - Error message to use on failure - * - * RETURN: Pointer to newly allocated object descriptor. Null on error - * - * DESCRIPTION: Allocate a new object descriptor. Gracefully handle - * error conditions. - * - ******************************************************************************/ - -void * -_cm_allocate_object_desc ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id) -{ - ACPI_OPERAND_OBJECT *object; - - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - - acpi_gbl_object_cache_requests++; - - /* Check the cache first */ - - if (acpi_gbl_object_cache) { - /* There is an object available, use it */ - - object = acpi_gbl_object_cache; - acpi_gbl_object_cache = object->cache.next; - object->cache.next = NULL; - - acpi_gbl_object_cache_hits++; - acpi_gbl_object_cache_depth--; - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - } - - else { - /* The cache is empty, create a new object */ - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - - /* Attempt to allocate new descriptor */ - - object = _cm_callocate (sizeof (ACPI_OPERAND_OBJECT), component_id, - module_name, line_number); - if (!object) { - /* Allocation failed */ - - _REPORT_ERROR (module_name, line_number, component_id, - ("Could not allocate an object descriptor\n")); - - return (NULL); - } - - /* Memory allocation metrics - compiled out in non debug mode. */ - - INCREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); - } - - /* Mark the descriptor type */ - - object->common.data_type = ACPI_DESC_TYPE_INTERNAL; - - return (object); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_delete_object_desc - * - * PARAMETERS: Object - Acpi internal object to be deleted - * - * RETURN: None. - * - * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache - * - ******************************************************************************/ - -void -acpi_cm_delete_object_desc ( - ACPI_OPERAND_OBJECT *object) -{ - - - /* Make sure that the object isn't already in the cache */ - - if (object->common.data_type == (ACPI_DESC_TYPE_INTERNAL | ACPI_CACHED_OBJECT)) { - return; - } - - /* Object must be an ACPI_OPERAND_OBJECT */ - - if (object->common.data_type != ACPI_DESC_TYPE_INTERNAL) { - return; - } - - - /* If cache is full, just free this object */ - - if (acpi_gbl_object_cache_depth >= MAX_OBJECT_CACHE_DEPTH) { - /* - * Memory allocation metrics. Call the macro here since we only - * care about dynamically allocated objects. - */ - DECREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); - - acpi_cm_free (object); - return; - } - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - - /* Clear the entire object. This is important! */ - - MEMSET (object, 0, sizeof (ACPI_OPERAND_OBJECT)); - object->common.data_type = ACPI_DESC_TYPE_INTERNAL | ACPI_CACHED_OBJECT; - - /* Put the object at the head of the global cache list */ - - object->cache.next = acpi_gbl_object_cache; - acpi_gbl_object_cache = object; - acpi_gbl_object_cache_depth++; - - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_delete_object_cache - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -acpi_cm_delete_object_cache ( - void) -{ - ACPI_OPERAND_OBJECT *next; - - - /* Traverse the global cache list */ - - while (acpi_gbl_object_cache) { - /* Delete one cached state object */ - - next = acpi_gbl_object_cache->cache.next; - acpi_gbl_object_cache->cache.next = NULL; - - /* - * Memory allocation metrics. Call the macro here since we only - * care about dynamically allocated objects. - */ - DECREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); - - acpi_cm_free (acpi_gbl_object_cache); - acpi_gbl_object_cache = next; - acpi_gbl_object_cache_depth--; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_init_static_object - * - * PARAMETERS: Obj_desc - Pointer to a "static" object - on stack - * or in the data segment. - * - * RETURN: None. - * - * DESCRIPTION: Initialize a static object. Sets flags to disallow dynamic - * deletion of the object. - * - ******************************************************************************/ - -void -acpi_cm_init_static_object ( - ACPI_OPERAND_OBJECT *obj_desc) -{ - - - if (!obj_desc) { - return; - } - - - /* - * Clear the entire descriptor - */ - MEMSET ((void *) obj_desc, 0, sizeof (ACPI_OPERAND_OBJECT)); - - - /* - * Initialize the header fields - * 1) This is an ACPI_OPERAND_OBJECT descriptor - * 2) The size is the full object (worst case) - * 3) The flags field indicates static allocation - * 4) Reference count starts at one (not really necessary since the - * object can't be deleted, but keeps everything sane) - */ - - obj_desc->common.data_type = ACPI_DESC_TYPE_INTERNAL; - obj_desc->common.flags = AOPOBJ_STATIC_ALLOCATION; - obj_desc->common.reference_count = 1; - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_get_simple_object_size - * - * PARAMETERS: *Internal_object - Pointer to the object we are examining - * *Ret_length - Where the length is returned - * - * RETURN: Status - * - * DESCRIPTION: This function is called to determine the space required to - * contain a simple object for return to an API user. - * - * The length includes the object structure plus any additional - * needed space. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_get_simple_object_size ( - ACPI_OPERAND_OBJECT *internal_object, - u32 *obj_length) -{ - u32 length; - ACPI_STATUS status = AE_OK; - - - /* Handle a null object (Could be a uninitialized package element -- which is legal) */ - - if (!internal_object) { - *obj_length = 0; - return (AE_OK); - } - - - /* Start with the length of the Acpi object */ - - length = sizeof (ACPI_OBJECT); - - if (VALID_DESCRIPTOR_TYPE (internal_object, ACPI_DESC_TYPE_NAMED)) { - /* Object is a named object (reference), just return the length */ - - *obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length); - return (status); - } - - - /* - * The final length depends on the object type - * Strings and Buffers are packed right up against the parent object and - * must be accessed bytewise or there may be alignment problems on - * certain processors - */ - - switch (internal_object->common.type) { - - case ACPI_TYPE_STRING: - - length += internal_object->string.length + 1; - break; - - - case ACPI_TYPE_BUFFER: - - length += internal_object->buffer.length; - break; - - - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_POWER: - - /* - * No extra data for these types - */ - break; - - - case INTERNAL_TYPE_REFERENCE: - - /* - * The only type that should be here is opcode AML_NAMEPATH_OP -- since - * this means an object reference - */ - if (internal_object->reference.opcode != AML_NAMEPATH_OP) { - status = AE_TYPE; - } - - else { - /* - * Get the actual length of the full pathname to this object. - * The reference will be converted to the pathname to the object - */ - length += ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node)); - } - break; - - - default: - - status = AE_TYPE; - break; - } - - - /* - * Account for the space required by the object rounded up to the next - * multiple of the machine word size. This keeps each object aligned - * on a machine word boundary. (preventing alignment faults on some - * machines.) - */ - *obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_get_element_length - * - * PARAMETERS: ACPI_PKG_CALLBACK - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: Get the length of one package element. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_get_element_length ( - u8 object_type, - ACPI_OPERAND_OBJECT *source_object, - ACPI_GENERIC_STATE *state, - void *context) -{ - ACPI_STATUS status = AE_OK; - ACPI_PKG_INFO *info = (ACPI_PKG_INFO *) context; - u32 object_space; - - - switch (object_type) { - case 0: - - /* - * Simple object - just get the size (Null object/entry is handled - * here also) and sum it into the running package length - */ - status = acpi_cm_get_simple_object_size (source_object, &object_space); - if (ACPI_FAILURE (status)) { - return (status); - } - - info->length += object_space; - break; - - - case 1: - /* Package - nothing much to do here, let the walk handle it */ - - info->num_packages++; - state->pkg.this_target_obj = NULL; - break; - - default: - return (AE_BAD_PARAMETER); - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_get_package_object_size - * - * PARAMETERS: *Internal_object - Pointer to the object we are examining - * *Ret_length - Where the length is returned - * - * RETURN: Status - * - * DESCRIPTION: This function is called to determine the space required to - * contain a package object for return to an API user. - * - * This is moderately complex since a package contains other - * objects including packages. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_get_package_object_size ( - ACPI_OPERAND_OBJECT *internal_object, - u32 *obj_length) -{ - ACPI_STATUS status; - ACPI_PKG_INFO info; - - - info.length = 0; - info.object_space = 0; - info.num_packages = 1; - - status = acpi_cm_walk_package_tree (internal_object, NULL, - acpi_cm_get_element_length, &info); - - /* - * We have handled all of the objects in all levels of the package. - * just add the length of the package objects themselves. - * Round up to the next machine word. - */ - info.length += ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * - info.num_packages; - - /* Return the total package length */ - - *obj_length = info.length; - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_get_object_size - * - * PARAMETERS: *Internal_object - Pointer to the object we are examining - * *Ret_length - Where the length will be returned - * - * RETURN: Status - * - * DESCRIPTION: This function is called to determine the space required to - * contain an object for return to an API user. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_get_object_size( - ACPI_OPERAND_OBJECT *internal_object, - u32 *obj_length) -{ - ACPI_STATUS status; - - - if ((VALID_DESCRIPTOR_TYPE (internal_object, ACPI_DESC_TYPE_INTERNAL)) && - (IS_THIS_OBJECT_TYPE (internal_object, ACPI_TYPE_PACKAGE))) { - status = acpi_cm_get_package_object_size (internal_object, obj_length); - } - - else { - status = acpi_cm_get_simple_object_size (internal_object, obj_length); - } - - return (status); -} - - diff --git a/reactos/drivers/bus/acpi/utils/cmutils.c b/reactos/drivers/bus/acpi/utils/cmutils.c deleted file mode 100644 index 387c64909b3..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmutils.c +++ /dev/null @@ -1,999 +0,0 @@ -/******************************************************************************* - * - * Module Name: cmutils - common utility procedures - * $Revision: 1.1 $ - * - ******************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmutils") - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_valid_acpi_name - * - * PARAMETERS: Character - The character to be examined - * - * RETURN: 1 if Character may appear in a name, else 0 - * - * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: - * 1) Upper case alpha - * 2) numeric - * 3) underscore - * - ******************************************************************************/ - -u8 -acpi_cm_valid_acpi_name ( - u32 name) -{ - NATIVE_CHAR *name_ptr = (NATIVE_CHAR *) &name; - u32 i; - - - for (i = 0; i < ACPI_NAME_SIZE; i++) { - if (!((name_ptr[i] == '_') || - (name_ptr[i] >= 'A' && name_ptr[i] <= 'Z') || - (name_ptr[i] >= '0' && name_ptr[i] <= '9'))) { - return (FALSE); - } - } - - - return (TRUE); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_valid_acpi_character - * - * PARAMETERS: Character - The character to be examined - * - * RETURN: 1 if Character may appear in a name, else 0 - * - * DESCRIPTION: Check for a printable character - * - ******************************************************************************/ - -u8 -acpi_cm_valid_acpi_character ( - NATIVE_CHAR character) -{ - - return ((u8) ((character == '_') || - (character >= 'A' && character <= 'Z') || - (character >= '0' && character <= '9'))); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_mutex_initialize - * - * PARAMETERS: None. - * - * RETURN: Status - * - * DESCRIPTION: Create the system mutex objects. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_mutex_initialize ( - void) -{ - u32 i; - ACPI_STATUS status; - - - /* - * Create each of the predefined mutex objects - */ - for (i = 0; i < NUM_MTX; i++) { - status = acpi_cm_create_mutex (i); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_mutex_terminate - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete all of the system mutex objects. - * - ******************************************************************************/ - -void -acpi_cm_mutex_terminate ( - void) -{ - u32 i; - - - /* - * Delete each predefined mutex object - */ - for (i = 0; i < NUM_MTX; i++) { - acpi_cm_delete_mutex (i); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_create_mutex - * - * PARAMETERS: Mutex_iD - ID of the mutex to be created - * - * RETURN: Status - * - * DESCRIPTION: Create a mutex object. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_create_mutex ( - ACPI_MUTEX_HANDLE mutex_id) -{ - ACPI_STATUS status = AE_OK; - - - if (mutex_id > MAX_MTX) { - return (AE_BAD_PARAMETER); - } - - - if (!acpi_gbl_acpi_mutex_info[mutex_id].mutex) { - status = acpi_os_create_semaphore (1, 1, - &acpi_gbl_acpi_mutex_info[mutex_id].mutex); - acpi_gbl_acpi_mutex_info[mutex_id].locked = FALSE; - acpi_gbl_acpi_mutex_info[mutex_id].use_count = 0; - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_delete_mutex - * - * PARAMETERS: Mutex_iD - ID of the mutex to be deleted - * - * RETURN: Status - * - * DESCRIPTION: Delete a mutex object. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_delete_mutex ( - ACPI_MUTEX_HANDLE mutex_id) -{ - ACPI_STATUS status; - - - if (mutex_id > MAX_MTX) { - return (AE_BAD_PARAMETER); - } - - - status = acpi_os_delete_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex); - - acpi_gbl_acpi_mutex_info[mutex_id].mutex = NULL; - acpi_gbl_acpi_mutex_info[mutex_id].locked = FALSE; - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_acquire_mutex - * - * PARAMETERS: Mutex_iD - ID of the mutex to be acquired - * - * RETURN: Status - * - * DESCRIPTION: Acquire a mutex object. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_acquire_mutex ( - ACPI_MUTEX_HANDLE mutex_id) -{ - ACPI_STATUS status; - u32 i; - u32 this_thread_id; - - - if (mutex_id > MAX_MTX) { - return (AE_BAD_PARAMETER); - } - - - this_thread_id = acpi_os_get_thread_id (); - - /* - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than or equal to this one. If so, the thread has violated - * the mutex ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = mutex_id; i < MAX_MTX; i++) { - if (acpi_gbl_acpi_mutex_info[i].owner_id == this_thread_id) { - if (i == mutex_id) { - return (AE_ALREADY_ACQUIRED); - } - - return (AE_ACQUIRE_DEADLOCK); - } - } - - - status = acpi_os_wait_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex, - 1, WAIT_FOREVER); - - if (ACPI_SUCCESS (status)) { - acpi_gbl_acpi_mutex_info[mutex_id].locked = TRUE; - acpi_gbl_acpi_mutex_info[mutex_id].use_count++; - acpi_gbl_acpi_mutex_info[mutex_id].owner_id = this_thread_id; - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_release_mutex - * - * PARAMETERS: Mutex_iD - ID of the mutex to be released - * - * RETURN: Status - * - * DESCRIPTION: Release a mutex object. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_release_mutex ( - ACPI_MUTEX_HANDLE mutex_id) -{ - ACPI_STATUS status; - u32 i; - u32 this_thread_id; - - - if (mutex_id > MAX_MTX) { - return (AE_BAD_PARAMETER); - } - - - /* - * Mutex must be acquired in order to release it! - */ - if (!acpi_gbl_acpi_mutex_info[mutex_id].locked) { - return (AE_NOT_ACQUIRED); - } - - - /* - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than this one. If so, the thread has violated - * the mutex ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - this_thread_id = acpi_os_get_thread_id (); - for (i = mutex_id; i < MAX_MTX; i++) { - if (acpi_gbl_acpi_mutex_info[i].owner_id == this_thread_id) { - if (i == mutex_id) { - continue; - } - - return (AE_RELEASE_DEADLOCK); - } - } - - acpi_gbl_acpi_mutex_info[mutex_id].locked = FALSE; /* Mark before unlocking */ - acpi_gbl_acpi_mutex_info[mutex_id].owner_id = 0; - - status = acpi_os_signal_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex, 1); - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_create_update_state_and_push - * - * PARAMETERS: *Object - Object to be added to the new state - * Action - Increment/Decrement - * State_list - List the state will be added to - * - * RETURN: None - * - * DESCRIPTION: Create a new state and push it - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_create_update_state_and_push ( - ACPI_OPERAND_OBJECT *object, - u16 action, - ACPI_GENERIC_STATE **state_list) -{ - ACPI_GENERIC_STATE *state; - - - /* Ignore null objects; these are expected */ - - if (!object) { - return (AE_OK); - } - - state = acpi_cm_create_update_state (object, action); - if (!state) { - return (AE_NO_MEMORY); - } - - - acpi_cm_push_generic_state (state_list, state); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_create_pkg_state_and_push - * - * PARAMETERS: *Object - Object to be added to the new state - * Action - Increment/Decrement - * State_list - List the state will be added to - * - * RETURN: None - * - * DESCRIPTION: Create a new state and push it - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_create_pkg_state_and_push ( - void *internal_object, - void *external_object, - u16 index, - ACPI_GENERIC_STATE **state_list) -{ - ACPI_GENERIC_STATE *state; - - - state = acpi_cm_create_pkg_state (internal_object, external_object, index); - if (!state) { - return (AE_NO_MEMORY); - } - - - acpi_cm_push_generic_state (state_list, state); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_push_generic_state - * - * PARAMETERS: List_head - Head of the state stack - * State - State object to push - * - * RETURN: Status - * - * DESCRIPTION: Push a state object onto a state stack - * - ******************************************************************************/ - -void -acpi_cm_push_generic_state ( - ACPI_GENERIC_STATE **list_head, - ACPI_GENERIC_STATE *state) -{ - /* Push the state object onto the front of the list (stack) */ - - state->common.next = *list_head; - *list_head = state; - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_pop_generic_state - * - * PARAMETERS: List_head - Head of the state stack - * - * RETURN: Status - * - * DESCRIPTION: Pop a state object from a state stack - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -acpi_cm_pop_generic_state ( - ACPI_GENERIC_STATE **list_head) -{ - ACPI_GENERIC_STATE *state; - - - /* Remove the state object at the head of the list (stack) */ - - state = *list_head; - if (state) { - /* Update the list head */ - - *list_head = state->common.next; - } - - return (state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_create_generic_state - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Create a generic state object. Attempt to obtain one from - * the global state cache; If none available, create a new one. - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -acpi_cm_create_generic_state (void) -{ - ACPI_GENERIC_STATE *state; - - - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - - acpi_gbl_state_cache_requests++; - - /* Check the cache first */ - - if (acpi_gbl_generic_state_cache) { - /* There is an object available, use it */ - - state = acpi_gbl_generic_state_cache; - acpi_gbl_generic_state_cache = state->common.next; - state->common.next = NULL; - - acpi_gbl_state_cache_hits++; - acpi_gbl_generic_state_cache_depth--; - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - - } - - else { - /* The cache is empty, create a new object */ - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - - state = acpi_cm_callocate (sizeof (ACPI_GENERIC_STATE)); - } - - /* Initialize */ - - if (state) { - /* Always zero out the object before init */ - - MEMSET (state, 0, sizeof (ACPI_GENERIC_STATE)); - - state->common.data_type = ACPI_DESC_TYPE_STATE; - } - - return (state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_create_update_state - * - * PARAMETERS: Object - Initial Object to be installed in the - * state - * Action - Update action to be performed - * - * RETURN: Status - * - * DESCRIPTION: Create an "Update State" - a flavor of the generic state used - * to update reference counts and delete complex objects such - * as packages. - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -acpi_cm_create_update_state ( - ACPI_OPERAND_OBJECT *object, - u16 action) -{ - ACPI_GENERIC_STATE *state; - - - /* Create the generic state object */ - - state = acpi_cm_create_generic_state (); - if (!state) { - return (NULL); - } - - /* Init fields specific to the update struct */ - - state->update.object = object; - state->update.value = action; - - return (state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_create_pkg_state - * - * PARAMETERS: Object - Initial Object to be installed in the - * state - * Action - Update action to be performed - * - * RETURN: Status - * - * DESCRIPTION: Create an "Update State" - a flavor of the generic state used - * to update reference counts and delete complex objects such - * as packages. - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -acpi_cm_create_pkg_state ( - void *internal_object, - void *external_object, - u16 index) -{ - ACPI_GENERIC_STATE *state; - - - /* Create the generic state object */ - - state = acpi_cm_create_generic_state (); - if (!state) { - return (NULL); - } - - /* Init fields specific to the update struct */ - - state->pkg.source_object = (ACPI_OPERAND_OBJECT *) internal_object; - state->pkg.dest_object = external_object; - state->pkg.index = index; - state->pkg.num_packages = 1; - - return (state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_create_control_state - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Create a "Control State" - a flavor of the generic state used - * to support nested IF/WHILE constructs in the AML. - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -acpi_cm_create_control_state ( - void) -{ - ACPI_GENERIC_STATE *state; - - - /* Create the generic state object */ - - state = acpi_cm_create_generic_state (); - if (!state) { - return (NULL); - } - - - /* Init fields specific to the control struct */ - - state->common.state = CONTROL_CONDITIONAL_EXECUTING; - - return (state); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_delete_generic_state - * - * PARAMETERS: State - The state object to be deleted - * - * RETURN: Status - * - * DESCRIPTION: Put a state object back into the global state cache. The object - * is not actually freed at this time. - * - ******************************************************************************/ - -void -acpi_cm_delete_generic_state ( - ACPI_GENERIC_STATE *state) -{ - - /* If cache is full, just free this state object */ - - if (acpi_gbl_generic_state_cache_depth >= MAX_STATE_CACHE_DEPTH) { - acpi_cm_free (state); - } - - /* Otherwise put this object back into the cache */ - - else { - acpi_cm_acquire_mutex (ACPI_MTX_CACHES); - - /* Clear the state */ - - MEMSET (state, 0, sizeof (ACPI_GENERIC_STATE)); - state->common.data_type = ACPI_DESC_TYPE_STATE; - - /* Put the object at the head of the global cache list */ - - state->common.next = acpi_gbl_generic_state_cache; - acpi_gbl_generic_state_cache = state; - acpi_gbl_generic_state_cache_depth++; - - - acpi_cm_release_mutex (ACPI_MTX_CACHES); - } - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_delete_generic_state_cache - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -acpi_cm_delete_generic_state_cache ( - void) -{ - ACPI_GENERIC_STATE *next; - - - /* Traverse the global cache list */ - - while (acpi_gbl_generic_state_cache) { - /* Delete one cached state object */ - - next = acpi_gbl_generic_state_cache->common.next; - acpi_cm_free (acpi_gbl_generic_state_cache); - acpi_gbl_generic_state_cache = next; - acpi_gbl_generic_state_cache_depth--; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_resolve_package_references - * - * PARAMETERS: Obj_desc - The Package object on which to resolve refs - * - * RETURN: Status - * - * DESCRIPTION: Walk through a package and turn internal references into values - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_resolve_package_references ( - ACPI_OPERAND_OBJECT *obj_desc) -{ - u32 count; - ACPI_OPERAND_OBJECT *sub_object; - - - if (obj_desc->common.type != ACPI_TYPE_PACKAGE) { - /* The object must be a package */ - - REPORT_ERROR (("Must resolve Package Refs on a Package\n")); - return(AE_ERROR); - } - - /* - * TBD: what about nested packages? */ - - for (count = 0; count < obj_desc->package.count; count++) { - sub_object = obj_desc->package.elements[count]; - - if (sub_object->common.type == INTERNAL_TYPE_REFERENCE) { - if (sub_object->reference.opcode == AML_ZERO_OP) { - sub_object->common.type = ACPI_TYPE_INTEGER; - sub_object->integer.value = 0; - } - - else if (sub_object->reference.opcode == AML_ONE_OP) { - sub_object->common.type = ACPI_TYPE_INTEGER; - sub_object->integer.value = 1; - } - - else if (sub_object->reference.opcode == AML_ONES_OP) { - sub_object->common.type = ACPI_TYPE_INTEGER; - sub_object->integer.value = ACPI_INTEGER_MAX; - } - } - } - - return(AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_cm_walk_package_tree - * - * PARAMETERS: Obj_desc - The Package object on which to resolve refs - * - * RETURN: Status - * - * DESCRIPTION: Walk through a package - * - ******************************************************************************/ - -ACPI_STATUS -acpi_cm_walk_package_tree ( - ACPI_OPERAND_OBJECT *source_object, - void *target_object, - ACPI_PKG_CALLBACK walk_callback, - void *context) -{ - ACPI_STATUS status = AE_OK; - ACPI_GENERIC_STATE *state_list = NULL; - ACPI_GENERIC_STATE *state; - u32 this_index; - ACPI_OPERAND_OBJECT *this_source_obj; - - - state = acpi_cm_create_pkg_state (source_object, target_object, 0); - if (!state) { - return (AE_NO_MEMORY); - } - - while (state) { - this_index = state->pkg.index; - this_source_obj = (ACPI_OPERAND_OBJECT *) - state->pkg.source_object->package.elements[this_index]; - - /* - * Check for - * 1) An uninitialized package element. It is completely - * legal to declare a package and leave it uninitialized - * 2) Not an internal object - can be a namespace node instead - * 3) Any type other than a package. Packages are handled in else - * case below. - */ - if ((!this_source_obj) || - (!VALID_DESCRIPTOR_TYPE ( - this_source_obj, ACPI_DESC_TYPE_INTERNAL)) || - (!IS_THIS_OBJECT_TYPE ( - this_source_obj, ACPI_TYPE_PACKAGE))) { - - status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj, - state, context); - if (ACPI_FAILURE (status)) { - /* TBD: must delete package created up to this point */ - - return (status); - } - - state->pkg.index++; - while (state->pkg.index >= state->pkg.source_object->package.count) { - /* - * We've handled all of the objects at this level, This means - * that we have just completed a package. That package may - * have contained one or more packages itself. - * - * Delete this state and pop the previous state (package). - */ - acpi_cm_delete_generic_state (state); - state = acpi_cm_pop_generic_state (&state_list); - - - /* Finished when there are no more states */ - - if (!state) { - /* - * We have handled all of the objects in the top level - * package just add the length of the package objects - * and exit - */ - return (AE_OK); - } - - /* - * Go back up a level and move the index past the just - * completed package object. - */ - state->pkg.index++; - } - } - - else { - /* This is a sub-object of type package */ - - status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj, - state, context); - if (ACPI_FAILURE (status)) { - /* TBD: must delete package created up to this point */ - - return (status); - } - - - /* - * The callback above returned a new target package object. - */ - - /* - * Push the current state and create a new one - */ - acpi_cm_push_generic_state (&state_list, state); - state = acpi_cm_create_pkg_state (this_source_obj, - state->pkg.this_target_obj, 0); - if (!state) { - /* TBD: must delete package created up to this point */ - - return (AE_NO_MEMORY); - } - } - } - - /* We should never get here */ - - return (AE_AML_INTERNAL); - -} - - -/******************************************************************************* - * - * FUNCTION: _Report_error - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Message - Error message to use on failure - * - * RETURN: None - * - * DESCRIPTION: Print error message - * - ******************************************************************************/ - -void -_report_error ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id) -{ - - - acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); -} - - -/******************************************************************************* - * - * FUNCTION: _Report_warning - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Message - Error message to use on failure - * - * RETURN: None - * - * DESCRIPTION: Print warning message - * - ******************************************************************************/ - -void -_report_warning ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id) -{ - - acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number); -} - - -/******************************************************************************* - * - * FUNCTION: _Report_info - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Message - Error message to use on failure - * - * RETURN: None - * - * DESCRIPTION: Print information message - * - ******************************************************************************/ - -void -_report_info ( - NATIVE_CHAR *module_name, - u32 line_number, - u32 component_id) -{ - - acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number); -} - - diff --git a/reactos/drivers/bus/acpi/utils/cmxface.c b/reactos/drivers/bus/acpi/utils/cmxface.c deleted file mode 100644 index ce5124b487d..00000000000 --- a/reactos/drivers/bus/acpi/utils/cmxface.c +++ /dev/null @@ -1,452 +0,0 @@ -/****************************************************************************** - * - * Module Name: cmxface - External interfaces for "global" ACPI functions - * $Revision: 1.1 $ - * - *****************************************************************************/ - -/* - * Copyright (C) 2000, 2001 R. Byron Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include - -#define _COMPONENT ACPI_UTILITIES - MODULE_NAME ("cmxface") - - -/******************************************************************************* - * - * FUNCTION: Acpi_initialize_subsystem - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initializes all global variables. This is the first function - * called, so any early initialization belongs here. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_initialize_subsystem ( - void) -{ - ACPI_STATUS status; - - - /* Initialize all globals used by the subsystem */ - - acpi_cm_init_globals (); - - /* Initialize the OS-Dependent layer */ - - status = acpi_os_initialize (); - if (ACPI_FAILURE (status)) { - REPORT_ERROR (("OSD failed to initialize, %s\n", - acpi_cm_format_exception (status))); - return (status); - } - - /* Create the default mutex objects */ - - status = acpi_cm_mutex_initialize (); - if (ACPI_FAILURE (status)) { - REPORT_ERROR (("Global mutex creation failure, %s\n", - acpi_cm_format_exception (status))); - return (status); - } - - /* - * Initialize the namespace manager and - * the root of the namespace tree - */ - - status = acpi_ns_root_initialize (); - if (ACPI_FAILURE (status)) { - REPORT_ERROR (("Namespace initialization failure, %s\n", - acpi_cm_format_exception (status))); - return (status); - } - - - /* If configured, initialize the AML debugger */ - - DEBUGGER_EXEC (acpi_db_initialize ()); - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_enable_subsystem - * - * PARAMETERS: Flags - Init/enable Options - * - * RETURN: Status - * - * DESCRIPTION: Completes the subsystem initialization including hardware. - * Puts system into ACPI mode if it isn't already. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_enable_subsystem ( - u32 flags) -{ - ACPI_STATUS status = AE_OK; - - - /* Sanity check the FADT for valid values */ - - status = acpi_cm_validate_fadt (); - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Install the default Op_region handlers. These are - * installed unless other handlers have already been - * installed via the Install_address_space_handler interface - */ - - if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - status = acpi_ev_install_default_address_space_handlers (); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - /* - * We must initialize the hardware before we can enable ACPI. - */ - - if (!(flags & ACPI_NO_HARDWARE_INIT)) { - status = acpi_hw_initialize (); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - /* - * Enable ACPI on this platform - */ - - if (!(flags & ACPI_NO_ACPI_ENABLE)) { - status = acpi_enable (); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - /* - * Note: - * We must have the hardware AND events initialized before we can execute - * ANY control methods SAFELY. Any control method can require ACPI hardware - * support, so the hardware MUST be initialized before execution! - */ - - if (!(flags & ACPI_NO_EVENT_INIT)) { - status = acpi_ev_initialize (); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - - /* - * Initialize all device objects in the namespace - * This runs the _STA and _INI methods. - */ - - if (!(flags & ACPI_NO_DEVICE_INIT)) { - status = acpi_ns_initialize_devices (); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - - /* - * Initialize the objects that remain uninitialized. This - * runs the executable AML that is part of the declaration of Op_regions - * and Fields. - */ - - if (!(flags & ACPI_NO_OBJECT_INIT)) { - status = acpi_ns_initialize_objects (); - if (ACPI_FAILURE (status)) { - return (status); - } - } - - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_terminate - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_terminate (void) -{ - - /* Terminate the AML Debuger if present */ - - DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE); - - /* TBD: [Investigate] This is no longer needed?*/ -/* Acpi_cm_release_mutex (ACPI_MTX_DEBUG_CMD_READY); */ - - - /* Shutdown and free all resources */ - - acpi_cm_subsystem_shutdown (); - - - /* Free the mutex objects */ - - acpi_cm_mutex_terminate (); - - - /* Now we can shutdown the OS-dependent layer */ - - acpi_os_terminate (); - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_get_system_info - * - * PARAMETERS: Out_buffer - a pointer to a buffer to receive the - * resources for the device - * Buffer_length - the number of bytes available in the buffer - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to get information about the current - * state of the ACPI subsystem. It will return system information - * in the Out_buffer. - * - * If the function fails an appropriate status will be returned - * and the value of Out_buffer is undefined. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_get_system_info ( - ACPI_BUFFER *out_buffer) -{ - ACPI_SYSTEM_INFO *info_ptr; - u32 i; - - - /* - * Must have a valid buffer - */ - if ((!out_buffer) || - (!out_buffer->pointer)) { - return (AE_BAD_PARAMETER); - } - - if (out_buffer->length < sizeof (ACPI_SYSTEM_INFO)) { - /* - * Caller's buffer is too small - */ - out_buffer->length = sizeof (ACPI_SYSTEM_INFO); - - return (AE_BUFFER_OVERFLOW); - } - - - /* - * Set return length and get data - */ - out_buffer->length = sizeof (ACPI_SYSTEM_INFO); - info_ptr = (ACPI_SYSTEM_INFO *) out_buffer->pointer; - - info_ptr->acpi_ca_version = ACPI_CA_VERSION; - - /* System flags (ACPI capabilities) */ - - info_ptr->flags = acpi_gbl_system_flags; - - /* Timer resolution - 24 or 32 bits */ - if (!acpi_gbl_FADT) { - info_ptr->timer_resolution = 0; - } - else if (acpi_gbl_FADT->tmr_val_ext == 0) { - info_ptr->timer_resolution = 24; - } - else { - info_ptr->timer_resolution = 32; - } - - /* Clear the reserved fields */ - - info_ptr->reserved1 = 0; - info_ptr->reserved2 = 0; - - /* Current debug levels */ - - info_ptr->debug_layer = acpi_dbg_layer; - info_ptr->debug_level = acpi_dbg_level; - - /* Current status of the ACPI tables, per table type */ - - info_ptr->num_table_types = NUM_ACPI_TABLES; - for (i = 0; i < NUM_ACPI_TABLES; i++) { - info_ptr->table_info[i].count = acpi_gbl_acpi_tables[i].count; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: Acpi_format_exception - * - * PARAMETERS: Out_buffer - a pointer to a buffer to receive the - * exception name - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function translates an ACPI exception into an ASCII string. - * - ******************************************************************************/ - -ACPI_STATUS -acpi_format_exception ( - ACPI_STATUS exception, - ACPI_BUFFER *out_buffer) -{ - u32 length; - NATIVE_CHAR *formatted_exception; - - - /* - * Must have a valid buffer - */ - if ((!out_buffer) || - (!out_buffer->pointer)) { - return (AE_BAD_PARAMETER); - } - - - /* Convert the exception code (Handles bad exception codes) */ - - formatted_exception = acpi_cm_format_exception (exception); - - /* - * Get length of string and check if it will fit in caller's buffer - */ - - length = STRLEN (formatted_exception); - if (out_buffer->length < length) { - out_buffer->length = length; - return (AE_BUFFER_OVERFLOW); - } - - - /* Copy the string, all done */ - - STRCPY (out_buffer->pointer, formatted_exception); - - return (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_allocate - * - * PARAMETERS: Size - Size of the allocation - * - * RETURN: Address of the allocated memory on success, NULL on failure. - * - * DESCRIPTION: The subsystem's equivalent of malloc. - * External front-end to the Cm* memory manager - * - ****************************************************************************/ - -void * -acpi_allocate ( - u32 size) -{ - - return (acpi_cm_allocate (size)); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_callocate - * - * PARAMETERS: Size - Size of the allocation - * - * RETURN: Address of the allocated memory on success, NULL on failure. - * - * DESCRIPTION: The subsystem's equivalent of calloc. - * External front-end to the Cm* memory manager - * - ****************************************************************************/ - -void * -acpi_callocate ( - u32 size) -{ - - return (acpi_cm_callocate (size)); -} - - -/***************************************************************************** - * - * FUNCTION: Acpi_free - * - * PARAMETERS: Address - Address of the memory to deallocate - * - * RETURN: None - * - * DESCRIPTION: Frees the memory at Address - * External front-end to the Cm* memory manager - * - ****************************************************************************/ - -void -acpi_free ( - void *address) -{ - - acpi_cm_free (address); -} From 3b5a836e9ea25d6330e39afebb7af9970c3d84b3 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 1 Mar 2010 00:44:33 +0000 Subject: [PATCH 013/211] - Update to new ACPI driver by Samuel Serapion (and fixes by me) - Part 2 of 2 svn path=/trunk/; revision=45733 --- reactos/drivers/bus/acpi/acpi.rbuild | 30 + reactos/drivers/bus/acpi/acpi.rc | 7 + reactos/drivers/bus/acpi/acpica/acpica.rbuild | 143 ++ .../bus/acpi/acpica/dispatcher/dsfield.c | 776 +++++++ .../bus/acpi/acpica/dispatcher/dsinit.c | 310 +++ .../bus/acpi/acpica/dispatcher/dsmethod.c | 762 +++++++ .../bus/acpi/acpica/dispatcher/dsmthdat.c | 846 ++++++++ .../bus/acpi/acpica/dispatcher/dsobject.c | 925 +++++++++ .../bus/acpi/acpica/dispatcher/dsopcode.c | 1619 +++++++++++++++ .../bus/acpi/acpica/dispatcher/dsutils.c | 1009 +++++++++ .../bus/acpi/acpica/dispatcher/dswexec.c | 853 ++++++++ .../bus/acpi/acpica/dispatcher/dswload.c | 1316 ++++++++++++ .../bus/acpi/acpica/dispatcher/dswscope.c | 311 +++ .../bus/acpi/acpica/dispatcher/dswstate.c | 918 ++++++++ .../drivers/bus/acpi/acpica/events/evevent.c | 430 ++++ .../drivers/bus/acpi/acpica/events/evgpe.c | 897 ++++++++ .../drivers/bus/acpi/acpica/events/evgpeblk.c | 1402 +++++++++++++ .../drivers/bus/acpi/acpica/events/evmisc.c | 740 +++++++ .../drivers/bus/acpi/acpica/events/evregion.c | 1284 ++++++++++++ .../drivers/bus/acpi/acpica/events/evrgnini.c | 799 +++++++ .../drivers/bus/acpi/acpica/events/evsci.c | 280 +++ .../drivers/bus/acpi/acpica/events/evxface.c | 967 +++++++++ .../drivers/bus/acpi/acpica/events/evxfevnt.c | 1112 ++++++++++ .../drivers/bus/acpi/acpica/events/evxfregn.c | 346 +++ .../bus/acpi/acpica/executer/exconfig.c | 751 +++++++ .../bus/acpi/acpica/executer/exconvrt.c | 826 ++++++++ .../bus/acpi/acpica/executer/excreate.c | 636 ++++++ .../drivers/bus/acpi/acpica/executer/exdump.c | 1194 +++++++++++ .../bus/acpi/acpica/executer/exfield.c | 466 +++++ .../bus/acpi/acpica/executer/exfldio.c | 1081 ++++++++++ .../drivers/bus/acpi/acpica/executer/exmisc.c | 873 ++++++++ .../bus/acpi/acpica/executer/exmutex.c | 621 ++++++ .../bus/acpi/acpica/executer/exnames.c | 560 +++++ .../bus/acpi/acpica/executer/exoparg1.c | 1183 +++++++++++ .../bus/acpi/acpica/executer/exoparg2.c | 741 +++++++ .../bus/acpi/acpica/executer/exoparg3.c | 377 ++++ .../bus/acpi/acpica/executer/exoparg6.c | 438 ++++ .../drivers/bus/acpi/acpica/executer/exprep.c | 686 ++++++ .../bus/acpi/acpica/executer/exregion.c | 630 ++++++ .../bus/acpi/acpica/executer/exresnte.c | 374 ++++ .../bus/acpi/acpica/executer/exresolv.c | 652 ++++++ .../bus/acpi/acpica/executer/exresop.c | 810 ++++++++ .../bus/acpi/acpica/executer/exstore.c | 822 ++++++++ .../bus/acpi/acpica/executer/exstoren.c | 386 ++++ .../bus/acpi/acpica/executer/exstorob.c | 316 +++ .../bus/acpi/acpica/executer/exsystem.c | 418 ++++ .../bus/acpi/acpica/executer/exutils.c | 574 +++++ .../drivers/bus/acpi/acpica/hardware/hwacpi.c | 278 +++ .../drivers/bus/acpi/acpica/hardware/hwgpe.c | 597 ++++++ .../drivers/bus/acpi/acpica/hardware/hwregs.c | 805 +++++++ .../bus/acpi/acpica/hardware/hwsleep.c | 711 +++++++ .../bus/acpi/acpica/hardware/hwtimer.c | 288 +++ .../bus/acpi/acpica/hardware/hwvalid.c | 424 ++++ .../bus/acpi/acpica/hardware/hwxface.c | 710 +++++++ .../drivers/bus/acpi/acpica/include/acapps.h | 252 +++ .../bus/acpi/acpica/include/accommon.h | 136 ++ .../bus/acpi/acpica/include/acconfig.h | 279 +++ .../drivers/bus/acpi/acpica/include/acdebug.h | 449 ++++ .../bus/acpi/acpica/include/acdisasm.h | 757 +++++++ .../bus/acpi/acpica/include/acdispat.h | 527 +++++ .../bus/acpi/acpica/include/acevents.h | 375 ++++ .../drivers/bus/acpi/acpica/include/acexcep.h | 382 ++++ .../bus/acpi/acpica/include/acglobal.h | 494 +++++ .../drivers/bus/acpi/acpica/include/achware.h | 269 +++ .../bus/acpi/acpica/include/acinterp.h | 784 +++++++ .../drivers/bus/acpi/acpica/include/aclocal.h | 1332 ++++++++++++ .../bus/acpi/acpica/include/acmacros.h | 605 ++++++ .../drivers/bus/acpi/acpica/include/acnames.h | 157 ++ .../bus/acpi/acpica/include/acnamesp.h | 566 +++++ .../bus/acpi/acpica/include/acobject.h | 648 ++++++ .../bus/acpi/acpica/include/acopcode.h | 397 ++++ .../bus/acpi/acpica/include/acoutput.h | 351 ++++ .../bus/acpi/acpica/include/acparser.h | 403 ++++ .../drivers/bus/acpi/acpica/include/acpi.h | 144 ++ .../bus/acpi/acpica/include/acpiosxf.h | 495 +++++ .../drivers/bus/acpi/acpica/include/acpixf.h | 687 ++++++ .../bus/acpi/acpica/include/acpredef.h | 598 ++++++ .../drivers/bus/acpi/acpica/include/acresrc.h | 465 +++++ .../bus/acpi/acpica/include/acrestyp.h | 544 +++++ .../bus/acpi/acpica/include/acstruct.h | 326 +++ .../bus/acpi/acpica/include/actables.h | 243 +++ .../drivers/bus/acpi/acpica/include/actbl.h | 451 ++++ .../drivers/bus/acpi/acpica/include/actbl1.h | 1145 ++++++++++ .../drivers/bus/acpi/acpica/include/actbl2.h | 1124 ++++++++++ .../drivers/bus/acpi/acpica/include/actbl71.h | 144 ++ .../drivers/bus/acpi/acpica/include/actypes.h | 1248 +++++++++++ .../drivers/bus/acpi/acpica/include/acutils.h | 963 +++++++++ .../drivers/bus/acpi/acpica/include/amlcode.h | 595 ++++++ .../bus/acpi/acpica/include/amlresrc.h | 485 +++++ .../acpi/acpica/include/platform/accygwin.h | 163 ++ .../acpi/acpica/include/platform/acdos16.h | 164 ++ .../bus/acpi/acpica/include/platform/acefi.h | 147 ++ .../bus/acpi/acpica/include/platform/acenv.h | 432 ++++ .../acpi/acpica/include/platform/acfreebsd.h | 180 ++ .../bus/acpi/acpica/include/platform/acgcc.h | 179 ++ .../acpi/acpica/include/platform/acintel.h | 168 ++ .../acpi/acpica/include/platform/aclinux.h | 233 +++ .../bus/acpi/acpica/include/platform/acmsvc.h | 249 +++ .../acpi/acpica/include/platform/acnetbsd.h | 188 ++ .../bus/acpi/acpica/include/platform/acos2.h | 172 ++ .../bus/acpi/acpica/include/platform/acwin.h | 157 ++ .../acpi/acpica/include/platform/acwin64.h | 155 ++ .../bus/acpi/acpica/namespace/nsaccess.c | 772 +++++++ .../bus/acpi/acpica/namespace/nsalloc.c | 666 ++++++ .../bus/acpi/acpica/namespace/nsdump.c | 826 ++++++++ .../bus/acpi/acpica/namespace/nsdumpdv.c | 234 +++ .../bus/acpi/acpica/namespace/nseval.c | 558 +++++ .../bus/acpi/acpica/namespace/nsinit.c | 727 +++++++ .../bus/acpi/acpica/namespace/nsload.c | 428 ++++ .../bus/acpi/acpica/namespace/nsnames.c | 375 ++++ .../bus/acpi/acpica/namespace/nsobject.c | 577 +++++ .../bus/acpi/acpica/namespace/nsparse.c | 297 +++ .../bus/acpi/acpica/namespace/nspredef.c | 1263 +++++++++++ .../bus/acpi/acpica/namespace/nsrepair.c | 686 ++++++ .../bus/acpi/acpica/namespace/nsrepair2.c | 796 +++++++ .../bus/acpi/acpica/namespace/nssearch.c | 507 +++++ .../bus/acpi/acpica/namespace/nsutils.c | 1184 +++++++++++ .../bus/acpi/acpica/namespace/nswalk.c | 468 +++++ .../bus/acpi/acpica/namespace/nsxfeval.c | 1020 +++++++++ .../bus/acpi/acpica/namespace/nsxfname.c | 776 +++++++ .../bus/acpi/acpica/namespace/nsxfobj.c | 357 ++++ reactos/drivers/bus/acpi/acpica/osl/osl.c | 751 +++++++ .../drivers/bus/acpi/acpica/parser/psargs.c | 893 ++++++++ .../drivers/bus/acpi/acpica/parser/psloop.c | 1341 ++++++++++++ .../drivers/bus/acpi/acpica/parser/psopcode.c | 589 ++++++ .../drivers/bus/acpi/acpica/parser/psparse.c | 791 +++++++ .../drivers/bus/acpi/acpica/parser/psscope.c | 374 ++++ .../drivers/bus/acpi/acpica/parser/pstree.c | 427 ++++ .../drivers/bus/acpi/acpica/parser/psutils.c | 362 ++++ .../drivers/bus/acpi/acpica/parser/pswalk.c | 193 ++ .../drivers/bus/acpi/acpica/parser/psxface.c | 510 +++++ .../bus/acpi/acpica/resources/rsaddr.c | 479 +++++ .../bus/acpi/acpica/resources/rscalc.c | 745 +++++++ .../bus/acpi/acpica/resources/rscreate.c | 533 +++++ .../bus/acpi/acpica/resources/rsdump.c | 872 ++++++++ .../bus/acpi/acpica/resources/rsinfo.c | 290 +++ .../drivers/bus/acpi/acpica/resources/rsio.c | 376 ++++ .../drivers/bus/acpi/acpica/resources/rsirq.c | 348 ++++ .../bus/acpi/acpica/resources/rslist.c | 286 +++ .../bus/acpi/acpica/resources/rsmemory.c | 323 +++ .../bus/acpi/acpica/resources/rsmisc.c | 683 ++++++ .../bus/acpi/acpica/resources/rsutils.c | 874 ++++++++ .../bus/acpi/acpica/resources/rsxface.c | 713 +++++++ .../drivers/bus/acpi/acpica/tables/tbconvrt.c | 547 +++++ .../drivers/bus/acpi/acpica/tables/tbfadt.c | 752 +++++++ .../drivers/bus/acpi/acpica/tables/tbfind.c | 215 ++ .../drivers/bus/acpi/acpica/tables/tbget.c | 608 ++++++ .../drivers/bus/acpi/acpica/tables/tbinstal.c | 785 +++++++ .../drivers/bus/acpi/acpica/tables/tbutils.c | 741 +++++++ .../drivers/bus/acpi/acpica/tables/tbxface.c | 750 +++++++ .../drivers/bus/acpi/acpica/tables/tbxfroot.c | 371 ++++ .../bus/acpi/acpica/utilities/utalloc.c | 488 +++++ .../bus/acpi/acpica/utilities/utcache.c | 433 ++++ .../bus/acpi/acpica/utilities/utclib.c | 961 +++++++++ .../bus/acpi/acpica/utilities/utcopy.c | 1142 ++++++++++ .../bus/acpi/acpica/utilities/utdebug.c | 814 ++++++++ .../bus/acpi/acpica/utilities/utdelete.c | 828 ++++++++ .../bus/acpi/acpica/utilities/uteval.c | 575 +++++ .../bus/acpi/acpica/utilities/utglobal.c | 975 +++++++++ .../drivers/bus/acpi/acpica/utilities/utids.c | 497 +++++ .../bus/acpi/acpica/utilities/utinit.c | 228 ++ .../bus/acpi/acpica/utilities/utlock.c | 277 +++ .../bus/acpi/acpica/utilities/utmath.c | 431 ++++ .../bus/acpi/acpica/utilities/utmisc.c | 1485 +++++++++++++ .../bus/acpi/acpica/utilities/utmutex.c | 477 +++++ .../bus/acpi/acpica/utilities/utobject.c | 859 ++++++++ .../bus/acpi/acpica/utilities/utresrc.c | 772 +++++++ .../bus/acpi/acpica/utilities/utstate.c | 470 +++++ .../bus/acpi/acpica/utilities/uttrack.c | 726 +++++++ .../bus/acpi/acpica/utilities/utxface.c | 734 +++++++ reactos/drivers/bus/acpi/acpienum.c | 151 ++ reactos/drivers/bus/acpi/busmgr/bus.c | 1849 +++++++++++++++++ reactos/drivers/bus/acpi/busmgr/button.c | 328 +++ reactos/drivers/bus/acpi/busmgr/power.c | 679 ++++++ reactos/drivers/bus/acpi/busmgr/system.c | 428 ++++ reactos/drivers/bus/acpi/busmgr/utils.c | 376 ++++ reactos/drivers/bus/acpi/buspdo.c | 1227 +++++++++++ reactos/drivers/bus/acpi/include/acpi_bus.h | 385 ++++ .../drivers/bus/acpi/include/acpi_drivers.h | 340 +++ reactos/drivers/bus/acpi/include/acpisys.h | 292 +++ reactos/drivers/bus/acpi/include/glue.h | 30 + reactos/drivers/bus/acpi/include/list.h | 251 +++ reactos/drivers/bus/acpi/main.c | 218 ++ reactos/drivers/bus/acpi/osl.c | 752 +++++++ reactos/drivers/bus/acpi/pnp.c | 563 +++++ reactos/drivers/bus/acpi/power.c | 260 +++ 186 files changed, 110057 insertions(+) create mode 100644 reactos/drivers/bus/acpi/acpi.rbuild create mode 100644 reactos/drivers/bus/acpi/acpi.rc create mode 100644 reactos/drivers/bus/acpi/acpica/acpica.rbuild create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsfield.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsobject.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dswload.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dswscope.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dswstate.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evevent.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evgpe.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evgpeblk.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evmisc.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evregion.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evrgnini.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evsci.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evxfevnt.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evxfregn.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exconfig.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exconvrt.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/excreate.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exdump.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exfield.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exfldio.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exmisc.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exmutex.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exnames.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exoparg1.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exoparg2.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exoparg3.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exoparg6.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exprep.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exregion.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exresnte.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exresolv.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exresop.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exstore.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exstoren.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exstorob.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exsystem.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwacpi.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwregs.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwtimer.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwvalid.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/include/acapps.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/accommon.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acconfig.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acdebug.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acdisasm.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acdispat.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acevents.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acexcep.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acglobal.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/achware.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acinterp.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/aclocal.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acmacros.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acnames.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acnamesp.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acobject.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acopcode.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acoutput.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acparser.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acpi.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acpiosxf.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acpixf.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acpredef.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acresrc.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acrestyp.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acstruct.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actables.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actbl.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actbl1.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actbl2.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actbl71.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actypes.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acutils.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/amlcode.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/amlresrc.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/accygwin.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acdos16.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acefi.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acenv.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acfreebsd.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acintel.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acmsvc.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acnetbsd.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acos2.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acwin.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acwin64.h create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsaccess.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsalloc.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsdump.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsdumpdv.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nseval.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsinit.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsload.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsnames.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsobject.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsparse.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nspredef.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsrepair.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsrepair2.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nssearch.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nswalk.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsxfeval.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsxfobj.c create mode 100644 reactos/drivers/bus/acpi/acpica/osl/osl.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psargs.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psloop.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psopcode.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psparse.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psscope.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/pstree.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/pswalk.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsaddr.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rscalc.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rscreate.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsdump.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsinfo.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsio.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsirq.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rslist.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsmemory.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsmisc.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbconvrt.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbfadt.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbfind.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbget.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbinstal.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbxfroot.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utalloc.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utcache.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utclib.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utcopy.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utdebug.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utdelete.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/uteval.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utglobal.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utids.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utinit.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utlock.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utmath.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utmisc.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utmutex.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utobject.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utresrc.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utstate.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/uttrack.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utxface.c create mode 100644 reactos/drivers/bus/acpi/acpienum.c create mode 100644 reactos/drivers/bus/acpi/busmgr/bus.c create mode 100644 reactos/drivers/bus/acpi/busmgr/button.c create mode 100644 reactos/drivers/bus/acpi/busmgr/power.c create mode 100644 reactos/drivers/bus/acpi/busmgr/system.c create mode 100644 reactos/drivers/bus/acpi/busmgr/utils.c create mode 100644 reactos/drivers/bus/acpi/buspdo.c create mode 100644 reactos/drivers/bus/acpi/include/acpi_bus.h create mode 100644 reactos/drivers/bus/acpi/include/acpi_drivers.h create mode 100644 reactos/drivers/bus/acpi/include/acpisys.h create mode 100644 reactos/drivers/bus/acpi/include/glue.h create mode 100644 reactos/drivers/bus/acpi/include/list.h create mode 100644 reactos/drivers/bus/acpi/main.c create mode 100644 reactos/drivers/bus/acpi/osl.c create mode 100644 reactos/drivers/bus/acpi/pnp.c create mode 100644 reactos/drivers/bus/acpi/power.c diff --git a/reactos/drivers/bus/acpi/acpi.rbuild b/reactos/drivers/bus/acpi/acpi.rbuild new file mode 100644 index 00000000000..f2b6a13cbca --- /dev/null +++ b/reactos/drivers/bus/acpi/acpi.rbuild @@ -0,0 +1,30 @@ + + + + + + + + + + + include + include + ntoskrnl + hal + wdmguid + acpica + + bus.c + button.c + power.c + utils.c + system.c + + osl.c + acpienum.c + pnp.c + power.c + buspdo.c + main.c + diff --git a/reactos/drivers/bus/acpi/acpi.rc b/reactos/drivers/bus/acpi/acpi.rc new file mode 100644 index 00000000000..7a466943475 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpi.rc @@ -0,0 +1,7 @@ +/* $Id: acpi.rc 21698 2006-04-22 05:55:17Z tretiakov $ */ + +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS ACPI Driver\0" +#define REACTOS_STR_INTERNAL_NAME "acpi\0" +#define REACTOS_STR_ORIGINAL_FILENAME "acpi.sys\0" +#include diff --git a/reactos/drivers/bus/acpi/acpica/acpica.rbuild b/reactos/drivers/bus/acpi/acpica/acpica.rbuild new file mode 100644 index 00000000000..b23eed8d5b2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/acpica.rbuild @@ -0,0 +1,143 @@ + + + + + include + + dsfield.c + dsinit.c + dsmethod.c + dsmthdat.c + dsobject.c + dsopcode.c + dsutils.c + dswexec.c + dswload.c + dswscope.c + dswstate.c + + + evevent.c + evgpe.c + evgpeblk.c + evmisc.c + evregion.c + evrgnini.c + evsci.c + evxface.c + evxfevnt.c + evxfregn.c + + + exconfig.c + exconvrt.c + excreate.c + exdump.c + exfield.c + exfldio.c + exmisc.c + exmutex.c + exoparg1.c + exoparg2.c + exoparg3.c + exoparg6.c + exnames.c + exprep.c + exregion.c + exresnte.c + exresolv.c + exresop.c + exstore.c + exstoren.c + exstorob.c + exsystem.c + exutils.c + + + hwacpi.c + hwgpe.c + hwregs.c + hwsleep.c + hwtimer.c + hwvalid.c + hwxface.c + + + nsaccess.c + nsalloc.c + nsdump.c + nsdumpdv.c + nseval.c + nsinit.c + nsload.c + nsnames.c + nsobject.c + nsparse.c + nspredef.c + nsrepair.c + nsrepair2.c + nssearch.c + nsutils.c + nswalk.c + nsxfeval.c + nsxfname.c + nsxfobj.c + + + + psargs.c + psloop.c + psopcode.c + psparse.c + psscope.c + pstree.c + psutils.c + pswalk.c + psxface.c + + + rsaddr.c + rscalc.c + rscreate.c + rsdump.c + rsinfo.c + rsio.c + rsirq.c + rslist.c + rsmemory.c + rsmisc.c + rsutils.c + rsxface.c + + + tbfadt.c + tbfind.c + tbinstal.c + tbutils.c + tbxface.c + tbxfroot.c + + + utalloc.c + utcache.c + utclib.c + utcopy.c + utdebug.c + utdelete.c + uteval.c + utglobal.c + utids.c + utinit.c + utlock.c + utmath.c + utmisc.c + utmutex.c + utobject.c + utresrc.c + utstate.c + uttrack.c + utxface.c + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsfield.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsfield.c new file mode 100644 index 00000000000..12d55f40c43 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsfield.c @@ -0,0 +1,776 @@ +/****************************************************************************** + * + * Module Name: dsfield - Dispatcher field routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSFIELD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acparser.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsfield") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsGetFieldNames ( + ACPI_CREATE_FIELD_INFO *Info, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateBufferField + * + * PARAMETERS: Op - Current parse op (CreateXXField) + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Execute the CreateField operators: + * CreateBitFieldOp, + * CreateByteFieldOp, + * CreateWordFieldOp, + * CreateDWordFieldOp, + * CreateQWordFieldOp, + * CreateFieldOp (all of which define a field in a buffer) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateBufferField ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *SecondDesc = NULL; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE (DsCreateBufferField); + + + /* + * Get the NameString argument (name of the new BufferField) + */ + if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) + { + /* For CreateField, name is the 4th argument */ + + Arg = AcpiPsGetArg (Op, 3); + } + else + { + /* For all other CreateXXXField operators, name is the 3rd argument */ + + Arg = AcpiPsGetArg (Op, 2); + } + + if (!Arg) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + if (WalkState->DeferredNode) + { + Node = WalkState->DeferredNode; + Status = AE_OK; + } + else + { + /* Execute flag should always be set when this function is entered */ + + if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE)) + { + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Creating new namespace node, should not already exist */ + + Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND; + + /* + * Mark node temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + + /* Enter the NameString into the namespace */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, + Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + } + + /* + * We could put the returned object (Node) on the object stack for later, + * but for now, we will put it in the "op" object that the parser uses, + * so we can get it again at the end of this scope. + */ + Op->Common.Node = Node; + + /* + * If there is no object attached to the node, this node was just created + * and we need to create the field object. Otherwise, this was a lookup + * of an existing node and we don't want to create the field object again. + */ + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * The Field definition is not fully parsed at this time. + * (We must save the address of the AML for the buffer and index operands) + */ + + /* Create the buffer field object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Remember location in AML stream of the field unit opcode and operands -- + * since the buffer and index operands must be evaluated. + */ + SecondDesc = ObjDesc->Common.NextObject; + SecondDesc->Extra.AmlStart = Op->Named.Data; + SecondDesc->Extra.AmlLength = Op->Named.Length; + ObjDesc->BufferField.Node = Node; + + /* Attach constructed field descriptors to parent node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + +Cleanup: + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetFieldNames + * + * PARAMETERS: Info - CreateField info structure + * ` WalkState - Current method state + * Arg - First parser arg for the field name list + * + * RETURN: Status + * + * DESCRIPTION: Process all named fields in a field declaration. Names are + * entered into the namespace. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsGetFieldNames ( + ACPI_CREATE_FIELD_INFO *Info, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_STATUS Status; + ACPI_INTEGER Position; + + + ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info); + + + /* First field starts at bit zero */ + + Info->FieldBitPosition = 0; + + /* Process all elements in the field list (of parse nodes) */ + + while (Arg) + { + /* + * Three types of field elements are handled: + * 1) Offset - specifies a bit offset + * 2) AccessAs - changes the access mode + * 3) Name - Enters a new named field into the namespace + */ + switch (Arg->Common.AmlOpcode) + { + case AML_INT_RESERVEDFIELD_OP: + + Position = (ACPI_INTEGER) Info->FieldBitPosition + + (ACPI_INTEGER) Arg->Common.Value.Size; + + if (Position > ACPI_UINT32_MAX) + { + ACPI_ERROR ((AE_INFO, + "Bit offset within field too large (> 0xFFFFFFFF)")); + return_ACPI_STATUS (AE_SUPPORT); + } + + Info->FieldBitPosition = (UINT32) Position; + break; + + + case AML_INT_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute -- to be used for all + * field units that follow, until field end or another AccessAs + * keyword. + * + * In FieldFlags, preserve the flag bits other than the + * ACCESS_TYPE bits + */ + Info->FieldFlags = (UINT8) + ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | + ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8))); + + Info->Attribute = (UINT8) (Arg->Common.Value.Integer); + break; + + + case AML_INT_NAMEDFIELD_OP: + + /* Lookup the name, it should already exist */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (char *) &Arg->Named.Name, Info->FieldType, + ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &Info->FieldNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); + return_ACPI_STATUS (Status); + } + else + { + Arg->Common.Node = Info->FieldNode; + Info->FieldBitLength = Arg->Common.Value.Size; + + /* + * If there is no object attached to the node, this node was + * just created and we need to create the field object. + * Otherwise, this was a lookup of an existing node and we + * don't want to create the field object again. + */ + if (!AcpiNsGetAttachedObject (Info->FieldNode)) + { + Status = AcpiExPrepFieldValue (Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + /* Keep track of bit position for the next field */ + + Position = (ACPI_INTEGER) Info->FieldBitPosition + + (ACPI_INTEGER) Arg->Common.Value.Size; + + if (Position > ACPI_UINT32_MAX) + { + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)", + ACPI_CAST_PTR (char, &Info->FieldNode->Name))); + return_ACPI_STATUS (AE_SUPPORT); + } + + Info->FieldBitPosition += Info->FieldBitLength; + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Invalid opcode in field list: %X", Arg->Common.AmlOpcode)); + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + Arg = Arg->Common.Next; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op); + + + /* First arg is the name of the parent OpRegion (must already exist) */ + + Arg = Op->Common.Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, + ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + Info.Attribute = 0; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD; + Info.RegionNode = RegionNode; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitFieldObjects + * + * PARAMETERS: Op - Op containing the Field definition and args + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: For each "Field Unit" name in the argument list that is + * part of the field declaration, enter the name into the + * namespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitFieldObjects ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_NAMESPACE_NODE *Node; + UINT8 Type = 0; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op); + + + /* Execute flag should always be set when this function is entered */ + + if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE)) + { + if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP) + { + /* BankField Op is deferred, just return OK */ + + return_ACPI_STATUS (AE_OK); + } + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * Get the FieldList argument for this opcode. This is the start of the + * list of field elements. + */ + switch (WalkState->Opcode) + { + case AML_FIELD_OP: + Arg = AcpiPsGetArg (Op, 2); + Type = ACPI_TYPE_LOCAL_REGION_FIELD; + break; + + case AML_BANK_FIELD_OP: + Arg = AcpiPsGetArg (Op, 4); + Type = ACPI_TYPE_LOCAL_BANK_FIELD; + break; + + case AML_INDEX_FIELD_OP: + Arg = AcpiPsGetArg (Op, 3); + Type = ACPI_TYPE_LOCAL_INDEX_FIELD; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Creating new namespace node(s), should not already exist */ + + Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND; + + /* + * Mark node(s) temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + + /* + * Walk the list of entries in the FieldList + * Note: FieldList can be of zero length. In this case, Arg will be NULL. + */ + while (Arg) + { + /* + * Ignore OFFSET and ACCESSAS terms here; we are only interested in the + * field names in order to enter them into the namespace. + */ + if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, + (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1, + Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); + if (Status != AE_ALREADY_EXISTS) + { + return_ACPI_STATUS (Status); + } + + /* Name already exists, just ignore this error */ + + Status = AE_OK; + } + + Arg->Common.Node = Node; + } + + /* Get the next field element in the list */ + + Arg = Arg->Common.Next; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateBankField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new bank field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateBankField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op); + + + /* First arg is the name of the parent OpRegion (must already exist) */ + + Arg = Op->Common.Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, + ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the Bank Register (Field) (must already exist) */ + + Arg = Arg->Common.Next; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* + * Third arg is the BankValue + * This arg is a TermArg, not a constant + * It will be evaluated later, by AcpiDsEvalBankFieldOperands + */ + Arg = Arg->Common.Next; + + /* Fourth arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD; + Info.RegionNode = RegionNode; + + /* + * Use Info.DataRegisterNode to store BankField Op + * It's safe because DataRegisterNode will never be used when create bank field + * We store AmlStart and AmlLength in the BankField Op for late evaluation + * Used in AcpiExPrepFieldValue(Info) + * + * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like "void *ParentOp"? + */ + Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateIndexField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new index field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op); + + + /* First arg is the name of the Index register (must already exist) */ + + Arg = Op->Common.Value.Arg; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* Second arg is the data register (must already exist) */ + + Arg = Arg->Common.Next; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* Next arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD; + Info.RegionNode = RegionNode; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c new file mode 100644 index 00000000000..efea20e83d3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c @@ -0,0 +1,310 @@ +/****************************************************************************** + * + * Module Name: dsinit - Object initialization namespace walk + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsinit") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitOneObject + * + * PARAMETERS: ObjHandle - Node for the object + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Operation Regions + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We are only interested in NS nodes owned by the table that + * was just loaded + */ + if (Node->OwnerId != Info->OwnerId) + { + return (AE_OK); + } + + Info->ObjectCount++; + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + + switch (Type) + { + case ACPI_TYPE_REGION: + + Status = AcpiDsInitializeRegion (ObjHandle); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "During Region initialization %p [%4.4s]", + ObjHandle, AcpiUtGetNodeName (ObjHandle))); + } + + Info->OpRegionCount++; + break; + + + case ACPI_TYPE_METHOD: + + Info->MethodCount++; + break; + + + case ACPI_TYPE_DEVICE: + + Info->DeviceCount++; + break; + + + default: + break; + } + + /* + * We ignore errors from above, and always return OK, since + * we don't want to abort the walk on a single error. + */ + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitializeObjects + * + * PARAMETERS: TableDesc - Descriptor for parent ACPI table + * StartNode - Root of subtree to be initialized. + * + * RETURN: Status + * + * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any + * necessary initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitializeObjects ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + + + ACPI_FUNCTION_TRACE (DsInitializeObjects); + + + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Starting initialization of namespace objects ****\n")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:")); + + Info.MethodCount = 0; + Info.OpRegionCount = 0; + Info.ObjectCount = 0; + Info.DeviceCount = 0; + Info.TableIndex = TableIndex; + Info.OwnerId = OwnerId; + + /* Walk entire namespace from the supplied root */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * We don't use AcpiWalkNamespace since we do not want to acquire + * the namespace reader lock. + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); + } + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", + Table->Signature, OwnerId, Info.ObjectCount, + Info.DeviceCount, Info.MethodCount, Info.OpRegionCount)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "%hd Methods, %hd Regions\n", Info.MethodCount, Info.OpRegionCount)); + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c new file mode 100644 index 00000000000..48172e962e2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c @@ -0,0 +1,762 @@ +/****************************************************************************** + * + * Module Name: dsmethod - Parser/Interpreter interface - control method parsing + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSMETHOD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdisasm.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsmethod") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsCreateMethodMutex ( + ACPI_OPERAND_OBJECT *MethodDesc); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodError + * + * PARAMETERS: Status - Execution status + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Called on method error. Invoke the global exception handler if + * present, dump the method data if the disassembler is configured + * + * Note: Allows the exception handler to change the status code + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodError ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Ignore AE_OK and control exception codes */ + + if (ACPI_SUCCESS (Status) || + (Status & AE_CODE_CONTROL)) + { + return (Status); + } + + /* Invoke the global exception handler */ + + if (AcpiGbl_ExceptionHandler) + { + /* Exit the interpreter, allow handler to execute methods */ + + AcpiExExitInterpreter (); + + /* + * Handler can map the exception code to anything it wants, including + * AE_OK, in which case the executing method will not be aborted. + */ + Status = AcpiGbl_ExceptionHandler (Status, + WalkState->MethodNode ? + WalkState->MethodNode->Name.Integer : 0, + WalkState->Opcode, WalkState->AmlOffset, NULL); + AcpiExEnterInterpreter (); + } + + AcpiDsClearImplicitReturn (WalkState); + +#ifdef ACPI_DISASSEMBLER + if (ACPI_FAILURE (Status)) + { + /* Display method locals/args if disassembler is present */ + + AcpiDmDumpMethodInfo (Status, WalkState, WalkState->Op); + } +#endif + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateMethodMutex + * + * PARAMETERS: ObjDesc - The method object + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object for a serialized control method + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsCreateMethodMutex ( + ACPI_OPERAND_OBJECT *MethodDesc) +{ + ACPI_OPERAND_OBJECT *MutexDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DsCreateMethodMutex); + + + /* Create the new mutex object */ + + MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); + if (!MutexDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Create the actual OS Mutex */ + + Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel; + MethodDesc->Method.Mutex = MutexDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBeginMethodExecution + * + * PARAMETERS: MethodNode - Node of the method + * ObjDesc - The method object + * WalkState - current state, NULL if not yet executing + * a method. + * + * RETURN: Status + * + * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, + * increments the thread count, and waits at the method semaphore + * for clearance to execute. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode); + + + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + /* Prevent wraparound of thread count */ + + if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX) + { + ACPI_ERROR ((AE_INFO, + "Method reached maximum reentrancy limit (255)")); + return_ACPI_STATUS (AE_AML_METHOD_LIMIT); + } + + /* + * If this method is serialized, we need to acquire the method mutex. + */ + if (ObjDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) + { + /* + * Create a mutex for the method if it is defined to be Serialized + * and a mutex has not already been created. We defer the mutex creation + * until a method is actually executed, to minimize the object count + */ + if (!ObjDesc->Method.Mutex) + { + Status = AcpiDsCreateMethodMutex (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * The CurrentSyncLevel (per-thread) must be less than or equal to + * the sync level of the method. This mechanism provides some + * deadlock prevention + * + * Top-level method invocation has no walk state at this point + */ + if (WalkState && + (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) + { + ACPI_ERROR ((AE_INFO, + "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)", + AcpiUtGetNodeName (MethodNode), + WalkState->Thread->CurrentSyncLevel)); + + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + /* + * Obtain the method mutex if necessary. Do not acquire mutex for a + * recursive call. + */ + if (!WalkState || + !ObjDesc->Method.Mutex->Mutex.ThreadId || + (WalkState->Thread->ThreadId != ObjDesc->Method.Mutex->Mutex.ThreadId)) + { + /* + * Acquire the method mutex. This releases the interpreter if we + * block (and reacquires it before it returns) + */ + Status = AcpiExSystemWaitMutex (ObjDesc->Method.Mutex->Mutex.OsMutex, + ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Update the mutex and walk info and save the original SyncLevel */ + + if (WalkState) + { + ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = + WalkState->Thread->CurrentSyncLevel; + + ObjDesc->Method.Mutex->Mutex.ThreadId = WalkState->Thread->ThreadId; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Method.SyncLevel; + } + else + { + ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = + ObjDesc->Method.Mutex->Mutex.SyncLevel; + } + } + + /* Always increase acquisition depth */ + + ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++; + } + + /* + * Allocate an Owner ID for this method, only if this is the first thread + * to begin concurrent execution. We only need one OwnerId, even if the + * method is invoked recursively. + */ + if (!ObjDesc->Method.OwnerId) + { + Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + /* + * Increment the method parse tree thread count since it has been + * reentered one more time (even if it is the same thread) + */ + ObjDesc->Method.ThreadCount++; + AcpiMethodCount++; + return_ACPI_STATUS (Status); + + +Cleanup: + /* On error, must release the method mutex (if present) */ + + if (ObjDesc->Method.Mutex) + { + AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCallControlMethod + * + * PARAMETERS: Thread - Info for this thread + * ThisWalkState - Current walk state + * Op - Current Op to be walked + * + * RETURN: Status + * + * DESCRIPTION: Transfer execution to a called control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_THREAD_STATE *Thread, + ACPI_WALK_STATE *ThisWalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_WALK_STATE *NextWalkState = NULL; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_EVALUATE_INFO *Info; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Calling method %p, currentstate=%p\n", + ThisWalkState->PrevOp, ThisWalkState)); + + /* + * Get the namespace entry for the control method we are about to call + */ + MethodNode = ThisWalkState->MethodCallNode; + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Init for new method, possibly wait on method mutex */ + + Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, + ThisWalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Begin method parse/execution. Create a new walk state */ + + NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, + NULL, ObjDesc, Thread); + if (!NextWalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * The resolved arguments were put on the previous walk state's operand + * stack. Operands on the previous walk state stack always + * start at index 0. Also, null terminate the list of arguments + */ + ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; + + /* + * Allocate and initialize the evaluation information block + * TBD: this is somewhat inefficient, should change interface to + * DsInitAmlWalk. For now, keeps this struct off the CPU stack + */ + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Parameters = &ThisWalkState->Operands[0]; + + Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, + ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, + Info, ACPI_IMODE_EXECUTE); + + ACPI_FREE (Info); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Delete the operands on the previous walkstate operand stack + * (they were copied to new objects) + */ + for (i = 0; i < ObjDesc->Method.ParamCount; i++) + { + AcpiUtRemoveReference (ThisWalkState->Operands [i]); + ThisWalkState->Operands [i] = NULL; + } + + /* Clear the operand stack */ + + ThisWalkState->NumOperands = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Begin nested execution of [%4.4s] **** WalkState=%p\n", + MethodNode->Name.Ascii, NextWalkState)); + + /* Invoke an internal method if necessary */ + + if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + { + Status = ObjDesc->Method.Extra.Implementation (NextWalkState); + if (Status == AE_OK) + { + Status = AE_CTRL_TERMINATE; + } + } + + return_ACPI_STATUS (Status); + + +Cleanup: + + /* On error, we must terminate the method properly */ + + AcpiDsTerminateControlMethod (ObjDesc, NextWalkState); + if (NextWalkState) + { + AcpiDsDeleteWalkState (NextWalkState); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsRestartControlMethod + * + * PARAMETERS: WalkState - State for preempted method (caller) + * ReturnDesc - Return value from the called method + * + * RETURN: Status + * + * DESCRIPTION: Restart a method that was preempted by another (nested) method + * invocation. Handle the return value (if any) from the callee. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc) +{ + ACPI_STATUS Status; + int SameAsImplicitReturn; + + + ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", + AcpiUtGetNodeName (WalkState->MethodNode), + WalkState->MethodCallOp, ReturnDesc)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n", + WalkState->ReturnUsed, + WalkState->Results, WalkState)); + + /* Did the called method return a value? */ + + if (ReturnDesc) + { + /* Is the implicit return object the same as the return desc? */ + + SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc); + + /* Are we actually going to use the return value? */ + + if (WalkState->ReturnUsed) + { + /* Save the return value from the previous method */ + + Status = AcpiDsResultPush (ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + return_ACPI_STATUS (Status); + } + + /* + * Save as THIS method's return value in case it is returned + * immediately to yet another method + */ + WalkState->ReturnDesc = ReturnDesc; + } + + /* + * The following code is the optional support for the so-called + * "implicit return". Some AML code assumes that the last value of the + * method is "implicitly" returned to the caller, in the absence of an + * explicit return value. + * + * Just save the last result of the method as the return value. + * + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) || + SameAsImplicitReturn) + { + /* + * Delete the return value if it will not be used by the + * calling method or remove one reference if the explicit return + * is the same as the implicit return value. + */ + AcpiUtRemoveReference (ReturnDesc); + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsTerminateControlMethod + * + * PARAMETERS: MethodDesc - Method object + * WalkState - State associated with the method + * + * RETURN: None + * + * DESCRIPTION: Terminate a control method. Delete everything that the method + * created, delete all locals and arguments, and delete the parse + * tree if requested. + * + * MUTEX: Interpreter is locked + * + ******************************************************************************/ + +void +AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState); + + + /* MethodDesc is required, WalkState is optional */ + + if (!MethodDesc) + { + return_VOID; + } + + if (WalkState) + { + /* Delete all arguments and locals */ + + AcpiDsMethodDataDeleteAll (WalkState); + + /* + * If method is serialized, release the mutex and restore the + * current sync level for this thread + */ + if (MethodDesc->Method.Mutex) + { + /* Acquisition Depth handles recursive calls */ + + MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; + if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) + { + WalkState->Thread->CurrentSyncLevel = + MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; + + AcpiOsReleaseMutex (MethodDesc->Method.Mutex->Mutex.OsMutex); + MethodDesc->Method.Mutex->Mutex.ThreadId = 0; + } + } + + /* + * Delete any namespace objects created anywhere within the + * namespace by the execution of this method. Unless this method + * is a module-level executable code method, in which case we + * want make the objects permanent. + */ + if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) + { + AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + } + } + + /* Decrement the thread count on the method */ + + if (MethodDesc->Method.ThreadCount) + { + MethodDesc->Method.ThreadCount--; + } + else + { + ACPI_ERROR ((AE_INFO, + "Invalid zero thread count in method")); + } + + /* Are there any other threads currently executing this method? */ + + if (MethodDesc->Method.ThreadCount) + { + /* + * Additional threads. Do not release the OwnerId in this case, + * we immediately reuse it for the next thread executing this method + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "*** Completed execution of one thread, %d threads remaining\n", + MethodDesc->Method.ThreadCount)); + } + else + { + /* This is the only executing thread for this method */ + + /* + * Support to dynamically change a method from NotSerialized to + * Serialized if it appears that the method is incorrectly written and + * does not support multiple thread execution. The best example of this + * is if such a method creates namespace objects and blocks. A second + * thread will fail with an AE_ALREADY_EXISTS exception + * + * This code is here because we must wait until the last thread exits + * before creating the synchronization semaphore. + */ + if ((MethodDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) && + (!MethodDesc->Method.Mutex)) + { + (void) AcpiDsCreateMethodMutex (MethodDesc); + } + + /* No more threads, we can free the OwnerId */ + + if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) + { + AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); + } + } + + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c new file mode 100644 index 00000000000..551e8480a98 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c @@ -0,0 +1,846 @@ +/******************************************************************************* + * + * Module Name: dsmthdat - control method arguments and local variables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSMTHDAT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsmthdat") + +/* Local prototypes */ + +static void +AcpiDsMethodDataDeleteValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInit + * + * PARAMETERS: WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Initialize the data structures that hold the method's arguments + * and locals. The data struct is an array of namespace nodes for + * each - this allows RefOf and DeRefOf to work properly for these + * special data types. + * + * NOTES: WalkState fields are initialized to zero by the + * ACPI_ALLOCATE_ZEROED(). + * + * A pseudo-Namespace Node is assigned to each argument and local + * so that RefOf() can return a pointer to the Node. + * + ******************************************************************************/ + +void +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (DsMethodDataInit); + + + /* Init the method arguments */ + + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE); + WalkState->Arguments[i].Name.Integer |= (i << 24); + WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED; + WalkState->Arguments[i].Type = ACPI_TYPE_ANY; + WalkState->Arguments[i].Flags = + ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; + } + + /* Init the method locals */ + + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE); + + WalkState->LocalVariables[i].Name.Integer |= (i << 24); + WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED; + WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; + WalkState->LocalVariables[i].Flags = + ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteAll + * + * PARAMETERS: WalkState - Current walk state object + * + * RETURN: None + * + * DESCRIPTION: Delete method locals and arguments. Arguments are only + * deleted if this method was called from another method. + * + ******************************************************************************/ + +void +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 Index; + + + ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll); + + + /* Detach the locals */ + + for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++) + { + if (WalkState->LocalVariables[Index].Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", + Index, WalkState->LocalVariables[Index].Object)); + + /* Detach object (if present) and remove a reference */ + + AcpiNsDetachObject (&WalkState->LocalVariables[Index]); + } + } + + /* Detach the arguments */ + + for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++) + { + if (WalkState->Arguments[Index].Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", + Index, WalkState->Arguments[Index].Object)); + + /* Detach object (if present) and remove a reference */ + + AcpiNsDetachObject (&WalkState->Arguments[Index]); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInitArgs + * + * PARAMETERS: *Params - Pointer to a parameter list for the method + * MaxParamCount - The arg count for this method + * WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Initialize arguments for a method. The parameter list is a list + * of ACPI operand objects, either null terminated or whose length + * is defined by MaxParamCount. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + UINT32 Index = 0; + + + ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params); + + + if (!Params) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); + return_ACPI_STATUS (AE_OK); + } + + /* Copy passed parameters into the new method stack frame */ + + while ((Index < ACPI_METHOD_NUM_ARGS) && + (Index < MaxParamCount) && + Params[Index]) + { + /* + * A valid parameter. + * Store the argument in the method/walk descriptor. + * Do not copy the arg in order to implement call by reference + */ + Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index, + Params[Index], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Index++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetNode + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg whose type to get + * WalkState - Current walk state object + * Node - Where the node is returned. + * + * RETURN: Status and node + * + * DESCRIPTION: Get the Node associated with a local or arg. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetNode ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **Node) +{ + ACPI_FUNCTION_TRACE (DsMethodDataGetNode); + + + /* + * Method Locals and Arguments are supported + */ + switch (Type) + { + case ACPI_REFCLASS_LOCAL: + + if (Index > ACPI_METHOD_MAX_LOCAL) + { + ACPI_ERROR ((AE_INFO, + "Local index %d is invalid (max %d)", + Index, ACPI_METHOD_MAX_LOCAL)); + return_ACPI_STATUS (AE_AML_INVALID_INDEX); + } + + /* Return a pointer to the pseudo-node */ + + *Node = &WalkState->LocalVariables[Index]; + break; + + case ACPI_REFCLASS_ARG: + + if (Index > ACPI_METHOD_MAX_ARG) + { + ACPI_ERROR ((AE_INFO, + "Arg index %d is invalid (max %d)", + Index, ACPI_METHOD_MAX_ARG)); + return_ACPI_STATUS (AE_AML_INVALID_INDEX); + } + + /* Return a pointer to the pseudo-node */ + + *Node = &WalkState->Arguments[Index]; + break; + + default: + ACPI_ERROR ((AE_INFO, "Type %d is invalid", Type)); + return_ACPI_STATUS (AE_TYPE); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataSetValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg to get + * Object - Object to be inserted into the stack entry + * WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. + * Note: There is no "implicit conversion" for locals. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (DsMethodDataSetValue); + + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "NewObj %p Type %2.2X, Refs=%d [%s]\n", Object, + Type, Object->Common.ReferenceCount, + AcpiUtGetTypeName (Object->Common.Type))); + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Increment ref count so object can't be deleted while installed. + * NOTE: We do not copy the object in order to preserve the call by + * reference semantics of ACPI Control Method invocation. + * (See ACPI Specification 2.0C) + */ + AcpiUtAddReference (Object); + + /* Install the object */ + + Node->Object = Object; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which localVar or argument to get + * WalkState - Current walk state object + * DestDesc - Where Arg or Local value is returned + * + * RETURN: Status + * + * DESCRIPTION: Retrieve value of selected Arg or Local for this method + * Used only in AcpiExResolveToValue(). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataGetValue); + + + /* Validate the object descriptor */ + + if (!DestDesc) + { + ACPI_ERROR ((AE_INFO, "Null object descriptor pointer")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the object from the node */ + + Object = Node->Object; + + /* Examine the returned object, it must be valid. */ + + if (!Object) + { + /* + * Index points to uninitialized object. + * This means that either 1) The expected argument was + * not passed to the method, or 2) A local variable + * was referenced by the method (via the ASL) + * before it was initialized. Either case is an error. + */ + + /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */ + + if (AcpiGbl_EnableInterpreterSlack) + { + Object = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!Object) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Node->Object = Object; + } + + /* Otherwise, return the error */ + + else switch (Type) + { + case ACPI_REFCLASS_ARG: + + ACPI_ERROR ((AE_INFO, + "Uninitialized Arg[%d] at node %p", + Index, Node)); + + return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); + + case ACPI_REFCLASS_LOCAL: + + /* + * No error message for this case, will be trapped again later to + * detect and ignore cases of Store(LocalX,LocalX) + */ + return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); + + default: + + ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: %X", Type)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + } + + /* + * The Index points to an initialized and valid object. + * Return an additional reference to the object + */ + *DestDesc = Object; + AcpiUtAddReference (Object); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which localVar or argument to delete + * WalkState - Current walk state object + * + * RETURN: None + * + * DESCRIPTION: Delete the entry at Opcode:Index. Inserts + * a null into the stack slot after the object is deleted. + * + ******************************************************************************/ + +static void +AcpiDsMethodDataDeleteValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue); + + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Get the associated object */ + + Object = AcpiNsGetAttachedObject (Node); + + /* + * Undefine the Arg or Local by setting its descriptor + * pointer to NULL. Locals/Args can contain both + * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs + */ + Node->Object = NULL; + + if ((Object) && + (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND)) + { + /* + * There is a valid object. + * Decrement the reference count by one to balance the + * increment when the object was stored. + */ + AcpiUtRemoveReference (Object); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsStoreObjectToLocal + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg to set + * ObjDesc - Value to be stored + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed + * as the new value for the Arg or Local and the reference count + * for ObjDesc is incremented. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsStoreObjectToLocal ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *CurrentObjDesc; + ACPI_OPERAND_OBJECT *NewObjDesc; + + + ACPI_FUNCTION_TRACE (DsStoreObjectToLocal); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n", + Type, Index, ObjDesc)); + + /* Parameter validation */ + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + CurrentObjDesc = AcpiNsGetAttachedObject (Node); + if (CurrentObjDesc == ObjDesc) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", + ObjDesc)); + return_ACPI_STATUS (Status); + } + + /* + * If the reference count on the object is more than one, we must + * take a copy of the object before we store. A reference count + * of exactly 1 means that the object was just created during the + * evaluation of an expression, and we can safely use it since it + * is not used anywhere else. + */ + NewObjDesc = ObjDesc; + if (ObjDesc->Common.ReferenceCount > 1) + { + Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * If there is an object already in this slot, we either + * have to delete it, or if this is an argument and there + * is an object reference stored there, we have to do + * an indirect store! + */ + if (CurrentObjDesc) + { + /* + * Check for an indirect store if an argument + * contains an object reference (stored as an Node). + * We don't allow this automatic dereferencing for + * locals, since a store to a local should overwrite + * anything there, including an object reference. + * + * If both Arg0 and Local0 contain RefOf (Local4): + * + * Store (1, Arg0) - Causes indirect store to local4 + * Store (1, Local0) - Stores 1 in local0, overwriting + * the reference to local4 + * Store (1, DeRefof (Local0)) - Causes indirect store to local4 + * + * Weird, but true. + */ + if (Type == ACPI_REFCLASS_ARG) + { + /* + * If we have a valid reference object that came from RefOf(), + * do the indirect store + */ + if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) && + (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Arg (%p) is an ObjRef(Node), storing in node %p\n", + NewObjDesc, CurrentObjDesc)); + + /* + * Store this object to the Node (perform the indirect store) + * NOTE: No implicit conversion is performed, as per the ACPI + * specification rules on storing to Locals/Args. + */ + Status = AcpiExStoreObjectToNode (NewObjDesc, + CurrentObjDesc->Reference.Object, WalkState, + ACPI_NO_IMPLICIT_CONVERSION); + + /* Remove local reference if we copied the object above */ + + if (NewObjDesc != ObjDesc) + { + AcpiUtRemoveReference (NewObjDesc); + } + return_ACPI_STATUS (Status); + } + } + + /* Delete the existing object before storing the new one */ + + AcpiDsMethodDataDeleteValue (Type, Index, WalkState); + } + + /* + * Install the Obj descriptor (*NewObjDesc) into + * the descriptor for the Arg or Local. + * (increments the object reference count by one) + */ + Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState); + + /* Remove local reference if we copied the object above */ + + if (NewObjDesc != ObjDesc) + { + AcpiUtRemoveReference (NewObjDesc); + } + + return_ACPI_STATUS (Status); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetType + * + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * Index - Which Local or Arg whose type to get + * WalkState - Current walk state object + * + * RETURN: Data type of current value of the selected Arg or Local + * + * DESCRIPTION: Get the type of the object stored in the Local or Arg + * + ******************************************************************************/ + +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataGetType); + + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_VALUE ((ACPI_TYPE_NOT_FOUND)); + } + + /* Get the object */ + + Object = AcpiNsGetAttachedObject (Node); + if (!Object) + { + /* Uninitialized local/arg, return TYPE_ANY */ + + return_VALUE (ACPI_TYPE_ANY); + } + + /* Get the object type */ + + return_VALUE (Object->Type); +} +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsobject.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsobject.c new file mode 100644 index 00000000000..cf444a1df2b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsobject.c @@ -0,0 +1,925 @@ +/****************************************************************************** + * + * Module Name: dsobject - Dispatcher object management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsobject") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr); + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalObject + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op object to the equivalent namespace object + * Simple objects are any objects other than a package object! + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DsBuildInternalObject); + + + *ObjDescPtr = NULL; + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) + { + /* + * This is a named object reference. If this name was + * previously looked up in the namespace, it was stored in this op. + * Otherwise, go ahead and look it up now + */ + if (!Op->Common.Node) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, + Op->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node))); + if (ACPI_FAILURE (Status)) + { + /* Check if we are resolving a named reference within a package */ + + if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) && + + ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + /* + * We didn't find the target and we are populating elements + * of a package - ignore if slack enabled. Some ASL code + * contains dangling invalid references in packages and + * expects that no exception will be issued. Leave the + * element as a null element. It cannot be used, but it + * can be overwritten by subsequent ASL code - this is + * typically the case. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Ignoring unresolved reference in package [%4.4s]\n", + WalkState->ScopeInfo->Scope.Node->Name.Ascii)); + + return_ACPI_STATUS (AE_OK); + } + else + { + ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status); + } + + return_ACPI_STATUS (Status); + } + } + + /* Special object resolution for elements of a package */ + + if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + /* + * Attempt to resolve the node to a value before we insert it into + * the package. If this is a reference to a common data type, + * resolve it immediately. According to the ACPI spec, package + * elements can only be "data objects" or method references. + * Attempt to resolve to an Integer, Buffer, String or Package. + * If cannot, return the named reference (for things like Devices, + * Methods, etc.) Buffer Fields and Fields will resolve to simple + * objects (int/buf/str/pkg). + * + * NOTE: References to things like Devices, Methods, Mutexes, etc. + * will remain as named references. This behavior is not described + * in the ACPI spec, but it appears to be an oversight. + */ + ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Op->Common.Node); + + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + switch (Op->Common.Node->Type) + { + /* + * For these types, we need the actual node, not the subobject. + * However, the subobject did not get an extra reference count above. + * + * TBD: should ExResolveNodeToValue be changed to fix this? + */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + + AcpiUtAddReference (Op->Common.Node->Object); + + /*lint -fallthrough */ + /* + * For these types, we need the actual node, not the subobject. + * The subobject got an extra reference count in ExResolveNodeToValue. + */ + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_METHOD: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_REGION: + + /* We will create a reference object for these types below */ + break; + + default: + /* + * All other types - the node was resolved to an actual + * object, we are done. + */ + goto Exit; + } + } + } + + /* Create and init a new internal ACPI object */ + + ObjDesc = AcpiUtCreateInternalObject ( + (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); + } + +Exit: + *ObjDescPtr = ObjDesc; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalBufferObj + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * BufferLength - Length of the buffer + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalBufferObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 BufferLength, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ByteList; + UINT32 ByteListLength = 0; + + + ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj); + + + /* + * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". + * The buffer object already exists (from the NS node), otherwise it must + * be created. + */ + ObjDesc = *ObjDescPtr; + if (!ObjDesc) + { + /* Create a new buffer object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* + * Second arg is the buffer data (optional) ByteList can be either + * individual bytes or a string initializer. In either case, a + * ByteList appears in the AML. + */ + Arg = Op->Common.Value.Arg; /* skip first arg */ + + ByteList = Arg->Named.Next; + if (ByteList) + { + if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) + { + ACPI_ERROR ((AE_INFO, + "Expecting bytelist, got AML opcode %X in op %p", + ByteList->Common.AmlOpcode, ByteList)); + + AcpiUtRemoveReference (ObjDesc); + return (AE_TYPE); + } + + ByteListLength = (UINT32) ByteList->Common.Value.Integer; + } + + /* + * The buffer length (number of bytes) will be the larger of: + * 1) The specified buffer length and + * 2) The length of the initializer byte list + */ + ObjDesc->Buffer.Length = BufferLength; + if (ByteListLength > BufferLength) + { + ObjDesc->Buffer.Length = ByteListLength; + } + + /* Allocate the buffer */ + + if (ObjDesc->Buffer.Length == 0) + { + ObjDesc->Buffer.Pointer = NULL; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Buffer defined with zero length in AML, creating\n")); + } + else + { + ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED ( + ObjDesc->Buffer.Length); + if (!ObjDesc->Buffer.Pointer) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize buffer from the ByteList (if present) */ + + if (ByteList) + { + ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data, + ByteListLength); + } + } + + ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalPackageObj + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * ElementCount - Number of elements in the package - this is + * the NumElements argument to Package() + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + * NOTE: The number of elements in the package will be always be the NumElements + * count, regardless of the number of elements in the package list. If + * NumElements is smaller, only that many package list elements are used. + * if NumElements is larger, the Package object is padded out with + * objects of type Uninitialized (as per ACPI spec.) + * + * Even though the ASL compilers do not allow NumElements to be smaller + * than the Package list length (for the fixed length package opcode), some + * BIOS code modifies the AML on the fly to adjust the NumElements, and + * this code compensates for that. This also provides compatibility with + * other AML interpreters. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 ElementCount, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE_OBJECT *Parent; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_STATUS Status = AE_OK; + UINT32 i; + UINT16 Index; + UINT16 ReferenceCount; + + + ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj); + + + /* Find the parent of a possibly nested package */ + + Parent = Op->Common.Parent; + while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + Parent = Parent->Common.Parent; + } + + /* + * If we are evaluating a Named package object "Name (xxxx, Package)", + * the package object already exists, otherwise it must be created. + */ + ObjDesc = *ObjDescPtr; + if (!ObjDesc) + { + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.Node = Parent->Common.Node; + } + + /* + * Allocate the element array (array of pointers to the individual + * objects) based on the NumElements parameter. Add an extra pointer slot + * so that the list is always null terminated. + */ + ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ElementCount + 1) * sizeof (void *)); + + if (!ObjDesc->Package.Elements) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.Count = ElementCount; + + /* + * Initialize the elements of the package, up to the NumElements count. + * Package is automatically padded with uninitialized (NULL) elements + * if NumElements is greater than the package list length. Likewise, + * Package is truncated if NumElements is less than the list length. + */ + Arg = Op->Common.Value.Arg; + Arg = Arg->Common.Next; + for (i = 0; Arg && (i < ElementCount); i++) + { + if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) + { + if (Arg->Common.Node->Type == ACPI_TYPE_METHOD) + { + /* + * A method reference "looks" to the parser to be a method + * invocation, so we special case it here + */ + Arg->Common.AmlOpcode = AML_INT_NAMEPATH_OP; + Status = AcpiDsBuildInternalObject (WalkState, Arg, + &ObjDesc->Package.Elements[i]); + } + else + { + /* This package element is already built, just get it */ + + ObjDesc->Package.Elements[i] = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); + } + } + else + { + Status = AcpiDsBuildInternalObject (WalkState, Arg, + &ObjDesc->Package.Elements[i]); + } + + if (*ObjDescPtr) + { + /* Existing package, get existing reference count */ + + ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount; + if (ReferenceCount > 1) + { + /* Make new element ref count match original ref count */ + + for (Index = 0; Index < (ReferenceCount - 1); Index++) + { + AcpiUtAddReference ((ObjDesc->Package.Elements[i])); + } + } + } + + Arg = Arg->Common.Next; + } + + /* Check for match between NumElements and actual length of PackageList */ + + if (Arg) + { + /* + * NumElements was exhausted, but there are remaining elements in the + * PackageList. Truncate the package to NumElements. + * + * Note: technically, this is an error, from ACPI spec: "It is an error + * for NumElements to be less than the number of elements in the + * PackageList". However, we just print a message and + * no exception is returned. This provides Windows compatibility. Some + * BIOSs will alter the NumElements on the fly, creating this type + * of ill-formed package object. + */ + while (Arg) + { + /* + * We must delete any package elements that were created earlier + * and are not going to be used because of the package truncation. + */ + if (Arg->Common.Node) + { + AcpiUtRemoveReference ( + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node)); + Arg->Common.Node = NULL; + } + + /* Find out how many elements there really are */ + + i++; + Arg = Arg->Common.Next; + } + + ACPI_INFO ((AE_INFO, + "Actual Package length (0x%X) is larger than NumElements field (0x%X), truncated\n", + i, ElementCount)); + } + else if (i < ElementCount) + { + /* + * Arg list (elements) was exhausted, but we did not reach NumElements count. + * Note: this is not an error, the package is padded out with NULLs. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Package List length (0x%X) smaller than NumElements count (0x%X), padded with null elements\n", + i, ElementCount)); + } + + ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateNode + * + * PARAMETERS: WalkState - Current walk state + * Node - NS Node to be initialized + * Op - Parser object to be translated + * + * RETURN: Status + * + * DESCRIPTION: Create the object to be associated with a namespace node + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op); + + + /* + * Because of the execution pass through the non-control-method + * parts of the table, we can arrive here twice. Only init + * the named object node the first time through + */ + if (AcpiNsGetAttachedObject (Node)) + { + return_ACPI_STATUS (AE_OK); + } + + if (!Op->Common.Value.Arg) + { + /* No arguments, there is nothing to do */ + + return_ACPI_STATUS (AE_OK); + } + + /* Build an internal object for the argument(s) */ + + Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Re-type the object according to its argument */ + + Node->Type = ObjDesc->Common.Type; + + /* Attach obj to node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + +#endif /* ACPI_NO_METHOD_EXECUTION */ + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitObjectFromOp + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser op used to init the internal object + * Opcode - AML opcode associated with the object + * RetObjDesc - Namespace object to be initialized + * + * RETURN: Status + * + * DESCRIPTION: Initialize a namespace object from a parser Op and its + * associated arguments. The namespace object is a more compact + * representation of the Op and its arguments. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitObjectFromOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode, + ACPI_OPERAND_OBJECT **RetObjDesc) +{ + const ACPI_OPCODE_INFO *OpInfo; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (DsInitObjectFromOp); + + + ObjDesc = *RetObjDesc; + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Unknown opcode */ + + return_ACPI_STATUS (AE_TYPE); + } + + /* Perform per-object initialization */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* + * Defer evaluation of Buffer TermArg operand + */ + ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); + ObjDesc->Buffer.AmlStart = Op->Named.Data; + ObjDesc->Buffer.AmlLength = Op->Named.Length; + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * Defer evaluation of Package TermArg operand + */ + ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); + ObjDesc->Package.AmlStart = Op->Named.Data; + ObjDesc->Package.AmlLength = Op->Named.Length; + break; + + + case ACPI_TYPE_INTEGER: + + switch (OpInfo->Type) + { + case AML_TYPE_CONSTANT: + /* + * Resolve AML Constants here - AND ONLY HERE! + * All constants are integers. + * We mark the integer with a flag that indicates that it started + * life as a constant -- so that stores to constants will perform + * as expected (noop). ZeroOp is used as a placeholder for optional + * target operands. + */ + ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT; + + switch (Opcode) + { + case AML_ZERO_OP: + + ObjDesc->Integer.Value = 0; + break; + + case AML_ONE_OP: + + ObjDesc->Integer.Value = 1; + break; + + case AML_ONES_OP: + + ObjDesc->Integer.Value = ACPI_INTEGER_MAX; + + /* Truncate value if we are executing from a 32-bit ACPI table */ + +#ifndef ACPI_NO_METHOD_EXECUTION + AcpiExTruncateFor32bitTable (ObjDesc); +#endif + break; + + case AML_REVISION_OP: + + ObjDesc->Integer.Value = ACPI_CA_VERSION; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown constant opcode %X", Opcode)); + Status = AE_AML_OPERAND_TYPE; + break; + } + break; + + + case AML_TYPE_LITERAL: + + ObjDesc->Integer.Value = Op->Common.Value.Integer; +#ifndef ACPI_NO_METHOD_EXECUTION + AcpiExTruncateFor32bitTable (ObjDesc); +#endif + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Integer type %X", + OpInfo->Type)); + Status = AE_AML_OPERAND_TYPE; + break; + } + break; + + + case ACPI_TYPE_STRING: + + ObjDesc->String.Pointer = Op->Common.Value.String; + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String); + + /* + * The string is contained in the ACPI table, don't ever try + * to delete it + */ + ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; + break; + + + case ACPI_TYPE_METHOD: + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (OpInfo->Type) + { + case AML_TYPE_LOCAL_VARIABLE: + + /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */ + + ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP; + ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL; + +#ifndef ACPI_NO_METHOD_EXECUTION + Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL, + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); +#endif + break; + + + case AML_TYPE_METHOD_ARGUMENT: + + /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */ + + ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP; + ObjDesc->Reference.Class = ACPI_REFCLASS_ARG; + +#ifndef ACPI_NO_METHOD_EXECUTION + Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG, + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); +#endif + break; + + default: /* Object name or Debug object */ + + switch (Op->Common.AmlOpcode) + { + case AML_INT_NAMEPATH_OP: + + /* Node was saved in Op */ + + ObjDesc->Reference.Node = Op->Common.Node; + ObjDesc->Reference.Object = Op->Common.Node->Object; + ObjDesc->Reference.Class = ACPI_REFCLASS_NAME; + break; + + case AML_DEBUG_OP: + + ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unimplemented reference type for AML opcode: %4.4X", Opcode)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unimplemented data type: %X", + ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + break; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c new file mode 100644 index 00000000000..3edbacc1d95 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c @@ -0,0 +1,1619 @@ +/****************************************************************************** + * + * Module Name: dsopcode - Dispatcher Op Region support and handling of + * "control" opcodes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSOPCODE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsopcode") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart); + +static ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecuteArguments + * + * PARAMETERS: Node - Object NS node + * ScopeNode - Parent NS node + * AmlLength - Length of executable AML + * AmlStart - Pointer to the AML + * + * RETURN: Status. + * + * DESCRIPTION: Late (deferred) execution of region or field arguments + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsExecuteArguments); + + + /* + * Allocate a new parser op to be the root of the parsed tree + */ + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the Node for use in AcpiPsParseAml */ + + Op->Common.Node = ScopeNode; + + /* Create and initialize a new parser state */ + + WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, + AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* Mark this parse as a deferred opcode */ + + WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP; + WalkState->DeferredNode = Node; + + /* Pass1: Parse the entire declaration */ + + Status = AcpiPsParseAml (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Get and init the Op created above */ + + Op->Common.Node = Node; + AcpiPsDeleteParseTree (Op); + + /* Evaluate the deferred arguments */ + + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Op->Common.Node = ScopeNode; + + /* Create and initialize a new parser state */ + + WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Execute the opcode and arguments */ + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, + AmlLength, NULL, ACPI_IMODE_EXECUTE); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* Mark this execution as a deferred opcode */ + + WalkState->DeferredNode = Node; + Status = AcpiPsParseAml (WalkState); + +Cleanup: + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBufferFieldArguments + * + * PARAMETERS: ObjDesc - A valid BufferField object + * + * RETURN: Status. + * + * DESCRIPTION: Get BufferField Buffer and Index. This implements the late + * evaluation of these field attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBufferFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT *ExtraDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the AML pointer (method object) and BufferField node */ + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + Node = ObjDesc->BufferField.Node; + + ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", + AcpiUtGetNodeName (Node))); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBankFieldArguments + * + * PARAMETERS: ObjDesc - A valid BankField object + * + * RETURN: Status. + * + * DESCRIPTION: Get BankField BankValue. This implements the late + * evaluation of these field attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBankFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT *ExtraDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the AML pointer (method object) and BankField node */ + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + Node = ObjDesc->BankField.Node; + + ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD, Node, NULL)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", + AcpiUtGetNodeName (Node))); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBufferArguments + * + * PARAMETERS: ObjDesc - A valid Buffer object + * + * RETURN: Status. + * + * DESCRIPTION: Get Buffer length and initializer byte list. This implements + * the late evaluation of these attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBufferArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the Buffer node */ + + Node = ObjDesc->Buffer.Node; + if (!Node) + { + ACPI_ERROR ((AE_INFO, + "No pointer back to NS node in buffer obj %p", ObjDesc)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node, + ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetPackageArguments + * + * PARAMETERS: ObjDesc - A valid Package object + * + * RETURN: Status. + * + * DESCRIPTION: Get Package length and initializer byte list. This implements + * the late evaluation of these attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetPackageArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the Package node */ + + Node = ObjDesc->Package.Node; + if (!Node) + { + ACPI_ERROR ((AE_INFO, + "No pointer back to NS node in package %p", ObjDesc)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node, + ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetRegionArguments + * + * PARAMETERS: ObjDesc - A valid region object + * + * RETURN: Status. + * + * DESCRIPTION: Get region address and length. This implements the late + * evaluation of these region attributes. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetRegionArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ExtraDesc; + + + ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc); + + + if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + if (!ExtraDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Get the Region node */ + + Node = ObjDesc->Region.Node; + + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL)); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", + AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); + + /* Execute the argument AML */ + + Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitializeRegion + * + * PARAMETERS: ObjHandle - Region namespace node + * + * RETURN: Status + * + * DESCRIPTION: Front end to EvInitializeRegion + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitializeRegion ( + ACPI_HANDLE ObjHandle) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ObjDesc = AcpiNsGetAttachedObject (ObjHandle); + + /* Namespace is NOT locked */ + + Status = AcpiEvInitializeRegion (ObjDesc, FALSE); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitBufferField + * + * PARAMETERS: AmlOpcode - CreateXxxField + * ObjDesc - BufferField object + * BufferDesc - Host Buffer + * OffsetDesc - Offset into buffer + * LengthDesc - Length of field (CREATE_FIELD_OP only) + * ResultDesc - Where to store the result + * + * RETURN: Status + * + * DESCRIPTION: Perform actual initialization of a buffer field + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc) +{ + UINT32 Offset; + UINT32 BitOffset; + UINT32 BitCount; + UINT8 FieldFlags; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc); + + + /* Host object must be a Buffer */ + + if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, + "Target of Create Field is not a Buffer object - %s", + AcpiUtGetObjectTypeName (BufferDesc))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * The last parameter to all of these opcodes (ResultDesc) started + * out as a NameString, and should therefore now be a NS node + * after resolution in AcpiExResolveOperands(). + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "(%s) destination not a NS Node [%s]", + AcpiPsGetOpcodeName (AmlOpcode), + AcpiUtGetDescriptorName (ResultDesc))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + Offset = (UINT32) OffsetDesc->Integer.Value; + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + switch (AmlOpcode) + { + case AML_CREATE_FIELD_OP: + + /* Offset is in bits, count is in bits */ + + FieldFlags = AML_FIELD_ACCESS_BYTE; + BitOffset = Offset; + BitCount = (UINT32) LengthDesc->Integer.Value; + + /* Must have a valid (>0) bit count */ + + if (BitCount == 0) + { + ACPI_ERROR ((AE_INFO, + "Attempt to CreateField of length zero")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + break; + + case AML_CREATE_BIT_FIELD_OP: + + /* Offset is in bits, Field is one bit */ + + BitOffset = Offset; + BitCount = 1; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_BYTE_FIELD_OP: + + /* Offset is in bytes, field is one byte */ + + BitOffset = 8 * Offset; + BitCount = 8; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_WORD_FIELD_OP: + + /* Offset is in bytes, field is one word */ + + BitOffset = 8 * Offset; + BitCount = 16; + FieldFlags = AML_FIELD_ACCESS_WORD; + break; + + case AML_CREATE_DWORD_FIELD_OP: + + /* Offset is in bytes, field is one dword */ + + BitOffset = 8 * Offset; + BitCount = 32; + FieldFlags = AML_FIELD_ACCESS_DWORD; + break; + + case AML_CREATE_QWORD_FIELD_OP: + + /* Offset is in bytes, field is one qword */ + + BitOffset = 8 * Offset; + BitCount = 64; + FieldFlags = AML_FIELD_ACCESS_QWORD; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown field creation opcode %02x", + AmlOpcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Entire field must fit within the current length of the buffer */ + + if ((BitOffset + BitCount) > + (8 * (UINT32) BufferDesc->Buffer.Length)) + { + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)", + AcpiUtGetNodeName (ResultDesc), + BitOffset + BitCount, + AcpiUtGetNodeName (BufferDesc->Buffer.Node), + 8 * (UINT32) BufferDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + /* + * Initialize areas of the field object that are common to all fields + * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), + * UPDATE_RULE = 0 (UPDATE_PRESERVE) + */ + Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, + BitOffset, BitCount); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + ObjDesc->BufferField.BufferObj = BufferDesc; + + /* Reference count for BufferDesc inherits ObjDesc count */ + + BufferDesc->Common.ReferenceCount = (UINT16) + (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount); + + +Cleanup: + + /* Always delete the operands */ + + AcpiUtRemoveReference (OffsetDesc); + AcpiUtRemoveReference (BufferDesc); + + if (AmlOpcode == AML_CREATE_FIELD_OP) + { + AcpiUtRemoveReference (LengthDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ + } + else + { + /* Now the address and length are valid for this BufferField */ + + ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalBufferFieldOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid BufferField Op object + * + * RETURN: Status + * + * DESCRIPTION: Get BufferField Buffer and Index + * Called from AcpiDsExecEndOp during BufferField parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalBufferFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op); + + + /* + * This is where we evaluate the address and length fields of the + * CreateXxxField declaration + */ + Node = Op->Common.Node; + + /* NextOp points to the op that holds the Buffer */ + + NextOp = Op->Common.Value.Arg; + + /* Evaluate/create the address and length operands */ + + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Resolve the operands */ + + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "(%s) bad operand(s) (%X)", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); + + return_ACPI_STATUS (Status); + } + + /* Initialize the Buffer Field */ + + if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) + { + /* NOTE: Slightly different operands for this opcode */ + + Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, + WalkState->Operands[0], WalkState->Operands[1], + WalkState->Operands[2], WalkState->Operands[3]); + } + else + { + /* All other, CreateXxxField opcodes */ + + Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, + WalkState->Operands[0], WalkState->Operands[1], + NULL, WalkState->Operands[2]); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalRegionOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid region Op object + * + * RETURN: Status + * + * DESCRIPTION: Get region address and length + * Called from AcpiDsExecEndOp during OpRegion parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *OperandDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op); + + + /* + * This is where we evaluate the address and length fields of the + * OpRegion declaration + */ + Node = Op->Common.Node; + + /* NextOp points to the op that holds the SpaceID */ + + NextOp = Op->Common.Value.Arg; + + /* NextOp points to address op */ + + NextOp = NextOp->Common.Next; + + /* Evaluate/create the address and length operands */ + + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Resolve the length and address operands to numbers */ + + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * Get the length operand and save it + * (at Top of stack) + */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; + + ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; + AcpiUtRemoveReference (OperandDesc); + + /* + * Get the address and save it + * (at top of stack - 1) + */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; + + ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) + OperandDesc->Integer.Value; + AcpiUtRemoveReference (OperandDesc); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", + ObjDesc, + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length)); + + /* Now the address and length are valid for this opregion */ + + ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalTableRegionOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid region Op object + * + * RETURN: Status + * + * DESCRIPTION: Get region address and length + * Called from AcpiDsExecEndOp during DataTableRegion parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalTableRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **Operand; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + UINT32 TableIndex; + ACPI_TABLE_HEADER *Table; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op); + + + /* + * This is where we evaluate the SignatureString and OemIDString + * and OemTableIDString of the DataTableRegion declaration + */ + Node = Op->Common.Node; + + /* NextOp points to SignatureString op */ + + NextOp = Op->Common.Value.Arg; + + /* + * Evaluate/create the SignatureString and OemIDString + * and OemTableIDString operands + */ + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Resolve the SignatureString and OemIDString + * and OemTableIDString operands + */ + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Operand = &WalkState->Operands[0]; + + /* Find the ACPI table */ + + Status = AcpiTbFindTable (Operand[0]->String.Pointer, + Operand[1]->String.Pointer, Operand[2]->String.Pointer, + &TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtRemoveReference (Operand[0]); + AcpiUtRemoveReference (Operand[1]); + AcpiUtRemoveReference (Operand[2]); + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); + ObjDesc->Region.Length = Table->Length; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", + ObjDesc, + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length)); + + /* Now the address and length are valid for this opregion */ + + ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalDataObjectOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid DataObject Op object + * ObjDesc - DataObject + * + * RETURN: Status + * + * DESCRIPTION: Get the operands and complete the following data object types: + * Buffer, Package. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalDataObjectOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ArgDesc; + UINT32 Length; + + + ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands); + + + /* The first operand (for all of these data objects) is the length */ + + /* + * Set proper index into operand stack for AcpiDsObjStackPush + * invoked inside AcpiDsCreateOperand. + */ + WalkState->OperandIndex = WalkState->NumOperands; + + Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveOperands (WalkState->Opcode, + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Extract length operand */ + + ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; + Length = (UINT32) ArgDesc->Integer.Value; + + /* Cleanup for length operand */ + + Status = AcpiDsObjStackPop (1, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtRemoveReference (ArgDesc); + + /* + * Create the actual data object + */ + switch (Op->Common.AmlOpcode) + { + case AML_BUFFER_OP: + + Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); + break; + + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); + break; + + default: + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Return the object in the WalkState, unless the parent is a package - + * in this case, the return object will be stored in the parse tree + * for the package. + */ + if ((!Op->Common.Parent) || + ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && + (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && + (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) + { + WalkState->ResultObj = ObjDesc; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalBankFieldOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid BankField Op object + * + * RETURN: Status + * + * DESCRIPTION: Get BankField BankValue + * Called from AcpiDsExecEndOp during BankField parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalBankFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *OperandDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *Arg; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op); + + + /* + * This is where we evaluate the BankValue field of the + * BankField declaration + */ + + /* NextOp points to the op that holds the Region */ + + NextOp = Op->Common.Value.Arg; + + /* NextOp points to the op that holds the Bank Register */ + + NextOp = NextOp->Common.Next; + + /* NextOp points to the op that holds the Bank Value */ + + NextOp = NextOp->Common.Next; + + /* + * Set proper index into operand stack for AcpiDsObjStackPush + * invoked inside AcpiDsCreateOperand. + * + * We use WalkState->Operands[0] to store the evaluated BankValue + */ + WalkState->OperandIndex = 0; + + Status = AcpiDsCreateOperand (WalkState, NextOp, 0); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1); + /* + * Get the BankValue operand and save it + * (at Top of stack) + */ + OperandDesc = WalkState->Operands[0]; + + /* Arg points to the start Bank Field */ + + Arg = AcpiPsGetArg (Op, 4); + while (Arg) + { + /* Ignore OFFSET and ACCESSAS terms here */ + + if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) + { + Node = Arg->Common.Node; + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value; + } + + /* Move to next field in the list */ + + Arg = Arg->Common.Next; + } + + AcpiUtRemoveReference (OperandDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecBeginControlOp + * + * PARAMETERS: WalkList - The list that owns the walk stack + * Op - The control Op + * + * RETURN: Status + * + * DESCRIPTION: Handles all control ops encountered during control method + * execution. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *ControlState; + + + ACPI_FUNCTION_NAME (DsExecBeginControlOp); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, + Op->Common.AmlOpcode, WalkState)); + + switch (Op->Common.AmlOpcode) + { + case AML_WHILE_OP: + + /* + * If this is an additional iteration of a while loop, continue. + * There is no need to allocate a new control state. + */ + if (WalkState->ControlState) + { + if (WalkState->ControlState->Control.AmlPredicateStart == + (WalkState->ParserState.Aml - 1)) + { + /* Reset the state to start-of-loop */ + + WalkState->ControlState->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + break; + } + } + + /*lint -fallthrough */ + + case AML_IF_OP: + + /* + * IF/WHILE: Create a new control state to manage these + * constructs. We need to manage these as a stack, in order + * to handle nesting. + */ + ControlState = AcpiUtCreateControlState (); + if (!ControlState) + { + Status = AE_NO_MEMORY; + break; + } + /* + * Save a pointer to the predicate for multiple executions + * of a loop + */ + ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; + ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; + ControlState->Control.Opcode = Op->Common.AmlOpcode; + + + /* Push the control state on this walk's control stack */ + + AcpiUtPushGenericState (&WalkState->ControlState, ControlState); + break; + + case AML_ELSE_OP: + + /* Predicate is in the state object */ + /* If predicate is true, the IF was executed, ignore ELSE part */ + + if (WalkState->LastPredicate) + { + Status = AE_CTRL_TRUE; + } + + break; + + case AML_RETURN_OP: + + break; + + default: + break; + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecEndControlOp + * + * PARAMETERS: WalkList - The list that owns the walk stack + * Op - The control Op + * + * RETURN: Status + * + * DESCRIPTION: Handles all control ops encountered during control method + * execution. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *ControlState; + + + ACPI_FUNCTION_NAME (DsExecEndControlOp); + + + switch (Op->Common.AmlOpcode) + { + case AML_IF_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op)); + + /* + * Save the result of the predicate in case there is an + * ELSE to come + */ + WalkState->LastPredicate = + (BOOLEAN) WalkState->ControlState->Common.Value; + + /* + * Pop the control state that was created at the start + * of the IF and free it + */ + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + break; + + + case AML_ELSE_OP: + + break; + + + case AML_WHILE_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); + + ControlState = WalkState->ControlState; + if (ControlState->Common.Value) + { + /* Predicate was true, the body of the loop was just executed */ + + /* + * This loop counter mechanism allows the interpreter to escape + * possibly infinite loops. This can occur in poorly written AML + * when the hardware does not respond within a while loop and the + * loop does not implement a timeout. + */ + ControlState->Control.LoopCount++; + if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS) + { + Status = AE_AML_INFINITE_LOOP; + break; + } + + /* + * Go back and evaluate the predicate and maybe execute the loop + * another time + */ + Status = AE_CTRL_PENDING; + WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; + break; + } + + /* Predicate was false, terminate this while loop */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[WHILE_OP] termination! Op=%p\n",Op)); + + /* Pop this control state and free it */ + + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + break; + + + case AML_RETURN_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); + + /* + * One optional operand -- the return value + * It can be either an immediate operand or a result that + * has been bubbled up the tree + */ + if (Op->Common.Value.Arg) + { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + + /* Return statement has an immediate operand */ + + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + */ + Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Get the return value and save as the last result + * value. This is the only place where WalkState->ReturnDesc + * is set to anything other than zero! + */ + WalkState->ReturnDesc = WalkState->Operands[0]; + } + else if (WalkState->ResultCount) + { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + + /* + * The return value has come from a previous calculation. + * + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + * + * Allow references created by the Index operator to return unchanged. + */ + if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && + ((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX)) + { + Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; + } + else + { + /* No return operand */ + + if (WalkState->NumOperands) + { + AcpiUtRemoveReference (WalkState->Operands [0]); + } + + WalkState->Operands [0] = NULL; + WalkState->NumOperands = 0; + WalkState->ReturnDesc = NULL; + } + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Completed RETURN_OP State=%p, RetVal=%p\n", + WalkState, WalkState->ReturnDesc)); + + /* End the control method execution right now */ + + Status = AE_CTRL_TERMINATE; + break; + + + case AML_NOOP_OP: + + /* Just do nothing! */ + break; + + + case AML_BREAK_POINT_OP: + + /* + * Set the single-step flag. This will cause the debugger (if present) + * to break to the console within the AML debugger at the start of the + * next AML instruction. + */ + ACPI_DEBUGGER_EXEC ( + AcpiGbl_CmSingleStep = TRUE); + ACPI_DEBUGGER_EXEC ( + AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n")); + + /* Call to the OSL in case OS wants a piece of the action */ + + Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, + "Executed AML Breakpoint opcode"); + break; + + + case AML_BREAK_OP: + case AML_CONTINUE_OP: /* ACPI 2.0 */ + + + /* Pop and delete control states until we find a while */ + + while (WalkState->ControlState && + (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) + { + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + } + + /* No while found? */ + + if (!WalkState->ControlState) + { + return (AE_AML_NO_WHILE); + } + + /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ + + WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; + + /* Return status depending on opcode */ + + if (Op->Common.AmlOpcode == AML_BREAK_OP) + { + Status = AE_CTRL_BREAK; + } + else + { + Status = AE_CTRL_CONTINUE; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown control opcode=%X Op=%p", + Op->Common.AmlOpcode, Op)); + + Status = AE_AML_BAD_OPCODE; + break; + } + + return (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsutils.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsutils.c new file mode 100644 index 00000000000..6c211ace8c6 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsutils.c @@ -0,0 +1,1009 @@ +/******************************************************************************* + * + * Module Name: dsutils - Dispatcher utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsClearImplicitReturn + * + * PARAMETERS: WalkState - Current State + * + * RETURN: None. + * + * DESCRIPTION: Clear and remove a reference on an implicit return value. Used + * to delete "stale" return values (if enabled, the return value + * from every operator is saved at least momentarily, in case the + * parent method exits.) + * + ******************************************************************************/ + +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME (DsClearImplicitReturn); + + + /* + * Slack must be enabled for this feature + */ + if (!AcpiGbl_EnableInterpreterSlack) + { + return; + } + + if (WalkState->ImplicitReturnObj) + { + /* + * Delete any "stale" implicit return. However, in + * complex statements, the implicit return value can be + * bubbled up several levels. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Removing reference on stale implicit return obj %p\n", + WalkState->ImplicitReturnObj)); + + AcpiUtRemoveReference (WalkState->ImplicitReturnObj); + WalkState->ImplicitReturnObj = NULL; + } +} + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiDsDoImplicitReturn + * + * PARAMETERS: ReturnDesc - The return value + * WalkState - Current State + * AddReference - True if a reference should be added to the + * return object + * + * RETURN: TRUE if implicit return enabled, FALSE otherwise + * + * DESCRIPTION: Implements the optional "implicit return". We save the result + * of every ASL operator and control method invocation in case the + * parent method exit. Before storing a new return value, we + * delete the previous return value. + * + ******************************************************************************/ + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference) +{ + ACPI_FUNCTION_NAME (DsDoImplicitReturn); + + + /* + * Slack must be enabled for this feature, and we must + * have a valid return object + */ + if ((!AcpiGbl_EnableInterpreterSlack) || + (!ReturnDesc)) + { + return (FALSE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result %p will be implicitly returned; Prev=%p\n", + ReturnDesc, + WalkState->ImplicitReturnObj)); + + /* + * Delete any "stale" implicit return value first. However, in + * complex statements, the implicit return value can be + * bubbled up several levels, so we don't clear the value if it + * is the same as the ReturnDesc. + */ + if (WalkState->ImplicitReturnObj) + { + if (WalkState->ImplicitReturnObj == ReturnDesc) + { + return (TRUE); + } + AcpiDsClearImplicitReturn (WalkState); + } + + /* Save the implicit return value, add a reference if requested */ + + WalkState->ImplicitReturnObj = ReturnDesc; + if (AddReference) + { + AcpiUtAddReference (ReturnDesc); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsIsResultUsed + * + * PARAMETERS: Op - Current Op + * WalkState - Current State + * + * RETURN: TRUE if result is used, FALSE otherwise + * + * DESCRIPTION: Check if a result object will be used by the parent + * + ******************************************************************************/ + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + const ACPI_OPCODE_INFO *ParentInfo; + + ACPI_FUNCTION_TRACE_PTR (DsIsResultUsed, Op); + + + /* Must have both an Op and a Result Object */ + + if (!Op) + { + ACPI_ERROR ((AE_INFO, "Null Op")); + return_UINT8 (TRUE); + } + + /* + * We know that this operator is not a + * Return() operator (would not come here.) The following code is the + * optional support for a so-called "implicit return". Some AML code + * assumes that the last value of the method is "implicitly" returned + * to the caller. Just save the last result as the return value. + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE); + + /* + * Now determine if the parent will use the result + * + * If there is no parent, or the parent is a ScopeOp, we are executing + * at the method level. An executing method typically has no parent, + * since each method is parsed separately. A method invoked externally + * via ExecuteControlMethod has a ScopeOp as the parent. + */ + if ((!Op->Common.Parent) || + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { + /* No parent, the return value cannot possibly be used */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "At Method level, result of [%s] not used\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); + return_UINT8 (FALSE); + } + + /* Get info on the parent. The RootOp is AML_SCOPE */ + + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); + if (ParentInfo->Class == AML_CLASS_UNKNOWN) + { + ACPI_ERROR ((AE_INFO, + "Unknown parent opcode Op=%p", Op)); + return_UINT8 (FALSE); + } + + /* + * Decide what to do with the result based on the parent. If + * the parent opcode will not use the result, delete the object. + * Otherwise leave it as is, it will be deleted when it is used + * as an operand later. + */ + switch (ParentInfo->Class) + { + case AML_CLASS_CONTROL: + + switch (Op->Common.Parent->Common.AmlOpcode) + { + case AML_RETURN_OP: + + /* Never delete the return value associated with a return opcode */ + + goto ResultUsed; + + case AML_IF_OP: + case AML_WHILE_OP: + + /* + * If we are executing the predicate AND this is the predicate op, + * we will use the return value + */ + if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + goto ResultUsed; + } + break; + + default: + /* Ignore other control opcodes */ + break; + } + + /* The general control opcode returns no result */ + + goto ResultNotUsed; + + + case AML_CLASS_CREATE: + + /* + * These opcodes allow TermArg(s) as operands and therefore + * the operands can be method calls. The result is used. + */ + goto ResultUsed; + + + case AML_CLASS_NAMED_OBJECT: + + if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP)) + { + /* + * These opcodes allow TermArg(s) as operands and therefore + * the operands can be method calls. The result is used. + */ + goto ResultUsed; + } + + goto ResultNotUsed; + + + default: + + /* + * In all other cases. the parent will actually use the return + * object, so keep it. + */ + goto ResultUsed; + } + + +ResultUsed: + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + + return_UINT8 (TRUE); + + +ResultNotUsed: + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] not used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + + return_UINT8 (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDeleteResultIfNotUsed + * + * PARAMETERS: Op - Current parse Op + * ResultObj - Result of the operation + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Used after interpretation of an opcode. If there is an internal + * result descriptor, check if the parent opcode will actually use + * this result. If not, delete the result now so that it will + * not become orphaned. + * + ******************************************************************************/ + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsDeleteResultIfNotUsed, ResultObj); + + + if (!Op) + { + ACPI_ERROR ((AE_INFO, "Null Op")); + return_VOID; + } + + if (!ResultObj) + { + return_VOID; + } + + if (!AcpiDsIsResultUsed (Op, WalkState)) + { + /* Must pop the result stack (ObjDesc should be equal to ResultObj) */ + + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_SUCCESS (Status)) + { + AcpiUtRemoveReference (ResultObj); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResolveOperands + * + * PARAMETERS: WalkState - Current walk state with operands on stack + * + * RETURN: Status + * + * DESCRIPTION: Resolve all operands to their values. Used to prepare + * arguments to a control method invocation (a call from one + * method to another.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResolveOperands ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (DsResolveOperands, WalkState); + + + /* + * Attempt to resolve each of the valid operands + * Method arguments are passed by reference, not by value. This means + * that the actual objects are passed, not copies of the objects. + */ + for (i = 0; i < WalkState->NumOperands; i++) + { + Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsClearOperands + * + * PARAMETERS: WalkState - Current walk state with operands on stack + * + * RETURN: None + * + * DESCRIPTION: Clear all operands on the current walk state operand stack. + * + ******************************************************************************/ + +void +AcpiDsClearOperands ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsClearOperands, WalkState); + + + /* Remove a reference on each operand on the stack */ + + for (i = 0; i < WalkState->NumOperands; i++) + { + /* + * Remove a reference to all operands, including both + * "Arguments" and "Targets". + */ + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + + WalkState->NumOperands = 0; + return_VOID; +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperand + * + * PARAMETERS: WalkState - Current walk state + * Arg - Parse object for the argument + * ArgIndex - Which argument (zero based) + * + * RETURN: Status + * + * DESCRIPTION: Translate a parse tree object that is an argument to an AML + * opcode to the equivalent interpreter object. This may include + * looking up a name or entering a new name into the internal + * namespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg, + UINT32 ArgIndex) +{ + ACPI_STATUS Status = AE_OK; + char *NameString; + UINT32 NameLength; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ParentOp; + UINT16 Opcode; + ACPI_INTERPRETER_MODE InterpreterMode; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateOperand, Arg); + + + /* A valid name must be looked up in the namespace */ + + if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + (Arg->Common.Value.String) && + !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg)); + + /* Get the entire name string from the AML stream */ + + Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Common.Value.Buffer, + &NameString, &NameLength); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* All prefixes have been handled, and the name is in NameString */ + + /* + * Special handling for BufferField declarations. This is a deferred + * opcode that unfortunately defines the field name as the last + * parameter instead of the first. We get here when we are performing + * the deferred execution, so the actual name of the field is already + * in the namespace. We don't want to attempt to look it up again + * because we may be executing in a different scope than where the + * actual opcode exists. + */ + if ((WalkState->DeferredNode) && + (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) && + (ArgIndex == (UINT32) ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2))) + { + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, WalkState->DeferredNode); + Status = AE_OK; + } + else /* All other opcodes */ + { + /* + * Differentiate between a namespace "create" operation + * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. + * IMODE_EXECUTE) in order to support the creation of + * namespace objects during the execution of control methods. + */ + ParentOp = Arg->Common.Parent; + OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode); + if ((OpInfo->Flags & AML_NSNODE) && + (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && + (ParentOp->Common.AmlOpcode != AML_REGION_OP) && + (ParentOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)) + { + /* Enter name into namespace if not found */ + + InterpreterMode = ACPI_IMODE_LOAD_PASS2; + } + else + { + /* Return a failure if name not found */ + + InterpreterMode = ACPI_IMODE_EXECUTE; + } + + Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, + ACPI_TYPE_ANY, InterpreterMode, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); + /* + * The only case where we pass through (ignore) a NOT_FOUND + * error is for the CondRefOf opcode. + */ + if (Status == AE_NOT_FOUND) + { + if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP) + { + /* + * For the Conditional Reference op, it's OK if + * the name is not found; We just need a way to + * indicate this to the interpreter, set the + * object to the root + */ + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); + Status = AE_OK; + } + else + { + /* + * We just plain didn't find it -- which is a + * very serious error at this point + */ + Status = AE_AML_NAME_NOT_FOUND; + } + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (NameString, Status); + } + } + + /* Free the namestring created above */ + + ACPI_FREE (NameString); + + /* Check status from the lookup */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Put the resulting object onto the current object stack */ + + Status = AcpiDsObjStackPush (ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + else + { + /* Check for null name case */ + + if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + /* + * If the name is null, this means that this is an + * optional result parameter that was not specified + * in the original ASL. Create a Zero Constant for a + * placeholder. (Store to a constant is a Noop.) + */ + Opcode = AML_ZERO_OP; /* Has no arguments! */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Null namepath: Arg=%p\n", Arg)); + } + else + { + Opcode = Arg->Common.AmlOpcode; + } + + /* Get the object type of the argument */ + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->ObjectType == ACPI_TYPE_INVALID) + { + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + if ((OpInfo->Flags & AML_HAS_RETVAL) || (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Argument previously created, already stacked\n")); + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject ( + WalkState->Operands [WalkState->NumOperands - 1], WalkState)); + + /* + * Use value that was already previously returned + * by the evaluation of this argument + */ + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* + * Only error is underflow, and this indicates + * a missing or null operand! + */ + ACPI_EXCEPTION ((AE_INFO, Status, + "Missing or null operand")); + return_ACPI_STATUS (Status); + } + } + else + { + /* Create an ACPI_INTERNAL_OBJECT for the argument */ + + ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new object */ + + Status = AcpiDsInitObjectFromOp ( + WalkState, Arg, Opcode, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (Status); + } + } + + /* Put the operand object on the object stack */ + + Status = AcpiDsObjStackPush (ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperands + * + * PARAMETERS: WalkState - Current state + * FirstArg - First argument of a parser argument tree + * + * RETURN: Status + * + * DESCRIPTION: Convert an operator's arguments from a parse tree format to + * namespace objects and place those argument object on the object + * stack in preparation for evaluation by the interpreter. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE_OBJECT *Arguments[ACPI_OBJ_NUM_OPERANDS]; + UINT32 ArgCount = 0; + UINT32 Index = WalkState->NumOperands; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateOperands, FirstArg); + + + /* Get all arguments in the list */ + + Arg = FirstArg; + while (Arg) + { + if (Index >= ACPI_OBJ_NUM_OPERANDS) + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + Arguments[Index] = Arg; + WalkState->Operands [Index] = NULL; + + /* Move on to next argument, if any */ + + Arg = Arg->Common.Next; + ArgCount++; + Index++; + } + + Index--; + + /* It is the appropriate order to get objects from the Result stack */ + + for (i = 0; i < ArgCount; i++) + { + Arg = Arguments[Index]; + + /* Force the filling of the operand stack in inverse order */ + + WalkState->OperandIndex = (UINT8) Index; + + Status = AcpiDsCreateOperand (WalkState, Arg, Index); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Index--; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", + Index, Arg, FirstArg)); + } + + return_ACPI_STATUS (Status); + + +Cleanup: + /* + * We must undo everything done above; meaning that we must + * pop everything off of the operand stack and delete those + * objects + */ + AcpiDsObjStackPopAndDelete (ArgCount, WalkState); + + ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %d", Index)); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsEvaluateNamePath + * + * PARAMETERS: WalkState - Current state of the parse tree walk, + * the opcode of current operation should be + * AML_INT_NAMEPATH_OP + * + * RETURN: Status + * + * DESCRIPTION: Translate the -NamePath- parse tree object to the equivalent + * interpreter object, convert it to value, if needed, duplicate + * it, if needed, and push it onto the current result stack. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsEvaluateNamePath ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = WalkState->Op; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *NewObjDesc; + UINT8 Type; + + + ACPI_FUNCTION_TRACE_PTR (DsEvaluateNamePath, WalkState); + + + if (!Op->Common.Parent) + { + /* This happens after certain exception processing */ + + goto Exit; + } + + if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP)) + { + /* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */ + + goto Exit; + } + + Status = AcpiDsCreateOperand (WalkState, Op, 0); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Op->Common.Flags & ACPI_PARSEOP_TARGET) + { + NewObjDesc = *Operand; + goto PushResult; + } + + Type = (*Operand)->Common.Type; + + Status = AcpiExResolveToValue (Operand, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Type == ACPI_TYPE_INTEGER) + { + /* It was incremented by AcpiExResolveToValue */ + + AcpiUtRemoveReference (*Operand); + + Status = AcpiUtCopyIobjectToIobject (*Operand, &NewObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + else + { + /* + * The object either was anew created or is + * a Namespace node - don't decrement it. + */ + NewObjDesc = *Operand; + } + + /* Cleanup for name-path operand */ + + Status = AcpiDsObjStackPop (1, WalkState); + if (ACPI_FAILURE (Status)) + { + WalkState->ResultObj = NewObjDesc; + goto Exit; + } + +PushResult: + + WalkState->ResultObj = NewObjDesc; + + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + if (ACPI_SUCCESS (Status)) + { + /* Force to take it from stack */ + + Op->Common.Flags |= ACPI_PARSEOP_IN_STACK; + } + +Exit: + + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c new file mode 100644 index 00000000000..9485c62bb1c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c @@ -0,0 +1,853 @@ +/****************************************************************************** + * + * Module Name: dswexec - Dispatcher method execution callbacks; + * dispatch to interpreter. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWEXEC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswexec") + +/* + * Dispatch table for opcode classes + */ +static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = +{ + AcpiExOpcode_0A_0T_1R, + AcpiExOpcode_1A_0T_0R, + AcpiExOpcode_1A_0T_1R, + AcpiExOpcode_1A_1T_0R, + AcpiExOpcode_1A_1T_1R, + AcpiExOpcode_2A_0T_0R, + AcpiExOpcode_2A_0T_1R, + AcpiExOpcode_2A_1T_1R, + AcpiExOpcode_2A_2T_1R, + AcpiExOpcode_3A_0T_0R, + AcpiExOpcode_3A_1T_1R, + AcpiExOpcode_6A_0T_1R +}; + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetPredicateValue + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * ResultObj - if non-zero, pop result from result stack + * + * RETURN: Status + * + * DESCRIPTION: Get the result of a predicate evaluation + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ResultObj) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *LocalObjDesc = NULL; + + + ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState); + + + WalkState->ControlState->Common.State = 0; + + if (ResultObj) + { + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not get result from predicate evaluation")); + + return_ACPI_STATUS (Status); + } + } + else + { + Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = WalkState->Operands [0]; + } + + if (!ObjDesc) + { + ACPI_ERROR ((AE_INFO, + "No predicate ObjDesc=%p State=%p", + ObjDesc, WalkState)); + + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * Result of predicate evaluation must be an Integer + * object. Implicitly convert the argument if necessary. + */ + Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, 16); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, + "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X", + ObjDesc, WalkState, ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* Truncate the predicate to 32-bits if necessary */ + + AcpiExTruncateFor32bitTable (LocalObjDesc); + + /* + * Save the result of the predicate evaluation on + * the control stack + */ + if (LocalObjDesc->Integer.Value) + { + WalkState->ControlState->Common.Value = TRUE; + } + else + { + /* + * Predicate is FALSE, we will just toss the + * rest of the package + */ + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_FALSE; + } + + /* Predicate can be used for an implicit return value */ + + (void) AcpiDsDoImplicitReturn (LocalObjDesc, WalkState, TRUE); + + +Cleanup: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", + WalkState->ControlState->Common.Value, WalkState->Op)); + + /* Break to debugger to display result */ + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (LocalObjDesc, WalkState)); + + /* + * Delete the predicate result object (we know that + * we don't need it anymore) + */ + if (LocalObjDesc != ObjDesc) + { + AcpiUtRemoveReference (LocalObjDesc); + } + AcpiUtRemoveReference (ObjDesc); + + WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecBeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Where to return op if a new one is created + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the execution of control + * methods. This is where most operators and operands are + * dispatched to the interpreter. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecBeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + UINT32 OpcodeClass; + + + ACPI_FUNCTION_TRACE_PTR (DsExecBeginOp, WalkState); + + + Op = WalkState->Op; + if (!Op) + { + Status = AcpiDsLoad2BeginOp (WalkState, OutOp); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + Op = *OutOp; + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + + if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "(%s) Popping scope for Op %p\n", + AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op)); + + Status = AcpiDsScopeStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + } + } + + if (Op == WalkState->Origin) + { + if (OutOp) + { + *OutOp = Op; + } + + return_ACPI_STATUS (AE_OK); + } + + /* + * If the previous opcode was a conditional, this opcode + * must be the beginning of the associated predicate. + * Save this knowledge in the current scope descriptor + */ + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n", + Op, WalkState)); + + WalkState->ControlState->Common.State = ACPI_CONTROL_PREDICATE_EXECUTING; + + /* Save start of predicate */ + + WalkState->ControlState->Control.PredicateOp = Op; + } + + + OpcodeClass = WalkState->OpInfo->Class; + + /* We want to send namepaths to the load code */ + + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) + { + OpcodeClass = AML_CLASS_NAMED_OBJECT; + } + + /* + * Handle the opcode based upon the opcode type + */ + switch (OpcodeClass) + { + case AML_CLASS_CONTROL: + + Status = AcpiDsExecBeginControlOp (WalkState, Op); + break; + + + case AML_CLASS_NAMED_OBJECT: + + if (WalkState->WalkType & ACPI_WALK_METHOD) + { + /* + * Found a named object declaration during method execution; + * we must enter this object into the namespace. The created + * object is temporary and will be deleted upon completion of + * the execution of this method. + */ + Status = AcpiDsLoad2BeginOp (WalkState, NULL); + } + + break; + + + case AML_CLASS_EXECUTE: + case AML_CLASS_CREATE: + + break; + + + default: + break; + } + + /* Nothing to do here during method execution */ + + return_ACPI_STATUS (Status); + + +ErrorExit: + Status = AcpiDsMethodError (Status, WalkState); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecEndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the execution of control + * methods. The only thing we really need to do here is to + * notice the beginning of IF, ELSE, and WHILE blocks. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + UINT32 OpType; + UINT32 OpClass; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *FirstArg; + + + ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState); + + + Op = WalkState->Op; + OpType = WalkState->OpInfo->Type; + OpClass = WalkState->OpInfo->Class; + + if (OpClass == AML_CLASS_UNKNOWN) + { + ACPI_ERROR ((AE_INFO, "Unknown opcode %X", Op->Common.AmlOpcode)); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + FirstArg = Op->Common.Value.Arg; + + /* Init the walk state */ + + WalkState->NumOperands = 0; + WalkState->OperandIndex = 0; + WalkState->ReturnDesc = NULL; + WalkState->ResultObj = NULL; + + /* Call debugger for single step support (DEBUG build only) */ + + ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass)); + ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);}); + + /* Decode the Opcode Class */ + + switch (OpClass) + { + case AML_CLASS_ARGUMENT: /* Constants, literals, etc. */ + + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) + { + Status = AcpiDsEvaluateNamePath (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + break; + + + case AML_CLASS_EXECUTE: /* Most operators with arguments */ + + /* Build resolved operand stack */ + + Status = AcpiDsCreateOperands (WalkState, FirstArg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * All opcodes require operand resolution, with the only exceptions + * being the ObjectType and SizeOf operators. + */ + if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE)) + { + /* Resolve all operands */ + + Status = AcpiExResolveOperands (WalkState->Opcode, + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Dispatch the request to the appropriate interpreter handler + * routine. There is one routine per opcode "type" based upon the + * number of opcode arguments and return type. + */ + Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState); + } + else + { + /* + * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the + * Local is uninitialized. + */ + if ((Status == AE_AML_UNINITIALIZED_LOCAL) && + (WalkState->Opcode == AML_STORE_OP) && + (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (WalkState->Operands[0]->Reference.Class == + WalkState->Operands[1]->Reference.Class) && + (WalkState->Operands[0]->Reference.Value == + WalkState->Operands[1]->Reference.Value)) + { + Status = AE_OK; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While resolving operands for [%s]", + AcpiPsGetOpcodeName (WalkState->Opcode))); + } + } + + /* Always delete the argument objects and clear the operand stack */ + + AcpiDsClearOperands (WalkState); + + /* + * If a result object was returned from above, push it on the + * current result stack + */ + if (ACPI_SUCCESS (Status) && + WalkState->ResultObj) + { + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + } + break; + + + default: + + switch (OpType) + { + case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ + + /* 1 Operand, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiDsExecEndControlOp (WalkState, Op); + + break; + + + case AML_TYPE_METHOD_CALL: + + /* + * If the method is referenced from within a package + * declaration, it is not a invocation of the method, just + * a reference to it. + */ + if ((Op->Asl.Parent) && + ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) || + (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Method Reference in a Package, Op=%p\n", Op)); + + Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node; + AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object); + return_ACPI_STATUS (AE_OK); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); + + /* + * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains + * the method Node pointer + */ + /* NextOp points to the op that holds the method name */ + + NextOp = FirstArg; + + /* NextOp points to first argument op */ + + NextOp = NextOp->Common.Next; + + /* + * Get the method's arguments and put them on the operand stack + */ + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + break; + } + + /* + * Since the operands will be passed to another control method, + * we must resolve all local references here (Local variables, + * arguments to *this* method, etc.) + */ + Status = AcpiDsResolveOperands (WalkState); + if (ACPI_FAILURE (Status)) + { + /* On error, clear all resolved operands */ + + AcpiDsClearOperands (WalkState); + break; + } + + /* + * Tell the walk loop to preempt this running method and + * execute the new method + */ + Status = AE_CTRL_TRANSFER; + + /* + * Return now; we don't want to disturb anything, + * especially the operand count! + */ + return_ACPI_STATUS (Status); + + + case AML_TYPE_CREATE_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing CreateField Buffer/Index Op=%p\n", Op)); + + Status = AcpiDsLoad2EndOp (WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + + Status = AcpiDsEvalBufferFieldOperands (WalkState, Op); + break; + + + case AML_TYPE_CREATE_OBJECT: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing CreateObject (Buffer/Package) Op=%p\n", Op)); + + switch (Op->Common.Parent->Common.AmlOpcode) + { + case AML_NAME_OP: + + /* + * Put the Node on the object stack (Contains the ACPI Name + * of this object) + */ + WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node; + WalkState->NumOperands = 1; + + Status = AcpiDsCreateNode (WalkState, + Op->Common.Parent->Common.Node, + Op->Common.Parent); + if (ACPI_FAILURE (Status)) + { + break; + } + + /* Fall through */ + /*lint -fallthrough */ + + case AML_INT_EVAL_SUBTREE_OP: + + Status = AcpiDsEvalDataObjectOperands (WalkState, Op, + AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); + break; + + default: + + Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL); + break; + } + + /* + * If a result object was returned from above, push it on the + * current result stack + */ + if (WalkState->ResultObj) + { + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + } + break; + + + case AML_TYPE_NAMED_FIELD: + case AML_TYPE_NAMED_COMPLEX: + case AML_TYPE_NAMED_SIMPLE: + case AML_TYPE_NAMED_NO_OBJ: + + Status = AcpiDsLoad2EndOp (WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing OpRegion Address/Length Op=%p\n", Op)); + + Status = AcpiDsEvalRegionOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing DataTableRegion Strings Op=%p\n", Op)); + + Status = AcpiDsEvalTableRegionOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + else if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing BankField Op=%p\n", Op)); + + Status = AcpiDsEvalBankFieldOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + break; + + + case AML_TYPE_UNDEFINED: + + ACPI_ERROR ((AE_INFO, + "Undefined opcode type Op=%p", Op)); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + + + case AML_TYPE_BOGUS: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Internal opcode=%X type Op=%p\n", + WalkState->Opcode, Op)); + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p", + OpClass, OpType, Op->Common.AmlOpcode, Op)); + + Status = AE_NOT_IMPLEMENTED; + break; + } + } + + /* + * ACPI 2.0 support for 64-bit integers: Truncate numeric + * result value if we are executing from a 32-bit ACPI table + */ + AcpiExTruncateFor32bitTable (WalkState->ResultObj); + + /* + * Check if we just completed the evaluation of a + * conditional predicate + */ + if ((ACPI_SUCCESS (Status)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj); + WalkState->ResultObj = NULL; + } + + +Cleanup: + + if (WalkState->ResultObj) + { + /* Break to debugger to display result */ + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, + WalkState)); + + /* + * Delete the result op if and only if: + * Parent will not use the result -- such as any + * non-nested type2 op in a method (parent will be method) + */ + AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState); + } + +#ifdef _UNDER_DEVELOPMENT + + if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd) + { + AcpiDbMethodEnd (WalkState); + } +#endif + + /* Invoke exception handler on error */ + + if (ACPI_FAILURE (Status)) + { + Status = AcpiDsMethodError (Status, WalkState); + } + + /* Always clear the object stack */ + + WalkState->NumOperands = 0; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswload.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswload.c new file mode 100644 index 00000000000..48c4ae6f163 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswload.c @@ -0,0 +1,1316 @@ +/****************************************************************************** + * + * Module Name: dswload - Dispatcher namespace load callbacks + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWLOAD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" + +#ifdef ACPI_ASL_COMPILER +#include "acdisasm.h" +#endif + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswload") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitCallbacks + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * PassNumber - 1, 2, or 3 + * + * RETURN: Status + * + * DESCRIPTION: Init walk state callbacks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitCallbacks ( + ACPI_WALK_STATE *WalkState, + UINT32 PassNumber) +{ + + switch (PassNumber) + { + case 1: + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; + WalkState->DescendingCallback = AcpiDsLoad1BeginOp; + WalkState->AscendingCallback = AcpiDsLoad1EndOp; + break; + + case 2: + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; + WalkState->DescendingCallback = AcpiDsLoad2BeginOp; + WalkState->AscendingCallback = AcpiDsLoad2EndOp; + break; + + case 3: +#ifndef ACPI_NO_METHOD_EXECUTION + WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | + ACPI_PARSE_DELETE_TREE; + WalkState->DescendingCallback = AcpiDsExecBeginOp; + WalkState->AscendingCallback = AcpiDsExecEndOp; +#endif + break; + + default: + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad1BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Where to return op if a new one is created + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE ObjectType; + char *Path; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE (DsLoad1BeginOp); + + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + + /* We are only interested in opcodes that have an associated name */ + + if (Op) + { + if (!(WalkState->OpInfo->Flags & AML_NAMED)) + { + *OutOp = Op; + return_ACPI_STATUS (AE_OK); + } + + /* Check if this object has already been installed in the namespace */ + + if (Op->Common.Node) + { + *OutOp = Op; + return_ACPI_STATUS (AE_OK); + } + } + + Path = AcpiPsGetNextNamestring (&WalkState->ParserState); + + /* Map the raw opcode into an internal object type */ + + ObjectType = WalkState->OpInfo->ObjectType; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType))); + + switch (WalkState->Opcode) + { + case AML_SCOPE_OP: + + /* + * The target name of the Scope() operator must exist at this point so + * that we can actually open the scope to enter new names underneath it. + * Allow search-to-root for single namesegs. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); +#ifdef ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + /* + * Table disassembly: + * Target of Scope() not found. Generate an External for it, and + * insert the name into the namespace. + */ + AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0); + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, + WalkState, &Node); + } +#endif + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + return_ACPI_STATUS (Status); + } + + /* + * Check to make sure that the target is + * one of the opcodes that actually opens a scope + */ + switch (Node->Type) + { + case ACPI_TYPE_ANY: + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* These are acceptable types */ + break; + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These types we will allow, but we will change the type. + * This enables some existing code of the form: + * + * Name (DEB, 0) + * Scope (DEB) { ... } + * + * Note: silently change the type here. On the second pass, + * we will report a warning + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Type override - [%4.4s] had invalid type (%s) " + "for Scope operator, changed to type ANY\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); + + Node->Type = ACPI_TYPE_ANY; + WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; + break; + + default: + + /* All other types are an error */ + + ACPI_ERROR ((AE_INFO, + "Invalid type (%s) for target of " + "Scope operator [%4.4s] (Cannot override)", + AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + + + default: + /* + * For all other named opcodes, we will enter the name into + * the namespace. + * + * Setup the search flags. + * Since we are entering a name into the namespace, we do not want to + * enable the search-to-root upsearch. + * + * There are only two conditions where it is acceptable that the name + * already exists: + * 1) the Scope() operator can reopen a scoping object that was + * previously defined (Scope, Method, Device, etc.) + * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, + * BufferField, or Package), the name of the object is already + * in the namespace. + */ + if (WalkState->DeferredNode) + { + /* This name is already in the namespace, get the node */ + + Node = WalkState->DeferredNode; + Status = AE_OK; + break; + } + + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (WalkState->MethodNode) + { + Node = NULL; + Status = AE_OK; + break; + } + + Flags = ACPI_NS_NO_UPSEARCH; + if ((WalkState->Opcode != AML_SCOPE_OP) && + (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) + { + Flags |= ACPI_NS_ERROR_IF_FOUND; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", + AcpiUtGetTypeName (ObjectType))); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[%s] Both Find or Create allowed\n", + AcpiUtGetTypeName (ObjectType))); + } + + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_ALREADY_EXISTS) + { + /* The name already exists in this scope */ + + if (Node->Flags & ANOBJ_IS_EXTERNAL) + { + /* + * Allow one create on an object or segment that was + * previously declared External + */ + Node->Flags &= ~ANOBJ_IS_EXTERNAL; + Node->Type = (UINT8) ObjectType; + + /* Just retyped a node, probably will need to open a scope */ + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + Status = AE_OK; + } + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + return_ACPI_STATUS (Status); + } + } + break; + } + + /* Common exit */ + + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* Initialize the op */ + +#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) + Op->Named.Path = ACPI_CAST_PTR (UINT8, Path); +#endif + + if (Node) + { + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->Common.Node = Node; + Op->Named.Name = Node->Name.Integer; + } + + AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); + *OutOp = Op; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad1EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_OBJECT_TYPE ObjectType; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (DsLoad1EndOp); + + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + + /* We are only interested in opcodes that have an associated name */ + + if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the object type to determine if we should pop the scope */ + + ObjectType = WalkState->OpInfo->ObjectType; + +#ifndef ACPI_NO_METHOD_EXECUTION + if (WalkState->OpInfo->Flags & AML_FIELD) + { + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!WalkState->MethodNode) + { + if (WalkState->Opcode == AML_FIELD_OP || + WalkState->Opcode == AML_BANK_FIELD_OP || + WalkState->Opcode == AML_INDEX_FIELD_OP) + { + Status = AcpiDsInitFieldObjects (Op, WalkState); + } + } + return_ACPI_STATUS (Status); + } + + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!WalkState->MethodNode) + { + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + REGION_DATA_TABLE, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } +#endif + + if (Op->Common.AmlOpcode == AML_NAME_OP) + { + /* For Name opcode, get the object type from the argument */ + + if (Op->Common.Value.Arg) + { + ObjectType = (AcpiPsGetOpcodeInfo ( + (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; + + /* Set node type if we have a namespace node */ + + if (Op->Common.Node) + { + Op->Common.Node->Type = (UINT8) ObjectType; + } + } + } + + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!WalkState->MethodNode) + { + if (Op->Common.AmlOpcode == AML_METHOD_OP) + { + /* + * MethodOp PkgLength NameString MethodFlags TermList + * + * Note: We must create the method node/object pair as soon as we + * see the method declaration. This allows later pass1 parsing + * of invocations of the method (need to know the number of + * arguments.) + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "LOADING-Method: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Op->Named.Node)); + + if (!AcpiNsGetAttachedObject (Op->Named.Node)) + { + WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); + WalkState->NumOperands = 1; + + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExCreateMethod (Op->Named.Data, + Op->Named.Length, WalkState); + } + + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + } + + /* Pop the scope stack (only if loading a table) */ + + if (!WalkState->MethodNode && + AcpiNsOpensScope (ObjectType)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", + AcpiUtGetTypeName (ObjectType), Op)); + + Status = AcpiDsScopeStackPop (WalkState); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad2BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Wher to return op if a new one is created + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE ObjectType; + char *BufferPtr; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE (DsLoad2BeginOp); + + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + + if (Op) + { + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) + { + /* We are executing a while loop outside of a method */ + + Status = AcpiDsExecBeginOp (WalkState, OutOp); + return_ACPI_STATUS (Status); + } + + /* We only care about Namespace opcodes here */ + + if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && + (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || + (!(WalkState->OpInfo->Flags & AML_NAMED))) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the name we are going to enter or lookup in the namespace */ + + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) + { + /* For Namepath op, get the path string */ + + BufferPtr = Op->Common.Value.String; + if (!BufferPtr) + { + /* No name, just exit */ + + return_ACPI_STATUS (AE_OK); + } + } + else + { + /* Get name from the op */ + + BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name); + } + } + else + { + /* Get the namestring from the raw AML */ + + BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState); + } + + /* Map the opcode into an internal object type */ + + ObjectType = WalkState->OpInfo->ObjectType; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType)); + + switch (WalkState->Opcode) + { + case AML_FIELD_OP: + case AML_BANK_FIELD_OP: + case AML_INDEX_FIELD_OP: + + Node = NULL; + Status = AE_OK; + break; + + case AML_INT_NAMEPATH_OP: + /* + * The NamePath is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); + break; + + case AML_SCOPE_OP: + + /* Special case for Scope(\) -> refers to the Root node */ + + if (Op && (Op->Named.Node == AcpiGbl_RootNode)) + { + Node = Op->Named.Node; + + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* + * The Path is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); + if (ACPI_FAILURE (Status)) + { +#ifdef ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + Status = AE_OK; + } + else + { + ACPI_ERROR_NAMESPACE (BufferPtr, Status); + } +#else + ACPI_ERROR_NAMESPACE (BufferPtr, Status); +#endif + return_ACPI_STATUS (Status); + } + } + + /* + * We must check to make sure that the target is + * one of the opcodes that actually opens a scope + */ + switch (Node->Type) + { + case ACPI_TYPE_ANY: + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* These are acceptable types */ + break; + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These types we will allow, but we will change the type. + * This enables some existing code of the form: + * + * Name (DEB, 0) + * Scope (DEB) { ... } + */ + ACPI_WARNING ((AE_INFO, + "Type override - [%4.4s] had invalid type (%s) " + "for Scope operator, changed to type ANY\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); + + Node->Type = ACPI_TYPE_ANY; + WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; + break; + + default: + + /* All other types are an error */ + + ACPI_ERROR ((AE_INFO, + "Invalid type (%s) for target of " + "Scope operator [%4.4s] (Cannot override)", + AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); + + return (AE_AML_OPERAND_TYPE); + } + break; + + default: + + /* All other opcodes */ + + if (Op && Op->Common.Node) + { + /* This op/node was previously entered into the namespace */ + + Node = Op->Common.Node; + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (AE_OK); + } + + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. + * + * Note: Name may already exist if we are executing a deferred opcode. + */ + if (WalkState->DeferredNode) + { + /* This name is already in the namespace, get the node */ + + Node = WalkState->DeferredNode; + Status = AE_OK; + break; + } + + Flags = ACPI_NS_NO_UPSEARCH; + if (WalkState->PassNumber == ACPI_IMODE_EXECUTE) + { + /* Execution mode, node cannot already exist, node is temporary */ + + Flags |= ACPI_NS_ERROR_IF_FOUND; + + if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + } + + /* Add new entry or lookup existing entry */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); + + if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "***New Node [%4.4s] %p is temporary\n", + AcpiUtGetNodeName (Node), Node)); + } + break; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (BufferPtr, Status); + return_ACPI_STATUS (Status); + } + + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new op */ + + if (Node) + { + Op->Named.Name = Node->Name.Integer; + } + *OutOp = Op; + } + + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->Common.Node = Node; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad2EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + ACPI_OBJECT_TYPE ObjectType; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *NewNode; +#ifndef ACPI_NO_METHOD_EXECUTION + UINT32 i; + UINT8 RegionSpace; +#endif + + + ACPI_FUNCTION_TRACE (DsLoad2EndOp); + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", + WalkState->OpInfo->Name, Op, WalkState)); + + /* Check if opcode had an associated namespace object */ + + if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) + { + return_ACPI_STATUS (AE_OK); + } + + if (Op->Common.AmlOpcode == AML_SCOPE_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Ending scope Op=%p State=%p\n", Op, WalkState)); + } + + ObjectType = WalkState->OpInfo->ObjectType; + + /* + * Get the Node/name from the earlier lookup + * (It was saved in the *op structure) + */ + Node = Op->Common.Node; + + /* + * Put the Node on the object stack (Contains the ACPI Name of + * this object) + */ + WalkState->Operands[0] = (void *) Node; + WalkState->NumOperands = 1; + + /* Pop the scope stack */ + + if (AcpiNsOpensScope (ObjectType) && + (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", + AcpiUtGetTypeName (ObjectType), Op)); + + Status = AcpiDsScopeStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + /* + * Named operations are as follows: + * + * AML_ALIAS + * AML_BANKFIELD + * AML_CREATEBITFIELD + * AML_CREATEBYTEFIELD + * AML_CREATEDWORDFIELD + * AML_CREATEFIELD + * AML_CREATEQWORDFIELD + * AML_CREATEWORDFIELD + * AML_DATA_REGION + * AML_DEVICE + * AML_EVENT + * AML_FIELD + * AML_INDEXFIELD + * AML_METHOD + * AML_METHODCALL + * AML_MUTEX + * AML_NAME + * AML_NAMEDFIELD + * AML_OPREGION + * AML_POWERRES + * AML_PROCESSOR + * AML_SCOPE + * AML_THERMALZONE + */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node)); + + /* Decode the opcode */ + + Arg = Op->Common.Value.Arg; + + switch (WalkState->OpInfo->Type) + { +#ifndef ACPI_NO_METHOD_EXECUTION + + case AML_TYPE_CREATE_FIELD: + /* + * Create the field object, but the field buffer and index must + * be evaluated later during the execution phase + */ + Status = AcpiDsCreateBufferField (Op, WalkState); + break; + + + case AML_TYPE_NAMED_FIELD: + /* + * If we are executing a method, initialize the field + */ + if (WalkState->MethodNode) + { + Status = AcpiDsInitFieldObjects (Op, WalkState); + } + + switch (Op->Common.AmlOpcode) + { + case AML_INDEX_FIELD_OP: + + Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, + WalkState); + break; + + case AML_BANK_FIELD_OP: + + Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState); + break; + + case AML_FIELD_OP: + + Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState); + break; + + default: + /* All NAMED_FIELD opcodes must be handled above */ + break; + } + break; + + + case AML_TYPE_NAMED_SIMPLE: + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + switch (Op->Common.AmlOpcode) + { + case AML_PROCESSOR_OP: + + Status = AcpiExCreateProcessor (WalkState); + break; + + case AML_POWER_RES_OP: + + Status = AcpiExCreatePowerResource (WalkState); + break; + + case AML_MUTEX_OP: + + Status = AcpiExCreateMutex (WalkState); + break; + + case AML_EVENT_OP: + + Status = AcpiExCreateEvent (WalkState); + break; + + + case AML_ALIAS_OP: + + Status = AcpiExCreateAlias (WalkState); + break; + + default: + /* Unknown opcode */ + + Status = AE_OK; + goto Cleanup; + } + + /* Delete operands */ + + for (i = 1; i < WalkState->NumOperands; i++) + { + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + + break; +#endif /* ACPI_NO_METHOD_EXECUTION */ + + case AML_TYPE_NAMED_COMPLEX: + + switch (Op->Common.AmlOpcode) + { +#ifndef ACPI_NO_METHOD_EXECUTION + case AML_REGION_OP: + case AML_DATA_REGION_OP: + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + RegionSpace = (ACPI_ADR_SPACE_TYPE) + ((Op->Common.Value.Arg)->Common.Value.Integer); + } + else + { + RegionSpace = REGION_DATA_TABLE; + } + + /* + * The OpRegion is not fully parsed at this time. The only valid + * argument is the SpaceId. (We must save the address of the + * AML of the address and length operands) + * + * If we have a valid region, initialize it. The namespace is + * unlocked at this point. + * + * Need to unlock interpreter if it is locked (if we are running + * a control method), in order to allow _REG methods to be run + * during AcpiEvInitializeRegion. + */ + if (WalkState->MethodNode) + { + /* + * Executing a method: initialize the region and unlock + * the interpreter + */ + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + RegionSpace, WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiExExitInterpreter (); + } + + Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), + FALSE); + if (WalkState->MethodNode) + { + AcpiExEnterInterpreter (); + } + + if (ACPI_FAILURE (Status)) + { + /* + * If AE_NOT_EXIST is returned, it is not fatal + * because many regions get created before a handler + * is installed for said region. + */ + if (AE_NOT_EXIST == Status) + { + Status = AE_OK; + } + } + break; + + + case AML_NAME_OP: + + Status = AcpiDsCreateNode (WalkState, Node, Op); + break; + + + case AML_METHOD_OP: + /* + * MethodOp PkgLength NameString MethodFlags TermList + * + * Note: We must create the method node/object pair as soon as we + * see the method declaration. This allows later pass1 parsing + * of invocations of the method (need to know the number of + * arguments.) + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "LOADING-Method: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Op->Named.Node)); + + if (!AcpiNsGetAttachedObject (Op->Named.Node)) + { + WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); + WalkState->NumOperands = 1; + + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExCreateMethod (Op->Named.Data, + Op->Named.Length, WalkState); + } + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + break; + +#endif /* ACPI_NO_METHOD_EXECUTION */ + + default: + /* All NAMED_COMPLEX opcodes must be handled above */ + break; + } + break; + + + case AML_CLASS_INTERNAL: + + /* case AML_INT_NAMEPATH_OP: */ + break; + + + case AML_CLASS_METHOD_CALL: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + /* + * Lookup the method name and save the Node + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &(NewNode)); + if (ACPI_SUCCESS (Status)) + { + /* + * Make sure that what we found is indeed a method + * We didn't search for a method on purpose, to see if the name + * would resolve + */ + if (NewNode->Type != ACPI_TYPE_METHOD) + { + Status = AE_AML_OPERAND_TYPE; + } + + /* We could put the returned object (Node) on the object stack for + * later, but for now, we will put it in the "op" object that the + * parser uses, so we can get it again at the end of this scope + */ + Op->Common.Node = NewNode; + } + else + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + } + break; + + + default: + break; + } + +Cleanup: + + /* Remove the Node pushed at the very beginning */ + + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswscope.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswscope.c new file mode 100644 index 00000000000..023f9ef6662 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswscope.c @@ -0,0 +1,311 @@ +/****************************************************************************** + * + * Module Name: dswscope - Scope stack manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWSCOPE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswscope") + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackClear + * + * PARAMETERS: WalkState - Current state + * + * RETURN: None + * + * DESCRIPTION: Pop (and free) everything on the scope stack except the + * root scope object (which remains at the stack top.) + * + ***************************************************************************/ + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + ACPI_FUNCTION_NAME (DsScopeStackClear); + + + while (WalkState->ScopeInfo) + { + /* Pop a scope off the stack */ + + ScopeInfo = WalkState->ScopeInfo; + WalkState->ScopeInfo = ScopeInfo->Scope.Next; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Popped object type (%s)\n", + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + AcpiUtDeleteGenericState (ScopeInfo); + } +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPush + * + * PARAMETERS: Node - Name to be made current + * Type - Type of frame being pushed + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Push the current scope on the scope stack, and make the + * passed Node current. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + ACPI_GENERIC_STATE *OldScopeInfo; + + + ACPI_FUNCTION_TRACE (DsScopeStackPush); + + + if (!Node) + { + /* Invalid scope */ + + ACPI_ERROR ((AE_INFO, "Null scope parameter")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Make sure object type is valid */ + + if (!AcpiUtValidObjectType (Type)) + { + ACPI_WARNING ((AE_INFO, + "Invalid object type: 0x%X", Type)); + } + + /* Allocate a new scope object */ + + ScopeInfo = AcpiUtCreateGenericState (); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init new scope object */ + + ScopeInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_WSCOPE; + ScopeInfo->Scope.Node = Node; + ScopeInfo->Common.Value = (UINT16) Type; + + WalkState->ScopeDepth++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth)); + + OldScopeInfo = WalkState->ScopeInfo; + if (OldScopeInfo) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[%4.4s] (%s)", + AcpiUtGetNodeName (OldScopeInfo->Scope.Node), + AcpiUtGetTypeName (OldScopeInfo->Common.Value))); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[\\___] (%s)", "ROOT")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + ", New scope -> [%4.4s] (%s)\n", + AcpiUtGetNodeName (ScopeInfo->Scope.Node), + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + + /* Push new scope object onto stack */ + + AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo); + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPop + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Pop the scope stack once. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + ACPI_GENERIC_STATE *NewScopeInfo; + + + ACPI_FUNCTION_TRACE (DsScopeStackPop); + + + /* + * Pop scope info object off the stack. + */ + ScopeInfo = AcpiUtPopGenericState (&WalkState->ScopeInfo); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_STACK_UNDERFLOW); + } + + WalkState->ScopeDepth--; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[%.2d] Popped scope [%4.4s] (%s), New scope -> ", + (UINT32) WalkState->ScopeDepth, + AcpiUtGetNodeName (ScopeInfo->Scope.Node), + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + + NewScopeInfo = WalkState->ScopeInfo; + if (NewScopeInfo) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[%4.4s] (%s)\n", + AcpiUtGetNodeName (NewScopeInfo->Scope.Node), + AcpiUtGetTypeName (NewScopeInfo->Common.Value))); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[\\___] (ROOT)\n")); + } + + AcpiUtDeleteGenericState (ScopeInfo); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswstate.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswstate.c new file mode 100644 index 00000000000..f0962bf53f1 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswstate.c @@ -0,0 +1,918 @@ +/****************************************************************************** + * + * Module Name: dswstate - Dispatcher parse tree walk management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __DSWSTATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswstate") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsResultStackPush ( + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultPop + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop an object off the top of this walk's result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + UINT32 Index; + ACPI_GENERIC_STATE *State; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (DsResultPop); + + + State = WalkState->Results; + + /* Incorrect state of result stack */ + + if (State && !WalkState->ResultCount) + { + ACPI_ERROR ((AE_INFO, "No results on result stack")); + return (AE_AML_INTERNAL); + } + + if (!State && WalkState->ResultCount) + { + ACPI_ERROR ((AE_INFO, "No result state for result stack")); + return (AE_AML_INTERNAL); + } + + /* Empty result stack */ + + if (!State) + { + ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", WalkState)); + return (AE_AML_NO_RETURN_VALUE); + } + + /* Return object of the top element and clean that top element result stack */ + + WalkState->ResultCount--; + Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + + *Object = State->Results.ObjDesc [Index]; + if (!*Object) + { + ACPI_ERROR ((AE_INFO, "No result objects on result stack, State=%p", + WalkState)); + return (AE_AML_NO_RETURN_VALUE); + } + + State->Results.ObjDesc [Index] = NULL; + if (Index == 0) + { + Status = AcpiDsResultStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object, + AcpiUtGetObjectTypeName (*Object), + Index, WalkState, WalkState->ResultCount)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultPush + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto the current result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultPush ( + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + ACPI_STATUS Status; + UINT32 Index; + + + ACPI_FUNCTION_NAME (DsResultPush); + + + if (WalkState->ResultCount > WalkState->ResultSize) + { + ACPI_ERROR ((AE_INFO, "Result stack is full")); + return (AE_AML_INTERNAL); + } + else if (WalkState->ResultCount == WalkState->ResultSize) + { + /* Extend the result stack */ + + Status = AcpiDsResultStackPush (WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Failed to extend the result stack")); + return (Status); + } + } + + if (!(WalkState->ResultCount < WalkState->ResultSize)) + { + ACPI_ERROR ((AE_INFO, "No free elements in result stack")); + return (AE_AML_INTERNAL); + } + + State = WalkState->Results; + if (!State) + { + ACPI_ERROR ((AE_INFO, "No result stack frame during push")); + return (AE_AML_INTERNAL); + } + + if (!Object) + { + ACPI_ERROR ((AE_INFO, + "Null Object! Obj=%p State=%p Num=%X", + Object, WalkState, WalkState->ResultCount)); + return (AE_BAD_PARAMETER); + } + + /* Assign the address of object to the top free element of result stack */ + + Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + State->Results.ObjDesc [Index] = Object; + WalkState->ResultCount++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), + WalkState, WalkState->ResultCount, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPush + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto the WalkState result stack + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsResultStackPush ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_NAME (DsResultStackPush); + + + /* Check for stack overflow */ + + if (((UINT32) WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) > + ACPI_RESULTS_OBJ_NUM_MAX) + { + ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%X", + WalkState, WalkState->ResultSize)); + return (AE_STACK_OVERFLOW); + } + + State = AcpiUtCreateGenericState (); + if (!State) + { + return (AE_NO_MEMORY); + } + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RESULT; + AcpiUtPushGenericState (&WalkState->Results, State); + + /* Increase the length of the result stack by the length of frame */ + + WalkState->ResultSize += ACPI_RESULTS_FRAME_OBJ_NUM; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", + State, WalkState)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPop + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop an object off of the WalkState result stack + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_NAME (DsResultStackPop); + + + /* Check for stack underflow */ + + if (WalkState->Results == NULL) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result stack underflow - State=%p\n", + WalkState)); + return (AE_AML_NO_OPERAND); + } + + if (WalkState->ResultSize < ACPI_RESULTS_FRAME_OBJ_NUM) + { + ACPI_ERROR ((AE_INFO, "Insufficient result stack size")); + return (AE_AML_INTERNAL); + } + + State = AcpiUtPopGenericState (&WalkState->Results); + AcpiUtDeleteGenericState (State); + + /* Decrease the length of result stack by the length of frame */ + + WalkState->ResultSize -= ACPI_RESULTS_FRAME_OBJ_NUM; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Result=%p RemainingResults=%X State=%p\n", + State, WalkState->ResultCount, WalkState)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPush + * + * PARAMETERS: Object - Object to push + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto this walk's object/operand stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME (DsObjStackPush); + + + /* Check for stack overflow */ + + if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS) + { + ACPI_ERROR ((AE_INFO, + "Object stack overflow! Obj=%p State=%p #Ops=%X", + Object, WalkState, WalkState->NumOperands)); + return (AE_STACK_OVERFLOW); + } + + /* Put the object onto the stack */ + + WalkState->Operands [WalkState->OperandIndex] = Object; + WalkState->NumOperands++; + + /* For the usual order of filling the operand stack */ + + WalkState->OperandIndex++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), + WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPop + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT + * deleted by this routine. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_NAME (DsObjStackPop); + + + for (i = 0; i < PopCount; i++) + { + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + ACPI_ERROR ((AE_INFO, + "Object stack underflow! Count=%X State=%p #Ops=%X", + PopCount, WalkState, WalkState->NumOperands)); + return (AE_STACK_UNDERFLOW); + } + + /* Just set the stack entry to null */ + + WalkState->NumOperands--; + WalkState->Operands [WalkState->NumOperands] = NULL; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopAndDelete + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack and delete each object that is + * popped off. + * + ******************************************************************************/ + +void +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState) +{ + INT32 i; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (DsObjStackPopAndDelete); + + + if (PopCount == 0) + { + return; + } + + for (i = (INT32) PopCount - 1; i >= 0; i--) + { + if (WalkState->NumOperands == 0) + { + return; + } + + /* Pop the stack and delete an object if present in this stack entry */ + + WalkState->NumOperands--; + ObjDesc = WalkState->Operands [i]; + if (ObjDesc) + { + AcpiUtRemoveReference (WalkState->Operands [i]); + WalkState->Operands [i] = NULL; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetCurrentWalkState + * + * PARAMETERS: Thread - Get current active state for this Thread + * + * RETURN: Pointer to the current walk state + * + * DESCRIPTION: Get the walk state that is at the head of the list (the "current" + * walk state.) + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsGetCurrentWalkState ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_FUNCTION_NAME (DsGetCurrentWalkState); + + + if (!Thread) + { + return (NULL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n", + Thread->WalkStateList)); + + return (Thread->WalkStateList); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPushWalkState + * + * PARAMETERS: WalkState - State to push + * Thread - Thread state object + * + * RETURN: None + * + * DESCRIPTION: Place the Thread state at the head of the state list + * + ******************************************************************************/ + +void +AcpiDsPushWalkState ( + ACPI_WALK_STATE *WalkState, + ACPI_THREAD_STATE *Thread) +{ + ACPI_FUNCTION_TRACE (DsPushWalkState); + + + WalkState->Next = Thread->WalkStateList; + Thread->WalkStateList = WalkState; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPopWalkState + * + * PARAMETERS: Thread - Current thread state + * + * RETURN: A WalkState object popped from the thread's stack + * + * DESCRIPTION: Remove and return the walkstate object that is at the head of + * the walk stack for the given walk list. NULL indicates that + * the list is empty. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsPopWalkState); + + + WalkState = Thread->WalkStateList; + + if (WalkState) + { + /* Next walk state becomes the current walk state */ + + Thread->WalkStateList = WalkState->Next; + + /* + * Don't clear the NEXT field, this serves as an indicator + * that there is a parent WALK STATE + * Do Not: WalkState->Next = NULL; + */ + } + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateWalkState + * + * PARAMETERS: OwnerId - ID for object creation + * Origin - Starting point for this walk + * MethodDesc - Method object + * Thread - Current thread state + * + * RETURN: Pointer to the new walk state. + * + * DESCRIPTION: Allocate and initialize a new walk state. The current walk + * state is set to this new state. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_THREAD_STATE *Thread) +{ + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsCreateWalkState); + + + WalkState = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE)); + if (!WalkState) + { + return_PTR (NULL); + } + + WalkState->DescriptorType = ACPI_DESC_TYPE_WALK; + WalkState->MethodDesc = MethodDesc; + WalkState->OwnerId = OwnerId; + WalkState->Origin = Origin; + WalkState->Thread = Thread; + + WalkState->ParserState.StartOp = Origin; + + /* Init the method args/local */ + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + AcpiDsMethodDataInit (WalkState); +#endif + + /* Put the new state at the head of the walk list */ + + if (Thread) + { + AcpiDsPushWalkState (WalkState, Thread); + } + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitAmlWalk + * + * PARAMETERS: WalkState - New state to be initialized + * Op - Current parse op + * MethodNode - Control method NS node, if any + * AmlStart - Start of AML + * AmlLength - Length of AML + * Info - Method info block (params, etc.) + * PassNumber - 1, 2, or 3 + * + * RETURN: Status + * + * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitAmlWalk ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *MethodNode, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_EVALUATE_INFO *Info, + UINT8 PassNumber) +{ + ACPI_STATUS Status; + ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; + ACPI_PARSE_OBJECT *ExtraOp; + + + ACPI_FUNCTION_TRACE (DsInitAmlWalk); + + + WalkState->ParserState.Aml = + WalkState->ParserState.AmlStart = AmlStart; + WalkState->ParserState.AmlEnd = + WalkState->ParserState.PkgEnd = AmlStart + AmlLength; + + /* The NextOp of the NextWalk will be the beginning of the method */ + + WalkState->NextOp = NULL; + WalkState->PassNumber = PassNumber; + + if (Info) + { + WalkState->Params = Info->Parameters; + WalkState->CallerReturnDesc = &Info->ReturnObject; + } + + Status = AcpiPsInitScope (&WalkState->ParserState, Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (MethodNode) + { + WalkState->ParserState.StartNode = MethodNode; + WalkState->WalkType = ACPI_WALK_METHOD; + WalkState->MethodNode = MethodNode; + WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); + + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Init the method arguments */ + + Status = AcpiDsMethodDataInitArgs (WalkState->Params, + ACPI_METHOD_NUM_ARGS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* + * Setup the current scope. + * Find a Named Op that has a namespace node associated with it. + * search upwards from this Op. Current scope is the first + * Op with a namespace node. + */ + ExtraOp = ParserState->StartOp; + while (ExtraOp && !ExtraOp->Common.Node) + { + ExtraOp = ExtraOp->Common.Parent; + } + + if (!ExtraOp) + { + ParserState->StartNode = NULL; + } + else + { + ParserState->StartNode = ExtraOp->Common.Node; + } + + if (ParserState->StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (ParserState->StartNode, + ParserState->StartNode->Type, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + Status = AcpiDsInitCallbacks (WalkState, PassNumber); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDeleteWalkState + * + * PARAMETERS: WalkState - State to delete + * + * RETURN: Status + * + * DESCRIPTION: Delete a walk state including all internal data structures + * + ******************************************************************************/ + +void +AcpiDsDeleteWalkState ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (DsDeleteWalkState, WalkState); + + + if (!WalkState) + { + return; + } + + if (WalkState->DescriptorType != ACPI_DESC_TYPE_WALK) + { + ACPI_ERROR ((AE_INFO, "%p is not a valid walk state", + WalkState)); + return; + } + + /* There should not be any open scopes */ + + if (WalkState->ParserState.Scope) + { + ACPI_ERROR ((AE_INFO, "%p walk still has a scope list", + WalkState)); + AcpiPsCleanupScope (&WalkState->ParserState); + } + + /* Always must free any linked control states */ + + while (WalkState->ControlState) + { + State = WalkState->ControlState; + WalkState->ControlState = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + /* Always must free any linked parse states */ + + while (WalkState->ScopeInfo) + { + State = WalkState->ScopeInfo; + WalkState->ScopeInfo = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + /* Always must free any stacked result states */ + + while (WalkState->Results) + { + State = WalkState->Results; + WalkState->Results = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + ACPI_FREE (WalkState); + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evevent.c b/reactos/drivers/bus/acpi/acpica/events/evevent.c new file mode 100644 index 00000000000..16f40271fcf --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evevent.c @@ -0,0 +1,430 @@ +/****************************************************************************** + * + * Module Name: evevent - Fixed Event handling and dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evevent") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvFixedEventInitialize ( + void); + +static UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeEvents + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeEvents ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInitializeEvents); + + + /* + * Initialize the Fixed and General Purpose Events. This is done prior to + * enabling SCIs to prevent interrupts from occurring before the handlers + * are installed. + */ + Status = AcpiEvFixedEventInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize fixed events")); + return_ACPI_STATUS (Status); + } + + Status = AcpiEvGpeInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize general purpose events")); + return_ACPI_STATUS (Status); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallFadtGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks + * (0 and 1). This causes the _PRW methods to be run, so the HW + * must be fully initialized at this point, including global lock + * support. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallFadtGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInstallFadtGpes); + + + /* Namespace must be locked */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* FADT GPE Block 0 */ + + (void) AcpiEvInitializeGpeBlock ( + AcpiGbl_FadtGpeDevice, AcpiGbl_GpeFadtBlocks[0]); + + /* FADT GPE Block 1 */ + + (void) AcpiEvInitializeGpeBlock ( + AcpiGbl_FadtGpeDevice, AcpiGbl_GpeFadtBlocks[1]); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallXruptHandlers + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install interrupt handlers for the SCI and Global Lock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallXruptHandlers ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInstallXruptHandlers); + + + /* Install the SCI handler */ + + Status = AcpiEvInstallSciHandler (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to install System Control Interrupt handler")); + return_ACPI_STATUS (Status); + } + + /* Install the handler for the Global Lock */ + + Status = AcpiEvInitGlobalLockHandler (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize Global Lock handler")); + return_ACPI_STATUS (Status); + } + + AcpiGbl_EventsInitialized = TRUE; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install the fixed event handlers and disable all fixed events. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvFixedEventInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* + * Initialize the structure that keeps track of fixed event handlers and + * enable the fixed events. + */ + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + AcpiGbl_FixedEventHandlers[i].Handler = NULL; + AcpiGbl_FixedEventHandlers[i].Context = NULL; + + /* Disable the fixed event */ + + if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) + { + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[i].EnableRegisterId, + ACPI_DISABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventDetect + * + * PARAMETERS: None + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Checks the PM status register for active fixed events + * + ******************************************************************************/ + +UINT32 +AcpiEvFixedEventDetect ( + void) +{ + UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; + UINT32 FixedStatus; + UINT32 FixedEnable; + UINT32 i; + + + ACPI_FUNCTION_NAME (EvFixedEventDetect); + + + /* + * Read the fixed feature status and enable registers, as all the cases + * depend on their values. Ignore errors here. + */ + (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_STATUS, &FixedStatus); + (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_ENABLE, &FixedEnable); + + ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, + "Fixed Event Block: Enable %08X Status %08X\n", + FixedEnable, FixedStatus)); + + /* + * Check for all possible Fixed Events and dispatch those that are active + */ + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + /* Both the status and enable bits must be on for this event */ + + if ((FixedStatus & AcpiGbl_FixedEventInfo[i].StatusBitMask) && + (FixedEnable & AcpiGbl_FixedEventInfo[i].EnableBitMask)) + { + /* Found an active (signalled) event */ + + AcpiFixedEventCount[i]++; + IntStatus |= AcpiEvFixedEventDispatch (i); + } + } + + return (IntStatus); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventDispatch + * + * PARAMETERS: Event - Event type + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Clears the status bit for the requested event, calls the + * handler that previously registered for the event. + * + ******************************************************************************/ + +static UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* Clear the status bit */ + + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); + + /* + * Make sure we've got a handler. If not, report an error. The event is + * disabled to prevent further interrupts. + */ + if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler) + { + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); + + ACPI_ERROR ((AE_INFO, + "No installed handler for fixed event [%08X]", + Event)); + + return (ACPI_INTERRUPT_NOT_HANDLED); + } + + /* Invoke the Fixed Event handler */ + + return ((AcpiGbl_FixedEventHandlers[Event].Handler)( + AcpiGbl_FixedEventHandlers[Event].Context)); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evgpe.c b/reactos/drivers/bus/acpi/acpica/events/evgpe.c new file mode 100644 index 00000000000..17738b38404 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evgpe.c @@ -0,0 +1,897 @@ +/****************************************************************************** + * + * Module Name: evgpe - General Purpose Event handling and dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpe") + +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchExecuteGpeMethod ( + void *Context); + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchEnableGpe ( + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSetGpeType + * + * PARAMETERS: GpeEventInfo - GPE to set + * Type - New type + * + * RETURN: Status + * + * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvSetGpeType); + + + /* Validate type and update register enable masks */ + + switch (Type) + { + case ACPI_GPE_TYPE_WAKE: + case ACPI_GPE_TYPE_RUNTIME: + case ACPI_GPE_TYPE_WAKE_RUN: + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the GPE if currently enabled */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + + /* Clear the type bits and insert the new Type */ + + GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; + GpeEventInfo->Flags |= Type; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvUpdateGpeEnableMasks + * + * PARAMETERS: GpeEventInfo - GPE to update + * Type - What to do: ACPI_GPE_DISABLE or + * ACPI_GPE_ENABLE + * + * RETURN: Status + * + * DESCRIPTION: Updates GPE register enable masks based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT8 RegisterBit; + + + ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMasks); + + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + RegisterBit = (UINT8) + (1 << (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)); + + /* 1) Disable case. Simply clear all enable bits */ + + if (Type == ACPI_GPE_DISABLE) + { + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + return_ACPI_STATUS (AE_OK); + } + + /* 2) Enable case. Set/Clear the appropriate enable bits */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + case ACPI_GPE_TYPE_RUNTIME: + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvEnableGpe + * + * PARAMETERS: GpeEventInfo - GPE to enable + * WriteToHardware - Enable now, or just mark data structs + * (WAKE GPEs should be deferred) + * + * RETURN: Status + * + * DESCRIPTION: Enable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvEnableGpe); + + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_ENABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mark wake-enabled or HW enable, or both */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); + + if (WriteToHardware) + { + /* Clear the GPE (of stale events), then enable it */ + + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Enable the requested runtime GPE */ + + Status = AcpiHwWriteGpeEnableReg (GpeEventInfo); + } + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDisableGpe + * + * PARAMETERS: GpeEventInfo - GPE to disable + * + * RETURN: Status + * + * DESCRIPTION: Disable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvDisableGpe); + + + /* + * Note: Always disable the GPE, even if we think that that it is already + * disabled. It is possible that the AML or some other code has enabled + * the GPE behind our back. + */ + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Clear the appropriate enabled flags for this GPE */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + /* Disable the requested runtime GPE */ + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); + break; + + default: + break; + } + + /* + * Always H/W disable this GPE, even if we don't know the GPE type. + * Simply clear the enable bit for this particular GPE, but do not + * write out the current GPE enable mask since this may inadvertently + * enable GPEs too early. An example is a rogue GPE that has arrived + * during ACPICA initialization - possibly because AML or other code + * has enabled the GPE. + */ + Status = AcpiHwLowDisableGpe (GpeEventInfo); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeEventInfo + * + * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1 + * GpeNumber - Raw GPE number + * + * RETURN: A GPE EventInfo struct. NULL if not a valid GPE + * + * DESCRIPTION: Returns the EventInfo struct associated with this GPE. + * Validates the GpeBlock and the GpeNumber + * + * Should be called only when the GPE lists are semaphore locked + * and not subject to change. + * + ******************************************************************************/ + +ACPI_GPE_EVENT_INFO * +AcpiEvGetGpeEventInfo ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_GPE_BLOCK_INFO *GpeBlock; + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + /* A NULL GpeBlock means use the FADT-defined GPE block(s) */ + + if (!GpeDevice) + { + /* Examine GPE Block 0 and 1 (These blocks are permanent) */ + + for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) + { + GpeBlock = AcpiGbl_GpeFadtBlocks[i]; + if (GpeBlock) + { + if ((GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8))) + { + return (&GpeBlock->EventInfo[GpeNumber - + GpeBlock->BlockBaseNumber]); + } + } + } + + /* The GpeNumber was not in the range of either FADT GPE block */ + + return (NULL); + } + + /* A Non-NULL GpeDevice means this is a GPE Block Device */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) GpeDevice); + if (!ObjDesc || + !ObjDesc->Device.GpeBlock) + { + return (NULL); + } + + GpeBlock = ObjDesc->Device.GpeBlock; + + if ((GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) + { + return (&GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]); + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeDetect + * + * PARAMETERS: GpeXruptList - Interrupt block for this interrupt. + * Can have multiple GPE blocks attached. + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Detect if any GP events have occurred. This function is + * executed at interrupt level. + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDetect ( + ACPI_GPE_XRUPT_INFO *GpeXruptList) +{ + ACPI_STATUS Status; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; + UINT8 EnabledStatusByte; + UINT32 StatusReg; + UINT32 EnableReg; + ACPI_CPU_FLAGS Flags; + UINT32 i; + UINT32 j; + + + ACPI_FUNCTION_NAME (EvGpeDetect); + + /* Check for the case where there are no GPEs */ + + if (!GpeXruptList) + { + return (IntStatus); + } + + /* + * We need to obtain the GPE lock for both the data structs and registers + * Note: Not necessary to obtain the hardware lock, since the GPE + * registers are owned by the GpeLock. + */ + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Examine all GPE blocks attached to this interrupt level */ + + GpeBlock = GpeXruptList->GpeBlockListHead; + while (GpeBlock) + { + /* + * Read all of the 8-bit GPE status and enable registers in this GPE + * block, saving all of them. Find all currently active GP events. + */ + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Get the next status/enable pair */ + + GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; + + /* Read the Status Register */ + + Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Read the Enable Register */ + + Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, + "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", + GpeRegisterInfo->BaseGpeNumber, StatusReg, EnableReg)); + + /* Check if there is anything active at all in this register */ + + EnabledStatusByte = (UINT8) (StatusReg & EnableReg); + if (!EnabledStatusByte) + { + /* No active GPEs in this register, move on */ + + continue; + } + + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + /* Examine one GPE bit */ + + if (EnabledStatusByte & (1 << j)) + { + /* + * Found an active GPE. Dispatch the event to a handler + * or method. + */ + IntStatus |= AcpiEvGpeDispatch ( + &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j], + j + GpeRegisterInfo->BaseGpeNumber); + } + } + } + + GpeBlock = GpeBlock->Next; + } + +UnlockAndExit: + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return (IntStatus); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAsynchExecuteGpeMethod + * + * PARAMETERS: Context (GpeEventInfo) - Info for this GPE + * + * RETURN: None + * + * DESCRIPTION: Perform the actual execution of a GPE control method. This + * function is called from an invocation of AcpiOsExecute and + * therefore does NOT execute at interrupt level - so that + * the control method itself is not executed in the context of + * an interrupt handler. + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchExecuteGpeMethod ( + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo = Context; + ACPI_STATUS Status; + ACPI_GPE_EVENT_INFO *LocalGpeEventInfo; + ACPI_EVALUATE_INFO *Info; + + + ACPI_FUNCTION_TRACE (EvAsynchExecuteGpeMethod); + + + /* Allocate a local GPE block */ + + LocalGpeEventInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_EVENT_INFO)); + if (!LocalGpeEventInfo) + { + ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, + "while handling a GPE")); + return_VOID; + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Must revalidate the GpeNumber/GpeBlock */ + + if (!AcpiEvValidGpeEvent (GpeEventInfo)) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_VOID; + } + + /* Set the GPE flags for return to enabled state */ + + (void) AcpiEvEnableGpe (GpeEventInfo, FALSE); + + /* + * Take a snapshot of the GPE info for this level - we copy the info to + * prevent a race condition with RemoveHandler/RemoveBlock. + */ + ACPI_MEMCPY (LocalGpeEventInfo, GpeEventInfo, + sizeof (ACPI_GPE_EVENT_INFO)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* + * Must check for control method type dispatch one more time to avoid a + * race with EvGpeInstallHandler + */ + if ((LocalGpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) + { + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + Status = AE_NO_MEMORY; + } + else + { + /* + * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx + * control method that corresponds to this GPE + */ + Info->PrefixNode = LocalGpeEventInfo->Dispatch.MethodNode; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info); + ACPI_FREE (Info); + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "while evaluating GPE method [%4.4s]", + AcpiUtGetNodeName (LocalGpeEventInfo->Dispatch.MethodNode))); + } + } + + /* Defer enabling of GPE until all notify handlers are done */ + + Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, + AcpiEvAsynchEnableGpe, LocalGpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (LocalGpeEventInfo); + } + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAsynchEnableGpe + * + * PARAMETERS: Context (GpeEventInfo) - Info for this GPE + * + * RETURN: None + * + * DESCRIPTION: Asynchronous clear/enable for GPE. This allows the GPE to + * complete (i.e., finish execution of Notify) + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchEnableGpe ( + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo = Context; + ACPI_STATUS Status; + + + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) + { + /* + * GPE is level-triggered, we clear the GPE status bit after handling + * the event. + */ + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + + /* Enable this GPE */ + + (void) AcpiHwWriteGpeEnableReg (GpeEventInfo); + +Exit: + ACPI_FREE (GpeEventInfo); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeDispatch + * + * PARAMETERS: GpeEventInfo - Info for this GPE + * GpeNumber - Number relative to the parent GPE block + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC) + * or method (e.g. _Lxx/_Exx) handler. + * + * This function executes at interrupt level. + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDispatch ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT32 GpeNumber) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvGpeDispatch); + + + AcpiGpeCount++; + + /* + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced. + */ + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_EDGE_TRIGGERED) + { + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to clear GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + } + + /* + * Dispatch the GPE to either an installed handler, or the control method + * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke + * it and do not attempt to run the method. If there is neither a handler + * nor a method, we disable this GPE to prevent further such pointless + * events from firing. + */ + switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) + { + case ACPI_GPE_DISPATCH_HANDLER: + + /* + * Invoke the installed handler (at interrupt level) + * Ignore return status for now. + * TBD: leave GPE disabled on error? + */ + (void) GpeEventInfo->Dispatch.Handler->Address ( + GpeEventInfo->Dispatch.Handler->Context); + + /* It is now safe to clear level-triggered events. */ + + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) + { + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to clear GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + } + break; + + case ACPI_GPE_DISPATCH_METHOD: + + /* + * Disable the GPE, so it doesn't keep firing before the method has a + * chance to run (it runs asynchronously with interrupts enabled). + */ + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to disable GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + + /* + * Execute the method associated with the GPE + * NOTE: Level-triggered GPEs are cleared after the method completes. + */ + Status = AcpiOsExecute (OSL_GPE_HANDLER, + AcpiEvAsynchExecuteGpeMethod, GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to queue handler for GPE[%2X] - event disabled", + GpeNumber)); + } + break; + + default: + + /* No handler or method to run! */ + + ACPI_ERROR ((AE_INFO, + "No handler or method for GPE[%2X], disabling event", + GpeNumber)); + + /* + * Disable the GPE. The GPE will remain disabled until the ACPICA + * Core Subsystem is restarted, or a handler is installed. + */ + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to disable GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + break; + } + + return_UINT32 (ACPI_INTERRUPT_HANDLED); +} + diff --git a/reactos/drivers/bus/acpi/acpica/events/evgpeblk.c b/reactos/drivers/bus/acpi/acpica/events/evgpeblk.c new file mode 100644 index 00000000000..c86f80aa7f5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evgpeblk.c @@ -0,0 +1,1402 @@ +/****************************************************************************** + * + * Module Name: evgpeblk - GPE block creation and initialization. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpeblk") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvSaveMethodInfo ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Info, + void **ReturnValue); + +static ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber); + +static ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt); + +static ACPI_STATUS +AcpiEvInstallGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock, + UINT32 InterruptNumber); + +static ACPI_STATUS +AcpiEvCreateGpeInfoBlocks ( + ACPI_GPE_BLOCK_INFO *GpeBlock); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvValidGpeEvent + * + * PARAMETERS: GpeEventInfo - Info for this GPE + * + * RETURN: TRUE if the GpeEvent is valid + * + * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. + * Should be called only when the GPE lists are semaphore locked + * and not subject to change. + * + ******************************************************************************/ + +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptBlock; + ACPI_GPE_BLOCK_INFO *GpeBlock; + + + ACPI_FUNCTION_ENTRY (); + + + /* No need for spin lock since we are not changing any list elements */ + + /* Walk the GPE interrupt levels */ + + GpeXruptBlock = AcpiGbl_GpeXruptListHead; + while (GpeXruptBlock) + { + GpeBlock = GpeXruptBlock->GpeBlockListHead; + + /* Walk the GPE blocks on this interrupt level */ + + while (GpeBlock) + { + if ((&GpeBlock->EventInfo[0] <= GpeEventInfo) && + (&GpeBlock->EventInfo[((ACPI_SIZE) + GpeBlock->RegisterCount) * 8] > GpeEventInfo)) + { + return (TRUE); + } + + GpeBlock = GpeBlock->Next; + } + + GpeXruptBlock = GpeXruptBlock->Next; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvWalkGpeList + * + * PARAMETERS: GpeWalkCallback - Routine called for each GPE block + * Context - Value passed to callback + * + * RETURN: Status + * + * DESCRIPTION: Walk the GPE lists. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context) +{ + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_STATUS Status = AE_OK; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvWalkGpeList); + + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Walk the interrupt level descriptor list */ + + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) + { + /* Walk all Gpe Blocks attached to this interrupt level */ + + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) + { + /* One callback per GPE block */ + + Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_END) /* Callback abort */ + { + Status = AE_OK; + } + goto UnlockAndExit; + } + + GpeBlock = GpeBlock->Next; + } + + GpeXruptInfo = GpeXruptInfo->Next; + } + +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDeleteGpeHandlers + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Delete all Handler objects found in the GPE data structs. + * Used only prior to termination. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + UINT32 i; + UINT32 j; + + + ACPI_FUNCTION_TRACE (EvDeleteGpeHandlers); + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j]; + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + ACPI_FREE (GpeEventInfo->Dispatch.Handler); + GpeEventInfo->Dispatch.Handler = NULL; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; + } + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSaveMethodInfo + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * control method under the _GPE portion of the namespace. + * Extract the name and GPE type from the object, saving this + * information for quick lookup during GPE dispatch + * + * The name of each GPE control method is of the form: + * "_Lxx" or "_Exx" + * Where: + * L - means that the GPE is level triggered + * E - means that the GPE is edge triggered + * xx - is the GPE number [in HEX] + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvSaveMethodInfo ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc, + void **ReturnValue) +{ + ACPI_GPE_BLOCK_INFO *GpeBlock = (void *) ObjDesc; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + UINT32 GpeNumber; + char Name[ACPI_NAME_SIZE + 1]; + UINT8 Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvSaveMethodInfo); + + + /* + * _Lxx and _Exx GPE method support + * + * 1) Extract the name from the object and convert to a string + */ + ACPI_MOVE_32_TO_32 ( + Name, &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Integer); + Name[ACPI_NAME_SIZE] = 0; + + /* + * 2) Edge/Level determination is based on the 2nd character + * of the method name + * + * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE + * if a _PRW object is found that points to this GPE. + */ + switch (Name[1]) + { + case 'L': + Type = ACPI_GPE_LEVEL_TRIGGERED; + break; + + case 'E': + Type = ACPI_GPE_EDGE_TRIGGERED; + break; + + default: + /* Unknown method type, just ignore it! */ + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Ignoring unknown GPE method type: %s " + "(name not of form _Lxx or _Exx)", + Name)); + return_ACPI_STATUS (AE_OK); + } + + /* Convert the last two characters of the name to the GPE Number */ + + GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); + if (GpeNumber == ACPI_UINT32_MAX) + { + /* Conversion failed; invalid method, just ignore it */ + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Could not extract GPE number from name: %s " + "(name is not of form _Lxx or _Exx)", + Name)); + return_ACPI_STATUS (AE_OK); + } + + /* Ensure that we have a valid GPE number for this GPE block */ + + if ((GpeNumber < GpeBlock->BlockBaseNumber) || + (GpeNumber >= (GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8)))) + { + /* + * Not valid for this GPE block, just ignore it. However, it may be + * valid for a different GPE block, since GPE0 and GPE1 methods both + * appear under \_GPE. + */ + return_ACPI_STATUS (AE_OK); + } + + /* + * Now we can add this information to the GpeEventInfo block for use + * during dispatch of this GPE. Default type is RUNTIME, although this may + * change when the _PRW methods are executed later. + */ + GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; + + GpeEventInfo->Flags = (UINT8) + (Type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME); + + GpeEventInfo->Dispatch.MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle; + + /* Update enable mask, but don't enable the HW GPE as of yet */ + + Status = AcpiEvEnableGpe (GpeEventInfo, FALSE); + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Registered GPE method %s as GPE number 0x%.2X\n", + Name, GpeNumber)); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvMatchPrwAndGpe + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is + * not aborted on a single _PRW failure. + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * Device. Run the _PRW method. If present, extract the GPE + * number and mark the GPE as a WAKE GPE. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Info, + void **ReturnValue) +{ + ACPI_GPE_WALK_INFO *GpeInfo = (void *) Info; + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_NAMESPACE_NODE *TargetGpeDevice; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_OPERAND_OBJECT *PkgDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 GpeNumber; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvMatchPrwAndGpe); + + + /* Check for a _PRW method under this device */ + + Status = AcpiUtEvaluateObject (ObjHandle, METHOD_NAME__PRW, + ACPI_BTYPE_PACKAGE, &PkgDesc); + if (ACPI_FAILURE (Status)) + { + /* Ignore all errors from _PRW, we don't want to abort the subsystem */ + + return_ACPI_STATUS (AE_OK); + } + + /* The returned _PRW package must have at least two elements */ + + if (PkgDesc->Package.Count < 2) + { + goto Cleanup; + } + + /* Extract pointers from the input context */ + + GpeDevice = GpeInfo->GpeDevice; + GpeBlock = GpeInfo->GpeBlock; + + /* + * The _PRW object must return a package, we are only interested in the + * first element + */ + ObjDesc = PkgDesc->Package.Elements[0]; + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + /* Use FADT-defined GPE device (from definition of _PRW) */ + + TargetGpeDevice = AcpiGbl_FadtGpeDevice; + + /* Integer is the GPE number in the FADT described GPE blocks */ + + GpeNumber = (UINT32) ObjDesc->Integer.Value; + } + else if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + /* Package contains a GPE reference and GPE number within a GPE block */ + + if ((ObjDesc->Package.Count < 2) || + ((ObjDesc->Package.Elements[0])->Common.Type != + ACPI_TYPE_LOCAL_REFERENCE) || + ((ObjDesc->Package.Elements[1])->Common.Type != + ACPI_TYPE_INTEGER)) + { + goto Cleanup; + } + + /* Get GPE block reference and decode */ + + TargetGpeDevice = ObjDesc->Package.Elements[0]->Reference.Node; + GpeNumber = (UINT32) ObjDesc->Package.Elements[1]->Integer.Value; + } + else + { + /* Unknown type, just ignore it */ + + goto Cleanup; + } + + /* + * Is this GPE within this block? + * + * TRUE if and only if these conditions are true: + * 1) The GPE devices match. + * 2) The GPE index(number) is within the range of the Gpe Block + * associated with the GPE device. + */ + if ((GpeDevice == TargetGpeDevice) && + (GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8))) + { + GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - + GpeBlock->BlockBaseNumber]; + + /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); + + Status = AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); + } + +Cleanup: + AcpiUtRemoveReference (PkgDesc); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeXruptBlock + * + * PARAMETERS: InterruptNumber - Interrupt for a GPE block + * + * RETURN: A GPE interrupt block + * + * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt + * block per unique interrupt level used for GPEs. Should be + * called only when the GPE lists are semaphore locked and not + * subject to change. + * + ******************************************************************************/ + +static ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber) +{ + ACPI_GPE_XRUPT_INFO *NextGpeXrupt; + ACPI_GPE_XRUPT_INFO *GpeXrupt; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock); + + + /* No need for lock since we are not changing any list elements here */ + + NextGpeXrupt = AcpiGbl_GpeXruptListHead; + while (NextGpeXrupt) + { + if (NextGpeXrupt->InterruptNumber == InterruptNumber) + { + return_PTR (NextGpeXrupt); + } + + NextGpeXrupt = NextGpeXrupt->Next; + } + + /* Not found, must allocate a new xrupt descriptor */ + + GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); + if (!GpeXrupt) + { + return_PTR (NULL); + } + + GpeXrupt->InterruptNumber = InterruptNumber; + + /* Install new interrupt descriptor with spin lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (AcpiGbl_GpeXruptListHead) + { + NextGpeXrupt = AcpiGbl_GpeXruptListHead; + while (NextGpeXrupt->Next) + { + NextGpeXrupt = NextGpeXrupt->Next; + } + + NextGpeXrupt->Next = GpeXrupt; + GpeXrupt->Previous = NextGpeXrupt; + } + else + { + AcpiGbl_GpeXruptListHead = GpeXrupt; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Install new interrupt handler if not SCI_INT */ + + if (InterruptNumber != AcpiGbl_FADT.SciInterrupt) + { + Status = AcpiOsInstallInterruptHandler (InterruptNumber, + AcpiEvGpeXruptHandler, GpeXrupt); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not install GPE interrupt handler at level 0x%X", + InterruptNumber)); + return_PTR (NULL); + } + } + + return_PTR (GpeXrupt); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDeleteGpeXrupt + * + * PARAMETERS: GpeXrupt - A GPE interrupt info block + * + * RETURN: Status + * + * DESCRIPTION: Remove and free a GpeXrupt block. Remove an associated + * interrupt handler if not the SCI interrupt. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt); + + + /* We never want to remove the SCI interrupt handler */ + + if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt) + { + GpeXrupt->GpeBlockListHead = NULL; + return_ACPI_STATUS (AE_OK); + } + + /* Disable this interrupt */ + + Status = AcpiOsRemoveInterruptHandler ( + GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Unlink the interrupt block with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeXrupt->Previous) + { + GpeXrupt->Previous->Next = GpeXrupt->Next; + } + else + { + /* No previous, update list head */ + + AcpiGbl_GpeXruptListHead = GpeXrupt->Next; + } + + if (GpeXrupt->Next) + { + GpeXrupt->Next->Previous = GpeXrupt->Previous; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Free the block */ + + ACPI_FREE (GpeXrupt); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallGpeBlock + * + * PARAMETERS: GpeBlock - New GPE block + * InterruptNumber - Xrupt to be associated with this + * GPE block + * + * RETURN: Status + * + * DESCRIPTION: Install new GPE block with mutex support + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvInstallGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock, + UINT32 InterruptNumber) +{ + ACPI_GPE_BLOCK_INFO *NextGpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptBlock; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvInstallGpeBlock); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptNumber); + if (!GpeXruptBlock) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Install the new block at the end of the list with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeXruptBlock->GpeBlockListHead) + { + NextGpeBlock = GpeXruptBlock->GpeBlockListHead; + while (NextGpeBlock->Next) + { + NextGpeBlock = NextGpeBlock->Next; + } + + NextGpeBlock->Next = GpeBlock; + GpeBlock->Previous = NextGpeBlock; + } + else + { + GpeXruptBlock->GpeBlockListHead = GpeBlock; + } + + GpeBlock->XruptBlock = GpeXruptBlock; + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDeleteGpeBlock + * + * PARAMETERS: GpeBlock - Existing GPE block + * + * RETURN: Status + * + * DESCRIPTION: Remove a GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDeleteGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvInstallGpeBlock); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Disable all GPEs in this block */ + + Status = AcpiHwDisableGpeBlock (GpeBlock->XruptBlock, GpeBlock, NULL); + + if (!GpeBlock->Previous && !GpeBlock->Next) + { + /* This is the last GpeBlock on this interrupt */ + + Status = AcpiEvDeleteGpeXrupt (GpeBlock->XruptBlock); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + else + { + /* Remove the block on this interrupt with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeBlock->Previous) + { + GpeBlock->Previous->Next = GpeBlock->Next; + } + else + { + GpeBlock->XruptBlock->GpeBlockListHead = GpeBlock->Next; + } + + if (GpeBlock->Next) + { + GpeBlock->Next->Previous = GpeBlock->Previous; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + } + + AcpiCurrentGpeCount -= GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH; + + /* Free the GpeBlock */ + + ACPI_FREE (GpeBlock->RegisterInfo); + ACPI_FREE (GpeBlock->EventInfo); + ACPI_FREE (GpeBlock); + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCreateGpeInfoBlocks + * + * PARAMETERS: GpeBlock - New GPE block + * + * RETURN: Status + * + * DESCRIPTION: Create the RegisterInfo and EventInfo blocks for this GPE block + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvCreateGpeInfoBlocks ( + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo = NULL; + ACPI_GPE_EVENT_INFO *GpeEventInfo = NULL; + ACPI_GPE_EVENT_INFO *ThisEvent; + ACPI_GPE_REGISTER_INFO *ThisRegister; + UINT32 i; + UINT32 j; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvCreateGpeInfoBlocks); + + + /* Allocate the GPE register information block */ + + GpeRegisterInfo = ACPI_ALLOCATE_ZEROED ( + (ACPI_SIZE) GpeBlock->RegisterCount * + sizeof (ACPI_GPE_REGISTER_INFO)); + if (!GpeRegisterInfo) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate the GpeRegisterInfo table")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Allocate the GPE EventInfo block. There are eight distinct GPEs + * per register. Initialization to zeros is sufficient. + */ + GpeEventInfo = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) GpeBlock->RegisterCount * + ACPI_GPE_REGISTER_WIDTH) * + sizeof (ACPI_GPE_EVENT_INFO)); + if (!GpeEventInfo) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate the GpeEventInfo table")); + Status = AE_NO_MEMORY; + goto ErrorExit; + } + + /* Save the new Info arrays in the GPE block */ + + GpeBlock->RegisterInfo = GpeRegisterInfo; + GpeBlock->EventInfo = GpeEventInfo; + + /* + * Initialize the GPE Register and Event structures. A goal of these + * tables is to hide the fact that there are two separate GPE register + * sets in a given GPE hardware block, the status registers occupy the + * first half, and the enable registers occupy the second half. + */ + ThisRegister = GpeRegisterInfo; + ThisEvent = GpeEventInfo; + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Init the RegisterInfo for this GPE register (8 GPEs) */ + + ThisRegister->BaseGpeNumber = (UINT8) (GpeBlock->BlockBaseNumber + + (i * ACPI_GPE_REGISTER_WIDTH)); + + ThisRegister->StatusAddress.Address = + GpeBlock->BlockAddress.Address + i; + + ThisRegister->EnableAddress.Address = + GpeBlock->BlockAddress.Address + i + GpeBlock->RegisterCount; + + ThisRegister->StatusAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->EnableAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->StatusAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->EnableAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->StatusAddress.BitOffset = 0; + ThisRegister->EnableAddress.BitOffset = 0; + + /* Init the EventInfo for each GPE within this register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + ThisEvent->GpeNumber = (UINT8) (ThisRegister->BaseGpeNumber + j); + ThisEvent->RegisterInfo = ThisRegister; + ThisEvent++; + } + + /* Disable all GPEs within this register */ + + Status = AcpiHwWrite (0x00, &ThisRegister->EnableAddress); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Clear any pending GPE events within this register */ + + Status = AcpiHwWrite (0xFF, &ThisRegister->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ThisRegister++; + } + + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + if (GpeRegisterInfo) + { + ACPI_FREE (GpeRegisterInfo); + } + if (GpeEventInfo) + { + ACPI_FREE (GpeEventInfo); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCreateGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE block + * GpeBlockAddress - Address and SpaceID + * RegisterCount - Number of GPE register pairs in the block + * GpeBlockBaseNumber - Starting GPE number for the block + * InterruptNumber - H/W interrupt for the block + * ReturnGpeBlock - Where the new block descriptor is returned + * + * RETURN: Status + * + * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within + * the block are disabled at exit. + * Note: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvCreateGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT8 GpeBlockBaseNumber, + UINT32 InterruptNumber, + ACPI_GPE_BLOCK_INFO **ReturnGpeBlock) +{ + ACPI_STATUS Status; + ACPI_GPE_BLOCK_INFO *GpeBlock; + + + ACPI_FUNCTION_TRACE (EvCreateGpeBlock); + + + if (!RegisterCount) + { + return_ACPI_STATUS (AE_OK); + } + + /* Allocate a new GPE block */ + + GpeBlock = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_BLOCK_INFO)); + if (!GpeBlock) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new GPE block */ + + GpeBlock->Node = GpeDevice; + GpeBlock->RegisterCount = RegisterCount; + GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; + + ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, + sizeof (ACPI_GENERIC_ADDRESS)); + + /* + * Create the RegisterInfo and EventInfo sub-structures + * Note: disables and clears all GPEs in the block + */ + Status = AcpiEvCreateGpeInfoBlocks (GpeBlock); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (GpeBlock); + return_ACPI_STATUS (Status); + } + + /* Install the new block in the global lists */ + + Status = AcpiEvInstallGpeBlock (GpeBlock, InterruptNumber); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (GpeBlock); + return_ACPI_STATUS (Status); + } + + /* Find all GPE methods (_Lxx, _Exx) for this block */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiEvSaveMethodInfo, NULL, GpeBlock, NULL); + + /* Return the new block */ + + if (ReturnGpeBlock) + { + (*ReturnGpeBlock) = GpeBlock; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", + (UINT32) GpeBlock->BlockBaseNumber, + (UINT32) (GpeBlock->BlockBaseNumber + + ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1)), + GpeDevice->Name.Ascii, + GpeBlock->RegisterCount, + InterruptNumber)); + + /* Update global count of currently available GPEs */ + + AcpiCurrentGpeCount += RegisterCount * ACPI_GPE_REGISTER_WIDTH; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE block + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Initialize and enable a GPE block. First find and run any + * _PRT methods associated with the block, then enable the + * appropriate GPEs. + * Note: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_STATUS Status; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_GPE_WALK_INFO GpeInfo; + UINT32 WakeGpeCount; + UINT32 GpeEnabledCount; + UINT32 i; + UINT32 j; + + + ACPI_FUNCTION_TRACE (EvInitializeGpeBlock); + + + /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */ + + if (!GpeBlock) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Runtime option: Should wake GPEs be enabled at runtime? The default + * is no, they should only be enabled just as the machine goes to sleep. + */ + if (AcpiGbl_LeaveWakeGpesDisabled) + { + /* + * Differentiate runtime vs wake GPEs, via the _PRW control methods. + * Each GPE that has one or more _PRWs that reference it is by + * definition a wake GPE and will not be enabled while the machine + * is running. + */ + GpeInfo.GpeBlock = GpeBlock; + GpeInfo.GpeDevice = GpeDevice; + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + AcpiEvMatchPrwAndGpe, NULL, &GpeInfo, NULL); + } + + /* + * Enable all GPEs in this block that have these attributes: + * 1) are "runtime" or "run/wake" GPEs, and + * 2) have a corresponding _Lxx or _Exx method + * + * Any other GPEs within this block must be enabled via the + * AcpiEnableGpe() external interface. + */ + WakeGpeCount = 0; + GpeEnabledCount = 0; + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + for (j = 0; j < 8; j++) + { + /* Get the info block for this particular GPE */ + + GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j]; + + if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) && + (GpeEventInfo->Flags & ACPI_GPE_TYPE_RUNTIME)) + { + GpeEnabledCount++; + } + + if (GpeEventInfo->Flags & ACPI_GPE_TYPE_WAKE) + { + WakeGpeCount++; + } + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Found %u Wake, Enabled %u Runtime GPEs in this block\n", + WakeGpeCount, GpeEnabledCount)); + + /* Enable all valid runtime GPEs found above */ + + Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not enable GPEs in GpeBlock %p", + GpeBlock)); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the GPE data structures + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvGpeInitialize ( + void) +{ + UINT32 RegisterCount0 = 0; + UINT32 RegisterCount1 = 0; + UINT32 GpeNumberMax = 0; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvGpeInitialize); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize the GPE Block(s) defined in the FADT + * + * Why the GPE register block lengths are divided by 2: From the ACPI + * Spec, section "General-Purpose Event Registers", we have: + * + * "Each register block contains two registers of equal length + * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the + * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN + * The length of the GPE1_STS and GPE1_EN registers is equal to + * half the GPE1_LEN. If a generic register block is not supported + * then its respective block pointer and block length values in the + * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need + * to be the same size." + */ + + /* + * Determine the maximum GPE number for this machine. + * + * Note: both GPE0 and GPE1 are optional, and either can exist without + * the other. + * + * If EITHER the register length OR the block address are zero, then that + * particular block is not supported. + */ + if (AcpiGbl_FADT.Gpe0BlockLength && + AcpiGbl_FADT.XGpe0Block.Address) + { + /* GPE block 0 exists (has both length and address > 0) */ + + RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2); + + GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1; + + /* Install GPE Block 0 */ + + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create GPE Block 0")); + } + } + + if (AcpiGbl_FADT.Gpe1BlockLength && + AcpiGbl_FADT.XGpe1Block.Address) + { + /* GPE block 1 exists (has both length and address > 0) */ + + RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2); + + /* Check for GPE0/GPE1 overlap (if both banks exist) */ + + if ((RegisterCount0) && + (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base)) + { + ACPI_ERROR ((AE_INFO, + "GPE0 block (GPE 0 to %d) overlaps the GPE1 block " + "(GPE %d to %d) - Ignoring GPE1", + GpeNumberMax, AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.Gpe1Base + + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1))); + + /* Ignore GPE1 block by setting the register count to zero */ + + RegisterCount1 = 0; + } + else + { + /* Install GPE Block 1 */ + + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT.XGpe1Block, RegisterCount1, + AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create GPE Block 1")); + } + + /* + * GPE0 and GPE1 do not have to be contiguous in the GPE number + * space. However, GPE0 always starts at GPE number zero. + */ + GpeNumberMax = AcpiGbl_FADT.Gpe1Base + + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); + } + } + + /* Exit if there are no GPE registers */ + + if ((RegisterCount0 + RegisterCount1) == 0) + { + /* GPEs are not required by ACPI, this is OK */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "There are no GPE blocks defined in the FADT\n")); + Status = AE_OK; + goto Cleanup; + } + + /* Check for Max GPE number out-of-range */ + + if (GpeNumberMax > ACPI_GPE_MAX) + { + ACPI_ERROR ((AE_INFO, + "Maximum GPE number from FADT is too large: 0x%X", + GpeNumberMax)); + Status = AE_BAD_VALUE; + goto Cleanup; + } + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evmisc.c b/reactos/drivers/bus/acpi/acpica/events/evmisc.c new file mode 100644 index 00000000000..1e7f9e1cb56 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evmisc.c @@ -0,0 +1,740 @@ +/****************************************************************************** + * + * Module Name: evmisc - Miscellaneous event manager support functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evmisc") + + +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvNotifyDispatch ( + void *Context); + +static UINT32 +AcpiEvGlobalLockHandler ( + void *Context); + +static ACPI_STATUS +AcpiEvRemoveGlobalLockHandler ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIsNotifyObject + * + * PARAMETERS: Node - Node to check + * + * RETURN: TRUE if notifies allowed on this object + * + * DESCRIPTION: Check type of node for a object that supports notifies. + * + * TBD: This could be replaced by a flag bit in the node. + * + ******************************************************************************/ + +BOOLEAN +AcpiEvIsNotifyObject ( + ACPI_NAMESPACE_NODE *Node) +{ + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + /* + * These are the ONLY objects that can receive ACPI notifications + */ + return (TRUE); + + default: + return (FALSE); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvQueueNotifyRequest + * + * PARAMETERS: Node - NS node for the notified object + * NotifyValue - Value from the Notify() request + * + * RETURN: Status + * + * DESCRIPTION: Dispatch a device notification event to a previously + * installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvQueueNotifyRequest ( + ACPI_NAMESPACE_NODE *Node, + UINT32 NotifyValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj = NULL; + ACPI_GENERIC_STATE *NotifyInfo; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_NAME (EvQueueNotifyRequest); + + + /* + * For value 3 (Ejection Request), some device method may need to be run. + * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need + * to be run. + * For value 0x80 (Status Change) on the power button or sleep button, + * initiate soft-off or sleep operation? + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n", + AcpiUtGetNodeName (Node), Node, NotifyValue, + AcpiUtGetNotifyName (NotifyValue))); + + /* Get the notify object attached to the NS Node */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* We have the notify object, Get the right handler */ + + switch (Node->Type) + { + /* Notify allowed only on these types */ + + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_PROCESSOR: + + if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) + { + HandlerObj = ObjDesc->CommonNotify.SystemNotify; + } + else + { + HandlerObj = ObjDesc->CommonNotify.DeviceNotify; + } + break; + + default: + + /* All other types are not supported */ + + return (AE_TYPE); + } + } + + /* + * If there is any handler to run, schedule the dispatcher. + * Check for: + * 1) Global system notify handler + * 2) Global device notify handler + * 3) Per-device notify handler + */ + if ((AcpiGbl_SystemNotify.Handler && + (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) || + (AcpiGbl_DeviceNotify.Handler && + (NotifyValue > ACPI_MAX_SYS_NOTIFY)) || + HandlerObj) + { + NotifyInfo = AcpiUtCreateGenericState (); + if (!NotifyInfo) + { + return (AE_NO_MEMORY); + } + + if (!HandlerObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Executing system notify handler for Notify (%4.4s, %X) " + "node %p\n", + AcpiUtGetNodeName (Node), NotifyValue, Node)); + } + + NotifyInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY; + NotifyInfo->Notify.Node = Node; + NotifyInfo->Notify.Value = (UINT16) NotifyValue; + NotifyInfo->Notify.HandlerObj = HandlerObj; + + Status = AcpiOsExecute ( + OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, NotifyInfo); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteGenericState (NotifyInfo); + } + } + else + { + /* There is no notify handler (per-device or system) for this device */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "No notify handler for Notify (%4.4s, %X) node %p\n", + AcpiUtGetNodeName (Node), NotifyValue, Node)); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvNotifyDispatch + * + * PARAMETERS: Context - To be passed to the notify handler + * + * RETURN: None. + * + * DESCRIPTION: Dispatch a device notification event to a previously + * installed handler. + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvNotifyDispatch ( + void *Context) +{ + ACPI_GENERIC_STATE *NotifyInfo = (ACPI_GENERIC_STATE *) Context; + ACPI_NOTIFY_HANDLER GlobalHandler = NULL; + void *GlobalContext = NULL; + ACPI_OPERAND_OBJECT *HandlerObj; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We will invoke a global notify handler if installed. This is done + * _before_ we invoke the per-device handler attached to the device. + */ + if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY) + { + /* Global system notification handler */ + + if (AcpiGbl_SystemNotify.Handler) + { + GlobalHandler = AcpiGbl_SystemNotify.Handler; + GlobalContext = AcpiGbl_SystemNotify.Context; + } + } + else + { + /* Global driver notification handler */ + + if (AcpiGbl_DeviceNotify.Handler) + { + GlobalHandler = AcpiGbl_DeviceNotify.Handler; + GlobalContext = AcpiGbl_DeviceNotify.Context; + } + } + + /* Invoke the system handler first, if present */ + + if (GlobalHandler) + { + GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, + GlobalContext); + } + + /* Now invoke the per-device handler, if present */ + + HandlerObj = NotifyInfo->Notify.HandlerObj; + if (HandlerObj) + { + HandlerObj->Notify.Handler (NotifyInfo->Notify.Node, + NotifyInfo->Notify.Value, + HandlerObj->Notify.Context); + } + + /* All done with the info object */ + + AcpiUtDeleteGenericState (NotifyInfo); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGlobalLockHandler + * + * PARAMETERS: Context - From thread interface, not used + * + * RETURN: ACPI_INTERRUPT_HANDLED + * + * DESCRIPTION: Invoked directly from the SCI handler when a global lock + * release interrupt occurs. Attempt to acquire the global lock, + * if successful, signal the thread waiting for the lock. + * + * NOTE: Assumes that the semaphore can be signaled from interrupt level. If + * this is not possible for some reason, a separate thread will have to be + * scheduled to do this. + * + ******************************************************************************/ + +static UINT32 +AcpiEvGlobalLockHandler ( + void *Context) +{ + BOOLEAN Acquired = FALSE; + ACPI_STATUS Status; + + + /* + * Attempt to get the lock. + * + * If we don't get it now, it will be marked pending and we will + * take another interrupt when it becomes free. + */ + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); + if (Acquired) + { + /* Got the lock, now wake the thread waiting for it */ + + AcpiGbl_GlobalLockAcquired = TRUE; + + /* Send a unit to the semaphore */ + + Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, 1); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not signal Global Lock semaphore")); + } + } + + return (ACPI_INTERRUPT_HANDLED); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitGlobalLockHandler + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for the global lock release event + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitGlobalLockHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInitGlobalLockHandler); + + + /* Attempt installation of the global lock handler */ + + Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler, NULL); + + /* + * If the global lock does not exist on this platform, the attempt to + * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick). + * Map to AE_OK, but mark global lock as not present. Any attempt to + * actually use the global lock will be flagged with an error. + */ + if (Status == AE_NO_HARDWARE_RESPONSE) + { + ACPI_ERROR ((AE_INFO, + "No response from Global Lock hardware, disabling lock")); + + AcpiGbl_GlobalLockPresent = FALSE; + return_ACPI_STATUS (AE_OK); + } + + AcpiGbl_GlobalLockPresent = TRUE; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvRemoveGlobalLockHandler + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Remove the handler for the Global Lock + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvRemoveGlobalLockHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvRemoveGlobalLockHandler); + + AcpiGbl_GlobalLockPresent = FALSE; + Status = AcpiRemoveFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvAcquireGlobalLock + * + * PARAMETERS: Timeout - Max time to wait for the lock, in millisec. + * + * RETURN: Status + * + * DESCRIPTION: Attempt to gain ownership of the Global Lock. + * + * MUTEX: Interpreter must be locked + * + * Note: The original implementation allowed multiple threads to "acquire" the + * Global Lock, and the OS would hold the lock until the last thread had + * released it. However, this could potentially starve the BIOS out of the + * lock, especially in the case where there is a tight handshake between the + * Embedded Controller driver and the BIOS. Therefore, this implementation + * allows only one thread to acquire the HW Global Lock at a time, and makes + * the global lock appear as a standard mutex on the OS side. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiEvAcquireGlobalLock ( + UINT16 Timeout) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN Acquired = FALSE; + + + ACPI_FUNCTION_TRACE (EvAcquireGlobalLock); + + + /* + * Only one thread can acquire the GL at a time, the GlobalLockMutex + * enforces this. This interface releases the interpreter if we must wait. + */ + Status = AcpiExSystemWaitMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex, + Timeout); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Update the global lock handle and check for wraparound. The handle is + * only used for the external global lock interfaces, but it is updated + * here to properly handle the case where a single thread may acquire the + * lock via both the AML and the AcpiAcquireGlobalLock interfaces. The + * handle is therefore updated on the first acquire from a given thread + * regardless of where the acquisition request originated. + */ + AcpiGbl_GlobalLockHandle++; + if (AcpiGbl_GlobalLockHandle == 0) + { + AcpiGbl_GlobalLockHandle = 1; + } + + /* + * Make sure that a global lock actually exists. If not, just treat the + * lock as a standard mutex. + */ + if (!AcpiGbl_GlobalLockPresent) + { + AcpiGbl_GlobalLockAcquired = TRUE; + return_ACPI_STATUS (AE_OK); + } + + /* Attempt to acquire the actual hardware lock */ + + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); + if (Acquired) + { + /* We got the lock */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired hardware Global Lock\n")); + + AcpiGbl_GlobalLockAcquired = TRUE; + return_ACPI_STATUS (AE_OK); + } + + /* + * Did not get the lock. The pending bit was set above, and we must now + * wait until we get the global lock released interrupt. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for hardware Global Lock\n")); + + /* + * Wait for handshake with the global lock interrupt handler. + * This interface releases the interpreter if we must wait. + */ + Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, + ACPI_WAIT_FOREVER); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvReleaseGlobalLock + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Releases ownership of the Global Lock. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvReleaseGlobalLock ( + void) +{ + BOOLEAN Pending = FALSE; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (EvReleaseGlobalLock); + + + /* Lock must be already acquired */ + + if (!AcpiGbl_GlobalLockAcquired) + { + ACPI_WARNING ((AE_INFO, + "Cannot release the ACPI Global Lock, it has not been acquired")); + return_ACPI_STATUS (AE_NOT_ACQUIRED); + } + + if (AcpiGbl_GlobalLockPresent) + { + /* Allow any thread to release the lock */ + + ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_FACS, Pending); + + /* + * If the pending bit was set, we must write GBL_RLS to the control + * register + */ + if (Pending) + { + Status = AcpiWriteBitRegister ( + ACPI_BITREG_GLOBAL_LOCK_RELEASE, ACPI_ENABLE_EVENT); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Released hardware Global Lock\n")); + } + + AcpiGbl_GlobalLockAcquired = FALSE; + + /* Release the local GL mutex */ + + AcpiOsReleaseMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Disable events and free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiEvTerminate ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvTerminate); + + + if (AcpiGbl_EventsInitialized) + { + /* + * Disable all event-related functionality. In all cases, on error, + * print a message but obviously we don't abort. + */ + + /* Disable all fixed events */ + + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + Status = AcpiDisableEvent (i, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not disable fixed event %d", (UINT32) i)); + } + } + + /* Disable all GPEs in all GPE blocks */ + + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); + + /* Remove SCI handler */ + + Status = AcpiEvRemoveSciHandler (); + if (ACPI_FAILURE(Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not remove SCI handler")); + } + + Status = AcpiEvRemoveGlobalLockHandler (); + if (ACPI_FAILURE(Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not remove Global Lock handler")); + } + } + + /* Deallocate all handler objects installed within GPE info structs */ + + Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, NULL); + + /* Return to original mode if necessary */ + + if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY) + { + Status = AcpiDisable (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "AcpiDisable failed")); + } + } + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/acpica/events/evregion.c b/reactos/drivers/bus/acpi/acpica/events/evregion.c new file mode 100644 index 00000000000..2bdfb872fe0 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evregion.c @@ -0,0 +1,1284 @@ +/****************************************************************************** + * + * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVREGION_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evregion") + + +/* Local prototypes */ + +static BOOLEAN +AcpiEvHasDefaultHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + +static ACPI_STATUS +AcpiEvRegRun ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvInstallHandler ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +/* These are the address spaces that will get default handlers */ + +#define ACPI_NUM_DEFAULT_SPACES 4 + +static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = +{ + ACPI_ADR_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_DATA_TABLE +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallRegionHandlers + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Installs the core subsystem default address space handlers. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (EvInstallRegionHandlers); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * All address spaces (PCI Config, EC, SMBus) are scope dependent and + * registration must occur for a specific device. + * + * In the case of the system memory and IO address spaces there is + * currently no device associated with the address space. For these we + * use the root. + * + * We install the default PCI config space handler at the root so that + * this space is immediately available even though the we have not + * enumerated all the PCI Root Buses yet. This is to conform to the ACPI + * specification which states that the PCI config space must be always + * available -- even though we are nowhere near ready to find the PCI root + * buses at this point. + * + * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler + * has already been installed (via AcpiInstallAddressSpaceHandler). + * Similar for AE_SAME_HANDLER. + */ + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) + { + Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i], + ACPI_DEFAULT_HANDLER, NULL, NULL); + switch (Status) + { + case AE_OK: + case AE_SAME_HANDLER: + case AE_ALREADY_EXISTS: + + /* These exceptions are all OK */ + + Status = AE_OK; + break; + + default: + + goto UnlockAndExit; + } + } + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvHasDefaultHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: TRUE if default handler is installed, FALSE otherwise + * + * DESCRIPTION: Check if the default handler is installed for the requested + * space ID. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvHasDefaultHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + + + /* Must have an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the linked list of handlers for this object */ + + while (HandlerObj) + { + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + { + return (TRUE); + } + } + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeOpRegions + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG methods for all Operation Regions that have + * an installed default region handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (EvInitializeOpRegions); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Run the _REG methods for OpRegions in each default address space */ + + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) + { + /* + * Make sure the installed handler is the DEFAULT handler. If not the + * default, the _REG methods will have already been run (when the + * handler was installed) + */ + if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i])) + { + Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i]); + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvExecuteRegMethod + * + * PARAMETERS: RegionObj - Region object + * Function - Passed to _REG: On (1) or Off (0) + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG method for a region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_OPERAND_OBJECT *Args[3]; + ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvExecuteRegMethod); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (RegionObj2->Extra.Method_REG == NULL) + { + return_ACPI_STATUS (AE_OK); + } + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = RegionObj2->Extra.Method_REG; + Info->Pathname = NULL; + Info->Parameters = Args; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + /* + * The _REG method has two arguments: + * + * Arg0 - Integer: + * Operation region space ID Same value as RegionObj->Region.SpaceId + * + * Arg1 - Integer: + * connection status 1 for connecting the handler, 0 for disconnecting + * the handler (Passed as a parameter) + */ + Args[0] = AcpiUtCreateIntegerObject ((UINT64) RegionObj->Region.SpaceId); + if (!Args[0]) + { + Status = AE_NO_MEMORY; + goto Cleanup1; + } + + Args[1] = AcpiUtCreateIntegerObject ((UINT64) Function); + if (!Args[1]) + { + Status = AE_NO_MEMORY; + goto Cleanup2; + } + + Args[2] = NULL; /* Terminate list */ + + /* Execute the method, no return value */ + + ACPI_DEBUG_EXEC ( + AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Info->PrefixNode, NULL)); + + Status = AcpiNsEvaluate (Info); + AcpiUtRemoveReference (Args[1]); + +Cleanup2: + AcpiUtRemoveReference (Args[0]); + +Cleanup1: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAddressSpaceDispatch + * + * PARAMETERS: RegionObj - Internal region object + * Function - Read or Write operation + * RegionOffset - Where in the region to read or write + * BitWidth - Field width in bits (8, 16, 32, or 64) + * Value - Pointer to in or out value, must be + * full 64-bit ACPI_INTEGER + * + * RETURN: Status + * + * DESCRIPTION: Dispatch an address space or operation region access to + * a previously installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + UINT32 RegionOffset, + UINT32 BitWidth, + ACPI_INTEGER *Value) +{ + ACPI_STATUS Status; + ACPI_ADR_SPACE_HANDLER Handler; + ACPI_ADR_SPACE_SETUP RegionSetup; + ACPI_OPERAND_OBJECT *HandlerDesc; + ACPI_OPERAND_OBJECT *RegionObj2; + void *RegionContext = NULL; + + + ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Ensure that there is a handler associated with this region */ + + HandlerDesc = RegionObj->Region.Handler; + if (!HandlerDesc) + { + ACPI_ERROR ((AE_INFO, + "No handler for Region [%4.4s] (%p) [%s]", + AcpiUtGetNodeName (RegionObj->Region.Node), + RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * It may be the case that the region has never been initialized. + * Some types of regions require special init code + */ + if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)) + { + /* This region has not been initialized yet, do it */ + + RegionSetup = HandlerDesc->AddressSpace.Setup; + if (!RegionSetup) + { + /* No initialization routine, exit with error */ + + ACPI_ERROR ((AE_INFO, + "No init routine for region(%p) [%s]", + RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * We must exit the interpreter because the region setup will + * potentially execute control methods (for example, the _REG method + * for this region) + */ + AcpiExExitInterpreter (); + + Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE, + HandlerDesc->AddressSpace.Context, &RegionContext); + + /* Re-enter the interpreter */ + + AcpiExEnterInterpreter (); + + /* Check for failure of the Region Setup */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "During region initialization: [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + return_ACPI_STATUS (Status); + } + + /* Region initialization may have been completed by RegionSetup */ + + if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)) + { + RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE; + + if (RegionObj2->Extra.RegionContext) + { + /* The handler for this region was already installed */ + + ACPI_FREE (RegionContext); + } + else + { + /* + * Save the returned context for use in all accesses to + * this particular region + */ + RegionObj2->Extra.RegionContext = RegionContext; + } + } + } + + /* We have everything we need, we can invoke the address space handler */ + + Handler = HandlerDesc->AddressSpace.Handler; + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", + &RegionObj->Region.Handler->AddressSpace, Handler, + ACPI_FORMAT_NATIVE_UINT (RegionObj->Region.Address + RegionOffset), + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + if (!(HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + { + /* + * For handlers other than the default (supplied) handlers, we must + * exit the interpreter because the handler *might* block -- we don't + * know what it will do, so we can't hold the lock on the intepreter. + */ + AcpiExExitInterpreter(); + } + + /* Call the handler */ + + Status = Handler (Function, + (RegionObj->Region.Address + RegionOffset), BitWidth, Value, + HandlerDesc->AddressSpace.Context, RegionObj2->Extra.RegionContext); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "Returned by Handler for [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + if (!(HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + { + /* + * We just returned from a non-default handler, we must re-enter the + * interpreter + */ + AcpiExEnterInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDetachRegion + * + * PARAMETERS: RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? + * + * RETURN: None + * + * DESCRIPTION: Break the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +void +AcpiEvDetachRegion( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; + ACPI_ADR_SPACE_SETUP RegionSetup; + void **RegionContext; + ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvDetachRegion); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_VOID; + } + RegionContext = &RegionObj2->Extra.RegionContext; + + /* Get the address handler from the region object */ + + HandlerObj = RegionObj->Region.Handler; + if (!HandlerObj) + { + /* This region has no handler, all done */ + + return_VOID; + } + + /* Find this region in the handler's list */ + + ObjDesc = HandlerObj->AddressSpace.RegionList; + LastObjPtr = &HandlerObj->AddressSpace.RegionList; + + while (ObjDesc) + { + /* Is this the correct Region? */ + + if (ObjDesc == RegionObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Removing Region %p from address handler %p\n", + RegionObj, HandlerObj)); + + /* This is it, remove it from the handler's list */ + + *LastObjPtr = ObjDesc->Region.Next; + ObjDesc->Region.Next = NULL; /* Must clear field */ + + if (AcpiNsIsLocked) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + } + + /* Now stop region accesses by executing the _REG method */ + + Status = AcpiEvExecuteRegMethod (RegionObj, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "from region _REG, [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + if (AcpiNsIsLocked) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + } + + /* + * If the region has been activated, call the setup handler with + * the deactivate notification + */ + if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) + { + RegionSetup = HandlerObj->AddressSpace.Setup; + Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE, + HandlerObj->AddressSpace.Context, RegionContext); + + /* Init routine may fail, Just ignore errors */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "from region handler - deactivate, [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE); + } + + /* + * Remove handler reference in the region + * + * NOTE: this doesn't mean that the region goes away, the region + * is just inaccessible as indicated to the _REG method + * + * If the region is on the handler's list, this must be the + * region's handler + */ + RegionObj->Region.Handler = NULL; + AcpiUtRemoveReference (HandlerObj); + + return_VOID; + } + + /* Walk the linked list of handlers */ + + LastObjPtr = &ObjDesc->Region.Next; + ObjDesc = ObjDesc->Region.Next; + } + + /* If we get here, the region was not in the handler's region list */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Cannot remove region %p from address handler %p\n", + RegionObj, HandlerObj)); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAttachRegion + * + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? + * + * RETURN: None + * + * DESCRIPTION: Create the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvAttachRegion ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked) +{ + + ACPI_FUNCTION_TRACE (EvAttachRegion); + + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Adding Region [%4.4s] %p to address handler %p [%s]\n", + AcpiUtGetNodeName (RegionObj->Region.Node), + RegionObj, HandlerObj, + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + /* Link this region to the front of the handler's list */ + + RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList; + HandlerObj->AddressSpace.RegionList = RegionObj; + + /* Install the region's handler */ + + if (RegionObj->Region.Handler) + { + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + + RegionObj->Region.Handler = HandlerObj; + AcpiUtAddReference (HandlerObj); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallHandler + * + * PARAMETERS: WalkNamespace callback + * + * DESCRIPTION: This routine installs an address handler into objects that are + * of type Region or Device. + * + * If the Object is a Device, and the device has a handler of + * the same type then the search is terminated in that branch. + * + * This is because the existing handler is closer in proximity + * to any more regions than the one we are trying to install. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvInstallHandler ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *NextHandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (EvInstallHandler); + + + HandlerObj = (ACPI_OPERAND_OBJECT *) Context; + + /* Parameter validation */ + + if (!HandlerObj) + { + return (AE_OK); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* + * We only care about regions and objects that are allowed to have + * address space handlers + */ + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_REGION) && + (Node != AcpiGbl_RootNode)) + { + return (AE_OK); + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, just exit */ + + return (AE_OK); + } + + /* Devices are handled different than regions */ + + if (ObjDesc->Common.Type == ACPI_TYPE_DEVICE) + { + /* Check if this Device already has a handler for this address space */ + + NextHandlerObj = ObjDesc->Device.Handler; + while (NextHandlerObj) + { + /* Found a handler, is it for the same address space? */ + + if (NextHandlerObj->AddressSpace.SpaceId == + HandlerObj->AddressSpace.SpaceId) + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Found handler for region [%s] in device %p(%p) " + "handler %p\n", + AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId), + ObjDesc, NextHandlerObj, HandlerObj)); + + /* + * Since the object we found it on was a device, then it + * means that someone has already installed a handler for + * the branch of the namespace from this device on. Just + * bail out telling the walk routine to not traverse this + * branch. This preserves the scoping rule for handlers. + */ + return (AE_CTRL_DEPTH); + } + + /* Walk the linked list of handlers attached to this device */ + + NextHandlerObj = NextHandlerObj->AddressSpace.Next; + } + + /* + * As long as the device didn't have a handler for this space we + * don't care about it. We just ignore it and proceed. + */ + return (AE_OK); + } + + /* Object is a Region */ + + if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId) + { + /* This region is for a different address space, just ignore it */ + + return (AE_OK); + } + + /* + * Now we have a region and it is for the handler's address space type. + * + * First disconnect region for any previous handler (if any) + */ + AcpiEvDetachRegion (ObjDesc, FALSE); + + /* Connect the region to the new handler */ + + Status = AcpiEvAttachRegion (HandlerObj, ObjDesc, FALSE); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallSpaceHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE Type; + UINT8 Flags = 0; + + + ACPI_FUNCTION_TRACE (EvInstallSpaceHandler); + + + /* + * This registration is valid for only the types below and the root. This + * is where the default handlers get placed. + */ + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if (Handler == ACPI_DEFAULT_HANDLER) + { + Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; + + switch (SpaceId) + { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + Handler = AcpiExSystemMemorySpaceHandler; + Setup = AcpiEvSystemMemoryRegionSetup; + break; + + case ACPI_ADR_SPACE_SYSTEM_IO: + Handler = AcpiExSystemIoSpaceHandler; + Setup = AcpiEvIoSpaceRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_CONFIG: + Handler = AcpiExPciConfigSpaceHandler; + Setup = AcpiEvPciConfigRegionSetup; + break; + + case ACPI_ADR_SPACE_CMOS: + Handler = AcpiExCmosSpaceHandler; + Setup = AcpiEvCmosRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_BAR_TARGET: + Handler = AcpiExPciBarSpaceHandler; + Setup = AcpiEvPciBarRegionSetup; + break; + + case ACPI_ADR_SPACE_DATA_TABLE: + Handler = AcpiExDataTableSpaceHandler; + Setup = NULL; + break; + + default: + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* If the caller hasn't specified a setup routine, use the default */ + + if (!Setup) + { + Setup = AcpiEvDefaultRegionSetup; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* + * The attached device object already exists. Make sure the handler + * is not already installed. + */ + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the handler list for this device */ + + while (HandlerObj) + { + /* Same SpaceId indicates a handler already installed */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.Handler == Handler) + { + /* + * It is (relatively) OK to attempt to install the SAME + * handler twice. This can easily happen with the + * PCI_Config space. + */ + Status = AE_SAME_HANDLER; + goto UnlockAndExit; + } + else + { + /* A handler is already installed */ + + Status = AE_ALREADY_EXISTS; + } + goto UnlockAndExit; + } + + /* Walk the linked list of handlers */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Creating object on Device %p while installing handler\n", Node)); + + /* ObjDesc does not exist, create one */ + + if (Node->Type == ACPI_TYPE_ANY) + { + Type = ACPI_TYPE_DEVICE; + } + else + { + Type = Node->Type; + } + + ObjDesc = AcpiUtCreateInternalObject (Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init new descriptor */ + + ObjDesc->Common.Type = (UINT8) Type; + + /* Attach the new object to the Node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, + AcpiUtGetNodeName (Node), Node, ObjDesc)); + + /* + * Install the handler + * + * At this point there is no existing handler. Just allocate the object + * for the handler and link it into the list. + */ + HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); + if (!HandlerObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init handler obj */ + + HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; + HandlerObj->AddressSpace.HandlerFlags = Flags; + HandlerObj->AddressSpace.RegionList = NULL; + HandlerObj->AddressSpace.Node = Node; + HandlerObj->AddressSpace.Handler = Handler; + HandlerObj->AddressSpace.Context = Context; + HandlerObj->AddressSpace.Setup = Setup; + + /* Install at head of Device.AddressSpace list */ + + HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; + + /* + * The Device object is the first reference on the HandlerObj. + * Each region that uses the handler adds a reference. + */ + ObjDesc->Device.Handler = HandlerObj; + + /* + * Walk the namespace finding all of the regions this + * handler will manage. + * + * Start at the device and search the branch toward + * the leaf nodes until either the leaf is encountered or + * a device is detected that has an address handler of the + * same type. + * + * In either case, back up and search down the remainder + * of the branch + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, NULL, + HandlerObj, NULL); + +UnlockAndExit: + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvExecuteRegMethods + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: Status + * + * DESCRIPTION: Run all _REG methods for the input Space ID; + * Note: assumes namespace is locked, or system init time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvExecuteRegMethods); + + + /* + * Run all _REG methods for all Operation Regions for this space ID. This + * is a separate walk in order to handle any interdependencies between + * regions and _REG methods. (i.e. handlers must be installed for all + * regions of this Space ID before we can run any _REG methods) + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL, + &SpaceId, NULL); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvRegRun + * + * PARAMETERS: WalkNamespace callback + * + * DESCRIPTION: Run _REG method for region objects of the requested spaceID + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvRegRun ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_ADR_SPACE_TYPE SpaceId; + ACPI_STATUS Status; + + + SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context); + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* + * We only care about regions.and objects that are allowed to have address + * space handlers + */ + if ((Node->Type != ACPI_TYPE_REGION) && + (Node != AcpiGbl_RootNode)) + { + return (AE_OK); + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, just exit */ + + return (AE_OK); + } + + /* Object is a Region */ + + if (ObjDesc->Region.SpaceId != SpaceId) + { + /* This region is for a different address space, just ignore it */ + + return (AE_OK); + } + + Status = AcpiEvExecuteRegMethod (ObjDesc, 1); + return (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/events/evrgnini.c b/reactos/drivers/bus/acpi/acpica/events/evrgnini.c new file mode 100644 index 00000000000..67f6cddf66d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evrgnini.c @@ -0,0 +1,799 @@ +/****************************************************************************** + * + * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVRGNINI_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evrgnini") + +/* Local prototypes */ + +static BOOLEAN +AcpiEvIsPciRootBridge ( + ACPI_NAMESPACE_NODE *Node); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSystemMemoryRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a SystemMemory operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_OPERAND_OBJECT *RegionDesc = (ACPI_OPERAND_OBJECT *) Handle; + ACPI_MEM_SPACE_CONTEXT *LocalRegionContext; + + + ACPI_FUNCTION_TRACE (EvSystemMemoryRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + if (*RegionContext) + { + LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext; + + /* Delete a cached mapping if present */ + + if (LocalRegionContext->MappedLength) + { + AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress, + LocalRegionContext->MappedLength); + } + ACPI_FREE (LocalRegionContext); + *RegionContext = NULL; + } + return_ACPI_STATUS (AE_OK); + } + + /* Create a new context */ + + LocalRegionContext = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_MEM_SPACE_CONTEXT)); + if (!(LocalRegionContext)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the region length and address for use in the handler */ + + LocalRegionContext->Length = RegionDesc->Region.Length; + LocalRegionContext->Address = RegionDesc->Region.Address; + + *RegionContext = LocalRegionContext; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIoSpaceRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a IO operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvIoSpaceRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = HandlerContext; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvPciConfigRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a PCI_Config operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER PciValue; + ACPI_PCI_ID *PciId = *RegionContext; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *PciRootNode; + ACPI_NAMESPACE_NODE *PciDeviceNode; + ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; + + + ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup); + + + HandlerObj = RegionObj->Region.Handler; + if (!HandlerObj) + { + /* + * No installed handler. This shouldn't happen because the dispatch + * routine checks before we get here, but we check again just in case. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Attempting to init a region %p, with no handler\n", RegionObj)); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + *RegionContext = NULL; + if (Function == ACPI_REGION_DEACTIVATE) + { + if (PciId) + { + ACPI_FREE (PciId); + } + return_ACPI_STATUS (Status); + } + + ParentNode = AcpiNsGetParentNode (RegionObj->Region.Node); + + /* + * Get the _SEG and _BBN values from the device upon which the handler + * is installed. + * + * We need to get the _SEG and _BBN objects relative to the PCI BUS device. + * This is the device the handler has been registered to handle. + */ + + /* + * If the AddressSpace.Node is still pointing to the root, we need + * to scan upward for a PCI Root bridge and re-associate the OpRegion + * handlers with that device. + */ + if (HandlerObj->AddressSpace.Node == AcpiGbl_RootNode) + { + /* Start search from the parent object */ + + PciRootNode = ParentNode; + while (PciRootNode != AcpiGbl_RootNode) + { + /* Get the _HID/_CID in order to detect a RootBridge */ + + if (AcpiEvIsPciRootBridge (PciRootNode)) + { + /* Install a handler for this PCI root bridge */ + + Status = AcpiInstallAddressSpaceHandler ( + (ACPI_HANDLE) PciRootNode, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_SAME_HANDLER) + { + /* + * It is OK if the handler is already installed on the + * root bridge. Still need to return a context object + * for the new PCI_Config operation region, however. + */ + Status = AE_OK; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not install PciConfig handler " + "for Root Bridge %4.4s", + AcpiUtGetNodeName (PciRootNode))); + } + } + break; + } + + PciRootNode = AcpiNsGetParentNode (PciRootNode); + } + + /* PCI root bridge not found, use namespace root node */ + } + else + { + PciRootNode = HandlerObj->AddressSpace.Node; + } + + /* + * If this region is now initialized, we are done. + * (InstallAddressSpaceHandler could have initialized it) + */ + if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) + { + return_ACPI_STATUS (AE_OK); + } + + /* Region is still not initialized. Create a new context */ + + PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID)); + if (!PciId) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * For PCI_Config space access, we need the segment, bus, device and + * function numbers. Acquire them here. + * + * Find the parent device object. (This allows the operation region to be + * within a subscope under the device, such as a control method.) + */ + PciDeviceNode = RegionObj->Region.Node; + while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE)) + { + PciDeviceNode = AcpiNsGetParentNode (PciDeviceNode); + } + + if (!PciDeviceNode) + { + ACPI_FREE (PciId); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Get the PCI device and function numbers from the _ADR object contained + * in the parent's scope. + */ + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, + PciDeviceNode, &PciValue); + + /* + * The default is zero, and since the allocation above zeroed the data, + * just do nothing on failure. + */ + if (ACPI_SUCCESS (Status)) + { + PciId->Device = ACPI_HIWORD (ACPI_LODWORD (PciValue)); + PciId->Function = ACPI_LOWORD (ACPI_LODWORD (PciValue)); + } + + /* The PCI segment number comes from the _SEG method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, + PciRootNode, &PciValue); + if (ACPI_SUCCESS (Status)) + { + PciId->Segment = ACPI_LOWORD (PciValue); + } + + /* The PCI bus number comes from the _BBN method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, + PciRootNode, &PciValue); + if (ACPI_SUCCESS (Status)) + { + PciId->Bus = ACPI_LOWORD (PciValue); + } + + /* Complete this device's PciId */ + + AcpiOsDerivePciId (PciRootNode, RegionObj->Region.Node, &PciId); + + *RegionContext = PciId; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIsPciRootBridge + * + * PARAMETERS: Node - Device node being examined + * + * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by + * examining the _HID and _CID for the device. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvIsPciRootBridge ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; + UINT32 i; + BOOLEAN Match; + + + /* Get the _HID and check for a PCI Root Bridge */ + + Status = AcpiUtExecute_HID (Node, &Hid); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + Match = AcpiUtIsPciRootBridge (Hid->String); + ACPI_FREE (Hid); + + if (Match) + { + return (TRUE); + } + + /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */ + + Status = AcpiUtExecute_CID (Node, &Cid); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + /* Check all _CIDs in the returned list */ + + for (i = 0; i < Cid->Count; i++) + { + if (AcpiUtIsPciRootBridge (Cid->Ids[i].String)) + { + ACPI_FREE (Cid); + return (TRUE); + } + } + + ACPI_FREE (Cid); + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvPciBarRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a PciBAR operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvPciBarRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvPciBarRegionSetup); + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCmosRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a CMOS operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvCmosRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvCmosRegionSetup); + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDefaultRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Default region initialization + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvDefaultRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = HandlerContext; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeRegion + * + * PARAMETERS: RegionObj - Region we are initializing + * AcpiNsLocked - Is namespace locked? + * + * RETURN: Status + * + * DESCRIPTION: Initializes the region, finds any _REG methods and saves them + * for execution at a later time + * + * Get the appropriate address space handler for a newly + * created region. + * + * This also performs address space specific initialization. For + * example, PCI regions must have an _ADR object that contains + * a PCI address in the scope of the definition. This address is + * required to perform an access to PCI config space. + * + * MUTEX: Interpreter should be unlocked, because we may run the _REG + * method for this region. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_ADR_SPACE_TYPE SpaceId; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; + ACPI_OPERAND_OBJECT *RegionObj2; + + + ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); + + + if (!RegionObj) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED) + { + return_ACPI_STATUS (AE_OK); + } + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + Node = AcpiNsGetParentNode (RegionObj->Region.Node); + SpaceId = RegionObj->Region.SpaceId; + + /* Setup defaults */ + + RegionObj->Region.Handler = NULL; + RegionObj2->Extra.Method_REG = NULL; + RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE); + RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; + + /* Find any "_REG" method associated with this region definition */ + + Status = AcpiNsSearchOneScope ( + *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per region + * definition. This will be executed when the handler is attached + * or removed + */ + RegionObj2->Extra.Method_REG = MethodNode; + } + + /* + * The following loop depends upon the root Node having no parent + * ie: AcpiGbl_RootNode->ParentEntry being set to NULL + */ + while (Node) + { + /* Check to see if a handler exists */ + + HandlerObj = NULL; + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* Can only be a handler if the object exists */ + + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + + HandlerObj = ObjDesc->Device.Handler; + break; + + case ACPI_TYPE_PROCESSOR: + + HandlerObj = ObjDesc->Processor.Handler; + break; + + case ACPI_TYPE_THERMAL: + + HandlerObj = ObjDesc->ThermalZone.Handler; + break; + + case ACPI_TYPE_METHOD: + /* + * If we are executing module level code, the original + * Node's object was replaced by this Method object and we + * saved the handler in the method object. + * + * See AcpiNsExecModuleCode + */ + if (ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL) + { + HandlerObj = ObjDesc->Method.Extra.Handler; + } + break; + + default: + /* Ignore other objects */ + break; + } + + while (HandlerObj) + { + /* Is this handler of the correct type? */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + /* Found correct handler */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Found handler %p for region %p in obj %p\n", + HandlerObj, RegionObj, ObjDesc)); + + Status = AcpiEvAttachRegion (HandlerObj, RegionObj, + AcpiNsLocked); + + /* + * Tell all users that this region is usable by + * running the _REG method + */ + if (AcpiNsLocked) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + Status = AcpiEvExecuteRegMethod (RegionObj, 1); + + if (AcpiNsLocked) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (AE_OK); + } + + /* Try next handler in the list */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + + /* This node does not have the handler we need; Pop up one level */ + + Node = AcpiNsGetParentNode (Node); + } + + /* If we get here, there is no handler for this region */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "No handler for RegionType %s(%X) (RegionObj %p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj)); + + return_ACPI_STATUS (AE_NOT_EXIST); +} + diff --git a/reactos/drivers/bus/acpi/acpica/events/evsci.c b/reactos/drivers/bus/acpi/acpica/events/evsci.c new file mode 100644 index 00000000000..cde433ce3ee --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evsci.c @@ -0,0 +1,280 @@ +/******************************************************************************* + * + * Module Name: evsci - System Control Interrupt configuration and + * legacy to ACPI mode state transition functions + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evsci") + +/* Local prototypes */ + +static UINT32 ACPI_SYSTEM_XFACE +AcpiEvSciXruptHandler ( + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSciXruptHandler + * + * PARAMETERS: Context - Calling Context + * + * RETURN: Status code indicates whether interrupt was handled. + * + * DESCRIPTION: Interrupt handler that will figure out what function or + * control method to call to deal with a SCI. + * + ******************************************************************************/ + +static UINT32 ACPI_SYSTEM_XFACE +AcpiEvSciXruptHandler ( + void *Context) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptList = Context; + UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; + + + ACPI_FUNCTION_TRACE (EvSciXruptHandler); + + + /* + * We are guaranteed by the ACPI CA initialization/shutdown code that + * if this interrupt handler is installed, ACPI is enabled. + */ + + /* + * Fixed Events: + * Check for and dispatch any Fixed Events that have occurred + */ + InterruptHandled |= AcpiEvFixedEventDetect (); + + /* + * General Purpose Events: + * Check for and dispatch any GPEs that have occurred + */ + InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); + + AcpiSciCount++; + return_UINT32 (InterruptHandled); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeXruptHandler + * + * PARAMETERS: Context - Calling Context + * + * RETURN: Status code indicates whether interrupt was handled. + * + * DESCRIPTION: Handler for GPE Block Device interrupts + * + ******************************************************************************/ + +UINT32 ACPI_SYSTEM_XFACE +AcpiEvGpeXruptHandler ( + void *Context) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptList = Context; + UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; + + + ACPI_FUNCTION_TRACE (EvGpeXruptHandler); + + + /* + * We are guaranteed by the ACPI CA initialization/shutdown code that + * if this interrupt handler is installed, ACPI is enabled. + */ + + /* GPEs: Check for and dispatch any GPEs that have occurred */ + + InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); + + return_UINT32 (InterruptHandled); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvInstallSciHandler + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Installs SCI handler. + * + ******************************************************************************/ + +UINT32 +AcpiEvInstallSciHandler ( + void) +{ + UINT32 Status = AE_OK; + + + ACPI_FUNCTION_TRACE (EvInstallSciHandler); + + + Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, + AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvRemoveSciHandler + * + * PARAMETERS: none + * + * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not + * installed to begin with + * + * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be + * taken. + * + * Note: It doesn't seem important to disable all events or set the event + * enable registers to their original values. The OS should disable + * the SCI interrupt level when the handler is removed, so no more + * events will come in. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvRemoveSciHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvRemoveSciHandler); + + + /* Just let the OS remove the handler and disable the level */ + + Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, + AcpiEvSciXruptHandler); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evxface.c b/reactos/drivers/bus/acpi/acpica/events/evxface.c new file mode 100644 index 00000000000..6eb5a14af06 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evxface.c @@ -0,0 +1,967 @@ +/****************************************************************************** + * + * Module Name: evxface - External interfaces for ACPI events + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallExceptionHandler + * + * PARAMETERS: Handler - Pointer to the handler function for the + * event + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallExceptionHandler); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (AcpiGbl_ExceptionHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_ExceptionHandler = Handler; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallExceptionHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallFixedEventHandler + * + * PARAMETERS: Event - Event type to enable. + * Handler - Pointer to the handler function for the + * event + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function and then enables the + * event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 Event, + ACPI_EVENT_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallFixedEventHandler); + + + /* Parameter validation */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler before enabling the event */ + + AcpiGbl_FixedEventHandlers[Event].Handler = Handler; + AcpiGbl_FixedEventHandlers[Event].Context = Context; + + Status = AcpiEnableEvent (Event, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Could not enable fixed event %X", Event)); + + /* Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Enabled fixed event %X, Handler=%p\n", Event, Handler)); + } + + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallFixedEventHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveFixedEventHandler + * + * PARAMETERS: Event - Event type to disable. + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Disables the event and unregisters the event handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 Event, + ACPI_EVENT_HANDLER Handler) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiRemoveFixedEventHandler); + + + /* Parameter validation */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Disable the event before removing the handler */ + + Status = AcpiDisableEvent (Event, 0); + + /* Always Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, + "Could not write to fixed event enable register %X", Event)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X\n", Event)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveFixedEventHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device + * Handler - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallNotifyHandler); + + + /* Parameter validation */ + + if ((!Device) || + (!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * Root Object: + * Registering a notify handler on the root object indicates that the + * caller wishes to receive notifications for all objects. Note that + * only one global handler can be regsitered (per notify type). + */ + if (Device == ACPI_ROOT_OBJECT) + { + /* Make sure the handler is not already installed */ + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + AcpiGbl_DeviceNotify.Handler)) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + AcpiGbl_SystemNotify.Node = Node; + AcpiGbl_SystemNotify.Handler = Handler; + AcpiGbl_SystemNotify.Context = Context; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + AcpiGbl_DeviceNotify.Node = Node; + AcpiGbl_DeviceNotify.Handler = Handler; + AcpiGbl_DeviceNotify.Context = Context; + } + + /* Global notify handler installed */ + } + + /* + * All Other Objects: + * Caller will only receive notifications specific to the target object. + * Note that only certain object types can receive notifications. + */ + else + { + /* Notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + Status = AE_TYPE; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* Object exists - make sure there's no handler */ + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + ObjDesc->CommonNotify.SystemNotify) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + ObjDesc->CommonNotify.DeviceNotify)) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + } + else + { + /* Create a new object */ + + ObjDesc = AcpiUtCreateInternalObject (Node->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Attach new object to the Node */ + + Status = AcpiNsAttachObject (Device, ObjDesc, Node->Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + /* Install the handler */ + + NotifyObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_NOTIFY); + if (!NotifyObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + NotifyObj->Notify.Node = Node; + NotifyObj->Notify.Handler = Handler; + NotifyObj->Notify.Context = Context; + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + ObjDesc->CommonNotify.SystemNotify = NotifyObj; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + ObjDesc->CommonNotify.DeviceNotify = NotifyObj; + } + + if (HandlerType == ACPI_ALL_NOTIFY) + { + /* Extra ref if installed in both */ + + AcpiUtAddReference (NotifyObj); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallNotifyHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveNotifyHandler); + + + /* Parameter validation */ + + if ((!Device) || + (!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Root Object */ + + if (Device == ACPI_ROOT_OBJECT) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Removing notify handler for namespace root object\n")); + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + !AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + !AcpiGbl_DeviceNotify.Handler)) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + AcpiGbl_SystemNotify.Node = NULL; + AcpiGbl_SystemNotify.Handler = NULL; + AcpiGbl_SystemNotify.Context = NULL; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + AcpiGbl_DeviceNotify.Node = NULL; + AcpiGbl_DeviceNotify.Handler = NULL; + AcpiGbl_DeviceNotify.Context = NULL; + } + } + + /* All Other Objects */ + + else + { + /* Notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + Status = AE_TYPE; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Object exists - make sure there's an existing handler */ + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + NotifyObj = ObjDesc->CommonNotify.SystemNotify; + if (!NotifyObj) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (NotifyObj->Notify.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Remove the handler */ + + ObjDesc->CommonNotify.SystemNotify = NULL; + AcpiUtRemoveReference (NotifyObj); + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + NotifyObj = ObjDesc->CommonNotify.DeviceNotify; + if (!NotifyObj) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (NotifyObj->Notify.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Remove the handler */ + + ObjDesc->CommonNotify.DeviceNotify = NULL; + AcpiUtRemoveReference (NotifyObj); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveNotifyHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallGpeHandler + * + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The GPE number within the GPE block + * Type - Whether this GPE should be treated as an + * edge- or level-triggered interrupt. + * Address - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for a General Purpose Event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Type, + ACPI_EVENT_HANDLER Address, + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiInstallGpeHandler); + + + /* Parameter validation */ + + if ((!Address) || (Type > ACPI_GPE_XRUPT_TYPE_MASK)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure that there isn't a handler there already */ + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + + /* Allocate and init handler object */ + + Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_HANDLER_INFO)); + if (!Handler) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + Handler->Address = Address; + Handler->Context = Context; + Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode; + + /* Disable the GPE before installing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Install the handler */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + GpeEventInfo->Dispatch.Handler = Handler; + + /* Setup up dispatch flags to indicate handler (vs. method) */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); + GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER); + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallGpeHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveGpeHandler + * + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The event to remove a handler + * Address - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + ACPI_EVENT_HANDLER Address) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiRemoveGpeHandler); + + + /* Parameter validation */ + + if (!Address) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure that a handler is indeed installed */ + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_HANDLER) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Make sure that the installed handler is the same */ + + if (GpeEventInfo->Dispatch.Handler->Address != Address) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Disable the GPE before removing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Remove the handler */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + Handler = GpeEventInfo->Dispatch.Handler; + + /* Restore Method node (if any), set dispatch flags */ + + GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ + if (Handler->MethodNode) + { + GpeEventInfo->Flags |= ACPI_GPE_DISPATCH_METHOD; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Now we can free the handler object */ + + ACPI_FREE (Handler); + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveGpeHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiAcquireGlobalLock + * + * PARAMETERS: Timeout - How long the caller is willing to wait + * Handle - Where the handle to the lock is returned + * (if acquired) + * + * RETURN: Status + * + * DESCRIPTION: Acquire the ACPI Global Lock + * + * Note: Allows callers with the same thread ID to acquire the global lock + * multiple times. In other words, externally, the behavior of the global lock + * is identical to an AML mutex. On the first acquire, a new handle is + * returned. On any subsequent calls to acquire by the same thread, the same + * handle is returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAcquireGlobalLock ( + UINT16 Timeout, + UINT32 *Handle) +{ + ACPI_STATUS Status; + + + if (!Handle) + { + return (AE_BAD_PARAMETER); + } + + /* Must lock interpreter to prevent race conditions */ + + AcpiExEnterInterpreter (); + + Status = AcpiExAcquireMutexObject (Timeout, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + + if (ACPI_SUCCESS (Status)) + { + /* Return the global lock handle (updated in AcpiEvAcquireGlobalLock) */ + + *Handle = AcpiGbl_GlobalLockHandle; + } + + AcpiExExitInterpreter (); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiAcquireGlobalLock) + + +/******************************************************************************* + * + * FUNCTION: AcpiReleaseGlobalLock + * + * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock + * + * RETURN: Status + * + * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReleaseGlobalLock ( + UINT32 Handle) +{ + ACPI_STATUS Status; + + + if (!Handle || (Handle != AcpiGbl_GlobalLockHandle)) + { + return (AE_NOT_ACQUIRED); + } + + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiReleaseGlobalLock) + diff --git a/reactos/drivers/bus/acpi/acpica/events/evxfevnt.c b/reactos/drivers/bus/acpi/acpica/events/evxfevnt.c new file mode 100644 index 00000000000..27066a39946 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evxfevnt.c @@ -0,0 +1,1112 @@ +/****************************************************************************** + * + * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVXFEVNT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evxfevnt") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvGetGpeDevice ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEnable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Transfers the system into ACPI mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnable ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiEnable); + + + /* ACPI tables must be present */ + + if (!AcpiTbTablesLoaded ()) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Check current mode */ + + if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); + } + else + { + /* Transition to ACPI mode */ + + Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode")); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Transition to ACPI mode successful\n")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnable) + + +/******************************************************************************* + * + * FUNCTION: AcpiDisable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisable ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiDisable); + + + if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "System is already in legacy (non-ACPI) mode\n")); + } + else + { + /* Transition to LEGACY mode */ + + Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY); + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not exit ACPI mode to legacy mode")); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDisable) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableEvent + * + * PARAMETERS: Event - The fixed eventto be enabled + * Flags - Reserved + * + * RETURN: Status + * + * DESCRIPTION: Enable an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 Event, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (AcpiEnableEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Enable the requested fixed event (by writing a one to the enable + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_ENABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Make sure that the hardware responded */ + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Value != 1) + { + ACPI_ERROR ((AE_INFO, + "Could not enable %s event", AcpiUtGetEventName (Event))); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnableEvent) + + +/******************************************************************************* + * + * FUNCTION: AcpiSetGpeType + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Type - New GPE type + * + * RETURN: Status + * + * DESCRIPTION: Set the type of an individual GPE + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetGpeType ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Type) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiSetGpeType); + + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type) + { + return_ACPI_STATUS (AE_OK); + } + + /* Set the new type (will disable GPE if currently enabled) */ + + Status = AcpiEvSetGpeType (GpeEventInfo, Type); + +UnlockAndExit: + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiSetGpeType) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableGpe + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Just enable, or also wake enable? + * Called from ISR or not + * + * RETURN: Status + * + * DESCRIPTION: Enable an ACPI event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiEnableGpe); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Perform the enable */ + + Status = AcpiEvEnableGpe (GpeEventInfo, TRUE); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnableGpe) + + +/******************************************************************************* + * + * FUNCTION: AcpiDisableGpe + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Just disable, or also wake disable? + * Called from ISR or not + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiDisableGpe); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiEvDisableGpe (GpeEventInfo); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDisableGpe) + + +/******************************************************************************* + * + * FUNCTION: AcpiDisableEvent + * + * PARAMETERS: Event - The fixed eventto be enabled + * Flags - Reserved + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (AcpiDisableEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Disable the requested fixed event (by writing a zero to the enable + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Value != 0) + { + ACPI_ERROR ((AE_INFO, + "Could not disable %s events", AcpiUtGetEventName (Event))); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDisableEvent) + + +/******************************************************************************* + * + * FUNCTION: AcpiClearEvent + * + * PARAMETERS: Event - The fixed event to be cleared + * + * RETURN: Status + * + * DESCRIPTION: Clear an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiClearEvent ( + UINT32 Event) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiClearEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Clear the requested fixed event (By writing a one to the status + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiClearEvent) + + +/******************************************************************************* + * + * FUNCTION: AcpiClearGpe + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Called from an ISR or not + * + * RETURN: Status + * + * DESCRIPTION: Clear an ACPI event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiClearGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiClearGpe); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiHwClearGpe (GpeEventInfo); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiClearGpe) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetEventStatus + * + * PARAMETERS: Event - The fixed event + * EventStatus - Where the current status of the event will + * be returned + * + * RETURN: Status + * + * DESCRIPTION: Obtains and returns the current status of the event + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 Event, + ACPI_EVENT_STATUS *EventStatus) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiGetEventStatus); + + + if (!EventStatus) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the status of the requested fixed event */ + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetGpeStatus + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Called from an ISR or not + * EventStatus - Where the current status of the event will + * be returned + * + * RETURN: Status + * + * DESCRIPTION: Get status of an event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetGpeStatus ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags, + ACPI_EVENT_STATUS *EventStatus) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiGetGpeStatus); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Obtain status on the requested GPE number */ + + Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device + * GpeBlockAddress - Address and SpaceID + * RegisterCount - Number of GPE register pairs in the block + * InterruptNumber - H/W interrupt for the block + * + * RETURN: Status + * + * DESCRIPTION: Create and Install a block of GPE registers + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallGpeBlock ( + ACPI_HANDLE GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT32 InterruptNumber) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_GPE_BLOCK_INFO *GpeBlock; + + + ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock); + + + if ((!GpeDevice) || + (!GpeBlockAddress) || + (!RegisterCount)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (GpeDevice); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * For user-installed GPE Block Devices, the GpeBlockBaseNumber + * is always zero + */ + Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount, + 0, InterruptNumber, &GpeBlock); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Run the _PRW methods and enable the GPEs */ + + Status = AcpiEvInitializeGpeBlock (Node, GpeBlock); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Get the DeviceObject attached to the node */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, create a new one */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + /* Install the GPE block in the DeviceObject */ + + ObjDesc->Device.GpeBlock = GpeBlock; + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device + * + * RETURN: Status + * + * DESCRIPTION: Remove a previously installed block of GPE registers + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveGpeBlock ( + ACPI_HANDLE GpeDevice) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock); + + + if (!GpeDevice) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (GpeDevice); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Get the DeviceObject attached to the node */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc || + !ObjDesc->Device.GpeBlock) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Delete the GPE block (but not the DeviceObject) */ + + Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock); + if (ACPI_SUCCESS (Status)) + { + ObjDesc->Device.GpeBlock = NULL; + } + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetGpeDevice + * + * PARAMETERS: Index - System GPE index (0-CurrentGpeCount) + * GpeDevice - Where the parent GPE Device is returned + * + * RETURN: Status + * + * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL + * gpe device indicates that the gpe number is contained in one of + * the FADT-defined gpe blocks. Otherwise, the GPE block device. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetGpeDevice ( + UINT32 Index, + ACPI_HANDLE *GpeDevice) +{ + ACPI_GPE_DEVICE_INFO Info; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetGpeDevice); + + + if (!GpeDevice) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (Index >= AcpiCurrentGpeCount) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Setup and walk the GPE list */ + + Info.Index = Index; + Info.Status = AE_NOT_EXIST; + Info.GpeDevice = NULL; + Info.NextBlockBaseIndex = 0; + + Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice); + return_ACPI_STATUS (Info.Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice) + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeDevice + * + * PARAMETERS: GPE_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE + * block device. NULL if the GPE is one of the FADT-defined GPEs. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvGetGpeDevice ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + ACPI_GPE_DEVICE_INFO *Info = Context; + + + /* Increment Index by the number of GPEs in this block */ + + Info->NextBlockBaseIndex += + (GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH); + + if (Info->Index < Info->NextBlockBaseIndex) + { + /* + * The GPE index is within this block, get the node. Leave the node + * NULL for the FADT-defined GPEs + */ + if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE) + { + Info->GpeDevice = GpeBlock->Node; + } + + Info->Status = AE_OK; + return (AE_CTRL_END); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiDisableAllGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableAllGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiDisableAllGpes); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwDisableAllGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEnableAllRuntimeGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableAllRuntimeGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwEnableAllRuntimeGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evxfregn.c b/reactos/drivers/bus/acpi/acpica/events/evxfregn.c new file mode 100644 index 00000000000..3b60589b71a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evxfregn.c @@ -0,0 +1,346 @@ +/****************************************************************************** + * + * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and + * Address Spaces. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EVXFREGN_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evxfregn") + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallAddressSpaceHandler + * + * PARAMETERS: Device - Handle for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler); + + + /* Parameter validation */ + + if (!Device) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Install the handler for all Regions for this Space ID */ + + Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Run all _REG methods for this address space */ + + Status = AcpiEvExecuteRegMethods (Node, SpaceId); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallAddressSpaceHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveAddressSpaceHandler + * + * PARAMETERS: Device - Handle for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a previously installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *RegionObj; + ACPI_OPERAND_OBJECT **LastObjPtr; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveAddressSpaceHandler); + + + /* Parameter validation */ + + if (!Device) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node || + ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode))) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure the internal object exists */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Find the address handler the user requested */ + + HandlerObj = ObjDesc->Device.Handler; + LastObjPtr = &ObjDesc->Device.Handler; + while (HandlerObj) + { + /* We have a handler, see if user requested this one */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + /* Handler must be the same as the installed handler */ + + if (HandlerObj->AddressSpace.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Matched SpaceId, first dereference this in the Regions */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Removing address handler %p(%p) for region %s " + "on Device %p(%p)\n", + HandlerObj, Handler, AcpiUtGetRegionName (SpaceId), + Node, ObjDesc)); + + RegionObj = HandlerObj->AddressSpace.RegionList; + + /* Walk the handler's region list */ + + while (RegionObj) + { + /* + * First disassociate the handler from the region. + * + * NOTE: this doesn't mean that the region goes away + * The region is just inaccessible as indicated to + * the _REG method + */ + AcpiEvDetachRegion (RegionObj, TRUE); + + /* + * Walk the list: Just grab the head because the + * DetachRegion removed the previous head. + */ + RegionObj = HandlerObj->AddressSpace.RegionList; + + } + + /* Remove this Handler object from the list */ + + *LastObjPtr = HandlerObj->AddressSpace.Next; + + /* Now we can delete the handler object */ + + AcpiUtRemoveReference (HandlerObj); + goto UnlockAndExit; + } + + /* Walk the linked list of handlers */ + + LastObjPtr = &HandlerObj->AddressSpace.Next; + HandlerObj = HandlerObj->AddressSpace.Next; + } + + /* The handler does not exist */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Unable to remove address handler %p for %s(%X), DevNode %p, obj %p\n", + Handler, AcpiUtGetRegionName (SpaceId), SpaceId, Node, ObjDesc)); + + Status = AE_NOT_EXIST; + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveAddressSpaceHandler) + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exconfig.c b/reactos/drivers/bus/acpi/acpica/executer/exconfig.c new file mode 100644 index 00000000000..d0acdd5f803 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exconfig.c @@ -0,0 +1,751 @@ +/****************************************************************************** + * + * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXCONFIG_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acdispat.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconfig") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExAddTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle); + +static ACPI_STATUS +AcpiExRegionRead ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Length, + UINT8 *Buffer); + + +/******************************************************************************* + * + * FUNCTION: AcpiExAddTable + * + * PARAMETERS: Table - Pointer to raw table + * ParentNode - Where to load the table (scope) + * DdbHandle - Where to return the table handle. + * + * RETURN: Status + * + * DESCRIPTION: Common function to Install and Load an ACPI table with a + * returned table handle. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExAddTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (ExAddTable); + + + /* Create an object to be the table handle */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init the table handle */ + + ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; + ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE; + *DdbHandle = ObjDesc; + + /* Install the new table into the local data structures */ + + ObjDesc->Reference.Value = TableIndex; + + /* Add the table to the namespace */ + + Status = AcpiNsLoadTable (TableIndex, ParentNode); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + *DdbHandle = NULL; + return_ACPI_STATUS (Status); + } + + /* Execute any module-level code that was found in the table */ + + AcpiExExitInterpreter (); + AcpiNsExecModuleCodeList (); + AcpiExEnterInterpreter (); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLoadTableOp + * + * PARAMETERS: WalkState - Current state with operands + * ReturnDesc - Where to store the return object + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from the RSDT/XSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExLoadTableOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *StartNode; + ACPI_NAMESPACE_NODE *ParameterNode = NULL; + ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *Table; + UINT32 TableIndex; + + + ACPI_FUNCTION_TRACE (ExLoadTableOp); + + + /* Validate lengths for the SignatureString, OEMIDString, OEMTableID */ + + if ((Operand[0]->String.Length > ACPI_NAME_SIZE) || + (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) || + (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Find the ACPI table in the RSDT/XSDT */ + + Status = AcpiTbFindTable (Operand[0]->String.Pointer, + Operand[1]->String.Pointer, + Operand[2]->String.Pointer, &TableIndex); + if (ACPI_FAILURE (Status)) + { + if (Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Table not found, return an Integer=0 and AE_OK */ + + DdbHandle = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!DdbHandle) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + *ReturnDesc = DdbHandle; + return_ACPI_STATUS (AE_OK); + } + + /* Default nodes */ + + StartNode = WalkState->ScopeInfo->Scope.Node; + ParentNode = AcpiGbl_RootNode; + + /* RootPath (optional parameter) */ + + if (Operand[3]->String.Length > 0) + { + /* + * Find the node referenced by the RootPathString. This is the + * location within the namespace where the table will be loaded. + */ + Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer, + ACPI_NS_SEARCH_PARENT, &ParentNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* ParameterPath (optional parameter) */ + + if (Operand[4]->String.Length > 0) + { + if ((Operand[4]->String.Pointer[0] != '\\') && + (Operand[4]->String.Pointer[0] != '^')) + { + /* + * Path is not absolute, so it will be relative to the node + * referenced by the RootPathString (or the NS root if omitted) + */ + StartNode = ParentNode; + } + + /* Find the node referenced by the ParameterPathString */ + + Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, + ACPI_NS_SEARCH_PARENT, &ParameterNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Load the table into the namespace */ + + Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Parameter Data (optional) */ + + if (ParameterNode) + { + /* Store the parameter data into the optional parameter object */ + + Status = AcpiExStore (Operand[5], + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), + WalkState); + if (ACPI_FAILURE (Status)) + { + (void) AcpiExUnloadTable (DdbHandle); + + AcpiUtRemoveReference (DdbHandle); + return_ACPI_STATUS (Status); + } + } + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + ACPI_INFO ((AE_INFO, + "Dynamic OEM Table Load - [%.4s] OemId [%.6s] OemTableId [%.8s]", + Table->Signature, Table->OemId, Table->OemTableId)); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, + AcpiGbl_TableHandlerContext); + } + + *ReturnDesc = DdbHandle; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRegionRead + * + * PARAMETERS: ObjDesc - Region descriptor + * Length - Number of bytes to read + * Buffer - Pointer to where to put the data + * + * RETURN: Status + * + * DESCRIPTION: Read data from an operation region. The read starts from the + * beginning of the region. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExRegionRead ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Length, + UINT8 *Buffer) +{ + ACPI_STATUS Status; + ACPI_INTEGER Value; + UINT32 RegionOffset = 0; + UINT32 i; + + + /* Bytewise reads */ + + for (i = 0; i < Length; i++) + { + Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, + RegionOffset, 8, &Value); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *Buffer = (UINT8) Value; + Buffer++; + RegionOffset++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLoadOp + * + * PARAMETERS: ObjDesc - Region or Buffer/Field where the table will be + * obtained + * Target - Where a handle to the table will be stored + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from a field or operation region + * + * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer + * objects before this code is reached. + * + * If source is an operation region, it must refer to SystemMemory, as + * per the ACPI specification. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExLoadOp ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *Target, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *Table; + ACPI_TABLE_DESC TableDesc; + UINT32 TableIndex; + ACPI_STATUS Status; + UINT32 Length; + + + ACPI_FUNCTION_TRACE (ExLoadOp); + + + ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); + + /* Source Object can be either an OpRegion or a Buffer/Field */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_REGION: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Load table from Region %p\n", ObjDesc)); + + /* Region must be SystemMemory (from ACPI spec) */ + + if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetRegionArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Get the table header first so we can get the table length */ + + Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), + ACPI_CAST_PTR (UINT8, Table)); + Length = Table->Length; + ACPI_FREE (Table); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Must have at least an ACPI table header */ + + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* + * The original implementation simply mapped the table, with no copy. + * However, the memory region is not guaranteed to remain stable and + * we must copy the table to a local buffer. For example, the memory + * region is corrupted after suspend on some machines. Dynamically + * loaded tables are usually small, so this overhead is minimal. + * + * The latest implementation (5/2009) does not use a mapping at all. + * We use the low-level operation region interface to read the table + * instead of the obvious optimization of using a direct mapping. + * This maintains a consistent use of operation regions across the + * entire subsystem. This is important if additional processing must + * be performed in the (possibly user-installed) operation region + * handler. For example, AcpiExec and ASLTS depend on this. + */ + + /* Allocate a buffer for the table */ + + TableDesc.Pointer = ACPI_ALLOCATE (Length); + if (!TableDesc.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Read the entire table */ + + Status = AcpiExRegionRead (ObjDesc, Length, + ACPI_CAST_PTR (UINT8, TableDesc.Pointer)); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (TableDesc.Pointer); + return_ACPI_STATUS (Status); + } + + TableDesc.Address = ObjDesc->Region.Address; + break; + + + case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Load table from Buffer or Field %p\n", ObjDesc)); + + /* Must have at least an ACPI table header */ + + if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* Get the actual table length from the table header */ + + Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); + Length = Table->Length; + + /* Table cannot extend beyond the buffer */ + + if (Length > ObjDesc->Buffer.Length) + { + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* + * Copy the table from the buffer because the buffer could be modified + * or even deleted in the future + */ + TableDesc.Pointer = ACPI_ALLOCATE (Length); + if (!TableDesc.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MEMCPY (TableDesc.Pointer, Table, Length); + TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer); + break; + + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Validate table checksum (will not get validated in TbAddTable) */ + + Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (TableDesc.Pointer); + return_ACPI_STATUS (Status); + } + + /* Complete the table descriptor */ + + TableDesc.Length = Length; + TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; + + /* Install the new table into the local data structures */ + + Status = AcpiTbAddTable (&TableDesc, &TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Add the table to the namespace. + * + * Note: Load the table objects relative to the root of the namespace. + * This appears to go against the ACPI specification, but we do it for + * compatibility with other ACPI implementations. + */ + Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle); + if (ACPI_FAILURE (Status)) + { + /* On error, TablePtr was deallocated above */ + + return_ACPI_STATUS (Status); + } + + /* Store the DdbHandle into the Target operand */ + + Status = AcpiExStore (DdbHandle, Target, WalkState); + if (ACPI_FAILURE (Status)) + { + (void) AcpiExUnloadTable (DdbHandle); + + /* TablePtr was deallocated above */ + + AcpiUtRemoveReference (DdbHandle); + return_ACPI_STATUS (Status); + } + + /* Remove the reference by added by AcpiExStore above */ + + AcpiUtRemoveReference (DdbHandle); + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer, + AcpiGbl_TableHandlerContext); + } + +Cleanup: + if (ACPI_FAILURE (Status)) + { + /* Delete allocated table buffer */ + + AcpiTbDeleteTable (&TableDesc); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExUnloadTable + * + * PARAMETERS: DdbHandle - Handle to a previously loaded table + * + * RETURN: Status + * + * DESCRIPTION: Unload an ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExUnloadTable ( + ACPI_OPERAND_OBJECT *DdbHandle) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; + UINT32 TableIndex; + ACPI_TABLE_HEADER *Table; + + + ACPI_FUNCTION_TRACE (ExUnloadTable); + + + /* + * Validate the handle + * Although the handle is partially validated in AcpiExReconfiguration() + * when it calls AcpiExResolveOperands(), the handle is more completely + * validated here. + * + * Handle must be a valid operand object of type reference. Also, the + * DdbHandle must still be marked valid (table has not been previously + * unloaded) + */ + if ((!DdbHandle) || + (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || + (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) || + (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the table index from the DdbHandle */ + + TableIndex = TableDesc->Reference.Value; + + /* Ensure the table is still loaded */ + + if (!AcpiTbIsTableLoaded (TableIndex)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, + AcpiGbl_TableHandlerContext); + } + } + + /* Delete the portion of the namespace owned by this table */ + + Status = AcpiTbDeleteNamespaceByOwner (TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + (void) AcpiTbReleaseOwnerId (TableIndex); + AcpiTbSetTableLoadedFlag (TableIndex, FALSE); + + /* + * Invalidate the handle. We do this because the handle may be stored + * in a named object and may not be actually deleted until much later. + */ + DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; + return_ACPI_STATUS (AE_OK); +} + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c b/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c new file mode 100644 index 00000000000..fd8fec1c711 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c @@ -0,0 +1,826 @@ +/****************************************************************************** + * + * Module Name: exconvrt - Object conversion routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXCONVRT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconvrt") + +/* Local prototypes */ + +static UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT16 Base, + UINT8 *String, + UINT8 MaxLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToInteger + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the new Integer object is returned + * Flags - Used for string conversion + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to an integer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToInteger ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Flags) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *Pointer; + ACPI_INTEGER Result; + UINT32 i; + UINT32 Count; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + + /* Note: Takes advantage of common buffer/string fields */ + + Pointer = ObjDesc->Buffer.Pointer; + Count = ObjDesc->Buffer.Length; + break; + + default: + return_ACPI_STATUS (AE_TYPE); + } + + /* + * Convert the buffer/string to an integer. Note that both buffers and + * strings are treated as raw data - we don't convert ascii to hex for + * strings. + * + * There are two terminating conditions for the loop: + * 1) The size of an integer has been reached, or + * 2) The end of the buffer or string has been reached + */ + Result = 0; + + /* String conversion is different than Buffer conversion */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + + /* + * Convert string to an integer - for most cases, the string must be + * hexadecimal as per the ACPI specification. The only exception (as + * of ACPI 3.0) is that the ToInteger() operator allows both decimal + * and hexadecimal strings (hex prefixed with "0x"). + */ + Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case ACPI_TYPE_BUFFER: + + /* Check for zero-length buffer */ + + if (!Count) + { + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + + /* Transfer no more than an integer's worth of data */ + + if (Count > AcpiGbl_IntegerByteWidth) + { + Count = AcpiGbl_IntegerByteWidth; + } + + /* + * Convert buffer to an integer - we simply grab enough raw data + * from the buffer to fill an integer + */ + for (i = 0; i < Count; i++) + { + /* + * Get next byte and shift it into the Result. + * Little endian is used, meaning that the first byte of the buffer + * is the LSB of the integer + */ + Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8)); + } + break; + + + default: + + /* No other types can get here */ + break; + } + + /* Create a new integer */ + + ReturnDesc = AcpiUtCreateIntegerObject (Result); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Result))); + + /* Save the Result */ + + AcpiExTruncateFor32bitTable (ReturnDesc); + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToBuffer + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the new buffer object is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to a Buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToBuffer ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + + case ACPI_TYPE_INTEGER: + + /* + * Create a new Buffer object. + * Need enough space for one integer + */ + ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the integer to the buffer, LSB first */ + + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_MEMCPY (NewBuf, + &ObjDesc->Integer.Value, + AcpiGbl_IntegerByteWidth); + break; + + + case ACPI_TYPE_STRING: + + /* + * Create a new Buffer object + * Size will be the string length + * + * NOTE: Add one to the string length to include the null terminator. + * The ACPI spec is unclear on this subject, but there is existing + * ASL/AML code that depends on the null being transferred to the new + * buffer. + */ + ReturnDesc = AcpiUtCreateBufferObject ( + (ACPI_SIZE) ObjDesc->String.Length + 1); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the string to the buffer */ + + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, + ObjDesc->String.Length); + break; + + + default: + return_ACPI_STATUS (AE_TYPE); + } + + /* Mark buffer initialized */ + + ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID; + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToAscii + * + * PARAMETERS: Integer - Value to be converted + * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX + * String - Where the string is returned + * DataWidth - Size of data item to be converted, in bytes + * + * RETURN: Actual string length + * + * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string + * + ******************************************************************************/ + +static UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT16 Base, + UINT8 *String, + UINT8 DataWidth) +{ + ACPI_INTEGER Digit; + UINT32 i; + UINT32 j; + UINT32 k = 0; + UINT32 HexLength; + UINT32 DecimalLength; + UINT32 Remainder; + BOOLEAN SupressZeros; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Base) + { + case 10: + + /* Setup max length for the decimal number */ + + switch (DataWidth) + { + case 1: + DecimalLength = ACPI_MAX8_DECIMAL_DIGITS; + break; + + case 4: + DecimalLength = ACPI_MAX32_DECIMAL_DIGITS; + break; + + case 8: + default: + DecimalLength = ACPI_MAX64_DECIMAL_DIGITS; + break; + } + + SupressZeros = TRUE; /* No leading zeros */ + Remainder = 0; + + for (i = DecimalLength; i > 0; i--) + { + /* Divide by nth factor of 10 */ + + Digit = Integer; + for (j = 0; j < i; j++) + { + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder); + } + + /* Handle leading zeros */ + + if (Remainder != 0) + { + SupressZeros = FALSE; + } + + if (!SupressZeros) + { + String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); + k++; + } + } + break; + + case 16: + + /* HexLength: 2 ascii hex chars per data byte */ + + HexLength = ACPI_MUL_2 (DataWidth); + for (i = 0, j = (HexLength-1); i < HexLength; i++, j--) + { + /* Get one hex digit, most significant digits first */ + + String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); + k++; + } + break; + + default: + return (0); + } + + /* + * Since leading zeros are suppressed, we must check for the case where + * the integer equals 0 + * + * Finally, null terminate the string and return the length + */ + if (!k) + { + String [0] = ACPI_ASCII_ZERO; + k = 1; + } + + String [k] = 0; + return ((UINT32) k); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToString + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the string object is returned + * Type - String flags (base and conversion type) + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to a string + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Type) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + UINT32 i; + UINT32 StringLength = 0; + UINT16 Base = 16; + UINT8 Separator = ','; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + + case ACPI_TYPE_INTEGER: + + switch (Type) + { + case ACPI_EXPLICIT_CONVERT_DECIMAL: + + /* Make room for maximum decimal number */ + + StringLength = ACPI_MAX_DECIMAL_DIGITS; + Base = 10; + break; + + default: + + /* Two hex string characters for each integer byte */ + + StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth); + break; + } + + /* + * Create a new String + * Need enough space for one ASCII integer (plus null terminator) + */ + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + NewBuf = ReturnDesc->Buffer.Pointer; + + /* Convert integer to string */ + + StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, + NewBuf, AcpiGbl_IntegerByteWidth); + + /* Null terminate at the correct place */ + + ReturnDesc->String.Length = StringLength; + NewBuf [StringLength] = 0; + break; + + + case ACPI_TYPE_BUFFER: + + /* Setup string length, base, and separator */ + + switch (Type) + { + case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * decimal values separated by commas." + */ + Base = 10; + + /* + * Calculate the final string length. Individual string values + * are variable length (include separator for each) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + if (ObjDesc->Buffer.Pointer[i] >= 100) + { + StringLength += 4; + } + else if (ObjDesc->Buffer.Pointer[i] >= 10) + { + StringLength += 3; + } + else + { + StringLength += 2; + } + } + break; + + case ACPI_IMPLICIT_CONVERT_HEX: + /* + * From the ACPI spec: + *"The entire contents of the buffer are converted to a string of + * two-character hexadecimal numbers, each separated by a space." + */ + Separator = ' '; + StringLength = (ObjDesc->Buffer.Length * 3); + break; + + case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * hexadecimal values separated by commas." + */ + StringLength = (ObjDesc->Buffer.Length * 3); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Create a new string object and string buffer + * (-1 because of extra separator included in StringLength from above) + * Allow creation of zero-length strings from zero-length buffers. + */ + if (StringLength) + { + StringLength--; + } + + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + NewBuf = ReturnDesc->Buffer.Pointer; + + /* + * Convert buffer bytes to hex or decimal values + * (separated by commas or spaces) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + NewBuf += AcpiExConvertToAscii ( + (ACPI_INTEGER) ObjDesc->Buffer.Pointer[i], Base, + NewBuf, 1); + *NewBuf++ = Separator; /* each separated by a comma or space */ + } + + /* + * Null terminate the string + * (overwrites final comma/space from above) + */ + if (ObjDesc->Buffer.Length) + { + NewBuf--; + } + *NewBuf = 0; + break; + + default: + return_ACPI_STATUS (AE_TYPE); + } + + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToTargetType + * + * PARAMETERS: DestinationType - Current type of the destination + * SourceDesc - Source object to be converted. + * ResultDesc - Where the converted object is returned + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Implements "implicit conversion" rules for storing an object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToTargetType ( + ACPI_OBJECT_TYPE DestinationType, + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExConvertToTargetType); + + + /* Default behavior */ + + *ResultDesc = SourceDesc; + + /* + * If required by the target, + * perform implicit conversion on the source before we store it. + */ + switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) + { + case ARGI_SIMPLE_TARGET: + case ARGI_FIXED_TARGET: + case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ + + switch (DestinationType) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + /* + * Named field can always handle conversions + */ + break; + + default: + /* No conversion allowed for these types */ + + if (DestinationType != SourceDesc->Common.Type) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Explicit operator, will store (%s) over existing type (%s)\n", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetTypeName (DestinationType))); + Status = AE_TYPE; + } + } + break; + + + case ARGI_TARGETREF: + + switch (DestinationType) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* + * These types require an Integer operand. We can convert + * a Buffer or a String to an Integer if necessary. + */ + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, + 16); + break; + + + case ACPI_TYPE_STRING: + /* + * The operand must be a String. We can convert an + * Integer or Buffer if necessary + */ + Status = AcpiExConvertToString (SourceDesc, ResultDesc, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + + case ACPI_TYPE_BUFFER: + /* + * The operand must be a Buffer. We can convert an + * Integer or String if necessary + */ + Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: %X", + DestinationType)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ARGI_REFERENCE: + /* + * CreateXxxxField cases - we are storing the field object into the name + */ + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Unknown Target type ID 0x%X AmlOpcode %X DestType %s", + GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), + WalkState->Opcode, AcpiUtGetTypeName (DestinationType))); + Status = AE_AML_INTERNAL; + } + + /* + * Source-to-Target conversion semantics: + * + * If conversion to the target type cannot be performed, then simply + * overwrite the target with the new object and type. + */ + if (Status == AE_TYPE) + { + Status = AE_OK; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/excreate.c b/reactos/drivers/bus/acpi/acpica/executer/excreate.c new file mode 100644 index 00000000000..e5463187a86 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/excreate.c @@ -0,0 +1,636 @@ +/****************************************************************************** + * + * Module Name: excreate - Named object creation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXCREATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("excreate") + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiExCreateAlias + * + * PARAMETERS: WalkState - Current state, contains operands + * + * RETURN: Status + * + * DESCRIPTION: Create a new named alias + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateAlias ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_NAMESPACE_NODE *TargetNode; + ACPI_NAMESPACE_NODE *AliasNode; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExCreateAlias); + + + /* Get the source/alias operands (both namespace nodes) */ + + AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; + + if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) || + (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) + { + /* + * Dereference an existing alias so that we don't create a chain + * of aliases. With this code, we guarantee that an alias is + * always exactly one level of indirection away from the + * actual aliased name. + */ + TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object); + } + + /* + * For objects that can never change (i.e., the NS node will + * permanently point to the same object), we can simply attach + * the object to the new NS node. For other objects (such as + * Integers, buffers, etc.), we have to point the Alias node + * to the original Node. + */ + switch (TargetNode->Type) + { + + /* For these types, the sub-object can change dynamically via a Store */ + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_BUFFER_FIELD: + + /* + * These types open a new scope, so we need the NS node in order to access + * any children. + */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_LOCAL_SCOPE: + + /* + * The new alias has the type ALIAS and points to the original + * NS node, not the object itself. + */ + AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; + AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); + break; + + case ACPI_TYPE_METHOD: + + /* + * Control method aliases need to be differentiated + */ + AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS; + AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); + break; + + default: + + /* Attach the original source object to the new Alias Node */ + + /* + * The new alias assumes the type of the target, and it points + * to the same object. The reference count of the object has an + * additional reference to prevent deletion out from under either the + * target node or the alias Node + */ + Status = AcpiNsAttachObject (AliasNode, + AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); + break; + } + + /* Since both operands are Nodes, we don't need to delete them */ + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateEvent + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new event object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateEvent ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (ExCreateEvent); + + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Create the actual OS semaphore, with zero initial units -- meaning + * that the event is created in an unsignalled state + */ + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, + &ObjDesc->Event.OsSemaphore); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Attach object to the Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], + ObjDesc, ACPI_TYPE_EVENT); + +Cleanup: + /* + * Remove local reference to the object (on error, will cause deletion + * of both object and semaphore if present.) + */ + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateMutex + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new mutex object + * + * Mutex (Name[0], SyncLevel[1]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateMutex ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS); + + + /* Create the new mutex object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create the actual OS Mutex */ + + Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Init object and attach to NS node */ + + ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; + ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + + Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); + + +Cleanup: + /* + * Remove local reference to the object (on error, will cause deletion + * of both object and semaphore if present.) + */ + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateRegion + * + * PARAMETERS: AmlStart - Pointer to the region declaration AML + * AmlLength - Max length of the declaration AML + * RegionSpace - SpaceID for the region + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new operation region object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateRegion ( + UINT8 *AmlStart, + UINT32 AmlLength, + UINT8 RegionSpace, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *RegionObj2; + + + ACPI_FUNCTION_TRACE (ExCreateRegion); + + + /* Get the Namespace Node */ + + Node = WalkState->Op->Common.Node; + + /* + * If the region object is already attached to this node, + * just return + */ + if (AcpiNsGetAttachedObject (Node)) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Space ID must be one of the predefined IDs, or in the user-defined + * range + */ + if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && + (RegionSpace < ACPI_USER_REGION_BEGIN)) + { + ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type %X", RegionSpace)); + return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", + AcpiUtGetRegionName (RegionSpace), RegionSpace)); + + /* Create the region descriptor */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Remember location in AML stream of address & length + * operands since they need to be evaluated at run time. + */ + RegionObj2 = ObjDesc->Common.NextObject; + RegionObj2->Extra.AmlStart = AmlStart; + RegionObj2->Extra.AmlLength = AmlLength; + + /* Init the region from the operands */ + + ObjDesc->Region.SpaceId = RegionSpace; + ObjDesc->Region.Address = 0; + ObjDesc->Region.Length = 0; + ObjDesc->Region.Node = Node; + + /* Install the new region object in the parent Node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); + + +Cleanup: + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateProcessor + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new processor object and populate the fields + * + * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateProcessor ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState); + + + /* Create the processor object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the processor object from the operands */ + + ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; + ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; + ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; + + /* Install the processor object in the parent Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_PROCESSOR); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreatePowerResource + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new PowerResource object and populate the fields + * + * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreatePowerResource ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState); + + + /* Create the power resource object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the power object from the operands */ + + ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; + ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; + + /* Install the power resource object in the parent Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_POWER); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateMethod + * + * PARAMETERS: AmlStart - First byte of the method's AML + * AmlLength - AML byte count for this method + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new method object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateMethod ( + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + UINT8 MethodFlags; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState); + + + /* Create a new method object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Exit; + } + + /* Save the method's AML pointer and length */ + + ObjDesc->Method.AmlStart = AmlStart; + ObjDesc->Method.AmlLength = AmlLength; + + /* + * Disassemble the method flags. Split off the Arg Count + * for efficiency + */ + MethodFlags = (UINT8) Operand[1]->Integer.Value; + + ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT); + ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); + + /* + * Get the SyncLevel. If method is serialized, a mutex will be + * created for this method when it is parsed. + */ + if (MethodFlags & AML_METHOD_SERIALIZED) + { + /* + * ACPI 1.0: SyncLevel = 0 + * ACPI 2.0: SyncLevel = SyncLevel in method declaration + */ + ObjDesc->Method.SyncLevel = (UINT8) + ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); + } + + /* Attach the new object to the method Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_METHOD); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + +Exit: + /* Remove a reference to the operand */ + + AcpiUtRemoveReference (Operand[1]); + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exdump.c b/reactos/drivers/bus/acpi/acpica/executer/exdump.c new file mode 100644 index 00000000000..5de5a6f6e40 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exdump.c @@ -0,0 +1,1194 @@ +/****************************************************************************** + * + * Module Name: exdump - Interpreter debug output routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exdump") + +/* + * The following routines are used for debug output only + */ +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Local prototypes */ + +static void +AcpiExOutString ( + char *Title, + char *Value); + +static void +AcpiExOutPointer ( + char *Title, + void *Value); + +static void +AcpiExDumpObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_EXDUMP_INFO *Info); + +static void +AcpiExDumpReferenceObj ( + ACPI_OPERAND_OBJECT *ObjDesc); + +static void +AcpiExDumpPackageObj ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Level, + UINT32 Index); + + +/******************************************************************************* + * + * Object Descriptor info tables + * + * Note: The first table entry must be an INIT opcode and must contain + * the table length (number of table entries) + * + ******************************************************************************/ + +static ACPI_EXDUMP_INFO AcpiExDumpInteger[2] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger), NULL}, + {ACPI_EXD_UINT64, ACPI_EXD_OFFSET (Integer.Value), "Value"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpString[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpString), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (String.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (String.Pointer), "Pointer"}, + {ACPI_EXD_STRING, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"}, + {ACPI_EXD_BUFFER, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpPackage[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Package.Flags), "Flags"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Package.Count), "Elements"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Package.Elements), "Element List"}, + {ACPI_EXD_PACKAGE, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.Handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.DeviceNotify), "Device Notify"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.MethodFlags), "Method Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ThreadCount), "Thread Count"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Method.AmlLength), "Aml Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"}, + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpRegion[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.SpaceId), "Space Id"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.Flags), "Flags"}, + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Region.Address), "Address"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Region.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Next), "Next"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpPower[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPower), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.SystemLevel), "System Level"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.ResourceOrder), "Resource Order"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.DeviceNotify), "Device Notify"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"}, + {ACPI_EXD_UINT8 , ACPI_EXD_OFFSET (Processor.Length), "Length"}, + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Processor.Address), "Address"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.DeviceNotify), "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.Handler), "Handler"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpThermal[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.DeviceNotify), "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.Handler), "Handler"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBufferField[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BufferField.BufferObj), "Buffer Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpRegionField[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.RegionObj), "Region Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBankField[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (BankField.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.RegionObj), "Region Object"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.BankObj), "Bank Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (IndexField.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.IndexObj), "Index Object"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"}, + {ACPI_EXD_REFERENCE,0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpAddressHandler[6] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (AddressSpace.SpaceId), "Space Id"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Next), "Next"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Context), "Context"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpNotify[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Context), "Context"} +}; + + +/* Miscellaneous tables */ + +static ACPI_EXDUMP_INFO AcpiExDumpCommon[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon), NULL}, + {ACPI_EXD_TYPE , 0, NULL}, + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Common.ReferenceCount), "Reference Count"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.FieldFlags), "Field Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.AccessByteWidth), "Access Byte Width"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BitLength), "Bit Length"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BaseByteOffset), "Base Byte Offset"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpNode[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (Flags), "Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"}, + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Child), "Child List"}, + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Peer), "Next Peer"} +}; + + +/* Dispatch table, indexed by object type */ + +static ACPI_EXDUMP_INFO *AcpiExDumpInfo[] = +{ + NULL, + AcpiExDumpInteger, + AcpiExDumpString, + AcpiExDumpBuffer, + AcpiExDumpPackage, + NULL, + AcpiExDumpDevice, + AcpiExDumpEvent, + AcpiExDumpMethod, + AcpiExDumpMutex, + AcpiExDumpRegion, + AcpiExDumpPower, + AcpiExDumpProcessor, + AcpiExDumpThermal, + AcpiExDumpBufferField, + NULL, + NULL, + AcpiExDumpRegionField, + AcpiExDumpBankField, + AcpiExDumpIndexField, + AcpiExDumpReference, + NULL, + NULL, + AcpiExDumpNotify, + AcpiExDumpAddressHandler, + NULL, + NULL, + NULL +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpObject + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Info - Info table corresponding to this object + * type + * + * RETURN: None + * + * DESCRIPTION: Walk the info table for this object + * + ******************************************************************************/ + +static void +AcpiExDumpObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_EXDUMP_INFO *Info) +{ + UINT8 *Target; + char *Name; + UINT8 Count; + + + if (!Info) + { + AcpiOsPrintf ( + "ExDumpObject: Display not implemented for object type %s\n", + AcpiUtGetObjectTypeName (ObjDesc)); + return; + } + + /* First table entry must contain the table length (# of table entries) */ + + Count = Info->Offset; + + while (Count) + { + Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset); + Name = Info->Name; + + switch (Info->Opcode) + { + case ACPI_EXD_INIT: + break; + + case ACPI_EXD_TYPE: + + AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); + break; + + case ACPI_EXD_UINT8: + + AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target); + break; + + case ACPI_EXD_UINT16: + + AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target)); + break; + + case ACPI_EXD_UINT32: + + AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target)); + break; + + case ACPI_EXD_UINT64: + + AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value", + ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); + break; + + case ACPI_EXD_POINTER: + case ACPI_EXD_ADDRESS: + + AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target)); + break; + + case ACPI_EXD_STRING: + + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); + AcpiOsPrintf ("\n"); + break; + + case ACPI_EXD_BUFFER: + + ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); + break; + + case ACPI_EXD_PACKAGE: + + /* Dump the package contents */ + + AcpiOsPrintf ("\nPackage Contents:\n"); + AcpiExDumpPackageObj (ObjDesc, 0, 0); + break; + + case ACPI_EXD_FIELD: + + AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon); + break; + + case ACPI_EXD_REFERENCE: + + AcpiExOutString ("Class Name", + ACPI_CAST_PTR (char, AcpiUtGetReferenceName (ObjDesc))); + AcpiExDumpReferenceObj (ObjDesc); + break; + + default: + + AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", + Info->Opcode); + return; + } + + Info++; + Count--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpOperand + * + * PARAMETERS: *ObjDesc - Pointer to entry to be dumped + * Depth - Current nesting depth + * + * RETURN: None + * + * DESCRIPTION: Dump an operand object + * + ******************************************************************************/ + +void +AcpiExDumpOperand ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth) +{ + UINT32 Length; + UINT32 Index; + + + ACPI_FUNCTION_NAME (ExDumpOperand) + + + if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + + if (!ObjDesc) + { + /* This could be a null element of a package */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); + return; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc)); + ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC); + return; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%p is not a node or operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); + ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); + return; + } + + /* ObjDesc is a valid object */ + + if (Depth > 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", + Depth, " ", Depth, ObjDesc)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); + } + + /* Decode object type */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc)); + + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_DEBUG: + + AcpiOsPrintf ("\n"); + break; + + + case ACPI_REFCLASS_INDEX: + + AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object); + break; + + + case ACPI_REFCLASS_TABLE: + + AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value); + break; + + + case ACPI_REFCLASS_REFOF: + + AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object, + AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) + ObjDesc->Reference.Object)->Common.Type)); + break; + + + case ACPI_REFCLASS_NAME: + + AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii); + break; + + + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_LOCAL: + + AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value); + break; + + + default: /* Unknown reference class */ + + AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class); + break; + } + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("Buffer length %.2X @ %p\n", + ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); + + /* Debug only -- dump the buffer contents */ + + if (ObjDesc->Buffer.Pointer) + { + Length = ObjDesc->Buffer.Length; + if (Length > 128) + { + Length = 128; + } + + AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n", + Length); + ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length); + } + break; + + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("Integer %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("Package [Len %X] ElementArray %p\n", + ObjDesc->Package.Count, ObjDesc->Package.Elements); + + /* + * If elements exist, package element pointer is valid, + * and debug_level exceeds 1, dump package's elements. + */ + if (ObjDesc->Package.Count && + ObjDesc->Package.Elements && + AcpiDbgLevel > 1) + { + for (Index = 0; Index < ObjDesc->Package.Count; Index++) + { + AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1); + } + } + break; + + + case ACPI_TYPE_REGION: + + AcpiOsPrintf ("Region %s (%X)", + AcpiUtGetRegionName (ObjDesc->Region.SpaceId), + ObjDesc->Region.SpaceId); + + /* + * If the address and length have not been evaluated, + * don't print them. + */ + if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)) + { + AcpiOsPrintf ("\n"); + } + else + { + AcpiOsPrintf (" base %8.8X%8.8X Length %X\n", + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length); + } + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("String length %X @ %p ", + ObjDesc->String.Length, + ObjDesc->String.Pointer); + + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + AcpiOsPrintf ("BankField\n"); + break; + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at " + "byte=%X bit=%X of below:\n", + ObjDesc->Field.BitLength, + ObjDesc->Field.AccessByteWidth, + ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, + ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, + ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.StartFieldBitOffset); + + AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf ("IndexField\n"); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n", + ObjDesc->BufferField.BitLength, + ObjDesc->BufferField.BaseByteOffset, + ObjDesc->BufferField.StartFieldBitOffset); + + if (!ObjDesc->BufferField.BufferObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n")); + } + else if ((ObjDesc->BufferField.BufferObj)->Common.Type != + ACPI_TYPE_BUFFER) + { + AcpiOsPrintf ("*not a Buffer*\n"); + } + else + { + AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1); + } + break; + + + case ACPI_TYPE_EVENT: + + AcpiOsPrintf ("Event\n"); + break; + + + case ACPI_TYPE_METHOD: + + AcpiOsPrintf ("Method(%X) @ %p:%X\n", + ObjDesc->Method.ParamCount, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength); + break; + + + case ACPI_TYPE_MUTEX: + + AcpiOsPrintf ("Mutex\n"); + break; + + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf ("Device\n"); + break; + + + case ACPI_TYPE_POWER: + + AcpiOsPrintf ("Power\n"); + break; + + + case ACPI_TYPE_PROCESSOR: + + AcpiOsPrintf ("Processor\n"); + break; + + + case ACPI_TYPE_THERMAL: + + AcpiOsPrintf ("Thermal\n"); + break; + + + default: + /* Unknown Type */ + + AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type); + break; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpOperands + * + * PARAMETERS: Operands - A list of Operand objects + * OpcodeName - AML opcode name + * NumOperands - Operand count for this opcode + * + * DESCRIPTION: Dump the operands associated with the opcode + * + ******************************************************************************/ + +void +AcpiExDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + const char *OpcodeName, + UINT32 NumOperands) +{ + ACPI_FUNCTION_NAME (ExDumpOperands); + + + if (!OpcodeName) + { + OpcodeName = "UNKNOWN"; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** Start operand dump for opcode [%s], %d operands\n", + OpcodeName, NumOperands)); + + if (NumOperands == 0) + { + NumOperands = 1; + } + + /* Dump the individual operands */ + + while (NumOperands) + { + AcpiExDumpOperand (*Operands, 0); + Operands++; + NumOperands--; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** End operand dump for [%s]\n", OpcodeName)); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOut* functions + * + * PARAMETERS: Title - Descriptive text + * Value - Value to be displayed + * + * DESCRIPTION: Object dump output formatting functions. These functions + * reduce the number of format strings required and keeps them + * all in one place for easy modification. + * + ******************************************************************************/ + +static void +AcpiExOutString ( + char *Title, + char *Value) +{ + AcpiOsPrintf ("%20s : %s\n", Title, Value); +} + +static void +AcpiExOutPointer ( + char *Title, + void *Value) +{ + AcpiOsPrintf ("%20s : %p\n", Title, Value); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpNamespaceNode + * + * PARAMETERS: Node - Descriptor to dump + * Flags - Force display if TRUE + * + * DESCRIPTION: Dumps the members of the given.Node + * + ******************************************************************************/ + +void +AcpiExDumpNamespaceNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags) +{ + + ACPI_FUNCTION_ENTRY (); + + + if (!Flags) + { + if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + } + + AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); + AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); + AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); + AcpiExOutPointer ("Parent", AcpiNsGetParentNode (Node)); + + AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node), + AcpiExDumpNode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpReferenceObj + * + * PARAMETERS: Object - Descriptor to dump + * + * DESCRIPTION: Dumps a reference object + * + ******************************************************************************/ + +static void +AcpiExDumpReferenceObj ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + + + RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + + if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME) + { + AcpiOsPrintf (" %p ", ObjDesc->Reference.Node); + + Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf (" Could not convert name to pathname\n"); + } + else + { + AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer); + ACPI_FREE (RetBuf.Pointer); + } + } + else if (ObjDesc->Reference.Object) + { + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) + { + AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object); + if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value); + } + else + { + AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object, + AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) + ObjDesc->Reference.Object)->Common.Type)); + } + } + else + { + AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpPackageObj + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Level - Indentation Level + * Index - Package index for this object + * + * DESCRIPTION: Dumps the elements of the package + * + ******************************************************************************/ + +static void +AcpiExDumpPackageObj ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Level, + UINT32 Index) +{ + UINT32 i; + + + /* Indentation and index output */ + + if (Level > 0) + { + for (i = 0; i < Level; i++) + { + AcpiOsPrintf (" "); + } + + AcpiOsPrintf ("[%.2d] ", Index); + } + + AcpiOsPrintf ("%p ", ObjDesc); + + /* Null package elements are allowed */ + + if (!ObjDesc) + { + AcpiOsPrintf ("[Null Object]\n"); + return; + } + + /* Packages may only contain a few object types */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("[String] Value: "); + for (i = 0; i < ObjDesc->String.Length; i++) + { + AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]); + } + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); + if (ObjDesc->Buffer.Length) + { + AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), + ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); + } + else + { + AcpiOsPrintf ("\n"); + } + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("[Package] Contains %d Elements:\n", + ObjDesc->Package.Count); + + for (i = 0; i < ObjDesc->Package.Count; i++) + { + AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i); + } + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X", + AcpiUtGetReferenceName (ObjDesc), + ObjDesc->Reference.Class); + AcpiExDumpReferenceObj (ObjDesc); + break; + + + default: + + AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpObjectDescriptor + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Flags - Force display if TRUE + * + * DESCRIPTION: Dumps the members of the object descriptor given. + * + ******************************************************************************/ + +void +AcpiExDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Flags) +{ + ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor); + + + if (!ObjDesc) + { + return_VOID; + } + + if (!Flags) + { + if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return_VOID; + } + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags); + + AcpiOsPrintf ("\nAttached Object (%p):\n", + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); + + AcpiExDumpObjectDescriptor ( + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); + return_VOID; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + AcpiOsPrintf ( + "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); + return_VOID; + } + + if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX) + { + return_VOID; + } + + /* Common Fields */ + + AcpiExDumpObject (ObjDesc, AcpiExDumpCommon); + + /* Object-specific fields */ + + AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]); + return_VOID; +} + +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exfield.c b/reactos/drivers/bus/acpi/acpica/executer/exfield.c new file mode 100644 index 00000000000..503e8e6b370 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exfield.c @@ -0,0 +1,466 @@ +/****************************************************************************** + * + * Module Name: exfield - ACPI AML (p-code) execution - field manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXFIELD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exfield") + + +/******************************************************************************* + * + * FUNCTION: AcpiExReadDataFromField + * + * PARAMETERS: WalkState - Current execution state + * ObjDesc - The named field + * RetBufferDesc - Where the return data object is stored + * + * RETURN: Status + * + * DESCRIPTION: Read from a named field. Returns either an Integer or a + * Buffer, depending on the size of the field. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReadDataFromField ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **RetBufferDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *BufferDesc; + ACPI_SIZE Length; + void *Buffer; + UINT32 Function; + + + ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); + + + /* Parameter validation */ + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + if (!RetBufferDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) + { + /* + * This is an SMBus or IPMI read. We must create a buffer to hold + * the data and then directly access the region handler. + * + * Note: Smbus protocol value is passed in upper 16-bits of Function + */ + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_READ; + } + + BufferDesc = AcpiUtCreateBufferObject (Length); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Call the region handler for the read */ + + Status = AcpiExAccessRegion (ObjDesc, 0, + ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), + Function); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + goto Exit; + } + + /* + * Allocate a buffer for the contents of the field. + * + * If the field is larger than the size of an ACPI_INTEGER, create + * a BUFFER to hold it. Otherwise, use an INTEGER. This allows + * the use of arithmetic operators on the returned value if the + * field size is equal or smaller than an Integer. + * + * Note: Field.length is in bits. + */ + Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength); + if (Length > AcpiGbl_IntegerByteWidth) + { + /* Field is too large for an Integer, create a Buffer instead */ + + BufferDesc = AcpiUtCreateBufferObject (Length); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + Buffer = BufferDesc->Buffer.Pointer; + } + else + { + /* Field will fit within an Integer (normal case) */ + + BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Length = AcpiGbl_IntegerByteWidth; + Buffer = &BufferDesc->Integer.Value; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", + ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BaseByteOffset)); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Read from the field */ + + Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + +Exit: + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (BufferDesc); + } + else + { + *RetBufferDesc = BufferDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExWriteDataToField + * + * PARAMETERS: SourceDesc - Contains data to write + * ObjDesc - The named field + * ResultDesc - Where the return value is returned, if any + * + * RETURN: Status + * + * DESCRIPTION: Write to a named field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExWriteDataToField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) +{ + ACPI_STATUS Status; + UINT32 Length; + void *Buffer; + ACPI_OPERAND_OBJECT *BufferDesc; + UINT32 Function; + + + ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); + + + /* Parameter validation */ + + if (!SourceDesc || !ObjDesc) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) + { + /* + * This is an SMBus or IPMI write. We will bypass the entire field + * mechanism and handoff the buffer directly to the handler. For + * these address spaces, the buffer is bi-directional; on a write, + * return data is returned in the same buffer. + * + * Source must be a buffer of sufficient size: + * ACPI_SMBUS_BUFFER_SIZE or ACPI_IPMI_BUFFER_SIZE. + * + * Note: SMBus protocol type is passed in upper 16-bits of Function + */ + if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, + "SMBus or IPMI write requires Buffer, found type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_WRITE; + } + + if (SourceDesc->Buffer.Length < Length) + { + ACPI_ERROR ((AE_INFO, + "SMBus or IPMI write requires Buffer of length %X, found length %X", + Length, SourceDesc->Buffer.Length)); + + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + + /* Create the bi-directional buffer */ + + BufferDesc = AcpiUtCreateBufferObject (Length); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Buffer = BufferDesc->Buffer.Pointer; + ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* + * Perform the write (returns status and perhaps data in the + * same buffer) + */ + Status = AcpiExAccessRegion (ObjDesc, 0, + (ACPI_INTEGER *) Buffer, Function); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + *ResultDesc = BufferDesc; + return_ACPI_STATUS (Status); + } + + /* Get a pointer to the data to be written */ + + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + Buffer = &SourceDesc->Integer.Value; + Length = sizeof (SourceDesc->Integer.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = SourceDesc->Buffer.Pointer; + Length = SourceDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = SourceDesc->String.Pointer; + Length = SourceDesc->String.Length; + break; + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", + SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), + SourceDesc->Common.Type, Buffer, Length)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", + ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type), + ObjDesc->Common.Type, + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BaseByteOffset)); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Write to the field */ + + Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exfldio.c b/reactos/drivers/bus/acpi/acpica/executer/exfldio.c new file mode 100644 index 00000000000..37a67865517 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exfldio.c @@ -0,0 +1,1081 @@ +/****************************************************************************** + * + * Module Name: exfldio - Aml Field I/O + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXFLDIO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acevents.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exfldio") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExFieldDatumIo ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); + +static BOOLEAN +AcpiExRegisterOverflow ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Value); + +static ACPI_STATUS +AcpiExSetupRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset); + + +/******************************************************************************* + * + * FUNCTION: AcpiExSetupRegion + * + * PARAMETERS: ObjDesc - Field to be read or written + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * + * RETURN: Status + * + * DESCRIPTION: Common processing for AcpiExExtractFromField and + * AcpiExInsertIntoField. Initialize the Region if necessary and + * validate the request. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExSetupRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *RgnDesc; + + + ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset); + + + RgnDesc = ObjDesc->CommonField.RegionObj; + + /* We must have a valid region */ + + if (RgnDesc->Common.Type != ACPI_TYPE_REGION) + { + ACPI_ERROR ((AE_INFO, "Needed Region, found type %X (%s)", + RgnDesc->Common.Type, + AcpiUtGetObjectTypeName (RgnDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetRegionArguments (RgnDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Exit now for SMBus or IPMI address space, it has a non-linear address space + * and the request cannot be directly validated + */ + if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_IPMI) + { + /* SMBus or IPMI has a non-linear address space */ + + return_ACPI_STATUS (AE_OK); + } + +#ifdef ACPI_UNDER_DEVELOPMENT + /* + * If the Field access is AnyAcc, we can now compute the optimal + * access (because we know know the length of the parent region) + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } +#endif + + /* + * Validate the request. The entire request from the byte offset for a + * length of one field datum (access width) must fit within the region. + * (Region length is specified in bytes) + */ + if (RgnDesc->Region.Length < + (ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset + + ObjDesc->CommonField.AccessByteWidth)) + { + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Slack mode only: We will go ahead and allow access to this + * field if it is within the region length rounded up to the next + * access width boundary. ACPI_SIZE cast for 64-bit compile. + */ + if (ACPI_ROUND_UP (RgnDesc->Region.Length, + ObjDesc->CommonField.AccessByteWidth) >= + ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset + + ObjDesc->CommonField.AccessByteWidth + + FieldDatumByteOffset)) + { + return_ACPI_STATUS (AE_OK); + } + } + + if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth) + { + /* + * This is the case where the AccessType (AccWord, etc.) is wider + * than the region itself. For example, a region of length one + * byte, and a field with Dword access specified. + */ + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)", + AcpiUtGetNodeName (ObjDesc->CommonField.Node), + ObjDesc->CommonField.AccessByteWidth, + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); + } + + /* + * Offset rounded up to next multiple of field width + * exceeds region length, indicate an error + */ + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)", + AcpiUtGetNodeName (ObjDesc->CommonField.Node), + ObjDesc->CommonField.BaseByteOffset, + FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); + + return_ACPI_STATUS (AE_AML_REGION_LIMIT); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAccessRegion + * + * PARAMETERS: ObjDesc - Field to be read + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * Value - Where to store value (must at least + * the size of ACPI_INTEGER) + * Function - Read or Write flag plus other region- + * dependent flags + * + * RETURN: Status + * + * DESCRIPTION: Read or Write a single field datum to an Operation Region. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAccessRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 Function) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RgnDesc; + UINT32 RegionOffset; + + + ACPI_FUNCTION_TRACE (ExAccessRegion); + + + /* + * Ensure that the region operands are fully evaluated and verify + * the validity of the request + */ + Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The physical address of this field datum is: + * + * 1) The base of the region, plus + * 2) The base offset of the field, plus + * 3) The current offset into the field + */ + RgnDesc = ObjDesc->CommonField.RegionObj; + RegionOffset = + ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset; + + if ((Function & ACPI_IO_MASK) == ACPI_READ) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]")); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, + " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n", + AcpiUtGetRegionName (RgnDesc->Region.SpaceId), + RgnDesc->Region.SpaceId, + ObjDesc->CommonField.AccessByteWidth, + ObjDesc->CommonField.BaseByteOffset, + FieldDatumByteOffset, + ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset)))); + + /* Invoke the appropriate AddressSpace/OpRegion handler */ + + Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, RegionOffset, + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_IMPLEMENTED) + { + ACPI_ERROR ((AE_INFO, + "Region %s(%X) not implemented", + AcpiUtGetRegionName (RgnDesc->Region.SpaceId), + RgnDesc->Region.SpaceId)); + } + else if (Status == AE_NOT_EXIST) + { + ACPI_ERROR ((AE_INFO, + "Region %s(%X) has no handler", + AcpiUtGetRegionName (RgnDesc->Region.SpaceId), + RgnDesc->Region.SpaceId)); + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRegisterOverflow + * + * PARAMETERS: ObjDesc - Register(Field) to be written + * Value - Value to be stored + * + * RETURN: TRUE if value overflows the field, FALSE otherwise + * + * DESCRIPTION: Check if a value is out of range of the field being written. + * Used to check if the values written to Index and Bank registers + * are out of range. Normally, the value is simply truncated + * to fit the field, but this case is most likely a serious + * coding error in the ASL. + * + ******************************************************************************/ + +static BOOLEAN +AcpiExRegisterOverflow ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Value) +{ + + if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE) + { + /* + * The field is large enough to hold the maximum integer, so we can + * never overflow it. + */ + return (FALSE); + } + + if (Value >= ((ACPI_INTEGER) 1 << ObjDesc->CommonField.BitLength)) + { + /* + * The Value is larger than the maximum value that can fit into + * the register. + */ + return (TRUE); + } + + /* The Value will fit into the field with no truncation */ + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExFieldDatumIo + * + * PARAMETERS: ObjDesc - Field to be read + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * Value - Where to store value (must be 64 bits) + * ReadWrite - Read or Write flag + * + * RETURN: Status + * + * DESCRIPTION: Read or Write a single datum of a field. The FieldType is + * demultiplexed here to handle the different types of fields + * (BufferField, RegionField, IndexField, BankField) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExFieldDatumIo ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite) +{ + ACPI_STATUS Status; + ACPI_INTEGER LocalValue; + + + ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset); + + + if (ReadWrite == ACPI_READ) + { + if (!Value) + { + LocalValue = 0; + + /* To support reads without saving return value */ + Value = &LocalValue; + } + + /* Clear the entire return buffer first, [Very Important!] */ + + *Value = 0; + } + + /* + * The four types of fields are: + * + * BufferField - Read/write from/to a Buffer + * RegionField - Read/write from/to a Operation Region. + * BankField - Write to a Bank Register, then read/write from/to an + * OperationRegion + * IndexField - Write to an Index Register, then read/write from/to a + * Data Register + */ + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER_FIELD: + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (ReadWrite == ACPI_READ) + { + /* + * Copy the data from the source buffer. + * Length is the field width in bytes. + */ + ACPI_MEMCPY (Value, + (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth); + } + else + { + /* + * Copy the data to the target buffer. + * Length is the field width in bytes. + */ + ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + Value, ObjDesc->CommonField.AccessByteWidth); + } + + Status = AE_OK; + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + /* + * Ensure that the BankValue is not beyond the capacity of + * the register + */ + if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj, + (ACPI_INTEGER) ObjDesc->BankField.Value)) + { + return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); + } + + /* + * For BankFields, we must write the BankValue to the BankRegister + * (itself a RegionField) before we can access the data. + */ + Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj, + &ObjDesc->BankField.Value, + sizeof (ObjDesc->BankField.Value)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now that the Bank has been selected, fall through to the + * RegionField case and write the datum to the Operation Region + */ + + /*lint -fallthrough */ + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + /* + * For simple RegionFields, we just directly access the owning + * Operation Region. + */ + Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value, + ReadWrite); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + + /* + * Ensure that the IndexValue is not beyond the capacity of + * the register + */ + if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj, + (ACPI_INTEGER) ObjDesc->IndexField.Value)) + { + return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); + } + + /* Write the index value to the IndexRegister (itself a RegionField) */ + + FieldDatumByteOffset += ObjDesc->IndexField.Value; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Write to Index Register: Value %8.8X\n", + FieldDatumByteOffset)); + + Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj, + &FieldDatumByteOffset, + sizeof (FieldDatumByteOffset)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ReadWrite == ACPI_READ) + { + /* Read the datum from the DataRegister */ + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Read from Data Register\n")); + + Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, + Value, sizeof (ACPI_INTEGER)); + } + else + { + /* Write the datum to the DataRegister */ + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Write to Data Register: Value %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (*Value))); + + Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, + Value, sizeof (ACPI_INTEGER)); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %X", + ObjDesc->Common.Type)); + Status = AE_AML_INTERNAL; + break; + } + + if (ACPI_SUCCESS (Status)) + { + if (ReadWrite == ACPI_READ) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Read %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Written %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExWriteWithUpdateRule + * + * PARAMETERS: ObjDesc - Field to be written + * Mask - bitmask within field datum + * FieldValue - Value to write + * FieldDatumByteOffset - Offset of datum within field + * + * RETURN: Status + * + * DESCRIPTION: Apply the field update rule to a field write + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExWriteWithUpdateRule ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Mask, + ACPI_INTEGER FieldValue, + UINT32 FieldDatumByteOffset) +{ + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER MergedValue; + ACPI_INTEGER CurrentValue; + + + ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask); + + + /* Start with the new bits */ + + MergedValue = FieldValue; + + /* If the mask is all ones, we don't need to worry about the update rule */ + + if (Mask != ACPI_INTEGER_MAX) + { + /* Decode the update rule */ + + switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK) + { + case AML_FIELD_UPDATE_PRESERVE: + /* + * Check if update rule needs to be applied (not if mask is all + * ones) The left shift drops the bits we want to ignore. + */ + if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) - + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0) + { + /* + * Read the current contents of the byte/word/dword containing + * the field, and merge with the new field value. + */ + Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, + &CurrentValue, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MergedValue |= (CurrentValue & ~Mask); + } + break; + + case AML_FIELD_UPDATE_WRITE_AS_ONES: + + /* Set positions outside the field to all ones */ + + MergedValue |= ~Mask; + break; + + case AML_FIELD_UPDATE_WRITE_AS_ZEROS: + + /* Set positions outside the field to all zeros */ + + MergedValue &= Mask; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown UpdateRule value: %X", + (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK))); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Mask), + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth, + ACPI_FORMAT_UINT64 (FieldValue), + ACPI_FORMAT_UINT64 (MergedValue))); + + /* Write the merged value */ + + Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, + &MergedValue, ACPI_WRITE); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExExtractFromField + * + * PARAMETERS: ObjDesc - Field to be read + * Buffer - Where to store the field data + * BufferLength - Length of Buffer + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the current value of the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExExtractFromField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength) +{ + ACPI_STATUS Status; + ACPI_INTEGER RawDatum; + ACPI_INTEGER MergedDatum; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; + UINT32 DatumCount; + UINT32 FieldDatumCount; + UINT32 i; + + + ACPI_FUNCTION_TRACE (ExExtractFromField); + + + /* Validate target buffer and clear it */ + + if (BufferLength < + ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength)) + { + ACPI_ERROR ((AE_INFO, + "Field size %X (bits) is too large for buffer (%X)", + ObjDesc->CommonField.BitLength, BufferLength)); + + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + ACPI_MEMSET (Buffer, 0, BufferLength); + + /* Compute the number of datums (access width data items) */ + + DatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); + + /* Priming read from the field */ + + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; + + /* Read the rest of the field */ + + for (i = 1; i < FieldDatumCount; i++) + { + /* Get next input datum from the field */ + + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, + &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Merge with previous datum if necessary. + * + * Note: Before the shift, check if the shift value will be larger than + * the integer size. If so, there is no need to perform the operation. + * This avoids the differences in behavior between different compilers + * concerning shift values larger than the target data width. + */ + if ((ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + { + MergedDatum |= RawDatum << + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + } + + if (i == DatumCount) + { + break; + } + + /* Write merged datum to target buffer */ + + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; + } + + /* Mask off any extra bits in the last datum */ + + BufferTailBits = ObjDesc->CommonField.BitLength % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) + { + MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits); + } + + /* Write the last datum to the buffer */ + + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExInsertIntoField + * + * PARAMETERS: ObjDesc - Field to be written + * Buffer - Data to be written + * BufferLength - Length of Buffer + * + * RETURN: Status + * + * DESCRIPTION: Store the Buffer contents into the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExInsertIntoField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength) +{ + ACPI_STATUS Status; + ACPI_INTEGER Mask; + ACPI_INTEGER WidthMask; + ACPI_INTEGER MergedDatum; + ACPI_INTEGER RawDatum = 0; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; + UINT32 DatumCount; + UINT32 FieldDatumCount; + UINT32 i; + UINT32 RequiredLength; + void *NewBuffer; + + + ACPI_FUNCTION_TRACE (ExInsertIntoField); + + + /* Validate input buffer */ + + NewBuffer = NULL; + RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength); + /* + * We must have a buffer that is at least as long as the field + * we are writing to. This is because individual fields are + * indivisible and partial writes are not supported -- as per + * the ACPI specification. + */ + if (BufferLength < RequiredLength) + { + /* We need to create a new buffer */ + + NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength); + if (!NewBuffer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the original data to the new buffer, starting + * at Byte zero. All unused (upper) bytes of the + * buffer will be 0. + */ + ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength); + Buffer = NewBuffer; + BufferLength = RequiredLength; + } + + /* + * Create the bitmasks used for bit insertion. + * Note: This if/else is used to bypass compiler differences with the + * shift operator + */ + if (ObjDesc->CommonField.AccessBitWidth == ACPI_INTEGER_BIT_SIZE) + { + WidthMask = ACPI_INTEGER_MAX; + } + else + { + WidthMask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.AccessBitWidth); + } + + Mask = WidthMask & + ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); + + /* Compute the number of datums (access width data items) */ + + DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + + FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); + + /* Get initial Datum from the input buffer */ + + ACPI_MEMCPY (&RawDatum, Buffer, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset; + + /* Write the entire field */ + + for (i = 1; i < FieldDatumCount; i++) + { + /* Write merged datum to the target field */ + + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, + MergedDatum, FieldOffset); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + + /* + * Start new output datum by merging with previous input datum + * if necessary. + * + * Note: Before the shift, check if the shift value will be larger than + * the integer size. If so, there is no need to perform the operation. + * This avoids the differences in behavior between different compilers + * concerning shift values larger than the target data width. + */ + if ((ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + { + MergedDatum = RawDatum >> + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + } + else + { + MergedDatum = 0; + } + + Mask = WidthMask; + + if (i == DatumCount) + { + break; + } + + /* Get the next input datum from the buffer */ + + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset; + } + + /* Mask off any extra bits in the last datum */ + + BufferTailBits = (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset) % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) + { + Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits); + } + + /* Write the last datum to the field */ + + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, + Mask, MergedDatum, FieldOffset); + +Exit: + /* Free temporary buffer if we used one */ + + if (NewBuffer) + { + ACPI_FREE (NewBuffer); + } + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exmisc.c b/reactos/drivers/bus/acpi/acpica/executer/exmisc.c new file mode 100644 index 00000000000..41e4a9752ec --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exmisc.c @@ -0,0 +1,873 @@ + +/****************************************************************************** + * + * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "amlresrc.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exmisc") + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetObjectReference + * + * PARAMETERS: ObjDesc - Create a reference to this object + * ReturnDesc - Where to store the reference + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Obtain and return a "reference" to the target object + * Common code for the RefOfOp and the CondRefOfOp. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ReferenceObj; + ACPI_OPERAND_OBJECT *ReferencedObj; + + + ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc); + + + *ReturnDesc = NULL; + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_OPERAND: + + if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Must be a reference to a Local or Arg + */ + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_DEBUG: + + /* The referenced object is the pseudo-node for the local/arg */ + + ReferencedObj = ObjDesc->Reference.Object; + break; + + default: + + ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + break; + + + case ACPI_DESC_TYPE_NAMED: + + /* + * A named reference that has already been resolved to a Node + */ + ReferencedObj = ObjDesc; + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid descriptor type %X", + ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))); + return_ACPI_STATUS (AE_TYPE); + } + + + /* Create a new reference object */ + + ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ReferenceObj) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF; + ReferenceObj->Reference.Object = ReferencedObj; + *ReturnDesc = ReferenceObj; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p Type [%s], returning Reference %p\n", + ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConcatTemplate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two resource templates + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + UINT8 *EndTag; + ACPI_SIZE Length0; + ACPI_SIZE Length1; + ACPI_SIZE NewLength; + + + ACPI_FUNCTION_TRACE (ExConcatTemplate); + + + /* + * Find the EndTag descriptor in each resource template. + * Note1: returned pointers point TO the EndTag, not past it. + * Note2: zero-length buffers are allowed; treated like one EndTag + */ + + /* Get the length of the first resource template */ + + Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); + + /* Get the length of the second resource template */ + + Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); + + /* Combine both lengths, minimum size will be 2 for EndTag */ + + NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); + + /* Create a new buffer object for the result (with one EndTag) */ + + ReturnDesc = AcpiUtCreateBufferObject (NewLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the templates to the new buffer, 0 first, then 1 follows. One + * EndTag descriptor is copied from Operand1. + */ + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0); + ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); + + /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ + + NewBuf[NewLength - 1] = 0; + NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; + + /* Return the completed resource template */ + + *ActualReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoConcatenate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_OPERAND_OBJECT *ReturnDesc; + char *NewBuf; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExDoConcatenate); + + + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + break; + + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; + + default: + ACPI_ERROR ((AE_INFO, "Invalid object type: %X", + Operand0->Common.Type)); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform the + * concatenation. + */ + + /* + * There are three cases to handle: + * + * 1) Two Integers concatenated to produce a new Buffer + * 2) Two Strings concatenated to produce a new String + * 3) Two Buffers concatenated to produce a new Buffer + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Result of two Integers is a Buffer */ + /* Need enough buffer space for two integers */ + + ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) + ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = (char *) ReturnDesc->Buffer.Pointer; + + /* Copy the first integer, LSB first */ + + ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value, + AcpiGbl_IntegerByteWidth); + + /* Copy the second integer (LSB first) after the first */ + + ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth, + &LocalOperand1->Integer.Value, + AcpiGbl_IntegerByteWidth); + break; + + case ACPI_TYPE_STRING: + + /* Result of two Strings is a String */ + + ReturnDesc = AcpiUtCreateStringObject ( + ((ACPI_SIZE) Operand0->String.Length + + LocalOperand1->String.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = ReturnDesc->String.Pointer; + + /* Concatenate the strings */ + + ACPI_STRCPY (NewBuf, Operand0->String.Pointer); + ACPI_STRCPY (NewBuf + Operand0->String.Length, + LocalOperand1->String.Pointer); + break; + + case ACPI_TYPE_BUFFER: + + /* Result of two Buffers is a Buffer */ + + ReturnDesc = AcpiUtCreateBufferObject ( + ((ACPI_SIZE) Operand0->Buffer.Length + + LocalOperand1->Buffer.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = (char *) ReturnDesc->Buffer.Pointer; + + /* Concatenate the buffers */ + + ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, + Operand0->Buffer.Length); + ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length, + LocalOperand1->Buffer.Pointer, + LocalOperand1->Buffer.Length); + break; + + default: + + /* Invalid object type, should not happen here */ + + ACPI_ERROR ((AE_INFO, "Invalid object type: %X", + Operand0->Common.Type)); + Status =AE_AML_INTERNAL; + goto Cleanup; + } + + *ActualReturnDesc = ReturnDesc; + +Cleanup: + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoMathOp + * + * PARAMETERS: Opcode - AML opcode + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 + * + * RETURN: Integer result of the operation + * + * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the + * math functions here is to prevent a lot of pointer dereferencing + * to obtain the operands. + * + ******************************************************************************/ + +ACPI_INTEGER +AcpiExDoMathOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1) +{ + + ACPI_FUNCTION_ENTRY (); + + + switch (Opcode) + { + case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ + + return (Integer0 + Integer1); + + + case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ + + return (Integer0 & Integer1); + + + case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ + + return (~(Integer0 & Integer1)); + + + case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ + + return (Integer0 | Integer1); + + + case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ + + return (~(Integer0 | Integer1)); + + + case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ + + return (Integer0 ^ Integer1); + + + case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ + + return (Integer0 * Integer1); + + + case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/ + + /* + * We need to check if the shiftcount is larger than the integer bit + * width since the behavior of this is not well-defined in the C language. + */ + if (Integer1 >= AcpiGbl_IntegerBitWidth) + { + return (0); + } + return (Integer0 << Integer1); + + + case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ + + /* + * We need to check if the shiftcount is larger than the integer bit + * width since the behavior of this is not well-defined in the C language. + */ + if (Integer1 >= AcpiGbl_IntegerBitWidth) + { + return (0); + } + return (Integer0 >> Integer1); + + + case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ + + return (Integer0 - Integer1); + + default: + + return (0); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoLogicalNumericOp + * + * PARAMETERS: Opcode - AML opcode + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 + * LogicalResult - TRUE/FALSE result of the operation + * + * RETURN: Status + * + * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric + * operators (LAnd and LOr), both operands must be integers. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Integer0 && Integer1); + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + + + ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp); + + + switch (Opcode) + { + case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ + + if (Integer0 && Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LOR_OP: /* LOr (Integer0, Integer1) */ + + if (Integer0 || Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoLogicalOp + * + * PARAMETERS: Opcode - AML opcode + * Operand0 - operand #0 + * Operand1 - operand #1 + * LogicalResult - TRUE/FALSE result of the operation + * + * RETURN: Status + * + * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the + * functions here is to prevent a lot of pointer dereferencing + * to obtain the operands and to simplify the generation of the + * logical value. For the Numeric operators (LAnd and LOr), both + * operands must be integers. For the other logical operators, + * operands can be any combination of Integer/String/Buffer. The + * first operand determines the type to which the second operand + * will be converted. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Operand0 == Operand1); + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoLogicalOp ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult) +{ + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_INTEGER Integer0; + ACPI_INTEGER Integer1; + UINT32 Length0; + UINT32 Length1; + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + int Compare; + + + ACPI_FUNCTION_TRACE (ExDoLogicalOp); + + + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI 3.0+ specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + break; + + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Two cases: 1) Both Integers, 2) Both Strings or Buffers + */ + if (Operand0->Common.Type == ACPI_TYPE_INTEGER) + { + /* + * 1) Both operands are of type integer + * Note: LocalOperand1 may have changed above + */ + Integer0 = Operand0->Integer.Value; + Integer1 = LocalOperand1->Integer.Value; + + switch (Opcode) + { + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + if (Integer0 == Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Integer0 > Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Integer0 < Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + } + else + { + /* + * 2) Both operands are Strings or both are Buffers + * Note: Code below takes advantage of common Buffer/String + * object fields. LocalOperand1 may have changed above. Use + * memcmp to handle nulls in buffers. + */ + Length0 = Operand0->Buffer.Length; + Length1 = LocalOperand1->Buffer.Length; + + /* Lexicographic compare: compare the data bytes */ + + Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer, + LocalOperand1->Buffer.Pointer, + (Length0 > Length1) ? Length1 : Length0); + + switch (Opcode) + { + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + /* Length and all bytes must be equal */ + + if ((Length0 == Length1) && + (Compare == 0)) + { + /* Length and all bytes match ==> TRUE */ + + LocalResult = TRUE; + } + break; + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Compare > 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + if (Compare < 0) + { + goto Cleanup; /* FALSE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 > Length1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Compare > 0) + { + goto Cleanup; /* FALSE */ + } + if (Compare < 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 < Length1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + } + +Cleanup: + + /* New object was created if implicit conversion performed - delete */ + + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exmutex.c b/reactos/drivers/bus/acpi/acpica/executer/exmutex.c new file mode 100644 index 00000000000..8b1bebf1e91 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exmutex.c @@ -0,0 +1,621 @@ + +/****************************************************************************** + * + * Module Name: exmutex - ASL Mutex Acquire/Release functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXMUTEX_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exmutex") + +/* Local prototypes */ + +static void +AcpiExLinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_STATE *Thread); + + +/******************************************************************************* + * + * FUNCTION: AcpiExUnlinkMutex + * + * PARAMETERS: ObjDesc - The mutex to be unlinked + * + * RETURN: None + * + * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list + * + ******************************************************************************/ + +void +AcpiExUnlinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread; + + + if (!Thread) + { + return; + } + + /* Doubly linked list */ + + if (ObjDesc->Mutex.Next) + { + (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; + } + + if (ObjDesc->Mutex.Prev) + { + (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next; + + /* + * Migrate the previous sync level associated with this mutex to the + * previous mutex on the list so that it may be preserved. This handles + * the case where several mutexes have been acquired at the same level, + * but are not released in opposite order. + */ + (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel = + ObjDesc->Mutex.OriginalSyncLevel; + } + else + { + Thread->AcquiredMutexList = ObjDesc->Mutex.Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLinkMutex + * + * PARAMETERS: ObjDesc - The mutex to be linked + * Thread - Current executing thread object + * + * RETURN: None + * + * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk + * + ******************************************************************************/ + +static void +AcpiExLinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_STATE *Thread) +{ + ACPI_OPERAND_OBJECT *ListHead; + + + ListHead = Thread->AcquiredMutexList; + + /* This object will be the first object in the list */ + + ObjDesc->Mutex.Prev = NULL; + ObjDesc->Mutex.Next = ListHead; + + /* Update old first object to point back to this object */ + + if (ListHead) + { + ListHead->Mutex.Prev = ObjDesc; + } + + /* Update list head */ + + Thread->AcquiredMutexList = ObjDesc; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireMutexObject + * + * PARAMETERS: TimeDesc - Timeout in milliseconds + * ObjDesc - Mutex object + * Thread - Current thread state + * + * RETURN: Status + * + * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common + * path that supports multiple acquires by the same thread. + * + * MUTEX: Interpreter must be locked + * + * NOTE: This interface is called from three places: + * 1) From AcpiExAcquireMutex, via an AML Acquire() operator + * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the + * global lock + * 3) From the external interface, AcpiAcquireGlobalLock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAcquireMutexObject ( + UINT16 Timeout, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_ID ThreadId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Support for multiple acquires by the owning thread */ + + if (ObjDesc->Mutex.ThreadId == ThreadId) + { + /* + * The mutex is already owned by this thread, just increment the + * acquisition depth + */ + ObjDesc->Mutex.AcquisitionDepth++; + return_ACPI_STATUS (AE_OK); + } + + /* Acquire the mutex, wait if necessary. Special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + Status = AcpiEvAcquireGlobalLock (Timeout); + } + else + { + Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, + Timeout); + } + + if (ACPI_FAILURE (Status)) + { + /* Includes failure from a timeout on TimeDesc */ + + return_ACPI_STATUS (Status); + } + + /* Acquired the mutex: update mutex object */ + + ObjDesc->Mutex.ThreadId = ThreadId; + ObjDesc->Mutex.AcquisitionDepth = 1; + ObjDesc->Mutex.OriginalSyncLevel = 0; + ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */ + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireMutex + * + * PARAMETERS: TimeDesc - Timeout integer + * ObjDesc - Mutex object + * WalkState - Current method execution state + * + * RETURN: Status + * + * DESCRIPTION: Acquire an AML mutex + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAcquireMutex ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_ERROR ((AE_INFO, "Cannot acquire Mutex [%4.4s], null thread info", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * Current sync level must be less than or equal to the sync level of the + * mutex. This mechanism provides some deadlock prevention + */ + if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) + { + ACPI_ERROR ((AE_INFO, + "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + WalkState->Thread->CurrentSyncLevel)); + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value, + ObjDesc, WalkState->Thread->ThreadId); + if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1) + { + /* Save Thread object, original/current sync levels */ + + ObjDesc->Mutex.OwnerThread = WalkState->Thread; + ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; + + /* Link the mutex to the current thread for force-unlock at method exit */ + + AcpiExLinkMutex (ObjDesc, WalkState->Thread); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseMutexObject + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Release a previously acquired Mutex, low level interface. + * Provides a common path that supports multiple releases (after + * previous multiple acquires) by the same thread. + * + * MUTEX: Interpreter must be locked + * + * NOTE: This interface is called from three places: + * 1) From AcpiExReleaseMutex, via an AML Acquire() operator + * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the + * global lock + * 3) From the external interface, AcpiReleaseGlobalLock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReleaseMutexObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExReleaseMutexObject); + + + if (ObjDesc->Mutex.AcquisitionDepth == 0) + { + return (AE_NOT_ACQUIRED); + } + + /* Match multiple Acquires with multiple Releases */ + + ObjDesc->Mutex.AcquisitionDepth--; + if (ObjDesc->Mutex.AcquisitionDepth != 0) + { + /* Just decrement the depth and return */ + + return_ACPI_STATUS (AE_OK); + } + + if (ObjDesc->Mutex.OwnerThread) + { + /* Unlink the mutex from the owner's list */ + + AcpiExUnlinkMutex (ObjDesc); + ObjDesc->Mutex.OwnerThread = NULL; + } + + /* Release the mutex, special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + Status = AcpiEvReleaseGlobalLock (); + } + else + { + AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); + } + + /* Clear mutex info */ + + ObjDesc->Mutex.ThreadId = 0; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseMutex + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * WalkState - Current method execution state + * + * RETURN: Status + * + * DESCRIPTION: Release a previously acquired Mutex. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReleaseMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + UINT8 PreviousSyncLevel; + + + ACPI_FUNCTION_TRACE (ExReleaseMutex); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* The mutex must have been previously acquired in order to release it */ + + if (!ObjDesc->Mutex.OwnerThread) + { + ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], not acquired", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED); + } + + /* Must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], null thread info", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * The Mutex is owned, but this thread must be the owner. + * Special case for Global Lock, any thread can release + */ + if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && + (ObjDesc != AcpiGbl_GlobalLockMutex)) + { + ACPI_ERROR ((AE_INFO, + "Thread %p cannot release Mutex [%4.4s] acquired by thread %p", + ACPI_CAST_PTR (void, WalkState->Thread->ThreadId), + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + ACPI_CAST_PTR (void, ObjDesc->Mutex.OwnerThread->ThreadId))); + return_ACPI_STATUS (AE_AML_NOT_OWNER); + } + + /* + * The sync level of the mutex must be equal to the current sync level. In + * other words, the current level means that at least one mutex at that + * level is currently being held. Attempting to release a mutex of a + * different level can only mean that the mutex ordering rule is being + * violated. This behavior is clarified in ACPI 4.0 specification. + */ + if (ObjDesc->Mutex.SyncLevel != WalkState->Thread->CurrentSyncLevel) + { + ACPI_ERROR ((AE_INFO, + "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %d current %d", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel)); + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + /* + * Get the previous SyncLevel from the head of the acquired mutex list. + * This handles the case where several mutexes at the same level have been + * acquired, but are not released in reverse order. + */ + PreviousSyncLevel = + WalkState->Thread->AcquiredMutexList->Mutex.OriginalSyncLevel; + + Status = AcpiExReleaseMutexObject (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ObjDesc->Mutex.AcquisitionDepth == 0) + { + /* Restore the previous SyncLevel */ + + WalkState->Thread->CurrentSyncLevel = PreviousSyncLevel; + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseAllMutexes + * + * PARAMETERS: Thread - Current executing thread object + * + * RETURN: Status + * + * DESCRIPTION: Release all mutexes held by this thread + * + * NOTE: This function is called as the thread is exiting the interpreter. + * Mutexes are not released when an individual control method is exited, but + * only when the parent thread actually exits the interpreter. This allows one + * method to acquire a mutex, and a different method to release it, as long as + * this is performed underneath a single parent control method. + * + ******************************************************************************/ + +void +AcpiExReleaseAllMutexes ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_ENTRY (); + + + /* Traverse the list of owned mutexes, releasing each one */ + + while (Next) + { + ObjDesc = Next; + Next = ObjDesc->Mutex.Next; + + ObjDesc->Mutex.Prev = NULL; + ObjDesc->Mutex.Next = NULL; + ObjDesc->Mutex.AcquisitionDepth = 0; + + /* Release the mutex, special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + /* Ignore errors */ + + (void) AcpiEvReleaseGlobalLock (); + } + else + { + AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); + } + + /* Mark mutex unowned */ + + ObjDesc->Mutex.OwnerThread = NULL; + ObjDesc->Mutex.ThreadId = 0; + + /* Update Thread SyncLevel (Last mutex is the important one) */ + + Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; + } +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exnames.c b/reactos/drivers/bus/acpi/acpica/executer/exnames.c new file mode 100644 index 00000000000..89fa2d4874d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exnames.c @@ -0,0 +1,560 @@ + +/****************************************************************************** + * + * Module Name: exnames - interpreter/scanner name load/execute + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXNAMES_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exnames") + +/* Local prototypes */ + +static char * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs); + +static ACPI_STATUS +AcpiExNameSegment ( + UINT8 **InAmlAddress, + char *NameString); + + +/******************************************************************************* + * + * FUNCTION: AcpiExAllocateNameString + * + * PARAMETERS: PrefixCount - Count of parent levels. Special cases: + * (-1)==root, 0==none + * NumNameSegs - count of 4-character name segments + * + * RETURN: A pointer to the allocated string segment. This segment must + * be deleted by the caller. + * + * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name + * string is long enough, and set up prefix if any. + * + ******************************************************************************/ + +static char * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs) +{ + char *TempPtr; + char *NameString; + UINT32 SizeNeeded; + + ACPI_FUNCTION_TRACE (ExAllocateNameString); + + + /* + * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix. + * Also, one byte for the null terminator. + * This may actually be somewhat longer than needed. + */ + if (PrefixCount == ACPI_UINT32_MAX) + { + /* Special case for root */ + + SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; + } + else + { + SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; + } + + /* + * Allocate a buffer for the name. + * This buffer must be deleted by the caller! + */ + NameString = ACPI_ALLOCATE (SizeNeeded); + if (!NameString) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate size %d", SizeNeeded)); + return_PTR (NULL); + } + + TempPtr = NameString; + + /* Set up Root or Parent prefixes if needed */ + + if (PrefixCount == ACPI_UINT32_MAX) + { + *TempPtr++ = AML_ROOT_PREFIX; + } + else + { + while (PrefixCount--) + { + *TempPtr++ = AML_PARENT_PREFIX; + } + } + + + /* Set up Dual or Multi prefixes if needed */ + + if (NumNameSegs > 2) + { + /* Set up multi prefixes */ + + *TempPtr++ = AML_MULTI_NAME_PREFIX_OP; + *TempPtr++ = (char) NumNameSegs; + } + else if (2 == NumNameSegs) + { + /* Set up dual prefixes */ + + *TempPtr++ = AML_DUAL_NAME_PREFIX; + } + + /* + * Terminate string following prefixes. AcpiExNameSegment() will + * append the segment(s) + */ + *TempPtr = 0; + + return_PTR (NameString); +} + +/******************************************************************************* + * + * FUNCTION: AcpiExNameSegment + * + * PARAMETERS: InAmlAddress - Pointer to the name in the AML code + * NameString - Where to return the name. The name is appended + * to any existing string to form a namepath + * + * RETURN: Status + * + * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExNameSegment ( + UINT8 **InAmlAddress, + char *NameString) +{ + char *AmlAddress = (void *) *InAmlAddress; + ACPI_STATUS Status = AE_OK; + UINT32 Index; + char CharBuf[5]; + + + ACPI_FUNCTION_TRACE (ExNameSegment); + + + /* + * If first character is a digit, then we know that we aren't looking at a + * valid name segment + */ + CharBuf[0] = *AmlAddress; + + if ('0' <= CharBuf[0] && CharBuf[0] <= '9') + { + ACPI_ERROR ((AE_INFO, "Invalid leading digit: %c", CharBuf[0])); + return_ACPI_STATUS (AE_CTRL_PENDING); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); + + for (Index = 0; + (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0)); + Index++) + { + CharBuf[Index] = *AmlAddress++; + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", CharBuf[Index])); + } + + + /* Valid name segment */ + + if (Index == 4) + { + /* Found 4 valid characters */ + + CharBuf[4] = '\0'; + + if (NameString) + { + ACPI_STRCAT (NameString, CharBuf); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Appended to - %s\n", NameString)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "No Name string - %s\n", CharBuf)); + } + } + else if (Index == 0) + { + /* + * First character was not a valid name character, + * so we are looking at something other than a name. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Leading character is not alpha: %02Xh (not a name)\n", + CharBuf[0])); + Status = AE_CTRL_PENDING; + } + else + { + /* + * Segment started with one or more valid characters, but fewer than + * the required 4 + */ + Status = AE_AML_BAD_NAME; + ACPI_ERROR ((AE_INFO, + "Bad character %02x in name, at %p", + *AmlAddress, AmlAddress)); + } + + *InAmlAddress = ACPI_CAST_PTR (UINT8, AmlAddress); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetNameString + * + * PARAMETERS: DataType - Object type to be associated with this + * name + * InAmlAddress - Pointer to the namestring in the AML code + * OutNameString - Where the namestring is returned + * OutNameLength - Length of the returned string + * + * RETURN: Status, namestring and length + * + * DESCRIPTION: Extract a full namepath from the AML byte stream, + * including any prefixes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExGetNameString ( + ACPI_OBJECT_TYPE DataType, + UINT8 *InAmlAddress, + char **OutNameString, + UINT32 *OutNameLength) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *AmlAddress = InAmlAddress; + char *NameString = NULL; + UINT32 NumSegments; + UINT32 PrefixCount = 0; + BOOLEAN HasPrefix = FALSE; + + + ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress); + + + if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType || + ACPI_TYPE_LOCAL_BANK_FIELD == DataType || + ACPI_TYPE_LOCAL_INDEX_FIELD == DataType) + { + /* Disallow prefixes for types associated with FieldUnit names */ + + NameString = AcpiExAllocateNameString (0, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + } + else + { + Status = AcpiExNameSegment (&AmlAddress, NameString); + } + } + else + { + /* + * DataType is not a field name. + * Examine first character of name for root or parent prefix operators + */ + switch (*AmlAddress) + { + case AML_ROOT_PREFIX: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", + AmlAddress)); + + /* + * Remember that we have a RootPrefix -- + * see comment in AcpiExAllocateNameString() + */ + AmlAddress++; + PrefixCount = ACPI_UINT32_MAX; + HasPrefix = TRUE; + break; + + + case AML_PARENT_PREFIX: + + /* Increment past possibly multiple parent prefixes */ + + do + { + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", + AmlAddress)); + + AmlAddress++; + PrefixCount++; + + } while (*AmlAddress == AML_PARENT_PREFIX); + + HasPrefix = TRUE; + break; + + + default: + + /* Not a prefix character */ + + break; + } + + /* Examine first character of name for name segment prefix operator */ + + switch (*AmlAddress) + { + case AML_DUAL_NAME_PREFIX: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", + AmlAddress)); + + AmlAddress++; + NameString = AcpiExAllocateNameString (PrefixCount, 2); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + + HasPrefix = TRUE; + + Status = AcpiExNameSegment (&AmlAddress, NameString); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExNameSegment (&AmlAddress, NameString); + } + break; + + + case AML_MULTI_NAME_PREFIX_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", + AmlAddress)); + + /* Fetch count of segments remaining in name path */ + + AmlAddress++; + NumSegments = *AmlAddress; + + NameString = AcpiExAllocateNameString (PrefixCount, NumSegments); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + + AmlAddress++; + HasPrefix = TRUE; + + while (NumSegments && + (Status = AcpiExNameSegment (&AmlAddress, NameString)) == + AE_OK) + { + NumSegments--; + } + + break; + + + case 0: + + /* NullName valid as of 8-12-98 ASL/AML Grammar Update */ + + if (PrefixCount == ACPI_UINT32_MAX) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "NameSeg is \"\\\" followed by NULL\n")); + } + + /* Consume the NULL byte */ + + AmlAddress++; + NameString = AcpiExAllocateNameString (PrefixCount, 0); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + break; + + + default: + + /* Name segment string */ + + NameString = AcpiExAllocateNameString (PrefixCount, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + Status = AcpiExNameSegment (&AmlAddress, NameString); + break; + } + } + + if (AE_CTRL_PENDING == Status && HasPrefix) + { + /* Ran out of segments after processing a prefix */ + + ACPI_ERROR ((AE_INFO, + "Malformed Name at %p", NameString)); + Status = AE_AML_BAD_NAME; + } + + if (ACPI_FAILURE (Status)) + { + if (NameString) + { + ACPI_FREE (NameString); + } + return_ACPI_STATUS (Status); + } + + *OutNameString = NameString; + *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c new file mode 100644 index 00000000000..4a90b9c9506 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c @@ -0,0 +1,1183 @@ + +/****************************************************************************** + * + * Module Name: exoparg1 - AML execution - opcodes with 1 argument + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXOPARG1_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg1") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (0 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_0A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute operator with no operands, one return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_TIMER_OP: /* Timer () */ + + /* Create a return object of type Integer */ + + ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ()); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + +Cleanup: + + /* Delete return object on error */ + + if ((ACPI_FAILURE (Status)) || WalkState->ResultObj) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + else + { + /* Save the return value */ + + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_0T_0R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on + * object stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_RELEASE_OP: /* Release (MutexObject) */ + + Status = AcpiExReleaseMutex (Operand[0], WalkState); + break; + + + case AML_RESET_OP: /* Reset (EventObject) */ + + Status = AcpiExSystemResetEvent (Operand[0]); + break; + + + case AML_SIGNAL_OP: /* Signal (EventObject) */ + + Status = AcpiExSystemSignalEvent (Operand[0]); + break; + + + case AML_SLEEP_OP: /* Sleep (MsecTime) */ + + Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value); + break; + + + case AML_STALL_OP: /* Stall (UsecTime) */ + + Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value); + break; + + + case AML_UNLOAD_OP: /* Unload (Handle) */ + + Status = AcpiExUnloadTable (Operand[0]); + break; + + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_1T_0R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, one target, and no + * return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_1T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_LOAD_OP: + + Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState); + break; + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_1T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, one target, and a + * return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; + UINT32 Temp32; + UINT32 i; + ACPI_INTEGER PowerOfTen; + ACPI_INTEGER Digit; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_BIT_NOT_OP: + case AML_FIND_SET_LEFT_BIT_OP: + case AML_FIND_SET_RIGHT_BIT_OP: + case AML_FROM_BCD_OP: + case AML_TO_BCD_OP: + case AML_COND_REF_OF_OP: + + /* Create a return object of type Integer for these opcodes */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + switch (WalkState->Opcode) + { + case AML_BIT_NOT_OP: /* Not (Operand, Result) */ + + ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value; + break; + + + case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */ + + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; + + /* + * Acpi specification describes Integer type as a little + * endian unsigned value, so this boundary condition is valid. + */ + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + { + ReturnDesc->Integer.Value >>= 1; + } + + ReturnDesc->Integer.Value = Temp32; + break; + + + case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ + + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; + + /* + * The Acpi specification describes Integer type as a little + * endian unsigned value, so this boundary condition is valid. + */ + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + { + ReturnDesc->Integer.Value <<= 1; + } + + /* Since the bit position is one-based, subtract from 33 (65) */ + + ReturnDesc->Integer.Value = + Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; + break; + + + case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */ + + /* + * The 64-bit ACPI integer can hold 16 4-bit BCD characters + * (if table is 32-bit, integer can hold 8 BCD characters) + * Convert each 4-bit BCD value + */ + PowerOfTen = 1; + ReturnDesc->Integer.Value = 0; + Digit = Operand[0]->Integer.Value; + + /* Convert each BCD digit (each is one nybble wide) */ + + for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) + { + /* Get the least significant 4-bit BCD digit */ + + Temp32 = ((UINT32) Digit) & 0xF; + + /* Check the range of the digit */ + + if (Temp32 > 9) + { + ACPI_ERROR ((AE_INFO, + "BCD digit too large (not decimal): 0x%X", + Temp32)); + + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + /* Sum the digit into the result with the current power of 10 */ + + ReturnDesc->Integer.Value += + (((ACPI_INTEGER) Temp32) * PowerOfTen); + + /* Shift to next BCD digit */ + + Digit >>= 4; + + /* Next power of 10 */ + + PowerOfTen *= 10; + } + break; + + + case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */ + + ReturnDesc->Integer.Value = 0; + Digit = Operand[0]->Integer.Value; + + /* Each BCD digit is one nybble wide */ + + for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) + { + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32); + + /* + * Insert the BCD digit that resides in the + * remainder from above + */ + ReturnDesc->Integer.Value |= + (((ACPI_INTEGER) Temp32) << ACPI_MUL_4 (i)); + } + + /* Overflow if there is any data left in Digit */ + + if (Digit > 0) + { + ACPI_ERROR ((AE_INFO, + "Integer too large to convert to BCD: %8.8X%8.8X", + ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + break; + + + case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */ + + /* + * This op is a little strange because the internal return value is + * different than the return value stored in the result descriptor + * (There are really two return values) + */ + if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode) + { + /* + * This means that the object does not exist in the namespace, + * return FALSE + */ + ReturnDesc->Integer.Value = 0; + goto Cleanup; + } + + /* Get the object reference, store it, and remove our reference */ + + Status = AcpiExGetObjectReference (Operand[0], + &ReturnDesc2, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState); + AcpiUtRemoveReference (ReturnDesc2); + + /* The object exists in the namespace, return TRUE */ + + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + goto Cleanup; + + + default: + /* No other opcodes get here */ + break; + } + break; + + + case AML_STORE_OP: /* Store (Source, Target) */ + + /* + * A store operand is typically a number, string, buffer or lvalue + * Be careful about deleting the source object, + * since the object itself may have been stored. + */ + Status = AcpiExStore (Operand[0], Operand[1], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* It is possible that the Store already produced a return object */ + + if (!WalkState->ResultObj) + { + /* + * Normally, we would remove a reference on the Operand[0] + * parameter; But since it is being used as the internal return + * object (meaning we would normally increment it), the two + * cancel out, and we simply don't do anything. + */ + WalkState->ResultObj = Operand[0]; + WalkState->Operands[0] = NULL; /* Prevent deletion */ + } + return_ACPI_STATUS (Status); + + + /* + * ACPI 2.0 Opcodes + */ + case AML_COPY_OP: /* Copy (Source, Target) */ + + Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, + WalkState); + break; + + + case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ + + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_DECIMAL); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */ + + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_HEX); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ + + Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ + + Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, + ACPI_ANY_BASE); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ + case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ + + /* These are two obsolete opcodes */ + + ACPI_ERROR ((AE_INFO, + "%s is obsolete and not implemented", + AcpiPsGetOpcodeName (WalkState->Opcode))); + Status = AE_SUPPORT; + goto Cleanup; + + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + if (ACPI_SUCCESS (Status)) + { + /* Store the return value computed above into the target object */ + + Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *TempDesc; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + UINT32 Type; + ACPI_INTEGER Value; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_LNOT_OP: /* LNot (Operand) */ + + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Set result to ONES (TRUE) if Value == 0. Note: + * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above. + */ + if (!Operand[0]->Integer.Value) + { + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + } + break; + + + case AML_DECREMENT_OP: /* Decrement (Operand) */ + case AML_INCREMENT_OP: /* Increment (Operand) */ + + /* + * Create a new integer. Can't just get the base integer and + * increment it because it may be an Arg or Field. + */ + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Since we are expecting a Reference operand, it can be either a + * NS Node or an internal object. + */ + TempDesc = Operand[0]; + if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND) + { + /* Internal reference object - prevent deletion */ + + AcpiUtAddReference (TempDesc); + } + + /* + * Convert the Reference operand to an Integer (This removes a + * reference on the Operand[0] object) + * + * NOTE: We use LNOT_OP here in order to force resolution of the + * reference operand to an actual integer. + */ + Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While resolving operands for [%s]", + AcpiPsGetOpcodeName (WalkState->Opcode))); + + goto Cleanup; + } + + /* + * TempDesc is now guaranteed to be an Integer object -- + * Perform the actual increment or decrement + */ + if (WalkState->Opcode == AML_INCREMENT_OP) + { + ReturnDesc->Integer.Value = TempDesc->Integer.Value +1; + } + else + { + ReturnDesc->Integer.Value = TempDesc->Integer.Value -1; + } + + /* Finished with this Integer object */ + + AcpiUtRemoveReference (TempDesc); + + /* + * Store the result back (indirectly) through the original + * Reference object + */ + Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); + break; + + + case AML_TYPE_OP: /* ObjectType (SourceObject) */ + + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. For example, we don't + * want to resolve a FieldUnit to its value, we want the actual + * FieldUnit object. + */ + + /* Get the type of the base object */ + + Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Allocate a descriptor to hold the type. */ + + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ + + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. + */ + + /* Get the base object */ + + Status = AcpiExResolveMultiple (WalkState, + Operand[0], &Type, &TempDesc); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * The type of the base object must be integer, buffer, string, or + * package. All others are not supported. + * + * NOTE: Integer is not specifically supported by the ACPI spec, + * but is supported implicitly via implicit operand conversion. + * rather than bother with conversion, we just use the byte width + * global (4 or 8 bytes). + */ + switch (Type) + { + case ACPI_TYPE_INTEGER: + Value = AcpiGbl_IntegerByteWidth; + break; + + case ACPI_TYPE_STRING: + Value = TempDesc->String.Length; + break; + + case ACPI_TYPE_BUFFER: + + /* Buffer arguments may not be evaluated at this point */ + + Status = AcpiDsGetBufferArguments (TempDesc); + Value = TempDesc->Buffer.Length; + break; + + case ACPI_TYPE_PACKAGE: + + /* Package arguments may not be evaluated at this point */ + + Status = AcpiDsGetPackageArguments (TempDesc); + Value = TempDesc->Package.Count; + break; + + default: + ACPI_ERROR ((AE_INFO, + "Operand must be Buffer/Integer/String/Package - found type %s", + AcpiUtGetTypeName (Type))); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Now that we have the size of the object, create a result + * object to hold the value + */ + ReturnDesc = AcpiUtCreateIntegerObject (Value); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case AML_REF_OF_OP: /* RefOf (SourceObject) */ + + Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + break; + + + case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */ + + /* Check for a method local or argument, or standalone String */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) + { + TempDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); + if (TempDesc && + ((TempDesc->Common.Type == ACPI_TYPE_STRING) || + (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE))) + { + Operand[0] = TempDesc; + AcpiUtAddReference (TempDesc); + } + else + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + else + { + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * This is a DerefOf (LocalX | ArgX) + * + * Must resolve/dereference the local/arg reference first + */ + switch (Operand[0]->Reference.Class) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* Set Operand[0] to the value of the local/arg */ + + Status = AcpiDsMethodDataGetValue ( + Operand[0]->Reference.Class, + Operand[0]->Reference.Value, + WalkState, &TempDesc); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Delete our reference to the input object and + * point to the object just retrieved + */ + AcpiUtRemoveReference (Operand[0]); + Operand[0] = TempDesc; + break; + + case ACPI_REFCLASS_REFOF: + + /* Get the object to which the reference refers */ + + TempDesc = Operand[0]->Reference.Object; + AcpiUtRemoveReference (Operand[0]); + Operand[0] = TempDesc; + break; + + default: + + /* Must be an Index op - handled below */ + break; + } + break; + + case ACPI_TYPE_STRING: + break; + + default: + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED) + { + if ((Operand[0])->Common.Type == ACPI_TYPE_STRING) + { + /* + * This is a DerefOf (String). The string is a reference + * to a named ACPI object. + * + * 1) Find the owning Node + * 2) Dereference the node to an actual object. Could be a + * Field, so we need to resolve the node to a value. + */ + Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node, + Operand[0]->String.Pointer, + ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc)); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc), + WalkState); + goto Cleanup; + } + } + + /* Operand[0] may have changed from the code above */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) + { + /* + * This is a DerefOf (ObjectReference) + * Get the actual object from the Node (This is the dereference). + * This case may only happen when a LocalX or ArgX is + * dereferenced above. + */ + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); + AcpiUtAddReference (ReturnDesc); + } + else + { + /* + * This must be a reference object produced by either the + * Index() or RefOf() operator + */ + switch (Operand[0]->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + /* + * The target type for the Index operator must be + * either a Buffer or a Package + */ + switch (Operand[0]->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + TempDesc = Operand[0]->Reference.Object; + + /* + * Create a new object that contains one element of the + * buffer -- the element pointed to by the index. + * + * NOTE: index into a buffer is NOT a pointer to a + * sub-buffer of the main buffer, it is only a pointer to a + * single element (byte) of the buffer! + * + * Since we are returning the value of the buffer at the + * indexed location, we don't need to add an additional + * reference to the buffer itself. + */ + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) + TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * Return the referenced element of the package. We must + * add another reference to the referenced object, however. + */ + ReturnDesc = *(Operand[0]->Reference.Where); + if (ReturnDesc) + { + AcpiUtAddReference (ReturnDesc); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Index TargetType %X in reference object %p", + Operand[0]->Reference.TargetType, Operand[0])); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ACPI_REFCLASS_REFOF: + + ReturnDesc = Operand[0]->Reference.Object; + + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == + ACPI_DESC_TYPE_NAMED) + { + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ReturnDesc); + } + + /* Add another reference to the object! */ + + AcpiUtAddReference (ReturnDesc); + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Unknown class in reference(%p) - %2.2X", + Operand[0], Operand[0]->Reference.Class)); + + Status = AE_TYPE; + goto Cleanup; + } + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg2.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg2.c new file mode 100644 index 00000000000..7c42652cc4c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg2.c @@ -0,0 +1,741 @@ +/****************************************************************************** + * + * Module Name: exoparg2 - AML execution - opcodes with 2 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXOPARG2_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acinterp.h" +#include "acevents.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg2") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_0T_0R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with two arguments, no target, and no return + * value. + * + * ALLOCATION: Deletes both operands + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_NAMESPACE_NODE *Node; + UINT32 Value; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the opcode */ + + switch (WalkState->Opcode) + { + case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */ + + /* The first operand is a namespace node */ + + Node = (ACPI_NAMESPACE_NODE *) Operand[0]; + + /* Second value is the notify value */ + + Value = (UINT32) Operand[1]->Integer.Value; + + /* Are notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + ACPI_ERROR ((AE_INFO, + "Unexpected notify object type [%s]", + AcpiUtGetTypeName (Node->Type))); + + Status = AE_AML_OPERAND_TYPE; + break; + } + +#ifdef ACPI_GPE_NOTIFY_CHECK + /* + * GPE method wake/notify check. Here, we want to ensure that we + * don't receive any "DeviceWake" Notifies from a GPE _Lxx or _Exx + * GPE method during system runtime. If we do, the GPE is marked + * as "wake-only" and disabled. + * + * 1) Is the Notify() value == DeviceWake? + * 2) Is this a GPE deferred method? (An _Lxx or _Exx method) + * 3) Did the original GPE happen at system runtime? + * (versus during wake) + * + * If all three cases are true, this is a wake-only GPE that should + * be disabled at runtime. + */ + if (Value == 2) /* DeviceWake */ + { + Status = AcpiEvCheckForWakeOnlyGpe (WalkState->GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + /* AE_WAKE_ONLY_GPE only error, means ignore this notify */ + + return_ACPI_STATUS (AE_OK) + } + } +#endif + + /* + * Dispatch the notify to the appropriate handler + * NOTE: the request is queued for execution after this method + * completes. The notify handlers are NOT invoked synchronously + * from this thread -- because handlers may in turn run other + * control methods. + */ + Status = AcpiEvQueueNotifyRequest (Node, Value); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_2T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets + * and one implicit return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_2T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Execute the opcode */ + + switch (WalkState->Opcode) + { + case AML_DIVIDE_OP: + + /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ + + ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc1) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc2) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ + + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + &ReturnDesc1->Integer.Value, + &ReturnDesc2->Integer.Value); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Store the results to the target reference operands */ + + Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + +Cleanup: + /* + * Since the remainder is not returned indirectly, remove a reference to + * it. Only the quotient is returned indirectly. + */ + AcpiUtRemoveReference (ReturnDesc2); + + if (ACPI_FAILURE (Status)) + { + /* Delete the return object */ + + AcpiUtRemoveReference (ReturnDesc1); + } + + /* Save return object (the remainder) on success */ + + else + { + WalkState->ResultObj = ReturnDesc1; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_1T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with two arguments, one target, and a return + * value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_INTEGER Index; + ACPI_STATUS Status = AE_OK; + ACPI_SIZE Length; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Execute the opcode */ + + if (WalkState->OpInfo->Flags & AML_MATH) + { + /* All simple math opcodes (add, etc.) */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode, + Operand[0]->Integer.Value, + Operand[1]->Integer.Value); + goto StoreResultToTarget; + } + + switch (WalkState->Opcode) + { + case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* ReturnDesc will contain the remainder */ + + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + NULL, + &ReturnDesc->Integer.Value); + break; + + + case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ + + Status = AcpiExDoConcatenate (Operand[0], Operand[1], + &ReturnDesc, WalkState); + break; + + + case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ + + /* + * Input object is guaranteed to be a buffer at this point (it may have + * been converted.) Copy the raw buffer data to a new object of + * type String. + */ + + /* + * Get the length of the new string. It is the smallest of: + * 1) Length of the input buffer + * 2) Max length as specified in the ToString operator + * 3) Length of input buffer up to a zero byte (null terminator) + * + * NOTE: A length of zero is ok, and will create a zero-length, null + * terminated string. + */ + Length = 0; + while ((Length < Operand[0]->Buffer.Length) && + (Length < Operand[1]->Integer.Value) && + (Operand[0]->Buffer.Pointer[Length])) + { + Length++; + } + + /* Allocate a new string object */ + + ReturnDesc = AcpiUtCreateStringObject (Length); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Copy the raw buffer data with no transform. + * (NULL terminated already) + */ + ACPI_MEMCPY (ReturnDesc->String.Pointer, + Operand[0]->Buffer.Pointer, Length); + break; + + + case AML_CONCAT_RES_OP: + + /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ + + Status = AcpiExConcatTemplate (Operand[0], Operand[1], + &ReturnDesc, WalkState); + break; + + + case AML_INDEX_OP: /* Index (Source Index Result) */ + + /* Create the internal return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Initialize the Index reference object */ + + Index = Operand[1]->Integer.Value; + ReturnDesc->Reference.Value = (UINT32) Index; + ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX; + + /* + * At this point, the Source operand is a String, Buffer, or Package. + * Verify that the index is within range. + */ + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_STRING: + + if (Index >= Operand[0]->String.Length) + { + Status = AE_AML_STRING_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_BUFFER: + + if (Index >= Operand[0]->Buffer.Length) + { + Status = AE_AML_BUFFER_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_PACKAGE: + + if (Index >= Operand[0]->Package.Count) + { + Status = AE_AML_PACKAGE_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; + ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; + break; + + default: + + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + /* Failure means that the Index was beyond the end of the object */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Index (%X%8.8X) is beyond end of object", + ACPI_FORMAT_UINT64 (Index))); + goto Cleanup; + } + + /* + * Save the target object and add a reference to it for the life + * of the index + */ + ReturnDesc->Reference.Object = Operand[0]; + AcpiUtAddReference (Operand[0]); + + /* Store the reference to the Target */ + + Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); + + /* Return the reference */ + + WalkState->ResultObj = ReturnDesc; + goto Cleanup; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + + +StoreResultToTarget: + + if (ACPI_SUCCESS (Status)) + { + /* + * Store the result of the operation (which is now in ReturnDesc) into + * the Target descriptor. + */ + Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_0T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + BOOLEAN LogicalResult = FALSE; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Create the internal return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Execute the Opcode */ + + if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC) + { + /* LogicalOp (Operand0, Operand1) */ + + Status = AcpiExDoLogicalNumericOp (WalkState->Opcode, + Operand[0]->Integer.Value, Operand[1]->Integer.Value, + &LogicalResult); + goto StoreLogicalResult; + } + else if (WalkState->OpInfo->Flags & AML_LOGICAL) + { + /* LogicalOp (Operand0, Operand1) */ + + Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], + Operand[1], &LogicalResult); + goto StoreLogicalResult; + } + + switch (WalkState->Opcode) + { + case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */ + + Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState); + if (Status == AE_TIME) + { + LogicalResult = TRUE; /* TRUE = Acquire timed out */ + Status = AE_OK; + } + break; + + + case AML_WAIT_OP: /* Wait (EventObject, Timeout) */ + + Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]); + if (Status == AE_TIME) + { + LogicalResult = TRUE; /* TRUE, Wait timed out */ + Status = AE_OK; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +StoreLogicalResult: + /* + * Set return value to according to LogicalResult. logical TRUE (all ones) + * Default is FALSE (zero) + */ + if (LogicalResult) + { + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + } + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg3.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg3.c new file mode 100644 index 00000000000..591d6aceb12 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg3.c @@ -0,0 +1,377 @@ + +/****************************************************************************** + * + * Module Name: exoparg3 - AML execution - opcodes with 3 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXOPARG3_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg3") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_3A_0T_0R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute Triadic operator (3 operands) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_3A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_SIGNAL_FATAL_INFO *Fatal; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + (UINT32) Operand[0]->Integer.Value, + (UINT32) Operand[1]->Integer.Value, + (UINT32) Operand[2]->Integer.Value)); + + Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); + if (Fatal) + { + Fatal->Type = (UINT32) Operand[0]->Integer.Value; + Fatal->Code = (UINT32) Operand[1]->Integer.Value; + Fatal->Argument = (UINT32) Operand[2]->Integer.Value; + } + + /* Always signal the OS! */ + + Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); + + /* Might return while OS is shutting down, just continue */ + + ACPI_FREE (Fatal); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_3A_1T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute Triadic operator (3 operands) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_3A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + char *Buffer = NULL; + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Index; + ACPI_SIZE Length; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ + + /* + * Create the return object. The Source operand is guaranteed to be + * either a String or a Buffer, so just use its type. + */ + ReturnDesc = AcpiUtCreateInternalObject ( + (Operand[0])->Common.Type); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the Integer values from the objects */ + + Index = Operand[1]->Integer.Value; + Length = (ACPI_SIZE) Operand[2]->Integer.Value; + + /* + * If the index is beyond the length of the String/Buffer, or if the + * requested length is zero, return a zero-length String/Buffer + */ + if (Index >= Operand[0]->String.Length) + { + Length = 0; + } + + /* Truncate request if larger than the actual String/Buffer */ + + else if ((Index + Length) > Operand[0]->String.Length) + { + Length = (ACPI_SIZE) Operand[0]->String.Length - + (ACPI_SIZE) Index; + } + + /* Strings always have a sub-pointer, not so for buffers */ + + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_STRING: + + /* Always allocate a new buffer for the String */ + + Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1); + if (!Buffer) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + case ACPI_TYPE_BUFFER: + + /* If the requested length is zero, don't allocate a buffer */ + + if (Length > 0) + { + /* Allocate a new buffer for the Buffer */ + + Buffer = ACPI_ALLOCATE_ZEROED (Length); + if (!Buffer) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + } + break; + + default: /* Should not happen */ + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (Buffer) + { + /* We have a buffer, copy the portion requested */ + + ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index, + Length); + } + + /* Set the length of the new String/Buffer */ + + ReturnDesc->String.Pointer = Buffer; + ReturnDesc->String.Length = (UINT32) Length; + + /* Mark buffer initialized */ + + ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Store the result in the target */ + + Status = AcpiExStore (ReturnDesc, Operand[3], WalkState); + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) || WalkState->ResultObj) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + + /* Set the return object and exit */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg6.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg6.c new file mode 100644 index 00000000000..c2609471dd7 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg6.c @@ -0,0 +1,438 @@ + +/****************************************************************************** + * + * Module Name: exoparg6 - AML execution - opcodes with 6 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXOPARG6_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg6") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + +/* Local prototypes */ + +static BOOLEAN +AcpiExDoMatch ( + UINT32 MatchOp, + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoMatch + * + * PARAMETERS: MatchOp - The AML match operand + * PackageObj - Object from the target package + * MatchObj - Object to be matched + * + * RETURN: TRUE if the match is successful, FALSE otherwise + * + * DESCRIPTION: Implements the low-level match for the ASL Match operator. + * Package elements will be implicitly converted to the type of + * the match object (Integer/Buffer/String). + * + ******************************************************************************/ + +static BOOLEAN +AcpiExDoMatch ( + UINT32 MatchOp, + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj) +{ + BOOLEAN LogicalResult = TRUE; + ACPI_STATUS Status; + + + /* + * Note: Since the PackageObj/MatchObj ordering is opposite to that of + * the standard logical operators, we have to reverse them when we call + * DoLogicalOp in order to make the implicit conversion rules work + * correctly. However, this means we have to flip the entire equation + * also. A bit ugly perhaps, but overall, better than fussing the + * parameters around at runtime, over and over again. + * + * Below, P[i] refers to the package element, M refers to the Match object. + */ + switch (MatchOp) + { + case MATCH_MTR: + + /* Always true */ + + break; + + case MATCH_MEQ: + + /* + * True if equal: (P[i] == M) + * Change to: (M == P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + case MATCH_MLE: + + /* + * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) + * Change to: (M >= P[i]) (M NotLess than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + LogicalResult = (BOOLEAN) !LogicalResult; + break; + + case MATCH_MLT: + + /* + * True if less than: (P[i] < M) + * Change to: (M > P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + case MATCH_MGE: + + /* + * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) + * Change to: (M <= P[i]) (M NotGreater than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + LogicalResult = (BOOLEAN)!LogicalResult; + break; + + case MATCH_MGT: + + /* + * True if greater than: (P[i] > M) + * Change to: (M < P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + default: + + /* Undefined */ + + return (FALSE); + } + + return LogicalResult; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_6A_0T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_6A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Index; + ACPI_OPERAND_OBJECT *ThisElement; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_MATCH_OP: + /* + * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2], + * MatchOp2[3], MatchObj2[4], StartIndex[5]) + */ + + /* Validate both Match Term Operators (MTR, MEQ, etc.) */ + + if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) || + (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR)) + { + ACPI_ERROR ((AE_INFO, "Match operator out of range")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + /* Get the package StartIndex, validate against the package length */ + + Index = Operand[5]->Integer.Value; + if (Index >= Operand[0]->Package.Count) + { + ACPI_ERROR ((AE_INFO, + "Index (%X%8.8X) beyond package end (%X)", + ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); + Status = AE_AML_PACKAGE_LIMIT; + goto Cleanup; + } + + /* Create an integer for the return value */ + /* Default return value is ACPI_INTEGER_MAX if no match found */ + + ReturnDesc = AcpiUtCreateIntegerObject (ACPI_INTEGER_MAX); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + + } + + /* + * Examine each element until a match is found. Both match conditions + * must be satisfied for a match to occur. Within the loop, + * "continue" signifies that the current element does not match + * and the next should be examined. + * + * Upon finding a match, the loop will terminate via "break" at + * the bottom. If it terminates "normally", MatchValue will be + * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no + * match was found. + */ + for ( ; Index < Operand[0]->Package.Count; Index++) + { + /* Get the current package element */ + + ThisElement = Operand[0]->Package.Elements[Index]; + + /* Treat any uninitialized (NULL) elements as non-matching */ + + if (!ThisElement) + { + continue; + } + + /* + * Both match conditions must be satisfied. Execution of a continue + * (proceed to next iteration of enclosing for loop) signifies a + * non-match. + */ + if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, + ThisElement, Operand[2])) + { + continue; + } + + if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, + ThisElement, Operand[4])) + { + continue; + } + + /* Match found: Index is the return value */ + + ReturnDesc->Integer.Value = Index; + break; + } + break; + + + case AML_LOAD_TABLE_OP: + + Status = AcpiExLoadTableOp (WalkState, &ReturnDesc); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/executer/exprep.c b/reactos/drivers/bus/acpi/acpica/executer/exprep.c new file mode 100644 index 00000000000..c915361e810 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exprep.c @@ -0,0 +1,686 @@ + +/****************************************************************************** + * + * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXPREP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exprep") + +/* Local prototypes */ + +static UINT32 +AcpiExDecodeFieldAccess ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT32 *ReturnByteAlignment); + + +#ifdef ACPI_UNDER_DEVELOPMENT + +static UINT32 +AcpiExGenerateAccess ( + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 RegionLength); + +/******************************************************************************* + * + * FUNCTION: AcpiExGenerateAccess + * + * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer + * FieldBitLength - Length of field in bits + * RegionLength - Length of parent in bytes + * + * RETURN: Field granularity (8, 16, 32 or 64) and + * ByteAlignment (1, 2, 3, or 4) + * + * DESCRIPTION: Generate an optimal access width for fields defined with the + * AnyAcc keyword. + * + * NOTE: Need to have the RegionLength in order to check for boundary + * conditions (end-of-region). However, the RegionLength is a deferred + * operation. Therefore, to complete this implementation, the generation + * of this access width must be deferred until the region length has + * been evaluated. + * + ******************************************************************************/ + +static UINT32 +AcpiExGenerateAccess ( + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 RegionLength) +{ + UINT32 FieldByteLength; + UINT32 FieldByteOffset; + UINT32 FieldByteEndOffset; + UINT32 AccessByteWidth; + UINT32 FieldStartOffset; + UINT32 FieldEndOffset; + UINT32 MinimumAccessWidth = 0xFFFFFFFF; + UINT32 MinimumAccesses = 0xFFFFFFFF; + UINT32 Accesses; + + + ACPI_FUNCTION_TRACE (ExGenerateAccess); + + + /* Round Field start offset and length to "minimal" byte boundaries */ + + FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8)); + FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + + FieldBitOffset, 8)); + FieldByteLength = FieldByteEndOffset - FieldByteOffset; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Bit length %d, Bit offset %d\n", + FieldBitLength, FieldBitOffset)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Byte Length %d, Byte Offset %d, End Offset %d\n", + FieldByteLength, FieldByteOffset, FieldByteEndOffset)); + + /* + * Iterative search for the maximum access width that is both aligned + * and does not go beyond the end of the region + * + * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes) + */ + for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1) + { + /* + * 1) Round end offset up to next access boundary and make sure that + * this does not go beyond the end of the parent region. + * 2) When the Access width is greater than the FieldByteLength, we + * are done. (This does not optimize for the perfectly aligned + * case yet). + */ + if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) + { + FieldStartOffset = + ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / + AccessByteWidth; + + FieldEndOffset = + ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), + AccessByteWidth) / AccessByteWidth; + + Accesses = FieldEndOffset - FieldStartOffset; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "AccessWidth %d end is within region\n", AccessByteWidth)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Field Start %d, Field End %d -- requires %d accesses\n", + FieldStartOffset, FieldEndOffset, Accesses)); + + /* Single access is optimal */ + + if (Accesses <= 1) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Entire field can be accessed with one operation of size %d\n", + AccessByteWidth)); + return_VALUE (AccessByteWidth); + } + + /* + * Fits in the region, but requires more than one read/write. + * try the next wider access on next iteration + */ + if (Accesses < MinimumAccesses) + { + MinimumAccesses = Accesses; + MinimumAccessWidth = AccessByteWidth; + } + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "AccessWidth %d end is NOT within region\n", AccessByteWidth)); + if (AccessByteWidth == 1) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Field goes beyond end-of-region!\n")); + + /* Field does not fit in the region at all */ + + return_VALUE (0); + } + + /* + * This width goes beyond the end-of-region, back off to + * previous access + */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Backing off to previous optimal access width of %d\n", + MinimumAccessWidth)); + return_VALUE (MinimumAccessWidth); + } + } + + /* + * Could not read/write field with one operation, + * just use max access width + */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Cannot access field in one operation, using width 8\n")); + return_VALUE (8); +} +#endif /* ACPI_UNDER_DEVELOPMENT */ + + +/******************************************************************************* + * + * FUNCTION: AcpiExDecodeFieldAccess + * + * PARAMETERS: ObjDesc - Field object + * FieldFlags - Encoded fieldflags (contains access bits) + * ReturnByteAlignment - Where the byte alignment is returned + * + * RETURN: Field granularity (8, 16, 32 or 64) and + * ByteAlignment (1, 2, 3, or 4) + * + * DESCRIPTION: Decode the AccessType bits of a field definition. + * + ******************************************************************************/ + +static UINT32 +AcpiExDecodeFieldAccess ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT32 *ReturnByteAlignment) +{ + UINT32 Access; + UINT32 ByteAlignment; + UINT32 BitLength; + + + ACPI_FUNCTION_TRACE (ExDecodeFieldAccess); + + + Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK); + + switch (Access) + { + case AML_FIELD_ACCESS_ANY: + +#ifdef ACPI_UNDER_DEVELOPMENT + ByteAlignment = + AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */); + BitLength = ByteAlignment * 8; +#endif + + ByteAlignment = 1; + BitLength = 8; + break; + + case AML_FIELD_ACCESS_BYTE: + case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ + ByteAlignment = 1; + BitLength = 8; + break; + + case AML_FIELD_ACCESS_WORD: + ByteAlignment = 2; + BitLength = 16; + break; + + case AML_FIELD_ACCESS_DWORD: + ByteAlignment = 4; + BitLength = 32; + break; + + case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ + ByteAlignment = 8; + BitLength = 64; + break; + + default: + /* Invalid field access type */ + + ACPI_ERROR ((AE_INFO, + "Unknown field access type %X", + Access)); + return_UINT32 (0); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * BufferField access can be on any byte boundary, so the + * ByteAlignment is always 1 byte -- regardless of any ByteAlignment + * implied by the field access type. + */ + ByteAlignment = 1; + } + + *ReturnByteAlignment = ByteAlignment; + return_UINT32 (BitLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPrepCommonFieldObject + * + * PARAMETERS: ObjDesc - The field object + * FieldFlags - Access, LockRule, and UpdateRule. + * The format of a FieldFlag is described + * in the ACPI specification + * FieldAttribute - Special attributes (not used) + * FieldBitPosition - Field start position + * FieldBitLength - Field length in number of bits + * + * RETURN: Status + * + * DESCRIPTION: Initialize the areas of the field object that are common + * to the various types of fields. Note: This is very "sensitive" + * code because we are solving the general case for field + * alignment. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPrepCommonFieldObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldBitPosition, + UINT32 FieldBitLength) +{ + UINT32 AccessBitWidth; + UINT32 ByteAlignment; + UINT32 NearestByteAddress; + + + ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject); + + + /* + * Note: the structure being initialized is the + * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common + * area are initialized by this procedure. + */ + ObjDesc->CommonField.FieldFlags = FieldFlags; + ObjDesc->CommonField.Attribute = FieldAttribute; + ObjDesc->CommonField.BitLength = FieldBitLength; + + /* + * Decode the access type so we can compute offsets. The access type gives + * two pieces of information - the width of each field access and the + * necessary ByteAlignment (address granularity) of the access. + * + * For AnyAcc, the AccessBitWidth is the largest width that is both + * necessary and possible in an attempt to access the whole field in one + * I/O operation. However, for AnyAcc, the ByteAlignment is always one + * byte. + * + * For all Buffer Fields, the ByteAlignment is always one byte. + * + * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is + * the same (equivalent) as the ByteAlignment. + */ + AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, + &ByteAlignment); + if (!AccessBitWidth) + { + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + /* Setup width (access granularity) fields */ + + ObjDesc->CommonField.AccessByteWidth = (UINT8) + ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ + + ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth; + + /* + * BaseByteOffset is the address of the start of the field within the + * region. It is the byte address of the first *datum* (field-width data + * unit) of the field. (i.e., the first datum that contains at least the + * first *bit* of the field.) + * + * Note: ByteAlignment is always either equal to the AccessBitWidth or 8 + * (Byte access), and it defines the addressing granularity of the parent + * region or buffer. + */ + NearestByteAddress = + ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); + ObjDesc->CommonField.BaseByteOffset = (UINT32) + ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); + + /* + * StartFieldBitOffset is the offset of the first bit of the field within + * a field datum. + */ + ObjDesc->CommonField.StartFieldBitOffset = (UINT8) + (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); + + /* + * Does the entire field fit within a single field access element? (datum) + * (i.e., without crossing a datum boundary) + */ + if ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) <= + (UINT16) AccessBitWidth) + { + ObjDesc->Common.Flags |= AOPOBJ_SINGLE_DATUM; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPrepFieldValue + * + * PARAMETERS: Info - Contains all field creation info + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPrepFieldValue ( + ACPI_CREATE_FIELD_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *SecondDesc = NULL; + UINT32 Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExPrepFieldValue); + + + /* Parameter validation */ + + if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD) + { + if (!Info->RegionNode) + { + ACPI_ERROR ((AE_INFO, "Null RegionNode")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + Type = AcpiNsGetType (Info->RegionNode); + if (Type != ACPI_TYPE_REGION) + { + ACPI_ERROR ((AE_INFO, + "Needed Region, found type %X (%s)", + Type, AcpiUtGetTypeName (Type))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + } + + /* Allocate a new field object */ + + ObjDesc = AcpiUtCreateInternalObject (Info->FieldType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize areas of the object that are common to all fields */ + + ObjDesc->CommonField.Node = Info->FieldNode; + Status = AcpiExPrepCommonFieldObject (ObjDesc, Info->FieldFlags, + Info->Attribute, Info->FieldBitPosition, Info->FieldBitLength); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to the field type */ + + switch (Info->FieldType) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + + ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); + + /* An additional reference for the container */ + + AcpiUtAddReference (ObjDesc->Field.RegionObj); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", + ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj)); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + ObjDesc->BankField.Value = Info->BankValue; + ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject ( + Info->RegionNode); + ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); + + /* An additional reference for the attached objects */ + + AcpiUtAddReference (ObjDesc->BankField.RegionObj); + AcpiUtAddReference (ObjDesc->BankField.BankObj); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n", + ObjDesc->BankField.StartFieldBitOffset, + ObjDesc->BankField.BaseByteOffset, + ObjDesc->Field.AccessByteWidth, + ObjDesc->BankField.RegionObj, + ObjDesc->BankField.BankObj)); + + /* + * Remember location in AML stream of the field unit + * opcode and operands -- since the BankValue + * operands must be evaluated. + */ + SecondDesc = ObjDesc->Common.NextObject; + SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Data; + SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Length; + + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + /* Get the Index and Data registers */ + + ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); + ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject ( + Info->DataRegisterNode); + + if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) + { + ACPI_ERROR ((AE_INFO, "Null Index Object during field prep")); + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* An additional reference for the attached objects */ + + AcpiUtAddReference (ObjDesc->IndexField.DataObj); + AcpiUtAddReference (ObjDesc->IndexField.IndexObj); + + /* + * April 2006: Changed to match MS behavior + * + * The value written to the Index register is the byte offset of the + * target field in units of the granularity of the IndexField + * + * Previously, the value was calculated as an index in terms of the + * width of the Data register, as below: + * + * ObjDesc->IndexField.Value = (UINT32) + * (Info->FieldBitPosition / ACPI_MUL_8 ( + * ObjDesc->Field.AccessByteWidth)); + * + * February 2006: Tried value as a byte offset: + * ObjDesc->IndexField.Value = (UINT32) + * ACPI_DIV_8 (Info->FieldBitPosition); + */ + ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN ( + ACPI_DIV_8 (Info->FieldBitPosition), + ObjDesc->IndexField.AccessByteWidth); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", + ObjDesc->IndexField.StartFieldBitOffset, + ObjDesc->IndexField.BaseByteOffset, + ObjDesc->IndexField.Value, + ObjDesc->Field.AccessByteWidth, + ObjDesc->IndexField.IndexObj, + ObjDesc->IndexField.DataObj)); + break; + + default: + /* No other types should get here */ + break; + } + + /* + * Store the constructed descriptor (ObjDesc) into the parent Node, + * preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, + AcpiNsGetType (Info->FieldNode)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n", + Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exregion.c b/reactos/drivers/bus/acpi/acpica/executer/exregion.c new file mode 100644 index 00000000000..5a37be25950 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exregion.c @@ -0,0 +1,630 @@ + +/****************************************************************************** + * + * Module Name: exregion - ACPI default OpRegion (address space) handlers + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXREGION_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exregion") + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemMemorySpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the System Memory address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + void *LogicalAddrPtr = NULL; + ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext; + UINT32 Length; + ACPI_SIZE MapLength; + ACPI_SIZE PageBoundaryMapLength; +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED + UINT32 Remainder; +#endif + + + ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler); + + + /* Validate and translate the bit width */ + + switch (BitWidth) + { + case 8: + Length = 1; + break; + + case 16: + Length = 2; + break; + + case 32: + Length = 4; + break; + + case 64: + Length = 8; + break; + + default: + ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %d", + BitWidth)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED + /* + * Hardware does not support non-aligned data transfers, we must verify + * the request. + */ + (void) AcpiUtShortDivide ((ACPI_INTEGER) Address, Length, NULL, &Remainder); + if (Remainder != 0) + { + return_ACPI_STATUS (AE_AML_ALIGNMENT); + } +#endif + + /* + * Does the request fit into the cached memory mapping? + * Is 1) Address below the current mapping? OR + * 2) Address beyond the current mapping? + */ + if ((Address < MemInfo->MappedPhysicalAddress) || + (((ACPI_INTEGER) Address + Length) > + ((ACPI_INTEGER) + MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) + { + /* + * The request cannot be resolved by the current memory mapping; + * Delete the existing mapping and create a new one. + */ + if (MemInfo->MappedLength) + { + /* Valid mapping, delete it */ + + AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress, + MemInfo->MappedLength); + } + + /* + * October 2009: Attempt to map from the requested address to the + * end of the region. However, we will never map more than one + * page, nor will we cross a page boundary. + */ + MapLength = (ACPI_SIZE) + ((MemInfo->Address + MemInfo->Length) - Address); + + /* + * If mapping the entire remaining portion of the region will cross + * a page boundary, just map up to the page boundary, do not cross. + * On some systems, crossing a page boundary while mapping regions + * can cause warnings if the pages have different attributes + * due to resource management. + * + * This has the added benefit of constraining a single mapping to + * one page, which is similar to the original code that used a 4k + * maximum window. + */ + PageBoundaryMapLength = + ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address; + if (PageBoundaryMapLength == 0) + { + PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE; + } + + if (MapLength > PageBoundaryMapLength) + { + MapLength = PageBoundaryMapLength; + } + + /* Create a new mapping starting at the address given */ + + MemInfo->MappedLogicalAddress = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) Address, MapLength); + if (!MemInfo->MappedLogicalAddress) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X%8.8X, size %X", + ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength)); + MemInfo->MappedLength = 0; + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the physical address and mapping size */ + + MemInfo->MappedPhysicalAddress = Address; + MemInfo->MappedLength = MapLength; + } + + /* + * Generate a logical pointer corresponding to the address we want to + * access + */ + LogicalAddrPtr = MemInfo->MappedLogicalAddress + + ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", + BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address))); + + /* + * Perform the memory read or write + * + * Note: For machines that do not support non-aligned transfers, the target + * address was checked for alignment above. We do not attempt to break the + * transfer up into smaller (byte-size) chunks because the AML specifically + * asked for a transfer width that the hardware may require. + */ + switch (Function) + { + case ACPI_READ: + + *Value = 0; + switch (BitWidth) + { + case 8: + *Value = (ACPI_INTEGER) ACPI_GET8 (LogicalAddrPtr); + break; + + case 16: + *Value = (ACPI_INTEGER) ACPI_GET16 (LogicalAddrPtr); + break; + + case 32: + *Value = (ACPI_INTEGER) ACPI_GET32 (LogicalAddrPtr); + break; + + case 64: + *Value = (ACPI_INTEGER) ACPI_GET64 (LogicalAddrPtr); + break; + + default: + /* BitWidth was already validated */ + break; + } + break; + + case ACPI_WRITE: + + switch (BitWidth) + { + case 8: + ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value; + break; + + case 16: + ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value; + break; + + case 32: + ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value; + break; + + case 64: + ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value; + break; + + default: + /* BitWidth was already validated */ + break; + } + break; + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemIoSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the System IO address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemIoSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value32; + + + ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n", + BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address))); + + /* Decode the function parameter */ + + switch (Function) + { + case ACPI_READ: + + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address, + &Value32, BitWidth); + *Value = Value32; + break; + + case ACPI_WRITE: + + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address, + (UINT32) *Value, BitWidth); + break; + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPciConfigSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the PCI Config address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPciConfigSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PCI_ID *PciId; + UINT16 PciRegister; + + + ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler); + + + /* + * The arguments to AcpiOs(Read|Write)PciConfiguration are: + * + * PciSegment is the PCI bus segment range 0-31 + * PciBus is the PCI bus number range 0-255 + * PciDevice is the PCI device number range 0-31 + * PciFunction is the PCI device function number + * PciRegister is the Config space register range 0-255 bytes + * + * Value - input value for write, output address for read + * + */ + PciId = (ACPI_PCI_ID *) RegionContext; + PciRegister = (UINT16) (UINT32) Address; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Pci-Config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", + Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device, + PciId->Function, PciRegister)); + + switch (Function) + { + case ACPI_READ: + + *Value = 0; + Status = AcpiOsReadPciConfiguration (PciId, PciRegister, + Value, BitWidth); + break; + + case ACPI_WRITE: + + Status = AcpiOsWritePciConfiguration (PciId, PciRegister, + *Value, BitWidth); + break; + + default: + + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCmosSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the CMOS address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCmosSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExCmosSpaceHandler); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPciBarSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPciBarSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDataTableSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the Data Table address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDataTableSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler); + + + /* Perform the memory read or write */ + + switch (Function) + { + case ACPI_READ: + + ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), + ACPI_DIV_8 (BitWidth)); + break; + + case ACPI_WRITE: + default: + + return_ACPI_STATUS (AE_SUPPORT); + } + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exresnte.c b/reactos/drivers/bus/acpi/acpica/executer/exresnte.c new file mode 100644 index 00000000000..5481bc899a8 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exresnte.c @@ -0,0 +1,374 @@ + +/****************************************************************************** + * + * Module Name: exresnte - AML Interpreter object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXRESNTE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresnte") + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveNodeToValue + * + * PARAMETERS: ObjectPtr - Pointer to a location that contains + * a pointer to a NS node, and will receive a + * pointer to the resolved object. + * WalkState - Current state. Valid only if executing AML + * code. NULL if simply resolving an object + * + * RETURN: Status + * + * DESCRIPTION: Resolve a Namespace node to a valued object + * + * Note: for some of the data types, the pointer attached to the Node + * can be either a pointer to an actual internal object or a pointer into the + * AML stream itself. These types are currently: + * + * ACPI_TYPE_INTEGER + * ACPI_TYPE_STRING + * ACPI_TYPE_BUFFER + * ACPI_TYPE_MUTEX + * ACPI_TYPE_PACKAGE + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveNodeToValue ( + ACPI_NAMESPACE_NODE **ObjectPtr, + ACPI_WALK_STATE *WalkState) + +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *SourceDesc; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_OBJECT_TYPE EntryType; + + + ACPI_FUNCTION_TRACE (ExResolveNodeToValue); + + + /* + * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the + * object that is attached to the Node. + */ + Node = *ObjectPtr; + SourceDesc = AcpiNsGetAttachedObject (Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", + Node, SourceDesc, AcpiUtGetTypeName (EntryType))); + + if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) || + (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS)) + { + /* There is always exactly one level of indirection */ + + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + SourceDesc = AcpiNsGetAttachedObject (Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + *ObjectPtr = Node; + } + + /* + * Several object types require no further processing: + * 1) Device/Thermal objects don't have a "real" subobject, return the Node + * 2) Method locals and arguments have a pseudo-Node + * 3) 10/2007: Added method type to assist with Package construction. + */ + if ((EntryType == ACPI_TYPE_DEVICE) || + (EntryType == ACPI_TYPE_THERMAL) || + (EntryType == ACPI_TYPE_METHOD) || + (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) + { + return_ACPI_STATUS (AE_OK); + } + + if (!SourceDesc) + { + ACPI_ERROR ((AE_INFO, "No object attached to node %p", + Node)); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * Action is based on the type of the Node, which indicates the type + * of the attached object or pointer + */ + switch (EntryType) + { + case ACPI_TYPE_PACKAGE: + + if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, "Object not a Package, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + Status = AcpiDsGetPackageArguments (SourceDesc); + if (ACPI_SUCCESS (Status)) + { + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + } + break; + + + case ACPI_TYPE_BUFFER: + + if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + Status = AcpiDsGetBufferArguments (SourceDesc); + if (ACPI_SUCCESS (Status)) + { + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + } + break; + + + case ACPI_TYPE_STRING: + + if (SourceDesc->Common.Type != ACPI_TYPE_STRING) + { + ACPI_ERROR ((AE_INFO, "Object not a String, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + + case ACPI_TYPE_INTEGER: + + if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "FieldRead Node=%p SourceDesc=%p Type=%X\n", + Node, SourceDesc, EntryType)); + + Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc); + break; + + /* For these objects, just return the object attached to the Node */ + + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_REGION: + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + /* TYPE_ANY is untyped, and thus there is no object associated with it */ + + case ACPI_TYPE_ANY: + + ACPI_ERROR ((AE_INFO, + "Untyped entry %p, no attached object!", Node)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (SourceDesc->Reference.Class) + { + case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */ + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_INDEX: + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + default: + /* No named references are allowed here */ + + ACPI_ERROR ((AE_INFO, + "Unsupported Reference type %X", + SourceDesc->Reference.Class)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + + + default: + + /* Default case is for unknown types */ + + ACPI_ERROR ((AE_INFO, + "Node %p - Unknown object type %X", + Node, EntryType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + + } /* switch (EntryType) */ + + + /* Return the object descriptor */ + + *ObjectPtr = (void *) ObjDesc; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exresolv.c b/reactos/drivers/bus/acpi/acpica/executer/exresolv.c new file mode 100644 index 00000000000..a3c8ab9b5ce --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exresolv.c @@ -0,0 +1,652 @@ + +/****************************************************************************** + * + * Module Name: exresolv - AML Interpreter object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXRESOLV_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresolv") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveToValue + * + * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can + * be either an (ACPI_OPERAND_OBJECT *) + * or an ACPI_HANDLE. + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Convert Reference objects to values + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); + + + if (!StackPtr || !*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Internal - null pointer")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * The entity pointed to by the StackPtr can be either + * 1) A valid ACPI_OPERAND_OBJECT, or + * 2) A ACPI_NAMESPACE_NODE (NamedObj) + */ + if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) + { + Status = AcpiExResolveObjectToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Internal - null pointer")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + } + + /* + * Object on the stack may have changed if AcpiExResolveObjectToValue() + * was called (i.e., we can't use an _else_ here.) + */ + if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) + { + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveObjectToValue + * + * PARAMETERS: StackPtr - Pointer to an internal object + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value from an internal object. The Reference type + * uses the associated AML opcode to determine the value. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *StackDesc; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + UINT8 RefType; + + + ACPI_FUNCTION_TRACE (ExResolveObjectToValue); + + + StackDesc = *StackPtr; + + /* This is an ACPI_OPERAND_OBJECT */ + + switch (StackDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + RefType = StackDesc->Reference.Class; + + switch (RefType) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* + * Get the local from the method's state info + * Note: this increments the local's object reference count + */ + Status = AcpiDsMethodDataGetValue (RefType, + StackDesc->Reference.Value, WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", + StackDesc->Reference.Value, ObjDesc)); + + /* + * Now we can delete the original Reference Object and + * replace it with the resolved value + */ + AcpiUtRemoveReference (StackDesc); + *StackPtr = ObjDesc; + break; + + + case ACPI_REFCLASS_INDEX: + + switch (StackDesc->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + /* Just return - do not dereference */ + break; + + + case ACPI_TYPE_PACKAGE: + + /* If method call or CopyObject - do not dereference */ + + if ((WalkState->Opcode == AML_INT_METHODCALL_OP) || + (WalkState->Opcode == AML_COPY_OP)) + { + break; + } + + /* Otherwise, dereference the PackageIndex to a package element */ + + ObjDesc = *StackDesc->Reference.Where; + if (ObjDesc) + { + /* + * Valid object descriptor, copy pointer to return value + * (i.e., dereference the package index) + * Delete the ref object, increment the returned object + */ + AcpiUtRemoveReference (StackDesc); + AcpiUtAddReference (ObjDesc); + *StackPtr = ObjDesc; + } + else + { + /* + * A NULL object descriptor means an uninitialized element of + * the package, can't dereference it + */ + ACPI_ERROR ((AE_INFO, + "Attempt to dereference an Index to NULL package element Idx=%p", + StackDesc)); + Status = AE_AML_UNINITIALIZED_ELEMENT; + } + break; + + + default: + + /* Invalid reference object */ + + ACPI_ERROR ((AE_INFO, + "Unknown TargetType %X in Index/Reference object %p", + StackDesc->Reference.TargetType, StackDesc)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_DEBUG: + case ACPI_REFCLASS_TABLE: + + /* Just leave the object as-is, do not dereference */ + + break; + + case ACPI_REFCLASS_NAME: /* Reference to a named object */ + + /* Dereference the name */ + + if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || + (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) + { + /* These node types do not have 'real' subobjects */ + + *StackPtr = (void *) StackDesc->Reference.Node; + } + else + { + /* Get the object pointed to by the namespace node */ + + *StackPtr = (StackDesc->Reference.Node)->Object; + AcpiUtAddReference (*StackPtr); + } + + AcpiUtRemoveReference (StackDesc); + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference type %X in %p", RefType, StackDesc)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ACPI_TYPE_BUFFER: + + Status = AcpiDsGetBufferArguments (StackDesc); + break; + + + case ACPI_TYPE_PACKAGE: + + Status = AcpiDsGetPackageArguments (StackDesc); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", + StackDesc, StackDesc->Common.Type)); + + Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); + + /* Remove a reference to the original operand, then override */ + + AcpiUtRemoveReference (*StackPtr); + *StackPtr = (void *) ObjDesc; + break; + + default: + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveMultiple + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * Operand - Starting point for resolution + * ReturnType - Where the object type is returned + * ReturnDesc - Where the resolved object is returned + * + * RETURN: Status + * + * DESCRIPTION: Return the base object and type. Traverse a reference list if + * necessary to get to the base object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveMultiple ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *Operand, + ACPI_OBJECT_TYPE *ReturnType, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; + ACPI_NAMESPACE_NODE *Node; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); + + + /* Operand can be either a namespace node or an operand descriptor */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_OPERAND: + Type = ObjDesc->Common.Type; + break; + + case ACPI_DESC_TYPE_NAMED: + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + + /* If we had an Alias node, use the attached object for type info */ + + if (Type == ACPI_TYPE_LOCAL_ALIAS) + { + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + } + break; + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* If type is anything other than a reference, we are done */ + + if (Type != ACPI_TYPE_LOCAL_REFERENCE) + { + goto Exit; + } + + /* + * For reference objects created via the RefOf, Index, or Load/LoadTable + * operators, we need to get to the base object (as per the ACPI + * specification of the ObjectType and SizeOf operators). This means + * traversing the list of possibly many nested references. + */ + while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_NAME: + + /* Dereference the reference pointer */ + + if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) + { + Node = ObjDesc->Reference.Object; + } + else /* AML_INT_NAMEPATH_OP */ + { + Node = ObjDesc->Reference.Node; + } + + /* All "References" point to a NS node */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "Not a NS node %p [%s]", + Node, AcpiUtGetDescriptorName (Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Get the attached object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, use the NS node type */ + + Type = AcpiNsGetType (Node); + goto Exit; + } + + /* Check for circular references */ + + if (ObjDesc == Operand) + { + return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); + } + break; + + + case ACPI_REFCLASS_INDEX: + + /* Get the type of this reference (index into another object) */ + + Type = ObjDesc->Reference.TargetType; + if (Type != ACPI_TYPE_PACKAGE) + { + goto Exit; + } + + /* + * The main object is a package, we want to get the type + * of the individual package element that is referenced by + * the index. + * + * This could of course in turn be another reference object. + */ + ObjDesc = *(ObjDesc->Reference.Where); + if (!ObjDesc) + { + /* NULL package elements are allowed */ + + Type = 0; /* Uninitialized */ + goto Exit; + } + break; + + + case ACPI_REFCLASS_TABLE: + + Type = ACPI_TYPE_DDB_HANDLE; + goto Exit; + + + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + if (ReturnDesc) + { + Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, + ObjDesc->Reference.Value, WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiUtRemoveReference (ObjDesc); + } + else + { + Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, + ObjDesc->Reference.Value, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Type = ACPI_TYPE_ANY; + goto Exit; + } + } + break; + + + case ACPI_REFCLASS_DEBUG: + + /* The Debug Object is of type "DebugObject" */ + + Type = ACPI_TYPE_DEBUG_OBJECT; + goto Exit; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference Class %2.2X", ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + } + + /* + * Now we are guaranteed to have an object that has not been created + * via the RefOf or Index operators. + */ + Type = ObjDesc->Common.Type; + + +Exit: + /* Convert internal types to external types */ + + switch (Type) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + Type = ACPI_TYPE_FIELD_UNIT; + break; + + case ACPI_TYPE_LOCAL_SCOPE: + + /* Per ACPI Specification, Scope is untyped */ + + Type = ACPI_TYPE_ANY; + break; + + default: + /* No change to Type required */ + break; + } + + *ReturnType = Type; + if (ReturnDesc) + { + *ReturnDesc = ObjDesc; + } + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exresop.c b/reactos/drivers/bus/acpi/acpica/executer/exresop.c new file mode 100644 index 00000000000..ecc63f61357 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exresop.c @@ -0,0 +1,810 @@ + +/****************************************************************************** + * + * Module Name: exresop - AML Interpreter operand/object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXRESOP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresop") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExCheckObjectType ( + ACPI_OBJECT_TYPE TypeNeeded, + ACPI_OBJECT_TYPE ThisType, + void *Object); + + +/******************************************************************************* + * + * FUNCTION: AcpiExCheckObjectType + * + * PARAMETERS: TypeNeeded Object type needed + * ThisType Actual object type + * Object Object pointer + * + * RETURN: Status + * + * DESCRIPTION: Check required type against actual type + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExCheckObjectType ( + ACPI_OBJECT_TYPE TypeNeeded, + ACPI_OBJECT_TYPE ThisType, + void *Object) +{ + ACPI_FUNCTION_ENTRY (); + + + if (TypeNeeded == ACPI_TYPE_ANY) + { + /* All types OK, so we don't perform any typechecks */ + + return (AE_OK); + } + + if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE) + { + /* + * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference + * objects and thus allow them to be targets. (As per the ACPI + * specification, a store to a constant is a noop.) + */ + if ((ThisType == ACPI_TYPE_INTEGER) && + (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT)) + { + return (AE_OK); + } + } + + if (TypeNeeded != ThisType) + { + ACPI_ERROR ((AE_INFO, + "Needed type [%s], found [%s] %p", + AcpiUtGetTypeName (TypeNeeded), + AcpiUtGetTypeName (ThisType), Object)); + + return (AE_AML_OPERAND_TYPE); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveOperands + * + * PARAMETERS: Opcode - Opcode being interpreted + * StackPtr - Pointer to the operand stack to be + * resolved + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Convert multiple input operands to the types required by the + * target operator. + * + * Each 5-bit group in ArgTypes represents one required + * operand and indicates the required Type. The corresponding operand + * will be converted to the required type if possible, otherwise we + * abort with an exception. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + UINT8 ObjectType; + UINT32 ArgTypes; + const ACPI_OPCODE_INFO *OpInfo; + UINT32 ThisArgType; + ACPI_OBJECT_TYPE TypeNeeded; + UINT16 TargetOp = 0; + + + ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode); + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + ArgTypes = OpInfo->RuntimeArgs; + if (ArgTypes == ARGI_INVALID_OPCODE) + { + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + Opcode)); + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", + Opcode, OpInfo->Name, ArgTypes)); + + /* + * Normal exit is with (ArgTypes == 0) at end of argument list. + * Function will return an exception from within the loop upon + * finding an entry which is not (or cannot be converted + * to) the required type; if stack underflows; or upon + * finding a NULL stack entry (which should not happen). + */ + while (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + if (!StackPtr || !*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Null stack entry at %p", + StackPtr)); + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Extract useful items */ + + ObjDesc = *StackPtr; + + /* Decode the descriptor type */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_NAMED: + + /* Namespace Node */ + + ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + + /* + * Resolve an alias object. The construction of these objects + * guarantees that there is only one level of alias indirection; + * thus, the attached object is always the aliased namespace node + */ + if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) + { + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + *StackPtr = ObjDesc; + ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + } + break; + + + case ACPI_DESC_TYPE_OPERAND: + + /* ACPI internal object */ + + ObjectType = ObjDesc->Common.Type; + + /* Check for bad ACPI_OBJECT_TYPE */ + + if (!AcpiUtValidObjectType (ObjectType)) + { + ACPI_ERROR ((AE_INFO, + "Bad operand object type [%X]", ObjectType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) + { + /* Validate the Reference */ + + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_DEBUG: + + TargetOp = AML_DEBUG_OP; + + /*lint -fallthrough */ + + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_INDEX: + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ + case ACPI_REFCLASS_NAME: /* Reference to a named object */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Operand is a Reference, Class [%s] %2.2X\n", + AcpiUtGetReferenceName (ObjDesc), + ObjDesc->Reference.Class)); + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference Class %2.2X in %p", + ObjDesc->Reference.Class, ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + } + break; + + + default: + + /* Invalid descriptor */ + + ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Get one argument type, point to the next */ + + ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); + INCREMENT_ARG_LIST (ArgTypes); + + /* + * Handle cases where the object does not need to be + * resolved to a value + */ + switch (ThisArgType) + { + case ARGI_REF_OR_STRING: /* Can be a String or Reference */ + + if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) && + (ObjDesc->Common.Type == ACPI_TYPE_STRING)) + { + /* + * String found - the string references a named object and + * must be resolved to a node + */ + goto NextOperand; + } + + /* + * Else not a string - fall through to the normal Reference + * case below + */ + /*lint -fallthrough */ + + case ARGI_REFERENCE: /* References: */ + case ARGI_INTEGER_REF: + case ARGI_OBJECT_REF: + case ARGI_DEVICE_REF: + case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ + case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ + case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ + + /* + * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE + * A Namespace Node is OK as-is + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + goto NextOperand; + } + + Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE, + ObjectType, ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + goto NextOperand; + + + case ARGI_DATAREFOBJ: /* Store operator only */ + + /* + * We don't want to resolve IndexOp reference objects during + * a store because this would be an implicit DeRefOf operation. + * Instead, we just want to store the reference object. + * -- All others must be resolved below. + */ + if ((Opcode == AML_STORE_OP) && + ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX)) + { + goto NextOperand; + } + break; + + default: + /* All cases covered above */ + break; + } + + /* + * Resolve this object to a value + */ + Status = AcpiExResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the resolved object */ + + ObjDesc = *StackPtr; + + /* + * Check the resulting object (value) type + */ + switch (ThisArgType) + { + /* + * For the simple cases, only one type of resolved object + * is allowed + */ + case ARGI_MUTEX: + + /* Need an operand of type ACPI_TYPE_MUTEX */ + + TypeNeeded = ACPI_TYPE_MUTEX; + break; + + case ARGI_EVENT: + + /* Need an operand of type ACPI_TYPE_EVENT */ + + TypeNeeded = ACPI_TYPE_EVENT; + break; + + case ARGI_PACKAGE: /* Package */ + + /* Need an operand of type ACPI_TYPE_PACKAGE */ + + TypeNeeded = ACPI_TYPE_PACKAGE; + break; + + case ARGI_ANYTYPE: + + /* Any operand type will do */ + + TypeNeeded = ACPI_TYPE_ANY; + break; + + case ARGI_DDBHANDLE: + + /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ + + TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE; + break; + + + /* + * The more complex cases allow multiple resolved object types + */ + case ARGI_INTEGER: + + /* + * Need an operand of type ACPI_TYPE_INTEGER, + * But we can implicitly convert from a STRING or BUFFER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_BUFFER: + + /* + * Need an operand of type ACPI_TYPE_BUFFER, + * But we can implicitly convert from a STRING or INTEGER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_STRING: + + /* + * Need an operand of type ACPI_TYPE_STRING, + * But we can implicitly convert from a BUFFER or INTEGER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToString (ObjDesc, StackPtr, + ACPI_IMPLICIT_CONVERT_HEX); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_COMPUTEDATA: + + /* Need an operand of type INTEGER, STRING or BUFFER */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_BUFFER_OR_STRING: + + /* Need an operand of type STRING or BUFFER */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + case ACPI_TYPE_INTEGER: + + /* Highest priority conversion is to type Buffer */ + + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_DATAOBJECT: + /* + * ARGI_DATAOBJECT is only used by the SizeOf operator. + * Need a buffer, string, package, or RefOf reference. + * + * The only reference allowed here is a direct reference to + * a namespace node. + */ + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_LOCAL_REFERENCE: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Buffer/String/Package/Reference], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_COMPLEXOBJ: + + /* Need a buffer or package or (ACPI 2.0) String */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Buffer/String/Package], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ + + /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_REGION: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Region/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_DATAREFOBJ: + + /* Used by the Store() operator only */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REFERENCE: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + case ACPI_TYPE_DDB_HANDLE: + + /* Valid operand */ + break; + + default: + + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Enable original behavior of Store(), allowing any and all + * objects as the source operand. The ACPI spec does not + * allow this, however. + */ + break; + } + + if (TargetOp == AML_DEBUG_OP) + { + /* Allow store of any object to the Debug object */ + + break; + } + + ACPI_ERROR ((AE_INFO, + "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + default: + + /* Unknown type */ + + ACPI_ERROR ((AE_INFO, + "Internal - Unknown ARGI (required operand) type %X", + ThisArgType)); + + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Make sure that the original object was resolved to the + * required object type (Simple cases only). + */ + Status = AcpiExCheckObjectType (TypeNeeded, + (*StackPtr)->Common.Type, *StackPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + +NextOperand: + /* + * If more operands needed, decrement StackPtr to point + * to next operand on stack + */ + if (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + StackPtr--; + } + } + + ACPI_DUMP_OPERANDS (WalkState->Operands, + AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exstore.c b/reactos/drivers/bus/acpi/acpica/executer/exstore.c new file mode 100644 index 00000000000..8ec8a23cffd --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exstore.c @@ -0,0 +1,822 @@ + +/****************************************************************************** + * + * Module Name: exstore - AML Interpreter object store support + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXSTORE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstore") + +/* Local prototypes */ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index); + +static ACPI_STATUS +AcpiExStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoDebugObject + * + * PARAMETERS: SourceDesc - Value to be stored + * Level - Indentation level (used for packages) + * Index - Current package element, zero if not pkg + * + * RETURN: None + * + * DESCRIPTION: Handles stores to the Debug Object. + * + ******************************************************************************/ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); + + + /* Print line header as long as we are not in the middle of an object display */ + + if (!((Level > 0) && Index == 0)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", + Level, " ")); + } + + /* Display index for package output only */ + + if (Index > 0) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "(%.2u) ", Index -1)); + } + + if (!SourceDesc) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Null Object]\n")); + return_VOID; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s ", + AcpiUtGetObjectTypeName (SourceDesc))); + + if (!AcpiUtValidInternalObject (SourceDesc)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "%p, Invalid Internal Object!\n", SourceDesc)); + return_VOID; + } + } + else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", + AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), + SourceDesc)); + return_VOID; + } + else + { + return_VOID; + } + + /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */ + + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Output correct integer width */ + + if (AcpiGbl_IntegerByteWidth == 4) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", + (UINT32) SourceDesc->Integer.Value)); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); + } + break; + + case ACPI_TYPE_BUFFER: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", + (UINT32) SourceDesc->Buffer.Length)); + ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, + (SourceDesc->Buffer.Length < 256) ? SourceDesc->Buffer.Length : 256); + break; + + case ACPI_TYPE_STRING: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", + SourceDesc->String.Length, SourceDesc->String.Pointer)); + break; + + case ACPI_TYPE_PACKAGE: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Contains 0x%.2X Elements]\n", + SourceDesc->Package.Count)); + + /* Output the entire contents of the package */ + + for (i = 0; i < SourceDesc->Package.Count; i++) + { + AcpiExDoDebugObject (SourceDesc->Package.Elements[i], + Level+4, i+1); + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s] ", + AcpiUtGetReferenceName (SourceDesc))); + + /* Decode the reference */ + + switch (SourceDesc->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X\n", + SourceDesc->Reference.Value)); + break; + + case ACPI_REFCLASS_TABLE: + + /* Case for DdbHandle */ + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Table Index 0x%X\n", + SourceDesc->Reference.Value)); + return; + + default: + break; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, " ")); + + /* Check for valid node first, then valid object */ + + if (SourceDesc->Reference.Node) + { + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != + ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + " %p - Not a valid namespace node\n", + SourceDesc->Reference.Node)); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Node %p [%4.4s] ", + SourceDesc->Reference.Node, (SourceDesc->Reference.Node)->Name.Ascii)); + + switch ((SourceDesc->Reference.Node)->Type) + { + /* These types have no attached object */ + + case ACPI_TYPE_DEVICE: + AcpiOsPrintf ("Device\n"); + break; + + case ACPI_TYPE_THERMAL: + AcpiOsPrintf ("Thermal Zone\n"); + break; + + default: + AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, + Level+4, 0); + break; + } + } + } + else if (SourceDesc->Reference.Object) + { + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == + ACPI_DESC_TYPE_NAMED) + { + AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) + SourceDesc->Reference.Object)->Object, + Level+4, 0); + } + else + { + AcpiExDoDebugObject (SourceDesc->Reference.Object, Level+4, 0); + } + } + break; + + default: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n", + SourceDesc)); + break; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStore + * + * PARAMETERS: *SourceDesc - Value to be stored + * *DestDesc - Where to store it. Must be an NS node + * or an ACPI_OPERAND_OBJECT of type + * Reference; + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store the value described by SourceDesc into the location + * described by DestDesc. Called by various interpreter + * functions to store the result of an operation into + * the destination operand -- not just simply the actual "Store" + * ASL operator. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStore ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *RefDesc = DestDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); + + + /* Validate parameters */ + + if (!SourceDesc || !DestDesc) + { + ACPI_ERROR ((AE_INFO, "Null parameter")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* DestDesc can be either a namespace node or an ACPI object */ + + if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) + { + /* + * Dest is a namespace node, + * Storing an object into a Named node. + */ + Status = AcpiExStoreObjectToNode (SourceDesc, + (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, + ACPI_IMPLICIT_CONVERSION); + + return_ACPI_STATUS (Status); + } + + /* Destination object must be a Reference or a Constant object */ + + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + break; + + case ACPI_TYPE_INTEGER: + + /* Allow stores to Constants -- a Noop as per ACPI spec */ + + if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) + { + return_ACPI_STATUS (AE_OK); + } + + /*lint -fallthrough */ + + default: + + /* Destination is not a Reference object */ + + ACPI_ERROR ((AE_INFO, + "Target is not a Reference or Constant object - %s [%p]", + AcpiUtGetObjectTypeName (DestDesc), DestDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Examine the Reference class. These cases are handled: + * + * 1) Store to Name (Change the object associated with a name) + * 2) Store to an indexed area of a Buffer or Package + * 3) Store to a Method Local or Arg + * 4) Store to the debug object + */ + switch (RefDesc->Reference.Class) + { + case ACPI_REFCLASS_REFOF: + + /* Storing an object into a Name "container" */ + + Status = AcpiExStoreObjectToNode (SourceDesc, + RefDesc->Reference.Object, + WalkState, ACPI_IMPLICIT_CONVERSION); + break; + + + case ACPI_REFCLASS_INDEX: + + /* Storing to an Index (pointer into a packager or buffer) */ + + Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); + break; + + + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* Store to a method local/arg */ + + Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, + RefDesc->Reference.Value, SourceDesc, WalkState); + break; + + + case ACPI_REFCLASS_DEBUG: + + /* + * Storing to the Debug object causes the value stored to be + * displayed and otherwise has no effect -- see ACPI Specification + */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** Write to Debug Object: Object %p %s ****:\n\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); + + AcpiExDoDebugObject (SourceDesc, 0, 0); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + RefDesc->Reference.Class)); + ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); + + Status = AE_AML_INTERNAL; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToIndex + * + * PARAMETERS: *SourceDesc - Value to be stored + * *DestDesc - Named object to receive the value + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store the object to indexed Buffer or Package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *IndexDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NewDesc; + UINT8 Value = 0; + UINT32 i; + + + ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); + + + /* + * Destination must be a reference pointer, and + * must point to either a buffer or a package + */ + switch (IndexDesc->Reference.TargetType) + { + case ACPI_TYPE_PACKAGE: + /* + * Storing to a package element. Copy the object and replace + * any existing object with the new object. No implicit + * conversion is performed. + * + * The object at *(IndexDesc->Reference.Where) is the + * element within the package that is to be modified. + * The parent package object is at IndexDesc->Reference.Object + */ + ObjDesc = *(IndexDesc->Reference.Where); + + if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE && + SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + /* This is a DDBHandle, just add a reference to it */ + + AcpiUtAddReference (SourceDesc); + NewDesc = SourceDesc; + } + else + { + /* Normal object, copy it */ + + Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (ObjDesc) + { + /* Decrement reference count by the ref count of the parent package */ + + for (i = 0; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) + { + AcpiUtRemoveReference (ObjDesc); + } + } + + *(IndexDesc->Reference.Where) = NewDesc; + + /* Increment ref count by the ref count of the parent package-1 */ + + for (i = 1; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) + { + AcpiUtAddReference (NewDesc); + } + + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + /* + * Store into a Buffer or String (not actually a real BufferField) + * at a location defined by an Index. + * + * The first 8-bit element of the source object is written to the + * 8-bit Buffer location defined by the Index destination object, + * according to the ACPI 2.0 specification. + */ + + /* + * Make sure the target is a Buffer or String. An error should + * not happen here, since the ReferenceObject was constructed + * by the INDEX_OP code. + */ + ObjDesc = IndexDesc->Reference.Object; + if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ObjDesc->Common.Type != ACPI_TYPE_STRING)) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * The assignment of the individual elements will be slightly + * different for each source type. + */ + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Use the least-significant byte of the integer */ + + Value = (UINT8) (SourceDesc->Integer.Value); + break; + + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + + /* Note: Takes advantage of common string/buffer fields */ + + Value = SourceDesc->Buffer.Pointer[0]; + break; + + default: + + /* All other types are invalid */ + + ACPI_ERROR ((AE_INFO, + "Source must be Integer/Buffer/String type, not %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Store the source value into the target buffer byte */ + + ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value; + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Target is not a Package or BufferField")); + Status = AE_AML_OPERAND_TYPE; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToNode + * + * PARAMETERS: SourceDesc - Value to be stored + * Node - Named object to receive the value + * WalkState - Current walk state + * ImplicitConversion - Perform implicit conversion (yes/no) + * + * RETURN: Status + * + * DESCRIPTION: Store the object to the named object. + * + * The Assignment of an object to a named object is handled here + * The value passed in will replace the current value (if any) + * with the input value. + * + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. + * + * Assumes parameters are already validated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreObjectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState, + UINT8 ImplicitConversion) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *TargetDesc; + ACPI_OPERAND_OBJECT *NewDesc; + ACPI_OBJECT_TYPE TargetType; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); + + + /* Get current type of the node, and object attached to Node */ + + TargetType = AcpiNsGetType (Node); + TargetDesc = AcpiNsGetAttachedObject (Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), + Node, AcpiUtGetTypeName (TargetType))); + + /* + * Resolve the source object to an actual value + * (If it is a reference object) + */ + Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* If no implicit conversion, drop into the default case below */ + + if ((!ImplicitConversion) || + ((WalkState->Opcode == AML_COPY_OP) && + (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) && + (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) && + (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD))) + { + /* + * Force execution of default (no implicit conversion). Note: + * CopyObject does not perform an implicit conversion, as per the ACPI + * spec -- except in case of region/bank/index fields -- because these + * objects must retain their original type permanently. + */ + TargetType = ACPI_TYPE_ANY; + } + + /* Do the actual store operation */ + + switch (TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + /* For fields, copy the source data to the target field. */ + + Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, + &WalkState->ResultObj); + break; + + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These target types are all of type Integer/String/Buffer, and + * therefore support implicit conversion before the store. + * + * Copy and/or convert the source object to a new target object + */ + Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, + &NewDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (NewDesc != TargetDesc) + { + /* + * Store the new NewDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * SourceDesc reference count is incremented by AttachObject. + * + * Note: This may change the type of the node if an explicit store + * has been performed such that the node/object type has been + * changed. + */ + Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Store %s into %s via Convert/Attach\n", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetObjectTypeName (NewDesc))); + } + break; + + + default: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Storing %s (%p) directly into node (%p) with no implicit conversion\n", + AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); + + /* No conversions for all other types. Just attach the source object */ + + Status = AcpiNsAttachObject (Node, SourceDesc, + SourceDesc->Common.Type); + break; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exstoren.c b/reactos/drivers/bus/acpi/acpica/executer/exstoren.c new file mode 100644 index 00000000000..0810560d39c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exstoren.c @@ -0,0 +1,386 @@ + +/****************************************************************************** + * + * Module Name: exstoren - AML Interpreter object store support, + * Store to Node (namespace object) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXSTOREN_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstoren") + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveObject + * + * PARAMETERS: SourceDescPtr - Pointer to the source object + * TargetType - Current type of the target + * WalkState - Current walk state + * + * RETURN: Status, resolved object in SourceDescPtr. + * + * DESCRIPTION: Resolve an object. If the object is a reference, dereference + * it and return the actual object in the SourceDescPtr. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveObject ( + ACPI_OPERAND_OBJECT **SourceDescPtr, + ACPI_OBJECT_TYPE TargetType, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExResolveObject); + + + /* Ensure we have a Target that can be stored to */ + + switch (TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* + * These cases all require only Integers or values that + * can be converted to Integers (Strings or Buffers) + */ + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * Stores into a Field/Region or into a Integer/Buffer/String + * are all essentially the same. This case handles the + * "interchangeable" types Integer, String, and Buffer. + */ + if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + /* Resolve a reference object first */ + + Status = AcpiExResolveToValue (SourceDescPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + } + + /* For CopyObject, no further validation necessary */ + + if (WalkState->Opcode == AML_COPY_OP) + { + break; + } + + /* Must have a Integer, Buffer, or String */ + + if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && + (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && + (SourceDesc->Common.Type != ACPI_TYPE_STRING) && + !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) + { + /* Conversion successful but still not a valid type */ + + ACPI_ERROR ((AE_INFO, + "Cannot assign type %s to %s (must be type Int/Str/Buf)", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetTypeName (TargetType))); + Status = AE_AML_OPERAND_TYPE; + } + break; + + + case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: + + /* + * All aliases should have been resolved earlier, during the + * operand resolution phase. + */ + ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object")); + Status = AE_AML_INTERNAL; + break; + + + case ACPI_TYPE_PACKAGE: + default: + + /* + * All other types than Alias and the various Fields come here, + * including the untyped case - ACPI_TYPE_ANY. + */ + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToObject + * + * PARAMETERS: SourceDesc - Object to store + * DestDesc - Object to receive a copy of the source + * NewDesc - New object if DestDesc is obsoleted + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: "Store" an object to another object. This may include + * converting the source type to the target type (implicit + * conversion), and a copy of the value of the source to + * the target. + * + * The Assignment of an object to another (not named) object + * is handled here. + * The Source passed in will replace the current value (if any) + * with the input value. + * + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. + * + * This module allows destination types of Number, String, + * Buffer, and Package. + * + * Assumes parameters are already validated. NOTE: SourceDesc + * resolution (from a reference object) must be performed by + * the caller if necessary. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreObjectToObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_OPERAND_OBJECT **NewDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ActualSrcDesc; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc); + + + ActualSrcDesc = SourceDesc; + if (!DestDesc) + { + /* + * There is no destination object (An uninitialized node or + * package element), so we can simply copy the source object + * creating a new destination object + */ + Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState); + return_ACPI_STATUS (Status); + } + + if (SourceDesc->Common.Type != DestDesc->Common.Type) + { + /* + * The source type does not match the type of the destination. + * Perform the "implicit conversion" of the source to the current type + * of the target as per the ACPI specification. + * + * If no conversion performed, ActualSrcDesc = SourceDesc. + * Otherwise, ActualSrcDesc is a temporary object to hold the + * converted object. + */ + Status = AcpiExConvertToTargetType (DestDesc->Common.Type, + SourceDesc, &ActualSrcDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SourceDesc == ActualSrcDesc) + { + /* + * No conversion was performed. Return the SourceDesc as the + * new object. + */ + *NewDesc = SourceDesc; + return_ACPI_STATUS (AE_OK); + } + } + + /* + * We now have two objects of identical types, and we can perform a + * copy of the *value* of the source object. + */ + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + DestDesc->Integer.Value = ActualSrcDesc->Integer.Value; + + /* Truncate value if we are executing from a 32-bit ACPI table */ + + AcpiExTruncateFor32bitTable (DestDesc); + break; + + case ACPI_TYPE_STRING: + + Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc); + break; + + case ACPI_TYPE_BUFFER: + + Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); + break; + + case ACPI_TYPE_PACKAGE: + + Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, + WalkState); + break; + + default: + /* + * All other types come here. + */ + ACPI_WARNING ((AE_INFO, "Store into type %s not implemented", + AcpiUtGetObjectTypeName (DestDesc))); + + Status = AE_NOT_IMPLEMENTED; + break; + } + + if (ActualSrcDesc != SourceDesc) + { + /* Delete the intermediate (temporary) source object */ + + AcpiUtRemoveReference (ActualSrcDesc); + } + + *NewDesc = DestDesc; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exstorob.c b/reactos/drivers/bus/acpi/acpica/executer/exstorob.c new file mode 100644 index 00000000000..b2f125d01fb --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exstorob.c @@ -0,0 +1,316 @@ + +/****************************************************************************** + * + * Module Name: exstorob - AML Interpreter object store support, store to object + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXSTOROB_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstorob") + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreBufferToBuffer + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Copy a buffer object to another buffer object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreBufferToBuffer ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + UINT32 Length; + UINT8 *Buffer; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc); + + + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* We know that SourceDesc is a buffer by now */ + + Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer); + Length = SourceDesc->Buffer.Length; + + /* + * If target is a buffer of length zero or is a static buffer, + * allocate a new buffer of the proper length + */ + if ((TargetDesc->Buffer.Length == 0) || + (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length); + if (!TargetDesc->Buffer.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + TargetDesc->Buffer.Length = Length; + } + + /* Copy source buffer to target buffer */ + + if (Length <= TargetDesc->Buffer.Length) + { + /* Clear existing buffer and copy in the new one */ + + ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); + ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length); + +#ifdef ACPI_OBSOLETE_BEHAVIOR + /* + * NOTE: ACPI versions up to 3.0 specified that the buffer must be + * truncated if the string is smaller than the buffer. However, "other" + * implementations of ACPI never did this and thus became the defacto + * standard. ACPI 3.0A changes this behavior such that the buffer + * is no longer truncated. + */ + + /* + * OBSOLETE BEHAVIOR: + * If the original source was a string, we must truncate the buffer, + * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer + * copy must not truncate the original buffer. + */ + if (OriginalSrcType == ACPI_TYPE_STRING) + { + /* Set the new length of the target */ + + TargetDesc->Buffer.Length = Length; + } +#endif + } + else + { + /* Truncate the source, copy only what will fit */ + + ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, + TargetDesc->Buffer.Length); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Truncating source buffer from %X to %X\n", + Length, TargetDesc->Buffer.Length)); + } + + /* Copy flags */ + + TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags; + TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreStringToString + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Copy a String object to another String object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreStringToString ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + UINT32 Length; + UINT8 *Buffer; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc); + + + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* We know that SourceDesc is a string by now */ + + Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer); + Length = SourceDesc->String.Length; + + /* + * Replace existing string value if it will fit and the string + * pointer is not a static pointer (part of an ACPI table) + */ + if ((Length < TargetDesc->String.Length) && + (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + { + /* + * String will fit in existing non-static buffer. + * Clear old string and copy in the new one + */ + ACPI_MEMSET (TargetDesc->String.Pointer, 0, + (ACPI_SIZE) TargetDesc->String.Length + 1); + ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + } + else + { + /* + * Free the current buffer, then allocate a new buffer + * large enough to hold the value + */ + if (TargetDesc->String.Pointer && + (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + { + /* Only free if not a pointer into the DSDT */ + + ACPI_FREE (TargetDesc->String.Pointer); + } + + TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED ( + (ACPI_SIZE) Length + 1); + if (!TargetDesc->String.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + } + + /* Set the new target length */ + + TargetDesc->String.Length = Length; + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exsystem.c b/reactos/drivers/bus/acpi/acpica/executer/exsystem.c new file mode 100644 index 00000000000..19674606a60 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exsystem.c @@ -0,0 +1,418 @@ + +/****************************************************************************** + * + * Module Name: exsystem - Interface to OS services + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXSYSTEM_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exsystem") + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitSemaphore + * + * PARAMETERS: Semaphore - Semaphore to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a semaphore wait with a check to see if the + * semaphore is available immediately. If it is not, the + * interpreter is released before waiting. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitSemaphore ( + ACPI_SEMAPHORE Semaphore, + UINT16 Timeout) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore); + + + Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiExRelinquishInterpreter (); + + Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", + AcpiFormatException (Status))); + + /* Reacquire the interpreter */ + + AcpiExReacquireInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitMutex + * + * PARAMETERS: Mutex - Mutex to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a mutex wait with a check to see if the + * mutex is available immediately. If it is not, the + * interpreter is released before waiting. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitMutex ( + ACPI_MUTEX Mutex, + UINT16 Timeout) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExSystemWaitMutex); + + + Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiExRelinquishInterpreter (); + + Status = AcpiOsAcquireMutex (Mutex, Timeout); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", + AcpiFormatException (Status))); + + /* Reacquire the interpreter */ + + AcpiExReacquireInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemDoStall + * + * PARAMETERS: HowLong - The amount of time to stall, + * in microseconds + * + * RETURN: Status + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * Note: ACPI specification requires that Stall() does not + * relinquish the processor, and delays longer than 100 usec + * should use Sleep() instead. We allow stalls up to 255 usec + * for compatibility with other interpreters and existing BIOSs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemDoStall ( + UINT32 HowLong) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_ENTRY (); + + + if (HowLong > 255) /* 255 microseconds */ + { + /* + * Longer than 255 usec, this is an error + * + * (ACPI specifies 100 usec as max, but this gives some slack in + * order to support existing BIOSs) + */ + ACPI_ERROR ((AE_INFO, "Time parameter is too large (%d)", + HowLong)); + Status = AE_AML_OPERAND_VALUE; + } + else + { + AcpiOsStall (HowLong); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemDoSuspend + * + * PARAMETERS: HowLong - The amount of time to suspend, + * in milliseconds + * + * RETURN: None + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemDoSuspend ( + ACPI_INTEGER HowLong) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Since this thread will sleep, we must release the interpreter */ + + AcpiExRelinquishInterpreter (); + + AcpiOsSleep (HowLong); + + /* And now we must get the interpreter again */ + + AcpiExReacquireInterpreter (); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemSignalEvent + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemSignalEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExSystemSignalEvent); + + + if (ObjDesc) + { + Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitEvent + * + * PARAMETERS: TimeDesc - The 'time to delay' object descriptor + * ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. This operation is a request to wait for an + * event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitEvent ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExSystemWaitEvent); + + + if (ObjDesc) + { + Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, + (UINT16) TimeDesc->Integer.Value); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemResetEvent + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Reset an event to a known state. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemResetEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + ACPI_SEMAPHORE TempSemaphore; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We are going to simply delete the existing semaphore and + * create a new one! + */ + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore); + if (ACPI_SUCCESS (Status)) + { + (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore); + ObjDesc->Event.OsSemaphore = TempSemaphore; + } + + return (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exutils.c b/reactos/drivers/bus/acpi/acpica/executer/exutils.c new file mode 100644 index 00000000000..1f5e861b68c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exutils.c @@ -0,0 +1,574 @@ + +/****************************************************************************** + * + * Module Name: exutils - interpreter/scanner utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXUTILS_C__ + +/* + * DEFINE_AML_GLOBALS is tested in amlcode.h + * to determine whether certain global names should be "defined" or only + * "declared" in the current compilation. This enhances maintainability + * by enabling a single header file to embody all knowledge of the names + * in question. + * + * Exactly one module of any executable should #define DEFINE_GLOBALS + * before #including the header files which use this convention. The + * names in question will be defined and initialized in that module, + * and declared as extern in all other modules which #include those + * header files. + */ + +#define DEFINE_AML_GLOBALS + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exutils") + +/* Local prototypes */ + +static UINT32 +AcpiExDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base); + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiExEnterInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Enter the interpreter execution region. Failure to enter + * the interpreter region is a fatal system error. Used in + * conjunction with ExitInterpreter. + * + ******************************************************************************/ + +void +AcpiExEnterInterpreter ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExEnterInterpreter); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReacquireInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Reacquire the interpreter execution region from within the + * interpreter code. Failure to enter the interpreter region is a + * fatal system error. Used in conjuction with + * RelinquishInterpreter + * + ******************************************************************************/ + +void +AcpiExReacquireInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExReacquireInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter, + * since it was not actually released by AcpiExRelinquishInterpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExEnterInterpreter (); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExExitInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region. This is the top level + * routine used to exit the interpreter when all processing has + * been completed. + * + ******************************************************************************/ + +void +AcpiExExitInterpreter ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExExitInterpreter); + + + Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRelinquishInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region, from within the + * interpreter - before attempting an operation that will possibly + * block the running thread. + * + * Cases where the interpreter is unlocked internally + * 1) Method to be blocked on a Sleep() AML opcode + * 2) Method to be blocked on an Acquire() AML opcode + * 3) Method to be blocked on a Wait() AML opcode + * 4) Method to be blocked to acquire the global lock + * 5) Method to be blocked waiting to execute a serialized control method + * that is currently executing + * 6) About to invoke a user-installed opregion handler + * + ******************************************************************************/ + +void +AcpiExRelinquishInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExRelinquishInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExExitInterpreter (); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExTruncateFor32bitTable + * + * PARAMETERS: ObjDesc - Object to be truncated + * + * RETURN: none + * + * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is + * 32-bit, as determined by the revision of the DSDT. + * + ******************************************************************************/ + +void +AcpiExTruncateFor32bitTable ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* + * Object must be a valid number and we must be executing + * a control method. NS node could be there for AML_INT_NAMEPATH_OP. + */ + if ((!ObjDesc) || + (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) || + (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) + { + return; + } + + if (AcpiGbl_IntegerByteWidth == 4) + { + /* + * We are running a method that exists in a 32-bit ACPI table. + * Truncate the value to 32 bits by zeroing out the upper 32-bit field + */ + ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireGlobalLock + * + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock + * + * RETURN: None + * + * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field + * flags specifiy that it is to be obtained before field access. + * + ******************************************************************************/ + +void +AcpiExAcquireGlobalLock ( + UINT32 FieldFlags) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExAcquireGlobalLock); + + + /* Only use the lock if the AlwaysLock bit is set */ + + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + + /* Attempt to get the global lock, wait forever */ + + Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not acquire Global Lock")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseGlobalLock + * + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock + * + * RETURN: None + * + * DESCRIPTION: Release the ACPI hardware Global Lock + * + ******************************************************************************/ + +void +AcpiExReleaseGlobalLock ( + UINT32 FieldFlags) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExReleaseGlobalLock); + + + /* Only use the lock if the AlwaysLock bit is set */ + + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + + /* Release the global lock */ + + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); + if (ACPI_FAILURE (Status)) + { + /* Report the error, but there isn't much else we can do */ + + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not release Global Lock")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDigitsNeeded + * + * PARAMETERS: Value - Value to be represented + * Base - Base of representation + * + * RETURN: The number of digits. + * + * DESCRIPTION: Calculate the number of digits needed to represent the Value + * in the given Base (Radix) + * + ******************************************************************************/ + +static UINT32 +AcpiExDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base) +{ + UINT32 NumDigits; + ACPI_INTEGER CurrentValue; + + + ACPI_FUNCTION_TRACE (ExDigitsNeeded); + + + /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ + + if (Value == 0) + { + return_UINT32 (1); + } + + CurrentValue = Value; + NumDigits = 0; + + /* Count the digits in the requested base */ + + while (CurrentValue) + { + (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL); + NumDigits++; + } + + return_UINT32 (NumDigits); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExEisaIdToString + * + * PARAMETERS: CompressedId - EISAID to be converted + * OutString - Where to put the converted string (8 bytes) + * + * RETURN: None + * + * DESCRIPTION: Convert a numeric EISAID to string representation. Return + * buffer must be large enough to hold the string. The string + * returned is always exactly of length ACPI_EISAID_STRING_SIZE + * (includes null terminator). The EISAID is always 32 bits. + * + ******************************************************************************/ + +void +AcpiExEisaIdToString ( + char *OutString, + ACPI_INTEGER CompressedId) +{ + UINT32 SwappedId; + + + ACPI_FUNCTION_ENTRY (); + + + /* The EISAID should be a 32-bit integer */ + + if (CompressedId > ACPI_UINT32_MAX) + { + ACPI_WARNING ((AE_INFO, + "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating", + ACPI_FORMAT_UINT64 (CompressedId))); + } + + /* Swap ID to big-endian to get contiguous bits */ + + SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId); + + /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */ + + OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F)); + OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F)); + OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F)); + OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 12); + OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 8); + OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 4); + OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 0); + OutString[7] = 0; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExIntegerToString + * + * PARAMETERS: OutString - Where to put the converted string. At least + * 21 bytes are needed to hold the largest + * possible 64-bit integer. + * Value - Value to be converted + * + * RETURN: None, string + * + * DESCRIPTION: Convert a 64-bit integer to decimal string representation. + * Assumes string buffer is large enough to hold the string. The + * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1). + * + ******************************************************************************/ + +void +AcpiExIntegerToString ( + char *OutString, + ACPI_INTEGER Value) +{ + UINT32 Count; + UINT32 DigitsNeeded; + UINT32 Remainder; + + + ACPI_FUNCTION_ENTRY (); + + + DigitsNeeded = AcpiExDigitsNeeded (Value, 10); + OutString[DigitsNeeded] = 0; + + for (Count = DigitsNeeded; Count > 0; Count--) + { + (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder); + OutString[Count-1] = (char) ('0' + Remainder);\ + } +} + +#endif diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwacpi.c b/reactos/drivers/bus/acpi/acpica/hardware/hwacpi.c new file mode 100644 index 00000000000..6b6d90ee02e --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwacpi.c @@ -0,0 +1,278 @@ + +/****************************************************************************** + * + * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWACPI_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwacpi") + + +/****************************************************************************** + * + * FUNCTION: AcpiHwSetMode + * + * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * RETURN: Status + * + * DESCRIPTION: Transitions the system into the requested mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode) +{ + + ACPI_STATUS Status; + UINT32 Retry; + + + ACPI_FUNCTION_TRACE (HwSetMode); + + /* + * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, + * system does not support mode transition. + */ + if (!AcpiGbl_FADT.SmiCommand) + { + ACPI_ERROR ((AE_INFO, "No SMI_CMD in FADT, mode transition failed")); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + /* + * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE + * in FADT: If it is zero, enabling or disabling is not supported. + * As old systems may have used zero for mode transition, + * we make sure both the numbers are zero to determine these + * transitions are not supported. + */ + if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable) + { + ACPI_ERROR ((AE_INFO, + "No ACPI mode transition supported in this system " + "(enable/disable both zero)")); + return_ACPI_STATUS (AE_OK); + } + + switch (Mode) + { + case ACPI_SYS_MODE_ACPI: + + /* BIOS should have disabled ALL fixed and GP events */ + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.AcpiEnable, 8); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); + break; + + case ACPI_SYS_MODE_LEGACY: + + /* + * BIOS should clear all fixed status bits and restore fixed event + * enable bits to default + */ + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.AcpiDisable, 8); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Attempting to enable Legacy (non-ACPI) mode\n")); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not write ACPI mode change")); + return_ACPI_STATUS (Status); + } + + /* + * Some hardware takes a LONG time to switch modes. Give them 3 sec to + * do so, but allow faster systems to proceed more quickly. + */ + Retry = 3000; + while (Retry) + { + if (AcpiHwGetMode() == Mode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", + Mode)); + return_ACPI_STATUS (AE_OK); + } + AcpiOsStall(1000); + Retry--; + } + + ACPI_ERROR ((AE_INFO, "Hardware did not change modes")); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetMode + * + * PARAMETERS: none + * + * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * DESCRIPTION: Return current operating state of system. Determined by + * querying the SCI_EN bit. + * + ******************************************************************************/ + +UINT32 +AcpiHwGetMode ( + void) +{ + ACPI_STATUS Status; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (HwGetMode); + + + /* + * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, + * system does not support mode transition. + */ + if (!AcpiGbl_FADT.SmiCommand) + { + return_UINT32 (ACPI_SYS_MODE_ACPI); + } + + Status = AcpiReadBitRegister (ACPI_BITREG_SCI_ENABLE, &Value); + if (ACPI_FAILURE (Status)) + { + return_UINT32 (ACPI_SYS_MODE_LEGACY); + } + + if (Value) + { + return_UINT32 (ACPI_SYS_MODE_ACPI); + } + else + { + return_UINT32 (ACPI_SYS_MODE_LEGACY); + } +} diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c b/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c new file mode 100644 index 00000000000..a45603d9d5f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c @@ -0,0 +1,597 @@ + +/****************************************************************************** + * + * Module Name: hwgpe - Low level GPE enable/disable/clear functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwgpe") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/****************************************************************************** + * + * FUNCTION: AcpiHwLowDisableGpe + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled + * + * RETURN: Status + * + * DESCRIPTION: Disable a single GPE in the enable register. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwLowDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; + UINT32 EnableMask; + + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return (AE_NOT_EXIST); + } + + /* Get current value of the enable register that contains this GPE */ + + Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Clear just the bit that corresponds to this GPE */ + + ACPI_CLEAR_BIT (EnableMask, ((UINT32) 1 << + (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber))); + + + /* Write the updated enable mask */ + + Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWriteGpeEnableReg + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled + * + * RETURN: Status + * + * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must + * already be cleared or set in the parent register + * EnableForRun mask. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWriteGpeEnableReg ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return (AE_NOT_EXIST); + } + + /* Write the entire GPE (runtime) enable register */ + + Status = AcpiHwWrite (GpeRegisterInfo->EnableForRun, + &GpeRegisterInfo->EnableAddress); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwClearGpe + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared + * + * RETURN: Status + * + * DESCRIPTION: Clear the status bit for a single GPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + UINT8 RegisterBit; + + + ACPI_FUNCTION_ENTRY (); + + + RegisterBit = (UINT8) (1 << + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + + /* + * Write a one to the appropriate bit in the status register to + * clear this GPE. + */ + Status = AcpiHwWrite (RegisterBit, + &GpeEventInfo->RegisterInfo->StatusAddress); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetGpeStatus + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to queried + * EventStatus - Where the GPE status is returned + * + * RETURN: Status + * + * DESCRIPTION: Return the status of a single GPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwGetGpeStatus ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + ACPI_EVENT_STATUS *EventStatus) +{ + UINT32 InByte; + UINT8 RegisterBit; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; + ACPI_EVENT_STATUS LocalEventStatus = 0; + + + ACPI_FUNCTION_ENTRY (); + + + if (!EventStatus) + { + return (AE_BAD_PARAMETER); + } + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + + /* Get the register bitmask for this GPE */ + + RegisterBit = (UINT8) (1 << + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + + /* GPE currently enabled? (enabled for runtime?) */ + + if (RegisterBit & GpeRegisterInfo->EnableForRun) + { + LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; + } + + /* GPE enabled for wake? */ + + if (RegisterBit & GpeRegisterInfo->EnableForWake) + { + LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED; + } + + /* GPE currently active (status bit == 1)? */ + + Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + if (RegisterBit & InByte) + { + LocalEventStatus |= ACPI_EVENT_FLAG_SET; + } + + /* Set return value */ + + (*EventStatus) = LocalEventStatus; + + +UnlockAndExit: + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwDisableGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Disable all GPEs within a single GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwDisableGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Disable all GPEs in this register */ + + Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwClearGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Clear status bits for all GPEs within a single GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Clear status on all GPEs in this register */ + + Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableRuntimeGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes + * combination wake/run GPEs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* NOTE: assumes that all GPEs are currently disabled */ + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + if (!GpeBlock->RegisterInfo[i].EnableForRun) + { + continue; + } + + /* Enable all "runtime" GPEs in this register */ + + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun, + &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableWakeupGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes + * combination wake/run GPEs. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + if (!GpeBlock->RegisterInfo[i].EnableForWake) + { + continue; + } + + /* Enable all "wake" GPEs in this register */ + + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake, + &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwDisableAllGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwDisableAllGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwDisableAllGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllRuntimeGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableAllRuntimeGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllWakeupGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c b/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c new file mode 100644 index 00000000000..163840d7f4a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c @@ -0,0 +1,805 @@ + +/******************************************************************************* + * + * Module Name: hwregs - Read/write access functions for the various ACPI + * control and status registers. + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWREGS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwregs") + + +/* Local Prototypes */ + +static ACPI_STATUS +AcpiHwReadMultiple ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB); + +static ACPI_STATUS +AcpiHwWriteMultiple ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB); + + +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateRegister + * + * PARAMETERS: Reg - GAS register structure + * MaxBitWidth - Max BitWidth supported (32 or 64) + * Address - Pointer to where the gas->address + * is returned + * + * RETURN: Status + * + * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS + * pointer, Address, SpaceId, BitWidth, and BitOffset. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address) +{ + + /* Must have a valid pointer to a GAS structure */ + + if (!Reg) + { + return (AE_BAD_PARAMETER); + } + + /* + * Copy the target address. This handles possible alignment issues. + * Address must not be null. A null address also indicates an optional + * ACPI register that is not supported, so no error message. + */ + ACPI_MOVE_64_TO_64 (Address, &Reg->Address); + if (!(*Address)) + { + return (AE_BAD_ADDRESS); + } + + /* Validate the SpaceID */ + + if ((Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && + (Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported address space: 0x%X", Reg->SpaceId)); + return (AE_SUPPORT); + } + + /* Validate the BitWidth */ + + if ((Reg->BitWidth != 8) && + (Reg->BitWidth != 16) && + (Reg->BitWidth != 32) && + (Reg->BitWidth != MaxBitWidth)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported register bit width: 0x%X", Reg->BitWidth)); + return (AE_SUPPORT); + } + + /* Validate the BitOffset. Just a warning for now. */ + + if (Reg->BitOffset != 0) + { + ACPI_WARNING ((AE_INFO, + "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max + * version of AcpiRead, used internally since the overhead of + * 64-bit values is not needed. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, or 32. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwRead); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Initialize entire 32-bit return value to zero */ + + *Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", + *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max + * version of AcpiWrite, used internally since the overhead of + * 64-bit values is not needed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwWrite); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", + Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwClearAcpiStatus + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Clears all fixed and general purpose status bits + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearAcpiStatus ( + void) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS LockFlags = 0; + + + ACPI_FUNCTION_TRACE (HwClearAcpiStatus); + + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n", + ACPI_BITMASK_ALL_FIXED_STATUS, + ACPI_FORMAT_UINT64 (AcpiGbl_XPm1aStatus.Address))); + + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); + + /* Clear the fixed events in PM1 A/B */ + + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, + ACPI_BITMASK_ALL_FIXED_STATUS); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Clear the GPE Bits in all GPE registers in all GPE blocks */ + + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); + +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetRegisterBitMask + * + * PARAMETERS: RegisterId - Index of ACPI Register to access + * + * RETURN: The bitmask to be used when accessing the register + * + * DESCRIPTION: Map RegisterId into a register bitmask. + * + ******************************************************************************/ + +ACPI_BIT_REGISTER_INFO * +AcpiHwGetBitRegisterInfo ( + UINT32 RegisterId) +{ + ACPI_FUNCTION_ENTRY (); + + + if (RegisterId > ACPI_BITREG_MAX) + { + ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: %X", RegisterId)); + return (NULL); + } + + return (&AcpiGbl_BitRegisterInfo[RegisterId]); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWritePm1Control + * + * PARAMETERS: Pm1aControl - Value to be written to PM1A control + * Pm1bControl - Value to be written to PM1B control + * + * RETURN: Status + * + * DESCRIPTION: Write the PM1 A/B control registers. These registers are + * different than than the PM1 A/B status and enable registers + * in that different values can be written to the A/B registers. + * Most notably, the SLP_TYP bits can be different, as per the + * values returned from the _Sx predefined methods. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWritePm1Control ( + UINT32 Pm1aControl, + UINT32 Pm1bControl) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwWritePm1Control); + + + Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (AcpiGbl_FADT.XPm1bControlBlock.Address) + { + Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock); + } + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRegisterRead + * + * PARAMETERS: RegisterId - ACPI Register ID + * ReturnValue - Where the register value is returned + * + * RETURN: Status and the value read. + * + * DESCRIPTION: Read from the specified ACPI register + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRegisterRead ( + UINT32 RegisterId, + UINT32 *ReturnValue) +{ + UINT32 Value = 0; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwRegisterRead); + + + switch (RegisterId) + { + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); + break; + + + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); + break; + + + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + + /* + * Zero the write-only bits. From the ACPI specification, "Hardware + * Write-Only Bits": "Upon reads to registers with write-only bits, + * software masks out all write-only bits." + */ + Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS; + break; + + + case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ + + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock); + break; + + + case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ + + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock); + break; + + + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ + + Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + RegisterId)); + Status = AE_BAD_PARAMETER; + break; + } + + if (ACPI_SUCCESS (Status)) + { + *ReturnValue = Value; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRegisterWrite + * + * PARAMETERS: RegisterId - ACPI Register ID + * Value - The value to write + * + * RETURN: Status + * + * DESCRIPTION: Write to the specified ACPI register + * + * NOTE: In accordance with the ACPI specification, this function automatically + * preserves the value of the following bits, meaning that these bits cannot be + * changed via this interface: + * + * PM1_CONTROL[0] = SCI_EN + * PM1_CONTROL[9] + * PM1_STATUS[11] + * + * ACPI References: + * 1) Hardware Ignored Bits: When software writes to a register with ignored + * bit fields, it preserves the ignored bit fields + * 2) SCI_EN: OSPM always preserves this bit position + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRegisterWrite ( + UINT32 RegisterId, + UINT32 Value) +{ + ACPI_STATUS Status; + UINT32 ReadValue; + + + ACPI_FUNCTION_TRACE (HwRegisterWrite); + + + switch (RegisterId) + { + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ + /* + * Handle the "ignored" bit in PM1 Status. According to the ACPI + * specification, ignored bits are to be preserved when writing. + * Normally, this would mean a read/modify/write sequence. However, + * preserving a bit in the status register is different. Writing a + * one clears the status, and writing a zero preserves the status. + * Therefore, we must always write zero to the ignored bit. + * + * This behavior is clarified in the ACPI 4.0 specification. + */ + Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS; + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); + break; + + + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); + break; + + + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ + + /* + * Perform a read first to preserve certain bits (per ACPI spec) + * Note: This includes SCI_EN, we never want to change this bit + */ + Status = AcpiHwReadMultiple (&ReadValue, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM1_CONTROL_PRESERVED_BITS, ReadValue); + + /* Now we can write the data */ + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + break; + + + case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ + + /* + * For control registers, all reserved bits must be preserved, + * as per the ACPI spec. + */ + Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue); + + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock); + break; + + + case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ + + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock); + break; + + + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ + + /* SMI_CMD is currently always in IO space */ + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + RegisterId)); + Status = AE_BAD_PARAMETER; + break; + } + +Exit: + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwReadMultiple + * + * PARAMETERS: Value - Where the register value is returned + * RegisterA - First ACPI register (required) + * RegisterB - Second ACPI register (optional) + * + * RETURN: Status + * + * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwReadMultiple ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB) +{ + UINT32 ValueA = 0; + UINT32 ValueB = 0; + ACPI_STATUS Status; + + + /* The first register is always required */ + + Status = AcpiHwRead (&ValueA, RegisterA); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Second register is optional */ + + if (RegisterB->Address) + { + Status = AcpiHwRead (&ValueB, RegisterB); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* + * OR the two return values together. No shifting or masking is necessary, + * because of how the PM1 registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" + */ + *Value = (ValueA | ValueB); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWriteMultiple + * + * PARAMETERS: Value - The value to write + * RegisterA - First ACPI register (required) + * RegisterB - Second ACPI register (optional) + * + * RETURN: Status + * + * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwWriteMultiple ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB) +{ + ACPI_STATUS Status; + + + /* The first register is always required */ + + Status = AcpiHwWrite (Value, RegisterA); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Second register is optional + * + * No bit shifting or clearing is necessary, because of how the PM1 + * registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" + */ + if (RegisterB->Address) + { + Status = AcpiHwWrite (Value, RegisterB); + } + + return (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c b/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c new file mode 100644 index 00000000000..fed4f1ddbf7 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c @@ -0,0 +1,711 @@ + +/****************************************************************************** + * + * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwsleep") + + +/******************************************************************************* + * + * FUNCTION: AcpiSetFirmwareWakingVector + * + * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode + * entry point. + * + * RETURN: Status + * + * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + UINT32 PhysicalAddress) +{ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); + + + /* Set the 32-bit vector */ + + AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; + + /* Clear the 64-bit vector if it exists */ + + if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) + { + AcpiGbl_FACS->XFirmwareWakingVector = 0; + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) + + +#if ACPI_MACHINE_WIDTH == 64 +/******************************************************************************* + * + * FUNCTION: AcpiSetFirmwareWakingVector64 + * + * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected + * mode entry point. + * + * RETURN: Status + * + * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if + * it exists in the table. This function is intended for use with + * 64-bit host operating systems. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress) +{ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); + + + /* Determine if the 64-bit vector actually exists */ + + if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Clear 32-bit vector, set the 64-bit X_ vector */ + + AcpiGbl_FACS->FirmwareWakingVector = 0; + AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepStatePrep + * + * PARAMETERS: SleepState - Which sleep state to enter + * + * RETURN: Status + * + * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) + * This function must execute with interrupts enabled. + * We break sleeping into 2 stages so that OSPM can handle + * various OS-specific tasks between the two steps. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepStatePrep ( + UINT8 SleepState) +{ + ACPI_STATUS Status; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); + + + /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ + + Status = AcpiGetSleepTypeData (SleepState, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Execute the _PTS method (Prepare To Sleep) */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = SleepState; + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Setup the argument to the _SST method (System STatus) */ + + switch (SleepState) + { + case ACPI_STATE_S0: + Arg.Integer.Value = ACPI_SST_WORKING; + break; + + case ACPI_STATE_S1: + case ACPI_STATE_S2: + case ACPI_STATE_S3: + Arg.Integer.Value = ACPI_SST_SLEEPING; + break; + + case ACPI_STATE_S4: + Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT; + break; + + default: + Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */ + break; + } + + /* + * Set the system indicators to show the desired sleep state. + * _SST is an optional method (return no error if not found) + */ + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While executing method _SST")); + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepState + * + * PARAMETERS: SleepState - Which sleep state to enter + * + * RETURN: Status + * + * DESCRIPTION: Enter a system sleep state + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepState ( + UINT8 SleepState) +{ + UINT32 Pm1aControl; + UINT32 Pm1bControl; + ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; + ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; + UINT32 InValue; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepState); + + + if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || + (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) + { + ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=%X B=%X", + AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); + SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + + /* Clear wake status */ + + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Clear all fixed and general purpose status bits */ + + Status = AcpiHwClearAcpiStatus (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SleepState != ACPI_STATE_S5) + { + /* + * Disable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Execute the _GTS method (Going To Sleep) */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = SleepState; + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Get current value of PM1A control */ + + Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, + &Pm1aControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Entering sleep state [S%d]\n", SleepState)); + + /* Clear the SLP_EN and SLP_TYP fields */ + + Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); + Pm1bControl = Pm1aControl; + + /* Insert the SLP_TYP bits */ + + Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); + Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); + + /* + * We split the writes of SLP_TYP and SLP_EN to workaround + * poorly implemented hardware. + */ + + /* Write #1: write the SLP_TYP data to the PM1 Control registers */ + + Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Insert the sleep enable (SLP_EN) bit */ + + Pm1aControl |= SleepEnableRegInfo->AccessBitMask; + Pm1bControl |= SleepEnableRegInfo->AccessBitMask; + + /* Flush caches, as per ACPI specification */ + + ACPI_FLUSH_CPU_CACHE (); + + /* Write #2: Write both SLP_TYP + SLP_EN */ + + Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SleepState > ACPI_STATE_S3) + { + /* + * We wanted to sleep > S3, but it didn't happen (by virtue of the + * fact that we are still executing!) + * + * Wait ten seconds, then try again. This is to get S4/S5 to work on + * all machines. + * + * We wait so long to allow chipsets that poll this reg very slowly + * to still read the right value. Ideally, this block would go + * away entirely. + */ + AcpiOsStall (10000000); + + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL, + SleepEnableRegInfo->AccessBitMask); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Wait until we enter sleep state */ + + do + { + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Spin until we wake */ + + } while (!InValue); + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepStateS4bios + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Perform a S4 bios request. + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepStateS4bios ( + void) +{ + UINT32 InValue; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); + + + /* Clear the wake status bit (PM1) */ + + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwClearAcpiStatus (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_FLUSH_CPU_CACHE (); + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); + + do { + AcpiOsStall(1000); + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } while (!InValue); + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) + + +/******************************************************************************* + * + * FUNCTION: AcpiLeaveSleepState + * + * PARAMETERS: SleepState - Which sleep state we just exited + * + * RETURN: Status + * + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep + * Called with interrupts ENABLED. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLeaveSleepState ( + UINT8 SleepState) +{ + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + ACPI_STATUS Status; + ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; + ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; + UINT32 Pm1aControl; + UINT32 Pm1bControl; + + + ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); + + + /* + * Set SLP_TYPE and SLP_EN to state S0. + * This is unclear from the ACPI Spec, but it is required + * by some machines. + */ + Status = AcpiGetSleepTypeData (ACPI_STATE_S0, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_SUCCESS (Status)) + { + SleepTypeRegInfo = + AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); + SleepEnableRegInfo = + AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + + /* Get current value of PM1A control */ + + Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, + &Pm1aControl); + if (ACPI_SUCCESS (Status)) + { + /* Clear the SLP_EN and SLP_TYP fields */ + + Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); + Pm1bControl = Pm1aControl; + + /* Insert the SLP_TYP bits */ + + Pm1aControl |= (AcpiGbl_SleepTypeA << + SleepTypeRegInfo->BitPosition); + Pm1bControl |= (AcpiGbl_SleepTypeB << + SleepTypeRegInfo->BitPosition); + + /* Write the control registers and ignore any errors */ + + (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + } + } + + /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */ + + AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID; + + /* Setup parameter object */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + + /* Ignore any errors from these methods */ + + Arg.Integer.Value = ACPI_SST_WAKING; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); + } + + Arg.Integer.Value = SleepState; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _BFS")); + } + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _WAK")); + } + /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ + + /* + * Restore the GPEs: + * 1) Disable/Clear all GPEs + * 2) Enable all runtime GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = TRUE; + + Status = AcpiHwEnableAllRuntimeGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Enable power button */ + + (void) AcpiWriteBitRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, + ACPI_ENABLE_EVENT); + + (void) AcpiWriteBitRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, + ACPI_CLEAR_STATUS); + + /* + * Enable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0); + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) + { + return_ACPI_STATUS (Status); + } + + Arg.Integer.Value = ACPI_SST_WORKING; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwtimer.c b/reactos/drivers/bus/acpi/acpica/hardware/hwtimer.c new file mode 100644 index 00000000000..f86fb7f865e --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwtimer.c @@ -0,0 +1,288 @@ + +/****************************************************************************** + * + * Name: hwtimer.c - ACPI Power Management Timer Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwtimer") + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimerResolution + * + * PARAMETERS: Resolution - Where the resolution is returned + * + * RETURN: Status and timer resolution + * + * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimerResolution ( + UINT32 *Resolution) +{ + ACPI_FUNCTION_TRACE (AcpiGetTimerResolution); + + + if (!Resolution) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) + { + *Resolution = 24; + } + else + { + *Resolution = 32; + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimerResolution) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimer + * + * PARAMETERS: Ticks - Where the timer value is returned + * + * RETURN: Status and current timer value (ticks) + * + * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimer ( + UINT32 *Ticks) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetTimer); + + + if (!Ticks) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimer) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimerDuration + * + * PARAMETERS: StartTicks - Starting timestamp + * EndTicks - End timestamp + * TimeElapsed - Where the elapsed time is returned + * + * RETURN: Status and TimeElapsed + * + * DESCRIPTION: Computes the time elapsed (in microseconds) between two + * PM Timer time stamps, taking into account the possibility of + * rollovers, the timer resolution, and timer frequency. + * + * The PM Timer's clock ticks at roughly 3.6 times per + * _microsecond_, and its clock continues through Cx state + * transitions (unlike many CPU timestamp counters) -- making it + * a versatile and accurate timer. + * + * Note that this function accommodates only a single timer + * rollover. Thus for 24-bit timers, this function should only + * be used for calculating durations less than ~4.6 seconds + * (~20 minutes for 32-bit timers) -- calculations below: + * + * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec + * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimerDuration ( + UINT32 StartTicks, + UINT32 EndTicks, + UINT32 *TimeElapsed) +{ + ACPI_STATUS Status; + UINT32 DeltaTicks; + ACPI_INTEGER Quotient; + + + ACPI_FUNCTION_TRACE (AcpiGetTimerDuration); + + + if (!TimeElapsed) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Compute Tick Delta: + * Handle (max one) timer rollovers on 24-bit versus 32-bit timers. + */ + if (StartTicks < EndTicks) + { + DeltaTicks = EndTicks - StartTicks; + } + else if (StartTicks > EndTicks) + { + if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) + { + /* 24-bit Timer */ + + DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF); + } + else + { + /* 32-bit Timer */ + + DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks; + } + } + else /* StartTicks == EndTicks */ + { + *TimeElapsed = 0; + return_ACPI_STATUS (AE_OK); + } + + /* + * Compute Duration (Requires a 64-bit multiply and divide): + * + * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY; + */ + Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000, + PM_TIMER_FREQUENCY, &Quotient, NULL); + + *TimeElapsed = (UINT32) Quotient; + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimerDuration) + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwvalid.c b/reactos/drivers/bus/acpi/acpica/hardware/hwvalid.c new file mode 100644 index 00000000000..650b695b2cc --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwvalid.c @@ -0,0 +1,424 @@ + +/****************************************************************************** + * + * Module Name: hwvalid - I/O request validation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWVALID_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwvalid") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwValidateIoRequest ( + ACPI_IO_ADDRESS Address, + UINT32 BitWidth); + + +/* + * Protected I/O ports. Some ports are always illegal, and some are + * conditionally illegal. This table must remain ordered by port address. + * + * The table is used to implement the Microsoft port access rules that + * first appeared in Windows XP. Some ports are always illegal, and some + * ports are only illegal if the BIOS calls _OSI with a WinXP string or + * later (meaning that the BIOS itelf is post-XP.) + * + * This provides ACPICA with the desired port protections and + * Microsoft compatibility. + * + * Description of port entries: + * DMA: DMA controller + * PIC0: Programmable Interrupt Controller (8259A) + * PIT1: System Timer 1 + * PIT2: System Timer 2 failsafe + * RTC: Real-time clock + * CMOS: Extended CMOS + * DMA1: DMA 1 page registers + * DMA1L: DMA 1 Ch 0 low page + * DMA2: DMA 2 page registers + * DMA2L: DMA 2 low page refresh + * ARBC: Arbitration control + * SETUP: Reserved system board setup + * POS: POS channel select + * PIC1: Cascaded PIC + * IDMA: ISA DMA + * ELCR: PIC edge/level registers + * PCI: PCI configuration space + */ +static const ACPI_PORT_INFO AcpiProtectedPorts[] = +{ + {"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP}, + {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL}, + {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP}, + {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP}, + {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, + {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP}, + {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP}, + {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, + {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP}, + {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, + {"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP}, + {"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP}, + {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP}, + {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL}, + {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP}, + {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL}, + {"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP} +}; + +#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (AcpiProtectedPorts) + + +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateIoRequest + * + * PARAMETERS: Address Address of I/O port/register + * BitWidth Number of bits (8,16,32) + * + * RETURN: Status + * + * DESCRIPTION: Validates an I/O request (address/length). Certain ports are + * always illegal and some ports are only illegal depending on + * the requests the BIOS AML code makes to the predefined + * _OSI method. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwValidateIoRequest ( + ACPI_IO_ADDRESS Address, + UINT32 BitWidth) +{ + UINT32 i; + UINT32 ByteWidth; + ACPI_IO_ADDRESS LastAddress; + const ACPI_PORT_INFO *PortInfo; + + + ACPI_FUNCTION_TRACE (HwValidateIoRequest); + + + /* Supported widths are 8/16/32 */ + + if ((BitWidth != 8) && + (BitWidth != 16) && + (BitWidth != 32)) + { + return (AE_BAD_PARAMETER); + } + + PortInfo = AcpiProtectedPorts; + ByteWidth = ACPI_DIV_8 (BitWidth); + LastAddress = Address + ByteWidth - 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X", + ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress), + ByteWidth)); + + /* Maximum 16-bit address in I/O space */ + + if (LastAddress > ACPI_UINT16_MAX) + { + ACPI_ERROR ((AE_INFO, + "Illegal I/O port address/length above 64K: 0x%p/%X", + ACPI_CAST_PTR (void, Address), ByteWidth)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* Exit if requested address is not within the protected port table */ + + if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End) + { + return_ACPI_STATUS (AE_OK); + } + + /* Check request against the list of protected I/O ports */ + + for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++) + { + /* + * Check if the requested address range will write to a reserved + * port. Four cases to consider: + * + * 1) Address range is contained completely in the port address range + * 2) Address range overlaps port range at the port range start + * 3) Address range overlaps port range at the port range end + * 4) Address range completely encompasses the port range + */ + if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start)) + { + /* Port illegality may depend on the _OSI calls made by the BIOS */ + + if (AcpiGbl_OsiData >= PortInfo->OsiDependency) + { + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", + ACPI_CAST_PTR (void, Address), ByteWidth, PortInfo->Name, + PortInfo->Start, PortInfo->End)); + + return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS); + } + } + + /* Finished if address range ends before the end of this port */ + + if (LastAddress <= PortInfo->End) + { + break; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwReadPort + * + * PARAMETERS: Address Address of I/O port/register to read + * Value Where value is placed + * Width Number of bits + * + * RETURN: Status and value read from port + * + * DESCRIPTION: Read data from an I/O port or register. This is a front-end + * to AcpiOsReadPort that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + ACPI_STATUS Status; + UINT32 OneByte; + UINT32 i; + + + /* Validate the entire request and perform the I/O */ + + Status = AcpiHwValidateIoRequest (Address, Width); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiOsReadPort (Address, Value, Width); + return (Status); + } + + if (Status != AE_AML_ILLEGAL_ADDRESS) + { + return (Status); + } + + /* + * There has been a protection violation within the request. Fall + * back to byte granularity port I/O and ignore the failing bytes. + * This provides Windows compatibility. + */ + for (i = 0, *Value = 0; i < Width; i += 8) + { + /* Validate and read one byte */ + + if (AcpiHwValidateIoRequest (Address, 8) == AE_OK) + { + Status = AcpiOsReadPort (Address, &OneByte, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *Value |= (OneByte << i); + } + + Address++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWritePort + * + * PARAMETERS: Address Address of I/O port/register to write + * Value Value to write + * Width Number of bits + * + * RETURN: Status + * + * DESCRIPTION: Write data to an I/O port or register. This is a front-end + * to AcpiOsWritePort that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + ACPI_STATUS Status; + UINT32 i; + + + /* Validate the entire request and perform the I/O */ + + Status = AcpiHwValidateIoRequest (Address, Width); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiOsWritePort (Address, Value, Width); + return (Status); + } + + if (Status != AE_AML_ILLEGAL_ADDRESS) + { + return (Status); + } + + /* + * There has been a protection violation within the request. Fall + * back to byte granularity port I/O and ignore the failing bytes. + * This provides Windows compatibility. + */ + for (i = 0; i < Width; i += 8) + { + /* Validate and write one byte */ + + if (AcpiHwValidateIoRequest (Address, 8) == AE_OK) + { + Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + Address++; + } + + return (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwxface.c b/reactos/drivers/bus/acpi/acpica/hardware/hwxface.c new file mode 100644 index 00000000000..6c345a593e1 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwxface.c @@ -0,0 +1,710 @@ + +/****************************************************************************** + * + * Module Name: hwxface - Public ACPICA hardware interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwxface") + + +/****************************************************************************** + * + * FUNCTION: AcpiReset + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Set reset register in memory or IO space. Note: Does not + * support reset register in PCI config space, this must be + * handled separately. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReset ( + void) +{ + ACPI_GENERIC_ADDRESS *ResetReg; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiReset); + + + ResetReg = &AcpiGbl_FADT.ResetRegister; + + /* Check if the reset register is supported */ + + if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) || + !ResetReg->Address) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) + { + /* + * For I/O space, write directly to the OSL. This bypasses the port + * validation mechanism, which may block a valid write to the reset + * register. + */ + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address, + AcpiGbl_FADT.ResetValue, ResetReg->BitWidth); + } + else + { + /* Write the reset value to the reset register */ + + Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiReset) + + +/****************************************************************************** + * + * FUNCTION: AcpiRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, 32, or 64. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRead ( + UINT64 *ReturnValue, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT32 Value; + UINT32 Width; + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (AcpiRead); + + + if (!ReturnValue) + { + return (AE_BAD_PARAMETER); + } + + /* Validate contents of the GAS register. Allow 64-bit transfers */ + + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Width = Reg->BitWidth; + if (Width == 64) + { + Width = 32; /* Break into two 32-bit transfers */ + } + + /* Initialize entire 64-bit return value to zero */ + + *ReturnValue = 0; + Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRead) + + +/****************************************************************************** + * + * FUNCTION: AcpiWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWrite ( + UINT64 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT32 Width; + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (AcpiWrite); + + + /* Validate contents of the GAS register. Allow 64-bit transfers */ + + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Width = Reg->BitWidth; + if (Width == 64) + { + Width = 32; /* Break into two 32-bit transfers */ + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Reg->BitWidth == 64) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Reg->BitWidth == 64) + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (Value), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWrite) + + +/******************************************************************************* + * + * FUNCTION: AcpiReadBitRegister + * + * PARAMETERS: RegisterId - ID of ACPI Bit Register to access + * ReturnValue - Value that was read from the register, + * normalized to bit position zero. + * + * RETURN: Status and the value read from the specified Register. Value + * returned is normalized to bit0 (is shifted all the way right) + * + * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note: The hardware lock is not required when reading the ACPI bit registers + * since almost all of them are single bit and it does not matter that + * the parent hardware register can be split across two physical + * registers. The only multi-bit field is SLP_TYP in the PM1 control + * register, but this field does not cross an 8-bit boundary (nor does + * it make much sense to actually read this field.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReadBitRegister ( + UINT32 RegisterId, + UINT32 *ReturnValue) +{ + ACPI_BIT_REGISTER_INFO *BitRegInfo; + UINT32 RegisterValue; + UINT32 Value; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId); + + + /* Get the info structure corresponding to the requested ACPI Register */ + + BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); + if (!BitRegInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Read the entire parent register */ + + Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, + &RegisterValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Normalize the value that was read, mask off other bits */ + + Value = ((RegisterValue & BitRegInfo->AccessBitMask) + >> BitRegInfo->BitPosition); + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n", + RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value)); + + *ReturnValue = Value; + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiReadBitRegister) + + +/******************************************************************************* + * + * FUNCTION: AcpiWriteBitRegister + * + * PARAMETERS: RegisterId - ID of ACPI Bit Register to access + * Value - Value to write to the register, in bit + * position zero. The bit is automaticallly + * shifted to the correct position. + * + * RETURN: Status + * + * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock + * since most operations require a read/modify/write sequence. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note that at this level, the fact that there may be actually two + * hardware registers (A and B - and B may not exist) is abstracted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWriteBitRegister ( + UINT32 RegisterId, + UINT32 Value) +{ + ACPI_BIT_REGISTER_INFO *BitRegInfo; + ACPI_CPU_FLAGS LockFlags; + UINT32 RegisterValue; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId); + + + /* Get the info structure corresponding to the requested ACPI Register */ + + BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); + if (!BitRegInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); + + /* + * At this point, we know that the parent register is one of the + * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control + */ + if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS) + { + /* + * 1) Case for PM1 Enable, PM1 Control, and PM2 Control + * + * Perform a register read to preserve the bits that we are not + * interested in + */ + Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, + &RegisterValue); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* + * Insert the input bit into the value that was just read + * and write the register + */ + ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, + BitRegInfo->AccessBitMask, Value); + + Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister, + RegisterValue); + } + else + { + /* + * 2) Case for PM1 Status + * + * The Status register is different from the rest. Clear an event + * by writing 1, writing 0 has no effect. So, the only relevant + * information is the single bit we're interested in, all others + * should be written as 0 so they will be left unchanged. + */ + RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value, + BitRegInfo->BitPosition, BitRegInfo->AccessBitMask); + + /* No need to write the register if value is all zeros */ + + if (RegisterValue) + { + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, + RegisterValue); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n", + RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue)); + + +UnlockAndExit: + + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetSleepTypeData + * + * PARAMETERS: SleepState - Numeric sleep state + * *SleepTypeA - Where SLP_TYPa is returned + * *SleepTypeB - Where SLP_TYPb is returned + * + * RETURN: Status - ACPI status + * + * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep + * state. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSleepTypeData ( + UINT8 SleepState, + UINT8 *SleepTypeA, + UINT8 *SleepTypeB) +{ + ACPI_STATUS Status = AE_OK; + ACPI_EVALUATE_INFO *Info; + + + ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData); + + + /* Validate parameters */ + + if ((SleepState > ACPI_S_STATES_MAX) || + !SleepTypeA || + !SleepTypeB) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]); + + /* Evaluate the namespace object containing the values for this state */ + + Status = AcpiNsEvaluate (Info); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%s while evaluating SleepState [%s]\n", + AcpiFormatException (Status), Info->Pathname)); + + goto Cleanup; + } + + /* Must have a return object */ + + if (!Info->ReturnObject) + { + ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]", + Info->Pathname)); + Status = AE_NOT_EXIST; + } + + /* It must be of type Package */ + + else if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package")); + Status = AE_AML_OPERAND_TYPE; + } + + /* + * The package must have at least two elements. NOTE (March 2005): This + * goes against the current ACPI spec which defines this object as a + * package with one encoded DWORD element. However, existing practice + * by BIOS vendors seems to be to have 2 or more elements, at least + * one per sleep type (A/B). + */ + else if (Info->ReturnObject->Package.Count < 2) + { + ACPI_ERROR ((AE_INFO, + "Sleep State return package does not have at least two elements")); + Status = AE_AML_NO_OPERAND; + } + + /* The first two elements must both be of type Integer */ + + else if (((Info->ReturnObject->Package.Elements[0])->Common.Type + != ACPI_TYPE_INTEGER) || + ((Info->ReturnObject->Package.Elements[1])->Common.Type + != ACPI_TYPE_INTEGER)) + { + ACPI_ERROR ((AE_INFO, + "Sleep State return package elements are not both Integers " + "(%s, %s)", + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]), + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1]))); + Status = AE_AML_OPERAND_TYPE; + } + else + { + /* Valid _Sx_ package size, type, and value */ + + *SleepTypeA = (UINT8) + (Info->ReturnObject->Package.Elements[0])->Integer.Value; + *SleepTypeB = (UINT8) + (Info->ReturnObject->Package.Elements[1])->Integer.Value; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While evaluating SleepState [%s], bad Sleep object %p type %s", + Info->Pathname, Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); + } + + AcpiUtRemoveReference (Info->ReturnObject); + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData) diff --git a/reactos/drivers/bus/acpi/acpica/include/acapps.h b/reactos/drivers/bus/acpi/acpica/include/acapps.h new file mode 100644 index 00000000000..c5ebef1d4af --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acapps.h @@ -0,0 +1,252 @@ +/****************************************************************************** + * + * Module Name: acapps - common include for ACPI applications/tools + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACAPPS +#define _ACAPPS + + +#ifdef _MSC_VER /* disable some level-4 warnings */ +#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ +#endif + +#define FILE_SUFFIX_DISASSEMBLY "dsl" +#define ACPI_TABLE_FILE_SUFFIX ".dat" + + +/* + * getopt + */ +int +AcpiGetopt( + int argc, + char **argv, + char *opts); + +extern int AcpiGbl_Optind; +extern char *AcpiGbl_Optarg; + + +/* + * adisasm + */ +ACPI_STATUS +AdAmlDisassemble ( + BOOLEAN OutToFile, + char *Filename, + char *Prefix, + char **OutFilename, + BOOLEAN GetAllTables); + +void +AdPrintStatistics ( + void); + +ACPI_STATUS +AdFindDsdt( + UINT8 **DsdtPtr, + UINT32 *DsdtLength); + +void +AdDumpTables ( + void); + +ACPI_STATUS +AdGetLocalTables ( + char *Filename, + BOOLEAN GetAllTables); + +ACPI_STATUS +AdParseTable ( + ACPI_TABLE_HEADER *Table, + ACPI_OWNER_ID *OwnerId, + BOOLEAN LoadTable, + BOOLEAN External); + +ACPI_STATUS +AdDisplayTables ( + char *Filename, + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AdDisplayStatistics ( + void); + + +/* + * adwalk + */ +void +AcpiDmCrossReferenceNamespace ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId); + +void +AcpiDmDumpTree ( + ACPI_PARSE_OBJECT *Origin); + +void +AcpiDmFindOrphanMethods ( + ACPI_PARSE_OBJECT *Origin); + +void +AcpiDmFinishNamespaceLoad ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId); + +void +AcpiDmConvertResourceIndexes ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot); + + +/* + * adfile + */ +ACPI_STATUS +AdInitialize ( + void); + +char * +FlGenerateFilename ( + char *InputFilename, + char *Suffix); + +ACPI_STATUS +FlSplitInputPathname ( + char *InputPath, + char **OutDirectoryPath, + char **OutFilename); + +char * +FlGenerateFilename ( + char *InputFilename, + char *Suffix); + +char * +AdGenerateFilename ( + char *Prefix, + char *TableId); + +void +AdWriteTable ( + ACPI_TABLE_HEADER *Table, + UINT32 Length, + char *TableName, + char *OemTableId); + +#endif /* _ACAPPS */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/accommon.h b/reactos/drivers/bus/acpi/acpica/include/accommon.h new file mode 100644 index 00000000000..690d3cdba95 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/accommon.h @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * Name: accommon.h - Common include files for generation of ACPICA source + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACCOMMON_H__ +#define __ACCOMMON_H__ + +/* + * Common set of includes for all ACPICA source files. + * We put them here because we don't want to duplicate them + * in the the source code again and again. + * + * Note: The order of these include files is important. + */ +#include "acconfig.h" /* Global configuration constants */ +#include "acmacros.h" /* C macros */ +#include "aclocal.h" /* Internal data types */ +#include "acobject.h" /* ACPI internal object */ +#include "acstruct.h" /* Common structures */ +#include "acglobal.h" /* All global variables */ +#include "achware.h" /* Hardware defines and interfaces */ +#include "acutils.h" /* Utility interfaces */ + + +#endif /* __ACCOMMON_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acconfig.h b/reactos/drivers/bus/acpi/acpica/include/acconfig.h new file mode 100644 index 00000000000..8fbe0e371b2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acconfig.h @@ -0,0 +1,279 @@ +/****************************************************************************** + * + * Name: acconfig.h - Global configuration constants + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACCONFIG_H +#define _ACCONFIG_H + + +/****************************************************************************** + * + * Configuration options + * + *****************************************************************************/ + +/* + * ACPI_DEBUG_OUTPUT - This switch enables all the debug facilities of the + * ACPI subsystem. This includes the DEBUG_PRINT output + * statements. When disabled, all DEBUG_PRINT + * statements are compiled out. + * + * ACPI_APPLICATION - Use this switch if the subsystem is going to be run + * at the application level. + * + */ + +/* + * OS name, used for the _OS object. The _OS object is essentially obsolete, + * but there is a large base of ASL/AML code in existing machines that check + * for the string below. The use of this string usually guarantees that + * the ASL will execute down the most tested code path. Also, there is some + * code that will not execute the _OSI method unless _OS matches the string + * below. Therefore, change this string at your own risk. + */ +#define ACPI_OS_NAME "Microsoft Windows NT" + +/* Maximum objects in the various object caches */ + +#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */ +#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ +#define ACPI_MAX_NAMESPACE_CACHE_DEPTH 96 /* Namespace objects */ + +/* + * Should the subsystem abort the loading of an ACPI table if the + * table checksum is incorrect? + */ +#define ACPI_CHECKSUM_ABORT FALSE + + +/****************************************************************************** + * + * Subsystem Constants + * + *****************************************************************************/ + +/* Version of ACPI supported */ + +#define ACPI_CA_SUPPORT_LEVEL 3 + +/* Maximum count for a semaphore object */ + +#define ACPI_MAX_SEMAPHORE_COUNT 256 + +/* Maximum object reference count (detects object deletion issues) */ + +#define ACPI_MAX_REFERENCE_COUNT 0x800 + +/* Default page size for use in mapping memory for operation regions */ + +#define ACPI_DEFAULT_PAGE_SIZE 4096 /* Must be power of 2 */ + +/* OwnerId tracking. 8 entries allows for 255 OwnerIds */ + +#define ACPI_NUM_OWNERID_MASKS 8 + +/* Size of the root table array is increased by this increment */ + +#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4 + +/* Maximum number of While() loop iterations before forced abort */ + +#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* Method info (in WALK_STATE), containing local variables and argumetns */ + +#define ACPI_METHOD_NUM_LOCALS 8 +#define ACPI_METHOD_MAX_LOCAL 7 + +#define ACPI_METHOD_NUM_ARGS 7 +#define ACPI_METHOD_MAX_ARG 6 + +/* + * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG + */ +#define ACPI_OBJ_NUM_OPERANDS 8 +#define ACPI_OBJ_MAX_OPERAND 7 + +/* Number of elements in the Result Stack frame, can be an arbitrary value */ + +#define ACPI_RESULTS_FRAME_OBJ_NUM 8 + +/* + * Maximal number of elements the Result Stack can contain, + * it may be an arbitray value not exceeding the types of + * ResultSize and ResultCount (now UINT8). + */ +#define ACPI_RESULTS_OBJ_NUM_MAX 255 + +/* Constants used in searching for the RSDP in low memory */ + +#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ +#define ACPI_EBDA_PTR_LENGTH 2 +#define ACPI_EBDA_WINDOW_SIZE 1024 +#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */ +#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000 +#define ACPI_RSDP_SCAN_STEP 16 + +/* Operation regions */ + +#define ACPI_NUM_PREDEFINED_REGIONS 9 +#define ACPI_USER_REGION_BEGIN 0x80 + +/* Maximum SpaceIds for Operation Regions */ + +#define ACPI_MAX_ADDRESS_SPACE 255 + +/* Array sizes. Used for range checking also */ + +#define ACPI_MAX_MATCH_OPCODE 5 + +/* RSDP checksums */ + +#define ACPI_RSDP_CHECKSUM_LENGTH 20 +#define ACPI_RSDP_XCHECKSUM_LENGTH 36 + +/* SMBus and IPMI bidirectional buffer size */ + +#define ACPI_SMBUS_BUFFER_SIZE 34 +#define ACPI_IPMI_BUFFER_SIZE 66 + +/* _SxD and _SxW control methods */ + +#define ACPI_NUM_SxD_METHODS 4 +#define ACPI_NUM_SxW_METHODS 5 + + +/****************************************************************************** + * + * ACPI AML Debugger + * + *****************************************************************************/ + +#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ + +#define ACPI_DEBUGGER_COMMAND_PROMPT '-' +#define ACPI_DEBUGGER_EXECUTE_PROMPT '%' + + +#endif /* _ACCONFIG_H */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/acdebug.h b/reactos/drivers/bus/acpi/acpica/include/acdebug.h new file mode 100644 index 00000000000..82f2b6d49c1 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acdebug.h @@ -0,0 +1,449 @@ +/****************************************************************************** + * + * Name: acdebug.h - ACPI/AML debugger + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDEBUG_H__ +#define __ACDEBUG_H__ + + +#define ACPI_DEBUG_BUFFER_SIZE 4196 + +typedef struct CommandInfo +{ + char *Name; /* Command Name */ + UINT8 MinArgs; /* Minimum arguments required */ + +} COMMAND_INFO; + +typedef struct ArgumentInfo +{ + char *Name; /* Argument Name */ + +} ARGUMENT_INFO; + +typedef struct acpi_execute_walk +{ + UINT32 Count; + UINT32 MaxCount; + +} ACPI_EXECUTE_WALK; + + +#define PARAM_LIST(pl) pl +#define DBTEST_OUTPUT_LEVEL(lvl) if (AcpiGbl_DbOpt_verbose) +#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ + AcpiOsPrintf PARAM_LIST(fp);} + +#define EX_NO_SINGLE_STEP 1 +#define EX_SINGLE_STEP 2 + + +/* + * dbxface - external debugger interfaces + */ +ACPI_STATUS +AcpiDbInitialize ( + void); + +void +AcpiDbTerminate ( + void); + +ACPI_STATUS +AcpiDbSingleStep ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 OpType); + + +/* + * dbcmds - debug commands and output routines + */ +ACPI_STATUS +AcpiDbDisassembleMethod ( + char *Name); + +void +AcpiDbDisplayTableInfo ( + char *TableArg); + +void +AcpiDbUnloadAcpiTable ( + char *TableArg, + char *InstanceArg); + +void +AcpiDbSetMethodBreakpoint ( + char *Location, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbGetBusInfo ( + void); + +void +AcpiDbDisassembleAml ( + char *Statements, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDumpNamespace ( + char *StartArg, + char *DepthArg); + +void +AcpiDbDumpNamespaceByOwner ( + char *OwnerArg, + char *DepthArg); + +void +AcpiDbSendNotify ( + char *Name, + UINT32 Value); + +void +AcpiDbSetMethodData ( + char *TypeArg, + char *IndexArg, + char *ValueArg); + +ACPI_STATUS +AcpiDbDisplayObjects ( + char *ObjTypeArg, + char *DisplayCountArg); + +ACPI_STATUS +AcpiDbFindNameInNamespace ( + char *NameArg); + +void +AcpiDbSetScope ( + char *Name); + +ACPI_STATUS +AcpiDbSleep ( + char *ObjectArg); + +void +AcpiDbFindReferences ( + char *ObjectArg); + +void +AcpiDbDisplayLocks ( + void); + +void +AcpiDbDisplayResources ( + char *ObjectArg); + +void +AcpiDbDisplayGpes ( + void); + +void +AcpiDbCheckIntegrity ( + void); + +void +AcpiDbGenerateGpe ( + char *GpeArg, + char *BlockArg); + +void +AcpiDbCheckPredefinedNames ( + void); + +void +AcpiDbBatchExecute ( + char *CountArg); + +/* + * dbdisply - debug display commands + */ +void +AcpiDbDisplayMethodInfo ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDecodeAndDisplayObject ( + char *Target, + char *OutputType); + +void +AcpiDbDisplayResultObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDbDisplayAllMethods ( + char *DisplayCountArg); + +void +AcpiDbDisplayArguments ( + void); + +void +AcpiDbDisplayLocals ( + void); + +void +AcpiDbDisplayResults ( + void); + +void +AcpiDbDisplayCallingTree ( + void); + +void +AcpiDbDisplayObjectType ( + char *ObjectArg); + +void +AcpiDbDisplayArgumentObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * dbexec - debugger control method execution + */ +void +AcpiDbExecute ( + char *Name, + char **Args, + UINT32 Flags); + +void +AcpiDbCreateExecutionThreads ( + char *NumThreadsArg, + char *NumLoopsArg, + char *MethodNameArg); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +UINT32 +AcpiDbGetCacheInfo ( + ACPI_MEMORY_LIST *Cache); +#endif + + +/* + * dbfileio - Debugger file I/O commands + */ +ACPI_OBJECT_TYPE +AcpiDbMatchArgument ( + char *UserArgument, + ARGUMENT_INFO *Arguments); + +void +AcpiDbCloseDebugFile ( + void); + +void +AcpiDbOpenDebugFile ( + char *Name); + +ACPI_STATUS +AcpiDbLoadAcpiTable ( + char *Filename); + +ACPI_STATUS +AcpiDbGetTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table); + +ACPI_STATUS +AcpiDbReadTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table); + + +/* + * dbhistry - debugger HISTORY command + */ +void +AcpiDbAddToHistory ( + char *CommandLine); + +void +AcpiDbDisplayHistory ( + void); + +char * +AcpiDbGetFromHistory ( + char *CommandNumArg); + + +/* + * dbinput - user front-end to the AML debugger + */ +ACPI_STATUS +AcpiDbCommandDispatch ( + char *InputBuffer, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void ACPI_SYSTEM_XFACE +AcpiDbExecuteThread ( + void *Context); + +ACPI_STATUS +AcpiDbUserCommands ( + char Prompt, + ACPI_PARSE_OBJECT *Op); + + +/* + * dbstats - Generation and display of ACPI table statistics + */ +void +AcpiDbGenerateStatistics ( + ACPI_PARSE_OBJECT *Root, + BOOLEAN IsMethod); + +ACPI_STATUS +AcpiDbDisplayStatistics ( + char *TypeArg); + + +/* + * dbutils - AML debugger utilities + */ +void +AcpiDbSetOutputDestination ( + UINT32 Where); + +void +AcpiDbDumpExternalObject ( + ACPI_OBJECT *ObjDesc, + UINT32 Level); + +void +AcpiDbPrepNamestring ( + char *Name); + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + char *Name); + +void +AcpiDbUInt32ToHexString ( + UINT32 Value, + char *Buffer); + +#endif /* __ACDEBUG_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acdisasm.h b/reactos/drivers/bus/acpi/acpica/include/acdisasm.h new file mode 100644 index 00000000000..de198ff5742 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acdisasm.h @@ -0,0 +1,757 @@ +/****************************************************************************** + * + * Name: acdisasm.h - AML disassembler + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDISASM_H__ +#define __ACDISASM_H__ + +#include "amlresrc.h" + + +#define BLOCK_NONE 0 +#define BLOCK_PAREN 1 +#define BLOCK_BRACE 2 +#define BLOCK_COMMA_LIST 4 +#define ACPI_DEFAULT_RESNAME *(UINT32 *) "__RD" + + +typedef const struct acpi_dmtable_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + +} ACPI_DMTABLE_INFO; + +/* + * Values for Opcode above. + * Note: 0-7 must not change, used as a flag shift value + */ +#define ACPI_DMT_FLAG0 0 +#define ACPI_DMT_FLAG1 1 +#define ACPI_DMT_FLAG2 2 +#define ACPI_DMT_FLAG3 3 +#define ACPI_DMT_FLAG4 4 +#define ACPI_DMT_FLAG5 5 +#define ACPI_DMT_FLAG6 6 +#define ACPI_DMT_FLAG7 7 +#define ACPI_DMT_FLAGS0 8 +#define ACPI_DMT_FLAGS2 9 +#define ACPI_DMT_UINT8 10 +#define ACPI_DMT_UINT16 11 +#define ACPI_DMT_UINT24 12 +#define ACPI_DMT_UINT32 13 +#define ACPI_DMT_UINT56 14 +#define ACPI_DMT_UINT64 15 +#define ACPI_DMT_STRING 16 +#define ACPI_DMT_NAME4 17 +#define ACPI_DMT_NAME6 18 +#define ACPI_DMT_NAME8 19 +#define ACPI_DMT_CHKSUM 20 +#define ACPI_DMT_SPACEID 21 +#define ACPI_DMT_GAS 22 +#define ACPI_DMT_ASF 23 +#define ACPI_DMT_DMAR 24 +#define ACPI_DMT_HEST 25 +#define ACPI_DMT_HESTNTFY 26 +#define ACPI_DMT_HESTNTYP 27 +#define ACPI_DMT_MADT 28 +#define ACPI_DMT_SRAT 29 +#define ACPI_DMT_EXIT 30 +#define ACPI_DMT_SIG 31 +#define ACPI_DMT_FADTPM 32 +#define ACPI_DMT_BUF16 33 +#define ACPI_DMT_IVRS 34 + + +typedef +void (*ACPI_DMTABLE_HANDLER) ( + ACPI_TABLE_HEADER *Table); + +typedef struct acpi_dmtable_data +{ + char *Signature; + ACPI_DMTABLE_INFO *TableInfo; + ACPI_DMTABLE_HANDLER TableHandler; + char *Name; + +} ACPI_DMTABLE_DATA; + + +typedef struct acpi_op_walk_info +{ + UINT32 Level; + UINT32 LastLevel; + UINT32 Count; + UINT32 BitOffset; + UINT32 Flags; + ACPI_WALK_STATE *WalkState; + +} ACPI_OP_WALK_INFO; + +typedef +ACPI_STATUS (*ASL_WALK_CALLBACK) ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +typedef struct acpi_resource_tag +{ + UINT32 BitIndex; + char *Tag; + +} ACPI_RESOURCE_TAG; + +/* Strings used for decoding flags to ASL keywords */ + +extern const char *AcpiGbl_WordDecode[]; +extern const char *AcpiGbl_IrqDecode[]; +extern const char *AcpiGbl_LockRule[]; +extern const char *AcpiGbl_AccessTypes[]; +extern const char *AcpiGbl_UpdateRules[]; +extern const char *AcpiGbl_MatchOps[]; + +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsfHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoBoot[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoBert[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbgp[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGas[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest6[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest7[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest8[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestBank[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8b[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8c[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrsHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt5[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt6[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt7[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt8[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSbst[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlic[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWaet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[]; + + +/* + * dmtable + */ +void +AcpiDmDumpDataTable ( + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AcpiDmDumpTable ( + UINT32 TableLength, + UINT32 TableOffset, + void *Table, + UINT32 SubTableLength, + ACPI_DMTABLE_INFO *Info); + +void +AcpiDmLineHeader ( + UINT32 Offset, + UINT32 ByteLength, + char *Name); + +void +AcpiDmLineHeader2 ( + UINT32 Offset, + UINT32 ByteLength, + char *Name, + UINT32 Value); + + +/* + * dmtbdump + */ +void +AcpiDmDumpAsf ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpCpep ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpDmar ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpEinj ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpErst ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpFadt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpHest ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpIvrs ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMcfg ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMadt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMsct ( + ACPI_TABLE_HEADER *Table); + +UINT32 +AcpiDmDumpRsdp ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpRsdt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpSlit ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpSrat ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpWdat ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpXsdt ( + ACPI_TABLE_HEADER *Table); + + +/* + * dmwalk + */ +void +AcpiDmDisassemble ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Origin, + UINT32 NumOpcodes); + +void +AcpiDmWalkParseTree ( + ACPI_PARSE_OBJECT *Op, + ASL_WALK_CALLBACK DescendingCallback, + ASL_WALK_CALLBACK AscendingCallback, + void *Context); + + +/* + * dmopcode + */ +void +AcpiDmDisassembleOneOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +UINT32 +AcpiDmListType ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmMethodFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmFieldFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmAddressSpace ( + UINT8 SpaceId); + +void +AcpiDmRegionFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmMatchOp ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmnames + */ +UINT32 +AcpiDmDumpName ( + UINT32 Name); + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmNamestring ( + char *Name); + + +/* + * dmobject + */ +void +AcpiDmDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDisplayArguments ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDisplayLocals ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDumpMethodInfo ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* + * dmbuffer + */ +void +AcpiDmDisasmByteList ( + UINT32 Level, + UINT8 *ByteData, + UINT32 ByteCount); + +void +AcpiDmByteList ( + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmIsEisaId ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmEisaId ( + UINT32 EncodedId); + +BOOLEAN +AcpiDmIsUnicodeBuffer ( + ACPI_PARSE_OBJECT *Op); + +BOOLEAN +AcpiDmIsStringBuffer ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmextern + */ +void +AcpiDmAddToExternalList ( + ACPI_PARSE_OBJECT *Op, + char *Path, + UINT8 Type, + UINT32 Value); + +void +AcpiDmAddExternalsToNamespace ( + void); + +UINT32 +AcpiDmGetExternalMethodCount ( + void); + +void +AcpiDmClearExternalList ( + void); + +void +AcpiDmEmitExternals ( + void); + + +/* + * dmresrc + */ +void +AcpiDmDumpInteger8 ( + UINT8 Value, + char *Name); + +void +AcpiDmDumpInteger16 ( + UINT16 Value, + char *Name); + +void +AcpiDmDumpInteger32 ( + UINT32 Value, + char *Name); + +void +AcpiDmDumpInteger64 ( + UINT64 Value, + char *Name); + +void +AcpiDmResourceTemplate ( + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op, + UINT8 *ByteData, + UINT32 ByteCount); + +ACPI_STATUS +AcpiDmIsResourceTemplate ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmBitList ( + UINT16 Mask); + +void +AcpiDmDescriptorName ( + void); + + +/* + * dmresrcl + */ +void +AcpiDmWordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmDwordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmExtendedDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmQwordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmMemory24Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmMemory32Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmFixedMemory32Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmGenericRegisterDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmInterruptDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorLargeDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorCommon ( + char *Name, + UINT8 *ByteData, + UINT32 Length, + UINT32 Level); + + +/* + * dmresrcs + */ +void +AcpiDmIrqDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmDmaDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmIoDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmFixedIoDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmStartDependentDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmEndDependentDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorSmallDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + + +/* + * dmutils + */ +void +AcpiDmDecodeAttribute ( + UINT8 Attribute); + +void +AcpiDmIndent ( + UINT32 Level); + +BOOLEAN +AcpiDmCommaIfListMember ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmCommaIfFieldMember ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmrestag + */ +void +AcpiDmFindResources ( + ACPI_PARSE_OBJECT *Root); + +void +AcpiDmCheckResourceReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +#endif /* __ACDISASM_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acdispat.h b/reactos/drivers/bus/acpi/acpica/include/acdispat.h new file mode 100644 index 00000000000..2aa86232b2f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acdispat.h @@ -0,0 +1,527 @@ +/****************************************************************************** + * + * Name: acdispat.h - dispatcher (parser to interpreter interface) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef _ACDISPAT_H_ +#define _ACDISPAT_H_ + + +#define NAMEOF_LOCAL_NTE "__L0" +#define NAMEOF_ARG_NTE "__A0" + + +/* + * dsopcode - support for late evaluation + */ +ACPI_STATUS +AcpiDsGetBufferFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetBankFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetRegionArguments ( + ACPI_OPERAND_OBJECT *RgnDesc); + +ACPI_STATUS +AcpiDsGetBufferArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetPackageArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsEvalBufferFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalTableRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalDataObjectOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsEvalBankFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsInitializeRegion ( + ACPI_HANDLE ObjHandle); + + +/* + * dsctrl - Parser/Interpreter interface, control stack routines + */ +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* + * dsexec - Parser/Interpreter interface, method execution callbacks + */ +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ResultObj); + +ACPI_STATUS +AcpiDsExecBeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *State); + + +/* + * dsfield - Parser/Interpreter interface for AML fields + */ +ACPI_STATUS +AcpiDsCreateField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateBankField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateBufferField ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsInitFieldObjects ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + + +/* + * dsload - Parser/Interpreter interface, namespace load callbacks + */ +ACPI_STATUS +AcpiDsLoad1BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsInitCallbacks ( + ACPI_WALK_STATE *WalkState, + UINT32 PassNumber); + + +/* + * dsmthdat - method data (locals/args) + */ +ACPI_STATUS +AcpiDsStoreObjectToLocal ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *SrcDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataGetEntry ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT ***Node); + +void +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsIsMethodValue ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc); + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataGetNode ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **Node); + +void +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState); + + +/* + * dsmethod - Parser/Interpreter interface - control method parsing + */ +ACPI_STATUS +AcpiDsParseMethod ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_THREAD_STATE *Thread, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc); + +void +AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodError ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState); + +/* + * dsinit + */ +ACPI_STATUS +AcpiDsInitializeObjects ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + + +/* + * dsobject - Parser/Interpreter interface - object initialization and conversion + */ +ACPI_STATUS +AcpiDsBuildInternalBufferObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 BufferLength, + ACPI_OPERAND_OBJECT **ObjDescPtr); + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *op, + UINT32 PackageLength, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsInitObjectFromOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + + +/* + * dsutils - Parser/Interpreter interface utility routines + */ +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference); + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg, + UINT32 ArgsRemaining); + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg); + +ACPI_STATUS +AcpiDsResolveOperands ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDsClearOperands ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsEvaluateNamePath ( + ACPI_WALK_STATE *WalkState); + + +/* + * dswscope - Scope Stack manipulation + */ +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_WALK_STATE *WalkState); + + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState); + + +/* + * dswstate - parser WALK_STATE management routines + */ +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsInitAmlWalk ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *MethodNode, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_EVALUATE_INFO *Info, + UINT8 PassNumber); + +void +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteWalkState ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_THREAD_STATE *Thread); + +void +AcpiDsPushWalkState ( + ACPI_WALK_STATE *WalkState, + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsResultStackClear ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsGetCurrentWalkState ( + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsResultPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsResultPush ( + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + +#endif /* _ACDISPAT_H_ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acevents.h b/reactos/drivers/bus/acpi/acpica/include/acevents.h new file mode 100644 index 00000000000..0cd5e2e2869 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acevents.h @@ -0,0 +1,375 @@ +/****************************************************************************** + * + * Name: acevents.h - Event subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEVENTS_H__ +#define __ACEVENTS_H__ + + +/* + * evevent + */ +ACPI_STATUS +AcpiEvInitializeEvents ( + void); + +ACPI_STATUS +AcpiEvInstallXruptHandlers ( + void); + +ACPI_STATUS +AcpiEvInstallFadtGpes ( + void); + +UINT32 +AcpiEvFixedEventDetect ( + void); + + +/* + * evmisc + */ +BOOLEAN +AcpiEvIsNotifyObject ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiEvAcquireGlobalLock( + UINT16 Timeout); + +ACPI_STATUS +AcpiEvReleaseGlobalLock( + void); + +ACPI_STATUS +AcpiEvInitGlobalLockHandler ( + void); + +UINT32 +AcpiEvGetGpeNumberIndex ( + UINT32 GpeNumber); + +ACPI_STATUS +AcpiEvQueueNotifyRequest ( + ACPI_NAMESPACE_NODE *Node, + UINT32 NotifyValue); + + +/* + * evgpe - GPE handling and dispatch + */ +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware); + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_GPE_EVENT_INFO * +AcpiEvGetGpeEventInfo ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber); + + +/* + * evgpeblk + */ +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context); + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiEvCreateGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT8 GpeBlockBaseNumber, + UINT32 InterruptNumber, + ACPI_GPE_BLOCK_INFO **ReturnGpeBlock); + +ACPI_STATUS +AcpiEvInitializeGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GPE_BLOCK_INFO *GpeBlock); + +ACPI_STATUS +AcpiEvDeleteGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock); + +UINT32 +AcpiEvGpeDispatch ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT32 GpeNumber); + +UINT32 +AcpiEvGpeDetect ( + ACPI_GPE_XRUPT_INFO *GpeXruptList); + +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvCheckForWakeOnlyGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiEvGpeInitialize ( + void); + + +/* + * evregion - Address Space handling + */ +ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void); + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void); + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + UINT32 RegionOffset, + UINT32 BitWidth, + ACPI_INTEGER *Value); + +ACPI_STATUS +AcpiEvAttachRegion ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked); + +void +AcpiEvDetachRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked); + +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + +ACPI_STATUS +AcpiEvExecuteRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function); + + +/* + * evregini - Region initialization and setup + */ +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvCmosRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvPciBarRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked); + + +/* + * evsci - SCI (System Control Interrupt) handling/dispatch + */ +UINT32 ACPI_SYSTEM_XFACE +AcpiEvGpeXruptHandler ( + void *Context); + +UINT32 +AcpiEvInstallSciHandler ( + void); + +ACPI_STATUS +AcpiEvRemoveSciHandler ( + void); + +UINT32 +AcpiEvInitializeSCI ( + UINT32 ProgramSCI); + +void +AcpiEvTerminate ( + void); + + +#endif /* __ACEVENTS_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acexcep.h b/reactos/drivers/bus/acpi/acpica/include/acexcep.h new file mode 100644 index 00000000000..dfe2e2ee734 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acexcep.h @@ -0,0 +1,382 @@ +/****************************************************************************** + * + * Name: acexcep.h - Exception codes returned by the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEXCEP_H__ +#define __ACEXCEP_H__ + + +/* + * Exceptions returned by external ACPI interfaces + */ +#define AE_CODE_ENVIRONMENTAL 0x0000 +#define AE_CODE_PROGRAMMER 0x1000 +#define AE_CODE_ACPI_TABLES 0x2000 +#define AE_CODE_AML 0x3000 +#define AE_CODE_CONTROL 0x4000 +#define AE_CODE_MASK 0xF000 + + +#define ACPI_SUCCESS(a) (!(a)) +#define ACPI_FAILURE(a) (a) + + +#define AE_OK (ACPI_STATUS) 0x0000 + +/* + * Environmental exceptions + */ +#define AE_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_ACPI_TABLES (ACPI_STATUS) (0x0002 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_NAMESPACE (ACPI_STATUS) (0x0003 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_MEMORY (ACPI_STATUS) (0x0004 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_FOUND (ACPI_STATUS) (0x0005 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_EXIST (ACPI_STATUS) (0x0006 | AE_CODE_ENVIRONMENTAL) +#define AE_ALREADY_EXISTS (ACPI_STATUS) (0x0007 | AE_CODE_ENVIRONMENTAL) +#define AE_TYPE (ACPI_STATUS) (0x0008 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_OBJECT (ACPI_STATUS) (0x0009 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_ENTRY (ACPI_STATUS) (0x000A | AE_CODE_ENVIRONMENTAL) +#define AE_BUFFER_OVERFLOW (ACPI_STATUS) (0x000B | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL) +#define AE_SUPPORT (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) +#define AE_LIMIT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) +#define AE_TIME (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) +#define AE_ACQUIRE_DEADLOCK (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) +#define AE_RELEASE_DEADLOCK (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_ACQUIRED (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) +#define AE_ALREADY_ACQUIRED (ACPI_STATUS) (0x0015 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_HARDWARE_RESPONSE (ACPI_STATUS) (0x0016 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_GLOBAL_LOCK (ACPI_STATUS) (0x0017 | AE_CODE_ENVIRONMENTAL) +#define AE_ABORT_METHOD (ACPI_STATUS) (0x0018 | AE_CODE_ENVIRONMENTAL) +#define AE_SAME_HANDLER (ACPI_STATUS) (0x0019 | AE_CODE_ENVIRONMENTAL) +#define AE_WAKE_ONLY_GPE (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL) +#define AE_OWNER_ID_LIMIT (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL) + +#define AE_CODE_ENV_MAX 0x001B + + +/* + * Programmer exceptions + */ +#define AE_BAD_PARAMETER (ACPI_STATUS) (0x0001 | AE_CODE_PROGRAMMER) +#define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER) +#define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER) +#define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER) +#define AE_BAD_HEX_CONSTANT (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) +#define AE_BAD_OCTAL_CONSTANT (ACPI_STATUS) (0x0006 | AE_CODE_PROGRAMMER) +#define AE_BAD_DECIMAL_CONSTANT (ACPI_STATUS) (0x0007 | AE_CODE_PROGRAMMER) +#define AE_MISSING_ARGUMENTS (ACPI_STATUS) (0x0008 | AE_CODE_PROGRAMMER) +#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0009 | AE_CODE_PROGRAMMER) + +#define AE_CODE_PGM_MAX 0x0009 + + +/* + * Acpi table exceptions + */ +#define AE_BAD_SIGNATURE (ACPI_STATUS) (0x0001 | AE_CODE_ACPI_TABLES) +#define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES) +#define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES) +#define AE_BAD_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_ACPI_TABLES) +#define AE_INVALID_TABLE_LENGTH (ACPI_STATUS) (0x0005 | AE_CODE_ACPI_TABLES) + +#define AE_CODE_TBL_MAX 0x0005 + + +/* + * AML exceptions. These are caused by problems with + * the actual AML byte stream + */ +#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0001 | AE_CODE_AML) +#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0002 | AE_CODE_AML) +#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0003 | AE_CODE_AML) +#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0005 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0006 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0007 | AE_CODE_AML) +#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x0008 | AE_CODE_AML) +#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x0009 | AE_CODE_AML) +#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000A | AE_CODE_AML) +#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) +#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000C | AE_CODE_AML) +#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000D | AE_CODE_AML) +#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x000E | AE_CODE_AML) +#define AE_AML_INTERNAL (ACPI_STATUS) (0x000F | AE_CODE_AML) +#define AE_AML_INVALID_SPACE_ID (ACPI_STATUS) (0x0010 | AE_CODE_AML) +#define AE_AML_STRING_LIMIT (ACPI_STATUS) (0x0011 | AE_CODE_AML) +#define AE_AML_NO_RETURN_VALUE (ACPI_STATUS) (0x0012 | AE_CODE_AML) +#define AE_AML_METHOD_LIMIT (ACPI_STATUS) (0x0013 | AE_CODE_AML) +#define AE_AML_NOT_OWNER (ACPI_STATUS) (0x0014 | AE_CODE_AML) +#define AE_AML_MUTEX_ORDER (ACPI_STATUS) (0x0015 | AE_CODE_AML) +#define AE_AML_MUTEX_NOT_ACQUIRED (ACPI_STATUS) (0x0016 | AE_CODE_AML) +#define AE_AML_INVALID_RESOURCE_TYPE (ACPI_STATUS) (0x0017 | AE_CODE_AML) +#define AE_AML_INVALID_INDEX (ACPI_STATUS) (0x0018 | AE_CODE_AML) +#define AE_AML_REGISTER_LIMIT (ACPI_STATUS) (0x0019 | AE_CODE_AML) +#define AE_AML_NO_WHILE (ACPI_STATUS) (0x001A | AE_CODE_AML) +#define AE_AML_ALIGNMENT (ACPI_STATUS) (0x001B | AE_CODE_AML) +#define AE_AML_NO_RESOURCE_END_TAG (ACPI_STATUS) (0x001C | AE_CODE_AML) +#define AE_AML_BAD_RESOURCE_VALUE (ACPI_STATUS) (0x001D | AE_CODE_AML) +#define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x001E | AE_CODE_AML) +#define AE_AML_BAD_RESOURCE_LENGTH (ACPI_STATUS) (0x001F | AE_CODE_AML) +#define AE_AML_ILLEGAL_ADDRESS (ACPI_STATUS) (0x0020 | AE_CODE_AML) +#define AE_AML_INFINITE_LOOP (ACPI_STATUS) (0x0021 | AE_CODE_AML) + +#define AE_CODE_AML_MAX 0x0021 + + +/* + * Internal exceptions used for control + */ +#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) (0x0001 | AE_CODE_CONTROL) +#define AE_CTRL_PENDING (ACPI_STATUS) (0x0002 | AE_CODE_CONTROL) +#define AE_CTRL_TERMINATE (ACPI_STATUS) (0x0003 | AE_CODE_CONTROL) +#define AE_CTRL_TRUE (ACPI_STATUS) (0x0004 | AE_CODE_CONTROL) +#define AE_CTRL_FALSE (ACPI_STATUS) (0x0005 | AE_CODE_CONTROL) +#define AE_CTRL_DEPTH (ACPI_STATUS) (0x0006 | AE_CODE_CONTROL) +#define AE_CTRL_END (ACPI_STATUS) (0x0007 | AE_CODE_CONTROL) +#define AE_CTRL_TRANSFER (ACPI_STATUS) (0x0008 | AE_CODE_CONTROL) +#define AE_CTRL_BREAK (ACPI_STATUS) (0x0009 | AE_CODE_CONTROL) +#define AE_CTRL_CONTINUE (ACPI_STATUS) (0x000A | AE_CODE_CONTROL) +#define AE_CTRL_SKIP (ACPI_STATUS) (0x000B | AE_CODE_CONTROL) +#define AE_CTRL_PARSE_CONTINUE (ACPI_STATUS) (0x000C | AE_CODE_CONTROL) +#define AE_CTRL_PARSE_PENDING (ACPI_STATUS) (0x000D | AE_CODE_CONTROL) + +#define AE_CODE_CTRL_MAX 0x000D + + +/* Exception strings for AcpiFormatException */ + +#ifdef DEFINE_ACPI_GLOBALS + +/* + * String versions of the exception codes above + * These strings must match the corresponding defines exactly + */ +char const *AcpiGbl_ExceptionNames_Env[] = +{ + "AE_OK", + "AE_ERROR", + "AE_NO_ACPI_TABLES", + "AE_NO_NAMESPACE", + "AE_NO_MEMORY", + "AE_NOT_FOUND", + "AE_NOT_EXIST", + "AE_ALREADY_EXISTS", + "AE_TYPE", + "AE_NULL_OBJECT", + "AE_NULL_ENTRY", + "AE_BUFFER_OVERFLOW", + "AE_STACK_OVERFLOW", + "AE_STACK_UNDERFLOW", + "AE_NOT_IMPLEMENTED", + "AE_SUPPORT", + "AE_LIMIT", + "AE_TIME", + "AE_ACQUIRE_DEADLOCK", + "AE_RELEASE_DEADLOCK", + "AE_NOT_ACQUIRED", + "AE_ALREADY_ACQUIRED", + "AE_NO_HARDWARE_RESPONSE", + "AE_NO_GLOBAL_LOCK", + "AE_ABORT_METHOD", + "AE_SAME_HANDLER", + "AE_WAKE_ONLY_GPE", + "AE_OWNER_ID_LIMIT" +}; + +char const *AcpiGbl_ExceptionNames_Pgm[] = +{ + NULL, + "AE_BAD_PARAMETER", + "AE_BAD_CHARACTER", + "AE_BAD_PATHNAME", + "AE_BAD_DATA", + "AE_BAD_HEX_CONSTANT", + "AE_BAD_OCTAL_CONSTANT", + "AE_BAD_DECIMAL_CONSTANT", + "AE_MISSING_ARGUMENTS", + "AE_BAD_ADDRESS" +}; + +char const *AcpiGbl_ExceptionNames_Tbl[] = +{ + NULL, + "AE_BAD_SIGNATURE", + "AE_BAD_HEADER", + "AE_BAD_CHECKSUM", + "AE_BAD_VALUE", + "AE_INVALID_TABLE_LENGTH" +}; + +char const *AcpiGbl_ExceptionNames_Aml[] = +{ + NULL, + "AE_AML_BAD_OPCODE", + "AE_AML_NO_OPERAND", + "AE_AML_OPERAND_TYPE", + "AE_AML_OPERAND_VALUE", + "AE_AML_UNINITIALIZED_LOCAL", + "AE_AML_UNINITIALIZED_ARG", + "AE_AML_UNINITIALIZED_ELEMENT", + "AE_AML_NUMERIC_OVERFLOW", + "AE_AML_REGION_LIMIT", + "AE_AML_BUFFER_LIMIT", + "AE_AML_PACKAGE_LIMIT", + "AE_AML_DIVIDE_BY_ZERO", + "AE_AML_BAD_NAME", + "AE_AML_NAME_NOT_FOUND", + "AE_AML_INTERNAL", + "AE_AML_INVALID_SPACE_ID", + "AE_AML_STRING_LIMIT", + "AE_AML_NO_RETURN_VALUE", + "AE_AML_METHOD_LIMIT", + "AE_AML_NOT_OWNER", + "AE_AML_MUTEX_ORDER", + "AE_AML_MUTEX_NOT_ACQUIRED", + "AE_AML_INVALID_RESOURCE_TYPE", + "AE_AML_INVALID_INDEX", + "AE_AML_REGISTER_LIMIT", + "AE_AML_NO_WHILE", + "AE_AML_ALIGNMENT", + "AE_AML_NO_RESOURCE_END_TAG", + "AE_AML_BAD_RESOURCE_VALUE", + "AE_AML_CIRCULAR_REFERENCE", + "AE_AML_BAD_RESOURCE_LENGTH", + "AE_AML_ILLEGAL_ADDRESS", + "AE_AML_INFINITE_LOOP" +}; + +char const *AcpiGbl_ExceptionNames_Ctrl[] = +{ + NULL, + "AE_CTRL_RETURN_VALUE", + "AE_CTRL_PENDING", + "AE_CTRL_TERMINATE", + "AE_CTRL_TRUE", + "AE_CTRL_FALSE", + "AE_CTRL_DEPTH", + "AE_CTRL_END", + "AE_CTRL_TRANSFER", + "AE_CTRL_BREAK", + "AE_CTRL_CONTINUE", + "AE_CTRL_SKIP", + "AE_CTRL_PARSE_CONTINUE", + "AE_CTRL_PARSE_PENDING" +}; + +#endif /* ACPI GLOBALS */ + +#endif /* __ACEXCEP_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acglobal.h b/reactos/drivers/bus/acpi/acpica/include/acglobal.h new file mode 100644 index 00000000000..82fe445169d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acglobal.h @@ -0,0 +1,494 @@ +/****************************************************************************** + * + * Name: acglobal.h - Declarations for global variables + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACGLOBAL_H__ +#define __ACGLOBAL_H__ + + +/* + * Ensure that the globals are actually defined and initialized only once. + * + * The use of these macros allows a single list of globals (here) in order + * to simplify maintenance of the code. + */ +#ifdef DEFINE_ACPI_GLOBALS +#define ACPI_EXTERN +#define ACPI_INIT_GLOBAL(a,b) a=b +#else +#define ACPI_EXTERN extern +#define ACPI_INIT_GLOBAL(a,b) a +#endif + + +#ifdef DEFINE_ACPI_GLOBALS + +/* Public globals, available from outside ACPICA subsystem */ + +/***************************************************************************** + * + * Runtime configuration (static defaults that can be overriden at runtime) + * + ****************************************************************************/ + +/* + * Enable "slack" in the AML interpreter? Default is FALSE, and the + * interpreter strictly follows the ACPI specification. Setting to TRUE + * allows the interpreter to ignore certain errors and/or bad AML constructs. + * + * Currently, these features are enabled by this flag: + * + * 1) Allow "implicit return" of last value in a control method + * 2) Allow access beyond the end of an operation region + * 3) Allow access to uninitialized locals/args (auto-init to integer 0) + * 4) Allow ANY object type to be a source operand for the Store() operator + * 5) Allow unresolved references (invalid target name) in package objects + * 6) Enable warning messages for behavior that is not ACPI spec compliant + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); + +/* + * Automatically serialize ALL control methods? Default is FALSE, meaning + * to use the Serialized/NotSerialized method flags on a per method basis. + * Only change this if the ASL code is poorly written and cannot handle + * reentrancy even though methods are marked "NotSerialized". + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); + +/* + * Create the predefined _OSI method in the namespace? Default is TRUE + * because ACPI CA is fully compatible with other ACPI implementations. + * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); + +/* + * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and + * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only + * be enabled just before going to sleep. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); + +/* + * Optionally use default values for the ACPI register widths. Set this to + * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_UseDefaultRegisterWidths, TRUE); + + +/* AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ + +ACPI_TABLE_FADT AcpiGbl_FADT; +UINT32 AcpiCurrentGpeCount; +UINT32 AcpiGbl_TraceFlags; +ACPI_NAME AcpiGbl_TraceMethodName; + +#endif + +/***************************************************************************** + * + * ACPI Table globals + * + ****************************************************************************/ + +/* + * AcpiGbl_RootTableList is the master list of ACPI tables found in the + * RSDT/XSDT. + * + */ +ACPI_EXTERN ACPI_INTERNAL_RSDT AcpiGbl_RootTableList; +ACPI_EXTERN ACPI_TABLE_FACS *AcpiGbl_FACS; + +/* These addresses are calculated from the FADT Event Block addresses */ + +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aStatus; +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; + +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bStatus; +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; + +/* + * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is + * determined by the revision of the DSDT: If the DSDT revision is less than + * 2, use only the lower 32 bits of the internal 64-bit Integer. + */ +ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; +ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; +ACPI_EXTERN UINT8 AcpiGbl_IntegerNybbleWidth; + + +/***************************************************************************** + * + * Mutual exlusion within ACPICA subsystem + * + ****************************************************************************/ + +/* + * Predefined mutex objects. This array contains the + * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. + * (The table maps local handles to the real OS handles) + */ +ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[ACPI_NUM_MUTEX]; + +/* + * Global lock mutex is an actual AML mutex object + * Global lock semaphore works in conjunction with the HW global lock + */ +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_GlobalLockMutex; +ACPI_EXTERN ACPI_SEMAPHORE AcpiGbl_GlobalLockSemaphore; +ACPI_EXTERN UINT16 AcpiGbl_GlobalLockHandle; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; + +/* + * Spinlocks are used for interfaces that can be possibly called at + * interrupt level + */ +ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_GpeLock; /* For GPE data structs and registers */ +ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_HardwareLock; /* For ACPI H/W except GPE registers */ + +/* Reader/Writer lock is used for namespace walk and dynamic table unload */ + +ACPI_EXTERN ACPI_RW_LOCK AcpiGbl_NamespaceRwLock; + + +/***************************************************************************** + * + * Miscellaneous globals + * + ****************************************************************************/ + +/* Object caches */ + +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_NamespaceCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_StateCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeExtCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_OperandCache; + +/* Global handlers */ + +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_DeviceNotify; +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SystemNotify; +ACPI_EXTERN ACPI_EXCEPTION_HANDLER AcpiGbl_ExceptionHandler; +ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; +ACPI_EXTERN ACPI_TABLE_HANDLER AcpiGbl_TableHandler; +ACPI_EXTERN void *AcpiGbl_TableHandlerContext; +ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; + + +/* Owner ID support */ + +ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS]; +ACPI_EXTERN UINT8 AcpiGbl_LastOwnerIdIndex; +ACPI_EXTERN UINT8 AcpiGbl_NextOwnerIdOffset; + +/* Misc */ + +ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; +ACPI_EXTERN UINT32 AcpiGbl_RsdpOriginalLocation; +ACPI_EXTERN UINT32 AcpiGbl_NsLookupCount; +ACPI_EXTERN UINT32 AcpiGbl_PsFindCount; +ACPI_EXTERN UINT16 AcpiGbl_Pm1EnableRegisterSave; +ACPI_EXTERN UINT8 AcpiGbl_DebuggerConfiguration; +ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; +ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; +ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; +ACPI_EXTERN BOOLEAN AcpiGbl_SystemAwakeAndRunning; +ACPI_EXTERN UINT8 AcpiGbl_OsiData; + + +#ifndef DEFINE_ACPI_GLOBALS + +/* Exception codes */ + +extern char const *AcpiGbl_ExceptionNames_Env[]; +extern char const *AcpiGbl_ExceptionNames_Pgm[]; +extern char const *AcpiGbl_ExceptionNames_Tbl[]; +extern char const *AcpiGbl_ExceptionNames_Aml[]; +extern char const *AcpiGbl_ExceptionNames_Ctrl[]; + +/* Other miscellaneous */ + +extern BOOLEAN AcpiGbl_Shutdown; +extern UINT32 AcpiGbl_StartupFlags; +extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]; +extern const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS]; +extern const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS]; +extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; +extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; +#endif + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +/* Lists for tracking memory allocations */ + +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_GlobalList; +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_NsNodeList; +ACPI_EXTERN BOOLEAN AcpiGbl_DisplayFinalMemStats; +#endif + + +/***************************************************************************** + * + * Namespace globals + * + ****************************************************************************/ + +#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) +#define NUM_PREDEFINED_NAMES 10 +#else +#define NUM_PREDEFINED_NAMES 9 +#endif + +ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_FadtGpeDevice; +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_ModuleCodeList; + + +extern const UINT8 AcpiGbl_NsProperties [ACPI_NUM_NS_TYPES]; +extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; + +#ifdef ACPI_DEBUG_OUTPUT +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentNodeCount; +ACPI_EXTERN ACPI_SIZE *AcpiGbl_EntryStackPointer; +ACPI_EXTERN ACPI_SIZE *AcpiGbl_LowestStackPointer; +ACPI_EXTERN UINT32 AcpiGbl_DeepestNesting; +#endif + + +/***************************************************************************** + * + * Interpreter globals + * + ****************************************************************************/ + + +ACPI_EXTERN ACPI_THREAD_STATE *AcpiGbl_CurrentWalkList; + +/* Control method single step flag */ + +ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; + + +/***************************************************************************** + * + * Hardware globals + * + ****************************************************************************/ + +extern ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG]; +ACPI_EXTERN UINT8 AcpiGbl_SleepTypeA; +ACPI_EXTERN UINT8 AcpiGbl_SleepTypeB; + + +/***************************************************************************** + * + * Event and GPE globals + * + ****************************************************************************/ + +extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN ACPI_GPE_XRUPT_INFO *AcpiGbl_GpeXruptListHead; +ACPI_EXTERN ACPI_GPE_BLOCK_INFO *AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS]; + + +/***************************************************************************** + * + * Debug support + * + ****************************************************************************/ + +/* Procedure nesting level for debug output */ + +extern UINT32 AcpiGbl_NestingLevel; + +/* Event counters */ + +ACPI_EXTERN UINT32 AcpiMethodCount; +ACPI_EXTERN UINT32 AcpiGpeCount; +ACPI_EXTERN UINT32 AcpiSciCount; +ACPI_EXTERN UINT32 AcpiFixedEventCount[ACPI_NUM_FIXED_EVENTS]; + +/* Support for dynamic control method tracing mechanism */ + +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; + + +/***************************************************************************** + * + * Debugger globals + * + ****************************************************************************/ + +ACPI_EXTERN UINT8 AcpiGbl_DbOutputFlags; + +#ifdef ACPI_DISASSEMBLER + +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_disasm; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_verbose; +ACPI_EXTERN ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; +#endif + + +#ifdef ACPI_DEBUGGER + +extern BOOLEAN AcpiGbl_MethodExecuting; +extern BOOLEAN AcpiGbl_AbortMethod; +extern BOOLEAN AcpiGbl_DbTerminateThreads; + +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_tables; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_stats; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_ini_methods; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_NoRegionSupport; + +ACPI_EXTERN char *AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]; +ACPI_EXTERN char AcpiGbl_DbLineBuf[80]; +ACPI_EXTERN char AcpiGbl_DbParsedBuf[80]; +ACPI_EXTERN char AcpiGbl_DbScopeBuf[40]; +ACPI_EXTERN char AcpiGbl_DbDebugFilename[40]; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOutputToFile; +ACPI_EXTERN char *AcpiGbl_DbBuffer; +ACPI_EXTERN char *AcpiGbl_DbFilename; +ACPI_EXTERN UINT32 AcpiGbl_DbDebugLevel; +ACPI_EXTERN UINT32 AcpiGbl_DbConsoleDebugLevel; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_DbScopeNode; + +/* + * Statistic globals + */ +ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; +ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; +ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCountMisc; +ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCountMisc; +ACPI_EXTERN UINT32 AcpiGbl_NumNodes; +ACPI_EXTERN UINT32 AcpiGbl_NumObjects; + + +ACPI_EXTERN UINT32 AcpiGbl_SizeOfParseTree; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfMethodTrees; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfNodeEntries; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfAcpiObjects; + +#endif /* ACPI_DEBUGGER */ + +#endif /* __ACGLOBAL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/achware.h b/reactos/drivers/bus/acpi/acpica/include/achware.h new file mode 100644 index 00000000000..c171a5fc1df --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/achware.h @@ -0,0 +1,269 @@ +/****************************************************************************** + * + * Name: achware.h -- hardware specific interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACHWARE_H__ +#define __ACHWARE_H__ + + +/* Values for the _SST predefined method */ + +#define ACPI_SST_INDICATOR_OFF 0 +#define ACPI_SST_WORKING 1 +#define ACPI_SST_WAKING 2 +#define ACPI_SST_SLEEPING 3 +#define ACPI_SST_SLEEP_CONTEXT 4 + + +/* + * hwacpi - high level functions + */ +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode); + +UINT32 +AcpiHwGetMode ( + void); + + +/* + * hwregs - ACPI Register I/O + */ +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address); + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_BIT_REGISTER_INFO * +AcpiHwGetBitRegisterInfo ( + UINT32 RegisterId); + +ACPI_STATUS +AcpiHwWritePm1Control ( + UINT32 Pm1aControl, + UINT32 Pm1bControl); + +ACPI_STATUS +AcpiHwRegisterRead ( + UINT32 RegisterId, + UINT32 *ReturnValue); + +ACPI_STATUS +AcpiHwRegisterWrite ( + UINT32 RegisterId, + UINT32 Value); + +ACPI_STATUS +AcpiHwClearAcpiStatus ( + void); + + +/* + * hwvalid - Port I/O with validation + */ +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * hwgpe - GPE support + */ +ACPI_STATUS +AcpiHwLowDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwWriteGpeEnableReg ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwDisableGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiHwClearGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwClearGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiHwGetGpeStatus ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + ACPI_EVENT_STATUS *EventStatus); + +ACPI_STATUS +AcpiHwDisableAllGpes ( + void); + +ACPI_STATUS +AcpiHwEnableAllRuntimeGpes ( + void); + +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + void); + +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/* + * hwtimer - ACPI Timer prototypes + */ +ACPI_STATUS +AcpiGetTimerResolution ( + UINT32 *Resolution); + +ACPI_STATUS +AcpiGetTimer ( + UINT32 *Ticks); + +ACPI_STATUS +AcpiGetTimerDuration ( + UINT32 StartTicks, + UINT32 EndTicks, + UINT32 *TimeElapsed); + + +#endif /* __ACHWARE_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acinterp.h b/reactos/drivers/bus/acpi/acpica/include/acinterp.h new file mode 100644 index 00000000000..74c5f0b4eba --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acinterp.h @@ -0,0 +1,784 @@ +/****************************************************************************** + * + * Name: acinterp.h - Interpreter subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACINTERP_H__ +#define __ACINTERP_H__ + + +#define ACPI_WALK_OPERANDS (&(WalkState->Operands [WalkState->NumOperands -1])) + +/* Macros for tables used for debug output */ + +#define ACPI_EXD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_OPERAND_OBJECT,f) +#define ACPI_EXD_NSOFFSET(f) (UINT8) ACPI_OFFSET (ACPI_NAMESPACE_NODE,f) +#define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_EXDUMP_INFO)) + +/* + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output. Two cases where we cannot + * pack the structures: + * + * 1) Hardware does not support misaligned memory transfers + * 2) Compiler does not support pointers within packed structures + */ +#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) +#pragma pack(1) +#endif + +typedef const struct acpi_exdump_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + +} ACPI_EXDUMP_INFO; + +/* Values for the Opcode field above */ + +#define ACPI_EXD_INIT 0 +#define ACPI_EXD_TYPE 1 +#define ACPI_EXD_UINT8 2 +#define ACPI_EXD_UINT16 3 +#define ACPI_EXD_UINT32 4 +#define ACPI_EXD_UINT64 5 +#define ACPI_EXD_LITERAL 6 +#define ACPI_EXD_POINTER 7 +#define ACPI_EXD_ADDRESS 8 +#define ACPI_EXD_STRING 9 +#define ACPI_EXD_BUFFER 10 +#define ACPI_EXD_PACKAGE 11 +#define ACPI_EXD_FIELD 12 +#define ACPI_EXD_REFERENCE 13 + +/* restore default alignment */ + +#pragma pack() + + +/* + * exconvrt - object conversion + */ +ACPI_STATUS +AcpiExConvertToInteger ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Flags); + +ACPI_STATUS +AcpiExConvertToBuffer ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + +ACPI_STATUS +AcpiExConvertToString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Type); + +/* Types for ->String conversion */ + +#define ACPI_EXPLICIT_BYTE_COPY 0x00000000 +#define ACPI_EXPLICIT_CONVERT_HEX 0x00000001 +#define ACPI_IMPLICIT_CONVERT_HEX 0x00000002 +#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003 + +ACPI_STATUS +AcpiExConvertToTargetType ( + ACPI_OBJECT_TYPE DestinationType, + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * exfield - ACPI AML (p-code) execution - field manipulation + */ +ACPI_STATUS +AcpiExCommonBufferSetup ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 BufferLength, + UINT32 *DatumCount); + +ACPI_STATUS +AcpiExWriteWithUpdateRule ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Mask, + ACPI_INTEGER FieldValue, + UINT32 FieldDatumByteOffset); + +void +AcpiExGetBufferDatum( + ACPI_INTEGER *Datum, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteGranularity, + UINT32 BufferOffset); + +void +AcpiExSetBufferDatum ( + ACPI_INTEGER MergedDatum, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteGranularity, + UINT32 BufferOffset); + +ACPI_STATUS +AcpiExReadDataFromField ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **RetBufferDesc); + +ACPI_STATUS +AcpiExWriteDataToField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + + +/* + * exfldio - low level field I/O + */ +ACPI_STATUS +AcpiExExtractFromField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); + +ACPI_STATUS +AcpiExInsertIntoField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); + +ACPI_STATUS +AcpiExAccessRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); + + +/* + * exmisc - misc support routines + */ +ACPI_STATUS +AcpiExGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult); + +ACPI_STATUS +AcpiExDoLogicalOp ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult); + +ACPI_INTEGER +AcpiExDoMathOp ( + UINT16 Opcode, + ACPI_INTEGER Operand0, + ACPI_INTEGER Operand1); + +ACPI_STATUS +AcpiExCreateMutex ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateProcessor ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreatePowerResource ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateRegion ( + UINT8 *AmlStart, + UINT32 AmlLength, + UINT8 RegionSpace, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateEvent ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateAlias ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateMethod ( + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_WALK_STATE *WalkState); + + +/* + * exconfig - dynamic table load/unload + */ +ACPI_STATUS +AcpiExLoadOp ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *Target, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExLoadTableOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiExUnloadTable ( + ACPI_OPERAND_OBJECT *DdbHandle); + + +/* + * exmutex - mutex support + */ +ACPI_STATUS +AcpiExAcquireMutex ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExAcquireMutexObject ( + UINT16 Timeout, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_ID ThreadId); + +ACPI_STATUS +AcpiExReleaseMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExReleaseMutexObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiExReleaseAllMutexes ( + ACPI_THREAD_STATE *Thread); + +void +AcpiExUnlinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* + * exprep - ACPI AML execution - prep utilities + */ +ACPI_STATUS +AcpiExPrepCommonFieldObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldBitPosition, + UINT32 FieldBitLength); + +ACPI_STATUS +AcpiExPrepFieldValue ( + ACPI_CREATE_FIELD_INFO *Info); + + +/* + * exsystem - Interface to OS services + */ +ACPI_STATUS +AcpiExSystemDoNotifyOp ( + ACPI_OPERAND_OBJECT *Value, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemDoSuspend( + ACPI_INTEGER Time); + +ACPI_STATUS +AcpiExSystemDoStall ( + UINT32 Time); + +ACPI_STATUS +AcpiExSystemSignalEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemWaitEvent( + ACPI_OPERAND_OBJECT *Time, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemResetEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemWaitSemaphore ( + ACPI_SEMAPHORE Semaphore, + UINT16 Timeout); + +ACPI_STATUS +AcpiExSystemWaitMutex ( + ACPI_MUTEX Mutex, + UINT16 Timeout); + +/* + * exoparg1 - ACPI AML execution, 1 operand + */ +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_1T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_1T_0R ( + ACPI_WALK_STATE *WalkState); + +/* + * exoparg2 - ACPI AML execution, 2 operands + */ +ACPI_STATUS +AcpiExOpcode_2A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_1T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_2T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exoparg3 - ACPI AML execution, 3 operands + */ +ACPI_STATUS +AcpiExOpcode_3A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_3A_1T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exoparg6 - ACPI AML execution, 6 operands + */ +ACPI_STATUS +AcpiExOpcode_6A_0T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exresolv - Object resolution and get value functions + */ +ACPI_STATUS +AcpiExResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExResolveMultiple ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *Operand, + ACPI_OBJECT_TYPE *ReturnType, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * exresnte - resolve namespace node + */ +ACPI_STATUS +AcpiExResolveNodeToValue ( + ACPI_NAMESPACE_NODE **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/* + * exresop - resolve operand to value + */ +ACPI_STATUS +AcpiExResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/* + * exdump - Interpreter debug output routines + */ +void +AcpiExDumpOperand ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth); + +void +AcpiExDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + const char *OpcodeName, + UINT32 NumOpcodes); + +void +AcpiExDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Flags); + +void +AcpiExDumpNamespaceNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags); + + +/* + * exnames - AML namestring support + */ +ACPI_STATUS +AcpiExGetNameString ( + ACPI_OBJECT_TYPE DataType, + UINT8 *InAmlAddress, + char **OutNameString, + UINT32 *OutNameLength); + + +/* + * exstore - Object store support + */ +ACPI_STATUS +AcpiExStore ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExStoreObjectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState, + UINT8 ImplicitConversion); + +#define ACPI_IMPLICIT_CONVERSION TRUE +#define ACPI_NO_IMPLICIT_CONVERSION FALSE + + +/* + * exstoren - resolve/store object + */ +ACPI_STATUS +AcpiExResolveObject ( + ACPI_OPERAND_OBJECT **SourceDescPtr, + ACPI_OBJECT_TYPE TargetType, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExStoreObjectToObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_OPERAND_OBJECT **NewDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * exstorob - store object - buffer/string + */ +ACPI_STATUS +AcpiExStoreBufferToBuffer ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExStoreStringToString ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + + +/* + * excopy - object copy + */ +ACPI_STATUS +AcpiExCopyIntegerToIndexField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExCopyIntegerToBankField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExCopyDataToNamedField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiExCopyIntegerToBufferField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + + +/* + * exutils - interpreter/scanner utilities + */ +void +AcpiExEnterInterpreter ( + void); + +void +AcpiExExitInterpreter ( + void); + +void +AcpiExReacquireInterpreter ( + void); + +void +AcpiExRelinquishInterpreter ( + void); + +void +AcpiExTruncateFor32bitTable ( + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiExAcquireGlobalLock ( + UINT32 Rule); + +void +AcpiExReleaseGlobalLock ( + UINT32 Rule); + +void +AcpiExEisaIdToString ( + char *Dest, + ACPI_INTEGER CompressedId); + +void +AcpiExIntegerToString ( + char *Dest, + ACPI_INTEGER Value); + + +/* + * exregion - default OpRegion handlers + */ +ACPI_STATUS +AcpiExSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExSystemIoSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExPciConfigSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExCmosSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExPciBarSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExEmbeddedControllerSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExSmBusSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + + +ACPI_STATUS +AcpiExDataTableSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +#endif /* __INTERP_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/aclocal.h b/reactos/drivers/bus/acpi/acpica/include/aclocal.h new file mode 100644 index 00000000000..52dbec3a6dc --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/aclocal.h @@ -0,0 +1,1332 @@ +/****************************************************************************** + * + * Name: aclocal.h - Internal data types used across the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACLOCAL_H__ +#define __ACLOCAL_H__ + + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +#define ACPI_SERIALIZED 0xFF + +typedef UINT32 ACPI_MUTEX_HANDLE; +#define ACPI_GLOBAL_LOCK (ACPI_SEMAPHORE) (-1) + +/* Total number of aml opcodes defined */ + +#define AML_NUM_OPCODES 0x7F + + +/* Forward declarations */ + +struct acpi_walk_state; +struct acpi_obj_mutex; +union acpi_parse_object; + + +/***************************************************************************** + * + * Mutex typedefs and structs + * + ****************************************************************************/ + + +/* + * Predefined handles for the mutex objects used within the subsystem + * All mutex objects are automatically created by AcpiUtMutexInitialize. + * + * The acquire/release ordering protocol is implied via this list. Mutexes + * with a lower value must be acquired before mutexes with a higher value. + * + * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames + * table below also! + */ +#define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */ +#define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */ +#define ACPI_MTX_TABLES 2 /* Data for ACPI tables */ +#define ACPI_MTX_EVENTS 3 /* Data for ACPI events */ +#define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */ +#define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */ +#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */ +#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */ + +#define ACPI_MAX_MUTEX 7 +#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#ifdef DEFINE_ACPI_GLOBALS + +/* Debug names for the mutexes above */ + +static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = +{ + "ACPI_MTX_Interpreter", + "ACPI_MTX_Namespace", + "ACPI_MTX_Tables", + "ACPI_MTX_Events", + "ACPI_MTX_Caches", + "ACPI_MTX_Memory", + "ACPI_MTX_CommandComplete", + "ACPI_MTX_CommandReady" +}; + +#endif +#endif + +/* Lock structure for reader/writer interfaces */ + +typedef struct acpi_rw_lock +{ + ACPI_MUTEX WriterMutex; + ACPI_MUTEX ReaderMutex; + UINT32 NumReaders; + +} ACPI_RW_LOCK; + + +/* + * Predefined handles for spinlocks used within the subsystem. + * These spinlocks are created by AcpiUtMutexInitialize + */ +#define ACPI_LOCK_GPES 0 +#define ACPI_LOCK_HARDWARE 1 + +#define ACPI_MAX_LOCK 1 +#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 + + +/* This Thread ID means that the mutex is not in use (unlocked) */ + +#define ACPI_MUTEX_NOT_ACQUIRED (ACPI_THREAD_ID) -1 + +/* Table for the global mutexes */ + +typedef struct acpi_mutex_info +{ + ACPI_MUTEX Mutex; + UINT32 UseCount; + ACPI_THREAD_ID ThreadId; + +} ACPI_MUTEX_INFO; + + +/* Lock flag parameter for various interfaces */ + +#define ACPI_MTX_DO_NOT_LOCK 0 +#define ACPI_MTX_LOCK 1 + + +/* Field access granularities */ + +#define ACPI_FIELD_BYTE_GRANULARITY 1 +#define ACPI_FIELD_WORD_GRANULARITY 2 +#define ACPI_FIELD_DWORD_GRANULARITY 4 +#define ACPI_FIELD_QWORD_GRANULARITY 8 + + +#define ACPI_ENTRY_NOT_FOUND NULL + + +/***************************************************************************** + * + * Namespace typedefs and structs + * + ****************************************************************************/ + +/* Operational modes of the AML interpreter/scanner */ + +typedef enum +{ + ACPI_IMODE_LOAD_PASS1 = 0x01, + ACPI_IMODE_LOAD_PASS2 = 0x02, + ACPI_IMODE_EXECUTE = 0x03 + +} ACPI_INTERPRETER_MODE; + + +/* + * The Namespace Node describes a named object that appears in the AML. + * DescriptorType is used to differentiate between internal descriptors. + * + * The node is optimized for both 32-bit and 64-bit platforms: + * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case. + * + * Note: The DescriptorType and Type fields must appear in the identical + * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT + * structures. + */ +typedef struct acpi_namespace_node +{ + union acpi_operand_object *Object; /* Interpreter object */ + UINT8 DescriptorType; /* Differentiate object descriptor types */ + UINT8 Type; /* ACPI Type associated with this name */ + UINT8 Flags; /* Miscellaneous flags */ + ACPI_OWNER_ID OwnerId; /* Node creator */ + ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ + struct acpi_namespace_node *Child; /* First child */ + struct acpi_namespace_node *Peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */ + + /* + * The following fields are used by the ASL compiler and disassembler only + */ +#ifdef ACPI_LARGE_NAMESPACE_NODE + union acpi_parse_object *Op; + UINT32 Value; + UINT32 Length; +#endif + +} ACPI_NAMESPACE_NODE; + + +/* Namespace Node flags */ + +#define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ +#define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */ +#define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ +#define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ +#define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */ +#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ +#define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (InstallMethod) */ + +#define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */ +#define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */ +#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */ +#define ANOBJ_IS_BIT_OFFSET 0x40 /* iASL only: Reference is a bit offset */ +#define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */ + + +/* One internal RSDT for table management */ + +typedef struct acpi_internal_rsdt +{ + ACPI_TABLE_DESC *Tables; + UINT32 Count; + UINT32 Size; + UINT8 Flags; + +} ACPI_INTERNAL_RSDT; + +/* Flags for above */ + +#define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */ +#define ACPI_ROOT_ORIGIN_ALLOCATED (1) +#define ACPI_ROOT_ALLOW_RESIZE (2) + + +/* Predefined (fixed) table indexes */ + +#define ACPI_TABLE_INDEX_DSDT (0) +#define ACPI_TABLE_INDEX_FACS (1) + + +typedef struct acpi_find_context +{ + char *SearchFor; + ACPI_HANDLE *List; + UINT32 *Count; + +} ACPI_FIND_CONTEXT; + + +typedef struct acpi_ns_search_data +{ + ACPI_NAMESPACE_NODE *Node; + +} ACPI_NS_SEARCH_DATA; + + +/* Object types used during package copies */ + +#define ACPI_COPY_TYPE_SIMPLE 0 +#define ACPI_COPY_TYPE_PACKAGE 1 + + +/* Info structure used to convert external<->internal namestrings */ + +typedef struct acpi_namestring_info +{ + const char *ExternalName; + const char *NextExternalChar; + char *InternalName; + UINT32 Length; + UINT32 NumSegments; + UINT32 NumCarats; + BOOLEAN FullyQualified; + +} ACPI_NAMESTRING_INFO; + + +/* Field creation info */ + +typedef struct acpi_create_field_info +{ + ACPI_NAMESPACE_NODE *RegionNode; + ACPI_NAMESPACE_NODE *FieldNode; + ACPI_NAMESPACE_NODE *RegisterNode; + ACPI_NAMESPACE_NODE *DataRegisterNode; + UINT32 BankValue; + UINT32 FieldBitPosition; + UINT32 FieldBitLength; + UINT8 FieldFlags; + UINT8 Attribute; + UINT8 FieldType; + +} ACPI_CREATE_FIELD_INFO; + + +typedef +ACPI_STATUS (*ACPI_INTERNAL_METHOD) ( + struct acpi_walk_state *WalkState); + + +/* + * Bitmapped ACPI types. Used internally only + */ +#define ACPI_BTYPE_ANY 0x00000000 +#define ACPI_BTYPE_INTEGER 0x00000001 +#define ACPI_BTYPE_STRING 0x00000002 +#define ACPI_BTYPE_BUFFER 0x00000004 +#define ACPI_BTYPE_PACKAGE 0x00000008 +#define ACPI_BTYPE_FIELD_UNIT 0x00000010 +#define ACPI_BTYPE_DEVICE 0x00000020 +#define ACPI_BTYPE_EVENT 0x00000040 +#define ACPI_BTYPE_METHOD 0x00000080 +#define ACPI_BTYPE_MUTEX 0x00000100 +#define ACPI_BTYPE_REGION 0x00000200 +#define ACPI_BTYPE_POWER 0x00000400 +#define ACPI_BTYPE_PROCESSOR 0x00000800 +#define ACPI_BTYPE_THERMAL 0x00001000 +#define ACPI_BTYPE_BUFFER_FIELD 0x00002000 +#define ACPI_BTYPE_DDB_HANDLE 0x00004000 +#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 +#define ACPI_BTYPE_REFERENCE 0x00010000 +#define ACPI_BTYPE_RESOURCE 0x00020000 + +#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) + +#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) +#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) +#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) +#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ +#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF + + +/* + * Information structure for ACPI predefined names. + * Each entry in the table contains the following items: + * + * Name - The ACPI reserved name + * ParamCount - Number of arguments to the method + * ExpectedReturnBtypes - Allowed type(s) for the return value + */ +typedef struct acpi_name_info +{ + char Name[ACPI_NAME_SIZE]; + UINT8 ParamCount; + UINT8 ExpectedBtypes; + +} ACPI_NAME_INFO; + +/* + * Secondary information structures for ACPI predefined objects that return + * package objects. This structure appears as the next entry in the table + * after the NAME_INFO structure above. + * + * The reason for this is to minimize the size of the predefined name table. + */ + +/* + * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2, + * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT + */ +typedef struct acpi_package_info +{ + UINT8 Type; + UINT8 ObjectType1; + UINT8 Count1; + UINT8 ObjectType2; + UINT8 Count2; + UINT8 Reserved; + +} ACPI_PACKAGE_INFO; + +/* Used for ACPI_PTYPE2_FIXED */ + +typedef struct acpi_package_info2 +{ + UINT8 Type; + UINT8 Count; + UINT8 ObjectType[4]; + +} ACPI_PACKAGE_INFO2; + +/* Used for ACPI_PTYPE1_OPTION */ + +typedef struct acpi_package_info3 +{ + UINT8 Type; + UINT8 Count; + UINT8 ObjectType[2]; + UINT8 TailObjectType; + UINT8 Reserved; + +} ACPI_PACKAGE_INFO3; + +typedef union acpi_predefined_info +{ + ACPI_NAME_INFO Info; + ACPI_PACKAGE_INFO RetInfo; + ACPI_PACKAGE_INFO2 RetInfo2; + ACPI_PACKAGE_INFO3 RetInfo3; + +} ACPI_PREDEFINED_INFO; + + +/* Data block used during object validation */ + +typedef struct acpi_predefined_data +{ + char *Pathname; + const ACPI_PREDEFINED_INFO *Predefined; + UINT32 Flags; + UINT8 NodeFlags; + +} ACPI_PREDEFINED_DATA; + +/* Defines for Flags field above */ + +#define ACPI_OBJECT_REPAIRED 1 + + +/* + * Bitmapped return value types + * Note: the actual data types must be contiguous, a loop in nspredef.c + * depends on this. + */ +#define ACPI_RTYPE_ANY 0x00 +#define ACPI_RTYPE_NONE 0x01 +#define ACPI_RTYPE_INTEGER 0x02 +#define ACPI_RTYPE_STRING 0x04 +#define ACPI_RTYPE_BUFFER 0x08 +#define ACPI_RTYPE_PACKAGE 0x10 +#define ACPI_RTYPE_REFERENCE 0x20 +#define ACPI_RTYPE_ALL 0x3F + +#define ACPI_NUM_RTYPES 5 /* Number of actual object types */ + + +/***************************************************************************** + * + * Event typedefs and structs + * + ****************************************************************************/ + +/* Dispatch info for each GPE -- either a method or handler, cannot be both */ + +typedef struct acpi_handler_info +{ + ACPI_EVENT_HANDLER Address; /* Address of handler, if any */ + void *Context; /* Context to be passed to handler */ + ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level (saved) */ + +} ACPI_HANDLER_INFO; + +typedef union acpi_gpe_dispatch_info +{ + ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level */ + struct acpi_handler_info *Handler; + +} ACPI_GPE_DISPATCH_INFO; + +/* + * Information about a GPE, one per each GPE in an array. + * NOTE: Important to keep this struct as small as possible. + */ +typedef struct acpi_gpe_event_info +{ + union acpi_gpe_dispatch_info Dispatch; /* Either Method or Handler */ + struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ + UINT8 Flags; /* Misc info about this GPE */ + UINT8 GpeNumber; /* This GPE */ + +} ACPI_GPE_EVENT_INFO; + +/* Information about a GPE register pair, one per each status/enable pair in an array */ + +typedef struct acpi_gpe_register_info +{ + ACPI_GENERIC_ADDRESS StatusAddress; /* Address of status reg */ + ACPI_GENERIC_ADDRESS EnableAddress; /* Address of enable reg */ + UINT8 EnableForWake; /* GPEs to keep enabled when sleeping */ + UINT8 EnableForRun; /* GPEs to keep enabled when running */ + UINT8 BaseGpeNumber; /* Base GPE number for this register */ + +} ACPI_GPE_REGISTER_INFO; + +/* + * Information about a GPE register block, one per each installed block -- + * GPE0, GPE1, and one per each installed GPE Block Device. + */ +typedef struct acpi_gpe_block_info +{ + ACPI_NAMESPACE_NODE *Node; + struct acpi_gpe_block_info *Previous; + struct acpi_gpe_block_info *Next; + struct acpi_gpe_xrupt_info *XruptBlock; /* Backpointer to interrupt block */ + ACPI_GPE_REGISTER_INFO *RegisterInfo; /* One per GPE register pair */ + ACPI_GPE_EVENT_INFO *EventInfo; /* One for each GPE */ + ACPI_GENERIC_ADDRESS BlockAddress; /* Base address of the block */ + UINT32 RegisterCount; /* Number of register pairs in block */ + UINT8 BlockBaseNumber;/* Base GPE number for this block */ + +} ACPI_GPE_BLOCK_INFO; + +/* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */ + +typedef struct acpi_gpe_xrupt_info +{ + struct acpi_gpe_xrupt_info *Previous; + struct acpi_gpe_xrupt_info *Next; + ACPI_GPE_BLOCK_INFO *GpeBlockListHead; /* List of GPE blocks for this xrupt */ + UINT32 InterruptNumber; /* System interrupt number */ + +} ACPI_GPE_XRUPT_INFO; + +typedef struct acpi_gpe_walk_info +{ + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_GPE_BLOCK_INFO *GpeBlock; + +} ACPI_GPE_WALK_INFO; + +typedef struct acpi_gpe_device_info +{ + UINT32 Index; + UINT32 NextBlockBaseIndex; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *GpeDevice; + +} ACPI_GPE_DEVICE_INFO; + +typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/* Information about each particular fixed event */ + +typedef struct acpi_fixed_event_handler +{ + ACPI_EVENT_HANDLER Handler; /* Address of handler. */ + void *Context; /* Context to be passed to handler */ + +} ACPI_FIXED_EVENT_HANDLER; + +typedef struct acpi_fixed_event_info +{ + UINT8 StatusRegisterId; + UINT8 EnableRegisterId; + UINT16 StatusBitMask; + UINT16 EnableBitMask; + +} ACPI_FIXED_EVENT_INFO; + +/* Information used during field processing */ + +typedef struct acpi_field_info +{ + UINT8 SkipField; + UINT8 FieldFlag; + UINT32 PkgLength; + +} ACPI_FIELD_INFO; + + +/***************************************************************************** + * + * Generic "state" object for stacks + * + ****************************************************************************/ + +#define ACPI_CONTROL_NORMAL 0xC0 +#define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1 +#define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2 +#define ACPI_CONTROL_PREDICATE_FALSE 0xC3 +#define ACPI_CONTROL_PREDICATE_TRUE 0xC4 + + +#define ACPI_STATE_COMMON \ + void *Next; \ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Flags; \ + UINT16 Value; \ + UINT16 State; + + /* There are 2 bytes available here until the next natural alignment boundary */ + +typedef struct acpi_common_state +{ + ACPI_STATE_COMMON +} ACPI_COMMON_STATE; + + +/* + * Update state - used to traverse complex objects such as packages + */ +typedef struct acpi_update_state +{ + ACPI_STATE_COMMON + union acpi_operand_object *Object; + +} ACPI_UPDATE_STATE; + + +/* + * Pkg state - used to traverse nested package structures + */ +typedef struct acpi_pkg_state +{ + ACPI_STATE_COMMON + UINT16 Index; + union acpi_operand_object *SourceObject; + union acpi_operand_object *DestObject; + struct acpi_walk_state *WalkState; + void *ThisTargetObj; + UINT32 NumPackages; + +} ACPI_PKG_STATE; + + +/* + * Control state - one per if/else and while constructs. + * Allows nesting of these constructs + */ +typedef struct acpi_control_state +{ + ACPI_STATE_COMMON + UINT16 Opcode; + union acpi_parse_object *PredicateOp; + UINT8 *AmlPredicateStart; /* Start of if/while predicate */ + UINT8 *PackageEnd; /* End of if/while block */ + UINT32 LoopCount; /* While() loop counter */ + +} ACPI_CONTROL_STATE; + + +/* + * Scope state - current scope during namespace lookups + */ +typedef struct acpi_scope_state +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *Node; + +} ACPI_SCOPE_STATE; + + +typedef struct acpi_pscope_state +{ + ACPI_STATE_COMMON + UINT32 ArgCount; /* Number of fixed arguments */ + union acpi_parse_object *Op; /* Current op being parsed */ + UINT8 *ArgEnd; /* Current argument end */ + UINT8 *PkgEnd; /* Current package end */ + UINT32 ArgList; /* Next argument to parse */ + +} ACPI_PSCOPE_STATE; + + +/* + * Thread state - one per thread across multiple walk states. Multiple walk + * states are created when there are nested control methods executing. + */ +typedef struct acpi_thread_state +{ + ACPI_STATE_COMMON + UINT8 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ + struct acpi_walk_state *WalkStateList; /* Head of list of WalkStates for this thread */ + union acpi_operand_object *AcquiredMutexList; /* List of all currently acquired mutexes */ + ACPI_THREAD_ID ThreadId; /* Running thread ID */ + +} ACPI_THREAD_STATE; + + +/* + * Result values - used to accumulate the results of nested + * AML arguments + */ +typedef struct acpi_result_values +{ + ACPI_STATE_COMMON + union acpi_operand_object *ObjDesc [ACPI_RESULTS_FRAME_OBJ_NUM]; + +} ACPI_RESULT_VALUES; + + +typedef +ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( + struct acpi_walk_state *WalkState, + union acpi_parse_object **OutOp); + +typedef +ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( + struct acpi_walk_state *WalkState); + + +/* + * Notify info - used to pass info to the deferred notify + * handler/dispatcher. + */ +typedef struct acpi_notify_info +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *Node; + union acpi_operand_object *HandlerObj; + +} ACPI_NOTIFY_INFO; + + +/* Generic state is union of structs above */ + +typedef union acpi_generic_state +{ + ACPI_COMMON_STATE Common; + ACPI_CONTROL_STATE Control; + ACPI_UPDATE_STATE Update; + ACPI_SCOPE_STATE Scope; + ACPI_PSCOPE_STATE ParseScope; + ACPI_PKG_STATE Pkg; + ACPI_THREAD_STATE Thread; + ACPI_RESULT_VALUES Results; + ACPI_NOTIFY_INFO Notify; + +} ACPI_GENERIC_STATE; + + +/***************************************************************************** + * + * Interpreter typedefs and structs + * + ****************************************************************************/ + +typedef +ACPI_STATUS (*ACPI_EXECUTE_OP) ( + struct acpi_walk_state *WalkState); + + +/***************************************************************************** + * + * Parser typedefs and structs + * + ****************************************************************************/ + +/* + * AML opcode, name, and argument layout + */ +typedef struct acpi_opcode_info +{ +#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) + char *Name; /* Opcode name (disassembler/debug only) */ +#endif + UINT32 ParseArgs; /* Grammar/Parse time arguments */ + UINT32 RuntimeArgs; /* Interpret time arguments */ + UINT16 Flags; /* Misc flags */ + UINT8 ObjectType; /* Corresponding internal object type */ + UINT8 Class; /* Opcode class */ + UINT8 Type; /* Opcode type */ + +} ACPI_OPCODE_INFO; + +typedef union acpi_parse_value +{ + ACPI_INTEGER Integer; /* Integer constant (Up to 64 bits) */ + UINT64_STRUCT Integer64; /* Structure overlay for 2 32-bit Dwords */ + UINT32 Size; /* bytelist or field size */ + char *String; /* NULL terminated string */ + UINT8 *Buffer; /* buffer or string */ + char *Name; /* NULL terminated string */ + union acpi_parse_object *Arg; /* arguments and contained ops */ + +} ACPI_PARSE_VALUE; + + +#ifdef ACPI_DISASSEMBLER +#define ACPI_DISASM_ONLY_MEMBERS(a) a; +#else +#define ACPI_DISASM_ONLY_MEMBERS(a) +#endif + +#define ACPI_PARSE_COMMON \ + union acpi_parse_object *Parent; /* Parent op */\ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Flags; /* Type of Op */\ + UINT16 AmlOpcode; /* AML opcode */\ + UINT32 AmlOffset; /* Offset of declaration in AML */\ + union acpi_parse_object *Next; /* Next op */\ + ACPI_NAMESPACE_NODE *Node; /* For use by interpreter */\ + ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ + UINT8 ArgListLength; /* Number of elements in the arg list */\ + ACPI_DISASM_ONLY_MEMBERS (\ + UINT8 DisasmFlags; /* Used during AML disassembly */\ + UINT8 DisasmOpcode; /* Subtype used for disassembly */\ + char AmlOpName[16]) /* Op name (debug only) */ + + +#define ACPI_DASM_BUFFER 0x00 +#define ACPI_DASM_RESOURCE 0x01 +#define ACPI_DASM_STRING 0x02 +#define ACPI_DASM_UNICODE 0x03 +#define ACPI_DASM_EISAID 0x04 +#define ACPI_DASM_MATCHOP 0x05 +#define ACPI_DASM_LNOT_PREFIX 0x06 +#define ACPI_DASM_LNOT_SUFFIX 0x07 +#define ACPI_DASM_IGNORE 0x08 + +/* + * Generic operation (for example: If, While, Store) + */ +typedef struct acpi_parse_obj_common +{ + ACPI_PARSE_COMMON +} ACPI_PARSE_OBJ_COMMON; + + +/* + * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions), + * and bytelists. + */ +typedef struct acpi_parse_obj_named +{ + ACPI_PARSE_COMMON + UINT8 *Path; + UINT8 *Data; /* AML body or bytelist data */ + UINT32 Length; /* AML length */ + UINT32 Name; /* 4-byte name or zero if no name */ + +} ACPI_PARSE_OBJ_NAMED; + + +/* This version is used by the iASL compiler only */ + +#define ACPI_MAX_PARSEOP_NAME 20 + +typedef struct acpi_parse_obj_asl +{ + ACPI_PARSE_COMMON + union acpi_parse_object *Child; + union acpi_parse_object *ParentMethod; + char *Filename; + char *ExternalName; + char *Namepath; + char NameSeg[4]; + UINT32 ExtraValue; + UINT32 Column; + UINT32 LineNumber; + UINT32 LogicalLineNumber; + UINT32 LogicalByteOffset; + UINT32 EndLine; + UINT32 EndLogicalLine; + UINT32 AcpiBtype; + UINT32 AmlLength; + UINT32 AmlSubtreeLength; + UINT32 FinalAmlLength; + UINT32 FinalAmlOffset; + UINT32 CompileFlags; + UINT16 ParseOpcode; + UINT8 AmlOpcodeLength; + UINT8 AmlPkgLenBytes; + UINT8 Extra; + char ParseOpName[ACPI_MAX_PARSEOP_NAME]; + +} ACPI_PARSE_OBJ_ASL; + +typedef union acpi_parse_object +{ + ACPI_PARSE_OBJ_COMMON Common; + ACPI_PARSE_OBJ_NAMED Named; + ACPI_PARSE_OBJ_ASL Asl; + +} ACPI_PARSE_OBJECT; + + +/* + * Parse state - one state per parser invocation and each control + * method. + */ +typedef struct acpi_parse_state +{ + UINT8 *AmlStart; /* First AML byte */ + UINT8 *Aml; /* Next AML byte */ + UINT8 *AmlEnd; /* (last + 1) AML byte */ + UINT8 *PkgStart; /* Current package begin */ + UINT8 *PkgEnd; /* Current package end */ + union acpi_parse_object *StartOp; /* Root of parse tree */ + struct acpi_namespace_node *StartNode; + union acpi_generic_state *Scope; /* Current scope */ + union acpi_parse_object *StartScope; + UINT32 AmlSize; + +} ACPI_PARSE_STATE; + + +/* Parse object flags */ + +#define ACPI_PARSEOP_GENERIC 0x01 +#define ACPI_PARSEOP_NAMED 0x02 +#define ACPI_PARSEOP_DEFERRED 0x04 +#define ACPI_PARSEOP_BYTELIST 0x08 +#define ACPI_PARSEOP_IN_STACK 0x10 +#define ACPI_PARSEOP_TARGET 0x20 +#define ACPI_PARSEOP_IN_CACHE 0x80 + +/* Parse object DisasmFlags */ + +#define ACPI_PARSEOP_IGNORE 0x01 +#define ACPI_PARSEOP_PARAMLIST 0x02 +#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 +#define ACPI_PARSEOP_SPECIAL 0x10 + + +/***************************************************************************** + * + * Hardware (ACPI registers) and PNP + * + ****************************************************************************/ + +typedef struct acpi_bit_register_info +{ + UINT8 ParentRegister; + UINT8 BitPosition; + UINT16 AccessBitMask; + +} ACPI_BIT_REGISTER_INFO; + + +/* + * Some ACPI registers have bits that must be ignored -- meaning that they + * must be preserved. + */ +#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ + +/* Write-only bits must be zeroed by software */ + +#define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */ + +/* For control registers, both ignored and reserved bits must be preserved */ + +/* + * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the + * ACPI specification to be a "preserved" bit - "OSPM always preserves this + * bit position", section 4.7.3.2.1. However, on some machines the OS must + * write a one to this bit after resume for the machine to work properly. + * To enable this, we no longer attempt to preserve this bit. No machines + * are known to fail if the bit is not preserved. (May 2009) + */ +#define ACPI_PM1_CONTROL_IGNORED_BITS 0x0200 /* Bit 9 */ +#define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */ +#define ACPI_PM1_CONTROL_PRESERVED_BITS \ + (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS) + +#define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */ + +/* + * Register IDs + * These are the full ACPI registers + */ +#define ACPI_REGISTER_PM1_STATUS 0x01 +#define ACPI_REGISTER_PM1_ENABLE 0x02 +#define ACPI_REGISTER_PM1_CONTROL 0x03 +#define ACPI_REGISTER_PM2_CONTROL 0x04 +#define ACPI_REGISTER_PM_TIMER 0x05 +#define ACPI_REGISTER_PROCESSOR_BLOCK 0x06 +#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07 + + +/* Masks used to access the BitRegisters */ + +#define ACPI_BITMASK_TIMER_STATUS 0x0001 +#define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010 +#define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020 +#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 +#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 +#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ +#define ACPI_BITMASK_WAKE_STATUS 0x8000 + +#define ACPI_BITMASK_ALL_FIXED_STATUS (\ + ACPI_BITMASK_TIMER_STATUS | \ + ACPI_BITMASK_BUS_MASTER_STATUS | \ + ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ + ACPI_BITMASK_POWER_BUTTON_STATUS | \ + ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ + ACPI_BITMASK_RT_CLOCK_STATUS | \ + ACPI_BITMASK_WAKE_STATUS) + +#define ACPI_BITMASK_TIMER_ENABLE 0x0001 +#define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020 +#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 +#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 +#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ + +#define ACPI_BITMASK_SCI_ENABLE 0x0001 +#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 +#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 +#define ACPI_BITMASK_SLEEP_TYPE 0x1C00 +#define ACPI_BITMASK_SLEEP_ENABLE 0x2000 + +#define ACPI_BITMASK_ARB_DISABLE 0x0001 + + +/* Raw bit position of each BitRegister */ + +#define ACPI_BITPOSITION_TIMER_STATUS 0x00 +#define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04 +#define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05 +#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 +#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 +#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ +#define ACPI_BITPOSITION_WAKE_STATUS 0x0F + +#define ACPI_BITPOSITION_TIMER_ENABLE 0x00 +#define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05 +#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 +#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 +#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ + +#define ACPI_BITPOSITION_SCI_ENABLE 0x00 +#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 +#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 +#define ACPI_BITPOSITION_SLEEP_TYPE 0x0A +#define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D + +#define ACPI_BITPOSITION_ARB_DISABLE 0x00 + + +/* Structs and definitions for _OSI support and I/O port validation */ + +#define ACPI_OSI_WIN_2000 0x01 +#define ACPI_OSI_WIN_XP 0x02 +#define ACPI_OSI_WIN_XP_SP1 0x03 +#define ACPI_OSI_WINSRV_2003 0x04 +#define ACPI_OSI_WIN_XP_SP2 0x05 +#define ACPI_OSI_WINSRV_2003_SP1 0x06 +#define ACPI_OSI_WIN_VISTA 0x07 +#define ACPI_OSI_WINSRV_2008 0x08 +#define ACPI_OSI_WIN_VISTA_SP1 0x09 +#define ACPI_OSI_WIN_7 0x0A + +#define ACPI_ALWAYS_ILLEGAL 0x00 + +typedef struct acpi_interface_info +{ + char *Name; + UINT8 Value; + +} ACPI_INTERFACE_INFO; + +typedef struct acpi_port_info +{ + char *Name; + UINT16 Start; + UINT16 End; + UINT8 OsiDependency; + +} ACPI_PORT_INFO; + + +/***************************************************************************** + * + * Resource descriptors + * + ****************************************************************************/ + +/* ResourceType values */ + +#define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0 +#define ACPI_ADDRESS_TYPE_IO_RANGE 1 +#define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2 + +/* Resource descriptor types and masks */ + +#define ACPI_RESOURCE_NAME_LARGE 0x80 +#define ACPI_RESOURCE_NAME_SMALL 0x00 + +#define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ +#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ +#define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ + + +/* + * Small resource descriptor "names" as defined by the ACPI specification. + * Note: Bits 2:0 are used for the descriptor length + */ +#define ACPI_RESOURCE_NAME_IRQ 0x20 +#define ACPI_RESOURCE_NAME_DMA 0x28 +#define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30 +#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 +#define ACPI_RESOURCE_NAME_IO 0x40 +#define ACPI_RESOURCE_NAME_FIXED_IO 0x48 +#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 +#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 +#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 +#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 +#define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70 +#define ACPI_RESOURCE_NAME_END_TAG 0x78 + +/* + * Large resource descriptor "names" as defined by the ACPI specification. + * Note: includes the Large Descriptor bit in bit[7] + */ +#define ACPI_RESOURCE_NAME_MEMORY24 0x81 +#define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82 +#define ACPI_RESOURCE_NAME_RESERVED_L1 0x83 +#define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84 +#define ACPI_RESOURCE_NAME_MEMORY32 0x85 +#define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86 +#define ACPI_RESOURCE_NAME_ADDRESS32 0x87 +#define ACPI_RESOURCE_NAME_ADDRESS16 0x88 +#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 +#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A +#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B +#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B + + +/***************************************************************************** + * + * Miscellaneous + * + ****************************************************************************/ + +#define ACPI_ASCII_ZERO 0x30 + + +/***************************************************************************** + * + * Disassembler + * + ****************************************************************************/ + +typedef struct acpi_external_list +{ + char *Path; + char *InternalPath; + struct acpi_external_list *Next; + UINT32 Value; + UINT16 Length; + UINT8 Type; + UINT8 Flags; + +} ACPI_EXTERNAL_LIST; + +/* Values for Flags field above */ + +#define ACPI_IPATH_ALLOCATED 0x01 + + +/***************************************************************************** + * + * Debugger + * + ****************************************************************************/ + +typedef struct acpi_db_method_info +{ + ACPI_HANDLE MainThreadGate; + ACPI_HANDLE ThreadCompleteGate; + ACPI_HANDLE InfoGate; + UINT32 *Threads; + UINT32 NumThreads; + UINT32 NumCreated; + UINT32 NumCompleted; + + char *Name; + UINT32 Flags; + UINT32 NumLoops; + char Pathname[128]; + char **Args; + + /* + * Arguments to be passed to method for the command + * Threads - + * the Number of threads, ID of current thread and + * Index of current thread inside all them created. + */ + char InitArgs; + char *Arguments[4]; + char NumThreadsStr[11]; + char IdOfThreadStr[11]; + char IndexOfThreadStr[11]; + +} ACPI_DB_METHOD_INFO; + +typedef struct acpi_integrity_info +{ + UINT32 Nodes; + UINT32 Objects; + +} ACPI_INTEGRITY_INFO; + + +#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 +#define ACPI_DB_CONSOLE_OUTPUT 0x02 +#define ACPI_DB_DUPLICATE_OUTPUT 0x03 + + +/***************************************************************************** + * + * Debug + * + ****************************************************************************/ + +/* Entry for a memory allocation (debug only) */ + +#define ACPI_MEM_MALLOC 0 +#define ACPI_MEM_CALLOC 1 +#define ACPI_MAX_MODULE_NAME 16 + +#define ACPI_COMMON_DEBUG_MEM_HEADER \ + struct acpi_debug_mem_block *Previous; \ + struct acpi_debug_mem_block *Next; \ + UINT32 Size; \ + UINT32 Component; \ + UINT32 Line; \ + char Module[ACPI_MAX_MODULE_NAME]; \ + UINT8 AllocType; + +typedef struct acpi_debug_mem_header +{ + ACPI_COMMON_DEBUG_MEM_HEADER + +} ACPI_DEBUG_MEM_HEADER; + +typedef struct acpi_debug_mem_block +{ + ACPI_COMMON_DEBUG_MEM_HEADER + UINT64 UserSpace; + +} ACPI_DEBUG_MEM_BLOCK; + + +#define ACPI_MEM_LIST_GLOBAL 0 +#define ACPI_MEM_LIST_NSNODE 1 +#define ACPI_MEM_LIST_MAX 1 +#define ACPI_NUM_MEM_LISTS 2 + + +#endif /* __ACLOCAL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acmacros.h b/reactos/drivers/bus/acpi/acpica/include/acmacros.h new file mode 100644 index 00000000000..3d351f9fc85 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acmacros.h @@ -0,0 +1,605 @@ +/****************************************************************************** + * + * Name: acmacros.h - C macros for the entire subsystem. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACMACROS_H__ +#define __ACMACROS_H__ + + +/* + * Extract data using a pointer. Any more than a byte and we + * get into potential aligment issues -- see the STORE macros below. + * Use with care. + */ +#define ACPI_GET8(ptr) *ACPI_CAST_PTR (UINT8, ptr) +#define ACPI_GET16(ptr) *ACPI_CAST_PTR (UINT16, ptr) +#define ACPI_GET32(ptr) *ACPI_CAST_PTR (UINT32, ptr) +#define ACPI_GET64(ptr) *ACPI_CAST_PTR (UINT64, ptr) +#define ACPI_SET8(ptr) *ACPI_CAST_PTR (UINT8, ptr) +#define ACPI_SET16(ptr) *ACPI_CAST_PTR (UINT16, ptr) +#define ACPI_SET32(ptr) *ACPI_CAST_PTR (UINT32, ptr) +#define ACPI_SET64(ptr) *ACPI_CAST_PTR (UINT64, ptr) + +/* + * printf() format helpers + */ + +/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */ + +#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i) + +#if ACPI_MACHINE_WIDTH == 64 +#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i) +#else +#define ACPI_FORMAT_NATIVE_UINT(i) 0, (i) +#endif + + +/* + * Macros for moving data around to/from buffers that are possibly unaligned. + * If the hardware supports the transfer of unaligned data, just do the store. + * Otherwise, we have to move one byte at a time. + */ +#ifdef ACPI_BIG_ENDIAN +/* + * Macros for big-endian machines + */ + +/* These macros reverse the bytes during the move, converting little-endian to big endian */ + + /* Big Endian <== Little Endian */ + /* Hi...Lo Lo...Hi */ +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_16_TO_32(d, s) {(*(UINT32 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_16_TO_64(d, s) {(*(UINT64 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_32_TO_32(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_32_TO_64(d, s) {(*(UINT64 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\ + ((UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\ + ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ + +#define ACPI_MOVE_64_TO_64(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[4];\ + (( UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} +#else +/* + * Macros for little-endian machines + */ + +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED + +/* The hardware supports unaligned transfers, just do the little-endian move */ + +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) *(UINT16 *)(void *)(d) = *(UINT16 *)(void *)(s) +#define ACPI_MOVE_16_TO_32(d, s) *(UINT32 *)(void *)(d) = *(UINT16 *)(void *)(s) +#define ACPI_MOVE_16_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT16 *)(void *)(s) + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_32_TO_32(d, s) *(UINT32 *)(void *)(d) = *(UINT32 *)(void *)(s) +#define ACPI_MOVE_32_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT32 *)(void *)(s) + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT64 *)(void *)(s) + +#else +/* + * The hardware does not support unaligned transfers. We must move the + * data one byte at a time. These macros work whether the source or + * the destination (or both) is/are unaligned. (Little-endian move) + */ + +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];} + +#define ACPI_MOVE_16_TO_32(d, s) {(*(UINT32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);} +#define ACPI_MOVE_16_TO_64(d, s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);} + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_32_TO_32(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];} + +#define ACPI_MOVE_32_TO_64(d, s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d, s);} + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_64(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[4];\ + (( UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[7];} +#endif +#endif + + +/* + * Fast power-of-two math macros for non-optimized compilers + */ +#define _ACPI_DIV(value, PowerOf2) ((UINT32) ((value) >> (PowerOf2))) +#define _ACPI_MUL(value, PowerOf2) ((UINT32) ((value) << (PowerOf2))) +#define _ACPI_MOD(value, Divisor) ((UINT32) ((value) & ((Divisor) -1))) + +#define ACPI_DIV_2(a) _ACPI_DIV(a, 1) +#define ACPI_MUL_2(a) _ACPI_MUL(a, 1) +#define ACPI_MOD_2(a) _ACPI_MOD(a, 2) + +#define ACPI_DIV_4(a) _ACPI_DIV(a, 2) +#define ACPI_MUL_4(a) _ACPI_MUL(a, 2) +#define ACPI_MOD_4(a) _ACPI_MOD(a, 4) + +#define ACPI_DIV_8(a) _ACPI_DIV(a, 3) +#define ACPI_MUL_8(a) _ACPI_MUL(a, 3) +#define ACPI_MOD_8(a) _ACPI_MOD(a, 8) + +#define ACPI_DIV_16(a) _ACPI_DIV(a, 4) +#define ACPI_MUL_16(a) _ACPI_MUL(a, 4) +#define ACPI_MOD_16(a) _ACPI_MOD(a, 16) + +#define ACPI_DIV_32(a) _ACPI_DIV(a, 5) +#define ACPI_MUL_32(a) _ACPI_MUL(a, 5) +#define ACPI_MOD_32(a) _ACPI_MOD(a, 32) + +/* + * Rounding macros (Power of two boundaries only) + */ +#define ACPI_ROUND_DOWN(value, boundary) (((ACPI_SIZE)(value)) & \ + (~(((ACPI_SIZE) boundary)-1))) + +#define ACPI_ROUND_UP(value, boundary) ((((ACPI_SIZE)(value)) + \ + (((ACPI_SIZE) boundary)-1)) & \ + (~(((ACPI_SIZE) boundary)-1))) + +/* Note: sizeof(ACPI_SIZE) evaluates to either 4 or 8 (32- vs 64-bit mode) */ + +#define ACPI_ROUND_DOWN_TO_32BIT(a) ACPI_ROUND_DOWN(a, 4) +#define ACPI_ROUND_DOWN_TO_64BIT(a) ACPI_ROUND_DOWN(a, 8) +#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a, sizeof(ACPI_SIZE)) + +#define ACPI_ROUND_UP_TO_32BIT(a) ACPI_ROUND_UP(a, 4) +#define ACPI_ROUND_UP_TO_64BIT(a) ACPI_ROUND_UP(a, 8) +#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a, sizeof(ACPI_SIZE)) + +#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) +#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) + +#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) + +/* Generic (non-power-of-two) rounding */ + +#define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary)) + +#define ACPI_IS_MISALIGNED(value) (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1)) + +/* + * Bitmask creation + * Bit positions start at zero. + * MASK_BITS_ABOVE creates a mask starting AT the position and above + * MASK_BITS_BELOW creates a mask starting one bit BELOW the position + */ +#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((UINT32) (position)))) +#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((UINT32) (position))) + +/* Bitfields within ACPI registers */ + +#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) ((Val << Pos) & Mask) +#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) + +#define ACPI_INSERT_BITS(Target, Mask, Source) Target = ((Target & (~(Mask))) | (Source & Mask)) + +/* + * An ACPI_NAMESPACE_NODE can appear in some contexts + * where a pointer to an ACPI_OPERAND_OBJECT can also + * appear. This macro is used to distinguish them. + * + * The "Descriptor" field is the first field in both structures. + */ +#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType) +#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType = t) + +/* + * Macros for the master AML opcode table + */ +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) +#define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \ + {Name, (UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type} +#else +#define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \ + {(UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type} +#endif + +#define ARG_TYPE_WIDTH 5 +#define ARG_1(x) ((UINT32)(x)) +#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH)) +#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH)) +#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH)) +#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH)) +#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH)) + +#define ARGI_LIST1(a) (ARG_1(a)) +#define ARGI_LIST2(a, b) (ARG_1(b)|ARG_2(a)) +#define ARGI_LIST3(a, b, c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) +#define ARGI_LIST4(a, b, c, d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) +#define ARGI_LIST5(a, b, c, d, e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) +#define ARGI_LIST6(a, b, c, d, e, f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) + +#define ARGP_LIST1(a) (ARG_1(a)) +#define ARGP_LIST2(a, b) (ARG_1(a)|ARG_2(b)) +#define ARGP_LIST3(a, b, c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) +#define ARGP_LIST4(a, b, c, d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) +#define ARGP_LIST5(a, b, c, d, e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) +#define ARGP_LIST6(a, b, c, d, e, f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) + +#define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F)) +#define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH)) + +/* + * Ascii error messages can be configured out + */ +#ifndef ACPI_NO_ERROR_MESSAGES +/* + * Error reporting. Callers module and line number are inserted by AE_INFO, + * the plist contains a set of parens to allow variable-length lists. + * These macros are used for both the debug and non-debug versions of the code. + */ +#define ACPI_ERROR_NAMESPACE(s, e) AcpiNsReportError (AE_INFO, s, e); +#define ACPI_ERROR_METHOD(s, n, p, e) AcpiNsReportMethodError (AE_INFO, s, n, p, e); +#define ACPI_WARN_PREDEFINED(plist) AcpiUtPredefinedWarning plist +#define ACPI_INFO_PREDEFINED(plist) AcpiUtPredefinedInfo plist + +#else + +/* No error messages */ + +#define ACPI_ERROR_NAMESPACE(s, e) +#define ACPI_ERROR_METHOD(s, n, p, e) +#define ACPI_WARN_PREDEFINED(plist) +#define ACPI_INFO_PREDEFINED(plist) + +#endif /* ACPI_NO_ERROR_MESSAGES */ + +/* + * Debug macros that are conditionally compiled + */ +#ifdef ACPI_DEBUG_OUTPUT +/* + * Function entry tracing + */ +#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ + AcpiUtTrace(ACPI_DEBUG_PARAMETERS) +#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTracePtr(ACPI_DEBUG_PARAMETERS, (void *)b) +#define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTraceU32(ACPI_DEBUG_PARAMETERS, (UINT32)b) +#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTraceStr(ACPI_DEBUG_PARAMETERS, (char *)b) + +#define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() + +/* + * Function exit tracing. + * WARNING: These macros include a return statement. This is usually considered + * bad form, but having a separate exit macro is very ugly and difficult to maintain. + * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros + * so that "_AcpiFunctionName" is defined. + * + * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining + * about these constructs. + */ +#ifdef ACPI_USE_DO_WHILE_0 +#define ACPI_DO_WHILE0(a) do a while(0) +#else +#define ACPI_DO_WHILE0(a) a +#endif + +#define return_VOID ACPI_DO_WHILE0 ({ \ + AcpiUtExit (ACPI_DEBUG_PARAMETERS); \ + return;}) +/* + * There are two versions of most of the return macros. The default version is + * safer, since it avoids side-effects by guaranteeing that the argument will + * not be evaluated twice. + * + * A less-safe version of the macros is provided for optional use if the + * compiler uses excessive CPU stack (for example, this may happen in the + * debug case if code optimzation is disabled.) + */ +#ifndef ACPI_SIMPLE_RETURN_MACROS + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + register ACPI_STATUS _s = (s); \ + AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + register void *_s = (void *) (s); \ + AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) _s); \ + return (_s); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + register ACPI_INTEGER _s = (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_UINT8(s) ACPI_DO_WHILE0 ({ \ + register UINT8 _s = (UINT8) (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + return (_s); }) +#define return_UINT32(s) ACPI_DO_WHILE0 ({ \ + register UINT32 _s = (UINT32) (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + return (_s); }) +#else /* Use original less-safe macros */ + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, (s)); \ + return((s)); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) (s)); \ + return((s)); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) (s)); \ + return((s)); }) +#define return_UINT8(s) return_VALUE(s) +#define return_UINT32(s) return_VALUE(s) + +#endif /* ACPI_SIMPLE_RETURN_MACROS */ + + +/* Conditional execution */ + +#define ACPI_DEBUG_EXEC(a) a +#define ACPI_DEBUG_ONLY_MEMBERS(a) a; +#define _VERBOSE_STRUCTURES + + +/* Various object display routines for debug */ + +#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand((a), 0) +#define ACPI_DUMP_OPERANDS(a, b ,c) AcpiExDumpOperands(a, b, c) +#define ACPI_DUMP_ENTRY(a, b) AcpiNsDumpEntry (a, b) +#define ACPI_DUMP_PATHNAME(a, b, c, d) AcpiNsDumpPathname(a, b, c, d) +#define ACPI_DUMP_BUFFER(a, b) AcpiUtDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ +#define ACPI_DEBUG_EXEC(a) +#define ACPI_DEBUG_ONLY_MEMBERS(a) +#define ACPI_FUNCTION_TRACE(a) +#define ACPI_FUNCTION_TRACE_PTR(a, b) +#define ACPI_FUNCTION_TRACE_U32(a, b) +#define ACPI_FUNCTION_TRACE_STR(a, b) +#define ACPI_FUNCTION_EXIT +#define ACPI_FUNCTION_STATUS_EXIT(s) +#define ACPI_FUNCTION_VALUE_EXIT(s) +#define ACPI_FUNCTION_ENTRY() +#define ACPI_DUMP_STACK_ENTRY(a) +#define ACPI_DUMP_OPERANDS(a, b, c) +#define ACPI_DUMP_ENTRY(a, b) +#define ACPI_DUMP_TABLES(a, b) +#define ACPI_DUMP_PATHNAME(a, b, c, d) +#define ACPI_DUMP_BUFFER(a, b) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) + +#define return_VOID return +#define return_ACPI_STATUS(s) return(s) +#define return_VALUE(s) return(s) +#define return_UINT8(s) return(s) +#define return_UINT32(s) return(s) +#define return_PTR(s) return(s) + +#endif /* ACPI_DEBUG_OUTPUT */ + +/* + * Some code only gets executed when the debugger is built in. + * Note that this is entirely independent of whether the + * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not. + */ +#ifdef ACPI_DEBUGGER +#define ACPI_DEBUGGER_EXEC(a) a +#else +#define ACPI_DEBUGGER_EXEC(a) +#endif + + +/* + * Memory allocation tracking (DEBUG ONLY) + */ +#define ACPI_MEM_PARAMETERS _COMPONENT, _AcpiModuleName, __LINE__ + +#ifndef ACPI_DBG_TRACK_ALLOCATIONS + +/* Memory allocation */ + +#define ACPI_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroed((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_FREE(a) AcpiOsFree(a) +#define ACPI_MEM_TRACKING(a) + +#else + +/* Memory allocation */ + +#define ACPI_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroedAndTrack((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_FREE(a) AcpiUtFreeAndTrack(a, ACPI_MEM_PARAMETERS) +#define ACPI_MEM_TRACKING(a) a + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + + +/* + * Macros used for ACPICA utilities only + */ + +/* Generate a UUID */ + +#define ACPI_INIT_UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ + (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \ + (b) & 0xFF, ((b) >> 8) & 0xFF, \ + (c) & 0xFF, ((c) >> 8) & 0xFF, \ + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) + +#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) + + +#endif /* ACMACROS_H */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acnames.h b/reactos/drivers/bus/acpi/acpica/include/acnames.h new file mode 100644 index 00000000000..eb9944aa16e --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acnames.h @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * Name: acnames.h - Global names and strings + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNAMES_H__ +#define __ACNAMES_H__ + +/* Method names - these methods can appear anywhere in the namespace */ + +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__CID "_CID" +#define METHOD_NAME__UID "_UID" +#define METHOD_NAME__ADR "_ADR" +#define METHOD_NAME__INI "_INI" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__BBN "_BBN" +#define METHOD_NAME__PRT "_PRT" +#define METHOD_NAME__CRS "_CRS" +#define METHOD_NAME__PRS "_PRS" +#define METHOD_NAME__PRW "_PRW" +#define METHOD_NAME__SRS "_SRS" + +/* Method names - these methods must appear at the namespace root */ + +#define METHOD_NAME__BFS "\\_BFS" +#define METHOD_NAME__GTS "\\_GTS" +#define METHOD_NAME__PTS "\\_PTS" +#define METHOD_NAME__SST "\\_SI._SST" +#define METHOD_NAME__WAK "\\_WAK" + +/* Definitions of the predefined namespace names */ + +#define ACPI_UNKNOWN_NAME (UINT32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (UINT32) 0x5F5F5F5C /* Root name is "\___" */ + +#define ACPI_PREFIX_MIXED (UINT32) 0x69706341 /* "Acpi" */ +#define ACPI_PREFIX_LOWER (UINT32) 0x69706361 /* "acpi" */ + +#define ACPI_NS_ROOT_PATH "\\" +#define ACPI_NS_SYSTEM_BUS "_SB_" + +#endif /* __ACNAMES_H__ */ + + diff --git a/reactos/drivers/bus/acpi/acpica/include/acnamesp.h b/reactos/drivers/bus/acpi/acpica/include/acnamesp.h new file mode 100644 index 00000000000..65798662d59 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acnamesp.h @@ -0,0 +1,566 @@ +/****************************************************************************** + * + * Name: acnamesp.h - Namespace subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNAMESP_H__ +#define __ACNAMESP_H__ + + +/* To search the entire name space, pass this as SearchBase */ + +#define ACPI_NS_ALL ((ACPI_HANDLE)0) + +/* + * Elements of AcpiNsProperties are bit significant + * and should be one-to-one with values of ACPI_OBJECT_TYPE + */ +#define ACPI_NS_NORMAL 0 +#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ +#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ + +/* Flags for AcpiNsLookup, AcpiNsSearchAndEnter */ + +#define ACPI_NS_NO_UPSEARCH 0 +#define ACPI_NS_SEARCH_PARENT 0x01 +#define ACPI_NS_DONT_OPEN_SCOPE 0x02 +#define ACPI_NS_NO_PEER_SEARCH 0x04 +#define ACPI_NS_ERROR_IF_FOUND 0x08 +#define ACPI_NS_PREFIX_IS_SCOPE 0x10 +#define ACPI_NS_EXTERNAL 0x20 +#define ACPI_NS_TEMPORARY 0x40 + +/* Flags for AcpiNsWalkNamespace */ + +#define ACPI_NS_WALK_NO_UNLOCK 0 +#define ACPI_NS_WALK_UNLOCK 0x01 +#define ACPI_NS_WALK_TEMP_NODES 0x02 + +/* Object is not a package element */ + +#define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX + +/* Always emit warning message, not dependent on node flags */ + +#define ACPI_WARN_ALWAYS 0 + + +/* + * nsinit - Namespace initialization + */ +ACPI_STATUS +AcpiNsInitializeObjects ( + void); + +ACPI_STATUS +AcpiNsInitializeDevices ( + void); + + +/* + * nsload - Namespace loading + */ +ACPI_STATUS +AcpiNsLoadNamespace ( + void); + +ACPI_STATUS +AcpiNsLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *Node); + + +/* + * nswalk - walk the namespace + */ +ACPI_STATUS +AcpiNsWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + UINT32 Flags, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue); + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNode ( + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNodeTyped ( + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); + +/* + * nsparse - table parsing + */ +ACPI_STATUS +AcpiNsParseTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + + +/* + * nsaccess - Top-level namespace access + */ +ACPI_STATUS +AcpiNsRootInitialize ( + void); + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + char *Name, + ACPI_OBJECT_TYPE Type, + ACPI_INTERPRETER_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **RetNode); + + +/* + * nsalloc - Named object allocation/deallocation + */ +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 Name); + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentHandle); + +void +AcpiNsDeleteNamespaceByOwner ( + ACPI_OWNER_ID OwnerId); + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *Parent); + +int +AcpiNsCompareNames ( + char *Name1, + char *Name2); + + +/* + * nsdump - Namespace dump/print utilities + */ +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth); + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel); + +void +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + char *Msg, + UINT32 Level, + UINT32 Component); + +void +AcpiNsPrintPathname ( + UINT32 NumSegments, + char *Pathname); + +ACPI_STATUS +AcpiNsDumpOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +void +AcpiNsDumpObjects ( + ACPI_OBJECT_TYPE Type, + UINT8 DisplayType, + UINT32 MaxDepth, + ACPI_OWNER_ID OwnerId, + ACPI_HANDLE StartHandle); + + +/* + * nseval - Namespace evaluation functions + */ +ACPI_STATUS +AcpiNsEvaluate ( + ACPI_EVALUATE_INFO *Info); + +void +AcpiNsExecModuleCodeList ( + void); + + +/* + * nspredef - Support for predefined/reserved names + */ +ACPI_STATUS +AcpiNsCheckPredefinedNames ( + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObject); + +const ACPI_PREDEFINED_INFO * +AcpiNsCheckForPredefinedName ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsCheckParameterCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Info); + + +/* + * nsnames - Name and Scope manipulation + */ +UINT32 +AcpiNsOpensScope ( + ACPI_OBJECT_TYPE Type); + +ACPI_STATUS +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer); + +char * +AcpiNsGetExternalPathname ( + ACPI_NAMESPACE_NODE *Node); + +char * +AcpiNsNameOfCurrentScope ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer); + +BOOLEAN +AcpiNsPatternMatch ( + ACPI_NAMESPACE_NODE *ObjNode, + char *SearchFor); + +ACPI_STATUS +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, + const char *ExternalPathname, + UINT32 Flags, + ACPI_NAMESPACE_NODE **OutNode); + +ACPI_SIZE +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node); + + +/* + * nsobject - Object management for namespace nodes + */ +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + ACPI_OBJECT_TYPE Type); + +ACPI_OPERAND_OBJECT * +AcpiNsGetAttachedObject ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_OPERAND_OBJECT * +AcpiNsGetSecondaryObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiNsAttachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void *Data); + +ACPI_STATUS +AcpiNsDetachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler); + +ACPI_STATUS +AcpiNsGetAttachedData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void **Data); + + +/* + * nsrepair - General return object repair for all + * predefined methods/objects + */ +ACPI_STATUS +AcpiNsRepairObject ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +ACPI_STATUS +AcpiNsRepairPackageList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ObjDescPtr); + + +/* + * nsrepair2 - Return object repair for specific + * predefined methods/objects + */ +ACPI_STATUS +AcpiNsComplexRepairs ( + ACPI_PREDEFINED_DATA *Data, + ACPI_NAMESPACE_NODE *Node, + ACPI_STATUS ValidateStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +void +AcpiNsRemoveNullElements ( + ACPI_PREDEFINED_DATA *Data, + UINT8 PackageType, + ACPI_OPERAND_OBJECT *ObjDesc); + +/* + * nssearch - Namespace searching and entry + */ +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 EntryName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_INTERPRETER_MODE InterpreterMode, + ACPI_OBJECT_TYPE Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **RetNode); + +ACPI_STATUS +AcpiNsSearchOneScope ( + UINT32 EntryName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **RetNode); + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type); + + +/* + * nsutils - Utility functions + */ +BOOLEAN +AcpiNsValidRootPrefix ( + char Prefix); + +ACPI_OBJECT_TYPE +AcpiNsGetType ( + ACPI_NAMESPACE_NODE *Node); + +UINT32 +AcpiNsLocal ( + ACPI_OBJECT_TYPE Type); + +void +AcpiNsReportError ( + const char *ModuleName, + UINT32 LineNumber, + const char *InternalName, + ACPI_STATUS LookupStatus); + +void +AcpiNsReportMethodError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Message, + ACPI_NAMESPACE_NODE *Node, + const char *Path, + ACPI_STATUS LookupStatus); + +void +AcpiNsPrintNodePathname ( + ACPI_NAMESPACE_NODE *Node, + const char *Msg); + +ACPI_STATUS +AcpiNsBuildInternalName ( + ACPI_NAMESTRING_INFO *Info); + +void +AcpiNsGetInternalNameLength ( + ACPI_NAMESTRING_INFO *Info); + +ACPI_STATUS +AcpiNsInternalizeName ( + const char *DottedName, + char **ConvertedName); + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + const char *InternalName, + UINT32 *ConvertedNameLength, + char **ConvertedName); + +ACPI_NAMESPACE_NODE * +AcpiNsValidateHandle ( + ACPI_HANDLE Handle); + +void +AcpiNsTerminate ( + void); + +ACPI_NAMESPACE_NODE * +AcpiNsGetParentNode ( + ACPI_NAMESPACE_NODE *Node); + + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextValidNode ( + ACPI_NAMESPACE_NODE *Node); + +#endif /* __ACNAMESP_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acobject.h b/reactos/drivers/bus/acpi/acpica/include/acobject.h new file mode 100644 index 00000000000..76f623c83db --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acobject.h @@ -0,0 +1,648 @@ + +/****************************************************************************** + * + * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACOBJECT_H +#define _ACOBJECT_H + +/* acpisrc:StructDefs -- for acpisrc conversion */ + + +/* + * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher + * to the interpreter, and to keep track of the various handlers such as + * address space handlers and notify handlers. The object is a constant + * size in order to allow it to be cached and reused. + * + * Note: The object is optimized to be aligned and will not work if it is + * byte-packed. + */ +#if ACPI_MACHINE_WIDTH == 64 +#pragma pack(8) +#else +#pragma pack(4) +#endif + +/******************************************************************************* + * + * Common Descriptors + * + ******************************************************************************/ + +/* + * Common area for all objects. + * + * DescriptorType is used to differentiate between internal descriptors, and + * must be in the same place across all descriptors + * + * Note: The DescriptorType and Type fields must appear in the identical + * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT + * structures. + */ +#define ACPI_OBJECT_COMMON_HEADER \ + union acpi_operand_object *NextObject; /* Objects linked to parent NS node */\ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Type; /* ACPI_OBJECT_TYPE */\ + UINT16 ReferenceCount; /* For object deletion management */\ + UINT8 Flags; + /* + * Note: There are 3 bytes available here before the + * next natural alignment boundary (for both 32/64 cases) + */ + +/* Values for Flag byte above */ + +#define AOPOBJ_AML_CONSTANT 0x01 +#define AOPOBJ_STATIC_POINTER 0x02 +#define AOPOBJ_DATA_VALID 0x04 +#define AOPOBJ_OBJECT_INITIALIZED 0x08 +#define AOPOBJ_SETUP_COMPLETE 0x10 +#define AOPOBJ_SINGLE_DATUM 0x20 +#define AOPOBJ_MODULE_LEVEL 0x40 + + +/****************************************************************************** + * + * Basic data types + * + *****************************************************************************/ + +typedef struct acpi_object_common +{ + ACPI_OBJECT_COMMON_HEADER + +} ACPI_OBJECT_COMMON; + + +typedef struct acpi_object_integer +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 Fill[3]; /* Prevent warning on some compilers */ + ACPI_INTEGER Value; + +} ACPI_OBJECT_INTEGER; + + +/* + * Note: The String and Buffer object must be identical through the Pointer + * and length elements. There is code that depends on this. + * + * Fields common to both Strings and Buffers + */ +#define ACPI_COMMON_BUFFER_INFO(_Type) \ + _Type *Pointer; \ + UINT32 Length; + + +typedef struct acpi_object_string /* Null terminated, ASCII characters only */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_BUFFER_INFO (char) /* String in AML stream or allocated string */ + +} ACPI_OBJECT_STRING; + + +typedef struct acpi_object_buffer +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_BUFFER_INFO (UINT8) /* Buffer in AML stream or allocated buffer */ + UINT32 AmlLength; + UINT8 *AmlStart; + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ + +} ACPI_OBJECT_BUFFER; + + +typedef struct acpi_object_package +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ + union acpi_operand_object **Elements; /* Array of pointers to AcpiObjects */ + UINT8 *AmlStart; + UINT32 AmlLength; + UINT32 Count; /* # of elements in package */ + +} ACPI_OBJECT_PACKAGE; + + +/****************************************************************************** + * + * Complex data types + * + *****************************************************************************/ + +typedef struct acpi_object_event +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_SEMAPHORE OsSemaphore; /* Actual OS synchronization object */ + +} ACPI_OBJECT_EVENT; + + +typedef struct acpi_object_mutex +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SyncLevel; /* 0-15, specified in Mutex() call */ + UINT16 AcquisitionDepth; /* Allow multiple Acquires, same thread */ + ACPI_MUTEX OsMutex; /* Actual OS synchronization object */ + ACPI_THREAD_ID ThreadId; /* Current owner of the mutex */ + struct acpi_thread_state *OwnerThread; /* Current owner of the mutex */ + union acpi_operand_object *Prev; /* Link for list of acquired mutexes */ + union acpi_operand_object *Next; /* Link for list of acquired mutexes */ + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + UINT8 OriginalSyncLevel; /* Owner's original sync level (0-15) */ + +} ACPI_OBJECT_MUTEX; + + +typedef struct acpi_object_region +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SpaceId; + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + union acpi_operand_object *Handler; /* Handler for region access */ + union acpi_operand_object *Next; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + +} ACPI_OBJECT_REGION; + + +typedef struct acpi_object_method +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 MethodFlags; + UINT8 ParamCount; + UINT8 SyncLevel; + union acpi_operand_object *Mutex; + UINT8 *AmlStart; + union + { + ACPI_INTERNAL_METHOD Implementation; + union acpi_operand_object *Handler; + } Extra; + + UINT32 AmlLength; + UINT8 ThreadCount; + ACPI_OWNER_ID OwnerId; + +} ACPI_OBJECT_METHOD; + + +/****************************************************************************** + * + * Objects that can be notified. All share a common NotifyInfo area. + * + *****************************************************************************/ + +/* + * Common fields for objects that support ASL notifications + */ +#define ACPI_COMMON_NOTIFY_INFO \ + union acpi_operand_object *SystemNotify; /* Handler for system notifies */\ + union acpi_operand_object *DeviceNotify; /* Handler for driver notifies */\ + union acpi_operand_object *Handler; /* Handler for Address space */ + + +typedef struct acpi_object_notify_common /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + +} ACPI_OBJECT_NOTIFY_COMMON; + + +typedef struct acpi_object_device +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + ACPI_GPE_BLOCK_INFO *GpeBlock; + +} ACPI_OBJECT_DEVICE; + + +typedef struct acpi_object_power_resource +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + UINT32 SystemLevel; + UINT32 ResourceOrder; + +} ACPI_OBJECT_POWER_RESOURCE; + + +typedef struct acpi_object_processor +{ + ACPI_OBJECT_COMMON_HEADER + + /* The next two fields take advantage of the 3-byte space before NOTIFY_INFO */ + + UINT8 ProcId; + UINT8 Length; + ACPI_COMMON_NOTIFY_INFO + ACPI_IO_ADDRESS Address; + +} ACPI_OBJECT_PROCESSOR; + + +typedef struct acpi_object_thermal_zone +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + +} ACPI_OBJECT_THERMAL_ZONE; + + +/****************************************************************************** + * + * Fields. All share a common header/info field. + * + *****************************************************************************/ + +/* + * Common bitfield for the field objects + * "Field Datum" -- a datum from the actual field object + * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field + */ +#define ACPI_COMMON_FIELD_INFO \ + UINT8 FieldFlags; /* Access, update, and lock bits */\ + UINT8 Attribute; /* From AccessAs keyword */\ + UINT8 AccessByteWidth; /* Read/Write size in bytes */\ + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */\ + UINT32 BitLength; /* Length of field in bits */\ + UINT32 BaseByteOffset; /* Byte offset within containing object */\ + UINT32 Value; /* Value to store into the Bank or Index register */\ + UINT8 StartFieldBitOffset;/* Bit offset within first field datum (0-63) */\ + UINT8 AccessBitWidth; /* Read/Write size in bits (8-64) */ + + +typedef struct acpi_object_field_common /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Parent Operation Region object (REGION/BANK fields only) */ + +} ACPI_OBJECT_FIELD_COMMON; + + +typedef struct acpi_object_region_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Containing OpRegion object */ + +} ACPI_OBJECT_REGION_FIELD; + + +typedef struct acpi_object_bank_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Containing OpRegion object */ + union acpi_operand_object *BankObj; /* BankSelect Register object */ + +} ACPI_OBJECT_BANK_FIELD; + + +typedef struct acpi_object_index_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + + /* + * No "RegionObj" pointer needed since the Index and Data registers + * are each field definitions unto themselves. + */ + union acpi_operand_object *IndexObj; /* Index register */ + union acpi_operand_object *DataObj; /* Data register */ + +} ACPI_OBJECT_INDEX_FIELD; + + +/* The BufferField is different in that it is part of a Buffer, not an OpRegion */ + +typedef struct acpi_object_buffer_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *BufferObj; /* Containing Buffer object */ + +} ACPI_OBJECT_BUFFER_FIELD; + + +/****************************************************************************** + * + * Objects for handlers + * + *****************************************************************************/ + +typedef struct acpi_object_notify_handler +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + ACPI_NOTIFY_HANDLER Handler; + void *Context; + +} ACPI_OBJECT_NOTIFY_HANDLER; + + +typedef struct acpi_object_addr_handler +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SpaceId; + UINT8 HandlerFlags; + ACPI_ADR_SPACE_HANDLER Handler; + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + void *Context; + ACPI_ADR_SPACE_SETUP Setup; + union acpi_operand_object *RegionList; /* regions using this handler */ + union acpi_operand_object *Next; + +} ACPI_OBJECT_ADDR_HANDLER; + +/* Flags for address handler (HandlerFlags) */ + +#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x01 + + +/****************************************************************************** + * + * Special internal objects + * + *****************************************************************************/ + +/* + * The Reference object is used for these opcodes: + * Arg[0-6], Local[0-7], IndexOp, NameOp, RefOfOp, LoadOp, LoadTableOp, DebugOp + * The Reference.Class differentiates these types. + */ +typedef struct acpi_object_reference +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 Class; /* Reference Class */ + UINT8 TargetType; /* Used for Index Op */ + UINT8 Reserved; + void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ + ACPI_NAMESPACE_NODE *Node; /* RefOf or Namepath */ + union acpi_operand_object **Where; /* Target of Index */ + UINT32 Value; /* Used for Local/Arg/Index/DdbHandle */ + +} ACPI_OBJECT_REFERENCE; + +/* Values for Reference.Class above */ + +typedef enum +{ + ACPI_REFCLASS_LOCAL = 0, /* Method local */ + ACPI_REFCLASS_ARG = 1, /* Method argument */ + ACPI_REFCLASS_REFOF = 2, /* Result of RefOf() TBD: Split to Ref/Node and Ref/OperandObj? */ + ACPI_REFCLASS_INDEX = 3, /* Result of Index() */ + ACPI_REFCLASS_TABLE = 4, /* DdbHandle - Load(), LoadTable() */ + ACPI_REFCLASS_NAME = 5, /* Reference to a named object */ + ACPI_REFCLASS_DEBUG = 6, /* Debug object */ + + ACPI_REFCLASS_MAX = 6 + +} ACPI_REFERENCE_CLASSES; + + +/* + * Extra object is used as additional storage for types that + * have AML code in their declarations (TermArgs) that must be + * evaluated at run time. + * + * Currently: Region and FieldUnit types + */ +typedef struct acpi_object_extra +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Method_REG; /* _REG method for this region (if any) */ + void *RegionContext; /* Region-specific data */ + UINT8 *AmlStart; + UINT32 AmlLength; + +} ACPI_OBJECT_EXTRA; + + +/* Additional data that can be attached to namespace nodes */ + +typedef struct acpi_object_data +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_OBJECT_HANDLER Handler; + void *Pointer; + +} ACPI_OBJECT_DATA; + + +/* Structure used when objects are cached for reuse */ + +typedef struct acpi_object_cache_list +{ + ACPI_OBJECT_COMMON_HEADER + union acpi_operand_object *Next; /* Link for object cache and internal lists*/ + +} ACPI_OBJECT_CACHE_LIST; + + +/****************************************************************************** + * + * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above + * + *****************************************************************************/ + +typedef union acpi_operand_object +{ + ACPI_OBJECT_COMMON Common; + ACPI_OBJECT_INTEGER Integer; + ACPI_OBJECT_STRING String; + ACPI_OBJECT_BUFFER Buffer; + ACPI_OBJECT_PACKAGE Package; + ACPI_OBJECT_EVENT Event; + ACPI_OBJECT_METHOD Method; + ACPI_OBJECT_MUTEX Mutex; + ACPI_OBJECT_REGION Region; + ACPI_OBJECT_NOTIFY_COMMON CommonNotify; + ACPI_OBJECT_DEVICE Device; + ACPI_OBJECT_POWER_RESOURCE PowerResource; + ACPI_OBJECT_PROCESSOR Processor; + ACPI_OBJECT_THERMAL_ZONE ThermalZone; + ACPI_OBJECT_FIELD_COMMON CommonField; + ACPI_OBJECT_REGION_FIELD Field; + ACPI_OBJECT_BUFFER_FIELD BufferField; + ACPI_OBJECT_BANK_FIELD BankField; + ACPI_OBJECT_INDEX_FIELD IndexField; + ACPI_OBJECT_NOTIFY_HANDLER Notify; + ACPI_OBJECT_ADDR_HANDLER AddressSpace; + ACPI_OBJECT_REFERENCE Reference; + ACPI_OBJECT_EXTRA Extra; + ACPI_OBJECT_DATA Data; + ACPI_OBJECT_CACHE_LIST Cache; + + /* + * Add namespace node to union in order to simplify code that accepts both + * ACPI_OPERAND_OBJECTs and ACPI_NAMESPACE_NODEs. The structures share + * a common DescriptorType field in order to differentiate them. + */ + ACPI_NAMESPACE_NODE Node; + +} ACPI_OPERAND_OBJECT; + + +/****************************************************************************** + * + * ACPI_DESCRIPTOR - objects that share a common descriptor identifier + * + *****************************************************************************/ + +/* Object descriptor types */ + +#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */ +#define ACPI_DESC_TYPE_STATE 0x02 +#define ACPI_DESC_TYPE_STATE_UPDATE 0x03 +#define ACPI_DESC_TYPE_STATE_PACKAGE 0x04 +#define ACPI_DESC_TYPE_STATE_CONTROL 0x05 +#define ACPI_DESC_TYPE_STATE_RPSCOPE 0x06 +#define ACPI_DESC_TYPE_STATE_PSCOPE 0x07 +#define ACPI_DESC_TYPE_STATE_WSCOPE 0x08 +#define ACPI_DESC_TYPE_STATE_RESULT 0x09 +#define ACPI_DESC_TYPE_STATE_NOTIFY 0x0A +#define ACPI_DESC_TYPE_STATE_THREAD 0x0B +#define ACPI_DESC_TYPE_WALK 0x0C +#define ACPI_DESC_TYPE_PARSER 0x0D +#define ACPI_DESC_TYPE_OPERAND 0x0E +#define ACPI_DESC_TYPE_NAMED 0x0F +#define ACPI_DESC_TYPE_MAX 0x0F + + +typedef struct acpi_common_descriptor +{ + void *CommonPointer; + UINT8 DescriptorType; /* To differentiate various internal objs */ + +} ACPI_COMMON_DESCRIPTOR; + +typedef union acpi_descriptor +{ + ACPI_COMMON_DESCRIPTOR Common; + ACPI_OPERAND_OBJECT Object; + ACPI_NAMESPACE_NODE Node; + ACPI_PARSE_OBJECT Op; + +} ACPI_DESCRIPTOR; + +#pragma pack() + +#endif /* _ACOBJECT_H */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acopcode.h b/reactos/drivers/bus/acpi/acpica/include/acopcode.h new file mode 100644 index 00000000000..bb309c78d3f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acopcode.h @@ -0,0 +1,397 @@ +/****************************************************************************** + * + * Name: acopcode.h - AML opcode information for the AML parser and interpreter + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOPCODE_H__ +#define __ACOPCODE_H__ + +#define MAX_EXTENDED_OPCODE 0x88 +#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1) +#define MAX_INTERNAL_OPCODE +#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1) + +/* Used for non-assigned opcodes */ + +#define _UNK 0x6B + +/* + * Reserved ASCII characters. Do not use any of these for + * internal opcodes, since they are used to differentiate + * name strings from AML opcodes + */ +#define _ASC 0x6C +#define _NAM 0x6C +#define _PFX 0x6D + + +/* + * All AML opcodes and the parse-time arguments for each. Used by the AML + * parser Each list is compressed into a 32-bit number and stored in the + * master opcode table (in psopcode.c). + */ +#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) +#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) +#define ARGP_ARG0 ARG_NONE +#define ARGP_ARG1 ARG_NONE +#define ARGP_ARG2 ARG_NONE +#define ARGP_ARG3 ARG_NONE +#define ARGP_ARG4 ARG_NONE +#define ARGP_ARG5 ARG_NONE +#define ARGP_ARG6 ARG_NONE +#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BREAK_OP ARG_NONE +#define ARGP_BREAK_POINT_OP ARG_NONE +#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) +#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) +#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) +#define ARGP_CONTINUE_OP ARG_NONE +#define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME) +#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DEBUG_OP ARG_NONE +#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) +#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) +#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) +#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) +#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) +#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) +#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOCAL0 ARG_NONE +#define ARGP_LOCAL1 ARG_NONE +#define ARGP_LOCAL2 ARG_NONE +#define ARGP_LOCAL3 ARG_NONE +#define ARGP_LOCAL4 ARG_NONE +#define ARGP_LOCAL5 ARG_NONE +#define ARGP_LOCAL6 ARG_NONE +#define ARGP_LOCAL7 ARG_NONE +#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) +#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) +#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) +#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NOOP_OP ARG_NONE +#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_ONE_OP ARG_NONE +#define ARGP_ONES_OP ARG_NONE +#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) +#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) +#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) +#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_REVISION_OP ARG_NONE +#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) +#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) +#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) +#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_TIMER_OP ARG_NONE +#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST) +#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) +#define ARGP_ZERO_OP ARG_NONE + + +/* + * All AML opcodes and the runtime arguments for each. Used by the AML + * interpreter Each list is compressed into a 32-bit number and stored + * in the master opcode table (in psopcode.c). + * + * (Used by PrepOperands procedure and the ASL Compiler) + */ +#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER) +#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE +#define ARGI_ARG0 ARG_NONE +#define ARGI_ARG1 ARG_NONE +#define ARGI_ARG2 ARG_NONE +#define ARGI_ARG3 ARG_NONE +#define ARGI_ARG4 ARG_NONE +#define ARGI_ARG5 ARG_NONE +#define ARGI_ARG6 ARG_NONE +#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BREAK_OP ARG_NONE +#define ARGI_BREAK_POINT_OP ARG_NONE +#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_BYTE_OP ARGI_INVALID_OPCODE +#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE +#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) +#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) +#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) +#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE +#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET) +#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING) +#define ARGI_DEBUG_OP ARG_NONE +#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_TARGETREF) +#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING) +#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE +#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF) +#define ARGI_DWORD_OP ARGI_INVALID_OPCODE +#define ARGI_ELSE_OP ARGI_INVALID_OPCODE +#define ARGI_EVENT_OP ARGI_INVALID_OPCODE +#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_IF_OP ARGI_INVALID_OPCODE +#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_TARGETREF) +#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_BUFFER,ARGI_TARGETREF) +#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE) +#define ARGI_LOCAL0 ARG_NONE +#define ARGI_LOCAL1 ARG_NONE +#define ARGI_LOCAL2 ARG_NONE +#define ARGI_LOCAL3 ARG_NONE +#define ARGI_LOCAL4 ARG_NONE +#define ARGI_LOCAL5 ARG_NONE +#define ARGI_LOCAL6 ARG_NONE +#define ARGI_LOCAL7 ARG_NONE +#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER) +#define ARGI_METHOD_OP ARGI_INVALID_OPCODE +#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE +#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE +#define ARGI_NAME_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE +#define ARGI_NOOP_OP ARG_NONE +#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER) +#define ARGI_ONE_OP ARG_NONE +#define ARGI_ONES_OP ARG_NONE +#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE +#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE +#define ARGI_QWORD_OP ARGI_INVALID_OPCODE +#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF) +#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) +#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_RETURN_OP ARGI_INVALID_OPCODE +#define ARGI_REVISION_OP ARG_NONE +#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE +#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) +#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE +#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF) +#define ARGI_STRING_OP ARGI_INVALID_OPCODE +#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE +#define ARGI_TIMER_OP ARG_NONE +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) +#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) +#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) +#define ARGI_WHILE_OP ARGI_INVALID_OPCODE +#define ARGI_WORD_OP ARGI_INVALID_OPCODE +#define ARGI_ZERO_OP ARG_NONE + +#endif /* __ACOPCODE_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acoutput.h b/reactos/drivers/bus/acpi/acpica/include/acoutput.h new file mode 100644 index 00000000000..4f4b1d9c69d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acoutput.h @@ -0,0 +1,351 @@ +/****************************************************************************** + * + * Name: acoutput.h -- debug output + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOUTPUT_H__ +#define __ACOUTPUT_H__ + +/* + * Debug levels and component IDs. These are used to control the + * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a + * per-component basis and a per-exception-type basis. + */ + +/* Component IDs are used in the global "DebugLayer" */ + +#define ACPI_UTILITIES 0x00000001 +#define ACPI_HARDWARE 0x00000002 +#define ACPI_EVENTS 0x00000004 +#define ACPI_TABLES 0x00000008 +#define ACPI_NAMESPACE 0x00000010 +#define ACPI_PARSER 0x00000020 +#define ACPI_DISPATCHER 0x00000040 +#define ACPI_EXECUTER 0x00000080 +#define ACPI_RESOURCES 0x00000100 +#define ACPI_CA_DEBUGGER 0x00000200 +#define ACPI_OS_SERVICES 0x00000400 +#define ACPI_CA_DISASSEMBLER 0x00000800 + +/* Component IDs for ACPI tools and utilities */ + +#define ACPI_COMPILER 0x00001000 +#define ACPI_TOOLS 0x00002000 +#define ACPI_EXAMPLE 0x00004000 +#define ACPI_DRIVER 0x00008000 + +#define ACPI_ALL_COMPONENTS 0x0000FFFF +#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) + +/* Component IDs reserved for ACPI drivers */ + +#define ACPI_ALL_DRIVERS 0xFFFF0000 + + +/* + * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros + */ +#define ACPI_LV_INIT 0x00000001 +#define ACPI_LV_DEBUG_OBJECT 0x00000002 +#define ACPI_LV_INFO 0x00000004 +#define ACPI_LV_REPAIR 0x00000008 +#define ACPI_LV_ALL_EXCEPTIONS 0x0000000F + +/* Trace verbosity level 1 [Standard Trace Level] */ + +#define ACPI_LV_INIT_NAMES 0x00000020 +#define ACPI_LV_PARSE 0x00000040 +#define ACPI_LV_LOAD 0x00000080 +#define ACPI_LV_DISPATCH 0x00000100 +#define ACPI_LV_EXEC 0x00000200 +#define ACPI_LV_NAMES 0x00000400 +#define ACPI_LV_OPREGION 0x00000800 +#define ACPI_LV_BFIELD 0x00001000 +#define ACPI_LV_TABLES 0x00002000 +#define ACPI_LV_VALUES 0x00004000 +#define ACPI_LV_OBJECTS 0x00008000 +#define ACPI_LV_RESOURCES 0x00010000 +#define ACPI_LV_USER_REQUESTS 0x00020000 +#define ACPI_LV_PACKAGE 0x00040000 +#define ACPI_LV_VERBOSITY1 0x0007FF40 | ACPI_LV_ALL_EXCEPTIONS + +/* Trace verbosity level 2 [Function tracing and memory allocation] */ + +#define ACPI_LV_ALLOCATIONS 0x00100000 +#define ACPI_LV_FUNCTIONS 0x00200000 +#define ACPI_LV_OPTIMIZATIONS 0x00400000 +#define ACPI_LV_VERBOSITY2 0x00700000 | ACPI_LV_VERBOSITY1 +#define ACPI_LV_ALL ACPI_LV_VERBOSITY2 + +/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */ + +#define ACPI_LV_MUTEX 0x01000000 +#define ACPI_LV_THREADS 0x02000000 +#define ACPI_LV_IO 0x04000000 +#define ACPI_LV_INTERRUPTS 0x08000000 +#define ACPI_LV_VERBOSITY3 0x0F000000 | ACPI_LV_VERBOSITY2 + +/* Exceptionally verbose output -- also used in the global "DebugLevel" */ + +#define ACPI_LV_AML_DISASSEMBLE 0x10000000 +#define ACPI_LV_VERBOSE_INFO 0x20000000 +#define ACPI_LV_FULL_TABLES 0x40000000 +#define ACPI_LV_EVENTS 0x80000000 +#define ACPI_LV_VERBOSE 0xF0000000 + + +/* + * Debug level macros that are used in the DEBUG_PRINT macros + */ +#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,ACPI_DEBUG_PARAMETERS + +/* + * Exception level -- used in the global "DebugLevel" + * + * Note: For errors, use the ACPI_ERROR or ACPI_EXCEPTION interfaces. + * For warnings, use ACPI_WARNING. + */ +#define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT) +#define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT) +#define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) +#define ACPI_DB_REPAIR ACPI_DEBUG_LEVEL (ACPI_LV_REPAIR) +#define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) + +/* Trace level -- also used in the global "DebugLevel" */ + +#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) +#define ACPI_DB_THREADS ACPI_DEBUG_LEVEL (ACPI_LV_THREADS) +#define ACPI_DB_PARSE ACPI_DEBUG_LEVEL (ACPI_LV_PARSE) +#define ACPI_DB_DISPATCH ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH) +#define ACPI_DB_LOAD ACPI_DEBUG_LEVEL (ACPI_LV_LOAD) +#define ACPI_DB_EXEC ACPI_DEBUG_LEVEL (ACPI_LV_EXEC) +#define ACPI_DB_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_NAMES) +#define ACPI_DB_OPREGION ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION) +#define ACPI_DB_BFIELD ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD) +#define ACPI_DB_TABLES ACPI_DEBUG_LEVEL (ACPI_LV_TABLES) +#define ACPI_DB_FUNCTIONS ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS) +#define ACPI_DB_OPTIMIZATIONS ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS) +#define ACPI_DB_VALUES ACPI_DEBUG_LEVEL (ACPI_LV_VALUES) +#define ACPI_DB_OBJECTS ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS) +#define ACPI_DB_ALLOCATIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS) +#define ACPI_DB_RESOURCES ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES) +#define ACPI_DB_IO ACPI_DEBUG_LEVEL (ACPI_LV_IO) +#define ACPI_DB_INTERRUPTS ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS) +#define ACPI_DB_USER_REQUESTS ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS) +#define ACPI_DB_PACKAGE ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE) +#define ACPI_DB_MUTEX ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX) +#define ACPI_DB_EVENTS ACPI_DEBUG_LEVEL (ACPI_LV_EVENTS) + +#define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL) + +/* Defaults for DebugLevel, debug and normal */ + +#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) +#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) +#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) + + +#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) +/* + * Module name is included in both debug and non-debug versions primarily for + * error messages. The __FILE__ macro is not very useful for this, because it + * often includes the entire pathname to the module + */ +#define ACPI_MODULE_NAME(Name) static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name; +#else +#define ACPI_MODULE_NAME(Name) +#endif + +/* + * Ascii error messages can be configured out + */ +#ifndef ACPI_NO_ERROR_MESSAGES +#define AE_INFO _AcpiModuleName, __LINE__ + +/* + * Error reporting. Callers module and line number are inserted by AE_INFO, + * the plist contains a set of parens to allow variable-length lists. + * These macros are used for both the debug and non-debug versions of the code. + */ +#define ACPI_INFO(plist) AcpiInfo plist +#define ACPI_WARNING(plist) AcpiWarning plist +#define ACPI_EXCEPTION(plist) AcpiException plist +#define ACPI_ERROR(plist) AcpiError plist + +#else + +/* No error messages */ + +#define ACPI_INFO(plist) +#define ACPI_WARNING(plist) +#define ACPI_EXCEPTION(plist) +#define ACPI_ERROR(plist) + +#endif /* ACPI_NO_ERROR_MESSAGES */ + + +/* + * Debug macros that are conditionally compiled + */ +#ifdef ACPI_DEBUG_OUTPUT + +/* + * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, + * define it now. This is the case where there the compiler does not support + * a __FUNCTION__ macro or equivalent. + */ +#ifndef ACPI_GET_FUNCTION_NAME +#define ACPI_GET_FUNCTION_NAME _AcpiFunctionName + +/* + * The Name parameter should be the procedure name as a quoted string. + * The function name is also used by the function exit macros below. + * Note: (const char) is used to be compatible with the debug interfaces + * and macros such as __FUNCTION__. + */ +#define ACPI_FUNCTION_NAME(Name) static const char _AcpiFunctionName[] = #Name; + +#else +/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ + +#define ACPI_FUNCTION_NAME(Name) +#endif /* ACPI_GET_FUNCTION_NAME */ + +/* + * Common parameters used for debug output functions: + * line number, function name, module(file) name, component ID + */ +#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT + +/* + * Master debug print macros + * Print message if and only if: + * 1) Debug print for the current component is enabled + * 2) Debug error level or trace level for the print statement is enabled + */ +#define ACPI_DEBUG_PRINT(plist) AcpiDebugPrint plist +#define ACPI_DEBUG_PRINT_RAW(plist) AcpiDebugPrintRaw plist + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ +#define ACPI_FUNCTION_NAME(a) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) + +#endif /* ACPI_DEBUG_OUTPUT */ + + +#endif /* __ACOUTPUT_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acparser.h b/reactos/drivers/bus/acpi/acpica/include/acparser.h new file mode 100644 index 00000000000..086688e3224 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acparser.h @@ -0,0 +1,403 @@ +/****************************************************************************** + * + * Module Name: acparser.h - AML Parser subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ACPARSER_H__ +#define __ACPARSER_H__ + + +#define OP_HAS_RETURN_VALUE 1 + +/* Variable number of arguments. This field must be 32 bits */ + +#define ACPI_VAR_ARGS ACPI_UINT32_MAX + + +#define ACPI_PARSE_DELETE_TREE 0x0001 +#define ACPI_PARSE_NO_TREE_DELETE 0x0000 +#define ACPI_PARSE_TREE_MASK 0x0001 + +#define ACPI_PARSE_LOAD_PASS1 0x0010 +#define ACPI_PARSE_LOAD_PASS2 0x0020 +#define ACPI_PARSE_EXECUTE 0x0030 +#define ACPI_PARSE_MODE_MASK 0x0030 + +#define ACPI_PARSE_DEFERRED_OP 0x0100 +#define ACPI_PARSE_DISASSEMBLE 0x0200 + +#define ACPI_PARSE_MODULE_LEVEL 0x0400 + +/****************************************************************************** + * + * Parser interfaces + * + *****************************************************************************/ + + +/* + * psxface - Parser external interfaces + */ +ACPI_STATUS +AcpiPsExecuteMethod ( + ACPI_EVALUATE_INFO *Info); + + +/* + * psargs - Parse AML opcode arguments + */ +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState); + +char * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT *Arg); + +ACPI_STATUS +AcpiPsGetNextNamepath ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + BOOLEAN MethodCall); + +ACPI_STATUS +AcpiPsGetNextArg ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT **ReturnArg); + + +/* + * psfind + */ +ACPI_PARSE_OBJECT * +AcpiPsFindName ( + ACPI_PARSE_OBJECT *Scope, + UINT32 Name, + UINT32 Opcode); + +ACPI_PARSE_OBJECT* +AcpiPsGetParent ( + ACPI_PARSE_OBJECT *Op); + + +/* + * psopcode - AML Opcode information + */ +const ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode); + +char * +AcpiPsGetOpcodeName ( + UINT16 Opcode); + +UINT8 +AcpiPsGetArgumentCount ( + UINT32 OpType); + + +/* + * psparse - top level parsing routines + */ +ACPI_STATUS +AcpiPsParseAml ( + ACPI_WALK_STATE *WalkState); + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode); + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *state); + +ACPI_STATUS +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiPsNextParseState ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS CallbackStatus); + + +/* + * psloop - main parse loop + */ +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState); + + +/* + * psscope - Scope stack management routines + */ +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Root); + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *state); + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount); + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount); + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *state); + + +/* + * pstree - parse tree manipulation routines + */ +void +AcpiPsAppendArg( + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_OBJECT *arg); + +ACPI_PARSE_OBJECT* +AcpiPsFind ( + ACPI_PARSE_OBJECT *Scope, + char *Path, + UINT16 Opcode, + UINT32 Create); + +ACPI_PARSE_OBJECT * +AcpiPsGetArg( + ACPI_PARSE_OBJECT *op, + UINT32 argn); + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op); + + +/* + * pswalk - parse tree walk routines + */ +ACPI_STATUS +AcpiPsWalkParsedAml ( + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_OBJECT *EndOp, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsGetNextWalkOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsDeleteCompletedOp ( + ACPI_WALK_STATE *WalkState); + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *root); + + +/* + * psutils - parser utilities + */ +ACPI_PARSE_OBJECT * +AcpiPsCreateScopeOp ( + void); + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *op, + UINT16 opcode); + +ACPI_PARSE_OBJECT * +AcpiPsAllocOp ( + UINT16 opcode); + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op); + +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c); + +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c); + +UINT32 +AcpiPsGetName( + ACPI_PARSE_OBJECT *op); + +void +AcpiPsSetName( + ACPI_PARSE_OBJECT *op, + UINT32 name); + + +/* + * psdump - display parser tree + */ +UINT32 +AcpiPsSprintPath ( + char *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +UINT32 +AcpiPsSprintOp ( + char *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +void +AcpiPsShow ( + ACPI_PARSE_OBJECT *op); + + +#endif /* __ACPARSER_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acpi.h b/reactos/drivers/bus/acpi/acpica/include/acpi.h new file mode 100644 index 00000000000..db552836627 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acpi.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * + * Name: acpi.h - Master public include file used to interface to ACPICA + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPI_H__ +#define __ACPI_H__ + +/* + * Public include files for use by code that will interface to ACPICA. + * + * Information includes the ACPICA data types, names, exceptions, and + * external interface prototypes. Also included are the definitions for + * all ACPI tables (FADT, MADT, etc.) + * + * Note: The order of these include files is important. + */ +#include +#include + +#include "platform/acenv.h" /* Environment-specific items */ +#include "acnames.h" /* Common ACPI names and strings */ +#include "actypes.h" /* ACPICA data types and structures */ +#include "acexcep.h" /* ACPICA exceptions */ +#include "actbl.h" /* ACPI table definitions */ +#include "acoutput.h" /* Error output and Debug macros */ +#include "acrestyp.h" /* Resource Descriptor structs */ +#include "acpiosxf.h" /* OSL interfaces (ACPICA-to-OS) */ +#include "acpixf.h" /* ACPI core subsystem external interfaces */ + +#include "acconfig.h" +#include "acmacros.h" + +#endif /* __ACPI_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h b/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h new file mode 100644 index 00000000000..730057d1efa --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h @@ -0,0 +1,495 @@ + +/****************************************************************************** + * + * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These + * interfaces must be implemented by OSL to interface the + * ACPI components to the host operating system. + * + *****************************************************************************/ + + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exer + se the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPIOSXF_H__ +#define __ACPIOSXF_H__ + +#include "platform/acenv.h" +#include "actypes.h" + + +/* Types for AcpiOsExecute */ + +typedef enum +{ + OSL_GLOBAL_LOCK_HANDLER, + OSL_NOTIFY_HANDLER, + OSL_GPE_HANDLER, + OSL_DEBUGGER_THREAD, + OSL_EC_POLL_HANDLER, + OSL_EC_BURST_HANDLER + +} ACPI_EXECUTE_TYPE; + +#define ACPI_NO_UNIT_LIMIT ((UINT32) -1) +#define ACPI_MUTEX_SEM 1 + + +/* Functions for AcpiOsSignal */ + +#define ACPI_SIGNAL_FATAL 0 +#define ACPI_SIGNAL_BREAKPOINT 1 + +typedef struct acpi_signal_fatal_info +{ + UINT32 Type; + UINT32 Code; + UINT32 Argument; + +} ACPI_SIGNAL_FATAL_INFO; + + +/* + * OSL Initialization and shutdown primitives + */ +ACPI_STATUS +AcpiOsInitialize ( + void); + +ACPI_STATUS +AcpiOsTerminate ( + void); + + +/* + * ACPI Table interfaces + */ +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void); + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal); + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable); + + +/* + * Spinlock primitives + */ +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle); + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle); + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_SPINLOCK Handle); + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags); + + +/* + * Semaphore primitives + */ +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_SEMAPHORE *OutHandle); + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_SEMAPHORE Handle); + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_SEMAPHORE Handle, + UINT32 Units, + UINT16 Timeout); + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_SEMAPHORE Handle, + UINT32 Units); + + +/* + * Mutex primitives. May be configured to use semaphores instead via + * ACPI_MUTEX_TYPE (see platform/acenv.h) + */ +#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) + +ACPI_STATUS +AcpiOsCreateMutex ( + ACPI_MUTEX *OutHandle); + +void +AcpiOsDeleteMutex ( + ACPI_MUTEX Handle); + +ACPI_STATUS +AcpiOsAcquireMutex ( + ACPI_MUTEX Handle, + UINT16 Timeout); + +void +AcpiOsReleaseMutex ( + ACPI_MUTEX Handle); +#endif + + +/* + * Memory allocation and mapping + */ +void * +AcpiOsAllocate ( + ACPI_SIZE Size); + +void +AcpiOsFree ( + void * Memory); + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS Where, + ACPI_SIZE Length); + +void +AcpiOsUnmapMemory ( + void *LogicalAddress, + ACPI_SIZE Size); + +ACPI_STATUS +AcpiOsGetPhysicalAddress ( + void *LogicalAddress, + ACPI_PHYSICAL_ADDRESS *PhysicalAddress); + + +/* + * Memory/Object Cache + */ +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache); + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache); + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache); + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache); + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object); + + +/* + * Interrupt handlers + */ +ACPI_STATUS +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context); + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine); + + +/* + * Threads and Scheduling + */ +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void); + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context); + +void +AcpiOsWaitEventsComplete ( + void *Context); + +void +AcpiOsSleep ( + ACPI_INTEGER Milliseconds); + +void +AcpiOsStall ( + UINT32 Microseconds); + + +/* + * Platform and hardware-independent I/O interfaces + */ +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * Platform and hardware-independent physical memory interfaces + */ +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * Platform and hardware-independent PCI configuration space access + * Note: Can't use "Register" as a parameter, changed to "Reg" -- + * certain compilers complain. + */ +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Reg, + void *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Reg, + ACPI_INTEGER Value, + UINT32 Width); + + +/* + * Interim function needed for PCI IRQ routing + */ +void +AcpiOsDerivePciId( + ACPI_HANDLE Rhandle, + ACPI_HANDLE Chandle, + ACPI_PCI_ID **PciId); + + +/* + * Miscellaneous + */ +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface); + +BOOLEAN +AcpiOsReadable ( + void *Pointer, + ACPI_SIZE Length); + +BOOLEAN +AcpiOsWritable ( + void *Pointer, + ACPI_SIZE Length); + +UINT64 +AcpiOsGetTimer ( + void); + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info); + + +/* + * Debug print routines + */ +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Format, + ...); + +void +AcpiOsVprintf ( + const char *Format, + va_list Args); + +void +AcpiOsRedirectOutput ( + void *Destination); + + +/* + * Debug input + */ +UINT32 +AcpiOsGetLine ( + char *Buffer); + + +/* + * Directory manipulation + */ +void * +AcpiOsOpenDirectory ( + char *Pathname, + char *WildcardSpec, + char RequestedFileType); + +/* RequesteFileType values */ + +#define REQUEST_FILE_ONLY 0 +#define REQUEST_DIR_ONLY 1 + + +char * +AcpiOsGetNextFilename ( + void *DirHandle); + +void +AcpiOsCloseDirectory ( + void *DirHandle); + + +#endif /* __ACPIOSXF_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acpixf.h b/reactos/drivers/bus/acpi/acpica/include/acpixf.h new file mode 100644 index 00000000000..a961009465a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acpixf.h @@ -0,0 +1,687 @@ + +/****************************************************************************** + * + * Name: acpixf.h - External interfaces to the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ACXFACE_H__ +#define __ACXFACE_H__ + +/* Current ACPICA subsystem version in YYYYMMDD format */ + +#define ACPI_CA_VERSION 0x20091214 + +#include "actypes.h" +#include "actbl.h" + +/* + * Globals that are publically available + */ +extern UINT32 AcpiCurrentGpeCount; +extern ACPI_TABLE_FADT AcpiGbl_FADT; + +/* Runtime configuration of debug print levels */ + +extern UINT32 AcpiDbgLevel; +extern UINT32 AcpiDbgLayer; + +/* ACPICA runtime options */ + +extern UINT8 AcpiGbl_EnableInterpreterSlack; +extern UINT8 AcpiGbl_AllMethodsSerialized; +extern UINT8 AcpiGbl_CreateOsiMethod; +extern UINT8 AcpiGbl_LeaveWakeGpesDisabled; +extern UINT8 AcpiGbl_UseDefaultRegisterWidths; +extern ACPI_NAME AcpiGbl_TraceMethodName; +extern UINT32 AcpiGbl_TraceFlags; + + +/* + * Global interfaces + */ +ACPI_STATUS +AcpiInitializeTables ( + ACPI_TABLE_DESC *InitialStorage, + UINT32 InitialTableCount, + BOOLEAN AllowResize); + +ACPI_STATUS +AcpiInitializeSubsystem ( + void); + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags); + +ACPI_STATUS +AcpiInitializeObjects ( + UINT32 Flags); + +ACPI_STATUS +AcpiTerminate ( + void); + +ACPI_STATUS +AcpiSubsystemStatus ( + void); + +ACPI_STATUS +AcpiEnable ( + void); + +ACPI_STATUS +AcpiDisable ( + void); + +ACPI_STATUS +AcpiGetSystemInfo ( + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetStatistics ( + ACPI_STATISTICS *Stats); + +const char * +AcpiFormatException ( + ACPI_STATUS Exception); + +ACPI_STATUS +AcpiPurgeCachedObjects ( + void); + + +/* + * ACPI Memory managment + */ +void * +AcpiAllocate ( + UINT32 Size); + +void * +AcpiCallocate ( + UINT32 Size); + +void +AcpiFree ( + void *Address); + + +/* + * ACPI table manipulation interfaces + */ +ACPI_STATUS +AcpiReallocateRootTable ( + void); + +ACPI_STATUS +AcpiFindRootPointer ( + ACPI_SIZE *RsdpAddress); + +ACPI_STATUS +AcpiLoadTables ( + void); + +ACPI_STATUS +AcpiGetTableHeader ( + ACPI_STRING Signature, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader); + +ACPI_STATUS +AcpiGetTable ( + ACPI_STRING Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **OutTable); + +ACPI_STATUS +AcpiGetTableByIndex ( + UINT32 TableIndex, + ACPI_TABLE_HEADER **OutTable); + +ACPI_STATUS +AcpiInstallTableHandler ( + ACPI_TABLE_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveTableHandler ( + ACPI_TABLE_HANDLER Handler); + + +/* + * Namespace and name interfaces + */ +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiGetDevices ( + char *HID, + ACPI_WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiGetName ( + ACPI_HANDLE Handle, + UINT32 NameType, + ACPI_BUFFER *RetPathPtr); + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle); + +ACPI_STATUS +AcpiAttachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void *Data); + +ACPI_STATUS +AcpiDetachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler); + +ACPI_STATUS +AcpiGetData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void **Data); + +ACPI_STATUS +AcpiDebugTrace ( + char *Name, + UINT32 DebugLevel, + UINT32 DebugLayer, + UINT32 Flags); + + +/* + * Object manipulation and enumeration + */ +ACPI_STATUS +AcpiEvaluateObject ( + ACPI_HANDLE Object, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ParameterObjects, + ACPI_BUFFER *ReturnObjectBuffer); + +ACPI_STATUS +AcpiEvaluateObjectTyped ( + ACPI_HANDLE Object, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer, + ACPI_OBJECT_TYPE ReturnType); + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Handle, + ACPI_DEVICE_INFO **ReturnBuffer); + +ACPI_STATUS +AcpiInstallMethod ( + UINT8 *Buffer); + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *OutHandle); + +ACPI_STATUS +AcpiGetType ( + ACPI_HANDLE Object, + ACPI_OBJECT_TYPE *OutType); + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Object, + ACPI_HANDLE *OutHandle); + + +/* + * Handler interfaces + */ +ACPI_STATUS +AcpiInstallInitializationHandler ( + ACPI_INIT_HANDLER Handler, + UINT32 Function); + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 AcpiEvent, + ACPI_EVENT_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 AcpiEvent, + ACPI_EVENT_HANDLER Handler); + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler); + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler); + +ACPI_STATUS +AcpiInstallGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Type, + ACPI_EVENT_HANDLER Address, + void *Context); + +ACPI_STATUS +AcpiRemoveGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + ACPI_EVENT_HANDLER Address); + +ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler); + + +/* + * Event interfaces + */ +ACPI_STATUS +AcpiAcquireGlobalLock ( + UINT16 Timeout, + UINT32 *Handle); + +ACPI_STATUS +AcpiReleaseGlobalLock ( + UINT32 Handle); + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 Event, + UINT32 Flags); + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Flags); + +ACPI_STATUS +AcpiClearEvent ( + UINT32 Event); + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 Event, + ACPI_EVENT_STATUS *EventStatus); + + +/* + * GPE Interfaces + */ +ACPI_STATUS +AcpiSetGpeType ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Type); + +ACPI_STATUS +AcpiEnableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiDisableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiClearGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiGetGpeStatus ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags, + ACPI_EVENT_STATUS *EventStatus); + +ACPI_STATUS +AcpiDisableAllGpes ( + void); + +ACPI_STATUS +AcpiEnableAllRuntimeGpes ( + void); + +ACPI_STATUS +AcpiGetGpeDevice ( + UINT32 GpeIndex, + ACPI_HANDLE *GpeDevice); + +ACPI_STATUS +AcpiInstallGpeBlock ( + ACPI_HANDLE GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT32 InterruptNumber); + +ACPI_STATUS +AcpiRemoveGpeBlock ( + ACPI_HANDLE GpeDevice); + + +/* + * Resource interfaces + */ +typedef +ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) ( + ACPI_RESOURCE *Resource, + void *Context); + +ACPI_STATUS +AcpiGetVendorResource ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_VENDOR_UUID *Uuid, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetCurrentResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetPossibleResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiWalkResources ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_WALK_RESOURCE_CALLBACK UserFunction, + void *Context); + +ACPI_STATUS +AcpiSetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *InBuffer); + +ACPI_STATUS +AcpiGetIrqRoutingTable ( + ACPI_HANDLE BusDeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiResourceToAddress64 ( + ACPI_RESOURCE *Resource, + ACPI_RESOURCE_ADDRESS64 *Out); + + +/* + * Hardware (ACPI device) interfaces + */ +ACPI_STATUS +AcpiReset ( + void); + +ACPI_STATUS +AcpiRead ( + UINT64 *Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiWrite ( + UINT64 Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiReadBitRegister ( + UINT32 RegisterId, + UINT32 *ReturnValue); + +ACPI_STATUS +AcpiWriteBitRegister ( + UINT32 RegisterId, + UINT32 Value); + +ACPI_STATUS +AcpiGetSleepTypeData ( + UINT8 SleepState, + UINT8 *Slp_TypA, + UINT8 *Slp_TypB); + +ACPI_STATUS +AcpiEnterSleepStatePrep ( + UINT8 SleepState); + +ACPI_STATUS +AcpiEnterSleepState ( + UINT8 SleepState); + +ACPI_STATUS +AcpiEnterSleepStateS4bios ( + void); + +ACPI_STATUS +AcpiLeaveSleepState ( + UINT8 SleepState) + ; +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + UINT32 PhysicalAddress); + +#if ACPI_MACHINE_WIDTH == 64 +ACPI_STATUS +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress); +#endif + + +/* + * Error/Warning output + */ +void ACPI_INTERNAL_VAR_XFACE +AcpiError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +AcpiException ( + const char *ModuleName, + UINT32 LineNumber, + ACPI_STATUS Status, + const char *Format, + ...) ACPI_PRINTF_LIKE(4); + +void ACPI_INTERNAL_VAR_XFACE +AcpiWarning ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +AcpiInfo ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + + +/* + * Debug output + */ +#ifdef ACPI_DEBUG_OUTPUT + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrint ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) ACPI_PRINTF_LIKE(6); + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrintRaw ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) ACPI_PRINTF_LIKE(6); +#endif + +#endif /* __ACXFACE_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acpredef.h b/reactos/drivers/bus/acpi/acpica/include/acpredef.h new file mode 100644 index 00000000000..2be401520b3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acpredef.h @@ -0,0 +1,598 @@ +/****************************************************************************** + * + * Name: acpredef - Information table for ACPI predefined methods and objects + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPREDEF_H__ +#define __ACPREDEF_H__ + + +/****************************************************************************** + * + * Return Package types + * + * 1) PTYPE1 packages do not contain sub-packages. + * + * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types: + * object type + * count + * object type + * count + * + * ACPI_PTYPE1_VAR: Variable-length length: + * object type (Int/Buf/Ref) + * + * ACPI_PTYPE1_OPTION: Package has some required and some optional elements + * (Used for _PRW) + * + * + * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each + * of the different types describe the contents of each of the sub-packages. + * + * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: + * object type + * count + * object type + * count + * (Used for _ALR,_MLS,_PSS,_TRT,_TSS) + * + * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element: + * object type + * (Used for _CSD,_PSD,_TSD) + * + * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types: + * object type + * count + * object type + * count + * (Used for _CST) + * + * ACPI_PTYPE2_FIXED: Each subpackage is of Fixed-length + * (Used for _PRT) + * + * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length + * (Used for _HPX) + * + * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length + * (Used for _ART, _FPS) + * + *****************************************************************************/ + +enum AcpiReturnPackageTypes +{ + ACPI_PTYPE1_FIXED = 1, + ACPI_PTYPE1_VAR = 2, + ACPI_PTYPE1_OPTION = 3, + ACPI_PTYPE2 = 4, + ACPI_PTYPE2_COUNT = 5, + ACPI_PTYPE2_PKG_COUNT = 6, + ACPI_PTYPE2_FIXED = 7, + ACPI_PTYPE2_MIN = 8, + ACPI_PTYPE2_REV_FIXED = 9 +}; + + +#ifdef ACPI_CREATE_PREDEFINED_TABLE +/* + * Predefined method/object information table. + * + * These are the names that can actually be evaluated via AcpiEvaluateObject. + * Not present in this table are the following: + * + * 1) Predefined/Reserved names that are never evaluated via + * AcpiEvaluateObject: + * _Lxx and _Exx GPE methods + * _Qxx EC methods + * _T_x compiler temporary variables + * + * 2) Predefined names that never actually exist within the AML code: + * Predefined resource descriptor field names + * + * 3) Predefined names that are implemented within ACPICA: + * _OSI + * + * 4) Some predefined names that are not documented within the ACPI spec. + * _WDG, _WED + * + * The main entries in the table each contain the following items: + * + * Name - The ACPI reserved name + * ParamCount - Number of arguments to the method + * ExpectedBtypes - Allowed type(s) for the return value. + * 0 means that no return value is expected. + * + * For methods that return packages, the next entry in the table contains + * information about the expected structure of the package. This information + * is saved here (rather than in a separate table) in order to minimize the + * overall size of the stored data. + * + * Note: The additional braces are intended to promote portability. + */ +static const ACPI_PREDEFINED_INFO PredefinedNames[] = +{ + {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC1", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC3", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC4", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC5", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC6", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC7", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC8", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC9", 0, ACPI_RTYPE_INTEGER}}, + {{"_ADR", 0, ACPI_RTYPE_INTEGER}}, + {{"_AL0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL4", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL5", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL6", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL7", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL8", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL9", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_ALC", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALI", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALP", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALR", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2 (Ints) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, + + {{"_ALT", 0, ACPI_RTYPE_INTEGER}}, + {{"_ART", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (2 Ref/11 Int) */ + {{{ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 11,0}}, + + {{"_BBN", 0, ACPI_RTYPE_INTEGER}}, + {{"_BCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_BCM", 1, 0}}, + {{"_BCT", 1, ACPI_RTYPE_INTEGER}}, + {{"_BDN", 0, ACPI_RTYPE_INTEGER}}, + {{"_BFS", 1, 0}}, + {{"_BIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (9 Int),(4 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, ACPI_RTYPE_STRING}, 4,0}}, + + {{"_BIX", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int),(4 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING}, 4,0}}, + + {{"_BLT", 3, 0}}, + {{"_BMA", 1, ACPI_RTYPE_INTEGER}}, + {{"_BMC", 1, 0}}, + {{"_BMD", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (5 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_BMS", 1, ACPI_RTYPE_INTEGER}}, + {{"_BQC", 0, ACPI_RTYPE_INTEGER}}, + {{"_BST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_BTM", 1, ACPI_RTYPE_INTEGER}}, + {{"_BTP", 1, 0}}, + {{"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* See PCI firmware spec 3.0 */ + {{"_CDM", 0, ACPI_RTYPE_INTEGER}}, + {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0}, 0,0}}, + + {{"_CRS", 0, ACPI_RTYPE_BUFFER}}, + {{"_CRT", 0, ACPI_RTYPE_INTEGER}}, + {{"_CSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n-1 Int) */ + {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */ + {{{ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,0}}, + + {{"_DCK", 1, ACPI_RTYPE_INTEGER}}, + {{"_DCS", 0, ACPI_RTYPE_INTEGER}}, + {{"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}}, + {{"_DDN", 0, ACPI_RTYPE_STRING}}, + {{"_DGS", 0, ACPI_RTYPE_INTEGER}}, + {{"_DIS", 0, 0}}, + {{"_DMA", 0, ACPI_RTYPE_BUFFER}}, + {{"_DOD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_DOS", 1, 0}}, + {{"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */ + {{"_DSS", 1, 0}}, + {{"_DSW", 3, 0}}, + {{"_DTI", 1, 0}}, + {{"_EC_", 0, ACPI_RTYPE_INTEGER}}, + {{"_EDL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs)*/ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_EJ0", 1, 0}}, + {{"_EJ1", 1, 0}}, + {{"_EJ2", 1, 0}}, + {{"_EJ3", 1, 0}}, + {{"_EJ4", 1, 0}}, + {{"_EJD", 0, ACPI_RTYPE_STRING}}, + {{"_FDE", 0, ACPI_RTYPE_BUFFER}}, + {{"_FDI", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0}, 0,0}}, + + {{"_FDM", 1, 0}}, + {{"_FIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_FIX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_FPS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (5 Int) */ + {{{ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_INTEGER, 5, 0}, 0,0}}, + + {{"_FSL", 1, 0}}, + {{"_FST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3,0}, 0,0}}, + + + {{"_GAI", 0, ACPI_RTYPE_INTEGER}}, + {{"_GHL", 0, ACPI_RTYPE_INTEGER}}, + {{"_GLK", 0, ACPI_RTYPE_INTEGER}}, + {{"_GPD", 0, ACPI_RTYPE_INTEGER}}, + {{"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */ + {{"_GSB", 0, ACPI_RTYPE_INTEGER}}, + {{"_GTF", 0, ACPI_RTYPE_BUFFER}}, + {{"_GTM", 0, ACPI_RTYPE_BUFFER}}, + {{"_GTS", 1, 0}}, + {{"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, + {{"_HOT", 0, ACPI_RTYPE_INTEGER}}, + {{"_HPP", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + /* + * For _HPX, a single package is returned, containing a Variable-length number + * of sub-packages. Each sub-package contains a PCI record setting. + * There are several different type of record settings, of different + * lengths, but all elements of all settings are Integers. + */ + {{"_HPX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (var Ints) */ + {{{ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ + {{"_INI", 0, 0}}, + {{"_IRC", 0, 0}}, + {{"_LCK", 1, 0}}, + {{"_LID", 0, ACPI_RTYPE_INTEGER}}, + {{"_MAT", 0, ACPI_RTYPE_BUFFER}}, + {{"_MBM", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (8 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8,0}, 0,0}}, + + {{"_MLS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (2 Str) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_STRING, 2,0}, 0,0}}, + + {{"_MSG", 1, 0}}, + {{"_MSM", 4, ACPI_RTYPE_INTEGER}}, + {{"_NTT", 0, ACPI_RTYPE_INTEGER}}, + {{"_OFF", 0, 0}}, + {{"_ON_", 0, 0}}, + {{"_OS_", 0, ACPI_RTYPE_STRING}}, + {{"_OSC", 4, ACPI_RTYPE_BUFFER}}, + {{"_OST", 3, 0}}, + {{"_PAI", 1, ACPI_RTYPE_INTEGER}}, + {{"_PCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PCT", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, + + {{"_PDC", 1, 0}}, + {{"_PDL", 0, ACPI_RTYPE_INTEGER}}, + {{"_PIC", 1, 0}}, + {{"_PIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int),(3 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, ACPI_RTYPE_STRING}, 3,0}}, + + {{"_PLD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Bufs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0,0}, 0,0}}, + + {{"_PMC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (11 Int),(3 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 11, ACPI_RTYPE_STRING}, 3,0}}, + + {{"_PMD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PMM", 0, ACPI_RTYPE_INTEGER}}, + {{"_PPC", 0, ACPI_RTYPE_INTEGER}}, + {{"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* See dig64 spec */ + {{"_PR0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PRL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PRS", 0, ACPI_RTYPE_BUFFER}}, + + /* + * For _PRT, many BIOSs reverse the 3rd and 4th Package elements (Source + * and SourceIndex). This bug is so prevalent that there is code in the + * ACPICA Resource Manager to detect this and switch them back. For now, + * do not allow and issue a warning. To allow this and eliminate the + * warning, add the ACPI_RTYPE_REFERENCE type to the 4th element (index 3) + * in the statement below. + */ + {{"_PRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (4): Int,Int,Int/Ref,Int */ + {{{ACPI_PTYPE2_FIXED, 4, ACPI_RTYPE_INTEGER,ACPI_RTYPE_INTEGER}, + ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, + ACPI_RTYPE_INTEGER}}, + + {{"_PRW", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each: Pkg/Int,Int,[Variable-length Refs] (Pkg is Ref/Int) */ + {{{ACPI_PTYPE1_OPTION, 2, ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE, + ACPI_RTYPE_INTEGER}, ACPI_RTYPE_REFERENCE,0}}, + + {{"_PS0", 0, 0}}, + {{"_PS1", 0, 0}}, + {{"_PS2", 0, 0}}, + {{"_PS3", 0, 0}}, + {{"_PSC", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (5 Int) with count */ + {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER,0,0}, 0,0}}, + + {{"_PSL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PSR", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (6 Int) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6,0}, 0,0}}, + + {{"_PSV", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSW", 1, 0}}, + {{"_PTC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, + + {{"_PTP", 2, ACPI_RTYPE_INTEGER}}, + {{"_PTS", 1, 0}}, + {{"_PUR", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, + + {{"_PXM", 0, ACPI_RTYPE_INTEGER}}, + {{"_REG", 2, 0}}, + {{"_REV", 0, ACPI_RTYPE_INTEGER}}, + {{"_RMV", 0, ACPI_RTYPE_INTEGER}}, + {{"_ROM", 2, ACPI_RTYPE_BUFFER}}, + {{"_RTV", 0, ACPI_RTYPE_INTEGER}}, + + /* + * For _S0_ through _S5_, the ACPI spec defines a return Package + * containing 1 Integer, but most DSDTs have it wrong - 2,3, or 4 integers. + * Allow this by making the objects "Variable-length length", but all elements + * must be Integers. + */ + {{"_S0_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S1_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S2_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S3_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S4_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S5_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S1D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S2D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S3D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S4D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S0W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S1W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S2W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S3W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S4W", 0, ACPI_RTYPE_INTEGER}}, + {{"_SBS", 0, ACPI_RTYPE_INTEGER}}, + {{"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */ + /* Note: the 3-arg definition may be removed for ACPI 4.0 */ + {{"_SDD", 1, 0}}, + {{"_SEG", 0, ACPI_RTYPE_INTEGER}}, + {{"_SHL", 1, ACPI_RTYPE_INTEGER}}, + {{"_SLI", 0, ACPI_RTYPE_BUFFER}}, + {{"_SPD", 1, ACPI_RTYPE_INTEGER}}, + {{"_SRS", 1, 0}}, + {{"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ + {{"_SST", 1, 0}}, + {{"_STA", 0, ACPI_RTYPE_INTEGER}}, + {{"_STM", 3, 0}}, + {{"_STP", 2, ACPI_RTYPE_INTEGER}}, + {{"_STR", 0, ACPI_RTYPE_BUFFER}}, + {{"_STV", 2, ACPI_RTYPE_INTEGER}}, + {{"_SUN", 0, ACPI_RTYPE_INTEGER}}, + {{"_SWS", 0, ACPI_RTYPE_INTEGER}}, + {{"_TC1", 0, ACPI_RTYPE_INTEGER}}, + {{"_TC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_TIP", 1, ACPI_RTYPE_INTEGER}}, + {{"_TIV", 1, ACPI_RTYPE_INTEGER}}, + {{"_TMP", 0, ACPI_RTYPE_INTEGER}}, + {{"_TPC", 0, ACPI_RTYPE_INTEGER}}, + {{"_TPT", 1, 0}}, + {{"_TRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2Ref/6Int */ + {{{ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 6, 0}}, + + {{"_TSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5Int with count */ + {{{ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_TSP", 0, ACPI_RTYPE_INTEGER}}, + {{"_TSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5Int */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_TST", 0, ACPI_RTYPE_INTEGER}}, + {{"_TTS", 1, 0}}, + {{"_TZD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_TZM", 0, ACPI_RTYPE_REFERENCE}}, + {{"_TZP", 0, ACPI_RTYPE_INTEGER}}, + {{"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, + {{"_UPC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_UPD", 0, ACPI_RTYPE_INTEGER}}, + {{"_UPP", 0, ACPI_RTYPE_INTEGER}}, + {{"_VPO", 0, ACPI_RTYPE_INTEGER}}, + + /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ + + {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ + + {{{0,0,0,0}, 0,0}} /* Table terminator */ +}; + +#if 0 + /* Not implemented */ + + {{"_WDG", 0, ACPI_RTYPE_BUFFER}}, /* MS Extension */ + {{"_WED", 1, ACPI_RTYPE_PACKAGE}}, /* MS Extension */ + + /* This is an internally implemented control method, no need to check */ + {{"_OSI", 1, ACPI_RTYPE_INTEGER}}, + + /* TBD: */ + + _PRT - currently ignore reversed entries. Attempt to fix here? + Think about possibly fixing package elements like _BIF, etc. +#endif +#endif +#endif diff --git a/reactos/drivers/bus/acpi/acpica/include/acresrc.h b/reactos/drivers/bus/acpi/acpica/include/acresrc.h new file mode 100644 index 00000000000..c70aa5e23d4 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acresrc.h @@ -0,0 +1,465 @@ +/****************************************************************************** + * + * Name: acresrc.h - Resource Manager function prototypes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACRESRC_H__ +#define __ACRESRC_H__ + +/* Need the AML resource descriptor structs */ + +#include "amlresrc.h" + + +/* + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output. Two cases where we cannot + * pack the structures: + * + * 1) Hardware does not support misaligned memory transfers + * 2) Compiler does not support pointers within packed structures + */ +#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) +#pragma pack(1) +#endif + +/* + * Individual entry for the resource conversion tables + */ +typedef const struct acpi_rsconvert_info +{ + UINT8 Opcode; + UINT8 ResourceOffset; + UINT8 AmlOffset; + UINT8 Value; + +} ACPI_RSCONVERT_INFO; + +/* Resource conversion opcodes */ + +#define ACPI_RSC_INITGET 0 +#define ACPI_RSC_INITSET 1 +#define ACPI_RSC_FLAGINIT 2 +#define ACPI_RSC_1BITFLAG 3 +#define ACPI_RSC_2BITFLAG 4 +#define ACPI_RSC_COUNT 5 +#define ACPI_RSC_COUNT16 6 +#define ACPI_RSC_LENGTH 7 +#define ACPI_RSC_MOVE8 8 +#define ACPI_RSC_MOVE16 9 +#define ACPI_RSC_MOVE32 10 +#define ACPI_RSC_MOVE64 11 +#define ACPI_RSC_SET8 12 +#define ACPI_RSC_DATA8 13 +#define ACPI_RSC_ADDRESS 14 +#define ACPI_RSC_SOURCE 15 +#define ACPI_RSC_SOURCEX 16 +#define ACPI_RSC_BITMASK 17 +#define ACPI_RSC_BITMASK16 18 +#define ACPI_RSC_EXIT_NE 19 +#define ACPI_RSC_EXIT_LE 20 +#define ACPI_RSC_EXIT_EQ 21 + +/* Resource Conversion sub-opcodes */ + +#define ACPI_RSC_COMPARE_AML_LENGTH 0 +#define ACPI_RSC_COMPARE_VALUE 1 + +#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO)) + +#define ACPI_RS_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f) +#define AML_OFFSET(f) (UINT8) ACPI_OFFSET (AML_RESOURCE,f) + + +typedef const struct acpi_rsdump_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + const char **Pointer; + +} ACPI_RSDUMP_INFO; + +/* Values for the Opcode field above */ + +#define ACPI_RSD_TITLE 0 +#define ACPI_RSD_LITERAL 1 +#define ACPI_RSD_STRING 2 +#define ACPI_RSD_UINT8 3 +#define ACPI_RSD_UINT16 4 +#define ACPI_RSD_UINT32 5 +#define ACPI_RSD_UINT64 6 +#define ACPI_RSD_1BITFLAG 7 +#define ACPI_RSD_2BITFLAG 8 +#define ACPI_RSD_SHORTLIST 9 +#define ACPI_RSD_LONGLIST 10 +#define ACPI_RSD_DWORDLIST 11 +#define ACPI_RSD_ADDRESS 12 +#define ACPI_RSD_SOURCE 13 + +/* restore default alignment */ + +#pragma pack() + + +/* Resource tables indexed by internal resource type */ + +extern const UINT8 AcpiGbl_AmlResourceSizes[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[]; + +/* Resource tables indexed by raw AML resource descriptor type */ + +extern const UINT8 AcpiGbl_ResourceStructSizes[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[]; + + +typedef struct acpi_vendor_walk_info +{ + ACPI_VENDOR_UUID *Uuid; + ACPI_BUFFER *Buffer; + ACPI_STATUS Status; + +} ACPI_VENDOR_WALK_INFO; + + +/* + * rscreate + */ +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *AmlBuffer, + ACPI_BUFFER *OutputBuffer); + +ACPI_STATUS +AcpiRsCreateAmlResources ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_BUFFER *OutputBuffer); + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_BUFFER *OutputBuffer); + + +/* + * rsutils + */ +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetMethodData ( + ACPI_HANDLE Handle, + char *Path, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + + +/* + * rscalc + */ +ACPI_STATUS +AcpiRsGetListLength ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + ACPI_SIZE *SizeNeeded); + +ACPI_STATUS +AcpiRsGetAmlLength ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_SIZE *SizeNeeded); + +ACPI_STATUS +AcpiRsGetPciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_SIZE *BufferSizeNeeded); + +ACPI_STATUS +AcpiRsConvertAmlToResources ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context); + +ACPI_STATUS +AcpiRsConvertResourcesToAml ( + ACPI_RESOURCE *Resource, + ACPI_SIZE AmlSizeNeeded, + UINT8 *OutputBuffer); + + +/* + * rsaddr + */ +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource); + +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml); + + +/* + * rsmisc + */ +ACPI_STATUS +AcpiRsConvertAmlToResource ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info); + +ACPI_STATUS +AcpiRsConvertResourceToAml ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info); + + +/* + * rsutils + */ +void +AcpiRsMoveData ( + void *Destination, + void *Source, + UINT16 ItemCount, + UINT8 MoveType); + +UINT8 +AcpiRsDecodeBitmask ( + UINT16 Mask, + UINT8 *List); + +UINT16 +AcpiRsEncodeBitmask ( + UINT8 *List, + UINT8 Count); + +ACPI_RS_LENGTH +AcpiRsGetResourceSource ( + ACPI_RS_LENGTH ResourceLength, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource, + AML_RESOURCE *Aml, + char *StringPtr); + +ACPI_RSDESC_SIZE +AcpiRsSetResourceSource ( + AML_RESOURCE *Aml, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource); + +void +AcpiRsSetResourceHeader ( + UINT8 DescriptorType, + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml); + +void +AcpiRsSetResourceLength ( + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml); + + +/* + * rsdump + */ +void +AcpiRsDumpResourceList ( + ACPI_RESOURCE *Resource); + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable); + + +/* + * Resource conversion tables + */ +extern ACPI_RSCONVERT_INFO AcpiRsConvertDma[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertIo[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[]; + +/* These resources require separate get/set tables */ + +extern ACPI_RSCONVERT_INFO AcpiRsGetIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[]; + +extern ACPI_RSCONVERT_INFO AcpiRsSetIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsSetVendor[]; + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/* + * rsinfo + */ +extern ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[]; + +/* + * rsdump + */ +extern ACPI_RSDUMP_INFO AcpiRsDumpIrq[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpDma[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpIo[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpVendor[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpEndTag[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpMemory24[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpMemory32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress16[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress64[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[]; +#endif + +#endif /* __ACRESRC_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acrestyp.h b/reactos/drivers/bus/acpi/acpica/include/acrestyp.h new file mode 100644 index 00000000000..7eb7600d982 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acrestyp.h @@ -0,0 +1,544 @@ +/****************************************************************************** + * + * Name: acrestyp.h - Defines, types, and structures for resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACRESTYP_H__ +#define __ACRESTYP_H__ + + +/* + * Definitions for Resource Attributes + */ +typedef UINT16 ACPI_RS_LENGTH; /* Resource Length field is fixed at 16 bits */ +typedef UINT32 ACPI_RSDESC_SIZE; /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */ + +/* + * Memory Attributes + */ +#define ACPI_READ_ONLY_MEMORY (UINT8) 0x00 +#define ACPI_READ_WRITE_MEMORY (UINT8) 0x01 + +#define ACPI_NON_CACHEABLE_MEMORY (UINT8) 0x00 +#define ACPI_CACHABLE_MEMORY (UINT8) 0x01 +#define ACPI_WRITE_COMBINING_MEMORY (UINT8) 0x02 +#define ACPI_PREFETCHABLE_MEMORY (UINT8) 0x03 + +/* + * IO Attributes + * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh. + * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh. + */ +#define ACPI_NON_ISA_ONLY_RANGES (UINT8) 0x01 +#define ACPI_ISA_ONLY_RANGES (UINT8) 0x02 +#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) + +/* Type of translation - 1=Sparse, 0=Dense */ + +#define ACPI_SPARSE_TRANSLATION (UINT8) 0x01 + +/* + * IO Port Descriptor Decode + */ +#define ACPI_DECODE_10 (UINT8) 0x00 /* 10-bit IO address decode */ +#define ACPI_DECODE_16 (UINT8) 0x01 /* 16-bit IO address decode */ + +/* + * IRQ Attributes + */ +#define ACPI_LEVEL_SENSITIVE (UINT8) 0x00 +#define ACPI_EDGE_SENSITIVE (UINT8) 0x01 + +#define ACPI_ACTIVE_HIGH (UINT8) 0x00 +#define ACPI_ACTIVE_LOW (UINT8) 0x01 + +#define ACPI_EXCLUSIVE (UINT8) 0x00 +#define ACPI_SHARED (UINT8) 0x01 + +/* + * DMA Attributes + */ +#define ACPI_COMPATIBILITY (UINT8) 0x00 +#define ACPI_TYPE_A (UINT8) 0x01 +#define ACPI_TYPE_B (UINT8) 0x02 +#define ACPI_TYPE_F (UINT8) 0x03 + +#define ACPI_NOT_BUS_MASTER (UINT8) 0x00 +#define ACPI_BUS_MASTER (UINT8) 0x01 + +#define ACPI_TRANSFER_8 (UINT8) 0x00 +#define ACPI_TRANSFER_8_16 (UINT8) 0x01 +#define ACPI_TRANSFER_16 (UINT8) 0x02 + +/* + * Start Dependent Functions Priority definitions + */ +#define ACPI_GOOD_CONFIGURATION (UINT8) 0x00 +#define ACPI_ACCEPTABLE_CONFIGURATION (UINT8) 0x01 +#define ACPI_SUB_OPTIMAL_CONFIGURATION (UINT8) 0x02 + +/* + * 16, 32 and 64-bit Address Descriptor resource types + */ +#define ACPI_MEMORY_RANGE (UINT8) 0x00 +#define ACPI_IO_RANGE (UINT8) 0x01 +#define ACPI_BUS_NUMBER_RANGE (UINT8) 0x02 + +#define ACPI_ADDRESS_NOT_FIXED (UINT8) 0x00 +#define ACPI_ADDRESS_FIXED (UINT8) 0x01 + +#define ACPI_POS_DECODE (UINT8) 0x00 +#define ACPI_SUB_DECODE (UINT8) 0x01 + +#define ACPI_PRODUCER (UINT8) 0x00 +#define ACPI_CONSUMER (UINT8) 0x01 + + +/* + * If possible, pack the following structures to byte alignment + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif + +/* UUID data structures for use in vendor-defined resource descriptors */ + +typedef struct acpi_uuid +{ + UINT8 Data[ACPI_UUID_LENGTH]; +} ACPI_UUID; + +typedef struct acpi_vendor_uuid +{ + UINT8 Subtype; + UINT8 Data[ACPI_UUID_LENGTH]; + +} ACPI_VENDOR_UUID; + +/* + * Structures used to describe device resources + */ +typedef struct acpi_resource_irq +{ + UINT8 DescriptorLength; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + UINT8 Interrupts[1]; + +} ACPI_RESOURCE_IRQ; + +typedef struct ACPI_RESOURCE_DMA +{ + UINT8 Type; + UINT8 BusMaster; + UINT8 Transfer; + UINT8 ChannelCount; + UINT8 Channels[1]; + +} ACPI_RESOURCE_DMA; + +typedef struct acpi_resource_start_dependent +{ + UINT8 DescriptorLength; + UINT8 CompatibilityPriority; + UINT8 PerformanceRobustness; + +} ACPI_RESOURCE_START_DEPENDENT; + + +/* + * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not + * needed because it has no fields + */ + + +typedef struct acpi_resource_io +{ + UINT8 IoDecode; + UINT8 Alignment; + UINT8 AddressLength; + UINT16 Minimum; + UINT16 Maximum; + +} ACPI_RESOURCE_IO; + +typedef struct acpi_resource_fixed_io +{ + UINT16 Address; + UINT8 AddressLength; + +} ACPI_RESOURCE_FIXED_IO; + +typedef struct acpi_resource_vendor +{ + UINT16 ByteLength; + UINT8 ByteData[1]; + +} ACPI_RESOURCE_VENDOR; + +/* Vendor resource with UUID info (introduced in ACPI 3.0) */ + +typedef struct acpi_resource_vendor_typed +{ + UINT16 ByteLength; + UINT8 UuidSubtype; + UINT8 Uuid[ACPI_UUID_LENGTH]; + UINT8 ByteData[1]; + +} ACPI_RESOURCE_VENDOR_TYPED; + +typedef struct acpi_resource_end_tag +{ + UINT8 Checksum; + +} ACPI_RESOURCE_END_TAG; + +typedef struct acpi_resource_memory24 +{ + UINT8 WriteProtect; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; + +} ACPI_RESOURCE_MEMORY24; + +typedef struct acpi_resource_memory32 +{ + UINT8 WriteProtect; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; + +} ACPI_RESOURCE_MEMORY32; + +typedef struct acpi_resource_fixed_memory32 +{ + UINT8 WriteProtect; + UINT32 Address; + UINT32 AddressLength; + +} ACPI_RESOURCE_FIXED_MEMORY32; + +typedef struct acpi_memory_attribute +{ + UINT8 WriteProtect; + UINT8 Caching; + UINT8 RangeType; + UINT8 Translation; + +} ACPI_MEMORY_ATTRIBUTE; + +typedef struct acpi_io_attribute +{ + UINT8 RangeType; + UINT8 Translation; + UINT8 TranslationType; + UINT8 Reserved1; + +} ACPI_IO_ATTRIBUTE; + +typedef union acpi_resource_attribute +{ + ACPI_MEMORY_ATTRIBUTE Mem; + ACPI_IO_ATTRIBUTE Io; + + /* Used for the *WordSpace macros */ + + UINT8 TypeSpecific; + +} ACPI_RESOURCE_ATTRIBUTE; + +typedef struct acpi_resource_source +{ + UINT8 Index; + UINT16 StringLength; + char *StringPtr; + +} ACPI_RESOURCE_SOURCE; + +/* Fields common to all address descriptors, 16/32/64 bit */ + +#define ACPI_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 ProducerConsumer; \ + UINT8 Decode; \ + UINT8 MinAddressFixed; \ + UINT8 MaxAddressFixed; \ + ACPI_RESOURCE_ATTRIBUTE Info; + +typedef struct acpi_resource_address +{ + ACPI_RESOURCE_ADDRESS_COMMON + +} ACPI_RESOURCE_ADDRESS; + +typedef struct acpi_resource_address16 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS16; + +typedef struct acpi_resource_address32 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS32; + +typedef struct acpi_resource_address64 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS64; + +typedef struct acpi_resource_extended_address64 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; + +} ACPI_RESOURCE_EXTENDED_ADDRESS64; + +typedef struct acpi_resource_extended_irq +{ + UINT8 ProducerConsumer; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + ACPI_RESOURCE_SOURCE ResourceSource; + UINT32 Interrupts[1]; + +} ACPI_RESOURCE_EXTENDED_IRQ; + +typedef struct acpi_resource_generic_register +{ + UINT8 SpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; + UINT64 Address; + +} ACPI_RESOURCE_GENERIC_REGISTER; + + +/* ACPI_RESOURCE_TYPEs */ + +#define ACPI_RESOURCE_TYPE_IRQ 0 +#define ACPI_RESOURCE_TYPE_DMA 1 +#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2 +#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3 +#define ACPI_RESOURCE_TYPE_IO 4 +#define ACPI_RESOURCE_TYPE_FIXED_IO 5 +#define ACPI_RESOURCE_TYPE_VENDOR 6 +#define ACPI_RESOURCE_TYPE_END_TAG 7 +#define ACPI_RESOURCE_TYPE_MEMORY24 8 +#define ACPI_RESOURCE_TYPE_MEMORY32 9 +#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10 +#define ACPI_RESOURCE_TYPE_ADDRESS16 11 +#define ACPI_RESOURCE_TYPE_ADDRESS32 12 +#define ACPI_RESOURCE_TYPE_ADDRESS64 13 +#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */ +#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15 +#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16 +#define ACPI_RESOURCE_TYPE_MAX 16 + +/* Master union for resource descriptors */ + +typedef union acpi_resource_data +{ + ACPI_RESOURCE_IRQ Irq; + ACPI_RESOURCE_DMA Dma; + ACPI_RESOURCE_START_DEPENDENT StartDpf; + ACPI_RESOURCE_IO Io; + ACPI_RESOURCE_FIXED_IO FixedIo; + ACPI_RESOURCE_VENDOR Vendor; + ACPI_RESOURCE_VENDOR_TYPED VendorTyped; + ACPI_RESOURCE_END_TAG EndTag; + ACPI_RESOURCE_MEMORY24 Memory24; + ACPI_RESOURCE_MEMORY32 Memory32; + ACPI_RESOURCE_FIXED_MEMORY32 FixedMemory32; + ACPI_RESOURCE_ADDRESS16 Address16; + ACPI_RESOURCE_ADDRESS32 Address32; + ACPI_RESOURCE_ADDRESS64 Address64; + ACPI_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + ACPI_RESOURCE_EXTENDED_IRQ ExtendedIrq; + ACPI_RESOURCE_GENERIC_REGISTER GenericReg; + + /* Common fields */ + + ACPI_RESOURCE_ADDRESS Address; /* Common 16/32/64 address fields */ + +} ACPI_RESOURCE_DATA; + + +/* Common resource header */ + +typedef struct acpi_resource +{ + UINT32 Type; + UINT32 Length; + ACPI_RESOURCE_DATA Data; + +} ACPI_RESOURCE; + +/* restore default alignment */ + +#pragma pack() + + +#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */ +#define ACPI_RS_SIZE_MIN (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (12) +#define ACPI_RS_SIZE(Type) (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type)) + +#define ACPI_NEXT_RESOURCE(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length) + + +typedef struct acpi_pci_routing_table +{ + UINT32 Length; + UINT32 Pin; + ACPI_INTEGER Address; /* here for 64-bit alignment */ + UINT32 SourceIndex; + char Source[4]; /* pad to 64 bits so sizeof() works in all cases */ + +} ACPI_PCI_ROUTING_TABLE; + +#endif /* __ACRESTYP_H__ */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/acstruct.h b/reactos/drivers/bus/acpi/acpica/include/acstruct.h new file mode 100644 index 00000000000..45c85fe0b2f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acstruct.h @@ -0,0 +1,326 @@ +/****************************************************************************** + * + * Name: acstruct.h - Internal structs + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACSTRUCT_H__ +#define __ACSTRUCT_H__ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +/***************************************************************************** + * + * Tree walking typedefs and structs + * + ****************************************************************************/ + + +/* + * Walk state - current state of a parse tree walk. Used for both a leisurely + * stroll through the tree (for whatever reason), and for control method + * execution. + */ +#define ACPI_NEXT_OP_DOWNWARD 1 +#define ACPI_NEXT_OP_UPWARD 2 + +/* + * Groups of definitions for WalkType used for different implementations of + * walkers (never simultaneously) - flags for interpreter: + */ +#define ACPI_WALK_NON_METHOD 0 +#define ACPI_WALK_METHOD 0x01 +#define ACPI_WALK_METHOD_RESTART 0x02 + +/* Flags for iASL compiler only */ + +#define ACPI_WALK_CONST_REQUIRED 0x10 +#define ACPI_WALK_CONST_OPTIONAL 0x20 + + +typedef struct acpi_walk_state +{ + struct acpi_walk_state *Next; /* Next WalkState in list */ + UINT8 DescriptorType; /* To differentiate various internal objs */ + UINT8 WalkType; + UINT16 Opcode; /* Current AML opcode */ + UINT8 NextOpInfo; /* Info about NextOp */ + UINT8 NumOperands; /* Stack pointer for Operands[] array */ + UINT8 OperandIndex; /* Index into operand stack, to be used by AcpiDsObjStackPush */ + ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ + BOOLEAN LastPredicate; /* Result of last predicate */ + UINT8 CurrentResult; + UINT8 ReturnUsed; + UINT8 ScopeDepth; + UINT8 PassNumber; /* Parse pass during table load */ + UINT8 ResultSize; /* Total elements for the result stack */ + UINT8 ResultCount; /* Current number of occupied elements of result stack */ + UINT32 AmlOffset; + UINT32 ArgTypes; + UINT32 MethodBreakpoint; /* For single stepping */ + UINT32 UserBreakpoint; /* User AML breakpoint */ + UINT32 ParseFlags; + + ACPI_PARSE_STATE ParserState; /* Current state of parser */ + UINT32 PrevArgTypes; + UINT32 ArgCount; /* push for fixed or var args */ + + struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ + struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ + union acpi_operand_object *Operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ + union acpi_operand_object **Params; + + UINT8 *AmlLastWhile; + union acpi_operand_object **CallerReturnDesc; + ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ + struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ + union acpi_operand_object *ImplicitReturnObj; + struct acpi_namespace_node *MethodCallNode; /* Called method Node*/ + ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ + union acpi_operand_object *MethodDesc; /* Method descriptor if running a method */ + struct acpi_namespace_node *MethodNode; /* Method node if running a method. */ + ACPI_PARSE_OBJECT *Op; /* Current parser op */ + const ACPI_OPCODE_INFO *OpInfo; /* Info on current opcode */ + ACPI_PARSE_OBJECT *Origin; /* Start of walk [Obsolete] */ + union acpi_operand_object *ResultObj; + ACPI_GENERIC_STATE *Results; /* Stack of accumulated results */ + union acpi_operand_object *ReturnDesc; /* Return object, if any */ + ACPI_GENERIC_STATE *ScopeInfo; /* Stack of nested scopes */ + ACPI_PARSE_OBJECT *PrevOp; /* Last op that was processed */ + ACPI_PARSE_OBJECT *NextOp; /* next op to be processed */ + ACPI_THREAD_STATE *Thread; + ACPI_PARSE_DOWNWARDS DescendingCallback; + ACPI_PARSE_UPWARDS AscendingCallback; + +} ACPI_WALK_STATE; + + +/* Info used by AcpiPsInitObjects */ + +typedef struct acpi_init_walk_info +{ + UINT16 MethodCount; + UINT16 DeviceCount; + UINT16 OpRegionCount; + UINT16 FieldCount; + UINT16 BufferCount; + UINT16 PackageCount; + UINT16 OpRegionInit; + UINT16 FieldInit; + UINT16 BufferInit; + UINT16 PackageInit; + UINT16 ObjectCount; + ACPI_OWNER_ID OwnerId; + UINT32 TableIndex; + +} ACPI_INIT_WALK_INFO; + + +typedef struct acpi_get_devices_info +{ + ACPI_WALK_CALLBACK UserFunction; + void *Context; + char *Hid; + +} ACPI_GET_DEVICES_INFO; + + +typedef union acpi_aml_operands +{ + ACPI_OPERAND_OBJECT *Operands[7]; + + struct + { + ACPI_OBJECT_INTEGER *Type; + ACPI_OBJECT_INTEGER *Code; + ACPI_OBJECT_INTEGER *Argument; + + } Fatal; + + struct + { + ACPI_OPERAND_OBJECT *Source; + ACPI_OBJECT_INTEGER *Index; + ACPI_OPERAND_OBJECT *Target; + + } Index; + + struct + { + ACPI_OPERAND_OBJECT *Source; + ACPI_OBJECT_INTEGER *Index; + ACPI_OBJECT_INTEGER *Length; + ACPI_OPERAND_OBJECT *Target; + + } Mid; + +} ACPI_AML_OPERANDS; + + +/* + * Structure used to pass object evaluation parameters. + * Purpose is to reduce CPU stack use. + */ +typedef struct acpi_evaluate_info +{ + ACPI_NAMESPACE_NODE *PrefixNode; + char *Pathname; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **Parameters; + ACPI_NAMESPACE_NODE *ResolvedNode; + ACPI_OPERAND_OBJECT *ReturnObject; + UINT8 ParamCount; + UINT8 PassNumber; + UINT8 ReturnObjectType; + UINT8 Flags; + +} ACPI_EVALUATE_INFO; + +/* Values for Flags above */ + +#define ACPI_IGNORE_RETURN_VALUE 1 + + +/* Info used by AcpiNsInitializeDevices */ + +typedef struct acpi_device_walk_info +{ + UINT16 DeviceCount; + UINT16 Num_STA; + UINT16 Num_INI; + ACPI_TABLE_DESC *TableDesc; + ACPI_EVALUATE_INFO *EvaluateInfo; + +} ACPI_DEVICE_WALK_INFO; + + +/* TBD: [Restructure] Merge with struct above */ + +typedef struct acpi_walk_info +{ + UINT32 DebugLevel; + UINT32 Count; + ACPI_OWNER_ID OwnerId; + UINT8 DisplayType; + +} ACPI_WALK_INFO; + +/* Display Types */ + +#define ACPI_DISPLAY_SUMMARY (UINT8) 0 +#define ACPI_DISPLAY_OBJECTS (UINT8) 1 +#define ACPI_DISPLAY_MASK (UINT8) 1 + +#define ACPI_DISPLAY_SHORT (UINT8) 2 + + +#endif diff --git a/reactos/drivers/bus/acpi/acpica/include/actables.h b/reactos/drivers/bus/acpi/acpica/include/actables.h new file mode 100644 index 00000000000..e4428e64155 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actables.h @@ -0,0 +1,243 @@ +/****************************************************************************** + * + * Name: actables.h - ACPI table management + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTABLES_H__ +#define __ACTABLES_H__ + + +ACPI_STATUS +AcpiAllocateRootTable ( + UINT32 InitialTableCount); + +/* + * tbfadt - FADT parse/convert/validate + */ +void +AcpiTbParseFadt ( + UINT32 TableIndex); + +void +AcpiTbCreateLocalFadt ( + ACPI_TABLE_HEADER *Table, + UINT32 Length); + + +/* + * tbfind - find ACPI table + */ +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + UINT32 *TableIndex); + + +/* + * tbinstal - Table removal and deletion + */ +ACPI_STATUS +AcpiTbResizeRootTableList ( + void); + +ACPI_STATUS +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc); + +ACPI_STATUS +AcpiTbAddTable ( + ACPI_TABLE_DESC *TableDesc, + UINT32 *TableIndex); + +ACPI_STATUS +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + UINT32 *TableIndex); + +void +AcpiTbDeleteTable ( + ACPI_TABLE_DESC *TableDesc); + +void +AcpiTbTerminate ( + void); + +ACPI_STATUS +AcpiTbDeleteNamespaceByOwner ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbAllocateOwnerId ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbReleaseOwnerId ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbGetOwnerId ( + UINT32 TableIndex, + ACPI_OWNER_ID *OwnerId); + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex); + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded); + + +/* + * tbutils - table manager utilities + */ +ACPI_STATUS +AcpiTbInitializeFacs ( + void); + +BOOLEAN +AcpiTbTablesLoaded ( + void); + +void +AcpiTbPrintTableHeader( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Header); + +UINT8 +AcpiTbChecksum ( + UINT8 *Buffer, + UINT32 Length); + +ACPI_STATUS +AcpiTbVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length); + +void +AcpiTbInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + char *Signature, + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbParseRootTable ( + ACPI_PHYSICAL_ADDRESS RsdpAddress); + +#endif /* __ACTABLES_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/actbl.h b/reactos/drivers/bus/acpi/acpica/include/actbl.h new file mode 100644 index 00000000000..caa3bdbe3b5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actbl.h @@ -0,0 +1,451 @@ +/****************************************************************************** + * + * Name: actbl.h - Basic ACPI Table Definitions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL_H__ +#define __ACTBL_H__ + + +/******************************************************************************* + * + * Fundamental ACPI tables + * + * This file contains definitions for the ACPI tables that are directly consumed + * by ACPICA. All other tables are consumed by the OS-dependent ACPI-related + * device drivers and other OS support code. + * + * The RSDP and FACS do not use the common ACPI table header. All other ACPI + * tables use the header. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_DSDT "DSDT" /* Differentiated System Description Table */ +#define ACPI_SIG_FADT "FACP" /* Fixed ACPI Description Table */ +#define ACPI_SIG_FACS "FACS" /* Firmware ACPI Control Structure */ +#define ACPI_SIG_PSDT "PSDT" /* Persistent System Description Table */ +#define ACPI_SIG_RSDP "RSD PTR " /* Root System Description Pointer */ +#define ACPI_SIG_RSDT "RSDT" /* Root System Description Table */ +#define ACPI_SIG_XSDT "XSDT" /* Extended System Description Table */ +#define ACPI_SIG_SSDT "SSDT" /* Secondary System Description Table */ +#define ACPI_RSDP_NAME "RSDP" /* Short name for RSDP, not signature */ + + +/* + * All tables and structures must be byte-packed to match the ACPI + * specification, since the tables are provided by the system BIOS + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * Master ACPI Table Header. This common header is used by all ACPI tables + * except the RSDP and FACS. + * + ******************************************************************************/ + +typedef struct acpi_table_header +{ + char Signature[ACPI_NAME_SIZE]; /* ASCII table signature */ + UINT32 Length; /* Length of table in bytes, including this header */ + UINT8 Revision; /* ACPI Specification minor version # */ + UINT8 Checksum; /* To make sum of entire table == 0 */ + char OemId[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */ + char OemTableId[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */ + UINT32 OemRevision; /* OEM revision number */ + char AslCompilerId[ACPI_NAME_SIZE]; /* ASCII ASL compiler vendor ID */ + UINT32 AslCompilerRevision; /* ASL compiler version */ + +} ACPI_TABLE_HEADER; + + +/******************************************************************************* + * + * GAS - Generic Address Structure (ACPI 2.0+) + * + * Note: Since this structure is used in the ACPI tables, it is byte aligned. + * If misaliged access is not supported by the hardware, accesses to the + * 64-bit Address field must be performed with care. + * + ******************************************************************************/ + +typedef struct acpi_generic_address +{ + UINT8 SpaceId; /* Address space where struct or register exists */ + UINT8 BitWidth; /* Size in bits of given register */ + UINT8 BitOffset; /* Bit offset within the register */ + UINT8 AccessWidth; /* Minimum Access size (ACPI 3.0) */ + UINT64 Address; /* 64-bit address of struct or register */ + +} ACPI_GENERIC_ADDRESS; + + +/******************************************************************************* + * + * RSDP - Root System Description Pointer (Signature is "RSD PTR ") + * Version 2 + * + ******************************************************************************/ + +typedef struct acpi_table_rsdp +{ + char Signature[8]; /* ACPI signature, contains "RSD PTR " */ + UINT8 Checksum; /* ACPI 1.0 checksum */ + char OemId[ACPI_OEM_ID_SIZE]; /* OEM identification */ + UINT8 Revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ + UINT32 RsdtPhysicalAddress; /* 32-bit physical address of the RSDT */ + UINT32 Length; /* Table length in bytes, including header (ACPI 2.0+) */ + UINT64 XsdtPhysicalAddress; /* 64-bit physical address of the XSDT (ACPI 2.0+) */ + UINT8 ExtendedChecksum; /* Checksum of entire table (ACPI 2.0+) */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + +} ACPI_TABLE_RSDP; + +#define ACPI_RSDP_REV0_SIZE 20 /* Size of original ACPI 1.0 RSDP */ + + +/******************************************************************************* + * + * RSDT/XSDT - Root System Description Tables + * Version 1 (both) + * + ******************************************************************************/ + +typedef struct acpi_table_rsdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + +} ACPI_TABLE_RSDT; + +typedef struct acpi_table_xsdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + +} ACPI_TABLE_XSDT; + + +/******************************************************************************* + * + * FACS - Firmware ACPI Control Structure (FACS) + * + ******************************************************************************/ + +typedef struct acpi_table_facs +{ + char Signature[4]; /* ASCII table signature */ + UINT32 Length; /* Length of structure, in bytes */ + UINT32 HardwareSignature; /* Hardware configuration signature */ + UINT32 FirmwareWakingVector; /* 32-bit physical address of the Firmware Waking Vector */ + UINT32 GlobalLock; /* Global Lock for shared hardware resources */ + UINT32 Flags; + UINT64 XFirmwareWakingVector; /* 64-bit version of the Firmware Waking Vector (ACPI 2.0+) */ + UINT8 Version; /* Version of this table (ACPI 2.0+) */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 OspmFlags; /* Flags to be set by OSPM (ACPI 4.0) */ + UINT8 Reserved1[24]; /* Reserved, must be zero */ + +} ACPI_TABLE_FACS; + +/* Masks for GlobalLock flag field above */ + +#define ACPI_GLOCK_PENDING (1) /* 00: Pending global lock ownership */ +#define ACPI_GLOCK_OWNED (1<<1) /* 01: Global lock is owned */ + +/* Masks for Flags field above */ + +#define ACPI_FACS_S4_BIOS_PRESENT (1) /* 00: S4BIOS support is present */ +#define ACPI_FACS_64BIT_WAKE (1<<1) /* 01: 64-bit wake vector supported (ACPI 4.0) */ + +/* Masks for OspmFlags field above */ + +#define ACPI_FACS_64BIT_ENVIRONMENT (1) /* 00: 64-bit wake environment is required (ACPI 4.0) */ + + +/******************************************************************************* + * + * FADT - Fixed ACPI Description Table (Signature "FACP") + * Version 4 + * + ******************************************************************************/ + +/* Fields common to all versions of the FADT */ + +typedef struct acpi_table_fadt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Facs; /* 32-bit physical address of FACS */ + UINT32 Dsdt; /* 32-bit physical address of DSDT */ + UINT8 Model; /* System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ + UINT8 PreferredProfile; /* Conveys preferred power management profile to OSPM. */ + UINT16 SciInterrupt; /* System vector of SCI interrupt */ + UINT32 SmiCommand; /* 32-bit Port address of SMI command port */ + UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */ + UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */ + UINT8 S4BiosRequest; /* Value to write to SMI CMD to enter S4BIOS state */ + UINT8 PstateControl; /* Processor performance state control*/ + UINT32 Pm1aEventBlock; /* 32-bit Port address of Power Mgt 1a Event Reg Blk */ + UINT32 Pm1bEventBlock; /* 32-bit Port address of Power Mgt 1b Event Reg Blk */ + UINT32 Pm1aControlBlock; /* 32-bit Port address of Power Mgt 1a Control Reg Blk */ + UINT32 Pm1bControlBlock; /* 32-bit Port address of Power Mgt 1b Control Reg Blk */ + UINT32 Pm2ControlBlock; /* 32-bit Port address of Power Mgt 2 Control Reg Blk */ + UINT32 PmTimerBlock; /* 32-bit Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT32 Gpe0Block; /* 32-bit Port address of General Purpose Event 0 Reg Blk */ + UINT32 Gpe1Block; /* 32-bit Port address of General Purpose Event 1 Reg Blk */ + UINT8 Pm1EventLength; /* Byte Length of ports at Pm1xEventBlock */ + UINT8 Pm1ControlLength; /* Byte Length of ports at Pm1xControlBlock */ + UINT8 Pm2ControlLength; /* Byte Length of ports at Pm2ControlBlock */ + UINT8 PmTimerLength; /* Byte Length of ports at PmTimerBlock */ + UINT8 Gpe0BlockLength; /* Byte Length of ports at Gpe0Block */ + UINT8 Gpe1BlockLength; /* Byte Length of ports at Gpe1Block */ + UINT8 Gpe1Base; /* Offset in GPE number space where GPE1 events start */ + UINT8 CstControl; /* Support for the _CST object and C States change notification */ + UINT16 C2Latency; /* Worst case HW latency to enter/exit C2 state */ + UINT16 C3Latency; /* Worst case HW latency to enter/exit C3 state */ + UINT16 FlushSize; /* Processor's memory cache line width, in bytes */ + UINT16 FlushStride; /* Number of flush strides that need to be read */ + UINT8 DutyOffset; /* Processor duty cycle index in processor's P_CNT reg */ + UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register */ + UINT8 DayAlarm; /* Index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonthAlarm; /* Index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* Index to century in RTC CMOS RAM */ + UINT16 BootFlags; /* IA-PC Boot Architecture Flags (see below for individual flags) */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ + ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ + UINT8 Reserved4[3]; /* Reserved, must be zero */ + UINT64 XFacs; /* 64-bit physical address of FACS */ + UINT64 XDsdt; /* 64-bit physical address of DSDT */ + ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPmTimerBlock; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe0Block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe1Block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ + +} ACPI_TABLE_FADT; + + +/* Masks for FADT Boot Architecture Flags (BootFlags) */ + +#define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */ +#define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */ +#define ACPI_FADT_NO_VGA (1<<2) /* 02: [V4] It is not safe to probe for VGA hardware */ +#define ACPI_FADT_NO_MSI (1<<3) /* 03: [V4] Message Signaled Interrupts (MSI) must not be enabled */ +#define ACPI_FADT_NO_ASPM (1<<4) /* 04: [V4] PCIe ASPM control must not be enabled */ + +/* Masks for FADT flags */ + +#define ACPI_FADT_WBINVD (1) /* 00: [V1] The wbinvd instruction works properly */ +#define ACPI_FADT_WBINVD_FLUSH (1<<1) /* 01: [V1] wbinvd flushes but does not invalidate caches */ +#define ACPI_FADT_C1_SUPPORTED (1<<2) /* 02: [V1] All processors support C1 state */ +#define ACPI_FADT_C2_MP_SUPPORTED (1<<3) /* 03: [V1] C2 state works on MP system */ +#define ACPI_FADT_POWER_BUTTON (1<<4) /* 04: [V1] Power button is handled as a control method device */ +#define ACPI_FADT_SLEEP_BUTTON (1<<5) /* 05: [V1] Sleep button is handled as a control method device */ +#define ACPI_FADT_FIXED_RTC (1<<6) /* 06: [V1] RTC wakeup status not in fixed register space */ +#define ACPI_FADT_S4_RTC_WAKE (1<<7) /* 07: [V1] RTC alarm can wake system from S4 */ +#define ACPI_FADT_32BIT_TIMER (1<<8) /* 08: [V1] ACPI timer width is 32-bit (0=24-bit) */ +#define ACPI_FADT_DOCKING_SUPPORTED (1<<9) /* 09: [V1] Docking supported */ +#define ACPI_FADT_RESET_REGISTER (1<<10) /* 10: [V2] System reset via the FADT RESET_REG supported */ +#define ACPI_FADT_SEALED_CASE (1<<11) /* 11: [V3] No internal expansion capabilities and case is sealed */ +#define ACPI_FADT_HEADLESS (1<<12) /* 12: [V3] No local video capabilities or local input devices */ +#define ACPI_FADT_SLEEP_TYPE (1<<13) /* 13: [V3] Must execute native instruction after writing SLP_TYPx register */ +#define ACPI_FADT_PCI_EXPRESS_WAKE (1<<14) /* 14: [V4] System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ +#define ACPI_FADT_PLATFORM_CLOCK (1<<15) /* 15: [V4] OSPM should use platform-provided timer (ACPI 3.0) */ +#define ACPI_FADT_S4_RTC_VALID (1<<16) /* 16: [V4] Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ +#define ACPI_FADT_REMOTE_POWER_ON (1<<17) /* 17: [V4] System is compatible with remote power on (ACPI 3.0) */ +#define ACPI_FADT_APIC_CLUSTER (1<<18) /* 18: [V4] All local APICs must use cluster model (ACPI 3.0) */ +#define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: [V4] All local xAPICs must use physical dest mode (ACPI 3.0) */ + + +/* Values for PreferredProfile (Prefered Power Management Profiles) */ + +enum AcpiPreferedPmProfiles +{ + PM_UNSPECIFIED = 0, + PM_DESKTOP = 1, + PM_MOBILE = 2, + PM_WORKSTATION = 3, + PM_ENTERPRISE_SERVER = 4, + PM_SOHO_SERVER = 5, + PM_APPLIANCE_PC = 6 +}; + + +/* Reset to default packing */ + +#pragma pack() + + +/* + * Internal table-related structures + */ +typedef union acpi_name_union +{ + UINT32 Integer; + char Ascii[4]; + +} ACPI_NAME_UNION; + + +/* Internal ACPI Table Descriptor. One per ACPI table. */ + +typedef struct acpi_table_desc +{ + ACPI_PHYSICAL_ADDRESS Address; + ACPI_TABLE_HEADER *Pointer; + UINT32 Length; /* Length fixed at 32 bits */ + ACPI_NAME_UNION Signature; + ACPI_OWNER_ID OwnerId; + UINT8 Flags; + +} ACPI_TABLE_DESC; + +/* Masks for Flags field above */ + +#define ACPI_TABLE_ORIGIN_UNKNOWN (0) +#define ACPI_TABLE_ORIGIN_MAPPED (1) +#define ACPI_TABLE_ORIGIN_ALLOCATED (2) +#define ACPI_TABLE_ORIGIN_OVERRIDE (4) +#define ACPI_TABLE_ORIGIN_MASK (7) +#define ACPI_TABLE_IS_LOADED (8) + + +/* + * Get the remaining ACPI tables + */ +#include "actbl1.h" +#include "actbl2.h" + +/* Macros used to generate offsets to specific table fields */ + +#define ACPI_FADT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_FADT, f) + +#endif /* __ACTBL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/actbl1.h b/reactos/drivers/bus/acpi/acpica/include/actbl1.h new file mode 100644 index 00000000000..8af7a183808 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actbl1.h @@ -0,0 +1,1145 @@ +/****************************************************************************** + * + * Name: actbl1.h - Additional ACPI table definitions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL1_H__ +#define __ACTBL1_H__ + + +/******************************************************************************* + * + * Additional ACPI Tables (1) + * + * These tables are not consumed directly by the ACPICA subsystem, but are + * included here to support device drivers and the AML disassembler. + * + * The tables in this file are fully defined within the ACPI specification. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */ +#define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling table */ +#define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */ +#define ACPI_SIG_EINJ "EINJ" /* Error Injection table */ +#define ACPI_SIG_ERST "ERST" /* Error Record Serialization Table */ +#define ACPI_SIG_HEST "HEST" /* Hardware Error Source Table */ +#define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ +#define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table */ +#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ +#define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ +#define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */ + + +/* + * All tables must be byte-packed to match the ACPI specification, since + * the tables are provided by the system BIOS. + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * Common subtable headers + * + ******************************************************************************/ + +/* Generic subtable header (used in MADT, SRAT, etc.) */ + +typedef struct acpi_subtable_header +{ + UINT8 Type; + UINT8 Length; + +} ACPI_SUBTABLE_HEADER; + + +/* Subtable header for WHEA tables (EINJ, ERST, WDAT) */ + +typedef struct acpi_whea_header +{ + UINT8 Action; + UINT8 Instruction; + UINT8 Flags; + UINT8 Reserved; + ACPI_GENERIC_ADDRESS RegisterRegion; + UINT64 Value; /* Value used with Read/Write register */ + UINT64 Mask; /* Bitmask required for this register instruction */ + +} ACPI_WHEA_HEADER; + + +/******************************************************************************* + * + * BERT - Boot Error Record Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_bert +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 RegionLength; /* Length of the boot error region */ + UINT64 Address; /* Physical addresss of the error region */ + +} ACPI_TABLE_BERT; + + +/* Boot Error Region (not a subtable, pointed to by Address field above) */ + +typedef struct acpi_bert_region +{ + UINT32 BlockStatus; /* Type of error information */ + UINT32 RawDataOffset; /* Offset to raw error data */ + UINT32 RawDataLength; /* Length of raw error data */ + UINT32 DataLength; /* Length of generic error data */ + UINT32 ErrorSeverity; /* Severity code */ + +} ACPI_BERT_REGION; + +/* Values for BlockStatus flags above */ + +#define ACPI_BERT_UNCORRECTABLE (1) +#define ACPI_BERT_CORRECTABLE (1<<1) +#define ACPI_BERT_MULTIPLE_UNCORRECTABLE (1<<2) +#define ACPI_BERT_MULTIPLE_CORRECTABLE (1<<3) +#define ACPI_BERT_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ + +/* Values for ErrorSeverity above */ + +enum AcpiBertErrorSeverity +{ + ACPI_BERT_ERROR_CORRECTABLE = 0, + ACPI_BERT_ERROR_FATAL = 1, + ACPI_BERT_ERROR_CORRECTED = 2, + ACPI_BERT_ERROR_NONE = 3, + ACPI_BERT_ERROR_RESERVED = 4 /* 4 and greater are reserved */ +}; + +/* + * Note: The generic error data that follows the ErrorSeverity field above + * uses the ACPI_HEST_GENERIC_DATA defined under the HEST table below + */ + + +/******************************************************************************* + * + * CPEP - Corrected Platform Error Polling table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_cpep +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 Reserved; + +} ACPI_TABLE_CPEP; + + +/* Subtable */ + +typedef struct acpi_cpep_polling +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* Processor ID */ + UINT8 Eid; /* Processor EID */ + UINT32 Interval; /* Polling interval (msec) */ + +} ACPI_CPEP_POLLING; + + +/******************************************************************************* + * + * ECDT - Embedded Controller Boot Resources Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_ecdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_GENERIC_ADDRESS Control; /* Address of EC command/status register */ + ACPI_GENERIC_ADDRESS Data; /* Address of EC data register */ + UINT32 Uid; /* Unique ID - must be same as the EC _UID method */ + UINT8 Gpe; /* The GPE for the EC */ + UINT8 Id[1]; /* Full namepath of the EC in the ACPI namespace */ + +} ACPI_TABLE_ECDT; + + +/******************************************************************************* + * + * EINJ - Error Injection Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_einj +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; + UINT8 Flags; + UINT8 Reserved[3]; + UINT32 Entries; + +} ACPI_TABLE_EINJ; + + +/* EINJ Injection Instruction Entries (actions) */ + +typedef struct acpi_einj_entry +{ + ACPI_WHEA_HEADER WheaHeader; /* Common header for WHEA tables */ + +} ACPI_EINJ_ENTRY; + +/* Masks for Flags field above */ + +#define ACPI_EINJ_PRESERVE (1) + +/* Values for Action field above */ + +enum AcpiEinjActions +{ + ACPI_EINJ_BEGIN_OPERATION = 0, + ACPI_EINJ_GET_TRIGGER_TABLE = 1, + ACPI_EINJ_SET_ERROR_TYPE = 2, + ACPI_EINJ_GET_ERROR_TYPE = 3, + ACPI_EINJ_END_OPERATION = 4, + ACPI_EINJ_EXECUTE_OPERATION = 5, + ACPI_EINJ_CHECK_BUSY_STATUS = 6, + ACPI_EINJ_GET_COMMAND_STATUS = 7, + ACPI_EINJ_ACTION_RESERVED = 8, /* 8 and greater are reserved */ + ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */ +}; + +/* Values for Instruction field above */ + +enum AcpiEinjInstructions +{ + ACPI_EINJ_READ_REGISTER = 0, + ACPI_EINJ_READ_REGISTER_VALUE = 1, + ACPI_EINJ_WRITE_REGISTER = 2, + ACPI_EINJ_WRITE_REGISTER_VALUE = 3, + ACPI_EINJ_NOOP = 4, + ACPI_EINJ_INSTRUCTION_RESERVED = 5 /* 5 and greater are reserved */ +}; + + +/* EINJ Trigger Error Action Table */ + +typedef struct acpi_einj_trigger +{ + UINT32 HeaderSize; + UINT32 Revision; + UINT32 TableSize; + UINT32 EntryCount; + +} ACPI_EINJ_TRIGGER; + +/* Command status return values */ + +enum AcpiEinjCommandStatus +{ + ACPI_EINJ_SUCCESS = 0, + ACPI_EINJ_FAILURE = 1, + ACPI_EINJ_INVALID_ACCESS = 2, + ACPI_EINJ_STATUS_RESERVED = 3 /* 3 and greater are reserved */ +}; + + +/* Error types returned from ACPI_EINJ_GET_ERROR_TYPE (bitfield) */ + +#define ACPI_EINJ_PROCESSOR_CORRECTABLE (1) +#define ACPI_EINJ_PROCESSOR_UNCORRECTABLE (1<<1) +#define ACPI_EINJ_PROCESSOR_FATAL (1<<2) +#define ACPI_EINJ_MEMORY_CORRECTABLE (1<<3) +#define ACPI_EINJ_MEMORY_UNCORRECTABLE (1<<4) +#define ACPI_EINJ_MEMORY_FATAL (1<<5) +#define ACPI_EINJ_PCIX_CORRECTABLE (1<<6) +#define ACPI_EINJ_PCIX_UNCORRECTABLE (1<<7) +#define ACPI_EINJ_PCIX_FATAL (1<<8) +#define ACPI_EINJ_PLATFORM_CORRECTABLE (1<<9) +#define ACPI_EINJ_PLATFORM_UNCORRECTABLE (1<<10) +#define ACPI_EINJ_PLATFORM_FATAL (1<<11) + + +/******************************************************************************* + * + * ERST - Error Record Serialization Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_erst +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; + UINT32 Reserved; + UINT32 Entries; + +} ACPI_TABLE_ERST; + + +/* ERST Serialization Entries (actions) */ + +typedef struct acpi_erst_entry +{ + ACPI_WHEA_HEADER WheaHeader; /* Common header for WHEA tables */ + +} ACPI_ERST_ENTRY; + +/* Masks for Flags field above */ + +#define ACPI_ERST_PRESERVE (1) + +/* Values for Action field above */ + +enum AcpiErstActions +{ + ACPI_ERST_BEGIN_WRITE = 0, + ACPI_ERST_BEGIN_READ = 1, + ACPI_ERST_BEGIN_CLEAR = 2, + ACPI_ERST_END = 3, + ACPI_ERST_SET_RECORD_OFFSET = 4, + ACPI_ERST_EXECUTE_OPERATION = 5, + ACPI_ERST_CHECK_BUSY_STATUS = 6, + ACPI_ERST_GET_COMMAND_STATUS = 7, + ACPI_ERST_GET_RECORD_ID = 8, + ACPI_ERST_SET_RECORD_ID = 9, + ACPI_ERST_GET_RECORD_COUNT = 10, + ACPI_ERST_BEGIN_DUMMY_WRIITE = 11, + ACPI_ERST_NOT_USED = 12, + ACPI_ERST_GET_ERROR_RANGE = 13, + ACPI_ERST_GET_ERROR_LENGTH = 14, + ACPI_ERST_GET_ERROR_ATTRIBUTES = 15, + ACPI_ERST_ACTION_RESERVED = 16 /* 16 and greater are reserved */ +}; + +/* Values for Instruction field above */ + +enum AcpiErstInstructions +{ + ACPI_ERST_READ_REGISTER = 0, + ACPI_ERST_READ_REGISTER_VALUE = 1, + ACPI_ERST_WRITE_REGISTER = 2, + ACPI_ERST_WRITE_REGISTER_VALUE = 3, + ACPI_ERST_NOOP = 4, + ACPI_ERST_LOAD_VAR1 = 5, + ACPI_ERST_LOAD_VAR2 = 6, + ACPI_ERST_STORE_VAR1 = 7, + ACPI_ERST_ADD = 8, + ACPI_ERST_SUBTRACT = 9, + ACPI_ERST_ADD_VALUE = 10, + ACPI_ERST_SUBTRACT_VALUE = 11, + ACPI_ERST_STALL = 12, + ACPI_ERST_STALL_WHILE_TRUE = 13, + ACPI_ERST_SKIP_NEXT_IF_TRUE = 14, + ACPI_ERST_GOTO = 15, + ACPI_ERST_SET_SRC_ADDRESS_BASE = 16, + ACPI_ERST_SET_DST_ADDRESS_BASE = 17, + ACPI_ERST_MOVE_DATA = 18, + ACPI_ERST_INSTRUCTION_RESERVED = 19 /* 19 and greater are reserved */ +}; + +/* Command status return values */ + +enum AcpiErstCommandStatus +{ + ACPI_ERST_SUCESS = 0, + ACPI_ERST_NO_SPACE = 1, + ACPI_ERST_NOT_AVAILABLE = 2, + ACPI_ERST_FAILURE = 3, + ACPI_ERST_RECORD_EMPTY = 4, + ACPI_ERST_NOT_FOUND = 5, + ACPI_ERST_STATUS_RESERVED = 6 /* 6 and greater are reserved */ +}; + + +/* Error Record Serialization Information */ + +typedef struct acpi_erst_info +{ + UINT16 Signature; /* Should be "ER" */ + UINT8 Data[48]; + +} ACPI_ERST_INFO; + + +/******************************************************************************* + * + * HEST - Hardware Error Source Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_hest +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 ErrorSourceCount; + +} ACPI_TABLE_HEST; + + +/* HEST subtable header */ + +typedef struct acpi_hest_header +{ + UINT16 Type; + UINT16 SourceId; + +} ACPI_HEST_HEADER; + + +/* Values for Type field above for subtables */ + +enum AcpiHestTypes +{ + ACPI_HEST_TYPE_IA32_CHECK = 0, + ACPI_HEST_TYPE_IA32_CORRECTED_CHECK = 1, + ACPI_HEST_TYPE_IA32_NMI = 2, + ACPI_HEST_TYPE_NOT_USED3 = 3, + ACPI_HEST_TYPE_NOT_USED4 = 4, + ACPI_HEST_TYPE_NOT_USED5 = 5, + ACPI_HEST_TYPE_AER_ROOT_PORT = 6, + ACPI_HEST_TYPE_AER_ENDPOINT = 7, + ACPI_HEST_TYPE_AER_BRIDGE = 8, + ACPI_HEST_TYPE_GENERIC_ERROR = 9, + ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */ +}; + + +/* + * HEST substructures contained in subtables + */ + +/* + * IA32 Error Bank(s) - Follows the ACPI_HEST_IA_MACHINE_CHECK and + * ACPI_HEST_IA_CORRECTED structures. + */ +typedef struct acpi_hest_ia_error_bank +{ + UINT8 BankNumber; + UINT8 ClearStatusOnInit; + UINT8 StatusFormat; + UINT8 Reserved; + UINT32 ControlRegister; + UINT64 ControlData; + UINT32 StatusRegister; + UINT32 AddressRegister; + UINT32 MiscRegister; + +} ACPI_HEST_IA_ERROR_BANK; + + +/* Common HEST sub-structure for PCI/AER structures below (6,7,8) */ + +typedef struct acpi_hest_aer_common +{ + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 Bus; + UINT16 Device; + UINT16 Function; + UINT16 DeviceControl; + UINT16 Reserved2; + UINT32 UncorrectableMask; + UINT32 UncorrectableSeverity; + UINT32 CorrectableMask; + UINT32 AdvancedCapabilities; + +} ACPI_HEST_AER_COMMON; + +/* Masks for HEST Flags fields */ + +#define ACPI_HEST_FIRMWARE_FIRST (1) +#define ACPI_HEST_GLOBAL (1<<1) + + +/* Hardware Error Notification */ + +typedef struct acpi_hest_notify +{ + UINT8 Type; + UINT8 Length; + UINT16 ConfigWriteEnable; + UINT32 PollInterval; + UINT32 Vector; + UINT32 PollingThresholdValue; + UINT32 PollingThresholdWindow; + UINT32 ErrorThresholdValue; + UINT32 ErrorThresholdWindow; + +} ACPI_HEST_NOTIFY; + +/* Values for Notify Type field above */ + +enum AcpiHestNotifyTypes +{ + ACPI_HEST_NOTIFY_POLLED = 0, + ACPI_HEST_NOTIFY_EXTERNAL = 1, + ACPI_HEST_NOTIFY_LOCAL = 2, + ACPI_HEST_NOTIFY_SCI = 3, + ACPI_HEST_NOTIFY_NMI = 4, + ACPI_HEST_NOTIFY_RESERVED = 5 /* 5 and greater are reserved */ +}; + +/* Values for ConfigWriteEnable bitfield above */ + +#define ACPI_HEST_TYPE (1) +#define ACPI_HEST_POLL_INTERVAL (1<<1) +#define ACPI_HEST_POLL_THRESHOLD_VALUE (1<<2) +#define ACPI_HEST_POLL_THRESHOLD_WINDOW (1<<3) +#define ACPI_HEST_ERR_THRESHOLD_VALUE (1<<4) +#define ACPI_HEST_ERR_THRESHOLD_WINDOW (1<<5) + + +/* + * HEST subtables + */ + +/* 0: IA32 Machine Check Exception */ + +typedef struct acpi_hest_ia_machine_check +{ + ACPI_HEST_HEADER Header; + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT64 GlobalCapabilityData; + UINT64 GlobalControlData; + UINT8 NumHardwareBanks; + UINT8 Reserved3[7]; + +} ACPI_HEST_IA_MACHINE_CHECK; + + +/* 1: IA32 Corrected Machine Check */ + +typedef struct acpi_hest_ia_corrected +{ + ACPI_HEST_HEADER Header; + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + ACPI_HEST_NOTIFY Notify; + UINT8 NumHardwareBanks; + UINT8 Reserved2[3]; + +} ACPI_HEST_IA_CORRECTED; + + +/* 2: IA32 Non-Maskable Interrupt */ + +typedef struct acpi_hest_ia_nmi +{ + ACPI_HEST_HEADER Header; + UINT32 Reserved; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 MaxRawDataLength; + +} ACPI_HEST_IA_NMI; + + +/* 3,4,5: Not used */ + +/* 6: PCI Express Root Port AER */ + +typedef struct acpi_hest_aer_root +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + UINT32 RootErrorCommand; + +} ACPI_HEST_AER_ROOT; + + +/* 7: PCI Express AER (AER Endpoint) */ + +typedef struct acpi_hest_aer +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + +} ACPI_HEST_AER; + + +/* 8: PCI Express/PCI-X Bridge AER */ + +typedef struct acpi_hest_aer_bridge +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + UINT32 UncorrectableMask2; + UINT32 UncorrectableSeverity2; + UINT32 AdvancedCapabilities2; + +} ACPI_HEST_AER_BRIDGE; + + +/* 9: Generic Hardware Error Source */ + +typedef struct acpi_hest_generic +{ + ACPI_HEST_HEADER Header; + UINT16 RelatedSourceId; + UINT8 Reserved; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 MaxRawDataLength; + ACPI_GENERIC_ADDRESS ErrorStatusAddress; + ACPI_HEST_NOTIFY Notify; + UINT32 ErrorBlockLength; + +} ACPI_HEST_GENERIC; + + +/* Generic Error Status block */ + +typedef struct acpi_hest_generic_status +{ + UINT32 BlockStatus; + UINT32 RawDataOffset; + UINT32 RawDataLength; + UINT32 DataLength; + UINT32 ErrorSeverity; + +} ACPI_HEST_GENERIC_STATUS; + +/* Values for BlockStatus flags above */ + +#define ACPI_HEST_UNCORRECTABLE (1) +#define ACPI_HEST_CORRECTABLE (1<<1) +#define ACPI_HEST_MULTIPLE_UNCORRECTABLE (1<<2) +#define ACPI_HEST_MULTIPLE_CORRECTABLE (1<<3) +#define ACPI_HEST_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ + + +/* Generic Error Data entry */ + +typedef struct acpi_hest_generic_data +{ + UINT8 SectionType[16]; + UINT32 ErrorSeverity; + UINT16 Revision; + UINT8 ValidationBits; + UINT8 Flags; + UINT32 ErrorDataLength; + UINT8 FruId[16]; + UINT8 FruText[20]; + +} ACPI_HEST_GENERIC_DATA; + + +/******************************************************************************* + * + * MADT - Multiple APIC Description Table + * Version 3 + * + ******************************************************************************/ + +typedef struct acpi_table_madt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Address; /* Physical address of local APIC */ + UINT32 Flags; + +} ACPI_TABLE_MADT; + +/* Masks for Flags field above */ + +#define ACPI_MADT_PCAT_COMPAT (1) /* 00: System also has dual 8259s */ + +/* Values for PCATCompat flag */ + +#define ACPI_MADT_DUAL_PIC 0 +#define ACPI_MADT_MULTIPLE_APIC 1 + + +/* Values for MADT subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiMadtType +{ + ACPI_MADT_TYPE_LOCAL_APIC = 0, + ACPI_MADT_TYPE_IO_APIC = 1, + ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, + ACPI_MADT_TYPE_NMI_SOURCE = 3, + ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, + ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, + ACPI_MADT_TYPE_IO_SAPIC = 6, + ACPI_MADT_TYPE_LOCAL_SAPIC = 7, + ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, + ACPI_MADT_TYPE_LOCAL_X2APIC = 9, + ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, + ACPI_MADT_TYPE_RESERVED = 11 /* 11 and greater are reserved */ +}; + + +/* + * MADT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + */ + +/* 0: Processor Local APIC */ + +typedef struct acpi_madt_local_apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT8 Id; /* Processor's local APIC id */ + UINT32 LapicFlags; + +} ACPI_MADT_LOCAL_APIC; + + +/* 1: IO APIC */ + +typedef struct acpi_madt_io_apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* I/O APIC ID */ + UINT8 Reserved; /* Reserved - must be zero */ + UINT32 Address; /* APIC physical address */ + UINT32 GlobalIrqBase; /* Global system interrupt where INTI lines start */ + +} ACPI_MADT_IO_APIC; + + +/* 2: Interrupt Override */ + +typedef struct acpi_madt_interrupt_override +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Bus; /* 0 - ISA */ + UINT8 SourceIrq; /* Interrupt source (IRQ) */ + UINT32 GlobalIrq; /* Global system interrupt */ + UINT16 IntiFlags; + +} ACPI_MADT_INTERRUPT_OVERRIDE; + + +/* 3: NMI Source */ + +typedef struct acpi_madt_nmi_source +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT32 GlobalIrq; /* Global system interrupt */ + +} ACPI_MADT_NMI_SOURCE; + + +/* 4: Local APIC NMI */ + +typedef struct acpi_madt_local_apic_nmi +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT16 IntiFlags; + UINT8 Lint; /* LINTn to which NMI is connected */ + +} ACPI_MADT_LOCAL_APIC_NMI; + + +/* 5: Address Override */ + +typedef struct acpi_madt_local_apic_override +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved, must be zero */ + UINT64 Address; /* APIC physical address */ + +} ACPI_MADT_LOCAL_APIC_OVERRIDE; + + +/* 6: I/O Sapic */ + +typedef struct acpi_madt_io_sapic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* I/O SAPIC ID */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 GlobalIrqBase; /* Global interrupt for SAPIC start */ + UINT64 Address; /* SAPIC physical address */ + +} ACPI_MADT_IO_SAPIC; + + +/* 7: Local Sapic */ + +typedef struct acpi_madt_local_sapic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT8 Id; /* SAPIC ID */ + UINT8 Eid; /* SAPIC EID */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 LapicFlags; + UINT32 Uid; /* Numeric UID - ACPI 3.0 */ + char UidString[1]; /* String UID - ACPI 3.0 */ + +} ACPI_MADT_LOCAL_SAPIC; + + +/* 8: Platform Interrupt Source */ + +typedef struct acpi_madt_interrupt_source +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT8 Type; /* 1=PMI, 2=INIT, 3=corrected */ + UINT8 Id; /* Processor ID */ + UINT8 Eid; /* Processor EID */ + UINT8 IoSapicVector; /* Vector value for PMI interrupts */ + UINT32 GlobalIrq; /* Global system interrupt */ + UINT32 Flags; /* Interrupt Source Flags */ + +} ACPI_MADT_INTERRUPT_SOURCE; + +/* Masks for Flags field above */ + +#define ACPI_MADT_CPEI_OVERRIDE (1) + + +/* 9: Processor Local X2APIC (ACPI 4.0) */ + +typedef struct acpi_madt_local_x2apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved - must be zero */ + UINT32 LocalApicId; /* Processor x2APIC ID */ + UINT32 LapicFlags; + UINT32 Uid; /* ACPI processor UID */ + +} ACPI_MADT_LOCAL_X2APIC; + + +/* 10: Local X2APIC NMI (ACPI 4.0) */ + +typedef struct acpi_madt_local_x2apic_nmi +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT32 Uid; /* ACPI processor UID */ + UINT8 Lint; /* LINTn to which NMI is connected */ + UINT8 Reserved[3]; /* Reserved - must be zero */ + +} ACPI_MADT_LOCAL_X2APIC_NMI; + + +/* + * Common flags fields for MADT subtables + */ + +/* MADT Local APIC flags (LapicFlags) */ + +#define ACPI_MADT_ENABLED (1) /* 00: Processor is usable if set */ + +/* MADT MPS INTI flags (IntiFlags) */ + +#define ACPI_MADT_POLARITY_MASK (3) /* 00-01: Polarity of APIC I/O input signals */ +#define ACPI_MADT_TRIGGER_MASK (3<<2) /* 02-03: Trigger mode of APIC input signals */ + +/* Values for MPS INTI flags */ + +#define ACPI_MADT_POLARITY_CONFORMS 0 +#define ACPI_MADT_POLARITY_ACTIVE_HIGH 1 +#define ACPI_MADT_POLARITY_RESERVED 2 +#define ACPI_MADT_POLARITY_ACTIVE_LOW 3 + +#define ACPI_MADT_TRIGGER_CONFORMS (0) +#define ACPI_MADT_TRIGGER_EDGE (1<<2) +#define ACPI_MADT_TRIGGER_RESERVED (2<<2) +#define ACPI_MADT_TRIGGER_LEVEL (3<<2) + + +/******************************************************************************* + * + * MSCT - Maximum System Characteristics Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_msct +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 ProximityOffset; /* Location of proximity info struct(s) */ + UINT32 MaxProximityDomains;/* Max number of proximity domains */ + UINT32 MaxClockDomains; /* Max number of clock domains */ + UINT64 MaxAddress; /* Max physical address in system */ + +} ACPI_TABLE_MSCT; + + +/* Subtable - Maximum Proximity Domain Information. Version 1 */ + +typedef struct acpi_msct_proximity +{ + UINT8 Revision; + UINT8 Length; + UINT32 RangeStart; /* Start of domain range */ + UINT32 RangeEnd; /* End of domain range */ + UINT32 ProcessorCapacity; + UINT64 MemoryCapacity; /* In bytes */ + +} ACPI_MSCT_PROXIMITY; + + +/******************************************************************************* + * + * SBST - Smart Battery Specification Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_sbst +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 WarningLevel; + UINT32 LowLevel; + UINT32 CriticalLevel; + +} ACPI_TABLE_SBST; + + +/******************************************************************************* + * + * SLIT - System Locality Distance Information Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_slit +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 LocalityCount; + UINT8 Entry[1]; /* Real size = localities^2 */ + +} ACPI_TABLE_SLIT; + + +/******************************************************************************* + * + * SRAT - System Resource Affinity Table + * Version 3 + * + ******************************************************************************/ + +typedef struct acpi_table_srat +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 TableRevision; /* Must be value '1' */ + UINT64 Reserved; /* Reserved, must be zero */ + +} ACPI_TABLE_SRAT; + +/* Values for subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiSratType +{ + ACPI_SRAT_TYPE_CPU_AFFINITY = 0, + ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, + ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY = 2, + ACPI_SRAT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ +}; + +/* + * SRAT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + */ + +/* 0: Processor Local APIC/SAPIC Affinity */ + +typedef struct acpi_srat_cpu_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProximityDomainLo; + UINT8 ApicId; + UINT32 Flags; + UINT8 LocalSapicEid; + UINT8 ProximityDomainHi[3]; + UINT32 Reserved; /* Reserved, must be zero */ + +} ACPI_SRAT_CPU_AFFINITY; + +/* Flags */ + +#define ACPI_SRAT_CPU_USE_AFFINITY (1) /* 00: Use affinity structure */ + + +/* 1: Memory Affinity */ + +typedef struct acpi_srat_mem_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 ProximityDomain; + UINT16 Reserved; /* Reserved, must be zero */ + UINT64 BaseAddress; + UINT64 Length; + UINT32 Reserved1; + UINT32 Flags; + UINT64 Reserved2; /* Reserved, must be zero */ + +} ACPI_SRAT_MEM_AFFINITY; + +/* Flags */ + +#define ACPI_SRAT_MEM_ENABLED (1) /* 00: Use affinity structure */ +#define ACPI_SRAT_MEM_HOT_PLUGGABLE (1<<1) /* 01: Memory region is hot pluggable */ +#define ACPI_SRAT_MEM_NON_VOLATILE (1<<2) /* 02: Memory region is non-volatile */ + + +/* 2: Processor Local X2_APIC Affinity (ACPI 4.0) */ + +typedef struct acpi_srat_x2apic_cpu_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved, must be zero */ + UINT32 ProximityDomain; + UINT32 ApicId; + UINT32 Flags; + UINT32 ClockDomain; + UINT32 Reserved2; + +} ACPI_SRAT_X2APIC_CPU_AFFINITY; + +/* Flags for ACPI_SRAT_CPU_AFFINITY and ACPI_SRAT_X2APIC_CPU_AFFINITY */ + +#define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ + + +/* Reset to default packing */ + +#pragma pack() + +#endif /* __ACTBL1_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/actbl2.h b/reactos/drivers/bus/acpi/acpica/include/actbl2.h new file mode 100644 index 00000000000..e57c02356cc --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actbl2.h @@ -0,0 +1,1124 @@ +/****************************************************************************** + * + * Name: actbl2.h - ACPI Specification Revision 2.0 Tables + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL2_H__ +#define __ACTBL2_H__ + + +/******************************************************************************* + * + * Additional ACPI Tables (2) + * + * These tables are not consumed directly by the ACPICA subsystem, but are + * included here to support device drivers and the AML disassembler. + * + * The tables in this file are defined by third-party specifications, and are + * not defined directly by the ACPI specification itself. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ +#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ +#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ +#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ +#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ +#define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */ +#define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ +#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ +#define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ +#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ +#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ +#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ +#define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ +#define ACPI_SIG_WAET "WAET" /* Windows ACPI Emulated devices Table */ +#define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */ +#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */ + + +/* + * All tables must be byte-packed to match the ACPI specification, since + * the tables are provided by the system BIOS. + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * ASF - Alert Standard Format table (Signature "ASF!") + * Revision 0x10 + * + * Conforms to the Alert Standard Format Specification V2.0, 23 April 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_asf +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + +} ACPI_TABLE_ASF; + + +/* ASF subtable header */ + +typedef struct acpi_asf_header +{ + UINT8 Type; + UINT8 Reserved; + UINT16 Length; + +} ACPI_ASF_HEADER; + + +/* Values for Type field above */ + +enum AcpiAsfType +{ + ACPI_ASF_TYPE_INFO = 0, + ACPI_ASF_TYPE_ALERT = 1, + ACPI_ASF_TYPE_CONTROL = 2, + ACPI_ASF_TYPE_BOOT = 3, + ACPI_ASF_TYPE_ADDRESS = 4, + ACPI_ASF_TYPE_RESERVED = 5 +}; + +/* + * ASF subtables + */ + +/* 0: ASF Information */ + +typedef struct acpi_asf_info +{ + ACPI_ASF_HEADER Header; + UINT8 MinResetValue; + UINT8 MinPollInterval; + UINT16 SystemId; + UINT32 MfgId; + UINT8 Flags; + UINT8 Reserved2[3]; + +} ACPI_ASF_INFO; + +/* Masks for Flags field above */ + +#define ACPI_ASF_SMBUS_PROTOCOLS (1) + + +/* 1: ASF Alerts */ + +typedef struct acpi_asf_alert +{ + ACPI_ASF_HEADER Header; + UINT8 AssertMask; + UINT8 DeassertMask; + UINT8 Alerts; + UINT8 DataLength; + +} ACPI_ASF_ALERT; + +typedef struct acpi_asf_alert_data +{ + UINT8 Address; + UINT8 Command; + UINT8 Mask; + UINT8 Value; + UINT8 SensorType; + UINT8 Type; + UINT8 Offset; + UINT8 SourceType; + UINT8 Severity; + UINT8 SensorNumber; + UINT8 Entity; + UINT8 Instance; + +} ACPI_ASF_ALERT_DATA; + + +/* 2: ASF Remote Control */ + +typedef struct acpi_asf_remote +{ + ACPI_ASF_HEADER Header; + UINT8 Controls; + UINT8 DataLength; + UINT16 Reserved2; + +} ACPI_ASF_REMOTE; + +typedef struct acpi_asf_control_data +{ + UINT8 Function; + UINT8 Address; + UINT8 Command; + UINT8 Value; + +} ACPI_ASF_CONTROL_DATA; + + +/* 3: ASF RMCP Boot Options */ + +typedef struct acpi_asf_rmcp +{ + ACPI_ASF_HEADER Header; + UINT8 Capabilities[7]; + UINT8 CompletionCode; + UINT32 EnterpriseId; + UINT8 Command; + UINT16 Parameter; + UINT16 BootOptions; + UINT16 OemParameters; + +} ACPI_ASF_RMCP; + + +/* 4: ASF Address */ + +typedef struct acpi_asf_address +{ + ACPI_ASF_HEADER Header; + UINT8 EpromAddress; + UINT8 Devices; + +} ACPI_ASF_ADDRESS; + + +/******************************************************************************* + * + * BOOT - Simple Boot Flag Table + * Version 1 + * + * Conforms to the "Simple Boot Flag Specification", Version 2.1 + * + ******************************************************************************/ + +typedef struct acpi_table_boot +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 CmosIndex; /* Index in CMOS RAM for the boot register */ + UINT8 Reserved[3]; + +} ACPI_TABLE_BOOT; + + +/******************************************************************************* + * + * DBGP - Debug Port table + * Version 1 + * + * Conforms to the "Debug Port Specification", Version 1.00, 2/9/2000 + * + ******************************************************************************/ + +typedef struct acpi_table_dbgp +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Type; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS DebugPort; + +} ACPI_TABLE_DBGP; + + +/******************************************************************************* + * + * DMAR - DMA Remapping table + * Version 1 + * + * Conforms to "Intel Virtualization Technology for Directed I/O", + * Version 1.2, Sept. 2008 + * + ******************************************************************************/ + +typedef struct acpi_table_dmar +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Width; /* Host Address Width */ + UINT8 Flags; + UINT8 Reserved[10]; + +} ACPI_TABLE_DMAR; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_INTR_REMAP (1) + + +/* DMAR subtable header */ + +typedef struct acpi_dmar_header +{ + UINT16 Type; + UINT16 Length; + +} ACPI_DMAR_HEADER; + +/* Values for subtable type in ACPI_DMAR_HEADER */ + +enum AcpiDmarType +{ + ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, + ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, + ACPI_DMAR_TYPE_ATSR = 2, + ACPI_DMAR_HARDWARE_AFFINITY = 3, + ACPI_DMAR_TYPE_RESERVED = 4 /* 4 and greater are reserved */ +}; + + +/* DMAR Device Scope structure */ + +typedef struct acpi_dmar_device_scope +{ + UINT8 EntryType; + UINT8 Length; + UINT16 Reserved; + UINT8 EnumerationId; + UINT8 Bus; + +} ACPI_DMAR_DEVICE_SCOPE; + +/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ + +enum AcpiDmarScopeType +{ + ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, + ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, + ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, + ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, + ACPI_DMAR_SCOPE_TYPE_HPET = 4, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ +}; + +typedef struct acpi_dmar_pci_path +{ + UINT8 Device; + UINT8 Function; + +} ACPI_DMAR_PCI_PATH; + + +/* + * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER + */ + +/* 0: Hardware Unit Definition */ + +typedef struct acpi_dmar_hardware_unit +{ + ACPI_DMAR_HEADER Header; + UINT8 Flags; + UINT8 Reserved; + UINT16 Segment; + UINT64 Address; /* Register Base Address */ + +} ACPI_DMAR_HARDWARE_UNIT; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_INCLUDE_ALL (1) + + +/* 1: Reserved Memory Defininition */ + +typedef struct acpi_dmar_reserved_memory +{ + ACPI_DMAR_HEADER Header; + UINT16 Reserved; + UINT16 Segment; + UINT64 BaseAddress; /* 4K aligned base address */ + UINT64 EndAddress; /* 4K aligned limit address */ + +} ACPI_DMAR_RESERVED_MEMORY; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_ALLOW_ALL (1) + + +/* 2: Root Port ATS Capability Reporting Structure */ + +typedef struct acpi_dmar_atsr +{ + ACPI_DMAR_HEADER Header; + UINT8 Flags; + UINT8 Reserved; + UINT16 Segment; + +} ACPI_DMAR_ATSR; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_ALL_PORTS (1) + + +/* 3: Remapping Hardware Static Affinity Structure */ + +typedef struct acpi_dmar_rhsa +{ + ACPI_DMAR_HEADER Header; + UINT32 Reserved; + UINT64 BaseAddress; + UINT32 ProximityDomain; + +} ACPI_DMAR_RHSA; + + +/******************************************************************************* + * + * HPET - High Precision Event Timer table + * Version 1 + * + * Conforms to "IA-PC HPET (High Precision Event Timers) Specification", + * Version 1.0a, October 2004 + * + ******************************************************************************/ + +typedef struct acpi_table_hpet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Id; /* Hardware ID of event timer block */ + ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */ + UINT8 Sequence; /* HPET sequence number */ + UINT16 MinimumTick; /* Main counter min tick, periodic mode */ + UINT8 Flags; + +} ACPI_TABLE_HPET; + +/* Masks for Flags field above */ + +#define ACPI_HPET_PAGE_PROTECT_MASK (3) + +/* Values for Page Protect flags */ + +enum AcpiHpetPageProtect +{ + ACPI_HPET_NO_PAGE_PROTECT = 0, + ACPI_HPET_PAGE_PROTECT4 = 1, + ACPI_HPET_PAGE_PROTECT64 = 2 +}; + + +/******************************************************************************* + * + * IBFT - Boot Firmware Table + * Version 1 + * + * Conforms to "iSCSI Boot Firmware Table (iBFT) as Defined in ACPI 3.0b + * Specification", Version 1.01, March 1, 2007 + * + * Note: It appears that this table is not intended to appear in the RSDT/XSDT. + * Therefore, it is not currently supported by the disassembler. + * + ******************************************************************************/ + +typedef struct acpi_table_ibft +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[12]; + +} ACPI_TABLE_IBFT; + + +/* IBFT common subtable header */ + +typedef struct acpi_ibft_header +{ + UINT8 Type; + UINT8 Version; + UINT16 Length; + UINT8 Index; + UINT8 Flags; + +} ACPI_IBFT_HEADER; + +/* Values for Type field above */ + +enum AcpiIbftType +{ + ACPI_IBFT_TYPE_NOT_USED = 0, + ACPI_IBFT_TYPE_CONTROL = 1, + ACPI_IBFT_TYPE_INITIATOR = 2, + ACPI_IBFT_TYPE_NIC = 3, + ACPI_IBFT_TYPE_TARGET = 4, + ACPI_IBFT_TYPE_EXTENSIONS = 5, + ACPI_IBFT_TYPE_RESERVED = 6 /* 6 and greater are reserved */ +}; + + +/* IBFT subtables */ + +typedef struct acpi_ibft_control +{ + ACPI_IBFT_HEADER Header; + UINT16 Extensions; + UINT16 InitiatorOffset; + UINT16 Nic0Offset; + UINT16 Target0Offset; + UINT16 Nic1Offset; + UINT16 Target1Offset; + +} ACPI_IBFT_CONTROL; + +typedef struct acpi_ibft_initiator +{ + ACPI_IBFT_HEADER Header; + UINT8 SnsServer[16]; + UINT8 SlpServer[16]; + UINT8 PrimaryServer[16]; + UINT8 SecondaryServer[16]; + UINT16 NameLength; + UINT16 NameOffset; + +} ACPI_IBFT_INITIATOR; + +typedef struct acpi_ibft_nic +{ + ACPI_IBFT_HEADER Header; + UINT8 IpAddress[16]; + UINT8 SubnetMaskPrefix; + UINT8 Origin; + UINT8 Gateway[16]; + UINT8 PrimaryDns[16]; + UINT8 SecondaryDns[16]; + UINT8 Dhcp[16]; + UINT16 Vlan; + UINT8 MacAddress[6]; + UINT16 PciAddress; + UINT16 NameLength; + UINT16 NameOffset; + +} ACPI_IBFT_NIC; + +typedef struct acpi_ibft_target +{ + ACPI_IBFT_HEADER Header; + UINT8 TargetIpAddress[16]; + UINT16 TargetIpSocket; + UINT8 TargetBootLun[8]; + UINT8 ChapType; + UINT8 NicAssociation; + UINT16 TargetNameLength; + UINT16 TargetNameOffset; + UINT16 ChapNameLength; + UINT16 ChapNameOffset; + UINT16 ChapSecretLength; + UINT16 ChapSecretOffset; + UINT16 ReverseChapNameLength; + UINT16 ReverseChapNameOffset; + UINT16 ReverseChapSecretLength; + UINT16 ReverseChapSecretOffset; + +} ACPI_IBFT_TARGET; + + +/******************************************************************************* + * + * IVRS - I/O Virtualization Reporting Structure + * Version 1 + * + * Conforms to "AMD I/O Virtualization Technology (IOMMU) Specification", + * Revision 1.26, February 2009. + * + ******************************************************************************/ + +typedef struct acpi_table_ivrs +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Info; /* Common virtualization info */ + UINT64 Reserved; + +} ACPI_TABLE_IVRS; + +/* Values for Info field above */ + +#define ACPI_IVRS_PHYSICAL_SIZE 0x00007F00 /* 7 bits, physical address size */ +#define ACPI_IVRS_VIRTUAL_SIZE 0x003F8000 /* 7 bits, virtual address size */ +#define ACPI_IVRS_ATS_RESERVED 0x00400000 /* ATS address translation range reserved */ + + +/* IVRS subtable header */ + +typedef struct acpi_ivrs_header +{ + UINT8 Type; /* Subtable type */ + UINT8 Flags; + UINT16 Length; /* Subtable length */ + UINT16 DeviceId; /* ID of IOMMU */ + +} ACPI_IVRS_HEADER; + +/* Values for subtable Type above */ + +enum AcpiIvrsType +{ + ACPI_IVRS_TYPE_HARDWARE = 0x10, + ACPI_IVRS_TYPE_MEMORY1 = 0x20, + ACPI_IVRS_TYPE_MEMORY2 = 0x21, + ACPI_IVRS_TYPE_MEMORY3 = 0x22 +}; + +/* Masks for Flags field above for IVHD subtable */ + +#define ACPI_IVHD_TT_ENABLE (1) +#define ACPI_IVHD_PASS_PW (1<<1) +#define ACPI_IVHD_RES_PASS_PW (1<<2) +#define ACPI_IVHD_ISOC (1<<3) +#define ACPI_IVHD_IOTLB (1<<4) + +/* Masks for Flags field above for IVMD subtable */ + +#define ACPI_IVMD_UNITY (1) +#define ACPI_IVMD_READ (1<<1) +#define ACPI_IVMD_WRITE (1<<2) +#define ACPI_IVMD_EXCLUSION_RANGE (1<<3) + + +/* + * IVRS subtables, correspond to Type in ACPI_IVRS_HEADER + */ + +/* 0x10: I/O Virtualization Hardware Definition Block (IVHD) */ + +typedef struct acpi_ivrs_hardware +{ + ACPI_IVRS_HEADER Header; + UINT16 CapabilityOffset; /* Offset for IOMMU control fields */ + UINT64 BaseAddress; /* IOMMU control registers */ + UINT16 PciSegmentGroup; + UINT16 Info; /* MSI number and unit ID */ + UINT32 Reserved; + +} ACPI_IVRS_HARDWARE; + +/* Masks for Info field above */ + +#define ACPI_IVHD_MSI_NUMBER_MASK 0x001F /* 5 bits, MSI message number */ +#define ACPI_IVHD_UNIT_ID_MASK 0x1F00 /* 5 bits, UnitID */ + + +/* + * Device Entries for IVHD subtable, appear after ACPI_IVRS_HARDWARE structure. + * Upper two bits of the Type field are the (encoded) length of the structure. + * Currently, only 4 and 8 byte entries are defined. 16 and 32 byte entries + * are reserved for future use but not defined. + */ +typedef struct acpi_ivrs_de_header +{ + UINT8 Type; + UINT16 Id; + UINT8 DataSetting; + +} ACPI_IVRS_DE_HEADER; + +/* Length of device entry is in the top two bits of Type field above */ + +#define ACPI_IVHD_ENTRY_LENGTH 0xC0 + +/* Values for device entry Type field above */ + +enum AcpiIvrsDeviceEntryType +{ + /* 4-byte device entries, all use ACPI_IVRS_DEVICE4 */ + + ACPI_IVRS_TYPE_PAD4 = 0, + ACPI_IVRS_TYPE_ALL = 1, + ACPI_IVRS_TYPE_SELECT = 2, + ACPI_IVRS_TYPE_START = 3, + ACPI_IVRS_TYPE_END = 4, + + /* 8-byte device entries */ + + ACPI_IVRS_TYPE_PAD8 = 64, + ACPI_IVRS_TYPE_NOT_USED = 65, + ACPI_IVRS_TYPE_ALIAS_SELECT = 66, /* Uses ACPI_IVRS_DEVICE8A */ + ACPI_IVRS_TYPE_ALIAS_START = 67, /* Uses ACPI_IVRS_DEVICE8A */ + ACPI_IVRS_TYPE_EXT_SELECT = 70, /* Uses ACPI_IVRS_DEVICE8B */ + ACPI_IVRS_TYPE_EXT_START = 71, /* Uses ACPI_IVRS_DEVICE8B */ + ACPI_IVRS_TYPE_SPECIAL = 72 /* Uses ACPI_IVRS_DEVICE8C */ +}; + +/* Values for Data field above */ + +#define ACPI_IVHD_INIT_PASS (1) +#define ACPI_IVHD_EINT_PASS (1<<1) +#define ACPI_IVHD_NMI_PASS (1<<2) +#define ACPI_IVHD_SYSTEM_MGMT (3<<4) +#define ACPI_IVHD_LINT0_PASS (1<<6) +#define ACPI_IVHD_LINT1_PASS (1<<7) + + +/* Types 0-4: 4-byte device entry */ + +typedef struct acpi_ivrs_device4 +{ + ACPI_IVRS_DE_HEADER Header; + +} ACPI_IVRS_DEVICE4; + +/* Types 66-67: 8-byte device entry */ + +typedef struct acpi_ivrs_device8a +{ + ACPI_IVRS_DE_HEADER Header; + UINT8 Reserved1; + UINT16 UsedId; + UINT8 Reserved2; + +} ACPI_IVRS_DEVICE8A; + +/* Types 70-71: 8-byte device entry */ + +typedef struct acpi_ivrs_device8b +{ + ACPI_IVRS_DE_HEADER Header; + UINT32 ExtendedData; + +} ACPI_IVRS_DEVICE8B; + +/* Values for ExtendedData above */ + +#define ACPI_IVHD_ATS_DISABLED (1<<31) + +/* Type 72: 8-byte device entry */ + +typedef struct acpi_ivrs_device8c +{ + ACPI_IVRS_DE_HEADER Header; + UINT8 Handle; + UINT16 UsedId; + UINT8 Variety; + +} ACPI_IVRS_DEVICE8C; + +/* Values for Variety field above */ + +#define ACPI_IVHD_IOAPIC 1 +#define ACPI_IVHD_HPET 2 + + +/* 0x20, 0x21, 0x22: I/O Virtualization Memory Definition Block (IVMD) */ + +typedef struct acpi_ivrs_memory +{ + ACPI_IVRS_HEADER Header; + UINT16 AuxData; + UINT64 Reserved; + UINT64 StartAddress; + UINT64 MemoryLength; + +} ACPI_IVRS_MEMORY; + + +/******************************************************************************* + * + * MCFG - PCI Memory Mapped Configuration table and sub-table + * Version 1 + * + * Conforms to "PCI Firmware Specification", Revision 3.0, June 20, 2005 + * + ******************************************************************************/ + +typedef struct acpi_table_mcfg +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[8]; + +} ACPI_TABLE_MCFG; + + +/* Subtable */ + +typedef struct acpi_mcfg_allocation +{ + UINT64 Address; /* Base address, processor-relative */ + UINT16 PciSegment; /* PCI segment group number */ + UINT8 StartBusNumber; /* Starting PCI Bus number */ + UINT8 EndBusNumber; /* Final PCI Bus number */ + UINT32 Reserved; + +} ACPI_MCFG_ALLOCATION; + + +/******************************************************************************* + * + * SPCR - Serial Port Console Redirection table + * Version 1 + * + * Conforms to "Serial Port Console Redirection Table", + * Version 1.00, January 11, 2002 + * + ******************************************************************************/ + +typedef struct acpi_table_spcr +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS SerialPort; + UINT8 InterruptType; + UINT8 PcInterrupt; + UINT32 Interrupt; + UINT8 BaudRate; + UINT8 Parity; + UINT8 StopBits; + UINT8 FlowControl; + UINT8 TerminalType; + UINT8 Reserved1; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT32 PciFlags; + UINT8 PciSegment; + UINT32 Reserved2; + +} ACPI_TABLE_SPCR; + +/* Masks for PciFlags field above */ + +#define ACPI_SPCR_DO_NOT_DISABLE (1) + + +/******************************************************************************* + * + * SPMI - Server Platform Management Interface table + * Version 5 + * + * Conforms to "Intelligent Platform Management Interface Specification + * Second Generation v2.0", Document Revision 1.0, February 12, 2004 with + * June 12, 2009 markup. + * + ******************************************************************************/ + +typedef struct acpi_table_spmi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; + UINT8 Reserved; /* Must be 1 */ + UINT16 SpecRevision; /* Version of IPMI */ + UINT8 InterruptType; + UINT8 GpeNumber; /* GPE assigned */ + UINT8 Reserved1; + UINT8 PciDeviceFlag; + UINT32 Interrupt; + ACPI_GENERIC_ADDRESS IpmiRegister; + UINT8 PciSegment; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT8 Reserved2; + +} ACPI_TABLE_SPMI; + +/* Values for InterfaceType above */ + +enum AcpiSpmiInterfaceTypes +{ + ACPI_SPMI_NOT_USED = 0, + ACPI_SPMI_KEYBOARD = 1, + ACPI_SPMI_SMI = 2, + ACPI_SPMI_BLOCK_TRANSFER = 3, + ACPI_SPMI_SMBUS = 4, + ACPI_SPMI_RESERVED = 5 /* 5 and above are reserved */ +}; + + +/******************************************************************************* + * + * TCPA - Trusted Computing Platform Alliance table + * Version 1 + * + * Conforms to "TCG PC Specific Implementation Specification", + * Version 1.1, August 18, 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_tcpa +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 Reserved; + UINT32 MaxLogLength; /* Maximum length for the event log area */ + UINT64 LogAddress; /* Address of the event log area */ + +} ACPI_TABLE_TCPA; + + +/******************************************************************************* + * + * UEFI - UEFI Boot optimization Table + * Version 1 + * + * Conforms to "Unified Extensible Firmware Interface Specification", + * Version 2.3, May 8, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_uefi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Identifier[16]; /* UUID identifier */ + UINT16 DataOffset; /* Offset of remaining data in table */ + +} ACPI_TABLE_UEFI; + + +/******************************************************************************* + * + * WAET - Windows ACPI Emulated devices Table + * Version 1 + * + * Conforms to "Windows ACPI Emulated Devices Table", version 1.0, April 6, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_waet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Flags; + +} ACPI_TABLE_WAET; + +/* Masks for Flags field above */ + +#define ACPI_WAET_RTC_NO_ACK (1) /* RTC requires no int acknowledge */ +#define ACPI_WAET_TIMER_ONE_READ (1<<1) /* PM timer requires only one read */ + + +/******************************************************************************* + * + * WDAT - Watchdog Action Table + * Version 1 + * + * Conforms to "Hardware Watchdog Timers Design Specification", + * Copyright 2006 Microsoft Corporation. + * + ******************************************************************************/ + +typedef struct acpi_table_wdat +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; /* Watchdog Header Length */ + UINT16 PciSegment; /* PCI Segment number */ + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT8 Reserved[3]; + UINT32 TimerPeriod; /* Period of one timer count (msec) */ + UINT32 MaxCount; /* Maximum counter value supported */ + UINT32 MinCount; /* Minimum counter value */ + UINT8 Flags; + UINT8 Reserved2[3]; + UINT32 Entries; /* Number of watchdog entries that follow */ + +} ACPI_TABLE_WDAT; + +/* Masks for Flags field above */ + +#define ACPI_WDAT_ENABLED (1) +#define ACPI_WDAT_STOPPED 0x80 + + +/* WDAT Instruction Entries (actions) */ + +typedef struct acpi_wdat_entry +{ + UINT8 Action; + UINT8 Instruction; + UINT16 Reserved; + ACPI_GENERIC_ADDRESS RegisterRegion; + UINT32 Value; /* Value used with Read/Write register */ + UINT32 Mask; /* Bitmask required for this register instruction */ + +} ACPI_WDAT_ENTRY; + +/* Values for Action field above */ + +enum AcpiWdatActions +{ + ACPI_WDAT_RESET = 1, + ACPI_WDAT_GET_CURRENT_COUNTDOWN = 4, + ACPI_WDAT_GET_COUNTDOWN = 5, + ACPI_WDAT_SET_COUNTDOWN = 6, + ACPI_WDAT_GET_RUNNING_STATE = 8, + ACPI_WDAT_SET_RUNNING_STATE = 9, + ACPI_WDAT_GET_STOPPED_STATE = 10, + ACPI_WDAT_SET_STOPPED_STATE = 11, + ACPI_WDAT_GET_REBOOT = 16, + ACPI_WDAT_SET_REBOOT = 17, + ACPI_WDAT_GET_SHUTDOWN = 18, + ACPI_WDAT_SET_SHUTDOWN = 19, + ACPI_WDAT_GET_STATUS = 32, + ACPI_WDAT_SET_STATUS = 33, + ACPI_WDAT_ACTION_RESERVED = 34 /* 34 and greater are reserved */ +}; + +/* Values for Instruction field above */ + +enum AcpiWdatInstructions +{ + ACPI_WDAT_READ_VALUE = 0, + ACPI_WDAT_READ_COUNTDOWN = 1, + ACPI_WDAT_WRITE_VALUE = 2, + ACPI_WDAT_WRITE_COUNTDOWN = 3, + ACPI_WDAT_INSTRUCTION_RESERVED = 4, /* 4 and greater are reserved */ + ACPI_WDAT_PRESERVE_REGISTER = 0x80 /* Except for this value */ +}; + + +/******************************************************************************* + * + * WDRT - Watchdog Resource Table + * Version 1 + * + * Conforms to "Watchdog Timer Hardware Requirements for Windows Server 2003", + * Version 1.01, August 28, 2006 + * + ******************************************************************************/ + +typedef struct acpi_table_wdrt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_GENERIC_ADDRESS ControlRegister; + ACPI_GENERIC_ADDRESS CountRegister; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT8 PciSegment; /* PCI Segment number */ + UINT16 MaxCount; /* Maximum counter value supported */ + UINT8 Units; + +} ACPI_TABLE_WDRT; + + +/* Reset to default packing */ + +#pragma pack() + +#endif /* __ACTBL2_H__ */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/actbl71.h b/reactos/drivers/bus/acpi/acpica/include/actbl71.h new file mode 100644 index 00000000000..0390d6f8de6 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actbl71.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * + * Name: actbl71.h - IA-64 Extensions to the ACPI Spec Rev. 0.71 + * This file includes tables specific to this + * specification revision. + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACTBL71_H__ +#define __ACTBL71_H__ + +/* 0.71 FADT Address_space data item bitmasks defines */ +/* If the associated bit is zero then it is in memory space else in io space */ +#define SMI_CMD_ADDRESS_SPACE 0x01 +#define PM1_BLK_ADDRESS_SPACE 0x02 +#define PM2_CNT_BLK_ADDRESS_SPACE 0x04 +#define PM_TMR_BLK_ADDRESS_SPACE 0x08 +#define GPE0_BLK_ADDRESS_SPACE 0x10 +#define GPE1_BLK_ADDRESS_SPACE 0x20 + +/* Only for clarity in declarations */ +typedef UINT64 IO_ADDRESS; + +#pragma pack(1) + +typedef struct /* Root System Descriptor Pointer */ +{ + NATIVE_CHAR signature [8]; /* contains "RSD PTR " */ + u8 checksum; /* to make sum of struct == 0 */ + NATIVE_CHAR oem_id [6]; /* OEM identification */ + u8 reserved; /* Must be 0 for 1.0, 2 for 2.0 */ + UINT64 rsdt_physical_address; /* 64-bit physical address of RSDT */ +} RSDP_DESCRIPTOR_REV071; + + +/*****************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Root System Description Table */ +/*****************************************/ +typedef struct +{ + ACPI_TABLE_HEADER header; /* Table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + UINT64 table_offset_entry [1]; /* Array of pointers to other */ + /* tables' headers */ +} RSDT_DESCRIPTOR_REV071; + + +/*******************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Firmware ACPI Control Structure */ +/*******************************************/ +typedef struct +{ + NATIVE_CHAR signature[4]; /* signature "FACS" */ + u32 length; /* length of structure, in bytes */ + u32 hardware_signature; /* hardware configuration signature */ + u32 reserved4; /* must be 0 */ + UINT64 firmware_waking_vector; /* ACPI OS waking vector */ + UINT64 global_lock; /* Global Lock */ + u32 S4_bios_f : 1; /* Indicates if S4_bIOS support is present */ + u32 reserved1 : 31; /* must be 0 */ + u8 reserved3 [28]; /* reserved - must be zero */ + +} FACS_DESCRIPTOR_REV071; + + +/******************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Fixed ACPI Description Table */ +/******************************************/ +typedef struct +{ + ACPI_TABLE_HEADER header; /* table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + UINT64 firmware_ctrl; /* 64-bit Physical address of FACS */ + UINT64 dsdt; /* 64-bit Physical address of DSDT */ + u8 model; /* System Interrupt Model */ + u8 address_space; /* Address Space Bitmask */ + u16 sci_int; /* System vector of SCI interrupt */ + u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ + u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ + u8 S4_bios_req; /* Value to write to SMI CMD to enter S4_bIOS state */ + u8 reserved2; /* reserved - must be zero */ + UINT64 smi_cmd; /* Port address of SMI command port */ + UINT64 pm1a_evt_blk; /* Port address of Power Mgt 1a Acpi_event Reg Blk */ + UINT64 pm1b_evt_blk; /* Port address of Power Mgt 1b Acpi_event Reg Blk */ + UINT64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ + UINT64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ + UINT64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ + UINT64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT64 gpe0blk; /* Port addr of General Purpose Acpi_event 0 Reg Blk */ + UINT64 gpe1_blk; /* Port addr of General Purpose Acpi_event 1 Reg Blk */ + u8 pm1_evt_len; /* Byte Length of ports at pm1_x_evt_blk */ + u8 pm1_cnt_len; /* Byte Length of ports at pm1_x_cnt_blk */ + u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ + u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ + u8 gpe0blk_len; /* Byte Length of ports at gpe0_blk */ + u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ + u8 gpe1_base; /* offset in gpe model where gpe1 events start */ + u8 reserved3; /* reserved */ + u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ + u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ + u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ + u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ + u8 century; /* index to century in RTC CMOS RAM */ + u8 reserved4; /* reserved */ + u32 flush_cash : 1; /* PAL_FLUSH_CACHE is correctly supported */ + u32 reserved5 : 1; /* reserved - must be zero */ + u32 proc_c1 : 1; /* all processors support C1 state */ + u32 plvl2_up : 1; /* C2 state works on MP system */ + u32 pwr_button : 1; /* Power button is handled as a generic feature */ + u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ + u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ + u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ + u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ + u32 dock_cap : 1; /* Supports Docking */ + u32 reserved6 : 22; /* reserved - must be zero */ + +} FADT_DESCRIPTOR_REV071; + +#pragma pack() + +#endif /* __ACTBL71_H__ */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/actypes.h b/reactos/drivers/bus/acpi/acpica/include/actypes.h new file mode 100644 index 00000000000..ef8d48bd29d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actypes.h @@ -0,0 +1,1248 @@ +/****************************************************************************** + * + * Name: actypes.h - Common data types for the entire ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTYPES_H__ +#define __ACTYPES_H__ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +/* + * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent header + * and must be either 32 or 64. 16-bit ACPICA is no longer supported, as of + * 12/2006. + */ +#ifndef ACPI_MACHINE_WIDTH +#error ACPI_MACHINE_WIDTH not defined +#endif + +/*! [Begin] no source code translation */ + +/* + * Data type ranges + * Note: These macros are designed to be compiler independent as well as + * working around problems that some 32-bit compilers have with 64-bit + * constants. + */ +#define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */ +#define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */ +#define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */ +#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ +#define ACPI_ASCII_MAX 0x7F + + +/* + * Architecture-specific ACPICA Subsystem Data Types + * + * The goal of these types is to provide source code portability across + * 16-bit, 32-bit, and 64-bit targets. + * + * 1) The following types are of fixed size for all targets (16/32/64): + * + * BOOLEAN Logical boolean + * + * UINT8 8-bit (1 byte) unsigned value + * UINT16 16-bit (2 byte) unsigned value + * UINT32 32-bit (4 byte) unsigned value + * UINT64 64-bit (8 byte) unsigned value + * + * INT16 16-bit (2 byte) signed value + * INT32 32-bit (4 byte) signed value + * INT64 64-bit (8 byte) signed value + * + * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the + * compiler-dependent header(s) and were introduced because there is no common + * 64-bit integer type across the various compilation models, as shown in + * the table below. + * + * Datatype LP64 ILP64 LLP64 ILP32 LP32 16bit + * char 8 8 8 8 8 8 + * short 16 16 16 16 16 16 + * _int32 32 + * int 32 64 32 32 16 16 + * long 64 64 32 32 32 32 + * long long 64 64 + * pointer 64 64 64 32 32 32 + * + * Note: ILP64 and LP32 are currently not supported. + * + * + * 2) These types represent the native word size of the target mode of the + * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are + * usually used for memory allocation, efficient loop counters, and array + * indexes. The types are similar to the size_t type in the C library and are + * required because there is no C type that consistently represents the native + * data width. ACPI_SIZE is needed because there is no guarantee that a + * kernel-level C library is present. + * + * ACPI_SIZE 16/32/64-bit unsigned value + * ACPI_NATIVE_INT 16/32/64-bit signed value + * + */ + +/******************************************************************************* + * + * Common types for all compilers, all targets + * + ******************************************************************************/ + +//typedef unsigned char BOOLEAN; +//typedef unsigned char UINT8; +//typedef unsigned short UINT16; +//typedef COMPILER_DEPENDENT_UINT64 UINT64; +//typedef COMPILER_DEPENDENT_INT64 INT64; + +/*! [End] no source code translation !*/ + + +/******************************************************************************* + * + * Types specific to 64-bit targets + * + ******************************************************************************/ + +#if ACPI_MACHINE_WIDTH == 64 + +/*! [Begin] no source code translation (keep the typedefs as-is) */ + +typedef unsigned int UINT32; +typedef int INT32; + +/*! [End] no source code translation !*/ + + +typedef INT64 ACPI_NATIVE_INT; +typedef UINT64 ACPI_SIZE; +typedef UINT64 ACPI_IO_ADDRESS; +typedef UINT64 ACPI_PHYSICAL_ADDRESS; + +#define ACPI_MAX_PTR ACPI_UINT64_MAX +#define ACPI_SIZE_MAX ACPI_UINT64_MAX +#define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ + +/* + * In the case of the Itanium Processor Family (IPF), the hardware does not + * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag + * to indicate that special precautions must be taken to avoid alignment faults. + * (IA64 or ia64 is currently used by existing compilers to indicate IPF.) + * + * Note: EM64T and other X86-64 processors support misaligned transfers, + * so there is no need to define this flag. + */ +#if defined (__IA64__) || defined (__ia64__) +#define ACPI_MISALIGNMENT_NOT_SUPPORTED +#endif + + +/******************************************************************************* + * + * Types specific to 32-bit targets + * + ******************************************************************************/ + +#elif ACPI_MACHINE_WIDTH == 32 + +/*! [Begin] no source code translation (keep the typedefs as-is) */ + +//typedef unsigned int UINT32; +//typedef int INT32; + +/*! [End] no source code translation !*/ + + +typedef INT32 ACPI_NATIVE_INT; +typedef UINT32 ACPI_SIZE; +typedef UINT32 ACPI_IO_ADDRESS; +typedef UINT32 ACPI_PHYSICAL_ADDRESS; + +#define ACPI_MAX_PTR ACPI_UINT32_MAX +#define ACPI_SIZE_MAX ACPI_UINT32_MAX + +#else + +/* ACPI_MACHINE_WIDTH must be either 64 or 32 */ + +#error unknown ACPI_MACHINE_WIDTH +#endif + + +/******************************************************************************* + * + * OS-dependent types + * + * If the defaults below are not appropriate for the host system, they can + * be defined in the OS-specific header, and this will take precedence. + * + ******************************************************************************/ + +/* Value returned by AcpiOsGetThreadId */ + +#ifndef ACPI_THREAD_ID +#define ACPI_THREAD_ID ACPI_SIZE +#endif + +/* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */ + +#ifndef ACPI_CPU_FLAGS +#define ACPI_CPU_FLAGS ACPI_SIZE +#endif + +/* Object returned from AcpiOsCreateCache */ + +#ifndef ACPI_CACHE_T +#ifdef ACPI_USE_LOCAL_CACHE +#define ACPI_CACHE_T ACPI_MEMORY_LIST +#else +#define ACPI_CACHE_T void * +#endif +#endif + +/* + * Synchronization objects - Mutexes, Semaphores, and SpinLocks + */ +#if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE) +/* + * These macros are used if the host OS does not support a mutex object. + * Map the OSL Mutex interfaces to binary semaphores. + */ +#define ACPI_MUTEX ACPI_SEMAPHORE +#define AcpiOsCreateMutex(OutHandle) AcpiOsCreateSemaphore (1, 1, OutHandle) +#define AcpiOsDeleteMutex(Handle) (void) AcpiOsDeleteSemaphore (Handle) +#define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time) +#define AcpiOsReleaseMutex(Handle) (void) AcpiOsSignalSemaphore (Handle, 1) +#endif + +/* Configurable types for synchronization objects */ + +#ifndef ACPI_SPINLOCK +#define ACPI_SPINLOCK void * +#endif + +#ifndef ACPI_SEMAPHORE +#define ACPI_SEMAPHORE void * +#endif + +#ifndef ACPI_MUTEX +#define ACPI_MUTEX void * +#endif + + +/******************************************************************************* + * + * Compiler-dependent types + * + * If the defaults below are not appropriate for the host compiler, they can + * be defined in the compiler-specific header, and this will take precedence. + * + ******************************************************************************/ + +/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ + +#ifndef ACPI_UINTPTR_T +#define ACPI_UINTPTR_T void * +#endif + +/* + * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because + * some compilers can catch printf format string problems + */ +#ifndef ACPI_PRINTF_LIKE +#define ACPI_PRINTF_LIKE(c) +#endif + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (for example, _AcpiModuleName). This allows us + * to to tell the compiler in a per-variable manner that a variable + * is unused + */ +#ifndef ACPI_UNUSED_VAR +#define ACPI_UNUSED_VAR +#endif + +/* + * All ACPICA functions that are available to the rest of the kernel are + * tagged with this macro which can be defined as appropriate for the host. + */ +#ifndef ACPI_EXPORT_SYMBOL +#define ACPI_EXPORT_SYMBOL(Symbol) +#endif + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */ + +#define ACPI_MAX_GPE_BLOCKS 2 + +/* Default ACPI register widths */ + +#define ACPI_GPE_REGISTER_WIDTH 8 +#define ACPI_PM1_REGISTER_WIDTH 16 +#define ACPI_PM2_REGISTER_WIDTH 8 +#define ACPI_PM_TIMER_WIDTH 32 + +/* Names within the namespace are 4 bytes long */ + +#define ACPI_NAME_SIZE 4 +#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ +#define ACPI_PATH_SEPARATOR '.' + +/* Sizes for ACPI table headers */ + +#define ACPI_OEM_ID_SIZE 6 +#define ACPI_OEM_TABLE_ID_SIZE 8 + +/* ACPI/PNP hardware IDs */ + +#define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" + +/* PM Timer ticks per second (HZ) */ + +#define PM_TIMER_FREQUENCY 3579545 + + +/******************************************************************************* + * + * Independent types + * + ******************************************************************************/ + +/* Logical defines and NULL */ + +#ifdef FALSE +#undef FALSE +#endif +#define FALSE (1 == 0) + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE (1 == 1) + +#ifndef NULL +#define NULL (void *) 0 +#endif + + +/* + * Miscellaneous types + */ +typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ +typedef UINT32 ACPI_NAME; /* 4-byte ACPI name */ +typedef char * ACPI_STRING; /* Null terminated ASCII string */ +typedef void * ACPI_HANDLE; /* Actually a ptr to a NS Node */ + + +/* Owner IDs are used to track namespace nodes for selective deletion */ + +typedef UINT8 ACPI_OWNER_ID; +#define ACPI_OWNER_ID_MAX 0xFF + + +typedef struct uint64_struct +{ + UINT32 Lo; + UINT32 Hi; + +} UINT64_STRUCT; + +typedef union uint64_overlay +{ + UINT64 Full; + UINT64_STRUCT Part; + +} UINT64_OVERLAY; + +typedef struct uint32_struct +{ + UINT32 Lo; + UINT32 Hi; + +} UINT32_STRUCT; + + +/* + * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI + * version 2, integers are 64 bits. Note that this pertains to the ACPI integer + * type only, not other integers used in the implementation of the ACPI CA + * subsystem. + */ +typedef UINT64 ACPI_INTEGER; +#define ACPI_INTEGER_MAX ACPI_UINT64_MAX +#define ACPI_INTEGER_BIT_SIZE 64 +#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ +#define ACPI_MAX64_DECIMAL_DIGITS 20 +#define ACPI_MAX32_DECIMAL_DIGITS 10 +#define ACPI_MAX16_DECIMAL_DIGITS 5 +#define ACPI_MAX8_DECIMAL_DIGITS 3 + +/* + * Constants with special meanings + */ +#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (ACPI_HANDLE, NULL, ACPI_MAX_PTR) +#define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ +#define ACPI_DO_NOT_WAIT 0 + + +/******************************************************************************* + * + * Commonly used macros + * + ******************************************************************************/ + +/* Data manipulation */ + +#define ACPI_LOBYTE(Integer) ((UINT8) (UINT16)(Integer)) +#define ACPI_HIBYTE(Integer) ((UINT8) (((UINT16)(Integer)) >> 8)) +#define ACPI_LOWORD(Integer) ((UINT16) (UINT32)(Integer)) +#define ACPI_HIWORD(Integer) ((UINT16)(((UINT32)(Integer)) >> 16)) +#define ACPI_LODWORD(Integer64) ((UINT32) (UINT64)(Integer64)) +#define ACPI_HIDWORD(Integer64) ((UINT32)(((UINT64)(Integer64)) >> 32)) + +#define ACPI_SET_BIT(target,bit) ((target) |= (bit)) +#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) +#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) +#define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) + +/* Size calculation */ + +#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) + +/* Pointer manipulation */ + +#define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p)) +#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p)) +#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b))) +#define ACPI_PTR_DIFF(a, b) (ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b))) + +/* Pointer/Integer type conversions */ + +#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i) +#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL) +#define ACPI_OFFSET(d, f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL) +#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) +#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) + +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b))) +#else +#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE)) +#endif + + +/******************************************************************************* + * + * Miscellaneous constants + * + ******************************************************************************/ + +/* + * Initialization sequence + */ +#define ACPI_FULL_INITIALIZATION 0x00 +#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 +#define ACPI_NO_HARDWARE_INIT 0x02 +#define ACPI_NO_EVENT_INIT 0x04 +#define ACPI_NO_HANDLER_INIT 0x08 +#define ACPI_NO_ACPI_ENABLE 0x10 +#define ACPI_NO_DEVICE_INIT 0x20 +#define ACPI_NO_OBJECT_INIT 0x40 + +/* + * Initialization state + */ +#define ACPI_SUBSYSTEM_INITIALIZE 0x01 +#define ACPI_INITIALIZED_OK 0x02 + +/* + * Power state values + */ +#define ACPI_STATE_UNKNOWN (UINT8) 0xFF + +#define ACPI_STATE_S0 (UINT8) 0 +#define ACPI_STATE_S1 (UINT8) 1 +#define ACPI_STATE_S2 (UINT8) 2 +#define ACPI_STATE_S3 (UINT8) 3 +#define ACPI_STATE_S4 (UINT8) 4 +#define ACPI_STATE_S5 (UINT8) 5 +#define ACPI_S_STATES_MAX ACPI_STATE_S5 +#define ACPI_S_STATE_COUNT 6 + +#define ACPI_STATE_D0 (UINT8) 0 +#define ACPI_STATE_D1 (UINT8) 1 +#define ACPI_STATE_D2 (UINT8) 2 +#define ACPI_STATE_D3 (UINT8) 3 +#define ACPI_D_STATES_MAX ACPI_STATE_D3 +#define ACPI_D_STATE_COUNT 4 + +#define ACPI_STATE_C0 (UINT8) 0 +#define ACPI_STATE_C1 (UINT8) 1 +#define ACPI_STATE_C2 (UINT8) 2 +#define ACPI_STATE_C3 (UINT8) 3 +#define ACPI_C_STATES_MAX ACPI_STATE_C3 +#define ACPI_C_STATE_COUNT 4 + +/* + * Sleep type invalid value + */ +#define ACPI_SLEEP_TYPE_MAX 0x7 +#define ACPI_SLEEP_TYPE_INVALID 0xFF + +/* + * Standard notify values + */ +#define ACPI_NOTIFY_BUS_CHECK (UINT8) 0x00 +#define ACPI_NOTIFY_DEVICE_CHECK (UINT8) 0x01 +#define ACPI_NOTIFY_DEVICE_WAKE (UINT8) 0x02 +#define ACPI_NOTIFY_EJECT_REQUEST (UINT8) 0x03 +#define ACPI_NOTIFY_DEVICE_CHECK_LIGHT (UINT8) 0x04 +#define ACPI_NOTIFY_FREQUENCY_MISMATCH (UINT8) 0x05 +#define ACPI_NOTIFY_BUS_MODE_MISMATCH (UINT8) 0x06 +#define ACPI_NOTIFY_POWER_FAULT (UINT8) 0x07 +#define ACPI_NOTIFY_CAPABILITIES_CHECK (UINT8) 0x08 +#define ACPI_NOTIFY_DEVICE_PLD_CHECK (UINT8) 0x09 +#define ACPI_NOTIFY_RESERVED (UINT8) 0x0A +#define ACPI_NOTIFY_LOCALITY_UPDATE (UINT8) 0x0B + +#define ACPI_NOTIFY_MAX 0x0B + +/* + * Types associated with ACPI names and objects. The first group of + * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition + * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, + * only add to the first group if the spec changes. + * + * NOTE: Types must be kept in sync with the global AcpiNsProperties + * and AcpiNsTypeNames arrays. + */ +typedef UINT32 ACPI_OBJECT_TYPE; + +#define ACPI_TYPE_ANY 0x00 +#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ +#define ACPI_TYPE_STRING 0x02 +#define ACPI_TYPE_BUFFER 0x03 +#define ACPI_TYPE_PACKAGE 0x04 /* ByteConst, multiple DataTerm/Constant/SuperName */ +#define ACPI_TYPE_FIELD_UNIT 0x05 +#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ +#define ACPI_TYPE_EVENT 0x07 +#define ACPI_TYPE_METHOD 0x08 /* Name, ByteConst, multiple Code */ +#define ACPI_TYPE_MUTEX 0x09 +#define ACPI_TYPE_REGION 0x0A +#define ACPI_TYPE_POWER 0x0B /* Name,ByteConst,WordConst,multi Node */ +#define ACPI_TYPE_PROCESSOR 0x0C /* Name,ByteConst,DWordConst,ByteConst,multi NmO */ +#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ +#define ACPI_TYPE_BUFFER_FIELD 0x0E +#define ACPI_TYPE_DDB_HANDLE 0x0F +#define ACPI_TYPE_DEBUG_OBJECT 0x10 + +#define ACPI_TYPE_EXTERNAL_MAX 0x10 + +/* + * These are object types that do not map directly to the ACPI + * ObjectType() operator. They are used for various internal purposes only. + * If new predefined ACPI_TYPEs are added (via the ACPI specification), these + * internal types must move upwards. (There is code that depends on these + * values being contiguous with the external types above.) + */ +#define ACPI_TYPE_LOCAL_REGION_FIELD 0x11 +#define ACPI_TYPE_LOCAL_BANK_FIELD 0x12 +#define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 +#define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, RefOf, Index */ +#define ACPI_TYPE_LOCAL_ALIAS 0x15 +#define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16 +#define ACPI_TYPE_LOCAL_NOTIFY 0x17 +#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18 +#define ACPI_TYPE_LOCAL_RESOURCE 0x19 +#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A +#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple ObjectList Nodes */ + +#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ + +/* + * These are special object types that never appear in + * a Namespace node, only in an ACPI_OPERAND_OBJECT + */ +#define ACPI_TYPE_LOCAL_EXTRA 0x1C +#define ACPI_TYPE_LOCAL_DATA 0x1D + +#define ACPI_TYPE_LOCAL_MAX 0x1D + +/* All types above here are invalid */ + +#define ACPI_TYPE_INVALID 0x1E +#define ACPI_TYPE_NOT_FOUND 0xFF + +#define ACPI_NUM_NS_TYPES (ACPI_TYPE_INVALID + 1) + + +/* + * All I/O + */ +#define ACPI_READ 0 +#define ACPI_WRITE 1 +#define ACPI_IO_MASK 1 + +/* + * Event Types: Fixed & General Purpose + */ +typedef UINT32 ACPI_EVENT_TYPE; + +/* + * Fixed events + */ +#define ACPI_EVENT_PMTIMER 0 +#define ACPI_EVENT_GLOBAL 1 +#define ACPI_EVENT_POWER_BUTTON 2 +#define ACPI_EVENT_SLEEP_BUTTON 3 +#define ACPI_EVENT_RTC 4 +#define ACPI_EVENT_MAX 4 +#define ACPI_NUM_FIXED_EVENTS ACPI_EVENT_MAX + 1 + +/* + * Event Status - Per event + * ------------- + * The encoding of ACPI_EVENT_STATUS is illustrated below. + * Note that a set bit (1) indicates the property is TRUE + * (e.g. if bit 0 is set then the event is enabled). + * +-------------+-+-+-+ + * | Bits 31:3 |2|1|0| + * +-------------+-+-+-+ + * | | | | + * | | | +- Enabled? + * | | +--- Enabled for wake? + * | +----- Set? + * +----------- + */ +typedef UINT32 ACPI_EVENT_STATUS; + +#define ACPI_EVENT_FLAG_DISABLED (ACPI_EVENT_STATUS) 0x00 +#define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 +#define ACPI_EVENT_FLAG_WAKE_ENABLED (ACPI_EVENT_STATUS) 0x02 +#define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x04 + +/* + * General Purpose Events (GPE) + */ +#define ACPI_GPE_INVALID 0xFF +#define ACPI_GPE_MAX 0xFF +#define ACPI_NUM_GPE 256 + +#define ACPI_GPE_ENABLE 0 +#define ACPI_GPE_DISABLE 1 + + +/* + * GPE info flags - Per GPE + * +-+-+-+---+---+-+ + * |7|6|5|4:3|2:1|0| + * +-+-+-+---+---+-+ + * | | | | | | + * | | | | | +--- Interrupt type: Edge or Level Triggered + * | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime + * | | | +--- Type of dispatch -- to method, handler, or none + * | | +--- Enabled for runtime? + * | +--- Enabled for wake? + * +--- Unused + */ +#define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 0x01 +#define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 0x01 +#define ACPI_GPE_EDGE_TRIGGERED (UINT8) 0x00 + +#define ACPI_GPE_TYPE_MASK (UINT8) 0x06 +#define ACPI_GPE_TYPE_WAKE_RUN (UINT8) 0x06 +#define ACPI_GPE_TYPE_WAKE (UINT8) 0x02 +#define ACPI_GPE_TYPE_RUNTIME (UINT8) 0x04 /* Default */ + +#define ACPI_GPE_DISPATCH_MASK (UINT8) 0x18 +#define ACPI_GPE_DISPATCH_HANDLER (UINT8) 0x08 +#define ACPI_GPE_DISPATCH_METHOD (UINT8) 0x10 +#define ACPI_GPE_DISPATCH_NOT_USED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_RUN_ENABLE_MASK (UINT8) 0x20 +#define ACPI_GPE_RUN_ENABLED (UINT8) 0x20 +#define ACPI_GPE_RUN_DISABLED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_WAKE_ENABLE_MASK (UINT8) 0x40 +#define ACPI_GPE_WAKE_ENABLED (UINT8) 0x40 +#define ACPI_GPE_WAKE_DISABLED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_ENABLE_MASK (UINT8) 0x60 /* Both run/wake */ + +/* + * Flags for GPE and Lock interfaces + */ +#define ACPI_EVENT_WAKE_ENABLE 0x2 /* AcpiGpeEnable */ +#define ACPI_EVENT_WAKE_DISABLE 0x2 /* AcpiGpeDisable */ + +#define ACPI_NOT_ISR 0x1 +#define ACPI_ISR 0x0 + + +/* Notify types */ + +#define ACPI_SYSTEM_NOTIFY 0x1 +#define ACPI_DEVICE_NOTIFY 0x2 +#define ACPI_ALL_NOTIFY (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY) +#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3 + +#define ACPI_MAX_SYS_NOTIFY 0x7f + + +/* Address Space (Operation Region) Types */ + +typedef UINT8 ACPI_ADR_SPACE_TYPE; + +#define ACPI_ADR_SPACE_SYSTEM_MEMORY (ACPI_ADR_SPACE_TYPE) 0 +#define ACPI_ADR_SPACE_SYSTEM_IO (ACPI_ADR_SPACE_TYPE) 1 +#define ACPI_ADR_SPACE_PCI_CONFIG (ACPI_ADR_SPACE_TYPE) 2 +#define ACPI_ADR_SPACE_EC (ACPI_ADR_SPACE_TYPE) 3 +#define ACPI_ADR_SPACE_SMBUS (ACPI_ADR_SPACE_TYPE) 4 +#define ACPI_ADR_SPACE_CMOS (ACPI_ADR_SPACE_TYPE) 5 +#define ACPI_ADR_SPACE_PCI_BAR_TARGET (ACPI_ADR_SPACE_TYPE) 6 +#define ACPI_ADR_SPACE_IPMI (ACPI_ADR_SPACE_TYPE) 7 +#define ACPI_ADR_SPACE_DATA_TABLE (ACPI_ADR_SPACE_TYPE) 8 +#define ACPI_ADR_SPACE_FIXED_HARDWARE (ACPI_ADR_SPACE_TYPE) 127 + + +/* + * BitRegister IDs + * + * These values are intended to be used by the hardware interfaces + * and are mapped to individual bitfields defined within the ACPI + * registers. See the AcpiGbl_BitRegisterInfo global table in utglobal.c + * for this mapping. + */ + +/* PM1 Status register */ + +#define ACPI_BITREG_TIMER_STATUS 0x00 +#define ACPI_BITREG_BUS_MASTER_STATUS 0x01 +#define ACPI_BITREG_GLOBAL_LOCK_STATUS 0x02 +#define ACPI_BITREG_POWER_BUTTON_STATUS 0x03 +#define ACPI_BITREG_SLEEP_BUTTON_STATUS 0x04 +#define ACPI_BITREG_RT_CLOCK_STATUS 0x05 +#define ACPI_BITREG_WAKE_STATUS 0x06 +#define ACPI_BITREG_PCIEXP_WAKE_STATUS 0x07 + +/* PM1 Enable register */ + +#define ACPI_BITREG_TIMER_ENABLE 0x08 +#define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x09 +#define ACPI_BITREG_POWER_BUTTON_ENABLE 0x0A +#define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0B +#define ACPI_BITREG_RT_CLOCK_ENABLE 0x0C +#define ACPI_BITREG_PCIEXP_WAKE_DISABLE 0x0D + +/* PM1 Control register */ + +#define ACPI_BITREG_SCI_ENABLE 0x0E +#define ACPI_BITREG_BUS_MASTER_RLD 0x0F +#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x10 +#define ACPI_BITREG_SLEEP_TYPE 0x11 +#define ACPI_BITREG_SLEEP_ENABLE 0x12 + +/* PM2 Control register */ + +#define ACPI_BITREG_ARB_DISABLE 0x13 + +#define ACPI_BITREG_MAX 0x13 +#define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 + + +/* Status register values. A 1 clears a status bit. 0 = no effect */ + +#define ACPI_CLEAR_STATUS 1 + +/* Enable and Control register values */ + +#define ACPI_ENABLE_EVENT 1 +#define ACPI_DISABLE_EVENT 0 + + +/* + * External ACPI object definition + */ + +/* + * Note: Type == ACPI_TYPE_ANY (0) is used to indicate a NULL package element + * or an unresolved named reference. + */ +typedef union acpi_object +{ + ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_INTEGER */ + ACPI_INTEGER Value; /* The actual number */ + } Integer; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_STRING */ + UINT32 Length; /* # of bytes in string, excluding trailing null */ + char *Pointer; /* points to the string value */ + } String; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_BUFFER */ + UINT32 Length; /* # of bytes in buffer */ + UINT8 *Pointer; /* points to the buffer */ + } Buffer; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_PACKAGE */ + UINT32 Count; /* # of elements in package */ + union acpi_object *Elements; /* Pointer to an array of ACPI_OBJECTs */ + } Package; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_LOCAL_REFERENCE */ + ACPI_OBJECT_TYPE ActualType; /* Type associated with the Handle */ + ACPI_HANDLE Handle; /* object reference */ + } Reference; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_PROCESSOR */ + UINT32 ProcId; + ACPI_IO_ADDRESS PblkAddress; + UINT32 PblkLength; + } Processor; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_POWER */ + UINT32 SystemLevel; + UINT32 ResourceOrder; + } PowerResource; + +} ACPI_OBJECT; + + +/* + * List of objects, used as a parameter list for control method evaluation + */ +typedef struct acpi_object_list +{ + UINT32 Count; + ACPI_OBJECT *Pointer; + +} ACPI_OBJECT_LIST; + + +/* + * Miscellaneous common Data Structures used by the interfaces + */ +#define ACPI_NO_BUFFER 0 +#define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) +#define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) + +typedef struct acpi_buffer +{ + ACPI_SIZE Length; /* Length in bytes of the buffer */ + void *Pointer; /* pointer to buffer */ + +} ACPI_BUFFER; + + +/* + * NameType for AcpiGetName + */ +#define ACPI_FULL_PATHNAME 0 +#define ACPI_SINGLE_NAME 1 +#define ACPI_NAME_TYPE_MAX 1 + + +/* + * Predefined Namespace items + */ +typedef struct acpi_predefined_names +{ + char *Name; + UINT8 Type; + char *Val; + +} ACPI_PREDEFINED_NAMES; + + +/* + * Structure and flags for AcpiGetSystemInfo + */ +#define ACPI_SYS_MODE_UNKNOWN 0x0000 +#define ACPI_SYS_MODE_ACPI 0x0001 +#define ACPI_SYS_MODE_LEGACY 0x0002 +#define ACPI_SYS_MODES_MASK 0x0003 + + +/* + * System info returned by AcpiGetSystemInfo() + */ +typedef struct acpi_system_info +{ + UINT32 AcpiCaVersion; + UINT32 Flags; + UINT32 TimerResolution; + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 DebugLevel; + UINT32 DebugLayer; + +} ACPI_SYSTEM_INFO; + + +/* + * System statistics returned by AcpiGetStatistics() + */ +typedef struct acpi_statistics +{ + UINT32 SciCount; + UINT32 GpeCount; + UINT32 FixedEventCount[ACPI_NUM_FIXED_EVENTS]; + UINT32 MethodCount; + +} ACPI_STATISTICS; + + +/* Table Event Types */ + +#define ACPI_TABLE_EVENT_LOAD 0x0 +#define ACPI_TABLE_EVENT_UNLOAD 0x1 +#define ACPI_NUM_TABLE_EVENTS 2 + + +/* + * Types specific to the OS service interfaces + */ +typedef UINT32 +(ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) ( + void *Context); + +typedef void +(ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) ( + void *Context); + +/* + * Various handlers and callback procedures + */ +typedef +UINT32 (*ACPI_EVENT_HANDLER) ( + void *Context); + +typedef +void (*ACPI_NOTIFY_HANDLER) ( + ACPI_HANDLE Device, + UINT32 Value, + void *Context); + +typedef +void (*ACPI_OBJECT_HANDLER) ( + ACPI_HANDLE Object, + void *Data); + +typedef +ACPI_STATUS (*ACPI_INIT_HANDLER) ( + ACPI_HANDLE Object, + UINT32 Function); + +#define ACPI_INIT_DEVICE_INI 1 + +typedef +ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) ( + ACPI_STATUS AmlStatus, + ACPI_NAME Name, + UINT16 Opcode, + UINT32 AmlOffset, + void *Context); + +/* Table Event handler (Load, LoadTable, etc.) and types */ + +typedef +ACPI_STATUS (*ACPI_TABLE_HANDLER) ( + UINT32 Event, + void *Table, + void *Context); + +#define ACPI_TABLE_LOAD 0x0 +#define ACPI_TABLE_UNLOAD 0x1 +#define ACPI_NUM_TABLE_EVENTS 2 + + +/* Address Spaces (For Operation Regions) */ + +typedef +ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +#define ACPI_DEFAULT_HANDLER NULL + +typedef +ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +#define ACPI_REGION_ACTIVATE 0 +#define ACPI_REGION_DEACTIVATE 1 + +typedef +ACPI_STATUS (*ACPI_WALK_CALLBACK) ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/* Interrupt handler return values */ + +#define ACPI_INTERRUPT_NOT_HANDLED 0x00 +#define ACPI_INTERRUPT_HANDLED 0x01 + +/* Length of 32-bit EISAID values when converted back to a string */ + +#define ACPI_EISAID_STRING_SIZE 8 /* Includes null terminator */ + +/* Length of UUID (string) values */ + +#define ACPI_UUID_LENGTH 16 + + +/* Structures used for device/processor HID, UID, CID */ + +typedef struct acpi_device_id +{ + UINT32 Length; /* Length of string + null */ + char *String; + +} ACPI_DEVICE_ID; + +typedef struct acpi_device_id_list +{ + UINT32 Count; /* Number of IDs in Ids array */ + UINT32 ListSize; /* Size of list, including ID strings */ + ACPI_DEVICE_ID Ids[1]; /* ID array */ + +} ACPI_DEVICE_ID_LIST; + +/* + * Structure returned from AcpiGetObjectInfo. + * Optimized for both 32- and 64-bit builds + */ +typedef struct acpi_device_info +{ + UINT32 InfoSize; /* Size of info, including ID strings */ + UINT32 Name; /* ACPI object Name */ + ACPI_OBJECT_TYPE Type; /* ACPI object Type */ + UINT8 ParamCount; /* If a method, required parameter count */ + UINT8 Valid; /* Indicates which optional fields are valid */ + UINT8 Flags; /* Miscellaneous info */ + UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ + UINT8 LowestDstates[5]; /* _SxW values: 0xFF indicates not valid */ + UINT32 CurrentStatus; /* _STA value */ + ACPI_INTEGER Address; /* _ADR value */ + ACPI_DEVICE_ID HardwareId; /* _HID value */ + ACPI_DEVICE_ID UniqueId; /* _UID value */ + ACPI_DEVICE_ID_LIST CompatibleIdList; /* _CID list */ + +} ACPI_DEVICE_INFO; + +/* Values for Flags field above (AcpiGetObjectInfo) */ + +#define ACPI_PCI_ROOT_BRIDGE 0x01 + +/* Flags for Valid field above (AcpiGetObjectInfo) */ + +#define ACPI_VALID_STA 0x01 +#define ACPI_VALID_ADR 0x02 +#define ACPI_VALID_HID 0x04 +#define ACPI_VALID_UID 0x08 +#define ACPI_VALID_CID 0x10 +#define ACPI_VALID_SXDS 0x20 +#define ACPI_VALID_SXWS 0x40 + +/* Flags for _STA method */ + +#define ACPI_STA_DEVICE_PRESENT 0x01 +#define ACPI_STA_DEVICE_ENABLED 0x02 +#define ACPI_STA_DEVICE_UI 0x04 +#define ACPI_STA_DEVICE_FUNCTIONING 0x08 +#define ACPI_STA_DEVICE_OK 0x08 /* Synonym */ +#define ACPI_STA_BATTERY_PRESENT 0x10 + + +/* Context structs for address space handlers */ + +typedef struct acpi_pci_id +{ + UINT16 Segment; + UINT16 Bus; + UINT16 Device; + UINT16 Function; + +} ACPI_PCI_ID; + +typedef struct acpi_mem_space_context +{ + UINT32 Length; + ACPI_PHYSICAL_ADDRESS Address; + ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress; + UINT8 *MappedLogicalAddress; + ACPI_SIZE MappedLength; + +} ACPI_MEM_SPACE_CONTEXT; + + +/* + * ACPI_MEMORY_LIST is used only if the ACPICA local cache is enabled + */ +typedef struct acpi_memory_list +{ + char *ListName; + void *ListHead; + UINT16 ObjectSize; + UINT16 MaxDepth; + UINT16 CurrentDepth; + UINT16 LinkOffset; + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Statistics for debug memory tracking only */ + + UINT32 TotalAllocated; + UINT32 TotalFreed; + UINT32 MaxOccupied; + UINT32 TotalSize; + UINT32 CurrentTotalSize; + UINT32 Requests; + UINT32 Hits; +#endif + +} ACPI_MEMORY_LIST; + + +#endif /* __ACTYPES_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acutils.h b/reactos/drivers/bus/acpi/acpica/include/acutils.h new file mode 100644 index 00000000000..3e12b7ca361 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acutils.h @@ -0,0 +1,963 @@ +/****************************************************************************** + * + * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACUTILS_H +#define _ACUTILS_H + + +extern const UINT8 AcpiGbl_ResourceAmlSizes[]; + +/* Strings used by the disassembler and debugger resource dump routines */ + +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) + +extern const char *AcpiGbl_BmDecode[]; +extern const char *AcpiGbl_ConfigDecode[]; +extern const char *AcpiGbl_ConsumeDecode[]; +extern const char *AcpiGbl_DecDecode[]; +extern const char *AcpiGbl_HeDecode[]; +extern const char *AcpiGbl_IoDecode[]; +extern const char *AcpiGbl_LlDecode[]; +extern const char *AcpiGbl_MaxDecode[]; +extern const char *AcpiGbl_MemDecode[]; +extern const char *AcpiGbl_MinDecode[]; +extern const char *AcpiGbl_MtpDecode[]; +extern const char *AcpiGbl_RngDecode[]; +extern const char *AcpiGbl_RwDecode[]; +extern const char *AcpiGbl_ShrDecode[]; +extern const char *AcpiGbl_SizDecode[]; +extern const char *AcpiGbl_TrsDecode[]; +extern const char *AcpiGbl_TtpDecode[]; +extern const char *AcpiGbl_TypDecode[]; +#endif + +/* Types for Resource descriptor entries */ + +#define ACPI_INVALID_RESOURCE 0 +#define ACPI_FIXED_LENGTH 1 +#define ACPI_VARIABLE_LENGTH 2 +#define ACPI_SMALL_VARIABLE_LENGTH 3 + +typedef +ACPI_STATUS (*ACPI_WALK_AML_CALLBACK) ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context); + +typedef +ACPI_STATUS (*ACPI_PKG_CALLBACK) ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +typedef struct acpi_pkg_info +{ + UINT8 *FreeSpace; + ACPI_SIZE Length; + UINT32 ObjectSpace; + UINT32 NumPackages; + +} ACPI_PKG_INFO; + +#define REF_INCREMENT (UINT16) 0 +#define REF_DECREMENT (UINT16) 1 +#define REF_FORCE_DELETE (UINT16) 2 + +/* AcpiUtDumpBuffer */ + +#define DB_BYTE_DISPLAY 1 +#define DB_WORD_DISPLAY 2 +#define DB_DWORD_DISPLAY 4 +#define DB_QWORD_DISPLAY 8 + + +/* + * utglobal - Global data structures and procedures + */ +ACPI_STATUS +AcpiUtInitGlobals ( + void); + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +char * +AcpiUtGetMutexName ( + UINT32 MutexId); + +const char * +AcpiUtGetNotifyName ( + UINT32 NotifyValue); + +#endif + +char * +AcpiUtGetTypeName ( + ACPI_OBJECT_TYPE Type); + +char * +AcpiUtGetNodeName ( + void *Object); + +char * +AcpiUtGetDescriptorName ( + void *Object); + +const char * +AcpiUtGetReferenceName ( + ACPI_OPERAND_OBJECT *Object); + +char * +AcpiUtGetObjectTypeName ( + ACPI_OPERAND_OBJECT *ObjDesc); + +char * +AcpiUtGetRegionName ( + UINT8 SpaceId); + +char * +AcpiUtGetEventName ( + UINT32 EventId); + +char +AcpiUtHexToAsciiChar ( + ACPI_INTEGER Integer, + UINT32 Position); + +BOOLEAN +AcpiUtValidObjectType ( + ACPI_OBJECT_TYPE Type); + + +/* + * utinit - miscellaneous initialization and shutdown + */ +ACPI_STATUS +AcpiUtHardwareInitialize ( + void); + +void +AcpiUtSubsystemShutdown ( + void); + + +/* + * utclib - Local implementations of C library functions + */ +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +ACPI_SIZE +AcpiUtStrlen ( + const char *String); + +char * +AcpiUtStrcpy ( + char *DstString, + const char *SrcString); + +char * +AcpiUtStrncpy ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count); + +int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count); + +int +AcpiUtStrncmp ( + const char *String1, + const char *String2, + ACPI_SIZE Count); + +int +AcpiUtStrcmp ( + const char *String1, + const char *String2); + +char * +AcpiUtStrcat ( + char *DstString, + const char *SrcString); + +char * +AcpiUtStrncat ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count); + +UINT32 +AcpiUtStrtoul ( + const char *String, + char **Terminator, + UINT32 Base); + +char * +AcpiUtStrstr ( + char *String1, + char *String2); + +void * +AcpiUtMemcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count); + +void * +AcpiUtMemset ( + void *Dest, + UINT8 Value, + ACPI_SIZE Count); + +int +AcpiUtToUpper ( + int c); + +int +AcpiUtToLower ( + int c); + +extern const UINT8 _acpi_ctype[]; + +#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ +#define _ACPI_XS 0x40 /* extra space */ +#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ +#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ +#define _ACPI_DI 0x04 /* '0'-'9' */ +#define _ACPI_LO 0x02 /* 'a'-'z' */ +#define _ACPI_PU 0x10 /* punctuation */ +#define _ACPI_SP 0x08 /* space */ +#define _ACPI_UP 0x01 /* 'A'-'Z' */ +#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ + +#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) +#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) +#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) +#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) +#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) +#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) +#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) + +#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ + +#define ACPI_IS_ASCII(c) ((c) < 0x80) + + +/* + * utcopy - Object construction and conversion interfaces + */ +ACPI_STATUS +AcpiUtBuildSimpleObject( + ACPI_OPERAND_OBJECT *Obj, + ACPI_OBJECT *UserObj, + UINT8 *DataSpace, + UINT32 *BufferSpaceUsed); + +ACPI_STATUS +AcpiUtBuildPackageObject ( + ACPI_OPERAND_OBJECT *Obj, + UINT8 *Buffer, + UINT32 *SpaceUsed); + +ACPI_STATUS +AcpiUtCopyIobjectToEobject ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiUtCopyEobjectToIobject ( + ACPI_OBJECT *Obj, + ACPI_OPERAND_OBJECT **InternalObj); + +ACPI_STATUS +AcpiUtCopyISimpleToIsimple ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj); + +ACPI_STATUS +AcpiUtCopyIobjectToIobject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **DestDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * utcreate - Object creation + */ +ACPI_STATUS +AcpiUtUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + + +/* + * utdebug - Debug interfaces + */ +void +AcpiUtInitStackPtrTrace ( + void); + +void +AcpiUtTrackStackPtr ( + void); + +void +AcpiUtTrace ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId); + +void +AcpiUtTracePtr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + void *Pointer); + +void +AcpiUtTraceU32 ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT32 Integer); + +void +AcpiUtTraceStr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + char *String); + +void +AcpiUtExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId); + +void +AcpiUtStatusExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_STATUS Status); + +void +AcpiUtValueExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_INTEGER Value); + +void +AcpiUtPtrExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT8 *Ptr); + +void +AcpiUtDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 componentId); + +void +AcpiUtDumpBuffer2 ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display); + +void +AcpiUtReportError ( + char *ModuleName, + UINT32 LineNumber); + +void +AcpiUtReportInfo ( + char *ModuleName, + UINT32 LineNumber); + +void +AcpiUtReportWarning ( + char *ModuleName, + UINT32 LineNumber); + +/* + * utdelete - Object deletion and reference counts + */ +void +AcpiUtAddReference ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtRemoveReference ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalPackageObject ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalSimpleObject ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList); + + +/* + * uteval - object evaluation + */ +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiUtEvaluateObject ( + ACPI_NAMESPACE_NODE *PrefixNode, + char *Path, + UINT32 ExpectedReturnBtypes, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( + char *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Value); + +ACPI_STATUS +AcpiUtExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *StatusFlags); + +ACPI_STATUS +AcpiUtExecutePowerMethods ( + ACPI_NAMESPACE_NODE *DeviceNode, + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues); + + +/* + * utids - device ID support + */ +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId); + +ACPI_STATUS +AcpiUtExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId); + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID_LIST **ReturnCidList); + + +/* + * utlock - reader/writer locks + */ +ACPI_STATUS +AcpiUtCreateRwLock ( + ACPI_RW_LOCK *Lock); + +void +AcpiUtDeleteRwLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtAcquireReadLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtReleaseReadLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtAcquireWriteLock ( + ACPI_RW_LOCK *Lock); + +void +AcpiUtReleaseWriteLock ( + ACPI_RW_LOCK *Lock); + + +/* + * utobject - internal object create/delete/cache routines + */ +ACPI_OPERAND_OBJECT * +AcpiUtCreateInternalObjectDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + ACPI_OBJECT_TYPE Type); + +void * +AcpiUtAllocateObjectDescDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +#define AcpiUtCreateInternalObject(t) AcpiUtCreateInternalObjectDbg (_AcpiModuleName,__LINE__,_COMPONENT,t) +#define AcpiUtAllocateObjectDesc() AcpiUtAllocateObjectDescDbg (_AcpiModuleName,__LINE__,_COMPONENT) + +void +AcpiUtDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object); + +BOOLEAN +AcpiUtValidInternalObject ( + void *Object); + +ACPI_OPERAND_OBJECT * +AcpiUtCreatePackageObject ( + UINT32 Count); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateIntegerObject ( + UINT64 Value); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateBufferObject ( + ACPI_SIZE BufferSize); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize); + +ACPI_STATUS +AcpiUtGetObjectSize( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + + +/* + * utstate - Generic state creation/cache routines + */ +void +AcpiUtPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State); + +ACPI_GENERIC_STATE * +AcpiUtPopGenericState ( + ACPI_GENERIC_STATE **ListHead); + + +ACPI_GENERIC_STATE * +AcpiUtCreateGenericState ( + void); + +ACPI_THREAD_STATE * +AcpiUtCreateThreadState ( + void); + +ACPI_GENERIC_STATE * +AcpiUtCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + +ACPI_GENERIC_STATE * +AcpiUtCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index); + +ACPI_STATUS +AcpiUtCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList); + +ACPI_STATUS +AcpiUtCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList); + +ACPI_GENERIC_STATE * +AcpiUtCreateControlState ( + void); + +void +AcpiUtDeleteGenericState ( + ACPI_GENERIC_STATE *State); + + +/* + * utmath + */ +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder); + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER InDividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder); + +/* + * utmisc + */ +const char * +AcpiUtValidateException ( + ACPI_STATUS Status); + +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id); + +BOOLEAN +AcpiUtIsAmlTable ( + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AcpiUtAllocateOwnerId ( + ACPI_OWNER_ID *OwnerId); + +void +AcpiUtReleaseOwnerId ( + ACPI_OWNER_ID *OwnerId); + +ACPI_STATUS +AcpiUtWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context); + +void +AcpiUtStrupr ( + char *SrcString); + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength); + +BOOLEAN +AcpiUtValidAcpiName ( + UINT32 Name); + +void +AcpiUtRepairName ( + char *Name); + +BOOLEAN +AcpiUtValidAcpiChar ( + char Character, + UINT32 Position); + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Base, + ACPI_INTEGER *RetInteger); + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedWarning ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...); + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedInfo ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...); + +/* Values for Base above (16=Hex, 10=Decimal) */ + +#define ACPI_ANY_BASE 0 + +UINT32 +AcpiUtDwordByteSwap ( + UINT32 Value); + +void +AcpiUtSetIntegerWidth ( + UINT8 Revision); + +#ifdef ACPI_DEBUG_OUTPUT +void +AcpiUtDisplayInitPathname ( + UINT8 Type, + ACPI_NAMESPACE_NODE *ObjHandle, + char *Path); +#endif + + +/* + * utresrc + */ +ACPI_STATUS +AcpiUtWalkAmlResources ( + UINT8 *Aml, + ACPI_SIZE AmlLength, + ACPI_WALK_AML_CALLBACK UserFunction, + void *Context); + +ACPI_STATUS +AcpiUtValidateResource ( + void *Aml, + UINT8 *ReturnIndex); + +UINT32 +AcpiUtGetDescriptorLength ( + void *Aml); + +UINT16 +AcpiUtGetResourceLength ( + void *Aml); + +UINT8 +AcpiUtGetResourceHeaderLength ( + void *Aml); + +UINT8 +AcpiUtGetResourceType ( + void *Aml); + +ACPI_STATUS +AcpiUtGetResourceEndTag ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 **EndTag); + + +/* + * utmutex - mutex support + */ +ACPI_STATUS +AcpiUtMutexInitialize ( + void); + +void +AcpiUtMutexTerminate ( + void); + +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/* + * utalloc - memory allocation and object caching + */ +ACPI_STATUS +AcpiUtCreateCaches ( + void); + +ACPI_STATUS +AcpiUtDeleteCaches ( + void); + +ACPI_STATUS +AcpiUtValidateBuffer ( + ACPI_BUFFER *Buffer); + +ACPI_STATUS +AcpiUtInitializeBuffer ( + ACPI_BUFFER *Buffer, + ACPI_SIZE RequiredLength); + +void * +AcpiUtAllocate ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void * +AcpiUtAllocateZeroed ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +void * +AcpiUtAllocateAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void * +AcpiUtAllocateZeroedAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void +AcpiUtFreeAndTrack ( + void *Address, + UINT32 Component, + const char *Module, + UINT32 Line); + +void +AcpiUtDumpAllocationInfo ( + void); + +void +AcpiUtDumpAllocations ( + UINT32 Component, + const char *Module); + +ACPI_STATUS +AcpiUtCreateList ( + char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache); + + +#endif + +#endif /* _ACUTILS_H */ diff --git a/reactos/drivers/bus/acpi/acpica/include/amlcode.h b/reactos/drivers/bus/acpi/acpica/include/amlcode.h new file mode 100644 index 00000000000..19740d9083c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/amlcode.h @@ -0,0 +1,595 @@ +/****************************************************************************** + * + * Name: amlcode.h - Definitions for AML, as included in "definition blocks" + * Declarations and definitions contained herein are derived + * directly from the ACPI specification. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __AMLCODE_H__ +#define __AMLCODE_H__ + +/* primary opcodes */ + +#define AML_NULL_CHAR (UINT16) 0x00 + +#define AML_ZERO_OP (UINT16) 0x00 +#define AML_ONE_OP (UINT16) 0x01 +#define AML_UNASSIGNED (UINT16) 0x02 +#define AML_ALIAS_OP (UINT16) 0x06 +#define AML_NAME_OP (UINT16) 0x08 +#define AML_BYTE_OP (UINT16) 0x0a +#define AML_WORD_OP (UINT16) 0x0b +#define AML_DWORD_OP (UINT16) 0x0c +#define AML_STRING_OP (UINT16) 0x0d +#define AML_QWORD_OP (UINT16) 0x0e /* ACPI 2.0 */ +#define AML_SCOPE_OP (UINT16) 0x10 +#define AML_BUFFER_OP (UINT16) 0x11 +#define AML_PACKAGE_OP (UINT16) 0x12 +#define AML_VAR_PACKAGE_OP (UINT16) 0x13 /* ACPI 2.0 */ +#define AML_METHOD_OP (UINT16) 0x14 +#define AML_DUAL_NAME_PREFIX (UINT16) 0x2e +#define AML_MULTI_NAME_PREFIX_OP (UINT16) 0x2f +#define AML_NAME_CHAR_SUBSEQ (UINT16) 0x30 +#define AML_NAME_CHAR_FIRST (UINT16) 0x41 +#define AML_EXTENDED_OP_PREFIX (UINT16) 0x5b +#define AML_ROOT_PREFIX (UINT16) 0x5c +#define AML_PARENT_PREFIX (UINT16) 0x5e +#define AML_LOCAL_OP (UINT16) 0x60 +#define AML_LOCAL0 (UINT16) 0x60 +#define AML_LOCAL1 (UINT16) 0x61 +#define AML_LOCAL2 (UINT16) 0x62 +#define AML_LOCAL3 (UINT16) 0x63 +#define AML_LOCAL4 (UINT16) 0x64 +#define AML_LOCAL5 (UINT16) 0x65 +#define AML_LOCAL6 (UINT16) 0x66 +#define AML_LOCAL7 (UINT16) 0x67 +#define AML_ARG_OP (UINT16) 0x68 +#define AML_ARG0 (UINT16) 0x68 +#define AML_ARG1 (UINT16) 0x69 +#define AML_ARG2 (UINT16) 0x6a +#define AML_ARG3 (UINT16) 0x6b +#define AML_ARG4 (UINT16) 0x6c +#define AML_ARG5 (UINT16) 0x6d +#define AML_ARG6 (UINT16) 0x6e +#define AML_STORE_OP (UINT16) 0x70 +#define AML_REF_OF_OP (UINT16) 0x71 +#define AML_ADD_OP (UINT16) 0x72 +#define AML_CONCAT_OP (UINT16) 0x73 +#define AML_SUBTRACT_OP (UINT16) 0x74 +#define AML_INCREMENT_OP (UINT16) 0x75 +#define AML_DECREMENT_OP (UINT16) 0x76 +#define AML_MULTIPLY_OP (UINT16) 0x77 +#define AML_DIVIDE_OP (UINT16) 0x78 +#define AML_SHIFT_LEFT_OP (UINT16) 0x79 +#define AML_SHIFT_RIGHT_OP (UINT16) 0x7a +#define AML_BIT_AND_OP (UINT16) 0x7b +#define AML_BIT_NAND_OP (UINT16) 0x7c +#define AML_BIT_OR_OP (UINT16) 0x7d +#define AML_BIT_NOR_OP (UINT16) 0x7e +#define AML_BIT_XOR_OP (UINT16) 0x7f +#define AML_BIT_NOT_OP (UINT16) 0x80 +#define AML_FIND_SET_LEFT_BIT_OP (UINT16) 0x81 +#define AML_FIND_SET_RIGHT_BIT_OP (UINT16) 0x82 +#define AML_DEREF_OF_OP (UINT16) 0x83 +#define AML_CONCAT_RES_OP (UINT16) 0x84 /* ACPI 2.0 */ +#define AML_MOD_OP (UINT16) 0x85 /* ACPI 2.0 */ +#define AML_NOTIFY_OP (UINT16) 0x86 +#define AML_SIZE_OF_OP (UINT16) 0x87 +#define AML_INDEX_OP (UINT16) 0x88 +#define AML_MATCH_OP (UINT16) 0x89 +#define AML_CREATE_DWORD_FIELD_OP (UINT16) 0x8a +#define AML_CREATE_WORD_FIELD_OP (UINT16) 0x8b +#define AML_CREATE_BYTE_FIELD_OP (UINT16) 0x8c +#define AML_CREATE_BIT_FIELD_OP (UINT16) 0x8d +#define AML_TYPE_OP (UINT16) 0x8e +#define AML_CREATE_QWORD_FIELD_OP (UINT16) 0x8f /* ACPI 2.0 */ +#define AML_LAND_OP (UINT16) 0x90 +#define AML_LOR_OP (UINT16) 0x91 +#define AML_LNOT_OP (UINT16) 0x92 +#define AML_LEQUAL_OP (UINT16) 0x93 +#define AML_LGREATER_OP (UINT16) 0x94 +#define AML_LLESS_OP (UINT16) 0x95 +#define AML_TO_BUFFER_OP (UINT16) 0x96 /* ACPI 2.0 */ +#define AML_TO_DECSTRING_OP (UINT16) 0x97 /* ACPI 2.0 */ +#define AML_TO_HEXSTRING_OP (UINT16) 0x98 /* ACPI 2.0 */ +#define AML_TO_INTEGER_OP (UINT16) 0x99 /* ACPI 2.0 */ +#define AML_TO_STRING_OP (UINT16) 0x9c /* ACPI 2.0 */ +#define AML_COPY_OP (UINT16) 0x9d /* ACPI 2.0 */ +#define AML_MID_OP (UINT16) 0x9e /* ACPI 2.0 */ +#define AML_CONTINUE_OP (UINT16) 0x9f /* ACPI 2.0 */ +#define AML_IF_OP (UINT16) 0xa0 +#define AML_ELSE_OP (UINT16) 0xa1 +#define AML_WHILE_OP (UINT16) 0xa2 +#define AML_NOOP_OP (UINT16) 0xa3 +#define AML_RETURN_OP (UINT16) 0xa4 +#define AML_BREAK_OP (UINT16) 0xa5 +#define AML_BREAK_POINT_OP (UINT16) 0xcc +#define AML_ONES_OP (UINT16) 0xff + +/* prefixed opcodes */ + +#define AML_EXTENDED_OPCODE (UINT16) 0x5b00 /* prefix for 2-byte opcodes */ + +#define AML_MUTEX_OP (UINT16) 0x5b01 +#define AML_EVENT_OP (UINT16) 0x5b02 +#define AML_SHIFT_RIGHT_BIT_OP (UINT16) 0x5b10 +#define AML_SHIFT_LEFT_BIT_OP (UINT16) 0x5b11 +#define AML_COND_REF_OF_OP (UINT16) 0x5b12 +#define AML_CREATE_FIELD_OP (UINT16) 0x5b13 +#define AML_LOAD_TABLE_OP (UINT16) 0x5b1f /* ACPI 2.0 */ +#define AML_LOAD_OP (UINT16) 0x5b20 +#define AML_STALL_OP (UINT16) 0x5b21 +#define AML_SLEEP_OP (UINT16) 0x5b22 +#define AML_ACQUIRE_OP (UINT16) 0x5b23 +#define AML_SIGNAL_OP (UINT16) 0x5b24 +#define AML_WAIT_OP (UINT16) 0x5b25 +#define AML_RESET_OP (UINT16) 0x5b26 +#define AML_RELEASE_OP (UINT16) 0x5b27 +#define AML_FROM_BCD_OP (UINT16) 0x5b28 +#define AML_TO_BCD_OP (UINT16) 0x5b29 +#define AML_UNLOAD_OP (UINT16) 0x5b2a +#define AML_REVISION_OP (UINT16) 0x5b30 +#define AML_DEBUG_OP (UINT16) 0x5b31 +#define AML_FATAL_OP (UINT16) 0x5b32 +#define AML_TIMER_OP (UINT16) 0x5b33 /* ACPI 3.0 */ +#define AML_REGION_OP (UINT16) 0x5b80 +#define AML_FIELD_OP (UINT16) 0x5b81 +#define AML_DEVICE_OP (UINT16) 0x5b82 +#define AML_PROCESSOR_OP (UINT16) 0x5b83 +#define AML_POWER_RES_OP (UINT16) 0x5b84 +#define AML_THERMAL_ZONE_OP (UINT16) 0x5b85 +#define AML_INDEX_FIELD_OP (UINT16) 0x5b86 +#define AML_BANK_FIELD_OP (UINT16) 0x5b87 +#define AML_DATA_REGION_OP (UINT16) 0x5b88 /* ACPI 2.0 */ + + +/* + * Combination opcodes (actually two one-byte opcodes) + * Used by the disassembler and iASL compiler + */ +#define AML_LGREATEREQUAL_OP (UINT16) 0x9295 +#define AML_LLESSEQUAL_OP (UINT16) 0x9294 +#define AML_LNOTEQUAL_OP (UINT16) 0x9293 + + +/* + * Internal opcodes + * Use only "Unknown" AML opcodes, don't attempt to use + * any valid ACPI ASCII values (A-Z, 0-9, '-') + */ +#define AML_INT_NAMEPATH_OP (UINT16) 0x002d +#define AML_INT_NAMEDFIELD_OP (UINT16) 0x0030 +#define AML_INT_RESERVEDFIELD_OP (UINT16) 0x0031 +#define AML_INT_ACCESSFIELD_OP (UINT16) 0x0032 +#define AML_INT_BYTELIST_OP (UINT16) 0x0033 +#define AML_INT_STATICSTRING_OP (UINT16) 0x0034 +#define AML_INT_METHODCALL_OP (UINT16) 0x0035 +#define AML_INT_RETURN_VALUE_OP (UINT16) 0x0036 +#define AML_INT_EVAL_SUBTREE_OP (UINT16) 0x0037 + + +#define ARG_NONE 0x0 + +/* + * Argument types for the AML Parser + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + * Zero is reserved as end-of-list indicator + */ +#define ARGP_BYTEDATA 0x01 +#define ARGP_BYTELIST 0x02 +#define ARGP_CHARLIST 0x03 +#define ARGP_DATAOBJ 0x04 +#define ARGP_DATAOBJLIST 0x05 +#define ARGP_DWORDDATA 0x06 +#define ARGP_FIELDLIST 0x07 +#define ARGP_NAME 0x08 +#define ARGP_NAMESTRING 0x09 +#define ARGP_OBJLIST 0x0A +#define ARGP_PKGLENGTH 0x0B +#define ARGP_SUPERNAME 0x0C +#define ARGP_TARGET 0x0D +#define ARGP_TERMARG 0x0E +#define ARGP_TERMLIST 0x0F +#define ARGP_WORDDATA 0x10 +#define ARGP_QWORDDATA 0x11 +#define ARGP_SIMPLENAME 0x12 + +/* + * Resolved argument types for the AML Interpreter + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types (0 is end-of-arg-list indicator) + * + * Note1: These values are completely independent from the ACPI_TYPEs + * i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER + * + * Note2: If and when 5 bits becomes insufficient, it would probably be best + * to convert to a 6-byte array of argument types, allowing 8 bits per argument. + */ + +/* Single, simple types */ + +#define ARGI_ANYTYPE 0x01 /* Don't care */ +#define ARGI_PACKAGE 0x02 +#define ARGI_EVENT 0x03 +#define ARGI_MUTEX 0x04 +#define ARGI_DDBHANDLE 0x05 + +/* Interchangeable types (via implicit conversion) */ + +#define ARGI_INTEGER 0x06 +#define ARGI_STRING 0x07 +#define ARGI_BUFFER 0x08 +#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */ +#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */ + +/* Reference objects */ + +#define ARGI_INTEGER_REF 0x0B +#define ARGI_OBJECT_REF 0x0C +#define ARGI_DEVICE_REF 0x0D +#define ARGI_REFERENCE 0x0E +#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ +#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ +#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ + +/* Multiple/complex types */ + +#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/ +#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ +#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ +#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */ +#define ARGI_DATAREFOBJ 0x16 + +/* Note: types above can expand to 0x1F maximum */ + +#define ARGI_INVALID_OPCODE 0xFFFFFFFF + + +/* + * hash offsets + */ +#define AML_EXTOP_HASH_OFFSET 22 +#define AML_LNOT_HASH_OFFSET 19 + + +/* + * opcode groups and types + */ +#define OPGRP_NAMED 0x01 +#define OPGRP_FIELD 0x02 +#define OPGRP_BYTELIST 0x04 + + +/* + * Opcode information + */ + +/* Opcode flags */ + +#define AML_LOGICAL 0x0001 +#define AML_LOGICAL_NUMERIC 0x0002 +#define AML_MATH 0x0004 +#define AML_CREATE 0x0008 +#define AML_FIELD 0x0010 +#define AML_DEFER 0x0020 +#define AML_NAMED 0x0040 +#define AML_NSNODE 0x0080 +#define AML_NSOPCODE 0x0100 +#define AML_NSOBJECT 0x0200 +#define AML_HAS_RETVAL 0x0400 +#define AML_HAS_TARGET 0x0800 +#define AML_HAS_ARGS 0x1000 +#define AML_CONSTANT 0x2000 +#define AML_NO_OPERAND_RESOLVE 0x4000 + +/* Convenient flag groupings */ + +#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL +#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ +#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ +#define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET +#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Monadic2R */ +#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */ +#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */ +#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Dyadic2R */ +#define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL +#define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS +#define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL +#define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL + + +/* + * The opcode Type is used in a dispatch table, do not change + * without updating the table. + */ +#define AML_TYPE_EXEC_0A_0T_1R 0x00 +#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */ +#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */ +#define AML_TYPE_EXEC_1A_1T_0R 0x03 +#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* Monadic2R */ +#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */ +#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */ +#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* Dyadic2R */ +#define AML_TYPE_EXEC_2A_2T_1R 0x08 +#define AML_TYPE_EXEC_3A_0T_0R 0x09 +#define AML_TYPE_EXEC_3A_1T_1R 0x0A +#define AML_TYPE_EXEC_6A_0T_1R 0x0B +/* End of types used in dispatch table */ + +#define AML_TYPE_LITERAL 0x0B +#define AML_TYPE_CONSTANT 0x0C +#define AML_TYPE_METHOD_ARGUMENT 0x0D +#define AML_TYPE_LOCAL_VARIABLE 0x0E +#define AML_TYPE_DATA_TERM 0x0F + +/* Generic for an op that returns a value */ + +#define AML_TYPE_METHOD_CALL 0x10 + +/* Misc */ + +#define AML_TYPE_CREATE_FIELD 0x11 +#define AML_TYPE_CREATE_OBJECT 0x12 +#define AML_TYPE_CONTROL 0x13 +#define AML_TYPE_NAMED_NO_OBJ 0x14 +#define AML_TYPE_NAMED_FIELD 0x15 +#define AML_TYPE_NAMED_SIMPLE 0x16 +#define AML_TYPE_NAMED_COMPLEX 0x17 +#define AML_TYPE_RETURN 0x18 + +#define AML_TYPE_UNDEFINED 0x19 +#define AML_TYPE_BOGUS 0x1A + +/* AML Package Length encodings */ + +#define ACPI_AML_PACKAGE_TYPE1 0x40 +#define ACPI_AML_PACKAGE_TYPE2 0x4000 +#define ACPI_AML_PACKAGE_TYPE3 0x400000 +#define ACPI_AML_PACKAGE_TYPE4 0x40000000 + +/* + * Opcode classes + */ +#define AML_CLASS_EXECUTE 0x00 +#define AML_CLASS_CREATE 0x01 +#define AML_CLASS_ARGUMENT 0x02 +#define AML_CLASS_NAMED_OBJECT 0x03 +#define AML_CLASS_CONTROL 0x04 +#define AML_CLASS_ASCII 0x05 +#define AML_CLASS_PREFIX 0x06 +#define AML_CLASS_INTERNAL 0x07 +#define AML_CLASS_RETURN_VALUE 0x08 +#define AML_CLASS_METHOD_CALL 0x09 +#define AML_CLASS_UNKNOWN 0x0A + + +/* Predefined Operation Region SpaceIDs */ + +typedef enum +{ + REGION_MEMORY = 0, + REGION_IO, + REGION_PCI_CONFIG, + REGION_EC, + REGION_SMBUS, + REGION_CMOS, + REGION_PCI_BAR, + REGION_IPMI, + REGION_DATA_TABLE, /* Internal use only */ + REGION_FIXED_HW = 0x7F + +} AML_REGION_TYPES; + + +/* Comparison operation codes for MatchOp operator */ + +typedef enum +{ + MATCH_MTR = 0, + MATCH_MEQ = 1, + MATCH_MLE = 2, + MATCH_MLT = 3, + MATCH_MGE = 4, + MATCH_MGT = 5 + +} AML_MATCH_OPERATOR; + +#define MAX_MATCH_OPERATOR 5 + + +/* + * FieldFlags + * + * This byte is extracted from the AML and includes three separate + * pieces of information about the field: + * 1) The field access type + * 2) The field update rule + * 3) The lock rule for the field + * + * Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.) + * 04 : LockRule (1 == Lock) + * 05 - 06 : UpdateRule + */ +#define AML_FIELD_ACCESS_TYPE_MASK 0x0F +#define AML_FIELD_LOCK_RULE_MASK 0x10 +#define AML_FIELD_UPDATE_RULE_MASK 0x60 + + +/* 1) Field Access Types */ + +typedef enum +{ + AML_FIELD_ACCESS_ANY = 0x00, + AML_FIELD_ACCESS_BYTE = 0x01, + AML_FIELD_ACCESS_WORD = 0x02, + AML_FIELD_ACCESS_DWORD = 0x03, + AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */ + AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */ + +} AML_ACCESS_TYPE; + + +/* 2) Field Lock Rules */ + +typedef enum +{ + AML_FIELD_LOCK_NEVER = 0x00, + AML_FIELD_LOCK_ALWAYS = 0x10 + +} AML_LOCK_RULE; + + +/* 3) Field Update Rules */ + +typedef enum +{ + AML_FIELD_UPDATE_PRESERVE = 0x00, + AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20, + AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40 + +} AML_UPDATE_RULE; + + +/* + * Field Access Attributes. + * This byte is extracted from the AML via the + * AccessAs keyword + */ +typedef enum +{ + AML_FIELD_ATTRIB_SMB_QUICK = 0x02, + AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04, + AML_FIELD_ATTRIB_SMB_BYTE = 0x06, + AML_FIELD_ATTRIB_SMB_WORD = 0x08, + AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A, + AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C, + AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D + +} AML_ACCESS_ATTRIBUTE; + + +/* Bit fields in MethodFlags byte */ + +#define AML_METHOD_ARG_COUNT 0x07 +#define AML_METHOD_SERIALIZED 0x08 +#define AML_METHOD_SYNC_LEVEL 0xF0 + +/* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */ + +#define AML_METHOD_INTERNAL_ONLY 0x01 +#define AML_METHOD_RESERVED1 0x02 +#define AML_METHOD_RESERVED2 0x04 + + +#endif /* __AMLCODE_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/amlresrc.h b/reactos/drivers/bus/acpi/acpica/include/amlresrc.h new file mode 100644 index 00000000000..689564c6289 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/amlresrc.h @@ -0,0 +1,485 @@ + +/****************************************************************************** + * + * Module Name: amlresrc.h - AML resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +#ifndef __AMLRESRC_H +#define __AMLRESRC_H + + +/* + * Resource descriptor tags, as defined in the ACPI specification. + * Used to symbolically reference fields within a descriptor. + */ +#define ACPI_RESTAG_ADDRESS "_ADR" +#define ACPI_RESTAG_ALIGNMENT "_ALN" +#define ACPI_RESTAG_ADDRESSSPACE "_ASI" +#define ACPI_RESTAG_ACCESSSIZE "_ASZ" +#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" +#define ACPI_RESTAG_BASEADDRESS "_BAS" +#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ +#define ACPI_RESTAG_DECODE "_DEC" +#define ACPI_RESTAG_DMA "_DMA" +#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ +#define ACPI_RESTAG_GRANULARITY "_GRA" +#define ACPI_RESTAG_INTERRUPT "_INT" +#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */ +#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */ +#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ +#define ACPI_RESTAG_LENGTH "_LEN" +#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ +#define ACPI_RESTAG_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ +#define ACPI_RESTAG_MAXADDR "_MAX" +#define ACPI_RESTAG_MINADDR "_MIN" +#define ACPI_RESTAG_MAXTYPE "_MAF" +#define ACPI_RESTAG_MINTYPE "_MIF" +#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" +#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" +#define ACPI_RESTAG_RANGETYPE "_RNG" +#define ACPI_RESTAG_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */ +#define ACPI_RESTAG_TRANSLATION "_TRA" +#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ +#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ +#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */ + + +/* Default sizes for "small" resource descriptors */ + +#define ASL_RDESC_IRQ_SIZE 0x02 +#define ASL_RDESC_DMA_SIZE 0x02 +#define ASL_RDESC_ST_DEPEND_SIZE 0x00 +#define ASL_RDESC_END_DEPEND_SIZE 0x00 +#define ASL_RDESC_IO_SIZE 0x07 +#define ASL_RDESC_FIXED_IO_SIZE 0x03 +#define ASL_RDESC_END_TAG_SIZE 0x01 + + +typedef struct asl_resource_node +{ + UINT32 BufferLength; + void *Buffer; + struct asl_resource_node *Next; + +} ASL_RESOURCE_NODE; + + +/* Macros used to generate AML resource length fields */ + +#define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER)) +#define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER)) + +/* + * Resource descriptors defined in the ACPI specification. + * + * Packing/alignment must be BYTE because these descriptors + * are used to overlay the raw AML byte stream. + */ +#pragma pack(1) + +/* + * SMALL descriptors + */ +#define AML_RESOURCE_SMALL_HEADER_COMMON \ + UINT8 DescriptorType; + +typedef struct aml_resource_small_header +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_SMALL_HEADER; + + +typedef struct aml_resource_irq +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 IrqMask; + UINT8 Flags; + +} AML_RESOURCE_IRQ; + + +typedef struct aml_resource_irq_noflags +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 IrqMask; + +} AML_RESOURCE_IRQ_NOFLAGS; + + +typedef struct aml_resource_dma +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 DmaChannelMask; + UINT8 Flags; + +} AML_RESOURCE_DMA; + + +typedef struct aml_resource_start_dependent +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Flags; + +} AML_RESOURCE_START_DEPENDENT; + + +typedef struct aml_resource_start_dependent_noprio +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_START_DEPENDENT_NOPRIO; + + +typedef struct aml_resource_end_dependent +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_END_DEPENDENT; + + +typedef struct aml_resource_io +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT8 Alignment; + UINT8 AddressLength; + +} AML_RESOURCE_IO; + + +typedef struct aml_resource_fixed_io +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 Address; + UINT8 AddressLength; + +} AML_RESOURCE_FIXED_IO; + + +typedef struct aml_resource_vendor_small +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_VENDOR_SMALL; + + +typedef struct aml_resource_end_tag +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Checksum; + +} AML_RESOURCE_END_TAG; + + +/* + * LARGE descriptors + */ +#define AML_RESOURCE_LARGE_HEADER_COMMON \ + UINT8 DescriptorType;\ + UINT16 ResourceLength; + +typedef struct aml_resource_large_header +{ + AML_RESOURCE_LARGE_HEADER_COMMON + +} AML_RESOURCE_LARGE_HEADER; + + +typedef struct aml_resource_memory24 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; + +} AML_RESOURCE_MEMORY24; + + +typedef struct aml_resource_vendor_large +{ + AML_RESOURCE_LARGE_HEADER_COMMON + +} AML_RESOURCE_VENDOR_LARGE; + + +typedef struct aml_resource_memory32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; + +} AML_RESOURCE_MEMORY32; + + +typedef struct aml_resource_fixed_memory32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT32 Address; + UINT32 AddressLength; + +} AML_RESOURCE_FIXED_MEMORY32; + + +#define AML_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 Flags; \ + UINT8 SpecificFlags; + + +typedef struct aml_resource_address +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + +} AML_RESOURCE_ADDRESS; + + +typedef struct aml_resource_extended_address64 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT8 Reserved; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; + +} AML_RESOURCE_EXTENDED_ADDRESS64; + +#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ + + +typedef struct aml_resource_address64 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + +} AML_RESOURCE_ADDRESS64; + + +typedef struct aml_resource_address32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; + +} AML_RESOURCE_ADDRESS32; + + +typedef struct aml_resource_address16 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; + +} AML_RESOURCE_ADDRESS16; + + +typedef struct aml_resource_extended_irq +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT8 InterruptCount; + UINT32 Interrupts[1]; + /* ResSourceIndex, ResSource optional fields follow */ + +} AML_RESOURCE_EXTENDED_IRQ; + + +typedef struct aml_resource_generic_register +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 AddressSpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; /* ACPI 3.0, was previously Reserved */ + UINT64 Address; + +} AML_RESOURCE_GENERIC_REGISTER; + +/* restore default alignment */ + +#pragma pack() + +/* Union of all resource descriptors, so we can allocate the worst case */ + +typedef union aml_resource +{ + /* Descriptor headers */ + + UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER SmallHeader; + AML_RESOURCE_LARGE_HEADER LargeHeader; + + /* Small resource descriptors */ + + AML_RESOURCE_IRQ Irq; + AML_RESOURCE_DMA Dma; + AML_RESOURCE_START_DEPENDENT StartDpf; + AML_RESOURCE_END_DEPENDENT EndDpf; + AML_RESOURCE_IO Io; + AML_RESOURCE_FIXED_IO FixedIo; + AML_RESOURCE_VENDOR_SMALL VendorSmall; + AML_RESOURCE_END_TAG EndTag; + + /* Large resource descriptors */ + + AML_RESOURCE_MEMORY24 Memory24; + AML_RESOURCE_GENERIC_REGISTER GenericReg; + AML_RESOURCE_VENDOR_LARGE VendorLarge; + AML_RESOURCE_MEMORY32 Memory32; + AML_RESOURCE_FIXED_MEMORY32 FixedMemory32; + AML_RESOURCE_ADDRESS16 Address16; + AML_RESOURCE_ADDRESS32 Address32; + AML_RESOURCE_ADDRESS64 Address64; + AML_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + AML_RESOURCE_EXTENDED_IRQ ExtendedIrq; + + /* Utility overlays */ + + AML_RESOURCE_ADDRESS Address; + UINT32 DwordItem; + UINT16 WordItem; + UINT8 ByteItem; + +} AML_RESOURCE; + +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/accygwin.h b/reactos/drivers/bus/acpi/acpica/include/platform/accygwin.h new file mode 100644 index 00000000000..e9585b44b10 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/accygwin.h @@ -0,0 +1,163 @@ +/****************************************************************************** + * + * Name: accygwin.h - OS specific defines, etc. for cygwin environment + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACCYGWIN_H__ +#define __ACCYGWIN_H__ + +/* + * ACPICA configuration + */ +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_DO_WHILE_0 +#define ACPI_THREAD_ID pthread_t +#define ACPI_FLUSH_CPU_CACHE() +/* + * This is needed since sem_timedwait does not appear to work properly + * on cygwin (always hangs forever). + */ +#define ACPI_USE_ALTERNATE_TIMEOUT + + +#include +#include +#include +#include +#include + +#if defined(__ia64__) || defined(__x86_64__) +#define ACPI_MACHINE_WIDTH 64 +#define COMPILER_DEPENDENT_INT64 long +#define COMPILER_DEPENDENT_UINT64 unsigned long +#else +#define ACPI_MACHINE_WIDTH 32 +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE +#endif + +#ifndef __cdecl +#define __cdecl +#endif + +#ifdef _ANSI +#define inline +#endif + + +/* Cygwin uses GCC */ + +#include "acgcc.h" + +#endif /* __ACCYGWIN_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acdos16.h b/reactos/drivers/bus/acpi/acpica/include/platform/acdos16.h new file mode 100644 index 00000000000..f3aead6084b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acdos16.h @@ -0,0 +1,164 @@ +/****************************************************************************** + * + * Name: acdos16.h - DOS specific defines, etc. + * $Revision: 1.18 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDOS16_H__ +#define __ACDOS16_H__ + + +/* NOTE: 16-bit ACPICA is no longer supported, December 2006 */ + +#define ACPI_USE_STANDARD_HEADERS +#define ACPI_MACHINE_WIDTH 16 + +/* Use a struct for 64-bit integers */ + +typedef struct +{ + unsigned long Lo; + unsigned long Hi; + +} COMPILER_DEPENDENT_UINT64; + +typedef struct +{ + long Lo; + long Hi; + +} COMPILER_DEPENDENT_INT64; + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE __cdecl +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE __cdecl + +#define ACPI_ASM_MACROS +#define BREAKPOINT3 +#define ACPI_DISABLE_IRQS() +#define ACPI_ENABLE_IRQS() +#define halt() +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) + + +#endif /* __ACDOS16_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h b/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h new file mode 100644 index 00000000000..40afaa401cf --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h @@ -0,0 +1,147 @@ +/****************************************************************************** + * + * Name: acefi.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEFI_H__ +#define __ACEFI_H__ + +#include +#include +#include + + +/* _int64 works for both IA32 and IA64 */ + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +/* warn C4142: redefinition of type */ + +#pragma warning(disable:4142) + + +#endif /* __ACEFI_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h b/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h new file mode 100644 index 00000000000..58cb03bfc1a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h @@ -0,0 +1,432 @@ +/****************************************************************************** + * + * Name: acenv.h - Host and compiler configuration + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACENV_H__ +#define __ACENV_H__ + +/* + * Environment configuration. The purpose of this file is to interface ACPICA + * to the local environment. This includes compiler-specific, OS-specific, + * and machine-specific configuration. + */ + +/* Types for ACPI_MUTEX_TYPE */ + +#define ACPI_BINARY_SEMAPHORE 0 +#define ACPI_OSL_MUTEX 1 + +/* Types for DEBUGGER_THREADING */ + +#define DEBUGGER_SINGLE_THREADED 0 +#define DEBUGGER_MULTI_THREADED 1 + + +/****************************************************************************** + * + * Configuration for ACPI tools and utilities + * + *****************************************************************************/ + +/* iASL configuration */ + +#ifdef ACPI_ASL_COMPILER +#define ACPI_APPLICATION +#define ACPI_DISASSEMBLER +#define ACPI_DEBUG_OUTPUT +#define ACPI_CONSTANT_EVAL_ONLY +#define ACPI_LARGE_NAMESPACE_NODE +#define ACPI_DATA_TABLE_DISASSEMBLY +#endif + +/* AcpiExec configuration */ + +#ifdef ACPI_EXEC_APP +#define ACPI_APPLICATION +#define ACPI_FULL_DEBUG +#define ACPI_MUTEX_DEBUG +#define ACPI_DBG_TRACK_ALLOCATIONS +#endif + +/* Linkable ACPICA library */ + +#ifdef ACPI_LIBRARY +#define ACPI_USE_LOCAL_CACHE +#endif + +/* Common for all ACPICA applications */ + +#ifdef ACPI_APPLICATION +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_LOCAL_CACHE +#endif + +/* Common debug support */ + +#ifdef ACPI_FULL_DEBUG +#define ACPI_DEBUGGER +#define ACPI_DEBUG_OUTPUT +#define ACPI_DISASSEMBLER +#endif + + +/*! [Begin] no source code translation */ + +/****************************************************************************** + * + * Host configuration files. The compiler configuration files are included + * by the host files. + * + *****************************************************************************/ + +#if defined(_LINUX) || defined(__linux__) +#include "aclinux.h" + +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include "acfreebsd.h" + +#elif defined(__NetBSD__) +#include "acnetbsd.h" + +#elif defined(__sun) +#include "acsolaris.h" + +#elif defined(MODESTO) +#include "acmodesto.h" + +#elif defined(NETWARE) +#include "acnetware.h" + +#elif defined(_CYGWIN) +#include "accygwin.h" + +#elif defined(WIN32) +#include "acwin.h" + +#elif defined(WIN64) +#include "acwin64.h" + +#elif defined(_WRS_LIB_BUILD) +#include "acvxworks.h" + +#elif defined(__OS2__) +#include "acos2.h" + +#elif defined(_AED_EFI) +#include "acefi.h" + +#else + +/* Unknown environment */ + +#error Unknown target environment +#endif + +/*! [End] no source code translation !*/ + + +/****************************************************************************** + * + * Setup defaults for the required symbols that were not defined in one of + * the host/compiler files above. + * + *****************************************************************************/ + +/* 64-bit data types */ + +#ifndef COMPILER_DEPENDENT_INT64 +#define COMPILER_DEPENDENT_INT64 long long +#endif + +#ifndef COMPILER_DEPENDENT_UINT64 +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#endif + +/* Type of mutex supported by host. Default is binary semaphores. */ + +#ifndef ACPI_MUTEX_TYPE +#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE +#endif + +/* Global Lock acquire/release */ + +#ifndef ACPI_ACQUIRE_GLOBAL_LOCK +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = 1 +#endif + +#ifndef ACPI_RELEASE_GLOBAL_LOCK +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) Acq = 0 +#endif + +/* Flush CPU cache - used when going to sleep. Wbinvd or similar. */ + +#ifndef ACPI_FLUSH_CPU_CACHE +#define ACPI_FLUSH_CPU_CACHE() +#endif + +/* + * Configurable calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#ifndef ACPI_SYSTEM_XFACE +#define ACPI_SYSTEM_XFACE +#endif + +#ifndef ACPI_EXTERNAL_XFACE +#define ACPI_EXTERNAL_XFACE +#endif + +#ifndef ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#endif + +#ifndef ACPI_INTERNAL_VAR_XFACE +#define ACPI_INTERNAL_VAR_XFACE +#endif + +/* + * Debugger threading model + * Use single threaded if the entire subsystem is contained in an application + * Use multiple threaded when the subsystem is running in the kernel. + * + * By default the model is single threaded if ACPI_APPLICATION is set, + * multi-threaded if ACPI_APPLICATION is not set. + */ +#ifndef DEBUGGER_THREADING +#ifdef ACPI_APPLICATION +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED + +#else +#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED +#endif +#endif /* !DEBUGGER_THREADING */ + + +/****************************************************************************** + * + * C library configuration + * + *****************************************************************************/ + +/* + * ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. + * Otherwise, local versions of string/memory functions will be used. + * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and + * the standard header files may be used. + * + * The ACPICA subsystem only uses low level C library functions that do not call + * operating system services and may therefore be inlined in the code. + * + * It may be necessary to tailor these include files to the target + * generation environment. + */ +#ifdef ACPI_USE_SYSTEM_CLIBRARY + +/* Use the standard C library headers. We want to keep these to a minimum */ + +#ifdef ACPI_USE_STANDARD_HEADERS + +/* Use the standard headers from the standard locations */ + +#include +#include +#include +#include + +#endif /* ACPI_USE_STANDARD_HEADERS */ + +/* We will be linking to the standard Clib functions */ + +#define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) +#define ACPI_STRCHR(s1,c) strchr((s1), (c)) +#define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s)) +#define ACPI_STRCPY(d,s) (void) strcpy((d), (s)) +#define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRNCMP(d,s,n) strncmp((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRCMP(d,s) strcmp((d), (s)) +#define ACPI_STRCAT(d,s) (void) strcat((d), (s)) +#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) +#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n)) +#define ACPI_TOUPPER(i) toupper((int) (i)) +#define ACPI_TOLOWER(i) tolower((int) (i)) +#define ACPI_IS_XDIGIT(i) isxdigit((int) (i)) +#define ACPI_IS_DIGIT(i) isdigit((int) (i)) +#define ACPI_IS_SPACE(i) isspace((int) (i)) +#define ACPI_IS_UPPER(i) isupper((int) (i)) +#define ACPI_IS_PRINT(i) isprint((int) (i)) +#define ACPI_IS_ALPHA(i) isalpha((int) (i)) + +#else + +/****************************************************************************** + * + * Not using native C library, use local implementations + * + *****************************************************************************/ + +/* + * Use local definitions of C library macros and functions. These function + * implementations may not be as efficient as an inline or assembly code + * implementation provided by a native C library, but they are functionally + * equivalent. + */ +#ifndef va_arg + +#ifndef _VALIST +#define _VALIST +typedef char *va_list; +#endif /* _VALIST */ + +/* Storage alignment properties */ + +#define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1) +#define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1) + +/* Variable argument list macro definitions */ + +#define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) +#define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND)))) +#define va_end(ap) (void) 0 +#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_Bnd (A,_AUPBND)))) + +#endif /* va_arg */ + +/* Use the local (ACPICA) definitions of the clib functions */ + +#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) +#define ACPI_STRCHR(s1,c) AcpiUtStrchr ((s1), (c)) +#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s)) +#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s)) +#define ACPI_STRNCPY(d,s,n) (void) AcpiUtStrncpy ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRNCMP(d,s,n) AcpiUtStrncmp ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s)) +#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s)) +#define ACPI_STRNCAT(d,s,n) AcpiUtStrncat ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRTOUL(d,s,n) AcpiUtStrtoul ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) AcpiUtMemcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) +#define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n)) +#define ACPI_TOUPPER AcpiUtToUpper +#define ACPI_TOLOWER AcpiUtToLower + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + +#endif /* __ACENV_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acfreebsd.h b/reactos/drivers/bus/acpi/acpica/include/platform/acfreebsd.h new file mode 100644 index 00000000000..20c5687c20b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acfreebsd.h @@ -0,0 +1,180 @@ +/****************************************************************************** + * + * Name: acfreebsd.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACFREEBSD_H__ +#define __ACFREEBSD_H__ + + +/* FreeBSD uses GCC */ + +#include "acgcc.h" +#include +#include + +#define ACPI_UINTPTR_T uintptr_t + +#define ACPI_USE_LOCAL_CACHE +#define ACPI_USE_SYSTEM_CLIBRARY + +#define __cdecl + +#ifdef _KERNEL + +#include +#include +#include +#include +#include + +#include "opt_acpi.h" + +#define ACPI_THREAD_ID lwpid_t + +#ifdef ACPI_DEBUG +#define ACPI_DEBUG_OUTPUT /* for backward compatibility */ +#define ACPI_DISASSEMBLER +#endif + +#ifdef ACPI_DEBUG_OUTPUT +#include "opt_ddb.h" +#ifdef DDB +#define ACPI_DEBUGGER +#endif /* DDB */ +#endif /* ACPI_DEBUG_OUTPUT */ + +#ifdef DEBUGGER_THREADING +#undef DEBUGGER_THREADING +#endif /* DEBUGGER_THREADING */ + +#define DEBUGGER_THREADING 0 /* integrated with DDB */ + +#else /* _KERNEL */ + +#if __STDC_HOSTED__ +#include +#endif + +#define ACPI_THREAD_ID pthread_t + +/* Not building kernel code, so use libc */ +#define ACPI_USE_STANDARD_HEADERS +#define ACPI_FLUSH_CPU_CACHE() + +#define __cli() +#define __sti() + +#endif /* _KERNEL */ + +#endif /* __ACFREEBSD_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h b/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h new file mode 100644 index 00000000000..e517a23ae22 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h @@ -0,0 +1,179 @@ +/****************************************************************************** + * + * Name: acgcc.h - GCC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACGCC_H__ +#define __ACGCC_H__ + +/* Function name is used for debug output. Non-ANSI, compiler-dependent */ + +#define ACPI_GET_FUNCTION_NAME __FUNCTION__ + +/* + * This macro is used to tag functions as "printf-like" because + * some compilers (like GCC) can catch printf format string problems. + */ +#define ACPI_PRINTF_LIKE(c) __attribute__ ((__format__ (__printf__, c, c+1))) + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (for example, _AcpiModuleName). This allows us + * to to tell the compiler warning in a per-variable manner that a variable + * is unused. + */ +#define ACPI_UNUSED_VAR __attribute__ ((unused)) + +#define COMPILER_DEPENDENT_INT64 long long int +#define COMPILER_DEPENDENT_UINT64 unsigned long long int + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "btsl $0x1,%%edx;" \ + "adcl $0x0,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "cmpb $0x3,%%dl;" \ + "sbbl %%eax,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ + } while(0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "andl $0x1,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ + } while(0) + +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + q32 = n_hi / d32; \ + r32 = n_lo / d32; \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + n_hi >>= 1; \ + n_lo >>= 1; \ +} + +#endif /* __ACGCC_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acintel.h b/reactos/drivers/bus/acpi/acpica/include/platform/acintel.h new file mode 100644 index 00000000000..44197a09946 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acintel.h @@ -0,0 +1,168 @@ +/****************************************************************************** + * + * Name: acintel.h - VC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACINTEL_H__ +#define __ACINTEL_H__ + + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +#define inline __inline + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +/* + * Math helper functions + */ +#define ACPI_DIV_64_BY_32(n, n_hi, n_lo, d32, q32, r32) \ +{ \ + q32 = n / d32; \ + r32 = n % d32; \ +} + +#define ACPI_SHIFT_RIGHT_64(n, n_hi, n_lo) \ +{ \ + n <<= 1; \ +} + +/* remark 981 - operands evaluated in no particular order */ +#pragma warning(disable:981) + +/* warn C4100: unreferenced formal parameter */ +#pragma warning(disable:4100) + +/* warn C4127: conditional expression is constant */ +#pragma warning(disable:4127) + +/* warn C4706: assignment within conditional expression */ +#pragma warning(disable:4706) + +/* warn C4214: bit field types other than int */ +#pragma warning(disable:4214) + + +#endif /* __ACINTEL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h b/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h new file mode 100644 index 00000000000..c6f868cdbf9 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h @@ -0,0 +1,233 @@ +/****************************************************************************** + * + * Name: aclinux.h - OS specific defines, etc. for Linux + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACLINUX_H__ +#define __ACLINUX_H__ + +/* Common (in-kernel/user-space) ACPICA configuration */ + +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_DO_WHILE_0 +#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE + + +#ifdef __KERNEL__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Host-dependent types and defines for in-kernel ACPICA */ + +#define ACPI_MACHINE_WIDTH BITS_PER_LONG +#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); +#define strtoul simple_strtoul + +#define ACPI_CACHE_T struct kmem_cache +#define ACPI_SPINLOCK spinlock_t * +#define ACPI_CPU_FLAGS unsigned long +#define ACPI_THREAD_ID struct task_struct * + +#else /* !__KERNEL__ */ + +#include +#include +#include +#include +#include + +/* Host-dependent types and defines for user-space ACPICA */ + +#define ACPI_FLUSH_CPU_CACHE() +#define ACPI_THREAD_ID pthread_t + +#if defined(__ia64__) || defined(__x86_64__) +#define ACPI_MACHINE_WIDTH 64 +#define COMPILER_DEPENDENT_INT64 long +#define COMPILER_DEPENDENT_UINT64 unsigned long +#else +#define ACPI_MACHINE_WIDTH 32 +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE +#endif + +#ifndef __cdecl +#define __cdecl +#endif + +#endif /* __KERNEL__ */ + +/* Linux uses GCC */ + +#include "acgcc.h" + + +#ifdef __KERNEL__ +/* + * Overrides for in-kernel ACPICA + */ +static inline acpi_thread_id acpi_os_get_thread_id(void) +{ + return current; +} + +/* + * The irqs_disabled() check is for resume from RAM. + * Interrupts are off during resume, just like they are for boot. + * However, boot has (system_state != SYSTEM_RUNNING) + * to quiet __might_sleep() in kmalloc() and resume does not. + */ +#include +static inline void *acpi_os_allocate(acpi_size size) +{ + return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void *acpi_os_allocate_zeroed(acpi_size size) +{ + return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void *acpi_os_acquire_object(acpi_cache_t * cache) +{ + return kmem_cache_zalloc(cache, + irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +#define ACPI_ALLOCATE(a) acpi_os_allocate(a) +#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a) +#define ACPI_FREE(a) kfree(a) + +/* Used within ACPICA to show where it is safe to preempt execution */ + +#define ACPI_PREEMPTION_POINT() \ + do { \ + if (!irqs_disabled()) \ + cond_resched(); \ + } while (0) + +#endif /* __KERNEL__ */ + +#endif /* __ACLINUX_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acmsvc.h b/reactos/drivers/bus/acpi/acpica/include/platform/acmsvc.h new file mode 100644 index 00000000000..ab9e75a88a8 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acmsvc.h @@ -0,0 +1,249 @@ +/****************************************************************************** + * + * Name: acmsvc.h - VC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACMSVC_H__ +#define __ACMSVC_H__ + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE __cdecl +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE __cdecl + +#ifndef _LINT +/* + * Math helper functions + */ +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + __asm mov edx, n_hi \ + __asm mov eax, n_lo \ + __asm div d32 \ + __asm mov q32, eax \ + __asm mov r32, edx \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + __asm shr n_hi, 1 \ + __asm rcr n_lo, 1 \ +} +#else + +/* Fake versions to make lint happy */ + +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + q32 = n_hi / d32; \ + r32 = n_lo / d32; \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + n_hi >>= 1; \ + n_lo >>= 1; \ +} +#endif + +/*! [Begin] no source code translation */ + +#ifdef ACPI_APPLICATION +#define ACPI_FLUSH_CPU_CACHE() +#else +#define ACPI_FLUSH_CPU_CACHE() __asm {WBINVD} +#endif + +#ifdef _DEBUG +#define ACPI_SIMPLE_RETURN_MACROS +#endif + +/*! [End] no source code translation !*/ + +/* + * Global Lock acquire/release code + * + * Note: Handles case where the FACS pointer is null + */ +#define ACPI_ACQUIRE_GLOBAL_LOCK(FacsPtr, Acq) __asm \ +{ \ + __asm mov eax, 0xFF \ + __asm mov ecx, FacsPtr \ + __asm or ecx, ecx \ + __asm jz exit_acq \ + __asm lea ecx, [ecx].GlobalLock \ + \ + __asm acq10: \ + __asm mov eax, [ecx] \ + __asm mov edx, eax \ + __asm and edx, 0xFFFFFFFE \ + __asm bts edx, 1 \ + __asm adc edx, 0 \ + __asm lock cmpxchg dword ptr [ecx], edx \ + __asm jnz acq10 \ + \ + __asm cmp dl, 3 \ + __asm sbb eax, eax \ + \ + __asm exit_acq: \ + __asm mov Acq, al \ +} + +#define ACPI_RELEASE_GLOBAL_LOCK(FacsPtr, Pnd) __asm \ +{ \ + __asm xor eax, eax \ + __asm mov ecx, FacsPtr \ + __asm or ecx, ecx \ + __asm jz exit_rel \ + __asm lea ecx, [ecx].GlobalLock \ + \ + __asm Rel10: \ + __asm mov eax, [ecx] \ + __asm mov edx, eax \ + __asm and edx, 0xFFFFFFFC \ + __asm lock cmpxchg dword ptr [ecx], edx \ + __asm jnz Rel10 \ + \ + __asm cmp dl, 3 \ + __asm and eax, 1 \ + \ + __asm exit_rel: \ + __asm mov Pnd, al \ +} + + +/* warn C4100: unreferenced formal parameter */ +#pragma warning(disable:4100) + +/* warn C4127: conditional expression is constant */ +#pragma warning(disable:4127) + +/* warn C4706: assignment within conditional expression */ +#pragma warning(disable:4706) + +/* warn C4131: uses old-style declarator (iASL compiler only) */ +#pragma warning(disable:4131) + + +#endif /* __ACMSVC_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acnetbsd.h b/reactos/drivers/bus/acpi/acpica/include/platform/acnetbsd.h new file mode 100644 index 00000000000..c04851b926a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acnetbsd.h @@ -0,0 +1,188 @@ +/****************************************************************************** + * + * Name: acnetbsd.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNETBSD_H__ +#define __ACNETBSD_H__ + +/* NetBSD uses GCC */ + +#include "acgcc.h" + +#ifdef _LP64 +#define ACPI_MACHINE_WIDTH 64 +#else +#define ACPI_MACHINE_WIDTH 32 +#endif + +#define COMPILER_DEPENDENT_INT64 int64_t +#define COMPILER_DEPENDENT_UINT64 uint64_t + +#ifdef _KERNEL +#include "opt_acpi.h" /* collect build-time options here */ + +#include +#include +#include +#include + +#define asm __asm + +#define ACPI_USE_NATIVE_DIVIDE + +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +#ifdef ACPI_DEBUG +#define ACPI_DEBUG_OUTPUT +#define ACPI_DBG_TRACK_ALLOCATIONS +#ifdef DEBUGGER_THREADING +#undef DEBUGGER_THREADING +#endif /* DEBUGGER_THREADING */ +#define DEBUGGER_THREADING 0 /* integrated with DDB */ +#include "opt_ddb.h" +#ifdef DDB +#define ACPI_DISASSEMBLER +#define ACPI_DEBUGGER +#endif /* DDB */ +#endif /* ACPI_DEBUG */ + +static __inline int +isprint(int ch) +{ + return(isspace(ch) || isascii(ch)); +} + +#else /* _KERNEL */ + +#include + +/* Not building kernel code, so use libc */ +#define ACPI_USE_STANDARD_HEADERS + +#define __cli() +#define __sti() + +/* XXX */ +#define __inline inline + +#endif /* _KERNEL */ + +/* Always use NetBSD code over our local versions */ +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_NATIVE_DIVIDE + +#endif /* __ACNETBSD_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acos2.h b/reactos/drivers/bus/acpi/acpica/include/platform/acos2.h new file mode 100644 index 00000000000..21e3373c24d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acos2.h @@ -0,0 +1,172 @@ +/****************************************************************************** + * + * Name: acos2.h - OS/2 specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOS2_H__ +#define __ACOS2_H__ +#define INCL_LONGLONG +#include + + +#define ACPI_MACHINE_WIDTH 32 + +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE + +#define ACPI_SYSTEM_XFACE APIENTRY +#define ACPI_EXTERNAL_XFACE APIENTRY +#define ACPI_INTERNAL_XFACE APIENTRY +#define ACPI_INTERNAL_VAR_XFACE APIENTRY + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (most specifically for _THIS_MODULE). This allow us + * to to tell the compiler warning in a per-variable manner that a variable + * is unused. + */ +#define ACPI_UNUSED_VAR + +#define ACPI_USE_STANDARD_HEADERS +#include + +#define ACPI_FLUSH_CPU_CACHE() Wbinvd() +void Wbinvd(void); + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = OSPMAcquireGlobalLock(GLptr) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) Pnd = OSPMReleaseGlobalLock(GLptr) +unsigned short OSPMAcquireGlobalLock (void *); +unsigned short OSPMReleaseGlobalLock (void *); + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + unsigned long long val = 0LL; \ + val = n_lo | ( ((unsigned long long)h_hi) << 32 ); \ + __llrotr (val,1); \ + n_hi = (unsigned long)((val >> 32 ) & 0xffffffff ); \ + n_lo = (unsigned long)(val & 0xffffffff); \ +} + +/* IBM VAC does not have inline */ + +#if __IBMC__ || __IBMCPP__ +#define inline +#endif + +#ifndef ACPI_ASL_COMPILER +#define ACPI_USE_LOCAL_CACHE +#undef ACPI_DEBUGGER +#endif + +#endif /* __ACOS2_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acwin.h b/reactos/drivers/bus/acpi/acpica/include/platform/acwin.h new file mode 100644 index 00000000000..a1f6e856e6d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acwin.h @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * Name: acwin.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACWIN_H__ +#define __ACWIN_H__ + +/*! [Begin] no source code translation (Keep the include) */ + +/* Windows uses VC */ +#ifdef _MSC_VER +#include "acmsvc.h" +#elif __GNUC__ +#include "acgcc.h" +#endif + +/*! [End] no source code translation !*/ + +#define ACPI_MACHINE_WIDTH 32 + +#define inline __inline + +#define ACPI_USE_STANDARD_HEADERS + +#ifdef ACPI_DEFINE_ALTERNATE_TYPES +/* + * Types used only in (Linux) translated source, defined here to enable + * cross-platform compilation (i.e., generate the Linux code on Windows, + * for test purposes only) + */ +typedef int s32; +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef COMPILER_DEPENDENT_UINT64 u64; +#endif + +/* + * Handle platform- and compiler-specific assembly language differences. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +#endif /* __ACWIN_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acwin64.h b/reactos/drivers/bus/acpi/acpica/include/platform/acwin64.h new file mode 100644 index 00000000000..faec855e22d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acwin64.h @@ -0,0 +1,155 @@ +/****************************************************************************** + * + * Name: acwin.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACWIN64_H__ +#define __ACWIN64_H__ + +/*! [Begin] no source code translation (Keep the include) */ + +#include "acintel.h" +/*! [End] no source code translation !*/ + +#define ACPI_MACHINE_WIDTH 64 + +#define ACPI_USE_STANDARD_HEADERS + +/* + * Handle platform- and compiler-specific assembly language differences. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +/*! [Begin] no source code translation */ + +#define ACPI_FLUSH_CPU_CACHE() + +/* + * For Acpi applications, we don't want to try to access the global lock + */ +#ifdef ACPI_APPLICATION +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) if (AcpiGbl_GlobalLockPresent) {Acq = 0xFF;} else {Acq = 0;} +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) if (AcpiGbl_GlobalLockPresent) {Pnd = 0xFF;} else {Pnd = 0;} +#else + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) + +#endif + + +#endif /* __ACWIN_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsaccess.c b/reactos/drivers/bus/acpi/acpica/namespace/nsaccess.c new file mode 100644 index 00000000000..2bc7d8d7118 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsaccess.c @@ -0,0 +1,772 @@ +/******************************************************************************* + * + * Module Name: nsaccess - Top-level functions for accessing ACPI namespace + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSACCESS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsaccess") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRootInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Allocate and initialize the default root named objects + * + * MUTEX: Locks namespace for entire execution + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRootInitialize ( + void) +{ + ACPI_STATUS Status; + const ACPI_PREDEFINED_NAMES *InitVal = NULL; + ACPI_NAMESPACE_NODE *NewNode; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STRING Val = NULL; + + + ACPI_FUNCTION_TRACE (NsRootInitialize); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The global root ptr is initially NULL, so a non-NULL value indicates + * that AcpiNsRootInitialize() has already been called; just return. + */ + if (AcpiGbl_RootNode) + { + Status = AE_OK; + goto UnlockAndExit; + } + + /* + * Tell the rest of the subsystem that the root is initialized + * (This is OK because the namespace is locked) + */ + AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct; + + /* Enter the pre-defined names in the name table */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Entering predefined entries into namespace\n")); + + for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) + { + /* _OSI is optional for now, will be permanent later */ + + if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) + { + continue; + } + + Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, + ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + NULL, &NewNode); + + if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create predefined name %s", + InitVal->Name)); + } + + /* + * Name entered successfully. If entry in PreDefinedNames[] specifies + * an initial value, create the initial value. + */ + if (InitVal->Val) + { + Status = AcpiOsPredefinedOverride (InitVal, &Val); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not override predefined %s", + InitVal->Name)); + } + + if (!Val) + { + Val = InitVal->Val; + } + + /* + * Entry requests an initial value, allocate a + * descriptor for it. + */ + ObjDesc = AcpiUtCreateInternalObject (InitVal->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* + * Convert value string from table entry to + * internal representation. Only types actually + * used for initial values are implemented here. + */ + switch (InitVal->Type) + { + case ACPI_TYPE_METHOD: + ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val); + ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; + +#if defined (ACPI_ASL_COMPILER) + + /* Save the parameter count for the iASL compiler */ + + NewNode->Value = ObjDesc->Method.ParamCount; +#else + /* Mark this as a very SPECIAL method */ + + ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; + ObjDesc->Method.Extra.Implementation = AcpiUtOsiImplementation; +#endif + break; + + case ACPI_TYPE_INTEGER: + + ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val); + break; + + + case ACPI_TYPE_STRING: + + /* Build an object around the static string */ + + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val); + ObjDesc->String.Pointer = Val; + ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; + break; + + + case ACPI_TYPE_MUTEX: + + ObjDesc->Mutex.Node = NewNode; + ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); + + /* Create a mutex */ + + Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + goto UnlockAndExit; + } + + /* Special case for ACPI Global Lock */ + + if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) + { + AcpiGbl_GlobalLockMutex = ObjDesc; + + /* Create additional counting semaphore for global lock */ + + Status = AcpiOsCreateSemaphore ( + 1, 0, &AcpiGbl_GlobalLockSemaphore); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + goto UnlockAndExit; + } + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unsupported initial type value %X", + InitVal->Type)); + AcpiUtRemoveReference (ObjDesc); + ObjDesc = NULL; + continue; + } + + /* Store pointer to value descriptor in the Node */ + + Status = AcpiNsAttachObject (NewNode, ObjDesc, + ObjDesc->Common.Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Save a handle to "_GPE", it is always present */ + + if (ACPI_SUCCESS (Status)) + { + Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, + &AcpiGbl_FadtGpeDevice); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsLookup + * + * PARAMETERS: ScopeInfo - Current scope info block + * Pathname - Search pathname, in internal format + * (as represented in the AML stream) + * Type - Type associated with name + * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found + * Flags - Flags describing the search restrictions + * WalkState - Current state of the walk + * ReturnNode - Where the Node is placed (if found + * or created successfully) + * + * RETURN: Status + * + * DESCRIPTION: Find or enter the passed name in the name space. + * Log an error if name not found in Exec mode. + * + * MUTEX: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + char *Pathname, + ACPI_OBJECT_TYPE Type, + ACPI_INTERPRETER_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + char *Path = Pathname; + ACPI_NAMESPACE_NODE *PrefixNode; + ACPI_NAMESPACE_NODE *CurrentNode = NULL; + ACPI_NAMESPACE_NODE *ThisNode = NULL; + UINT32 NumSegments; + UINT32 NumCarats; + ACPI_NAME SimpleName; + ACPI_OBJECT_TYPE TypeToCheckFor; + ACPI_OBJECT_TYPE ThisSearchType; + UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; + UINT32 LocalFlags; + + + ACPI_FUNCTION_TRACE (NsLookup); + + + if (!ReturnNode) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); + *ReturnNode = ACPI_ENTRY_NOT_FOUND; + AcpiGbl_NsLookupCount++; + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + /* Get the prefix scope. A null scope means use the root scope */ + + if ((!ScopeInfo) || + (!ScopeInfo->Scope.Node)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Null scope prefix, using root node (%p)\n", + AcpiGbl_RootNode)); + + PrefixNode = AcpiGbl_RootNode; + } + else + { + PrefixNode = ScopeInfo->Scope.Node; + if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]", + PrefixNode, AcpiUtGetDescriptorName (PrefixNode))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE)) + { + /* + * This node might not be a actual "scope" node (such as a + * Device/Method, etc.) It could be a Package or other object + * node. Backup up the tree to find the containing scope node. + */ + while (!AcpiNsOpensScope (PrefixNode->Type) && + PrefixNode->Type != ACPI_TYPE_ANY) + { + PrefixNode = AcpiNsGetParentNode (PrefixNode); + } + } + } + + /* Save type. TBD: may be no longer necessary */ + + TypeToCheckFor = Type; + + /* + * Begin examination of the actual pathname + */ + if (!Pathname) + { + /* A Null NamePath is allowed and refers to the root */ + + NumSegments = 0; + ThisNode = AcpiGbl_RootNode; + Path = ""; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Null Pathname (Zero segments), Flags=%X\n", Flags)); + } + else + { + /* + * Name pointer is valid (and must be in internal name format) + * + * Check for scope prefixes: + * + * As represented in the AML stream, a namepath consists of an + * optional scope prefix followed by a name segment part. + * + * If present, the scope prefix is either a Root Prefix (in + * which case the name is fully qualified), or one or more + * Parent Prefixes (in which case the name's scope is relative + * to the current scope). + */ + if (*Path == (UINT8) AML_ROOT_PREFIX) + { + /* Pathname is fully qualified, start from the root */ + + ThisNode = AcpiGbl_RootNode; + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Point to name segment part */ + + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Path is absolute from root [%p]\n", ThisNode)); + } + else + { + /* Pathname is relative to current scope, start there */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching relative to prefix scope [%4.4s] (%p)\n", + AcpiUtGetNodeName (PrefixNode), PrefixNode)); + + /* + * Handle multiple Parent Prefixes (carat) by just getting + * the parent node for each prefix instance. + */ + ThisNode = PrefixNode; + NumCarats = 0; + while (*Path == (UINT8) AML_PARENT_PREFIX) + { + /* Name is fully qualified, no search rules apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* + * Point past this prefix to the name segment + * part or the next Parent Prefix + */ + Path++; + + /* Backup to the parent node */ + + NumCarats++; + ThisNode = AcpiNsGetParentNode (ThisNode); + if (!ThisNode) + { + /* Current scope has no parent scope */ + + ACPI_ERROR ((AE_INFO, + "ACPI path has too many parent prefixes (^) " + "- reached beyond root node")); + return_ACPI_STATUS (AE_NOT_FOUND); + } + } + + if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Search scope is [%4.4s], path has %d carat(s)\n", + AcpiUtGetNodeName (ThisNode), NumCarats)); + } + } + + /* + * Determine the number of ACPI name segments in this pathname. + * + * The segment part consists of either: + * - A Null name segment (0) + * - A DualNamePrefix followed by two 4-byte name segments + * - A MultiNamePrefix followed by a byte indicating the + * number of segments and the segments themselves. + * - A single 4-byte name segment + * + * Examine the name prefix opcode, if any, to determine the number of + * segments. + */ + switch (*Path) + { + case 0: + /* + * Null name after a root or parent prefixes. We already + * have the correct target node and there are no name segments. + */ + NumSegments = 0; + Type = ThisNode->Type; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Prefix-only Pathname (Zero name segments), Flags=%X\n", + Flags)); + break; + + case AML_DUAL_NAME_PREFIX: + + /* More than one NameSeg, search rules do not apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Two segments, point to first name segment */ + + NumSegments = 2; + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Dual Pathname (2 segments, Flags=%X)\n", Flags)); + break; + + case AML_MULTI_NAME_PREFIX_OP: + + /* More than one NameSeg, search rules do not apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Extract segment count, point to first name segment */ + + Path++; + NumSegments = (UINT32) (UINT8) *Path; + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Multi Pathname (%d Segments, Flags=%X)\n", + NumSegments, Flags)); + break; + + default: + /* + * Not a Null name, no Dual or Multi prefix, hence there is + * only one name segment and Pathname is already pointing to it. + */ + NumSegments = 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Simple Pathname (1 segment, Flags=%X)\n", Flags)); + break; + } + + ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path)); + } + + + /* + * Search namespace for each segment of the name. Loop through and + * verify (or add to the namespace) each name segment. + * + * The object type is significant only at the last name + * segment. (We don't care about the types along the path, only + * the type of the final target object.) + */ + ThisSearchType = ACPI_TYPE_ANY; + CurrentNode = ThisNode; + while (NumSegments && CurrentNode) + { + NumSegments--; + if (!NumSegments) + { + /* This is the last segment, enable typechecking */ + + ThisSearchType = Type; + + /* + * Only allow automatic parent search (search rules) if the caller + * requested it AND we have a single, non-fully-qualified NameSeg + */ + if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) && + (Flags & ACPI_NS_SEARCH_PARENT)) + { + LocalFlags |= ACPI_NS_SEARCH_PARENT; + } + + /* Set error flag according to caller */ + + if (Flags & ACPI_NS_ERROR_IF_FOUND) + { + LocalFlags |= ACPI_NS_ERROR_IF_FOUND; + } + } + + /* Extract one ACPI name from the front of the pathname */ + + ACPI_MOVE_32_TO_32 (&SimpleName, Path); + + /* Try to find the single (4 character) ACPI name */ + + Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, + InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + /* Name not found in ACPI namespace */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] not found in scope [%4.4s] %p\n", + (char *) &SimpleName, (char *) &CurrentNode->Name, + CurrentNode)); + } + + *ReturnNode = ThisNode; + return_ACPI_STATUS (Status); + } + + /* More segments to follow? */ + + if (NumSegments > 0) + { + /* + * If we have an alias to an object that opens a scope (such as a + * device or processor), we need to dereference the alias here so + * that we can access any children of the original node (via the + * remaining segments). + */ + if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS) + { + if (!ThisNode->Object) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) + ThisNode->Object)->Type)) + { + ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; + } + } + } + + /* Special handling for the last segment (NumSegments == 0) */ + + else + { + /* + * Sanity typecheck of the target object: + * + * If 1) This is the last segment (NumSegments == 0) + * 2) And we are looking for a specific type + * (Not checking for TYPE_ANY) + * 3) Which is not an alias + * 4) Which is not a local type (TYPE_SCOPE) + * 5) And the type of target object is known (not TYPE_ANY) + * 6) And target object does not match what we are looking for + * + * Then we have a type mismatch. Just warn and ignore it. + */ + if ((TypeToCheckFor != ACPI_TYPE_ANY) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && + (ThisNode->Type != ACPI_TYPE_ANY) && + (ThisNode->Type != TypeToCheckFor)) + { + /* Complain about a type mismatch */ + + ACPI_WARNING ((AE_INFO, + "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)", + ACPI_CAST_PTR (char, &SimpleName), + AcpiUtGetTypeName (ThisNode->Type), + AcpiUtGetTypeName (TypeToCheckFor))); + } + + /* + * If this is the last name segment and we are not looking for a + * specific type, but the type of found object is known, use that + * type to (later) see if it opens a scope. + */ + if (Type == ACPI_TYPE_ANY) + { + Type = ThisNode->Type; + } + } + + /* Point to next name segment and make this node current */ + + Path += ACPI_NAME_SIZE; + CurrentNode = ThisNode; + } + + /* Always check if we need to open a new scope */ + + if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) + { + /* + * If entry is a type which opens a scope, push the new scope on the + * scope stack. + */ + if (AcpiNsOpensScope (Type)) + { + Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + *ReturnNode = ThisNode; + return_ACPI_STATUS (AE_OK); +} + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsalloc.c b/reactos/drivers/bus/acpi/acpica/namespace/nsalloc.c new file mode 100644 index 00000000000..9693cb7835a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsalloc.c @@ -0,0 +1,666 @@ +/******************************************************************************* + * + * Module Name: nsalloc - Namespace allocation and deletion utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSALLOC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsalloc") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCreateNode + * + * PARAMETERS: Name - Name of the new node (4 char ACPI name) + * + * RETURN: New namespace node (Null on failure) + * + * DESCRIPTION: Create a namespace node + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 Name) +{ + ACPI_NAMESPACE_NODE *Node; +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + UINT32 Temp; +#endif + + + ACPI_FUNCTION_TRACE (NsCreateNode); + + + Node = AcpiOsAcquireObject (AcpiGbl_NamespaceCache); + if (!Node) + { + return_PTR (NULL); + } + + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + Temp = AcpiGbl_NsNodeList->TotalAllocated - + AcpiGbl_NsNodeList->TotalFreed; + if (Temp > AcpiGbl_NsNodeList->MaxOccupied) + { + AcpiGbl_NsNodeList->MaxOccupied = Temp; + } +#endif + + Node->Name.Integer = Name; + ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED); + return_PTR (Node); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNode + * + * PARAMETERS: Node - Node to be deleted + * + * RETURN: None + * + * DESCRIPTION: Delete a namespace node. All node deletions must come through + * here. Detaches any attached objects, including any attached + * data. If a handler is associated with attached data, it is + * invoked before the node is deleted. + * + ******************************************************************************/ + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (NsDeleteNode); + + + /* Detach an object if there is one */ + + AcpiNsDetachObject (Node); + + /* + * Delete an attached data object if present (an object that was created + * and attached via AcpiAttachData). Note: After any normal object is + * detached above, the only possible remaining object is a data object. + */ + ObjDesc = Node->Object; + if (ObjDesc && + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + /* Invoke the attached data deletion handler if present */ + + if (ObjDesc->Data.Handler) + { + ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer); + } + + AcpiUtRemoveReference (ObjDesc); + } + + /* Now we can delete the node */ + + (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); + + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", + Node, AcpiGbl_CurrentNodeCount)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRemoveNode + * + * PARAMETERS: Node - Node to be removed/deleted + * + * RETURN: None + * + * DESCRIPTION: Remove (unlink) and delete a namespace node + * + ******************************************************************************/ + +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *PrevNode; + ACPI_NAMESPACE_NODE *NextNode; + + + ACPI_FUNCTION_TRACE_PTR (NsRemoveNode, Node); + + + ParentNode = AcpiNsGetParentNode (Node); + + PrevNode = NULL; + NextNode = ParentNode->Child; + + /* Find the node that is the previous peer in the parent's child list */ + + while (NextNode != Node) + { + PrevNode = NextNode; + NextNode = PrevNode->Peer; + } + + if (PrevNode) + { + /* Node is not first child, unlink it */ + + PrevNode->Peer = NextNode->Peer; + if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + PrevNode->Flags |= ANOBJ_END_OF_PEER_LIST; + } + } + else + { + /* Node is first child (has no previous peer) */ + + if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + /* No peers at all */ + + ParentNode->Child = NULL; + } + else + { /* Link peer list to parent */ + + ParentNode->Child = NextNode->Peer; + } + } + + /* Delete the node and any attached objects */ + + AcpiNsDeleteNode (Node); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInstallNode + * + * PARAMETERS: WalkState - Current state of the walk + * ParentNode - The parent of the new Node + * Node - The new Node to install + * Type - ACPI object type of the new Node + * + * RETURN: None + * + * DESCRIPTION: Initialize a new namespace node and install it amongst + * its peers. + * + * Note: Current namespace lookup is linear search. This appears + * to be sufficient as namespace searches consume only a small + * fraction of the execution time of the ACPI subsystem. + * + ******************************************************************************/ + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ + ACPI_NAMESPACE_NODE *Node, /* New Child*/ + ACPI_OBJECT_TYPE Type) +{ + ACPI_OWNER_ID OwnerId = 0; + ACPI_NAMESPACE_NODE *ChildNode; + + + ACPI_FUNCTION_TRACE (NsInstallNode); + + + /* + * Get the owner ID from the Walk state. The owner ID is used to track + * table deletion and deletion of objects created by methods. + */ + if (WalkState) + { + OwnerId = WalkState->OwnerId; + } + + /* Link the new entry into the parent and existing children */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + ParentNode->Child = Node; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; + } + else + { + while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) + { + ChildNode = ChildNode->Peer; + } + + ChildNode->Peer = Node; + + /* Clear end-of-list flag */ + + ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; + } + + /* Init the new entry */ + + Node->OwnerId = OwnerId; + Node->Type = (UINT8) Type; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId, + AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type), + ParentNode)); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteChildren + * + * PARAMETERS: ParentNode - Delete this objects children + * + * RETURN: None. + * + * DESCRIPTION: Delete all children of the parent object. In other words, + * deletes a "scope". + * + ******************************************************************************/ + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *NextNode; + UINT8 Flags; + + + ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode); + + + if (!ParentNode) + { + return_VOID; + } + + /* If no children, all done! */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + return_VOID; + } + + /* Deallocate all children at this level */ + + do + { + /* Get the things we need */ + + NextNode = ChildNode->Peer; + Flags = ChildNode->Flags; + + /* Grandchildren should have all been deleted already */ + + if (ChildNode->Child) + { + ACPI_ERROR ((AE_INFO, "Found a grandchild! P=%p C=%p", + ParentNode, ChildNode)); + } + + /* + * Delete this child node and move on to the next child in the list. + * No need to unlink the node since we are deleting the entire branch. + */ + AcpiNsDeleteNode (ChildNode); + ChildNode = NextNode; + + } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); + + /* Clear the parent's child pointer */ + + ParentNode->Child = NULL; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceSubtree + * + * PARAMETERS: ParentNode - Root of the subtree to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Delete a subtree of the namespace. This includes all objects + * stored within the subtree. + * + ******************************************************************************/ + +void +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode = NULL; + UINT32 Level = 1; + + + ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree); + + + if (!ParentNode) + { + return_VOID; + } + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* Get the next node in this scope (NULL if none) */ + + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + if (ChildNode) + { + /* Found a child node - detach any attached object */ + + AcpiNsDetachObject (ChildNode); + + /* Check if this node has any children */ + + if (ChildNode->Child) + { + /* + * There is at least one child of this node, + * visit the node + */ + Level++; + ParentNode = ChildNode; + ChildNode = NULL; + } + } + else + { + /* + * No more children of this parent node. + * Move up to the grandparent. + */ + Level--; + + /* + * Now delete all of the children of this parent + * all at the same time. + */ + AcpiNsDeleteChildren (ParentNode); + + /* New "last child" is this parent node */ + + ChildNode = ParentNode; + + /* Move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceByOwner + * + * PARAMETERS: OwnerId - All nodes with this owner will be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete entries within the namespace that are owned by a + * specific ID. Used to delete entire ACPI tables. All + * reference counts are updated. + * + * MUTEX: Locks namespace during deletion walk. + * + ******************************************************************************/ + +void +AcpiNsDeleteNamespaceByOwner ( + ACPI_OWNER_ID OwnerId) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *DeletionNode; + ACPI_NAMESPACE_NODE *ParentNode; + UINT32 Level; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId); + + + if (OwnerId == 0) + { + return_VOID; + } + + /* Lock namespace for possible update */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + DeletionNode = NULL; + ParentNode = AcpiGbl_RootNode; + ChildNode = NULL; + Level = 1; + + /* + * Traverse the tree of nodes until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* + * Get the next child of this parent node. When ChildNode is NULL, + * the first child of the parent is returned + */ + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + + if (DeletionNode) + { + AcpiNsDeleteChildren (DeletionNode); + AcpiNsRemoveNode (DeletionNode); + DeletionNode = NULL; + } + + if (ChildNode) + { + if (ChildNode->OwnerId == OwnerId) + { + /* Found a matching child node - detach any attached object */ + + AcpiNsDetachObject (ChildNode); + } + + /* Check if this node has any children */ + + if (ChildNode->Child) + { + /* + * There is at least one child of this node, + * visit the node + */ + Level++; + ParentNode = ChildNode; + ChildNode = NULL; + } + else if (ChildNode->OwnerId == OwnerId) + { + DeletionNode = ChildNode; + } + } + else + { + /* + * No more children of this parent node. + * Move up to the grandparent. + */ + Level--; + if (Level != 0) + { + if (ParentNode->OwnerId == OwnerId) + { + DeletionNode = ParentNode; + } + } + + /* New "last child" is this parent node */ + + ChildNode = ParentNode; + + /* Move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsdump.c b/reactos/drivers/bus/acpi/acpica/namespace/nsdump.c new file mode 100644 index 00000000000..d799f7c64ce --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsdump.c @@ -0,0 +1,826 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsdump") + +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +void +AcpiNsDumpRootDevices ( + void); + +static ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); +#endif + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/******************************************************************************* + * + * FUNCTION: AcpiNsPrintPathname + * + * PARAMETERS: NumSegments - Number of ACPI name segments + * Pathname - The compressed (internal) path + * + * RETURN: None + * + * DESCRIPTION: Print an object's full namespace pathname + * + ******************************************************************************/ + +void +AcpiNsPrintPathname ( + UINT32 NumSegments, + char *Pathname) +{ + UINT32 i; + + + ACPI_FUNCTION_NAME (NsPrintPathname); + + + if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE)) + { + return; + } + + /* Print the entire name */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); + + while (NumSegments) + { + for (i = 0; i < 4; i++) + { + ACPI_IS_PRINT (Pathname[i]) ? + AcpiOsPrintf ("%c", Pathname[i]) : + AcpiOsPrintf ("?"); + } + + Pathname += ACPI_NAME_SIZE; + NumSegments--; + if (NumSegments) + { + AcpiOsPrintf ("."); + } + } + + AcpiOsPrintf ("]\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpPathname + * + * PARAMETERS: Handle - Object + * Msg - Prefix message + * Level - Desired debug level + * Component - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ******************************************************************************/ + +void +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + char *Msg, + UINT32 Level, + UINT32 Component) +{ + + ACPI_FUNCTION_TRACE (NsDumpPathname); + + + /* Do this only if the requested debug level and component are enabled */ + + if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) + { + return_VOID; + } + + /* Convert handle to a full pathname and print it (with supplied message) */ + + AcpiNsPrintNodePathname (Handle, Msg); + AcpiOsPrintf ("\n"); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpOneObject + * + * PARAMETERS: ObjHandle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Dump a single Node + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDumpOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *ThisNode; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_OBJECT_TYPE ObjType; + ACPI_OBJECT_TYPE Type; + UINT32 BytesToDump; + UINT32 DbgLevel; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsDumpOneObject); + + + /* Is output enabled? */ + + if (!(AcpiDbgLevel & Info->DebugLevel)) + { + return (AE_OK); + } + + if (!ObjHandle) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); + return (AE_OK); + } + + ThisNode = AcpiNsValidateHandle (ObjHandle); + if (!ThisNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n", + ObjHandle)); + return (AE_OK); + } + + Type = ThisNode->Type; + + /* Check if the owner matches */ + + if ((Info->OwnerId != ACPI_OWNER_ID_MAX) && + (Info->OwnerId != ThisNode->OwnerId)) + { + return (AE_OK); + } + + if (!(Info->DisplayType & ACPI_DISPLAY_SHORT)) + { + /* Indent the object according to the level */ + + AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " "); + + /* Check the node type and name */ + + if (Type > ACPI_TYPE_LOCAL_MAX) + { + ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type %08X", Type)); + } + + AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); + } + + /* Now we can print out the pertinent information */ + + AcpiOsPrintf (" %-12s %p %2.2X ", + AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); + + DbgLevel = AcpiDbgLevel; + AcpiDbgLevel = 0; + ObjDesc = AcpiNsGetAttachedObject (ThisNode); + AcpiDbgLevel = DbgLevel; + + /* Temp nodes are those nodes created by a control method */ + + if (ThisNode->Flags & ANOBJ_TEMPORARY) + { + AcpiOsPrintf ("(T) "); + } + + switch (Info->DisplayType & ACPI_DISPLAY_MASK) + { + case ACPI_DISPLAY_SUMMARY: + + if (!ObjDesc) + { + /* No attached object, we are done */ + + AcpiOsPrintf ("\n"); + return (AE_OK); + } + + switch (Type) + { + case ACPI_TYPE_PROCESSOR: + + AcpiOsPrintf ("ID %X Len %.4X Addr %p\n", + ObjDesc->Processor.ProcId, ObjDesc->Processor.Length, + ACPI_CAST_PTR (void, ObjDesc->Processor.Address)); + break; + + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf ("Notify Object: %p\n", ObjDesc); + break; + + + case ACPI_TYPE_METHOD: + + AcpiOsPrintf ("Args %X Len %.4X Aml %p\n", + (UINT32) ObjDesc->Method.ParamCount, + ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart); + break; + + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("= %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_PACKAGE: + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf ("Elements %.2X\n", + ObjDesc->Package.Count); + } + else + { + AcpiOsPrintf ("[Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_BUFFER: + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf ("Len %.2X", + ObjDesc->Buffer.Length); + + /* Dump some of the buffer */ + + if (ObjDesc->Buffer.Length > 0) + { + AcpiOsPrintf (" ="); + for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++) + { + AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]); + } + } + AcpiOsPrintf ("\n"); + } + else + { + AcpiOsPrintf ("[Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length); + AcpiUtPrintString (ObjDesc->String.Pointer, 32); + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_REGION: + + AcpiOsPrintf ("[%s]", + AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); + if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n", + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length); + } + else + { + AcpiOsPrintf (" [Address/Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc)); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + if (ObjDesc->BufferField.BufferObj && + ObjDesc->BufferField.BufferObj->Buffer.Node) + { + AcpiOsPrintf ("Buf [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->BufferField.BufferObj->Buffer.Node)); + } + break; + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + AcpiOsPrintf ("Rgn [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->CommonField.RegionObj->Region.Node)); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->CommonField.RegionObj->Region.Node), + AcpiUtGetNodeName ( + ObjDesc->BankField.BankObj->CommonField.Node)); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->IndexField.IndexObj->CommonField.Node), + AcpiUtGetNodeName ( + ObjDesc->IndexField.DataObj->CommonField.Node)); + break; + + + case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: + + AcpiOsPrintf ("Target %4.4s (%p)\n", + AcpiUtGetNodeName (ObjDesc), ObjDesc); + break; + + default: + + AcpiOsPrintf ("Object %p\n", ObjDesc); + break; + } + + /* Common field handling */ + + switch (Type) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n", + (ObjDesc->CommonField.BaseByteOffset * 8) + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessByteWidth); + break; + + default: + break; + } + break; + + + case ACPI_DISPLAY_OBJECTS: + + AcpiOsPrintf ("O:%p", ObjDesc); + if (!ObjDesc) + { + /* No attached object, we are done */ + + AcpiOsPrintf ("\n"); + return (AE_OK); + } + + AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount); + + switch (Type) + { + case ACPI_TYPE_METHOD: + + /* Name is a Method and its AML offset/length are set */ + + AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength); + break; + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf (" I:%8.8X8.8%X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + case ACPI_TYPE_STRING: + + AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer, + ObjDesc->String.Length); + break; + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length); + break; + + default: + + AcpiOsPrintf ("\n"); + break; + } + break; + + + default: + AcpiOsPrintf ("\n"); + break; + } + + /* If debug turned off, done */ + + if (!(AcpiDbgLevel & ACPI_LV_VALUES)) + { + return (AE_OK); + } + + /* If there is an attached object, display it */ + + DbgLevel = AcpiDbgLevel; + AcpiDbgLevel = 0; + ObjDesc = AcpiNsGetAttachedObject (ThisNode); + AcpiDbgLevel = DbgLevel; + + /* Dump attached objects */ + + while (ObjDesc) + { + ObjType = ACPI_TYPE_INVALID; + AcpiOsPrintf ("Attached Object %p: ", ObjDesc); + + /* Decode the type of attached object and dump the contents */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_NAMED: + + AcpiOsPrintf ("(Ptr to Node)\n"); + BytesToDump = sizeof (ACPI_NAMESPACE_NODE); + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + break; + + case ACPI_DESC_TYPE_OPERAND: + + ObjType = ObjDesc->Common.Type; + + if (ObjType > ACPI_TYPE_LOCAL_MAX) + { + AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n", + ObjType); + BytesToDump = 32; + } + else + { + AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n", + ObjType, AcpiUtGetTypeName (ObjType)); + BytesToDump = sizeof (ACPI_OPERAND_OBJECT); + } + + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + break; + + default: + + break; + } + + /* If value is NOT an internal object, we are done */ + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + goto Cleanup; + } + + /* Valid object, get the pointer to next level, if any */ + + switch (ObjType) + { + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + /* + * NOTE: takes advantage of common fields between string/buffer + */ + BytesToDump = ObjDesc->String.Length; + ObjDesc = (void *) ObjDesc->String.Pointer; + AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n", + ObjDesc, BytesToDump); + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + goto Cleanup; + + case ACPI_TYPE_BUFFER_FIELD: + ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj; + break; + + case ACPI_TYPE_PACKAGE: + ObjDesc = (void *) ObjDesc->Package.Elements; + break; + + case ACPI_TYPE_METHOD: + ObjDesc = (void *) ObjDesc->Method.AmlStart; + break; + + case ACPI_TYPE_LOCAL_REGION_FIELD: + ObjDesc = (void *) ObjDesc->Field.RegionObj; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + ObjDesc = (void *) ObjDesc->BankField.RegionObj; + break; + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + ObjDesc = (void *) ObjDesc->IndexField.IndexObj; + break; + + default: + goto Cleanup; + } + + ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ + } + +Cleanup: + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpObjects + * + * PARAMETERS: Type - Object type to be dumped + * DisplayType - 0 or ACPI_DISPLAY_SUMMARY + * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX + * for an effectively unlimited depth. + * OwnerId - Dump only objects owned by this ID. Use + * ACPI_UINT32_MAX to match all owners. + * StartHandle - Where in namespace to start/end search + * + * RETURN: None + * + * DESCRIPTION: Dump typed objects within the loaded namespace. Uses + * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. + * + ******************************************************************************/ + +void +AcpiNsDumpObjects ( + ACPI_OBJECT_TYPE Type, + UINT8 DisplayType, + UINT32 MaxDepth, + ACPI_OWNER_ID OwnerId, + ACPI_HANDLE StartHandle) +{ + ACPI_WALK_INFO Info; + + + ACPI_FUNCTION_ENTRY (); + + + Info.DebugLevel = ACPI_LV_TABLES; + Info.OwnerId = OwnerId; + Info.DisplayType = DisplayType; + + (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpEntry + * + * PARAMETERS: Handle - Node to be dumped + * DebugLevel - Output level + * + * RETURN: None + * + * DESCRIPTION: Dump a single Node + * + ******************************************************************************/ + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel) +{ + ACPI_WALK_INFO Info; + + + ACPI_FUNCTION_ENTRY (); + + + Info.DebugLevel = DebugLevel; + Info.OwnerId = ACPI_OWNER_ID_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY; + + (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL); +} + + +#ifdef ACPI_ASL_COMPILER +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpTables + * + * PARAMETERS: SearchBase - Root of subtree to be dumped, or + * NS_ALL to dump the entire namespace + * MaxDepth - Maximum depth of dump. Use INT_MAX + * for an effectively unlimited depth. + * + * RETURN: None + * + * DESCRIPTION: Dump the name space, or a portion of it. + * + ******************************************************************************/ + +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth) +{ + ACPI_HANDLE SearchHandle = SearchBase; + + + ACPI_FUNCTION_TRACE (NsDumpTables); + + + if (!AcpiGbl_RootNode) + { + /* + * If the name space has not been initialized, + * there is nothing to dump. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); + return_VOID; + } + + if (ACPI_NS_ALL == SearchBase) + { + /* Entire namespace */ + + SearchHandle = AcpiGbl_RootNode; + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); + } + + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth, + ACPI_OWNER_ID_MAX, SearchHandle); + return_VOID; +} +#endif +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsdumpdv.c b/reactos/drivers/bus/acpi/acpica/namespace/nsdumpdv.c new file mode 100644 index 00000000000..fbb66a61675 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsdumpdv.c @@ -0,0 +1,234 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSDUMPDV_C__ + +#include "acpi.h" + + +/* TBD: This entire module is apparently obsolete and should be removed */ + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsdumpdv") + +#ifdef ACPI_OBSOLETE_FUNCTIONS +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +#include "acnamesp.h" + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpOneDevice + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Dump a single Node that represents a device + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_BUFFER Buffer; + ACPI_DEVICE_INFO *Info; + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsDumpOneDevice); + + + Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiGetObjectInfo (ObjHandle, &Buffer); + if (ACPI_SUCCESS (Status)) + { + Info = Buffer.Pointer; + for (i = 0; i < Level; i++) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, + " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", + Info->HardwareId.Value, ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus)); + ACPI_FREE (Info); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpRootDevices + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Dump all objects of type "device" + * + ******************************************************************************/ + +void +AcpiNsDumpRootDevices ( + void) +{ + ACPI_HANDLE SysBusHandle; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (NsDumpRootDevices); + + + /* Only dump the table if tracing is enabled */ + + if (!(ACPI_LV_TABLES & AcpiDbgLevel)) + { + return; + } + + Status = AcpiGetHandle (NULL, ACPI_NS_SYSTEM_BUS, &SysBusHandle); + if (ACPI_FAILURE (Status)) + { + return; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "Display of all devices in the namespace:\n")); + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiNsDumpOneDevice, NULL, NULL, NULL); +} + +#endif +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nseval.c b/reactos/drivers/bus/acpi/acpica/namespace/nseval.c new file mode 100644 index 00000000000..07af96ed93d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nseval.c @@ -0,0 +1,558 @@ +/******************************************************************************* + * + * Module Name: nseval - Object evaluation, includes control method execution + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nseval") + +/* Local prototypes */ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluate + * + * PARAMETERS: Info - Evaluation info block, contains: + * PrefixNode - Prefix or Method/Object Node to execute + * Pathname - Name of method to execute, If NULL, the + * Node is the object to execute + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * Flags - ACPI_IGNORE_RETURN_VALUE to delete return + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method or return the current value of an + * ACPI namespace object. + * + * MUTEX: Locks interpreter + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluate ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (NsEvaluate); + + + if (!Info) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Initialize the return value to an invalid object */ + + Info->ReturnObject = NULL; + Info->ParamCount = 0; + + /* + * Get the actual namespace node for the target object. Handles these cases: + * + * 1) Null node, Pathname (absolute path) + * 2) Node, Pathname (path relative to Node) + * 3) Node, Null Pathname + */ + Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname, + ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * For a method alias, we must grab the actual method node so that proper + * scoping context will be established before execution. + */ + if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + { + Info->ResolvedNode = + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname, + Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode))); + + Node = Info->ResolvedNode; + + /* + * Two major cases here: + * + * 1) The object is a control method -- execute it + * 2) The object is not a method -- just return it's current value + */ + if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD) + { + /* + * 1) Object is a control method - execute it + */ + + /* Verify that there is a method object associated with this node */ + + Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode); + if (!Info->ObjDesc) + { + ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object")); + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Count the number of arguments being passed to the method */ + + if (Info->Parameters) + { + while (Info->Parameters[Info->ParamCount]) + { + if (Info->ParamCount > ACPI_METHOD_MAX_ARG) + { + return_ACPI_STATUS (AE_LIMIT); + } + Info->ParamCount++; + } + } + + ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method", + ACPI_LV_INFO, _COMPONENT); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Method at AML address %p Length %X\n", + Info->ObjDesc->Method.AmlStart + 1, + Info->ObjDesc->Method.AmlLength - 1)); + + /* + * Any namespace deletion must acquire both the namespace and + * interpreter locks to ensure that no thread is using the portion of + * the namespace that is being deleted. + * + * Execute the method via the interpreter. The interpreter is locked + * here before calling into the AML parser + */ + AcpiExEnterInterpreter (); + Status = AcpiPsExecuteMethod (Info); + AcpiExExitInterpreter (); + } + else + { + /* + * 2) Object is not a method, return its current value + * + * Disallow certain object types. For these, "evaluation" is undefined. + */ + switch (Info->ResolvedNode->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_REGION: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_LOCAL_SCOPE: + + ACPI_ERROR ((AE_INFO, + "[%4.4s] Evaluation of object type [%s] is not supported", + Info->ResolvedNode->Name.Ascii, + AcpiUtGetTypeName (Info->ResolvedNode->Type))); + + return_ACPI_STATUS (AE_TYPE); + + default: + break; + } + + /* + * Objects require additional resolution steps (e.g., the Node may be + * a field that must be read, etc.) -- we can't just grab the object + * out of the node. + * + * Use ResolveNodeToValue() to get the associated value. + * + * NOTE: we can get away with passing in NULL for a walk state because + * ResolvedNode is guaranteed to not be a reference to either a method + * local or a method argument (because this interface is never called + * from a running method.) + * + * Even though we do not directly invoke the interpreter for object + * resolution, we must lock it because we could access an opregion. + * The opregion access code assumes that the interpreter is locked. + */ + AcpiExEnterInterpreter (); + + /* Function has a strange interface */ + + Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL); + AcpiExExitInterpreter (); + + /* + * If AcpiExResolveNodeToValue() succeeded, the return value was placed + * in ResolvedNode. + */ + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_RETURN_VALUE; + Info->ReturnObject = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode); + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", + Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); + } + } + + /* + * Check input argument count against the ASL-defined count for a method. + * Also check predefined names: argument count and return value against + * the ACPI specification. Some incorrect return value types are repaired. + */ + (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount, + Status, &Info->ReturnObject); + + /* Check if there is a return value that must be dealt with */ + + if (Status == AE_CTRL_RETURN_VALUE) + { + /* If caller does not want the return value, delete it */ + + if (Info->Flags & ACPI_IGNORE_RETURN_VALUE) + { + AcpiUtRemoveReference (Info->ReturnObject); + Info->ReturnObject = NULL; + } + + /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ + + Status = AE_OK; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "*** Completed evaluation of object %s ***\n", Info->Pathname)); + + /* + * Namespace was unlocked by the handling AcpiNs* function, so we + * just return + */ + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCodeList + * + * PARAMETERS: None + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute all elements of the global module-level code list. + * Each element is executed as a single control method. + * + ******************************************************************************/ + +void +AcpiNsExecModuleCodeList ( + void) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_EVALUATE_INFO *Info; + UINT32 MethodCount = 0; + + + ACPI_FUNCTION_TRACE (NsExecModuleCodeList); + + + /* Exit now if the list is empty */ + + Next = AcpiGbl_ModuleCodeList; + if (!Next) + { + return_VOID; + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_VOID; + } + + /* Walk the list, executing each "method" */ + + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + + /* Clear the link field and execute the method */ + + Prev->Method.Mutex = NULL; + AcpiNsExecModuleCode (Prev, Info); + MethodCount++; + + /* Delete the (temporary) method object */ + + AcpiUtRemoveReference (Prev); + } + + ACPI_INFO ((AE_INFO, + "Executed %u blocks of module-level executable AML code", + MethodCount)); + + ACPI_FREE (Info); + AcpiGbl_ModuleCodeList = NULL; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCode + * + * PARAMETERS: MethodObj - Object container for the module-level code + * Info - Info block for method evaluation + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute a control method containing a block of module-level + * executable AML code. The control method is temporarily + * installed to the root node, then evaluated. + * + ******************************************************************************/ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ParentObj; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsExecModuleCode); + + + /* + * Get the parent node. We cheat by using the NextObject field + * of the method object descriptor. + */ + ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + MethodObj->Method.NextObject); + Type = AcpiNsGetType (ParentNode); + + /* + * Get the region handler and save it in the method object. We may need + * this if an operation region declaration causes a _REG method to be run. + * + * We can't do this in AcpiPsLinkModuleCode because + * AcpiGbl_RootNode->Object is NULL at PASS1. + */ + if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object) + { + MethodObj->Method.Extra.Handler = + ParentNode->Object->Device.Handler; + } + + /* Must clear NextObject (AcpiNsAttachObject needs the field) */ + + MethodObj->Method.NextObject = NULL; + + /* Initialize the evaluation information block */ + + ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + Info->PrefixNode = ParentNode; + + /* + * Get the currently attached parent object. Add a reference, because the + * ref count will be decreased when the method object is installed to + * the parent node. + */ + ParentObj = AcpiNsGetAttachedObject (ParentNode); + if (ParentObj) + { + AcpiUtAddReference (ParentObj); + } + + /* Install the method (module-level code) in the parent node */ + + Status = AcpiNsAttachObject (ParentNode, MethodObj, + ACPI_TYPE_METHOD); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Execute the parent node as a control method */ + + Status = AcpiNsEvaluate (Info); + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n", + MethodObj->Method.AmlStart)); + + /* Delete a possible implicit return value (in slack mode) */ + + if (Info->ReturnObject) + { + AcpiUtRemoveReference (Info->ReturnObject); + } + + /* Detach the temporary method object */ + + AcpiNsDetachObject (ParentNode); + + /* Restore the original parent object */ + + if (ParentObj) + { + Status = AcpiNsAttachObject (ParentNode, ParentObj, Type); + } + else + { + ParentNode->Type = (UINT8) Type; + } + +Exit: + if (ParentObj) + { + AcpiUtRemoveReference (ParentObj); + } + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsinit.c b/reactos/drivers/bus/acpi/acpica/namespace/nsinit.c new file mode 100644 index 00000000000..b36fa6c7ea9 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsinit.c @@ -0,0 +1,727 @@ +/****************************************************************************** + * + * Module Name: nsinit - namespace initialization + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acdispat.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsinit") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiNsFindIniMethods ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitializeObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Walk the entire namespace and perform any necessary + * initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeObjects ( + void) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + + + ACPI_FUNCTION_TRACE (NsInitializeObjects); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Starting initialization of namespace objects ****\n")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Completing Region/Field/Buffer/Package initialization:")); + + /* Set all init info to zero */ + + ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); + + /* Walk entire namespace from the supplied root */ + + Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, + &Info, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd " + "Buffers %hd/%hd Packages (%hd nodes)\n", + Info.OpRegionInit, Info.OpRegionCount, + Info.FieldInit, Info.FieldCount, + Info.BufferInit, Info.BufferCount, + Info.PackageInit, Info.PackageCount, Info.ObjectCount)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "%hd Control Methods found\n", Info.MethodCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "%hd Op Regions found\n", Info.OpRegionCount)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitializeDevices + * + * PARAMETERS: None + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices. + * This means running _INI on all present devices. + * + * Note: We install PCI config space handler on region access, + * not here. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeDevices ( + void) +{ + ACPI_STATUS Status; + ACPI_DEVICE_WALK_INFO Info; + + + ACPI_FUNCTION_TRACE (NsInitializeDevices); + + + /* Init counters */ + + Info.DeviceCount = 0; + Info.Num_STA = 0; + Info.Num_INI = 0; + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Initializing Device/Processor/Thermal objects " + "by executing _INI methods:")); + + /* Tree analysis: find all subtrees that contain _INI methods */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Allocate the evaluation information block */ + + Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info.EvaluateInfo) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } + + /* + * Execute the "global" _INI method that may appear at the root. This + * support is provided for Windows compatibility (Vista+) and is not + * part of the ACPI specification. + */ + Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; + Info.EvaluateInfo->Pathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + + /* Walk namespace to execute all _INIs on present devices */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); + + ACPI_FREE (Info.EvaluateInfo); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nExecuted %hd _INI methods requiring %hd _STA executions " + "(examined %hd objects)\n", + Info.Num_INI, Info.Num_STA, Info.DeviceCount)); + + return_ACPI_STATUS (Status); + + +ErrorExit: + ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization")); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitOneObject + * + * PARAMETERS: ObjHandle - Node + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Op Regions + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status = AE_OK; + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (NsInitOneObject); + + + Info->ObjectCount++; + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return (AE_OK); + } + + /* Increment counters for object types we are looking for */ + + switch (Type) + { + case ACPI_TYPE_REGION: + Info->OpRegionCount++; + break; + + case ACPI_TYPE_BUFFER_FIELD: + Info->FieldCount++; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + Info->FieldCount++; + break; + + case ACPI_TYPE_BUFFER: + Info->BufferCount++; + break; + + case ACPI_TYPE_PACKAGE: + Info->PackageCount++; + break; + + default: + + /* No init required, just exit now */ + return (AE_OK); + } + + /* If the object is already initialized, nothing else to do */ + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return (AE_OK); + } + + /* Must lock the interpreter before executing AML code */ + + AcpiExEnterInterpreter (); + + /* + * Each of these types can contain executable AML code within the + * declaration. + */ + switch (Type) + { + case ACPI_TYPE_REGION: + + Info->OpRegionInit++; + Status = AcpiDsGetRegionArguments (ObjDesc); + break; + + case ACPI_TYPE_BUFFER_FIELD: + + Info->FieldInit++; + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + Info->FieldInit++; + Status = AcpiDsGetBankFieldArguments (ObjDesc); + break; + + case ACPI_TYPE_BUFFER: + + Info->BufferInit++; + Status = AcpiDsGetBufferArguments (ObjDesc); + break; + + case ACPI_TYPE_PACKAGE: + + Info->PackageInit++; + Status = AcpiDsGetPackageArguments (ObjDesc); + break; + + default: + /* No other types can get here */ + break; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not execute arguments for [%4.4s] (%s)", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type))); + } + + /* + * Print a dot for each object unless we are going to print the entire + * pathname + */ + if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + } + + /* + * We ignore errors from above, and always return OK, since we don't want + * to abort the walk on any single error. + */ + AcpiExExitInterpreter (); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsFindIniMethods + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Called during namespace walk. Finds objects named _INI under + * device/processor/thermal objects, and marks the entire subtree + * with a SUBTREE_HAS_INI flag. This flag is used during the + * subsequent device initialization walk to avoid entire subtrees + * that do not contain an _INI. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsFindIniMethods ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode; + + + /* Keep count of device/processor/thermal objects */ + + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + if ((Node->Type == ACPI_TYPE_DEVICE) || + (Node->Type == ACPI_TYPE_PROCESSOR) || + (Node->Type == ACPI_TYPE_THERMAL)) + { + Info->DeviceCount++; + return (AE_OK); + } + + /* We are only looking for methods named _INI */ + + if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI)) + { + return (AE_OK); + } + + /* + * The only _INI methods that we care about are those that are + * present under Device, Processor, and Thermal objects. + */ + ParentNode = AcpiNsGetParentNode (Node); + switch (ParentNode->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* Mark parent and bubble up the INI present flag to the root */ + + while (ParentNode) + { + ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI; + ParentNode = AcpiNsGetParentNode (ParentNode); + } + break; + + default: + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitOneDevice + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: This is called once per device soon after ACPI is enabled + * to initialize each device. It determines if the device is + * present, and if so, calls _INI. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); + ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo; + UINT32 Flags; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *DeviceNode; + + + ACPI_FUNCTION_TRACE (NsInitOneDevice); + + + /* We are interested in Devices, Processors and ThermalZones only */ + + DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && + (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && + (DeviceNode->Type != ACPI_TYPE_THERMAL)) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Because of an earlier namespace analysis, all subtrees that contain an + * _INI method are tagged. + * + * If this device subtree does not contain any _INI methods, we + * can exit now and stop traversing this entire subtree. + */ + if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI)) + { + return_ACPI_STATUS (AE_CTRL_DEPTH); + } + + /* + * Run _STA to determine if this device is present and functioning. We + * must know this information for two important reasons (from ACPI spec): + * + * 1) We can only run _INI if the device is present. + * 2) We must abort the device tree walk on this subtree if the device is + * not present and is not functional (we will not examine the children) + * + * The _STA method is not required to be present under the device, we + * assume the device is present if _STA does not exist. + */ + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA)); + + Status = AcpiUtExecute_STA (DeviceNode, &Flags); + if (ACPI_FAILURE (Status)) + { + /* Ignore error and move on to next device */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Flags == -1 means that _STA was not found. In this case, we assume that + * the device is both present and functional. + * + * From the ACPI spec, description of _STA: + * + * "If a device object (including the processor object) does not have an + * _STA object, then OSPM assumes that all of the above bits are set (in + * other words, the device is present, ..., and functioning)" + */ + if (Flags != ACPI_UINT32_MAX) + { + WalkInfo->Num_STA++; + } + + /* + * Examine the PRESENT and FUNCTIONING status bits + * + * Note: ACPI spec does not seem to specify behavior for the present but + * not functioning case, so we assume functioning if present. + */ + if (!(Flags & ACPI_STA_DEVICE_PRESENT)) + { + /* Device is not present, we must examine the Functioning bit */ + + if (Flags & ACPI_STA_DEVICE_FUNCTIONING) + { + /* + * Device is not present but is "functioning". In this case, + * we will not run _INI, but we continue to examine the children + * of this device. + * + * From the ACPI spec, description of _STA: (Note - no mention + * of whether to run _INI or not on the device in question) + * + * "_STA may return bit 0 clear (not present) with bit 3 set + * (device is functional). This case is used to indicate a valid + * device for which no device driver should be loaded (for example, + * a bridge device.) Children of this device may be present and + * valid. OSPM should continue enumeration below a device whose + * _STA returns this bit combination" + */ + return_ACPI_STATUS (AE_OK); + } + else + { + /* + * Device is not present and is not functioning. We must abort the + * walk of this subtree immediately -- don't look at the children + * of such a device. + * + * From the ACPI spec, description of _INI: + * + * "If the _STA method indicates that the device is not present, + * OSPM will not run the _INI and will not examine the children + * of the device for _INI methods" + */ + return_ACPI_STATUS (AE_CTRL_DEPTH); + } + } + + /* + * The device is present or is assumed present if no _STA exists. + * Run the _INI if it exists (not required to exist) + * + * Note: We know there is an _INI within this subtree, but it may not be + * under this particular device, it may be lower in the branch. + */ + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); + + Info->PrefixNode = DeviceNode; + Info->Pathname = METHOD_NAME__INI; + Info->Parameters = NULL; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info); + if (ACPI_SUCCESS (Status)) + { + WalkInfo->Num_INI++; + + if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && + (!(AcpiDbgLevel & ACPI_LV_INFO))) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + } + } + +#ifdef ACPI_DEBUG_OUTPUT + else if (Status != AE_NOT_FOUND) + { + /* Ignore error and move on to next device */ + + char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode); + + ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", + ScopeName)); + ACPI_FREE (ScopeName); + } +#endif + + /* Ignore errors from above */ + + Status = AE_OK; + + /* + * The _INI method has been run if present; call the Global Initialization + * Handler for this device. + */ + if (AcpiGbl_InitHandler) + { + Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI); + } + + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsload.c b/reactos/drivers/bus/acpi/acpica/namespace/nsload.c new file mode 100644 index 00000000000..a9f3824718b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsload.c @@ -0,0 +1,428 @@ +/****************************************************************************** + * + * Module Name: nsload - namespace loading/expanding/contracting procedures + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSLOAD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acdispat.h" +#include "actables.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsload") + +/* Local prototypes */ + +#ifdef ACPI_FUTURE_IMPLEMENTATION +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle); + +static ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle); +#endif + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiNsLoadTable + * + * PARAMETERS: TableIndex - Index for table to be loaded + * Node - Owning NS node + * + * RETURN: Status + * + * DESCRIPTION: Load one ACPI table into the namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsLoadTable); + + + /* + * Parse the table and load the namespace with all named + * objects found within. Control methods are NOT parsed + * at this time. In fact, the control methods cannot be + * parsed until the entire namespace is loaded, because + * if a control method makes a forward reference (call) + * to another control method, we can't continue parsing + * because we don't know how many arguments to parse next! + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* If table already loaded into namespace, just return */ + + if (AcpiTbIsTableLoaded (TableIndex)) + { + Status = AE_ALREADY_EXISTS; + goto Unlock; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Loading table into namespace ****\n")); + + Status = AcpiTbAllocateOwnerId (TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Unlock; + } + + Status = AcpiNsParseTable (TableIndex, Node); + if (ACPI_SUCCESS (Status)) + { + AcpiTbSetTableLoadedFlag (TableIndex, TRUE); + } + else + { + (void) AcpiTbReleaseOwnerId (TableIndex); + } + +Unlock: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now we can parse the control methods. We always parse + * them here for a sanity check, and if configured for + * just-in-time parsing, we delete the control method + * parse trees. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Begin Table Method Parsing and Object Initialization\n")); + + Status = AcpiDsInitializeObjects (TableIndex, Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Completed Table Method Parsing and Object Initialization\n")); + + return_ACPI_STATUS (Status); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiLoadNamespace + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the name space from what ever is pointed to by DSDT. + * (DSDT points to either the BIOS or a buffer.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLoadNamespace ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLoadNameSpace); + + + /* There must be at least a DSDT installed */ + + if (AcpiGbl_DSDT == NULL) + { + ACPI_ERROR ((AE_INFO, "DSDT is not in memory")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* + * Load the namespace. The DSDT is required, + * but the SSDT and PSDT tables are optional. + */ + Status = AcpiNsLoadTableByType (ACPI_TABLE_ID_DSDT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ignore exceptions from these */ + + (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_SSDT); + (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_PSDT); + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "ACPI Namespace successfully loaded at root %p\n", + AcpiGbl_RootNode)); + + return_ACPI_STATUS (Status); +} +#endif + +#ifdef ACPI_FUTURE_IMPLEMENTATION +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteSubtree + * + * PARAMETERS: StartHandle - Handle in namespace where search begins + * + * RETURNS Status + * + * DESCRIPTION: Walks the namespace starting at the given handle and deletes + * all objects, entries, and scopes in the entire subtree. + * + * Namespace/Interpreter should be locked or the subsystem should + * be in shutdown before this routine is called. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle) +{ + ACPI_STATUS Status; + ACPI_HANDLE ChildHandle; + ACPI_HANDLE ParentHandle; + ACPI_HANDLE NextChildHandle; + ACPI_HANDLE Dummy; + UINT32 Level; + + + ACPI_FUNCTION_TRACE (NsDeleteSubtree); + + + ParentHandle = StartHandle; + ChildHandle = NULL; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* Attempt to get the next object in this scope */ + + Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle, + ChildHandle, &NextChildHandle); + + ChildHandle = NextChildHandle; + + /* Did we get a new object? */ + + if (ACPI_SUCCESS (Status)) + { + /* Check if this object has any children */ + + if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle, + NULL, &Dummy))) + { + /* + * There is at least one child of this object, + * visit the object + */ + Level++; + ParentHandle = ChildHandle; + ChildHandle = NULL; + } + } + else + { + /* + * No more children in this object, go back up to + * the object's parent + */ + Level--; + + /* Delete all children now */ + + AcpiNsDeleteChildren (ChildHandle); + + ChildHandle = ParentHandle; + Status = AcpiGetParent (ParentHandle, &ParentHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + /* Now delete the starting object, and we are done */ + + AcpiNsRemoveNode (ChildHandle); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsUnloadNameSpace + * + * PARAMETERS: Handle - Root of namespace subtree to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Shrinks the namespace, typically in response to an undocking + * event. Deletes an entire subtree starting from (and + * including) the given handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsUnloadNameSpace); + + + /* Parameter validation */ + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + if (!Handle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* This function does the real work */ + + Status = AcpiNsDeleteSubtree (Handle); + + return_ACPI_STATUS (Status); +} +#endif +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c b/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c new file mode 100644 index 00000000000..c00a4457b2a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c @@ -0,0 +1,375 @@ +/******************************************************************************* + * + * Module Name: nsnames - Name manipulation and search + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSNAMES_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsnames") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildExternalPath + * + * PARAMETERS: Node - NS node whose pathname is needed + * Size - Size of the pathname + * *NameBuffer - Where to return the pathname + * + * RETURN: Status + * Places the pathname into the NameBuffer, in external format + * (name segments separated by path separators) + * + * DESCRIPTION: Generate a full pathaname + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer) +{ + ACPI_SIZE Index; + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_ENTRY (); + + + /* Special case for root */ + + Index = Size - 1; + if (Index < ACPI_NAME_SIZE) + { + NameBuffer[0] = AML_ROOT_PREFIX; + NameBuffer[1] = 0; + return (AE_OK); + } + + /* Store terminator byte, then build name backwards */ + + ParentNode = Node; + NameBuffer[Index] = 0; + + while ((Index > ACPI_NAME_SIZE) && (ParentNode != AcpiGbl_RootNode)) + { + Index -= ACPI_NAME_SIZE; + + /* Put the name into the buffer */ + + ACPI_MOVE_32_TO_32 ((NameBuffer + Index), &ParentNode->Name); + ParentNode = AcpiNsGetParentNode (ParentNode); + + /* Prefix name with the path separator */ + + Index--; + NameBuffer[Index] = ACPI_PATH_SEPARATOR; + } + + /* Overwrite final separator with the root prefix character */ + + NameBuffer[Index] = AML_ROOT_PREFIX; + + if (Index != 0) + { + ACPI_ERROR ((AE_INFO, + "Could not construct external pathname; index=%X, size=%X, Path=%s", + (UINT32) Index, (UINT32) Size, &NameBuffer[Size])); + + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetExternalPathname + * + * PARAMETERS: Node - Namespace node whose pathname is needed + * + * RETURN: Pointer to storage containing the fully qualified name of + * the node, In external format (name segments separated by path + * separators.) + * + * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually + * for error and debug statements. + * + ******************************************************************************/ + +char * +AcpiNsGetExternalPathname ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + char *NameBuffer; + ACPI_SIZE Size; + + + ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node); + + + /* Calculate required buffer size based on depth below root */ + + Size = AcpiNsGetPathnameLength (Node); + if (!Size) + { + return_PTR (NULL); + } + + /* Allocate a buffer to be returned to caller */ + + NameBuffer = ACPI_ALLOCATE_ZEROED (Size); + if (!NameBuffer) + { + ACPI_ERROR ((AE_INFO, "Could not allocate %u bytes", (UINT32) Size)); + return_PTR (NULL); + } + + /* Build the path in the allocated buffer */ + + Status = AcpiNsBuildExternalPath (Node, Size, NameBuffer); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (NameBuffer); + return_PTR (NULL); + } + + return_PTR (NameBuffer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetPathnameLength + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Length of path, including prefix + * + * DESCRIPTION: Get the length of the pathname string for this node + * + ******************************************************************************/ + +ACPI_SIZE +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_SIZE Size; + ACPI_NAMESPACE_NODE *NextNode; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Compute length of pathname as 5 * number of name segments. + * Go back up the parent tree to the root + */ + Size = 0; + NextNode = Node; + + while (NextNode && (NextNode != AcpiGbl_RootNode)) + { + if (ACPI_GET_DESCRIPTOR_TYPE (NextNode) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "Invalid Namespace Node (%p) while traversing namespace", + NextNode)); + return 0; + } + Size += ACPI_PATH_SEGMENT_LENGTH; + NextNode = AcpiNsGetParentNode (NextNode); + } + + if (!Size) + { + Size = 1; /* Root node case */ + } + + return (Size + 1); /* +1 for null string terminator */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsHandleToPathname + * + * PARAMETERS: TargetHandle - Handle of named object whose name is + * to be found + * Buffer - Where the pathname is returned + * + * RETURN: Status, Buffer is filled with pathname if status is AE_OK + * + * DESCRIPTION: Build and return a full namespace pathname + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_SIZE RequiredSize; + + + ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle); + + + Node = AcpiNsValidateHandle (TargetHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Determine size required for the caller buffer */ + + RequiredSize = AcpiNsGetPathnameLength (Node); + if (!RequiredSize) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (Buffer, RequiredSize); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Build the path in the caller buffer */ + + Status = AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n", + (char *) Buffer->Pointer, (UINT32) RequiredSize)); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsobject.c b/reactos/drivers/bus/acpi/acpica/namespace/nsobject.c new file mode 100644 index 00000000000..c0163f4ea24 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsobject.c @@ -0,0 +1,577 @@ +/******************************************************************************* + * + * Module Name: nsobject - Utilities for objects attached to namespace + * table entries + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsobject") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsAttachObject + * + * PARAMETERS: Node - Parent Node + * Object - Object to be attached + * Type - Type of object, or ACPI_TYPE_ANY if not + * known + * + * RETURN: Status + * + * DESCRIPTION: Record the given object as the value associated with the + * name whose ACPI_HANDLE is passed. If Object is NULL + * and Type is ACPI_TYPE_ANY, set the name as having no value. + * Note: Future may require that the Node->Flags field be passed + * as a parameter. + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + ACPI_OBJECT_TYPE Type) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *LastObjDesc; + ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY; + + + ACPI_FUNCTION_TRACE (NsAttachObject); + + + /* + * Parameter validation + */ + if (!Node) + { + /* Invalid handle */ + + ACPI_ERROR ((AE_INFO, "Null NamedObj handle")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!Object && (ACPI_TYPE_ANY != Type)) + { + /* Null object */ + + ACPI_ERROR ((AE_INFO, + "Null object, but type not ACPI_TYPE_ANY")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + /* Not a name handle */ + + ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]", + Node, AcpiUtGetDescriptorName (Node))); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check if this object is already attached */ + + if (Node->Object == Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj %p already installed in NameObj %p\n", + Object, Node)); + + return_ACPI_STATUS (AE_OK); + } + + /* If null object, we will just install it */ + + if (!Object) + { + ObjDesc = NULL; + ObjectType = ACPI_TYPE_ANY; + } + + /* + * If the source object is a namespace Node with an attached object, + * we will use that (attached) object + */ + else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) && + ((ACPI_NAMESPACE_NODE *) Object)->Object) + { + /* + * Value passed is a name handle and that name has a + * non-null value. Use that name's value and type. + */ + ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; + ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; + } + + /* + * Otherwise, we will use the parameter object, but we must type + * it first + */ + else + { + ObjDesc = (ACPI_OPERAND_OBJECT *) Object; + + /* Use the given type */ + + ObjectType = Type; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", + ObjDesc, Node, AcpiUtGetNodeName (Node))); + + /* Detach an existing attached object if present */ + + if (Node->Object) + { + AcpiNsDetachObject (Node); + } + + if (ObjDesc) + { + /* + * Must increment the new value's reference count + * (if it is an internal object) + */ + AcpiUtAddReference (ObjDesc); + + /* + * Handle objects with multiple descriptors - walk + * to the end of the descriptor list + */ + LastObjDesc = ObjDesc; + while (LastObjDesc->Common.NextObject) + { + LastObjDesc = LastObjDesc->Common.NextObject; + } + + /* Install the object at the front of the object list */ + + LastObjDesc->Common.NextObject = Node->Object; + } + + Node->Type = (UINT8) ObjectType; + Node->Object = ObjDesc; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDetachObject + * + * PARAMETERS: Node - A Namespace node whose object will be detached + * + * RETURN: None. + * + * DESCRIPTION: Detach/delete an object associated with a namespace node. + * if the object is an allocated object, it is freed. + * Otherwise, the field is simply cleared. + * + ******************************************************************************/ + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (NsDetachObject); + + + ObjDesc = Node->Object; + + if (!ObjDesc || + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_VOID; + } + + if (Node->Flags & ANOBJ_ALLOCATED_BUFFER) + { + /* Free the dynamic aml buffer */ + + if (ObjDesc->Common.Type == ACPI_TYPE_METHOD) + { + ACPI_FREE (ObjDesc->Method.AmlStart); + } + } + + /* Clear the entry in all cases */ + + Node->Object = NULL; + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) + { + Node->Object = ObjDesc->Common.NextObject; + if (Node->Object && + ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA)) + { + Node->Object = Node->Object->Common.NextObject; + } + } + + /* Reset the node type to untyped */ + + Node->Type = ACPI_TYPE_ANY; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", + Node, AcpiUtGetNodeName (Node), ObjDesc)); + + /* Remove one reference on the object (and all subobjects) */ + + AcpiUtRemoveReference (ObjDesc); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetAttachedObject + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Current value of the object field from the Node whose + * handle is passed + * + * DESCRIPTION: Obtain the object attached to a namespace node. + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiNsGetAttachedObject ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node); + + + if (!Node) + { + ACPI_WARNING ((AE_INFO, "Null Node ptr")); + return_PTR (NULL); + } + + if (!Node->Object || + ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) && + (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) || + ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_PTR (NULL); + } + + return_PTR (Node->Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetSecondaryObject + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Current value of the object field from the Node whose + * handle is passed. + * + * DESCRIPTION: Obtain a secondary object associated with a namespace node. + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiNsGetSecondaryObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc); + + + if ((!ObjDesc) || + (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) || + (!ObjDesc->Common.NextObject) || + ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_PTR (NULL); + } + + return_PTR (ObjDesc->Common.NextObject); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsAttachData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler to be associated with the data + * Data - Data to be attached + * + * RETURN: Status + * + * DESCRIPTION: Low-level attach data. Create and attach a Data object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsAttachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void *Data) +{ + ACPI_OPERAND_OBJECT *PrevObjDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *DataDesc; + + + /* We only allow one attachment per handler */ + + PrevObjDesc = NULL; + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + return (AE_ALREADY_EXISTS); + } + + PrevObjDesc = ObjDesc; + ObjDesc = ObjDesc->Common.NextObject; + } + + /* Create an internal object for the data */ + + DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA); + if (!DataDesc) + { + return (AE_NO_MEMORY); + } + + DataDesc->Data.Handler = Handler; + DataDesc->Data.Pointer = Data; + + /* Install the data object */ + + if (PrevObjDesc) + { + PrevObjDesc->Common.NextObject = DataDesc; + } + else + { + Node->Object = DataDesc; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDetachData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler associated with the data + * + * RETURN: Status + * + * DESCRIPTION: Low-level detach data. Delete the data node, but the caller + * is responsible for the actual data. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDetachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *PrevObjDesc; + + + PrevObjDesc = NULL; + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + if (PrevObjDesc) + { + PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject; + } + else + { + Node->Object = ObjDesc->Common.NextObject; + } + + AcpiUtRemoveReference (ObjDesc); + return (AE_OK); + } + + PrevObjDesc = ObjDesc; + ObjDesc = ObjDesc->Common.NextObject; + } + + return (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetAttachedData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler associated with the data + * Data - Where the data is returned + * + * RETURN: Status + * + * DESCRIPTION: Low level interface to obtain data previously associated with + * a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetAttachedData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void **Data) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + *Data = ObjDesc->Data.Pointer; + return (AE_OK); + } + + ObjDesc = ObjDesc->Common.NextObject; + } + + return (AE_NOT_FOUND); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c b/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c new file mode 100644 index 00000000000..58301560ae0 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c @@ -0,0 +1,297 @@ +/****************************************************************************** + * + * Module Name: nsparse - namespace interface to AML parser + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSPARSE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acdispat.h" +#include "actables.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsparse") + + +/******************************************************************************* + * + * FUNCTION: NsOneCompleteParse + * + * PARAMETERS: PassNumber - 1 or 2 + * TableDesc - The table to be parsed. + * + * RETURN: Status + * + * DESCRIPTION: Perform one complete parse of an ACPI/AML table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_PARSE_OBJECT *ParseRoot; + ACPI_STATUS Status; + UINT32 AmlLength; + UINT8 *AmlStart; + ACPI_WALK_STATE *WalkState; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + + + ACPI_FUNCTION_TRACE (NsOneCompleteParse); + + + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create and init a Root Node */ + + ParseRoot = AcpiPsCreateScopeOp (); + if (!ParseRoot) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + AcpiPsFreeOp (ParseRoot); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + AcpiPsFreeOp (ParseRoot); + return_ACPI_STATUS (Status); + } + + /* Table must consist of at least a complete header */ + + if (Table->Length < sizeof (ACPI_TABLE_HEADER)) + { + Status = AE_BAD_HEADER; + } + else + { + AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, + AmlStart, AmlLength, NULL, (UINT8) PassNumber); + } + + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* StartNode is the default location to load the table */ + + if (StartNode && StartNode != AcpiGbl_RootNode) + { + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + } + + /* Parse the AML */ + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", PassNumber)); + Status = AcpiPsParseAml (WalkState); + +Cleanup: + AcpiPsDeleteParseTree (ParseRoot); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsParseTable + * + * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse + * StartNode - Where to enter the table into the namespace + * + * RETURN: Status + * + * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsParseTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsParseTable); + + + /* + * AML Parse, pass 1 + * + * In this pass, we load most of the namespace. Control methods + * are not parsed until later. A parse tree is not created. Instead, + * each Parser Op subtree is deleted when it is finished. This saves + * a great deal of memory, and allows a small cache of parse objects + * to service the entire parse. The second pass of the parse then + * performs another complete parse of the AML. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, + TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * AML Parse, pass 2 + * + * In this pass, we resolve forward references and other things + * that could not be completed during the first pass. + * Another complete parse of the AML is performed, but the + * overhead of this is compensated for by the fact that the + * parse objects are all cached. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, + TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nspredef.c b/reactos/drivers/bus/acpi/acpica/namespace/nspredef.c new file mode 100644 index 00000000000..d979c43e93f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nspredef.c @@ -0,0 +1,1263 @@ +/****************************************************************************** + * + * Module Name: nspredef - Validation of ACPI predefined methods and objects + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define ACPI_CREATE_PREDEFINED_TABLE + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acpredef.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nspredef") + + +/******************************************************************************* + * + * This module validates predefined ACPI objects that appear in the namespace, + * at the time they are evaluated (via AcpiEvaluateObject). The purpose of this + * validation is to detect problems with BIOS-exposed predefined ACPI objects + * before the results are returned to the ACPI-related drivers. + * + * There are several areas that are validated: + * + * 1) The number of input arguments as defined by the method/object in the + * ASL is validated against the ACPI specification. + * 2) The type of the return object (if any) is validated against the ACPI + * specification. + * 3) For returned package objects, the count of package elements is + * validated, as well as the type of each package element. Nested + * packages are supported. + * + * For any problems found, a warning message is issued. + * + ******************************************************************************/ + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsCheckPackage ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count); + +static ACPI_STATUS +AcpiNsCheckPackageElements ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **Elements, + UINT8 Type1, + UINT32 Count1, + UINT8 Type2, + UINT32 Count2, + UINT32 StartIndex); + +static ACPI_STATUS +AcpiNsCheckObjectType ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr, + UINT32 ExpectedBtypes, + UINT32 PackageIndex); + +static ACPI_STATUS +AcpiNsCheckReference ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject); + +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes); + +/* + * Names for the types that can be returned by the predefined objects. + * Used for warning messages. Must be in the same order as the ACPI_RTYPEs + */ +static const char *AcpiRtypeNames[] = +{ + "/Integer", + "/String", + "/Buffer", + "/Package", + "/Reference", +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPredefinedNames + * + * PARAMETERS: Node - Namespace node for the method/object + * UserParamCount - Number of parameters actually passed + * ReturnStatus - Status from the object evaluation + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status + * + * DESCRIPTION: Check an ACPI name for a match in the predefined name list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsCheckPredefinedNames ( + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status = AE_OK; + const ACPI_PREDEFINED_INFO *Predefined; + char *Pathname; + ACPI_PREDEFINED_DATA *Data; + + + /* Match the name for this method/object against the predefined list */ + + Predefined = AcpiNsCheckForPredefinedName (Node); + + /* Get the full pathname to the object, for use in warning messages */ + + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_OK); /* Could not get pathname, ignore */ + } + + /* + * Check that the parameter count for this method matches the ASL + * definition. For predefined names, ensure that both the caller and + * the method itself are in accordance with the ACPI specification. + */ + AcpiNsCheckParameterCount (Pathname, Node, UserParamCount, Predefined); + + /* If not a predefined name, we cannot validate the return object */ + + if (!Predefined) + { + goto Cleanup; + } + + /* + * If the method failed or did not actually return an object, we cannot + * validate the return object + */ + if ((ReturnStatus != AE_OK) && (ReturnStatus != AE_CTRL_RETURN_VALUE)) + { + goto Cleanup; + } + + /* + * If there is no return value, check if we require a return value for + * this predefined name. Either one return value is expected, or none, + * for both methods and other objects. + * + * Exit now if there is no return object. Warning if one was expected. + */ + if (!ReturnObject) + { + if ((Predefined->Info.ExpectedBtypes) && + (!(Predefined->Info.ExpectedBtypes & ACPI_RTYPE_NONE))) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Missing expected return value")); + + Status = AE_AML_NO_RETURN_VALUE; + } + goto Cleanup; + } + + /* + * 1) We have a return value, but if one wasn't expected, just exit, this is + * not a problem. For example, if the "Implicit Return" feature is + * enabled, methods will always return a value. + * + * 2) If the return value can be of any type, then we cannot perform any + * validation, exit. + */ + if ((!Predefined->Info.ExpectedBtypes) || + (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL)) + { + goto Cleanup; + } + + /* Create the parameter data block for object validation */ + + Data = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PREDEFINED_DATA)); + if (!Data) + { + goto Cleanup; + } + Data->Predefined = Predefined; + Data->NodeFlags = Node->Flags; + Data->Pathname = Pathname; + + /* + * Check that the type of the main return object is what is expected + * for this predefined name + */ + Status = AcpiNsCheckObjectType (Data, ReturnObjectPtr, + Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* + * For returned Package objects, check the type of all sub-objects. + * Note: Package may have been newly created by call above. + */ + if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiNsCheckPackage (Data, ReturnObjectPtr); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + + /* + * The return object was OK, or it was successfully repaired above. + * Now make some additional checks such as verifying that package + * objects are sorted correctly (if required) or buffer objects have + * the correct data width (bytes vs. dwords). These repairs are + * performed on a per-name basis, i.e., the code is specific to + * particular predefined names. + */ + Status = AcpiNsComplexRepairs (Data, Node, Status, ReturnObjectPtr); + +Exit: + /* + * If the object validation failed or if we successfully repaired one + * or more objects, mark the parent node to suppress further warning + * messages during the next evaluation of the same method/object. + */ + if (ACPI_FAILURE (Status) || (Data->Flags & ACPI_OBJECT_REPAIRED)) + { + Node->Flags |= ANOBJ_EVALUATED; + } + ACPI_FREE (Data); + +Cleanup: + ACPI_FREE (Pathname); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckParameterCount + * + * PARAMETERS: Pathname - Full pathname to the node (for error msgs) + * Node - Namespace node for the method/object + * UserParamCount - Number of args passed in by the caller + * Predefined - Pointer to entry in predefined name table + * + * RETURN: None + * + * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a + * predefined name is what is expected (i.e., what is defined in + * the ACPI specification for this predefined name.) + * + ******************************************************************************/ + +void +AcpiNsCheckParameterCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Predefined) +{ + UINT32 ParamCount; + UINT32 RequiredParamsCurrent; + UINT32 RequiredParamsOld; + + + /* Methods have 0-7 parameters. All other types have zero. */ + + ParamCount = 0; + if (Node->Type == ACPI_TYPE_METHOD) + { + ParamCount = Node->Object->Method.ParamCount; + } + + if (!Predefined) + { + /* + * Check the parameter count for non-predefined methods/objects. + * + * Warning if too few or too many arguments have been passed by the + * caller. An incorrect number of arguments may not cause the method + * to fail. However, the method will fail if there are too few + * arguments and the method attempts to use one of the missing ones. + */ + if (UserParamCount < ParamCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Insufficient arguments - needs %u, found %u", + ParamCount, UserParamCount)); + } + else if (UserParamCount > ParamCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Excess arguments - needs %u, found %u", + ParamCount, UserParamCount)); + } + return; + } + + /* + * Validate the user-supplied parameter count. + * Allow two different legal argument counts (_SCP, etc.) + */ + RequiredParamsCurrent = Predefined->Info.ParamCount & 0x0F; + RequiredParamsOld = Predefined->Info.ParamCount >> 4; + + if (UserParamCount != ACPI_UINT32_MAX) + { + if ((UserParamCount != RequiredParamsCurrent) && + (UserParamCount != RequiredParamsOld)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Parameter count mismatch - " + "caller passed %u, ACPI requires %u", + UserParamCount, RequiredParamsCurrent)); + } + } + + /* + * Check that the ASL-defined parameter count is what is expected for + * this predefined name (parameter count as defined by the ACPI + * specification) + */ + if ((ParamCount != RequiredParamsCurrent) && + (ParamCount != RequiredParamsOld)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, Node->Flags, + "Parameter count mismatch - ASL declared %u, ACPI requires %u", + ParamCount, RequiredParamsCurrent)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckForPredefinedName + * + * PARAMETERS: Node - Namespace node for the method/object + * + * RETURN: Pointer to entry in predefined table. NULL indicates not found. + * + * DESCRIPTION: Check an object name against the predefined object list. + * + ******************************************************************************/ + +const ACPI_PREDEFINED_INFO * +AcpiNsCheckForPredefinedName ( + ACPI_NAMESPACE_NODE *Node) +{ + const ACPI_PREDEFINED_INFO *ThisName; + + + /* Quick check for a predefined name, first character must be underscore */ + + if (Node->Name.Ascii[0] != '_') + { + return (NULL); + } + + /* Search info table for a predefined method/object name */ + + ThisName = PredefinedNames; + while (ThisName->Info.Name[0]) + { + if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Info.Name)) + { + return (ThisName); + } + + /* + * Skip next entry in the table if this name returns a Package + * (next entry contains the package info) + */ + if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + ThisName++; + } + + ThisName++; + } + + return (NULL); /* Not found */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackage + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status + * + * DESCRIPTION: Check a returned package object for the correct count and + * correct type of all sub-objects. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackage ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + const ACPI_PREDEFINED_INFO *Package; + ACPI_OPERAND_OBJECT **Elements; + ACPI_STATUS Status = AE_OK; + UINT32 ExpectedCount; + UINT32 Count; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsCheckPackage); + + + /* The package info for this name is in the next table entry */ + + Package = Data->Predefined + 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%s Validating return Package of Type %X, Count %X\n", + Data->Pathname, Package->RetInfo.Type, ReturnObject->Package.Count)); + + /* + * For variable-length Packages, we can safely remove all embedded + * and trailing NULL package elements + */ + AcpiNsRemoveNullElements (Data, Package->RetInfo.Type, ReturnObject); + + /* Extract package count and elements array */ + + Elements = ReturnObject->Package.Elements; + Count = ReturnObject->Package.Count; + + /* The package must have at least one element, else invalid */ + + if (!Count) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package has no elements (empty)")); + + return (AE_AML_OPERAND_VALUE); + } + + /* + * Decode the type of the expected package contents + * + * PTYPE1 packages contain no subpackages + * PTYPE2 packages contain sub-packages + */ + switch (Package->RetInfo.Type) + { + case ACPI_PTYPE1_FIXED: + + /* + * The package count is fixed and there are no sub-packages + * + * If package is too small, exit. + * If package is larger than expected, issue warning but continue + */ + ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; + if (Count < ExpectedCount) + { + goto PackageTooSmall; + } + else if (Count > ExpectedCount) + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Return Package is larger than needed - " + "found %u, expected %u\n", + Data->Pathname, Count, ExpectedCount)); + } + + /* Validate all elements of the returned package */ + + Status = AcpiNsCheckPackageElements (Data, Elements, + Package->RetInfo.ObjectType1, Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); + break; + + + case ACPI_PTYPE1_VAR: + + /* + * The package count is variable, there are no sub-packages, and all + * elements must be of the same type + */ + for (i = 0; i < Count; i++) + { + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo.ObjectType1, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + Elements++; + } + break; + + + case ACPI_PTYPE1_OPTION: + + /* + * The package count is variable, there are no sub-packages. There are + * a fixed number of required elements, and a variable number of + * optional elements. + * + * Check if package is at least as large as the minimum required + */ + ExpectedCount = Package->RetInfo3.Count; + if (Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Variable number of sub-objects */ + + for (i = 0; i < Count; i++) + { + if (i < Package->RetInfo3.Count) + { + /* These are the required package elements (0, 1, or 2) */ + + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo3.ObjectType[i], i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + else + { + /* These are the optional package elements */ + + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo3.TailObjectType, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + Elements++; + } + break; + + + case ACPI_PTYPE2_REV_FIXED: + + /* First element is the (Integer) revision */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Elements++; + Count--; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + case ACPI_PTYPE2_PKG_COUNT: + + /* First element is the (Integer) count of sub-packages to follow */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Count cannot be larger than the parent package length, but allow it + * to be smaller. The >= accounts for the Integer above. + */ + ExpectedCount = (UINT32) (*Elements)->Integer.Value; + if (ExpectedCount >= Count) + { + goto PackageTooSmall; + } + + Count = ExpectedCount; + Elements++; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + case ACPI_PTYPE2: + case ACPI_PTYPE2_FIXED: + case ACPI_PTYPE2_MIN: + case ACPI_PTYPE2_COUNT: + + /* + * These types all return a single Package that consists of a + * variable number of sub-Packages. + * + * First, ensure that the first element is a sub-Package. If not, + * the BIOS may have incorrectly returned the object as a single + * package instead of a Package of Packages (a common error if + * there is only one entry). We may be able to repair this by + * wrapping the returned Package with a new outer Package. + */ + if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE)) + { + /* Create the new outer package and populate it */ + + Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update locals to point to the new package (of 1 element) */ + + ReturnObject = *ReturnObjectPtr; + Elements = ReturnObject->Package.Elements; + Count = 1; + } + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + default: + + /* Should not get here if predefined info table is correct */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid internal return type in table entry: %X", + Package->RetInfo.Type)); + + return (AE_AML_INTERNAL); + } + + return (Status); + + +PackageTooSmall: + + /* Error exit for the case with an incorrect package count */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package is too small - found %u elements, expected %u", + Count, ExpectedCount)); + + return (AE_AML_OPERAND_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * Package - Pointer to package-specific info for method + * Elements - Element list of parent package. All elements + * of this list should be of type Package. + * Count - Count of subpackages + * + * RETURN: Status + * + * DESCRIPTION: Examine a list of subpackages + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count) +{ + ACPI_OPERAND_OBJECT *SubPackage; + ACPI_OPERAND_OBJECT **SubElements; + ACPI_STATUS Status; + UINT32 ExpectedCount; + UINT32 i; + UINT32 j; + + + /* + * Validate each sub-Package in the parent Package + * + * NOTE: assumes list of sub-packages contains no NULL elements. + * Any NULL elements should have been removed by earlier call + * to AcpiNsRemoveNullElements. + */ + for (i = 0; i < Count; i++) + { + SubPackage = *Elements; + SubElements = SubPackage->Package.Elements; + + /* Each sub-object must be of type Package */ + + Status = AcpiNsCheckObjectType (Data, &SubPackage, + ACPI_RTYPE_PACKAGE, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Examine the different types of expected sub-packages */ + + switch (Package->RetInfo.Type) + { + case ACPI_PTYPE2: + case ACPI_PTYPE2_PKG_COUNT: + case ACPI_PTYPE2_REV_FIXED: + + /* Each subpackage has a fixed number of elements */ + + ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + Package->RetInfo.Count2, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_PTYPE2_FIXED: + + /* Each sub-package has a fixed length */ + + ExpectedCount = Package->RetInfo2.Count; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + for (j = 0; j < ExpectedCount; j++) + { + Status = AcpiNsCheckObjectType (Data, &SubElements[j], + Package->RetInfo2.ObjectType[j], j); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + break; + + + case ACPI_PTYPE2_MIN: + + /* Each sub-package has a variable but minimum length */ + + ExpectedCount = Package->RetInfo.Count1; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_PTYPE2_COUNT: + + /* + * First element is the (Integer) count of elements, including + * the count field. + */ + Status = AcpiNsCheckObjectType (Data, SubElements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Make sure package is large enough for the Count and is + * is as large as the minimum size + */ + ExpectedCount = (UINT32) (*SubElements)->Integer.Value; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + if (SubPackage->Package.Count < Package->RetInfo.Count1) + { + ExpectedCount = Package->RetInfo.Count1; + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, (SubElements + 1), + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + default: /* Should not get here, type was validated by caller */ + + return (AE_AML_INTERNAL); + } + + Elements++; + } + + return (AE_OK); + + +PackageTooSmall: + + /* The sub-package count was smaller than required */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Sub-Package[%u] is too small - found %u elements, expected %u", + i, SubPackage->Package.Count, ExpectedCount)); + + return (AE_AML_OPERAND_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageElements + * + * PARAMETERS: Data - Pointer to validation data structure + * Elements - Pointer to the package elements array + * Type1 - Object type for first group + * Count1 - Count for first group + * Type2 - Object type for second group + * Count2 - Count for second group + * StartIndex - Start of the first group of elements + * + * RETURN: Status + * + * DESCRIPTION: Check that all elements of a package are of the correct object + * type. Supports up to two groups of different object types. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackageElements ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **Elements, + UINT8 Type1, + UINT32 Count1, + UINT8 Type2, + UINT32 Count2, + UINT32 StartIndex) +{ + ACPI_OPERAND_OBJECT **ThisElement = Elements; + ACPI_STATUS Status; + UINT32 i; + + + /* + * Up to two groups of package elements are supported by the data + * structure. All elements in each group must be of the same type. + * The second group can have a count of zero. + */ + for (i = 0; i < Count1; i++) + { + Status = AcpiNsCheckObjectType (Data, ThisElement, + Type1, i + StartIndex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ThisElement++; + } + + for (i = 0; i < Count2; i++) + { + Status = AcpiNsCheckObjectType (Data, ThisElement, + Type2, (i + Count1 + StartIndex)); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ThisElement++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckObjectType + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * ExpectedBtypes - Bitmap of expected return type(s) + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * + * RETURN: Status + * + * DESCRIPTION: Check the type of the return object against the expected object + * type(s). Use of Btype allows multiple expected object types. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckObjectType ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr, + UINT32 ExpectedBtypes, + UINT32 PackageIndex) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status = AE_OK; + UINT32 ReturnBtype; + char TypeBuffer[48]; /* Room for 5 types */ + + + /* + * If we get a NULL ReturnObject here, it is a NULL package element, + * and this is always an error. + */ + if (!ReturnObject) + { + goto TypeErrorExit; + } + + /* A Namespace node should not get here, but make sure */ + + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid return type - Found a Namespace node [%4.4s] type %s", + ReturnObject->Node.Name.Ascii, + AcpiUtGetTypeName (ReturnObject->Node.Type))); + return (AE_AML_OPERAND_TYPE); + } + + /* + * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. + * The bitmapped type allows multiple possible return types. + * + * Note, the cases below must handle all of the possible types returned + * from all of the predefined names (including elements of returned + * packages) + */ + switch (ReturnObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + ReturnBtype = ACPI_RTYPE_INTEGER; + break; + + case ACPI_TYPE_BUFFER: + ReturnBtype = ACPI_RTYPE_BUFFER; + break; + + case ACPI_TYPE_STRING: + ReturnBtype = ACPI_RTYPE_STRING; + break; + + case ACPI_TYPE_PACKAGE: + ReturnBtype = ACPI_RTYPE_PACKAGE; + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + ReturnBtype = ACPI_RTYPE_REFERENCE; + break; + + default: + /* Not one of the supported objects, must be incorrect */ + + goto TypeErrorExit; + } + + /* Is the object one of the expected types? */ + + if (!(ReturnBtype & ExpectedBtypes)) + { + /* Type mismatch -- attempt repair of the returned object */ + + Status = AcpiNsRepairObject (Data, ExpectedBtypes, + PackageIndex, ReturnObjectPtr); + if (ACPI_SUCCESS (Status)) + { + return (AE_OK); /* Repair was successful */ + } + goto TypeErrorExit; + } + + /* For reference objects, check that the reference type is correct */ + + if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + Status = AcpiNsCheckReference (Data, ReturnObject); + } + + return (Status); + + +TypeErrorExit: + + /* Create a string with all expected types for this predefined object */ + + AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes); + + if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - found %s, expected %s", + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + } + else + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package type mismatch at index %u - " + "found %s, expected %s", PackageIndex, + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + } + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckReference + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObject - Object returned from the evaluation of a + * method or object + * + * RETURN: Status + * + * DESCRIPTION: Check a returned reference object for the correct reference + * type. The only reference type that can be returned from a + * predefined method is a named reference. All others are invalid. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckReference ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject) +{ + + /* + * Check the reference object for the correct reference type (opcode). + * The only type of reference that can be converted to an ACPI_OBJECT is + * a reference to a named object (reference class: NAME) + */ + if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME) + { + return (AE_OK); + } + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - unexpected reference object type [%s] %2.2X", + AcpiUtGetReferenceName (ReturnObject), + ReturnObject->Reference.Class)); + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetExpectedTypes + * + * PARAMETERS: Buffer - Pointer to where the string is returned + * ExpectedBtypes - Bitmap of expected return type(s) + * + * RETURN: Buffer is populated with type names. + * + * DESCRIPTION: Translate the expected types bitmap into a string of ascii + * names of expected types, for use in warning messages. + * + ******************************************************************************/ + +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes) +{ + UINT32 ThisRtype; + UINT32 i; + UINT32 j; + + + j = 1; + Buffer[0] = 0; + ThisRtype = ACPI_RTYPE_INTEGER; + + for (i = 0; i < ACPI_NUM_RTYPES; i++) + { + /* If one of the expected types, concatenate the name of this type */ + + if (ExpectedBtypes & ThisRtype) + { + ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); + j = 0; /* Use name separator from now on */ + } + ThisRtype <<= 1; /* Next Rtype */ + } +} diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsrepair.c b/reactos/drivers/bus/acpi/acpica/namespace/nsrepair.c new file mode 100644 index 00000000000..5c402df36b5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsrepair.c @@ -0,0 +1,686 @@ +/****************************************************************************** + * + * Module Name: nsrepair - Repair for objects returned by predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSREPAIR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsrepair") + + +/******************************************************************************* + * + * This module attempts to repair or convert objects returned by the + * predefined methods to an object type that is expected, as per the ACPI + * specification. The need for this code is dictated by the many machines that + * return incorrect types for the standard predefined methods. Performing these + * conversions here, in one place, eliminates the need for individual ACPI + * device drivers to do the same. Note: Most of these conversions are different + * than the internal object conversion routines used for implicit object + * conversion. + * + * The following conversions can be performed as necessary: + * + * Integer -> String + * Integer -> Buffer + * String -> Integer + * String -> Buffer + * Buffer -> Integer + * Buffer -> String + * Buffer -> Package of Integers + * Package -> Package of one Package + * + ******************************************************************************/ + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsConvertToInteger ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToString ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToBuffer ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToPackage ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairObject + * + * PARAMETERS: Data - Pointer to validation data structure + * ExpectedBtypes - Object types expected + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if repair was successful. + * + * DESCRIPTION: Attempt to repair/convert a return object of a type that was + * not expected. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairObject ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (NsRepairObject); + + + /* + * At this point, we know that the type of the returned object was not + * one of the expected types for this predefined name. Attempt to + * repair the object by converting it to one of the expected object + * types for this predefined name. + */ + if (ExpectedBtypes & ACPI_RTYPE_INTEGER) + { + Status = AcpiNsConvertToInteger (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_STRING) + { + Status = AcpiNsConvertToString (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_BUFFER) + { + Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + Status = AcpiNsConvertToPackage (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + + /* We cannot repair this object */ + + return (AE_AML_OPERAND_TYPE); + + +ObjectRepaired: + + /* Object was successfully repaired */ + + /* + * If the original object is a package element, we need to: + * 1. Set the reference count of the new object to match the + * reference count of the old object. + * 2. Decrement the reference count of the original object. + */ + if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) + { + NewObject->Common.ReferenceCount = + ReturnObject->Common.ReferenceCount; + + if (ReturnObject->Common.ReferenceCount > 1) + { + ReturnObject->Common.ReferenceCount--; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Converted %s to expected %s at index %u\n", + Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject), + AcpiUtGetObjectTypeName (NewObject), PackageIndex)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Converted %s to expected %s\n", + Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject), + AcpiUtGetObjectTypeName (NewObject))); + } + + /* Delete old object, install the new return object */ + + AcpiUtRemoveReference (ReturnObject); + *ReturnObjectPtr = NewObject; + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToInteger + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToInteger ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + UINT64 Value = 0; + UINT32 i; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + /* String-to-Integer conversion */ + + Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, + ACPI_ANY_BASE, &Value); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_BUFFER: + + /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ + + if (OriginalObject->Buffer.Length > 8) + { + return (AE_AML_OPERAND_TYPE); + } + + /* Extract each buffer byte to create the integer */ + + for (i = 0; i < OriginalObject->Buffer.Length; i++) + { + Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8)); + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + NewObject = AcpiUtCreateIntegerObject (Value); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToString + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToString ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_SIZE Length; + ACPI_STATUS Status; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + /* + * Integer-to-String conversion. Commonly, convert + * an integer of value 0 to a NULL string. The last element of + * _BIF and _BIX packages occasionally need this fix. + */ + if (OriginalObject->Integer.Value == 0) + { + /* Allocate a new NULL string object */ + + NewObject = AcpiUtCreateStringObject (0); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + } + else + { + Status = AcpiExConvertToString (OriginalObject, &NewObject, + ACPI_IMPLICIT_CONVERT_HEX); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + break; + + case ACPI_TYPE_BUFFER: + /* + * Buffer-to-String conversion. Use a ToString + * conversion, no transform performed on the buffer data. The best + * example of this is the _BIF method, where the string data from + * the battery is often (incorrectly) returned as buffer object(s). + */ + Length = 0; + while ((Length < OriginalObject->Buffer.Length) && + (OriginalObject->Buffer.Pointer[Length])) + { + Length++; + } + + /* Allocate a new string object */ + + NewObject = AcpiUtCreateStringObject (Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* + * Copy the raw buffer data with no transform. String is already NULL + * terminated at Length+1. + */ + ACPI_MEMCPY (NewObject->String.Pointer, + OriginalObject->Buffer.Pointer, Length); + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToBuffer + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToBuffer ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Elements; + UINT32 *DwordBuffer; + UINT32 Count; + UINT32 i; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + /* + * Integer-to-Buffer conversion. + * Convert the Integer to a packed-byte buffer. _MAT and other + * objects need this sometimes, if a read has been performed on a + * Field object that is less than or equal to the global integer + * size (32 or 64 bits). + */ + Status = AcpiExConvertToBuffer (OriginalObject, &NewObject); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_STRING: + + /* String-to-Buffer conversion. Simple data copy */ + + NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + ACPI_MEMCPY (NewObject->Buffer.Pointer, + OriginalObject->String.Pointer, OriginalObject->String.Length); + break; + + case ACPI_TYPE_PACKAGE: + /* + * This case is often seen for predefined names that must return a + * Buffer object with multiple DWORD integers within. For example, + * _FDE and _GTM. The Package can be converted to a Buffer. + */ + + /* All elements of the Package must be integers */ + + Elements = OriginalObject->Package.Elements; + Count = OriginalObject->Package.Count; + + for (i = 0; i < Count; i++) + { + if ((!*Elements) || + ((*Elements)->Common.Type != ACPI_TYPE_INTEGER)) + { + return (AE_AML_OPERAND_TYPE); + } + Elements++; + } + + /* Create the new buffer object to replace the Package */ + + NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count)); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* Copy the package elements (integers) to the buffer as DWORDs */ + + Elements = OriginalObject->Package.Elements; + DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer); + + for (i = 0; i < Count; i++) + { + *DwordBuffer = (UINT32) (*Elements)->Integer.Value; + DwordBuffer++; + Elements++; + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToPackage + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of + * the buffer is converted to a single integer package element. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToPackage ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_OPERAND_OBJECT **Elements; + UINT32 Length; + UINT8 *Buffer; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* Buffer-to-Package conversion */ + + Length = OriginalObject->Buffer.Length; + NewObject = AcpiUtCreatePackageObject (Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* Convert each buffer byte to an integer package element */ + + Elements = NewObject->Package.Elements; + Buffer = OriginalObject->Buffer.Pointer; + + while (Length--) + { + *Elements = AcpiUtCreateIntegerObject ((UINT64) *Buffer); + if (!*Elements) + { + AcpiUtRemoveReference (NewObject); + return (AE_NO_MEMORY); + } + Elements++; + Buffer++; + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * ObjDescPtr - Pointer to the object to repair. The new + * package object is returned here, + * overwriting the old object. + * + * RETURN: Status, new object in *ObjDescPtr + * + * DESCRIPTION: Repair a common problem with objects that are defined to return + * a variable-length Package of Packages. If the variable-length + * is one, some BIOS code mistakenly simply declares a single + * Package instead of a Package with one sub-Package. This + * function attempts to repair this error by wrapping a Package + * object around the original Package, creating the correct + * Package with one sub-Package. + * + * Names that can be repaired in this manner include: + * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairPackageList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *PkgObjDesc; + + + ACPI_FUNCTION_NAME (NsRepairPackageList); + + + /* + * Create the new outer package and populate it. The new package will + * have a single element, the lone subpackage. + */ + PkgObjDesc = AcpiUtCreatePackageObject (1); + if (!PkgObjDesc) + { + return (AE_NO_MEMORY); + } + + PkgObjDesc->Package.Elements[0] = *ObjDescPtr; + + /* Return the new object in the object pointer */ + + *ObjDescPtr = PkgObjDesc; + Data->Flags |= ACPI_OBJECT_REPAIRED; + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Repaired incorrectly formed Package\n", Data->Pathname)); + + return (AE_OK); +} diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsrepair2.c b/reactos/drivers/bus/acpi/acpica/namespace/nsrepair2.c new file mode 100644 index 00000000000..c08028452b4 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsrepair2.c @@ -0,0 +1,796 @@ +/****************************************************************************** + * + * Module Name: nsrepair2 - Repair for objects returned by specific + * predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSREPAIR2_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acpredef.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsrepair2") + + +/* + * Information structure and handler for ACPI predefined names that can + * be repaired on a per-name basis. + */ +typedef +ACPI_STATUS (*ACPI_REPAIR_FUNCTION) ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +typedef struct acpi_repair_info +{ + char Name[ACPI_NAME_SIZE]; + ACPI_REPAIR_FUNCTION RepairFunction; + +} ACPI_REPAIR_INFO; + + +/* Local prototypes */ + +static const ACPI_REPAIR_INFO * +AcpiNsMatchRepairableName ( + ACPI_NAMESPACE_NODE *Node); + +static ACPI_STATUS +AcpiNsRepair_ALR ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_FDE ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_PSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_TSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsCheckSortedList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject, + UINT32 ExpectedCount, + UINT32 SortIndex, + UINT8 SortDirection, + char *SortKeyName); + +static ACPI_STATUS +AcpiNsSortList ( + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count, + UINT32 Index, + UINT8 SortDirection); + +/* Values for SortDirection above */ + +#define ACPI_SORT_ASCENDING 0 +#define ACPI_SORT_DESCENDING 1 + + +/* + * This table contains the names of the predefined methods for which we can + * perform more complex repairs. + * + * As necessary: + * + * _ALR: Sort the list ascending by AmbientIlluminance + * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs + * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs + * _PSS: Sort the list descending by Power + * _TSS: Sort the list descending by Power + */ +static const ACPI_REPAIR_INFO AcpiNsRepairableNames[] = +{ + {"_ALR", AcpiNsRepair_ALR}, + {"_FDE", AcpiNsRepair_FDE}, + {"_GTM", AcpiNsRepair_FDE}, /* _GTM has same repair as _FDE */ + {"_PSS", AcpiNsRepair_PSS}, + {"_TSS", AcpiNsRepair_TSS}, + {{0,0,0,0}, NULL} /* Table terminator */ +}; + + +#define ACPI_FDE_FIELD_COUNT 5 +#define ACPI_FDE_BYTE_BUFFER_SIZE 5 +#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (UINT32)) + + +/****************************************************************************** + * + * FUNCTION: AcpiNsComplexRepairs + * + * PARAMETERS: Data - Pointer to validation data structure + * Node - Namespace node for the method/object + * ValidateStatus - Original status of earlier validation + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if repair was successful. If name is not + * matched, ValidateStatus is returned. + * + * DESCRIPTION: Attempt to repair/convert a return object of a type that was + * not expected. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsComplexRepairs ( + ACPI_PREDEFINED_DATA *Data, + ACPI_NAMESPACE_NODE *Node, + ACPI_STATUS ValidateStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + const ACPI_REPAIR_INFO *Predefined; + ACPI_STATUS Status; + + + /* Check if this name is in the list of repairable names */ + + Predefined = AcpiNsMatchRepairableName (Node); + if (!Predefined) + { + return (ValidateStatus); + } + + Status = Predefined->RepairFunction (Data, ReturnObjectPtr); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsMatchRepairableName + * + * PARAMETERS: Node - Namespace node for the method/object + * + * RETURN: Pointer to entry in repair table. NULL indicates not found. + * + * DESCRIPTION: Check an object name against the repairable object list. + * + *****************************************************************************/ + +static const ACPI_REPAIR_INFO * +AcpiNsMatchRepairableName ( + ACPI_NAMESPACE_NODE *Node) +{ + const ACPI_REPAIR_INFO *ThisName; + + + /* Search info table for a repairable predefined method/object name */ + + ThisName = AcpiNsRepairableNames; + while (ThisName->RepairFunction) + { + if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name)) + { + return (ThisName); + } + ThisName++; + } + + return (NULL); /* Not found */ +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_ALR + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list + * ascending by the ambient illuminance values. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_ALR ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status; + + + Status = AcpiNsCheckSortedList (Data, ReturnObject, 2, 1, + ACPI_SORT_ASCENDING, "AmbientIlluminance"); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_FDE + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return + * value is a Buffer of 5 DWORDs. This function repairs a common + * problem where the return value is a Buffer of BYTEs, not + * DWORDs. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_FDE ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *BufferObject; + UINT8 *ByteBuffer; + UINT32 *DwordBuffer; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsRepair_FDE); + + + switch (ReturnObject->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* This is the expected type. Length should be (at least) 5 DWORDs */ + + if (ReturnObject->Buffer.Length >= ACPI_FDE_DWORD_BUFFER_SIZE) + { + return (AE_OK); + } + + /* We can only repair if we have exactly 5 BYTEs */ + + if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Incorrect return buffer length %u, expected %u", + ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE)); + + return (AE_AML_OPERAND_TYPE); + } + + /* Create the new (larger) buffer object */ + + BufferObject = AcpiUtCreateBufferObject (ACPI_FDE_DWORD_BUFFER_SIZE); + if (!BufferObject) + { + return (AE_NO_MEMORY); + } + + /* Expand each byte to a DWORD */ + + ByteBuffer = ReturnObject->Buffer.Pointer; + DwordBuffer = ACPI_CAST_PTR (UINT32, BufferObject->Buffer.Pointer); + + for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) + { + *DwordBuffer = (UINT32) *ByteBuffer; + DwordBuffer++; + ByteBuffer++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s Expanded Byte Buffer to expected DWord Buffer\n", + Data->Pathname)); + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + /* Delete the original return object, return the new buffer object */ + + AcpiUtRemoveReference (ReturnObject); + *ReturnObjectPtr = BufferObject; + + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_TSS + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list + * descending by the power dissipation values. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_TSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status; + + + Status = AcpiNsCheckSortedList (Data, ReturnObject, 5, 1, + ACPI_SORT_DESCENDING, "PowerDissipation"); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_PSS + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list + * by the CPU frequencies. Check that the power dissipation values + * are all proportional to CPU frequency (i.e., sorting by + * frequency should be the same as sorting by power.) + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_PSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT **OuterElements; + UINT32 OuterElementCount; + ACPI_OPERAND_OBJECT **Elements; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 PreviousValue; + ACPI_STATUS Status; + UINT32 i; + + + /* + * Entries (sub-packages) in the _PSS Package must be sorted by power + * dissipation, in descending order. If it appears that the list is + * incorrectly sorted, sort it. We sort by CpuFrequency, since this + * should be proportional to the power. + */ + Status =AcpiNsCheckSortedList (Data, ReturnObject, 6, 0, + ACPI_SORT_DESCENDING, "CpuFrequency"); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * We now know the list is correctly sorted by CPU frequency. Check if + * the power dissipation values are proportional. + */ + PreviousValue = ACPI_UINT32_MAX; + OuterElements = ReturnObject->Package.Elements; + OuterElementCount = ReturnObject->Package.Count; + + for (i = 0; i < OuterElementCount; i++) + { + Elements = (*OuterElements)->Package.Elements; + ObjDesc = Elements[1]; /* Index1 = PowerDissipation */ + + if ((UINT32) ObjDesc->Integer.Value > PreviousValue) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "SubPackage[%u,%u] - suspicious power dissipation values", + i-1, i)); + } + + PreviousValue = (UINT32) ObjDesc->Integer.Value; + OuterElements++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsCheckSortedList + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObject - Pointer to the top-level returned object + * ExpectedCount - Minimum length of each sub-package + * SortIndex - Sub-package entry to sort on + * SortDirection - Ascending or descending + * SortKeyName - Name of the SortIndex field + * + * RETURN: Status. AE_OK if the list is valid and is sorted correctly or + * has been repaired by sorting the list. + * + * DESCRIPTION: Check if the package list is valid and sorted correctly by the + * SortIndex. If not, then sort the list. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckSortedList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject, + UINT32 ExpectedCount, + UINT32 SortIndex, + UINT8 SortDirection, + char *SortKeyName) +{ + UINT32 OuterElementCount; + ACPI_OPERAND_OBJECT **OuterElements; + ACPI_OPERAND_OBJECT **Elements; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 i; + UINT32 PreviousValue; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (NsCheckSortedList); + + + /* The top-level object must be a package */ + + if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) + { + return (AE_AML_OPERAND_TYPE); + } + + /* + * NOTE: assumes list of sub-packages contains no NULL elements. + * Any NULL elements should have been removed by earlier call + * to AcpiNsRemoveNullElements. + */ + OuterElements = ReturnObject->Package.Elements; + OuterElementCount = ReturnObject->Package.Count; + if (!OuterElementCount) + { + return (AE_AML_PACKAGE_LIMIT); + } + + PreviousValue = 0; + if (SortDirection == ACPI_SORT_DESCENDING) + { + PreviousValue = ACPI_UINT32_MAX; + } + + /* Examine each subpackage */ + + for (i = 0; i < OuterElementCount; i++) + { + /* Each element of the top-level package must also be a package */ + + if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE) + { + return (AE_AML_OPERAND_TYPE); + } + + /* Each sub-package must have the minimum length */ + + if ((*OuterElements)->Package.Count < ExpectedCount) + { + return (AE_AML_PACKAGE_LIMIT); + } + + Elements = (*OuterElements)->Package.Elements; + ObjDesc = Elements[SortIndex]; + + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + return (AE_AML_OPERAND_TYPE); + } + + /* + * The list must be sorted in the specified order. If we detect a + * discrepancy, issue a warning and sort the entire list + */ + if (((SortDirection == ACPI_SORT_ASCENDING) && + (ObjDesc->Integer.Value < PreviousValue)) || + ((SortDirection == ACPI_SORT_DESCENDING) && + (ObjDesc->Integer.Value > PreviousValue))) + { + Status = AcpiNsSortList (ReturnObject->Package.Elements, + OuterElementCount, SortIndex, SortDirection); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Data->Flags |= ACPI_OBJECT_REPAIRED; + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Repaired unsorted list - now sorted by %s\n", + Data->Pathname, SortKeyName)); + return (AE_OK); + } + + PreviousValue = (UINT32) ObjDesc->Integer.Value; + OuterElements++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRemoveNullElements + * + * PARAMETERS: Data - Pointer to validation data structure + * PackageType - An AcpiReturnPackageTypes value + * ObjDesc - A Package object + * + * RETURN: None. + * + * DESCRIPTION: Remove all NULL package elements from packages that contain + * a variable number of sub-packages. + * + *****************************************************************************/ + +void +AcpiNsRemoveNullElements ( + ACPI_PREDEFINED_DATA *Data, + UINT8 PackageType, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT **Source; + ACPI_OPERAND_OBJECT **Dest; + UINT32 Count; + UINT32 NewCount; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsRemoveNullElements); + + + /* + * PTYPE1 packages contain no subpackages. + * PTYPE2 packages contain a variable number of sub-packages. We can + * safely remove all NULL elements from the PTYPE2 packages. + */ + switch (PackageType) + { + case ACPI_PTYPE1_FIXED: + case ACPI_PTYPE1_VAR: + case ACPI_PTYPE1_OPTION: + return; + + case ACPI_PTYPE2: + case ACPI_PTYPE2_COUNT: + case ACPI_PTYPE2_PKG_COUNT: + case ACPI_PTYPE2_FIXED: + case ACPI_PTYPE2_MIN: + case ACPI_PTYPE2_REV_FIXED: + break; + + default: + return; + } + + Count = ObjDesc->Package.Count; + NewCount = Count; + + Source = ObjDesc->Package.Elements; + Dest = Source; + + /* Examine all elements of the package object, remove nulls */ + + for (i = 0; i < Count; i++) + { + if (!*Source) + { + NewCount--; + } + else + { + *Dest = *Source; + Dest++; + } + Source++; + } + + /* Update parent package if any null elements were removed */ + + if (NewCount < Count) + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Found and removed %u NULL elements\n", + Data->Pathname, (Count - NewCount))); + + /* NULL terminate list and update the package count */ + + *Dest = NULL; + ObjDesc->Package.Count = NewCount; + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsSortList + * + * PARAMETERS: Elements - Package object element list + * Count - Element count for above + * Index - Sort by which package element + * SortDirection - Ascending or Descending sort + * + * RETURN: Status + * + * DESCRIPTION: Sort the objects that are in a package element list. + * + * NOTE: Assumes that all NULL elements have been removed from the package. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsSortList ( + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count, + UINT32 Index, + UINT8 SortDirection) +{ + ACPI_OPERAND_OBJECT *ObjDesc1; + ACPI_OPERAND_OBJECT *ObjDesc2; + ACPI_OPERAND_OBJECT *TempObj; + UINT32 i; + UINT32 j; + + + /* Simple bubble sort */ + + for (i = 1; i < Count; i++) + { + for (j = (Count - 1); j >= i; j--) + { + ObjDesc1 = Elements[j-1]->Package.Elements[Index]; + ObjDesc2 = Elements[j]->Package.Elements[Index]; + + if (((SortDirection == ACPI_SORT_ASCENDING) && + (ObjDesc1->Integer.Value > ObjDesc2->Integer.Value)) || + + ((SortDirection == ACPI_SORT_DESCENDING) && + (ObjDesc1->Integer.Value < ObjDesc2->Integer.Value))) + { + TempObj = Elements[j-1]; + Elements[j-1] = Elements[j]; + Elements[j] = TempObj; + } + } + } + + return (AE_OK); +} diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nssearch.c b/reactos/drivers/bus/acpi/acpica/namespace/nssearch.c new file mode 100644 index 00000000000..fce7c5ad4de --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nssearch.c @@ -0,0 +1,507 @@ +/******************************************************************************* + * + * Module Name: nssearch - Namespace search + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSSEARCH_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#ifdef ACPI_ASL_COMPILER +#include "amlcode.h" +#endif + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nssearch") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchOneScope + * + * PARAMETERS: TargetName - Ascii ACPI name to search for + * ParentNode - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Named obj is returned + * + * RETURN: Status + * + * DESCRIPTION: Search a single level of the namespace. Performs a + * simple search of the specified level, and does not add + * entries or search parents. + * + * + * Named object lists are built (and subsequently dumped) in the + * order in which the names are encountered during the namespace load; + * + * All namespace searching is linear in this implementation, but + * could be easily modified to support any improved search + * algorithm. However, the linear search was chosen for simplicity + * and because the trees are small and the other interpreter + * execution overhead is relatively high. + * + * Note: CPU execution analysis has shown that the AML interpreter spends + * a very small percentage of its time searching the namespace. Therefore, + * the linear search seems to be sufficient, as there would seem to be + * little value in improving the search. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchOneScope ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (NsSearchOneScope); + + +#ifdef ACPI_DEBUG_OUTPUT + if (ACPI_LV_NAMES & AcpiDbgLevel) + { + char *ScopeName; + + ScopeName = AcpiNsGetExternalPathname (ParentNode); + if (ScopeName) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching %s (%p) For [%4.4s] (%s)\n", + ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName), + AcpiUtGetTypeName (Type))); + + ACPI_FREE (ScopeName); + } + } +#endif + + /* + * Search for name at this namespace level, which is to say that we + * must search for the name among the children of this object + */ + Node = ParentNode->Child; + while (Node) + { + /* Check for match against the name */ + + if (Node->Name.Integer == TargetName) + { + /* Resolve a control method alias if any */ + + if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + { + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + } + + /* Found matching entry */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", + ACPI_CAST_PTR (char, &TargetName), + AcpiUtGetTypeName (Node->Type), + Node, AcpiUtGetNodeName (ParentNode), ParentNode)); + + *ReturnNode = Node; + return_ACPI_STATUS (AE_OK); + } + + /* + * The last entry in the list points back to the parent, + * so a flag is used to indicate the end-of-list + */ + if (Node->Flags & ANOBJ_END_OF_PEER_LIST) + { + /* Searched entire list, we are done */ + + break; + } + + /* Didn't match name, move on to the next peer object */ + + Node = Node->Peer; + } + + /* Searched entire namespace level, not found */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] (%s) not found in search in scope [%4.4s] " + "%p first child %p\n", + ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type), + AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child)); + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchParentTree + * + * PARAMETERS: TargetName - Ascii ACPI name to search for + * Node - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Node is returned + * + * RETURN: Status + * + * DESCRIPTION: Called when a name has not been found in the current namespace + * level. Before adding it or giving up, ACPI scope rules require + * searching enclosing scopes in cases identified by AcpiNsLocal(). + * + * "A name is located by finding the matching name in the current + * name space, and then in the parent name space. If the parent + * name space does not contain the name, the search continues + * recursively until either the name is found or the name space + * does not have a parent (the root of the name space). This + * indicates that the name is not found" (From ACPI Specification, + * section 5.3) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_TRACE (NsSearchParentTree); + + + ParentNode = AcpiNsGetParentNode (Node); + + /* + * If there is no parent (i.e., we are at the root) or type is "local", + * we won't be searching the parent tree. + */ + if (!ParentNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", + ACPI_CAST_PTR (char, &TargetName))); + return_ACPI_STATUS (AE_NOT_FOUND); + } + + if (AcpiNsLocal (Type)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "[%4.4s] type [%s] must be local to this scope (no parent search)\n", + ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type))); + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* Search the parent tree */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching parent [%4.4s] for [%4.4s]\n", + AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName))); + + /* Search parents until target is found or we have backed up to the root */ + + while (ParentNode) + { + /* + * Search parent scope. Use TYPE_ANY because we don't care about the + * object type at this point, we only care about the existence of + * the actual name we are searching for. Typechecking comes later. + */ + Status = AcpiNsSearchOneScope ( + TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Not found here, go up another level (until we reach the root) */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + + /* Not found in parent tree */ + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchAndEnter + * + * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) + * WalkState - Current state of the walk + * Node - Starting node where search will begin + * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x. + * Otherwise,search only. + * Type - Object type to match + * Flags - Flags describing the search restrictions + * ReturnNode - Where the Node is returned + * + * RETURN: Status + * + * DESCRIPTION: Search for a name segment in a single namespace level, + * optionally adding it if it is not found. If the passed + * Type is not Any and the type previously stored in the + * entry was Any (i.e. unknown), update the stored type. + * + * In ACPI_IMODE_EXECUTE, search only. + * In other modes, search and add if not found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 TargetName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_INTERPRETER_MODE InterpreterMode, + ACPI_OBJECT_TYPE Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *NewNode; + + + ACPI_FUNCTION_TRACE (NsSearchAndEnter); + + + /* Parameter validation */ + + if (!Node || !TargetName || !ReturnNode) + { + ACPI_ERROR ((AE_INFO, + "Null parameter: Node %p Name %X ReturnNode %p", + Node, TargetName, ReturnNode)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Name must consist of valid ACPI characters. We will repair the name if + * necessary because we don't want to abort because of this, but we want + * all namespace names to be printable. A warning message is appropriate. + * + * This issue came up because there are in fact machines that exhibit + * this problem, and we want to be able to enable ACPI support for them, + * even though there are a few bad names. + */ + AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName)); + + /* Try to find the name in the namespace level specified by the caller */ + + *ReturnNode = ACPI_ENTRY_NOT_FOUND; + Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode); + if (Status != AE_NOT_FOUND) + { + /* + * If we found it AND the request specifies that a find is an error, + * return the error + */ + if ((Status == AE_OK) && + (Flags & ACPI_NS_ERROR_IF_FOUND)) + { + Status = AE_ALREADY_EXISTS; + } + +#ifdef ACPI_ASL_COMPILER + if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY) + { + (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL; + } +#endif + + /* Either found it or there was an error: finished either way */ + + return_ACPI_STATUS (Status); + } + + /* + * The name was not found. If we are NOT performing the first pass + * (name entry) of loading the namespace, search the parent tree (all the + * way to the root if necessary.) We don't want to perform the parent + * search when the namespace is actually being loaded. We want to perform + * the search when namespace references are being resolved (load pass 2) + * and during the execution phase. + */ + if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && + (Flags & ACPI_NS_SEARCH_PARENT)) + { + /* + * Not found at this level - search parent tree according to the + * ACPI specification + */ + Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* In execute mode, just search, never add names. Exit now */ + + if (InterpreterMode == ACPI_IMODE_EXECUTE) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s Not found in %p [Not adding]\n", + ACPI_CAST_PTR (char, &TargetName), Node)); + + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* Create the new named object */ + + NewNode = AcpiNsCreateNode (TargetName); + if (!NewNode) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + +#ifdef ACPI_ASL_COMPILER + + /* Node is an object defined by an External() statement */ + + if (Flags & ACPI_NS_EXTERNAL || + (WalkState && WalkState->Opcode == AML_SCOPE_OP)) + { + NewNode->Flags |= ANOBJ_IS_EXTERNAL; + } +#endif + + if (Flags & ACPI_NS_TEMPORARY) + { + NewNode->Flags |= ANOBJ_TEMPORARY; + } + + /* Install the new object into the parent's list of children */ + + AcpiNsInstallNode (WalkState, Node, NewNode, Type); + *ReturnNode = NewNode; + return_ACPI_STATUS (AE_OK); +} + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c b/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c new file mode 100644 index 00000000000..ed0c3f7ec81 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c @@ -0,0 +1,1184 @@ +/****************************************************************************** + * + * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing + * parents and siblings and Scope manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsutils") + +/* Local prototypes */ + +static BOOLEAN +AcpiNsValidPathSeparator ( + char Sep); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *NodeToSearch); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiNsReportError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * InternalName - Name or path of the namespace node + * LookupStatus - Exception code from NS lookup + * + * RETURN: None + * + * DESCRIPTION: Print warning message with full pathname + * + ******************************************************************************/ + +void +AcpiNsReportError ( + const char *ModuleName, + UINT32 LineNumber, + const char *InternalName, + ACPI_STATUS LookupStatus) +{ + ACPI_STATUS Status; + UINT32 BadName; + char *Name = NULL; + + + AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); + + if (LookupStatus == AE_BAD_CHARACTER) + { + /* There is a non-ascii character in the name */ + + ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName)); + AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName); + } + else + { + /* Convert path to external format */ + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, + InternalName, NULL, &Name); + + /* Print target name */ + + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf ("[%s]", Name); + } + else + { + AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]"); + } + + if (Name) + { + ACPI_FREE (Name); + } + } + + AcpiOsPrintf (" Namespace lookup failure, %s\n", + AcpiFormatException (LookupStatus)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsReportMethodError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Message - Error message to use on failure + * PrefixNode - Prefix relative to the path + * Path - Path to the node (optional) + * MethodStatus - Execution status + * + * RETURN: None + * + * DESCRIPTION: Print warning message with full pathname + * + ******************************************************************************/ + +void +AcpiNsReportMethodError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Message, + ACPI_NAMESPACE_NODE *PrefixNode, + const char *Path, + ACPI_STATUS MethodStatus) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = PrefixNode; + + + AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); + + if (Path) + { + Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH, + &Node); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("[Could not get node by pathname]"); + } + } + + AcpiNsPrintNodePathname (Node, Message); + AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsPrintNodePathname + * + * PARAMETERS: Node - Object + * Message - Prefix message + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ******************************************************************************/ + +void +AcpiNsPrintNodePathname ( + ACPI_NAMESPACE_NODE *Node, + const char *Message) +{ + ACPI_BUFFER Buffer; + ACPI_STATUS Status; + + + if (!Node) + { + AcpiOsPrintf ("[NULL NAME]"); + return; + } + + /* Convert handle to full pathname and print it (with supplied message) */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + + Status = AcpiNsHandleToPathname (Node, &Buffer); + if (ACPI_SUCCESS (Status)) + { + if (Message) + { + AcpiOsPrintf ("%s ", Message); + } + + AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node); + ACPI_FREE (Buffer.Pointer); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidRootPrefix + * + * PARAMETERS: Prefix - Character to be checked + * + * RETURN: TRUE if a valid prefix + * + * DESCRIPTION: Check if a character is a valid ACPI Root prefix + * + ******************************************************************************/ + +BOOLEAN +AcpiNsValidRootPrefix ( + char Prefix) +{ + + return ((BOOLEAN) (Prefix == '\\')); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidPathSeparator + * + * PARAMETERS: Sep - Character to be checked + * + * RETURN: TRUE if a valid path separator + * + * DESCRIPTION: Check if a character is a valid ACPI path separator + * + ******************************************************************************/ + +static BOOLEAN +AcpiNsValidPathSeparator ( + char Sep) +{ + + return ((BOOLEAN) (Sep == '.')); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetType + * + * PARAMETERS: Node - Parent Node to be examined + * + * RETURN: Type field from Node whose handle is passed + * + * DESCRIPTION: Return the type of a Namespace node + * + ******************************************************************************/ + +ACPI_OBJECT_TYPE +AcpiNsGetType ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_FUNCTION_TRACE (NsGetType); + + + if (!Node) + { + ACPI_WARNING ((AE_INFO, "Null Node parameter")); + return_UINT32 (ACPI_TYPE_ANY); + } + + return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsLocal + * + * PARAMETERS: Type - A namespace object type + * + * RETURN: LOCAL if names must be found locally in objects of the + * passed type, 0 if enclosing scopes should be searched + * + * DESCRIPTION: Returns scope rule for the given object type. + * + ******************************************************************************/ + +UINT32 +AcpiNsLocal ( + ACPI_OBJECT_TYPE Type) +{ + ACPI_FUNCTION_TRACE (NsLocal); + + + if (!AcpiUtValidObjectType (Type)) + { + /* Type code out of range */ + + ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type)); + return_UINT32 (ACPI_NS_NORMAL); + } + + return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetInternalNameLength + * + * PARAMETERS: Info - Info struct initialized with the + * external name pointer. + * + * RETURN: None + * + * DESCRIPTION: Calculate the length of the internal (AML) namestring + * corresponding to the external (ASL) namestring. + * + ******************************************************************************/ + +void +AcpiNsGetInternalNameLength ( + ACPI_NAMESTRING_INFO *Info) +{ + const char *NextExternalChar; + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + NextExternalChar = Info->ExternalName; + Info->NumCarats = 0; + Info->NumSegments = 0; + Info->FullyQualified = FALSE; + + /* + * For the internal name, the required length is 4 bytes per segment, plus + * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null + * (which is not really needed, but no there's harm in putting it there) + * + * strlen() + 1 covers the first NameSeg, which has no path separator + */ + if (AcpiNsValidRootPrefix (*NextExternalChar)) + { + Info->FullyQualified = TRUE; + NextExternalChar++; + + /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */ + + while (AcpiNsValidRootPrefix (*NextExternalChar)) + { + NextExternalChar++; + } + } + else + { + /* Handle Carat prefixes */ + + while (*NextExternalChar == '^') + { + Info->NumCarats++; + NextExternalChar++; + } + } + + /* + * Determine the number of ACPI name "segments" by counting the number of + * path separators within the string. Start with one segment since the + * segment count is [(# separators) + 1], and zero separators is ok. + */ + if (*NextExternalChar) + { + Info->NumSegments = 1; + for (i = 0; NextExternalChar[i]; i++) + { + if (AcpiNsValidPathSeparator (NextExternalChar[i])) + { + Info->NumSegments++; + } + } + } + + Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) + + 4 + Info->NumCarats; + + Info->NextExternalChar = NextExternalChar; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildInternalName + * + * PARAMETERS: Info - Info struct fully initialized + * + * RETURN: Status + * + * DESCRIPTION: Construct the internal (AML) namestring + * corresponding to the external (ASL) namestring. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsBuildInternalName ( + ACPI_NAMESTRING_INFO *Info) +{ + UINT32 NumSegments = Info->NumSegments; + char *InternalName = Info->InternalName; + const char *ExternalName = Info->NextExternalChar; + char *Result = NULL; + UINT32 i; + + + ACPI_FUNCTION_TRACE (NsBuildInternalName); + + + /* Setup the correct prefixes, counts, and pointers */ + + if (Info->FullyQualified) + { + InternalName[0] = '\\'; + + if (NumSegments <= 1) + { + Result = &InternalName[1]; + } + else if (NumSegments == 2) + { + InternalName[1] = AML_DUAL_NAME_PREFIX; + Result = &InternalName[2]; + } + else + { + InternalName[1] = AML_MULTI_NAME_PREFIX_OP; + InternalName[2] = (char) NumSegments; + Result = &InternalName[3]; + } + } + else + { + /* + * Not fully qualified. + * Handle Carats first, then append the name segments + */ + i = 0; + if (Info->NumCarats) + { + for (i = 0; i < Info->NumCarats; i++) + { + InternalName[i] = '^'; + } + } + + if (NumSegments <= 1) + { + Result = &InternalName[i]; + } + else if (NumSegments == 2) + { + InternalName[i] = AML_DUAL_NAME_PREFIX; + Result = &InternalName[(ACPI_SIZE) i+1]; + } + else + { + InternalName[i] = AML_MULTI_NAME_PREFIX_OP; + InternalName[(ACPI_SIZE) i+1] = (char) NumSegments; + Result = &InternalName[(ACPI_SIZE) i+2]; + } + } + + /* Build the name (minus path separators) */ + + for (; NumSegments; NumSegments--) + { + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (AcpiNsValidPathSeparator (*ExternalName) || + (*ExternalName == 0)) + { + /* Pad the segment with underscore(s) if segment is short */ + + Result[i] = '_'; + } + else + { + /* Convert the character to uppercase and save it */ + + Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName); + ExternalName++; + } + } + + /* Now we must have a path separator, or the pathname is bad */ + + if (!AcpiNsValidPathSeparator (*ExternalName) && + (*ExternalName != 0)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Move on the next segment */ + + ExternalName++; + Result += ACPI_NAME_SIZE; + } + + /* Terminate the string */ + + *Result = 0; + + if (Info->FullyQualified) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n", + InternalName, InternalName)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n", + InternalName, InternalName)); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInternalizeName + * + * PARAMETERS: *ExternalName - External representation of name + * **Converted Name - Where to return the resulting + * internal represention of the name + * + * RETURN: Status + * + * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0") + * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * + *******************************************************************************/ + +ACPI_STATUS +AcpiNsInternalizeName ( + const char *ExternalName, + char **ConvertedName) +{ + char *InternalName; + ACPI_NAMESTRING_INFO Info; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsInternalizeName); + + + if ((!ExternalName) || + (*ExternalName == 0) || + (!ConvertedName)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the length of the new internal name */ + + Info.ExternalName = ExternalName; + AcpiNsGetInternalNameLength (&Info); + + /* We need a segment to store the internal name */ + + InternalName = ACPI_ALLOCATE_ZEROED (Info.Length); + if (!InternalName) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Build the name */ + + Info.InternalName = InternalName; + Status = AcpiNsBuildInternalName (&Info); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (InternalName); + return_ACPI_STATUS (Status); + } + + *ConvertedName = InternalName; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExternalizeName + * + * PARAMETERS: InternalNameLength - Lenth of the internal name below + * InternalName - Internal representation of name + * ConvertedNameLength - Where the length is returned + * ConvertedName - Where the resulting external name + * is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * to its external (printable) form (e.g. "\_PR_.CPU0") + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + const char *InternalName, + UINT32 *ConvertedNameLength, + char **ConvertedName) +{ + UINT32 NamesIndex = 0; + UINT32 NumSegments = 0; + UINT32 RequiredLength; + UINT32 PrefixLength = 0; + UINT32 i = 0; + UINT32 j = 0; + + + ACPI_FUNCTION_TRACE (NsExternalizeName); + + + if (!InternalNameLength || + !InternalName || + !ConvertedName) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check for a prefix (one '\' | one or more '^') */ + + switch (InternalName[0]) + { + case '\\': + PrefixLength = 1; + break; + + case '^': + for (i = 0; i < InternalNameLength; i++) + { + if (InternalName[i] == '^') + { + PrefixLength = i + 1; + } + else + { + break; + } + } + + if (i == InternalNameLength) + { + PrefixLength = i; + } + + break; + + default: + break; + } + + /* + * Check for object names. Note that there could be 0-255 of these + * 4-byte elements. + */ + if (PrefixLength < InternalNameLength) + { + switch (InternalName[PrefixLength]) + { + case AML_MULTI_NAME_PREFIX_OP: + + /* 4-byte names */ + + NamesIndex = PrefixLength + 2; + NumSegments = (UINT8) + InternalName[(ACPI_SIZE) PrefixLength + 1]; + break; + + case AML_DUAL_NAME_PREFIX: + + /* Two 4-byte names */ + + NamesIndex = PrefixLength + 1; + NumSegments = 2; + break; + + case 0: + + /* NullName */ + + NamesIndex = 0; + NumSegments = 0; + break; + + default: + + /* one 4-byte name */ + + NamesIndex = PrefixLength; + NumSegments = 1; + break; + } + } + + /* + * Calculate the length of ConvertedName, which equals the length + * of the prefix, length of all object names, length of any required + * punctuation ('.') between object names, plus the NULL terminator. + */ + RequiredLength = PrefixLength + (4 * NumSegments) + + ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; + + /* + * Check to see if we're still in bounds. If not, there's a problem + * with InternalName (invalid format). + */ + if (RequiredLength > InternalNameLength) + { + ACPI_ERROR ((AE_INFO, "Invalid internal name")); + return_ACPI_STATUS (AE_BAD_PATHNAME); + } + + /* Build the ConvertedName */ + + *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength); + if (!(*ConvertedName)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + j = 0; + + for (i = 0; i < PrefixLength; i++) + { + (*ConvertedName)[j++] = InternalName[i]; + } + + if (NumSegments > 0) + { + for (i = 0; i < NumSegments; i++) + { + if (i > 0) + { + (*ConvertedName)[j++] = '.'; + } + + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + } + } + + if (ConvertedNameLength) + { + *ConvertedNameLength = (UINT32) RequiredLength; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidateHandle + * + * PARAMETERS: Handle - Handle to be validated and typecast to a + * namespace node. + * + * RETURN: A pointer to a namespace node + * + * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special + * cases for the root node. + * + * NOTE: Real integer handles would allow for more verification + * and keep all pointers within this subsystem - however this introduces + * more overhead and has not been necessary to this point. Drivers + * holding handles are typically notified before a node becomes invalid + * due to a table unload. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsValidateHandle ( + ACPI_HANDLE Handle) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* Parameter validation */ + + if ((!Handle) || (Handle == ACPI_ROOT_OBJECT)) + { + return (AcpiGbl_RootNode); + } + + /* We can at least attempt to verify the handle */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED) + { + return (NULL); + } + + return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for namespace and ACPI table storage. + * + ******************************************************************************/ + +void +AcpiNsTerminate ( + void) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (NsTerminate); + + + /* + * 1) Free the entire namespace -- all nodes and objects + * + * Delete all object descriptors attached to namepsace nodes + */ + AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); + + /* Detach any objects attached to the root */ + + ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode); + if (ObjDesc) + { + AcpiNsDetachObject (AcpiGbl_RootNode); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsOpensScope + * + * PARAMETERS: Type - A valid namespace type + * + * RETURN: NEWSCOPE if the passed type "opens a name scope" according + * to the ACPI specification, else 0 + * + ******************************************************************************/ + +UINT32 +AcpiNsOpensScope ( + ACPI_OBJECT_TYPE Type) +{ + ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type)); + + + if (!AcpiUtValidObjectType (Type)) + { + /* type code out of range */ + + ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type)); + return_UINT32 (ACPI_NS_NORMAL); + } + + return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNode + * + * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The + * \ (backslash) and ^ (carat) prefixes, and the + * . (period) to separate segments are supported. + * PrefixNode - Root of subtree to be searched, or NS_ALL for the + * root of the name space. If Name is fully + * qualified (first INT8 is '\'), the passed value + * of Scope will not be accessed. + * Flags - Used to indicate whether to perform upsearch or + * not. + * ReturnNode - Where the Node is returned + * + * DESCRIPTION: Look up a name relative to a given scope and return the + * corresponding Node. NOTE: Scope can be null. + * + * MUTEX: Locks namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, + const char *Pathname, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_GENERIC_STATE ScopeInfo; + ACPI_STATUS Status; + char *InternalPath; + + + ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname)); + + + if (!Pathname) + { + *ReturnNode = PrefixNode; + if (!PrefixNode) + { + *ReturnNode = AcpiGbl_RootNode; + } + return_ACPI_STATUS (AE_OK); + } + + /* Convert path to internal representation */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Must lock namespace during lookup */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Setup lookup scope (search starting point) */ + + ScopeInfo.Scope.Node = PrefixNode; + + /* Lookup the name in the namespace */ + + Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), + NULL, ReturnNode); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n", + Pathname, AcpiFormatException (Status))); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +Cleanup: + ACPI_FREE (InternalPath); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetParentNode + * + * PARAMETERS: Node - Current table entry + * + * RETURN: Parent entry of the given entry + * + * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetParentNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_FUNCTION_ENTRY (); + + + if (!Node) + { + return (NULL); + } + + /* + * Walk to the end of this peer list. The last entry is marked with a flag + * and the peer pointer is really a pointer back to the parent. This saves + * putting a parent back pointer in each and every named object! + */ + while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) + { + Node = Node->Peer; + } + + return (Node->Peer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextValidNode + * + * PARAMETERS: Node - Current table entry + * + * RETURN: Next valid Node in the linked node list. NULL if no more valid + * nodes. + * + * DESCRIPTION: Find the next valid node within a name table. + * Useful for implementing NULL-end-of-list loops. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextValidNode ( + ACPI_NAMESPACE_NODE *Node) +{ + + /* If we are at the end of this peer list, return NULL */ + + if (Node->Flags & ANOBJ_END_OF_PEER_LIST) + { + return NULL; + } + + /* Otherwise just return the next peer */ + + return (Node->Peer); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiNsFindParentName + * + * PARAMETERS: *ChildNode - Named Obj whose name is to be found + * + * RETURN: The ACPI name + * + * DESCRIPTION: Search for the given obj in its parent scope and return the + * name segment, or "????" if the parent name can't be found + * (which "should not happen"). + * + ******************************************************************************/ + +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_TRACE (NsFindParentName); + + + if (ChildNode) + { + /* Valid entry. Get the parent Node */ + + ParentNode = AcpiNsGetParentNode (ChildNode); + if (ParentNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Parent of %p [%4.4s] is %p [%4.4s]\n", + ChildNode, AcpiUtGetNodeName (ChildNode), + ParentNode, AcpiUtGetNodeName (ParentNode))); + + if (ParentNode->Name.Integer) + { + return_VALUE ((ACPI_NAME) ParentNode->Name.Integer); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Unable to find parent of %p (%4.4s)\n", + ChildNode, AcpiUtGetNodeName (ChildNode))); + } + + return_VALUE (ACPI_UNKNOWN_NAME); +} +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nswalk.c b/reactos/drivers/bus/acpi/acpica/namespace/nswalk.c new file mode 100644 index 00000000000..7711e9a3768 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nswalk.c @@ -0,0 +1,468 @@ +/****************************************************************************** + * + * Module Name: nswalk - Functions for walking the ACPI namespace + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSWALK_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextNode + * + * PARAMETERS: ParentNode - Parent node whose children we are + * getting + * ChildNode - Previous child that was found. + * The NEXT child will be returned + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * DESCRIPTION: Return the next peer node within the namespace. If Handle + * is valid, Scope is ignored. Otherwise, the first node + * within Scope is returned. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNode ( + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_FUNCTION_ENTRY (); + + + if (!ChildNode) + { + /* It's really the parent's _scope_ that we want */ + + return (ParentNode->Child); + } + + /* + * Get the next node. + * + * If we are at the end of this peer list, return NULL + */ + if (ChildNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + return NULL; + } + + /* Otherwise just return the next peer */ + + return (ChildNode->Peer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextNodeTyped + * + * PARAMETERS: Type - Type of node to be searched for + * ParentNode - Parent node whose children we are + * getting + * ChildNode - Previous child that was found. + * The NEXT child will be returned + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * DESCRIPTION: Return the next peer node within the namespace. If Handle + * is valid, Scope is ignored. Otherwise, the first node + * within Scope is returned. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNodeTyped ( + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *NextNode = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + NextNode = AcpiNsGetNextNode (ParentNode, ChildNode); + + /* If any type is OK, we are done */ + + if (Type == ACPI_TYPE_ANY) + { + /* NextNode is NULL if we are at the end-of-list */ + + return (NextNode); + } + + /* Must search for the node -- but within this scope only */ + + while (NextNode) + { + /* If type matches, we are done */ + + if (NextNode->Type == Type) + { + return (NextNode); + } + + /* Otherwise, move on to the next node */ + + NextNode = AcpiNsGetNextValidNode (NextNode); + } + + /* Not found */ + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartNode - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * Flags - Whether to unlock the NS before invoking + * the callback routine + * PreOrderVisit - Called during tree pre-order visit + * when an object of "Type" is found + * PostOrderVisit - Called during tree post-order visit + * when an object of "Type" is found + * Context - Passed to user function(s) above + * ReturnValue - from the UserFunction if terminated + * early. Otherwise, returns NULL. + * RETURNS: Status + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the node specified by StartHandle. + * The callback function is called whenever a node that matches + * the type parameter is found. If the callback function returns + * a non-zero value, the search is terminated immediately and + * this value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the callback function(s) can be + * tailored to each task, whether it is a print function, + * a compare function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartNode, + UINT32 MaxDepth, + UINT32 Flags, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_STATUS MutexStatus; + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_OBJECT_TYPE ChildType; + UINT32 Level; + BOOLEAN NodePreviouslyVisited = FALSE; + + + ACPI_FUNCTION_TRACE (NsWalkNamespace); + + + /* Special case for the namespace Root Node */ + + if (StartNode == ACPI_ROOT_OBJECT) + { + StartNode = AcpiGbl_RootNode; + } + + /* Null child means "get first node" */ + + ParentNode = StartNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + ChildType = ACPI_TYPE_ANY; + Level = 1; + + /* + * Traverse the tree of nodes until we bubble back up to where we + * started. When Level is zero, the loop is done because we have + * bubbled up to (and passed) the original parent handle (StartEntry) + */ + while (Level > 0 && ChildNode) + { + Status = AE_OK; + + /* Found next child, get the type if we are not searching for ANY */ + + if (Type != ACPI_TYPE_ANY) + { + ChildType = ChildNode->Type; + } + + /* + * Ignore all temporary namespace nodes (created during control + * method execution) unless told otherwise. These temporary nodes + * can cause a race condition because they can be deleted during + * the execution of the user function (if the namespace is + * unlocked before invocation of the user function.) Only the + * debugger namespace dump will examine the temporary nodes. + */ + if ((ChildNode->Flags & ANOBJ_TEMPORARY) && + !(Flags & ACPI_NS_WALK_TEMP_NODES)) + { + Status = AE_CTRL_DEPTH; + } + + /* Type must match requested type */ + + else if (ChildType == Type) + { + /* + * Found a matching node, invoke the user callback function. + * Unlock the namespace if flag is set. + */ + if (Flags & ACPI_NS_WALK_UNLOCK) + { + MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (MutexStatus)) + { + return_ACPI_STATUS (MutexStatus); + } + } + + /* + * Invoke the user function, either pre-order or post-order + * or both. + */ + if (!NodePreviouslyVisited) + { + if (PreOrderVisit) + { + Status = PreOrderVisit (ChildNode, Level, + Context, ReturnValue); + } + } + else + { + if (PostOrderVisit) + { + Status = PostOrderVisit (ChildNode, Level, + Context, ReturnValue); + } + } + + if (Flags & ACPI_NS_WALK_UNLOCK) + { + MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (MutexStatus)) + { + return_ACPI_STATUS (MutexStatus); + } + } + + switch (Status) + { + case AE_OK: + case AE_CTRL_DEPTH: + + /* Just keep going */ + break; + + case AE_CTRL_TERMINATE: + + /* Exit now, with OK status */ + + return_ACPI_STATUS (AE_OK); + + default: + + /* All others are valid exceptions */ + + return_ACPI_STATUS (Status); + } + } + + /* + * Depth first search: Attempt to go down another level in the + * namespace if we are allowed to. Don't go any further if we have + * reached the caller specified maximum depth or if the user + * function has specified that the maximum depth has been reached. + */ + if (!NodePreviouslyVisited && + (Level < MaxDepth) && + (Status != AE_CTRL_DEPTH)) + { + if (ChildNode->Child) + { + /* There is at least one child of this node, visit it */ + + Level++; + ParentNode = ChildNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + continue; + } + } + + /* No more children, re-visit this node */ + + if (!NodePreviouslyVisited) + { + NodePreviouslyVisited = TRUE; + continue; + } + + /* No more children, visit peers */ + + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + if (ChildNode) + { + NodePreviouslyVisited = FALSE; + } + + /* No peers, re-visit parent */ + + else + { + /* + * No more children of this node (AcpiNsGetNextNode failed), go + * back upwards in the namespace tree to the node's parent. + */ + Level--; + ChildNode = ParentNode; + ParentNode = AcpiNsGetParentNode (ParentNode); + + NodePreviouslyVisited = TRUE; + } + } + + /* Complete walk, not terminated by user function */ + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsxfeval.c b/reactos/drivers/bus/acpi/acpica/namespace/nsxfeval.c new file mode 100644 index 00000000000..a0f96a04ee0 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsxfeval.c @@ -0,0 +1,1020 @@ +/******************************************************************************* + * + * Module Name: nsxfeval - Public interfaces to the ACPI subsystem + * ACPI Object evaluation interfaces + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfeval") + +/* Local prototypes */ + +static void +AcpiNsResolveReferences ( + ACPI_EVALUATE_INFO *Info); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvaluateObjectTyped + * + * PARAMETERS: Handle - Object handle (optional) + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, + * terminated by NULL. May be NULL + * if no parameters are being passed. + * ReturnBuffer - Where to put method's return value (if + * any). If NULL, no value is returned. + * ReturnType - Expected type of return object + * + * RETURN: Status + * + * DESCRIPTION: Find and evaluate the given object, passing the given + * parameters if necessary. One of "Handle" or "Pathname" must + * be valid (non-null) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvaluateObjectTyped ( + ACPI_HANDLE Handle, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer, + ACPI_OBJECT_TYPE ReturnType) +{ + ACPI_STATUS Status; + BOOLEAN MustFree = FALSE; + + + ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped); + + + /* Return buffer must be valid */ + + if (!ReturnBuffer) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER) + { + MustFree = TRUE; + } + + /* Evaluate the object */ + + Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Type ANY means "don't care" */ + + if (ReturnType == ACPI_TYPE_ANY) + { + return_ACPI_STATUS (AE_OK); + } + + if (ReturnBuffer->Length == 0) + { + /* Error because caller specifically asked for a return value */ + + ACPI_ERROR ((AE_INFO, "No return value")); + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Examine the object type returned from EvaluateObject */ + + if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType) + { + return_ACPI_STATUS (AE_OK); + } + + /* Return object type does not match requested type */ + + ACPI_ERROR ((AE_INFO, + "Incorrect return type [%s] requested [%s]", + AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type), + AcpiUtGetTypeName (ReturnType))); + + if (MustFree) + { + /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ + + AcpiOsFree (ReturnBuffer->Pointer); + ReturnBuffer->Pointer = NULL; + } + + ReturnBuffer->Length = 0; + return_ACPI_STATUS (AE_TYPE); +} + +ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped) + + +/******************************************************************************* + * + * FUNCTION: AcpiEvaluateObject + * + * PARAMETERS: Handle - Object handle (optional) + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, + * terminated by NULL. May be NULL + * if no parameters are being passed. + * ReturnBuffer - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Find and evaluate the given object, passing the given + * parameters if necessary. One of "Handle" or "Pathname" must + * be valid (non-null) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvaluateObject ( + ACPI_HANDLE Handle, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer) +{ + ACPI_STATUS Status; + ACPI_EVALUATE_INFO *Info; + ACPI_SIZE BufferSpaceNeeded; + UINT32 i; + + + ACPI_FUNCTION_TRACE (AcpiEvaluateObject); + + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Pathname = Pathname; + + /* Convert and validate the device handle */ + + Info->PrefixNode = AcpiNsValidateHandle (Handle); + if (!Info->PrefixNode) + { + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* + * If there are parameters to be passed to a control method, the external + * objects must all be converted to internal objects + */ + if (ExternalParams && ExternalParams->Count) + { + /* + * Allocate a new parameter block for the internal objects + * Add 1 to count to allow for null terminated internal list + */ + Info->Parameters = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ExternalParams->Count + 1) * sizeof (void *)); + if (!Info->Parameters) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Convert each external object in the list to an internal object */ + + for (i = 0; i < ExternalParams->Count; i++) + { + Status = AcpiUtCopyEobjectToIobject ( + &ExternalParams->Pointer[i], &Info->Parameters[i]); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + Info->Parameters[ExternalParams->Count] = NULL; + } + + /* + * Three major cases: + * 1) Fully qualified pathname + * 2) No handle, not fully qualified pathname (error) + * 3) Valid handle + */ + if ((Pathname) && + (AcpiNsValidRootPrefix (Pathname[0]))) + { + /* The path is fully qualified, just evaluate by name */ + + Info->PrefixNode = NULL; + Status = AcpiNsEvaluate (Info); + } + else if (!Handle) + { + /* + * A handle is optional iff a fully qualified pathname is specified. + * Since we've already handled fully qualified names above, this is + * an error + */ + if (!Pathname) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Both Handle and Pathname are NULL")); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Null Handle with relative pathname [%s]", Pathname)); + } + + Status = AE_BAD_PARAMETER; + } + else + { + /* We have a namespace a node and a possible relative path */ + + Status = AcpiNsEvaluate (Info); + } + + /* + * If we are expecting a return value, and all went well above, + * copy the return value to an external object. + */ + if (ReturnBuffer) + { + if (!Info->ReturnObject) + { + ReturnBuffer->Length = 0; + } + else + { + if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == + ACPI_DESC_TYPE_NAMED) + { + /* + * If we received a NS Node as a return object, this means that + * the object we are evaluating has nothing interesting to + * return (such as a mutex, etc.) We return an error because + * these types are essentially unsupported by this interface. + * We don't check up front because this makes it easier to add + * support for various types at a later date if necessary. + */ + Status = AE_TYPE; + Info->ReturnObject = NULL; /* No need to delete a NS Node */ + ReturnBuffer->Length = 0; + } + + if (ACPI_SUCCESS (Status)) + { + /* Dereference Index and RefOf references */ + + AcpiNsResolveReferences (Info); + + /* Get the size of the returned object */ + + Status = AcpiUtGetObjectSize (Info->ReturnObject, + &BufferSpaceNeeded); + if (ACPI_SUCCESS (Status)) + { + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (ReturnBuffer, + BufferSpaceNeeded); + if (ACPI_FAILURE (Status)) + { + /* + * Caller's buffer is too small or a new one can't + * be allocated + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Needed buffer size %X, %s\n", + (UINT32) BufferSpaceNeeded, + AcpiFormatException (Status))); + } + else + { + /* We have enough space for the object, build it */ + + Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject, + ReturnBuffer); + } + } + } + } + } + + if (Info->ReturnObject) + { + /* + * Delete the internal return object. NOTE: Interpreter must be + * locked to avoid race condition. + */ + AcpiExEnterInterpreter (); + + /* Remove one reference on the return object (should delete it) */ + + AcpiUtRemoveReference (Info->ReturnObject); + AcpiExExitInterpreter (); + } + + +Cleanup: + + /* Free the input parameter list (if we created one) */ + + if (Info->Parameters) + { + /* Free the allocated parameter block */ + + AcpiUtDeleteInternalObjectList (Info->Parameters); + } + + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEvaluateObject) + + +/******************************************************************************* + * + * FUNCTION: AcpiNsResolveReferences + * + * PARAMETERS: Info - Evaluation info block + * + * RETURN: Info->ReturnObject is replaced with the dereferenced object + * + * DESCRIPTION: Dereference certain reference objects. Called before an + * internal return object is converted to an external ACPI_OBJECT. + * + * Performs an automatic dereference of Index and RefOf reference objects. + * These reference objects are not supported by the ACPI_OBJECT, so this is a + * last resort effort to return something useful. Also, provides compatibility + * with other ACPI implementations. + * + * NOTE: does not handle references within returned package objects or nested + * references, but this support could be added later if found to be necessary. + * + ******************************************************************************/ + +static void +AcpiNsResolveReferences ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + + + /* We are interested in reference objects only */ + + if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return; + } + + /* + * Two types of references are supported - those created by Index and + * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted + * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle + * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to + * an ACPI_OBJECT. + */ + switch (Info->ReturnObject->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + ObjDesc = *(Info->ReturnObject->Reference.Where); + break; + + case ACPI_REFCLASS_REFOF: + + Node = Info->ReturnObject->Reference.Object; + if (Node) + { + ObjDesc = Node->Object; + } + break; + + default: + return; + } + + /* Replace the existing reference object */ + + if (ObjDesc) + { + AcpiUtAddReference (ObjDesc); + AcpiUtRemoveReference (Info->ReturnObject); + Info->ReturnObject = ObjDesc; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartObject - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * PreOrderVisit - Called during tree pre-order visit + * when an object of "Type" is found + * PostOrderVisit - Called during tree post-order visit + * when an object of "Type" is found + * Context - Passed to user function(s) above + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The callback function is called whenever an object that matches + * the type parameter is found. If the callback function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the callback function(s) can be + * tailored to each task, whether it is a print function, + * a compare function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiWalkNamespace); + + + /* Parameter validation */ + + if ((Type > ACPI_TYPE_LOCAL_MAX) || + (!MaxDepth) || + (!PreOrderVisit && !PostOrderVisit)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Need to acquire the namespace reader lock to prevent interference + * with any concurrent table unloads (which causes the deletion of + * namespace objects). We cannot allow the deletion of a namespace node + * while the user function is using it. The exception to this are the + * nodes created and deleted during control method execution -- these + * nodes are marked as temporary nodes and are ignored by the namespace + * walk. Thus, control methods can be executed while holding the + * namespace deletion lock (and the user function can execute control + * methods.) + */ + Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Lock the namespace around the walk. The namespace will be + * unlocked/locked around each call to the user function - since the user + * function must be allowed to make ACPICA calls itself (for example, it + * will typically execute control methods during device enumeration.) + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, + ACPI_NS_WALK_UNLOCK, PreOrderVisit, + PostOrderVisit, Context, ReturnValue); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +UnlockAndExit: + (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWalkNamespace) + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetDeviceCallback + * + * PARAMETERS: Callback from AcpiGetDevice + * + * RETURN: Status + * + * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- + * present devices, or if they specified a HID, it filters based + * on that. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsGetDeviceCallback ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_GET_DEVICES_INFO *Info = Context; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + UINT32 Flags; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; + UINT32 i; + BOOLEAN Found; + int NoMatch; + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (ObjHandle); + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* Run _STA to determine if device is present */ + + Status = AcpiUtExecute_STA (Node, &Flags); + if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + if (!(Flags & ACPI_STA_DEVICE_PRESENT) && + !(Flags & ACPI_STA_DEVICE_FUNCTIONING)) + { + /* + * Don't examine the children of the device only when the + * device is neither present nor functional. See ACPI spec, + * description of _STA for more information. + */ + return (AE_CTRL_DEPTH); + } + + /* Filter based on device HID & CID */ + + if (Info->Hid != NULL) + { + Status = AcpiUtExecute_HID (Node, &Hid); + if (Status == AE_NOT_FOUND) + { + return (AE_OK); + } + else if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + NoMatch = ACPI_STRCMP (Hid->String, Info->Hid); + ACPI_FREE (Hid); + + if (NoMatch) + { + /* + * HID does not match, attempt match within the + * list of Compatible IDs (CIDs) + */ + Status = AcpiUtExecute_CID (Node, &Cid); + if (Status == AE_NOT_FOUND) + { + return (AE_OK); + } + else if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + /* Walk the CID list */ + + Found = FALSE; + for (i = 0; i < Cid->Count; i++) + { + if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0) + { + /* Found a matching CID */ + + Found = TRUE; + break; + } + } + + ACPI_FREE (Cid); + if (!Found) + { + return (AE_OK); + } + } + } + + /* We have a valid device, invoke the user function */ + + Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, + ReturnValue); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetDevices + * + * PARAMETERS: HID - HID to search for. Can be NULL. + * UserFunction - Called when a matching object is found + * Context - Passed to user function + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object of type + * Device is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * This is a wrapper for WalkNamespace, but the callback performs + * additional filtering. Please see AcpiNsGetDeviceCallback. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetDevices ( + char *HID, + ACPI_WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_GET_DEVICES_INFO Info; + + + ACPI_FUNCTION_TRACE (AcpiGetDevices); + + + /* Parameter validation */ + + if (!UserFunction) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * We're going to call their callback from OUR callback, so we need + * to know what it is, and their context parameter. + */ + Info.Hid = HID; + Info.Context = Context; + Info.UserFunction = UserFunction; + + /* + * Lock the namespace around the walk. + * The namespace will be unlocked/locked around each call + * to the user function - since this function + * must be allowed to make Acpi calls itself. + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetDevices) + + +/******************************************************************************* + * + * FUNCTION: AcpiAttachData + * + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler for this attachment + * Data - Pointer to data to be attached + * + * RETURN: Status + * + * DESCRIPTION: Attach arbitrary data and handler to a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAttachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void *Data) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler || + !Data) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsAttachData (Node, Handler, Data); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiAttachData) + + +/******************************************************************************* + * + * FUNCTION: AcpiDetachData + * + * PARAMETERS: ObjHandle - Namespace node handle + * Handler - Handler used in call to AcpiAttachData + * + * RETURN: Status + * + * DESCRIPTION: Remove data that was previously attached to a node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDetachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsDetachData (Node, Handler); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDetachData) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetData + * + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler used in call to AttachData + * Data - Where the data is returned + * + * RETURN: Status + * + * DESCRIPTION: Retrieve data that was previously attached to a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void **Data) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler || + !Data) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsGetAttachedData (Node, Handler, Data); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetData) + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c b/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c new file mode 100644 index 00000000000..cb7aaa6f941 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c @@ -0,0 +1,776 @@ +/****************************************************************************** + * + * Module Name: nsxfname - Public interfaces to the ACPI subsystem + * ACPI Namespace oriented interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSXFNAME_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfname") + +/* Local prototypes */ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea); + + +/****************************************************************************** + * + * FUNCTION: AcpiGetHandle + * + * PARAMETERS: Parent - Object to search under (search scope). + * Pathname - Pointer to an asciiz string containing the + * name + * RetHandle - Where the return handle is returned + * + * RETURN: Status + * + * DESCRIPTION: This routine will search for a caller specified name in the + * name space. The caller can restrict the search region by + * specifying a non NULL parent. The parent value is itself a + * namespace handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + ACPI_NAMESPACE_NODE *PrefixNode = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + /* Parameter Validation */ + + if (!RetHandle || !Pathname) + { + return (AE_BAD_PARAMETER); + } + + /* Convert a parent handle to a prefix node */ + + if (Parent) + { + PrefixNode = AcpiNsValidateHandle (Parent); + if (!PrefixNode) + { + return (AE_BAD_PARAMETER); + } + } + + /* + * Valid cases are: + * 1) Fully qualified pathname + * 2) Parent + Relative pathname + * + * Error for + */ + if (AcpiNsValidRootPrefix (Pathname[0])) + { + /* Pathname is fully qualified (starts with '\') */ + + /* Special case for root-only, since we can't search for it */ + + if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH)) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); + return (AE_OK); + } + } + else if (!PrefixNode) + { + /* Relative path with null prefix is disallowed */ + + return (AE_BAD_PARAMETER); + } + + /* Find the Node and convert to a handle */ + + Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node); + if (ACPI_SUCCESS (Status)) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); + } + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetHandle) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetName + * + * PARAMETERS: Handle - Handle to be converted to a pathname + * NameType - Full pathname or single segment + * Buffer - Buffer for returned path + * + * RETURN: Pointer to a string containing the fully qualified Name. + * + * DESCRIPTION: This routine returns the fully qualified name associated with + * the Handle parameter. This and the AcpiPathnameToHandle are + * complementary functions. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetName ( + ACPI_HANDLE Handle, + UINT32 NameType, + ACPI_BUFFER *Buffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + /* Parameter validation */ + + if (NameType > ACPI_NAME_TYPE_MAX) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtValidateBuffer (Buffer); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (NameType == ACPI_FULL_PATHNAME) + { + /* Get the full pathname (From the namespace root) */ + + Status = AcpiNsHandleToPathname (Handle, Buffer); + return (Status); + } + + /* + * Wants the single segment ACPI name. + * Validate handle and convert to a namespace Node + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Just copy the ACPI name from the Node and zero terminate it */ + + ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node), + ACPI_NAME_SIZE); + ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; + Status = AE_OK; + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetName) + + +/****************************************************************************** + * + * FUNCTION: AcpiNsCopyDeviceId + * + * PARAMETERS: Dest - Pointer to the destination DEVICE_ID + * Source - Pointer to the source DEVICE_ID + * StringArea - Pointer to where to copy the dest string + * + * RETURN: Pointer to the next string area + * + * DESCRIPTION: Copy a single DEVICE_ID, including the string data. + * + ******************************************************************************/ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea) +{ + /* Create the destination DEVICE_ID */ + + Dest->String = StringArea; + Dest->Length = Source->Length; + + /* Copy actual string and return a pointer to the next string area */ + + ACPI_MEMCPY (StringArea, Source->String, Source->Length); + return (StringArea + Source->Length); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetObjectInfo + * + * PARAMETERS: Handle - Object Handle + * ReturnBuffer - Where the info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns information about an object as gleaned from the + * namespace node and possibly by running several standard + * control methods (Such as in the case of a device.) + * + * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, + * _ADR, _SxW, and _SxD methods. + * + * Note: Allocates the return buffer, must be freed by the caller. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Handle, + ACPI_DEVICE_INFO **ReturnBuffer) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_DEVICE_INFO *Info; + ACPI_DEVICE_ID_LIST *CidList = NULL; + ACPI_DEVICE_ID *Hid = NULL; + ACPI_DEVICE_ID *Uid = NULL; + char *NextIdString; + ACPI_OBJECT_TYPE Type; + ACPI_NAME Name; + UINT8 ParamCount= 0; + UINT8 Valid = 0; + UINT32 InfoSize; + UINT32 i; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Handle || !ReturnBuffer) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + /* Get the namespace node data while the namespace is locked */ + + InfoSize = sizeof (ACPI_DEVICE_INFO); + Type = Node->Type; + Name = Node->Name.Integer; + + if (Node->Type == ACPI_TYPE_METHOD) + { + ParamCount = Node->Object->Method.ParamCount; + } + + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) + { + /* + * Get extra info for ACPI Device/Processor objects only: + * Run the Device _HID, _UID, and _CID methods. + * + * Note: none of these methods are required, so they may or may + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. + */ + + /* Execute the Device._HID method */ + + Status = AcpiUtExecute_HID (Node, &Hid); + if (ACPI_SUCCESS (Status)) + { + InfoSize += Hid->Length; + Valid |= ACPI_VALID_HID; + } + + /* Execute the Device._UID method */ + + Status = AcpiUtExecute_UID (Node, &Uid); + if (ACPI_SUCCESS (Status)) + { + InfoSize += Uid->Length; + Valid |= ACPI_VALID_UID; + } + + /* Execute the Device._CID method */ + + Status = AcpiUtExecute_CID (Node, &CidList); + if (ACPI_SUCCESS (Status)) + { + /* Add size of CID strings and CID pointer array */ + + InfoSize += (CidList->ListSize - sizeof (ACPI_DEVICE_ID_LIST)); + Valid |= ACPI_VALID_CID; + } + } + + /* + * Now that we have the variable-length data, we can allocate the + * return buffer + */ + Info = ACPI_ALLOCATE_ZEROED (InfoSize); + if (!Info) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the fixed-length data */ + + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) + { + /* + * Get extra info for ACPI Device/Processor objects only: + * Run the _STA, _ADR and, SxW, and _SxD methods. + * + * Note: none of these methods are required, so they may or may + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. + */ + + /* Execute the Device._STA method */ + + Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_STA; + } + + /* Execute the Device._ADR method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, + &Info->Address); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_ADR; + } + + /* Execute the Device._SxW methods */ + + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, + Info->LowestDstates); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_SXWS; + } + + /* Execute the Device._SxD methods */ + + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, + Info->HighestDstates); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_SXDS; + } + } + + /* + * Create a pointer to the string area of the return buffer. + * Point to the end of the base ACPI_DEVICE_INFO structure. + */ + NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids); + if (CidList) + { + /* Point past the CID DEVICE_ID array */ + + NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_DEVICE_ID)); + } + + /* + * Copy the HID, UID, and CIDs to the return buffer. The variable-length + * strings are copied to the reserved area at the end of the buffer. + * + * For HID and CID, check if the ID is a PCI Root Bridge. + */ + if (Hid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId, + Hid, NextIdString); + + if (AcpiUtIsPciRootBridge (Hid->String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } + + if (Uid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId, + Uid, NextIdString); + } + + if (CidList) + { + Info->CompatibleIdList.Count = CidList->Count; + Info->CompatibleIdList.ListSize = CidList->ListSize; + + /* Copy each CID */ + + for (i = 0; i < CidList->Count; i++) + { + NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i], + &CidList->Ids[i], NextIdString); + + if (AcpiUtIsPciRootBridge (CidList->Ids[i].String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } + } + + /* Copy the fixed-length data */ + + Info->InfoSize = InfoSize; + Info->Type = Type; + Info->Name = Name; + Info->ParamCount = ParamCount; + Info->Valid = Valid; + + *ReturnBuffer = Info; + Status = AE_OK; + + +Cleanup: + if (Hid) + { + ACPI_FREE (Hid); + } + if (Uid) + { + ACPI_FREE (Uid); + } + if (CidList) + { + ACPI_FREE (CidList); + } + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallMethod + * + * PARAMETERS: Buffer - An ACPI table containing one control method + * + * RETURN: Status + * + * DESCRIPTION: Install a control method into the namespace. If the method + * name already exists in the namespace, it is overwritten. The + * input buffer must contain a valid DSDT or SSDT containing a + * single control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallMethod ( + UINT8 *Buffer) +{ + ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer); + UINT8 *AmlBuffer; + UINT8 *AmlStart; + char *Path; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *MethodObj; + ACPI_PARSE_STATE ParserState; + UINT32 AmlLength; + UINT16 Opcode; + UINT8 MethodFlags; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Buffer) + { + return (AE_BAD_PARAMETER); + } + + /* Table must be a DSDT or SSDT */ + + if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + { + return (AE_BAD_HEADER); + } + + /* First AML opcode in the table must be a control method */ + + ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER); + Opcode = AcpiPsPeekOpcode (&ParserState); + if (Opcode != AML_METHOD_OP) + { + return (AE_BAD_PARAMETER); + } + + /* Extract method information from the raw AML */ + + ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); + ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); + Path = AcpiPsGetNextNamestring (&ParserState); + MethodFlags = *ParserState.Aml++; + AmlStart = ParserState.Aml; + AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); + + /* + * Allocate resources up-front. We don't want to have to delete a new + * node from the namespace if we cannot allocate memory. + */ + AmlBuffer = ACPI_ALLOCATE (AmlLength); + if (!AmlBuffer) + { + return (AE_NO_MEMORY); + } + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + ACPI_FREE (AmlBuffer); + return (AE_NO_MEMORY); + } + + /* Lock namespace for AcpiNsLookup, we may be creating a new node */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* The lookup either returns an existing node or creates a new one */ + + Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) /* NsLookup */ + { + if (Status != AE_ALREADY_EXISTS) + { + goto ErrorExit; + } + + /* Node existed previously, make sure it is a method node */ + + if (Node->Type != ACPI_TYPE_METHOD) + { + Status = AE_TYPE; + goto ErrorExit; + } + } + + /* Copy the method AML to the local buffer */ + + ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength); + + /* Initialize the method object with the new method's information */ + + MethodObj->Method.AmlStart = AmlBuffer; + MethodObj->Method.AmlLength = AmlLength; + + MethodObj->Method.ParamCount = (UINT8) + (MethodFlags & AML_METHOD_ARG_COUNT); + + MethodObj->Method.MethodFlags = (UINT8) + (MethodFlags & ~AML_METHOD_ARG_COUNT); + + if (MethodFlags & AML_METHOD_SERIALIZED) + { + MethodObj->Method.SyncLevel = (UINT8) + ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); + } + + /* + * Now that it is complete, we can attach the new method object to + * the method Node (detaches/deletes any existing object) + */ + Status = AcpiNsAttachObject (Node, MethodObj, + ACPI_TYPE_METHOD); + + /* + * Flag indicates AML buffer is dynamic, must be deleted later. + * Must be set only after attach above. + */ + Node->Flags |= ANOBJ_ALLOCATED_BUFFER; + + /* Remove local reference to the method object */ + + AcpiUtRemoveReference (MethodObj); + return (Status); + + +ErrorExit: + + ACPI_FREE (AmlBuffer); + ACPI_FREE (MethodObj); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallMethod) diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsxfobj.c b/reactos/drivers/bus/acpi/acpica/namespace/nsxfobj.c new file mode 100644 index 00000000000..9c42a33f8b2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsxfobj.c @@ -0,0 +1,357 @@ +/******************************************************************************* + * + * Module Name: nsxfobj - Public interfaces to the ACPI subsystem + * ACPI Object oriented interfaces + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFOBJ_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfobj") + +/******************************************************************************* + * + * FUNCTION: AcpiGetType + * + * PARAMETERS: Handle - Handle of object whose type is desired + * RetType - Where the type will be placed + * + * RETURN: Status + * + * DESCRIPTION: This routine returns the type associatd with a particular handle + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetType ( + ACPI_HANDLE Handle, + ACPI_OBJECT_TYPE *RetType) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter Validation */ + + if (!RetType) + { + return (AE_BAD_PARAMETER); + } + + /* + * Special case for the predefined Root Node + * (return type ANY) + */ + if (Handle == ACPI_ROOT_OBJECT) + { + *RetType = ACPI_TYPE_ANY; + return (AE_OK); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + *RetType = Node->Type; + + + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetType) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetParent + * + * PARAMETERS: Handle - Handle of object whose parent is desired + * RetHandle - Where the parent handle will be placed + * + * RETURN: Status + * + * DESCRIPTION: Returns a handle to the parent of the object represented by + * Handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Handle, + ACPI_HANDLE *RetHandle) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_STATUS Status; + + + if (!RetHandle) + { + return (AE_BAD_PARAMETER); + } + + /* Special case for the predefined Root Node (no parent) */ + + if (Handle == ACPI_ROOT_OBJECT) + { + return (AE_NULL_ENTRY); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Get the parent entry */ + + ParentNode = AcpiNsGetParentNode (Node); + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode); + + /* Return exception if parent is null */ + + if (!ParentNode) + { + Status = AE_NULL_ENTRY; + } + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetParent) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetNextObject + * + * PARAMETERS: Type - Type of object to be searched for + * Parent - Parent object whose children we are getting + * LastChild - Previous child that was found. + * The NEXT child will be returned + * RetHandle - Where handle to the next object is placed + * + * RETURN: Status + * + * DESCRIPTION: Return the next peer object within the namespace. If Handle is + * valid, Scope is ignored. Otherwise, the first object within + * Scope is returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode = NULL; + ACPI_NAMESPACE_NODE *ChildNode = NULL; + + + /* Parameter validation */ + + if (Type > ACPI_TYPE_EXTERNAL_MAX) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* If null handle, use the parent */ + + if (!Child) + { + /* Start search at the beginning of the specified scope */ + + ParentNode = AcpiNsValidateHandle (Parent); + if (!ParentNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + else + { + /* Non-null handle, ignore the parent */ + /* Convert and validate the handle */ + + ChildNode = AcpiNsValidateHandle (Child); + if (!ChildNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* Internal function does the real work */ + + Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode); + if (!Node) + { + Status = AE_NOT_FOUND; + goto UnlockAndExit; + } + + if (RetHandle) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); + } + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetNextObject) + diff --git a/reactos/drivers/bus/acpi/acpica/osl/osl.c b/reactos/drivers/bus/acpi/acpica/osl/osl.c new file mode 100644 index 00000000000..a8c240a77d2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/osl/osl.c @@ -0,0 +1,751 @@ +/******************************************************************************* +* * +* ACPI Component Architecture Operating System Layer (OSL) for ReactOS * +* * +*******************************************************************************/ + +#include + +#define NDEBUG +#include + +#define NUM_SEMAPHORES 128 + +static PKINTERRUPT AcpiInterrupt; +static BOOLEAN AcpiInterruptHandlerRegistered = FALSE; +static ACPI_OSD_HANDLER AcpiIrqHandler = NULL; +static PVOID AcpiIrqContext = NULL; +static ULONG AcpiIrqNumber = 0; +static KDPC AcpiDpc; +static PVOID IVTVirtualAddress = NULL; + + +typedef struct semaphore_entry +{ + UINT16 MaxUnits; + UINT16 CurrentUnits; + void *OsHandle; +} SEMAPHORE_ENTRY; + +static SEMAPHORE_ENTRY AcpiGbl_Semaphores[NUM_SEMAPHORES]; + +VOID NTAPI +OslDpcStub( + IN PKDPC Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2) +{ + ACPI_OSD_EXEC_CALLBACK Routine = (ACPI_OSD_EXEC_CALLBACK)SystemArgument1; + + DPRINT("OslDpcStub()\n"); + DPRINT("Calling [%p]([%p])\n", Routine, SystemArgument2); + (*Routine)(SystemArgument2); +} + +BOOLEAN NTAPI +OslIsrStub( + PKINTERRUPT Interrupt, + PVOID ServiceContext) +{ + INT32 Status; + + Status = (*AcpiIrqHandler)(AcpiIrqContext); + + if (ACPI_SUCCESS(Status)) + return TRUE; + else + return FALSE; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine); + +ACPI_STATUS +AcpiOsInitialize (void) +{ + DPRINT("AcpiOsInitialize called\n"); + +#ifndef NDEBUG + /* Verboseness level of the acpica core */ + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = 0xFFFFFFFF; +#endif + + UINT32 i; + + for (i = 0; i < NUM_SEMAPHORES; i++) + { + AcpiGbl_Semaphores[i].OsHandle = NULL; + } + + KeInitializeDpc(&AcpiDpc, OslDpcStub, NULL); + + return AE_OK; +} + +ACPI_STATUS +AcpiOsTerminate(void) +{ + DPRINT1("AcpiOsTerminate() called\n"); + + if (AcpiInterruptHandlerRegistered) + AcpiOsRemoveInterruptHandler(AcpiIrqNumber, AcpiIrqHandler); + + return AE_OK; +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Fmt, + ...) +{ + va_list Args; + va_start (Args, Fmt); + + AcpiOsVprintf (Fmt, Args); + + va_end (Args); + return; +} + +void +AcpiOsVprintf ( + const char *Fmt, + va_list Args) +{ + vDbgPrintEx (-1, DPFLTR_ERROR_LEVEL, Fmt, Args); + return; +} + +void * +AcpiOsAllocate (ACPI_SIZE size) +{ + DPRINT("AcpiOsAllocate size %d\n",size); + return ExAllocatePool(NonPagedPool, size); +} + +void * +AcpiOsCallocate(ACPI_SIZE size) +{ + PVOID ptr = ExAllocatePool(NonPagedPool, size); + if (ptr) + memset(ptr, 0, size); + return ptr; +} + +void +AcpiOsFree(void *ptr) +{ + if (!ptr) + DPRINT1("Attempt to free null pointer!!!\n"); + ExFreePool(ptr); +} + +#ifndef ACPI_USE_LOCAL_CACHE + +void* +AcpiOsAcquireObjectHelper ( + POOL_TYPE PoolType, + SIZE_T NumberOfBytes, + ULONG Tag) +{ + void* Alloc = ExAllocatePool(PoolType, NumberOfBytes); + + /* acpica expects memory allocated from cache to be zeroed */ + RtlZeroMemory(Alloc,NumberOfBytes); + return Alloc; +} + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache) +{ + PNPAGED_LOOKASIDE_LIST Lookaside = + ExAllocatePool(NonPagedPool,sizeof(NPAGED_LOOKASIDE_LIST)); + + ExInitializeNPagedLookasideList(Lookaside, + (PALLOCATE_FUNCTION)AcpiOsAcquireObjectHelper,// custom memory allocator + NULL, + 0, + ObjectSize, + 'IPCA', + 0); + *ReturnCache = (ACPI_CACHE_T *)Lookaside; + + DPRINT("AcpiOsCreateCache %p\n", Lookaside); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsDeleteCache %p\n", Cache); + ExDeleteNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST) Cache); + ExFreePool(Cache); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsPurgeCache\n"); + /* No such functionality for LookAside lists */ + return (AE_OK); +} + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache) +{ + PNPAGED_LOOKASIDE_LIST List = (PNPAGED_LOOKASIDE_LIST)Cache; + DPRINT("AcpiOsAcquireObject from %p\n", Cache); + void* ptr = + ExAllocateFromNPagedLookasideList(List); + ASSERT(ptr); + + RtlZeroMemory(ptr,List->L.Size); + return ptr; +} + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object) +{ + DPRINT("AcpiOsReleaseObject %p from %p\n",Object, Cache); + ExFreeToNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST)Cache, + Object); + return (AE_OK); +} + +#endif + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS phys, + ACPI_SIZE length) +{ + PHYSICAL_ADDRESS Address; + + DPRINT("AcpiOsMapMemory(phys 0x%X size 0x%X)\n", (ULONG)phys, length); + if (phys == 0x0) + { + IVTVirtualAddress = ExAllocatePool(NonPagedPool, length); + return IVTVirtualAddress; + } + + Address.QuadPart = (ULONG)phys; + return MmMapIoSpace(Address, length, MmNonCached); +} + +void +AcpiOsUnmapMemory ( + void *virt, + ACPI_SIZE length) +{ + DPRINT("AcpiOsUnmapMemory()\n"); + + if (virt == 0x0) + { + ExFreePool(IVTVirtualAddress); + return; + } + MmUnmapIoSpace(virt, length); +} + +UINT32 +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context) +{ + ULONG Vector; + KIRQL DIrql; + KAFFINITY Affinity; + NTSTATUS Status; + + DPRINT("AcpiOsInstallInterruptHandler()\n"); + Vector = HalGetInterruptVector( + Internal, + 0, + InterruptNumber, + 0, + &DIrql, + &Affinity); + + AcpiIrqNumber = InterruptNumber; + AcpiIrqHandler = ServiceRoutine; + AcpiIrqContext = Context; + AcpiInterruptHandlerRegistered = TRUE; + + Status = IoConnectInterrupt( + &AcpiInterrupt, + OslIsrStub, + NULL, + NULL, + Vector, + DIrql, + DIrql, + LevelSensitive, /* FIXME: LevelSensitive or Latched? */ + TRUE, + Affinity, + FALSE); + + if (!NT_SUCCESS(Status)) + { + DPRINT("Could not connect to interrupt %d\n", Vector); + return AE_ERROR; + } + return AE_OK; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine) +{ + DPRINT("AcpiOsRemoveInterruptHandler()\n"); + if (AcpiInterruptHandlerRegistered) + { + IoDisconnectInterrupt(AcpiInterrupt); + AcpiInterrupt = NULL; + AcpiInterruptHandlerRegistered = FALSE; + } + + return AE_OK; +} + +void +AcpiOsStall (UINT32 microseconds) +{ + DPRINT1("AcpiOsStall %d\n",microseconds); + KeStallExecutionProcessor(microseconds); + return; +} + +void +AcpiOsSleep (ACPI_INTEGER milliseconds) +{ + DPRINT1("AcpiOsSleep %d\n", milliseconds); + KeStallExecutionProcessor(milliseconds*1000); + return; +} + +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadPort %p, width %d\n",Address,Width); + + switch (Width) + { + case 8: + *Value = READ_PORT_UCHAR((PUCHAR)Address); + break; + + case 16: + *Value = READ_PORT_USHORT((PUSHORT)Address); + break; + + case 32: + *Value = READ_PORT_ULONG((PULONG)Address); + break; + default: + DPRINT1("AcpiOsReadPort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWritePort %p, width %d\n",Address,Width); + switch (Width) + { + case 8: + WRITE_PORT_UCHAR((PUCHAR)Address, Value); + break; + + case 16: + WRITE_PORT_USHORT((PUSHORT)Address, Value); + break; + + case 32: + WRITE_PORT_ULONG((PULONG)Address, Value); + break; + + default: + DPRINT1("AcpiOsWritePort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadMemory %p\n", Address); + switch (Width) + { + case 8: + *Value = (*(PUCHAR)(ULONG)Address); + break; + case 16: + *Value = (*(PUSHORT)(ULONG)Address); + break; + case 32: + *Value = (*(PULONG)(ULONG)Address); + break; + + default: + DPRINT1("AcpiOsReadMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWriteMemory %p\n", Address); + switch (Width) + { + case 8: + *(PUCHAR)(ULONG)Address = Value; + break; + case 16: + *(PUSHORT)(ULONG)Address = Value; + break; + case 32: + *(PULONG)(ULONG)Address = Value; + break; + + default: + DPRINT1("AcpiOsWriteMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + void *Value, + UINT32 Width) +{ + NTSTATUS Status; + PCI_SLOT_NUMBER slot; + + if (Register == 0) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Bus; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsReadPciConfiguration, slot=0x%X, func=0x%X\n", slot.u.AsULONG, Register); + Status = HalGetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + Value, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + ACPI_INTEGER Value, + UINT32 Width) +{ + NTSTATUS Status; + ULONG buf = Value; + PCI_SLOT_NUMBER slot; + + if (Register == 0) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Bus; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsWritePciConfiguration, slot=0x%x\n", slot.u.AsULONG); + Status = HalSetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + &buf, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_SEMAPHORE *OutHandle) +{ + PFAST_MUTEX Mutex; + + Mutex = ExAllocatePool(NonPagedPool, sizeof(FAST_MUTEX)); + if (!Mutex) + return AE_NO_MEMORY; + + DPRINT("AcpiOsCreateSemaphore() at 0x%X\n", Mutex); + + ExInitializeFastMutex(Mutex); + + *OutHandle = Mutex; + return AE_OK; +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_SEMAPHORE Handle) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsDeleteSemaphore(handle 0x%X)\n", Handle); + + if (!Mutex) + return AE_BAD_PARAMETER; + + ExFreePool(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsWaitSemaphore( + ACPI_SEMAPHORE Handle, + UINT32 units, + UINT16 timeout) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + if (!Mutex || (units < 1)) + { + DPRINT("AcpiOsWaitSemaphore(handle 0x%X, units %d) Bad parameters\n", + Mutex, units); + return AE_BAD_PARAMETER; + } + + DPRINT("Waiting for semaphore %p\n", Handle); + ASSERT(Mutex); + + ExAcquireFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsSignalSemaphore %p\n",Handle); + ASSERT(Mutex); + + ExReleaseFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle) +{ + DPRINT("AcpiOsCreateLock\n"); + return (AcpiOsCreateSemaphore (1, 1, OutHandle)); +} + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle) +{ + DPRINT("AcpiOsDeleteLock %p\n", Handle); + AcpiOsDeleteSemaphore (Handle); +} + + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_HANDLE Handle) +{ + DPRINT("AcpiOsAcquireLock, %p\n", Handle); + AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); + return (0); +} + + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags) +{ + DPRINT("AcpiOsReleaseLock %p\n",Handle); + AcpiOsSignalSemaphore (Handle, 1); +} + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info) +{ + + switch (Function) + { + case ACPI_SIGNAL_FATAL: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + case ACPI_SIGNAL_BREAKPOINT: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + } + + return (AE_OK); +} + + +ACPI_THREAD_ID +AcpiOsGetThreadId (void) +{ + return (ULONG)PsGetCurrentThreadId(); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + DPRINT1("AcpiOsExecute\n"); + + KeInsertQueueDpc(&AcpiDpc, (PVOID)Function, (PVOID)Context); + +#ifdef _MULTI_THREADED + //_beginthread (Function, (unsigned) 0, Context); +#endif + + return 0; +} + +UINT64 +AcpiOsGetTimer (void) +{ + DPRINT("AcpiOsGetTimer\n"); + LARGE_INTEGER Timer; + KeQueryTickCount(&Timer); + + return Timer.QuadPart; +} + +void +AcpiOsDerivePciId( + ACPI_HANDLE rhandle, + ACPI_HANDLE chandle, + ACPI_PCI_ID **PciId) +{ + DPRINT("AcpiOsDerivePciId\n"); + return; +} + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal) +{ + if (!InitVal || !NewVal) + return AE_BAD_PARAMETER; + + *NewVal = ACPI_OS_NAME; + DPRINT("AcpiOsPredefinedOverride\n"); + return AE_OK; +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void); + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable) +{ + DPRINT("AcpiOsTableOverride\n"); + *NewTable = NULL; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface) +{ + DPRINT("AcpiOsValidateInterface\n"); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateAddress ( + UINT8 SpaceId, + ACPI_PHYSICAL_ADDRESS Address, + ACPI_SIZE Length) +{ + DPRINT("AcpiOsValidateAddress\n"); + return (AE_OK); +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void) +{ + DPRINT("AcpiOsGetRootPointer\n"); + ACPI_PHYSICAL_ADDRESS pa = 0; + + AcpiFindRootPointer(&pa); + return pa; +} diff --git a/reactos/drivers/bus/acpi/acpica/parser/psargs.c b/reactos/drivers/bus/acpi/acpica/parser/psargs.c new file mode 100644 index 00000000000..60d4a835b1b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psargs.c @@ -0,0 +1,893 @@ +/****************************************************************************** + * + * Module Name: psargs - Parse AML opcode arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PSARGS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdispat.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psargs") + +/* Local prototypes */ + +static UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState); + +static ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState); + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageLength + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Decoded package length. On completion, the AML pointer points + * past the length byte or bytes. + * + * DESCRIPTION: Decode and return a package length field. + * Note: Largest package length is 28 bits, from ACPI specification + * + ******************************************************************************/ + +static UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml = ParserState->Aml; + UINT32 PackageLength = 0; + UINT32 ByteCount; + UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */ + + + ACPI_FUNCTION_TRACE (PsGetNextPackageLength); + + + /* + * Byte 0 bits [6:7] contain the number of additional bytes + * used to encode the package length, either 0,1,2, or 3 + */ + ByteCount = (Aml[0] >> 6); + ParserState->Aml += ((ACPI_SIZE) ByteCount + 1); + + /* Get bytes 3, 2, 1 as needed */ + + while (ByteCount) + { + /* + * Final bit positions for the package length bytes: + * Byte3->[20:27] + * Byte2->[12:19] + * Byte1->[04:11] + * Byte0->[00:03] + */ + PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4)); + + ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */ + ByteCount--; + } + + /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ + + PackageLength |= (Aml[0] & ByteZeroMask); + return_UINT32 (PackageLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageEnd + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to end-of-package +1 + * + * DESCRIPTION: Get next package length and return a pointer past the end of + * the package. Consumes the package length field + * + ******************************************************************************/ + +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT32 PackageLength; + + + ACPI_FUNCTION_TRACE (PsGetNextPackageEnd); + + + /* Function below updates ParserState->Aml */ + + PackageLength = AcpiPsGetNextPackageLength (ParserState); + + return_PTR (Start + PackageLength); /* end of package */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamestring + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to the start of the name string (pointer points into + * the AML. + * + * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name + * prefix characters. Set parser state to point past the string. + * (Name is consumed from the AML.) + * + ******************************************************************************/ + +char * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT8 *End = ParserState->Aml; + + + ACPI_FUNCTION_TRACE (PsGetNextNamestring); + + + /* Point past any namestring prefix characters (backslash or carat) */ + + while (AcpiPsIsPrefixChar (*End)) + { + End++; + } + + /* Decode the path prefix character */ + + switch (*End) + { + case 0: + + /* NullName */ + + if (End == Start) + { + Start = NULL; + } + End++; + break; + + case AML_DUAL_NAME_PREFIX: + + /* Two name segments */ + + End += 1 + (2 * ACPI_NAME_SIZE); + break; + + case AML_MULTI_NAME_PREFIX_OP: + + /* Multiple name segments, 4 chars each, count in next byte */ + + End += 2 + (*(End + 1) * ACPI_NAME_SIZE); + break; + + default: + + /* Single name segment */ + + End += ACPI_NAME_SIZE; + break; + } + + ParserState->Aml = End; + return_PTR ((char *) Start); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamepath + * + * PARAMETERS: ParserState - Current parser state object + * Arg - Where the namepath will be stored + * ArgCount - If the namepath points to a control method + * the method's argument is returned here. + * PossibleMethodCall - Whether the namepath can possibly be the + * start of a method call + * + * RETURN: Status + * + * DESCRIPTION: Get next name (if method call, return # of required args). + * Names are looked up in the internal namespace to determine + * if the name represents a control method. If a method + * is found, the number of arguments to the method is returned. + * This information is critical for parsing to continue correctly. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextNamepath ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + BOOLEAN PossibleMethodCall) +{ + ACPI_STATUS Status; + char *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_OPERAND_OBJECT *MethodDesc; + ACPI_NAMESPACE_NODE *Node; + UINT8 *Start = ParserState->Aml; + + + ACPI_FUNCTION_TRACE (PsGetNextNamepath); + + + Path = AcpiPsGetNextNamestring (ParserState); + AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); + + /* Null path case is allowed, just exit */ + + if (!Path) + { + Arg->Common.Value.Name = Path; + return_ACPI_STATUS (AE_OK); + } + + /* + * Lookup the name in the internal namespace, starting with the current + * scope. We don't want to add anything new to the namespace here, + * however, so we use MODE_EXECUTE. + * Allow searching of the parent tree, but don't open a new scope - + * we just want to lookup the object (must be mode EXECUTE to perform + * the upsearch) + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + + /* + * If this name is a control method invocation, we must + * setup the method call + */ + if (ACPI_SUCCESS (Status) && + PossibleMethodCall && + (Node->Type == ACPI_TYPE_METHOD)) + { + if (WalkState->Opcode == AML_UNLOAD_OP) + { + /* + * AcpiPsGetNextNamestring has increased the AML pointer, + * so we need to restore the saved AML pointer for method call. + */ + WalkState->ParserState.Aml = Start; + WalkState->ArgCount = 1; + AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); + return_ACPI_STATUS (AE_OK); + } + + /* This name is actually a control method invocation */ + + MethodDesc = AcpiNsGetAttachedObject (Node); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path)); + + NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + if (!NameOp) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Change Arg into a METHOD CALL and attach name to it */ + + AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); + NameOp->Common.Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Common.Node = Node; + AcpiPsAppendArg (Arg, NameOp); + + if (!MethodDesc) + { + ACPI_ERROR ((AE_INFO, + "Control Method %p has no attached object", + Node)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p Args %X\n", + Node, MethodDesc->Method.ParamCount)); + + /* Get the number of arguments to expect */ + + WalkState->ArgCount = MethodDesc->Method.ParamCount; + return_ACPI_STATUS (AE_OK); + } + + /* + * Special handling if the name was not found during the lookup - + * some NotFound cases are allowed + */ + if (Status == AE_NOT_FOUND) + { + /* 1) NotFound is ok during load pass 1/2 (allow forward references) */ + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) != + ACPI_PARSE_EXECUTE) + { + Status = AE_OK; + } + + /* 2) NotFound during a CondRefOf(x) is ok by definition */ + + else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP) + { + Status = AE_OK; + } + + /* + * 3) NotFound while building a Package is ok at this point, we + * may flag as an error later if slack mode is not enabled. + * (Some ASL code depends on allowing this behavior) + */ + else if ((Arg->Common.Parent) && + ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + Status = AE_OK; + } + } + + /* Final exception check (may have been changed from code above) */ + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) + { + /* Report a control method execution error */ + + Status = AcpiDsMethodError (Status, WalkState); + } + } + + /* Save the namepath */ + + Arg->Common.Value.Name = Path; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextSimpleArg + * + * PARAMETERS: ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * Arg - Where the argument is returned + * + * RETURN: None + * + * DESCRIPTION: Get the next simple argument (constant, string, or namestring) + * + ******************************************************************************/ + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT *Arg) +{ + UINT32 Length; + UINT16 Opcode; + UINT8 *Aml = ParserState->Aml; + + + ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType); + + + switch (ArgType) + { + case ARGP_BYTEDATA: + + /* Get 1 byte from the AML stream */ + + Opcode = AML_BYTE_OP; + Arg->Common.Value.Integer = (ACPI_INTEGER) *Aml; + Length = 1; + break; + + + case ARGP_WORDDATA: + + /* Get 2 bytes from the AML stream */ + + Opcode = AML_WORD_OP; + ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 2; + break; + + + case ARGP_DWORDDATA: + + /* Get 4 bytes from the AML stream */ + + Opcode = AML_DWORD_OP; + ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 4; + break; + + + case ARGP_QWORDDATA: + + /* Get 8 bytes from the AML stream */ + + Opcode = AML_QWORD_OP; + ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 8; + break; + + + case ARGP_CHARLIST: + + /* Get a pointer to the string, point past the string */ + + Opcode = AML_STRING_OP; + Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml); + + /* Find the null terminator */ + + Length = 0; + while (Aml[Length]) + { + Length++; + } + Length++; + break; + + + case ARGP_NAME: + case ARGP_NAMESTRING: + + AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); + Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState); + return_VOID; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid ArgType %X", ArgType)); + return_VOID; + } + + AcpiPsInitOp (Arg, Opcode); + ParserState->Aml += Length; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextField + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: A newly allocated FIELD op + * + * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) + * + ******************************************************************************/ + +static ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 AmlOffset = (UINT32) + ACPI_PTR_DIFF (ParserState->Aml, + ParserState->AmlStart); + ACPI_PARSE_OBJECT *Field; + UINT16 Opcode; + UINT32 Name; + + + ACPI_FUNCTION_TRACE (PsGetNextField); + + + /* Determine field type */ + + switch (ACPI_GET8 (ParserState->Aml)) + { + default: + + Opcode = AML_INT_NAMEDFIELD_OP; + break; + + case 0x00: + + Opcode = AML_INT_RESERVEDFIELD_OP; + ParserState->Aml++; + break; + + case 0x01: + + Opcode = AML_INT_ACCESSFIELD_OP; + ParserState->Aml++; + break; + } + + /* Allocate a new field op */ + + Field = AcpiPsAllocOp (Opcode); + if (!Field) + { + return_PTR (NULL); + } + + Field->Common.AmlOffset = AmlOffset; + + /* Decode the field type */ + + switch (Opcode) + { + case AML_INT_NAMEDFIELD_OP: + + /* Get the 4-character name */ + + ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml); + AcpiPsSetName (Field, Name); + ParserState->Aml += ACPI_NAME_SIZE; + + /* Get the length which is encoded as a package length */ + + Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_INT_RESERVEDFIELD_OP: + + /* Get the length which is encoded as a package length */ + + Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_INT_ACCESSFIELD_OP: + + /* + * Get AccessType and AccessAttrib and merge into the field Op + * AccessType is first operand, AccessAttribute is second + */ + Field->Common.Value.Integer = (((UINT32) ACPI_GET8 (ParserState->Aml) << 8)); + ParserState->Aml++; + Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml); + ParserState->Aml++; + break; + + default: + + /* Opcode was set in previous switch */ + break; + } + + return_PTR (Field); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextArg + * + * PARAMETERS: WalkState - Current state + * ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * ReturnArg - Where the next arg is returned + * + * RETURN: Status, and an op object containing the next argument. + * + * DESCRIPTION: Get next argument (including complex list arguments that require + * pushing the parser stack) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextArg ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT **ReturnArg) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE_OBJECT *Prev = NULL; + ACPI_PARSE_OBJECT *Field; + UINT32 Subop; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState); + + + switch (ArgType) + { + case ARGP_BYTEDATA: + case ARGP_WORDDATA: + case ARGP_DWORDDATA: + case ARGP_CHARLIST: + case ARGP_NAME: + case ARGP_NAMESTRING: + + /* Constants, strings, and namestrings are all the same size */ + + Arg = AcpiPsAllocOp (AML_BYTE_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); + break; + + + case ARGP_PKGLENGTH: + + /* Package length, nothing returned */ + + ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); + break; + + + case ARGP_FIELDLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list */ + + while (ParserState->Aml < ParserState->PkgEnd) + { + Field = AcpiPsGetNextField (ParserState); + if (!Field) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + if (Prev) + { + Prev->Common.Next = Field; + } + else + { + Arg = Field; + } + Prev = Field; + } + + /* Skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_BYTELIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list */ + + Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Fill in bytelist data */ + + Arg->Common.Value.Size = (UINT32) + ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); + Arg->Named.Data = ParserState->Aml; + + /* Skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_TARGET: + case ARGP_SUPERNAME: + case ARGP_SIMPLENAME: + + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0 || + AcpiPsIsLeadingChar (Subop) || + AcpiPsIsPrefixChar (Subop)) + { + /* NullName or NameString */ + + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* To support SuperName arg of Unload */ + + if (WalkState->Opcode == AML_UNLOAD_OP) + { + Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1); + + /* + * If the SuperName arg of Unload is a method call, + * we have restored the AML pointer, just free this Arg + */ + if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) + { + AcpiPsFreeOp (Arg); + Arg = NULL; + } + } + else + { + Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); + } + } + else + { + /* Single complex argument, nothing returned */ + + WalkState->ArgCount = 1; + } + break; + + + case ARGP_DATAOBJ: + case ARGP_TERMARG: + + /* Single complex argument, nothing returned */ + + WalkState->ArgCount = 1; + break; + + + case ARGP_DATAOBJLIST: + case ARGP_TERMLIST: + case ARGP_OBJLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list of variable arguments, nothing returned */ + + WalkState->ArgCount = ACPI_VAR_ARGS; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid ArgType: %X", ArgType)); + Status = AE_AML_OPERAND_TYPE; + break; + } + + *ReturnArg = Arg; + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/parser/psloop.c b/reactos/drivers/bus/acpi/acpica/parser/psloop.c new file mode 100644 index 00000000000..4171e0dc6de --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psloop.c @@ -0,0 +1,1341 @@ +/****************************************************************************** + * + * Module Name: psloop - Main AML parse loop + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, (such as + * Perl) do. Parsing is done by hand rather than with a YACC generated parser + * to tightly constrain stack and dynamic memory usage. Parsing is kept + * flexible and the code fairly compact by parsing based on a list of AML + * opcode templates in AmlOpInfo[]. + */ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psloop") + +static UINT32 AcpiGbl_Depth = 0; + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiPsGetAmlOpcode ( + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiPsBuildNamedOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *UnnamedOp, + ACPI_PARSE_OBJECT **Op); + +static ACPI_STATUS +AcpiPsCreateOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT **NewOp); + +static ACPI_STATUS +AcpiPsGetArguments ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *Op); + +static ACPI_STATUS +AcpiPsCompleteOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **Op, + ACPI_STATUS Status); + +static ACPI_STATUS +AcpiPsCompleteFinalOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS Status); + +static void +AcpiPsLinkModuleCode ( + ACPI_PARSE_OBJECT *ParentOp, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId); + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetAmlOpcode + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Extract the next AML opcode from the input stream. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsGetAmlOpcode ( + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState); + + + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, + WalkState->ParserState.AmlStart); + WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState)); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + + switch (WalkState->OpInfo->Class) + { + case AML_CLASS_ASCII: + case AML_CLASS_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + WalkState->Opcode = AML_INT_NAMEPATH_OP; + WalkState->ArgTypes = ARGP_NAMESTRING; + break; + + case AML_CLASS_UNKNOWN: + + /* The opcode is unrecognized. Just skip unknown opcodes */ + + ACPI_ERROR ((AE_INFO, + "Found unknown opcode %X at AML address %p offset %X, ignoring", + WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset)); + + ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128); + + /* Assume one-byte bad opcode */ + + WalkState->ParserState.Aml++; + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + + default: + + /* Found opcode info, this is a normal opcode */ + + WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode); + WalkState->ArgTypes = WalkState->OpInfo->ParseArgs; + break; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsBuildNamedOp + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Begin of named Op in AML + * UnnamedOp - Early Op (not a named Op) + * Op - Returned Op + * + * RETURN: Status + * + * DESCRIPTION: Parse a named Op + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsBuildNamedOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *UnnamedOp, + ACPI_PARSE_OBJECT **Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState); + + + UnnamedOp->Common.Value.Arg = NULL; + UnnamedOp->Common.ArgListLength = 0; + UnnamedOp->Common.AmlOpcode = WalkState->Opcode; + + /* + * Get and append arguments until we find the node that contains + * the name (the type ARGP_NAME). + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && + (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)) + { + Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiPsAppendArg (UnnamedOp, Arg); + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } + + /* + * Make sure that we found a NAME and didn't run out of arguments + */ + if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* We know that this arg is a name, move to next arg */ + + INCREMENT_ARG_LIST (WalkState->ArgTypes); + + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = NULL; + + Status = WalkState->DescendingCallback (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog")); + return_ACPI_STATUS (Status); + } + + if (!*Op) + { + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + } + + Status = AcpiPsNextParseState (WalkState, *Op, Status); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_PENDING) + { + return_ACPI_STATUS (AE_CTRL_PARSE_PENDING); + } + return_ACPI_STATUS (Status); + } + + AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg); + AcpiGbl_Depth++; + + if ((*Op)->Common.AmlOpcode == AML_REGION_OP || + (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP) + { + /* + * Defer final parsing of an OperationRegion body, because we don't + * have enough info in the first pass to parse it correctly (i.e., + * there may be method calls within the TermArg elements of the body.) + * + * However, we must continue parsing because the opregion is not a + * standalone package -- we don't know where the end is at this point. + * + * (Length is unknown until parse of the body complete) + */ + (*Op)->Named.Data = AmlOpStart; + (*Op)->Named.Length = 0; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateOp + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Op start in AML + * NewOp - Returned Op + * + * RETURN: Status + * + * DESCRIPTION: Get Op from AML + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCreateOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT **NewOp) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *NamedOp = NULL; + ACPI_PARSE_OBJECT *ParentScope; + UINT8 ArgumentCount; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState); + + + Status = AcpiPsGetAmlOpcode (WalkState); + if (Status == AE_CTRL_PARSE_CONTINUE) + { + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + } + + /* Create Op structure and append to parent's argument list */ + + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + if (WalkState->OpInfo->Flags & AML_NAMED) + { + Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp); + AcpiPsFreeOp (Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *NewOp = NamedOp; + return_ACPI_STATUS (AE_OK); + } + + /* Not a named opcode, just allocate Op and append to parent */ + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration + * BodyLength is unknown until we parse the body + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } + + if (WalkState->Opcode == AML_BANK_FIELD_OP) + { + /* + * Backup to beginning of BankField declaration + * BodyLength is unknown until we parse the body + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } + + ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState)); + AcpiPsAppendArg (ParentScope, Op); + + if (ParentScope) + { + OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode); + if (OpInfo->Flags & AML_HAS_TARGET) + { + ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type); + if (ParentScope->Common.ArgListLength > ArgumentCount) + { + Op->Common.Flags |= ACPI_PARSEOP_TARGET; + } + } + else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) + { + Op->Common.Flags |= ACPI_PARSEOP_TARGET; + } + } + + if (WalkState->DescendingCallback != NULL) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = *NewOp = Op; + + Status = WalkState->DescendingCallback (WalkState, &Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_CTRL_PARSE_PENDING; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArguments + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Op start in AML + * Op - Current Op + * + * RETURN: Status + * + * DESCRIPTION: Get arguments for passed Op. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsGetArguments ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg = NULL; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); + + + switch (Op->Common.AmlOpcode) + { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_QWORD_OP: /* AML_QWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + + /* Fill in constant or string argument directly */ + + AcpiPsGetNextSimpleArg (&(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op); + break; + + case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + + Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + WalkState->ArgTypes = 0; + break; + + default: + /* + * Op is not a constant or string, append each argument to the Op + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount) + { + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, + WalkState->ParserState.AmlStart); + + Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Arg) + { + Arg->Common.AmlOffset = WalkState->AmlOffset; + AcpiPsAppendArg (Op, Arg); + } + + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } + + + /* + * Handle executable code at "module-level". This refers to + * executable opcodes that appear outside of any control method. + */ + if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) && + ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0)) + { + /* + * We want to skip If/Else/While constructs during Pass1 because we + * want to actually conditionally execute the code during Pass2. + * + * Except for disassembly, where we always want to walk the + * If/Else/While packages + */ + switch (Op->Common.AmlOpcode) + { + case AML_IF_OP: + case AML_ELSE_OP: + case AML_WHILE_OP: + + /* + * Currently supported module-level opcodes are: + * IF/ELSE/WHILE. These appear to be the most common, + * and easiest to support since they open an AML + * package. + */ + if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) + { + AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart, + (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart), + WalkState->OwnerId); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Pass1: Skipping an If/Else/While body\n")); + + /* Skip body of if/else/while in pass 1 */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + break; + + default: + /* + * Check for an unsupported executable opcode at module + * level. We must be in PASS1, the parent must be a SCOPE, + * The opcode class must be EXECUTE, and the opcode must + * not be an argument to another opcode. + */ + if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) && + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if ((OpInfo->Class == AML_CLASS_EXECUTE) && + (!Arg)) + { + ACPI_WARNING ((AE_INFO, + "Detected an unsupported executable opcode " + "at module-level: [0x%.4X] at table offset 0x%.4X", + Op->Common.AmlOpcode, + (UINT32) (ACPI_PTR_DIFF (AmlOpStart, + WalkState->ParserState.AmlStart) + + sizeof (ACPI_TABLE_HEADER)))); + } + } + break; + } + } + + /* Special processing for certain opcodes */ + + switch (Op->Common.AmlOpcode) + { + case AML_METHOD_OP: + /* + * Skip parsing of control method because we don't have enough + * info in the first pass to parse it correctly. + * + * Save the length and address of the body + */ + Op->Named.Data = WalkState->ParserState.Aml; + Op->Named.Length = (UINT32) + (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml); + + /* Skip body of method */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + break; + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + if ((Op->Common.Parent) && + (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) + { + /* + * Skip parsing of Buffers and Packages because we don't have + * enough info in the first pass to parse them correctly. + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = (UINT32) + (WalkState->ParserState.PkgEnd - AmlOpStart); + + /* Skip body */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + } + break; + + case AML_WHILE_OP: + + if (WalkState->ControlState) + { + WalkState->ControlState->Control.PackageEnd = + WalkState->ParserState.PkgEnd; + } + break; + + default: + + /* No action for all other opcodes */ + break; + } + + break; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsLinkModuleCode + * + * PARAMETERS: ParentOp - Parent parser op + * AmlStart - Pointer to the AML + * AmlLength - Length of executable AML + * OwnerId - OwnerId of module level code + * + * RETURN: None. + * + * DESCRIPTION: Wrap the module-level code with a method object and link the + * object to the global list. Note, the mutex field of the method + * object is used to link multiple module-level code objects. + * + ******************************************************************************/ + +static void +AcpiPsLinkModuleCode ( + ACPI_PARSE_OBJECT *ParentOp, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_OPERAND_OBJECT *MethodObj; + ACPI_NAMESPACE_NODE *ParentNode; + + + /* Get the tail of the list */ + + Prev = Next = AcpiGbl_ModuleCodeList; + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + } + + /* + * Insert the module level code into the list. Merge it if it is + * adjacent to the previous element. + */ + if (!Prev || + ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart)) + { + /* Create, initialize, and link a new temporary method object */ + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + return; + } + + if (ParentOp->Common.Node) + { + ParentNode = ParentOp->Common.Node; + } + else + { + ParentNode = AcpiGbl_RootNode; + } + + MethodObj->Method.AmlStart = AmlStart; + MethodObj->Method.AmlLength = AmlLength; + MethodObj->Method.OwnerId = OwnerId; + MethodObj->Method.Flags |= AOPOBJ_MODULE_LEVEL; + + /* + * Save the parent node in NextObject. This is cheating, but we + * don't want to expand the method object. + */ + MethodObj->Method.NextObject = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode); + + if (!Prev) + { + AcpiGbl_ModuleCodeList = MethodObj; + } + else + { + Prev->Method.Mutex = MethodObj; + } + } + else + { + Prev->Method.AmlLength += AmlLength; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteOp + * + * PARAMETERS: WalkState - Current state + * Op - Returned Op + * Status - Parse status before complete Op + * + * RETURN: Status + * + * DESCRIPTION: Complete Op + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCompleteOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **Op, + ACPI_STATUS Status) +{ + ACPI_STATUS Status2; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState); + + + /* + * Finished one argument of the containing scope + */ + WalkState->ParserState.Scope->ParseScope.ArgCount--; + + /* Close this Op (will result in parse subtree deletion) */ + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + *Op = NULL; + + switch (Status) + { + case AE_OK: + break; + + + case AE_CTRL_TRANSFER: + + /* We are about to transfer to a called method */ + + WalkState->PrevOp = NULL; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + + + case AE_CTRL_END: + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + if (*Op) + { + WalkState->Op = *Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode); + WalkState->Opcode = (*Op)->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, *Op, Status); + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + Status = AE_OK; + break; + + + case AE_CTRL_BREAK: + case AE_CTRL_CONTINUE: + + /* Pop off scopes until we find the While */ + + while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP)) + { + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } + + /* Close this iteration of the While loop */ + + WalkState->Op = *Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode); + WalkState->Opcode = (*Op)->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, *Op, Status); + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + Status = AE_OK; + break; + + + case AE_CTRL_TERMINATE: + + /* Clean up */ + do + { + if (*Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + AcpiUtDeleteGenericState ( + AcpiUtPopGenericState (&WalkState->ControlState)); + } + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (*Op); + + return_ACPI_STATUS (AE_OK); + + + default: /* All other non-AE_OK status */ + + do + { + if (*Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (*Op); + + +#if 0 + /* + * TBD: Cleanup parse ops on error + */ + if (*Op == NULL) + { + AcpiPsPopScope (ParserState, Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } +#endif + WalkState->PrevOp = NULL; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + } + + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (&(WalkState->ParserState))) + { + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op)); + } + else + { + *Op = NULL; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteFinalOp + * + * PARAMETERS: WalkState - Current state + * Op - Current Op + * Status - Current parse status before complete last + * Op + * + * RETURN: Status + * + * DESCRIPTION: Complete last Op. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCompleteFinalOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS Status) +{ + ACPI_STATUS Status2; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState); + + + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several ASL blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op)); + do + { + if (Op) + { + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + /* First error is most important */ + + (void) AcpiPsCompleteThisOp (WalkState, Op); + return_ACPI_STATUS (Status); + } + } + + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes, + &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseLoop + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = NULL; /* current op */ + ACPI_PARSE_STATE *ParserState; + UINT8 *AmlOpStart = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState); + + + if (WalkState->DescendingCallback == NULL) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + ParserState = &WalkState->ParserState; + WalkState->ArgTypes = 0; + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + + if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) + { + /* We are restarting a preempted control method */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + /* + * We must check if a predicate to an IF or WHILE statement + * was just completed + */ + if ((ParserState->Scope->ParseScope.Op) && + ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) || + (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING)) + { + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + WalkState->Op = NULL; + Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); + if (ACPI_FAILURE (Status) && + ((Status & AE_CODE_MASK) != AE_CODE_CONTROL)) + { + if (Status == AE_AML_NO_RETURN_VALUE) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Invoked method did not return a value")); + + } + + ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed")); + return_ACPI_STATUS (Status); + } + + Status = AcpiPsNextParseState (WalkState, Op, Status); + } + + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); + } + else if (WalkState->PrevOp) + { + /* We were in the middle of an op */ + + Op = WalkState->PrevOp; + WalkState->ArgTypes = WalkState->PrevArgTypes; + } + } +#endif + + /* Iterative parsing loop, while there is more AML to process: */ + + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) + { + AmlOpStart = ParserState->Aml; + if (!Op) + { + Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_PARSE_CONTINUE) + { + continue; + } + + if (Status == AE_CTRL_PARSE_PENDING) + { + Status = AE_OK; + } + + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + + Op->Common.AmlOffset = WalkState->AmlOffset; + + if (WalkState->OpInfo) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", + (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name, + Op, ParserState->Aml, Op->Common.AmlOffset)); + } + } + + + /* + * Start ArgCount at zero because we don't know if there are + * any args yet + */ + WalkState->ArgCount = 0; + + /* Are there any arguments that must be processed? */ + + if (WalkState->ArgTypes) + { + /* Get arguments */ + + Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op); + if (ACPI_FAILURE (Status)) + { + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + } + + /* Check for arguments that need to be processed */ + + if (WalkState->ArgCount) + { + /* + * There are arguments (complex ones), push Op and + * prepare for argument + */ + Status = AcpiPsPushScope (ParserState, Op, + WalkState->ArgTypes, WalkState->ArgCount); + if (ACPI_FAILURE (Status)) + { + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + + Op = NULL; + continue; + } + + /* + * All arguments have been processed -- Op is complete, + * prepare for next + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (WalkState->OpInfo->Flags & AML_NAMED) + { + if (AcpiGbl_Depth) + { + AcpiGbl_Depth--; + } + + if (Op->Common.AmlOpcode == AML_REGION_OP || + Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Completed parsing an OpRegion declaration, we now + * know the length. + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + } + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + + if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP) + { + /* + * Backup to beginning of BankField declaration + * + * BodyLength is unknown until we parse the body + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + } + } + + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } /* while ParserState->Aml */ + + Status = AcpiPsCompleteFinalOp (WalkState, Op, Status); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/parser/psopcode.c b/reactos/drivers/bus/acpi/acpica/parser/psopcode.c new file mode 100644 index 00000000000..d107c523707 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psopcode.c @@ -0,0 +1,589 @@ +/****************************************************************************** + * + * Module Name: psopcode - Parser/Interpreter opcode information table + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acopcode.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psopcode") + + +static const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6}; + + +/******************************************************************************* + * + * NAME: AcpiGbl_AmlOpInfo + * + * DESCRIPTION: Opcode table. Each entry contains + * The name is a simple ascii string, the operand specifier is an + * ascii string with one letter per operand. The letter specifies + * the operand type. + * + ******************************************************************************/ + +/* + * Summary of opcode types/flags + * + + Opcodes that have associated namespace objects (AML_NSOBJECT flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_INT_NAMEDFIELD_OP + AML_INT_METHODCALL_OP + AML_INT_NAMEPATH_OP + + Opcodes that are "namespace" opcodes (AML_NSOPCODE flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_INT_NAMEDFIELD_OP + + Opcodes that have an associated namespace node (AML_NSNODE flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_INT_NAMEDFIELD_OP + AML_INT_METHODCALL_OP + AML_INT_NAMEPATH_OP + + Opcodes that define named ACPI objects (AML_NAMED flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_INT_NAMEDFIELD_OP + + Opcodes that contain executable AML as part of the definition that + must be deferred until needed + + AML_METHOD_OP + AML_VAR_PACKAGE_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_REGION_OP + AML_BUFFER_OP + + Field opcodes + + AML_CREATE_FIELD_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + + Field "Create" opcodes + + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + + ******************************************************************************/ + + +/* + * Master Opcode information table. A summary of everything we know about each + * opcode, all in one place. + */ +const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = +{ +/*! [Begin] no source code translation */ +/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ + +/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), +/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), +/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), +/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), +/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R), +/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), +/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), +/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), +/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), + +/* Prefixed opcodes (Two-byte opcodes with a prefix op) */ + +/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), +/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE), +/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R), +/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), +/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), +/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R), +/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD | AML_DEFER), + +/* Internal opcodes that map to invalid AML opcodes */ + +/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ), +/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), +/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0), +/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), +/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL), +/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), + +/* ACPI 2.0 opcodes */ + +/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), +/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), +/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), +/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), + +/* ACPI 3.0 opcodes */ + +/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R) + +/*! [End] no source code translation !*/ +}; + +/* + * This table is directly indexed by the opcodes, and returns an + * index into the table above + */ +static const UINT8 AcpiGbl_ShortOpIndex[256] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 8 9 A B C D E F */ +/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, +/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, +/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, +/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, +/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, +/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, +/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, +/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, +/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, +/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, +/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, +/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, +/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, +/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, +/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, +}; + +/* + * This table is indexed by the second opcode of the extended opcode + * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo) + */ +static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 8 9 A B C D E F */ +/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, +/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, +/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +/* 0x88 */ 0x7C, +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeInfo + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the info about the opcode. + * + * DESCRIPTION: Find AML opcode description based on the opcode. + * NOTE: This procedure must ALWAYS return a valid pointer! + * + ******************************************************************************/ + +const ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode) +{ + ACPI_FUNCTION_NAME (PsGetOpcodeInfo); + + + /* + * Detect normal 8-bit opcode or extended 16-bit opcode + */ + if (!(Opcode & 0xFF00)) + { + /* Simple (8-bit) opcode: 0-255, can't index beyond table */ + + return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]); + } + + if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) && + (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE)) + { + /* Valid extended (16-bit) opcode */ + + return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]); + } + + /* Unknown AML opcode */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Unknown AML opcode [%4.4X]\n", Opcode)); + + return (&AcpiGbl_AmlOpInfo [_UNK]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeName + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the name of the opcode (ASCII String) + * Note: Never returns NULL. + * + * DESCRIPTION: Translate an opcode into a human-readable string + * + ******************************************************************************/ + +char * +AcpiPsGetOpcodeName ( + UINT16 Opcode) +{ +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) + + const ACPI_OPCODE_INFO *Op; + + + Op = AcpiPsGetOpcodeInfo (Opcode); + + /* Always guaranteed to return a valid pointer */ + + return (Op->Name); + +#else + return ("OpcodeName unavailable"); + +#endif +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArgumentCount + * + * PARAMETERS: OpType - Type associated with the AML opcode + * + * RETURN: Argument count + * + * DESCRIPTION: Obtain the number of expected arguments for an AML opcode + * + ******************************************************************************/ + +UINT8 +AcpiPsGetArgumentCount ( + UINT32 OpType) +{ + + if (OpType <= AML_TYPE_EXEC_6A_0T_1R) + { + return (AcpiGbl_ArgumentCount[OpType]); + } + + return (0); +} diff --git a/reactos/drivers/bus/acpi/acpica/parser/psparse.c b/reactos/drivers/bus/acpi/acpica/parser/psparse.c new file mode 100644 index 00000000000..820f54bd0ca --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psparse.c @@ -0,0 +1,791 @@ +/****************************************************************************** + * + * Module Name: psparse - Parser top level AML parse routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, + * like Perl, do. Parsing is done by hand rather than with a YACC + * generated parser to tightly constrain stack and dynamic memory + * usage. At the same time, parsing is kept flexible and the code + * fairly compact by parsing based on a list of AML opcode + * templates in AmlOpInfo[] + */ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psparse") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeSize + * + * PARAMETERS: Opcode - An AML opcode + * + * RETURN: Size of the opcode, in bytes (1 or 2) + * + * DESCRIPTION: Get the size of the current opcode. + * + ******************************************************************************/ + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode) +{ + + /* Extended (2-byte) opcode if > 255 */ + + if (Opcode > 0x00FF) + { + return (2); + } + + /* Otherwise, just a single byte opcode */ + + return (1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: ParserState - A parser state object + * + * RETURN: Next AML opcode + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml; + UINT16 Opcode; + + + Aml = ParserState->Aml; + Opcode = (UINT16) ACPI_GET8 (Aml); + + if (Opcode == AML_EXTENDED_OP_PREFIX) + { + /* Extended opcode, get the second opcode byte */ + + Aml++; + Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml)); + } + + return (Opcode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteThisOp + * + * PARAMETERS: WalkState - Current State + * Op - Op to complete + * + * RETURN: Status + * + * DESCRIPTION: Perform any cleanup at the completion of an Op. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + const ACPI_OPCODE_INFO *ParentInfo; + ACPI_PARSE_OBJECT *ReplacementOp = NULL; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op); + + + /* Check for null Op, can happen if AML code is corrupt */ + + if (!Op) + { + return_ACPI_STATUS (AE_OK); /* OK for now */ + } + + /* Delete this op and the subtree below it if asked to */ + + if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || + (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT)) + { + return_ACPI_STATUS (AE_OK); + } + + /* Make sure that we only delete this subtree */ + + if (Op->Common.Parent) + { + Prev = Op->Common.Parent->Common.Value.Arg; + if (!Prev) + { + /* Nothing more to do */ + + goto Cleanup; + } + + /* + * Check if we need to replace the operator and its subtree + * with a return value op (placeholder op) + */ + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); + + switch (ParentInfo->Class) + { + case AML_CLASS_CONTROL: + break; + + case AML_CLASS_CREATE: + + /* + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op + */ + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + break; + + case AML_CLASS_NAMED_OBJECT: + + /* + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op + */ + if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + } + else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) + { + if ((Op->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + else + { + ReplacementOp->Named.Data = Op->Named.Data; + ReplacementOp->Named.Length = Op->Named.Length; + } + } + } + break; + + default: + + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + } + + /* We must unlink this op from the parent tree */ + + if (Prev == Op) + { + /* This op is the first in the list */ + + if (ReplacementOp) + { + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Op->Common.Parent->Common.Value.Arg = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + } + else + { + Op->Common.Parent->Common.Value.Arg = Op->Common.Next; + } + } + + /* Search the parent list */ + + else while (Prev) + { + /* Traverse all siblings in the parent's argument list */ + + Next = Prev->Common.Next; + if (Next == Op) + { + if (ReplacementOp) + { + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Prev->Common.Next = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + Next = NULL; + } + else + { + Prev->Common.Next = Op->Common.Next; + Next = NULL; + } + } + Prev = Next; + } + } + + +Cleanup: + + /* Now we can actually delete the subtree rooted at Op */ + + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsNextParseState + * + * PARAMETERS: WalkState - Current state + * Op - Current parse op + * CallbackStatus - Status from previous operation + * + * RETURN: Status + * + * DESCRIPTION: Update the parser state based upon the return exception from + * the parser callback. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsNextParseState ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS CallbackStatus) +{ + ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; + ACPI_STATUS Status = AE_CTRL_PENDING; + + + ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op); + + + switch (CallbackStatus) + { + case AE_CTRL_TERMINATE: + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + ParserState->Aml = ParserState->AmlEnd; + Status = AE_CTRL_TERMINATE; + break; + + + case AE_CTRL_BREAK: + + ParserState->Aml = WalkState->AmlLastWhile; + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_BREAK; + break; + + + case AE_CTRL_CONTINUE: + + ParserState->Aml = WalkState->AmlLastWhile; + Status = AE_CTRL_CONTINUE; + break; + + + case AE_CTRL_PENDING: + + ParserState->Aml = WalkState->AmlLastWhile; + break; + +#if 0 + case AE_CTRL_SKIP: + + ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd; + Status = AE_OK; + break; +#endif + + case AE_CTRL_TRUE: + /* + * Predicate of an IF was true, and we are at the matching ELSE. + * Just close out this package + */ + ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState); + Status = AE_CTRL_PENDING; + break; + + + case AE_CTRL_FALSE: + /* + * Either an IF/WHILE Predicate was false or we encountered a BREAK + * opcode. In both cases, we do not execute the rest of the + * package; We simply close out the parent (finishing the walk of + * this branch of the tree) and continue execution at the parent + * level. + */ + ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd; + + /* In the case of a BREAK, just force a predicate (if any) to FALSE */ + + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_END; + break; + + + case AE_CTRL_TRANSFER: + + /* A method call (invocation) -- transfer control */ + + Status = AE_CTRL_TRANSFER; + WalkState->PrevOp = Op; + WalkState->MethodCallOp = Op; + WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node; + + /* Will return value (if any) be used by the caller? */ + + WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState); + break; + + + default: + + Status = CallbackStatus; + if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL) + { + Status = AE_OK; + } + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseAml + * + * PARAMETERS: WalkState - Current state + * + * + * RETURN: Status + * + * DESCRIPTION: Parse raw AML and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseAml ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_THREAD_STATE *Thread; + ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList; + ACPI_WALK_STATE *PreviousWalkState; + + + ACPI_FUNCTION_TRACE (PsParseAml); + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Entered with WalkState=%p Aml=%p size=%X\n", + WalkState, WalkState->ParserState.Aml, + WalkState->ParserState.AmlSize)); + + if (!WalkState->ParserState.Aml) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Create and initialize a new thread state */ + + Thread = AcpiUtCreateThreadState (); + if (!Thread) + { + if (WalkState->MethodDesc) + { + /* Executing a control method - additional cleanup */ + + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + } + + AcpiDsDeleteWalkState (WalkState); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + WalkState->Thread = Thread; + + /* + * If executing a method, the starting SyncLevel is this method's + * SyncLevel + */ + if (WalkState->MethodDesc) + { + WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel; + } + + AcpiDsPushWalkState (WalkState, Thread); + + /* + * This global allows the AML debugger to get a handle to the currently + * executing control method. + */ + AcpiGbl_CurrentWalkList = Thread; + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState)); + + Status = AE_OK; + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + /* + * The ParseLoop executes AML until the method terminates + * or calls another method. + */ + Status = AcpiPsParseLoop (WalkState); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Completed one call to walk loop, %s State=%p\n", + AcpiFormatException (Status), WalkState)); + + if (Status == AE_CTRL_TRANSFER) + { + /* + * A method call was detected. + * Transfer control to the called control method + */ + Status = AcpiDsCallControlMethod (Thread, WalkState, NULL); + if (ACPI_FAILURE (Status)) + { + Status = AcpiDsMethodError (Status, WalkState); + } + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + WalkState = AcpiDsGetCurrentWalkState (Thread); + continue; + } + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + } + else if ((Status != AE_OK) && (WalkState->MethodDesc)) + { + /* Either the method parse or actual execution failed */ + + ACPI_ERROR_METHOD ("Method parse/execution failed", + WalkState->MethodNode, NULL, Status); + + /* Check for possible multi-thread reentrancy problem */ + + if ((Status == AE_ALREADY_EXISTS) && + (!WalkState->MethodDesc->Method.Mutex)) + { + ACPI_INFO ((AE_INFO, + "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error", + WalkState->MethodNode->Name.Ascii)); + + /* + * Method tried to create an object twice. The probable cause is + * that the method cannot handle reentrancy. + * + * The method is marked NotSerialized, but it tried to create + * a named object, causing the second thread entrance to fail. + * Workaround this problem by marking the method permanently + * as Serialized. + */ + WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; + WalkState->MethodDesc->Method.SyncLevel = 0; + } + } + + /* We are done with this walk, move on to the parent if any */ + + WalkState = AcpiDsPopWalkState (Thread); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method or if we + * encountered an error during the method parse phase, there's lots of + * cleanup to do + */ + if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) || + (ACPI_FAILURE (Status))) + { + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiPsCleanupScope (&WalkState->ParserState); + PreviousWalkState = WalkState; + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "ReturnValue=%p, ImplicitValue=%p State=%p\n", + WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState)); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (Thread); + if (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + /* + * There is another walk state, restart it. + * If the method return value is not used by the parent, + * The object is deleted + */ + if (!PreviousWalkState->ReturnDesc) + { + /* + * In slack mode execution, if there is no return value + * we should implicitly return zero (0) as a default value. + */ + if (AcpiGbl_EnableInterpreterSlack && + !PreviousWalkState->ImplicitReturnObj) + { + PreviousWalkState->ImplicitReturnObj = + AcpiUtCreateIntegerObject ((UINT64) 0); + if (!PreviousWalkState->ImplicitReturnObj) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* Restart the calling control method */ + + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ImplicitReturnObj); + } + else + { + /* + * We have a valid return value, delete any implicit + * return value. + */ + AcpiDsClearImplicitReturn (PreviousWalkState); + + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ReturnDesc); + } + if (ACPI_SUCCESS (Status)) + { + WalkState->WalkType |= ACPI_WALK_METHOD_RESTART; + } + } + else + { + /* On error, delete any return object or implicit return */ + + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + AcpiDsClearImplicitReturn (PreviousWalkState); + } + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + else if (PreviousWalkState->CallerReturnDesc) + { + if (PreviousWalkState->ImplicitReturnObj) + { + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ImplicitReturnObj; + } + else + { + /* NULL if no return value */ + + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ReturnDesc; + } + } + else + { + if (PreviousWalkState->ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + } + if (PreviousWalkState->ImplicitReturnObj) + { + /* Caller doesn't want it, must delete it */ + + AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj); + } + } + + AcpiDsDeleteWalkState (PreviousWalkState); + } + + /* Normal exit */ + + AcpiExReleaseAllMutexes (Thread); + AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread)); + AcpiGbl_CurrentWalkList = PrevWalkList; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/parser/psscope.c b/reactos/drivers/bus/acpi/acpica/parser/psscope.c new file mode 100644 index 00000000000..979dbb15151 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psscope.c @@ -0,0 +1,374 @@ +/****************************************************************************** + * + * Module Name: psscope - Parser scope stack management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psscope") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetParentScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to an Op object + * + * DESCRIPTION: Get parent of current op being parsed + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *ParserState) +{ + + return (ParserState->Scope->ParseScope.Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsHasCompletedScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Boolean, TRUE = scope completed. + * + * DESCRIPTION: Is parsing of current argument complete? Determined by + * 1) AML pointer is at or beyond the end of the scope + * 2) The scope argument count has reached zero. + * + ******************************************************************************/ + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState) +{ + + return ((BOOLEAN) + ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || + !ParserState->Scope->ParseScope.ArgCount))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitScope + * + * PARAMETERS: ParserState - Current parser state object + * Root - the Root Node of this new scope + * + * RETURN: Status + * + * DESCRIPTION: Allocate and init a new scope object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *RootOp) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp); + + + Scope = AcpiUtCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE; + Scope->ParseScope.Op = RootOp; + Scope->ParseScope.ArgCount = ACPI_VAR_ARGS; + Scope->ParseScope.ArgEnd = ParserState->AmlEnd; + Scope->ParseScope.PkgEnd = ParserState->AmlEnd; + + ParserState->Scope = Scope; + ParserState->StartOp = RootOp; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPushScope + * + * PARAMETERS: ParserState - Current parser state object + * Op - Current op to be pushed + * RemainingArgs - List of args remaining + * ArgCount - Fixed or variable number of args + * + * RETURN: Status + * + * DESCRIPTION: Push current op to begin parsing its argument + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op); + + + Scope = AcpiUtCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE; + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; + Scope->ParseScope.ArgCount = ArgCount; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + + /* Push onto scope stack */ + + AcpiUtPushGenericState (&ParserState->Scope, Scope); + + if (ArgCount == ACPI_VAR_ARGS) + { + /* Multiple arguments */ + + Scope->ParseScope.ArgEnd = ParserState->PkgEnd; + } + else + { + /* Single argument */ + + Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPopScope + * + * PARAMETERS: ParserState - Current parser state object + * Op - Where the popped op is returned + * ArgList - Where the popped "next argument" is + * returned + * ArgCount - Count of objects in ArgList + * + * RETURN: Status + * + * DESCRIPTION: Return to parsing a previous op + * + ******************************************************************************/ + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount) +{ + ACPI_GENERIC_STATE *Scope = ParserState->Scope; + + + ACPI_FUNCTION_TRACE (PsPopScope); + + + /* Only pop the scope if there is in fact a next scope */ + + if (Scope->Common.Next) + { + Scope = AcpiUtPopGenericState (&ParserState->Scope); + + /* Return to parsing previous op */ + + *Op = Scope->ParseScope.Op; + *ArgList = Scope->ParseScope.ArgList; + *ArgCount = Scope->ParseScope.ArgCount; + ParserState->PkgEnd = Scope->ParseScope.PkgEnd; + + /* All done with this scope state structure */ + + AcpiUtDeleteGenericState (Scope); + } + else + { + /* Empty parse stack, prepare to fetch next opcode */ + + *Op = NULL; + *ArgList = 0; + *ArgCount = 0; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Popped Op %p Args %X\n", *Op, *ArgCount)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCleanupScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: None + * + * DESCRIPTION: Destroy available list, remaining stack levels, and return + * root scope + * + ******************************************************************************/ + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState); + + + if (!ParserState) + { + return_VOID; + } + + /* Delete anything on the scope stack */ + + while (ParserState->Scope) + { + Scope = AcpiUtPopGenericState (&ParserState->Scope); + AcpiUtDeleteGenericState (Scope); + } + + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/acpica/parser/pstree.c b/reactos/drivers/bus/acpi/acpica/parser/pstree.c new file mode 100644 index 00000000000..20ac405cac3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/pstree.c @@ -0,0 +1,427 @@ +/****************************************************************************** + * + * Module Name: pstree - Parser op tree manipulation/traversal/search + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __PSTREE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("pstree") + +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *op); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArg + * + * PARAMETERS: Op - Get an argument for this op + * Argn - Nth argument to get + * + * RETURN: The argument (as an Op object). NULL if argument does not exist + * + * DESCRIPTION: Get the specified op's argument. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetArg ( + ACPI_PARSE_OBJECT *Op, + UINT32 Argn) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_ENTRY (); + + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Invalid opcode or ASCII character */ + + return (NULL); + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(OpInfo->Flags & AML_HAS_ARGS)) + { + /* Has no linked argument objects */ + + return (NULL); + } + + /* Get the requested argument object */ + + Arg = Op->Common.Value.Arg; + while (Arg && Argn) + { + Argn--; + Arg = Arg->Common.Next; + } + + return (Arg); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAppendArg + * + * PARAMETERS: Op - Append an argument to this Op. + * Arg - Argument Op to append + * + * RETURN: None. + * + * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK) + * + ******************************************************************************/ + +void +AcpiPsAppendArg ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_PARSE_OBJECT *PrevArg; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Op) + { + return; + } + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Invalid opcode */ + + ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X", + Op->Common.AmlOpcode)); + return; + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(OpInfo->Flags & AML_HAS_ARGS)) + { + /* Has no linked argument objects */ + + return; + } + + /* Append the argument to the linked argument list */ + + if (Op->Common.Value.Arg) + { + /* Append to existing argument list */ + + PrevArg = Op->Common.Value.Arg; + while (PrevArg->Common.Next) + { + PrevArg = PrevArg->Common.Next; + } + PrevArg->Common.Next = Arg; + } + else + { + /* No argument list, this will be the first argument */ + + Op->Common.Value.Arg = Arg; + } + + /* Set the parent in this arg and any args linked after it */ + + while (Arg) + { + Arg->Common.Parent = Op; + Arg = Arg->Common.Next; + + Op->Common.ArgListLength++; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetDepthNext + * + * PARAMETERS: Origin - Root of subtree to search + * Op - Last (previous) Op that was found + * + * RETURN: Next Op found in the search. + * + * DESCRIPTION: Get next op in tree (walking the tree in depth-first order) + * Return NULL when reaching "origin" or when walking up from root + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *Arg; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Op) + { + return (NULL); + } + + /* Look for an argument or child */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + return (Next); + } + + /* Look for a sibling */ + + Next = Op->Common.Next; + if (Next) + { + return (Next); + } + + /* Look for a sibling of parent */ + + Parent = Op->Common.Parent; + + while (Parent) + { + Arg = AcpiPsGetArg (Parent, 0); + while (Arg && (Arg != Origin) && (Arg != Op)) + { + Arg = Arg->Common.Next; + } + + if (Arg == Origin) + { + /* Reached parent of origin, end search */ + + return (NULL); + } + + if (Parent->Common.Next) + { + /* Found sibling of parent */ + + return (Parent->Common.Next); + } + + Op = Parent; + Parent = Parent->Common.Parent; + } + + return (Next); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiPsGetChild + * + * PARAMETERS: Op - Get the child of this Op + * + * RETURN: Child Op, Null if none is found. + * + * DESCRIPTION: Get op's children or NULL if none + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Child = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Op->Common.AmlOpcode) + { + case AML_SCOPE_OP: + case AML_ELSE_OP: + case AML_DEVICE_OP: + case AML_THERMAL_ZONE_OP: + case AML_INT_METHODCALL_OP: + + Child = AcpiPsGetArg (Op, 0); + break; + + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_IF_OP: + case AML_WHILE_OP: + case AML_FIELD_OP: + + Child = AcpiPsGetArg (Op, 1); + break; + + + case AML_POWER_RES_OP: + case AML_INDEX_FIELD_OP: + + Child = AcpiPsGetArg (Op, 2); + break; + + + case AML_PROCESSOR_OP: + case AML_BANK_FIELD_OP: + + Child = AcpiPsGetArg (Op, 3); + break; + + + default: + /* All others have no children */ + break; + } + + return (Child); +} +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/parser/psutils.c b/reactos/drivers/bus/acpi/acpica/parser/psutils.c new file mode 100644 index 00000000000..42f2b015d6c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psutils.c @@ -0,0 +1,362 @@ +/****************************************************************************** + * + * Module Name: psutils - Parser miscellaneous utilities (Parser only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateScopeOp + * + * PARAMETERS: None + * + * RETURN: A new Scope object, null on failure + * + * DESCRIPTION: Create a Scope and associated namepath op with the root name + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsCreateScopeOp ( + void) +{ + ACPI_PARSE_OBJECT *ScopeOp; + + + ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP); + if (!ScopeOp) + { + return (NULL); + } + + ScopeOp->Named.Name = ACPI_ROOT_NAME; + return (ScopeOp); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitOp + * + * PARAMETERS: Op - A newly allocated Op object + * Opcode - Opcode to store in the Op + * + * RETURN: None + * + * DESCRIPTION: Initialize a parse (Op) object + * + ******************************************************************************/ + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode) +{ + ACPI_FUNCTION_ENTRY (); + + + Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER; + Op->Common.AmlOpcode = Opcode; + + ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName, + (AcpiPsGetOpcodeInfo (Opcode))->Name, + sizeof (Op->Common.AmlOpName))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAllocOp + * + * PARAMETERS: Opcode - Opcode that will be stored in the new Op + * + * RETURN: Pointer to the new Op, null on failure + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode. A cache of opcodes is available for the pure + * GENERIC_OP, since this is by far the most commonly used. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsAllocOp ( + UINT16 Opcode) +{ + ACPI_PARSE_OBJECT *Op; + const ACPI_OPCODE_INFO *OpInfo; + UINT8 Flags = ACPI_PARSEOP_GENERIC; + + + ACPI_FUNCTION_ENTRY (); + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + + /* Determine type of ParseOp required */ + + if (OpInfo->Flags & AML_DEFER) + { + Flags = ACPI_PARSEOP_DEFERRED; + } + else if (OpInfo->Flags & AML_NAMED) + { + Flags = ACPI_PARSEOP_NAMED; + } + else if (Opcode == AML_INT_BYTELIST_OP) + { + Flags = ACPI_PARSEOP_BYTELIST; + } + + /* Allocate the minimum required size object */ + + if (Flags == ACPI_PARSEOP_GENERIC) + { + /* The generic op (default) is by far the most common (16 to 1) */ + + Op = AcpiOsAcquireObject (AcpiGbl_PsNodeCache); + } + else + { + /* Extended parseop */ + + Op = AcpiOsAcquireObject (AcpiGbl_PsNodeExtCache); + } + + /* Initialize the Op */ + + if (Op) + { + AcpiPsInitOp (Op, Opcode); + Op->Common.Flags = Flags; + } + + return (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFreeOp + * + * PARAMETERS: Op - Op to be freed + * + * RETURN: None. + * + * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list + * or actually free it. + * + ******************************************************************************/ + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_FUNCTION_NAME (PsFreeOp); + + + if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", Op)); + } + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op); + } + else + { + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op); + } +} + + +/******************************************************************************* + * + * FUNCTION: Utility functions + * + * DESCRIPTION: Low level character and object functions + * + ******************************************************************************/ + + +/* + * Is "c" a namestring lead character? + */ +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c) +{ + return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z'))); +} + + +/* + * Is "c" a namestring prefix character? + */ +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c) +{ + return ((BOOLEAN) (c == '\\' || c == '^')); +} + + +/* + * Get op's name (4-byte name segment) or 0 if unnamed + */ +UINT32 +AcpiPsGetName ( + ACPI_PARSE_OBJECT *Op) +{ + + /* The "generic" object has no name associated with it */ + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + return (0); + } + + /* Only the "Extended" parse objects have a name */ + + return (Op->Named.Name); +} + + +/* + * Set op's name + */ +void +AcpiPsSetName ( + ACPI_PARSE_OBJECT *Op, + UINT32 name) +{ + + /* The "generic" object has no name associated with it */ + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + return; + } + + Op->Named.Name = name; +} + diff --git a/reactos/drivers/bus/acpi/acpica/parser/pswalk.c b/reactos/drivers/bus/acpi/acpica/parser/pswalk.c new file mode 100644 index 00000000000..d8d5f5e6f21 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/pswalk.c @@ -0,0 +1,193 @@ +/****************************************************************************** + * + * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("pswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseTree + * + * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete + * + * RETURN: None + * + * DESCRIPTION: Delete a portion of or an entire parse tree. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *SubtreeRoot) +{ + ACPI_PARSE_OBJECT *Op = SubtreeRoot; + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot); + + + /* Visit all nodes in the subtree */ + + while (Op) + { + /* Check if we are not ascending */ + + if (Op != Parent) + { + /* Look for an argument or child of the current op */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + /* Still going downward in tree (Op is not completed yet) */ + + Op = Next; + continue; + } + } + + /* No more children, this Op is complete. */ + + Next = Op->Common.Next; + Parent = Op->Common.Parent; + + AcpiPsFreeOp (Op); + + /* If we are back to the starting point, the walk is complete. */ + + if (Op == SubtreeRoot) + { + return_VOID; + } + if (Next) + { + Op = Next; + } + else + { + Op = Parent; + } + } + + return_VOID; +} diff --git a/reactos/drivers/bus/acpi/acpica/parser/psxface.c b/reactos/drivers/bus/acpi/acpica/parser/psxface.c new file mode 100644 index 00000000000..1bf36e01c93 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psxface.c @@ -0,0 +1,510 @@ +/****************************************************************************** + * + * Module Name: psxface - Parser external interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PSXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psxface") + +/* Local Prototypes */ + +static void +AcpiPsStartTrace ( + ACPI_EVALUATE_INFO *Info); + +static void +AcpiPsStopTrace ( + ACPI_EVALUATE_INFO *Info); + +static void +AcpiPsUpdateParameterList ( + ACPI_EVALUATE_INFO *Info, + UINT16 Action); + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugTrace + * + * PARAMETERS: MethodName - Valid ACPI name string + * DebugLevel - Optional level mask. 0 to use default + * DebugLayer - Optional layer mask. 0 to use default + * Flags - bit 1: one shot(1) or persistent(0) + * + * RETURN: Status + * + * DESCRIPTION: External interface to enable debug tracing during control + * method execution + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDebugTrace ( + char *Name, + UINT32 DebugLevel, + UINT32 DebugLayer, + UINT32 Flags) +{ + ACPI_STATUS Status; + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* TBDs: Validate name, allow full path or just nameseg */ + + AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name); + AcpiGbl_TraceFlags = Flags; + + if (DebugLevel) + { + AcpiGbl_TraceDbgLevel = DebugLevel; + } + if (DebugLayer) + { + AcpiGbl_TraceDbgLayer = DebugLayer; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsStartTrace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Start control method execution trace + * + ******************************************************************************/ + +static void +AcpiPsStartTrace ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return; + } + + if ((!AcpiGbl_TraceMethodName) || + (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer)) + { + goto Exit; + } + + AcpiGbl_OriginalDbgLevel = AcpiDbgLevel; + AcpiGbl_OriginalDbgLayer = AcpiDbgLayer; + + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = ACPI_UINT32_MAX; + + if (AcpiGbl_TraceDbgLevel) + { + AcpiDbgLevel = AcpiGbl_TraceDbgLevel; + } + if (AcpiGbl_TraceDbgLayer) + { + AcpiDbgLayer = AcpiGbl_TraceDbgLayer; + } + + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsStopTrace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Stop control method execution trace + * + ******************************************************************************/ + +static void +AcpiPsStopTrace ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return; + } + + if ((!AcpiGbl_TraceMethodName) || + (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer)) + { + goto Exit; + } + + /* Disable further tracing if type is one-shot */ + + if (AcpiGbl_TraceFlags & 1) + { + AcpiGbl_TraceMethodName = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; + } + + AcpiDbgLevel = AcpiGbl_OriginalDbgLevel; + AcpiDbgLayer = AcpiGbl_OriginalDbgLayer; + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsExecuteMethod + * + * PARAMETERS: Info - Method info block, contains: + * Node - Method Node to execute + * ObjDesc - Method object + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * PassNumber - Parse or execute pass + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsExecuteMethod ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (PsExecuteMethod); + + + /* Validate the Info and method Node */ + + if (!Info || !Info->ResolvedNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The caller "owns" the parameters, so give each one an extra reference + */ + AcpiPsUpdateParameterList (Info, REF_INCREMENT); + + /* Begin tracing if requested */ + + AcpiPsStartTrace (Info); + + /* + * Execute the method. Performs parse simultaneously + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", + Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc)); + + /* Create and init a Root Node */ + + Op = AcpiPsCreateScopeOp (); + if (!Op) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create and initialize a new walk state */ + + Info->PassNumber = ACPI_IMODE_EXECUTE; + WalkState = AcpiDsCreateWalkState ( + Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode, + Info->ObjDesc->Method.AmlStart, + Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + if (Info->ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL) + { + WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL; + } + + /* Invoke an internal method if necessary */ + + if (Info->ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + { + Status = Info->ObjDesc->Method.Extra.Implementation (WalkState); + Info->ReturnObject = WalkState->ReturnDesc; + + /* Cleanup states */ + + AcpiDsScopeStackClear (WalkState); + AcpiPsCleanupScope (&WalkState->ParserState); + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* + * Start method evaluation with an implicit return of zero. This is done + * for Windows compatibility. + */ + if (AcpiGbl_EnableInterpreterSlack) + { + WalkState->ImplicitReturnObj = + AcpiUtCreateIntegerObject ((UINT64) 0); + if (!WalkState->ImplicitReturnObj) + { + Status = AE_NO_MEMORY; + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + } + + /* Parse the AML */ + + Status = AcpiPsParseAml (WalkState); + + /* WalkState was deleted by ParseAml */ + +Cleanup: + AcpiPsDeleteParseTree (Op); + + /* End optional tracing */ + + AcpiPsStopTrace (Info); + + /* Take away the extra reference that we gave the parameters above */ + + AcpiPsUpdateParameterList (Info, REF_DECREMENT); + + /* Exit now if error above */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * If the method has returned an object, signal this to the caller with + * a control exception code + */ + if (Info->ReturnObject) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", + Info->ReturnObject)); + ACPI_DUMP_STACK_ENTRY (Info->ReturnObject); + + Status = AE_CTRL_RETURN_VALUE; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsUpdateParameterList + * + * PARAMETERS: Info - See ACPI_EVALUATE_INFO + * (Used: ParameterType and Parameters) + * Action - Add or Remove reference + * + * RETURN: Status + * + * DESCRIPTION: Update reference count on all method parameter objects + * + ******************************************************************************/ + +static void +AcpiPsUpdateParameterList ( + ACPI_EVALUATE_INFO *Info, + UINT16 Action) +{ + UINT32 i; + + + if (Info->Parameters) + { + /* Update reference count for each parameter */ + + for (i = 0; Info->Parameters[i]; i++) + { + /* Ignore errors, just do them all */ + + (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action); + } + } +} + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsaddr.c b/reactos/drivers/bus/acpi/acpica/resources/rsaddr.c new file mode 100644 index 00000000000..f2f3c4421f6 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsaddr.c @@ -0,0 +1,479 @@ +/******************************************************************************* + * + * Module Name: rsaddr - Address resource descriptors (16/32/64) + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSADDR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsaddr") + + +/******************************************************************************* + * + * AcpiRsConvertAddress16 - All WORD (16-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16, + sizeof (AML_RESOURCE_ADDRESS16), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Granularity), + AML_OFFSET (Address16.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS16)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32, + sizeof (AML_RESOURCE_ADDRESS32), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Granularity), + AML_OFFSET (Address32.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS32)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64, + sizeof (AML_RESOURCE_ADDRESS64), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Granularity), + AML_OFFSET (Address64.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS64)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* Revision ID */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID), + AML_OFFSET (ExtAddress64.RevisionID), + 1}, + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + * Type-Specific Attribute + */ + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Granularity), + AML_OFFSET (ExtAddress64.Granularity), + 6} +}; + + +/******************************************************************************* + * + * AcpiRsConvertGeneralFlags - Flags common to all address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)}, + + /* Resource Type (Memory, Io, BusNumber, etc.) */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType), + AML_OFFSET (Address.ResourceType), + 1}, + + /* General Flags - Consume, Decode, MinFixed, MaxFixed */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer), + AML_OFFSET (Address.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode), + AML_OFFSET (Address.Flags), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed), + AML_OFFSET (Address.Flags), + 2}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed), + AML_OFFSET (Address.Flags), + 3} +}; + + +/******************************************************************************* + * + * AcpiRsConvertMemFlags - Flags common to Memory address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)}, + + /* Memory-specific flags */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect), + AML_OFFSET (Address.SpecificFlags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching), + AML_OFFSET (Address.SpecificFlags), + 1}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType), + AML_OFFSET (Address.SpecificFlags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation), + AML_OFFSET (Address.SpecificFlags), + 5} +}; + + +/******************************************************************************* + * + * AcpiRsConvertIoFlags - Flags common to I/O address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)}, + + /* I/O-specific flags */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType), + AML_OFFSET (Address.SpecificFlags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation), + AML_OFFSET (Address.SpecificFlags), + 4}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType), + AML_OFFSET (Address.SpecificFlags), + 5} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetAddressCommon + * + * PARAMETERS: Resource - Pointer to the internal resource struct + * Aml - Pointer to the AML resource descriptor + * + * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise + * + * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor + * to an internal resource descriptor + * + ******************************************************************************/ + +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Validate the Resource Type */ + + if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0)) + { + return (FALSE); + } + + /* Get the Resource Type and General Flags */ + + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags); + + /* Get the Type-Specific Flags (Memory and I/O descriptors only) */ + + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) + { + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags); + } + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) + { + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags); + } + else + { + /* Generic resource type, just grab the TypeSpecific byte */ + + Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags; + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetAddressCommon + * + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * Resource - Pointer to the internal resource struct + * + * RETURN: None + * + * DESCRIPTION: Convert common flag fields from a resource descriptor to an + * AML descriptor + * + ******************************************************************************/ + +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Set the Resource Type and General Flags */ + + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags); + + /* Set the Type-Specific Flags (Memory and I/O descriptors only) */ + + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) + { + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags); + } + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) + { + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags); + } + else + { + /* Generic resource type, just copy the TypeSpecific byte */ + + Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific; + } +} + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rscalc.c b/reactos/drivers/bus/acpi/acpica/resources/rscalc.c new file mode 100644 index 00000000000..76aa44ff839 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rscalc.c @@ -0,0 +1,745 @@ +/******************************************************************************* + * + * Module Name: rscalc - Calculate stream and list lengths + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSCALC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rscalc") + + +/* Local prototypes */ + +static UINT8 +AcpiRsCountSetBits ( + UINT16 BitField); + +static ACPI_RS_LENGTH +AcpiRsStructOptionLength ( + ACPI_RESOURCE_SOURCE *ResourceSource); + +static UINT32 +AcpiRsStreamOptionLength ( + UINT32 ResourceLength, + UINT32 MinimumTotalLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCountSetBits + * + * PARAMETERS: BitField - Field in which to count bits + * + * RETURN: Number of bits set within the field + * + * DESCRIPTION: Count the number of bits set in a resource field. Used for + * (Short descriptor) interrupt and DMA lists. + * + ******************************************************************************/ + +static UINT8 +AcpiRsCountSetBits ( + UINT16 BitField) +{ + UINT8 BitsSet; + + + ACPI_FUNCTION_ENTRY (); + + + for (BitsSet = 0; BitField; BitsSet++) + { + /* Zero the least significant bit that is set */ + + BitField &= (UINT16) (BitField - 1); + } + + return (BitsSet); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStructOptionLength + * + * PARAMETERS: ResourceSource - Pointer to optional descriptor field + * + * RETURN: Status + * + * DESCRIPTION: Common code to handle optional ResourceSourceIndex and + * ResourceSource fields in some Large descriptors. Used during + * list-to-stream conversion + * + ******************************************************************************/ + +static ACPI_RS_LENGTH +AcpiRsStructOptionLength ( + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * If the ResourceSource string is valid, return the size of the string + * (StringLength includes the NULL terminator) plus the size of the + * ResourceSourceIndex (1). + */ + if (ResourceSource->StringPtr) + { + return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1)); + } + + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStreamOptionLength + * + * PARAMETERS: ResourceLength - Length from the resource header + * MinimumTotalLength - Minimum length of this resource, before + * any optional fields. Includes header size + * + * RETURN: Length of optional string (0 if no string present) + * + * DESCRIPTION: Common code to handle optional ResourceSourceIndex and + * ResourceSource fields in some Large descriptors. Used during + * stream-to-list conversion + * + ******************************************************************************/ + +static UINT32 +AcpiRsStreamOptionLength ( + UINT32 ResourceLength, + UINT32 MinimumAmlResourceLength) +{ + UINT32 StringLength = 0; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * The ResourceSourceIndex and ResourceSource are optional elements of some + * Large-type resource descriptors. + */ + + /* + * If the length of the actual resource descriptor is greater than the ACPI + * spec-defined minimum length, it means that a ResourceSourceIndex exists + * and is followed by a (required) null terminated string. The string length + * (including the null terminator) is the resource length minus the minimum + * length, minus one byte for the ResourceSourceIndex itself. + */ + if (ResourceLength > MinimumAmlResourceLength) + { + /* Compute the length of the optional string */ + + StringLength = ResourceLength - MinimumAmlResourceLength - 1; + } + + /* + * Round the length up to a multiple of the native word in order to + * guarantee that the entire resource descriptor is native word aligned + */ + return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetAmlLength + * + * PARAMETERS: Resource - Pointer to the resource linked list + * SizeNeeded - Where the required size is returned + * + * RETURN: Status + * + * DESCRIPTION: Takes a linked list of internal resource descriptors and + * calculates the size buffer needed to hold the corresponding + * external resource byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetAmlLength ( + ACPI_RESOURCE *Resource, + ACPI_SIZE *SizeNeeded) +{ + ACPI_SIZE AmlSizeNeeded = 0; + ACPI_RS_LENGTH TotalSize; + + + ACPI_FUNCTION_TRACE (RsGetAmlLength); + + + /* Traverse entire list of internal resource descriptors */ + + while (Resource) + { + /* Validate the descriptor type */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* Get the base size of the (external stream) resource descriptor */ + + TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type]; + + /* + * Augment the base size for descriptors with optional and/or + * variable-length fields + */ + switch (Resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + + /* Length can be 3 or 2 */ + + if (Resource->Data.Irq.DescriptorLength == 2) + { + TotalSize--; + } + break; + + + case ACPI_RESOURCE_TYPE_START_DEPENDENT: + + /* Length can be 1 or 0 */ + + if (Resource->Data.Irq.DescriptorLength == 0) + { + TotalSize--; + } + break; + + + case ACPI_RESOURCE_TYPE_VENDOR: + /* + * Vendor Defined Resource: + * For a Vendor Specific resource, if the Length is between 1 and 7 + * it will be created as a Small Resource data type, otherwise it + * is a Large Resource data type. + */ + if (Resource->Data.Vendor.ByteLength > 7) + { + /* Base size of a Large resource descriptor */ + + TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER); + } + + /* Add the size of the vendor-specific data */ + + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + Resource->Data.Vendor.ByteLength); + break; + + + case ACPI_RESOURCE_TYPE_END_TAG: + /* + * End Tag: + * We are done -- return the accumulated total size. + */ + *SizeNeeded = AmlSizeNeeded + TotalSize; + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + + + case ACPI_RESOURCE_TYPE_ADDRESS16: + /* + * 16-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address16.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_ADDRESS32: + /* + * 32-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address32.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_ADDRESS64: + /* + * 64-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address64.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + /* + * Extended IRQ Resource: + * Add the size of each additional optional interrupt beyond the + * required 1 (4 bytes for each UINT32 interrupt number) + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + + ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) + + + /* Add the size of the optional ResourceSource info */ + + AcpiRsStructOptionLength ( + &Resource->Data.ExtendedIrq.ResourceSource)); + break; + + + default: + break; + } + + /* Update the total */ + + AmlSizeNeeded += TotalSize; + + /* Point to the next object */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + /* Did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetListLength + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * AmlBufferLength - Size of AmlBuffer + * SizeNeeded - Where the size needed is returned + * + * RETURN: Status + * + * DESCRIPTION: Takes an external resource byte stream and calculates the size + * buffer needed to hold the corresponding internal resource + * descriptor linked list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetListLength ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + ACPI_SIZE *SizeNeeded) +{ + ACPI_STATUS Status; + UINT8 *EndAml; + UINT8 *Buffer; + UINT32 BufferSize; + UINT16 Temp16; + UINT16 ResourceLength; + UINT32 ExtraStructBytes; + UINT8 ResourceIndex; + UINT8 MinimumAmlResourceLength; + + + ACPI_FUNCTION_TRACE (RsGetListLength); + + + *SizeNeeded = 0; + EndAml = AmlBuffer + AmlBufferLength; + + /* Walk the list of AML resource descriptors */ + + while (AmlBuffer < EndAml) + { + /* Validate the Resource Type and Resource Length */ + + Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the resource length and base (minimum) AML size */ + + ResourceLength = AcpiUtGetResourceLength (AmlBuffer); + MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; + + /* + * Augment the size for descriptors with optional + * and/or variable length fields + */ + ExtraStructBytes = 0; + Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer); + + switch (AcpiUtGetResourceType (AmlBuffer)) + { + case ACPI_RESOURCE_NAME_IRQ: + /* + * IRQ Resource: + * Get the number of bits set in the 16-bit IRQ mask + */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + ExtraStructBytes = AcpiRsCountSetBits (Temp16); + break; + + + case ACPI_RESOURCE_NAME_DMA: + /* + * DMA Resource: + * Get the number of bits set in the 8-bit DMA mask + */ + ExtraStructBytes = AcpiRsCountSetBits (*Buffer); + break; + + + case ACPI_RESOURCE_NAME_VENDOR_SMALL: + case ACPI_RESOURCE_NAME_VENDOR_LARGE: + /* + * Vendor Resource: + * Get the number of vendor data bytes + */ + ExtraStructBytes = ResourceLength; + break; + + + case ACPI_RESOURCE_NAME_END_TAG: + /* + * End Tag: + * This is the normal exit, add size of EndTag + */ + *SizeNeeded += ACPI_RS_SIZE_MIN; + return_ACPI_STATUS (AE_OK); + + + case ACPI_RESOURCE_NAME_ADDRESS32: + case ACPI_RESOURCE_NAME_ADDRESS16: + case ACPI_RESOURCE_NAME_ADDRESS64: + /* + * Address Resource: + * Add the size of the optional ResourceSource + */ + ExtraStructBytes = AcpiRsStreamOptionLength ( + ResourceLength, MinimumAmlResourceLength); + break; + + + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: + /* + * Extended IRQ Resource: + * Using the InterruptTableLength, add 4 bytes for each additional + * interrupt. Note: at least one interrupt is required and is + * included in the minimum descriptor size (reason for the -1) + */ + ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32); + + /* Add the size of the optional ResourceSource */ + + ExtraStructBytes += AcpiRsStreamOptionLength ( + ResourceLength - ExtraStructBytes, MinimumAmlResourceLength); + break; + + + default: + break; + } + + /* + * Update the required buffer size for the internal descriptor structs + * + * Important: Round the size up for the appropriate alignment. This + * is a requirement on IA64. + */ + BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] + + ExtraStructBytes; + BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); + + *SizeNeeded += BufferSize; + + ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, + "Type %.2X, AmlLength %.2X InternalLength %.2X\n", + AcpiUtGetResourceType (AmlBuffer), + AcpiUtGetDescriptorLength (AmlBuffer), BufferSize)); + + /* + * Point to the next resource within the AML stream using the length + * contained in the resource descriptor header + */ + AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer); + } + + /* Did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPciRoutingTableLength + * + * PARAMETERS: PackageObject - Pointer to the package object + * BufferSizeNeeded - UINT32 pointer of the size buffer + * needed to properly return the + * parsed data + * + * RETURN: Status + * + * DESCRIPTION: Given a package representing a PCI routing table, this + * calculates the size of the corresponding linked list of + * descriptions. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_SIZE *BufferSizeNeeded) +{ + UINT32 NumberOfElements; + ACPI_SIZE TempSizeNeeded = 0; + ACPI_OPERAND_OBJECT **TopObjectList; + UINT32 Index; + ACPI_OPERAND_OBJECT *PackageElement; + ACPI_OPERAND_OBJECT **SubObjectList; + BOOLEAN NameFound; + UINT32 TableIndex; + + + ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength); + + + NumberOfElements = PackageObject->Package.Count; + + /* + * Calculate the size of the return buffer. + * The base size is the number of elements * the sizes of the + * structures. Additional space for the strings is added below. + * The minus one is to subtract the size of the UINT8 Source[1] + * member because it is added below. + * + * But each PRT_ENTRY structure has a pointer to a string and + * the size of that string must be found. + */ + TopObjectList = PackageObject->Package.Elements; + + for (Index = 0; Index < NumberOfElements; Index++) + { + /* Dereference the sub-package */ + + PackageElement = *TopObjectList; + + /* We must have a valid Package object */ + + if (!PackageElement || + (PackageElement->Common.Type != ACPI_TYPE_PACKAGE)) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * The SubObjectList will now point to an array of the + * four IRQ elements: Address, Pin, Source and SourceIndex + */ + SubObjectList = PackageElement->Package.Elements; + + /* Scan the IrqTableElements for the Source Name String */ + + NameFound = FALSE; + + for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) + { + if (*SubObjectList && /* Null object allowed */ + + ((ACPI_TYPE_STRING == + (*SubObjectList)->Common.Type) || + + ((ACPI_TYPE_LOCAL_REFERENCE == + (*SubObjectList)->Common.Type) && + + ((*SubObjectList)->Reference.Class == + ACPI_REFCLASS_NAME)))) + { + NameFound = TRUE; + } + else + { + /* Look at the next element */ + + SubObjectList++; + } + } + + TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); + + /* Was a String type found? */ + + if (NameFound) + { + if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING) + { + /* + * The length String.Length field does not include the + * terminating NULL, add 1 + */ + TempSizeNeeded += ((ACPI_SIZE) + (*SubObjectList)->String.Length + 1); + } + else + { + TempSizeNeeded += AcpiNsGetPathnameLength ( + (*SubObjectList)->Reference.Node); + } + } + else + { + /* + * If no name was found, then this is a NULL, which is + * translated as a UINT32 zero. + */ + TempSizeNeeded += sizeof (UINT32); + } + + /* Round up the size since each element must be aligned */ + + TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded); + + /* Point to the next ACPI_OPERAND_OBJECT */ + + TopObjectList++; + } + + /* + * Add an extra element to the end of the list, essentially a + * NULL terminator + */ + *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE); + return_ACPI_STATUS (AE_OK); +} diff --git a/reactos/drivers/bus/acpi/acpica/resources/rscreate.c b/reactos/drivers/bus/acpi/acpica/resources/rscreate.c new file mode 100644 index 00000000000..e9c840b64e5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rscreate.c @@ -0,0 +1,533 @@ +/******************************************************************************* + * + * Module Name: rscreate - Create resource lists/tables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSCREATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rscreate") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateResourceList + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code + * If OutputBuffer is not large enough, OutputBufferLength + * indicates how large OutputBuffer should be, else it + * indicates how may UINT8 elements of OutputBuffer are valid. + * + * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method + * execution and parses the stream to create a linked list + * of device resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *AmlBuffer, + ACPI_BUFFER *OutputBuffer) +{ + + ACPI_STATUS Status; + UINT8 *AmlStart; + ACPI_SIZE ListSizeNeeded = 0; + UINT32 AmlBufferLength; + void *Resource; + + + ACPI_FUNCTION_TRACE (RsCreateResourceList); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", + AmlBuffer)); + + /* Params already validated, so we don't re-validate here */ + + AmlBufferLength = AmlBuffer->Buffer.Length; + AmlStart = AmlBuffer->Buffer.Pointer; + + /* + * Pass the AmlBuffer into a module that can calculate + * the buffer size needed for the linked list + */ + Status = AcpiRsGetListLength (AmlStart, AmlBufferLength, + &ListSizeNeeded); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", + Status, (UINT32) ListSizeNeeded)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Do the conversion */ + + Resource = OutputBuffer->Pointer; + Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength, + AcpiRsConvertAmlToResources, &Resource); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreatePciRoutingTable + * + * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT + * package + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. + * If the OutputBuffer is too small, the error will be + * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a + * linked list of PCI interrupt descriptions + * + * NOTE: It is the caller's responsibility to ensure that the start of the + * output buffer is aligned properly (if necessary). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_BUFFER *OutputBuffer) +{ + UINT8 *Buffer; + ACPI_OPERAND_OBJECT **TopObjectList; + ACPI_OPERAND_OBJECT **SubObjectList; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_SIZE BufferSizeNeeded = 0; + UINT32 NumberOfElements; + UINT32 Index; + ACPI_PCI_ROUTING_TABLE *UserPrt; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_BUFFER PathBuffer; + + + ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); + + + /* Params already validated, so we don't re-validate here */ + + /* Get the required buffer length */ + + Status = AcpiRsGetPciRoutingTableLength (PackageObject, + &BufferSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", + (UINT32) BufferSizeNeeded)); + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a + * package that in turn contains an ACPI_INTEGER Address, a UINT8 Pin, + * a Name, and a UINT8 SourceIndex. + */ + TopObjectList = PackageObject->Package.Elements; + NumberOfElements = PackageObject->Package.Count; + Buffer = OutputBuffer->Pointer; + UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); + + for (Index = 0; Index < NumberOfElements; Index++) + { + /* + * Point UserPrt past this current structure + * + * NOTE: On the first iteration, UserPrt->Length will + * be zero because we cleared the return buffer earlier + */ + Buffer += UserPrt->Length; + UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); + + /* + * Fill in the Length field with the information we have at this point. + * The minus four is to subtract the size of the UINT8 Source[4] member + * because it is added below. + */ + UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); + + /* Each element of the top-level package must also be a package */ + + if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X]) Need sub-package, found %s", + Index, AcpiUtGetObjectTypeName (*TopObjectList))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Each sub-package must be of length 4 */ + + if ((*TopObjectList)->Package.Count != 4) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X]) Need package of length 4, found length %d", + Index, (*TopObjectList)->Package.Count)); + return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); + } + + /* + * Dereference the sub-package. + * The SubObjectList will now point to an array of the four IRQ + * elements: [Address, Pin, Source, SourceIndex] + */ + SubObjectList = (*TopObjectList)->Package.Elements; + + /* 1) First subobject: Dereference the PRT.Address */ + + ObjDesc = SubObjectList[0]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "(PRT[%X].Address) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->Address = ObjDesc->Integer.Value; + + /* 2) Second subobject: Dereference the PRT.Pin */ + + ObjDesc = SubObjectList[1]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "(PRT[%X].Pin) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; + + /* + * If the BIOS has erroneously reversed the _PRT SourceName (index 2) + * and the SourceIndex (index 3), fix it. _PRT is important enough to + * workaround this BIOS error. This also provides compatibility with + * other ACPI implementations. + */ + ObjDesc = SubObjectList[3]; + if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) + { + SubObjectList[3] = SubObjectList[2]; + SubObjectList[2] = ObjDesc; + + ACPI_WARNING ((AE_INFO, + "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed", + Index)); + } + + /* + * 3) Third subobject: Dereference the PRT.SourceName + * The name may be unresolved (slack mode), so allow a null object + */ + ObjDesc = SubObjectList[2]; + if (ObjDesc) + { + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X].Source) Need name, found Reference Class %X", + Index, ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + Node = ObjDesc->Reference.Node; + + /* Use *remaining* length of the buffer as max for pathname */ + + PathBuffer.Length = OutputBuffer->Length - + (UINT32) ((UINT8 *) UserPrt->Source - + (UINT8 *) OutputBuffer->Pointer); + PathBuffer.Pointer = UserPrt->Source; + + Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); + + /* +1 to include null terminator */ + + UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; + break; + + + case ACPI_TYPE_STRING: + + ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); + + /* + * Add to the Length field the length of the string + * (add 1 for terminator) + */ + UserPrt->Length += ObjDesc->String.Length + 1; + break; + + + case ACPI_TYPE_INTEGER: + /* + * If this is a number, then the Source Name is NULL, since the + * entire buffer was zeroed out, we can leave this alone. + * + * Add to the Length field the length of the UINT32 NULL + */ + UserPrt->Length += sizeof (UINT32); + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "(PRT[%X].Source) Need Ref/String/Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* Now align the current length */ + + UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length); + + /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ + + ObjDesc = SubObjectList[3]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X].SourceIndex) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value; + + /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ + + TopObjectList++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateAmlResources + * + * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. + * If the OutputBuffer is too small, the error will be + * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the linked list of device resources and + * creates a bytestream to be used as input for the + * _SRS control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateAmlResources ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_BUFFER *OutputBuffer) +{ + ACPI_STATUS Status; + ACPI_SIZE AmlSizeNeeded = 0; + + + ACPI_FUNCTION_TRACE (RsCreateAmlResources); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", + LinkedListBuffer)); + + /* + * Params already validated, so we don't re-validate here + * + * Pass the LinkedListBuffer into a module that calculates + * the buffer size needed for the byte stream. + */ + Status = AcpiRsGetAmlLength (LinkedListBuffer, + &AmlSizeNeeded); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", + (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Do the conversion */ + + Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, + OutputBuffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsdump.c b/reactos/drivers/bus/acpi/acpica/resources/rsdump.c new file mode 100644 index 00000000000..62db284c6f3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsdump.c @@ -0,0 +1,872 @@ +/******************************************************************************* + * + * Module Name: rsdump - Functions to display the resource structures. + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsdump") + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Local prototypes */ + +static void +AcpiRsOutString ( + char *Title, + char *Value); + +static void +AcpiRsOutInteger8 ( + char *Title, + UINT8 Value); + +static void +AcpiRsOutInteger16 ( + char *Title, + UINT16 Value); + +static void +AcpiRsOutInteger32 ( + char *Title, + UINT32 Value); + +static void +AcpiRsOutInteger64 ( + char *Title, + UINT64 Value); + +static void +AcpiRsOutTitle ( + char *Title); + +static void +AcpiRsDumpByteList ( + UINT16 Length, + UINT8 *Data); + +static void +AcpiRsDumpDwordList ( + UINT8 Length, + UINT32 *Data); + +static void +AcpiRsDumpShortByteList ( + UINT8 Length, + UINT8 *Data); + +static void +AcpiRsDumpResourceSource ( + ACPI_RESOURCE_SOURCE *ResourceSource); + +static void +AcpiRsDumpAddressCommon ( + ACPI_RESOURCE_DATA *Resource); + +static void +AcpiRsDumpDescriptor ( + void *Resource, + ACPI_RSDUMP_INFO *Table); + + +#define ACPI_RSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f) +#define ACPI_PRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f) +#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_RSDUMP_INFO)) + + +/******************************************************************************* + * + * Resource Descriptor info tables + * + * Note: The first table entry must be a Title or Literal and must contain + * the table length (number of table entries) + * + ******************************************************************************/ + +ACPI_RSDUMP_INFO AcpiRsDumpIrq[7] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq), "IRQ", NULL}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.DescriptorLength), "Descriptor Length", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LlDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_ShrDecode}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.InterruptCount), "Interrupt Count", NULL}, + {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]), "Interrupt List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpDma[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma), "DMA", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TypDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BmDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SizDecode}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Dma.ChannelCount), "Channel Count", NULL}, + {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]), "Channel List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[4] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf), "Start-Dependent-Functions",NULL}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (StartDpf.DescriptorLength), "Descriptor Length", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority), "Compatibility Priority", AcpiGbl_ConfigDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness), "Performance/Robustness", AcpiGbl_ConfigDecode} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[1] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf), "End-Dependent-Functions", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpIo[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo), "I/O", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode), "Address Decoding", AcpiGbl_IoDecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[3] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo), "Fixed I/O", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedIo.Address), "Address", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedIo.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpVendor[3] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor), "Vendor Specific", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Vendor.ByteLength), "Length", NULL}, + {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]), "Vendor Data", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpEndTag[1] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag), "EndTag", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24), "24-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32), "32-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[4] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32), "32-Bit Fixed Memory Range",NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.Address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress16[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16), "16-Bit WORD Address Space",NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address16.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress32[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32), "32-Bit DWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address32.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress64[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64), "64-Bit QWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address64.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64), "64-Bit Extended Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.AddressLength), "Address Length", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific), "Type-Specific Attribute", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq), "Extended IRQ", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer), "Type", AcpiGbl_ConsumeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LlDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_ShrDecode}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource), NULL, NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount), "Interrupt Count", NULL}, + {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]), "Interrupt List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg), "Generic Register", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.SpaceId), "Space ID", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitWidth), "Bit Width", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitOffset), "Bit Offset", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.AccessSize), "Access Size", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (GenericReg.Address), "Address", NULL} +}; + + +/* + * Tables used for common address descriptor flag fields + */ +static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags), NULL, NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer), "Consumer/Producer", AcpiGbl_ConsumeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DecDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed), "Min Relocatability", AcpiGbl_MinDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed), "Max Relocatability", AcpiGbl_MaxDecode} +}; + +static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] = +{ + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags), "Resource Type", (void *) "Memory Range"}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MemDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MtpDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TtpDecode} +}; + +static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] = +{ + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags), "Resource Type", (void *) "I/O Range"}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RngDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TtpDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TrsDecode} +}; + + +/* + * Table used to dump _PRT contents + */ +static ACPI_RSDUMP_INFO AcpiRsDumpPrt[5] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt), NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_PRT_OFFSET (Address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (Pin), "Pin", NULL}, + {ACPI_RSD_STRING, ACPI_PRT_OFFSET (Source[0]), "Source", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (SourceIndex), "Source Index", NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpDescriptor + * + * PARAMETERS: Resource + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +static void +AcpiRsDumpDescriptor ( + void *Resource, + ACPI_RSDUMP_INFO *Table) +{ + UINT8 *Target = NULL; + UINT8 *PreviousTarget; + char *Name; + UINT8 Count; + + + /* First table entry must contain the table length (# of table entries) */ + + Count = Table->Offset; + + while (Count) + { + PreviousTarget = Target; + Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset); + Name = Table->Name; + + switch (Table->Opcode) + { + case ACPI_RSD_TITLE: + /* + * Optional resource title + */ + if (Table->Name) + { + AcpiOsPrintf ("%s Resource\n", Name); + } + break; + + /* Strings */ + + case ACPI_RSD_LITERAL: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer)); + break; + + case ACPI_RSD_STRING: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target)); + break; + + /* Data items, 8/16/32/64 bit */ + + case ACPI_RSD_UINT8: + AcpiRsOutInteger8 (Name, ACPI_GET8 (Target)); + break; + + case ACPI_RSD_UINT16: + AcpiRsOutInteger16 (Name, ACPI_GET16 (Target)); + break; + + case ACPI_RSD_UINT32: + AcpiRsOutInteger32 (Name, ACPI_GET32 (Target)); + break; + + case ACPI_RSD_UINT64: + AcpiRsOutInteger64 (Name, ACPI_GET64 (Target)); + break; + + /* Flags: 1-bit and 2-bit flags supported */ + + case ACPI_RSD_1BITFLAG: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, + Table->Pointer [*Target & 0x01])); + break; + + case ACPI_RSD_2BITFLAG: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, + Table->Pointer [*Target & 0x03])); + break; + + case ACPI_RSD_SHORTLIST: + /* + * Short byte list (single line output) for DMA and IRQ resources + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsOutTitle (Name); + AcpiRsDumpShortByteList (*PreviousTarget, Target); + } + break; + + case ACPI_RSD_LONGLIST: + /* + * Long byte list for Vendor resource data + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target); + } + break; + + case ACPI_RSD_DWORDLIST: + /* + * Dword list for Extended Interrupt resources + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsDumpDwordList (*PreviousTarget, + ACPI_CAST_PTR (UINT32, Target)); + } + break; + + case ACPI_RSD_ADDRESS: + /* + * Common flags for all Address resources + */ + AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target)); + break; + + case ACPI_RSD_SOURCE: + /* + * Optional ResourceSource for Address resources + */ + AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target)); + break; + + default: + AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", + Table->Opcode); + return; + } + + Table++; + Count--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpResourceSource + * + * PARAMETERS: ResourceSource - Pointer to a Resource Source struct + * + * RETURN: None + * + * DESCRIPTION: Common routine for dumping the optional ResourceSource and the + * corresponding ResourceSourceIndex. + * + ******************************************************************************/ + +static void +AcpiRsDumpResourceSource ( + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + ACPI_FUNCTION_ENTRY (); + + + if (ResourceSource->Index == 0xFF) + { + return; + } + + AcpiRsOutInteger8 ("Resource Source Index", + ResourceSource->Index); + + AcpiRsOutString ("Resource Source", + ResourceSource->StringPtr ? + ResourceSource->StringPtr : "[Not Specified]"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpAddressCommon + * + * PARAMETERS: Resource - Pointer to an internal resource descriptor + * + * RETURN: None + * + * DESCRIPTION: Dump the fields that are common to all Address resource + * descriptors + * + ******************************************************************************/ + +static void +AcpiRsDumpAddressCommon ( + ACPI_RESOURCE_DATA *Resource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Decode the type-specific flags */ + + switch (Resource->Address.ResourceType) + { + case ACPI_MEMORY_RANGE: + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags); + break; + + case ACPI_IO_RANGE: + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags); + break; + + case ACPI_BUS_NUMBER_RANGE: + + AcpiRsOutString ("Resource Type", "Bus Number Range"); + break; + + default: + + AcpiRsOutInteger8 ("Resource Type", + (UINT8) Resource->Address.ResourceType); + break; + } + + /* Decode the general flags */ + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpResourceList + * + * PARAMETERS: ResourceList - Pointer to a resource descriptor list + * + * RETURN: None + * + * DESCRIPTION: Dispatches the structure to the correct dump routine. + * + ******************************************************************************/ + +void +AcpiRsDumpResourceList ( + ACPI_RESOURCE *ResourceList) +{ + UINT32 Count = 0; + UINT32 Type; + + + ACPI_FUNCTION_ENTRY (); + + + if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer)) + { + return; + } + + /* Walk list and dump all resource descriptors (END_TAG terminates) */ + + do + { + AcpiOsPrintf ("\n[%02X] ", Count); + Count++; + + /* Validate Type before dispatch */ + + Type = ResourceList->Type; + if (Type > ACPI_RESOURCE_TYPE_MAX) + { + AcpiOsPrintf ( + "Invalid descriptor type (%X) in resource list\n", + ResourceList->Type); + return; + } + + /* Dump the resource descriptor */ + + AcpiRsDumpDescriptor (&ResourceList->Data, + AcpiGbl_DumpResourceDispatch[Type]); + + /* Point to the next resource structure */ + + ResourceList = ACPI_ADD_PTR (ACPI_RESOURCE, ResourceList, + ResourceList->Length); + + /* Exit when END_TAG descriptor is reached */ + + } while (Type != ACPI_RESOURCE_TYPE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIrqList + * + * PARAMETERS: RouteTable - Pointer to the routing table to dump. + * + * RETURN: None + * + * DESCRIPTION: Print IRQ routing table + * + ******************************************************************************/ + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable) +{ + ACPI_PCI_ROUTING_TABLE *PrtElement; + UINT8 Count; + + + ACPI_FUNCTION_ENTRY (); + + + if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer)) + { + return; + } + + PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable); + + /* Dump all table elements, Exit on zero length element */ + + for (Count = 0; PrtElement->Length; Count++) + { + AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count); + AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt); + + PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE, + PrtElement, PrtElement->Length); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsOut* + * + * PARAMETERS: Title - Name of the resource field + * Value - Value of the resource field + * + * RETURN: None + * + * DESCRIPTION: Miscellaneous helper functions to consistently format the + * output of the resource dump routines + * + ******************************************************************************/ + +static void +AcpiRsOutString ( + char *Title, + char *Value) +{ + AcpiOsPrintf ("%27s : %s", Title, Value); + if (!*Value) + { + AcpiOsPrintf ("[NULL NAMESTRING]"); + } + AcpiOsPrintf ("\n"); +} + +static void +AcpiRsOutInteger8 ( + char *Title, + UINT8 Value) +{ + AcpiOsPrintf ("%27s : %2.2X\n", Title, Value); +} + +static void +AcpiRsOutInteger16 ( + char *Title, + UINT16 Value) +{ + AcpiOsPrintf ("%27s : %4.4X\n", Title, Value); +} + +static void +AcpiRsOutInteger32 ( + char *Title, + UINT32 Value) +{ + AcpiOsPrintf ("%27s : %8.8X\n", Title, Value); +} + +static void +AcpiRsOutInteger64 ( + char *Title, + UINT64 Value) +{ + AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title, + ACPI_FORMAT_UINT64 (Value)); +} + +static void +AcpiRsOutTitle ( + char *Title) +{ + AcpiOsPrintf ("%27s : ", Title); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDump*List + * + * PARAMETERS: Length - Number of elements in the list + * Data - Start of the list + * + * RETURN: None + * + * DESCRIPTION: Miscellaneous functions to dump lists of raw data + * + ******************************************************************************/ + +static void +AcpiRsDumpByteList ( + UINT16 Length, + UINT8 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%25s%2.2X : %2.2X\n", + "Byte", i, Data[i]); + } +} + +static void +AcpiRsDumpShortByteList ( + UINT8 Length, + UINT8 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%X ", Data[i]); + } + AcpiOsPrintf ("\n"); +} + +static void +AcpiRsDumpDwordList ( + UINT8 Length, + UINT32 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%25s%2.2X : %8.8X\n", + "Dword", i, Data[i]); + } +} + +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsinfo.c b/reactos/drivers/bus/acpi/acpica/resources/rsinfo.c new file mode 100644 index 00000000000..abf79943d97 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsinfo.c @@ -0,0 +1,290 @@ +/******************************************************************************* + * + * Module Name: rsinfo - Dispatch and Info tables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSINFO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsinfo") + +/* + * Resource dispatch and information tables. Any new resource types (either + * Large or Small) must be reflected in each of these tables, so they are here + * in one place. + * + * The tables for Large descriptors are indexed by bits 6:0 of the AML + * descriptor type byte. The tables for Small descriptors are indexed by + * bits 6:3 of the descriptor byte. The tables for internal resource + * descriptors are indexed by the ACPI_RESOURCE_TYPE field. + */ + + +/* Dispatch table for resource-to-AML (Set Resource) conversion functions */ + +ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[] = +{ + AcpiRsSetIrq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */ + AcpiRsConvertDma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */ + AcpiRsSetStartDpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */ + AcpiRsConvertEndDpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */ + AcpiRsConvertIo, /* 0x04, ACPI_RESOURCE_TYPE_IO */ + AcpiRsConvertFixedIo, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */ + AcpiRsSetVendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */ + AcpiRsConvertEndTag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */ + AcpiRsConvertMemory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */ + AcpiRsConvertMemory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */ + AcpiRsConvertFixedMemory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + AcpiRsConvertAddress16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */ + AcpiRsConvertAddress32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */ + AcpiRsConvertAddress64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ + AcpiRsConvertExtAddress64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + AcpiRsConvertExtIrq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + AcpiRsConvertGenericReg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + +/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ + +ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[] = +{ + /* Small descriptors */ + + NULL, /* 0x00, Reserved */ + NULL, /* 0x01, Reserved */ + NULL, /* 0x02, Reserved */ + NULL, /* 0x03, Reserved */ + AcpiRsGetIrq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */ + AcpiRsConvertDma, /* 0x05, ACPI_RESOURCE_NAME_DMA */ + AcpiRsGetStartDpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */ + AcpiRsConvertEndDpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ + AcpiRsConvertIo, /* 0x08, ACPI_RESOURCE_NAME_IO */ + AcpiRsConvertFixedIo, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ + NULL, /* 0x0A, Reserved */ + NULL, /* 0x0B, Reserved */ + NULL, /* 0x0C, Reserved */ + NULL, /* 0x0D, Reserved */ + AcpiRsGetVendorSmall, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ + AcpiRsConvertEndTag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ + + /* Large descriptors */ + + NULL, /* 0x00, Reserved */ + AcpiRsConvertMemory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ + AcpiRsConvertGenericReg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ + NULL, /* 0x03, Reserved */ + AcpiRsGetVendorLarge, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */ + AcpiRsConvertMemory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */ + AcpiRsConvertFixedMemory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */ + AcpiRsConvertAddress32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */ + AcpiRsConvertAddress16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ + AcpiRsConvertExtIrq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ + AcpiRsConvertAddress64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ + AcpiRsConvertExtAddress64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ +}; + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Dispatch table for resource dump functions */ + +ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[] = +{ + AcpiRsDumpIrq, /* ACPI_RESOURCE_TYPE_IRQ */ + AcpiRsDumpDma, /* ACPI_RESOURCE_TYPE_DMA */ + AcpiRsDumpStartDpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */ + AcpiRsDumpEndDpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */ + AcpiRsDumpIo, /* ACPI_RESOURCE_TYPE_IO */ + AcpiRsDumpFixedIo, /* ACPI_RESOURCE_TYPE_FIXED_IO */ + AcpiRsDumpVendor, /* ACPI_RESOURCE_TYPE_VENDOR */ + AcpiRsDumpEndTag, /* ACPI_RESOURCE_TYPE_END_TAG */ + AcpiRsDumpMemory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */ + AcpiRsDumpMemory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */ + AcpiRsDumpFixedMemory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + AcpiRsDumpAddress16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */ + AcpiRsDumpAddress32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */ + AcpiRsDumpAddress64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */ + AcpiRsDumpExtAddress64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + AcpiRsDumpExtIrq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + AcpiRsDumpGenericReg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; +#endif + + +/* + * Base sizes for external AML resource descriptors, indexed by internal type. + * Includes size of the descriptor header (1 byte for small descriptors, + * 3 bytes for large descriptors) + */ +const UINT8 AcpiGbl_AmlResourceSizes[] = +{ + sizeof (AML_RESOURCE_IRQ), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */ + sizeof (AML_RESOURCE_DMA), /* ACPI_RESOURCE_TYPE_DMA */ + sizeof (AML_RESOURCE_START_DEPENDENT), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */ + sizeof (AML_RESOURCE_END_DEPENDENT), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */ + sizeof (AML_RESOURCE_IO), /* ACPI_RESOURCE_TYPE_IO */ + sizeof (AML_RESOURCE_FIXED_IO), /* ACPI_RESOURCE_TYPE_FIXED_IO */ + sizeof (AML_RESOURCE_VENDOR_SMALL), /* ACPI_RESOURCE_TYPE_VENDOR */ + sizeof (AML_RESOURCE_END_TAG), /* ACPI_RESOURCE_TYPE_END_TAG */ + sizeof (AML_RESOURCE_MEMORY24), /* ACPI_RESOURCE_TYPE_MEMORY24 */ + sizeof (AML_RESOURCE_MEMORY32), /* ACPI_RESOURCE_TYPE_MEMORY32 */ + sizeof (AML_RESOURCE_FIXED_MEMORY32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + sizeof (AML_RESOURCE_ADDRESS16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */ + sizeof (AML_RESOURCE_ADDRESS32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */ + sizeof (AML_RESOURCE_ADDRESS64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */ + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + sizeof (AML_RESOURCE_EXTENDED_IRQ), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + sizeof (AML_RESOURCE_GENERIC_REGISTER) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + + +const UINT8 AcpiGbl_ResourceStructSizes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_IRQ), + ACPI_RS_SIZE (ACPI_RESOURCE_DMA), + ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), + ACPI_RS_SIZE_MIN, + ACPI_RS_SIZE (ACPI_RESOURCE_IO), + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), + 0, + 0, + 0, + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RS_SIZE_MIN, + + /* Large descriptors */ + + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24), + ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32), + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16), + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64), + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64) +}; + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsio.c b/reactos/drivers/bus/acpi/acpica/resources/rsio.c new file mode 100644 index 00000000000..fb9213dd72e --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsio.c @@ -0,0 +1,376 @@ +/******************************************************************************* + * + * Module Name: rsio - IO and DMA resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsio") + + +/******************************************************************************* + * + * AcpiRsConvertIo + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertIo[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, + ACPI_RS_SIZE (ACPI_RESOURCE_IO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, + sizeof (AML_RESOURCE_IO), + 0}, + + /* Decode flag */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode), + AML_OFFSET (Io.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Address Alignment + * Length + * Minimum Base Address + * Maximum Base Address + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment), + AML_OFFSET (Io.Alignment), + 2}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum), + AML_OFFSET (Io.Minimum), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsConvertFixedIo + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, + sizeof (AML_RESOURCE_FIXED_IO), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Base Address + * Length + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength), + AML_OFFSET (FixedIo.AddressLength), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address), + AML_OFFSET (FixedIo.Address), + 1} +}; + + +/******************************************************************************* + * + * AcpiRsConvertGenericReg + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, + ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, + sizeof (AML_RESOURCE_GENERIC_REGISTER), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Address Space ID + * Register Bit Width + * Register Bit Offset + * Access Size + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId), + AML_OFFSET (GenericReg.AddressSpaceId), + 4}, + + /* Get the Register Address */ + + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address), + AML_OFFSET (GenericReg.Address), + 1} +}; + + +/******************************************************************************* + * + * AcpiRsConvertEndDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, + sizeof (AML_RESOURCE_END_DEPENDENT), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsConvertEndTag + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)}, + + /* + * Note: The checksum field is set to zero, meaning that the resource + * data is treated as if the checksum operation succeeded. + * (ACPI Spec 1.0b Section 6.4.2.8) + */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, + sizeof (AML_RESOURCE_END_TAG), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsGetStartDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, + ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), + ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)}, + + /* Defaults for Compatibility and Performance priorities */ + + {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + ACPI_ACCEPTABLE_CONFIGURATION, + 2}, + + /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength), + AML_OFFSET (StartDpf.DescriptorType), + 0}, + + /* All done if there is no flag byte present in the descriptor */ + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, + + /* Flag byte is present, get the flags */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + AML_OFFSET (StartDpf.Flags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + AML_OFFSET (StartDpf.Flags), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsSetStartDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] = +{ + /* Start with a default descriptor of length 1 */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, + sizeof (AML_RESOURCE_START_DEPENDENT), + ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)}, + + /* Set the default flag values */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + AML_OFFSET (StartDpf.Flags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + AML_OFFSET (StartDpf.Flags), + 2}, + /* + * All done if the output descriptor length is required to be 1 + * (i.e., optimization to 0 bytes cannot be attempted) + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), + 1}, + + /* Set length to 0 bytes (no flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}, + + /* + * All done if the output descriptor length is required to be 0. + * + * TBD: Perhaps we should check for error if input flags are not + * compatible with a 0-byte descriptor. + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), + 0}, + + /* Reset length to 1 byte (descriptor with flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)}, + + + /* + * All done if flags byte is necessary -- if either priority value + * is not ACPI_ACCEPTABLE_CONFIGURATION + */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + ACPI_ACCEPTABLE_CONFIGURATION}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + ACPI_ACCEPTABLE_CONFIGURATION}, + + /* Flag byte is not necessary */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)} +}; + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsirq.c b/reactos/drivers/bus/acpi/acpica/resources/rsirq.c new file mode 100644 index 00000000000..7eab4351399 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsirq.c @@ -0,0 +1,348 @@ +/******************************************************************************* + * + * Module Name: rsirq - IRQ resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIRQ_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsirq") + + +/******************************************************************************* + * + * AcpiRsGetIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetIrq[8] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ, + ACPI_RS_SIZE (ACPI_RESOURCE_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsGetIrq)}, + + /* Get the IRQ mask (bytes 1:2) */ + + {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), + AML_OFFSET (Irq.IrqMask), + ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, + + /* Set default flags (others are zero) */ + + {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering), + ACPI_EDGE_SENSITIVE, + 1}, + + /* Get the descriptor length (2 or 3 for IRQ descriptor) */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Irq.DescriptorLength), + AML_OFFSET (Irq.DescriptorType), + 0}, + + /* All done if no flag byte present in descriptor */ + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3}, + + /* Get flags: Triggering[0], Polarity[3], Sharing[4] */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), + AML_OFFSET (Irq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), + AML_OFFSET (Irq.Flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), + AML_OFFSET (Irq.Flags), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsSetIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetIrq[13] = +{ + /* Start with a default descriptor of length 3 */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ, + sizeof (AML_RESOURCE_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsSetIrq)}, + + /* Convert interrupt list to 16-bit IRQ bitmask */ + + {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), + AML_OFFSET (Irq.IrqMask), + ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, + + /* Set the flags byte */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), + AML_OFFSET (Irq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), + AML_OFFSET (Irq.Flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), + AML_OFFSET (Irq.Flags), + 4}, + + /* + * All done if the output descriptor length is required to be 3 + * (i.e., optimization to 2 bytes cannot be attempted) + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.Irq.DescriptorLength), + 3}, + + /* Set length to 2 bytes (no flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)}, + + /* + * All done if the output descriptor length is required to be 2. + * + * TBD: Perhaps we should check for error if input flags are not + * compatible with a 2-byte descriptor. + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.Irq.DescriptorLength), + 2}, + + /* Reset length to 3 bytes (descriptor with flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ)}, + + /* + * Check if the flags byte is necessary. Not needed if the flags are: + * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE + */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Triggering), + ACPI_EDGE_SENSITIVE}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Polarity), + ACPI_ACTIVE_HIGH}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Sharable), + ACPI_EXCLUSIVE}, + + /* We can optimize to a 2-byte IrqNoFlags() descriptor */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertExtIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[9] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ, + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtIrq)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ, + sizeof (AML_RESOURCE_EXTENDED_IRQ), + 0}, + + /* Flag bits */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer), + AML_OFFSET (ExtendedIrq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering), + AML_OFFSET (ExtendedIrq.Flags), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity), + AML_OFFSET (ExtendedIrq.Flags), + 2}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Sharable), + AML_OFFSET (ExtendedIrq.Flags), + 3}, + + /* IRQ Table length (Byte4) */ + + {ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount), + AML_OFFSET (ExtendedIrq.InterruptCount), + sizeof (UINT32)}, + + /* Copy every IRQ in the table, each is 32 bits */ + + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), + AML_OFFSET (ExtendedIrq.Interrupts[0]), + 0}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource), + ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), + sizeof (AML_RESOURCE_EXTENDED_IRQ)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertDma + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertDma[6] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA, + ACPI_RS_SIZE (ACPI_RESOURCE_DMA), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertDma)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA, + sizeof (AML_RESOURCE_DMA), + 0}, + + /* Flags: transfer preference, bus mastering, channel speed */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer), + AML_OFFSET (Dma.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster), + AML_OFFSET (Dma.Flags), + 2}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Type), + AML_OFFSET (Dma.Flags), + 5}, + + /* DMA channel mask bits */ + + {ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]), + AML_OFFSET (Dma.DmaChannelMask), + ACPI_RS_OFFSET (Data.Dma.ChannelCount)} +}; + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rslist.c b/reactos/drivers/bus/acpi/acpica/resources/rslist.c new file mode 100644 index 00000000000..3adce2b3939 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rslist.c @@ -0,0 +1,286 @@ +/******************************************************************************* + * + * Module Name: rslist - Linked list utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSLIST_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rslist") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertAmlToResources + * + * PARAMETERS: ACPI_WALK_AML_CALLBACK + * ResourcePtr - Pointer to the buffer that will + * contain the output structures + * + * RETURN: Status + * + * DESCRIPTION: Convert an AML resource to an internal representation of the + * resource that is aligned and easier to access. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertAmlToResources ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context) +{ + ACPI_RESOURCE **ResourcePtr = ACPI_CAST_INDIRECT_PTR ( + ACPI_RESOURCE, Context); + ACPI_RESOURCE *Resource; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsConvertAmlToResources); + + + /* + * Check that the input buffer and all subsequent pointers into it + * are aligned on a native word boundary. Most important on IA64 + */ + Resource = *ResourcePtr; + if (ACPI_IS_MISALIGNED (Resource)) + { + ACPI_WARNING ((AE_INFO, + "Misaligned resource pointer %p", Resource)); + } + + /* Convert the AML byte stream resource to a local resource struct */ + + Status = AcpiRsConvertAmlToResource ( + Resource, ACPI_CAST_PTR (AML_RESOURCE, Aml), + AcpiGbl_GetResourceDispatch[ResourceIndex]); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not convert AML resource (Type %X)", *Aml)); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, + "Type %.2X, AmlLength %.2X InternalLength %.2X\n", + AcpiUtGetResourceType (Aml), Length, + Resource->Length)); + + /* Point to the next structure in the output buffer */ + + *ResourcePtr = ACPI_ADD_PTR (void, Resource, Resource->Length); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertResourcesToAml + * + * PARAMETERS: Resource - Pointer to the resource linked list + * AmlSizeNeeded - Calculated size of the byte stream + * needed from calling AcpiRsGetAmlLength() + * The size of the OutputBuffer is + * guaranteed to be >= AmlSizeNeeded + * OutputBuffer - Pointer to the buffer that will + * contain the byte stream + * + * RETURN: Status + * + * DESCRIPTION: Takes the resource linked list and parses it, creating a + * byte stream of resources in the caller's output buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertResourcesToAml ( + ACPI_RESOURCE *Resource, + ACPI_SIZE AmlSizeNeeded, + UINT8 *OutputBuffer) +{ + UINT8 *Aml = OutputBuffer; + UINT8 *EndAml = OutputBuffer + AmlSizeNeeded; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsConvertResourcesToAml); + + + /* Walk the resource descriptor list, convert each descriptor */ + + while (Aml < EndAml) + { + /* Validate the (internal) Resource Type */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + ACPI_ERROR ((AE_INFO, + "Invalid descriptor type (%X) in resource list", + Resource->Type)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* Perform the conversion */ + + Status = AcpiRsConvertResourceToAml (Resource, + ACPI_CAST_PTR (AML_RESOURCE, Aml), + AcpiGbl_SetResourceDispatch[Resource->Type]); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not convert resource (type %X) to AML", + Resource->Type)); + return_ACPI_STATUS (Status); + } + + /* Perform final sanity check on the new AML resource descriptor */ + + Status = AcpiUtValidateResource ( + ACPI_CAST_PTR (AML_RESOURCE, Aml), NULL); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Check for end-of-list, normal exit */ + + if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) + { + /* An End Tag indicates the end of the input Resource Template */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Extract the total length of the new descriptor and set the + * Aml to point to the next (output) resource descriptor + */ + Aml += AcpiUtGetDescriptorLength (Aml); + + /* Point to the next input resource descriptor */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + /* Completed buffer, but did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsmemory.c b/reactos/drivers/bus/acpi/acpica/resources/rsmemory.c new file mode 100644 index 00000000000..a3d08c01a1b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsmemory.c @@ -0,0 +1,323 @@ +/******************************************************************************* + * + * Module Name: rsmem24 - Memory resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSMEMORY_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsmemory") + + +/******************************************************************************* + * + * AcpiRsConvertMemory24 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory24)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24, + sizeof (AML_RESOURCE_MEMORY24), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory24.WriteProtect), + AML_OFFSET (Memory24.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Memory24.Minimum), + AML_OFFSET (Memory24.Minimum), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsConvertMemory32 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32, + sizeof (AML_RESOURCE_MEMORY32), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory32.WriteProtect), + AML_OFFSET (Memory32.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Memory32.Minimum), + AML_OFFSET (Memory32.Minimum), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsConvertFixedMemory32 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32, + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedMemory32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32, + sizeof (AML_RESOURCE_FIXED_MEMORY32), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.FixedMemory32.WriteProtect), + AML_OFFSET (FixedMemory32.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Base Address + * Range Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.FixedMemory32.Address), + AML_OFFSET (FixedMemory32.Address), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsGetVendorSmall + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[3] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorSmall)}, + + /* Length of the vendor data (byte count) */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + sizeof (UINT8)}, + + /* Vendor data */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_SMALL_HEADER), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsGetVendorLarge + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[3] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorLarge)}, + + /* Length of the vendor data (byte count) */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + sizeof (UINT8)}, + + /* Vendor data */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_LARGE_HEADER), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsSetVendor + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetVendor[7] = +{ + /* Default is a small vendor descriptor */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL, + sizeof (AML_RESOURCE_SMALL_HEADER), + ACPI_RSC_TABLE_SIZE (AcpiRsSetVendor)}, + + /* Get the length and copy the data */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_SMALL_HEADER), + 0}, + + /* + * All done if the Vendor byte length is 7 or less, meaning that it will + * fit within a small descriptor + */ + {ACPI_RSC_EXIT_LE, 0, 0, 7}, + + /* Must create a large vendor descriptor */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE, + sizeof (AML_RESOURCE_LARGE_HEADER), + 0}, + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_LARGE_HEADER), + 0} +}; + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsmisc.c b/reactos/drivers/bus/acpi/acpica/resources/rsmisc.c new file mode 100644 index 00000000000..3565334e732 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsmisc.c @@ -0,0 +1,683 @@ +/******************************************************************************* + * + * Module Name: rsmisc - Miscellaneous resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsmisc") + + +#define INIT_RESOURCE_TYPE(i) i->ResourceOffset +#define INIT_RESOURCE_LENGTH(i) i->AmlOffset +#define INIT_TABLE_LENGTH(i) i->Value + +#define COMPARE_OPCODE(i) i->ResourceOffset +#define COMPARE_TARGET(i) i->AmlOffset +#define COMPARE_VALUE(i) i->Value + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertAmlToResource + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table + * + * RETURN: Status + * + * DESCRIPTION: Convert an external AML resource descriptor to the corresponding + * internal resource descriptor + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertAmlToResource ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info) +{ + ACPI_RS_LENGTH AmlResourceLength; + void *Source; + void *Destination; + char *Target; + UINT8 Count; + UINT8 FlagsMode = FALSE; + UINT16 ItemCount = 0; + UINT16 Temp16 = 0; + + + ACPI_FUNCTION_TRACE (RsConvertAmlToResource); + + + if (((ACPI_SIZE) Resource) & 0x3) + { + /* Each internal resource struct is expected to be 32-bit aligned */ + + ACPI_WARNING ((AE_INFO, + "Misaligned resource pointer (get): %p Type %2.2X Len %X", + Resource, Resource->Type, Resource->Length)); + } + + /* Extract the resource Length field (does not include header length) */ + + AmlResourceLength = AcpiUtGetResourceLength (Aml); + + /* + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) + */ + Count = INIT_TABLE_LENGTH (Info); + + while (Count) + { + /* + * Source is the external AML byte stream buffer, + * destination is the internal resource descriptor + */ + Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); + Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); + + switch (Info->Opcode) + { + case ACPI_RSC_INITGET: + /* + * Get the resource type and the initial (minimum) length + */ + ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info)); + Resource->Type = INIT_RESOURCE_TYPE (Info); + Resource->Length = INIT_RESOURCE_LENGTH (Info); + break; + + + case ACPI_RSC_INITSET: + break; + + + case ACPI_RSC_FLAGINIT: + + FlagsMode = TRUE; + break; + + + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + ACPI_SET8 (Destination) = (UINT8) + ((ACPI_GET8 (Source) >> Info->Value) & 0x01); + break; + + + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + ACPI_SET8 (Destination) = (UINT8) + ((ACPI_GET8 (Source) >> Info->Value) & 0x03); + break; + + + case ACPI_RSC_COUNT: + + ItemCount = ACPI_GET8 (Source); + ACPI_SET8 (Destination) = (UINT8) ItemCount; + + Resource->Length = Resource->Length + + (Info->Value * (ItemCount - 1)); + break; + + + case ACPI_RSC_COUNT16: + + ItemCount = AmlResourceLength; + ACPI_SET16 (Destination) = ItemCount; + + Resource->Length = Resource->Length + + (Info->Value * (ItemCount - 1)); + break; + + + case ACPI_RSC_LENGTH: + + Resource->Length = Resource->Length + Info->Value; + break; + + + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + /* + * Raw data move. Use the Info value field unless ItemCount has + * been previously initialized via a COUNT opcode + */ + if (Info->Value) + { + ItemCount = Info->Value; + } + AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); + break; + + + case ACPI_RSC_SET8: + + ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value); + break; + + + case ACPI_RSC_DATA8: + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target)); + break; + + + case ACPI_RSC_ADDRESS: + /* + * Common handler for address descriptor flags + */ + if (!AcpiRsGetAddressCommon (Resource, Aml)) + { + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } + break; + + + case ACPI_RSC_SOURCE: + /* + * Optional ResourceSource (Index and String) + */ + Resource->Length += + AcpiRsGetResourceSource (AmlResourceLength, Info->Value, + Destination, Aml, NULL); + break; + + + case ACPI_RSC_SOURCEX: + /* + * Optional ResourceSource (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + Target = ACPI_ADD_PTR (char, Resource, Info->AmlOffset + (ItemCount * 4)); + + Resource->Length += + AcpiRsGetResourceSource (AmlResourceLength, + (ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value), + Destination, Aml, Target); + break; + + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination); + if (ItemCount) + { + Resource->Length += (ItemCount - 1); + } + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_SET8 (Target) = (UINT8) ItemCount; + break; + + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + ACPI_MOVE_16_TO_16 (&Temp16, Source); + + ItemCount = AcpiRsDecodeBitmask (Temp16, Destination); + if (ItemCount) + { + Resource->Length += (ItemCount - 1); + } + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_SET8 (Target) = (UINT8) ItemCount; + break; + + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (Info->ResourceOffset) + { + case ACPI_RSC_COMPARE_AML_LENGTH: + if (AmlResourceLength != Info->Value) + { + goto Exit; + } + break; + + case ACPI_RSC_COMPARE_VALUE: + if (ACPI_GET8 (Source) != Info->Value) + { + goto Exit; + } + break; + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Count--; + Info++; + } + +Exit: + if (!FlagsMode) + { + /* Round the resource struct length up to the next boundary (32 or 64) */ + + Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length); + } + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertResourceToAml + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table + * + * RETURN: Status + * + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertResourceToAml ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info) +{ + void *Source = NULL; + void *Destination; + ACPI_RSDESC_SIZE AmlLength = 0; + UINT8 Count; + UINT16 Temp16 = 0; + UINT16 ItemCount = 0; + + + ACPI_FUNCTION_TRACE (RsConvertResourceToAml); + + + /* + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) + */ + Count = INIT_TABLE_LENGTH (Info); + + while (Count) + { + /* + * Source is the internal resource descriptor, + * destination is the external AML byte stream buffer + */ + Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); + Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); + + switch (Info->Opcode) + { + case ACPI_RSC_INITSET: + + ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info)); + AmlLength = INIT_RESOURCE_LENGTH (Info); + AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml); + break; + + + case ACPI_RSC_INITGET: + break; + + + case ACPI_RSC_FLAGINIT: + /* + * Clear the flag byte + */ + ACPI_SET8 (Destination) = 0; + break; + + + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + ACPI_SET8 (Destination) |= (UINT8) + ((ACPI_GET8 (Source) & 0x01) << Info->Value); + break; + + + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + ACPI_SET8 (Destination) |= (UINT8) + ((ACPI_GET8 (Source) & 0x03) << Info->Value); + break; + + + case ACPI_RSC_COUNT: + + ItemCount = ACPI_GET8 (Source); + ACPI_SET8 (Destination) = (UINT8) ItemCount; + + AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1))); + break; + + + case ACPI_RSC_COUNT16: + + ItemCount = ACPI_GET16 (Source); + AmlLength = (UINT16) (AmlLength + ItemCount); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_LENGTH: + + AcpiRsSetResourceLength (Info->Value, Aml); + break; + + + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + + if (Info->Value) + { + ItemCount = Info->Value; + } + AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); + break; + + + case ACPI_RSC_ADDRESS: + + /* Set the Resource Type, General Flags, and Type-Specific Flags */ + + AcpiRsSetAddressCommon (Aml, Resource); + break; + + + case ACPI_RSC_SOURCEX: + /* + * Optional ResourceSource (Index and String) + */ + AmlLength = AcpiRsSetResourceSource ( + Aml, (ACPI_RS_LENGTH) AmlLength, Source); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_SOURCE: + /* + * Optional ResourceSource (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + ACPI_SET8 (Destination) = (UINT8) + AcpiRsEncodeBitmask (Source, + *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); + break; + + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + Temp16 = AcpiRsEncodeBitmask (Source, + *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); + ACPI_MOVE_16_TO_16 (Destination, &Temp16); + break; + + + case ACPI_RSC_EXIT_LE: + /* + * Control - Exit conversion if less than or equal + */ + if (ItemCount <= Info->Value) + { + goto Exit; + } + break; + + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (COMPARE_OPCODE (Info)) + { + case ACPI_RSC_COMPARE_VALUE: + + if (*ACPI_ADD_PTR (UINT8, Resource, + COMPARE_TARGET (Info)) != COMPARE_VALUE (Info)) + { + goto Exit; + } + break; + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; + + + case ACPI_RSC_EXIT_EQ: + /* + * Control - Exit conversion if equal + */ + if (*ACPI_ADD_PTR (UINT8, Resource, + COMPARE_TARGET (Info)) == COMPARE_VALUE (Info)) + { + goto Exit; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Count--; + Info++; + } + +Exit: + return_ACPI_STATUS (AE_OK); +} + + +#if 0 +/* Previous resource validations */ + + if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) + { + return_ACPI_STATUS (AE_SUPPORT); + } + + if (Resource->Data.StartDpf.PerformanceRobustness >= 3) + { + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); + } + + if (((Aml->Irq.Flags & 0x09) == 0x00) || + ((Aml->Irq.Flags & 0x09) == 0x09)) + { + /* + * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive] + * polarity/trigger interrupts are allowed (ACPI spec, section + * "IRQ Format"), so 0x00 and 0x09 are illegal. + */ + ACPI_ERROR ((AE_INFO, + "Invalid interrupt polarity/trigger in resource list, %X", + Aml->Irq.Flags)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + Resource->Data.ExtendedIrq.InterruptCount = Temp8; + if (Temp8 < 1) + { + /* Must have at least one IRQ */ + + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + } + + if (Resource->Data.Dma.Transfer == 0x03) + { + ACPI_ERROR ((AE_INFO, + "Invalid DMA.Transfer preference (3)")); + return_ACPI_STATUS (AE_BAD_DATA); + } +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsutils.c b/reactos/drivers/bus/acpi/acpica/resources/rsutils.c new file mode 100644 index 00000000000..4e0f04ce8e5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsutils.c @@ -0,0 +1,874 @@ +/******************************************************************************* + * + * Module Name: rsutils - Utilities for the resource manager + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acresrc.h" + + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDecodeBitmask + * + * PARAMETERS: Mask - Bitmask to decode + * List - Where the converted list is returned + * + * RETURN: Count of bits set (length of list) + * + * DESCRIPTION: Convert a bit mask into a list of values + * + ******************************************************************************/ + +UINT8 +AcpiRsDecodeBitmask ( + UINT16 Mask, + UINT8 *List) +{ + UINT8 i; + UINT8 BitCount; + + + ACPI_FUNCTION_ENTRY (); + + + /* Decode the mask bits */ + + for (i = 0, BitCount = 0; Mask; i++) + { + if (Mask & 0x0001) + { + List[BitCount] = i; + BitCount++; + } + + Mask >>= 1; + } + + return (BitCount); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEncodeBitmask + * + * PARAMETERS: List - List of values to encode + * Count - Length of list + * + * RETURN: Encoded bitmask + * + * DESCRIPTION: Convert a list of values to an encoded bitmask + * + ******************************************************************************/ + +UINT16 +AcpiRsEncodeBitmask ( + UINT8 *List, + UINT8 Count) +{ + UINT32 i; + UINT16 Mask; + + + ACPI_FUNCTION_ENTRY (); + + + /* Encode the list into a single bitmask */ + + for (i = 0, Mask = 0; i < Count; i++) + { + Mask |= (0x1 << List[i]); + } + + return (Mask); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMoveData + * + * PARAMETERS: Destination - Pointer to the destination descriptor + * Source - Pointer to the source descriptor + * ItemCount - How many items to move + * MoveType - Byte width + * + * RETURN: None + * + * DESCRIPTION: Move multiple data items from one descriptor to another. Handles + * alignment issues and endian issues if necessary, as configured + * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) + * + ******************************************************************************/ + +void +AcpiRsMoveData ( + void *Destination, + void *Source, + UINT16 ItemCount, + UINT8 MoveType) +{ + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + /* One move per item */ + + for (i = 0; i < ItemCount; i++) + { + switch (MoveType) + { + /* + * For the 8-bit case, we can perform the move all at once + * since there are no alignment or endian issues + */ + case ACPI_RSC_MOVE8: + ACPI_MEMCPY (Destination, Source, ItemCount); + return; + + /* + * 16-, 32-, and 64-bit cases must use the move macros that perform + * endian conversion and/or accomodate hardware that cannot perform + * misaligned memory transfers + */ + case ACPI_RSC_MOVE16: + ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], + &ACPI_CAST_PTR (UINT16, Source)[i]); + break; + + case ACPI_RSC_MOVE32: + ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], + &ACPI_CAST_PTR (UINT32, Source)[i]); + break; + + case ACPI_RSC_MOVE64: + ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], + &ACPI_CAST_PTR (UINT64, Source)[i]); + break; + + default: + return; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceLength + * + * PARAMETERS: TotalLength - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the ResourceLength field of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically. Note: Descriptor Type field must + * be valid. + * + ******************************************************************************/ + +void +AcpiRsSetResourceLength ( + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml) +{ + ACPI_RS_LENGTH ResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* Length is the total descriptor length minus the header length */ + + ResourceLength = (ACPI_RS_LENGTH) + (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); + + /* Length is stored differently for large and small descriptors */ + + if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) + { + /* Large descriptor -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); + } + else + { + /* Small descriptor -- bits 2:0 of byte 0 contain the length */ + + Aml->SmallHeader.DescriptorType = (UINT8) + + /* Clear any existing length, preserving descriptor type bits */ + + ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) + + | ResourceLength); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceHeader + * + * PARAMETERS: DescriptorType - Byte to be inserted as the type + * TotalLength - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically + * + ******************************************************************************/ + +void +AcpiRsSetResourceHeader ( + UINT8 DescriptorType, + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Set the Resource Type */ + + Aml->SmallHeader.DescriptorType = DescriptorType; + + /* Set the Resource Length */ + + AcpiRsSetResourceLength (TotalLength, Aml); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStrcpy + * + * PARAMETERS: Destination - Pointer to the destination string + * Source - Pointer to the source string + * + * RETURN: String length, including NULL terminator + * + * DESCRIPTION: Local string copy that returns the string length, saving a + * strcpy followed by a strlen. + * + ******************************************************************************/ + +static UINT16 +AcpiRsStrcpy ( + char *Destination, + char *Source) +{ + UINT16 i; + + + ACPI_FUNCTION_ENTRY (); + + + for (i = 0; Source[i]; i++) + { + Destination[i] = Source[i]; + } + + Destination[i] = 0; + + /* Return string length including the NULL terminator */ + + return ((UINT16) (i + 1)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetResourceSource + * + * PARAMETERS: ResourceLength - Length field of the descriptor + * MinimumLength - Minimum length of the descriptor (minus + * any optional fields) + * ResourceSource - Where the ResourceSource is returned + * Aml - Pointer to the raw AML descriptor + * StringPtr - (optional) where to store the actual + * ResourceSource string + * + * RETURN: Length of the string plus NULL terminator, rounded up to native + * word boundary + * + * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor + * to an internal resource descriptor + * + ******************************************************************************/ + +ACPI_RS_LENGTH +AcpiRsGetResourceSource ( + ACPI_RS_LENGTH ResourceLength, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource, + AML_RESOURCE *Aml, + char *StringPtr) +{ + ACPI_RSDESC_SIZE TotalLength; + UINT8 *AmlResourceSource; + + + ACPI_FUNCTION_ENTRY (); + + + TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); + AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); + + /* + * ResourceSource is present if the length of the descriptor is longer than + * the minimum length. + * + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the minimum length. + */ + if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) + { + /* Get the ResourceSourceIndex */ + + ResourceSource->Index = AmlResourceSource[0]; + + ResourceSource->StringPtr = StringPtr; + if (!StringPtr) + { + /* + * String destination pointer is not specified; Set the String + * pointer to the end of the current ResourceSource structure. + */ + ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource, + sizeof (ACPI_RESOURCE_SOURCE)); + } + + /* + * In order for the Resource length to be a multiple of the native + * word, calculate the length of the string (+1 for NULL terminator) + * and expand to the next word multiple. + * + * Zero the entire area of the buffer. + */ + TotalLength = (UINT32) ACPI_STRLEN ( + ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; + TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); + + ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); + + /* Copy the ResourceSource string to the destination */ + + ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, + ACPI_CAST_PTR (char, &AmlResourceSource[1])); + + return ((ACPI_RS_LENGTH) TotalLength); + } + + /* ResourceSource is not present */ + + ResourceSource->Index = 0; + ResourceSource->StringLength = 0; + ResourceSource->StringPtr = NULL; + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceSource + * + * PARAMETERS: Aml - Pointer to the raw AML descriptor + * MinimumLength - Minimum length of the descriptor (minus + * any optional fields) + * ResourceSource - Internal ResourceSource + + * + * RETURN: Total length of the AML descriptor + * + * DESCRIPTION: Convert an optional ResourceSource from internal format to a + * raw AML resource descriptor + * + ******************************************************************************/ + +ACPI_RSDESC_SIZE +AcpiRsSetResourceSource ( + AML_RESOURCE *Aml, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + UINT8 *AmlResourceSource; + ACPI_RSDESC_SIZE DescriptorLength; + + + ACPI_FUNCTION_ENTRY (); + + + DescriptorLength = MinimumLength; + + /* Non-zero string length indicates presence of a ResourceSource */ + + if (ResourceSource->StringLength) + { + /* Point to the end of the AML descriptor */ + + AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); + + /* Copy the ResourceSourceIndex */ + + AmlResourceSource[0] = (UINT8) ResourceSource->Index; + + /* Copy the ResourceSource string */ + + ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), + ResourceSource->StringPtr); + + /* + * Add the length of the string (+ 1 for null terminator) to the + * final descriptor length + */ + DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); + } + + /* Return the new total length of the AML descriptor */ + + return (DescriptorLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrtMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _PRT value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetPrtMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, + ACPI_BTYPE_PACKAGE, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Create a resource linked list from the byte stream buffer that comes + * back from the _CRS method execution. + */ + Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by EvaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetCrsMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _CRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetCrsMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, + ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by evaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrsMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _PRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetPrsMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, + ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by evaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetMethodData + * + * PARAMETERS: Handle - Handle to the containing object + * Path - Path to method, relative to Handle + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _CRS or _PRS value of an + * object contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetMethodData ( + ACPI_HANDLE Handle, + char *Path, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by EvaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetSrsMethodData + * + * PARAMETERS: Node - Device node + * InBuffer - Pointer to a buffer structure of the + * parameter + * + * RETURN: Status + * + * DESCRIPTION: This function is called to set the _SRS of an object contained + * in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + * Note: Parameters guaranteed valid by caller + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *InBuffer) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_OPERAND_OBJECT *Args[2]; + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + + + ACPI_FUNCTION_TRACE (RsSetSrsMethodData); + + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = Node; + Info->Pathname = METHOD_NAME__SRS; + Info->Parameters = Args; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + /* + * The InBuffer parameter will point to a linked list of + * resource parameters. It needs to be formatted into a + * byte stream to be sent in as an input parameter to _SRS + * + * Convert the linked list into a byte stream + */ + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Create and initialize the method parameter object */ + + Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!Args[0]) + { + /* + * Must free the buffer allocated above (otherwise it is freed + * later) + */ + ACPI_FREE (Buffer.Pointer); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Args[0]->Buffer.Length = (UINT32) Buffer.Length; + Args[0]->Buffer.Pointer = Buffer.Pointer; + Args[0]->Common.Flags = AOPOBJ_DATA_VALID; + Args[1] = NULL; + + /* Execute the method, no return value is expected */ + + Status = AcpiNsEvaluate (Info); + + /* Clean up and return the status from AcpiNsEvaluate */ + + AcpiUtRemoveReference (Args[0]); + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsxface.c b/reactos/drivers/bus/acpi/acpica/resources/rsxface.c new file mode 100644 index 00000000000..a509c7afc7a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsxface.c @@ -0,0 +1,713 @@ +/******************************************************************************* + * + * Module Name: rsxface - Public interfaces to the resource manager + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsxface") + +/* Local macros for 16,32-bit to 64-bit conversion */ + +#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) +#define ACPI_COPY_ADDRESS(Out, In) \ + ACPI_COPY_FIELD(Out, In, ResourceType); \ + ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ + ACPI_COPY_FIELD(Out, In, Decode); \ + ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ + ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ + ACPI_COPY_FIELD(Out, In, Info); \ + ACPI_COPY_FIELD(Out, In, Granularity); \ + ACPI_COPY_FIELD(Out, In, Minimum); \ + ACPI_COPY_FIELD(Out, In, Maximum); \ + ACPI_COPY_FIELD(Out, In, TranslationOffset); \ + ACPI_COPY_FIELD(Out, In, AddressLength); \ + ACPI_COPY_FIELD(Out, In, ResourceSource); + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiRsMatchVendorResource ( + ACPI_RESOURCE *Resource, + void *Context); + +static ACPI_STATUS +AcpiRsValidateParameters ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *Buffer, + ACPI_NAMESPACE_NODE **ReturnNode); + + +/******************************************************************************* + * + * FUNCTION: AcpiRsValidateParameters + * + * PARAMETERS: DeviceHandle - Handle to a device + * Buffer - Pointer to a data buffer + * ReturnNode - Pointer to where the device node is returned + * + * RETURN: Status + * + * DESCRIPTION: Common parameter validation for resource interfaces + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiRsValidateParameters ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *Buffer, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (RsValidateParameters); + + + /* + * Must have a valid handle to an ACPI device + */ + if (!DeviceHandle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Node = AcpiNsValidateHandle (DeviceHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (Node->Type != ACPI_TYPE_DEVICE) + { + return_ACPI_STATUS (AE_TYPE); + } + + /* + * Validate the user buffer object + * + * if there is a non-zero buffer length we also need a valid pointer in + * the buffer. If it's a zero buffer length, we'll be returning the + * needed buffer size (later), so keep going. + */ + Status = AcpiUtValidateBuffer (Buffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *ReturnNode = Node; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetIrqRoutingTable + * + * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying + * RetBuffer - Pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the IRQ routing table for a + * specific bus. The caller must first acquire a handle for the + * desired bus. The routine table is placed in the buffer pointed + * to by the RetBuffer variable parameter. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + * This function attempts to execute the _PRT method contained in + * the object indicated by the passed DeviceHandle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetIrqRoutingTable ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetPrtMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetCurrentResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * RetBuffer - Pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the current resources for a + * specific device. The caller must first acquire a handle for + * the desired device. The resource data is placed in the buffer + * pointed to by the RetBuffer variable parameter. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + * This function attempts to execute the _CRS method contained in + * the object indicated by the passed DeviceHandle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetCurrentResources); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetCrsMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetPossibleResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * RetBuffer - Pointer to a buffer to receive the + * resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get a list of the possible resources + * for a specific device. The caller must first acquire a handle + * for the desired device. The resource data is placed in the + * buffer pointed to by the RetBuffer variable. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetPossibleResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetPossibleResources); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetPrsMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources) + + +/******************************************************************************* + * + * FUNCTION: AcpiSetCurrentResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are setting resources + * InBuffer - Pointer to a buffer containing the + * resources to be set for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to set the current resources for a + * specific device. The caller must first acquire a handle for + * the desired device. The resource data is passed to the routine + * the buffer pointed to by the InBuffer variable. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *InBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiSetCurrentResources); + + + /* Validate the buffer, don't allow zero length */ + + if ((!InBuffer) || + (!InBuffer->Pointer) || + (!InBuffer->Length)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsSetSrsMethodData (Node, InBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources) + + +/****************************************************************************** + * + * FUNCTION: AcpiResourceToAddress64 + * + * PARAMETERS: Resource - Pointer to a resource + * Out - Pointer to the users's return buffer + * (a struct acpi_resource_address64) + * + * RETURN: Status + * + * DESCRIPTION: If the resource is an address16, address32, or address64, + * copy it to the address64 return buffer. This saves the + * caller from having to duplicate code for different-sized + * addresses. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiResourceToAddress64 ( + ACPI_RESOURCE *Resource, + ACPI_RESOURCE_ADDRESS64 *Out) +{ + ACPI_RESOURCE_ADDRESS16 *Address16; + ACPI_RESOURCE_ADDRESS32 *Address32; + + + if (!Resource || !Out) + { + return (AE_BAD_PARAMETER); + } + + /* Convert 16 or 32 address descriptor to 64 */ + + switch (Resource->Type) + { + case ACPI_RESOURCE_TYPE_ADDRESS16: + + Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data); + ACPI_COPY_ADDRESS (Out, Address16); + break; + + case ACPI_RESOURCE_TYPE_ADDRESS32: + + Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data); + ACPI_COPY_ADDRESS (Out, Address32); + break; + + case ACPI_RESOURCE_TYPE_ADDRESS64: + + /* Simple copy for 64 bit source */ + + ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64)); + break; + + default: + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetVendorResource + * + * PARAMETERS: DeviceHandle - Handle for the parent device object + * Name - Method name for the parent resource + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * Uuid - Pointer to the UUID to be matched. + * includes both subtype and 16-byte UUID + * RetBuffer - Where the vendor resource is returned + * + * RETURN: Status + * + * DESCRIPTION: Walk a resource template for the specified evice to find a + * vendor-defined resource that matches the supplied UUID and + * UUID subtype. Returns a ACPI_RESOURCE of type Vendor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetVendorResource ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_VENDOR_UUID *Uuid, + ACPI_BUFFER *RetBuffer) +{ + ACPI_VENDOR_WALK_INFO Info; + ACPI_STATUS Status; + + + /* Other parameters are validated by AcpiWalkResources */ + + if (!Uuid || !RetBuffer) + { + return (AE_BAD_PARAMETER); + } + + Info.Uuid = Uuid; + Info.Buffer = RetBuffer; + Info.Status = AE_NOT_EXIST; + + /* Walk the _CRS or _PRS resource list for this device */ + + Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource, + &Info); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + return (Info.Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetVendorResource) + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMatchVendorResource + * + * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiRsMatchVendorResource ( + ACPI_RESOURCE *Resource, + void *Context) +{ + ACPI_VENDOR_WALK_INFO *Info = Context; + ACPI_RESOURCE_VENDOR_TYPED *Vendor; + ACPI_BUFFER *Buffer; + ACPI_STATUS Status; + + + /* Ignore all descriptors except Vendor */ + + if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR) + { + return (AE_OK); + } + + Vendor = &Resource->Data.VendorTyped; + + /* + * For a valid match, these conditions must hold: + * + * 1) Length of descriptor data must be at least as long as a UUID struct + * 2) The UUID subtypes must match + * 3) The UUID data must match + */ + if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) || + (Vendor->UuidSubtype != Info->Uuid->Subtype) || + (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH))) + { + return (AE_OK); + } + + /* Validate/Allocate/Clear caller buffer */ + + Buffer = Info->Buffer; + Status = AcpiUtInitializeBuffer (Buffer, Resource->Length); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Found the correct resource, copy and return it */ + + ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length); + Buffer->Length = Resource->Length; + + /* Found the desired descriptor, terminate resource walk */ + + Info->Status = AE_OK; + return (AE_CTRL_TERMINATE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiWalkResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * Name - Method name of the resources we want + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * UserFunction - Called for each resource + * Context - Passed to UserFunction + * + * RETURN: Status + * + * DESCRIPTION: Retrieves the current or possible resource list for the + * specified device. The UserFunction is called once for + * each resource in the list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkResources ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_WALK_RESOURCE_CALLBACK UserFunction, + void *Context) +{ + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + ACPI_RESOURCE *Resource; + ACPI_RESOURCE *ResourceEnd; + + + ACPI_FUNCTION_TRACE (AcpiWalkResources); + + + /* Parameter validation */ + + if (!DeviceHandle || !UserFunction || !Name || + (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) && + !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the _CRS or _PRS resource list */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Buffer now contains the resource list */ + + Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer); + ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length); + + /* Walk the resource list until the EndTag is found (or buffer end) */ + + while (Resource < ResourceEnd) + { + /* Sanity check the resource */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + Status = AE_AML_INVALID_RESOURCE_TYPE; + break; + } + + /* Invoke the user function, abort on any error returned */ + + Status = UserFunction (Resource, Context); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_TERMINATE) + { + /* This is an OK termination by the user function */ + + Status = AE_OK; + } + break; + } + + /* EndTag indicates end-of-list */ + + if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) + { + break; + } + + /* Get the next resource descriptor */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + ACPI_FREE (Buffer.Pointer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWalkResources) diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbconvrt.c b/reactos/drivers/bus/acpi/acpica/tables/tbconvrt.c new file mode 100644 index 00000000000..77ece2ae07a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbconvrt.c @@ -0,0 +1,547 @@ +/****************************************************************************** + * + * Module Name: tbconvrt - ACPI Table conversion utilities + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include + +#define _COMPONENT ACPI_TABLES + MODULE_NAME ("tbconvrt") + + +/* + * Build a GAS structure from earlier ACPI table entries (V1.0 and 0.71 extensions) + * + * 1) Address space + * 2) Length in bytes -- convert to length in bits + * 3) Bit offset is zero + * 4) Reserved field is zero + * 5) Expand address to 64 bits + */ +#define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d) {a.address_space_id = (u8) d;\ + a.register_bit_width = (u8) MUL_8 (b);\ + a.register_bit_offset = 0;\ + a.reserved = 0;\ + ACPI_STORE_ADDRESS (a.address,c);} + + +/* ACPI V1.0 entries -- address space is always I/O */ + +#define ASL_BUILD_GAS_FROM_V1_ENTRY(a,b,c) ASL_BUILD_GAS_FROM_ENTRY(a,b,c,ADDRESS_SPACE_SYSTEM_IO) + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_to_xsdt + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_convert_to_xsdt ( + ACPI_TABLE_DESC *table_info, + u32 *number_of_tables) { + u32 table_size; + u32 pointer_size; + u32 i; + XSDT_DESCRIPTOR *new_table; + + +#ifndef _IA64 + + if (acpi_gbl_RSDP->revision < 2) { + pointer_size = sizeof (u32); + } + + else +#endif + { + pointer_size = 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. + */ + + table_size = table_info->pointer->length; + *number_of_tables = (table_size - + sizeof (ACPI_TABLE_HEADER)) / pointer_size; + + /* Compute size of the converted XSDT */ + + table_size = (*number_of_tables * sizeof (UINT64)) + sizeof (ACPI_TABLE_HEADER); + + + /* Allocate an XSDT */ + + new_table = acpi_cm_callocate (table_size); + if (!new_table) { + return (AE_NO_MEMORY); + } + + /* Copy the header and set the length */ + + MEMCPY (new_table, table_info->pointer, sizeof (ACPI_TABLE_HEADER)); + new_table->header.length = table_size; + + /* Copy the table pointers */ + + for (i = 0; i < *number_of_tables; i++) { + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + new_table->table_offset_entry[i] = + ((RSDT_DESCRIPTOR_REV071 *) table_info->pointer)->table_offset_entry[i]; +#else + ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], + ((RSDT_DESCRIPTOR_REV1 *) table_info->pointer)->table_offset_entry[i]); +#endif + } + else { + new_table->table_offset_entry[i] = + ((XSDT_DESCRIPTOR *) table_info->pointer)->table_offset_entry[i]; + } + } + + + /* Delete the original table (either mapped or in a buffer) */ + + acpi_tb_delete_single_table (table_info); + + + /* Point the table descriptor to the new table */ + + table_info->pointer = (ACPI_TABLE_HEADER *) new_table; + table_info->base_pointer = (ACPI_TABLE_HEADER *) new_table; + table_info->length = table_size; + table_info->allocation = ACPI_MEM_ALLOCATED; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_table_fadt + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * Converts BIOS supplied 1.0 and 0.71 ACPI FADT to an intermediate + * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply + * copied to the intermediate FADT. The ACPI CA software uses this + * intermediate FADT. Thus a significant amount of special #ifdef + * type codeing is saved. This intermediate FADT will need to be + * freed at some point. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_convert_table_fadt (void) +{ + +#ifdef _IA64 + FADT_DESCRIPTOR_REV071 *FADT71; + u8 pm1_address_space; + u8 pm2_address_space; + u8 pm_timer_address_space; + u8 gpe0address_space; + u8 gpe1_address_space; +#else + FADT_DESCRIPTOR_REV1 *FADT1; +#endif + + FADT_DESCRIPTOR_REV2 *FADT2; + ACPI_TABLE_DESC *table_desc; + + + /* Acpi_gbl_FADT is valid */ + /* Allocate and zero the 2.0 buffer */ + + FADT2 = acpi_cm_callocate (sizeof (FADT_DESCRIPTOR_REV2)); + if (FADT2 == NULL) { + return (AE_NO_MEMORY); + } + + + /* The ACPI FADT revision number is FADT2_REVISION_ID=3 */ + /* So, if the current table revision is less than 3 it is type 1.0 or 0.71 */ + + if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) { + /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ + + *FADT2 = *((FADT_DESCRIPTOR_REV2*) acpi_gbl_FADT); + + } + + else { + +#ifdef _IA64 + /* + * For the 64-bit case only, a revision ID less than V2.0 means the + * tables are the 0.71 extensions + */ + + /* The BIOS stored FADT should agree with Revision 0.71 */ + + FADT71 = (FADT_DESCRIPTOR_REV071 *) acpi_gbl_FADT; + + /* Copy the table header*/ + + FADT2->header = FADT71->header; + + /* Copy the common fields */ + + FADT2->sci_int = FADT71->sci_int; + FADT2->acpi_enable = FADT71->acpi_enable; + FADT2->acpi_disable = FADT71->acpi_disable; + FADT2->S4_bios_req = FADT71->S4_bios_req; + FADT2->plvl2_lat = FADT71->plvl2_lat; + FADT2->plvl3_lat = FADT71->plvl3_lat; + FADT2->day_alrm = FADT71->day_alrm; + FADT2->mon_alrm = FADT71->mon_alrm; + FADT2->century = FADT71->century; + FADT2->gpe1_base = FADT71->gpe1_base; + + /* + * We still use the block length registers even though + * the GAS structure should obsolete them. This is because + * these registers are byte lengths versus the GAS which + * contains a bit width + */ + FADT2->pm1_evt_len = FADT71->pm1_evt_len; + FADT2->pm1_cnt_len = FADT71->pm1_cnt_len; + FADT2->pm2_cnt_len = FADT71->pm2_cnt_len; + FADT2->pm_tm_len = FADT71->pm_tm_len; + FADT2->gpe0blk_len = FADT71->gpe0blk_len; + FADT2->gpe1_blk_len = FADT71->gpe1_blk_len; + FADT2->gpe1_base = FADT71->gpe1_base; + + /* Copy the existing 0.71 flags to 2.0. The other bits are zero.*/ + + FADT2->wb_invd = FADT71->flush_cash; + FADT2->proc_c1 = FADT71->proc_c1; + FADT2->plvl2_up = FADT71->plvl2_up; + FADT2->pwr_button = FADT71->pwr_button; + FADT2->sleep_button = FADT71->sleep_button; + FADT2->fixed_rTC = FADT71->fixed_rTC; + FADT2->rtcs4 = FADT71->rtcs4; + FADT2->tmr_val_ext = FADT71->tmr_val_ext; + FADT2->dock_cap = FADT71->dock_cap; + + + /* We should not use these next two addresses */ + /* Since our buffer is pre-zeroed nothing to do for */ + /* the next three data items in the structure */ + /* FADT2->Firmware_ctrl = 0; */ + /* FADT2->Dsdt = 0; */ + + /* System Interrupt Model isn't used in ACPI 2.0*/ + /* FADT2->Reserved1 = 0; */ + + /* This field is set by the OEM to convey the preferred */ + /* power management profile to OSPM. It doesn't have any*/ + /* 0.71 equivalence. Since we don't know what kind of */ + /* 64-bit system this is, we will pick unspecified. */ + + FADT2->prefer_PM_profile = PM_UNSPECIFIED; + + + /* Port address of SMI command port */ + /* We shouldn't use this port because IA64 doesn't */ + /* have or use SMI. It has PMI. */ + + FADT2->smi_cmd = (u32)(FADT71->smi_cmd & 0xFFFFFFFF); + + + /* processor performance state control*/ + /* The value OSPM writes to the SMI_CMD register to assume */ + /* processor performance state control responsibility. */ + /* There isn't any equivalence in 0.71 */ + /* Again this should be meaningless for IA64 */ + /* FADT2->Pstate_cnt = 0; */ + + /* The 32-bit Power management and GPE registers are */ + /* not valid in IA-64 and we are not going to use them */ + /* so leaving them pre-zeroed. */ + + /* Support for the _CST object and C States change notification.*/ + /* This data item hasn't any 0.71 equivalence so leaving it zero.*/ + /* FADT2->Cst_cnt = 0; */ + + /* number of flush strides that need to be read */ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Flush_size = 0; */ + + /* Processor's memory cache line width, in bytes */ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Flush_stride = 0; */ + + /* Processor's duty cycle index in processor's P_CNT reg*/ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Duty_offset = 0; */ + + /* Processor's duty cycle value bit width in P_CNT register.*/ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Duty_width = 0; */ + + + /* Since there isn't any equivalence in 0.71 */ + /* and since Big_sur had to support legacy */ + + FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES; + + /* Copy to ACPI 2.0 64-BIT Extended Addresses */ + + FADT2->Xfirmware_ctrl = FADT71->firmware_ctrl; + FADT2->Xdsdt = FADT71->dsdt; + + + /* Extract the address space IDs */ + + pm1_address_space = (u8)((FADT71->address_space & PM1_BLK_ADDRESS_SPACE) >> 1); + pm2_address_space = (u8)((FADT71->address_space & PM2_CNT_BLK_ADDRESS_SPACE) >> 2); + pm_timer_address_space = (u8)((FADT71->address_space & PM_TMR_BLK_ADDRESS_SPACE) >> 3); + gpe0address_space = (u8)((FADT71->address_space & GPE0_BLK_ADDRESS_SPACE) >> 4); + gpe1_address_space = (u8)((FADT71->address_space & GPE1_BLK_ADDRESS_SPACE) >> 5); + + /* + * Convert the 0.71 (non-GAS style) Block addresses to V2.0 GAS structures, + * in this order: + * + * PM 1_a Events + * PM 1_b Events + * PM 1_a Control + * PM 1_b Control + * PM 2 Control + * PM Timer Control + * GPE Block 0 + * GPE Block 1 + */ + + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_evt_blk, FADT71->pm1_evt_len, FADT71->pm1a_evt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_evt_blk, FADT71->pm1_evt_len, FADT71->pm1b_evt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1a_cnt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1b_cnt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm2_cnt_blk, FADT71->pm2_cnt_len, FADT71->pm2_cnt_blk, pm2_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm_tmr_blk, FADT71->pm_tm_len, FADT71->pm_tmr_blk, pm_timer_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe0blk, FADT71->gpe0blk_len, FADT71->gpe0blk, gpe0address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe1_blk, FADT71->gpe1_blk_len, FADT71->gpe1_blk, gpe1_address_space); + +#else + + /* ACPI 1.0 FACS */ + + + /* The BIOS stored FADT should agree with Revision 1.0 */ + + FADT1 = (FADT_DESCRIPTOR_REV1*) acpi_gbl_FADT; + + /* + * Copy the table header and the common part of the tables + * The 2.0 table is an extension of the 1.0 table, so the + * entire 1.0 table can be copied first, then expand some + * fields to 64 bits. + */ + + MEMCPY (FADT2, FADT1, sizeof (FADT_DESCRIPTOR_REV1)); + + + /* Convert table pointers to 64-bit fields */ + + ACPI_STORE_ADDRESS (FADT2->Xfirmware_ctrl, FADT1->firmware_ctrl); + ACPI_STORE_ADDRESS (FADT2->Xdsdt, FADT1->dsdt); + + /* System Interrupt Model isn't used in ACPI 2.0*/ + /* FADT2->Reserved1 = 0; */ + + /* This field is set by the OEM to convey the preferred */ + /* power management profile to OSPM. It doesn't have any*/ + /* 1.0 equivalence. Since we don't know what kind of */ + /* 32-bit system this is, we will pick unspecified. */ + + FADT2->prefer_PM_profile = PM_UNSPECIFIED; + + + /* Processor Performance State Control. This is the value */ + /* OSPM writes to the SMI_CMD register to assume processor */ + /* performance state control responsibility. There isn't */ + /* any equivalence in 1.0. So leave it zeroed. */ + + FADT2->pstate_cnt = 0; + + + /* Support for the _CST object and C States change notification.*/ + /* This data item hasn't any 1.0 equivalence so leaving it zero.*/ + + FADT2->cst_cnt = 0; + + + /* Since there isn't any equivalence in 1.0 and since it */ + /* is highly likely that a 1.0 system has legacy support. */ + + FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES; + + + /* + * Convert the V1.0 Block addresses to V2.0 GAS structures + * in this order: + * + * PM 1_a Events + * PM 1_b Events + * PM 1_a Control + * PM 1_b Control + * PM 2 Control + * PM Timer Control + * GPE Block 0 + * GPE Block 1 + */ + + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_evt_blk, FADT1->pm1_evt_len, FADT1->pm1a_evt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_evt_blk, FADT1->pm1_evt_len, FADT1->pm1b_evt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1a_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1b_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm2_cnt_blk, FADT1->pm2_cnt_len, FADT1->pm2_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm_tmr_blk, FADT1->pm_tm_len, FADT1->pm_tmr_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe0blk, FADT1->gpe0blk_len, FADT1->gpe0blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe1_blk, FADT1->gpe1_blk_len, FADT1->gpe1_blk); +#endif + } + + + /* + * Global FADT pointer will point to the common V2.0 FADT + */ + acpi_gbl_FADT = FADT2; + acpi_gbl_FADT->header.length = sizeof (FADT_DESCRIPTOR); + + + /* Free the original table */ + + table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_FADT]; + acpi_tb_delete_single_table (table_desc); + + + /* Install the new table */ + + table_desc->pointer = (ACPI_TABLE_HEADER *) acpi_gbl_FADT; + table_desc->base_pointer = acpi_gbl_FADT; + table_desc->allocation = ACPI_MEM_ALLOCATED; + table_desc->length = sizeof (FADT_DESCRIPTOR_REV2); + + + /* Dump the entire FADT */ + + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_table_facs + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_build_common_facs ( + ACPI_TABLE_DESC *table_info) +{ + ACPI_COMMON_FACS *common_facs; + +#ifdef _IA64 + FACS_DESCRIPTOR_REV071 *FACS71; +#else + FACS_DESCRIPTOR_REV1 *FACS1; +#endif + + FACS_DESCRIPTOR_REV2 *FACS2; + + + /* Allocate a common FACS */ + + common_facs = acpi_cm_callocate (sizeof (ACPI_COMMON_FACS)); + if (!common_facs) { + return (AE_NO_MEMORY); + } + + + /* Copy fields to the new FACS */ + + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + /* 0.71 FACS */ + + FACS71 = (FACS_DESCRIPTOR_REV071 *) acpi_gbl_FACS; + + common_facs->global_lock = (u32 *) &(FACS71->global_lock); + common_facs->firmware_waking_vector = &FACS71->firmware_waking_vector; + common_facs->vector_width = 64; +#else + /* ACPI 1.0 FACS */ + + FACS1 = (FACS_DESCRIPTOR_REV1 *) acpi_gbl_FACS; + + common_facs->global_lock = &(FACS1->global_lock); + common_facs->firmware_waking_vector = (UINT64 *) &FACS1->firmware_waking_vector; + common_facs->vector_width = 32; + +#endif + } + + else { + /* ACPI 2.0 FACS */ + + FACS2 = (FACS_DESCRIPTOR_REV2 *) acpi_gbl_FACS; + + common_facs->global_lock = &(FACS2->global_lock); + common_facs->firmware_waking_vector = &FACS2->Xfirmware_waking_vector; + common_facs->vector_width = 64; + } + + + /* Set the global FACS pointer to point to the common FACS */ + + + acpi_gbl_FACS = common_facs; + + return (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c b/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c new file mode 100644 index 00000000000..c657a0b75ac --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c @@ -0,0 +1,752 @@ +/****************************************************************************** + * + * Module Name: tbfadt - FADT table utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBFADT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbfadt") + +/* Local prototypes */ + +static inline void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *GenericAddress, + UINT8 SpaceId, + UINT8 ByteWidth, + UINT64 Address); + +static void +AcpiTbConvertFadt ( + void); + +static void +AcpiTbValidateFadt ( + void); + +static void +AcpiTbSetupFadtRegisters ( + void); + + +/* Table for conversion of FADT to common internal format and FADT validation */ + +typedef struct acpi_fadt_info +{ + char *Name; + UINT8 Address64; + UINT8 Address32; + UINT8 Length; + UINT8 DefaultLength; + UINT8 Type; + +} ACPI_FADT_INFO; + +#define ACPI_FADT_REQUIRED 1 +#define ACPI_FADT_SEPARATE_LENGTH 2 + +static ACPI_FADT_INFO FadtInfoTable[] = +{ + {"Pm1aEventBlock", + ACPI_FADT_OFFSET (XPm1aEventBlock), + ACPI_FADT_OFFSET (Pm1aEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), + ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ + ACPI_FADT_REQUIRED}, + + {"Pm1bEventBlock", + ACPI_FADT_OFFSET (XPm1bEventBlock), + ACPI_FADT_OFFSET (Pm1bEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), + ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ + 0}, + + {"Pm1aControlBlock", + ACPI_FADT_OFFSET (XPm1aControlBlock), + ACPI_FADT_OFFSET (Pm1aControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), + ACPI_PM1_REGISTER_WIDTH, + ACPI_FADT_REQUIRED}, + + {"Pm1bControlBlock", + ACPI_FADT_OFFSET (XPm1bControlBlock), + ACPI_FADT_OFFSET (Pm1bControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), + ACPI_PM1_REGISTER_WIDTH, + 0}, + + {"Pm2ControlBlock", + ACPI_FADT_OFFSET (XPm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlLength), + ACPI_PM2_REGISTER_WIDTH, + ACPI_FADT_SEPARATE_LENGTH}, + + {"PmTimerBlock", + ACPI_FADT_OFFSET (XPmTimerBlock), + ACPI_FADT_OFFSET (PmTimerBlock), + ACPI_FADT_OFFSET (PmTimerLength), + ACPI_PM_TIMER_WIDTH, + ACPI_FADT_REQUIRED}, + + {"Gpe0Block", + ACPI_FADT_OFFSET (XGpe0Block), + ACPI_FADT_OFFSET (Gpe0Block), + ACPI_FADT_OFFSET (Gpe0BlockLength), + 0, + ACPI_FADT_SEPARATE_LENGTH}, + + {"Gpe1Block", + ACPI_FADT_OFFSET (XGpe1Block), + ACPI_FADT_OFFSET (Gpe1Block), + ACPI_FADT_OFFSET (Gpe1BlockLength), + 0, + ACPI_FADT_SEPARATE_LENGTH} +}; + +#define ACPI_FADT_INFO_ENTRIES \ + (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO)) + + +/* Table used to split Event Blocks into separate status/enable registers */ + +typedef struct acpi_fadt_pm_info +{ + ACPI_GENERIC_ADDRESS *Target; + UINT8 Source; + UINT8 RegisterNum; + +} ACPI_FADT_PM_INFO; + +static ACPI_FADT_PM_INFO FadtPmInfoTable[] = +{ + {&AcpiGbl_XPm1aStatus, + ACPI_FADT_OFFSET (XPm1aEventBlock), + 0}, + + {&AcpiGbl_XPm1aEnable, + ACPI_FADT_OFFSET (XPm1aEventBlock), + 1}, + + {&AcpiGbl_XPm1bStatus, + ACPI_FADT_OFFSET (XPm1bEventBlock), + 0}, + + {&AcpiGbl_XPm1bEnable, + ACPI_FADT_OFFSET (XPm1bEventBlock), + 1} +}; + +#define ACPI_FADT_PM_INFO_ENTRIES \ + (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO)) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitGenericAddress + * + * PARAMETERS: GenericAddress - GAS struct to be initialized + * SpaceId - ACPI Space ID for this register + * ByteWidth - Width of this register, in bytes + * Address - Address of the register + * + * RETURN: None + * + * DESCRIPTION: Initialize a Generic Address Structure (GAS) + * See the ACPI specification for a full description and + * definition of this structure. + * + ******************************************************************************/ + +static inline void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *GenericAddress, + UINT8 SpaceId, + UINT8 ByteWidth, + UINT64 Address) +{ + + /* + * The 64-bit Address field is non-aligned in the byte packed + * GAS struct. + */ + ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address); + + /* All other fields are byte-wide */ + + GenericAddress->SpaceId = SpaceId; + GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth); + GenericAddress->BitOffset = 0; + GenericAddress->AccessWidth = 0; /* Access width ANY */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbParseFadt + * + * PARAMETERS: TableIndex - Index for the FADT + * + * RETURN: None + * + * DESCRIPTION: Initialize the FADT, DSDT and FACS tables + * (FADT contains the addresses of the DSDT and FACS) + * + ******************************************************************************/ + +void +AcpiTbParseFadt ( + UINT32 TableIndex) +{ + UINT32 Length; + ACPI_TABLE_HEADER *Table; + + + /* + * The FADT has multiple versions with different lengths, + * and it contains pointers to both the DSDT and FACS tables. + * + * Get a local copy of the FADT and convert it to a common format + * Map entire FADT, assumed to be smaller than one page. + */ + Length = AcpiGbl_RootTableList.Tables[TableIndex].Length; + + Table = AcpiOsMapMemory ( + AcpiGbl_RootTableList.Tables[TableIndex].Address, Length); + if (!Table) + { + return; + } + + /* + * Validate the FADT checksum before we copy the table. Ignore + * checksum error as we want to try to get the DSDT and FACS. + */ + (void) AcpiTbVerifyChecksum (Table, Length); + + /* Create a local copy of the FADT in common ACPI 2.0+ format */ + + AcpiTbCreateLocalFadt (Table, Length); + + /* All done with the real FADT, unmap it */ + + AcpiOsUnmapMemory (Table, Length); + + /* Obtain the DSDT and FACS tables via their addresses within the FADT */ + + AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, + ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); + + AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, + ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCreateLocalFadt + * + * PARAMETERS: Table - Pointer to BIOS FADT + * Length - Length of the table + * + * RETURN: None + * + * DESCRIPTION: Get a local copy of the FADT and convert it to a common format. + * Performs validation on some important FADT fields. + * + * NOTE: We create a local copy of the FADT regardless of the version. + * + ******************************************************************************/ + +void +AcpiTbCreateLocalFadt ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) +{ + + /* + * Check if the FADT is larger than the largest table that we expect + * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue + * a warning. + */ + if (Length > sizeof (ACPI_TABLE_FADT)) + { + ACPI_WARNING ((AE_INFO, + "FADT (revision %u) is longer than ACPI 2.0 version, " + "truncating length 0x%X to 0x%X", + Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT))); + } + + /* Clear the entire local FADT */ + + ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT)); + + /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */ + + ACPI_MEMCPY (&AcpiGbl_FADT, Table, + ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT))); + + /* Convert the local copy of the FADT to the common internal format */ + + AcpiTbConvertFadt (); + + /* Validate FADT values now, before we make any changes */ + + AcpiTbValidateFadt (); + + /* Initialize the global ACPI register structures */ + + AcpiTbSetupFadtRegisters (); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbConvertFadt + * + * PARAMETERS: None, uses AcpiGbl_FADT + * + * RETURN: None + * + * DESCRIPTION: Converts all versions of the FADT to a common internal format. + * Expand 32-bit addresses to 64-bit as necessary. + * + * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), + * and must contain a copy of the actual FADT. + * + * Notes on 64-bit register addresses: + * + * After this FADT conversion, later ACPICA code will only use the 64-bit "X" + * fields of the FADT for all ACPI register addresses. + * + * The 64-bit "X" fields are optional extensions to the original 32-bit FADT + * V1.0 fields. Even if they are present in the FADT, they are optional and + * are unused if the BIOS sets them to zero. Therefore, we must copy/expand + * 32-bit V1.0 fields if the corresponding X field is zero. + * + * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the + * corresponding "X" fields in the internal FADT. + * + * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded + * to the corresponding 64-bit X fields. For compatibility with other ACPI + * implementations, we ignore the 64-bit field if the 32-bit field is valid, + * regardless of whether the host OS is 32-bit or 64-bit. + * + ******************************************************************************/ + +static void +AcpiTbConvertFadt ( + void) +{ + ACPI_GENERIC_ADDRESS *Address64; + UINT32 Address32; + UINT32 i; + + + /* Update the local FADT table header length */ + + AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT); + + /* + * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. + * Later code will always use the X 64-bit field. + */ + if (!AcpiGbl_FADT.XFacs) + { + AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; + } + if (!AcpiGbl_FADT.XDsdt) + { + AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; + } + + /* + * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which + * should be zero are indeed zero. This will workaround BIOSs that + * inadvertently place values in these fields. + * + * The ACPI 1.0 reserved fields that will be zeroed are the bytes located + * at offset 45, 55, 95, and the word located at offset 109, 110. + */ + if (AcpiGbl_FADT.Header.Revision < 3) + { + AcpiGbl_FADT.PreferredProfile = 0; + AcpiGbl_FADT.PstateControl = 0; + AcpiGbl_FADT.CstControl = 0; + AcpiGbl_FADT.BootFlags = 0; + } + + /* + * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" + * generic address structures as necessary. Later code will always use + * the 64-bit address structures. + * + * March 2009: + * We now always use the 32-bit address if it is valid (non-null). This + * is not in accordance with the ACPI specification which states that + * the 64-bit address supersedes the 32-bit version, but we do this for + * compatibility with other ACPI implementations. Most notably, in the + * case where both the 32 and 64 versions are non-null, we use the 32-bit + * version. This is the only address that is guaranteed to have been + * tested by the BIOS manufacturer. + */ + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + Address32 = *ACPI_ADD_PTR (UINT32, + &AcpiGbl_FADT, FadtInfoTable[i].Address32); + + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + + /* + * If both 32- and 64-bit addresses are valid (non-zero), + * they must match. + */ + if (Address64->Address && Address32 && + (Address64->Address != (UINT64) Address32)) + { + ACPI_ERROR ((AE_INFO, + "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 32", + FadtInfoTable[i].Name, Address32, + ACPI_FORMAT_UINT64 (Address64->Address))); + } + + /* Always use 32-bit address if it is valid (non-null) */ + + if (Address32) + { + /* + * Copy the 32-bit address to the 64-bit GAS structure. The + * Space ID is always I/O for 32-bit legacy address fields + */ + AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length), + (UINT64) Address32); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateFadt + * + * PARAMETERS: Table - Pointer to the FADT to be validated + * + * RETURN: None + * + * DESCRIPTION: Validate various important fields within the FADT. If a problem + * is found, issue a message, but no status is returned. + * Used by both the table manager and the disassembler. + * + * Possible additional checks: + * (AcpiGbl_FADT.Pm1EventLength >= 4) + * (AcpiGbl_FADT.Pm1ControlLength >= 2) + * (AcpiGbl_FADT.PmTimerLength >= 4) + * Gpe block lengths must be multiple of 2 + * + ******************************************************************************/ + +static void +AcpiTbValidateFadt ( + void) +{ + char *Name; + ACPI_GENERIC_ADDRESS *Address64; + UINT8 Length; + UINT32 i; + + + /* + * Check for FACS and DSDT address mismatches. An address mismatch between + * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and + * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. + */ + if (AcpiGbl_FADT.Facs && + (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs)) + { + ACPI_WARNING ((AE_INFO, + "32/64X FACS address mismatch in FADT - " + "%8.8X/%8.8X%8.8X, using 32", + AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs))); + + AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; + } + + if (AcpiGbl_FADT.Dsdt && + (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt)) + { + ACPI_WARNING ((AE_INFO, + "32/64X DSDT address mismatch in FADT - " + "%8.8X/%8.8X%8.8X, using 32", + AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt))); + + AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; + } + + /* Examine all of the 64-bit extended address fields (X fields) */ + + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + /* + * Generate pointer to the 64-bit address, get the register + * length (width) and the register name + */ + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + Length = *ACPI_ADD_PTR (UINT8, + &AcpiGbl_FADT, FadtInfoTable[i].Length); + Name = FadtInfoTable[i].Name; + + /* + * For each extended field, check for length mismatch between the + * legacy length field and the corresponding 64-bit X length field. + */ + if (Address64->Address && + (Address64->BitWidth != ACPI_MUL_8 (Length))) + { + ACPI_WARNING ((AE_INFO, + "32/64X length mismatch in %s: %d/%d", + Name, ACPI_MUL_8 (Length), Address64->BitWidth)); + } + + if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED) + { + /* + * Field is required (PM1aEvent, PM1aControl, PmTimer). + * Both the address and length must be non-zero. + */ + if (!Address64->Address || !Length) + { + ACPI_ERROR ((AE_INFO, + "Required field %s has zero address and/or length:" + " %8.8X%8.8X/%X", + Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + } + } + else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH) + { + /* + * Field is optional (PM2Control, GPE0, GPE1) AND has its own + * length field. If present, both the address and length must + * be valid. + */ + if ((Address64->Address && !Length) || + (!Address64->Address && Length)) + { + ACPI_WARNING ((AE_INFO, + "Optional field %s has zero address or length: " + "%8.8X%8.8X/%X", + Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + } + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetupFadtRegisters + * + * PARAMETERS: None, uses AcpiGbl_FADT. + * + * RETURN: None + * + * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally, + * force FADT register definitions to their default lengths. + * + ******************************************************************************/ + +static void +AcpiTbSetupFadtRegisters ( + void) +{ + ACPI_GENERIC_ADDRESS *Target64; + ACPI_GENERIC_ADDRESS *Source64; + UINT8 Pm1RegisterByteWidth; + UINT32 i; + + + /* + * Optionally check all register lengths against the default values and + * update them if they are incorrect. + */ + if (AcpiGbl_UseDefaultRegisterWidths) + { + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, + FadtInfoTable[i].Address64); + + /* + * If a valid register (Address != 0) and the (DefaultLength > 0) + * (Not a GPE register), then check the width against the default. + */ + if ((Target64->Address) && + (FadtInfoTable[i].DefaultLength > 0) && + (FadtInfoTable[i].DefaultLength != Target64->BitWidth)) + { + ACPI_WARNING ((AE_INFO, + "Invalid length for %s: %d, using default %d", + FadtInfoTable[i].Name, Target64->BitWidth, + FadtInfoTable[i].DefaultLength)); + + /* Incorrect size, set width to the default */ + + Target64->BitWidth = FadtInfoTable[i].DefaultLength; + } + } + } + + /* + * Get the length of the individual PM1 registers (enable and status). + * Each register is defined to be (event block length / 2). Extra divide + * by 8 converts bits to bytes. + */ + Pm1RegisterByteWidth = (UINT8) + ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth); + + /* + * Calculate separate GAS structs for the PM1x (A/B) Status and Enable + * registers. These addresses do not appear (directly) in the FADT, so it + * is useful to pre-calculate them from the PM1 Event Block definitions. + * + * The PM event blocks are split into two register blocks, first is the + * PM Status Register block, followed immediately by the PM Enable + * Register block. Each is of length (Pm1EventLength/2) + * + * Note: The PM1A event block is required by the ACPI specification. + * However, the PM1B event block is optional and is rarely, if ever, + * used. + */ + + for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++) + { + Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, + FadtPmInfoTable[i].Source); + + if (Source64->Address) + { + AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target, + Source64->SpaceId, Pm1RegisterByteWidth, + Source64->Address + + (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth)); + } + } +} + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbfind.c b/reactos/drivers/bus/acpi/acpica/tables/tbfind.c new file mode 100644 index 00000000000..1838b5eb78a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbfind.c @@ -0,0 +1,215 @@ +/****************************************************************************** + * + * Module Name: tbfind - find table + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBFIND_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbfind") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFindTable + * + * PARAMETERS: Signature - String with ACPI table signature + * OemId - String with the table OEM ID + * OemTableId - String with the OEM Table ID + * TableIndex - Where the table index is returned + * + * RETURN: Status and table index + * + * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the + * Signature, OEM ID and OEM Table ID. Returns an index that can + * be used to get the table header or entire table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + UINT32 *TableIndex) +{ + UINT32 i; + ACPI_STATUS Status; + ACPI_TABLE_HEADER Header; + + + ACPI_FUNCTION_TRACE (TbFindTable); + + + /* Normalize the input strings */ + + ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER)); + ACPI_STRNCPY (Header.Signature, Signature, ACPI_NAME_SIZE); + ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE); + ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE); + + /* Search for the table */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature), + Header.Signature, ACPI_NAME_SIZE)) + { + /* Not the requested table */ + + continue; + } + + /* Table with matching signature has been found */ + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + /* Table is not currently mapped, map it */ + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + continue; + } + } + + /* Check for table match on all IDs */ + + if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature, + Header.Signature, ACPI_NAME_SIZE) && + (!OemId[0] || + !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId, + Header.OemId, ACPI_OEM_ID_SIZE)) && + (!OemTableId[0] || + !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId, + Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE))) + { + *TableIndex = i; + + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", + Header.Signature)); + return_ACPI_STATUS (AE_OK); + } + } + + return_ACPI_STATUS (AE_NOT_FOUND); +} diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbget.c b/reactos/drivers/bus/acpi/acpica/tables/tbget.c new file mode 100644 index 00000000000..e16db9d26b3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbget.c @@ -0,0 +1,608 @@ +/****************************************************************************** + * + * Module Name: tbget - ACPI Table get* routines + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include + +#define _COMPONENT ACPI_TABLES + MODULE_NAME ("tbget") + +#define RSDP_CHECKSUM_LENGTH 20 + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table_ptr + * + * PARAMETERS: Table_type - one of the defined table types + * Instance - Which table of this type + * Table_ptr_loc - pointer to location to place the pointer for + * return + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the pointer to an ACPI table. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_ptr ( + ACPI_TABLE_TYPE table_type, + u32 instance, + ACPI_TABLE_HEADER **table_ptr_loc) +{ + ACPI_TABLE_DESC *table_desc; + u32 i; + + + if (!acpi_gbl_DSDT) { + return (AE_NO_ACPI_TABLES); + } + + if (table_type > ACPI_TABLE_MAX) { + return (AE_BAD_PARAMETER); + } + + + /* + * For all table types (Single/Multiple), the first + * instance is always in the list head. + */ + + if (instance == 1) { + /* + * Just pluck the pointer out of the global table! + * Will be null if no table is present + */ + + *table_ptr_loc = acpi_gbl_acpi_tables[table_type].pointer; + return (AE_OK); + } + + + /* + * Check for instance out of range + */ + if (instance > acpi_gbl_acpi_tables[table_type].count) { + return (AE_NOT_EXIST); + } + + /* Walk the list to get the desired table + * Since the if (Instance == 1) check above checked for the + * first table, setting Table_desc equal to the .Next member + * is actually pointing to the second table. Therefore, we + * need to walk from the 2nd table until we reach the Instance + * that the user is looking for and return its table pointer. + */ + table_desc = acpi_gbl_acpi_tables[table_type].next; + for (i = 2; i < instance; i++) { + table_desc = table_desc->next; + } + + /* We are now pointing to the requested table's descriptor */ + + *table_ptr_loc = table_desc->pointer; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table + * + * PARAMETERS: Physical_address - Physical address of table to retrieve + * *Buffer_ptr - If Buffer_ptr is valid, read data from + * buffer rather than searching memory + * *Table_info - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Maps the physical address of table into a logical address + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table ( + ACPI_PHYSICAL_ADDRESS physical_address, + ACPI_TABLE_HEADER *buffer_ptr, + ACPI_TABLE_DESC *table_info) +{ + ACPI_TABLE_HEADER *table_header = NULL; + ACPI_TABLE_HEADER *full_table = NULL; + u32 size; + u8 allocation; + ACPI_STATUS status = AE_OK; + + + if (!table_info) { + return (AE_BAD_PARAMETER); + } + + + if (buffer_ptr) { + /* + * Getting data from a buffer, not BIOS tables + */ + + table_header = buffer_ptr; + status = acpi_tb_validate_table_header (table_header); + if (ACPI_FAILURE (status)) { + /* Table failed verification, map all errors to BAD_DATA */ + + return (AE_BAD_DATA); + } + + /* Allocate buffer for the entire table */ + + full_table = acpi_cm_allocate (table_header->length); + if (!full_table) { + return (AE_NO_MEMORY); + } + + /* Copy the entire table (including header) to the local buffer */ + + size = table_header->length; + MEMCPY (full_table, buffer_ptr, size); + + /* Save allocation type */ + + allocation = ACPI_MEM_ALLOCATED; + } + + + /* + * Not reading from a buffer, just map the table's physical memory + * into our address space. + */ + else { + size = SIZE_IN_HEADER; + + status = acpi_tb_map_acpi_table (physical_address, &size, + (void **) &full_table); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Save allocation type */ + + allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + table_info->pointer = full_table; + table_info->length = size; + table_info->allocation = allocation; + table_info->base_pointer = full_table; + + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_all_tables + * + * PARAMETERS: Number_of_tables - Number of tables to get + * Table_ptr - Input buffer pointer, optional + * + * RETURN: Status + * + * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must + * already be loaded and validated. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_all_tables ( + u32 number_of_tables, + ACPI_TABLE_HEADER *table_ptr) +{ + ACPI_STATUS status = AE_OK; + u32 index; + ACPI_TABLE_DESC table_info; + + + /* + * Loop through all table pointers found in RSDT. + * This will NOT include the FACS and DSDT - we must get + * them after the loop + */ + + for (index = 0; index < number_of_tables; index++) { + /* Clear the Table_info each time */ + + MEMSET (&table_info, 0, sizeof (ACPI_TABLE_DESC)); + + /* Get the table via the XSDT */ + + status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) + ACPI_GET_ADDRESS (acpi_gbl_XSDT->table_offset_entry[index]), + table_ptr, &table_info); + + /* Ignore a table that failed verification */ + + if (status == AE_BAD_DATA) { + continue; + } + + /* However, abort on serious errors */ + + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Recognize and install the table */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + /* + * Unrecognized or unsupported table, delete it and ignore the + * error. Just get as many tables as we can, later we will + * determine if there are enough tables to continue. + */ + + acpi_tb_uninstall_table (&table_info); + } + } + + + /* + * Convert the FADT to a common format. This allows earlier revisions of the + * table to coexist with newer versions, using common access code. + */ + status = acpi_tb_convert_table_fadt (); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* + * Get the minimum set of ACPI tables, namely: + * + * 1) FADT (via RSDT in loop above) + * 2) FACS + * 3) DSDT + * + */ + + + /* + * Get the FACS (must have the FADT first, from loop above) + * Acpi_tb_get_table_facs will fail if FADT pointer is not valid + */ + + status = acpi_tb_get_table_facs (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* Install the FACS */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* + * Create the common FACS pointer table + * (Contains pointers to the original table) + */ + + status = acpi_tb_build_common_facs (&table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* + * Get the DSDT (We know that the FADT is valid now) + */ + + status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xdsdt), + table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Install the DSDT */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Dump the DSDT Header */ + + /* Dump the entire DSDT */ + + /* + * Initialize the capabilities flags. + * Assumes that platform supports ACPI_MODE since we have tables! + */ + acpi_gbl_system_flags |= acpi_hw_get_mode_capabilities (); + + + /* Always delete the RSDP mapping, we are done with it */ + + acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP); + + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_verify_rsdp + * + * PARAMETERS: Number_of_tables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_verify_rsdp ( + ACPI_PHYSICAL_ADDRESS rsdp_physical_address) +{ + ACPI_TABLE_DESC table_info; + ACPI_STATUS status; + u8 *table_ptr; + + + /* + * Obtain access to the RSDP structure + */ + status = acpi_os_map_memory (rsdp_physical_address, + sizeof (RSDP_DESCRIPTOR), + (void **) &table_ptr); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* + * The signature and checksum must both be correct + */ + if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { + /* Nope, BAD Signature */ + + status = AE_BAD_SIGNATURE; + goto cleanup; + } + + if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) { + /* Nope, BAD Checksum */ + + status = AE_BAD_CHECKSUM; + goto cleanup; + } + + /* TBD: Check extended checksum if table version >= 2 */ + + /* The RSDP supplied is OK */ + + table_info.pointer = (ACPI_TABLE_HEADER *) table_ptr; + table_info.length = sizeof (RSDP_DESCRIPTOR); + table_info.allocation = ACPI_MEM_MAPPED; + table_info.base_pointer = table_ptr; + + /* Save the table pointers and allocation info */ + + status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); + if (ACPI_FAILURE (status)) { + goto cleanup; + } + + + /* Save the RSDP in a global for easy access */ + + acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer; + return (status); + + + /* Error exit */ +cleanup: + + acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR)); + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table_rsdt + * + * PARAMETERS: Number_of_tables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_rsdt ( + u32 *number_of_tables) +{ + ACPI_TABLE_DESC table_info; + ACPI_STATUS status = AE_OK; + ACPI_PHYSICAL_ADDRESS physical_address; + u32 signature_length; + char *table_signature; + + + /* + * Get the RSDT from the RSDP + */ + + /* + * For RSDP revision 0 or 1, we use the RSDT. + * For RSDP revision 2 (and above), we use the XSDT + */ + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + /* 0.71 RSDP has 64bit Rsdt address field */ + physical_address = ((RSDP_DESCRIPTOR_REV071 *)acpi_gbl_RSDP)->rsdt_physical_address; +#else + physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->rsdt_physical_address; +#endif + table_signature = RSDT_SIG; + signature_length = sizeof (RSDT_SIG) -1; + } + else { + physical_address = (ACPI_PHYSICAL_ADDRESS) + ACPI_GET_ADDRESS (acpi_gbl_RSDP->xsdt_physical_address); + table_signature = XSDT_SIG; + signature_length = sizeof (XSDT_SIG) -1; + } + + + /* Get the RSDT/XSDT */ + + status = acpi_tb_get_table (physical_address, NULL, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* Check the RSDT or XSDT signature */ + + if (STRNCMP ((char *) table_info.pointer, table_signature, + signature_length)) { + /* Invalid RSDT or XSDT signature */ + + REPORT_ERROR (("Invalid signature where RSDP indicates %s should be located\n", + table_signature)); + + return (AE_NO_ACPI_TABLES); + } + + + /* Valid RSDT signature, verify the checksum */ + + status = acpi_tb_verify_table_checksum (table_info.pointer); + + + /* Convert and/or copy to an XSDT structure */ + + status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Save the table pointers and allocation info */ + + status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + acpi_gbl_XSDT = (XSDT_DESCRIPTOR *) table_info.pointer; + + return (status); +} + + +/****************************************************************************** + * + * FUNCTION: Acpi_tb_get_table_facs + * + * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from + * buffer rather than searching memory + * *Table_info - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns a pointer to the FACS as defined in FADT. This + * function assumes the global variable FADT has been + * correctly initialized. The value of FADT->Firmware_ctrl + * into a far pointer which is returned. + * + *****************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_facs ( + ACPI_TABLE_HEADER *buffer_ptr, + ACPI_TABLE_DESC *table_info) +{ + void *table_ptr = NULL; + u32 size; + u8 allocation; + ACPI_STATUS status = AE_OK; + + + /* Must have a valid FADT pointer */ + + if (!acpi_gbl_FADT) { + return (AE_NO_ACPI_TABLES); + } + + size = sizeof (FACS_DESCRIPTOR); + if (buffer_ptr) { + /* + * Getting table from a file -- allocate a buffer and + * read the table. + */ + table_ptr = acpi_cm_allocate (size); + if(!table_ptr) { + return (AE_NO_MEMORY); + } + + MEMCPY (table_ptr, buffer_ptr, size); + + /* Save allocation type */ + + allocation = ACPI_MEM_ALLOCATED; + } + + else { + /* Just map the physical memory to our address space */ + + status = acpi_tb_map_acpi_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xfirmware_ctrl), + &size, &table_ptr); + if (ACPI_FAILURE(status)) { + return (status); + } + + /* Save allocation type */ + + allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + table_info->pointer = table_ptr; + table_info->length = size; + table_info->allocation = allocation; + table_info->base_pointer = table_ptr; + + return (status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c b/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c new file mode 100644 index 00000000000..c911f84f68b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c @@ -0,0 +1,785 @@ +/****************************************************************************** + * + * Module Name: tbinstal - ACPI table installation and removal + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __TBINSTAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbinstal") + + +/****************************************************************************** + * + * FUNCTION: AcpiTbVerifyTable + * + * PARAMETERS: TableDesc - table + * + * RETURN: Status + * + * DESCRIPTION: this function is called to verify and map table + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (TbVerifyTable); + + + /* Map the table if necessary */ + + if (!TableDesc->Pointer) + { + if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_MAPPED) + { + TableDesc->Pointer = AcpiOsMapMemory ( + TableDesc->Address, TableDesc->Length); + } + + if (!TableDesc->Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* FACS is the odd table, has no standard ACPI header and no checksum */ + + if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS)) + { + /* Always calculate checksum, ignore bad checksum if requested */ + + Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAddTable + * + * PARAMETERS: TableDesc - Table descriptor + * TableIndex - Where the table index is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to add an ACPI table. It is used to + * dynamically load tables via the Load and LoadTable AML + * operators. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAddTable ( + ACPI_TABLE_DESC *TableDesc, + UINT32 *TableIndex) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *OverrideTable = NULL; + + + ACPI_FUNCTION_TRACE (TbAddTable); + + + if (!TableDesc->Pointer) + { + Status = AcpiTbVerifyTable (TableDesc); + if (ACPI_FAILURE (Status) || !TableDesc->Pointer) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Originally, we checked the table signature for "SSDT" or "PSDT" here. + * Next, we added support for OEMx tables, signature "OEM". + * Valid tables were encountered with a null signature, so we've just + * given up on validating the signature, since it seems to be a waste + * of code. The original code was removed (05/2008). + */ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Check if table is already registered */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_FAILURE (Status) || + !AcpiGbl_RootTableList.Tables[i].Pointer) + { + continue; + } + } + + /* + * Check for a table match on the entire table length, + * not just the header. + */ + if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length) + { + continue; + } + + if (ACPI_MEMCMP (TableDesc->Pointer, + AcpiGbl_RootTableList.Tables[i].Pointer, + AcpiGbl_RootTableList.Tables[i].Length)) + { + continue; + } + + /* + * Note: the current mechanism does not unregister a table if it is + * dynamically unloaded. The related namespace entries are deleted, + * but the table remains in the root table list. + * + * The assumption here is that the number of different tables that + * will be loaded is actually small, and there is minimal overhead + * in just keeping the table in case it is needed again. + * + * If this assumption changes in the future (perhaps on large + * machines with many table load/unload operations), tables will + * need to be unregistered when they are unloaded, and slots in the + * root table list should be reused when empty. + */ + + /* + * Table is already registered. + * We can delete the table that was passed as a parameter. + */ + AcpiTbDeleteTable (TableDesc); + *TableIndex = i; + + if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) + { + /* Table is still loaded, this is an error */ + + Status = AE_ALREADY_EXISTS; + goto Release; + } + else + { + /* Table was unloaded, allow it to be reloaded */ + + TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer; + TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address; + Status = AE_OK; + goto PrintHeader; + } + } + + /* + * ACPI Table Override: + * Allow the host to override dynamically loaded tables. + */ + Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable); + if (ACPI_SUCCESS (Status) && OverrideTable) + { + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + TableDesc->Pointer->Signature, + ACPI_CAST_PTR (void, TableDesc->Address))); + + /* We can delete the table that was passed as a parameter */ + + AcpiTbDeleteTable (TableDesc); + + /* Setup descriptor for the new table */ + + TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable); + TableDesc->Pointer = OverrideTable; + TableDesc->Length = OverrideTable->Length; + TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + + /* Add the table to the global root table list */ + + Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer, + TableDesc->Length, TableDesc->Flags, TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Release; + } + +PrintHeader: + AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); + +Release: + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbResizeRootTableList + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Expand the size of global table array + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbResizeRootTableList ( + void) +{ + ACPI_TABLE_DESC *Tables; + + + ACPI_FUNCTION_TRACE (TbResizeRootTableList); + + + /* AllowResize flag is a parameter to AcpiInitializeTables */ + + if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) + { + ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); + return_ACPI_STATUS (AE_SUPPORT); + } + + /* Increase the Table Array size */ + + Tables = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) AcpiGbl_RootTableList.Size + + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC)); + if (!Tables) + { + ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy and free the previous table array */ + + if (AcpiGbl_RootTableList.Tables) + { + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, + (ACPI_SIZE) AcpiGbl_RootTableList.Size * sizeof (ACPI_TABLE_DESC)); + + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + } + + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.Size += ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbStoreTable + * + * PARAMETERS: Address - Table address + * Table - Table header + * Length - Table length + * Flags - flags + * + * RETURN: Status and table index. + * + * DESCRIPTION: Add an ACPI table to the global table list + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + UINT32 *TableIndex) +{ + ACPI_STATUS Status = AE_OK; + + + /* Ensure that there is room for the table in the Root Table List */ + + if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + { + Status = AcpiTbResizeRootTableList(); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* Initialize added table */ + + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = Address; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Pointer = Table; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Length = Length; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].OwnerId = 0; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Flags = Flags; + + ACPI_MOVE_32_TO_32 ( + &(AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Signature), + Table->Signature); + + *TableIndex = AcpiGbl_RootTableList.Count; + AcpiGbl_RootTableList.Count++; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteTable + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: None + * + * DESCRIPTION: Delete one internal ACPI table + * + ******************************************************************************/ + +void +AcpiTbDeleteTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + /* Table must be mapped or allocated */ + + if (!TableDesc->Pointer) + { + return; + } + + switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_MAPPED: + AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); + break; + + case ACPI_TABLE_ORIGIN_ALLOCATED: + ACPI_FREE (TableDesc->Pointer); + break; + + default: + break; + } + + TableDesc->Pointer = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbTerminate + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all internal ACPI tables + * + ******************************************************************************/ + +void +AcpiTbTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbTerminate); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Delete the individual tables */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; i++) + { + AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); + } + + /* + * Delete the root table array if allocated locally. Array cannot be + * mapped, so we don't need to check for that flag. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + + AcpiGbl_RootTableList.Tables = NULL; + AcpiGbl_RootTableList.Flags = 0; + AcpiGbl_RootTableList.Count = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteNamespaceByOwner + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Delete all namespace objects created when this table was loaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbDeleteNamespaceByOwner ( + UINT32 TableIndex) +{ + ACPI_OWNER_ID OwnerId; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (TableIndex >= AcpiGbl_RootTableList.Count) + { + /* The table index does not exist */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Get the owner ID for this table, used to delete namespace nodes */ + + OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* + * Need to acquire the namespace writer lock to prevent interference + * with any concurrent namespace walks. The interpreter must be + * released during the deletion since the acquisition of the deletion + * lock may block, and also since the execution of a namespace walk + * must be allowed to use the interpreter. + */ + (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); + + AcpiNsDeleteNamespaceByOwner (OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAllocateOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Allocates OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAllocateOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbAllocateOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + Status = AcpiUtAllocateOwnerId + (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Releases OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbReleaseOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbReleaseOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + AcpiUtReleaseOwnerId ( + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetOwnerId + * + * PARAMETERS: TableIndex - Table index + * OwnerId - Where the table OwnerId is returned + * + * RETURN: Status + * + * DESCRIPTION: returns OwnerId for the ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetOwnerId ( + UINT32 TableIndex, + ACPI_OWNER_ID *OwnerId) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbGetOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbIsTableLoaded + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Table Loaded Flag + * + ******************************************************************************/ + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex) +{ + BOOLEAN IsLoaded = FALSE; + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + IsLoaded = (BOOLEAN) + (AcpiGbl_RootTableList.Tables[TableIndex].Flags & + ACPI_TABLE_IS_LOADED); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return (IsLoaded); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetTableLoadedFlag + * + * PARAMETERS: TableIndex - Table index + * IsLoaded - TRUE if table is loaded, FALSE otherwise + * + * RETURN: None + * + * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. + * + ******************************************************************************/ + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded) +{ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + if (IsLoaded) + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags |= + ACPI_TABLE_IS_LOADED; + } + else + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags &= + ~ACPI_TABLE_IS_LOADED; + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); +} + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbutils.c b/reactos/drivers/bus/acpi/acpica/tables/tbutils.c new file mode 100644 index 00000000000..ec2a88e283d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbutils.c @@ -0,0 +1,741 @@ +/****************************************************************************** + * + * Module Name: tbutils - table utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbutils") + +/* Local prototypes */ + +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length); + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header); + +static ACPI_PHYSICAL_ADDRESS +AcpiTbGetRootTableEntry ( + UINT8 *TableEntry, + UINT32 TableEntrySize); + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitializeFacs + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global + * for accessing the Global Lock and Firmware Waking Vector + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInitializeFacs ( + void) +{ + ACPI_STATUS Status; + + + Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_FACS)); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbTablesLoaded + * + * PARAMETERS: None + * + * RETURN: TRUE if required ACPI tables are loaded + * + * DESCRIPTION: Determine if the minimum required ACPI tables are present + * (FADT, FACS, DSDT) + * + ******************************************************************************/ + +BOOLEAN +AcpiTbTablesLoaded ( + void) +{ + + if (AcpiGbl_RootTableList.Count >= 3) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFixString + * + * PARAMETERS: String - String to be repaired + * Length - Maximum length + * + * RETURN: None + * + * DESCRIPTION: Replace every non-printable or non-ascii byte in the string + * with a question mark '?'. + * + ******************************************************************************/ + +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length) +{ + + while (Length && *String) + { + if (!ACPI_IS_PRINT (*String)) + { + *String = '?'; + } + String++; + Length--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCleanupTableHeader + * + * PARAMETERS: OutHeader - Where the cleaned header is returned + * Header - Input ACPI table header + * + * RETURN: Returns the cleaned header in OutHeader + * + * DESCRIPTION: Copy the table header and ensure that all "string" fields in + * the header consist of printable characters. + * + ******************************************************************************/ + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header) +{ + + ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER)); + + AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE); + AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (OutHeader->OemTableId, ACPI_OEM_TABLE_ID_SIZE); + AcpiTbFixString (OutHeader->AslCompilerId, ACPI_NAME_SIZE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbPrintTableHeader + * + * PARAMETERS: Address - Table physical address + * Header - Table header + * + * RETURN: None + * + * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. + * + ******************************************************************************/ + +void +AcpiTbPrintTableHeader ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Header) +{ + ACPI_TABLE_HEADER LocalHeader; + + + /* + * The reason that the Address is cast to a void pointer is so that we + * can use %p which will work properly on both 32-bit and 64-bit hosts. + */ + if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_FACS)) + { + /* FACS only has signature and length fields */ + + ACPI_INFO ((AE_INFO, "%4.4s %p %05X", + Header->Signature, ACPI_CAST_PTR (void, Address), + Header->Length)); + } + else if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_RSDP)) + { + /* RSDP has no common fields */ + + ACPI_MEMCPY (LocalHeader.OemId, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE); + + ACPI_INFO ((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", + ACPI_CAST_PTR (void, Address), + (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ? + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision, + LocalHeader.OemId)); + } + else + { + /* Standard ACPI table with full common header */ + + AcpiTbCleanupTableHeader (&LocalHeader, Header); + + ACPI_INFO ((AE_INFO, + "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", + LocalHeader.Signature, ACPI_CAST_PTR (void, Address), + LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId, + LocalHeader.OemTableId, LocalHeader.OemRevision, + LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateChecksum + * + * PARAMETERS: Table - ACPI table to verify + * Length - Length of entire table + * + * RETURN: Status + * + * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns + * exception on bad checksum. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) +{ + UINT8 Checksum; + + + /* Compute the checksum on the table */ + + Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Length); + + /* Checksum ok? (should be zero) */ + + if (Checksum) + { + ACPI_WARNING ((AE_INFO, + "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", + Table->Signature, Table->Checksum, + (UINT8) (Table->Checksum - Checksum))); + +#if (ACPI_CHECKSUM_ABORT) + return (AE_BAD_CHECKSUM); +#endif + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbChecksum + * + * PARAMETERS: Buffer - Pointer to memory region to be checked + * Length - Length of this memory region + * + * RETURN: Checksum (UINT8) + * + * DESCRIPTION: Calculates circular checksum of memory region. + * + ******************************************************************************/ + +UINT8 +AcpiTbChecksum ( + UINT8 *Buffer, + UINT32 Length) +{ + UINT8 Sum = 0; + UINT8 *End = Buffer + Length; + + + while (Buffer < End) + { + Sum = (UINT8) (Sum + *(Buffer++)); + } + + return Sum; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInstallTable + * + * PARAMETERS: Address - Physical address of DSDT or FACS + * Signature - Table signature, NULL if no need to + * match + * TableIndex - Index into root table array + * + * RETURN: None + * + * DESCRIPTION: Install an ACPI table into the global data structure. The + * table override mechanism is implemented here to allow the host + * OS to replace any table before it is installed in the root + * table array. + * + ******************************************************************************/ + +void +AcpiTbInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + char *Signature, + UINT32 TableIndex) +{ + UINT8 Flags; + ACPI_STATUS Status; + ACPI_TABLE_HEADER *TableToInstall; + ACPI_TABLE_HEADER *MappedTable; + ACPI_TABLE_HEADER *OverrideTable = NULL; + + + if (!Address) + { + ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", + Signature)); + return; + } + + /* Map just the table header */ + + MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!MappedTable) + { + return; + } + + /* If a particular signature is expected (DSDT/FACS), it must match */ + + if (Signature && + !ACPI_COMPARE_NAME (MappedTable->Signature, Signature)) + { + ACPI_ERROR ((AE_INFO, + "Invalid signature 0x%X for ACPI table, expected [%s]", + *ACPI_CAST_PTR (UINT32, MappedTable->Signature), Signature)); + goto UnmapAndExit; + } + + /* + * ACPI Table Override: + * + * Before we install the table, let the host OS override it with a new + * one if desired. Any table within the RSDT/XSDT can be replaced, + * including the DSDT which is pointed to by the FADT. + */ + Status = AcpiOsTableOverride (MappedTable, &OverrideTable); + if (ACPI_SUCCESS (Status) && OverrideTable) + { + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + MappedTable->Signature, ACPI_CAST_PTR (void, Address))); + + AcpiGbl_RootTableList.Tables[TableIndex].Pointer = OverrideTable; + Address = ACPI_PTR_TO_PHYSADDR (OverrideTable); + + TableToInstall = OverrideTable; + Flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + else + { + TableToInstall = MappedTable; + Flags = ACPI_TABLE_ORIGIN_MAPPED; + } + + /* Initialize the table entry */ + + AcpiGbl_RootTableList.Tables[TableIndex].Address = Address; + AcpiGbl_RootTableList.Tables[TableIndex].Length = TableToInstall->Length; + AcpiGbl_RootTableList.Tables[TableIndex].Flags = Flags; + + ACPI_MOVE_32_TO_32 ( + &(AcpiGbl_RootTableList.Tables[TableIndex].Signature), + TableToInstall->Signature); + + AcpiTbPrintTableHeader (Address, TableToInstall); + + if (TableIndex == ACPI_TABLE_INDEX_DSDT) + { + /* Global integer width is based upon revision of the DSDT */ + + AcpiUtSetIntegerWidth (TableToInstall->Revision); + } + +UnmapAndExit: + AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetRootTableEntry + * + * PARAMETERS: TableEntry - Pointer to the RSDT/XSDT table entry + * TableEntrySize - sizeof 32 or 64 (RSDT or XSDT) + * + * RETURN: Physical address extracted from the root table + * + * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on + * both 32-bit and 64-bit platforms + * + * NOTE: ACPI_PHYSICAL_ADDRESS is 32-bit on 32-bit platforms, 64-bit on + * 64-bit platforms. + * + ******************************************************************************/ + +static ACPI_PHYSICAL_ADDRESS +AcpiTbGetRootTableEntry ( + UINT8 *TableEntry, + UINT32 TableEntrySize) +{ + UINT64 Address64; + + + /* + * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): + * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT + */ + if (TableEntrySize == sizeof (UINT32)) + { + /* + * 32-bit platform, RSDT: Return 32-bit table entry + * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return + */ + return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (UINT32, TableEntry))); + } + else + { + /* + * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return + * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, + * return 64-bit + */ + ACPI_MOVE_64_TO_64 (&Address64, TableEntry); + +#if ACPI_MACHINE_WIDTH == 32 + if (Address64 > ACPI_UINT32_MAX) + { + /* Will truncate 64-bit address to 32 bits, issue warning */ + + ACPI_WARNING ((AE_INFO, + "64-bit Physical Address in XSDT is too large (%8.8X%8.8X)," + " truncating", + ACPI_FORMAT_UINT64 (Address64))); + } +#endif + return ((ACPI_PHYSICAL_ADDRESS) (Address64)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbParseRootTable + * + * PARAMETERS: Rsdp - Pointer to the RSDP + * + * RETURN: Status + * + * DESCRIPTION: This function is called to parse the Root System Description + * Table (RSDT or XSDT) + * + * NOTE: Tables are mapped (not copied) for efficiency. The FACS must + * be mapped and cannot be copied because it contains the actual + * memory location of the ACPI Global Lock. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbParseRootTable ( + ACPI_PHYSICAL_ADDRESS RsdpAddress) +{ + ACPI_TABLE_RSDP *Rsdp; + UINT32 TableEntrySize; + UINT32 i; + UINT32 TableCount; + ACPI_TABLE_HEADER *Table; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + UINT8 *TableEntry; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbParseRootTable); + + + /* + * Map the entire RSDP and extract the address of the RSDT or XSDT + */ + Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP)); + if (!Rsdp) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiTbPrintTableHeader (RsdpAddress, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp)); + + /* Differentiate between RSDT and XSDT root tables */ + + if (Rsdp->Revision > 1 && Rsdp->XsdtPhysicalAddress) + { + /* + * Root table is an XSDT (64-bit physical addresses). We must use the + * XSDT if the revision is > 1 and the XSDT pointer is present, as per + * the ACPI specification. + */ + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress; + TableEntrySize = sizeof (UINT64); + } + else + { + /* Root table is an RSDT (32-bit physical addresses) */ + + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress; + TableEntrySize = sizeof (UINT32); + } + + /* + * It is not possible to map more than one entry in some environments, + * so unmap the RSDP here before mapping other tables + */ + AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP)); + + + /* Map the RSDT/XSDT table header to get the full table length */ + + Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiTbPrintTableHeader (Address, Table); + + /* Get the length of the full table, verify length and map entire table */ + + Length = Table->Length; + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + ACPI_ERROR ((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", Length)); + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + Table = AcpiOsMapMemory (Address, Length); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Validate the root table checksum */ + + Status = AcpiTbVerifyChecksum (Table, Length); + if (ACPI_FAILURE (Status)) + { + AcpiOsUnmapMemory (Table, Length); + return_ACPI_STATUS (Status); + } + + /* Calculate the number of tables described in the root table */ + + TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / + TableEntrySize); + + /* + * First two entries in the table array are reserved for the DSDT + * and FACS, which are not actually present in the RSDT/XSDT - they + * come from the FADT + */ + TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); + AcpiGbl_RootTableList.Count = 2; + + /* + * Initialize the root table array from the RSDT/XSDT + */ + for (i = 0; i < TableCount; i++) + { + if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + { + /* There is no more room in the root table array, attempt resize */ + + Status = AcpiTbResizeRootTableList (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", + (unsigned) (TableCount - + (AcpiGbl_RootTableList.Count - 2)))); + break; + } + } + + /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ + + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = + AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); + + TableEntry += TableEntrySize; + AcpiGbl_RootTableList.Count++; + } + + /* + * It is not possible to map more than one entry in some environments, + * so unmap the root table here before mapping other tables + */ + AcpiOsUnmapMemory (Table, Length); + + /* + * Complete the initialization of the root table array by examining + * the header of each table + */ + for (i = 2; i < AcpiGbl_RootTableList.Count; i++) + { + AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, + NULL, i); + + /* Special case for FADT - get the DSDT and FACS */ + + if (ACPI_COMPARE_NAME ( + &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT)) + { + AcpiTbParseFadt (i); + } + } + + return_ACPI_STATUS (AE_OK); +} diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbxface.c b/reactos/drivers/bus/acpi/acpica/tables/tbxface.c new file mode 100644 index 00000000000..4c12916c5ac --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbxface.c @@ -0,0 +1,750 @@ +/****************************************************************************** + * + * Module Name: tbxface - Public interfaces to the ACPI subsystem + * ACPI table oriented interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbxface") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbLoadNamespace ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiAllocateRootTable + * + * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of + * ACPI_TABLE_DESC structures + * + * RETURN: Status + * + * DESCRIPTION: Allocate a root table array. Used by iASL compiler and + * AcpiInitializeTables. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAllocateRootTable ( + UINT32 InitialTableCount) +{ + + AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; + + return (AcpiTbResizeRootTableList ()); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeTables + * + * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated + * ACPI_TABLE_DESC structures. If NULL, the + * array is dynamically allocated. + * InitialTableCount - Size of InitialTableArray, in number of + * ACPI_TABLE_DESC structures + * AllowRealloc - Flag to tell Table Manager if resize of + * pre-allocated array is allowed. Ignored + * if InitialTableArray is NULL. + * + * RETURN: Status + * + * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. + * + * NOTE: Allows static allocation of the initial table array in order + * to avoid the use of dynamic memory in confined environments + * such as the kernel boot sequence where it may not be available. + * + * If the host OS memory managers are initialized, use NULL for + * InitialTableArray, and the table will be dynamically allocated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeTables ( + ACPI_TABLE_DESC *InitialTableArray, + UINT32 InitialTableCount, + BOOLEAN AllowResize) +{ + ACPI_PHYSICAL_ADDRESS RsdpAddress; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInitializeTables); + + + /* + * Set up the Root Table Array + * Allocate the table array if requested + */ + if (!InitialTableArray) + { + Status = AcpiAllocateRootTable (InitialTableCount); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* Root Table Array has been statically allocated by the host */ + + ACPI_MEMSET (InitialTableArray, 0, + (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); + + AcpiGbl_RootTableList.Tables = InitialTableArray; + AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; + if (AllowResize) + { + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; + } + } + + /* Get the address of the RSDP */ + + RsdpAddress = AcpiOsGetRootPointer (); + if (!RsdpAddress) + { + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* + * Get the root table (RSDT or XSDT) and extract all entries to the local + * Root Table Array. This array contains the information of the RSDT/XSDT + * in a common, more useable format. + */ + Status = AcpiTbParseRootTable (RsdpAddress); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeTables) + + +/******************************************************************************* + * + * FUNCTION: AcpiReallocateRootTable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the + * root list from the previously provided scratch area. Should + * be called once dynamic memory allocation is available in the + * kernel + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReallocateRootTable ( + void) +{ + ACPI_TABLE_DESC *Tables; + ACPI_SIZE NewSize; + + + ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); + + + /* + * Only reallocate the root table if the host provided a static buffer + * for the table array in the call to AcpiInitializeTables. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + return_ACPI_STATUS (AE_SUPPORT); + } + + NewSize = ((ACPI_SIZE) AcpiGbl_RootTableList.Count + + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC); + + /* Create new array and copy the old array */ + + Tables = ACPI_ALLOCATE_ZEROED (NewSize); + if (!Tables) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, NewSize); + + AcpiGbl_RootTableList.Size = AcpiGbl_RootTableList.Count; + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.Flags = + ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTableHeader + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * OutTableHeader - The pointer to the table header to fill + * + * RETURN: Status and pointer to mapped table header + * + * DESCRIPTION: Finds an ACPI table header. + * + * NOTE: Caller is responsible in unmapping the header with + * AcpiOsUnmapMemory + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTableHeader ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader) +{ + UINT32 i; + UINT32 j; + ACPI_TABLE_HEADER *Header; + + + /* Parameter validation */ + + if (!Signature || !OutTableHeader) + { + return (AE_BAD_PARAMETER); + } + + /* Walk the root table list */ + + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + { + if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature)) + { + continue; + } + + if (++j < Instance) + { + continue; + } + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + if ((AcpiGbl_RootTableList.Tables[i].Flags & + ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_MAPPED) + { + Header = AcpiOsMapMemory ( + AcpiGbl_RootTableList.Tables[i].Address, + sizeof (ACPI_TABLE_HEADER)); + if (!Header) + { + return AE_NO_MEMORY; + } + + ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER)); + AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER)); + } + else + { + return AE_NOT_FOUND; + } + } + else + { + ACPI_MEMCPY (OutTableHeader, + AcpiGbl_RootTableList.Tables[i].Pointer, + sizeof(ACPI_TABLE_HEADER)); + } + + return (AE_OK); + } + + return (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTable + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * OutTable - Where the pointer to the table is returned + * + * RETURN: Status and pointer to table + * + * DESCRIPTION: Finds and verifies an ACPI table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTable ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **OutTable) +{ + UINT32 i; + UINT32 j; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Signature || !OutTable) + { + return (AE_BAD_PARAMETER); + } + + /* Walk the root table list */ + + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + { + if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature)) + { + continue; + } + + if (++j < Instance) + { + continue; + } + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_SUCCESS (Status)) + { + *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; + } + + return (Status); + } + + return (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTableByIndex + * + * PARAMETERS: TableIndex - Table index + * Table - Where the pointer to the table is returned + * + * RETURN: Status and pointer to the table + * + * DESCRIPTION: Obtain a table by an index into the global table list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTableByIndex ( + UINT32 TableIndex, + ACPI_TABLE_HEADER **Table) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetTableByIndex); + + + /* Parameter validation */ + + if (!Table) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Validate index */ + + if (TableIndex >= AcpiGbl_RootTableList.Count) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer) + { + /* Table is not mapped, map it */ + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + if (ACPI_FAILURE (Status)) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); + } + } + + *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbLoadNamespace + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in + * the RSDT/XSDT. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiTbLoadNamespace ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbLoadNamespace); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* + * Load the namespace. The DSDT is required, but any SSDT and PSDT tables + * are optional. + */ + if (!AcpiGbl_RootTableList.Count || + !ACPI_COMPARE_NAME ( + &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), + ACPI_SIG_DSDT) || + ACPI_FAILURE (AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) + { + Status = AE_NO_ACPI_TABLES; + goto UnlockAndExit; + } + + /* A valid DSDT is required */ + + Status = AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); + if (ACPI_FAILURE (Status)) + { + Status = AE_NO_ACPI_TABLES; + goto UnlockAndExit; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* Load and parse tables */ + + Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_SSDT) && + !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_PSDT)) || + ACPI_FAILURE (AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[i]))) + { + continue; + } + + /* Ignore errors while loading tables, get as many as possible */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + (void) AcpiNsLoadTable (i, AcpiGbl_RootNode); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiLoadTables + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLoadTables ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLoadTables); + + + /* Load the namespace from the tables */ + + Status = AcpiTbLoadNamespace (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While loading namespace from ACPI tables")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiLoadTables) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallTableHandler + * + * PARAMETERS: Handler - Table event handler + * Context - Value passed to the handler on each event + * + * RETURN: Status + * + * DESCRIPTION: Install table event handler + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallTableHandler ( + ACPI_TABLE_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallTableHandler); + + + if (!Handler) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow more than one handler */ + + if (AcpiGbl_TableHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_TableHandler = Handler; + AcpiGbl_TableHandlerContext = Context; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveTableHandler + * + * PARAMETERS: Handler - Table event handler that was installed + * previously. + * + * RETURN: Status + * + * DESCRIPTION: Remove table event handler + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveTableHandler ( + ACPI_TABLE_HANDLER Handler) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Make sure that the installed handler is the same */ + + if (!Handler || + Handler != AcpiGbl_TableHandler) + { + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* Remove the handler */ + + AcpiGbl_TableHandler = NULL; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler) + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbxfroot.c b/reactos/drivers/bus/acpi/acpica/tables/tbxfroot.c new file mode 100644 index 00000000000..e0a571f36f4 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbxfroot.c @@ -0,0 +1,371 @@ +/****************************************************************************** + * + * Module Name: tbxfroot - Find the root ACPI table (RSDT) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBXFROOT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbxfroot") + +/* Local prototypes */ + +static UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length); + +static ACPI_STATUS +AcpiTbValidateRsdp ( + ACPI_TABLE_RSDP *Rsdp); + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateRsdp + * + * PARAMETERS: Rsdp - Pointer to unvalidated RSDP + * + * RETURN: Status + * + * DESCRIPTION: Validate the RSDP (ptr) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiTbValidateRsdp ( + ACPI_TABLE_RSDP *Rsdp) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * The signature and checksum must both be correct + * + * Note: Sometimes there exists more than one RSDP in memory; the valid + * RSDP has a valid checksum, all others have an invalid checksum. + */ + if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP, + sizeof (ACPI_SIG_RSDP)-1) != 0) + { + /* Nope, BAD Signature */ + + return (AE_BAD_SIGNATURE); + } + + /* Check the standard checksum */ + + if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + { + return (AE_BAD_CHECKSUM); + } + + /* Check extended checksum if table version >= 2 */ + + if ((Rsdp->Revision >= 2) && + (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) + { + return (AE_BAD_CHECKSUM); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiFindRootPointer + * + * PARAMETERS: TableAddress - Where the table pointer is returned + * + * RETURN: Status, RSDP physical address + * + * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor + * pointer structure. If it is found, set *RSDP to point to it. + * + * NOTE1: The RSDP must be either in the first 1K of the Extended + * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) + * Only a 32-bit physical address is necessary. + * + * NOTE2: This function is always available, regardless of the + * initialization state of the rest of ACPI. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiFindRootPointer ( + ACPI_SIZE *TableAddress) +{ + UINT8 *TablePtr; + UINT8 *MemRover; + UINT32 PhysicalAddress; + + + ACPI_FUNCTION_TRACE (AcpiFindRootPointer); + + + /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ + + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH); + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr); + + /* Convert segment part to physical address */ + + PhysicalAddress <<= 4; + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH); + + /* EBDA present? */ + + if (PhysicalAddress > 0x400) + { + /* + * 1b) Search EBDA paragraphs (EBDA is required to be a + * minimum of 1K length) + */ + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, + ACPI_EBDA_WINDOW_SIZE); + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); + + if (MemRover) + { + /* Return the physical address */ + + PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr); + + *TableAddress = PhysicalAddress; + return_ACPI_STATUS (AE_OK); + } + } + + /* + * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh + */ + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE); + + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); + + if (MemRover) + { + /* Return the physical address */ + + PhysicalAddress = (UINT32) + (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr)); + + *TableAddress = PhysicalAddress; + return_ACPI_STATUS (AE_OK); + } + + /* A valid RSDP was not found */ + + ACPI_ERROR ((AE_INFO, "A valid RSDP was not found")); + return_ACPI_STATUS (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiFindRootPointer) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbScanMemoryForRsdp + * + * PARAMETERS: StartAddress - Starting pointer for search + * Length - Maximum length to search + * + * RETURN: Pointer to the RSDP if found, otherwise NULL. + * + * DESCRIPTION: Search a block of memory for the RSDP signature + * + ******************************************************************************/ + +static UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length) +{ + ACPI_STATUS Status; + UINT8 *MemRover; + UINT8 *EndAddress; + + + ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp); + + + EndAddress = StartAddress + Length; + + /* Search from given start address for the requested length */ + + for (MemRover = StartAddress; MemRover < EndAddress; + MemRover += ACPI_RSDP_SCAN_STEP) + { + /* The RSDP signature and checksum must both be correct */ + + Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover)); + if (ACPI_SUCCESS (Status)) + { + /* Sig and checksum valid, we have found a real RSDP */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "RSDP located at physical address %p\n", MemRover)); + return_PTR (MemRover); + } + + /* No sig match or bad checksum, keep searching */ + } + + /* Searched entire block, no RSDP was found */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Searched entire block from %p, valid RSDP was not found\n", + StartAddress)); + return_PTR (NULL); +} + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utalloc.c b/reactos/drivers/bus/acpi/acpica/utilities/utalloc.c new file mode 100644 index 00000000000..a66b94005c1 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utalloc.c @@ -0,0 +1,488 @@ +/****************************************************************************** + * + * Module Name: utalloc - local memory allocation routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTALLOC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdebug.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utalloc") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateCaches + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create all local caches + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateCaches ( + void) +{ + ACPI_STATUS Status; + + + /* Object Caches, for frequently used objects */ + + Status = AcpiOsCreateCache ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE), + ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-Parse", sizeof (ACPI_PARSE_OBJ_COMMON), + ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-ParseExt", sizeof (ACPI_PARSE_OBJ_NAMED), + ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-Operand", sizeof (ACPI_OPERAND_OBJECT), + ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Memory allocation lists */ + + Status = AcpiUtCreateList ("Acpi-Global", 0, + &AcpiGbl_GlobalList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + &AcpiGbl_NsNodeList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } +#endif + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteCaches + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge and delete all local caches + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtDeleteCaches ( + void) +{ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + char Buffer[7]; + + if (AcpiGbl_DisplayFinalMemStats) + { + ACPI_STRCPY (Buffer, "MEMORY"); + (void) AcpiDbDisplayStatistics (Buffer); + } +#endif + + (void) AcpiOsDeleteCache (AcpiGbl_NamespaceCache); + AcpiGbl_NamespaceCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_StateCache); + AcpiGbl_StateCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_OperandCache); + AcpiGbl_OperandCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_PsNodeCache); + AcpiGbl_PsNodeCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache); + AcpiGbl_PsNodeExtCache = NULL; + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Debug only - display leftover memory allocation, if any */ + + AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL); + + /* Free memory lists */ + + AcpiOsFree (AcpiGbl_GlobalList); + AcpiGbl_GlobalList = NULL; + + AcpiOsFree (AcpiGbl_NsNodeList); + AcpiGbl_NsNodeList = NULL; +#endif + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateBuffer + * + * PARAMETERS: Buffer - Buffer descriptor to be validated + * + * RETURN: Status + * + * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtValidateBuffer ( + ACPI_BUFFER *Buffer) +{ + + /* Obviously, the structure pointer must be valid */ + + if (!Buffer) + { + return (AE_BAD_PARAMETER); + } + + /* Special semantics for the length */ + + if ((Buffer->Length == ACPI_NO_BUFFER) || + (Buffer->Length == ACPI_ALLOCATE_BUFFER) || + (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER)) + { + return (AE_OK); + } + + /* Length is valid, the buffer pointer must be also */ + + if (!Buffer->Pointer) + { + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitializeBuffer + * + * PARAMETERS: Buffer - Buffer to be validated + * RequiredLength - Length needed + * + * RETURN: Status + * + * DESCRIPTION: Validate that the buffer is of the required length or + * allocate a new buffer. Returned buffer is always zeroed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInitializeBuffer ( + ACPI_BUFFER *Buffer, + ACPI_SIZE RequiredLength) +{ + ACPI_SIZE InputBufferLength; + + + /* Parameter validation */ + + if (!Buffer || !RequiredLength) + { + return (AE_BAD_PARAMETER); + } + + /* + * Buffer->Length is used as both an input and output parameter. Get the + * input actual length and set the output required buffer length. + */ + InputBufferLength = Buffer->Length; + Buffer->Length = RequiredLength; + + /* + * The input buffer length contains the actual buffer length, or the type + * of buffer to be allocated by this routine. + */ + switch (InputBufferLength) + { + case ACPI_NO_BUFFER: + + /* Return the exception (and the required buffer length) */ + + return (AE_BUFFER_OVERFLOW); + + case ACPI_ALLOCATE_BUFFER: + + /* Allocate a new buffer */ + + Buffer->Pointer = AcpiOsAllocate (RequiredLength); + break; + + case ACPI_ALLOCATE_LOCAL_BUFFER: + + /* Allocate a new buffer with local interface to allow tracking */ + + Buffer->Pointer = ACPI_ALLOCATE (RequiredLength); + break; + + default: + + /* Existing buffer: Validate the size of the buffer */ + + if (InputBufferLength < RequiredLength) + { + return (AE_BUFFER_OVERFLOW); + } + break; + } + + /* Validate allocation from above or input buffer pointer */ + + if (!Buffer->Pointer) + { + return (AE_NO_MEMORY); + } + + /* Have a valid buffer, clear it */ + + ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocate + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of malloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocate ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + void *Allocation; + + + ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size); + + + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + ACPI_WARNING ((Module, Line, + "Attempt to allocate zero bytes, allocating 1 byte")); + Size = 1; + } + + Allocation = AcpiOsAllocate (Size); + if (!Allocation) + { + /* Report allocation error */ + + ACPI_WARNING ((Module, Line, + "Could not allocate size %X", (UINT32) Size)); + + return_PTR (NULL); + } + + return_PTR (Allocation); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateZeroed + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory. + * + ******************************************************************************/ + +void * +AcpiUtAllocateZeroed ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + void *Allocation; + + + ACPI_FUNCTION_ENTRY (); + + + Allocation = AcpiUtAllocate (Size, Component, Module, Line); + if (Allocation) + { + /* Clear the memory block */ + + ACPI_MEMSET (Allocation, 0, Size); + } + + return (Allocation); +} + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utcache.c b/reactos/drivers/bus/acpi/acpica/utilities/utcache.c new file mode 100644 index 00000000000..aabc0a23052 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utcache.c @@ -0,0 +1,433 @@ +/****************************************************************************** + * + * Module Name: utcache - local cache allocation routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTCACHE_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcache") + + +#ifdef ACPI_USE_LOCAL_CACHE +/******************************************************************************* + * + * FUNCTION: AcpiOsCreateCache + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * MaxDepth - Maximum depth of the cache (in objects) + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a cache object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + ACPI_FUNCTION_ENTRY (); + + + if (!CacheName || !ReturnCache || (ObjectSize < 16)) + { + return (AE_BAD_PARAMETER); + } + + /* Create the cache object */ + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + /* Populate the cache object and return it */ + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + Cache->LinkOffset = 8; + Cache->ListName = CacheName; + Cache->ObjectSize = ObjectSize; + Cache->MaxDepth = MaxDepth; + + *ReturnCache = Cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsPurgeCache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_MEMORY_LIST *Cache) +{ + char *Next; + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Cache) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Walk the list of objects in this cache */ + + while (Cache->ListHead) + { + /* Delete and unlink one cached state object */ + + Next = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Cache->ListHead)[Cache->LinkOffset]))); + ACPI_FREE (Cache->ListHead); + + Cache->ListHead = Next; + Cache->CurrentDepth--; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsDeleteCache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache and delete the + * cache object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_MEMORY_LIST *Cache) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* Purge all objects in the cache */ + + Status = AcpiOsPurgeCache (Cache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Now we can delete the cache object */ + + AcpiOsFree (Cache); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsReleaseObject + * + * PARAMETERS: Cache - Handle to cache object + * Object - The object to be released + * + * RETURN: None + * + * DESCRIPTION: Release an object to the specified cache. If cache is full, + * the object is deleted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_MEMORY_LIST *Cache, + void *Object) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Cache || !Object) + { + return (AE_BAD_PARAMETER); + } + + /* If cache is full, just free this object */ + + if (Cache->CurrentDepth >= Cache->MaxDepth) + { + ACPI_FREE (Object); + ACPI_MEM_TRACKING (Cache->TotalFreed++); + } + + /* Otherwise put this object back into the cache */ + + else + { + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Mark the object as cached */ + + ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize); + ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED); + + /* Put the object at the head of the cache list */ + + * (ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[Cache->LinkOffset]))) = Cache->ListHead; + Cache->ListHead = Object; + Cache->CurrentDepth++; + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsAcquireObject + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: the acquired object. NULL on error + * + * DESCRIPTION: Get an object from the specified cache. If cache is empty, + * the object is allocated. + * + ******************************************************************************/ + +void * +AcpiOsAcquireObject ( + ACPI_MEMORY_LIST *Cache) +{ + ACPI_STATUS Status; + void *Object; + + + ACPI_FUNCTION_NAME (OsAcquireObject); + + + if (!Cache) + { + return (NULL); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + ACPI_MEM_TRACKING (Cache->Requests++); + + /* Check the cache first */ + + if (Cache->ListHead) + { + /* There is an object available, use it */ + + Object = Cache->ListHead; + Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[Cache->LinkOffset]))); + + Cache->CurrentDepth--; + + ACPI_MEM_TRACKING (Cache->Hits++); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p from %s cache\n", Object, Cache->ListName)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + /* Clear (zero) the previously used Object */ + + ACPI_MEMSET (Object, 0, Cache->ObjectSize); + } + else + { + /* The cache is empty, create a new object */ + + ACPI_MEM_TRACKING (Cache->TotalAllocated++); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied) + { + Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed; + } +#endif + + /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ + + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); + if (!Object) + { + return (NULL); + } + } + + return (Object); +} +#endif /* ACPI_USE_LOCAL_CACHE */ + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utclib.c b/reactos/drivers/bus/acpi/acpica/utilities/utclib.c new file mode 100644 index 00000000000..a9b8122fab8 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utclib.c @@ -0,0 +1,961 @@ +/****************************************************************************** + * + * Module Name: cmclib - Local implementation of C library functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMCLIB_C__ + +#include "acpi.h" +#include "accommon.h" + +/* + * These implementations of standard C Library routines can optionally be + * used if a C library is not available. In general, they are less efficient + * than an inline or assembly implementation + */ + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("cmclib") + + +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +#define NEGATIVE 1 +#define POSITIVE 0 + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcmp (memcmp) + * + * PARAMETERS: Buffer1 - First Buffer + * Buffer2 - Second Buffer + * Count - Maximum # of bytes to compare + * + * RETURN: Index where Buffers mismatched, or 0 if Buffers matched + * + * DESCRIPTION: Compare two Buffers, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count) +{ + + for ( ; Count-- && (*Buffer1 == *Buffer2); Buffer1++, Buffer2++) + { + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *Buffer1 - + (unsigned char) *Buffer2)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcpy (memcpy) + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory + * + ******************************************************************************/ + +void * +AcpiUtMemcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + char *Old = (char *) Src; + + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemset (memset) + * + * PARAMETERS: Dest - Buffer to set + * Value - Value to set each byte of memory + * Count - Number of bytes to set + * + * RETURN: Dest + * + * DESCRIPTION: Initialize a buffer to a known value. + * + ******************************************************************************/ + +void * +AcpiUtMemset ( + void *Dest, + UINT8 Value, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + + + while (Count) + { + *New = (char) Value; + New++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrlen (strlen) + * + * PARAMETERS: String - Null terminated string + * + * RETURN: Length + * + * DESCRIPTION: Returns the length of the input string + * + ******************************************************************************/ + + +ACPI_SIZE +AcpiUtStrlen ( + const char *String) +{ + UINT32 Length = 0; + + + /* Count the string until a null is encountered */ + + while (*String) + { + Length++; + String++; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcpy (strcpy) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string + * + ******************************************************************************/ + +char * +AcpiUtStrcpy ( + char *DstString, + const char *SrcString) +{ + char *String = DstString; + + + /* Move bytes brute force */ + + while (*SrcString) + { + *String = *SrcString; + + String++; + SrcString++; + } + + /* Null terminate */ + + *String = 0; + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncpy (strncpy) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string, with a maximum length + * + ******************************************************************************/ + +char * +AcpiUtStrncpy ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count) +{ + char *String = DstString; + + + /* Copy the string */ + + for (String = DstString; + Count && (Count--, (*String++ = *SrcString++)); ) + {;} + + /* Pad with nulls if necessary */ + + while (Count--) + { + *String = 0; + String++; + } + + /* Return original pointer */ + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcmp (strcmp) + * + * PARAMETERS: String1 - First string + * String2 - Second string + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings + * + ******************************************************************************/ + +int +AcpiUtStrcmp ( + const char *String1, + const char *String2) +{ + + + for ( ; (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((unsigned char) *String1 - (unsigned char) *String2); +} + + +#ifdef ACPI_FUTURE_IMPLEMENTATION +/* Not used at this time */ +/******************************************************************************* + * + * FUNCTION: AcpiUtStrchr (strchr) + * + * PARAMETERS: String - Search string + * ch - character to search for + * + * RETURN: Ptr to char or NULL if not found + * + * DESCRIPTION: Search a string for a character + * + ******************************************************************************/ + +char * +AcpiUtStrchr ( + const char *String, + int ch) +{ + + + for ( ; (*String); String++) + { + if ((*String) == (char) ch) + { + return ((char *) String); + } + } + + return (NULL); +} +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncmp (strncmp) + * + * PARAMETERS: String1 - First string + * String2 - Second string + * Count - Maximum # of bytes to compare + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtStrncmp ( + const char *String1, + const char *String2, + ACPI_SIZE Count) +{ + + + for ( ; Count-- && (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *String1 - + (unsigned char) *String2)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcat (Strcat) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string + * + ******************************************************************************/ + +char * +AcpiUtStrcat ( + char *DstString, + const char *SrcString) +{ + char *String; + + + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatenate the string */ + + for (--String; (*String++ = *SrcString++); ) + { ; } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncat (strncat) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string, + * with a maximum count. + * + ******************************************************************************/ + +char * +AcpiUtStrncat ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count) +{ + char *String; + + + if (Count) + { + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatenate the string */ + + for (--String; (*String++ = *SrcString++) && --Count; ) + { ; } + + /* Null terminate if necessary */ + + if (!Count) + { + *String = 0; + } + } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrstr (strstr) + * + * PARAMETERS: String1 - Target string + * String2 - Substring to search for + * + * RETURN: Where substring match starts, Null if no match found + * + * DESCRIPTION: Checks if String2 occurs in String1. This is not really a + * full implementation of strstr, only sufficient for command + * matching + * + ******************************************************************************/ + +char * +AcpiUtStrstr ( + char *String1, + char *String2) +{ + char *String; + + + if (AcpiUtStrlen (String2) > AcpiUtStrlen (String1)) + { + return (NULL); + } + + /* Walk entire string, comparing the letters */ + + for (String = String1; *String2; ) + { + if (*String2 != *String) + { + return (NULL); + } + + String2++; + String++; + } + + return (String1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul (strtoul) + * + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte is + * returned + * Base - Radix of the string + * + * RETURN: Converted value + * + * DESCRIPTION: Convert a string into a 32-bit unsigned value. + * Note: use AcpiUtStrtoul64 for 64-bit integers. + * + ******************************************************************************/ + +UINT32 +AcpiUtStrtoul ( + const char *String, + char **Terminator, + UINT32 Base) +{ + UINT32 converted = 0; + UINT32 index; + UINT32 sign; + const char *StringStart; + UINT32 ReturnValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* + * Save the value of the pointer to the buffer's first + * character, save the current errno value, and then + * skip over any white space in the buffer: + */ + StringStart = String; + while (ACPI_IS_SPACE (*String) || *String == '\t') + { + ++String; + } + + /* + * The buffer may contain an optional plus or minus sign. + * If it does, then skip over it but remember what is was: + */ + if (*String == '-') + { + sign = NEGATIVE; + ++String; + } + else if (*String == '+') + { + ++String; + sign = POSITIVE; + } + else + { + sign = POSITIVE; + } + + /* + * If the input parameter Base is zero, then we need to + * determine if it is octal, decimal, or hexadecimal: + */ + if (Base == 0) + { + if (*String == '0') + { + if (AcpiUtToLower (*(++String)) == 'x') + { + Base = 16; + ++String; + } + else + { + Base = 8; + } + } + else + { + Base = 10; + } + } + else if (Base < 2 || Base > 36) + { + /* + * The specified Base parameter is not in the domain of + * this function: + */ + goto done; + } + + /* + * For octal and hexadecimal bases, skip over the leading + * 0 or 0x, if they are present. + */ + if (Base == 8 && *String == '0') + { + String++; + } + + if (Base == 16 && + *String == '0' && + AcpiUtToLower (*(++String)) == 'x') + { + String++; + } + + /* + * Main loop: convert the string to an unsigned long: + */ + while (*String) + { + if (ACPI_IS_DIGIT (*String)) + { + index = (UINT32) ((UINT8) *String - '0'); + } + else + { + index = (UINT32) AcpiUtToUpper (*String); + if (ACPI_IS_UPPER (index)) + { + index = index - 'A' + 10; + } + else + { + goto done; + } + } + + if (index >= Base) + { + goto done; + } + + /* + * Check to see if value is out of range: + */ + + if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) / + (UINT32) Base)) + { + Status = AE_ERROR; + ReturnValue = 0; /* reset */ + } + else + { + ReturnValue *= Base; + ReturnValue += index; + converted = 1; + } + + ++String; + } + +done: + /* + * If appropriate, update the caller's pointer to the next + * unconverted character in the buffer. + */ + if (Terminator) + { + if (converted == 0 && ReturnValue == 0 && String != NULL) + { + *Terminator = (char *) StringStart; + } + else + { + *Terminator = (char *) String; + } + } + + if (Status == AE_ERROR) + { + ReturnValue = ACPI_UINT32_MAX; + } + + /* + * If a minus sign was present, then "the conversion is negated": + */ + if (sign == NEGATIVE) + { + ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + } + + return (ReturnValue); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToUpper (TOUPPER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to uppercase + * + ******************************************************************************/ + +int +AcpiUtToUpper ( + int c) +{ + + return (ACPI_IS_LOWER(c) ? ((c)-0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToLower (TOLOWER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to lowercase + * + ******************************************************************************/ + +int +AcpiUtToLower ( + int c) +{ + + return (ACPI_IS_UPPER(c) ? ((c)+0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: is* functions + * + * DESCRIPTION: is* functions use the ctype table below + * + ******************************************************************************/ + +const UINT8 _acpi_ctype[257] = { + _ACPI_CN, /* 0x0 0. */ + _ACPI_CN, /* 0x1 1. */ + _ACPI_CN, /* 0x2 2. */ + _ACPI_CN, /* 0x3 3. */ + _ACPI_CN, /* 0x4 4. */ + _ACPI_CN, /* 0x5 5. */ + _ACPI_CN, /* 0x6 6. */ + _ACPI_CN, /* 0x7 7. */ + _ACPI_CN, /* 0x8 8. */ + _ACPI_CN|_ACPI_SP, /* 0x9 9. */ + _ACPI_CN|_ACPI_SP, /* 0xA 10. */ + _ACPI_CN|_ACPI_SP, /* 0xB 11. */ + _ACPI_CN|_ACPI_SP, /* 0xC 12. */ + _ACPI_CN|_ACPI_SP, /* 0xD 13. */ + _ACPI_CN, /* 0xE 14. */ + _ACPI_CN, /* 0xF 15. */ + _ACPI_CN, /* 0x10 16. */ + _ACPI_CN, /* 0x11 17. */ + _ACPI_CN, /* 0x12 18. */ + _ACPI_CN, /* 0x13 19. */ + _ACPI_CN, /* 0x14 20. */ + _ACPI_CN, /* 0x15 21. */ + _ACPI_CN, /* 0x16 22. */ + _ACPI_CN, /* 0x17 23. */ + _ACPI_CN, /* 0x18 24. */ + _ACPI_CN, /* 0x19 25. */ + _ACPI_CN, /* 0x1A 26. */ + _ACPI_CN, /* 0x1B 27. */ + _ACPI_CN, /* 0x1C 28. */ + _ACPI_CN, /* 0x1D 29. */ + _ACPI_CN, /* 0x1E 30. */ + _ACPI_CN, /* 0x1F 31. */ + _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ + _ACPI_PU, /* 0x21 33. '!' */ + _ACPI_PU, /* 0x22 34. '"' */ + _ACPI_PU, /* 0x23 35. '#' */ + _ACPI_PU, /* 0x24 36. '$' */ + _ACPI_PU, /* 0x25 37. '%' */ + _ACPI_PU, /* 0x26 38. '&' */ + _ACPI_PU, /* 0x27 39. ''' */ + _ACPI_PU, /* 0x28 40. '(' */ + _ACPI_PU, /* 0x29 41. ')' */ + _ACPI_PU, /* 0x2A 42. '*' */ + _ACPI_PU, /* 0x2B 43. '+' */ + _ACPI_PU, /* 0x2C 44. ',' */ + _ACPI_PU, /* 0x2D 45. '-' */ + _ACPI_PU, /* 0x2E 46. '.' */ + _ACPI_PU, /* 0x2F 47. '/' */ + _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ + _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ + _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ + _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ + _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ + _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ + _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ + _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ + _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ + _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ + _ACPI_PU, /* 0x3A 58. ':' */ + _ACPI_PU, /* 0x3B 59. ';' */ + _ACPI_PU, /* 0x3C 60. '<' */ + _ACPI_PU, /* 0x3D 61. '=' */ + _ACPI_PU, /* 0x3E 62. '>' */ + _ACPI_PU, /* 0x3F 63. '?' */ + _ACPI_PU, /* 0x40 64. '@' */ + _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ + _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ + _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ + _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ + _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ + _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ + _ACPI_UP, /* 0x47 71. 'G' */ + _ACPI_UP, /* 0x48 72. 'H' */ + _ACPI_UP, /* 0x49 73. 'I' */ + _ACPI_UP, /* 0x4A 74. 'J' */ + _ACPI_UP, /* 0x4B 75. 'K' */ + _ACPI_UP, /* 0x4C 76. 'L' */ + _ACPI_UP, /* 0x4D 77. 'M' */ + _ACPI_UP, /* 0x4E 78. 'N' */ + _ACPI_UP, /* 0x4F 79. 'O' */ + _ACPI_UP, /* 0x50 80. 'P' */ + _ACPI_UP, /* 0x51 81. 'Q' */ + _ACPI_UP, /* 0x52 82. 'R' */ + _ACPI_UP, /* 0x53 83. 'S' */ + _ACPI_UP, /* 0x54 84. 'T' */ + _ACPI_UP, /* 0x55 85. 'U' */ + _ACPI_UP, /* 0x56 86. 'V' */ + _ACPI_UP, /* 0x57 87. 'W' */ + _ACPI_UP, /* 0x58 88. 'X' */ + _ACPI_UP, /* 0x59 89. 'Y' */ + _ACPI_UP, /* 0x5A 90. 'Z' */ + _ACPI_PU, /* 0x5B 91. '[' */ + _ACPI_PU, /* 0x5C 92. '\' */ + _ACPI_PU, /* 0x5D 93. ']' */ + _ACPI_PU, /* 0x5E 94. '^' */ + _ACPI_PU, /* 0x5F 95. '_' */ + _ACPI_PU, /* 0x60 96. '`' */ + _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ + _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ + _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ + _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ + _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ + _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ + _ACPI_LO, /* 0x67 103. 'g' */ + _ACPI_LO, /* 0x68 104. 'h' */ + _ACPI_LO, /* 0x69 105. 'i' */ + _ACPI_LO, /* 0x6A 106. 'j' */ + _ACPI_LO, /* 0x6B 107. 'k' */ + _ACPI_LO, /* 0x6C 108. 'l' */ + _ACPI_LO, /* 0x6D 109. 'm' */ + _ACPI_LO, /* 0x6E 110. 'n' */ + _ACPI_LO, /* 0x6F 111. 'o' */ + _ACPI_LO, /* 0x70 112. 'p' */ + _ACPI_LO, /* 0x71 113. 'q' */ + _ACPI_LO, /* 0x72 114. 'r' */ + _ACPI_LO, /* 0x73 115. 's' */ + _ACPI_LO, /* 0x74 116. 't' */ + _ACPI_LO, /* 0x75 117. 'u' */ + _ACPI_LO, /* 0x76 118. 'v' */ + _ACPI_LO, /* 0x77 119. 'w' */ + _ACPI_LO, /* 0x78 120. 'x' */ + _ACPI_LO, /* 0x79 121. 'y' */ + _ACPI_LO, /* 0x7A 122. 'z' */ + _ACPI_PU, /* 0x7B 123. '{' */ + _ACPI_PU, /* 0x7C 124. '|' */ + _ACPI_PU, /* 0x7D 125. '}' */ + _ACPI_PU, /* 0x7E 126. '~' */ + _ACPI_CN, /* 0x7F 127. */ + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ +}; + + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utcopy.c b/reactos/drivers/bus/acpi/acpica/utilities/utcopy.c new file mode 100644 index 00000000000..5423eff9dec --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utcopy.c @@ -0,0 +1,1142 @@ +/****************************************************************************** + * + * Module Name: utcopy - Internal to external object translation utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTCOPY_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcopy") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, + UINT8 *DataSpace, + ACPI_SIZE *BufferSpaceUsed); + +static ACPI_STATUS +AcpiUtCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT8 *Buffer, + ACPI_SIZE *SpaceUsed); + +static ACPI_STATUS +AcpiUtCopyEsimpleToIsimple( + ACPI_OBJECT *UserObj, + ACPI_OPERAND_OBJECT **ReturnObj); + +static ACPI_STATUS +AcpiUtCopyEpackageToIpackage ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject); + +static ACPI_STATUS +AcpiUtCopySimpleObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc); + +static ACPI_STATUS +AcpiUtCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIsimpleToEsimple + * + * PARAMETERS: InternalObject - Source object to be copied + * ExternalObject - Where to return the copied object + * DataSpace - Where object data is returned (such as + * buffer and string data) + * BufferSpaceUsed - Length of DataSpace that was used + * + * RETURN: Status + * + * DESCRIPTION: This function is called to copy a simple internal object to + * an external object. + * + * The DataSpace buffer is assumed to have sufficient space for + * the object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, + UINT8 *DataSpace, + ACPI_SIZE *BufferSpaceUsed) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple); + + + *BufferSpaceUsed = 0; + + /* + * Check for NULL object case (could be an uninitialized + * package element) + */ + if (!InternalObject) + { + return_ACPI_STATUS (AE_OK); + } + + /* Always clear the external object */ + + ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); + + /* + * In general, the external object will be the same type as + * the internal object + */ + ExternalObject->Type = InternalObject->Common.Type; + + /* However, only a limited number of external types are supported */ + + switch (InternalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + ExternalObject->String.Pointer = (char *) DataSpace; + ExternalObject->String.Length = InternalObject->String.Length; + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + (ACPI_SIZE) InternalObject->String.Length + 1); + + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->String.Pointer, + (ACPI_SIZE) InternalObject->String.Length + 1); + break; + + + case ACPI_TYPE_BUFFER: + + ExternalObject->Buffer.Pointer = DataSpace; + ExternalObject->Buffer.Length = InternalObject->Buffer.Length; + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + InternalObject->String.Length); + + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->Buffer.Pointer, + InternalObject->Buffer.Length); + break; + + + case ACPI_TYPE_INTEGER: + + ExternalObject->Integer.Value = InternalObject->Integer.Value; + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + /* This is an object reference. */ + + switch (InternalObject->Reference.Class) + { + case ACPI_REFCLASS_NAME: + + /* + * For namepath, return the object handle ("reference") + * We are referring to the namespace node + */ + ExternalObject->Reference.Handle = + InternalObject->Reference.Node; + ExternalObject->Reference.ActualType = + AcpiNsGetType (InternalObject->Reference.Node); + break; + + default: + + /* All other reference types are unsupported */ + + return_ACPI_STATUS (AE_TYPE); + } + break; + + + case ACPI_TYPE_PROCESSOR: + + ExternalObject->Processor.ProcId = + InternalObject->Processor.ProcId; + ExternalObject->Processor.PblkAddress = + InternalObject->Processor.Address; + ExternalObject->Processor.PblkLength = + InternalObject->Processor.Length; + break; + + + case ACPI_TYPE_POWER: + + ExternalObject->PowerResource.SystemLevel = + InternalObject->PowerResource.SystemLevel; + + ExternalObject->PowerResource.ResourceOrder = + InternalObject->PowerResource.ResourceOrder; + break; + + + default: + /* + * There is no corresponding external object type + */ + ACPI_ERROR ((AE_INFO, + "Unsupported object type, cannot convert to external object: %s", + AcpiUtGetTypeName (InternalObject->Common.Type))); + + return_ACPI_STATUS (AE_SUPPORT); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIelementToEelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; + ACPI_SIZE ObjectSpace; + UINT32 ThisIndex; + ACPI_OBJECT *TargetObject; + + + ACPI_FUNCTION_ENTRY (); + + + ThisIndex = State->Pkg.Index; + TargetObject = (ACPI_OBJECT *) + &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* + * This is a simple or null object + */ + Status = AcpiUtCopyIsimpleToEsimple (SourceObject, + TargetObject, Info->FreeSpace, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* + * Build the package object + */ + TargetObject->Type = ACPI_TYPE_PACKAGE; + TargetObject->Package.Count = SourceObject->Package.Count; + TargetObject->Package.Elements = + ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); + + /* + * Pass the new package object back to the package walk routine + */ + State->Pkg.ThisTargetObj = TargetObject; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( + (ACPI_SIZE) TargetObject->Package.Count * + sizeof (ACPI_OBJECT)); + break; + + + default: + return (AE_BAD_PARAMETER); + } + + Info->FreeSpace += ObjectSpace; + Info->Length += ObjectSpace; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIpackageToEpackage + * + * PARAMETERS: InternalObject - Pointer to the object we are returning + * Buffer - Where the object is returned + * SpaceUsed - Where the object length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to place a package object in a user + * buffer. A package object by definition contains other objects. + * + * The buffer is assumed to have sufficient space for the object. + * The caller must have verified the buffer length needed using + * the AcpiUtGetObjectSize function before calling this function. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT8 *Buffer, + ACPI_SIZE *SpaceUsed) +{ + ACPI_OBJECT *ExternalObject; + ACPI_STATUS Status; + ACPI_PKG_INFO Info; + + + ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage); + + + /* + * First package at head of the buffer + */ + ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer); + + /* + * Free space begins right after the first package + */ + Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( + sizeof (ACPI_OBJECT)); + Info.ObjectSpace = 0; + Info.NumPackages = 1; + + ExternalObject->Type = InternalObject->Common.Type; + ExternalObject->Package.Count = InternalObject->Package.Count; + ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, + Info.FreeSpace); + + /* + * Leave room for an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace += ExternalObject->Package.Count * + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + + Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, + AcpiUtCopyIelementToEelement, &Info); + + *SpaceUsed = Info.Length; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIobjectToEobject + * + * PARAMETERS: InternalObject - The internal object to be converted + * RetBuffer - Where the object is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to build an API object to be returned + * to the caller. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyIobjectToEobject ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject); + + + if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE) + { + /* + * Package object: Copy all subobjects (including + * nested packages) + */ + Status = AcpiUtCopyIpackageToEpackage (InternalObject, + RetBuffer->Pointer, &RetBuffer->Length); + } + else + { + /* + * Build a simple object (no nested objects) + */ + Status = AcpiUtCopyIsimpleToEsimple (InternalObject, + ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer), + ACPI_ADD_PTR (UINT8, RetBuffer->Pointer, + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), + &RetBuffer->Length); + /* + * build simple does not include the object size in the length + * so we add it in here + */ + RetBuffer->Length += sizeof (ACPI_OBJECT); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEsimpleToIsimple + * + * PARAMETERS: ExternalObject - The external object to be converted + * RetInternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: This function copies an external object to an internal one. + * NOTE: Pointers can be copied, we don't need to copy data. + * (The pointers have to be valid in our address space no matter + * what we do with them!) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyEsimpleToIsimple ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **RetInternalObject) +{ + ACPI_OPERAND_OBJECT *InternalObject; + + + ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple); + + + /* + * Simple types supported are: String, Buffer, Integer + */ + switch (ExternalObject->Type) + { + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_LOCAL_REFERENCE: + + InternalObject = AcpiUtCreateInternalObject ( + (UINT8) ExternalObject->Type); + if (!InternalObject) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + break; + + case ACPI_TYPE_ANY: /* This is the case for a NULL object */ + + *RetInternalObject = NULL; + return_ACPI_STATUS (AE_OK); + + default: + /* All other types are not supported */ + + ACPI_ERROR ((AE_INFO, + "Unsupported object type, cannot convert to internal object: %s", + AcpiUtGetTypeName (ExternalObject->Type))); + + return_ACPI_STATUS (AE_SUPPORT); + } + + + /* Must COPY string and buffer contents */ + + switch (ExternalObject->Type) + { + case ACPI_TYPE_STRING: + + InternalObject->String.Pointer = + ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) + ExternalObject->String.Length + 1); + + if (!InternalObject->String.Pointer) + { + goto ErrorExit; + } + + ACPI_MEMCPY (InternalObject->String.Pointer, + ExternalObject->String.Pointer, + ExternalObject->String.Length); + + InternalObject->String.Length = ExternalObject->String.Length; + break; + + + case ACPI_TYPE_BUFFER: + + InternalObject->Buffer.Pointer = + ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length); + if (!InternalObject->Buffer.Pointer) + { + goto ErrorExit; + } + + ACPI_MEMCPY (InternalObject->Buffer.Pointer, + ExternalObject->Buffer.Pointer, + ExternalObject->Buffer.Length); + + InternalObject->Buffer.Length = ExternalObject->Buffer.Length; + + /* Mark buffer data valid */ + + InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID; + break; + + + case ACPI_TYPE_INTEGER: + + InternalObject->Integer.Value = ExternalObject->Integer.Value; + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + + /* TBD: should validate incoming handle */ + + InternalObject->Reference.Class = ACPI_REFCLASS_NAME; + InternalObject->Reference.Node = ExternalObject->Reference.Handle; + break; + + default: + /* Other types can't get here */ + break; + } + + *RetInternalObject = InternalObject; + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + AcpiUtRemoveReference (InternalObject); + return_ACPI_STATUS (AE_NO_MEMORY); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEpackageToIpackage + * + * PARAMETERS: ExternalObject - The external object to be converted + * InternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Copy an external package object to an internal package. + * Handles nested packages. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyEpackageToIpackage ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *PackageObject; + ACPI_OPERAND_OBJECT **PackageElements; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage); + + + /* Create the package object */ + + PackageObject = AcpiUtCreatePackageObject (ExternalObject->Package.Count); + if (!PackageObject) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + PackageElements = PackageObject->Package.Elements; + + /* + * Recursive implementation. Probably ok, since nested external packages + * as parameters should be very rare. + */ + for (i = 0; i < ExternalObject->Package.Count; i++) + { + Status = AcpiUtCopyEobjectToIobject ( + &ExternalObject->Package.Elements[i], + &PackageElements[i]); + if (ACPI_FAILURE (Status)) + { + /* Truncate package and delete it */ + + PackageObject->Package.Count = i; + PackageElements[i] = NULL; + AcpiUtRemoveReference (PackageObject); + return_ACPI_STATUS (Status); + } + } + + /* Mark package data valid */ + + PackageObject->Package.Flags |= AOPOBJ_DATA_VALID; + + *InternalObject = PackageObject; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEobjectToIobject + * + * PARAMETERS: ExternalObject - The external object to be converted + * InternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Converts an external object to an internal object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyEobjectToIobject ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject); + + + if (ExternalObject->Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiUtCopyEpackageToIpackage (ExternalObject, InternalObject); + } + else + { + /* + * Build a simple object (no nested objects) + */ + Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopySimpleObject + * + * PARAMETERS: SourceDesc - The internal object to be copied + * DestDesc - New target object + * + * RETURN: Status + * + * DESCRIPTION: Simple copy of one internal object to another. Reference count + * of the destination object is preserved. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopySimpleObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc) +{ + UINT16 ReferenceCount; + ACPI_OPERAND_OBJECT *NextObject; + ACPI_STATUS Status; + + + /* Save fields from destination that we don't want to overwrite */ + + ReferenceCount = DestDesc->Common.ReferenceCount; + NextObject = DestDesc->Common.NextObject; + + /* Copy the entire source object over the destination object*/ + + ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc, + sizeof (ACPI_OPERAND_OBJECT)); + + /* Restore the saved fields */ + + DestDesc->Common.ReferenceCount = ReferenceCount; + DestDesc->Common.NextObject = NextObject; + + /* New object is not static, regardless of source */ + + DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + + /* Handle the objects with extra data */ + + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + /* + * Allocate and copy the actual buffer if and only if: + * 1) There is a valid buffer pointer + * 2) The buffer has a length > 0 + */ + if ((SourceDesc->Buffer.Pointer) && + (SourceDesc->Buffer.Length)) + { + DestDesc->Buffer.Pointer = + ACPI_ALLOCATE (SourceDesc->Buffer.Length); + if (!DestDesc->Buffer.Pointer) + { + return (AE_NO_MEMORY); + } + + /* Copy the actual buffer data */ + + ACPI_MEMCPY (DestDesc->Buffer.Pointer, + SourceDesc->Buffer.Pointer, + SourceDesc->Buffer.Length); + } + break; + + case ACPI_TYPE_STRING: + /* + * Allocate and copy the actual string if and only if: + * 1) There is a valid string pointer + * (Pointer to a NULL string is allowed) + */ + if (SourceDesc->String.Pointer) + { + DestDesc->String.Pointer = + ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); + if (!DestDesc->String.Pointer) + { + return (AE_NO_MEMORY); + } + + /* Copy the actual string data */ + + ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, + (ACPI_SIZE) SourceDesc->String.Length + 1); + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * We copied the reference object, so we now must add a reference + * to the object pointed to by the reference + * + * DDBHandle reference (from Load/LoadTable) is a special reference, + * it does not have a Reference.Object, so does not need to + * increase the reference count + */ + if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + break; + } + + AcpiUtAddReference (SourceDesc->Reference.Object); + break; + + case ACPI_TYPE_REGION: + /* + * We copied the Region Handler, so we now must add a reference + */ + if (DestDesc->Region.Handler) + { + AcpiUtAddReference (DestDesc->Region.Handler); + } + break; + + /* + * For Mutex and Event objects, we cannot simply copy the underlying + * OS object. We must create a new one. + */ + case ACPI_TYPE_MUTEX: + + Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_EVENT: + + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, + &DestDesc->Event.OsSemaphore); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + default: + /* Nothing to do for other simple objects */ + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIelementToIelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT **ThisTargetPtr; + ACPI_OPERAND_OBJECT *TargetObject; + + + ACPI_FUNCTION_ENTRY (); + + + ThisIndex = State->Pkg.Index; + ThisTargetPtr = (ACPI_OPERAND_OBJECT **) + &State->Pkg.DestObject->Package.Elements[ThisIndex]; + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* A null source object indicates a (legal) null package element */ + + if (SourceObject) + { + /* + * This is a simple object, just copy it + */ + TargetObject = AcpiUtCreateInternalObject ( + SourceObject->Common.Type); + if (!TargetObject) + { + return (AE_NO_MEMORY); + } + + Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + *ThisTargetPtr = TargetObject; + } + else + { + /* Pass through a null element */ + + *ThisTargetPtr = NULL; + } + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* + * This object is a package - go down another nesting level + * Create and build the package object + */ + TargetObject = AcpiUtCreatePackageObject (SourceObject->Package.Count); + if (!TargetObject) + { + return (AE_NO_MEMORY); + } + + TargetObject->Common.Flags = SourceObject->Common.Flags; + + /* Pass the new package object back to the package walk routine */ + + State->Pkg.ThisTargetObj = TargetObject; + + /* Store the object pointer in the parent package object */ + + *ThisTargetPtr = TargetObject; + break; + + + default: + return (AE_BAD_PARAMETER); + } + + return (Status); + +ErrorExit: + AcpiUtRemoveReference (TargetObject); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIpackageToIpackage + * + * PARAMETERS: SourceObj - Pointer to the source package object + * DestObj - Where the internal object is returned + * WalkState - Current Walk state descriptor + * + * RETURN: Status + * + * DESCRIPTION: This function is called to copy an internal package object + * into another internal package object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); + + + DestObj->Common.Type = SourceObj->Common.Type; + DestObj->Common.Flags = SourceObj->Common.Flags; + DestObj->Package.Count = SourceObj->Package.Count; + + /* + * Create the object array and walk the source package tree + */ + DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) SourceObj->Package.Count + 1) * + sizeof (void *)); + if (!DestObj->Package.Elements) + { + ACPI_ERROR ((AE_INFO, "Package allocation failure")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the package element-by-element by walking the package "tree". + * This handles nested packages of arbitrary depth. + */ + Status = AcpiUtWalkPackageTree (SourceObj, DestObj, + AcpiUtCopyIelementToIelement, WalkState); + if (ACPI_FAILURE (Status)) + { + /* On failure, delete the destination package object */ + + AcpiUtRemoveReference (DestObj); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIobjectToIobject + * + * PARAMETERS: SourceDesc - The internal object to be copied + * DestDesc - Where the copied object is returned + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Copy an internal object to a new internal object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyIobjectToIobject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject); + + + /* Create the top level object */ + + *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type); + if (!*DestDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the object and possible subobjects */ + + if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc, + WalkState); + } + else + { + Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utdebug.c b/reactos/drivers/bus/acpi/acpica/utilities/utdebug.c new file mode 100644 index 00000000000..3901b07d197 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utdebug.c @@ -0,0 +1,814 @@ +/****************************************************************************** + * + * Module Name: utdebug - Debug print routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTDEBUG_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utdebug") + + +#ifdef ACPI_DEBUG_OUTPUT + +static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; +static char *AcpiGbl_FnEntryStr = "----Entry"; +static char *AcpiGbl_FnExitStr = "----Exit-"; + +/* Local prototypes */ + +static const char * +AcpiUtTrimFunctionName ( + const char *FunctionName); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitStackPtrTrace + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Save the current CPU stack pointer at subsystem startup + * + ******************************************************************************/ + +void +AcpiUtInitStackPtrTrace ( + void) +{ + ACPI_SIZE CurrentSp; + + + AcpiGbl_EntryStackPointer = &CurrentSp; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrackStackPtr + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Save the current CPU stack pointer + * + ******************************************************************************/ + +void +AcpiUtTrackStackPtr ( + void) +{ + ACPI_SIZE CurrentSp; + + + if (&CurrentSp < AcpiGbl_LowestStackPointer) + { + AcpiGbl_LowestStackPointer = &CurrentSp; + } + + if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting) + { + AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrimFunctionName + * + * PARAMETERS: FunctionName - Ascii string containing a procedure name + * + * RETURN: Updated pointer to the function name + * + * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. + * This allows compiler macros such as __FUNCTION__ to be used + * with no change to the debug output. + * + ******************************************************************************/ + +static const char * +AcpiUtTrimFunctionName ( + const char *FunctionName) +{ + + /* All Function names are longer than 4 chars, check is safe */ + + if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED) + { + /* This is the case where the original source has not been modified */ + + return (FunctionName + 4); + } + + if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER) + { + /* This is the case where the source has been 'linuxized' */ + + return (FunctionName + 5); + } + + return (FunctionName); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugPrint + * + * PARAMETERS: RequestedDebugLevel - Requested debug print level + * LineNumber - Caller's line number (for error output) + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print error message with prefix consisting of the module name, + * line number, and component ID. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrint ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) +{ + ACPI_THREAD_ID ThreadId; + va_list args; + + + /* + * Stay silent if the debug level or component ID is disabled + */ + if (!(RequestedDebugLevel & AcpiDbgLevel) || + !(ComponentId & AcpiDbgLayer)) + { + return; + } + + /* + * Thread tracking and context switch notification + */ + ThreadId = AcpiOsGetThreadId (); + if (ThreadId != AcpiGbl_PrevThreadId) + { + if (ACPI_LV_THREADS & AcpiDbgLevel) + { + AcpiOsPrintf ( + "\n**** Context Switch from TID %p to TID %p ****\n\n", + ACPI_CAST_PTR (void, AcpiGbl_PrevThreadId), + ACPI_CAST_PTR (void, ThreadId)); + } + + AcpiGbl_PrevThreadId = ThreadId; + } + + /* + * Display the module name, current line number, thread ID (if requested), + * current procedure nesting level, and the current procedure name + */ + AcpiOsPrintf ("%8s-%04ld ", ModuleName, LineNumber); + + if (ACPI_LV_THREADS & AcpiDbgLevel) + { + AcpiOsPrintf ("[%p] ", ACPI_CAST_PTR (void, ThreadId)); + } + + AcpiOsPrintf ("[%02ld] %-22.22s: ", + AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName)); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + va_end (args); +} + +ACPI_EXPORT_SYMBOL (AcpiDebugPrint) + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugPrintRaw + * + * PARAMETERS: RequestedDebugLevel - Requested debug print level + * LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print message with no headers. Has same interface as + * DebugPrint so that the same macros can be used. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrintRaw ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) +{ + va_list args; + + + if (!(RequestedDebugLevel & AcpiDbgLevel) || + !(ComponentId & AcpiDbgLayer)) + { + return; + } + + va_start (args, Format); + AcpiOsVprintf (Format, args); + va_end (args); +} + +ACPI_EXPORT_SYMBOL (AcpiDebugPrintRaw) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrace + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTrace ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s\n", AcpiGbl_FnEntryStr); +} + +ACPI_EXPORT_SYMBOL (AcpiUtTrace) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTracePtr + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Pointer - Pointer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTracePtr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + void *Pointer) +{ + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %p\n", AcpiGbl_FnEntryStr, Pointer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTraceStr + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * String - Additional string to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTraceStr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + char *String) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FnEntryStr, String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTraceU32 + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Integer - Integer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTraceU32 ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT32 Integer) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %08X\n", AcpiGbl_FnEntryStr, Integer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s\n", AcpiGbl_FnExitStr); + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStatusExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Status - Exit status code + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit status also. + * + ******************************************************************************/ + +void +AcpiUtStatusExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_STATUS Status) +{ + + if (ACPI_SUCCESS (Status)) + { + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FnExitStr, + AcpiFormatException (Status)); + } + else + { + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, + AcpiFormatException (Status)); + } + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtStatusExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValueExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Value - Value to be printed with exit msg + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit value also. + * + ******************************************************************************/ + +void +AcpiUtValueExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_INTEGER Value) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, + ACPI_FORMAT_UINT64 (Value)); + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtValueExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPtrExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Ptr - Pointer to display + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit value also. + * + ******************************************************************************/ + +void +AcpiUtPtrExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT8 *Ptr) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %p\n", AcpiGbl_FnExitStr, Ptr); + + AcpiGbl_NestingLevel--; +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ******************************************************************************/ + +void +AcpiUtDumpBuffer2 ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display) +{ + UINT32 i = 0; + UINT32 j; + UINT32 Temp32; + UINT8 BufChar; + + + if (!Buffer) + { + AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n"); + return; + } + + if ((Count < 4) || (Count & 0x01)) + { + Display = DB_BYTE_DISPLAY; + } + + /* Nasty little dump buffer routine! */ + + while (i < Count) + { + /* Print current offset */ + + AcpiOsPrintf ("%6.4X: ", i); + + /* Print 16 hex chars */ + + for (j = 0; j < 16;) + { + if (i + j >= Count) + { + /* Dump fill spaces */ + + AcpiOsPrintf ("%*s", ((Display * 2) + 1), " "); + j += Display; + continue; + } + + switch (Display) + { + case DB_BYTE_DISPLAY: + default: /* Default is BYTE display */ + + AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]); + break; + + + case DB_WORD_DISPLAY: + + ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%04X ", Temp32); + break; + + + case DB_DWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%08X ", Temp32); + break; + + + case DB_QWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%08X", Temp32); + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]); + AcpiOsPrintf ("%08X ", Temp32); + break; + } + + j += Display; + } + + /* + * Print the ASCII equivalent characters but watch out for the bad + * unprintable ones (printable chars are 0x20 through 0x7E) + */ + AcpiOsPrintf (" "); + for (j = 0; j < 16; j++) + { + if (i + j >= Count) + { + AcpiOsPrintf ("\n"); + return; + } + + BufChar = Buffer[(ACPI_SIZE) i + j]; + if (ACPI_IS_PRINT (BufChar)) + { + AcpiOsPrintf ("%c", BufChar); + } + else + { + AcpiOsPrintf ("."); + } + } + + /* Done with that line. */ + + AcpiOsPrintf ("\n"); + i += 16; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ******************************************************************************/ + +void +AcpiUtDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 ComponentId) +{ + + /* Only dump the buffer if tracing is enabled */ + + if (!((ACPI_LV_TABLES & AcpiDbgLevel) && + (ComponentId & AcpiDbgLayer))) + { + return; + } + + AcpiUtDumpBuffer2 (Buffer, Count, Display); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c b/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c new file mode 100644 index 00000000000..bf30aee74e0 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c @@ -0,0 +1,828 @@ +/******************************************************************************* + * + * Module Name: utdelete - object deletion and reference count utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTDELETE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utdelete") + +/* Local prototypes */ + +static void +AcpiUtDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object); + +static void +AcpiUtUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteInternalObj + * + * PARAMETERS: Object - Object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Low level object deletion, after reference counts have been + * updated (All reference counts, including sub-objects!) + * + ******************************************************************************/ + +static void +AcpiUtDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object) +{ + void *ObjPointer = NULL; + ACPI_OPERAND_OBJECT *HandlerDesc; + ACPI_OPERAND_OBJECT *SecondDesc; + ACPI_OPERAND_OBJECT *NextDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; + + + ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object); + + + if (!Object) + { + return_VOID; + } + + /* + * Must delete or free any pointers within the object that are not + * actual ACPI objects (for example, a raw buffer pointer). + */ + switch (Object->Common.Type) + { + case ACPI_TYPE_STRING: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", + Object, Object->String.Pointer)); + + /* Free the actual string buffer */ + + if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + /* But only if it is NOT a pointer into an ACPI table */ + + ObjPointer = Object->String.Pointer; + } + break; + + + case ACPI_TYPE_BUFFER: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", + Object, Object->Buffer.Pointer)); + + /* Free the actual buffer */ + + if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + /* But only if it is NOT a pointer into an ACPI table */ + + ObjPointer = Object->Buffer.Pointer; + } + break; + + + case ACPI_TYPE_PACKAGE: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", + Object->Package.Count)); + + /* + * Elements of the package are not handled here, they are deleted + * separately + */ + + /* Free the (variable length) element pointer array */ + + ObjPointer = Object->Package.Elements; + break; + + + /* + * These objects have a possible list of notify handlers. + * Device object also may have a GPE block. + */ + case ACPI_TYPE_DEVICE: + + if (Object->Device.GpeBlock) + { + (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock); + } + + /*lint -fallthrough */ + + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* Walk the notify handler list for this object */ + + HandlerDesc = Object->CommonNotify.Handler; + while (HandlerDesc) + { + NextDesc = HandlerDesc->AddressSpace.Next; + AcpiUtRemoveReference (HandlerDesc); + HandlerDesc = NextDesc; + } + break; + + + case ACPI_TYPE_MUTEX: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Mutex %p, OS Mutex %p\n", + Object, Object->Mutex.OsMutex)); + + if (Object == AcpiGbl_GlobalLockMutex) + { + /* Global Lock has extra semaphore */ + + (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore); + AcpiGbl_GlobalLockSemaphore = NULL; + + AcpiOsDeleteMutex (Object->Mutex.OsMutex); + AcpiGbl_GlobalLockMutex = NULL; + } + else + { + AcpiExUnlinkMutex (Object); + AcpiOsDeleteMutex (Object->Mutex.OsMutex); + } + break; + + + case ACPI_TYPE_EVENT: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Event %p, OS Semaphore %p\n", + Object, Object->Event.OsSemaphore)); + + (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore); + Object->Event.OsSemaphore = NULL; + break; + + + case ACPI_TYPE_METHOD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Method %p\n", Object)); + + /* Delete the method mutex if it exists */ + + if (Object->Method.Mutex) + { + AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex); + AcpiUtDeleteObjectDesc (Object->Method.Mutex); + Object->Method.Mutex = NULL; + } + break; + + + case ACPI_TYPE_REGION: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Region %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + /* + * Free the RegionContext if and only if the handler is one of the + * default handlers -- and therefore, we created the context object + * locally, it was not created by an external caller. + */ + HandlerDesc = Object->Region.Handler; + if (HandlerDesc) + { + NextDesc = HandlerDesc->AddressSpace.RegionList; + LastObjPtr = &HandlerDesc->AddressSpace.RegionList; + + /* Remove the region object from the handler's list */ + + while (NextDesc) + { + if (NextDesc == Object) + { + *LastObjPtr = NextDesc->Region.Next; + break; + } + + /* Walk the linked list of handler */ + + LastObjPtr = &NextDesc->Region.Next; + NextDesc = NextDesc->Region.Next; + } + + if (HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + { + /* Deactivate region and free region context */ + + if (HandlerDesc->AddressSpace.Setup) + { + (void) HandlerDesc->AddressSpace.Setup (Object, + ACPI_REGION_DEACTIVATE, + HandlerDesc->AddressSpace.Context, + &SecondDesc->Extra.RegionContext); + } + } + + AcpiUtRemoveReference (HandlerDesc); + } + + /* Now we can free the Extra object */ + + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Buffer Field %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Bank Field %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + default: + break; + } + + /* Free any allocated memory (pointer within the object) found above */ + + if (ObjPointer) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", + ObjPointer)); + ACPI_FREE (ObjPointer); + } + + /* Now the object can be safely deleted */ + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", + Object, AcpiUtGetObjectTypeName (Object))); + + AcpiUtDeleteObjectDesc (Object); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteInternalObjectList + * + * PARAMETERS: ObjList - Pointer to the list to be deleted + * + * RETURN: None + * + * DESCRIPTION: This function deletes an internal object list, including both + * simple objects and package objects + * + ******************************************************************************/ + +void +AcpiUtDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList) +{ + ACPI_OPERAND_OBJECT **InternalObj; + + + ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList); + + + /* Walk the null-terminated internal list */ + + for (InternalObj = ObjList; *InternalObj; InternalObj++) + { + AcpiUtRemoveReference (*InternalObj); + } + + /* Free the combined parameter pointer list and object array */ + + ACPI_FREE (ObjList); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtUpdateRefCount + * + * PARAMETERS: Object - Object whose ref count is to be updated + * Action - What to do + * + * RETURN: New ref count + * + * DESCRIPTION: Modify the ref count and return it. + * + ******************************************************************************/ + +static void +AcpiUtUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action) +{ + UINT16 Count; + UINT16 NewCount; + + + ACPI_FUNCTION_NAME (UtUpdateRefCount); + + + if (!Object) + { + return; + } + + Count = Object->Common.ReferenceCount; + NewCount = Count; + + /* + * Perform the reference count action (increment, decrement, force delete) + */ + switch (Action) + { + case REF_INCREMENT: + + NewCount++; + Object->Common.ReferenceCount = NewCount; + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Incremented]\n", + Object, NewCount)); + break; + + case REF_DECREMENT: + + if (Count < 1) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, can't decrement! (Set to 0)\n", + Object, NewCount)); + + NewCount = 0; + } + else + { + NewCount--; + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Decremented]\n", + Object, NewCount)); + } + + if (Object->Common.Type == ACPI_TYPE_METHOD) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); + } + + Object->Common.ReferenceCount = NewCount; + if (NewCount == 0) + { + AcpiUtDeleteInternalObj (Object); + } + break; + + case REF_FORCE_DELETE: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); + + NewCount = 0; + Object->Common.ReferenceCount = NewCount; + AcpiUtDeleteInternalObj (Object); + break; + + default: + + ACPI_ERROR ((AE_INFO, "Unknown action (%X)", Action)); + break; + } + + /* + * Sanity check the reference count, for debug purposes only. + * (A deleted object will have a huge reference count) + */ + if (Count > ACPI_MAX_REFERENCE_COUNT) + { + ACPI_WARNING ((AE_INFO, + "Large Reference Count (%X) in object %p", Count, Object)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtUpdateObjectReference + * + * PARAMETERS: Object - Increment ref count for this object + * and all sub-objects + * Action - Either REF_INCREMENT or REF_DECREMENT or + * REF_FORCE_DELETE + * + * RETURN: Status + * + * DESCRIPTION: Increment the object reference count + * + * Object references are incremented when: + * 1) An object is attached to a Node (namespace object) + * 2) An object is copied (all subobjects must be incremented) + * + * Object references are decremented when: + * 1) An object is detached from an Node + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_OPERAND_OBJECT *NextObject = NULL; + ACPI_GENERIC_STATE *State; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object); + + + while (Object) + { + /* Make sure that this isn't a namespace handle */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", Object)); + return_ACPI_STATUS (AE_OK); + } + + /* + * All sub-objects must have their reference count incremented also. + * Different object types have different subobjects. + */ + switch (Object->Common.Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + case ACPI_TYPE_THERMAL: + + /* Update the notify objects for these types (if present) */ + + AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action); + AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action); + break; + + case ACPI_TYPE_PACKAGE: + /* + * We must update all the sub-objects of the package, + * each of whom may have their own sub-objects. + */ + for (i = 0; i < Object->Package.Count; i++) + { + /* + * Push each element onto the stack for later processing. + * Note: There can be null elements within the package, + * these are simply ignored + */ + Status = AcpiUtCreateUpdateStateAndPush ( + Object->Package.Elements[i], Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + } + break; + + case ACPI_TYPE_BUFFER_FIELD: + + NextObject = Object->BufferField.BufferObj; + break; + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + NextObject = Object->Field.RegionObj; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + NextObject = Object->BankField.BankObj; + Status = AcpiUtCreateUpdateStateAndPush ( + Object->BankField.RegionObj, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + break; + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + NextObject = Object->IndexField.IndexObj; + Status = AcpiUtCreateUpdateStateAndPush ( + Object->IndexField.DataObj, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * The target of an Index (a package, string, or buffer) or a named + * reference must track changes to the ref count of the index or + * target object. + */ + if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) || + (Object->Reference.Class== ACPI_REFCLASS_NAME)) + { + NextObject = Object->Reference.Object; + } + break; + + case ACPI_TYPE_REGION: + default: + break; /* No subobjects for all other types */ + } + + /* + * Now we can update the count in the main object. This can only + * happen after we update the sub-objects in case this causes the + * main object to be deleted. + */ + AcpiUtUpdateRefCount (Object, Action); + Object = NULL; + + /* Move on to the next object to be updated */ + + if (NextObject) + { + Object = NextObject; + NextObject = NULL; + } + else if (StateList) + { + State = AcpiUtPopGenericState (&StateList); + Object = State->Update.Object; + AcpiUtDeleteGenericState (State); + } + } + + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not update object reference count")); + + /* Free any stacked Update State objects */ + + while (StateList) + { + State = AcpiUtPopGenericState (&StateList); + AcpiUtDeleteGenericState (State); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAddReference + * + * PARAMETERS: Object - Object whose reference count is to be + * incremented + * + * RETURN: None + * + * DESCRIPTION: Add one reference to an ACPI object + * + ******************************************************************************/ + +void +AcpiUtAddReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object); + + + /* Ensure that we have a valid object */ + + if (!AcpiUtValidInternalObject (Object)) + { + return_VOID; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Incremented]\n", + Object, Object->Common.ReferenceCount)); + + /* Increment the reference count */ + + (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveReference + * + * PARAMETERS: Object - Object whose ref count will be decremented + * + * RETURN: None + * + * DESCRIPTION: Decrement the reference count of an ACPI internal object + * + ******************************************************************************/ + +void +AcpiUtRemoveReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object); + + + /* + * Allow a NULL pointer to be passed in, just ignore it. This saves + * each caller from having to check. Also, ignore NS nodes. + * + */ + if (!Object || + (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)) + + { + return_VOID; + } + + /* Ensure that we have a valid object */ + + if (!AcpiUtValidInternalObject (Object)) + { + return_VOID; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Decremented]\n", + Object, Object->Common.ReferenceCount)); + + /* + * Decrement the reference count, and only actually delete the object + * if the reference count becomes 0. (Must also decrement the ref count + * of all subobjects!) + */ + (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/uteval.c b/reactos/drivers/bus/acpi/acpica/utilities/uteval.c new file mode 100644 index 00000000000..ecb0cf19a70 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/uteval.c @@ -0,0 +1,575 @@ +/****************************************************************************** + * + * Module Name: uteval - Object evaluation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("uteval") + + +/* + * Strings supported by the _OSI predefined (internal) method. + * + * March 2009: Removed "Linux" as this host no longer wants to respond true + * for this string. Basically, the only safe OS strings are windows-related + * and in many or most cases represent the only test path within the + * BIOS-provided ASL code. + * + * The second element of each entry is used to track the newest version of + * Windows that the BIOS has requested. + */ +static const ACPI_INTERFACE_INFO AcpiInterfacesSupported[] = +{ + /* Operating System Vendor Strings */ + + {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */ + {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */ + {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ + {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ + {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ + {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ + {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ + {"Windows 2006.1", ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ + {"Windows 2006 SP1", ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ + {"Windows 2009", ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ + + /* Feature Group Strings */ + + {"Extended Address Space Descriptor", 0} + + /* + * All "optional" feature group strings (features that are implemented + * by the host) should be implemented in the host version of + * AcpiOsValidateInterface and should not be added here. + */ +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtOsiImplementation + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Implementation of the _OSI predefined control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *StringDesc; + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT32 ReturnValue; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtOsiImplementation); + + + /* Validate the string input argument */ + + StringDesc = WalkState->Arguments[0].Object; + if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING)) + { + return_ACPI_STATUS (AE_TYPE); + } + + /* Create a return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Default return value is 0, NOT SUPPORTED */ + + ReturnValue = 0; + + /* Compare input string to static table of supported interfaces */ + + for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiInterfacesSupported); i++) + { + if (!ACPI_STRCMP (StringDesc->String.Pointer, + AcpiInterfacesSupported[i].Name)) + { + /* + * The interface is supported. + * Update the OsiData if necessary. We keep track of the latest + * version of Windows that has been requested by the BIOS. + */ + if (AcpiInterfacesSupported[i].Value > AcpiGbl_OsiData) + { + AcpiGbl_OsiData = AcpiInterfacesSupported[i].Value; + } + + ReturnValue = ACPI_UINT32_MAX; + goto Exit; + } + } + + /* + * Did not match the string in the static table, call the host OSL to + * check for a match with one of the optional strings (such as + * "Module Device", "3.0 Thermal Model", etc.) + */ + Status = AcpiOsValidateInterface (StringDesc->String.Pointer); + if (ACPI_SUCCESS (Status)) + { + /* The interface is supported */ + + ReturnValue = ACPI_UINT32_MAX; + } + + +Exit: + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, + "ACPI: BIOS _OSI(%s) is %ssupported\n", + StringDesc->String.Pointer, ReturnValue == 0 ? "not " : "")); + + /* Complete the return value */ + + ReturnDesc->Integer.Value = ReturnValue; + WalkState->ReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtEvaluateObject + * + * PARAMETERS: PrefixNode - Starting node + * Path - Path to object from starting node + * ExpectedReturnTypes - Bitmap of allowed return types + * ReturnDesc - Where a return value is stored + * + * RETURN: Status + * + * DESCRIPTION: Evaluates a namespace object and verifies the type of the + * return object. Common code that simplifies accessing objects + * that have required return objects of fixed types. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtEvaluateObject ( + ACPI_NAMESPACE_NODE *PrefixNode, + char *Path, + UINT32 ExpectedReturnBtypes, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_STATUS Status; + UINT32 ReturnBtype; + + + ACPI_FUNCTION_TRACE (UtEvaluateObject); + + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = PrefixNode; + Info->Pathname = Path; + + /* Evaluate the object/method */ + + Status = AcpiNsEvaluate (Info); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n", + AcpiUtGetNodeName (PrefixNode), Path)); + } + else + { + ACPI_ERROR_METHOD ("Method execution failed", + PrefixNode, Path, Status); + } + + goto Cleanup; + } + + /* Did we get a return object? */ + + if (!Info->ReturnObject) + { + if (ExpectedReturnBtypes) + { + ACPI_ERROR_METHOD ("No object was returned from", + PrefixNode, Path, AE_NOT_EXIST); + + Status = AE_NOT_EXIST; + } + + goto Cleanup; + } + + /* Map the return object type to the bitmapped type */ + + switch ((Info->ReturnObject)->Common.Type) + { + case ACPI_TYPE_INTEGER: + ReturnBtype = ACPI_BTYPE_INTEGER; + break; + + case ACPI_TYPE_BUFFER: + ReturnBtype = ACPI_BTYPE_BUFFER; + break; + + case ACPI_TYPE_STRING: + ReturnBtype = ACPI_BTYPE_STRING; + break; + + case ACPI_TYPE_PACKAGE: + ReturnBtype = ACPI_BTYPE_PACKAGE; + break; + + default: + ReturnBtype = 0; + break; + } + + if ((AcpiGbl_EnableInterpreterSlack) && + (!ExpectedReturnBtypes)) + { + /* + * We received a return object, but one was not expected. This can + * happen frequently if the "implicit return" feature is enabled. + * Just delete the return object and return AE_OK. + */ + AcpiUtRemoveReference (Info->ReturnObject); + goto Cleanup; + } + + /* Is the return object one of the expected types? */ + + if (!(ExpectedReturnBtypes & ReturnBtype)) + { + ACPI_ERROR_METHOD ("Return object type is incorrect", + PrefixNode, Path, AE_TYPE); + + ACPI_ERROR ((AE_INFO, + "Type returned from %s was incorrect: %s, expected Btypes: %X", + Path, AcpiUtGetObjectTypeName (Info->ReturnObject), + ExpectedReturnBtypes)); + + /* On error exit, we must delete the return object */ + + AcpiUtRemoveReference (Info->ReturnObject); + Status = AE_TYPE; + goto Cleanup; + } + + /* Object type is OK, return it */ + + *ReturnDesc = Info->ReturnObject; + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtEvaluateNumericObject + * + * PARAMETERS: ObjectName - Object name to be evaluated + * DeviceNode - Node for the device + * Value - Where the value is returned + * + * RETURN: Status + * + * DESCRIPTION: Evaluates a numeric namespace object for a selected device + * and stores result in *Value. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( + char *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Value) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtEvaluateNumericObject); + + + Status = AcpiUtEvaluateObject (DeviceNode, ObjectName, + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the returned Integer */ + + *Value = ObjDesc->Integer.Value; + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_STA + * + * PARAMETERS: DeviceNode - Node for the device + * Flags - Where the status flags are returned + * + * RETURN: Status + * + * DESCRIPTION: Executes _STA for selected device and stores results in + * *Flags. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *Flags) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_STA); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA, + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (AE_NOT_FOUND == Status) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "_STA on %4.4s was not found, assuming device is present\n", + AcpiUtGetNodeName (DeviceNode))); + + *Flags = ACPI_UINT32_MAX; + Status = AE_OK; + } + + return_ACPI_STATUS (Status); + } + + /* Extract the status flags */ + + *Flags = (UINT32) ObjDesc->Integer.Value; + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecutePowerMethods + * + * PARAMETERS: DeviceNode - Node for the device + * MethodNames - Array of power method names + * MethodCount - Number of methods to execute + * OutValues - Where the power method values are returned + * + * RETURN: Status, OutValues + * + * DESCRIPTION: Executes the specified power methods for the device and returns + * the result(s). + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecutePowerMethods ( + ACPI_NAMESPACE_NODE *DeviceNode, + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_STATUS FinalStatus = AE_NOT_FOUND; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtExecutePowerMethods); + + + for (i = 0; i < MethodCount; i++) + { + /* + * Execute the power method (_SxD or _SxW). The only allowable + * return type is an Integer. + */ + Status = AcpiUtEvaluateObject (DeviceNode, + ACPI_CAST_PTR (char, MethodNames[i]), + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_SUCCESS (Status)) + { + OutValues[i] = (UINT8) ObjDesc->Integer.Value; + + /* Delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + FinalStatus = AE_OK; /* At least one value is valid */ + continue; + } + + OutValues[i] = ACPI_UINT8_MAX; + if (Status == AE_NOT_FOUND) + { + continue; /* Ignore if not found */ + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n", + ACPI_CAST_PTR (char, MethodNames[i]), + AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status))); + } + + return_ACPI_STATUS (FinalStatus); +} diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utglobal.c b/reactos/drivers/bus/acpi/acpica/utilities/utglobal.c new file mode 100644 index 00000000000..b49ce352fbc --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utglobal.c @@ -0,0 +1,975 @@ +/****************************************************************************** + * + * Module Name: utglobal - Global variables for the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTGLOBAL_C__ +#define DEFINE_ACPI_GLOBALS + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utglobal") + + +/******************************************************************************* + * + * Static global variable initialization. + * + ******************************************************************************/ + +/* + * We want the debug switches statically initialized so they + * are already set when the debugger is entered. + */ + +/* Debug switch - level and trace mask */ + +#ifdef ACPI_DEBUG_OUTPUT +UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT; +#else +UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; +#endif + +/* Debug switch - layer (component) mask */ + +UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; +UINT32 AcpiGbl_NestingLevel = 0; + +/* Debugger globals */ + +BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; +BOOLEAN AcpiGbl_AbortMethod = FALSE; +BOOLEAN AcpiGbl_MethodExecuting = FALSE; + +/* System flags */ + +UINT32 AcpiGbl_StartupFlags = 0; + +/* System starts uninitialized */ + +BOOLEAN AcpiGbl_Shutdown = TRUE; + +const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = +{ + "\\_S0_", + "\\_S1_", + "\\_S2_", + "\\_S3_", + "\\_S4_", + "\\_S5_" +}; + +const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] = +{ + "_S0W", + "_S1W", + "_S2W", + "_S3W", + "_S4W" +}; + +const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = +{ + "_S1D", + "_S2D", + "_S3D", + "_S4D" +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiFormatException + * + * PARAMETERS: Status - The ACPI_STATUS code to be formatted + * + * RETURN: A string containing the exception text. A valid pointer is + * always returned. + * + * DESCRIPTION: This function translates an ACPI exception into an ASCII string + * It is here instead of utxface.c so it is always present. + * + ******************************************************************************/ + +const char * +AcpiFormatException ( + ACPI_STATUS Status) +{ + const char *Exception = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + Exception = AcpiUtValidateException (Status); + if (!Exception) + { + /* Exception code was not recognized */ + + ACPI_ERROR ((AE_INFO, + "Unknown exception code: 0x%8.8X", Status)); + + Exception = "UNKNOWN_STATUS_CODE"; + } + + return (ACPI_CAST_PTR (const char, Exception)); +} + +ACPI_EXPORT_SYMBOL (AcpiFormatException) + + +/******************************************************************************* + * + * Namespace globals + * + ******************************************************************************/ + +/* + * Predefined ACPI Names (Built-in to the Interpreter) + * + * NOTES: + * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run + * during the initialization sequence. + * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to + * perform a Notify() operation on it. + */ +const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = +{ + {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_SB_", ACPI_TYPE_DEVICE, NULL}, + {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_TZ_", ACPI_TYPE_THERMAL, NULL}, + {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, + {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, + {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, + +#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) + {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, +#endif + + /* Table terminator */ + + {NULL, ACPI_TYPE_ANY, NULL} +}; + +/* + * Properties of the ACPI Object Types, both internal and external. + * The table is indexed by values of ACPI_OBJECT_TYPE + */ +const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = +{ + ACPI_NS_NORMAL, /* 00 Any */ + ACPI_NS_NORMAL, /* 01 Number */ + ACPI_NS_NORMAL, /* 02 String */ + ACPI_NS_NORMAL, /* 03 Buffer */ + ACPI_NS_NORMAL, /* 04 Package */ + ACPI_NS_NORMAL, /* 05 FieldUnit */ + ACPI_NS_NEWSCOPE, /* 06 Device */ + ACPI_NS_NORMAL, /* 07 Event */ + ACPI_NS_NEWSCOPE, /* 08 Method */ + ACPI_NS_NORMAL, /* 09 Mutex */ + ACPI_NS_NORMAL, /* 10 Region */ + ACPI_NS_NEWSCOPE, /* 11 Power */ + ACPI_NS_NEWSCOPE, /* 12 Processor */ + ACPI_NS_NEWSCOPE, /* 13 Thermal */ + ACPI_NS_NORMAL, /* 14 BufferField */ + ACPI_NS_NORMAL, /* 15 DdbHandle */ + ACPI_NS_NORMAL, /* 16 Debug Object */ + ACPI_NS_NORMAL, /* 17 DefField */ + ACPI_NS_NORMAL, /* 18 BankField */ + ACPI_NS_NORMAL, /* 19 IndexField */ + ACPI_NS_NORMAL, /* 20 Reference */ + ACPI_NS_NORMAL, /* 21 Alias */ + ACPI_NS_NORMAL, /* 22 MethodAlias */ + ACPI_NS_NORMAL, /* 23 Notify */ + ACPI_NS_NORMAL, /* 24 Address Handler */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ + ACPI_NS_NEWSCOPE, /* 27 Scope */ + ACPI_NS_NORMAL, /* 28 Extra */ + ACPI_NS_NORMAL, /* 29 Data */ + ACPI_NS_NORMAL /* 30 Invalid */ +}; + + +/* Hex to ASCII conversion table */ + +static const char AcpiGbl_HexToAscii[] = +{ + '0','1','2','3','4','5','6','7', + '8','9','A','B','C','D','E','F' +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtHexToAsciiChar + * + * PARAMETERS: Integer - Contains the hex digit + * Position - bit position of the digit within the + * integer (multiple of 4) + * + * RETURN: The converted Ascii character + * + * DESCRIPTION: Convert a hex digit to an Ascii character + * + ******************************************************************************/ + +char +AcpiUtHexToAsciiChar ( + ACPI_INTEGER Integer, + UINT32 Position) +{ + + return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); +} + + +/****************************************************************************** + * + * Event and Hardware globals + * + ******************************************************************************/ + +ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = +{ + /* Name Parent Register Register Bit Position Register Bit Mask */ + + /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, + /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, + /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, + /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, + /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, + /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, + /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, + /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, + + /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, + /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, + /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, + /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, + /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, + /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, + + /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, + /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, + /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, + /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE}, + /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, + + /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} +}; + + +ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = +{ + /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, + /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, + /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, + /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, + /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, +}; + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetRegionName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a Space ID into a name string (Debug only) + * + ******************************************************************************/ + +/* Region type decoding */ + +const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = +{ + "SystemMemory", + "SystemIO", + "PCI_Config", + "EmbeddedControl", + "SMBus", + "SystemCMOS", + "PCIBARTarget", + "IPMI", + "DataTable" +}; + + +char * +AcpiUtGetRegionName ( + UINT8 SpaceId) +{ + + if (SpaceId >= ACPI_USER_REGION_BEGIN) + { + return ("UserDefinedRegion"); + } + else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) + { + return ("InvalidSpaceId"); + } + + return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId])); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetEventName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a Event ID into a name string (Debug only) + * + ******************************************************************************/ + +/* Event type decoding */ + +static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = +{ + "PM_Timer", + "GlobalLock", + "PowerButton", + "SleepButton", + "RealTimeClock", +}; + + +char * +AcpiUtGetEventName ( + UINT32 EventId) +{ + + if (EventId > ACPI_EVENT_MAX) + { + return ("InvalidEventID"); + } + + return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId])); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetTypeName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a Type ID into a name string (Debug only) + * + ******************************************************************************/ + +/* + * Elements of AcpiGbl_NsTypeNames below must match + * one-to-one with values of ACPI_OBJECT_TYPE + * + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; + * when stored in a table it really means that we have thus far seen no + * evidence to indicate what type is actually going to be stored for this entry. + */ +static const char AcpiGbl_BadType[] = "UNDEFINED"; + +/* Printable names of the ACPI object types */ + +static const char *AcpiGbl_NsTypeNames[] = +{ + /* 00 */ "Untyped", + /* 01 */ "Integer", + /* 02 */ "String", + /* 03 */ "Buffer", + /* 04 */ "Package", + /* 05 */ "FieldUnit", + /* 06 */ "Device", + /* 07 */ "Event", + /* 08 */ "Method", + /* 09 */ "Mutex", + /* 10 */ "Region", + /* 11 */ "Power", + /* 12 */ "Processor", + /* 13 */ "Thermal", + /* 14 */ "BufferField", + /* 15 */ "DdbHandle", + /* 16 */ "DebugObject", + /* 17 */ "RegionField", + /* 18 */ "BankField", + /* 19 */ "IndexField", + /* 20 */ "Reference", + /* 21 */ "Alias", + /* 22 */ "MethodAlias", + /* 23 */ "Notify", + /* 24 */ "AddrHandler", + /* 25 */ "ResourceDesc", + /* 26 */ "ResourceFld", + /* 27 */ "Scope", + /* 28 */ "Extra", + /* 29 */ "Data", + /* 30 */ "Invalid" +}; + + +char * +AcpiUtGetTypeName ( + ACPI_OBJECT_TYPE Type) +{ + + if (Type > ACPI_TYPE_INVALID) + { + return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); + } + + return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type])); +} + + +char * +AcpiUtGetObjectTypeName ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + if (!ObjDesc) + { + return ("[NULL Object Descriptor]"); + } + + return (AcpiUtGetTypeName (ObjDesc->Common.Type)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetNodeName + * + * PARAMETERS: Object - A namespace node + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Validate the node and return the node's ACPI name. + * + ******************************************************************************/ + +char * +AcpiUtGetNodeName ( + void *Object) +{ + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object; + + + /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ + + if (!Object) + { + return ("NULL"); + } + + /* Check for Root node */ + + if ((Object == ACPI_ROOT_OBJECT) || + (Object == AcpiGbl_RootNode)) + { + return ("\"\\\" "); + } + + /* Descriptor must be a namespace node */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + return ("####"); + } + + /* + * Ensure name is valid. The name was validated/repaired when the node + * was created, but make sure it has not been corrupted. + */ + AcpiUtRepairName (Node->Name.Ascii); + + /* Return the name */ + + return (Node->Name.Ascii); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetDescriptorName + * + * PARAMETERS: Object - An ACPI object + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Validate object and return the descriptor type + * + ******************************************************************************/ + +/* Printable names of object descriptor types */ + +static const char *AcpiGbl_DescTypeNames[] = +{ + /* 00 */ "Invalid", + /* 01 */ "Cached", + /* 02 */ "State-Generic", + /* 03 */ "State-Update", + /* 04 */ "State-Package", + /* 05 */ "State-Control", + /* 06 */ "State-RootParseScope", + /* 07 */ "State-ParseScope", + /* 08 */ "State-WalkScope", + /* 09 */ "State-Result", + /* 10 */ "State-Notify", + /* 11 */ "State-Thread", + /* 12 */ "Walk", + /* 13 */ "Parser", + /* 14 */ "Operand", + /* 15 */ "Node" +}; + + +char * +AcpiUtGetDescriptorName ( + void *Object) +{ + + if (!Object) + { + return ("NULL OBJECT"); + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) + { + return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); + } + + return (ACPI_CAST_PTR (char, + AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)])); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetReferenceName + * + * PARAMETERS: Object - An ACPI reference object + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Decode a reference object sub-type to a string. + * + ******************************************************************************/ + +/* Printable names of reference object sub-types */ + +static const char *AcpiGbl_RefClassNames[] = +{ + /* 00 */ "Local", + /* 01 */ "Argument", + /* 02 */ "RefOf", + /* 03 */ "Index", + /* 04 */ "DdbHandle", + /* 05 */ "Named Object", + /* 06 */ "Debug" +}; + +const char * +AcpiUtGetReferenceName ( + ACPI_OPERAND_OBJECT *Object) +{ + + if (!Object) + { + return ("NULL Object"); + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) + { + return ("Not an Operand object"); + } + + if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return ("Not a Reference object"); + } + + if (Object->Reference.Class > ACPI_REFCLASS_MAX) + { + return ("Unknown Reference class"); + } + + return (AcpiGbl_RefClassNames[Object->Reference.Class]); +} + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/* + * Strings and procedures used for debug only + */ + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetMutexName + * + * PARAMETERS: MutexId - The predefined ID for this mutex. + * + * RETURN: String containing the name of the mutex. Always returns a valid + * pointer. + * + * DESCRIPTION: Translate a mutex ID into a name string (Debug only) + * + ******************************************************************************/ + +char * +AcpiUtGetMutexName ( + UINT32 MutexId) +{ + + if (MutexId > ACPI_MAX_MUTEX) + { + return ("Invalid Mutex ID"); + } + + return (AcpiGbl_MutexNames[MutexId]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetNotifyName + * + * PARAMETERS: NotifyValue - Value from the Notify() request + * + * RETURN: String corresponding to the Notify Value. + * + * DESCRIPTION: Translate a Notify Value to a notify namestring. + * + ******************************************************************************/ + +/* Names for Notify() values, used for debug output */ + +static const char *AcpiGbl_NotifyValueNames[] = +{ + "Bus Check", + "Device Check", + "Device Wake", + "Eject Request", + "Device Check Light", + "Frequency Mismatch", + "Bus Mode Mismatch", + "Power Fault", + "Capabilities Check", + "Device PLD Check", + "Reserved", + "System Locality Update" +}; + +const char * +AcpiUtGetNotifyName ( + UINT32 NotifyValue) +{ + + if (NotifyValue <= ACPI_NOTIFY_MAX) + { + return (AcpiGbl_NotifyValueNames[NotifyValue]); + } + else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) + { + return ("Reserved"); + } + else /* Greater or equal to 0x80 */ + { + return ("**Device Specific**"); + } +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidObjectType + * + * PARAMETERS: Type - Object type to be validated + * + * RETURN: TRUE if valid object type, FALSE otherwise + * + * DESCRIPTION: Validate an object type + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidObjectType ( + ACPI_OBJECT_TYPE Type) +{ + + if (Type > ACPI_TYPE_LOCAL_MAX) + { + /* Note: Assumes all TYPEs are contiguous (external/local) */ + + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitGlobals + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Init library globals. All globals that require specific + * initialization should be initialized here! + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInitGlobals ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtInitGlobals); + + + /* Create all memory caches */ + + Status = AcpiUtCreateCaches (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mutex locked flags */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + AcpiGbl_MutexInfo[i].Mutex = NULL; + AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[i].UseCount = 0; + } + + for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) + { + AcpiGbl_OwnerIdMask[i] = 0; + } + + /* Last OwnerID is never valid */ + + AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; + + /* Event counters */ + + AcpiMethodCount = 0; + AcpiSciCount = 0; + AcpiGpeCount = 0; + + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + AcpiFixedEventCount[i] = 0; + } + + /* GPE support */ + + AcpiGbl_GpeXruptListHead = NULL; + AcpiGbl_GpeFadtBlocks[0] = NULL; + AcpiGbl_GpeFadtBlocks[1] = NULL; + AcpiCurrentGpeCount = 0; + + /* Global handlers */ + + AcpiGbl_SystemNotify.Handler = NULL; + AcpiGbl_DeviceNotify.Handler = NULL; + AcpiGbl_ExceptionHandler = NULL; + AcpiGbl_InitHandler = NULL; + AcpiGbl_TableHandler = NULL; + + /* Global Lock support */ + + AcpiGbl_GlobalLockSemaphore = NULL; + AcpiGbl_GlobalLockMutex = NULL; + AcpiGbl_GlobalLockAcquired = FALSE; + AcpiGbl_GlobalLockHandle = 0; + AcpiGbl_GlobalLockPresent = FALSE; + + /* Miscellaneous variables */ + + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_DbTerminateThreads = FALSE; + AcpiGbl_Shutdown = FALSE; + AcpiGbl_NsLookupCount = 0; + AcpiGbl_PsFindCount = 0; + AcpiGbl_AcpiHardwarePresent = TRUE; + AcpiGbl_LastOwnerIdIndex = 0; + AcpiGbl_NextOwnerIdOffset = 0; + AcpiGbl_TraceMethodName = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; + AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; + AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; + AcpiGbl_OsiData = 0; + + /* Hardware oriented */ + + AcpiGbl_EventsInitialized = FALSE; + AcpiGbl_SystemAwakeAndRunning = TRUE; + + /* Namespace */ + + AcpiGbl_ModuleCodeList = NULL; + AcpiGbl_RootNode = NULL; + AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; + AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; + AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; + AcpiGbl_RootNodeStruct.Child = NULL; + AcpiGbl_RootNodeStruct.Peer = NULL; + AcpiGbl_RootNodeStruct.Object = NULL; + AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; + + +#ifdef ACPI_DISASSEMBLER + AcpiGbl_ExternalList = NULL; +#endif + +#ifdef ACPI_DEBUG_OUTPUT + AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); +#endif + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + AcpiGbl_DisplayFinalMemStats = FALSE; +#endif + + return_ACPI_STATUS (AE_OK); +} + +/* Public globals */ + +ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) +ACPI_EXPORT_SYMBOL (AcpiDbgLevel) +ACPI_EXPORT_SYMBOL (AcpiDbgLayer) +ACPI_EXPORT_SYMBOL (AcpiGpeCount) +ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount) + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utids.c b/reactos/drivers/bus/acpi/acpica/utilities/utids.c new file mode 100644 index 00000000000..76693305008 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utids.c @@ -0,0 +1,497 @@ +/****************************************************************************** + * + * Module Name: utids - support for device IDs - HID, UID, CID + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTIDS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utids") + +/* Local prototypes */ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIdString + * + * PARAMETERS: Destination - Where to copy the string + * Source - Source string + * + * RETURN: None + * + * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. + * Performs removal of a leading asterisk if present -- workaround + * for a known issue on a bunch of machines. + * + ******************************************************************************/ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source) +{ + + /* + * Workaround for ID strings that have a leading asterisk. This construct + * is not allowed by the ACPI specification (ID strings must be + * alphanumeric), but enough existing machines have this embedded in their + * ID strings that the following code is useful. + */ + if (*Source == '*') + { + Source++; + } + + /* Do the actual copy */ + + ACPI_STRCPY (Destination, Source); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_HID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the string HID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _HID control method that returns the hardware + * ID of the device. The HID is either an 32-bit encoded EISAID + * Integer or a String. A string is always returned. An EISAID + * is converted to a string. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID *Hid; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_HID); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + Length = ACPI_EISAID_STRING_SIZE; + } + else + { + Length = ObjDesc->String.Length + 1; + } + + /* Allocate a buffer for the HID */ + + Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Hid) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after DEVICE_ID struct */ + + Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_DEVICE_ID)); + + /* Convert EISAID to a string or simply copy existing string */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value); + } + else + { + AcpiUtCopyIdString (Hid->String, ObjDesc->String.Pointer); + } + + Hid->Length = Length; + *ReturnId = Hid; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_UID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the string UID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _UID control method that returns the unique + * ID of the device. The UID is either a 64-bit Integer (NOT an + * EISAID) or a string. Always returns a string. A 64-bit integer + * is converted to a decimal string. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID *Uid; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_UID); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + Length = ACPI_MAX64_DECIMAL_DIGITS + 1; + } + else + { + Length = ObjDesc->String.Length + 1; + } + + /* Allocate a buffer for the UID */ + + Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Uid) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after DEVICE_ID struct */ + + Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_DEVICE_ID)); + + /* Convert an Integer to string, or just copy an existing string */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value); + } + else + { + AcpiUtCopyIdString (Uid->String, ObjDesc->String.Pointer); + } + + Uid->Length = Length; + *ReturnId = Uid; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_CID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnCidList - Where the CID list is returned + * + * RETURN: Status, list of CID strings + * + * DESCRIPTION: Executes the _CID control method that returns one or more + * compatible hardware IDs for the device. + * + * NOTE: Internal function, no parameter validation + * + * A _CID method can return either a single compatible ID or a package of + * compatible IDs. Each compatible ID can be one of the following: + * 1) Integer (32 bit compressed EISA ID) or + * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") + * + * The Integer CIDs are converted to string format by this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID_LIST **ReturnCidList) +{ + ACPI_OPERAND_OBJECT **CidObjects; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID_LIST *CidList; + char *NextIdString; + UINT32 StringAreaSize; + UINT32 Length; + UINT32 CidListSize; + ACPI_STATUS Status; + UINT32 Count; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtExecute_CID); + + + /* Evaluate the _CID method for this device */ + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Get the count and size of the returned _CIDs. _CID can return either + * a Package of Integers/Strings or a single Integer or String. + * Note: This section also validates that all CID elements are of the + * correct type (Integer or String). + */ + if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + Count = ObjDesc->Package.Count; + CidObjects = ObjDesc->Package.Elements; + } + else /* Single Integer or String CID */ + { + Count = 1; + CidObjects = &ObjDesc; + } + + StringAreaSize = 0; + for (i = 0; i < Count; i++) + { + /* String lengths include null terminator */ + + switch (CidObjects[i]->Common.Type) + { + case ACPI_TYPE_INTEGER: + StringAreaSize += ACPI_EISAID_STRING_SIZE; + break; + + case ACPI_TYPE_STRING: + StringAreaSize += CidObjects[i]->String.Length + 1; + break; + + default: + Status = AE_TYPE; + goto Cleanup; + } + } + + /* + * Now that we know the length of the CIDs, allocate return buffer: + * 1) Size of the base structure + + * 2) Size of the CID DEVICE_ID array + + * 3) Size of the actual CID strings + */ + CidListSize = sizeof (ACPI_DEVICE_ID_LIST) + + ((Count - 1) * sizeof (ACPI_DEVICE_ID)) + + StringAreaSize; + + CidList = ACPI_ALLOCATE_ZEROED (CidListSize); + if (!CidList) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for CID strings starts after the CID DEVICE_ID array */ + + NextIdString = ACPI_CAST_PTR (char, CidList->Ids) + + ((ACPI_SIZE) Count * sizeof (ACPI_DEVICE_ID)); + + /* Copy/convert the CIDs to the return buffer */ + + for (i = 0; i < Count; i++) + { + if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER) + { + /* Convert the Integer (EISAID) CID to a string */ + + AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value); + Length = ACPI_EISAID_STRING_SIZE; + } + else /* ACPI_TYPE_STRING */ + { + /* Copy the String CID from the returned object */ + + AcpiUtCopyIdString (NextIdString, CidObjects[i]->String.Pointer); + Length = CidObjects[i]->String.Length + 1; + } + + CidList->Ids[i].String = NextIdString; + CidList->Ids[i].Length = Length; + NextIdString += Length; + } + + /* Finish the CID list */ + + CidList->Count = Count; + CidList->ListSize = CidListSize; + *ReturnCidList = CidList; + + +Cleanup: + + /* On exit, we must delete the _CID return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utinit.c b/reactos/drivers/bus/acpi/acpica/utilities/utinit.c new file mode 100644 index 00000000000..d59904b46a2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utinit.c @@ -0,0 +1,228 @@ +/****************************************************************************** + * + * Module Name: utinit - Common ACPI subsystem initialization + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utinit") + +/* Local prototypes */ + +static void AcpiUtTerminate ( + void); + + +/****************************************************************************** + * + * FUNCTION: AcpiUtTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Free global memory + * + ******************************************************************************/ + +static void +AcpiUtTerminate ( + void) +{ + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_BLOCK_INFO *NextGpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo; + + + ACPI_FUNCTION_TRACE (UtTerminate); + + + /* Free global GPE blocks and related info structures */ + + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) + { + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) + { + NextGpeBlock = GpeBlock->Next; + ACPI_FREE (GpeBlock->EventInfo); + ACPI_FREE (GpeBlock->RegisterInfo); + ACPI_FREE (GpeBlock); + + GpeBlock = NextGpeBlock; + } + NextGpeXruptInfo = GpeXruptInfo->Next; + ACPI_FREE (GpeXruptInfo); + GpeXruptInfo = NextGpeXruptInfo; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtSubsystemShutdown + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Shutdown the various components. Do not delete the mutex + * objects here, because the AML debugger may be still running. + * + ******************************************************************************/ + +void +AcpiUtSubsystemShutdown ( + void) +{ + ACPI_FUNCTION_TRACE (UtSubsystemShutdown); + + +#ifndef ACPI_ASL_COMPILER + + /* Close the AcpiEvent Handling */ + + AcpiEvTerminate (); +#endif + + /* Close the Namespace */ + + AcpiNsTerminate (); + + /* Delete the ACPI tables */ + + AcpiTbTerminate (); + + /* Close the globals */ + + AcpiUtTerminate (); + + /* Purge the local caches */ + + (void) AcpiUtDeleteCaches (); + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utlock.c b/reactos/drivers/bus/acpi/acpica/utilities/utlock.c new file mode 100644 index 00000000000..dd4e100001a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utlock.c @@ -0,0 +1,277 @@ +/****************************************************************************** + * + * Module Name: utlock - Reader/Writer lock interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTLOCK_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utlock") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateRwLock + * AcpiUtDeleteRwLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader/writer lock creation and deletion interfaces. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateRwLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Lock->NumReaders = 0; + Status = AcpiOsCreateMutex (&Lock->ReaderMutex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateMutex (&Lock->WriterMutex); + return (Status); +} + + +void +AcpiUtDeleteRwLock ( + ACPI_RW_LOCK *Lock) +{ + + AcpiOsDeleteMutex (Lock->ReaderMutex); + AcpiOsDeleteMutex (Lock->WriterMutex); + + Lock->NumReaders = 0; + Lock->ReaderMutex = NULL; + Lock->WriterMutex = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireReadLock + * AcpiUtReleaseReadLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader interfaces for reader/writer locks. On acquisition, + * only the first reader acquires the write mutex. On release, + * only the last reader releases the write mutex. Although this + * algorithm can in theory starve writers, this should not be a + * problem with ACPICA since the subsystem is infrequently used + * in comparison to (for example) an I/O system. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireReadLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Acquire the write lock only for the first reader */ + + Lock->NumReaders++; + if (Lock->NumReaders == 1) + { + Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER); + } + + AcpiOsReleaseMutex (Lock->ReaderMutex); + return (Status); +} + + +ACPI_STATUS +AcpiUtReleaseReadLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Release the write lock only for the very last reader */ + + Lock->NumReaders--; + if (Lock->NumReaders == 0) + { + AcpiOsReleaseMutex (Lock->WriterMutex); + } + + AcpiOsReleaseMutex (Lock->ReaderMutex); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireWriteLock + * AcpiUtReleaseWriteLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Writer interfaces for reader/writer locks. Simply acquire or + * release the writer mutex associated with the lock. Acquisition + * of the lock is fully exclusive and will block all readers and + * writers until it is released. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireWriteLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER); + return (Status); +} + + +void +AcpiUtReleaseWriteLock ( + ACPI_RW_LOCK *Lock) +{ + + AcpiOsReleaseMutex (Lock->WriterMutex); +} + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utmath.c b/reactos/drivers/bus/acpi/acpica/utilities/utmath.c new file mode 100644 index 00000000000..b0a40ff2bcf --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utmath.c @@ -0,0 +1,431 @@ +/******************************************************************************* + * + * Module Name: utmath - Integer math support routines + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTMATH_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmath") + +/* + * Support for double-precision integer divide. This code is included here + * in order to support kernel environments where the double-precision math + * library is not available. + */ + +#ifndef ACPI_USE_NATIVE_DIVIDE +/******************************************************************************* + * + * FUNCTION: AcpiUtShortDivide + * + * PARAMETERS: Dividend - 64-bit dividend + * Divisor - 32-bit divisor + * OutQuotient - Pointer to where the quotient is returned + * OutRemainder - Pointer to where the remainder is returned + * + * RETURN: Status (Checks for divide-by-zero) + * + * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits) + * divide and modulo. The result is a 64-bit quotient and a + * 32-bit remainder. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER Dividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder) +{ + UINT64_OVERLAY DividendOvl; + UINT64_OVERLAY Quotient; + UINT32 Remainder32; + + + ACPI_FUNCTION_TRACE (UtShortDivide); + + + /* Always check for a zero divisor */ + + if (Divisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + DividendOvl.Full = Dividend; + + /* + * The quotient is 64 bits, the remainder is always 32 bits, + * and is generated by the second divide. + */ + ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor, + Quotient.Part.Hi, Remainder32); + ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor, + Quotient.Part.Lo, Remainder32); + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = Quotient.Full; + } + if (OutRemainder) + { + *OutRemainder = Remainder32; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDivide + * + * PARAMETERS: InDividend - Dividend + * InDivisor - Divisor + * OutQuotient - Pointer to where the quotient is returned + * OutRemainder - Pointer to where the remainder is returned + * + * RETURN: Status (Checks for divide-by-zero) + * + * DESCRIPTION: Perform a divide and modulo. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder) +{ + UINT64_OVERLAY Dividend; + UINT64_OVERLAY Divisor; + UINT64_OVERLAY Quotient; + UINT64_OVERLAY Remainder; + UINT64_OVERLAY NormalizedDividend; + UINT64_OVERLAY NormalizedDivisor; + UINT32 Partial1; + UINT64_OVERLAY Partial2; + UINT64_OVERLAY Partial3; + + + ACPI_FUNCTION_TRACE (UtDivide); + + + /* Always check for a zero divisor */ + + if (InDivisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + Divisor.Full = InDivisor; + Dividend.Full = InDividend; + if (Divisor.Part.Hi == 0) + { + /* + * 1) Simplest case is where the divisor is 32 bits, we can + * just do two divides + */ + Remainder.Part.Hi = 0; + + /* + * The quotient is 64 bits, the remainder is always 32 bits, + * and is generated by the second divide. + */ + ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor.Part.Lo, + Quotient.Part.Hi, Partial1); + ACPI_DIV_64_BY_32 (Partial1, Dividend.Part.Lo, Divisor.Part.Lo, + Quotient.Part.Lo, Remainder.Part.Lo); + } + + else + { + /* + * 2) The general case where the divisor is a full 64 bits + * is more difficult + */ + Quotient.Part.Hi = 0; + NormalizedDividend = Dividend; + NormalizedDivisor = Divisor; + + /* Normalize the operands (shift until the divisor is < 32 bits) */ + + do + { + ACPI_SHIFT_RIGHT_64 (NormalizedDivisor.Part.Hi, + NormalizedDivisor.Part.Lo); + ACPI_SHIFT_RIGHT_64 (NormalizedDividend.Part.Hi, + NormalizedDividend.Part.Lo); + + } while (NormalizedDivisor.Part.Hi != 0); + + /* Partial divide */ + + ACPI_DIV_64_BY_32 (NormalizedDividend.Part.Hi, + NormalizedDividend.Part.Lo, + NormalizedDivisor.Part.Lo, + Quotient.Part.Lo, Partial1); + + /* + * The quotient is always 32 bits, and simply requires adjustment. + * The 64-bit remainder must be generated. + */ + Partial1 = Quotient.Part.Lo * Divisor.Part.Hi; + Partial2.Full = (ACPI_INTEGER) Quotient.Part.Lo * Divisor.Part.Lo; + Partial3.Full = (ACPI_INTEGER) Partial2.Part.Hi + Partial1; + + Remainder.Part.Hi = Partial3.Part.Lo; + Remainder.Part.Lo = Partial2.Part.Lo; + + if (Partial3.Part.Hi == 0) + { + if (Partial3.Part.Lo >= Dividend.Part.Hi) + { + if (Partial3.Part.Lo == Dividend.Part.Hi) + { + if (Partial2.Part.Lo > Dividend.Part.Lo) + { + Quotient.Part.Lo--; + Remainder.Full -= Divisor.Full; + } + } + else + { + Quotient.Part.Lo--; + Remainder.Full -= Divisor.Full; + } + } + + Remainder.Full = Remainder.Full - Dividend.Full; + Remainder.Part.Hi = (UINT32) -((INT32) Remainder.Part.Hi); + Remainder.Part.Lo = (UINT32) -((INT32) Remainder.Part.Lo); + + if (Remainder.Part.Lo) + { + Remainder.Part.Hi--; + } + } + } + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = Quotient.Full; + } + if (OutRemainder) + { + *OutRemainder = Remainder.Full; + } + + return_ACPI_STATUS (AE_OK); +} + +#else + +/******************************************************************************* + * + * FUNCTION: AcpiUtShortDivide, AcpiUtDivide + * + * PARAMETERS: See function headers above + * + * DESCRIPTION: Native versions of the UtDivide functions. Use these if either + * 1) The target is a 64-bit platform and therefore 64-bit + * integer math is supported directly by the machine. + * 2) The target is a 32-bit or 16-bit platform, and the + * double-precision integer math library is available to + * perform the divide. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER InDividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder) +{ + + ACPI_FUNCTION_TRACE (UtShortDivide); + + + /* Always check for a zero divisor */ + + if (Divisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = InDividend / Divisor; + } + if (OutRemainder) + { + *OutRemainder = (UINT32) (InDividend % Divisor); + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder) +{ + ACPI_FUNCTION_TRACE (UtDivide); + + + /* Always check for a zero divisor */ + + if (InDivisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = InDividend / InDivisor; + } + if (OutRemainder) + { + *OutRemainder = InDividend % InDivisor; + } + + return_ACPI_STATUS (AE_OK); +} + +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utmisc.c b/reactos/drivers/bus/acpi/acpica/utilities/utmisc.c new file mode 100644 index 00000000000..bc27cd52938 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utmisc.c @@ -0,0 +1,1485 @@ +/******************************************************************************* + * + * Module Name: utmisc - common utility procedures + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmisc") + +/* + * Common suffix for messages + */ +#define ACPI_COMMON_MSG_SUFFIX \ + AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateException + * + * PARAMETERS: Status - The ACPI_STATUS code to be formatted + * + * RETURN: A string containing the exception text. NULL if exception is + * not valid. + * + * DESCRIPTION: This function validates and translates an ACPI exception into + * an ASCII string. + * + ******************************************************************************/ + +const char * +AcpiUtValidateException ( + ACPI_STATUS Status) +{ + UINT32 SubStatus; + const char *Exception = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Status is composed of two parts, a "type" and an actual code + */ + SubStatus = (Status & ~AE_CODE_MASK); + + switch (Status & AE_CODE_MASK) + { + case AE_CODE_ENVIRONMENTAL: + + if (SubStatus <= AE_CODE_ENV_MAX) + { + Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; + } + break; + + case AE_CODE_PROGRAMMER: + + if (SubStatus <= AE_CODE_PGM_MAX) + { + Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus]; + } + break; + + case AE_CODE_ACPI_TABLES: + + if (SubStatus <= AE_CODE_TBL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus]; + } + break; + + case AE_CODE_AML: + + if (SubStatus <= AE_CODE_AML_MAX) + { + Exception = AcpiGbl_ExceptionNames_Aml [SubStatus]; + } + break; + + case AE_CODE_CONTROL: + + if (SubStatus <= AE_CODE_CTRL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus]; + } + break; + + default: + break; + } + + return (ACPI_CAST_PTR (const char, Exception)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtIsPciRootBridge + * + * PARAMETERS: Id - The HID/CID in string format + * + * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id) +{ + + /* + * Check if this is a PCI root bridge. + * ACPI 3.0+: check for a PCI Express root also. + */ + if (!(ACPI_STRCMP (Id, + PCI_ROOT_HID_STRING)) || + + !(ACPI_STRCMP (Id, + PCI_EXPRESS_ROOT_HID_STRING))) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtIsAmlTable + * + * PARAMETERS: Table - An ACPI table + * + * RETURN: TRUE if table contains executable AML; FALSE otherwise + * + * DESCRIPTION: Check ACPI Signature for a table that contains AML code. + * Currently, these are DSDT,SSDT,PSDT. All other table types are + * data tables that do not contain AML code. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsAmlTable ( + ACPI_TABLE_HEADER *Table) +{ + + /* These are the only tables that contain executable AML */ + + if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) || + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateOwnerId + * + * PARAMETERS: OwnerId - Where the new owner ID is returned + * + * RETURN: Status + * + * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to + * track objects created by the table or method, to be deleted + * when the method exits or the table is unloaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAllocateOwnerId ( + ACPI_OWNER_ID *OwnerId) +{ + UINT32 i; + UINT32 j; + UINT32 k; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtAllocateOwnerId); + + + /* Guard against multiple allocations of ID to the same location */ + + if (*OwnerId) + { + ACPI_ERROR ((AE_INFO, "Owner ID [%2.2X] already exists", *OwnerId)); + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + + /* Mutex for the global ID mask */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Find a free owner ID, cycle through all possible IDs on repeated + * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have + * to be scanned twice. + */ + for (i = 0, j = AcpiGbl_LastOwnerIdIndex; + i < (ACPI_NUM_OWNERID_MASKS + 1); + i++, j++) + { + if (j >= ACPI_NUM_OWNERID_MASKS) + { + j = 0; /* Wraparound to start of mask array */ + } + + for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++) + { + if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX) + { + /* There are no free IDs in this mask */ + + break; + } + + if (!(AcpiGbl_OwnerIdMask[j] & (1 << k))) + { + /* + * Found a free ID. The actual ID is the bit index plus one, + * making zero an invalid Owner ID. Save this as the last ID + * allocated and update the global ID mask. + */ + AcpiGbl_OwnerIdMask[j] |= (1 << k); + + AcpiGbl_LastOwnerIdIndex = (UINT8) j; + AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1); + + /* + * Construct encoded ID from the index and bit position + * + * Note: Last [j].k (bit 255) is never used and is marked + * permanently allocated (prevents +1 overflow) + */ + *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j)); + + ACPI_DEBUG_PRINT ((ACPI_DB_VALUES, + "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId)); + goto Exit; + } + } + + AcpiGbl_NextOwnerIdOffset = 0; + } + + /* + * All OwnerIds have been allocated. This typically should + * not happen since the IDs are reused after deallocation. The IDs are + * allocated upon table load (one per table) and method execution, and + * they are released when a table is unloaded or a method completes + * execution. + * + * If this error happens, there may be very deep nesting of invoked control + * methods, or there may be a bug where the IDs are not released. + */ + Status = AE_OWNER_ID_LIMIT; + ACPI_ERROR ((AE_INFO, + "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReleaseOwnerId + * + * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID + * + * RETURN: None. No error is returned because we are either exiting a + * control method or unloading a table. Either way, we would + * ignore any error anyway. + * + * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 + * + ******************************************************************************/ + +void +AcpiUtReleaseOwnerId ( + ACPI_OWNER_ID *OwnerIdPtr) +{ + ACPI_OWNER_ID OwnerId = *OwnerIdPtr; + ACPI_STATUS Status; + UINT32 Index; + UINT32 Bit; + + + ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId); + + + /* Always clear the input OwnerId (zero is an invalid ID) */ + + *OwnerIdPtr = 0; + + /* Zero is not a valid OwnerID */ + + if (OwnerId == 0) + { + ACPI_ERROR ((AE_INFO, "Invalid OwnerId: %2.2X", OwnerId)); + return_VOID; + } + + /* Mutex for the global ID mask */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Normalize the ID to zero */ + + OwnerId--; + + /* Decode ID to index/offset pair */ + + Index = ACPI_DIV_32 (OwnerId); + Bit = 1 << ACPI_MOD_32 (OwnerId); + + /* Free the owner ID only if it is valid */ + + if (AcpiGbl_OwnerIdMask[Index] & Bit) + { + AcpiGbl_OwnerIdMask[Index] ^= Bit; + } + else + { + ACPI_ERROR ((AE_INFO, + "Release of non-allocated OwnerId: %2.2X", OwnerId + 1)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrupr (strupr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert string to uppercase + * + * NOTE: This is not a POSIX function, so it appears here, not in utclib.c + * + ******************************************************************************/ + +void +AcpiUtStrupr ( + char *SrcString) +{ + char *String; + + + ACPI_FUNCTION_ENTRY (); + + + if (!SrcString) + { + return; + } + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) ACPI_TOUPPER (*String); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPrintString + * + * PARAMETERS: String - Null terminated ASCII string + * MaxLength - Maximum output length + * + * RETURN: None + * + * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape + * sequences. + * + ******************************************************************************/ + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength) +{ + UINT32 i; + + + if (!String) + { + AcpiOsPrintf ("<\"NULL STRING PTR\">"); + return; + } + + AcpiOsPrintf ("\""); + for (i = 0; String[i] && (i < MaxLength); i++) + { + /* Escape sequences */ + + switch (String[i]) + { + case 0x07: + AcpiOsPrintf ("\\a"); /* BELL */ + break; + + case 0x08: + AcpiOsPrintf ("\\b"); /* BACKSPACE */ + break; + + case 0x0C: + AcpiOsPrintf ("\\f"); /* FORMFEED */ + break; + + case 0x0A: + AcpiOsPrintf ("\\n"); /* LINEFEED */ + break; + + case 0x0D: + AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/ + break; + + case 0x09: + AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */ + break; + + case 0x0B: + AcpiOsPrintf ("\\v"); /* VERTICAL TAB */ + break; + + case '\'': /* Single Quote */ + case '\"': /* Double Quote */ + case '\\': /* Backslash */ + AcpiOsPrintf ("\\%c", (int) String[i]); + break; + + default: + + /* Check for printable character or hex escape */ + + if (ACPI_IS_PRINT (String[i])) + { + /* This is a normal character */ + + AcpiOsPrintf ("%c", (int) String[i]); + } + else + { + /* All others will be Hex escapes */ + + AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]); + } + break; + } + } + AcpiOsPrintf ("\""); + + if (i == MaxLength && String[i]) + { + AcpiOsPrintf ("..."); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDwordByteSwap + * + * PARAMETERS: Value - Value to be converted + * + * RETURN: UINT32 integer with bytes swapped + * + * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) + * + ******************************************************************************/ + +UINT32 +AcpiUtDwordByteSwap ( + UINT32 Value) +{ + union + { + UINT32 Value; + UINT8 Bytes[4]; + } Out; + union + { + UINT32 Value; + UINT8 Bytes[4]; + } In; + + + ACPI_FUNCTION_ENTRY (); + + + In.Value = Value; + + Out.Bytes[0] = In.Bytes[3]; + Out.Bytes[1] = In.Bytes[2]; + Out.Bytes[2] = In.Bytes[1]; + Out.Bytes[3] = In.Bytes[0]; + + return (Out.Value); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtSetIntegerWidth + * + * PARAMETERS: Revision From DSDT header + * + * RETURN: None + * + * DESCRIPTION: Set the global integer bit width based upon the revision + * of the DSDT. For Revision 1 and 0, Integers are 32 bits. + * For Revision 2 and above, Integers are 64 bits. Yes, this + * makes a difference. + * + ******************************************************************************/ + +void +AcpiUtSetIntegerWidth ( + UINT8 Revision) +{ + + if (Revision < 2) + { + /* 32-bit case */ + + AcpiGbl_IntegerBitWidth = 32; + AcpiGbl_IntegerNybbleWidth = 8; + AcpiGbl_IntegerByteWidth = 4; + } + else + { + /* 64-bit case (ACPI 2.0+) */ + + AcpiGbl_IntegerBitWidth = 64; + AcpiGbl_IntegerNybbleWidth = 16; + AcpiGbl_IntegerByteWidth = 8; + } +} + + +#ifdef ACPI_DEBUG_OUTPUT +/******************************************************************************* + * + * FUNCTION: AcpiUtDisplayInitPathname + * + * PARAMETERS: Type - Object type of the node + * ObjHandle - Handle whose pathname will be displayed + * Path - Additional path string to be appended. + * (NULL if no extra path) + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Display full pathname of an object, DEBUG ONLY + * + ******************************************************************************/ + +void +AcpiUtDisplayInitPathname ( + UINT8 Type, + ACPI_NAMESPACE_NODE *ObjHandle, + char *Path) +{ + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + + + ACPI_FUNCTION_ENTRY (); + + + /* Only print the path if the appropriate debug level is enabled */ + + if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) + { + return; + } + + /* Get the full pathname to the node */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Print what we're doing */ + + switch (Type) + { + case ACPI_TYPE_METHOD: + AcpiOsPrintf ("Executing "); + break; + + default: + AcpiOsPrintf ("Initializing "); + break; + } + + /* Print the object type and pathname */ + + AcpiOsPrintf ("%-12s %s", + AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); + + /* Extra path is used to append names like _STA, _INI, etc. */ + + if (Path) + { + AcpiOsPrintf (".%s", Path); + } + AcpiOsPrintf ("\n"); + + ACPI_FREE (Buffer.Pointer); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidAcpiChar + * + * PARAMETERS: Char - The character to be examined + * Position - Byte position (0-3) + * + * RETURN: TRUE if the character is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI character. Must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + * We allow a '!' as the last character because of the ASF! table + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidAcpiChar ( + char Character, + UINT32 Position) +{ + + if (!((Character >= 'A' && Character <= 'Z') || + (Character >= '0' && Character <= '9') || + (Character == '_'))) + { + /* Allow a '!' in the last position */ + + if (Character == '!' && Position == 3) + { + return (TRUE); + } + + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidAcpiName + * + * PARAMETERS: Name - The name to be examined + * + * RETURN: TRUE if the name is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidAcpiName ( + UINT32 Name) +{ + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i)) + { + return (FALSE); + } + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRepairName + * + * PARAMETERS: Name - The ACPI name to be repaired + * + * RETURN: Repaired version of the name + * + * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and + * return the new name. NOTE: the Name parameter must reside in + * read/write memory, cannot be a const. + * + * An ACPI Name must consist of valid ACPI characters. We will repair the name + * if necessary because we don't want to abort because of this, but we want + * all namespace names to be printable. A warning message is appropriate. + * + * This issue came up because there are in fact machines that exhibit + * this problem, and we want to be able to enable ACPI support for them, + * even though there are a few bad names. + * + ******************************************************************************/ + +void +AcpiUtRepairName ( + char *Name) +{ + UINT32 i; + BOOLEAN FoundBadChar = FALSE; + + + ACPI_FUNCTION_NAME (UtRepairName); + + + /* Check each character in the name */ + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (AcpiUtValidAcpiChar (Name[i], i)) + { + continue; + } + + /* + * Replace a bad character with something printable, yet technically + * still invalid. This prevents any collisions with existing "good" + * names in the namespace. + */ + Name[i] = '*'; + FoundBadChar = TRUE; + } + + if (FoundBadChar) + { + /* Report warning only if in strict mode or debug mode */ + + if (!AcpiGbl_EnableInterpreterSlack) + { + ACPI_WARNING ((AE_INFO, + "Found bad character(s) in name, repaired: [%4.4s]\n", Name)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Found bad character(s) in name, repaired: [%4.4s]\n", Name)); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul64 + * + * PARAMETERS: String - Null terminated string + * Base - Radix of the string: 16 or ACPI_ANY_BASE; + * ACPI_ANY_BASE means 'in behalf of ToInteger' + * RetInteger - Where the converted integer is returned + * + * RETURN: Status and Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. Performs either a + * 32-bit or 64-bit conversion, depending on the current mode + * of the interpreter. + * NOTE: Does not support Octal strings, not needed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Base, + ACPI_INTEGER *RetInteger) +{ + UINT32 ThisDigit = 0; + ACPI_INTEGER ReturnValue = 0; + ACPI_INTEGER Quotient; + ACPI_INTEGER Dividend; + UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); + UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); + UINT8 ValidDigits = 0; + UINT8 SignOf0x = 0; + UINT8 Term = 0; + + + ACPI_FUNCTION_TRACE_STR (UtStroul64, String); + + + switch (Base) + { + case ACPI_ANY_BASE: + case 16: + break; + + default: + /* Invalid Base */ + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!String) + { + goto ErrorExit; + } + + /* Skip over any white space in the buffer */ + + while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t')) + { + String++; + } + + if (ToIntegerOp) + { + /* + * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. + * We need to determine if it is decimal or hexadecimal. + */ + if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x')) + { + SignOf0x = 1; + Base = 16; + + /* Skip over the leading '0x' */ + String += 2; + } + else + { + Base = 10; + } + } + + /* Any string left? Check that '0x' is not followed by white space. */ + + if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t') + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + goto AllDone; + } + } + + /* + * Perform a 32-bit or 64-bit conversion, depending upon the current + * execution mode of the interpreter + */ + Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; + + /* Main loop: convert the string to a 32- or 64-bit integer */ + + while (*String) + { + if (ACPI_IS_DIGIT (*String)) + { + /* Convert ASCII 0-9 to Decimal value */ + + ThisDigit = ((UINT8) *String) - '0'; + } + else if (Base == 10) + { + /* Digit is out of range; possible in ToInteger case only */ + + Term = 1; + } + else + { + ThisDigit = (UINT8) ACPI_TOUPPER (*String); + if (ACPI_IS_XDIGIT ((char) ThisDigit)) + { + /* Convert ASCII Hex char to value */ + + ThisDigit = ThisDigit - 'A' + 10; + } + else + { + Term = 1; + } + } + + if (Term) + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + break; + } + } + else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) + { + /* Skip zeros */ + String++; + continue; + } + + ValidDigits++; + + if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) + { + /* + * This is ToInteger operation case. + * No any restrictions for string-to-integer conversion, + * see ACPI spec. + */ + goto ErrorExit; + } + + /* Divide the digit into the correct position */ + + (void) AcpiUtShortDivide ((Dividend - (ACPI_INTEGER) ThisDigit), + Base, &Quotient, NULL); + + if (ReturnValue > Quotient) + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + break; + } + } + + ReturnValue *= Base; + ReturnValue += ThisDigit; + String++; + } + + /* All done, normal exit */ + +AllDone: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ReturnValue))); + + *RetInteger = ReturnValue; + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + /* Base was set/validated above */ + + if (Base == 10) + { + return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); + } + else + { + return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateUpdateStateAndPush + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + /* Ignore null objects; these are expected */ + + if (!Object) + { + return (AE_OK); + } + + State = AcpiUtCreateUpdateState (Object, Action); + if (!State) + { + return (AE_NO_MEMORY); + } + + AcpiUtPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtWalkPackageTree + * + * PARAMETERS: SourceObject - The package to walk + * TargetObject - Target object (if package is being copied) + * WalkCallback - Called once for each package element + * Context - Passed to the callback function + * + * RETURN: Status + * + * DESCRIPTION: Walk through a package + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_GENERIC_STATE *State; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT *ThisSourceObj; + + + ACPI_FUNCTION_TRACE (UtWalkPackageTree); + + + State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0); + if (!State) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + while (State) + { + /* Get one element of the package */ + + ThisIndex = State->Pkg.Index; + ThisSourceObj = (ACPI_OPERAND_OBJECT *) + State->Pkg.SourceObject->Package.Elements[ThisIndex]; + + /* + * Check for: + * 1) An uninitialized package element. It is completely + * legal to declare a package and leave it uninitialized + * 2) Not an internal object - can be a namespace node instead + * 3) Any type other than a package. Packages are handled in else + * case below. + */ + if ((!ThisSourceObj) || + (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || + (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE)) + { + Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, + State, Context); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + State->Pkg.Index++; + while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) + { + /* + * We've handled all of the objects at this level, This means + * that we have just completed a package. That package may + * have contained one or more packages itself. + * + * Delete this state and pop the previous state (package). + */ + AcpiUtDeleteGenericState (State); + State = AcpiUtPopGenericState (&StateList); + + /* Finished when there are no more states */ + + if (!State) + { + /* + * We have handled all of the objects in the top level + * package just add the length of the package objects + * and exit + */ + return_ACPI_STATUS (AE_OK); + } + + /* + * Go back up a level and move the index past the just + * completed package object. + */ + State->Pkg.Index++; + } + } + else + { + /* This is a subobject of type package */ + + Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, + State, Context); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Push the current state and create a new one + * The callback above returned a new target package object. + */ + AcpiUtPushGenericState (&StateList, State); + State = AcpiUtCreatePkgState (ThisSourceObj, + State->Pkg.ThisTargetObj, 0); + if (!State) + { + /* Free any stacked Update State objects */ + + while (StateList) + { + State = AcpiUtPopGenericState (&StateList); + AcpiUtDeleteGenericState (State); + } + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + } + + /* We should never get here */ + + return_ACPI_STATUS (AE_AML_INTERNAL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiError, AcpiException, AcpiWarning, AcpiInfo + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Print message with module/line/version info + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list args; + + + AcpiOsPrintf ("ACPI Error: "); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiException ( + const char *ModuleName, + UINT32 LineNumber, + ACPI_STATUS Status, + const char *Format, + ...) +{ + va_list args; + + + AcpiOsPrintf ("ACPI Exception: %s, ", AcpiFormatException (Status)); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiWarning ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list args; + + + AcpiOsPrintf ("ACPI Warning: "); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiInfo ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list args; + + + AcpiOsPrintf ("ACPI: "); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + AcpiOsPrintf ("\n"); + va_end (args); +} + +ACPI_EXPORT_SYMBOL (AcpiError) +ACPI_EXPORT_SYMBOL (AcpiException) +ACPI_EXPORT_SYMBOL (AcpiWarning) +ACPI_EXPORT_SYMBOL (AcpiInfo) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPredefinedWarning + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Pathname - Full pathname to the node + * NodeFlags - From Namespace node for the method/object + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Warnings for the predefined validation module. Messages are + * only emitted the first time a problem with a particular + * method/object is detected. This prevents a flood of error + * messages for methods that are repeatedly evaluated. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedWarning ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...) +{ + va_list args; + + + /* + * Warning messages for this method/object will be disabled after the + * first time a validation fails or an object is successfully repaired. + */ + if (NodeFlags & ANOBJ_EVALUATED) + { + return; + } + + AcpiOsPrintf ("ACPI Warning for %s: ", Pathname); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +/******************************************************************************* + * + * FUNCTION: AcpiUtPredefinedInfo + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Pathname - Full pathname to the node + * NodeFlags - From Namespace node for the method/object + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Info messages for the predefined validation module. Messages + * are only emitted the first time a problem with a particular + * method/object is detected. This prevents a flood of + * messages for methods that are repeatedly evaluated. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedInfo ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...) +{ + va_list args; + + + /* + * Warning messages for this method/object will be disabled after the + * first time a validation fails or an object is successfully repaired. + */ + if (NodeFlags & ANOBJ_EVALUATED) + { + return; + } + + AcpiOsPrintf ("ACPI Info for %s: ", Pathname); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c b/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c new file mode 100644 index 00000000000..f6e7cc36522 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c @@ -0,0 +1,477 @@ +/******************************************************************************* + * + * Module Name: utmutex - local mutex support + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTMUTEX_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmutex") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCreateMutex ( + ACPI_MUTEX_HANDLE MutexId); + +static ACPI_STATUS +AcpiUtDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMutexInitialize + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Create the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtMutexInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtMutexInitialize); + + + /* Create each of the predefined mutex objects */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + Status = AcpiUtCreateMutex (i); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Create the spinlocks for use at interrupt level */ + + Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create the reader/writer lock for namespace access */ + + Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMutexTerminate + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. + * + ******************************************************************************/ + +void +AcpiUtMutexTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtMutexTerminate); + + + /* Delete each predefined mutex object */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + (void) AcpiUtDeleteMutex (i); + } + + /* Delete the spinlocks */ + + AcpiOsDeleteLock (AcpiGbl_GpeLock); + AcpiOsDeleteLock (AcpiGbl_HardwareLock); + + /* Delete the reader/writer lock */ + + AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateMutex + * + * PARAMETERS: MutexID - ID of the mutex to be created + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCreateMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId); + + + if (MutexId > ACPI_MAX_MUTEX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!AcpiGbl_MutexInfo[MutexId].Mutex) + { + Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex); + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[MutexId].UseCount = 0; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteMutex + * + * PARAMETERS: MutexID - ID of the mutex to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete a mutex object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + + ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId); + + + if (MutexId > ACPI_MAX_MUTEX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex); + + AcpiGbl_MutexInfo[MutexId].Mutex = NULL; + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireMutex + * + * PARAMETERS: MutexID - ID of the mutex to be acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + ACPI_THREAD_ID ThisThreadId; + + + ACPI_FUNCTION_NAME (UtAcquireMutex); + + + if (MutexId > ACPI_MAX_MUTEX) + { + return (AE_BAD_PARAMETER); + } + + ThisThreadId = AcpiOsGetThreadId (); + +#ifdef ACPI_MUTEX_DEBUG + { + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than or equal to this one. If so, the thread has violated + * the mutex ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < ACPI_NUM_MUTEX; i++) + { + if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) + { + if (i == MutexId) + { + ACPI_ERROR ((AE_INFO, + "Mutex [%s] already acquired by this thread [%p]", + AcpiUtGetMutexName (MutexId), + ACPI_CAST_PTR (void, ThisThreadId))); + + return (AE_ALREADY_ACQUIRED); + } + + ACPI_ERROR ((AE_INFO, + "Invalid acquire order: Thread %p owns [%s], wants [%s]", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (i), + AcpiUtGetMutexName (MutexId))); + + return (AE_ACQUIRE_DEADLOCK); + } + } + } +#endif + + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %p attempting to acquire Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + + Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex, + ACPI_WAIT_FOREVER); + if (ACPI_SUCCESS (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p acquired Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + + AcpiGbl_MutexInfo[MutexId].UseCount++; + AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Thread %p could not acquire Mutex [%X]", + ACPI_CAST_PTR (void, ThisThreadId), MutexId)); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReleaseMutex + * + * PARAMETERS: MutexID - ID of the mutex to be released + * + * RETURN: Status + * + * DESCRIPTION: Release a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_THREAD_ID ThisThreadId; + + + ACPI_FUNCTION_NAME (UtReleaseMutex); + + + ThisThreadId = AcpiOsGetThreadId (); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + + if (MutexId > ACPI_MAX_MUTEX) + { + return (AE_BAD_PARAMETER); + } + + /* + * Mutex must be acquired in order to release it! + */ + if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED) + { + ACPI_ERROR ((AE_INFO, + "Mutex [%X] is not acquired, cannot release", MutexId)); + + return (AE_NOT_ACQUIRED); + } + +#ifdef ACPI_MUTEX_DEBUG + { + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than this one. If so, the thread has violated the mutex + * ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < ACPI_NUM_MUTEX; i++) + { + if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) + { + if (i == MutexId) + { + continue; + } + + ACPI_ERROR ((AE_INFO, + "Invalid release order: owns [%s], releasing [%s]", + AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); + + return (AE_RELEASE_DEADLOCK); + } + } + } +#endif + + /* Mark unlocked FIRST */ + + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + + AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex); + return (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utobject.c b/reactos/drivers/bus/acpi/acpica/utilities/utobject.c new file mode 100644 index 00000000000..5164744891b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utobject.c @@ -0,0 +1,859 @@ +/****************************************************************************** + * + * Module Name: utobject - ACPI object create/delete/size/cache routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utobject") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateInternalObjectDbg + * + * PARAMETERS: ModuleName - Source file name of caller + * LineNumber - Line number of caller + * ComponentId - Component type of caller + * Type - ACPI Type of the new object + * + * RETURN: A new internal object, null on failure + * + * DESCRIPTION: Create and initialize a new internal object. + * + * NOTE: We always allocate the worst-case object descriptor because + * these objects are cached, and we want them to be + * one-size-satisifies-any-request. This in itself may not be + * the most memory efficient, but the efficiency of the object + * cache should more than make up for this! + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateInternalObjectDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + ACPI_OBJECT_TYPE Type) +{ + ACPI_OPERAND_OBJECT *Object; + ACPI_OPERAND_OBJECT *SecondObject; + + + ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg, + AcpiUtGetTypeName (Type)); + + + /* Allocate the raw object descriptor */ + + Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); + if (!Object) + { + return_PTR (NULL); + } + + switch (Type) + { + case ACPI_TYPE_REGION: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + + /* These types require a secondary object */ + + SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, + LineNumber, ComponentId); + if (!SecondObject) + { + AcpiUtDeleteObjectDesc (Object); + return_PTR (NULL); + } + + SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA; + SecondObject->Common.ReferenceCount = 1; + + /* Link the second object to the first */ + + Object->Common.NextObject = SecondObject; + break; + + default: + /* All others have no secondary object */ + break; + } + + /* Save the object type in the object descriptor */ + + Object->Common.Type = (UINT8) Type; + + /* Init the reference count */ + + Object->Common.ReferenceCount = 1; + + /* Any per-type initialization should go here */ + + return_PTR (Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePackageObject + * + * PARAMETERS: Count - Number of package elements + * + * RETURN: Pointer to a new Package object, null on failure + * + * DESCRIPTION: Create a fully initialized package object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreatePackageObject ( + UINT32 Count) +{ + ACPI_OPERAND_OBJECT *PackageDesc; + ACPI_OPERAND_OBJECT **PackageElements; + + + ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count); + + + /* Create a new Package object */ + + PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); + if (!PackageDesc) + { + return_PTR (NULL); + } + + /* + * Create the element array. Count+1 allows the array to be null + * terminated. + */ + PackageElements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) Count + 1) * sizeof (void *)); + if (!PackageElements) + { + ACPI_FREE (PackageDesc); + return_PTR (NULL); + } + + PackageDesc->Package.Count = Count; + PackageDesc->Package.Elements = PackageElements; + return_PTR (PackageDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateIntegerObject + * + * PARAMETERS: InitialValue - Initial value for the integer + * + * RETURN: Pointer to a new Integer object, null on failure + * + * DESCRIPTION: Create an initialized integer object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateIntegerObject ( + UINT64 InitialValue) +{ + ACPI_OPERAND_OBJECT *IntegerDesc; + + + ACPI_FUNCTION_TRACE (UtCreateIntegerObject); + + + /* Create and initialize a new integer object */ + + IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!IntegerDesc) + { + return_PTR (NULL); + } + + IntegerDesc->Integer.Value = InitialValue; + return_PTR (IntegerDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateBufferObject + * + * PARAMETERS: BufferSize - Size of buffer to be created + * + * RETURN: Pointer to a new Buffer object, null on failure + * + * DESCRIPTION: Create a fully initialized buffer object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateBufferObject ( + ACPI_SIZE BufferSize) +{ + ACPI_OPERAND_OBJECT *BufferDesc; + UINT8 *Buffer = NULL; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize); + + + /* Create a new Buffer object */ + + BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!BufferDesc) + { + return_PTR (NULL); + } + + /* Create an actual buffer only if size > 0 */ + + if (BufferSize > 0) + { + /* Allocate the actual buffer */ + + Buffer = ACPI_ALLOCATE_ZEROED (BufferSize); + if (!Buffer) + { + ACPI_ERROR ((AE_INFO, "Could not allocate size %X", + (UINT32) BufferSize)); + AcpiUtRemoveReference (BufferDesc); + return_PTR (NULL); + } + } + + /* Complete buffer object initialization */ + + BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + BufferDesc->Buffer.Pointer = Buffer; + BufferDesc->Buffer.Length = (UINT32) BufferSize; + + /* Return the new buffer descriptor */ + + return_PTR (BufferDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateStringObject + * + * PARAMETERS: StringSize - Size of string to be created. Does not + * include NULL terminator, this is added + * automatically. + * + * RETURN: Pointer to a new String object + * + * DESCRIPTION: Create a fully initialized string object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize) +{ + ACPI_OPERAND_OBJECT *StringDesc; + char *String; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize); + + + /* Create a new String object */ + + StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); + if (!StringDesc) + { + return_PTR (NULL); + } + + /* + * Allocate the actual string buffer -- (Size + 1) for NULL terminator. + * NOTE: Zero-length strings are NULL terminated + */ + String = ACPI_ALLOCATE_ZEROED (StringSize + 1); + if (!String) + { + ACPI_ERROR ((AE_INFO, "Could not allocate size %X", + (UINT32) StringSize)); + AcpiUtRemoveReference (StringDesc); + return_PTR (NULL); + } + + /* Complete string object initialization */ + + StringDesc->String.Pointer = String; + StringDesc->String.Length = (UINT32) StringSize; + + /* Return the new string descriptor */ + + return_PTR (StringDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidInternalObject + * + * PARAMETERS: Object - Object to be validated + * + * RETURN: TRUE if object is valid, FALSE otherwise + * + * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidInternalObject ( + void *Object) +{ + + ACPI_FUNCTION_NAME (UtValidInternalObject); + + + /* Check for a null pointer */ + + if (!Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n")); + return (FALSE); + } + + /* Check the descriptor type field */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Object)) + { + case ACPI_DESC_TYPE_OPERAND: + + /* The object appears to be a valid ACPI_OPERAND_OBJECT */ + + return (TRUE); + + default: + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%p is not not an ACPI operand obj [%s]\n", + Object, AcpiUtGetDescriptorName (Object))); + break; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateObjectDescDbg + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * + * RETURN: Pointer to newly allocated object descriptor. Null on error + * + * DESCRIPTION: Allocate a new object descriptor. Gracefully handle + * error conditions. + * + ******************************************************************************/ + +void * +AcpiUtAllocateObjectDescDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg); + + + Object = AcpiOsAcquireObject (AcpiGbl_OperandCache); + if (!Object) + { + ACPI_ERROR ((ModuleName, LineNumber, + "Could not allocate an object descriptor")); + + return_PTR (NULL); + } + + /* Mark the descriptor type */ + + ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND); + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", + Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT))); + + return_PTR (Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteObjectDesc + * + * PARAMETERS: Object - An Acpi internal object to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache + * + ******************************************************************************/ + +void +AcpiUtDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object) +{ + ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object); + + + /* Object must be an ACPI_OPERAND_OBJECT */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) + { + ACPI_ERROR ((AE_INFO, + "%p is not an ACPI Operand object [%s]", Object, + AcpiUtGetDescriptorName (Object))); + return_VOID; + } + + (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetSimpleObjectSize + * + * PARAMETERS: InternalObject - An ACPI operand object + * ObjLength - Where the length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain a simple object for return to an external user. + * + * The length includes the object structure plus any additional + * needed space. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_SIZE Length; + ACPI_SIZE Size; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject); + + + /* Start with the length of the (external) Acpi object */ + + Length = sizeof (ACPI_OBJECT); + + /* A NULL object is allowed, can be a legal uninitialized package element */ + + if (!InternalObject) + { + /* + * Object is NULL, just return the length of ACPI_OBJECT + * (A NULL ACPI_OBJECT is an object of all zeroes.) + */ + *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); + return_ACPI_STATUS (AE_OK); + } + + /* A Namespace Node should never appear here */ + + if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED) + { + /* A namespace node should never get here */ + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * The final length depends on the object type + * Strings and Buffers are packed right up against the parent object and + * must be accessed bytewise or there may be alignment problems on + * certain processors + */ + switch (InternalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + Length += (ACPI_SIZE) InternalObject->String.Length + 1; + break; + + + case ACPI_TYPE_BUFFER: + + Length += (ACPI_SIZE) InternalObject->Buffer.Length; + break; + + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + + /* No extra data for these types */ + + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (InternalObject->Reference.Class) + { + case ACPI_REFCLASS_NAME: + + /* + * Get the actual length of the full pathname to this object. + * The reference will be converted to the pathname to the object + */ + Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node); + if (!Size) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size); + break; + + default: + + /* + * No other reference opcodes are supported. + * Notably, Locals and Args are not supported, but this may be + * required eventually. + */ + ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " + "unsupported Reference Class [%s] %X in object %p", + AcpiUtGetReferenceName (InternalObject), + InternalObject->Reference.Class, InternalObject)); + Status = AE_TYPE; + break; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " + "unsupported type [%s] %X in object %p", + AcpiUtGetObjectTypeName (InternalObject), + InternalObject->Common.Type, InternalObject)); + Status = AE_TYPE; + break; + } + + /* + * Account for the space required by the object rounded up to the next + * multiple of the machine word size. This keeps each object aligned + * on a machine word boundary. (preventing alignment faults on some + * machines.) + */ + *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetElementLength + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Get the length of one package element. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; + ACPI_SIZE ObjectSpace; + + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* + * Simple object - just get the size (Null object/entry is handled + * here also) and sum it into the running package length + */ + Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Info->Length += ObjectSpace; + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* Package object - nothing much to do here, let the walk handle it */ + + Info->NumPackages++; + State->Pkg.ThisTargetObj = NULL; + break; + + + default: + + /* No other types allowed */ + + return (AE_BAD_PARAMETER); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetPackageObjectSize + * + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain a package object for return to an external user. + * + * This is moderately complex since a package contains other + * objects including packages. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_STATUS Status; + ACPI_PKG_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject); + + + Info.Length = 0; + Info.ObjectSpace = 0; + Info.NumPackages = 1; + + Status = AcpiUtWalkPackageTree (InternalObject, NULL, + AcpiUtGetElementLength, &Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * We have handled all of the objects in all levels of the package. + * just add the length of the package objects themselves. + * Round up to the next machine word. + */ + Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * + (ACPI_SIZE) Info.NumPackages; + + /* Return the total package length */ + + *ObjLength = Info.Length; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetObjectSize + * + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length will be returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain an object for return to an API user. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtGetObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) && + (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)) + { + Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength); + } + else + { + Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength); + } + + return (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c b/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c new file mode 100644 index 00000000000..2f19d639868 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c @@ -0,0 +1,772 @@ +/******************************************************************************* + * + * Module Name: utresrc - Resource managment utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTRESRC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlresrc.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utresrc") + + +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) + +/* + * Strings used to decode resource descriptors. + * Used by both the disasssembler and the debugger resource dump routines + */ +const char *AcpiGbl_BmDecode[] = +{ + "NotBusMaster", + "BusMaster" +}; + +const char *AcpiGbl_ConfigDecode[] = +{ + "0 - Good Configuration", + "1 - Acceptable Configuration", + "2 - Suboptimal Configuration", + "3 - ***Invalid Configuration***", +}; + +const char *AcpiGbl_ConsumeDecode[] = +{ + "ResourceProducer", + "ResourceConsumer" +}; + +const char *AcpiGbl_DecDecode[] = +{ + "PosDecode", + "SubDecode" +}; + +const char *AcpiGbl_HeDecode[] = +{ + "Level", + "Edge" +}; + +const char *AcpiGbl_IoDecode[] = +{ + "Decode10", + "Decode16" +}; + +const char *AcpiGbl_LlDecode[] = +{ + "ActiveHigh", + "ActiveLow" +}; + +const char *AcpiGbl_MaxDecode[] = +{ + "MaxNotFixed", + "MaxFixed" +}; + +const char *AcpiGbl_MemDecode[] = +{ + "NonCacheable", + "Cacheable", + "WriteCombining", + "Prefetchable" +}; + +const char *AcpiGbl_MinDecode[] = +{ + "MinNotFixed", + "MinFixed" +}; + +const char *AcpiGbl_MtpDecode[] = +{ + "AddressRangeMemory", + "AddressRangeReserved", + "AddressRangeACPI", + "AddressRangeNVS" +}; + +const char *AcpiGbl_RngDecode[] = +{ + "InvalidRanges", + "NonISAOnlyRanges", + "ISAOnlyRanges", + "EntireRange" +}; + +const char *AcpiGbl_RwDecode[] = +{ + "ReadOnly", + "ReadWrite" +}; + +const char *AcpiGbl_ShrDecode[] = +{ + "Exclusive", + "Shared" +}; + +const char *AcpiGbl_SizDecode[] = +{ + "Transfer8", + "Transfer8_16", + "Transfer16", + "InvalidSize" +}; + +const char *AcpiGbl_TrsDecode[] = +{ + "DenseTranslation", + "SparseTranslation" +}; + +const char *AcpiGbl_TtpDecode[] = +{ + "TypeStatic", + "TypeTranslation" +}; + +const char *AcpiGbl_TypDecode[] = +{ + "Compatibility", + "TypeA", + "TypeB", + "TypeF" +}; + +#endif + + +/* + * Base sizes of the raw AML resource descriptors, indexed by resource type. + * Zero indicates a reserved (and therefore invalid) resource type. + */ +const UINT8 AcpiGbl_ResourceAmlSizes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO), + 0, + 0, + 0, + 0, + ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG), + + /* Large descriptors */ + + 0, + ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER), + 0, + ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64) +}; + + +/* + * Resource types, used to validate the resource length field. + * The length of fixed-length types must match exactly, variable + * lengths must meet the minimum required length, etc. + * Zero indicates a reserved (and therefore invalid) resource type. + */ +static const UINT8 AcpiGbl_ResourceTypes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_SMALL_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_SMALL_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + 0, + 0, + 0, + 0, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + + /* Large descriptors */ + + 0, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + 0, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtWalkAmlResources + * + * PARAMETERS: Aml - Pointer to the raw AML resource template + * AmlLength - Length of the entire template + * UserFunction - Called once for each descriptor found. If + * NULL, a pointer to the EndTag is returned + * Context - Passed to UserFunction + * + * RETURN: Status + * + * DESCRIPTION: Walk a raw AML resource list(buffer). User function called + * once for each resource found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtWalkAmlResources ( + UINT8 *Aml, + ACPI_SIZE AmlLength, + ACPI_WALK_AML_CALLBACK UserFunction, + void *Context) +{ + ACPI_STATUS Status; + UINT8 *EndAml; + UINT8 ResourceIndex; + UINT32 Length; + UINT32 Offset = 0; + + + ACPI_FUNCTION_TRACE (UtWalkAmlResources); + + + /* The absolute minimum resource template is one EndTag descriptor */ + + if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + + /* Point to the end of the resource template buffer */ + + EndAml = Aml + AmlLength; + + /* Walk the byte list, abort on any invalid descriptor type or length */ + + while (Aml < EndAml) + { + /* Validate the Resource Type and Resource Length */ + + Status = AcpiUtValidateResource (Aml, &ResourceIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the length of this descriptor */ + + Length = AcpiUtGetDescriptorLength (Aml); + + /* Invoke the user function */ + + if (UserFunction) + { + Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* An EndTag descriptor terminates this resource template */ + + if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) + { + /* + * There must be at least one more byte in the buffer for + * the 2nd byte of the EndTag + */ + if ((Aml + 1) >= EndAml) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + + /* Return the pointer to the EndTag if requested */ + + if (!UserFunction) + { + *(void **) Context = Aml; + } + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + } + + Aml += Length; + Offset += Length; + } + + /* Did not find an EndTag descriptor */ + + return (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateResource + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * ReturnIndex - Where the resource index is returned. NULL + * if the index is not required. + * + * RETURN: Status, and optionally the Index into the global resource tables + * + * DESCRIPTION: Validate an AML resource descriptor by checking the Resource + * Type and Resource Length. Returns an index into the global + * resource information/dispatch tables for later use. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtValidateResource ( + void *Aml, + UINT8 *ReturnIndex) +{ + UINT8 ResourceType; + UINT8 ResourceIndex; + ACPI_RS_LENGTH ResourceLength; + ACPI_RS_LENGTH MinimumResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * 1) Validate the ResourceType field (Byte 0) + */ + ResourceType = ACPI_GET8 (Aml); + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ResourceType & ACPI_RESOURCE_NAME_LARGE) + { + /* Verify the large resource type (name) against the max */ + + if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX) + { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* + * Large Resource Type -- bits 6:0 contain the name + * Translate range 0x80-0x8B to index range 0x10-0x1B + */ + ResourceIndex = (UINT8) (ResourceType - 0x70); + } + else + { + /* + * Small Resource Type -- bits 6:3 contain the name + * Shift range to index range 0x00-0x0F + */ + ResourceIndex = (UINT8) + ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); + } + + /* Check validity of the resource type, zero indicates name is invalid */ + + if (!AcpiGbl_ResourceTypes[ResourceIndex]) + { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + + /* + * 2) Validate the ResourceLength field. This ensures that the length + * is at least reasonable, and guarantees that it is non-zero. + */ + ResourceLength = AcpiUtGetResourceLength (Aml); + MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; + + /* Validate based upon the type of resource - fixed length or variable */ + + switch (AcpiGbl_ResourceTypes[ResourceIndex]) + { + case ACPI_FIXED_LENGTH: + + /* Fixed length resource, length must match exactly */ + + if (ResourceLength != MinimumResourceLength) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + case ACPI_VARIABLE_LENGTH: + + /* Variable length resource, length must be at least the minimum */ + + if (ResourceLength < MinimumResourceLength) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + case ACPI_SMALL_VARIABLE_LENGTH: + + /* Small variable length resource, length can be (Min) or (Min-1) */ + + if ((ResourceLength > MinimumResourceLength) || + (ResourceLength < (MinimumResourceLength - 1))) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + default: + + /* Shouldn't happen (because of validation earlier), but be sure */ + + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* Optionally return the resource table index */ + + if (ReturnIndex) + { + *ReturnIndex = ResourceIndex; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceType + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: The Resource Type with no extraneous bits (except the + * Large/Small descriptor bit -- this is left alone) + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +UINT8 +AcpiUtGetResourceType ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource Type -- bits 6:0 contain the name */ + + return (ACPI_GET8 (Aml)); + } + else + { + /* Small Resource Type -- bits 6:3 contain the name */ + + return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte Length + * + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By + * definition, this does not include the size of the descriptor + * header or the length field itself. + * + ******************************************************************************/ + +UINT16 +AcpiUtGetResourceLength ( + void *Aml) +{ + ACPI_RS_LENGTH ResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1)); + + } + else + { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + ResourceLength = (UINT16) (ACPI_GET8 (Aml) & + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + } + + return (ResourceLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceHeaderLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Length of the AML header (depends on large/small descriptor) + * + * DESCRIPTION: Get the length of the header for this resource. + * + ******************************************************************************/ + +UINT8 +AcpiUtGetResourceHeaderLength ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Examine the large/small bit in the resource header */ + + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + return (sizeof (AML_RESOURCE_LARGE_HEADER)); + } + else + { + return (sizeof (AML_RESOURCE_SMALL_HEADER)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetDescriptorLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte length + * + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the + * length of the descriptor header and the length field itself. + * Used to walk descriptor lists. + * + ******************************************************************************/ + +UINT32 +AcpiUtGetDescriptorLength ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * Get the Resource Length (does not include header length) and add + * the header length (depends on if this is a small or large resource) + */ + return (AcpiUtGetResourceLength (Aml) + + AcpiUtGetResourceHeaderLength (Aml)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceEndTag + * + * PARAMETERS: ObjDesc - The resource template buffer object + * EndTag - Where the pointer to the EndTag is returned + * + * RETURN: Status, pointer to the end tag + * + * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template + * Note: allows a buffer length of zero. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtGetResourceEndTag ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 **EndTag) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtGetResourceEndTag); + + + /* Allow a buffer length of zero */ + + if (!ObjDesc->Buffer.Length) + { + *EndTag = ObjDesc->Buffer.Pointer; + return_ACPI_STATUS (AE_OK); + } + + /* Validate the template and get a pointer to the EndTag */ + + Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length, NULL, EndTag); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utstate.c b/reactos/drivers/bus/acpi/acpica/utilities/utstate.c new file mode 100644 index 00000000000..245ca02bfc5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utstate.c @@ -0,0 +1,470 @@ +/******************************************************************************* + * + * Module Name: utstate - state object support procedures + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTSTATE_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utstate") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePkgStateAndPush + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index); + if (!State) + { + return (AE_NO_MEMORY); + } + + AcpiUtPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPushGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * State - State object to push + * + * RETURN: None + * + * DESCRIPTION: Push a state object onto a state stack + * + ******************************************************************************/ + +void +AcpiUtPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State) +{ + ACPI_FUNCTION_TRACE (UtPushGenericState); + + + /* Push the state object onto the front of the list (stack) */ + + State->Common.Next = *ListHead; + *ListHead = State; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPopGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * + * RETURN: The popped state object + * + * DESCRIPTION: Pop a state object from a state stack + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtPopGenericState ( + ACPI_GENERIC_STATE **ListHead) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtPopGenericState); + + + /* Remove the state object at the head of the list (stack) */ + + State = *ListHead; + if (State) + { + /* Update the list head */ + + *ListHead = State->Common.Next; + } + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateGenericState + * + * PARAMETERS: None + * + * RETURN: The new state object. NULL on failure. + * + * DESCRIPTION: Create a generic state object. Attempt to obtain one from + * the global state cache; If none available, create a new one. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateGenericState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + State = AcpiOsAcquireObject (AcpiGbl_StateCache); + if (State) + { + /* Initialize */ + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE; + } + + return (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateThreadState + * + * PARAMETERS: None + * + * RETURN: New Thread State. NULL on failure + * + * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used + * to track per-thread info during method execution + * + ******************************************************************************/ + +ACPI_THREAD_STATE * +AcpiUtCreateThreadState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtCreateThreadState); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_THREAD; + State->Thread.ThreadId = AcpiOsGetThreadId (); + + /* Check for invalid thread ID - zero is very bad, it will break things */ + + if (!State->Thread.ThreadId) + { + ACPI_ERROR ((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId")); + State->Thread.ThreadId = (ACPI_THREAD_ID) 1; + } + + return_PTR ((ACPI_THREAD_STATE *) State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateUpdateState + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (UtCreateUpdateState, Object); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_UPDATE; + State->Update.Object = Object; + State->Update.Value = Action; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePkgState + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Package State" + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (UtCreatePkgState, InternalObject); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PACKAGE; + State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; + State->Pkg.DestObject = ExternalObject; + State->Pkg.Index= Index; + State->Pkg.NumPackages = 1; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateControlState + * + * PARAMETERS: None + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Control State" - a flavor of the generic state used + * to support nested IF/WHILE constructs in the AML. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateControlState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtCreateControlState); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the control struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_CONTROL; + State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteGenericState + * + * PARAMETERS: State - The state object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Release a state object to the state cache. NULL state objects + * are ignored. + * + ******************************************************************************/ + +void +AcpiUtDeleteGenericState ( + ACPI_GENERIC_STATE *State) +{ + ACPI_FUNCTION_TRACE (UtDeleteGenericState); + + + /* Ignore null state */ + + if (State) + { + (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); + } + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/uttrack.c b/reactos/drivers/bus/acpi/acpica/utilities/uttrack.c new file mode 100644 index 00000000000..d712c1a3e5a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/uttrack.c @@ -0,0 +1,726 @@ +/****************************************************************************** + * + * Module Name: uttrack - Memory allocation tracking routines (debug only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +/* + * These procedures are used for tracking memory leaks in the subsystem, and + * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set. + * + * Each memory allocation is tracked via a doubly linked list. Each + * element contains the caller's component, module name, function name, and + * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call + * AcpiUtTrackAllocation to add an element to the list; deletion + * occurs in the body of AcpiUtFree. + */ + +#define __UTTRACK_C__ + +#include "acpi.h" +#include "accommon.h" + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("uttrack") + +/* Local prototypes */ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation); + +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + const char *Module, + UINT32 Line); + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + UINT32 Component, + const char *Module, + UINT32 Line); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateList + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a local memory list for tracking purposed + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateList ( + char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + + Cache->ListName = ListName; + Cache->ObjectSize = ObjectSize; + + *ReturnCache = Cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateAndTrack + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: The subsystem's equivalent of malloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocateAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *Allocation; + ACPI_STATUS Status; + + + Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); + if (!Allocation) + { + return (NULL); + } + + Status = AcpiUtTrackAllocation (Allocation, Size, + ACPI_MEM_MALLOC, Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Allocation); + return (NULL); + } + + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->TotalSize += (UINT32) Size; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; + if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + { + AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + } + + return ((void *) &Allocation->UserSpace); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateZeroedAndTrack + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocateZeroedAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *Allocation; + ACPI_STATUS Status; + + + Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); + if (!Allocation) + { + /* Report allocation error */ + + ACPI_ERROR ((Module, Line, + "Could not allocate size %X", (UINT32) Size)); + return (NULL); + } + + Status = AcpiUtTrackAllocation (Allocation, Size, + ACPI_MEM_CALLOC, Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Allocation); + return (NULL); + } + + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->TotalSize += (UINT32) Size; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; + if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + { + AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + } + + return ((void *) &Allocation->UserSpace); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFreeAndTrack + * + * PARAMETERS: Allocation - Address of the memory to deallocate + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None + * + * DESCRIPTION: Frees the memory at Allocation + * + ******************************************************************************/ + +void +AcpiUtFreeAndTrack ( + void *Allocation, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *DebugBlock; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation); + + + if (NULL == Allocation) + { + ACPI_ERROR ((Module, Line, + "Attempt to delete a NULL address")); + + return_VOID; + } + + DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, + (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); + + AcpiGbl_GlobalList->TotalFreed++; + AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; + + Status = AcpiUtRemoveAllocation (DebugBlock, + Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory")); + } + + AcpiOsFree (DebugBlock); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFindAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * + * RETURN: A list element if found; NULL otherwise. + * + * DESCRIPTION: Searches for an element in the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation) +{ + ACPI_DEBUG_MEM_BLOCK *Element; + + + ACPI_FUNCTION_ENTRY (); + + + Element = AcpiGbl_GlobalList->ListHead; + + /* Search for the address. */ + + while (Element) + { + if (Element == Allocation) + { + return (Element); + } + + Element = Element->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrackAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * Size - Size of the allocation + * AllocType - MEM_MALLOC or MEM_CALLOC + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None. + * + * DESCRIPTION: Inserts an element into the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Allocation, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_MEMORY_LIST *MemList; + ACPI_DEBUG_MEM_BLOCK *Element; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation); + + + MemList = AcpiGbl_GlobalList; + Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Search list for this address to make sure it is not already on the list. + * This will catch several kinds of problems. + */ + Element = AcpiUtFindAllocation (Allocation); + if (Element) + { + ACPI_ERROR ((AE_INFO, + "UtTrackAllocation: Allocation already present in list! (%p)", + Allocation)); + + ACPI_ERROR ((AE_INFO, "Element %p Address %p", + Element, Allocation)); + + goto UnlockAndExit; + } + + /* Fill in the instance data. */ + + Allocation->Size = (UINT32) Size; + Allocation->AllocType = AllocType; + Allocation->Component = Component; + Allocation->Line = Line; + + ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); + Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; + + /* Insert at list head */ + + if (MemList->ListHead) + { + ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; + } + + Allocation->Next = MemList->ListHead; + Allocation->Previous = NULL; + + MemList->ListHead = Allocation; + + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: + * + * DESCRIPTION: Deletes an element from the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Allocation, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_MEMORY_LIST *MemList; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtRemoveAllocation); + + + MemList = AcpiGbl_GlobalList; + if (NULL == MemList->ListHead) + { + /* No allocations! */ + + ACPI_ERROR ((Module, Line, + "Empty allocation list, nothing to free!")); + + return_ACPI_STATUS (AE_OK); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Unlink */ + + if (Allocation->Previous) + { + (Allocation->Previous)->Next = Allocation->Next; + } + else + { + MemList->ListHead = Allocation->Next; + } + + if (Allocation->Next) + { + (Allocation->Next)->Previous = Allocation->Previous; + } + + /* Mark the segment as deleted */ + + ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", + Allocation->Size)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpAllocationInfo + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: Print some info about the outstanding allocations. + * + ******************************************************************************/ + +void +AcpiUtDumpAllocationInfo ( + void) +{ +/* + ACPI_MEMORY_LIST *MemList; +*/ + + ACPI_FUNCTION_TRACE (UtDumpAllocationInfo); + +/* + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current allocations", + MemList->CurrentCount, + ROUND_UP_TO_1K (MemList->CurrentSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", + MemList->MaxConcurrentCount, + ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); + + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", + RunningObjectCount, + ROUND_UP_TO_1K (RunningObjectSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", + RunningAllocCount, + ROUND_UP_TO_1K (RunningAllocSize))); + + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current Nodes", + AcpiGbl_CurrentNodeCount, + ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max Nodes", + AcpiGbl_MaxConcurrentNodeCount, + ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * + sizeof (ACPI_NAMESPACE_NODE))))); +*/ + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpAllocations + * + * PARAMETERS: Component - Component(s) to dump info for. + * Module - Module to dump info for. NULL means all. + * + * RETURN: None + * + * DESCRIPTION: Print a list of all outstanding allocations. + * + ******************************************************************************/ + +void +AcpiUtDumpAllocations ( + UINT32 Component, + const char *Module) +{ + ACPI_DEBUG_MEM_BLOCK *Element; + ACPI_DESCRIPTOR *Descriptor; + UINT32 NumOutstanding = 0; + + + ACPI_FUNCTION_TRACE (UtDumpAllocations); + + + /* + * Walk the allocation list. + */ + if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY))) + { + return; + } + + Element = AcpiGbl_GlobalList->ListHead; + while (Element) + { + if ((Element->Component & Component) && + ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) + { + /* Ignore allocated objects that are in a cache */ + + Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); + if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) + { + AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", + Descriptor, Element->Size, Element->Module, + Element->Line, AcpiUtGetDescriptorName (Descriptor)); + + /* Most of the elements will be Operand objects. */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) + { + case ACPI_DESC_TYPE_OPERAND: + AcpiOsPrintf ("%12.12s R%hd", + AcpiUtGetTypeName (Descriptor->Object.Common.Type), + Descriptor->Object.Common.ReferenceCount); + break; + + case ACPI_DESC_TYPE_PARSER: + AcpiOsPrintf ("AmlOpcode %04hX", + Descriptor->Op.Asl.AmlOpcode); + break; + + case ACPI_DESC_TYPE_NAMED: + AcpiOsPrintf ("%4.4s", + AcpiUtGetNodeName (&Descriptor->Node)); + break; + + default: + break; + } + + AcpiOsPrintf ( "\n"); + NumOutstanding++; + } + } + Element = Element->Next; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + + /* Print summary */ + + if (!NumOutstanding) + { + ACPI_INFO ((AE_INFO, + "No outstanding allocations")); + } + else + { + ACPI_ERROR ((AE_INFO, + "%d(%X) Outstanding allocations", + NumOutstanding, NumOutstanding)); + } + + return_VOID; +} + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utxface.c b/reactos/drivers/bus/acpi/acpica/utilities/utxface.c new file mode 100644 index 00000000000..ba57f4922b7 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utxface.c @@ -0,0 +1,734 @@ +/****************************************************************************** + * + * Module Name: utxface - External interfaces for "global" ACPI functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acdebug.h" +#include "actables.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utxface") + + +#ifndef ACPI_ASL_COMPILER + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeSubsystem + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initializes all global variables. This is the first function + * called, so any early initialization belongs here. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeSubsystem ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem); + + + AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE; + ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ()); + + /* Initialize the OS-Dependent layer */ + + Status = AcpiOsInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization")); + return_ACPI_STATUS (Status); + } + + /* Initialize all globals used by the subsystem */ + + Status = AcpiUtInitGlobals (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals")); + return_ACPI_STATUS (Status); + } + + /* Create the default mutex objects */ + + Status = AcpiUtMutexInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation")); + return_ACPI_STATUS (Status); + } + + /* + * Initialize the namespace manager and + * the root of the namespace tree + */ + Status = AcpiNsRootInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization")); + return_ACPI_STATUS (Status); + } + + /* If configured, initialize the AML debugger */ + + ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ()); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableSubsystem + * + * PARAMETERS: Flags - Init/enable Options + * + * RETURN: Status + * + * DESCRIPTION: Completes the subsystem initialization including hardware. + * Puts system into ACPI mode if it isn't already. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiEnableSubsystem); + + + /* Enable ACPI mode */ + + if (!(Flags & ACPI_NO_ACPI_ENABLE)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); + + AcpiGbl_OriginalMode = AcpiHwGetMode(); + + Status = AcpiEnable (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "AcpiEnable failed")); + return_ACPI_STATUS (Status); + } + } + + /* + * Obtain a permanent mapping for the FACS. This is required for the + * Global Lock and the Firmware Waking Vector + */ + Status = AcpiTbInitializeFacs (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Could not map the FACS table")); + return_ACPI_STATUS (Status); + } + + /* + * Install the default OpRegion handlers. These are installed unless + * other handlers have already been installed via the + * InstallAddressSpaceHandler interface. + */ + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing default address space handlers\n")); + + Status = AcpiEvInstallRegionHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize ACPI Event handling (Fixed and General Purpose) + * + * Note1: We must have the hardware and events initialized before we can + * execute any control methods safely. Any control method can require + * ACPI hardware support, so the hardware must be fully initialized before + * any method execution! + * + * Note2: Fixed events are initialized and enabled here. GPEs are + * initialized, but cannot be enabled until after the hardware is + * completely initialized (SCI and GlobalLock activated) and the various + * initialization control methods are run (_REG, _STA, _INI) on the + * entire namespace. + */ + if (!(Flags & ACPI_NO_EVENT_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI events\n")); + + Status = AcpiEvInitializeEvents (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Install the SCI handler and Global Lock handler. This completes the + * hardware initialization. + */ + if (!(Flags & ACPI_NO_HANDLER_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing SCI/GL handlers\n")); + + Status = AcpiEvInstallXruptHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem) + + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeObjects + * + * PARAMETERS: Flags - Init/enable Options + * + * RETURN: Status + * + * DESCRIPTION: Completes namespace initialization by initializing device + * objects and executing AML code for Regions, buffers, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeObjects ( + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiInitializeObjects); + + + /* + * Run all _REG methods + * + * Note: Any objects accessed by the _REG methods will be automatically + * initialized, even if they contain executable AML (see the call to + * AcpiNsInitializeObjects below). + */ + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Executing _REG OpRegion methods\n")); + + Status = AcpiEvInitializeOpRegions (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Execute any module-level code that was detected during the table load + * phase. Although illegal since ACPI 2.0, there are many machines that + * contain this type of code. Each block of detected executable AML code + * outside of any control method is wrapped with a temporary control + * method object and placed on a global list. The methods on this list + * are executed below. + */ + AcpiNsExecModuleCodeList (); + + /* + * Initialize the objects that remain uninitialized. This runs the + * executable AML that may be part of the declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + if (!(Flags & ACPI_NO_OBJECT_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); + + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize all device objects in the namespace. This runs the device + * _STA and _INI methods. + */ + if (!(Flags & ACPI_NO_DEVICE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); + + Status = AcpiNsInitializeDevices (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize the GPE blocks defined in the FADT (GPE block 0 and 1). + * The runtime GPEs are enabled here. + * + * This is where the _PRW methods are executed for the GPEs. These + * methods can only be executed after the SCI and Global Lock handlers are + * installed and initialized. + * + * GPEs can only be enabled after the _REG, _STA, and _INI methods have + * been run. This ensures that all Operation Regions and all Devices have + * been initialized and are ready. + */ + if (!(Flags & ACPI_NO_EVENT_INIT)) + { + Status = AcpiEvInstallFadtGpes (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* + * Empty the caches (delete the cached objects) on the assumption that + * the table load filled them up more than they will be at runtime -- + * thus wasting non-paged memory. + */ + Status = AcpiPurgeCachedObjects (); + + AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK; + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeObjects) + + +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiTerminate + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTerminate ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiTerminate); + + + /* Just exit if subsystem is already shutdown */ + + if (AcpiGbl_Shutdown) + { + ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated")); + return_ACPI_STATUS (AE_OK); + } + + /* Subsystem appears active, go ahead and shut it down */ + + AcpiGbl_Shutdown = TRUE; + AcpiGbl_StartupFlags = 0; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); + + /* Terminate the AML Debugger if present */ + + ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE); + + /* Shutdown and free all resources */ + + AcpiUtSubsystemShutdown (); + + /* Free the mutex objects */ + + AcpiUtMutexTerminate (); + + +#ifdef ACPI_DEBUGGER + + /* Shut down the debugger */ + + AcpiDbTerminate (); +#endif + + /* Now we can shutdown the OS-dependent layer */ + + Status = AcpiOsTerminate (); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiTerminate) + + +#ifndef ACPI_ASL_COMPILER +/******************************************************************************* + * + * FUNCTION: AcpiSubsystemStatus + * + * PARAMETERS: None + * + * RETURN: Status of the ACPI subsystem + * + * DESCRIPTION: Other drivers that use the ACPI subsystem should call this + * before making any other calls, to ensure the subsystem + * initialized successfully. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSubsystemStatus ( + void) +{ + + if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK) + { + return (AE_OK); + } + else + { + return (AE_ERROR); + } +} + +ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetSystemInfo + * + * PARAMETERS: OutBuffer - A buffer to receive the resources for the + * device + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get information about the current + * state of the ACPI subsystem. It will return system information + * in the OutBuffer. + * + * If the function fails an appropriate status will be returned + * and the value of OutBuffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSystemInfo ( + ACPI_BUFFER *OutBuffer) +{ + ACPI_SYSTEM_INFO *InfoPtr; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetSystemInfo); + + + /* Parameter validation */ + + Status = AcpiUtValidateBuffer (OutBuffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Populate the return buffer + */ + InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; + + InfoPtr->AcpiCaVersion = ACPI_CA_VERSION; + + /* System flags (ACPI capabilities) */ + + InfoPtr->Flags = ACPI_SYS_MODE_ACPI; + + /* Timer resolution - 24 or 32 bits */ + + if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) + { + InfoPtr->TimerResolution = 24; + } + else + { + InfoPtr->TimerResolution = 32; + } + + /* Clear the reserved fields */ + + InfoPtr->Reserved1 = 0; + InfoPtr->Reserved2 = 0; + + /* Current debug levels */ + + InfoPtr->DebugLayer = AcpiDbgLayer; + InfoPtr->DebugLevel = AcpiDbgLevel; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetStatistics + * + * PARAMETERS: Stats - Where the statistics are returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: Get the contents of the various system counters + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetStatistics ( + ACPI_STATISTICS *Stats) +{ + ACPI_FUNCTION_TRACE (AcpiGetStatistics); + + + /* Parameter validation */ + + if (!Stats) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Various interrupt-based event counters */ + + Stats->SciCount = AcpiSciCount; + Stats->GpeCount = AcpiGpeCount; + + ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount, + sizeof (AcpiFixedEventCount)); + + + /* Other counters */ + + Stats->MethodCount = AcpiMethodCount; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetStatistics) + + +/***************************************************************************** + * + * FUNCTION: AcpiInstallInitializationHandler + * + * PARAMETERS: Handler - Callback procedure + * Function - Not (currently) used, see below + * + * RETURN: Status + * + * DESCRIPTION: Install an initialization handler + * + * TBD: When a second function is added, must save the Function also. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiInstallInitializationHandler ( + ACPI_INIT_HANDLER Handler, + UINT32 Function) +{ + + if (!Handler) + { + return (AE_BAD_PARAMETER); + } + + if (AcpiGbl_InitHandler) + { + return (AE_ALREADY_EXISTS); + } + + AcpiGbl_InitHandler = Handler; + return AE_OK; +} + +ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler) + + +/***************************************************************************** + * + * FUNCTION: AcpiPurgeCachedObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Empty all caches (delete the cached objects) + * + ****************************************************************************/ + +ACPI_STATUS +AcpiPurgeCachedObjects ( + void) +{ + ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects); + + (void) AcpiOsPurgeCache (AcpiGbl_StateCache); + (void) AcpiOsPurgeCache (AcpiGbl_OperandCache); + (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache); + (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache); + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects) + +#endif /* ACPI_ASL_COMPILER */ + diff --git a/reactos/drivers/bus/acpi/acpienum.c b/reactos/drivers/bus/acpi/acpienum.c new file mode 100644 index 00000000000..50ab9eeee4b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpienum.c @@ -0,0 +1,151 @@ +/* $Id: acpienum.c 21698 2006-04-22 05:55:17Z tretiakov $ + * + * PROJECT: ReactOS ACPI bus driver + * FILE: acpi/ospm/acpienum.c + * PURPOSE: ACPI namespace enumerator + * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) + * UPDATE HISTORY: + * 01-05-2001 CSH Created + */ +#include +#include +#include +#include +#include + +//#define NDEBUG +#include + +#define HAS_CHILDREN(d) ((d)->children.next != &((d)->children)) +#define HAS_SIBLINGS(d) (((d)->parent) && ((d)->node.next != &(d)->parent->children)) +#define NODE_TO_DEVICE(n) (list_entry(n, struct acpi_device, node)) + +extern struct acpi_device *acpi_root; + +NTSTATUS +Bus_PlugInDevice ( + struct acpi_device *Device, + PFDO_DEVICE_DATA FdoData + ) +{ + PDEVICE_OBJECT pdo; + PPDO_DEVICE_DATA pdoData; + NTSTATUS status; + ULONG index; + WCHAR temp[256]; + PLIST_ENTRY entry; + + PAGED_CODE (); + + /* Check we didnt add this already */ + for (entry = FdoData->ListOfPDOs.Flink; + entry != &FdoData->ListOfPDOs; entry = entry->Flink) + { + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + //dont duplicate devices + if(pdoData->AcpiHandle == Device->handle) + return STATUS_SUCCESS; + } + + DPRINT("Exposing PDO\n" + "======AcpiHandle: %p\n" + "======HardwareId: %s\n", + Device->handle, + Device->pnp.hardware_id); + + + // + // Create the PDO + // + + DPRINT("FdoData->NextLowerDriver = 0x%p\n", FdoData->NextLowerDriver); + + status = IoCreateDevice(FdoData->Common.Self->DriverObject, + sizeof(PDO_DEVICE_DATA), + NULL, + FILE_DEVICE_CONTROLLER, + FILE_AUTOGENERATED_DEVICE_NAME, + FALSE, + &pdo); + + if (!NT_SUCCESS (status)) { + return status; + } + + pdoData = (PPDO_DEVICE_DATA) pdo->DeviceExtension; + pdoData->AcpiHandle = Device->handle; + + // + // Copy the hardware IDs + // + index = 0; + index += swprintf(&temp[index], + L"ACPI\\%hs", + Device->pnp.hardware_id); + index++; + + index += swprintf(&temp[index], + L"*%hs", + Device->pnp.hardware_id); + index++; + temp[index] = UNICODE_NULL; + + pdoData->HardwareIDs = ExAllocatePool(NonPagedPool, index*sizeof(WCHAR)); + + + if (!pdoData->HardwareIDs) { + IoDeleteDevice(pdo); + return STATUS_INSUFFICIENT_RESOURCES; + } + + RtlCopyMemory (pdoData->HardwareIDs, temp, index*sizeof(WCHAR)); + Bus_InitializePdo (pdo, FdoData); + + // + // Device Relation changes if a new pdo is created. So let + // the PNP system now about that. This forces it to send bunch of pnp + // queries and cause the function driver to be loaded. + // + + //IoInvalidateDeviceRelations (FdoData->UnderlyingPDO, BusRelations); + + return status; +} + + +/* looks alot like acpi_bus_walk doesnt it */ +NTSTATUS +ACPIEnumerateDevices(PFDO_DEVICE_DATA DeviceExtension) +{ + ULONG Count = 0; + struct acpi_device *Device = acpi_root; + + while(Device) + { + if (Device->status.present && Device->status.enabled && + Device->flags.hardware_id) + { + Bus_PlugInDevice(Device, DeviceExtension); + Count++; + } + + if (HAS_CHILDREN(Device)) { + Device = NODE_TO_DEVICE(Device->children.next); + continue; + } + if (HAS_SIBLINGS(Device)) { + Device = NODE_TO_DEVICE(Device->node.next); + continue; + } + while ((Device = Device->parent)) { + if (HAS_SIBLINGS(Device)) { + Device = NODE_TO_DEVICE(Device->node.next); + break; + } + } + } + DPRINT("acpi device count: %d\n", Count); + return STATUS_SUCCESS; +} + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/busmgr/bus.c b/reactos/drivers/bus/acpi/busmgr/bus.c new file mode 100644 index 00000000000..88589023365 --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/bus.c @@ -0,0 +1,1849 @@ +/* + * acpi_bus.c - ACPI Bus Driver ($Revision: 80 $) + * + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + + /* + * Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#include + +#include +#include +#include +#include + +//#define NDEBUG +#include + +#define _COMPONENT ACPI_BUS_COMPONENT +ACPI_MODULE_NAME ("acpi_bus") + +#define WALK_UP 0 +#define WALK_DOWN 1 + +#define STRUCT_TO_INT(s) (*((int*)&s)) +#define HAS_CHILDREN(d) ((d)->children.next != &((d)->children)) +#define HAS_SIBLINGS(d) (((d)->parent) && ((d)->node.next != &(d)->parent->children)) +#define NODE_TO_DEVICE(n) (list_entry(n, struct acpi_device, node)) + +extern int event_is_open; +extern void acpi_pic_sci_set_trigger(unsigned int irq, UINT16 trigger); + +typedef int (*acpi_bus_walk_callback)(struct acpi_device*, int, void*); + +struct acpi_device *acpi_root; +KSPIN_LOCK acpi_bus_event_lock; +LIST_HEAD(acpi_bus_event_list); +//DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue); + + +static int +acpi_device_register ( + struct acpi_device *device, + struct acpi_device *parent) +{ + int result = 0; + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + return_VALUE(result); +} + + +static int +acpi_device_unregister ( + struct acpi_device *device) +{ + if (!device) + return_VALUE(AE_BAD_PARAMETER); + +#ifdef CONFIG_LDM + put_device(&device->dev); +#endif /*CONFIG_LDM*/ + + return_VALUE(0); +} + + +/* -------------------------------------------------------------------------- + Device Management + -------------------------------------------------------------------------- */ + +void +acpi_bus_data_handler ( + ACPI_HANDLE handle, + void *context) +{ + DPRINT1("acpi_bus_data_handler not implemented"); + + /* TBD */ + + return; +} + + +int +acpi_bus_get_device ( + ACPI_HANDLE handle, + struct acpi_device **device) +{ + ACPI_STATUS status = AE_OK; + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + /* TBD: Support fixed-feature devices */ + + status = AcpiGetData(handle, acpi_bus_data_handler, (void**)device); + if (ACPI_FAILURE(status) || !*device) { + DPRINT( "Error getting context for object [%p]\n", + handle); + return_VALUE(AE_NOT_FOUND); + } + + return 0; +} + +ACPI_STATUS acpi_bus_get_status_handle(ACPI_HANDLE handle, + unsigned long long *sta) +{ + ACPI_STATUS status; + + status = acpi_evaluate_integer(handle, "_STA", NULL, sta); + if (ACPI_SUCCESS(status)) + return AE_OK; + + if (status == AE_NOT_FOUND) { + *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | + ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; + return AE_OK; + } + return status; +} + +int +acpi_bus_get_status ( + struct acpi_device *device) +{ + ACPI_STATUS status; + unsigned long long sta; + + status = acpi_bus_get_status_handle(device->handle, &sta); + if (ACPI_FAILURE(status)) + return -1; + + STRUCT_TO_INT(device->status) = (int) sta; + + if (device->status.functional && !device->status.present) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " + "functional but not present;\n", + device->pnp.bus_id, + (UINT32) STRUCT_TO_INT(device->status))); + } + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", + device->pnp.bus_id, + (UINT32) STRUCT_TO_INT(device->status))); + return 0; +} + +void acpi_bus_private_data_handler(ACPI_HANDLE handle, + void *context) +{ + return; +} + +int acpi_bus_get_private_data(ACPI_HANDLE handle, void **data) +{ + ACPI_STATUS status = AE_OK; + + if (!*data) + return -1; + + status = AcpiGetData(handle, acpi_bus_private_data_handler, data); + if (ACPI_FAILURE(status) || !*data) { + DPRINT("No context for object [%p]\n", handle); + return -1; + } + + return 0; +} +/* -------------------------------------------------------------------------- + Power Management + -------------------------------------------------------------------------- */ + +int +acpi_bus_get_power ( + ACPI_HANDLE handle, + int *state) +{ + int result = 0; + ACPI_STATUS status = 0; + struct acpi_device *device = NULL; + unsigned long long psc = 0; + + result = acpi_bus_get_device(handle, &device); + if (result) + return_VALUE(result); + + *state = ACPI_STATE_UNKNOWN; + + if (!device->flags.power_manageable) { + /* TBD: Non-recursive algorithm for walking up hierarchy */ + if (device->parent) + *state = device->parent->power.state; + else + *state = ACPI_STATE_D0; + } + else { + /* + * Get the device's power state either directly (via _PSC) or + * indirectly (via power resources). + */ + if (device->power.flags.explicit_get) { + status = acpi_evaluate_integer(device->handle, "_PSC", + NULL, &psc); + if (ACPI_FAILURE(status)) + return_VALUE(AE_NOT_FOUND); + device->power.state = (int) psc; + } + else if (device->power.flags.power_resources) { + result = acpi_power_get_inferred_state(device); + if (result) + return_VALUE(result); + } + + *state = device->power.state; + } + + DPRINT("Device [%s] power state is D%d\n", + device->pnp.bus_id, device->power.state); + + return_VALUE(0); +} + + +int +acpi_bus_set_power ( + ACPI_HANDLE handle, + int state) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_device *device = NULL; + char object_name[5] = {'_','P','S','0'+state,'\0'}; + + + result = acpi_bus_get_device(handle, &device); + if (result) + return_VALUE(result); + + if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) + return_VALUE(AE_BAD_PARAMETER); + + /* Make sure this is a valid target state */ + + if (!device->flags.power_manageable) { + DPRINT1( "Device is not power manageable\n"); + return_VALUE(AE_NOT_FOUND); + } + /* + * Get device's current power state + */ + //if (!acpi_power_nocheck) { + /* + * Maybe the incorrect power state is returned on the bogus + * bios, which is different with the real power state. + * For example: the bios returns D0 state and the real power + * state is D3. OS expects to set the device to D0 state. In + * such case if OS uses the power state returned by the BIOS, + * the device can't be transisted to the correct power state. + * So if the acpi_power_nocheck is set, it is unnecessary to + * get the power state by calling acpi_bus_get_power. + */ + acpi_bus_get_power(device->handle, &device->power.state); + //} + + if ((state == device->power.state) && !device->flags.force_power_state) { + DPRINT1("Device is already at D%d\n", state); + return 0; + } + if (!device->power.states[state].flags.valid) { + DPRINT1( "Device does not support D%d\n", state); + return AE_NOT_FOUND; + } + if (device->parent && (state < device->parent->power.state)) { + DPRINT1( "Cannot set device to a higher-powered state than parent\n"); + return AE_NOT_FOUND; + } + + /* + * Transition Power + * ---------------- + * On transitions to a high-powered state we first apply power (via + * power resources) then evalute _PSx. Conversly for transitions to + * a lower-powered state. + */ + if (state < device->power.state) { + if (device->power.flags.power_resources) { + result = acpi_power_transition(device, state); + if (result) + goto end; + } + if (device->power.states[state].flags.explicit_set) { + status = AcpiEvaluateObject(device->handle, + object_name, NULL, NULL); + if (ACPI_FAILURE(status)) { + result = AE_NOT_FOUND; + goto end; + } + } + } + else { + if (device->power.states[state].flags.explicit_set) { + status = AcpiEvaluateObject(device->handle, + object_name, NULL, NULL); + if (ACPI_FAILURE(status)) { + result = AE_NOT_FOUND; + goto end; + } + } + if (device->power.flags.power_resources) { + result = acpi_power_transition(device, state); + if (result) + goto end; + } + } + +end: + if (result) + DPRINT( "Error transitioning device [%s] to D%d\n", + device->pnp.bus_id, state); + else + DPRINT("Device [%s] transitioned to D%d\n", + device->pnp.bus_id, state); + + return result; +} + +BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle) +{ + struct acpi_device *device; + int result; + + result = acpi_bus_get_device(handle, &device); + return result ? 0 : device->flags.power_manageable; +} + +BOOLEAN acpi_bus_can_wakeup(ACPI_HANDLE handle) +{ + struct acpi_device *device; + int result; + + result = acpi_bus_get_device(handle, &device); + return result ? 0 : device->wakeup.flags.valid; +} + +static int +acpi_bus_get_power_flags ( + struct acpi_device *device) +{ + ACPI_STATUS status = 0; + ACPI_HANDLE handle = 0; + UINT32 i = 0; + + if (!device) + return AE_NOT_FOUND; + + /* + * Power Management Flags + */ + status = AcpiGetHandle(device->handle, "_PSC", &handle); + if (ACPI_SUCCESS(status)) + device->power.flags.explicit_get = 1; + status = AcpiGetHandle(device->handle, "_IRC", &handle); + if (ACPI_SUCCESS(status)) + device->power.flags.inrush_current = 1; + status = AcpiGetHandle(device->handle, "_PRW", &handle); + if (ACPI_SUCCESS(status)) + device->flags.wake_capable = 1; + + /* + * Enumerate supported power management states + */ + for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { + struct acpi_device_power_state *ps = &device->power.states[i]; + char object_name[5] = {'_','P','R','0'+i,'\0'}; + + /* Evaluate "_PRx" to se if power resources are referenced */ + acpi_evaluate_reference(device->handle, object_name, NULL, + &ps->resources); + if (ps->resources.count) { + device->power.flags.power_resources = 1; + ps->flags.valid = 1; + } + + /* Evaluate "_PSx" to see if we can do explicit sets */ + object_name[2] = 'S'; + status = AcpiGetHandle(device->handle, object_name, &handle); + if (ACPI_SUCCESS(status)) { + ps->flags.explicit_set = 1; + ps->flags.valid = 1; + } + + /* State is valid if we have some power control */ + if (ps->resources.count || ps->flags.explicit_set) + ps->flags.valid = 1; + + ps->power = -1; /* Unknown - driver assigned */ + ps->latency = -1; /* Unknown - driver assigned */ + } + + /* Set defaults for D0 and D3 states (always valid) */ + device->power.states[ACPI_STATE_D0].flags.valid = 1; + device->power.states[ACPI_STATE_D0].power = 100; + device->power.states[ACPI_STATE_D3].flags.valid = 1; + device->power.states[ACPI_STATE_D3].power = 0; + + device->power.state = ACPI_STATE_UNKNOWN; + + return 0; +} + +/* -------------------------------------------------------------------------- + Performance Management + -------------------------------------------------------------------------- */ + +static int +acpi_bus_get_perf_flags ( + struct acpi_device *device) +{ + if (!device) + return AE_NOT_FOUND; + + device->performance.state = ACPI_STATE_UNKNOWN; + + return 0; +} + + +/* -------------------------------------------------------------------------- + Event Management + -------------------------------------------------------------------------- */ + + +int +acpi_bus_generate_event ( + struct acpi_device *device, + UINT8 type, + int data) +{ + struct acpi_bus_event *event = NULL; + //unsigned long flags = 0; + + DPRINT1("acpi_bus_generate_event"); + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + /* drop event on the floor if no one's listening */ + //if (!event_is_open) + // return_VALUE(0); + + event = ExAllocatePool(NonPagedPool,sizeof(struct acpi_bus_event)); + if (!event) + return_VALUE(-4); + + sprintf(event->device_class, "%s", device->pnp.device_class); + sprintf(event->bus_id, "%s", device->pnp.bus_id); + event->type = type; + event->data = data; + + //spin_lock_irqsave(&acpi_bus_event_lock, flags); + list_add_tail(&event->node, &acpi_bus_event_list); + //spin_unlock_irqrestore(&acpi_bus_event_lock, flags); + + //wake_up_interruptible(&acpi_bus_event_queue); + + return_VALUE(0); +} + +int +acpi_bus_receive_event ( + struct acpi_bus_event *event) +{ + //unsigned long flags = 0; + //struct acpi_bus_event *entry = NULL; + + //DECLARE_WAITQUEUE(wait, current); + + DPRINT1("acpi_bus_receive_event"); + + //if (!event) + // return AE_BAD_PARAMETER; + + //if (list_empty(&acpi_bus_event_list)) { + + // set_current_state(TASK_INTERRUPTIBLE); + // add_wait_queue(&acpi_bus_event_queue, &wait); + + // if (list_empty(&acpi_bus_event_list)) + // schedule(); + + // remove_wait_queue(&acpi_bus_event_queue, &wait); + // set_current_state(TASK_RUNNING); + + // if (signal_pending(current)) + // return_VALUE(-ERESTARTSYS); + //} + + //spin_lock_irqsave(&acpi_bus_event_lock, flags); + //entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node); + //if (entry) + // list_del(&entry->node); + //spin_unlock_irqrestore(&acpi_bus_event_lock, flags); + + //if (!entry) + // return_VALUE(AE_NOT_FOUND); + + //memcpy(event, entry, sizeof(struct acpi_bus_event)); + + //kfree(entry); + UNIMPLEMENTED; + return_VALUE(0); +} + + +/* -------------------------------------------------------------------------- + Namespace Management + -------------------------------------------------------------------------- */ + + +/** + * acpi_bus_walk + * ------------- + * Used to walk the ACPI Bus's device namespace. Can walk down (depth-first) + * or up. Able to parse starting at any node in the namespace. Note that a + * callback return value of -249 will terminate the walk. + * + * @start: starting point + * callback: function to call for every device encountered while parsing + * direction: direction to parse (up or down) + * @data: context for this search operation + */ +static int +acpi_bus_walk ( + struct acpi_device *start, + acpi_bus_walk_callback callback, + int direction, + void *data) +{ + int result = 0; + int level = 0; + struct acpi_device *device = NULL; + + if (!start || !callback) + return AE_BAD_PARAMETER; + + device = start; + + /* + * Parse Namespace + * --------------- + * Parse a given subtree (specified by start) in the given direction. + * Walking 'up' simply means that we execute the callback on leaf + * devices prior to their parents (useful for things like removing + * or powering down a subtree). + */ + + while (device) { + + if (direction == WALK_DOWN) + if (-249 == callback(device, level, data)) + break; + + /* Depth First */ + + if (HAS_CHILDREN(device)) { + device = NODE_TO_DEVICE(device->children.next); + ++level; + continue; + } + + if (direction == WALK_UP) + if (-249 == callback(device, level, data)) + break; + + /* Now Breadth */ + + if (HAS_SIBLINGS(device)) { + device = NODE_TO_DEVICE(device->node.next); + continue; + } + + /* Scope Exhausted - Find Next */ + + while ((device = device->parent)) { + --level; + if (HAS_SIBLINGS(device)) { + device = NODE_TO_DEVICE(device->node.next); + break; + } + } + } + + if ((direction == WALK_UP) && (result == 0)) + callback(start, level, data); + + return result; +} + + +/* -------------------------------------------------------------------------- + Notification Handling + -------------------------------------------------------------------------- */ + +static void +acpi_bus_check_device (ACPI_HANDLE handle) +{ + struct acpi_device *device; + ACPI_STATUS status = 0; + struct acpi_device_status old_status; + + if (acpi_bus_get_device(handle, &device)) + return; + if (!device) + return; + + old_status = device->status; + + /* + * Make sure this device's parent is present before we go about + * messing with the device. + */ + if (device->parent && !device->parent->status.present) { + device->status = device->parent->status; + return; + } + + status = acpi_bus_get_status(device); + if (ACPI_FAILURE(status)) + return; + + if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) + return; + + + /* + * Device Insertion/Removal + */ + if ((device->status.present) && !(old_status.present)) { + DPRINT("Device insertion detected\n"); + /* TBD: Handle device insertion */ + } + else if (!(device->status.present) && (old_status.present)) { + DPRINT("Device removal detected\n"); + /* TBD: Handle device removal */ + } + +} + + +static void +acpi_bus_check_scope (ACPI_HANDLE handle) +{ + /* Status Change? */ + acpi_bus_check_device(handle); + + /* + * TBD: Enumerate child devices within this device's scope and + * run acpi_bus_check_device()'s on them. + */ +} + + +/** + * acpi_bus_notify + * --------------- + * Callback for all 'system-level' device notifications (values 0x00-0x7F). + */ +static void +acpi_bus_notify ( + ACPI_HANDLE handle, + UINT32 type, + void *data) +{ + struct acpi_device *device = NULL; + struct acpi_driver *driver; + + DPRINT1("Notification %#02x to handle %p\n", type, handle); + + //blocking_notifier_call_chain(&acpi_bus_notify_list, + // type, (void *)handle); + + switch (type) { + + case ACPI_NOTIFY_BUS_CHECK: + DPRINT("Received BUS CHECK notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_scope(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_DEVICE_CHECK: + DPRINT("Received DEVICE CHECK notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_device(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_DEVICE_WAKE: + DPRINT("Received DEVICE WAKE notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_device(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_EJECT_REQUEST: + DPRINT1("Received EJECT REQUEST notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_DEVICE_CHECK_LIGHT: + DPRINT1("Received DEVICE CHECK LIGHT notification for device [%s]\n", + device->pnp.bus_id); + /* TBD: Exactly what does 'light' mean? */ + break; + + case ACPI_NOTIFY_FREQUENCY_MISMATCH: + DPRINT1("Received FREQUENCY MISMATCH notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_BUS_MODE_MISMATCH: + DPRINT1("Received BUS MODE MISMATCH notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_POWER_FAULT: + DPRINT1("Received POWER FAULT notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + default: + DPRINT1("Received unknown/unsupported notification [%08x]\n", + type); + break; + } + + acpi_bus_get_device(handle, &device); + if (device) { + driver = device->driver; + if (driver && driver->ops.notify && + (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS)) + driver->ops.notify(device, type); + } +} + + +/* -------------------------------------------------------------------------- + Driver Management + -------------------------------------------------------------------------- */ + + +static LIST_HEAD(acpi_bus_drivers); +//static DECLARE_MUTEX(acpi_bus_drivers_lock); + + +/** + * acpi_bus_match + * -------------- + * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it + * matches the specified driver's criteria. + */ +static int +acpi_bus_match ( + struct acpi_device *device, + struct acpi_driver *driver) +{ + int error = 0; + + if (device->flags.hardware_id) + if (strstr(driver->ids, device->pnp.hardware_id)) + goto Done; + + if (device->flags.compatible_ids) { + ACPI_DEVICE_ID_LIST *cid_list = device->pnp.cid_list; + int i; + + /* compare multiple _CID entries against driver ids */ + for (i = 0; i < cid_list->Count; i++) + { + if (strstr(driver->ids, cid_list->Ids[i].String)) + goto Done; + } + } + error = -2; + + Done: + + return error; +} + + +/** + * acpi_bus_driver_init + * -------------------- + * Used to initialize a device via its device driver. Called whenever a + * driver is bound to a device. Invokes the driver's add() and start() ops. + */ +static int +acpi_bus_driver_init ( + struct acpi_device *device, + struct acpi_driver *driver) +{ + int result = 0; + + if (!device || !driver) + return_VALUE(AE_BAD_PARAMETER); + + if (!driver->ops.add) + return_VALUE(-38); + + result = driver->ops.add(device); + if (result) { + device->driver = NULL; + //acpi_driver_data(device) = NULL; + return_VALUE(result); + } + + device->driver = driver; + + /* + * TBD - Configuration Management: Assign resources to device based + * upon possible configuration and currently allocated resources. + */ + + if (driver->ops.start) { + result = driver->ops.start(device); + if (result && driver->ops.remove) + driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); + return_VALUE(result); + } + + DPRINT("Driver successfully bound to device\n"); + + if (driver->ops.scan) { + driver->ops.scan(device); + } + + return_VALUE(0); +} + + +/** + * acpi_bus_attach + * ------------- + * Callback for acpi_bus_walk() used to find devices that match a specific + * driver's criteria and then attach the driver. + */ +static int +acpi_bus_attach ( + struct acpi_device *device, + int level, + void *data) +{ + int result = 0; + struct acpi_driver *driver = NULL; + + if (!device || !data) + return_VALUE(AE_BAD_PARAMETER); + + driver = (struct acpi_driver *) data; + + if (device->driver) + return_VALUE(-9); + + if (!device->status.present) + return_VALUE(AE_NOT_FOUND); + + result = acpi_bus_match(device, driver); + if (result) + return_VALUE(result); + + DPRINT("Found driver [%s] for device [%s]\n", + driver->name, device->pnp.bus_id); + + result = acpi_bus_driver_init(device, driver); + if (result) + return_VALUE(result); + + //down(&acpi_bus_drivers_lock); + ++driver->references; + //up(&acpi_bus_drivers_lock); + + return_VALUE(0); +} + + +/** + * acpi_bus_unattach + * ----------------- + * Callback for acpi_bus_walk() used to find devices that match a specific + * driver's criteria and unattach the driver. + */ +static int +acpi_bus_unattach ( + struct acpi_device *device, + int level, + void *data) +{ + int result = 0; + struct acpi_driver *driver = (struct acpi_driver *) data; + + if (!device || !driver) + return_VALUE(AE_BAD_PARAMETER); + + if (device->driver != driver) + return_VALUE(-6); + + if (!driver->ops.remove) + return_VALUE(-23); + + result = driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); + if (result) + return_VALUE(result); + + device->driver = NULL; + acpi_driver_data(device) = NULL; + + //down(&acpi_bus_drivers_lock); + driver->references--; + //up(&acpi_bus_drivers_lock); + + return_VALUE(0); +} + + +/** + * acpi_bus_find_driver + * -------------------- + * Parses the list of registered drivers looking for a driver applicable for + * the specified device. + */ +static int +acpi_bus_find_driver ( + struct acpi_device *device) +{ + int result = AE_NOT_FOUND; + struct list_head *entry = NULL; + struct acpi_driver *driver = NULL; + + if (!device || device->driver) + return_VALUE(AE_BAD_PARAMETER); + + //down(&acpi_bus_drivers_lock); + + list_for_each(entry, &acpi_bus_drivers) { + + driver = list_entry(entry, struct acpi_driver, node); + + if (acpi_bus_match(device, driver)) + continue; + + result = acpi_bus_driver_init(device, driver); + if (!result) + ++driver->references; + + break; + } + + //up(&acpi_bus_drivers_lock); + + return_VALUE(result); +} + + +/** + * acpi_bus_register_driver + * ------------------------ + * Registers a driver with the ACPI bus. Searches the namespace for all + * devices that match the driver's criteria and binds. + */ +int +acpi_bus_register_driver ( + struct acpi_driver *driver) +{ + if (!driver) + return_VALUE(AE_BAD_PARAMETER); + + //if (acpi_disabled) + // return_VALUE(AE_NOT_FOUND); + + //down(&acpi_bus_drivers_lock); + list_add_tail(&driver->node, &acpi_bus_drivers); + //up(&acpi_bus_drivers_lock); + + acpi_bus_walk(acpi_root, acpi_bus_attach, + WALK_DOWN, driver); + + return_VALUE(driver->references); +} + + +/** + * acpi_bus_unregister_driver + * -------------------------- + * Unregisters a driver with the ACPI bus. Searches the namespace for all + * devices that match the driver's criteria and unbinds. + */ +void +acpi_bus_unregister_driver ( + struct acpi_driver *driver) +{ + if (!driver) + return; + + acpi_bus_walk(acpi_root, acpi_bus_unattach, WALK_UP, driver); + + if (driver->references) + return; + + //down(&acpi_bus_drivers_lock); + list_del(&driver->node); + //up(&acpi_bus_drivers_lock); + + return; +} + + +/* -------------------------------------------------------------------------- + Device Enumeration + -------------------------------------------------------------------------- */ + +static int +acpi_bus_get_flags ( + struct acpi_device *device) +{ + ACPI_STATUS status = AE_OK; + ACPI_HANDLE temp = NULL; + + /* Presence of _STA indicates 'dynamic_status' */ + status = AcpiGetHandle(device->handle, "_STA", &temp); + if (ACPI_SUCCESS(status)) + device->flags.dynamic_status = 1; + + /* Presence of _CID indicates 'compatible_ids' */ + status = AcpiGetHandle(device->handle, "_CID", &temp); + if (ACPI_SUCCESS(status)) + device->flags.compatible_ids = 1; + + /* Presence of _RMV indicates 'removable' */ + status = AcpiGetHandle(device->handle, "_RMV", &temp); + if (ACPI_SUCCESS(status)) + device->flags.removable = 1; + + /* Presence of _EJD|_EJ0 indicates 'ejectable' */ + status = AcpiGetHandle(device->handle, "_EJD", &temp); + if (ACPI_SUCCESS(status)) + device->flags.ejectable = 1; + else { + status = AcpiGetHandle(device->handle, "_EJ0", &temp); + if (ACPI_SUCCESS(status)) + device->flags.ejectable = 1; + } + + /* Presence of _LCK indicates 'lockable' */ + status = AcpiGetHandle(device->handle, "_LCK", &temp); + if (ACPI_SUCCESS(status)) + device->flags.lockable = 1; + + /* Presence of _PS0|_PR0 indicates 'power manageable' */ + status = AcpiGetHandle(device->handle, "_PS0", &temp); + if (ACPI_FAILURE(status)) + status = AcpiGetHandle(device->handle, "_PR0", &temp); + if (ACPI_SUCCESS(status)) + device->flags.power_manageable = 1; + + /* TBD: Peformance management */ + + return_VALUE(0); +} + + +int +acpi_bus_add ( + struct acpi_device **child, + struct acpi_device *parent, + ACPI_HANDLE handle, + int type) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_device *device = NULL; + char bus_id[5] = {'?',0}; + ACPI_BUFFER buffer; + ACPI_DEVICE_INFO *info; + char *hid = NULL; + char *uid = NULL; + ACPI_DEVICE_ID_LIST *cid_list = NULL; + int i = 0; + + if (!child) + return_VALUE(AE_BAD_PARAMETER); + + device = ExAllocatePool(NonPagedPool,sizeof(struct acpi_device)); + if (!device) { + DPRINT1("Memory allocation error\n"); + return_VALUE(-12); + } + memset(device, 0, sizeof(struct acpi_device)); + + device->handle = handle; + device->parent = parent; + + /* + * Bus ID + * ------ + * The device's Bus ID is simply the object name. + * TBD: Shouldn't this value be unique (within the ACPI namespace)? + */ + switch (type) { + case ACPI_BUS_TYPE_SYSTEM: + sprintf(device->pnp.bus_id, "%s", "ACPI"); + break; + case ACPI_BUS_TYPE_POWER_BUTTON: + sprintf(device->pnp.bus_id, "%s", "PWRF"); + break; + case ACPI_BUS_TYPE_SLEEP_BUTTON: + sprintf(device->pnp.bus_id, "%s", "SLPF"); + break; + default: + buffer.Length = sizeof(bus_id); + buffer.Pointer = bus_id; + AcpiGetName(handle, ACPI_SINGLE_NAME, &buffer); + + + /* Clean up trailing underscores (if any) */ + for (i = 3; i > 1; i--) { + if (bus_id[i] == '_') + bus_id[i] = '\0'; + else + break; + } + sprintf(device->pnp.bus_id, "%s", bus_id); + buffer.Pointer = NULL; + break; + } + + /* + * Flags + * ----- + * Get prior to calling acpi_bus_get_status() so we know whether + * or not _STA is present. Note that we only look for object + * handles -- cannot evaluate objects until we know the device is + * present and properly initialized. + */ + result = acpi_bus_get_flags(device); + if (result) + goto end; + + /* + * Status + * ------ + * See if the device is present. We always assume that non-Device() + * objects (e.g. thermal zones, power resources, processors, etc.) are + * present, functioning, etc. (at least when parent object is present). + * Note that _STA has a different meaning for some objects (e.g. + * power resources) so we need to be careful how we use it. + */ + switch (type) { + case ACPI_BUS_TYPE_DEVICE: + result = acpi_bus_get_status(device); + if (result) + goto end; + break; + default: + STRUCT_TO_INT(device->status) = 0x0F; + break; + } + if (!device->status.present) { + result = -2; + goto end; + } + + /* + * Initialize Device + * ----------------- + * TBD: Synch with Core's enumeration/initialization process. + */ + + /* + * Hardware ID, Unique ID, & Bus Address + * ------------------------------------- + */ + switch (type) { + case ACPI_BUS_TYPE_DEVICE: + status = AcpiGetObjectInfo(handle,&info); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error reading device info\n")); + result = AE_NOT_FOUND; + goto end; + } + if (info->Valid & ACPI_VALID_HID) + hid = info->HardwareId.String; + if (info->Valid & ACPI_VALID_UID) + uid = info->UniqueId.String; + if (info->Valid & ACPI_VALID_CID) { + cid_list = &info->CompatibleIdList; + device->pnp.cid_list = ExAllocatePool(NonPagedPool,cid_list->ListSize); + if (device->pnp.cid_list) + memcpy(device->pnp.cid_list, cid_list, cid_list->ListSize); + else + DPRINT("Memory allocation error\n"); + } + if (info->Valid & ACPI_VALID_ADR) { + device->pnp.bus_address = info->Address; + device->flags.bus_address = 1; + } + break; + case ACPI_BUS_TYPE_POWER: + hid = ACPI_POWER_HID; + break; + case ACPI_BUS_TYPE_PROCESSOR: + hid = ACPI_PROCESSOR_HID; + break; + case ACPI_BUS_TYPE_SYSTEM: + hid = ACPI_SYSTEM_HID; + break; + case ACPI_BUS_TYPE_THERMAL: + hid = ACPI_THERMAL_HID; + break; + case ACPI_BUS_TYPE_POWER_BUTTON: + hid = ACPI_BUTTON_HID_POWERF; + break; + case ACPI_BUS_TYPE_SLEEP_BUTTON: + hid = ACPI_BUTTON_HID_SLEEPF; + break; + } + + /* + * \_SB + * ---- + * Fix for the system root bus device -- the only root-level device. + */ + if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { + hid = ACPI_BUS_HID; + sprintf(device->pnp.device_name, "%s", ACPI_BUS_DEVICE_NAME); + sprintf(device->pnp.device_class, "%s", ACPI_BUS_CLASS); + } + + if (hid) { + sprintf(device->pnp.hardware_id, "%s", hid); + device->flags.hardware_id = 1; + } + if (uid) { + sprintf(device->pnp.unique_id, "%s", uid); + device->flags.unique_id = 1; + } + + /* + * If we called get_object_info, we now are finished with the buffer, + * so we can free it. + */ + //if (buffer.Pointer) + //AcpiOsFree(buffer.Pointer); + + /* + * Power Management + * ---------------- + */ + if (device->flags.power_manageable) { + result = acpi_bus_get_power_flags(device); + if (result) + goto end; + } + + /* + * Performance Management + * ---------------------- + */ + if (device->flags.performance_manageable) { + result = acpi_bus_get_perf_flags(device); + if (result) + goto end; + } + + /* + * Context + * ------- + * Attach this 'struct acpi_device' to the ACPI object. This makes + * resolutions from handle->device very efficient. Note that we need + * to be careful with fixed-feature devices as they all attach to the + * root object. + */ + switch (type) { + case ACPI_BUS_TYPE_POWER_BUTTON: + case ACPI_BUS_TYPE_SLEEP_BUTTON: + break; + default: + status = AcpiAttachData(device->handle, + acpi_bus_data_handler, device); + break; + } + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error attaching device data\n")); + result = AE_NOT_FOUND; + goto end; + } + + /* + * Linkage + * ------- + * Link this device to its parent and siblings. + */ + INIT_LIST_HEAD(&device->children); + if (!device->parent) + INIT_LIST_HEAD(&device->node); + else + list_add_tail(&device->node, &device->parent->children); + + /* + * Global Device Hierarchy: + * ------------------------ + * Register this device with the global device hierarchy. + */ + acpi_device_register(device, parent); + + /* + * Bind _ADR-Based Devices + * ----------------------- + * If there's a a bus address (_ADR) then we utilize the parent's + * 'bind' function (if exists) to bind the ACPI- and natively- + * enumerated device representations. + */ + if (device->flags.bus_address) { + if (device->parent && device->parent->ops.bind) + device->parent->ops.bind(device); + } + + /* + * Locate & Attach Driver + * ---------------------- + * If there's a hardware id (_HID) or compatible ids (_CID) we check + * to see if there's a driver installed for this kind of device. Note + * that drivers can install before or after a device is enumerated. + * + * TBD: Assumes LDM provides driver hot-plug capability. + */ + if (device->flags.hardware_id || device->flags.compatible_ids) + acpi_bus_find_driver(device); + +end: + if (result) { + if (device->pnp.cid_list) { + ExFreePool(device->pnp.cid_list); + } + ExFreePool(device); + return_VALUE(result); + } + *child = device; + + return_VALUE(0); +} + + +static int +acpi_bus_remove ( + struct acpi_device *device, + int type) +{ + + if (!device) + return_VALUE(AE_NOT_FOUND); + + acpi_device_unregister(device); + + if (device && device->pnp.cid_list) + ExFreePool(device->pnp.cid_list); + + if (device) + ExFreePool(device); + + return_VALUE(0); +} + + +int +acpi_bus_scan ( + struct acpi_device *start) +{ + ACPI_STATUS status = AE_OK; + struct acpi_device *parent = NULL; + struct acpi_device *child = NULL; + ACPI_HANDLE phandle = 0; + ACPI_HANDLE chandle = 0; + ACPI_OBJECT_TYPE type = 0; + UINT32 level = 1; + + if (!start) + return_VALUE(AE_BAD_PARAMETER); + + parent = start; + phandle = start->handle; + + /* + * Parse through the ACPI namespace, identify all 'devices', and + * create a new 'struct acpi_device' for each. + */ + while ((level > 0) && parent) { + + status = AcpiGetNextObject(ACPI_TYPE_ANY, phandle, + chandle, &chandle); + + /* + * If this scope is exhausted then move our way back up. + */ + if (ACPI_FAILURE(status)) { + level--; + chandle = phandle; + AcpiGetParent(phandle, &phandle); + if (parent->parent) + parent = parent->parent; + continue; + } + + status = AcpiGetType(chandle, &type); + if (ACPI_FAILURE(status)) + continue; + + /* + * If this is a scope object then parse it (depth-first). + */ + if (type == ACPI_TYPE_LOCAL_SCOPE) { + level++; + phandle = chandle; + chandle = 0; + continue; + } + + /* + * We're only interested in objects that we consider 'devices'. + */ + switch (type) { + case ACPI_TYPE_DEVICE: + type = ACPI_BUS_TYPE_DEVICE; + break; + case ACPI_TYPE_PROCESSOR: + type = ACPI_BUS_TYPE_PROCESSOR; + break; + case ACPI_TYPE_THERMAL: + type = ACPI_BUS_TYPE_THERMAL; + break; + case ACPI_TYPE_POWER: + type = ACPI_BUS_TYPE_POWER; + break; + default: + continue; + } + + status = acpi_bus_add(&child, parent, chandle, type); + if (ACPI_FAILURE(status)) + continue; + + /* + * If the device is present, enabled, and functioning then + * parse its scope (depth-first). Note that we need to + * represent absent devices to facilitate PnP notifications + * -- but only the subtree head (not all of its children, + * which will be enumerated when the parent is inserted). + * + * TBD: Need notifications and other detection mechanisms + * in place before we can fully implement this. + */ + if (child->status.present) { + status = AcpiGetNextObject(ACPI_TYPE_ANY, chandle, + 0, NULL); + if (ACPI_SUCCESS(status)) { + level++; + phandle = chandle; + chandle = 0; + parent = child; + } + } + } + + return_VALUE(0); +} + + +static int +acpi_bus_scan_fixed ( + struct acpi_device *root) +{ + int result = 0; + struct acpi_device *device = NULL; + + if (!root) + return_VALUE(AE_NOT_FOUND); + + /* + * Enumerate all fixed-feature devices. + */ + if (AcpiGbl_FADT.Flags & ACPI_FADT_POWER_BUTTON) + result = acpi_bus_add(&device, acpi_root, + NULL, ACPI_BUS_TYPE_POWER_BUTTON); + + if (AcpiGbl_FADT.Flags & ACPI_FADT_SLEEP_BUTTON) + result = acpi_bus_add(&device, acpi_root, + NULL, ACPI_BUS_TYPE_SLEEP_BUTTON); + + return_VALUE(result); +} + + +/* -------------------------------------------------------------------------- + Initialization/Cleanup + -------------------------------------------------------------------------- */ + +static int +acpi_bus_init_irq (void) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT arg = {ACPI_TYPE_INTEGER}; + ACPI_OBJECT_LIST arg_list = {1, &arg}; + //char *message = NULL; + + DPRINT("acpi_bus_init_irq"); + + /* + * Let the system know what interrupt model we are using by + * evaluating the \_PIC object, if exists. + */ + + //switch (acpi_irq_model) { + //case ACPI_IRQ_MODEL_PIC: + // message = "PIC"; + // break; + //case ACPI_IRQ_MODEL_IOAPIC: + // message = "IOAPIC"; + // break; + //case ACPI_IRQ_MODEL_IOSAPIC: + // message = "IOSAPIC"; + // break; + //default: + // DPRINT1("Unknown interrupt routing model\n"); + // return_VALUE(AE_NOT_FOUND); + //} + + //DPRINT("Using %s for interrupt routing\n", message); + + //arg.Integer.Value = acpi_irq_model; + + //status = AcpiEvaluateObject(NULL, "\\_PIC", &arg_list, NULL); + //if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { + // ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n")); + // return_VALUE(AE_NOT_FOUND); + //} + + return_VALUE(0); +} + + +//void +//acpi_early_init (void) +//{ +// ACPI_STATUS status = AE_OK; +// +// DPRINT("acpi_early_init"); +// +// if (acpi_disabled) +// return_VOID; +// + /* enable workarounds, unless strict ACPI spec. compliance */ +// if (!acpi_strict) +// acpi_gbl_enable_interpreter_slack = TRUE; +// +// status = acpi_reallocate_root_table(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to reallocate ACPI tables\n"); +// goto error0; +// } +// +// status = acpi_initialize_subsystem(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to initialize the ACPI Interpreter\n"); +// goto error0; +// } +// +// status = acpi_load_tables(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to load the System Description Tables\n"); +// goto error0; +// } +// +//#ifdef CONFIG_X86 +// if (!acpi_ioapic) { +// /* compatible (0) means level (3) */ +// if (!(acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)) { +// acpi_sci_flags &= ~ACPI_MADT_TRIGGER_MASK; +// acpi_sci_flags |= ACPI_MADT_TRIGGER_LEVEL; +// } +// /* Set PIC-mode SCI trigger type */ +// acpi_pic_sci_set_trigger(acpi_gbl_FADT.sci_interrupt, +// (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2); +// } else { +// /* +// * now that acpi_gbl_FADT is initialized, +// * update it with result from INT_SRC_OVR parsing +// */ +// acpi_gbl_FADT.sci_interrupt = acpi_sci_override_gsi; +// } +//#endif +// +// status = +// acpi_enable_subsystem(~ +// (ACPI_NO_HARDWARE_INIT | +// ACPI_NO_ACPI_ENABLE)); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); +// goto error0; +// } +// +// return; +// +// error0: +// disable_acpi(); +// return; +//} + +int +acpi_bus_init (void) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + + DPRINT("acpi_bus_init"); + + status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to start the ACPI Interpreter\n"); + goto error1; + } + + /* + * ACPI 2.0 requires the EC driver to be loaded and work before + * the EC device is found in the namespace. This is accomplished + * by looking for the ECDT table, and getting the EC parameters out + * of that. + */ + //result = acpi_ec_ecdt_probe(); + /* Ignore result. Not having an ECDT is not fatal. */ + + status = AcpiInitializeObjects(ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to initialize ACPI objects\n"); + goto error1; + } + + /* + * Maybe EC region is required at bus_scan/acpi_get_devices. So it + * is necessary to enable it as early as possible. + */ + //acpi_boot_ec_enable(); + + /* Initialize sleep structures */ + //acpi_sleep_init(); + + /* + * Get the system interrupt model and evaluate \_PIC. + */ + result = acpi_bus_init_irq(); + if (result) + goto error1; + + /* + * Register the for all standard device notifications. + */ + status = AcpiInstallNotifyHandler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to register for device notifications\n"); + result = AE_NOT_FOUND; + goto error1; + } + + /* + * Create the root device in the bus's device tree + */ + result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT, + ACPI_BUS_TYPE_SYSTEM); + if (result) + goto error2; + + /* + * Enumerate devices in the ACPI namespace. + */ + result = acpi_bus_scan_fixed(acpi_root); + if (result) + DPRINT1("acpi_bus_scan_fixed failed\n"); + result = acpi_bus_scan(acpi_root); + if (result) + DPRINT1("acpi_bus_scan failed\n"); + + //acpi_motherboard_init(); + return_VALUE(0); + + /* Mimic structured exception handling */ +error2: + AcpiRemoveNotifyHandler(ACPI_ROOT_OBJECT, + ACPI_SYSTEM_NOTIFY, &acpi_bus_notify); +error1: + AcpiTerminate(); + return_VALUE(AE_NOT_FOUND); +} + +static void +acpi_bus_exit (void) +{ + ACPI_STATUS status = AE_OK; + + DPRINT("acpi_bus_exit"); + + status = AcpiRemoveNotifyHandler(ACPI_ROOT_OBJECT, + ACPI_SYSTEM_NOTIFY, acpi_bus_notify); + if (ACPI_FAILURE(status)) + DPRINT1("Error removing notify handler\n"); + +#ifdef CONFIG_ACPI_PCI + acpi_pci_root_exit(); + acpi_pci_link_exit(); +#endif +#ifdef CONFIG_ACPI_EC + acpi_ec_exit(); +#endif + //acpi_power_exit(); + acpi_system_exit(); + + acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL); + + status = AcpiTerminate(); + if (ACPI_FAILURE(status)) + DPRINT1("Unable to terminate the ACPI Interpreter\n"); + else + DPRINT1("Interpreter disabled\n"); + + return_VOID; +} + + +int +acpi_init (void) +{ + int result = 0; + + DPRINT("acpi_init"); + + DPRINT("Subsystem revision %08x\n",ACPI_CA_VERSION); + + result = acpi_bus_init(); + + //if (!result) { + //pci_mmcfg_late_init(); + //if (!(pm_flags & PM_APM)) + // pm_flags |= PM_ACPI; + //else { + //DPRINT1("APM is already active, exiting\n"); + //disable_acpi(); + //result = -ENODEV; + //} + //} else + // disable_acpi(); + + /* + * If the laptop falls into the DMI check table, the power state check + * will be disabled in the course of device power transistion. + */ + //dmi_check_system(power_nocheck_dmi_table); + + /* + * Install drivers required for proper enumeration of the + * ACPI namespace. + */ + acpi_system_init(); /* ACPI System */ + acpi_power_init(); /* ACPI Bus Power Management */ + acpi_button_init(); + //acpi_ec_init(); /* ACPI Embedded Controller */ +#ifdef CONFIG_ACPI_PCI + if (!acpi_pci_disabled) { + acpi_pci_link_init(); /* ACPI PCI Interrupt Link */ + acpi_pci_root_init(); /* ACPI PCI Root Bridge */ + } +#endif + + //acpi_scan_init(); + //acpi_ec_init(); + //acpi_power_init(); + //acpi_system_init(); + //acpi_debug_init(); + //acpi_sleep_proc_init(); + //acpi_wakeup_device_init(); + + return result; +} + + +void +acpi_exit (void) +{ + DPRINT("acpi_exit"); + +#ifdef CONFIG_PM + pm_active = 0; +#endif + + acpi_bus_exit(); + + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/busmgr/button.c b/reactos/drivers/bus/acpi/busmgr/button.c new file mode 100644 index 00000000000..5e3eb2b5f0f --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/button.c @@ -0,0 +1,328 @@ +/* + * acpi_button.c - ACPI Button Driver ($Revision: 29 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ +#include + +#include +#include +#include +#include + +#define NDEBUG +#include + + + +#define _COMPONENT ACPI_BUTTON_COMPONENT +ACPI_MODULE_NAME ("acpi_button") + + +static int acpi_button_add (struct acpi_device *device); +static int acpi_button_remove (struct acpi_device *device, int type); + +static struct acpi_driver acpi_button_driver = { + .name = ACPI_BUTTON_DRIVER_NAME, + .class = ACPI_BUTTON_CLASS, + .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E", + .ops = { + .add = acpi_button_add, + .remove = acpi_button_remove, + }, +}; + +struct acpi_button { + ACPI_HANDLE handle; + struct acpi_device *device; /* Fixed button kludge */ + UINT8 type; + unsigned long pushed; +}; +/* -------------------------------------------------------------------------- + Driver Interface + -------------------------------------------------------------------------- */ + +void +acpi_button_notify ( + ACPI_HANDLE handle, + UINT32 event, + void *data) +{ + struct acpi_button *button = (struct acpi_button *) data; + + ACPI_FUNCTION_TRACE("acpi_button_notify"); + + if (!button || !button->device) + return_VOID; + + switch (event) { + case ACPI_BUTTON_NOTIFY_STATUS: + acpi_bus_generate_event(button->device, event, ++button->pushed); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Unsupported event [0x%x]\n", event)); + break; + } + + return_VOID; +} + + +ACPI_STATUS +acpi_button_notify_fixed ( + void *data) +{ + struct acpi_button *button = (struct acpi_button *) data; + + ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); + + if (!button) + return_ACPI_STATUS(AE_BAD_PARAMETER); + + acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); + + return_ACPI_STATUS(AE_OK); +} + + +static int +acpi_button_add ( + struct acpi_device *device) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_button *button = NULL; + + static struct acpi_device *power_button; + static struct acpi_device *sleep_button; + static struct acpi_device *lid_button; + + ACPI_FUNCTION_TRACE("acpi_button_add"); + + if (!device) + return_VALUE(-1); + + button = ExAllocatePool(NonPagedPool,sizeof(struct acpi_button)); + if (!button) + return_VALUE(-4); + memset(button, 0, sizeof(struct acpi_button)); + + button->device = device; + button->handle = device->handle; + acpi_driver_data(device) = button; + + /* + * Determine the button type (via hid), as fixed-feature buttons + * need to be handled a bit differently than generic-space. + */ + if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { + button->type = ACPI_BUTTON_TYPE_POWER; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_POWER); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) { + button->type = ACPI_BUTTON_TYPE_POWERF; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_POWERF); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) { + button->type = ACPI_BUTTON_TYPE_SLEEP; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_SLEEP); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) { + button->type = ACPI_BUTTON_TYPE_SLEEPF; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_SLEEPF); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) { + button->type = ACPI_BUTTON_TYPE_LID; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_LID); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); + } + else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", + acpi_device_hid(device))); + result = -15; + goto end; + } + + /* + * Ensure only one button of each type is used. + */ + switch (button->type) { + case ACPI_BUTTON_TYPE_POWER: + case ACPI_BUTTON_TYPE_POWERF: + if (!power_button) + power_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + case ACPI_BUTTON_TYPE_SLEEP: + case ACPI_BUTTON_TYPE_SLEEPF: + if (!sleep_button) + sleep_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + case ACPI_BUTTON_TYPE_LID: + if (!lid_button) + lid_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + } + + switch (button->type) { + case ACPI_BUTTON_TYPE_POWERF: + status = AcpiInstallFixedEventHandler ( + ACPI_EVENT_POWER_BUTTON, + acpi_button_notify_fixed, + button); + break; + case ACPI_BUTTON_TYPE_SLEEPF: + status = AcpiInstallFixedEventHandler ( + ACPI_EVENT_SLEEP_BUTTON, + acpi_button_notify_fixed, + button); + break; + case ACPI_BUTTON_TYPE_LID: + status = AcpiInstallFixedEventHandler ( + ACPI_BUTTON_TYPE_LID, + acpi_button_notify_fixed, + button); + break; + default: + status = AcpiInstallNotifyHandler ( + button->handle, + ACPI_DEVICE_NOTIFY, + acpi_button_notify, + button); + break; + } + + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); + result = -15; + goto end; + } + + DPRINT("%s [%s]\n", + acpi_device_name(device), acpi_device_bid(device)); + +end: + if (result) { + ExFreePool(button); + } + + return_VALUE(result); +} + + +static int +acpi_button_remove (struct acpi_device *device, int type) +{ + ACPI_STATUS status = 0; + struct acpi_button *button = NULL; + + ACPI_FUNCTION_TRACE("acpi_button_remove"); + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + button = acpi_driver_data(device); + + /* Unregister for device notifications. */ + switch (button->type) { + case ACPI_BUTTON_TYPE_POWERF: + status = AcpiRemoveFixedEventHandler( + ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed); + break; + case ACPI_BUTTON_TYPE_SLEEPF: + status = AcpiRemoveFixedEventHandler( + ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed); + break; + case ACPI_BUTTON_TYPE_LID: + status = AcpiRemoveFixedEventHandler( + ACPI_BUTTON_TYPE_LID, acpi_button_notify_fixed); + break; + default: + status = AcpiRemoveNotifyHandler(button->handle, + ACPI_DEVICE_NOTIFY, acpi_button_notify); + break; + } + + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + + ExFreePool(button); + + return_VALUE(0); +} + + +int +acpi_button_init (void) +{ + int result = 0; + + ACPI_FUNCTION_TRACE("acpi_button_init"); + + result = acpi_bus_register_driver(&acpi_button_driver); + if (result < 0) { + return_VALUE(-15); + } + + return_VALUE(0); +} + + +void +acpi_button_exit (void) +{ + ACPI_FUNCTION_TRACE("acpi_button_exit"); + + acpi_bus_unregister_driver(&acpi_button_driver); + + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/busmgr/power.c b/reactos/drivers/bus/acpi/busmgr/power.c new file mode 100644 index 00000000000..6c6bc0814bf --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/power.c @@ -0,0 +1,679 @@ +/* + * acpi_power.c - ACPI Bus Power Management ($Revision: 39 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +/* + * ACPI power-managed devices may be controlled in two ways: + * 1. via "Device Specific (D-State) Control" + * 2. via "Power Resource Control". + * This module is used to manage devices relying on Power Resource Control. + * + * An ACPI "power resource object" describes a software controllable power + * plane, clock plane, or other resource used by a power managed device. + * A device may rely on multiple power resources, and a power resource + * may be shared by multiple devices. + */ + +/* + * Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#include +#include +#include +#include +#include + +//#define NDEBUG +#include + + +#define _COMPONENT ACPI_POWER_COMPONENT +ACPI_MODULE_NAME ("acpi_power") + +#define ACPI_POWER_RESOURCE_STATE_OFF 0x00 +#define ACPI_POWER_RESOURCE_STATE_ON 0x01 +#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF + +int acpi_power_nocheck; + +static int acpi_power_add (struct acpi_device *device); +static int acpi_power_remove (struct acpi_device *device, int type); +static int acpi_power_resume(struct acpi_device *device); + +static struct acpi_driver acpi_power_driver = { + .name = ACPI_POWER_DRIVER_NAME, + .class = ACPI_POWER_CLASS, + .ids = ACPI_POWER_HID, + .ops = { + .add = acpi_power_add, + .remove = acpi_power_remove, + .resume = acpi_power_resume, + }, +}; + +struct acpi_power_reference { + struct list_head node; + struct acpi_device *device; +}; + +struct acpi_power_resource +{ + struct acpi_device * device; + acpi_bus_id name; + UINT32 system_level; + UINT32 order; + //struct mutex resource_lock; + struct list_head reference; +}; + +static struct list_head acpi_power_resource_list; + + +/* -------------------------------------------------------------------------- + Power Resource Management + -------------------------------------------------------------------------- */ + +static int +acpi_power_get_context ( + ACPI_HANDLE handle, + struct acpi_power_resource **resource) +{ + int result = 0; + struct acpi_device *device = NULL; + + if (!resource) + return_VALUE(-15); + + result = acpi_bus_get_device(handle, &device); + if (result) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", + handle)); + return_VALUE(result); + } + + *resource = (struct acpi_power_resource *) acpi_driver_data(device); + if (!*resource) + return_VALUE(-15); + + return 0; +} + + +static int +acpi_power_get_state ( + ACPI_HANDLE handle, + int *state) +{ + ACPI_STATUS status = AE_OK; + unsigned long sta = 0; + char node_name[5]; + ACPI_BUFFER buffer = { sizeof(node_name), node_name }; + + + if (!handle || !state) + return_VALUE(-1); + + status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status)) + return_VALUE(-15); + + *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: + ACPI_POWER_RESOURCE_STATE_OFF; + + AcpiGetName(handle, ACPI_SINGLE_NAME, &buffer); + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", + node_name, *state?"on":"off")); + + return 0; +} + + +static int +acpi_power_get_list_state ( + struct acpi_handle_list *list, + int *state) +{ + int result = 0, state1; + UINT32 i = 0; + + if (!list || !state) + return_VALUE(-1); + + /* The state of the list is 'on' IFF all resources are 'on'. */ + + for (i=0; icount; i++) { + /* + * The state of the power resource can be obtained by + * using the ACPI handle. In such case it is unnecessary to + * get the Power resource first and then get its state again. + */ + result = acpi_power_get_state(list->handles[i], &state1); + if (result) + return result; + + *state = state1; + + if (*state != ACPI_POWER_RESOURCE_STATE_ON) + break; + } + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", + *state?"on":"off")); + + return result; +} + + +static int +acpi_power_on ( + ACPI_HANDLE handle, struct acpi_device *dev) +{ + int result = 0; + int found = 0; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + struct acpi_power_reference *ref; + + result = acpi_power_get_context(handle, &resource); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + ref = container_of(node, struct acpi_power_reference, node); + if (dev->handle == ref->device->handle) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] already referenced by resource [%s]\n", + dev->pnp.bus_id, resource->name)); + found = 1; + break; + } + } + + if (!found) { + ref = ExAllocatePool(NonPagedPool,sizeof (struct acpi_power_reference)); + if (!ref) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "kmalloc() failed\n")); + //mutex_unlock(&resource->resource_lock); + return -1;//-ENOMEM; + } + list_add_tail(&ref->node, &resource->reference); + ref->device = dev; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] added to resource [%s] references\n", + dev->pnp.bus_id, resource->name)); + } + //mutex_unlock(&resource->resource_lock); + + status = AcpiEvaluateObject(resource->device->handle, "_ON", NULL, NULL); + if (ACPI_FAILURE(status)) + return_VALUE(-15); + + /* Update the power resource's _device_ power state */ + resource->device->power.state = ACPI_STATE_D0; + + return 0; +} + + +static int +acpi_power_off_device ( + ACPI_HANDLE handle, + struct acpi_device *dev) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + struct acpi_power_reference *ref; + + result = acpi_power_get_context(handle, &resource); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + ref = container_of(node, struct acpi_power_reference, node); + if (dev->handle == ref->device->handle) { + list_del(&ref->node); + ExFreePool(ref); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] removed from resource [%s] references\n", + dev->pnp.bus_id, resource->name)); + break; + } + } + + if (!list_empty(&resource->reference)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cannot turn resource [%s] off - resource is in use\n", + resource->name)); + //mutex_unlock(&resource->resource_lock); + return 0; + } + //mutex_unlock(&resource->resource_lock); + + status = AcpiEvaluateObject(resource->device->handle, "_OFF", NULL, NULL); + if (ACPI_FAILURE(status)) + return -1; + + /* Update the power resource's _device_ power state */ + resource->device->power.state = ACPI_STATE_D3; + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", + resource->name)); + + return 0; +} + +/** + * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in + * ACPI 3.0) _PSW (Power State Wake) + * @dev: Device to handle. + * @enable: 0 - disable, 1 - enable the wake capabilities of the device. + * @sleep_state: Target sleep state of the system. + * @dev_state: Target power state of the device. + * + * Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present. On failure reset the device's + * wakeup.flags.valid flag. + * + * RETURN VALUE: + * 0 if either _DSW or _PSW has been successfully executed + * 0 if neither _DSW nor _PSW has been found + * -ENODEV if the execution of either _DSW or _PSW has failed + */ +int acpi_device_sleep_wake(struct acpi_device *dev, + int enable, int sleep_state, int dev_state) +{ + union acpi_object in_arg[3]; + struct acpi_object_list arg_list = { 3, in_arg }; + ACPI_STATUS status = AE_OK; + + /* + * Try to execute _DSW first. + * + * Three agruments are needed for the _DSW object: + * Argument 0: enable/disable the wake capabilities + * Argument 1: target system state + * Argument 2: target device state + * When _DSW object is called to disable the wake capabilities, maybe + * the first argument is filled. The values of the other two agruments + * are meaningless. + */ + in_arg[0].Type = ACPI_TYPE_INTEGER; + in_arg[0].Integer.Value = enable; + in_arg[1].Type = ACPI_TYPE_INTEGER; + in_arg[1].Integer.Value = sleep_state; + in_arg[2].Type = ACPI_TYPE_INTEGER; + in_arg[2].Integer.Value = dev_state; + status = AcpiEvaluateObject(dev->handle, "_DSW", &arg_list, NULL); + if (ACPI_SUCCESS(status)) { + return 0; + } else if (status != AE_NOT_FOUND) { + DPRINT1("_DSW execution failed\n"); + dev->wakeup.flags.valid = 0; + return -1; + } + + /* Execute _PSW */ + arg_list.Count = 1; + in_arg[0].Integer.Value = enable; + status = AcpiEvaluateObject(dev->handle, "_PSW", &arg_list, NULL); + if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { + DPRINT1("_PSW execution failed\n"); + dev->wakeup.flags.valid = 0; + return -1; + } + + return 0; +} + +/* + * Prepare a wakeup device, two steps (Ref ACPI 2.0:P229): + * 1. Power on the power resources required for the wakeup device + * 2. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present + */ +int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) +{ + int i, err = 0; + + if (!dev || !dev->wakeup.flags.valid) + return -1; + + //mutex_lock(&acpi_device_lock); + + if (dev->wakeup.prepare_count++) + goto out; + + /* Open power resource */ + for (i = 0; i < dev->wakeup.resources.count; i++) { + int ret = acpi_power_on(dev->wakeup.resources.handles[i], dev); + if (ret) { + DPRINT( "Transition power state\n"); + dev->wakeup.flags.valid = 0; + err = -1; + goto err_out; + } + } + + /* + * Passing 3 as the third argument below means the device may be placed + * in arbitrary power state afterwards. + */ + err = acpi_device_sleep_wake(dev, 1, sleep_state, 3); + + err_out: + if (err) + dev->wakeup.prepare_count = 0; + + out: + //mutex_unlock(&acpi_device_lock); + return err; +} + +/* + * Shutdown a wakeup device, counterpart of above method + * 1. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present + * 2. Shutdown down the power resources + */ +int acpi_disable_wakeup_device_power(struct acpi_device *dev) +{ + int i, err = 0; + + if (!dev || !dev->wakeup.flags.valid) + return -1; + + //mutex_lock(&acpi_device_lock); + + if (--dev->wakeup.prepare_count > 0) + goto out; + + /* + * Executing the code below even if prepare_count is already zero when + * the function is called may be useful, for example for initialisation. + */ + if (dev->wakeup.prepare_count < 0) + dev->wakeup.prepare_count = 0; + + err = acpi_device_sleep_wake(dev, 0, 0, 0); + if (err) + goto out; + + /* Close power resource */ + for (i = 0; i < dev->wakeup.resources.count; i++) { + int ret = acpi_power_off_device( + dev->wakeup.resources.handles[i], dev); + if (ret) { + DPRINT("Transition power state\n"); + dev->wakeup.flags.valid = 0; + err = -1; + goto out; + } + } + + out: + //mutex_unlock(&acpi_device_lock); + return err; +} + +/* -------------------------------------------------------------------------- + Device Power Management + -------------------------------------------------------------------------- */ + +int +acpi_power_get_inferred_state ( + struct acpi_device *device) +{ + int result = 0; + struct acpi_handle_list *list = NULL; + int list_state = 0; + int i = 0; + + + if (!device) + return_VALUE(-1); + + device->power.state = ACPI_STATE_UNKNOWN; + + /* + * We know a device's inferred power state when all the resources + * required for a given D-state are 'on'. + */ + for (i=ACPI_STATE_D0; ipower.states[i].resources; + if (list->count < 1) + continue; + + result = acpi_power_get_list_state(list, &list_state); + if (result) + return_VALUE(result); + + if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { + device->power.state = i; + return_VALUE(0); + } + } + + device->power.state = ACPI_STATE_D3; + + return_VALUE(0); +} + + +int +acpi_power_transition ( + struct acpi_device *device, + int state) +{ + int result = 0; + struct acpi_handle_list *cl = NULL; /* Current Resources */ + struct acpi_handle_list *tl = NULL; /* Target Resources */ + int i = 0; + + if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) + return_VALUE(-1); + + if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3)) + return_VALUE(-15); + + cl = &device->power.states[device->power.state].resources; + tl = &device->power.states[state].resources; + + /* TBD: Resources must be ordered. */ + + /* + * First we reference all power resources required in the target list + * (e.g. so the device doesn't lose power while transitioning). + */ + for (i = 0; i < tl->count; i++) { + result = acpi_power_on(tl->handles[i], device); + if (result) + goto end; + } + + if (device->power.state == state) { + goto end; + } + + /* + * Then we dereference all power resources used in the current list. + */ + for (i = 0; i < cl->count; i++) { + result = acpi_power_off_device(cl->handles[i], device); + if (result) + goto end; + } + + end: + if (result) + device->power.state = ACPI_STATE_UNKNOWN; + else { + /* We shouldn't change the state till all above operations succeed */ + device->power.state = state; + } + + return result; +} + +/* -------------------------------------------------------------------------- + Driver Interface + -------------------------------------------------------------------------- */ + +int +acpi_power_add ( + struct acpi_device *device) +{ + int result = 0, state; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + union acpi_object acpi_object; + ACPI_BUFFER buffer = {sizeof(ACPI_OBJECT), &acpi_object}; + + + if (!device) + return_VALUE(-1); + + resource = ExAllocatePool(NonPagedPool,sizeof(struct acpi_power_resource)); + if (!resource) + return_VALUE(-4); + + resource->device = device; + //mutex_init(&resource->resource_lock); + INIT_LIST_HEAD(&resource->reference); + + strcpy(resource->name, device->pnp.bus_id); + strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); + strcpy(acpi_device_class(device), ACPI_POWER_CLASS); + device->driver_data = resource; + + /* Evalute the object to get the system level and resource order. */ + status = AcpiEvaluateObject(device->handle, NULL, NULL, &buffer); + if (ACPI_FAILURE(status)) { + result = -15; + goto end; + } + resource->system_level = acpi_object.PowerResource.SystemLevel; + resource->order = acpi_object.PowerResource.ResourceOrder; + + result = acpi_power_get_state(device->handle, &state); + if (result) + goto end; + + switch (state) { + case ACPI_POWER_RESOURCE_STATE_ON: + device->power.state = ACPI_STATE_D0; + break; + case ACPI_POWER_RESOURCE_STATE_OFF: + device->power.state = ACPI_STATE_D3; + break; + default: + device->power.state = ACPI_STATE_UNKNOWN; + break; + } + + + DPRINT("%s [%s] (%s)\n", acpi_device_name(device), + acpi_device_bid(device), state?"on":"off"); + +end: + if (result) + ExFreePool(resource); + + return result; +} + + +int +acpi_power_remove ( + struct acpi_device *device, + int type) +{ + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + resource = acpi_driver_data(device); + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + struct acpi_power_reference *ref = container_of(node, struct acpi_power_reference, node); + list_del(&ref->node); + ExFreePool(ref); + } + //mutex_unlock(&resource->resource_lock); + ExFreePool(resource); + + return_VALUE(0); +} + +static int acpi_power_resume(struct acpi_device *device) +{ + int result = 0, state; + struct acpi_power_resource *resource = NULL; + struct acpi_power_reference *ref; + + if (!device || !acpi_driver_data(device)) + return -1; + + resource = acpi_driver_data(device); + + result = acpi_power_get_state(device->handle, &state); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + if (state == ACPI_POWER_RESOURCE_STATE_OFF && + !list_empty(&resource->reference)) { + ref = container_of(resource->reference.next, struct acpi_power_reference, node); + //mutex_unlock(&resource->resource_lock); + result = acpi_power_on(device->handle, ref->device); + return result; + } + + //mutex_unlock(&resource->resource_lock); + return 0; +} + +int +acpi_power_init (void) +{ + int result = 0; + + DPRINT("acpi_power_init"); + + INIT_LIST_HEAD(&acpi_power_resource_list); + + + result = acpi_bus_register_driver(&acpi_power_driver); + if (result < 0) { + return_VALUE(-15); + } + + return_VALUE(0); +} diff --git a/reactos/drivers/bus/acpi/busmgr/system.c b/reactos/drivers/bus/acpi/busmgr/system.c new file mode 100644 index 00000000000..1ffee4c95c7 --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/system.c @@ -0,0 +1,428 @@ +/* + * acpi_system.c - ACPI System Driver ($Revision: 57 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +/* Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ +#include +#include +#include +#include +#include "list.h" + +//#define NDEBUG +#include + +ACPI_STATUS acpi_system_save_state(UINT32); + +#define _COMPONENT ACPI_SYSTEM_COMPONENT +ACPI_MODULE_NAME ("acpi_system") + +#define PREFIX "ACPI: " + +static int acpi_system_add (struct acpi_device *device); +static int acpi_system_remove (struct acpi_device *device, int type); + +ACPI_STATUS acpi_suspend (UINT32 state); + +static struct acpi_driver acpi_system_driver = { + .name = ACPI_SYSTEM_DRIVER_NAME, + .class = ACPI_SYSTEM_CLASS, + .ids = ACPI_SYSTEM_HID, + .ops = { + .add = acpi_system_add, + .remove = acpi_system_remove + }, +}; + +struct acpi_system +{ + ACPI_HANDLE handle; + UINT8 states[ACPI_S_STATE_COUNT]; +}; + + +static int +acpi_system_add ( + struct acpi_device *device) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_system *system = NULL; + UINT8 i = 0; + + ACPI_FUNCTION_TRACE("acpi_system_add"); + + if (!device) + return_VALUE(-1); + + system = ExAllocatePool(NonPagedPool,sizeof(struct acpi_system)); + if (!system) + return_VALUE(-14); + memset(system, 0, sizeof(struct acpi_system)); + + system->handle = device->handle; + sprintf(acpi_device_name(device), "%s", ACPI_SYSTEM_DEVICE_NAME); + sprintf(acpi_device_class(device), "%s", ACPI_SYSTEM_CLASS); + acpi_driver_data(device) = system; + + DPRINT("%s [%s] (supports", + acpi_device_name(device), acpi_device_bid(device)); + for (i=0; iS4bios_f &&*/ + 0 != AcpiGbl_FADT.SmiCommand) { + DPRINT(" S4bios"); + system->states[i] = 1; + } + /* no break */ + default: + if (ACPI_SUCCESS(status)) { + system->states[i] = 1; + DPRINT(" S%d", i); + } + } + } + +//#ifdef CONFIG_PM +// /* Install the soft-off (S5) handler. */ +// if (system->states[ACPI_STATE_S5]) { +// pm_power_off = acpi_power_off; +// register_sysrq_key('o', &sysrq_acpi_poweroff_op); +// } +//#endif + + if (result) + ExFreePool(system); + + return_VALUE(result); +} + +static int +acpi_system_remove ( + struct acpi_device *device, + int type) +{ + struct acpi_system *system = NULL; + + ACPI_FUNCTION_TRACE("acpi_system_remove"); + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + system = (struct acpi_system *) acpi_driver_data(device); + +//#ifdef CONFIG_PM +// /* Remove the soft-off (S5) handler. */ +// if (system->states[ACPI_STATE_S5]) { +// unregister_sysrq_key('o', &sysrq_acpi_poweroff_op); +// pm_power_off = NULL; +// } +//#endif +// +// + ExFreePool(system); + + return 0; +} + +/** + * acpi_system_restore_state - OS-specific restoration of state + * @state: sleep state we're exiting + * + * Note that if we're coming back from S4, the memory image should have + * already been loaded from the disk and is already in place. (Otherwise how + * else would we be here?). + */ +ACPI_STATUS +acpi_system_restore_state( + UINT32 state) +{ + /* + * We should only be here if we're coming back from STR or STD. + * And, in the case of the latter, the memory image should have already + * been loaded from disk. + */ + if (state > ACPI_STATE_S1) { + //acpi_restore_state_mem(); + + /* Do _early_ resume for irqs. Required by + * ACPI specs. + */ + /* TBD: call arch dependant reinitialization of the + * interrupts. + */ +#ifdef _X86_ + //init_8259A(0); +#endif + /* wait for power to come back */ + KeStallExecutionProcessor(100); + + } + + /* Be really sure that irqs are disabled. */ + //ACPI_DISABLE_IRQS(); + + /* Wait a little again, just in case... */ + KeStallExecutionProcessor(10); + + /* enable interrupts once again */ + //ACPI_ENABLE_IRQS(); + + /* turn all the devices back on */ + //if (state > ACPI_STATE_S1) + //pm_send_all(PM_RESUME, (void *)0); + + return AE_OK; +} + + +/** + * acpi_system_save_state - save OS specific state and power down devices + * @state: sleep state we're entering. + * + * This handles saving all context to memory, and possibly disk. + * First, we call to the device driver layer to save device state. + * Once we have that, we save whatevery processor and kernel state we + * need to memory. + * If we're entering S4, we then write the memory image to disk. + * + * Only then it is safe for us to power down devices, since we may need + * the disks and upstream buses to write to. + */ +ACPI_STATUS +acpi_system_save_state( + UINT32 state) +{ + int error = 0; + + /* Send notification to devices that they will be suspended. + * If any device or driver cannot make the transition, either up + * or down, we'll get an error back. + */ + /*if (state > ACPI_STATE_S1) { + error = pm_send_all(PM_SAVE_STATE, (void *)3); + if (error) + return AE_ERROR; + }*/ + + //if (state <= ACPI_STATE_S5) { + // /* Tell devices to stop I/O and actually save their state. + // * It is theoretically possible that something could fail, + // * so handle that gracefully.. + // */ + // if (state > ACPI_STATE_S1 && state != ACPI_STATE_S5) { + // error = pm_send_all(PM_SUSPEND, (void *)3); + // if (error) { + // /* Tell devices to restore state if they have + // * it saved and to start taking I/O requests. + // */ + // pm_send_all(PM_RESUME, (void *)0); + // return error; + // } + // } + + /* flush caches */ + ACPI_FLUSH_CPU_CACHE(); + + /* Do arch specific saving of state. */ + if (state > ACPI_STATE_S1) { + error = 0;//acpi_save_state_mem(); + + /* TBD: if no s4bios, write codes for + * acpi_save_state_disk()... + */ +#if 0 + if (!error && (state == ACPI_STATE_S4)) + error = acpi_save_state_disk(); +#endif + /*if (error) { + pm_send_all(PM_RESUME, (void *)0); + return error; + }*/ + } + //} + /* disable interrupts + * Note that acpi_suspend -- our caller -- will do this once we return. + * But, we want it done early, so we don't get any suprises during + * the device suspend sequence. + */ + //ACPI_DISABLE_IRQS(); + + /* Unconditionally turn off devices. + * Obvious if we enter a sleep state. + * If entering S5 (soft off), this should put devices in a + * quiescent state. + */ + + //if (state > ACPI_STATE_S1) { + // error = pm_send_all(PM_SUSPEND, (void *)3); + + // /* We're pretty screwed if we got an error from this. + // * We try to recover by simply calling our own restore_state + // * function; see above for definition. + // * + // * If it's S5 though, go through with it anyway.. + // */ + // if (error && state != ACPI_STATE_S5) + // acpi_system_restore_state(state); + //} + return error ? AE_ERROR : AE_OK; +} + + +/**************************************************************************** + * + * FUNCTION: acpi_system_suspend + * + * PARAMETERS: %state: Sleep state to enter. + * + * RETURN: ACPI_STATUS, whether or not we successfully entered and + * exited sleep. + * + * DESCRIPTION: Perform OS-specific action to enter sleep state. + * This is the final step in going to sleep, per spec. If we + * know we're coming back (i.e. not entering S5), we save the + * processor flags. [ We'll have to save and restore them anyway, + * so we use the arch-agnostic save_flags and restore_flags + * here.] We then set the place to return to in arch-specific + * globals using arch_set_return_point. Finally, we call the + * ACPI function to write the proper values to I/O ports. + * + ****************************************************************************/ + +ACPI_STATUS +acpi_system_suspend( + UINT32 state) +{ + ACPI_STATUS status = AE_ERROR; + //unsigned long flags = 0; + + //local_irq_save(flags); + /* kernel_fpu_begin(); */ + + switch (state) { + case ACPI_STATE_S1: + case ACPI_STATE_S5: + //barrier(); + status = AcpiEnterSleepState(state); + break; + case ACPI_STATE_S4: + //do_suspend_lowlevel_s4bios(0); + break; + } + + /* kernel_fpu_end(); */ + //local_irq_restore(flags); + + return status; +} + + + +/** + * acpi_suspend - OS-agnostic system suspend/resume support (S? states) + * @state: state we're entering + * + */ +ACPI_STATUS +acpi_suspend ( + UINT32 state) +{ + ACPI_STATUS status; + + /* only support S1 and S5 on kernel 2.4 */ + //if (state != ACPI_STATE_S1 && state != ACPI_STATE_S4 + // && state != ACPI_STATE_S5) + // return AE_ERROR; + + + //if (ACPI_STATE_S4 == state) { + // /* For s4bios, we need a wakeup address. */ + // if (1 == AcpiGbl_FACS->S4bios_f && + // 0 != AcpiGbl_FADT->smi_cmd) { + // if (!acpi_wakeup_address) + // return AE_ERROR; + // AcpiSetFirmwareWakingVector((acpi_physical_address) acpi_wakeup_address); + // } else + // /* We don't support S4 under 2.4. Give up */ + // return AE_ERROR; + //} + + status = AcpiEnterSleepState(state); + if (!ACPI_SUCCESS(status) && state != ACPI_STATE_S5) + return status; + + AcpiEnterSleepStatePrep(state); + + /* disable interrupts and flush caches */ + //ACPI_DISABLE_IRQS(); + ACPI_FLUSH_CPU_CACHE(); + + /* perform OS-specific sleep actions */ + status = acpi_system_suspend(state); + + /* Even if we failed to go to sleep, all of the devices are in an suspended + * mode. So, we run these unconditionaly to make sure we have a usable system + * no matter what. + */ + AcpiLeaveSleepState(state); + acpi_system_restore_state(state); + + /* make sure interrupts are enabled */ + //ACPI_ENABLE_IRQS(); + + /* reset firmware waking vector */ + AcpiSetFirmwareWakingVector((ACPI_PHYSICAL_ADDRESS) 0); + + return status; +} + +int +acpi_system_init (void) +{ + int result = 0; + + ACPI_FUNCTION_TRACE("acpi_system_init"); + + result = acpi_bus_register_driver(&acpi_system_driver); + if (result < 0) + return_VALUE(AE_NOT_FOUND); + + return_VALUE(0); +} + + +void +acpi_system_exit (void) +{ + ACPI_FUNCTION_TRACE("acpi_system_exit"); + acpi_bus_unregister_driver(&acpi_system_driver); + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/busmgr/utils.c b/reactos/drivers/bus/acpi/busmgr/utils.c new file mode 100644 index 00000000000..67eaed017ca --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/utils.c @@ -0,0 +1,376 @@ +/* + * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#include + +#include +#include +#include +#include + +//#define NDEBUG +#include + + /* Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#define _COMPONENT ACPI_BUS_COMPONENT +ACPI_MODULE_NAME ("acpi_utils") + +static void +acpi_util_eval_error(ACPI_HANDLE h, ACPI_STRING p, ACPI_STATUS s) +{ +#ifdef ACPI_DEBUG_OUTPUT + char prefix[80] = {'\0'}; + ACPI_BUFFER buffer = {sizeof(prefix), prefix}; + AcpiGetName(h, ACPI_FULL_PATHNAME, &buffer); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n", + (char *) prefix, p, AcpiFormatException(s))); +#else + return; +#endif +} + + +/* -------------------------------------------------------------------------- + Object Evaluation Helpers + -------------------------------------------------------------------------- */ + + +ACPI_STATUS +acpi_extract_package ( + ACPI_OBJECT *package, + ACPI_BUFFER *format, + ACPI_BUFFER *buffer) +{ + UINT32 size_required = 0; + UINT32 tail_offset = 0; + char *format_string = NULL; + UINT32 format_count = 0; + UINT32 i = 0; + UINT8 *head = NULL; + UINT8 *tail = NULL; + + if (!package || (package->Type != ACPI_TYPE_PACKAGE) || (package->Package.Count < 1)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + if (!format || !format->Pointer || (format->Length < 1)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + if (!buffer) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + format_count = (format->Length/sizeof(char)) - 1; + if (format_count > package->Package.Count) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count)); + return_ACPI_STATUS(AE_BAD_DATA); + } + + format_string = format->Pointer; + + /* + * Calculate size_required. + */ + for (i=0; iPackage.Elements[i]); + + if (!element) { + return_ACPI_STATUS(AE_BAD_DATA); + } + + switch (element->Type) { + + case ACPI_TYPE_INTEGER: + switch (format_string[i]) { + case 'N': + size_required += sizeof(ACPI_INTEGER); + tail_offset += sizeof(ACPI_INTEGER); + break; + case 'S': + size_required += sizeof(char*) + sizeof(ACPI_INTEGER) + sizeof(char); + tail_offset += sizeof(char*); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecing [%c].\n", i, format_string[i])); + return_ACPI_STATUS(AE_BAD_DATA); + break; + } + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + switch (format_string[i]) { + case 'S': + size_required += sizeof(char*) + (element->String.Length * sizeof(char)) + sizeof(char); + tail_offset += sizeof(char*); + break; + case 'B': + size_required += sizeof(UINT8*) + (element->Buffer.Length * sizeof(UINT8)); + tail_offset += sizeof(UINT8*); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format_string[i])); + return_ACPI_STATUS(AE_BAD_DATA); + break; + } + break; + + case ACPI_TYPE_PACKAGE: + default: + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i)); + /* TBD: handle nested packages... */ + return_ACPI_STATUS(AE_SUPPORT); + break; + } + } + + /* + * Validate output buffer. + */ + if (buffer->Length < size_required) { + buffer->Length = size_required; + return_ACPI_STATUS(AE_BUFFER_OVERFLOW); + } + else if (buffer->Length != size_required || !buffer->Pointer) { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + head = buffer->Pointer; + tail = buffer->Pointer + tail_offset; + + /* + * Extract package data. + */ + for (i=0; iPackage.Elements[i]); + + if (!element) { + return_ACPI_STATUS(AE_BAD_DATA); + } + + switch (element->Type) { + + case ACPI_TYPE_INTEGER: + switch (format_string[i]) { + case 'N': + *((ACPI_INTEGER*)head) = element->Integer.Value; + head += sizeof(ACPI_INTEGER); + break; + case 'S': + pointer = (UINT8**)head; + *pointer = tail; + *((ACPI_INTEGER*)tail) = element->Integer.Value; + head += sizeof(ACPI_INTEGER*); + tail += sizeof(ACPI_INTEGER); + /* NULL terminate string */ + *tail = (char)0; + tail += sizeof(char); + break; + default: + /* Should never get here */ + break; + } + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + switch (format_string[i]) { + case 'S': + pointer = (UINT8**)head; + *pointer = tail; + memcpy(tail, element->String.Pointer, element->String.Length); + head += sizeof(char*); + tail += element->String.Length * sizeof(char); + /* NULL terminate string */ + *tail = (char)0; + tail += sizeof(char); + break; + case 'B': + pointer = (UINT8**)head; + *pointer = tail; + memcpy(tail, element->Buffer.Pointer, element->Buffer.Length); + head += sizeof(UINT8*); + tail += element->Buffer.Length * sizeof(UINT8); + break; + default: + /* Should never get here */ + break; + } + break; + + case ACPI_TYPE_PACKAGE: + /* TBD: handle nested packages... */ + default: + /* Should never get here */ + break; + } + } + + return_ACPI_STATUS(AE_OK); +} + + +ACPI_STATUS +acpi_evaluate_integer ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + ACPI_OBJECT_LIST *arguments, + unsigned long long *data) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT element; + ACPI_BUFFER buffer = {sizeof(ACPI_OBJECT), &element}; + + ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); + + if (!data) + return_ACPI_STATUS(AE_BAD_PARAMETER); + + status = AcpiEvaluateObject(handle, pathname, arguments, &buffer); + if (ACPI_FAILURE(status)) { + acpi_util_eval_error(handle, pathname, status); + return_ACPI_STATUS(status); + } + + if (element.Type != ACPI_TYPE_INTEGER) { + acpi_util_eval_error(handle, pathname, AE_BAD_DATA); + return_ACPI_STATUS(AE_BAD_DATA); + } + + *data = element.Integer.Value; + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); + + return_ACPI_STATUS(AE_OK); +} + + +ACPI_STATUS +acpi_evaluate_reference ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + ACPI_OBJECT_LIST *arguments, + struct acpi_handle_list *list) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT *package = NULL; + ACPI_OBJECT *element = NULL; + ACPI_BUFFER buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + UINT32 i = 0; + + ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); + + if (!list) { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + /* Evaluate object. */ + + status = AcpiEvaluateObject(handle, pathname, arguments, &buffer); + if (ACPI_FAILURE(status)) + goto end; + + package = (ACPI_OBJECT *) buffer.Pointer; + + if ((buffer.Length == 0) || !package) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No return object (len %X ptr %p)\n", + buffer.Length, package)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + if (package->Type != ACPI_TYPE_PACKAGE) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Package], found type %X\n", + package->Type)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + if (!package->Package.Count) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "[Package] has zero elements (%p)\n", + package)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + + if (package->Package.Count > ACPI_MAX_HANDLES) { + return AE_NO_MEMORY; + } + list->count = package->Package.Count; + + /* Extract package data. */ + + for (i = 0; i < list->count; i++) { + + element = &(package->Package.Elements[i]); + + if (element->Type != ACPI_TYPE_LOCAL_REFERENCE) { + status = AE_BAD_DATA; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Reference] package element, found type %X\n", + element->type)); + acpi_util_eval_error(handle, pathname, status); + break; + } + + if (!element->Reference.Handle) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid reference in" + " package %s\n", pathname)); + status = AE_NULL_ENTRY; + break; + } + /* Get the ACPI_HANDLE. */ + + list->handles[i] = element->Reference.Handle; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n", + list->handles[i])); + } + +end: + if (ACPI_FAILURE(status)) { + list->count = 0; + //ExFreePool(list->handles); + } + + AcpiOsFree(buffer.Pointer); + + return_ACPI_STATUS(status); +} + + diff --git a/reactos/drivers/bus/acpi/buspdo.c b/reactos/drivers/bus/acpi/buspdo.c new file mode 100644 index 00000000000..2f1ff5a08f3 --- /dev/null +++ b/reactos/drivers/bus/acpi/buspdo.c @@ -0,0 +1,1227 @@ +#include + +#include +#include +#include +#include + +#include +#include + +//#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (PAGE, Bus_PDO_PnP) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceCaps) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceId) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceText) +#pragma alloc_text (PAGE, Bus_PDO_QueryResources) +#pragma alloc_text (PAGE, Bus_PDO_QueryResourceRequirements) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceRelations) +#pragma alloc_text (PAGE, Bus_PDO_QueryBusInformation) +#pragma alloc_text (PAGE, Bus_GetDeviceCapabilities) +#endif + +NTSTATUS +Bus_PDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PPDO_DEVICE_DATA DeviceData + ) +{ + NTSTATUS status; + + PAGED_CODE (); + + + // + // NB: Because we are a bus enumerator, we have no one to whom we could + // defer these irps. Therefore we do not pass them down but merely + // return them. + // + + switch (IrpStack->MinorFunction) { + + case IRP_MN_START_DEVICE: + + // + // Here we do what ever initialization and ``turning on'' that is + // required to allow others to access this device. + // Power up the device. + // + DeviceData->Common.DevicePowerState = PowerDeviceD0; + SET_NEW_PNP_STATE(DeviceData->Common, Started); + status = STATUS_SUCCESS; + break; + + case IRP_MN_STOP_DEVICE: + + // + // Here we shut down the device and give up and unmap any resources + // we acquired for the device. + // + + SET_NEW_PNP_STATE(DeviceData->Common, Stopped); + status = STATUS_SUCCESS; + break; + + + case IRP_MN_QUERY_STOP_DEVICE: + + // + // No reason here why we can't stop the device. + // If there were a reason we should speak now, because answering success + // here may result in a stop device irp. + // + + SET_NEW_PNP_STATE(DeviceData->Common, StopPending); + status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: + + // + // The stop was canceled. Whatever state we set, or resources we put + // on hold in anticipation of the forthcoming STOP device IRP should be + // put back to normal. Someone, in the long list of concerned parties, + // has failed the stop device query. + // + + // + // First check to see whether you have received cancel-stop + // without first receiving a query-stop. This could happen if someone + // above us fails a query-stop and passes down the subsequent + // cancel-stop. + // + + if (StopPending == DeviceData->Common.DevicePnPState) + { + // + // We did receive a query-stop, so restore. + // + RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); + } + status = STATUS_SUCCESS;// We must not fail this IRP. + break; + case IRP_MN_QUERY_CAPABILITIES: + + // + // Return the capabilities of a device, such as whether the device + // can be locked or ejected..etc + // + + status = Bus_PDO_QueryDeviceCaps(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_ID: + + // Query the IDs of the device + status = Bus_PDO_QueryDeviceId(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_DEVICE_RELATIONS: + + DPRINT("\tQueryDeviceRelation Type: %s\n",DbgDeviceRelationString(\ + IrpStack->Parameters.QueryDeviceRelations.Type)); + + status = Bus_PDO_QueryDeviceRelations(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_DEVICE_TEXT: + + status = Bus_PDO_QueryDeviceText(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_RESOURCES: + + status = Bus_PDO_QueryResources(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: + + status = Bus_PDO_QueryResourceRequirements(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_BUS_INFORMATION: + + status = Bus_PDO_QueryBusInformation(DeviceData, Irp); + + break; + + + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: + + // + // OPTIONAL for bus drivers. + // The PnP Manager sends this IRP to a device + // stack so filter and function drivers can adjust the + // resources required by the device, if appropriate. + // + + //break; + + //case IRP_MN_QUERY_PNP_DEVICE_STATE: + + // + // OPTIONAL for bus drivers. + // The PnP Manager sends this IRP after the drivers for + // a device return success from the IRP_MN_START_DEVICE + // request. The PnP Manager also sends this IRP when a + // driver for the device calls IoInvalidateDeviceState. + // + + // break; + + //case IRP_MN_READ_CONFIG: + //case IRP_MN_WRITE_CONFIG: + + // + // Bus drivers for buses with configuration space must handle + // this request for their child devices. Our devices don't + // have a config space. + // + + // break; + + //case IRP_MN_SET_LOCK: + + // break; + + default: + + // + // For PnP requests to the PDO that we do not understand we should + // return the IRP WITHOUT setting the status or information fields. + // These fields may have already been set by a filter (eg acpi). + status = Irp->IoStatus.Status; + + break; + } + + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; +} + +// +// FIX ME FIX ME FIX ME !!! +// +NTSTATUS +Bus_PDO_QueryDeviceCaps( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + + PIO_STACK_LOCATION stack; + PDEVICE_CAPABILITIES deviceCapabilities; + DEVICE_CAPABILITIES parentCapabilities; + NTSTATUS status; + + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + // + // Get the packet. + // + deviceCapabilities=stack->Parameters.DeviceCapabilities.Capabilities; + + // + // Set the capabilities. + // + + if (deviceCapabilities->Version != 1 || + deviceCapabilities->Size < sizeof(DEVICE_CAPABILITIES)) + { + return STATUS_UNSUCCESSFUL; + } + + // + // Get the device capabilities of the parent + // + status = Bus_GetDeviceCapabilities( + FDO_FROM_PDO(DeviceData)->NextLowerDriver, &parentCapabilities); + if (!NT_SUCCESS(status)) { + + DPRINT("\tQueryDeviceCaps failed\n"); + return status; + + } + + // + // The entries in the DeviceState array are based on the capabilities + // of the parent devnode. These entries signify the highest-powered + // state that the device can support for the corresponding system + // state. A driver can specify a lower (less-powered) state than the + // bus driver. For eg: Suppose the acpi bus controller supports + // D0, D2, and D3; and the acpi Device supports D0, D1, D2, and D3. + // Following the above rule, the device cannot specify D1 as one of + // it's power state. A driver can make the rules more restrictive + // but cannot loosen them. + // First copy the parent's S to D state mapping + // + + RtlCopyMemory( + deviceCapabilities->DeviceState, + parentCapabilities.DeviceState, + (PowerSystemShutdown + 1) * sizeof(DEVICE_POWER_STATE) + ); + + // + // Adjust the caps to what your device supports. + // Our device just supports D0 and D3. + // + + deviceCapabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0; + + if (deviceCapabilities->DeviceState[PowerSystemSleeping1] != PowerDeviceD0) + deviceCapabilities->DeviceState[PowerSystemSleeping1] = PowerDeviceD1; + + if (deviceCapabilities->DeviceState[PowerSystemSleeping2] != PowerDeviceD0) + deviceCapabilities->DeviceState[PowerSystemSleeping2] = PowerDeviceD3; + + if (deviceCapabilities->DeviceState[PowerSystemSleeping3] != PowerDeviceD0) + deviceCapabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; + + // We can wake the system from D1 + deviceCapabilities->DeviceWake = PowerDeviceD1; + + // + // Specifies whether the device hardware supports the D1 and D2 + // power state. Set these bits explicitly. + // + + deviceCapabilities->DeviceD1 = TRUE; // Yes we can + deviceCapabilities->DeviceD2 = FALSE; + + // + // Specifies whether the device can respond to an external wake + // signal while in the D0, D1, D2, and D3 state. + // Set these bits explicitly. + // + + deviceCapabilities->WakeFromD0 = FALSE; + deviceCapabilities->WakeFromD1 = TRUE; //Yes we can + deviceCapabilities->WakeFromD2 = FALSE; + deviceCapabilities->WakeFromD3 = FALSE; + + + // We have no latencies + + deviceCapabilities->D1Latency = 0; + deviceCapabilities->D2Latency = 0; + deviceCapabilities->D3Latency = 0; + + // Ejection supported + + deviceCapabilities->EjectSupported = TRUE; + + // + // This flag specifies whether the device's hardware is disabled. + // The PnP Manager only checks this bit right after the device is + // enumerated. Once the device is started, this bit is ignored. + // + deviceCapabilities->HardwareDisabled = FALSE; + + // + // Out simulated device can be physically removed. + // + deviceCapabilities->Removable = TRUE; + // + // Setting it to TURE prevents the warning dialog from appearing + // whenever the device is surprise removed. + // + deviceCapabilities->SurpriseRemovalOK = TRUE; + + // We don't support system-wide unique IDs. + + deviceCapabilities->UniqueID = FALSE; + + // + // Specify whether the Device Manager should suppress all + // installation pop-ups except required pop-ups such as + // "no compatible drivers found." + // + + deviceCapabilities->SilentInstall = FALSE; + + // + // Specifies an address indicating where the device is located + // on its underlying bus. The interpretation of this number is + // bus-specific. If the address is unknown or the bus driver + // does not support an address, the bus driver leaves this + // member at its default value of 0xFFFFFFFF. In this example + // the location address is same as instance id. + // + + //deviceCapabilities->Address = DeviceData->SerialNo; + + // + // UINumber specifies a number associated with the device that can + // be displayed in the user interface. + // + //deviceCapabilities->UINumber = DeviceData->SerialNo; + + return STATUS_SUCCESS; + +} + +NTSTATUS +Bus_PDO_QueryDeviceId( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + PIO_STACK_LOCATION stack; + PWCHAR buffer; + WCHAR temp[256]; + ULONG length; + NTSTATUS status = STATUS_SUCCESS; + struct acpi_device *Device; + + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryId.IdType) { + + case BusQueryDeviceID: + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + length = swprintf(temp, + L"ACPI\\%hs", + Device->pnp.hardware_id); + + temp[++length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR), 'IPCA'); + + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof(WCHAR)); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + DPRINT("BusQueryDeviceID: %ls\n",buffer); + break; + + case BusQueryInstanceID: + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + if(Device->flags.unique_id) + length = swprintf(temp, + L"%hs", + Device->pnp.unique_id); + else + /* FIXME: Generate unique id! */ + length = swprintf(temp, L"%ls", L"0000"); + + temp[++length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof (WCHAR), 'IPCA'); + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof (WCHAR)); + DPRINT("BusQueryInstanceID: %ls\n",buffer); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + break; + + case BusQueryHardwareIDs: + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + length = 0; + + length += swprintf(&temp[length], + L"ACPI\\%hs", + Device->pnp.hardware_id); + length++; + + length += swprintf(&temp[length], + L"*%hs", + Device->pnp.hardware_id); + length++; + + temp[length] = UNICODE_NULL; + + length++; + + temp[length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR), 'IPCA'); + + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof(WCHAR)); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + DPRINT("BusQueryHardwareIDs: %ls\n",buffer); + break; + + default: + status = Irp->IoStatus.Status; + } + return status; +} + +NTSTATUS +Bus_PDO_QueryDeviceText( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + PWCHAR Buffer; + PIO_STACK_LOCATION stack; + NTSTATUS status; + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryDeviceText.DeviceTextType) { + + case DeviceTextDescription: + + if (!Irp->IoStatus.Information) { + if (wcsstr (DeviceData->HardwareIDs, L"PNP000") != 0) + Buffer = L"Programmable interrupt controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP010") != 0) + Buffer = L"System timer"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP020") != 0) + Buffer = L"DMA controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP03") != 0) + Buffer = L"Keyboard"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP040") != 0) + Buffer = L"Parallel port"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP05") != 0) + Buffer = L"Serial port"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP06") != 0) + Buffer = L"Disk controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP07") != 0) + Buffer = L"Disk controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP09") != 0) + Buffer = L"Display adapter"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0A0") != 0) + Buffer = L"Bus controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0E0") != 0) + Buffer = L"PCMCIA controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0F") != 0) + Buffer = L"Mouse device"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP8") != 0) + Buffer = L"Network adapter"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPA0") != 0) + Buffer = L"SCSI controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPB0") != 0) + Buffer = L"Multimedia device"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPC00") != 0) + Buffer = L"Modem"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0C") != 0) + Buffer = L"Power Button"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0E") != 0) + Buffer = L"Sleep Button"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0D") != 0) + Buffer = L"Lid Switch"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C09") != 0) + Buffer = L"ACPI Embedded Controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0B") != 0) + Buffer = L"ACPI Fan"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0A03") != 0) + Buffer = L"PCI Root Bridge"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0A") != 0) + Buffer = L"ACPI Battery"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0F") != 0) + Buffer = L"PCI Interrupt Link"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI_PWR") != 0) + Buffer = L"ACPI Power Resource"; + else if (wcsstr(DeviceData->HardwareIDs, L"Processor") != 0) + Buffer = L"Processor"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI_SYS") != 0) + Buffer = L"ACPI System"; + else if (wcsstr(DeviceData->HardwareIDs, L"ThermalZone") != 0) + Buffer = L"ACPI Thermal Zone"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI0002") != 0) + Buffer = L"Smart Battery"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI0003") != 0) + Buffer = L"AC Adapter"; + else + Buffer = L"Other ACPI device"; + + DPRINT("\tDeviceTextDescription :%ws\n", Buffer); + + Irp->IoStatus.Information = (ULONG_PTR) Buffer; + } + status = STATUS_SUCCESS; + break; + + default: + status = Irp->IoStatus.Status; + break; + } + + return status; + +} + +NTSTATUS +Bus_PDO_QueryResources( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + BOOLEAN Done; + ULONG NumberOfResources = 0; + PCM_RESOURCE_LIST ResourceList; + PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor; + ACPI_STATUS AcpiStatus; + ACPI_BUFFER Buffer; + ACPI_RESOURCE* resource; + ULONG ResourceListSize; + ULONG i; + + ULONG RequirementsListSize; + PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; + PIO_RESOURCE_DESCRIPTOR RequirementDescriptor; + + + /* Get current resources */ + Buffer.Length = 0; + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + return STATUS_SUCCESS; + } + if (Buffer.Length > 0) + { + Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length); + if (!Buffer.Pointer) + { + ASSERT(FALSE); + } + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + ASSERT(FALSE); + } + } + + resource= Buffer.Pointer; + /* Count number of resources */ + Done = FALSE; + while (!Done) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + NumberOfResources += irq_data->InterruptCount; + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + NumberOfResources += dma_data->ChannelCount; + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + NumberOfResources++; + break; + } + case ACPI_RESOURCE_TYPE_END_TAG: + { + Done = TRUE; + break; + } + default: + { + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + /* Allocate memory */ + ResourceListSize = sizeof(CM_RESOURCE_LIST) + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); + ResourceList = (PCM_RESOURCE_LIST)ExAllocatePool(PagedPool, ResourceListSize); + + if (!ResourceList) + return FALSE; + ResourceList->Count = 1; + ResourceList->List[0].InterfaceType = Internal; /* FIXME */ + ResourceList->List[0].BusNumber = 0; /* We're the only ACPI bus device in the system */ + ResourceList->List[0].PartialResourceList.Version = 1; + ResourceList->List[0].PartialResourceList.Revision = 1; + ResourceList->List[0].PartialResourceList.Count = NumberOfResources; + ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors; + + RequirementsListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); + RequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)ExAllocatePool(PagedPool, RequirementsListSize); + + if (!RequirementsList) + { + ExFreePool(ResourceList); + return STATUS_SUCCESS; + } + RequirementsList->ListSize = RequirementsListSize; + RequirementsList->InterfaceType = Internal; + RequirementsList->BusNumber = 0; + RequirementsList->SlotNumber = 0; /* Not used by WDM drivers */ + RequirementsList->AlternativeLists = 1; + RequirementsList->List[0].Version = 1; + RequirementsList->List[0].Revision = 1; + RequirementsList->List[0].Count = NumberOfResources; + RequirementDescriptor = RequirementsList->List[0].Descriptors; + + /* Fill resources list structure */ + Done = FALSE; + while (!Done) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + for (i = 0; i < irq_data->InterruptCount; i++) + { + ResourceDescriptor->Type = CmResourceTypeInterrupt; + + ResourceDescriptor->ShareDisposition = + (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); + ResourceDescriptor->Flags = + (irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); + ResourceDescriptor->u.Interrupt.Level = irq_data->Interrupts[i]; + ResourceDescriptor->u.Interrupt.Vector = 0; + ResourceDescriptor->u.Interrupt.Affinity = (KAFFINITY)(-1); + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = ResourceDescriptor->Type; + RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; + RequirementDescriptor->Flags = ResourceDescriptor->Flags; + RequirementDescriptor->u.Interrupt.MinimumVector = RequirementDescriptor->u.Interrupt.MaximumVector + = irq_data->Interrupts[i]; + + ResourceDescriptor++; + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + for (i = 0; i < dma_data->ChannelCount; i++) + { + ResourceDescriptor->Type = CmResourceTypeDma; + ResourceDescriptor->Flags = 0; + switch (dma_data->Type) + { + case ACPI_TYPE_A: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_A; break; + case ACPI_TYPE_B: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_B; break; + case ACPI_TYPE_F: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_F; break; + } + if (dma_data->BusMaster == ACPI_BUS_MASTER) + ResourceDescriptor->Flags |= CM_RESOURCE_DMA_BUS_MASTER; + switch (dma_data->Transfer) + { + case ACPI_TRANSFER_8: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8; break; + case ACPI_TRANSFER_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_16; break; + case ACPI_TRANSFER_8_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break; + } + ResourceDescriptor->u.Dma.Channel = dma_data->Channels[i]; + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = ResourceDescriptor->Type; + RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; + RequirementDescriptor->Flags = ResourceDescriptor->Flags; + RequirementDescriptor->u.Dma.MinimumChannel = RequirementDescriptor->u.Dma.MaximumChannel + = ResourceDescriptor->u.Dma.Channel; + + ResourceDescriptor++; + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + ACPI_RESOURCE_IO *io_data = (ACPI_RESOURCE_IO*) &resource->Data; + ResourceDescriptor->Type = CmResourceTypePort; + ResourceDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (io_data->IoDecode == ACPI_DECODE_16) + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_16_BIT_DECODE; + else + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE; + ResourceDescriptor->u.Port.Start.u.HighPart = 0; + ResourceDescriptor->u.Port.Start.u.LowPart = io_data->Minimum; + ResourceDescriptor->u.Port.Length = io_data->AddressLength; + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = ResourceDescriptor->Type; + RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; + RequirementDescriptor->Flags = ResourceDescriptor->Flags; + RequirementDescriptor->u.Port.Length = ResourceDescriptor->u.Port.Length; + RequirementDescriptor->u.Port.Alignment = 1; /* Start address is specified, so it doesn't matter */ + RequirementDescriptor->u.Port.MinimumAddress = RequirementDescriptor->u.Port.MaximumAddress + = ResourceDescriptor->u.Port.Start; + + ResourceDescriptor++; + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_END_TAG: + { + Done = TRUE; + break; + } + default: + { + DPRINT1("Unhandled resource type\n"); + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + ExFreePool(Buffer.Pointer); + Irp->IoStatus.Information = (ULONG_PTR)ResourceList; + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_PDO_QueryResourceRequirements( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + BOOLEAN Done; + ULONG NumberOfResources = 0; + ACPI_STATUS AcpiStatus; + ACPI_BUFFER Buffer; + ACPI_RESOURCE* resource; + ULONG i, RequirementsListSize; + PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; + PIO_RESOURCE_DESCRIPTOR RequirementDescriptor; + + PAGED_CODE (); + + + /* Get current resources */ + Buffer.Length = 0; + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + return STATUS_SUCCESS; + } + if (Buffer.Length > 0) + { + Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length); + if (!Buffer.Pointer) + { + ASSERT(FALSE); + } + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + ASSERT(FALSE); + } + } + + resource= Buffer.Pointer; + /* Count number of resources */ + Done = FALSE; + while (!Done) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + NumberOfResources += irq_data->InterruptCount; + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + NumberOfResources += dma_data->ChannelCount; + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + NumberOfResources++; + break; + } + case ACPI_RESOURCE_TYPE_END_TAG: + { + Done = TRUE; + break; + } + default: + { + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + RequirementsListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); + RequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)ExAllocatePool(PagedPool, RequirementsListSize); + + if (!RequirementsList) + { + ExFreePool(Buffer.Pointer); + return STATUS_SUCCESS; + } + RequirementsList->ListSize = RequirementsListSize; + RequirementsList->InterfaceType = Internal; + RequirementsList->BusNumber = 0; + RequirementsList->SlotNumber = 0; /* Not used by WDM drivers */ + RequirementsList->AlternativeLists = 1; + RequirementsList->List[0].Version = 1; + RequirementsList->List[0].Revision = 1; + RequirementsList->List[0].Count = NumberOfResources; + RequirementDescriptor = RequirementsList->List[0].Descriptors; + + /* Fill resources list structure */ + Done = FALSE; + while (!Done) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + for (i = 0; i < irq_data->InterruptCount; i++) + { + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = CmResourceTypeInterrupt; + RequirementDescriptor->ShareDisposition = (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); + RequirementDescriptor->Flags =(irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); + RequirementDescriptor->u.Interrupt.MinimumVector = irq_data->Interrupts[i]; + + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + for (i = 0; i < dma_data->ChannelCount; i++) + { + RequirementDescriptor->Type = CmResourceTypeDma; + RequirementDescriptor->Flags = 0; + switch (dma_data->Type) + { + case ACPI_TYPE_A: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_A; break; + case ACPI_TYPE_B: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_B; break; + case ACPI_TYPE_F: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_F; break; + } + if (dma_data->BusMaster == ACPI_BUS_MASTER) + RequirementDescriptor->Flags |= CM_RESOURCE_DMA_BUS_MASTER; + switch (dma_data->Transfer) + { + case ACPI_TRANSFER_8: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_8; break; + case ACPI_TRANSFER_16: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_16; break; + case ACPI_TRANSFER_8_16: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break; + } + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + RequirementDescriptor->u.Dma.MinimumChannel = dma_data->Channels[i]; + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + ACPI_RESOURCE_IO *io_data = (ACPI_RESOURCE_IO*) &resource->Data; + RequirementDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (io_data->IoDecode == ACPI_DECODE_16) + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_16_BIT_DECODE; + else + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE; + + RequirementDescriptor->u.Port.Length = io_data->AddressLength; + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = CmResourceTypePort; + RequirementDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + RequirementDescriptor->u.Port.Alignment = 1; /* Start address is specified, so it doesn't matter */ + RequirementDescriptor->u.Port.MinimumAddress.QuadPart = io_data->Minimum; + RequirementDescriptor->u.Port.MaximumAddress.QuadPart = io_data->Maximum; + + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_END_TAG: + { + Done = TRUE; + break; + } + default: + { + DPRINT1("Unhandled resource type\n"); + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + ExFreePool(Buffer.Pointer); + + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_PDO_QueryDeviceRelations( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +/*++ + +Routine Description: + + The PnP Manager sends this IRP to gather information about + devices with a relationship to the specified device. + Bus drivers must handle this request for TargetDeviceRelation + for their child devices (child PDOs). + + If a driver returns relations in response to this IRP, + it allocates a DEVICE_RELATIONS structure from paged + memory containing a count and the appropriate number of + device object pointers. The PnP Manager frees the structure + when it is no longer needed. If a driver replaces a + DEVICE_RELATIONS structure allocated by another driver, + it must free the previous structure. + + A driver must reference the PDO of any device that it + reports in this IRP (ObReferenceObject). The PnP Manager + removes the reference when appropriate. + +Arguments: + + DeviceData - Pointer to the PDO's device extension. + Irp - Pointer to the irp. + +Return Value: + + NT STATUS + +--*/ +{ + + PIO_STACK_LOCATION stack; + PDEVICE_RELATIONS deviceRelations; + NTSTATUS status; + + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryDeviceRelations.Type) { + + case TargetDeviceRelation: + + deviceRelations = (PDEVICE_RELATIONS) Irp->IoStatus.Information; + if (deviceRelations) { + // + // Only PDO can handle this request. Somebody above + // is not playing by rule. + // + ASSERTMSG("Someone above is handling TargetDeviceRelation", !deviceRelations); + } + + deviceRelations = (PDEVICE_RELATIONS) + ExAllocatePoolWithTag (PagedPool, + sizeof(DEVICE_RELATIONS), + 'IPCA'); + if (!deviceRelations) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + // + // There is only one PDO pointer in the structure + // for this relation type. The PnP Manager removes + // the reference to the PDO when the driver or application + // un-registers for notification on the device. + // + + deviceRelations->Count = 1; + deviceRelations->Objects[0] = DeviceData->Common.Self; + ObReferenceObject(DeviceData->Common.Self); + + status = STATUS_SUCCESS; + Irp->IoStatus.Information = (ULONG_PTR) deviceRelations; + break; + + case BusRelations: // Not handled by PDO + case EjectionRelations: // optional for PDO + case RemovalRelations: // // optional for PDO + default: + status = Irp->IoStatus.Status; + } + + return status; +} + +NTSTATUS +Bus_PDO_QueryBusInformation( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +/*++ + +Routine Description: + + The PnP Manager uses this IRP to request the type and + instance number of a device's parent bus. Bus drivers + should handle this request for their child devices (PDOs). + +Arguments: + + DeviceData - Pointer to the PDO's device extension. + Irp - Pointer to the irp. + +Return Value: + + NT STATUS + +--*/ +{ + + PPNP_BUS_INFORMATION busInfo; + + PAGED_CODE (); + + busInfo = ExAllocatePoolWithTag (PagedPool, sizeof(PNP_BUS_INFORMATION), + 'IPCA'); + + if (busInfo == NULL) { + return STATUS_INSUFFICIENT_RESOURCES; + } + + busInfo->BusTypeGuid = GUID_ACPI_INTERFACE_STANDARD; + + busInfo->LegacyBusType = InternalPowerBus; + + busInfo->BusNumber = 0; //fixme + + Irp->IoStatus.Information = (ULONG_PTR)busInfo; + + return STATUS_SUCCESS; +} + + +NTSTATUS +Bus_GetDeviceCapabilities( + PDEVICE_OBJECT DeviceObject, + PDEVICE_CAPABILITIES DeviceCapabilities + ) +{ + IO_STATUS_BLOCK ioStatus; + KEVENT pnpEvent; + NTSTATUS status; + PDEVICE_OBJECT targetObject; + PIO_STACK_LOCATION irpStack; + PIRP pnpIrp; + + PAGED_CODE(); + + // + // Initialize the capabilities that we will send down + // + RtlZeroMemory( DeviceCapabilities, sizeof(DEVICE_CAPABILITIES) ); + DeviceCapabilities->Size = sizeof(DEVICE_CAPABILITIES); + DeviceCapabilities->Version = 1; + DeviceCapabilities->Address = -1; + DeviceCapabilities->UINumber = -1; + + // + // Initialize the event + // + KeInitializeEvent( &pnpEvent, NotificationEvent, FALSE ); + + targetObject = IoGetAttachedDeviceReference( DeviceObject ); + + // + // Build an Irp + // + pnpIrp = IoBuildSynchronousFsdRequest( + IRP_MJ_PNP, + targetObject, + NULL, + 0, + NULL, + &pnpEvent, + &ioStatus + ); + if (pnpIrp == NULL) { + + status = STATUS_INSUFFICIENT_RESOURCES; + goto GetDeviceCapabilitiesExit; + + } + + // + // Pnp Irps all begin life as STATUS_NOT_SUPPORTED; + // + pnpIrp->IoStatus.Status = STATUS_NOT_SUPPORTED; + + // + // Get the top of stack + // + irpStack = IoGetNextIrpStackLocation( pnpIrp ); + + // + // Set the top of stack + // + RtlZeroMemory( irpStack, sizeof(IO_STACK_LOCATION ) ); + irpStack->MajorFunction = IRP_MJ_PNP; + irpStack->MinorFunction = IRP_MN_QUERY_CAPABILITIES; + irpStack->Parameters.DeviceCapabilities.Capabilities = DeviceCapabilities; + + // + // Call the driver + // + status = IoCallDriver( targetObject, pnpIrp ); + if (status == STATUS_PENDING) { + + // + // Block until the irp comes back. + // Important thing to note here is when you allocate + // the memory for an event in the stack you must do a + // KernelMode wait instead of UserMode to prevent + // the stack from getting paged out. + // + + KeWaitForSingleObject( + &pnpEvent, + Executive, + KernelMode, + FALSE, + NULL + ); + status = ioStatus.Status; + + } + +GetDeviceCapabilitiesExit: + // + // Done with reference + // + ObDereferenceObject( targetObject ); + + // + // Done + // + return status; + +} + + diff --git a/reactos/drivers/bus/acpi/include/acpi_bus.h b/reactos/drivers/bus/acpi/include/acpi_bus.h new file mode 100644 index 00000000000..fa264a19c27 --- /dev/null +++ b/reactos/drivers/bus/acpi/include/acpi_bus.h @@ -0,0 +1,385 @@ +/* + * acpi_bus.h - ACPI Bus Driver ($Revision: 22 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#ifndef __ACPI_BUS_H__ +#define __ACPI_BUS_H__ + +#include + +#include "list.h" + + +/* TBD: Make dynamic */ +#define ACPI_MAX_HANDLES 10 +struct acpi_handle_list { + UINT32 count; + ACPI_HANDLE handles[ACPI_MAX_HANDLES]; +}; + + +/* acpi_utils.h */ +ACPI_STATUS +acpi_extract_package ( + ACPI_OBJECT *package, + ACPI_BUFFER *format, + ACPI_BUFFER *buffer); +ACPI_STATUS +acpi_evaluate_integer ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + struct acpi_object_list *arguments, + unsigned long long *data); +ACPI_STATUS +acpi_evaluate_reference ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + struct acpi_object_list *arguments, + struct acpi_handle_list *list); + +enum acpi_bus_removal_type { + ACPI_BUS_REMOVAL_NORMAL = 0, + ACPI_BUS_REMOVAL_EJECT, + ACPI_BUS_REMOVAL_SUPRISE, + ACPI_BUS_REMOVAL_TYPE_COUNT +}; + +enum acpi_bus_device_type { + ACPI_BUS_TYPE_DEVICE = 0, + ACPI_BUS_TYPE_POWER, + ACPI_BUS_TYPE_PROCESSOR, + ACPI_BUS_TYPE_THERMAL, + ACPI_BUS_TYPE_SYSTEM, + ACPI_BUS_TYPE_POWER_BUTTON, + ACPI_BUS_TYPE_SLEEP_BUTTON, + ACPI_BUS_DEVICE_TYPE_COUNT +}; + +struct acpi_driver; +struct acpi_device; + + +/* + * ACPI Driver + * ----------- + */ + +typedef int (*acpi_op_add) (struct acpi_device *device); +typedef int (*acpi_op_remove) (struct acpi_device *device, int type); +typedef int (*acpi_op_start) (struct acpi_device *device); +typedef int (*acpi_op_suspend) (struct acpi_device *device, int state); +typedef int (*acpi_op_resume) (struct acpi_device *device, int state); +typedef int (*acpi_op_scan) (struct acpi_device *device); +typedef int (*acpi_op_bind) (struct acpi_device *device); +typedef int (*acpi_op_unbind) (struct acpi_device * device); +typedef void (*acpi_op_notify) (struct acpi_device * device, UINT32 event); + +struct acpi_bus_ops { + UINT32 acpi_op_add:1; + UINT32 acpi_op_start:1; +}; + +struct acpi_device_ops { + acpi_op_add add; + acpi_op_remove remove; + acpi_op_start start; + acpi_op_suspend suspend; + acpi_op_resume resume; + acpi_op_bind bind; + acpi_op_unbind unbind; + acpi_op_notify notify; + acpi_op_scan scan; +}; + +#define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */ + +struct acpi_driver { + struct list_head node; + char name[80]; + char class[80]; + int references; + unsigned int flags; + char *ids; /* Supported Hardware IDs */ + struct acpi_device_ops ops; +}; + +/* + * ACPI Device + * ----------- + */ + +/* Status (_STA) */ + +struct acpi_device_status { + UINT32 present:1; + UINT32 enabled:1; + UINT32 show_in_ui:1; + UINT32 functional:1; + UINT32 battery_present:1; + UINT32 reserved:27; +}; + + +/* Flags */ + +struct acpi_device_flags { + UINT32 dynamic_status:1; + UINT32 hardware_id:1; + UINT32 compatible_ids:1; + UINT32 bus_address:1; + UINT32 unique_id:1; + UINT32 removable:1; + UINT32 ejectable:1; + UINT32 lockable:1; + UINT32 suprise_removal_ok:1; + UINT32 power_manageable:1; + UINT32 performance_manageable:1; + UINT32 wake_capable:1; + UINT32 force_power_state:1; + UINT32 reserved:20; +}; + +/* Plug and Play */ + +typedef char acpi_bus_id[8]; +typedef unsigned long acpi_bus_address; +typedef char acpi_hardware_id[9]; +typedef char acpi_unique_id[9]; +typedef char acpi_device_name[40]; +typedef char acpi_device_class[20]; + +struct acpi_device_pnp { + acpi_bus_id bus_id; /* Object name */ + acpi_bus_address bus_address; /* _ADR */ + acpi_hardware_id hardware_id; /* _HID */ + ACPI_DEVICE_ID_LIST *cid_list; /* _CIDs */ + acpi_unique_id unique_id; /* _UID */ + acpi_device_name device_name; /* Driver-determined */ + acpi_device_class device_class; /* " */ +}; + +#define acpi_device_bid(d) ((d)->pnp.bus_id) +#define acpi_device_adr(d) ((d)->pnp.bus_address) +#define acpi_device_hid(d) ((d)->pnp.hardware_id) +#define acpi_device_uid(d) ((d)->pnp.unique_id) +#define acpi_device_name(d) ((d)->pnp.device_name) +#define acpi_device_class(d) ((d)->pnp.device_class) + + +/* Power Management */ + +struct acpi_device_power_flags { + UINT32 explicit_get:1; /* _PSC present? */ + UINT32 power_resources:1; /* Power resources */ + UINT32 inrush_current:1; /* Serialize Dx->D0 */ + UINT32 power_removed:1; /* Optimize Dx->D0 */ + UINT32 reserved:28; +}; + +struct acpi_device_power_state { + struct { + UINT8 valid:1; + UINT8 explicit_set:1; /* _PSx present? */ + UINT8 reserved:6; + } flags; + int power; /* % Power (compared to D0) */ + int latency; /* Dx->D0 time (microseconds) */ + struct acpi_handle_list resources; /* Power resources referenced */ +}; + +struct acpi_device_power { + int state; /* Current state */ + struct acpi_device_power_flags flags; + struct acpi_device_power_state states[4]; /* Power states (D0-D3) */ +}; + + +/* Performance Management */ + +struct acpi_device_perf_flags { + UINT8 reserved:8; +}; + +struct acpi_device_perf_state { + struct { + UINT8 valid:1; + UINT8 reserved:7; + } flags; + UINT8 power; /* % Power (compared to P0) */ + UINT8 performance; /* % Performance ( " ) */ + int latency; /* Px->P0 time (microseconds) */ +}; + +struct acpi_device_perf { + int state; + struct acpi_device_perf_flags flags; + int state_count; + struct acpi_device_perf_state *states; +}; + +/* Wakeup Management */ +struct acpi_device_wakeup_flags { + UINT8 valid:1; /* Can successfully enable wakeup? */ + UINT8 run_wake:1; /* Run-Wake GPE devices */ +}; + +struct acpi_device_wakeup_state { + UINT8 enabled:1; +}; + +struct acpi_device_wakeup { + ACPI_HANDLE gpe_device; + ACPI_INTEGER gpe_number; + ACPI_INTEGER sleep_state; + struct acpi_handle_list resources; + struct acpi_device_wakeup_state state; + struct acpi_device_wakeup_flags flags; + int prepare_count; +}; + + +/* Device */ + +struct acpi_device { + int device_type; + ACPI_HANDLE handle; + struct acpi_device *parent; + struct list_head children; + struct list_head node; + struct list_head wakeup_list; + struct acpi_device_status status; + struct acpi_device_flags flags; + struct acpi_device_pnp pnp; + struct acpi_device_power power; + struct acpi_device_wakeup wakeup; + struct acpi_device_perf performance; + struct acpi_device_ops ops; + struct acpi_driver *driver; + void *driver_data; + struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ + enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ + +}; + +#define acpi_driver_data(d) ((d)->driver_data) + +#define to_acpi_device(d) container_of(d, struct acpi_device, dev) +#define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) + +/* acpi_device.dev.bus == &acpi_bus_type */ +extern struct bus_type acpi_bus_type; + +/* + * Events + * ------ + */ + +struct acpi_bus_event { + struct list_head node; + acpi_device_class device_class; + acpi_bus_id bus_id; + UINT32 type; + UINT32 data; +}; + + +/* + * External Functions + */ +int acpi_bus_get_private_data(ACPI_HANDLE, void **); + +void acpi_bus_data_handler(ACPI_HANDLE handle, void *context); +ACPI_STATUS acpi_bus_get_status_handle(ACPI_HANDLE handle, + unsigned long long *sta); +int acpi_bus_get_status(struct acpi_device *device); +int acpi_bus_get_power(ACPI_HANDLE handle, int *state); +int acpi_bus_set_power(ACPI_HANDLE handle, int state); +BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle); +BOOLEAN acpi_bus_can_wakeup(ACPI_HANDLE handle); +int acpi_bus_generate_proc_event(struct acpi_device *device, UINT8 type, int data); +int acpi_bus_receive_event(struct acpi_bus_event *event); +int acpi_bus_register_driver(struct acpi_driver *driver); +void acpi_bus_unregister_driver(struct acpi_driver *driver); +int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, + ACPI_HANDLE handle, int type); +int acpi_bus_trim(struct acpi_device *start, int rmdevice); +int acpi_bus_start(struct acpi_device *device); +ACPI_STATUS acpi_bus_get_ejd(ACPI_HANDLE handle, ACPI_HANDLE * ejd); +int acpi_match_device_ids(struct acpi_device *device, + const struct acpi_device_id *ids); + +/* + * Bind physical devices with ACPI devices + */ +//struct acpi_bus_type { +// struct list_head list; +// struct bus_type *bus; +// /* For general devices under the bus */ +// int (*find_device) (struct device *, ACPI_HANDLE *); +// /* For bridges, such as PCI root bridge, IDE controller */ +// int (*find_bridge) (struct device *, ACPI_HANDLE *); +//}; +//int register_acpi_bus_type(struct acpi_bus_type *); +//int unregister_acpi_bus_type(struct acpi_bus_type *); +//struct device *acpi_get_physical_device(ACPI_HANDLE); + +struct acpi_pci_root { + struct list_head node; + struct acpi_device * device; + struct acpi_pci_id id; + struct pci_bus *bus; + UINT16 segment; + UINT8 bus_nr; + + UINT32 osc_support_set; /* _OSC state of support bits */ + UINT32 osc_control_set; /* _OSC state of control bits */ + UINT32 osc_control_qry; /* the latest _OSC query result */ + + UINT32 osc_queried:1; /* has _OSC control been queried? */ +}; + +//static inline int acpi_pm_device_sleep_state(struct device *d, int *p) +//{ +// if (p) +// *p = ACPI_STATE_D0; +// return ACPI_STATE_D3; +//} +//static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable) +//{ +// return -1; +//} + +/* system defines: move to bigger header */ +extern enum acpi_irq_model_id acpi_irq_model; + +enum acpi_irq_model_id { + ACPI_IRQ_MODEL_PIC = 0, + ACPI_IRQ_MODEL_IOAPIC, + ACPI_IRQ_MODEL_IOSAPIC, + ACPI_IRQ_MODEL_COUNT +}; + + + +#endif /*__ACPI_BUS_H__*/ diff --git a/reactos/drivers/bus/acpi/include/acpi_drivers.h b/reactos/drivers/bus/acpi/include/acpi_drivers.h new file mode 100644 index 00000000000..6506e44882b --- /dev/null +++ b/reactos/drivers/bus/acpi/include/acpi_drivers.h @@ -0,0 +1,340 @@ +/* + * acpi_drivers.h ($Revision: 32 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#ifndef __ACPI_DRIVERS_H__ +#define __ACPI_DRIVERS_H__ + +#define ACPI_MAX_STRING 80 + + +/* -------------------------------------------------------------------------- + ACPI Bus + -------------------------------------------------------------------------- */ + +#define ACPI_BUS_COMPONENT 0x00010000 +#define ACPI_BUS_CLASS "system_bus" +#define ACPI_BUS_HID "ACPI_BUS" +#define ACPI_BUS_DRIVER_NAME "ACPI Bus Driver" +#define ACPI_BUS_DEVICE_NAME "System Bus" + + +/* -------------------------------------------------------------------------- + AC Adapter + -------------------------------------------------------------------------- */ + +#define ACPI_AC_COMPONENT 0x00020000 +#define ACPI_AC_CLASS "ac_adapter" +#define ACPI_AC_HID "ACPI0003" +#define ACPI_AC_DRIVER_NAME "ACPI AC Adapter Driver" +#define ACPI_AC_DEVICE_NAME "AC Adapter" +#define ACPI_AC_FILE_STATE "state" +#define ACPI_AC_NOTIFY_STATUS 0x80 +#define ACPI_AC_STATUS_OFFLINE 0x00 +#define ACPI_AC_STATUS_ONLINE 0x01 +#define ACPI_AC_STATUS_UNKNOWN 0xFF + + +/* -------------------------------------------------------------------------- + Battery + -------------------------------------------------------------------------- */ + +#define ACPI_BATTERY_COMPONENT 0x00040000 +#define ACPI_BATTERY_CLASS "battery" +#define ACPI_BATTERY_HID "PNP0C0A" +#define ACPI_BATTERY_DRIVER_NAME "ACPI Battery Driver" +#define ACPI_BATTERY_DEVICE_NAME "Battery" +#define ACPI_BATTERY_FILE_INFO "info" +#define ACPI_BATTERY_FILE_STATUS "state" +#define ACPI_BATTERY_FILE_ALARM "alarm" +#define ACPI_BATTERY_NOTIFY_STATUS 0x80 +#define ACPI_BATTERY_NOTIFY_INFO 0x81 +#define ACPI_BATTERY_UNITS_WATTS "mW" +#define ACPI_BATTERY_UNITS_AMPS "mA" + + +/* -------------------------------------------------------------------------- + Button + -------------------------------------------------------------------------- */ + +#define ACPI_BUTTON_COMPONENT 0x00080000 +#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" +#define ACPI_BUTTON_CLASS "button" +#define ACPI_BUTTON_FILE_INFO "info" +#define ACPI_BUTTON_FILE_STATE "state" +#define ACPI_BUTTON_TYPE_UNKNOWN 0x00 +#define ACPI_BUTTON_NOTIFY_STATUS 0x80 + +#define ACPI_BUTTON_SUBCLASS_POWER "power" +#define ACPI_BUTTON_HID_POWER "PNP0C0C" +#define ACPI_BUTTON_HID_POWERF "ACPI_FPB" +#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)" +#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)" +#define ACPI_BUTTON_TYPE_POWER 0x01 +#define ACPI_BUTTON_TYPE_POWERF 0x02 + +#define ACPI_BUTTON_SUBCLASS_SLEEP "sleep" +#define ACPI_BUTTON_HID_SLEEP "PNP0C0E" +#define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB" +#define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button (CM)" +#define ACPI_BUTTON_DEVICE_NAME_SLEEPF "Sleep Button (FF)" +#define ACPI_BUTTON_TYPE_SLEEP 0x03 +#define ACPI_BUTTON_TYPE_SLEEPF 0x04 + +#define ACPI_BUTTON_SUBCLASS_LID "lid" +#define ACPI_BUTTON_HID_LID "PNP0C0D" +#define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch" +#define ACPI_BUTTON_TYPE_LID 0x05 + +int acpi_button_init (void); +void acpi_button_exit (void); + +/* -------------------------------------------------------------------------- + Embedded Controller + -------------------------------------------------------------------------- */ + +#define ACPI_EC_COMPONENT 0x00100000 +#define ACPI_EC_CLASS "embedded_controller" +#define ACPI_EC_HID "PNP0C09" +#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" +#define ACPI_EC_DEVICE_NAME "Embedded Controller" +#define ACPI_EC_FILE_INFO "info" + +#ifdef CONFIG_ACPI_EC + +int acpi_ec_ecdt_probe (void); +int acpi_ec_init (void); +void acpi_ec_exit (void); + +#endif + + +/* -------------------------------------------------------------------------- + Fan + -------------------------------------------------------------------------- */ + +#define ACPI_FAN_COMPONENT 0x00200000 +#define ACPI_FAN_CLASS "fan" +#define ACPI_FAN_HID "PNP0C0B" +#define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver" +#define ACPI_FAN_DEVICE_NAME "Fan" +#define ACPI_FAN_FILE_STATE "state" +#define ACPI_FAN_NOTIFY_STATUS 0x80 + + +/* -------------------------------------------------------------------------- + PCI + -------------------------------------------------------------------------- */ + +#ifdef CONFIG_ACPI_PCI + +#define ACPI_PCI_COMPONENT 0x00400000 + +/* ACPI PCI Root Bridge (pci_root.c) */ + +#define ACPI_PCI_ROOT_CLASS "pci_bridge" +#define ACPI_PCI_ROOT_HID "PNP0A03" +#define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver" +#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" + +int acpi_pci_root_init (void); +void acpi_pci_root_exit (void); + +/* ACPI PCI Interrupt Link (pci_link.c) */ + +#define ACPI_PCI_LINK_CLASS "pci_irq_routing" +#define ACPI_PCI_LINK_HID "PNP0C0F" +#define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver" +#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" +#define ACPI_PCI_LINK_FILE_INFO "info" +#define ACPI_PCI_LINK_FILE_STATUS "state" + +int acpi_pci_link_check (void); +int acpi_pci_link_get_irq (ACPI_HANDLE handle, int index, int* edge_level, int* active_high_low); +int acpi_pci_link_init (void); +void acpi_pci_link_exit (void); + +/* ACPI PCI Interrupt Routing (pci_irq.c) */ + +int acpi_pci_irq_add_prt (ACPI_HANDLE handle, int segment, int bus); + +/* ACPI PCI Device Binding (pci_bind.c) */ + +struct pci_bus; + +int acpi_pci_bind (struct acpi_device *device); +int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus); + +#endif /*CONFIG_ACPI_PCI*/ + + +/* -------------------------------------------------------------------------- + Power Resource + -------------------------------------------------------------------------- */ + +#define ACPI_POWER_COMPONENT 0x00800000 +#define ACPI_POWER_CLASS "power_resource" +#define ACPI_POWER_HID "ACPI_PWR" +#define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver" +#define ACPI_POWER_DEVICE_NAME "Power Resource" +#define ACPI_POWER_FILE_INFO "info" +#define ACPI_POWER_FILE_STATUS "state" +#define ACPI_POWER_RESOURCE_STATE_OFF 0x00 +#define ACPI_POWER_RESOURCE_STATE_ON 0x01 +#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF + + + +int acpi_power_get_inferred_state (struct acpi_device *device); +int acpi_power_transition (struct acpi_device *device, int state); +int acpi_power_init (void); +void acpi_power_exit (void); + + +/* -------------------------------------------------------------------------- + Processor + -------------------------------------------------------------------------- */ + +#define ACPI_PROCESSOR_COMPONENT 0x01000000 +#define ACPI_PROCESSOR_CLASS "processor" +#define ACPI_PROCESSOR_HID "Processor" +#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" +#define ACPI_PROCESSOR_DEVICE_NAME "Processor" +#define ACPI_PROCESSOR_FILE_INFO "info" +#define ACPI_PROCESSOR_FILE_POWER "power" +#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" +#define ACPI_PROCESSOR_FILE_THROTTLING "throttling" +#define ACPI_PROCESSOR_FILE_LIMIT "limit" +#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 +#define ACPI_PROCESSOR_NOTIFY_POWER 0x81 +#define ACPI_PROCESSOR_LIMIT_NONE 0x00 +#define ACPI_PROCESSOR_LIMIT_INCREMENT 0x01 +#define ACPI_PROCESSOR_LIMIT_DECREMENT 0x02 + +int acpi_processor_set_thermal_limit(ACPI_HANDLE handle, int type); + + +/* -------------------------------------------------------------------------- + System + -------------------------------------------------------------------------- */ + +#define ACPI_SYSTEM_COMPONENT 0x02000000 +#define ACPI_SYSTEM_CLASS "system" +#define ACPI_SYSTEM_HID "ACPI_SYS" +#define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" +#define ACPI_SYSTEM_DEVICE_NAME "System" +#define ACPI_SYSTEM_FILE_INFO "info" +#define ACPI_SYSTEM_FILE_EVENT "event" +#define ACPI_SYSTEM_FILE_ALARM "alarm" +#define ACPI_SYSTEM_FILE_DSDT "dsdt" +#define ACPI_SYSTEM_FILE_FADT "fadt" +#define ACPI_SYSTEM_FILE_SLEEP "sleep" +#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" +#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" + +int acpi_system_init (void); +void acpi_system_exit (void); + + +/* -------------------------------------------------------------------------- + Thermal Zone + -------------------------------------------------------------------------- */ + +#define ACPI_THERMAL_COMPONENT 0x04000000 +#define ACPI_THERMAL_CLASS "thermal_zone" +#define ACPI_THERMAL_HID "ThermalZone" +#define ACPI_THERMAL_DRIVER_NAME "ACPI Thermal Zone Driver" +#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" +#define ACPI_THERMAL_FILE_STATE "state" +#define ACPI_THERMAL_FILE_TEMPERATURE "temperature" +#define ACPI_THERMAL_FILE_TRIP_POINTS "trip_points" +#define ACPI_THERMAL_FILE_COOLING_MODE "cooling_mode" +#define ACPI_THERMAL_FILE_POLLING_FREQ "polling_frequency" +#define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80 +#define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81 +#define ACPI_THERMAL_NOTIFY_DEVICES 0x82 +#define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 +#define ACPI_THERMAL_NOTIFY_HOT 0xF1 +#define ACPI_THERMAL_MODE_ACTIVE 0x00 +#define ACPI_THERMAL_MODE_PASSIVE 0x01 +#define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff" + +/* Motherboard devices */ +int acpi_motherboard_init(void); +/* -------------------------------------------------------------------------- + Debug Support + -------------------------------------------------------------------------- */ + +#define ACPI_DEBUG_RESTORE 0 +#define ACPI_DEBUG_LOW 1 +#define ACPI_DEBUG_MEDIUM 2 +#define ACPI_DEBUG_HIGH 3 +#define ACPI_DEBUG_DRIVERS 4 + +extern UINT32 acpi_dbg_level; +extern UINT32 acpi_dbg_layer; + +static inline void +acpi_set_debug ( + UINT32 flag) +{ + static UINT32 layer_save; + static UINT32 level_save; + + switch (flag) { + case ACPI_DEBUG_RESTORE: + acpi_dbg_layer = layer_save; + acpi_dbg_level = level_save; + break; + case ACPI_DEBUG_LOW: + case ACPI_DEBUG_MEDIUM: + case ACPI_DEBUG_HIGH: + case ACPI_DEBUG_DRIVERS: + layer_save = acpi_dbg_layer; + level_save = acpi_dbg_level; + break; + } + + switch (flag) { + case ACPI_DEBUG_LOW: + acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; + acpi_dbg_level = ACPI_DEBUG_DEFAULT; + break; + case ACPI_DEBUG_MEDIUM: + acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; + acpi_dbg_level = ACPI_LV_FUNCTIONS | ACPI_LV_ALL_EXCEPTIONS; + break; + case ACPI_DEBUG_HIGH: + acpi_dbg_layer = 0xFFFFFFFF; + acpi_dbg_level = 0xFFFFFFFF; + break; + case ACPI_DEBUG_DRIVERS: + acpi_dbg_layer = ACPI_ALL_DRIVERS; + acpi_dbg_level = 0xFFFFFFFF; + break; + } +} + + +#endif /*__ACPI_DRIVERS_H__*/ diff --git a/reactos/drivers/bus/acpi/include/acpisys.h b/reactos/drivers/bus/acpi/include/acpisys.h new file mode 100644 index 00000000000..4779d2233f8 --- /dev/null +++ b/reactos/drivers/bus/acpi/include/acpisys.h @@ -0,0 +1,292 @@ +/* + * PROJECT: ReactOS ACPI bus driver + * FILE: acpi/ospm/include/acpisys.h + * PURPOSE: ACPI bus driver definitions + */ +typedef enum _DEVICE_PNP_STATE { + + NotStarted = 0, // Not started yet + Started, // Device has received the START_DEVICE IRP + StopPending, // Device has received the QUERY_STOP IRP + Stopped, // Device has received the STOP_DEVICE IRP + UnKnown // Unknown state + +} DEVICE_PNP_STATE; + +// +// A common header for the device extensions of the PDOs and FDO +// + +typedef struct _COMMON_DEVICE_DATA +{ + PDEVICE_OBJECT Self; + BOOLEAN IsFDO; + DEVICE_PNP_STATE DevicePnPState; + DEVICE_PNP_STATE PreviousPnPState; + SYSTEM_POWER_STATE SystemPowerState; + DEVICE_POWER_STATE DevicePowerState; +} COMMON_DEVICE_DATA, *PCOMMON_DEVICE_DATA; + +typedef struct _PDO_DEVICE_DATA +{ + COMMON_DEVICE_DATA Common; + ACPI_HANDLE AcpiHandle; + // A back pointer to the bus + PDEVICE_OBJECT ParentFdo; + // An array of (zero terminated wide character strings). + // The array itself also null terminated + PWCHAR HardwareIDs; + // Link point to hold all the PDOs for a single bus together + LIST_ENTRY Link; + ULONG InterfaceRefCount; + +} PDO_DEVICE_DATA, *PPDO_DEVICE_DATA; + +// +// The device extension of the bus itself. From whence the PDO's are born. +// + +typedef struct _FDO_DEVICE_DATA +{ + COMMON_DEVICE_DATA Common; + PDEVICE_OBJECT UnderlyingPDO; + + // The underlying bus PDO and the actual device object to which our + // FDO is attached + PDEVICE_OBJECT NextLowerDriver; + + // List of PDOs created so far + LIST_ENTRY ListOfPDOs; + + // The PDOs currently enumerated. + ULONG NumPDOs; + + // A synchronization for access to the device extension. + FAST_MUTEX Mutex; + + // The name returned from IoRegisterDeviceInterface, + // which is used as a handle for IoSetDeviceInterfaceState. + UNICODE_STRING InterfaceName; + +} FDO_DEVICE_DATA, *PFDO_DEVICE_DATA; + +#define FDO_FROM_PDO(pdoData) \ + ((PFDO_DEVICE_DATA) (pdoData)->ParentFdo->DeviceExtension) + +#define INITIALIZE_PNP_STATE(_Data_) \ + (_Data_).DevicePnPState = NotStarted;\ + (_Data_).PreviousPnPState = NotStarted; + +#define SET_NEW_PNP_STATE(_Data_, _state_) \ + (_Data_).PreviousPnPState = (_Data_).DevicePnPState;\ + (_Data_).DevicePnPState = (_state_); + +#define RESTORE_PREVIOUS_PNP_STATE(_Data_) \ + (_Data_).DevicePnPState = (_Data_).PreviousPnPState;\ + +/* acpienum.c */ + +//NTSTATUS +//ACPIEnumerateDevices( +// PFDO_DEVICE_EXTENSION DeviceExtension); + +NTSTATUS +NTAPI +Bus_CreateClose ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +VOID +Bus_DriverUnload ( + PDRIVER_OBJECT DriverObject + ); + +PCHAR +PnPMinorFunctionString ( + UCHAR MinorFunction +); + +NTSTATUS +NTAPI +Bus_AddDevice( + PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT PhysicalDeviceObject + ); + +NTSTATUS +Bus_SendIrpSynchronously ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +NTSTATUS +NTAPI +Bus_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +NTSTATUS +Bus_CompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context + ); + +VOID +Bus_InitializePdo ( + PDEVICE_OBJECT Pdo, + PFDO_DEVICE_DATA FdoData + ); + + +void +Bus_RemoveFdo ( + PFDO_DEVICE_DATA FdoData + ); + +NTSTATUS +Bus_DestroyPdo ( + PDEVICE_OBJECT Device, + PPDO_DEVICE_DATA PdoData + ); + + +NTSTATUS +Bus_FDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PFDO_DEVICE_DATA DeviceData + ); + + +NTSTATUS +Bus_StartFdo ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp ); + +PCHAR +DbgDeviceIDString( + BUS_QUERY_ID_TYPE Type + ); + +PCHAR +DbgDeviceRelationString( + DEVICE_RELATION_TYPE Type + ); + +NTSTATUS +Bus_FDO_Power ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp + ); + +NTSTATUS +Bus_PDO_Power ( + PPDO_DEVICE_DATA PdoData, + PIRP Irp + ); + +NTSTATUS +NTAPI +Bus_Power ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +PCHAR +PowerMinorFunctionString ( + UCHAR MinorFunction +); + +PCHAR +DbgSystemPowerString( + SYSTEM_POWER_STATE Type + ); + +PCHAR +DbgDevicePowerString( + DEVICE_POWER_STATE Type + ); + +NTSTATUS +Bus_PDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PPDO_DEVICE_DATA DeviceData + ); + +NTSTATUS +Bus_PDO_QueryDeviceCaps( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryDeviceId( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + + +NTSTATUS +Bus_PDO_QueryDeviceText( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryResources( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryResourceRequirements( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryDeviceRelations( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryBusInformation( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_GetDeviceCapabilities( + PDEVICE_OBJECT DeviceObject, + PDEVICE_CAPABILITIES DeviceCapabilities + ); + +NTSTATUS +Bus_PDO_QueryInterface( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +BOOLEAN +Bus_GetCrispinessLevel( + PVOID Context, + PUCHAR Level + ); +BOOLEAN +Bus_SetCrispinessLevel( + PVOID Context, + UCHAR Level + ); +BOOLEAN +Bus_IsSafetyLockEnabled( + PVOID Context + ); +VOID +Bus_InterfaceReference ( + PVOID Context + ); +VOID +Bus_InterfaceDereference ( + PVOID Context + ); + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/include/glue.h b/reactos/drivers/bus/acpi/include/glue.h new file mode 100644 index 00000000000..6b45ba8f42c --- /dev/null +++ b/reactos/drivers/bus/acpi/include/glue.h @@ -0,0 +1,30 @@ +#ifndef __GLUE_HEADER +#define __GLUE_HEADER + +#include + +/* header for linux macros and definitions */ + + /** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ + #define container_of(ptr, type, member) (type *)( (char *)(ptr) - offsetof(type,member) ) + + +#define time_after(a,b) \ + ((long)(b) - (long)(a) < 0)) + +#define time_before(a,b) time_after(b,a) + +#define in_interrupt() ((__readeflags() >> 9) & 1) + +typedef int (*acpi_table_handler) (ACPI_TABLE_HEADER *table); + +typedef int (*acpi_table_entry_handler) (ACPI_SUBTABLE_HEADER *header, const unsigned long end); + + +#endif diff --git a/reactos/drivers/bus/acpi/include/list.h b/reactos/drivers/bus/acpi/include/list.h new file mode 100644 index 00000000000..bac8727aa73 --- /dev/null +++ b/reactos/drivers/bus/acpi/include/list.h @@ -0,0 +1,251 @@ + #ifndef _LINUX_LIST_H + #define _LINUX_LIST_H + + + /* + * Simple doubly linked list implementation. + * + * Some of the internal functions ("__xxx") are useful when + * manipulating whole lists rather than single entries, as + * sometimes we already know the next/prev entries and we can + * generate better code by using them directly rather than + * using the generic single-entry routines. + */ + + struct list_head { + struct list_head *next, *prev; + }; + + #define LIST_HEAD_INIT(name) { &(name), &(name) } + + #define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + + #define INIT_LIST_HEAD(ptr) do { \ + (ptr)->next = (ptr); (ptr)->prev = (ptr); \ + } while (0) + + + /* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ + static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) + { + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; + } + + /** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ + static inline void list_add(struct list_head *new, struct list_head *head) + { + __list_add(new, head, head->next); + } + + /** + * list_add_tail - add a new entry + * @new: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + */ + static inline void list_add_tail(struct list_head *new, struct list_head *head) + { + __list_add(new, head->prev, head); + } + + /* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ + static inline void __list_del(struct list_head *prev, struct list_head *next) + { + next->prev = prev; + prev->next = next; + } + + /** + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * Note: list_empty on entry does not return true after this, the entry is in an undefined state. + */ + static inline void list_del(struct list_head *entry) + { + __list_del(entry->prev, entry->next); + entry->next = (void *) 0; + entry->prev = (void *) 0; + } + + /** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ + static inline void list_del_init(struct list_head *entry) + { + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); + } + + /** + * list_move - delete from one list and add as another's head + * @list: the entry to move + * @head: the head that will precede our entry + */ + static inline void list_move(struct list_head *list, struct list_head *head) + { + __list_del(list->prev, list->next); + list_add(list, head); + } + + /** + * list_move_tail - delete from one list and add as another's tail + * @list: the entry to move + * @head: the head that will follow our entry + */ + static inline void list_move_tail(struct list_head *list, + struct list_head *head) + { + __list_del(list->prev, list->next); + list_add_tail(list, head); + } + + /** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ + static inline int list_empty(struct list_head *head) + { + return head->next == head; + } + + static inline void __list_splice(struct list_head *list, + struct list_head *head) + { + struct list_head *first = list->next; + struct list_head *last = list->prev; + struct list_head *at = head->next; + + first->prev = head; + head->next = first; + + last->next = at; + at->prev = last; + } + +/** + * list_splice - join two lists + * @list: the new list to add. + * @head: the place to add it in the first list. + */ + static inline void list_splice(struct list_head *list, struct list_head *head) + { + if (!list_empty(list)) + __list_splice(list, head); + } + + /** + * list_splice_init - join two lists and reinitialise the emptied list. + * @list: the new list to add. + * @head: the place to add it in the first list. + * + * The list at @list is reinitialised + */ + static inline void list_splice_init(struct list_head *list, + struct list_head *head) + { + if (!list_empty(list)) { + __list_splice(list, head); + INIT_LIST_HEAD(list); + } + } + + /** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ + #define list_entry(ptr, type, member) \ + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + + /** + * list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ + #define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); \ + pos = pos->next) + /** + * list_for_each_prev - iterate over a list backwards + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ + #define list_for_each_prev(pos, head) \ + for (pos = (head)->prev; pos != (head); \ + pos = pos->prev) + +/** + * list_for_each_safe - iterate over a list safe against removal of list entry + * @pos: the &struct list_head to use as a loop counter. + * @n: another &struct list_head to use as temporary storage + * @head: the head for your list. + */ + #define list_for_each_safe(pos, n, head) \ + for (pos = (head)->next, n = pos->next; pos != (head); \ + pos = n, n = pos->next) + + /** + * list_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + + /** + * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry + * @pos: the type * to use as a loop counter. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, typeof(*n), member)) + + /** + * list_for_each_entry_continue - iterate over list of given type + * continuing after existing point + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry_continue(pos, head, member) \ + for (pos = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + + #endif diff --git a/reactos/drivers/bus/acpi/main.c b/reactos/drivers/bus/acpi/main.c new file mode 100644 index 00000000000..d8d8b3e7dad --- /dev/null +++ b/reactos/drivers/bus/acpi/main.c @@ -0,0 +1,218 @@ +#include + +#include +#include + +#include +#include + +//#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (INIT, DriverEntry) +#pragma alloc_text (PAGE, Bus_AddDevice) + +#endif + + + +NTSTATUS +NTAPI +Bus_AddDevice( + PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT PhysicalDeviceObject + ) + +{ + NTSTATUS status; + PDEVICE_OBJECT deviceObject = NULL; + PFDO_DEVICE_DATA deviceData = NULL; + PWCHAR deviceName = NULL; + ULONG nameLength; + + PAGED_CODE (); + + DPRINT("Add Device: 0x%p\n", PhysicalDeviceObject); + + DPRINT1("#################### Bus_CreateClose Creating FDO Device ####################\n"); + status = IoCreateDevice(DriverObject, + sizeof(FDO_DEVICE_DATA), + NULL, + FILE_DEVICE_ACPI, + FILE_DEVICE_SECURE_OPEN, + TRUE, + &deviceObject); + if (!NT_SUCCESS(status)) + { + DPRINT1("IoCreateDevice() failed with status 0x%X\n", status); + goto End; + } + + deviceData = (PFDO_DEVICE_DATA) deviceObject->DeviceExtension; + RtlZeroMemory (deviceData, sizeof (FDO_DEVICE_DATA)); + + // + // Set the initial state of the FDO + // + + INITIALIZE_PNP_STATE(deviceData->Common); + + deviceData->Common.IsFDO = TRUE; + + deviceData->Common.Self = deviceObject; + + ExInitializeFastMutex (&deviceData->Mutex); + + InitializeListHead (&deviceData->ListOfPDOs); + + // Set the PDO for use with PlugPlay functions + + deviceData->UnderlyingPDO = PhysicalDeviceObject; + + // + // Set the initial powerstate of the FDO + // + + deviceData->Common.DevicePowerState = PowerDeviceUnspecified; + deviceData->Common.SystemPowerState = PowerSystemWorking; + + deviceObject->Flags |= DO_POWER_PAGABLE; + + // + // Attach our FDO to the device stack. + // The return value of IoAttachDeviceToDeviceStack is the top of the + // attachment chain. This is where all the IRPs should be routed. + // + + deviceData->NextLowerDriver = IoAttachDeviceToDeviceStack ( + deviceObject, + PhysicalDeviceObject); + + if (NULL == deviceData->NextLowerDriver) { + + status = STATUS_NO_SUCH_DEVICE; + goto End; + } + + +#ifndef NDEBUG + // + // We will demonstrate here the step to retrieve the name of the PDO + // + + status = IoGetDeviceProperty (PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + 0, + NULL, + &nameLength); + + if (status != STATUS_BUFFER_TOO_SMALL) + { + DPRINT1("AddDevice:IoGDP failed (0x%x)\n", status); + goto End; + } + + deviceName = ExAllocatePoolWithTag (NonPagedPool, + nameLength, 'IPCA'); + + if (NULL == deviceName) { + DPRINT1("AddDevice: no memory to alloc for deviceName(0x%x)\n", nameLength); + status = STATUS_INSUFFICIENT_RESOURCES; + goto End; + } + + status = IoGetDeviceProperty (PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + nameLength, + deviceName, + &nameLength); + + if (!NT_SUCCESS (status)) { + + DPRINT1("AddDevice:IoGDP(2) failed (0x%x)", status); + goto End; + } + + DPRINT1("AddDevice: %p to %p->%p (%ws) \n", + deviceObject, + deviceData->NextLowerDriver, + PhysicalDeviceObject, + deviceName); + +#endif + + // + // We are done with initializing, so let's indicate that and return. + // This should be the final step in the AddDevice process. + // + deviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + +End: + if (deviceName){ + ExFreePool(deviceName); + } + if (!NT_SUCCESS(status) && deviceObject){ + if (deviceData && deviceData->NextLowerDriver){ + IoDetachDevice (deviceData->NextLowerDriver); + } + IoDeleteDevice (deviceObject); + } + return status; + +} + +NTSTATUS +NTAPI +ACPIDispatchDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IrpSp; + NTSTATUS Status; + + DPRINT("Called. IRP is at (0x%X)\n", Irp); + + Irp->IoStatus.Information = 0; + + IrpSp = IoGetCurrentIrpStackLocation(Irp); + switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) { + default: + DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode); + Status = STATUS_NOT_IMPLEMENTED; + break; + } + + if (Status != STATUS_PENDING) { + Irp->IoStatus.Status = Status; + + DPRINT("Completing IRP at 0x%X\n", Irp); + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + + DPRINT("Leaving. Status 0x%X\n", Status); + + return Status; +} + +NTSTATUS +NTAPI +DriverEntry ( + PDRIVER_OBJECT DriverObject, + PUNICODE_STRING RegistryPath + ) +{ + DPRINT("Driver Entry \n"); + + // + // Set entry points into the driver + // + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ACPIDispatchDeviceControl; + DriverObject->MajorFunction [IRP_MJ_PNP] = Bus_PnP; + DriverObject->MajorFunction [IRP_MJ_POWER] = Bus_Power; + + DriverObject->DriverExtension->AddDevice = Bus_AddDevice; + + return STATUS_SUCCESS; +} diff --git a/reactos/drivers/bus/acpi/osl.c b/reactos/drivers/bus/acpi/osl.c new file mode 100644 index 00000000000..be26a0811f9 --- /dev/null +++ b/reactos/drivers/bus/acpi/osl.c @@ -0,0 +1,752 @@ +/******************************************************************************* +* * +* ACPI Component Architecture Operating System Layer (OSL) for ReactOS * +* * +*******************************************************************************/ +#include + +#include + +#define NDEBUG +#include + +#define NUM_SEMAPHORES 128 + +static PKINTERRUPT AcpiInterrupt; +static BOOLEAN AcpiInterruptHandlerRegistered = FALSE; +static ACPI_OSD_HANDLER AcpiIrqHandler = NULL; +static PVOID AcpiIrqContext = NULL; +static ULONG AcpiIrqNumber = 0; +static KDPC AcpiDpc; +static PVOID IVTVirtualAddress = NULL; + + +typedef struct semaphore_entry +{ + UINT16 MaxUnits; + UINT16 CurrentUnits; + void *OsHandle; +} SEMAPHORE_ENTRY; + +static SEMAPHORE_ENTRY AcpiGbl_Semaphores[NUM_SEMAPHORES]; + +VOID NTAPI +OslDpcStub( + IN PKDPC Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2) +{ + ACPI_OSD_EXEC_CALLBACK Routine = (ACPI_OSD_EXEC_CALLBACK)SystemArgument1; + + DPRINT("OslDpcStub()\n"); + DPRINT("Calling [%p]([%p])\n", Routine, SystemArgument2); + (*Routine)(SystemArgument2); +} + +BOOLEAN NTAPI +OslIsrStub( + PKINTERRUPT Interrupt, + PVOID ServiceContext) +{ + INT32 Status; + + Status = (*AcpiIrqHandler)(AcpiIrqContext); + + if (ACPI_SUCCESS(Status)) + return TRUE; + else + return FALSE; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine); + +ACPI_STATUS +AcpiOsInitialize (void) +{ + DPRINT("AcpiOsInitialize called\n"); + +#ifndef NDEBUG + /* Verboseness level of the acpica core */ + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = 0xFFFFFFFF; +#endif + + UINT32 i; + + for (i = 0; i < NUM_SEMAPHORES; i++) + { + AcpiGbl_Semaphores[i].OsHandle = NULL; + } + + KeInitializeDpc(&AcpiDpc, OslDpcStub, NULL); + + return AE_OK; +} + +ACPI_STATUS +AcpiOsTerminate(void) +{ + DPRINT1("AcpiOsTerminate() called\n"); + + if (AcpiInterruptHandlerRegistered) + AcpiOsRemoveInterruptHandler(AcpiIrqNumber, AcpiIrqHandler); + + return AE_OK; +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Fmt, + ...) +{ + va_list Args; + va_start (Args, Fmt); + + AcpiOsVprintf (Fmt, Args); + + va_end (Args); + return; +} + +void +AcpiOsVprintf ( + const char *Fmt, + va_list Args) +{ + vDbgPrintEx (-1, DPFLTR_ERROR_LEVEL, Fmt, Args); + return; +} + +void * +AcpiOsAllocate (ACPI_SIZE size) +{ + DPRINT("AcpiOsAllocate size %d\n",size); + return ExAllocatePool(NonPagedPool, size); +} + +void * +AcpiOsCallocate(ACPI_SIZE size) +{ + PVOID ptr = ExAllocatePool(NonPagedPool, size); + if (ptr) + memset(ptr, 0, size); + return ptr; +} + +void +AcpiOsFree(void *ptr) +{ + if (!ptr) + DPRINT1("Attempt to free null pointer!!!\n"); + ExFreePool(ptr); +} + +#ifndef ACPI_USE_LOCAL_CACHE + +void* +AcpiOsAcquireObjectHelper ( + POOL_TYPE PoolType, + SIZE_T NumberOfBytes, + ULONG Tag) +{ + void* Alloc = ExAllocatePool(PoolType, NumberOfBytes); + + /* acpica expects memory allocated from cache to be zeroed */ + RtlZeroMemory(Alloc,NumberOfBytes); + return Alloc; +} + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache) +{ + PNPAGED_LOOKASIDE_LIST Lookaside = + ExAllocatePool(NonPagedPool,sizeof(NPAGED_LOOKASIDE_LIST)); + + ExInitializeNPagedLookasideList(Lookaside, + (PALLOCATE_FUNCTION)AcpiOsAcquireObjectHelper,// custom memory allocator + NULL, + 0, + ObjectSize, + 'IPCA', + 0); + *ReturnCache = (ACPI_CACHE_T *)Lookaside; + + DPRINT("AcpiOsCreateCache %p\n", Lookaside); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsDeleteCache %p\n", Cache); + ExDeleteNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST) Cache); + ExFreePool(Cache); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsPurgeCache\n"); + /* No such functionality for LookAside lists */ + return (AE_OK); +} + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache) +{ + PNPAGED_LOOKASIDE_LIST List = (PNPAGED_LOOKASIDE_LIST)Cache; + DPRINT("AcpiOsAcquireObject from %p\n", Cache); + void* ptr = + ExAllocateFromNPagedLookasideList(List); + ASSERT(ptr); + + RtlZeroMemory(ptr,List->L.Size); + return ptr; +} + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object) +{ + DPRINT("AcpiOsReleaseObject %p from %p\n",Object, Cache); + ExFreeToNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST)Cache, + Object); + return (AE_OK); +} + +#endif + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS phys, + ACPI_SIZE length) +{ + PHYSICAL_ADDRESS Address; + + DPRINT("AcpiOsMapMemory(phys 0x%X size 0x%X)\n", (ULONG)phys, length); + if (phys == 0x0) + { + IVTVirtualAddress = ExAllocatePool(NonPagedPool, length); + return IVTVirtualAddress; + } + + Address.QuadPart = (ULONG)phys; + return MmMapIoSpace(Address, length, MmNonCached); +} + +void +AcpiOsUnmapMemory ( + void *virt, + ACPI_SIZE length) +{ + DPRINT("AcpiOsUnmapMemory()\n"); + + if (virt == 0x0) + { + ExFreePool(IVTVirtualAddress); + return; + } + MmUnmapIoSpace(virt, length); +} + +UINT32 +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context) +{ + ULONG Vector; + KIRQL DIrql; + KAFFINITY Affinity; + NTSTATUS Status; + + DPRINT("AcpiOsInstallInterruptHandler()\n"); + Vector = HalGetInterruptVector( + Internal, + 0, + InterruptNumber, + 0, + &DIrql, + &Affinity); + + AcpiIrqNumber = InterruptNumber; + AcpiIrqHandler = ServiceRoutine; + AcpiIrqContext = Context; + AcpiInterruptHandlerRegistered = TRUE; + + Status = IoConnectInterrupt( + &AcpiInterrupt, + OslIsrStub, + NULL, + NULL, + Vector, + DIrql, + DIrql, + LevelSensitive, /* FIXME: LevelSensitive or Latched? */ + TRUE, + Affinity, + FALSE); + + if (!NT_SUCCESS(Status)) + { + DPRINT("Could not connect to interrupt %d\n", Vector); + return AE_ERROR; + } + return AE_OK; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine) +{ + DPRINT("AcpiOsRemoveInterruptHandler()\n"); + if (AcpiInterruptHandlerRegistered) + { + IoDisconnectInterrupt(AcpiInterrupt); + AcpiInterrupt = NULL; + AcpiInterruptHandlerRegistered = FALSE; + } + + return AE_OK; +} + +void +AcpiOsStall (UINT32 microseconds) +{ + DPRINT1("AcpiOsStall %d\n",microseconds); + KeStallExecutionProcessor(microseconds); + return; +} + +void +AcpiOsSleep (ACPI_INTEGER milliseconds) +{ + DPRINT1("AcpiOsSleep %d\n", milliseconds); + KeStallExecutionProcessor(milliseconds*1000); + return; +} + +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadPort %p, width %d\n",Address,Width); + + switch (Width) + { + case 8: + *Value = READ_PORT_UCHAR((PUCHAR)Address); + break; + + case 16: + *Value = READ_PORT_USHORT((PUSHORT)Address); + break; + + case 32: + *Value = READ_PORT_ULONG((PULONG)Address); + break; + default: + DPRINT1("AcpiOsReadPort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWritePort %p, width %d\n",Address,Width); + switch (Width) + { + case 8: + WRITE_PORT_UCHAR((PUCHAR)Address, Value); + break; + + case 16: + WRITE_PORT_USHORT((PUSHORT)Address, Value); + break; + + case 32: + WRITE_PORT_ULONG((PULONG)Address, Value); + break; + + default: + DPRINT1("AcpiOsWritePort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadMemory %p\n", Address); + switch (Width) + { + case 8: + *Value = (*(PUCHAR)(ULONG)Address); + break; + case 16: + *Value = (*(PUSHORT)(ULONG)Address); + break; + case 32: + *Value = (*(PULONG)(ULONG)Address); + break; + + default: + DPRINT1("AcpiOsReadMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWriteMemory %p\n", Address); + switch (Width) + { + case 8: + *(PUCHAR)(ULONG)Address = Value; + break; + case 16: + *(PUSHORT)(ULONG)Address = Value; + break; + case 32: + *(PULONG)(ULONG)Address = Value; + break; + + default: + DPRINT1("AcpiOsWriteMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + void *Value, + UINT32 Width) +{ + NTSTATUS Status; + PCI_SLOT_NUMBER slot; + + if (Register == 0) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Bus; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsReadPciConfiguration, slot=0x%X, func=0x%X\n", slot.u.AsULONG, Register); + Status = HalGetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + Value, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + ACPI_INTEGER Value, + UINT32 Width) +{ + NTSTATUS Status; + ULONG buf = Value; + PCI_SLOT_NUMBER slot; + + if (Register == 0) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Bus; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsWritePciConfiguration, slot=0x%x\n", slot.u.AsULONG); + Status = HalSetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + &buf, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_SEMAPHORE *OutHandle) +{ + PFAST_MUTEX Mutex; + + Mutex = ExAllocatePool(NonPagedPool, sizeof(FAST_MUTEX)); + if (!Mutex) + return AE_NO_MEMORY; + + DPRINT("AcpiOsCreateSemaphore() at 0x%X\n", Mutex); + + ExInitializeFastMutex(Mutex); + + *OutHandle = Mutex; + return AE_OK; +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_SEMAPHORE Handle) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsDeleteSemaphore(handle 0x%X)\n", Handle); + + if (!Mutex) + return AE_BAD_PARAMETER; + + ExFreePool(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsWaitSemaphore( + ACPI_SEMAPHORE Handle, + UINT32 units, + UINT16 timeout) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + if (!Mutex || (units < 1)) + { + DPRINT("AcpiOsWaitSemaphore(handle 0x%X, units %d) Bad parameters\n", + Mutex, units); + return AE_BAD_PARAMETER; + } + + DPRINT("Waiting for semaphore %p\n", Handle); + ASSERT(Mutex); + + ExAcquireFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsSignalSemaphore %p\n",Handle); + ASSERT(Mutex); + + ExReleaseFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle) +{ + DPRINT("AcpiOsCreateLock\n"); + return (AcpiOsCreateSemaphore (1, 1, OutHandle)); +} + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle) +{ + DPRINT("AcpiOsDeleteLock %p\n", Handle); + AcpiOsDeleteSemaphore (Handle); +} + + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_HANDLE Handle) +{ + DPRINT("AcpiOsAcquireLock, %p\n", Handle); + AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); + return (0); +} + + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags) +{ + DPRINT("AcpiOsReleaseLock %p\n",Handle); + AcpiOsSignalSemaphore (Handle, 1); +} + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info) +{ + + switch (Function) + { + case ACPI_SIGNAL_FATAL: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + case ACPI_SIGNAL_BREAKPOINT: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + } + + return (AE_OK); +} + + +ACPI_THREAD_ID +AcpiOsGetThreadId (void) +{ + return (ULONG)PsGetCurrentThreadId(); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + DPRINT1("AcpiOsExecute\n"); + + KeInsertQueueDpc(&AcpiDpc, (PVOID)Function, (PVOID)Context); + +#ifdef _MULTI_THREADED + //_beginthread (Function, (unsigned) 0, Context); +#endif + + return 0; +} + +UINT64 +AcpiOsGetTimer (void) +{ + DPRINT("AcpiOsGetTimer\n"); + LARGE_INTEGER Timer; + KeQueryTickCount(&Timer); + + return Timer.QuadPart; +} + +void +AcpiOsDerivePciId( + ACPI_HANDLE rhandle, + ACPI_HANDLE chandle, + ACPI_PCI_ID **PciId) +{ + DPRINT("AcpiOsDerivePciId\n"); + return; +} + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal) +{ + if (!InitVal || !NewVal) + return AE_BAD_PARAMETER; + + *NewVal = ACPI_OS_NAME; + DPRINT("AcpiOsPredefinedOverride\n"); + return AE_OK; +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void); + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable) +{ + DPRINT("AcpiOsTableOverride\n"); + *NewTable = NULL; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface) +{ + DPRINT("AcpiOsValidateInterface\n"); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateAddress ( + UINT8 SpaceId, + ACPI_PHYSICAL_ADDRESS Address, + ACPI_SIZE Length) +{ + DPRINT("AcpiOsValidateAddress\n"); + return (AE_OK); +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void) +{ + DPRINT("AcpiOsGetRootPointer\n"); + ACPI_PHYSICAL_ADDRESS pa = 0; + + AcpiFindRootPointer(&pa); + return pa; +} diff --git a/reactos/drivers/bus/acpi/pnp.c b/reactos/drivers/bus/acpi/pnp.c new file mode 100644 index 00000000000..5b2338dc58c --- /dev/null +++ b/reactos/drivers/bus/acpi/pnp.c @@ -0,0 +1,563 @@ +#include + +#include + +#include +#include +#include + +#include +//#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (PAGE, Bus_PnP) +#pragma alloc_text (PAGE, Bus_PlugInDevice) +#pragma alloc_text (PAGE, Bus_InitializePdo) +#pragma alloc_text (PAGE, Bus_UnPlugDevice) +#pragma alloc_text (PAGE, Bus_DestroyPdo) +#pragma alloc_text (PAGE, Bus_FDO_PnP) +#pragma alloc_text (PAGE, Bus_StartFdo) +#pragma alloc_text (PAGE, Bus_SendIrpSynchronously) +#endif + + +NTSTATUS +NTAPI +Bus_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + PIO_STACK_LOCATION irpStack; + NTSTATUS status; + PCOMMON_DEVICE_DATA commonData; + + PAGED_CODE (); + + irpStack = IoGetCurrentIrpStackLocation (Irp); + ASSERT (IRP_MJ_PNP == irpStack->MajorFunction); + + commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension; + + + if (commonData->IsFDO) { + DPRINT("FDO %s IRP:0x%p\n", + PnPMinorFunctionString(irpStack->MinorFunction), + Irp); + // + // Request is for the bus FDO + // + status = Bus_FDO_PnP ( + DeviceObject, + Irp, + irpStack, + (PFDO_DEVICE_DATA) commonData); + } else { + DPRINT("PDO %s IRP: 0x%p\n", + PnPMinorFunctionString(irpStack->MinorFunction), + Irp); + // + // Request is for the child PDO. + // + status = Bus_PDO_PnP ( + DeviceObject, + Irp, + irpStack, + (PPDO_DEVICE_DATA) commonData); + } + + return status; +} + +NTSTATUS +Bus_FDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PFDO_DEVICE_DATA DeviceData + ) +{ + NTSTATUS status; + ULONG length, prevcount, numPdosPresent; + PLIST_ENTRY entry; + PPDO_DEVICE_DATA pdoData; + PDEVICE_RELATIONS relations, oldRelations; + + PAGED_CODE (); + + switch (IrpStack->MinorFunction) { + + case IRP_MN_START_DEVICE: + + status = Bus_StartFdo (DeviceData, Irp); + + + // + // We must now complete the IRP, since we stopped it in the + // completion routine with MORE_PROCESSING_REQUIRED. + // + + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; + + case IRP_MN_QUERY_STOP_DEVICE: + + // + // The PnP manager is trying to stop the device + // for resource rebalancing. + // + SET_NEW_PNP_STATE(DeviceData->Common, StopPending); + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: + + // + // The PnP Manager sends this IRP, at some point after an + // IRP_MN_QUERY_STOP_DEVICE, to inform the drivers for a + // device that the device will not be stopped for + // resource reconfiguration. + // + // + // First check to see whether you have received cancel-stop + // without first receiving a query-stop. This could happen if + // someone above us fails a query-stop and passes down the subsequent + // cancel-stop. + // + + if (StopPending == DeviceData->Common.DevicePnPState) + { + // + // We did receive a query-stop, so restore. + // + RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); + ASSERT(DeviceData->Common.DevicePnPState == Started); + } + Irp->IoStatus.Status = STATUS_SUCCESS; // We must not fail the IRP. + break; + + case IRP_MN_QUERY_DEVICE_RELATIONS: + + DPRINT("\tQueryDeviceRelation Type: %s\n", + DbgDeviceRelationString(\ + IrpStack->Parameters.QueryDeviceRelations.Type)); + + if (BusRelations != IrpStack->Parameters.QueryDeviceRelations.Type) { + // + // We don't support any other Device Relations + // + break; + } + + + ExAcquireFastMutex (&DeviceData->Mutex); + + oldRelations = (PDEVICE_RELATIONS) Irp->IoStatus.Information; + if (oldRelations) { + prevcount = oldRelations->Count; + if (!DeviceData->NumPDOs) { + // + // There is a device relations struct already present and we have + // nothing to add to it, so just call IoSkip and IoCall + // + ExReleaseFastMutex (&DeviceData->Mutex); + break; + } + } + else { + prevcount = 0; + } + + // + // Calculate the number of PDOs actually present on the bus + // + numPdosPresent = 0; + for (entry = DeviceData->ListOfPDOs.Flink; + entry != &DeviceData->ListOfPDOs; + entry = entry->Flink) { + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + numPdosPresent++; + } + + // + // Need to allocate a new relations structure and add our + // PDOs to it. + // + + length = sizeof(DEVICE_RELATIONS) + + ((numPdosPresent + prevcount) * sizeof (PDEVICE_OBJECT)) -1; + + relations = (PDEVICE_RELATIONS) ExAllocatePoolWithTag (PagedPool, + length, 'IPCA'); + + if (NULL == relations) { + // + // Fail the IRP + // + ExReleaseFastMutex (&DeviceData->Mutex); + Irp->IoStatus.Status = status = STATUS_INSUFFICIENT_RESOURCES; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + return status; + + } + + // + // Copy in the device objects so far + // + if (prevcount) { + RtlCopyMemory (relations->Objects, oldRelations->Objects, + prevcount * sizeof (PDEVICE_OBJECT)); + } + + relations->Count = prevcount + numPdosPresent; + + // + // For each PDO present on this bus add a pointer to the device relations + // buffer, being sure to take out a reference to that object. + // The Plug & Play system will dereference the object when it is done + // with it and free the device relations buffer. + // + + for (entry = DeviceData->ListOfPDOs.Flink; + entry != &DeviceData->ListOfPDOs; + entry = entry->Flink) { + + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + relations->Objects[prevcount] = pdoData->Common.Self; + ObReferenceObject (pdoData->Common.Self); + prevcount++; + } + + DPRINT("\t#PDOs present = %d\n\t#PDOs reported = %d\n", + DeviceData->NumPDOs, relations->Count); + + // + // Replace the relations structure in the IRP with the new + // one. + // + if (oldRelations) { + ExFreePool (oldRelations); + } + Irp->IoStatus.Information = (ULONG_PTR) relations; + + ExReleaseFastMutex (&DeviceData->Mutex); + + // + // Set up and pass the IRP further down the stack + // + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + default: + + // + // In the default case we merely call the next driver. + // We must not modify Irp->IoStatus.Status or complete the IRP. + // + + break; + } + + IoSkipCurrentIrpStackLocation (Irp); + status = IoCallDriver (DeviceData->NextLowerDriver, Irp); + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_StartFdo ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp ) +{ + NTSTATUS status = STATUS_SUCCESS; + POWER_STATE powerState; + ACPI_STATUS AcpiStatus; + + PAGED_CODE (); + + FdoData->Common.DevicePowerState = PowerDeviceD0; + powerState.DeviceState = PowerDeviceD0; + PoSetPowerState ( FdoData->Common.Self, DevicePowerState, powerState ); + + SET_NEW_PNP_STATE(FdoData->Common, Started); + + AcpiStatus = AcpiInitializeSubsystem(); + if(ACPI_FAILURE(AcpiStatus)){ + DPRINT1("Unable to AcpiInitializeSubsystem\n"); + return STATUS_UNSUCCESSFUL; + } + + + AcpiStatus = AcpiInitializeTables(NULL, 16, 0); + if (ACPI_FAILURE(status)){ + DPRINT1("Unable to AcpiInitializeSubsystem\n"); + return STATUS_UNSUCCESSFUL; + } + + AcpiStatus = AcpiLoadTables(); + if(ACPI_FAILURE(AcpiStatus)){ + DPRINT1("Unable to AcpiLoadTables\n"); + AcpiTerminate(); + return STATUS_UNSUCCESSFUL; + } + + DPRINT("Acpi subsystem init\n"); + /* Initialize ACPI bus manager */ + AcpiStatus = acpi_init(); + if (!ACPI_SUCCESS(AcpiStatus)) { + DPRINT("acpi_init() failed with status 0x%X\n", AcpiStatus); + AcpiTerminate(); + return STATUS_UNSUCCESSFUL; + } + status = ACPIEnumerateDevices(FdoData); + + return status; +} + +NTSTATUS +Bus_SendIrpSynchronously ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + KEVENT event; + NTSTATUS status; + + PAGED_CODE(); + + KeInitializeEvent(&event, NotificationEvent, FALSE); + + IoCopyCurrentIrpStackLocationToNext(Irp); + + IoSetCompletionRoutine(Irp, + Bus_CompletionRoutine, + &event, + TRUE, + TRUE, + TRUE + ); + + status = IoCallDriver(DeviceObject, Irp); + + // + // Wait for lower drivers to be done with the Irp. + // Important thing to note here is when you allocate + // the memory for an event in the stack you must do a + // KernelMode wait instead of UserMode to prevent + // the stack from getting paged out. + // + + if (status == STATUS_PENDING) { + KeWaitForSingleObject(&event, + Executive, + KernelMode, + FALSE, + NULL + ); + status = Irp->IoStatus.Status; + } + + return status; +} + +NTSTATUS +Bus_CompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context + ) +{ + UNREFERENCED_PARAMETER (DeviceObject); + + // + // If the lower driver didn't return STATUS_PENDING, we don't need to + // set the event because we won't be waiting on it. + // This optimization avoids grabbing the dispatcher lock and improves perf. + // + if (Irp->PendingReturned == TRUE) { + + KeSetEvent ((PKEVENT) Context, IO_NO_INCREMENT, FALSE); + } + return STATUS_MORE_PROCESSING_REQUIRED; // Keep this IRP +} + +NTSTATUS +Bus_DestroyPdo ( + PDEVICE_OBJECT Device, + PPDO_DEVICE_DATA PdoData + ) +{ + PAGED_CODE (); + + // + // BusEnum does not queue any irps at this time so we have nothing to do. + // + + // + // Free any resources. + // + + if (PdoData->HardwareIDs) { + ExFreePool (PdoData->HardwareIDs); + PdoData->HardwareIDs = NULL; + } + + DPRINT("\tDeleting PDO: 0x%p\n", Device); + IoDeleteDevice (Device); + return STATUS_SUCCESS; +} + + +VOID +Bus_InitializePdo ( + PDEVICE_OBJECT Pdo, + PFDO_DEVICE_DATA FdoData + ) +{ + PPDO_DEVICE_DATA pdoData; + + PAGED_CODE (); + + pdoData = (PPDO_DEVICE_DATA) Pdo->DeviceExtension; + + DPRINT("pdo 0x%p, extension 0x%p\n", Pdo, pdoData); + + // + // Initialize the rest + // + pdoData->Common.IsFDO = FALSE; + pdoData->Common.Self = Pdo; + + pdoData->ParentFdo = FdoData->Common.Self; + + + INITIALIZE_PNP_STATE(pdoData->Common); + + // + // PDO's usually start their life at D3 + // + + pdoData->Common.DevicePowerState = PowerDeviceD3; + pdoData->Common.SystemPowerState = PowerSystemWorking; + + Pdo->Flags |= DO_POWER_PAGABLE; + + ExAcquireFastMutex (&FdoData->Mutex); + InsertTailList(&FdoData->ListOfPDOs, &pdoData->Link); + FdoData->NumPDOs++; + ExReleaseFastMutex (&FdoData->Mutex); + + // This should be the last step in initialization. + Pdo->Flags &= ~DO_DEVICE_INITIALIZING; + +} + +#if DBG + +PCHAR +PnPMinorFunctionString ( + UCHAR MinorFunction +) +{ + switch (MinorFunction) + { + case IRP_MN_START_DEVICE: + return "IRP_MN_START_DEVICE"; + case IRP_MN_QUERY_REMOVE_DEVICE: + return "IRP_MN_QUERY_REMOVE_DEVICE"; + case IRP_MN_REMOVE_DEVICE: + return "IRP_MN_REMOVE_DEVICE"; + case IRP_MN_CANCEL_REMOVE_DEVICE: + return "IRP_MN_CANCEL_REMOVE_DEVICE"; + case IRP_MN_STOP_DEVICE: + return "IRP_MN_STOP_DEVICE"; + case IRP_MN_QUERY_STOP_DEVICE: + return "IRP_MN_QUERY_STOP_DEVICE"; + case IRP_MN_CANCEL_STOP_DEVICE: + return "IRP_MN_CANCEL_STOP_DEVICE"; + case IRP_MN_QUERY_DEVICE_RELATIONS: + return "IRP_MN_QUERY_DEVICE_RELATIONS"; + case IRP_MN_QUERY_INTERFACE: + return "IRP_MN_QUERY_INTERFACE"; + case IRP_MN_QUERY_CAPABILITIES: + return "IRP_MN_QUERY_CAPABILITIES"; + case IRP_MN_QUERY_RESOURCES: + return "IRP_MN_QUERY_RESOURCES"; + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: + return "IRP_MN_QUERY_RESOURCE_REQUIREMENTS"; + case IRP_MN_QUERY_DEVICE_TEXT: + return "IRP_MN_QUERY_DEVICE_TEXT"; + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: + return "IRP_MN_FILTER_RESOURCE_REQUIREMENTS"; + case IRP_MN_READ_CONFIG: + return "IRP_MN_READ_CONFIG"; + case IRP_MN_WRITE_CONFIG: + return "IRP_MN_WRITE_CONFIG"; + case IRP_MN_EJECT: + return "IRP_MN_EJECT"; + case IRP_MN_SET_LOCK: + return "IRP_MN_SET_LOCK"; + case IRP_MN_QUERY_ID: + return "IRP_MN_QUERY_ID"; + case IRP_MN_QUERY_PNP_DEVICE_STATE: + return "IRP_MN_QUERY_PNP_DEVICE_STATE"; + case IRP_MN_QUERY_BUS_INFORMATION: + return "IRP_MN_QUERY_BUS_INFORMATION"; + case IRP_MN_DEVICE_USAGE_NOTIFICATION: + return "IRP_MN_DEVICE_USAGE_NOTIFICATION"; + case IRP_MN_SURPRISE_REMOVAL: + return "IRP_MN_SURPRISE_REMOVAL"; + case IRP_MN_QUERY_LEGACY_BUS_INFORMATION: + return "IRP_MN_QUERY_LEGACY_BUS_INFORMATION"; + default: + return "unknown_pnp_irp"; + } +} + +PCHAR +DbgDeviceRelationString( + DEVICE_RELATION_TYPE Type + ) +{ + switch (Type) + { + case BusRelations: + return "BusRelations"; + case EjectionRelations: + return "EjectionRelations"; + case RemovalRelations: + return "RemovalRelations"; + case TargetDeviceRelation: + return "TargetDeviceRelation"; + default: + return "UnKnown Relation"; + } +} + +PCHAR +DbgDeviceIDString( + BUS_QUERY_ID_TYPE Type + ) +{ + switch (Type) + { + case BusQueryDeviceID: + return "BusQueryDeviceID"; + case BusQueryHardwareIDs: + return "BusQueryHardwareIDs"; + case BusQueryCompatibleIDs: + return "BusQueryCompatibleIDs"; + case BusQueryInstanceID: + return "BusQueryInstanceID"; + case BusQueryDeviceSerialNumber: + return "BusQueryDeviceSerialNumber"; + default: + return "UnKnown ID"; + } +} + +#endif + + diff --git a/reactos/drivers/bus/acpi/power.c b/reactos/drivers/bus/acpi/power.c new file mode 100644 index 00000000000..720207db8d2 --- /dev/null +++ b/reactos/drivers/bus/acpi/power.c @@ -0,0 +1,260 @@ +#include + +#include +#include + +#include +#include + +//#define NDEBUG +#include + +NTSTATUS +NTAPI +Bus_Power ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + PIO_STACK_LOCATION irpStack; + NTSTATUS status; + PCOMMON_DEVICE_DATA commonData; + + status = STATUS_SUCCESS; + irpStack = IoGetCurrentIrpStackLocation (Irp); + ASSERT (IRP_MJ_POWER == irpStack->MajorFunction); + + commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension; + + if (commonData->IsFDO) { + + DPRINT("FDO %s IRP:0x%p %s %s\n", + PowerMinorFunctionString(irpStack->MinorFunction), Irp, + DbgSystemPowerString(commonData->SystemPowerState), + DbgDevicePowerString(commonData->DevicePowerState)); + + + status = Bus_FDO_Power ((PFDO_DEVICE_DATA)DeviceObject->DeviceExtension, + Irp); + } else { + + DPRINT("PDO %s IRP:0x%p %s %s\n", + PowerMinorFunctionString(irpStack->MinorFunction), Irp, + DbgSystemPowerString(commonData->SystemPowerState), + DbgDevicePowerString(commonData->DevicePowerState)); + + status = Bus_PDO_Power ((PPDO_DEVICE_DATA)DeviceObject->DeviceExtension, + Irp); + } + + return status; +} + + +NTSTATUS +Bus_FDO_Power ( + PFDO_DEVICE_DATA Data, + PIRP Irp + ) +{ + NTSTATUS status = STATUS_SUCCESS; + POWER_STATE powerState; + POWER_STATE_TYPE powerType; + PIO_STACK_LOCATION stack; + ULONG AcpiState; + ACPI_STATUS AcpiStatus; + + stack = IoGetCurrentIrpStackLocation (Irp); + powerType = stack->Parameters.Power.Type; + powerState = stack->Parameters.Power.State; + + + if (stack->MinorFunction == IRP_MN_SET_POWER) { + DPRINT("\tRequest to set %s state to %s\n", + ((powerType == SystemPowerState) ? "System" : "Device"), + ((powerType == SystemPowerState) ? \ + DbgSystemPowerString(powerState.SystemState) :\ + DbgDevicePowerString(powerState.DeviceState))); + } + + if (powerType == SystemPowerState) { + status = STATUS_SUCCESS; + switch (powerState.SystemState) { + case PowerSystemSleeping1: + AcpiState = ACPI_STATE_S1; + break; + case PowerSystemSleeping2: + AcpiState = ACPI_STATE_S2; + break; + case PowerSystemSleeping3: + AcpiState = ACPI_STATE_S3; + break; + case PowerSystemHibernate: + AcpiState = ACPI_STATE_S4; + break; + case PowerSystemShutdown: + AcpiState = ACPI_STATE_S5; + break; + default: + return STATUS_UNSUCCESSFUL; + break; + } + AcpiStatus = AcpiEnterSleepState(AcpiState); + if (!ACPI_SUCCESS(AcpiStatus)) { + DPRINT1("Failed to enter sleep state %d (Status 0x%X)\n", + AcpiState, AcpiStatus); + status = STATUS_UNSUCCESSFUL; + } + } + PoStartNextPowerIrp (Irp); + IoSkipCurrentIrpStackLocation(Irp); + status = PoCallDriver (Data->NextLowerDriver, Irp); + return status; +} + + +NTSTATUS +Bus_PDO_Power ( + PPDO_DEVICE_DATA PdoData, + PIRP Irp + ) +{ + NTSTATUS status; + PIO_STACK_LOCATION stack; + POWER_STATE powerState; + POWER_STATE_TYPE powerType; + + stack = IoGetCurrentIrpStackLocation (Irp); + powerType = stack->Parameters.Power.Type; + powerState = stack->Parameters.Power.State; + + switch (stack->MinorFunction) { + case IRP_MN_SET_POWER: + + DPRINT("\tSetting %s power state to %s\n", + ((powerType == SystemPowerState) ? "System" : "Device"), + ((powerType == SystemPowerState) ? \ + DbgSystemPowerString(powerState.SystemState) : \ + DbgDevicePowerString(powerState.DeviceState))); + + switch (powerType) { + case DevicePowerState: + PoSetPowerState (PdoData->Common.Self, powerType, powerState); + PdoData->Common.DevicePowerState = powerState.DeviceState; + status = STATUS_SUCCESS; + break; + + case SystemPowerState: + PdoData->Common.SystemPowerState = powerState.SystemState; + status = STATUS_SUCCESS; + break; + + default: + status = STATUS_NOT_SUPPORTED; + break; + } + break; + + case IRP_MN_QUERY_POWER: + status = STATUS_SUCCESS; + break; + + case IRP_MN_WAIT_WAKE: + // + // We cannot support wait-wake because we are root-enumerated + // driver, and our parent, the PnP manager, doesn't support wait-wake. + // + case IRP_MN_POWER_SEQUENCE: + default: + status = STATUS_NOT_SUPPORTED; + break; + } + + if (status != STATUS_NOT_SUPPORTED) { + + Irp->IoStatus.Status = status; + } + + PoStartNextPowerIrp(Irp); + status = Irp->IoStatus.Status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; +} + +#ifndef NDEBUG + +PCHAR +PowerMinorFunctionString ( + UCHAR MinorFunction +) +{ + switch (MinorFunction) + { + case IRP_MN_SET_POWER: + return "IRP_MN_SET_POWER"; + case IRP_MN_QUERY_POWER: + return "IRP_MN_QUERY_POWER"; + case IRP_MN_POWER_SEQUENCE: + return "IRP_MN_POWER_SEQUENCE"; + case IRP_MN_WAIT_WAKE: + return "IRP_MN_WAIT_WAKE"; + + default: + return "unknown_power_irp"; + } +} + +PCHAR +DbgSystemPowerString( + SYSTEM_POWER_STATE Type + ) +{ + switch (Type) + { + case PowerSystemUnspecified: + return "PowerSystemUnspecified"; + case PowerSystemWorking: + return "PowerSystemWorking"; + case PowerSystemSleeping1: + return "PowerSystemSleeping1"; + case PowerSystemSleeping2: + return "PowerSystemSleeping2"; + case PowerSystemSleeping3: + return "PowerSystemSleeping3"; + case PowerSystemHibernate: + return "PowerSystemHibernate"; + case PowerSystemShutdown: + return "PowerSystemShutdown"; + case PowerSystemMaximum: + return "PowerSystemMaximum"; + default: + return "UnKnown System Power State"; + } + } + +PCHAR +DbgDevicePowerString( + DEVICE_POWER_STATE Type + ) +{ + switch (Type) + { + case PowerDeviceUnspecified: + return "PowerDeviceUnspecified"; + case PowerDeviceD0: + return "PowerDeviceD0"; + case PowerDeviceD1: + return "PowerDeviceD1"; + case PowerDeviceD2: + return "PowerDeviceD2"; + case PowerDeviceD3: + return "PowerDeviceD3"; + case PowerDeviceMaximum: + return "PowerDeviceMaximum"; + default: + return "UnKnown Device Power State"; + } +} + +#endif From 993e2a396de9da8d3f51f95a58ba38a8d25718b2 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 1 Mar 2010 09:32:35 +0000 Subject: [PATCH 014/211] [PORTCLS] - Revert to broken IID_IUnknown definition svn path=/trunk/; revision=45735 --- reactos/drivers/wdm/audio/backpln/portcls/guids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/guids.cpp b/reactos/drivers/wdm/audio/backpln/portcls/guids.cpp index 4496e5785e1..457868d2c62 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/guids.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/guids.cpp @@ -57,7 +57,7 @@ const GUID IID_IDmaChannel = {0x22C6AC61L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0x const GUID IID_IRegistryKey = {0xE8DA4302l, 0xF304, 0x11D0, {0x95, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}}; const GUID IID_IServiceSink = {0x22C6AC64L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}}; const GUID IID_IPortClsVersion = {0x7D89A7BBL, 0x869B, 0x4567, {0x8D, 0xBE, 0x1E, 0x16, 0x8C, 0xC8, 0x53, 0xDE}}; -const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; +const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x46}}; const GUID IID_IPortEvents = {0xA80F29C4L, 0x5498, 0x11D2, {0x95, 0xD9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}}; const GUID KSNAME_PIN = {0x146F1A80, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; From 3aefe2262949e0d3469dfdb159f733d0cbef04f5 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 1 Mar 2010 11:10:15 +0000 Subject: [PATCH 015/211] [MSXML3] sync msxml3 to wine 1.1.39 svn path=/trunk/; revision=45736 --- reactos/dll/win32/msxml3/attribute.c | 7 +- reactos/dll/win32/msxml3/cdata.c | 170 ++++---- reactos/dll/win32/msxml3/comment.c | 182 ++++----- reactos/dll/win32/msxml3/docfrag.c | 2 +- reactos/dll/win32/msxml3/domdoc.c | 482 +++++++++++++---------- reactos/dll/win32/msxml3/domimpl.c | 4 +- reactos/dll/win32/msxml3/element.c | 19 +- reactos/dll/win32/msxml3/entityref.c | 2 +- reactos/dll/win32/msxml3/factory.c | 3 +- reactos/dll/win32/msxml3/httprequest.c | 2 +- reactos/dll/win32/msxml3/msxml_private.h | 4 +- reactos/dll/win32/msxml3/node.c | 143 ++++--- reactos/dll/win32/msxml3/nodelist.c | 11 +- reactos/dll/win32/msxml3/nodemap.c | 25 +- reactos/dll/win32/msxml3/parseerror.c | 17 +- reactos/dll/win32/msxml3/pi.c | 4 +- reactos/dll/win32/msxml3/queryresult.c | 11 +- reactos/dll/win32/msxml3/schema.c | 2 +- reactos/dll/win32/msxml3/text.c | 171 ++++---- reactos/include/psdk/msxml2.idl | 9 + 20 files changed, 660 insertions(+), 610 deletions(-) diff --git a/reactos/dll/win32/msxml3/attribute.c b/reactos/dll/win32/msxml3/attribute.c index 04b8c46cb4e..d78fa479f40 100644 --- a/reactos/dll/win32/msxml3/attribute.c +++ b/reactos/dll/win32/msxml3/attribute.c @@ -55,7 +55,7 @@ static HRESULT WINAPI domattr_QueryInterface( void** ppvObject ) { domattr *This = impl_from_IXMLDOMAttribute( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMAttribute ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -213,7 +213,10 @@ static HRESULT WINAPI domattr_get_parentNode( IXMLDOMNode** parent ) { domattr *This = impl_from_IXMLDOMAttribute( iface ); - return IXMLDOMNode_get_parentNode( IXMLDOMNode_from_impl(&This->node), parent ); + TRACE("(%p)->(%p)\n", This, parent); + if (!parent) return E_INVALIDARG; + *parent = NULL; + return S_FALSE; } static HRESULT WINAPI domattr_get_childNodes( diff --git a/reactos/dll/win32/msxml3/cdata.c b/reactos/dll/win32/msxml3/cdata.c index 7d02a946a0c..3fba66cdbc7 100644 --- a/reactos/dll/win32/msxml3/cdata.c +++ b/reactos/dll/win32/msxml3/cdata.c @@ -55,7 +55,7 @@ static HRESULT WINAPI domcdata_QueryInterface( void** ppvObject ) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMCDATASection ) || IsEqualGUID( riid, &IID_IXMLDOMCharacterData) || @@ -480,7 +480,7 @@ static HRESULT WINAPI domcdata_get_data( BSTR *p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - HRESULT hr = E_FAIL; + HRESULT hr; VARIANT vRet; if(!p) @@ -500,17 +500,14 @@ static HRESULT WINAPI domcdata_put_data( BSTR data) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - HRESULT hr = E_FAIL; VARIANT val; - TRACE("%p %s\n", This, debugstr_w(data) ); + TRACE("(%p)->(%s)\n", This, debugstr_w(data) ); V_VT(&val) = VT_BSTR; V_BSTR(&val) = data; - hr = IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); - - return hr; + return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); } static HRESULT WINAPI domcdata_get_length( @@ -518,23 +515,21 @@ static HRESULT WINAPI domcdata_get_length( LONG *len) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlChar *pContent; - LONG nLength = 0; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%p)\n", This, len); if(!len) return E_INVALIDARG; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMCDATASection_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); - xmlFree(pContent); + *len = SysStringLen(data); + SysFreeString(data); } - *len = nLength; - return S_OK; } @@ -543,11 +538,10 @@ static HRESULT WINAPI domcdata_substringData( LONG offset, LONG count, BSTR *p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlChar *pContent; - LONG nLength = 0; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%d %d %p)\n", This, offset, count, p); if(!p) return E_INVALIDARG; @@ -557,26 +551,24 @@ static HRESULT WINAPI domcdata_substringData( return E_INVALIDARG; if(count == 0) - return hr; + return S_FALSE; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMCDATASection_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); + LONG len = SysStringLen(data); - if( offset < nLength) + if(offset < len) { - BSTR sContent = bstr_from_xmlChar(pContent); - if(offset + count > nLength) - *p = SysAllocString(&sContent[offset]); + if(offset + count > len) + *p = SysAllocString(&data[offset]); else - *p = SysAllocStringLen(&sContent[offset], count); - - SysFreeString(sContent); - hr = S_OK; + *p = SysAllocStringLen(&data[offset], count); } + else + hr = S_FALSE; - xmlFree(pContent); + SysFreeString(data); } return hr; @@ -587,26 +579,30 @@ static HRESULT WINAPI domcdata_appendData( BSTR p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlChar *pContent; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", iface); + TRACE("(%p)->(%s)\n", This, debugstr_w(p)); /* Nothing to do if NULL or an Empty string passed in. */ - if(p == NULL || SysStringLen(p) == 0) - return S_OK; + if((p_len = SysStringLen(p)) == 0) return S_OK; - pContent = xmlChar_from_wchar( p ); - if(pContent) + hr = IXMLDOMCDATASection_get_data(iface, &data); + if(hr == S_OK) { - if(xmlTextConcat(This->node.node, pContent, SysStringLen(p) ) == 0) - hr = S_OK; - else - hr = E_FAIL; + LONG len = SysStringLen(data); + BSTR str = SysAllocStringLen(NULL, p_len + len); + + memcpy(str, data, len*sizeof(WCHAR)); + memcpy(&str[len], p, p_len*sizeof(WCHAR)); + str[len+p_len] = 0; + + hr = IXMLDOMCDATASection_put_data(iface, str); + + SysFreeString(str); + SysFreeString(data); } - else - hr = E_FAIL; - heap_free(pContent); return hr; } @@ -616,16 +612,14 @@ static HRESULT WINAPI domcdata_insertData( LONG offset, BSTR p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlChar *pXmlContent; - BSTR sNewString; - HRESULT hr = S_FALSE; - LONG nLength = 0, nLengthP = 0; - xmlChar *str = NULL; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", This); + TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p)); /* If have a NULL or empty string, don't do anything. */ - if(SysStringLen(p) == 0) + if((p_len = SysStringLen(p)) == 0) return S_OK; if(offset < 0) @@ -633,48 +627,29 @@ static HRESULT WINAPI domcdata_insertData( return E_INVALIDARG; } - pXmlContent = xmlNodeGetContent(This->node.node); - if(pXmlContent) + hr = IXMLDOMCDATASection_get_data(iface, &data); + if(hr == S_OK) { - BSTR sContent = bstr_from_xmlChar( pXmlContent ); - nLength = SysStringLen(sContent); - nLengthP = SysStringLen(p); + LONG len = SysStringLen(data); + BSTR str; - if(nLength < offset) + if(len < offset) { - SysFreeString(sContent); - xmlFree(pXmlContent); - + SysFreeString(data); return E_INVALIDARG; } - sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1); - if(sNewString) - { - if(offset > 0) - memcpy(sNewString, sContent, offset * sizeof(WCHAR)); + str = SysAllocStringLen(NULL, len + p_len); + /* start part, supplied string and end part */ + memcpy(str, data, offset*sizeof(WCHAR)); + memcpy(&str[offset], p, p_len*sizeof(WCHAR)); + memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR)); + str[len+p_len] = 0; - memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR)); + hr = IXMLDOMCDATASection_put_data(iface, str); - if(offset+nLengthP < nLength) - memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR)); - - sNewString[nLengthP + nLength] = 0; - - str = xmlChar_from_wchar(sNewString); - if(str) - { - xmlNodeSetContent(This->node.node, str); - hr = S_OK; - } - heap_free(str); - - SysFreeString(sNewString); - } - - SysFreeString(sContent); - - xmlFree(pXmlContent); + SysFreeString(str); + SysFreeString(data); } return hr; @@ -684,11 +659,12 @@ static HRESULT WINAPI domcdata_deleteData( IXMLDOMCDATASection *iface, LONG offset, LONG count) { + domcdata *This = impl_from_IXMLDOMCDATASection( iface ); HRESULT hr; LONG len = -1; BSTR str; - TRACE("%p %d %d\n", iface, offset, count); + TRACE("(%p)->(%d %d)\n", This, offset, count); hr = IXMLDOMCDATASection_get_length(iface, &len); if(hr != S_OK) return hr; @@ -731,15 +707,25 @@ static HRESULT WINAPI domcdata_replaceData( IXMLDOMCDATASection *iface, LONG offset, LONG count, BSTR p) { - FIXME("\n"); - return E_NOTIMPL; + domcdata *This = impl_from_IXMLDOMCDATASection( iface ); + HRESULT hr; + + TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p)); + + hr = IXMLDOMCDATASection_deleteData(iface, offset, count); + + if (hr == S_OK) + hr = IXMLDOMCDATASection_insertData(iface, offset, p); + + return hr; } static HRESULT WINAPI domcdata_splitText( IXMLDOMCDATASection *iface, LONG offset, IXMLDOMText **txtNode) { - FIXME("\n"); + domcdata *This = impl_from_IXMLDOMCDATASection( iface ); + FIXME("(%p)->(%d %p)\n", This, offset, txtNode); return E_NOTIMPL; } diff --git a/reactos/dll/win32/msxml3/comment.c b/reactos/dll/win32/msxml3/comment.c index 1e3b965e84a..e74de07e876 100644 --- a/reactos/dll/win32/msxml3/comment.c +++ b/reactos/dll/win32/msxml3/comment.c @@ -55,7 +55,7 @@ static HRESULT WINAPI domcomment_QueryInterface( void** ppvObject ) { domcomment *This = impl_from_IXMLDOMComment( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMComment ) || IsEqualGUID( riid, &IID_IXMLDOMCharacterData) || @@ -474,9 +474,11 @@ static HRESULT WINAPI domcomment_get_data( BSTR *p) { domcomment *This = impl_from_IXMLDOMComment( iface ); - HRESULT hr = E_FAIL; + HRESULT hr; VARIANT vRet; + TRACE("(%p)->(%p)\n", This, p); + if(!p) return E_INVALIDARG; @@ -494,17 +496,14 @@ static HRESULT WINAPI domcomment_put_data( BSTR data) { domcomment *This = impl_from_IXMLDOMComment( iface ); - HRESULT hr = E_FAIL; VARIANT val; - TRACE("%p %s\n", This, debugstr_w(data) ); + TRACE("(%p)->(%s)\n", This, debugstr_w(data) ); V_VT(&val) = VT_BSTR; V_BSTR(&val) = data; - hr = IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); - - return hr; + return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); } static HRESULT WINAPI domcomment_get_length( @@ -512,24 +511,22 @@ static HRESULT WINAPI domcomment_get_length( LONG *len) { domcomment *This = impl_from_IXMLDOMComment( iface ); - xmlChar *pContent; - LONG nLength = 0; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%p)\n", This, len); if(!len) return E_INVALIDARG; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMComment_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); - xmlFree(pContent); + *len = SysStringLen(data); + SysFreeString(data); } - *len = nLength; - - return S_OK; + return hr; } static HRESULT WINAPI domcomment_substringData( @@ -537,11 +534,10 @@ static HRESULT WINAPI domcomment_substringData( LONG offset, LONG count, BSTR *p) { domcomment *This = impl_from_IXMLDOMComment( iface ); - xmlChar *pContent; - LONG nLength = 0; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; - TRACE("%p %d %d %p\n", iface, offset, count, p); + TRACE("(%p)->(%d %d %p)\n", This, offset, count, p); if(!p) return E_INVALIDARG; @@ -553,24 +549,22 @@ static HRESULT WINAPI domcomment_substringData( if(count == 0) return S_FALSE; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMComment_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); + LONG len = SysStringLen(data); - if( offset < nLength) + if(offset < len) { - BSTR sContent = bstr_from_xmlChar(pContent); - if(offset + count > nLength) - *p = SysAllocString(&sContent[offset]); + if(offset + count > len) + *p = SysAllocString(&data[offset]); else - *p = SysAllocStringLen(&sContent[offset], count); - - SysFreeString(sContent); - hr = S_OK; + *p = SysAllocStringLen(&data[offset], count); } + else + hr = S_FALSE; - xmlFree(pContent); + SysFreeString(data); } return hr; @@ -581,40 +575,30 @@ static HRESULT WINAPI domcomment_appendData( BSTR p) { domcomment *This = impl_from_IXMLDOMComment( iface ); - xmlChar *pContent; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", iface); + TRACE("(%p)->(%s)\n", This, debugstr_w(p)); /* Nothing to do if NULL or an Empty string passed in. */ - if(p == NULL || SysStringLen(p) == 0) - return S_OK; + if((p_len = SysStringLen(p)) == 0) return S_OK; - pContent = xmlChar_from_wchar( p ); - if(pContent) + hr = IXMLDOMComment_get_data(iface, &data); + if(hr == S_OK) { - /* Older versions of libxml < 2.6.27 didn't correctly support - xmlTextConcat on Comment nodes. Fallback to setting the - contents directly if xmlTextConcat fails. - */ - if(xmlTextConcat(This->node.node, pContent, SysStringLen(p) ) == 0) - hr = S_OK; - else - { - xmlChar *pNew; - pNew = xmlStrcat(xmlNodeGetContent(This->node.node), pContent); - if(pNew) - { - xmlNodeSetContent(This->node.node, pNew); - hr = S_OK; - } - else - hr = E_FAIL; - } - HeapFree( GetProcessHeap(), 0, pContent ); + LONG len = SysStringLen(data); + BSTR str = SysAllocStringLen(NULL, p_len + len); + + memcpy(str, data, len*sizeof(WCHAR)); + memcpy(&str[len], p, p_len*sizeof(WCHAR)); + str[len+p_len] = 0; + + hr = IXMLDOMComment_put_data(iface, str); + + SysFreeString(str); + SysFreeString(data); } - else - hr = E_FAIL; return hr; } @@ -624,16 +608,14 @@ static HRESULT WINAPI domcomment_insertData( LONG offset, BSTR p) { domcomment *This = impl_from_IXMLDOMComment( iface ); - xmlChar *pXmlContent; - BSTR sNewString; - HRESULT hr = S_FALSE; - LONG nLength = 0, nLengthP = 0; - xmlChar *str = NULL; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p %d %p\n", iface, offset, p); + TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p)); /* If have a NULL or empty string, don't do anything. */ - if(SysStringLen(p) == 0) + if((p_len = SysStringLen(p)) == 0) return S_OK; if(offset < 0) @@ -641,48 +623,29 @@ static HRESULT WINAPI domcomment_insertData( return E_INVALIDARG; } - pXmlContent = xmlNodeGetContent(This->node.node); - if(pXmlContent) + hr = IXMLDOMComment_get_data(iface, &data); + if(hr == S_OK) { - BSTR sContent = bstr_from_xmlChar( pXmlContent ); - nLength = SysStringLen(sContent); - nLengthP = SysStringLen(p); + LONG len = SysStringLen(data); + BSTR str; - if(nLength < offset) + if(len < offset) { - SysFreeString(sContent); - xmlFree(pXmlContent); - + SysFreeString(data); return E_INVALIDARG; } - sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1); - if(sNewString) - { - if(offset > 0) - memcpy(sNewString, sContent, offset * sizeof(WCHAR)); + str = SysAllocStringLen(NULL, len + p_len); + /* start part, supplied string and end part */ + memcpy(str, data, offset*sizeof(WCHAR)); + memcpy(&str[offset], p, p_len*sizeof(WCHAR)); + memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR)); + str[len+p_len] = 0; - memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR)); + hr = IXMLDOMComment_put_data(iface, str); - if(offset+nLengthP < nLength) - memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR)); - - sNewString[nLengthP + nLength] = 0; - - str = xmlChar_from_wchar(sNewString); - if(str) - { - xmlNodeSetContent(This->node.node, str); - hr = S_OK; - } - HeapFree( GetProcessHeap(), 0, str ); - - SysFreeString(sNewString); - } - - SysFreeString(sContent); - - xmlFree(pXmlContent); + SysFreeString(str); + SysFreeString(data); } return hr; @@ -696,7 +659,7 @@ static HRESULT WINAPI domcomment_deleteData( LONG len = -1; BSTR str; - TRACE("%p %d %d\n", iface, offset, count); + TRACE("(%p)->(%d %d)\n", iface, offset, count); hr = IXMLDOMComment_get_length(iface, &len); if(hr != S_OK) return hr; @@ -739,8 +702,17 @@ static HRESULT WINAPI domcomment_replaceData( IXMLDOMComment *iface, LONG offset, LONG count, BSTR p) { - FIXME("\n"); - return E_NOTIMPL; + domcomment *This = impl_from_IXMLDOMComment( iface ); + HRESULT hr; + + TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p)); + + hr = IXMLDOMComment_deleteData(iface, offset, count); + + if (hr == S_OK) + hr = IXMLDOMComment_insertData(iface, offset, p); + + return hr; } static const struct IXMLDOMCommentVtbl domcomment_vtbl = diff --git a/reactos/dll/win32/msxml3/docfrag.c b/reactos/dll/win32/msxml3/docfrag.c index b5f6e464799..fff3f62a419 100644 --- a/reactos/dll/win32/msxml3/docfrag.c +++ b/reactos/dll/win32/msxml3/docfrag.c @@ -55,7 +55,7 @@ static HRESULT WINAPI domfrag_QueryInterface( void** ppvObject ) { domfrag *This = impl_from_IXMLDOMDocumentFragment( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentFragment ) || IsEqualGUID( riid, &IID_IDispatch ) || diff --git a/reactos/dll/win32/msxml3/domdoc.c b/reactos/dll/win32/msxml3/domdoc.c index 4914a7c0064..41c1f417642 100644 --- a/reactos/dll/win32/msxml3/domdoc.c +++ b/reactos/dll/win32/msxml3/domdoc.c @@ -47,6 +47,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml); #ifdef HAVE_LIBXML2 +#include + +/* not defined in older versions */ +#define XML_SAVE_FORMAT 1 +#define XML_SAVE_NO_DECL 2 +#define XML_SAVE_NO_EMPTY 4 +#define XML_SAVE_NO_XHTML 8 +#define XML_SAVE_XHTML 16 +#define XML_SAVE_AS_XML 32 +#define XML_SAVE_AS_HTML 64 + static const WCHAR SZ_PROPERTY_SELECTION_LANGUAGE[] = {'S','e','l','e','c','t','i','o','n','L','a','n','g','u','a','g','e',0}; static const WCHAR SZ_VALUE_XPATH[] = {'X','P','a','t','h',0}; static const WCHAR SZ_VALUE_XSLPATTERN[] = {'X','S','L','P','a','t','t','e','r','n',0}; @@ -290,7 +301,7 @@ static HRESULT WINAPI xmldoc_IPersistStream_IsDirty( { domdoc *This = impl_from_IPersistStream(iface); - FIXME("(%p->%p): stub!\n", iface, This); + FIXME("(%p): stub!\n", This); return S_FALSE; } @@ -306,7 +317,7 @@ static HRESULT WINAPI xmldoc_IPersistStream_Load( char *ptr; xmlDocPtr xmldoc = NULL; - TRACE("(%p, %p)\n", iface, pStm); + TRACE("(%p)->(%p)\n", This, pStm); if (!pStm) return E_INVALIDARG; @@ -355,7 +366,7 @@ static HRESULT WINAPI xmldoc_IPersistStream_Save( HRESULT hr; BSTR xmlString; - TRACE("(%p, %p, %d)\n", iface, pStm, fClearDirty); + TRACE("(%p)->(%p %d)\n", This, pStm, fClearDirty); hr = IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), &xmlString ); if(hr == S_OK) @@ -376,7 +387,8 @@ static HRESULT WINAPI xmldoc_IPersistStream_Save( static HRESULT WINAPI xmldoc_IPersistStream_GetSizeMax( IPersistStream *iface, ULARGE_INTEGER *pcbSize) { - TRACE("(%p, %p): stub!\n", iface, pcbSize); + domdoc *This = impl_from_IPersistStream(iface); + TRACE("(%p)->(%p): stub!\n", This, pcbSize); return E_NOTIMPL; } @@ -436,7 +448,7 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID rii { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject ); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid( riid ), ppvObject ); *ppvObject = NULL; @@ -459,6 +471,10 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID rii { *ppvObject = &(This->lpvtblIObjectWithSite); } + else if (IsEqualGUID(&IID_IObjectSafety, riid)) + { + *ppvObject = &(This->lpvtblIObjectSafety); + } else if( IsEqualGUID( riid, &IID_ISupportErrorInfo )) { *ppvObject = &This->lpvtblISupportErrorInfo; @@ -940,7 +956,8 @@ static HRESULT WINAPI domdoc_get_doctype( IXMLDOMDocument2 *iface, IXMLDOMDocumentType** documentType ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("(%p)\n", This); return E_NOTIMPL; } @@ -949,6 +966,10 @@ static HRESULT WINAPI domdoc_get_implementation( IXMLDOMDocument2 *iface, IXMLDOMImplementation** impl ) { + domdoc *This = impl_from_IXMLDOMDocument2(iface); + + TRACE("(%p)->(%p)\n", This, impl); + if(!impl) return E_INVALIDARG; @@ -967,7 +988,7 @@ static HRESULT WINAPI domdoc_get_documentElement( IXMLDOMNode *element_node; HRESULT hr; - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, DOMElement); if(!DOMElement) return E_INVALIDARG; @@ -1027,52 +1048,55 @@ static HRESULT WINAPI domdoc_createElement( BSTR tagname, IXMLDOMElement** element ) { - xmlNodePtr xmlnode; domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlChar *xml_name; - IUnknown *elem_unk; + IXMLDOMNode *node; + VARIANT type; HRESULT hr; - TRACE("%p->(%s,%p)\n", iface, debugstr_w(tagname), element); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(tagname), element); - xml_name = xmlChar_from_wchar(tagname); - xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL); - xmldoc_add_orphan(xmlnode->doc, xmlnode); + if (!element || !tagname) return E_INVALIDARG; - TRACE("created xmlptr %p\n", xmlnode); - elem_unk = create_element(xmlnode); - heap_free(xml_name); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_ELEMENT; + + hr = IXMLDOMDocument_createNode(iface, type, tagname, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMElement, (void**)element); + IXMLDOMNode_Release(node); + } - hr = IUnknown_QueryInterface(elem_unk, &IID_IXMLDOMElement, (void **)element); - IUnknown_Release(elem_unk); - TRACE("returning %p\n", *element); return hr; } static HRESULT WINAPI domdoc_createDocumentFragment( IXMLDOMDocument2 *iface, - IXMLDOMDocumentFragment** docFrag ) + IXMLDOMDocumentFragment** frag ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p\n", iface); + TRACE("(%p)->(%p)\n", This, frag); - if(!docFrag) - return E_INVALIDARG; + if (!frag) return E_INVALIDARG; - *docFrag = NULL; + *frag = NULL; - xmlnode = xmlNewDocFragment(get_doc( This ) ); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_DOCUMENT_FRAGMENT; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument_createNode(iface, type, NULL, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMDocumentFragment, (void**)frag); + IXMLDOMNode_Release(node); + } - xmldoc_add_orphan(xmlnode->doc, xmlnode); - *docFrag = (IXMLDOMDocumentFragment*)create_doc_fragment(xmlnode); - - return S_OK; + return hr; } @@ -1082,29 +1106,28 @@ static HRESULT WINAPI domdoc_createTextNode( IXMLDOMText** text ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; - xmlChar *xml_content; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p->(%s %p)\n", iface, debugstr_w(data), text); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), text); - if(!text) - return E_INVALIDARG; + if (!text) return E_INVALIDARG; *text = NULL; - xml_content = xmlChar_from_wchar(data); - xmlnode = xmlNewText(xml_content); - heap_free(xml_content); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_TEXT; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMText, (void**)text); + IXMLDOMNode_Release(node); + hr = IXMLDOMText_put_data(*text, data); + } - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *text = (IXMLDOMText*)create_text(xmlnode); - - return S_OK; + return hr; } @@ -1114,29 +1137,28 @@ static HRESULT WINAPI domdoc_createComment( IXMLDOMComment** comment ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; - xmlChar *xml_content; + VARIANT type; + HRESULT hr; + IXMLDOMNode *node; - TRACE("%p->(%s %p)\n", iface, debugstr_w(data), comment); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), comment); - if(!comment) - return E_INVALIDARG; + if (!comment) return E_INVALIDARG; *comment = NULL; - xml_content = xmlChar_from_wchar(data); - xmlnode = xmlNewComment(xml_content); - heap_free(xml_content); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_COMMENT; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMComment, (void**)comment); + IXMLDOMNode_Release(node); + hr = IXMLDOMComment_put_data(*comment, data); + } - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *comment = (IXMLDOMComment*)create_comment(xmlnode); - - return S_OK; + return hr; } @@ -1146,29 +1168,28 @@ static HRESULT WINAPI domdoc_createCDATASection( IXMLDOMCDATASection** cdata ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; - xmlChar *xml_content; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p->(%s %p)\n", iface, debugstr_w(data), cdata); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), cdata); - if(!cdata) - return E_INVALIDARG; + if (!cdata) return E_INVALIDARG; *cdata = NULL; - xml_content = xmlChar_from_wchar(data); - xmlnode = xmlNewCDataBlock(get_doc( This ), xml_content, strlen( (char*)xml_content) ); - heap_free(xml_content); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_CDATA_SECTION; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)cdata); + IXMLDOMNode_Release(node); + hr = IXMLDOMCDATASection_put_data(*cdata, data); + } - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *cdata = (IXMLDOMCDATASection*)create_cdata(xmlnode); - - return S_OK; + return hr; } @@ -1178,35 +1199,36 @@ static HRESULT WINAPI domdoc_createProcessingInstruction( BSTR data, IXMLDOMProcessingInstruction** pi ) { -#ifdef HAVE_XMLNEWDOCPI - xmlNodePtr xmlnode; domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlChar *xml_target, *xml_content; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p->(%s %s %p)\n", iface, debugstr_w(target), debugstr_w(data), pi); + TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), pi); - if(!pi) - return E_INVALIDARG; + if (!pi) return E_INVALIDARG; - if(!target || lstrlenW(target) == 0) - return E_FAIL; + *pi = NULL; - xml_target = xmlChar_from_wchar(target); - xml_content = xmlChar_from_wchar(data); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_PROCESSING_INSTRUCTION; - xmlnode = xmlNewDocPI(get_doc(This), xml_target, xml_content); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - TRACE("created xmlptr %p\n", xmlnode); - *pi = (IXMLDOMProcessingInstruction*)create_pi(xmlnode); + hr = IXMLDOMDocument2_createNode(iface, type, target, NULL, &node); + if (hr == S_OK) + { + VARIANT v_data; - heap_free(xml_content); - heap_free(xml_target); + /* this is to bypass check in ::put_data() that blocks "(%s %p)\n", iface, debugstr_w(name), attribute); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), attribute); - if(!attribute) - return E_INVALIDARG; + if (!attribute || !name) return E_INVALIDARG; - *attribute = NULL; + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_ATTRIBUTE; - xml_name = xmlChar_from_wchar(name); - xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL); - heap_free(xml_name); + hr = IXMLDOMDocument_createNode(iface, type, name, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMAttribute, (void**)attribute); + IXMLDOMNode_Release(node); + } - if(!xmlnode) - return E_FAIL; - - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *attribute = (IXMLDOMAttribute*)create_attribute(xmlnode); - - return S_OK; + return hr; } static HRESULT WINAPI domdoc_createEntityReference( IXMLDOMDocument2 *iface, BSTR name, - IXMLDOMEntityReference** entityRef ) + IXMLDOMEntityReference** entityref ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; - xmlChar *xml_name; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p\n", iface); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), entityref); - if(!entityRef) - return E_INVALIDARG; + if (!entityref) return E_INVALIDARG; - *entityRef = NULL; + *entityref = NULL; - xml_name = xmlChar_from_wchar(name); - xmlnode = xmlNewReference(get_doc( This ), xml_name ); - heap_free(xml_name); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_ENTITY_REFERENCE; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument2_createNode(iface, type, name, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMEntityReference, (void**)entityref); + IXMLDOMNode_Release(node); + } - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *entityRef = (IXMLDOMEntityReference*)create_doc_entity_ref(xmlnode); - - return S_OK; + return hr; } @@ -1284,7 +1300,7 @@ static HRESULT WINAPI domdoc_getElementsByTagName( domdoc *This = impl_from_IXMLDOMDocument2( iface ); LPWSTR szPattern; HRESULT hr; - TRACE("(%p)->(%s, %p)\n", This, debugstr_w(tagName), resultList); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(tagName), resultList); if (tagName[0] == '*' && tagName[1] == 0) { @@ -1329,51 +1345,86 @@ static HRESULT WINAPI domdoc_createNode( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); DOMNodeType node_type; - xmlNodePtr xmlnode = NULL; + xmlNodePtr xmlnode; xmlChar *xml_name; HRESULT hr; - TRACE("(%p)->(type,%s,%s,%p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node); + TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node); + + if(!node) return E_INVALIDARG; if(namespaceURI && namespaceURI[0]) FIXME("nodes with namespaces currently not supported.\n"); hr = get_node_type(Type, &node_type); - if(FAILED(hr)) - return hr; + if(FAILED(hr)) return hr; TRACE("node_type %d\n", node_type); + /* exit earlier for types that need name */ + switch(node_type) + { + case NODE_ELEMENT: + case NODE_ATTRIBUTE: + case NODE_ENTITY_REFERENCE: + case NODE_PROCESSING_INSTRUCTION: + if (!name || SysStringLen(name) == 0) return E_FAIL; + default: + break; + } + xml_name = xmlChar_from_wchar(name); switch(node_type) { case NODE_ELEMENT: xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL); - *node = create_node(xmlnode); - TRACE("created %p\n", xmlnode); break; case NODE_ATTRIBUTE: - xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL); - if(xmlnode) - { - xmlnode->doc = get_doc( This ); - - *node = (IXMLDOMNode*)create_attribute(xmlnode); - } - - TRACE("created %p\n", xmlnode); + xmlnode = (xmlNodePtr)xmlNewDocProp(get_doc(This), xml_name, NULL); break; - + case NODE_TEXT: + xmlnode = (xmlNodePtr)xmlNewDocText(get_doc(This), NULL); + break; + case NODE_CDATA_SECTION: + xmlnode = xmlNewCDataBlock(get_doc(This), NULL, 0); + break; + case NODE_ENTITY_REFERENCE: + xmlnode = xmlNewReference(get_doc(This), xml_name); + break; + case NODE_PROCESSING_INSTRUCTION: +#ifdef HAVE_XMLNEWDOCPI + xmlnode = xmlNewDocPI(get_doc(This), xml_name, NULL); +#else + FIXME("xmlNewDocPI() not supported, use libxml2 2.6.15 or greater\n"); + xmlnode = NULL; +#endif + break; + case NODE_COMMENT: + xmlnode = xmlNewDocComment(get_doc(This), NULL); + break; + case NODE_DOCUMENT_FRAGMENT: + xmlnode = xmlNewDocFragment(get_doc(This)); + break; + /* unsupported types */ + case NODE_DOCUMENT: + case NODE_DOCUMENT_TYPE: + case NODE_ENTITY: + case NODE_NOTATION: + heap_free(xml_name); + return E_INVALIDARG; default: FIXME("unhandled node type %d\n", node_type); + xmlnode = NULL; break; } + *node = create_node(xmlnode); heap_free(xml_name); - if(xmlnode && *node) + if(*node) { + TRACE("created node (%d, %p, %p)\n", node_type, *node, xmlnode); xmldoc_add_orphan(xmlnode->doc, xmlnode); return S_OK; } @@ -1386,7 +1437,8 @@ static HRESULT WINAPI domdoc_nodeFromID( BSTR idString, IXMLDOMNode** node ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("(%p)->(%s %p)\n", This, debugstr_w(idString), node); return E_NOTIMPL; } @@ -1432,7 +1484,7 @@ static HRESULT WINAPI domdoc_load( IStream *pStream = NULL; xmlDocPtr xmldoc; - TRACE("type %d\n", V_VT(&xmlSource) ); + TRACE("(%p)->type %d\n", This, V_VT(&xmlSource) ); *isSuccessful = VARIANT_FALSE; @@ -1528,7 +1580,8 @@ static HRESULT WINAPI domdoc_get_readyState( IXMLDOMDocument2 *iface, LONG *value ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("(%p)->(%p)\n", This, value); return E_NOTIMPL; } @@ -1556,7 +1609,8 @@ static HRESULT WINAPI domdoc_get_url( IXMLDOMDocument2 *iface, BSTR* urlString ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("(%p)->(%p)\n", This, urlString); return E_NOTIMPL; } @@ -1567,7 +1621,7 @@ static HRESULT WINAPI domdoc_get_async( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p <- %d\n", isAsync, This->async); + TRACE("(%p)->(%p: %d)\n", This, isAsync, This->async); *isAsync = This->async; return S_OK; } @@ -1579,7 +1633,7 @@ static HRESULT WINAPI domdoc_put_async( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%d\n", isAsync); + TRACE("(%p)->(%d)\n", This, isAsync); This->async = isAsync; return S_OK; } @@ -1588,7 +1642,8 @@ static HRESULT WINAPI domdoc_put_async( static HRESULT WINAPI domdoc_abort( IXMLDOMDocument2 *iface ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1619,7 +1674,7 @@ static HRESULT WINAPI domdoc_loadXML( int len; HRESULT hr = S_FALSE, hr2; - TRACE("%p %s %p\n", This, debugstr_w( bstrXML ), isSuccessful ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w( bstrXML ), isSuccessful ); assert ( &This->node ); @@ -1651,6 +1706,24 @@ static HRESULT WINAPI domdoc_loadXML( return hr; } +static int XMLCALL domdoc_save_writecallback(void *ctx, const char *buffer, + int len) +{ + DWORD written = -1; + + if(!WriteFile(ctx, buffer, len, &written, NULL)) + { + WARN("write error\n"); + return -1; + } + else + return written; +} + +static int XMLCALL domdoc_save_closecallback(void *ctx) +{ + return CloseHandle(ctx) ? 0 : -1; +} static HRESULT WINAPI domdoc_save( IXMLDOMDocument2 *iface, @@ -1658,10 +1731,8 @@ static HRESULT WINAPI domdoc_save( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); HANDLE handle; - xmlChar *mem, *p; - int size; + xmlSaveCtxtPtr ctx; HRESULT ret = S_OK; - DWORD written; TRACE("(%p)->(var(vt %d, %s))\n", This, V_VT(&destination), V_VT(&destination) == VT_BSTR ? debugstr_w(V_BSTR(&destination)) : NULL); @@ -1707,31 +1778,19 @@ static HRESULT WINAPI domdoc_save( return S_FALSE; } - xmlDocDumpMemory(get_doc(This), &mem, &size); - - /* - * libxml2 always adds XML declaration on top of the file and one for each processing instruction node in DOM tree. - * MSXML adds XML declaration only for processing instruction nodes. - * We skip the first XML declaration generated by libxml2 to get exactly what we need. - */ - p = mem; - if(size > 2 && p[0] == '<' && p[1] == '?') { - while(p < mem+size && (p[0] != '?' || p[1] != '>')) - p++; - p += 2; - while(p < mem+size && isspace(*p)) - p++; - size -= p-mem; - } - - if(!WriteFile(handle, p, (DWORD)size, &written, NULL) || written != (DWORD)size) + /* disable top XML declaration */ + ctx = xmlSaveToIO(domdoc_save_writecallback, domdoc_save_closecallback, + handle, NULL, XML_SAVE_NO_DECL); + if (!ctx) { - WARN("write error\n"); - ret = S_FALSE; + CloseHandle(handle); + return S_FALSE; } - xmlFree(mem); - CloseHandle(handle); + if (xmlSaveDoc(ctx, get_doc(This)) == -1) ret = S_FALSE; + /* will close file through close callback */ + xmlSaveClose(ctx); + return ret; } @@ -1741,7 +1800,7 @@ static HRESULT WINAPI domdoc_get_validateOnParse( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p <- %d\n", isValidating, This->validating); + TRACE("(%p)->(%p: %d)\n", This, isValidating, This->validating); *isValidating = This->validating; return S_OK; } @@ -1753,7 +1812,7 @@ static HRESULT WINAPI domdoc_put_validateOnParse( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%d\n", isValidating); + TRACE("(%p)->(%d)\n", This, isValidating); This->validating = isValidating; return S_OK; } @@ -1765,7 +1824,7 @@ static HRESULT WINAPI domdoc_get_resolveExternals( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p <- %d\n", isResolving, This->resolving); + TRACE("(%p)->(%p: %d)\n", This, isResolving, This->resolving); *isResolving = This->resolving; return S_OK; } @@ -1777,7 +1836,7 @@ static HRESULT WINAPI domdoc_put_resolveExternals( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%d\n", isResolving); + TRACE("(%p)->(%d)\n", This, isResolving); This->resolving = isResolving; return S_OK; } @@ -1789,7 +1848,7 @@ static HRESULT WINAPI domdoc_get_preserveWhiteSpace( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p <- %d\n", isPreserving, This->preserving); + TRACE("(%p)->(%p: %d)\n", This, isPreserving, This->preserving); *isPreserving = This->preserving; return S_OK; } @@ -1801,7 +1860,7 @@ static HRESULT WINAPI domdoc_put_preserveWhiteSpace( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%d\n", isPreserving); + TRACE("(%p)->(%d)\n", This, isPreserving); This->preserving = isPreserving; return S_OK; } @@ -1811,7 +1870,8 @@ static HRESULT WINAPI domdoc_put_onReadyStateChange( IXMLDOMDocument2 *iface, VARIANT readyStateChangeSink ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1820,7 +1880,8 @@ static HRESULT WINAPI domdoc_put_onDataAvailable( IXMLDOMDocument2 *iface, VARIANT onDataAvailableSink ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1828,7 +1889,8 @@ static HRESULT WINAPI domdoc_put_onTransformNode( IXMLDOMDocument2 *iface, VARIANT onTransformNodeSink ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1836,7 +1898,8 @@ static HRESULT WINAPI domdoc_get_namespaces( IXMLDOMDocument2* iface, IXMLDOMSchemaCollection** schemaCollection ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("(%p)->(%p)\n", This, schemaCollection); return E_NOTIMPL; } @@ -1903,7 +1966,8 @@ static HRESULT WINAPI domdoc_validate( IXMLDOMDocument2* iface, IXMLDOMParseError** err) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("(%p)->(%p)\n", This, err); return E_NOTIMPL; } @@ -1914,6 +1978,8 @@ static HRESULT WINAPI domdoc_setProperty( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); + TRACE("(%p)->(%s)\n", This, debugstr_w(p)); + if (lstrcmpiW(p, SZ_PROPERTY_SELECTION_LANGUAGE) == 0) { VARIANT varStr; @@ -1953,6 +2019,8 @@ static HRESULT WINAPI domdoc_getProperty( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); + TRACE("(%p)->(%p)\n", This, debugstr_w(p)); + if (var == NULL) return E_INVALIDARG; if (lstrcmpiW(p, SZ_PROPERTY_SELECTION_LANGUAGE) == 0) @@ -2082,7 +2150,7 @@ xmldoc_GetSite( IObjectWithSite *iface, REFIID iid, void ** ppvSite ) { domdoc *This = impl_from_IObjectWithSite(iface); - TRACE("%p %s %p\n", This, debugstr_guid( iid ), ppvSite ); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid( iid ), ppvSite ); if ( !This->site ) return E_FAIL; @@ -2095,7 +2163,7 @@ xmldoc_SetSite( IObjectWithSite *iface, IUnknown *punk ) { domdoc *This = impl_from_IObjectWithSite(iface); - TRACE("%p %p\n", iface, punk); + TRACE("(%p)->(%p)\n", iface, punk); if(!punk) { @@ -2146,7 +2214,7 @@ static ULONG WINAPI xmldoc_Safety_Release(IObjectSafety *iface) return IXMLDocument_Release((IXMLDocument *)This); } -#define SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER) +#define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA) static HRESULT WINAPI xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions) @@ -2158,7 +2226,7 @@ static HRESULT WINAPI xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *ifa if(!pdwSupportedOptions || !pdwEnabledOptions) return E_POINTER; - *pdwSupportedOptions = SUPPORTED_OPTIONS; + *pdwSupportedOptions = SAFETY_SUPPORTED_OPTIONS; *pdwEnabledOptions = This->safeopt; return S_OK; @@ -2168,13 +2236,9 @@ static HRESULT WINAPI xmldoc_Safety_SetInterfaceSafetyOptions(IObjectSafety *ifa DWORD dwOptionSetMask, DWORD dwEnabledOptions) { domdoc *This = impl_from_IObjectSafety(iface); - TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions); - if(dwOptionSetMask & ~SUPPORTED_OPTIONS) - return E_FAIL; - - This->safeopt = dwEnabledOptions & dwEnabledOptions; + This->safeopt = dwEnabledOptions & dwOptionSetMask & SAFETY_SUPPORTED_OPTIONS; return S_OK; } diff --git a/reactos/dll/win32/msxml3/domimpl.c b/reactos/dll/win32/msxml3/domimpl.c index 1a07676e33f..dd518a1bc3b 100644 --- a/reactos/dll/win32/msxml3/domimpl.c +++ b/reactos/dll/win32/msxml3/domimpl.c @@ -54,7 +54,7 @@ static HRESULT WINAPI dimimpl_QueryInterface( void** ppvObject ) { domimpl *This = impl_from_IXMLDOMImplementation( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMImplementation ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -181,7 +181,7 @@ static HRESULT WINAPI dimimpl_hasFeature(IXMLDOMImplementation* This, BSTR featu BOOL bValidFeature = FALSE; BOOL bValidVersion = FALSE; - TRACE("feature(%s) version (%s)\n", debugstr_w(feature), debugstr_w(version)); + TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_w(version), hasFeature); if(!feature || !hasFeature) return E_INVALIDARG; diff --git a/reactos/dll/win32/msxml3/element.c b/reactos/dll/win32/msxml3/element.c index f7bd3b03e08..01547709b7b 100644 --- a/reactos/dll/win32/msxml3/element.c +++ b/reactos/dll/win32/msxml3/element.c @@ -62,7 +62,7 @@ static HRESULT WINAPI domelem_QueryInterface( { domelem *This = impl_from_IXMLDOMElement( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMElement ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -493,7 +493,7 @@ static HRESULT WINAPI domelem_get_tagName( DWORD offset = 0; LPWSTR str; - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, p ); element = get_element( This ); if ( !element ) @@ -526,7 +526,7 @@ static HRESULT WINAPI domelem_getAttribute( xmlChar *xml_name, *xml_value = NULL; HRESULT hr = S_FALSE; - TRACE("(%p)->(%s,%p)\n", This, debugstr_w(name), value); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), value); if(!value || !name) return E_INVALIDARG; @@ -567,7 +567,7 @@ static HRESULT WINAPI domelem_setAttribute( HRESULT hr; VARIANT var; - TRACE("(%p)->(%s, var)\n", This, debugstr_w(name)); + TRACE("(%p)->(%s var)\n", This, debugstr_w(name)); element = get_element( This ); if ( !element ) @@ -660,7 +660,8 @@ static HRESULT WINAPI domelem_setAttributeNode( IXMLDOMAttribute* domAttribute, IXMLDOMAttribute** attributeNode) { - FIXME("\n"); + domelem *This = impl_from_IXMLDOMElement( iface ); + FIXME("(%p)->(%p %p)\n", This, domAttribute, attributeNode); return E_NOTIMPL; } @@ -669,7 +670,8 @@ static HRESULT WINAPI domelem_removeAttributeNode( IXMLDOMAttribute* domAttribute, IXMLDOMAttribute** attributeNode) { - FIXME("\n"); + domelem *This = impl_from_IXMLDOMElement( iface ); + FIXME("(%p)->(%p %p)\n", This, domAttribute, attributeNode); return E_NOTIMPL; } @@ -684,7 +686,7 @@ static HRESULT WINAPI domelem_getElementsByTagName( xmlNodePtr element; HRESULT hr; - TRACE("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), resultList); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), resultList); if (bstrName[0] == '*' && bstrName[1] == 0) { @@ -714,7 +716,8 @@ static HRESULT WINAPI domelem_getElementsByTagName( static HRESULT WINAPI domelem_normalize( IXMLDOMElement *iface ) { - FIXME("\n"); + domelem *This = impl_from_IXMLDOMElement( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } diff --git a/reactos/dll/win32/msxml3/entityref.c b/reactos/dll/win32/msxml3/entityref.c index 1489dbd0c57..db461934538 100644 --- a/reactos/dll/win32/msxml3/entityref.c +++ b/reactos/dll/win32/msxml3/entityref.c @@ -55,7 +55,7 @@ static HRESULT WINAPI entityref_QueryInterface( void** ppvObject ) { entityref *This = impl_from_IXMLDOMEntityReference( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMEntityReference ) || IsEqualGUID( riid, &IID_IDispatch ) || diff --git a/reactos/dll/win32/msxml3/factory.c b/reactos/dll/win32/msxml3/factory.c index 45ba3680c0f..af94d5cbcf1 100644 --- a/reactos/dll/win32/msxml3/factory.c +++ b/reactos/dll/win32/msxml3/factory.c @@ -167,7 +167,8 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv ) cf = (IClassFactory*) &domdoccf.lpVtbl; } else if( IsEqualCLSID( rclsid, &CLSID_SAXXMLReader) || - IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 )) + IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 ) || + IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 )) { cf = (IClassFactory*) &saxreadcf.lpVtbl; } diff --git a/reactos/dll/win32/msxml3/httprequest.c b/reactos/dll/win32/msxml3/httprequest.c index a477753a71a..458548406a0 100644 --- a/reactos/dll/win32/msxml3/httprequest.c +++ b/reactos/dll/win32/msxml3/httprequest.c @@ -50,7 +50,7 @@ static inline httprequest *impl_from_IXMLHTTPRequest( IXMLHTTPRequest *iface ) static HRESULT WINAPI httprequest_QueryInterface(IXMLHTTPRequest *iface, REFIID riid, void **ppvObject) { httprequest *This = impl_from_IXMLHTTPRequest( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLHTTPRequest) || IsEqualGUID( riid, &IID_IDispatch) || diff --git a/reactos/dll/win32/msxml3/msxml_private.h b/reactos/dll/win32/msxml3/msxml_private.h index e46642d84b6..1df3e8b6cd5 100644 --- a/reactos/dll/win32/msxml3/msxml_private.h +++ b/reactos/dll/win32/msxml3/msxml_private.h @@ -1,5 +1,5 @@ /* - * MSXML Class Factory + * Common definitions * * Copyright 2005 Mike McCormack * @@ -174,6 +174,8 @@ static inline BSTR bstr_from_xmlChar(const xmlChar *str) if(ret) MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len); } + else + ret = SysAllocStringLen(NULL, 0); return ret; } diff --git a/reactos/dll/win32/msxml3/node.c b/reactos/dll/win32/msxml3/node.c index 6729512d69e..ac97681aac9 100644 --- a/reactos/dll/win32/msxml3/node.c +++ b/reactos/dll/win32/msxml3/node.c @@ -87,7 +87,7 @@ static HRESULT WINAPI xmlnode_QueryInterface( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if(This->pUnkOuter) return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject); @@ -230,7 +230,7 @@ static HRESULT WINAPI xmlnode_get_nodeName( xmlnode *This = impl_from_IXMLDOMNode( iface ); const xmlChar *str; - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, name ); if (!name) return E_INVALIDARG; @@ -250,16 +250,16 @@ static HRESULT WINAPI xmlnode_get_nodeName( str = (const xmlChar*) "#document-fragment"; break; case XML_TEXT_NODE: - str = (const xmlChar*) "#text"; - break; + str = (const xmlChar*) "#text"; + break; case XML_DOCUMENT_NODE: - str = (const xmlChar*) "#document"; - break; - case XML_ATTRIBUTE_NODE: - case XML_ELEMENT_NODE: - case XML_PI_NODE: + str = (const xmlChar*) "#document"; + break; + case XML_ATTRIBUTE_NODE: + case XML_ELEMENT_NODE: + case XML_PI_NODE: str = This->node->name; - break; + break; default: FIXME("nodeName not mapped correctly (%d)\n", This->node->type); str = This->node->name; @@ -280,7 +280,7 @@ static HRESULT WINAPI xmlnode_get_nodeValue( xmlnode *This = impl_from_IXMLDOMNode( iface ); HRESULT r = S_FALSE; - TRACE("%p %p\n", This, value); + TRACE("(%p)->(%p)\n", This, value); if(!value) return E_INVALIDARG; @@ -327,23 +327,11 @@ static HRESULT WINAPI xmlnode_put_nodeValue( { xmlnode *This = impl_from_IXMLDOMNode( iface ); HRESULT hr; - xmlChar *str = NULL; - VARIANT string_value; TRACE("%p type(%d)\n", This, This->node->type); - VariantInit(&string_value); - hr = VariantChangeType(&string_value, &value, 0, VT_BSTR); - if(FAILED(hr)) - { - VariantClear(&string_value); - WARN("Couldn't convert to VT_BSTR\n"); - return hr; - } - - hr = S_FALSE; /* Document, Document Fragment, Document Type, Element, - Entity, Entity Reference, Notation aren't supported. */ + Entity, Entity Reference, Notation aren't supported. */ switch ( This->node->type ) { case XML_ATTRIBUTE_NODE: @@ -351,20 +339,33 @@ static HRESULT WINAPI xmlnode_put_nodeValue( case XML_COMMENT_NODE: case XML_PI_NODE: case XML_TEXT_NODE: - { + { + VARIANT string_value; + xmlChar *str; + + VariantInit(&string_value); + hr = VariantChangeType(&string_value, &value, 0, VT_BSTR); + if(FAILED(hr)) + { + VariantClear(&string_value); + WARN("Couldn't convert to VT_BSTR\n"); + return hr; + } + str = xmlChar_from_wchar(V_BSTR(&string_value)); + VariantClear(&string_value); + xmlNodeSetContent(This->node, str); heap_free(str); hr = S_OK; break; - } + } default: /* Do nothing for unsupported types. */ + hr = E_FAIL; break; } - VariantClear(&string_value); - return hr; } @@ -374,7 +375,7 @@ static HRESULT WINAPI xmlnode_get_nodeType( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p %p\n", This, type); + TRACE("(%p)->(%p)\n", This, type); assert( (int)NODE_ELEMENT == (int)XML_ELEMENT_NODE ); assert( (int)NODE_NOTATION == (int)XML_NOTATION_NODE ); @@ -390,7 +391,7 @@ static HRESULT get_node( xmlNodePtr node, IXMLDOMNode **out ) { - TRACE("%p->%s %p\n", This, name, node ); + TRACE("(%p)->(%s %p %p)\n", This, name, node, out ); if ( !out ) return E_INVALIDARG; @@ -419,7 +420,7 @@ static HRESULT WINAPI xmlnode_get_childNodes( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p %p\n", This, childList ); + TRACE("(%p)->(%p)\n", This, childList ); if ( !childList ) return E_INVALIDARG; @@ -445,7 +446,7 @@ static HRESULT WINAPI xmlnode_get_lastChild( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, lastChild ); if (!lastChild) return E_INVALIDARG; @@ -470,7 +471,7 @@ static HRESULT WINAPI xmlnode_get_previousSibling( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, previousSibling ); if (!previousSibling) return E_INVALIDARG; @@ -494,7 +495,7 @@ static HRESULT WINAPI xmlnode_get_nextSibling( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, nextSibling ); if (!nextSibling) return E_INVALIDARG; @@ -517,7 +518,7 @@ static HRESULT WINAPI xmlnode_get_attributes( IXMLDOMNamedNodeMap** attributeMap) { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, attributeMap); if (!attributeMap) return E_INVALIDARG; @@ -553,7 +554,7 @@ static HRESULT WINAPI xmlnode_insertBefore( IXMLDOMNode *before = NULL, *new; HRESULT hr; - TRACE("(%p)->(%p,var,%p)\n",This,newChild,outNewChild); + TRACE("(%p)->(%p var %p)\n",This,newChild,outNewChild); if (!newChild) return E_INVALIDARG; @@ -620,7 +621,7 @@ static HRESULT WINAPI xmlnode_replaceChild( IXMLDOMNode *realOldChild; HRESULT hr; - TRACE("%p->(%p,%p,%p)\n",This,newChild,oldChild,outOldChild); + TRACE("(%p)->(%p %p %p)\n", This, newChild, oldChild, outOldChild); /* Do not believe any documentation telling that newChild == NULL means removal. It does certainly *not* apply to msxml3! */ @@ -684,7 +685,7 @@ static HRESULT WINAPI xmlnode_removeChild( HRESULT hr; IXMLDOMNode *child; - TRACE("%p->(%p, %p)\n", This, childNode, oldChild); + TRACE("(%p)->(%p %p)\n", This, childNode, oldChild); if(!childNode) return E_INVALIDARG; @@ -726,7 +727,7 @@ static HRESULT WINAPI xmlnode_appendChild( VARIANT var; HRESULT hr; - TRACE("(%p)->(%p,%p)\n", This, newChild, outNewChild); + TRACE("(%p)->(%p %p)\n", This, newChild, outNewChild); hr = IXMLDOMNode_get_nodeType(newChild, &type); if(FAILED(hr) || type == NODE_ATTRIBUTE) { @@ -744,7 +745,7 @@ static HRESULT WINAPI xmlnode_hasChildNodes( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, hasChild); if (!hasChild) return E_INVALIDARG; @@ -764,7 +765,7 @@ static HRESULT WINAPI xmlnode_get_ownerDocument( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p (%p)\n", This, DOMDocument); + TRACE("(%p)->(%p)\n", This, DOMDocument); return DOMDocument_create_from_xmldoc(This->node->doc, (IXMLDOMDocument2**)DOMDocument); } @@ -778,7 +779,7 @@ static HRESULT WINAPI xmlnode_cloneNode( xmlNodePtr pClone = NULL; IXMLDOMNode *pNode = NULL; - TRACE("%p (%d)\n", This, deep); + TRACE("(%p)->(%d %p)\n", This, deep, cloneRoot); if(!cloneRoot) return E_INVALIDARG; @@ -814,7 +815,7 @@ static HRESULT WINAPI xmlnode_get_nodeTypeString( xmlnode *This = impl_from_IXMLDOMNode( iface ); const xmlChar *str; - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, xmlnodeType ); if (!xmlnodeType) return E_INVALIDARG; @@ -878,7 +879,7 @@ static HRESULT WINAPI xmlnode_get_text( BSTR str = NULL; xmlChar *pContent; - TRACE("%p type %d\n", This, This->node->type); + TRACE("(%p, type %d)->(%p)\n", This, This->node->type, text); if ( !text ) return E_INVALIDARG; @@ -906,7 +907,7 @@ static HRESULT WINAPI xmlnode_put_text( xmlnode *This = impl_from_IXMLDOMNode( iface ); xmlChar *str, *str2; - TRACE("%p\n", This); + TRACE("(%p)->(%s)\n", This, debugstr_w(text)); switch(This->node->type) { @@ -932,7 +933,8 @@ static HRESULT WINAPI xmlnode_get_specified( IXMLDOMNode *iface, VARIANT_BOOL* isSpecified) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("(%p)->(%p)\n", This, isSpecified); return E_NOTIMPL; } @@ -940,12 +942,11 @@ static HRESULT WINAPI xmlnode_get_definition( IXMLDOMNode *iface, IXMLDOMNode** definitionNode) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("(%p)->(%p)\n", This, definitionNode); return E_NOTIMPL; } -static HRESULT WINAPI xmlnode_get_dataType(IXMLDOMNode*, VARIANT*); - static inline BYTE hex_to_byte(xmlChar c) { if(c <= '9') return c-'0'; @@ -1136,7 +1137,7 @@ static HRESULT WINAPI xmlnode_get_nodeTypedValue( xmlChar *content; HRESULT hres = S_FALSE; - TRACE("iface %p\n", iface); + TRACE("(%p)->(%p)\n", This, typedValue); if(!typedValue) return E_INVALIDARG; @@ -1146,10 +1147,10 @@ static HRESULT WINAPI xmlnode_get_nodeTypedValue( if(This->node->type == XML_ELEMENT_NODE || This->node->type == XML_TEXT_NODE || This->node->type == XML_ENTITY_REF_NODE) - hres = xmlnode_get_dataType(iface, &type); + hres = IXMLDOMNode_get_dataType(iface, &type); if(hres != S_OK && This->node->type != XML_ELEMENT_NODE) - return xmlnode_get_nodeValue(iface, typedValue); + return IXMLDOMNode_get_nodeValue(iface, typedValue); content = xmlNodeGetContent(This->node); hres = VARIANT_from_xmlChar(content, typedValue, @@ -1164,7 +1165,8 @@ static HRESULT WINAPI xmlnode_put_nodeTypedValue( IXMLDOMNode *iface, VARIANT typedValue) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1175,7 +1177,7 @@ static HRESULT WINAPI xmlnode_get_dataType( xmlnode *This = impl_from_IXMLDOMNode( iface ); xmlChar *pVal; - TRACE("iface %p\n", iface); + TRACE("(%p)->(%p)\n", This, dataTypeName); if(!dataTypeName) return E_INVALIDARG; @@ -1220,7 +1222,7 @@ static HRESULT WINAPI xmlnode_put_dataType( xmlnode *This = impl_from_IXMLDOMNode( iface ); HRESULT hr = E_FAIL; - TRACE("iface %p\n", iface); + TRACE("(%p)->(%s)\n", This, debugstr_w(dataTypeName)); if(dataTypeName == NULL) return E_INVALIDARG; @@ -1382,7 +1384,7 @@ static HRESULT WINAPI xmlnode_get_xml( xmlBufferPtr pXmlBuf; int nSize; - TRACE("iface %p %d\n", iface, This->node->type); + TRACE("(%p %d)->(%p)\n", This, This->node->type, xmlString); if(!xmlString) return E_INVALIDARG; @@ -1440,7 +1442,7 @@ static HRESULT WINAPI xmlnode_transformNode( xmlDocPtr result = NULL; IXMLDOMNode *ssNew; - TRACE("%p %p %p\n", This, styleSheet, xmlString); + TRACE("(%p)->(%p %p)\n", This, styleSheet, xmlString); if (!libxslt_handle) return E_NOTIMPL; @@ -1517,7 +1519,7 @@ static HRESULT WINAPI xmlnode_selectNodes( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p %s %p\n", This, debugstr_w(queryString), resultList ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(queryString), resultList ); return queryresult_create( This->node, queryString, resultList ); } @@ -1531,7 +1533,7 @@ static HRESULT WINAPI xmlnode_selectSingleNode( IXMLDOMNodeList *list; HRESULT r; - TRACE("%p %s %p\n", This, debugstr_w(queryString), resultNode ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(queryString), resultNode ); *resultNode = NULL; r = IXMLDOMNode_selectNodes(iface, queryString, &list); @@ -1547,7 +1549,8 @@ static HRESULT WINAPI xmlnode_get_parsed( IXMLDOMNode *iface, VARIANT_BOOL* isParsed) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("(%p)->(%p)\n", This, isParsed); return E_NOTIMPL; } @@ -1559,7 +1562,7 @@ static HRESULT WINAPI xmlnode_get_namespaceURI( HRESULT hr = S_FALSE; xmlNsPtr *pNSList; - TRACE("%p %p\n", This, namespaceURI ); + TRACE("(%p)->(%p)\n", This, namespaceURI ); if(!namespaceURI) return E_INVALIDARG; @@ -1586,7 +1589,7 @@ static HRESULT WINAPI xmlnode_get_prefix( HRESULT hr = S_FALSE; xmlNsPtr *pNSList; - TRACE("%p %p\n", This, prefixString ); + TRACE("(%p)->(%p)\n", This, prefixString ); if(!prefixString) return E_INVALIDARG; @@ -1613,7 +1616,7 @@ static HRESULT WINAPI xmlnode_get_baseName( BSTR str = NULL; HRESULT r = S_FALSE; - TRACE("%p %p\n", This, nameString ); + TRACE("(%p)->(%p)\n", This, nameString ); if ( !nameString ) return E_INVALIDARG; @@ -1622,10 +1625,12 @@ static HRESULT WINAPI xmlnode_get_baseName( { case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: + case XML_PI_NODE: str = bstr_from_xmlChar( This->node->name ); r = S_OK; break; case XML_TEXT_NODE: + case XML_COMMENT_NODE: break; default: ERR("Unhandled type %d\n", This->node->type ); @@ -1643,7 +1648,8 @@ static HRESULT WINAPI xmlnode_transformNodeToObject( IXMLDOMNode* stylesheet, VARIANT outputObject) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("(%p)->(%p)\n", This, stylesheet); return E_NOTIMPL; } @@ -1738,12 +1744,21 @@ IXMLDOMNode *create_node( xmlNodePtr node ) case XML_CDATA_SECTION_NODE: pUnk = create_cdata( node ); break; + case XML_ENTITY_REF_NODE: + pUnk = create_doc_entity_ref( node ); + break; + case XML_PI_NODE: + pUnk = create_pi( node ); + break; case XML_COMMENT_NODE: pUnk = create_comment( node ); break; case XML_DOCUMENT_NODE: pUnk = create_domdoc( node ); break; + case XML_DOCUMENT_FRAG_NODE: + pUnk = create_doc_fragment( node ); + break; default: { xmlnode *new_node; diff --git a/reactos/dll/win32/msxml3/nodelist.c b/reactos/dll/win32/msxml3/nodelist.c index 011fff0bf61..f643c5e8cbb 100644 --- a/reactos/dll/win32/msxml3/nodelist.c +++ b/reactos/dll/win32/msxml3/nodelist.c @@ -64,7 +64,7 @@ static HRESULT WINAPI xmlnodelist_QueryInterface( REFIID riid, void** ppvObject ) { - TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject); if(!ppvObject) return E_INVALIDARG; @@ -205,7 +205,7 @@ static HRESULT WINAPI xmlnodelist_get_item( xmlNodePtr curr; LONG nodeIndex = 0; - TRACE("%p %d\n", This, index); + TRACE("(%p)->(%d %p)\n", This, index, listItem); if(!listItem) return E_INVALIDARG; @@ -238,7 +238,7 @@ static HRESULT WINAPI xmlnodelist_get_length( xmlnodelist *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, listLength); if(!listLength) return E_INVALIDARG; @@ -260,7 +260,7 @@ static HRESULT WINAPI xmlnodelist_nextNode( { xmlnodelist *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p %p\n", This, nextItem ); + TRACE("(%p)->(%p)\n", This, nextItem ); if(!nextItem) return E_INVALIDARG; @@ -289,7 +289,8 @@ static HRESULT WINAPI xmlnodelist__newEnum( IXMLDOMNodeList* iface, IUnknown** ppUnk) { - FIXME("\n"); + xmlnodelist *This = impl_from_IXMLDOMNodeList( iface ); + FIXME("(%p)->(%p)\n", This, ppUnk); return E_NOTIMPL; } diff --git a/reactos/dll/win32/msxml3/nodemap.c b/reactos/dll/win32/msxml3/nodemap.c index 91f7a323e5e..7d23ec80bd5 100644 --- a/reactos/dll/win32/msxml3/nodemap.c +++ b/reactos/dll/win32/msxml3/nodemap.c @@ -62,7 +62,7 @@ static HRESULT WINAPI xmlnodemap_QueryInterface( REFIID riid, void** ppvObject ) { xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); - TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject); if( IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -207,7 +207,7 @@ static HRESULT WINAPI xmlnodemap_getNamedItem( xmlAttrPtr attr; xmlNodePtr node; - TRACE("%p %s %p\n", This, debugstr_w(name), namedItem ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), namedItem ); if ( !namedItem ) return E_INVALIDARG; @@ -242,7 +242,7 @@ static HRESULT WINAPI xmlnodemap_setNamedItem( IXMLDOMNode *pAttr = NULL; xmlNodePtr node; - TRACE("%p %p %p\n", This, newItem, namedItem ); + TRACE("(%p)->(%p %p)\n", This, newItem, namedItem ); if(!newItem) return E_INVALIDARG; @@ -292,7 +292,7 @@ static HRESULT WINAPI xmlnodemap_removeNamedItem( xmlAttrPtr attr; xmlNodePtr node; - TRACE("%p %s %p\n", This, debugstr_w(name), namedItem ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), namedItem ); if ( !name) return E_INVALIDARG; @@ -337,7 +337,7 @@ static HRESULT WINAPI xmlnodemap_get_item( xmlAttrPtr curr; LONG attrIndex; - TRACE("%p %d\n", This, index); + TRACE("(%p)->(%d %p)\n", This, index, listItem); *listItem = NULL; @@ -370,7 +370,7 @@ static HRESULT WINAPI xmlnodemap_get_length( xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, listLength); if( !listLength ) return E_INVALIDARG; @@ -402,7 +402,8 @@ static HRESULT WINAPI xmlnodemap_getQualifiedItem( BSTR namespaceURI, IXMLDOMNode** qualifiedItem) { - FIXME("\n"); + xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); + FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(baseName), debugstr_w(namespaceURI), qualifiedItem); return E_NOTIMPL; } @@ -412,7 +413,8 @@ static HRESULT WINAPI xmlnodemap_removeQualifiedItem( BSTR namespaceURI, IXMLDOMNode** qualifiedItem) { - FIXME("\n"); + xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); + FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(baseName), debugstr_w(namespaceURI), qualifiedItem); return E_NOTIMPL; } @@ -425,7 +427,7 @@ static HRESULT WINAPI xmlnodemap_nextNode( xmlAttrPtr curr; LONG attrIndex; - TRACE("%p %d\n", This, This->iterator); + TRACE("(%p)->(%p: %d)\n", This, nextItem, This->iterator); *nextItem = NULL; @@ -451,7 +453,7 @@ static HRESULT WINAPI xmlnodemap_reset( { xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); - TRACE("%p %d\n", This, This->iterator); + TRACE("(%p: %d)\n", This, This->iterator); This->iterator = 0; @@ -462,7 +464,8 @@ static HRESULT WINAPI xmlnodemap__newEnum( IXMLDOMNamedNodeMap *iface, IUnknown** ppUnk) { - FIXME("\n"); + xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); + FIXME("(%p)->(%p)\n", This, ppUnk); return E_NOTIMPL; } diff --git a/reactos/dll/win32/msxml3/parseerror.c b/reactos/dll/win32/msxml3/parseerror.c index 40b17a0f3d9..4b0dc57f508 100644 --- a/reactos/dll/win32/msxml3/parseerror.c +++ b/reactos/dll/win32/msxml3/parseerror.c @@ -56,7 +56,7 @@ static HRESULT WINAPI parseError_QueryInterface( REFIID riid, void** ppvObject ) { - TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -208,7 +208,8 @@ static HRESULT WINAPI parseError_get_url( IXMLDOMParseError *iface, BSTR *url ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, url); return E_NOTIMPL; } @@ -232,7 +233,8 @@ static HRESULT WINAPI parseError_get_srcText( IXMLDOMParseError *iface, BSTR *srcText ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, srcText); return E_NOTIMPL; } @@ -240,7 +242,8 @@ static HRESULT WINAPI parseError_get_line( IXMLDOMParseError *iface, LONG *line ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, line); return E_NOTIMPL; } @@ -248,7 +251,8 @@ static HRESULT WINAPI parseError_get_linepos( IXMLDOMParseError *iface, LONG *linepos ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, linepos); return E_NOTIMPL; } @@ -256,7 +260,8 @@ static HRESULT WINAPI parseError_get_filepos( IXMLDOMParseError *iface, LONG *filepos ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, filepos); return E_NOTIMPL; } diff --git a/reactos/dll/win32/msxml3/pi.c b/reactos/dll/win32/msxml3/pi.c index f32cebf8300..0baefe49031 100644 --- a/reactos/dll/win32/msxml3/pi.c +++ b/reactos/dll/win32/msxml3/pi.c @@ -55,7 +55,7 @@ static HRESULT WINAPI dom_pi_QueryInterface( void** ppvObject ) { dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMProcessingInstruction ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -526,7 +526,7 @@ static HRESULT WINAPI dom_pi_put_data( BSTR sTarget; static const WCHAR szXML[] = {'x','m','l',0}; - TRACE("%p %s\n", This, debugstr_w(data) ); + TRACE("(%p)->(%s)\n", This, debugstr_w(data) ); /* Cannot set data to a PI node whose target is 'xml' */ hr = dom_pi_get_nodeName(iface, &sTarget); diff --git a/reactos/dll/win32/msxml3/queryresult.c b/reactos/dll/win32/msxml3/queryresult.c index ab545968c08..eab83a904b6 100644 --- a/reactos/dll/win32/msxml3/queryresult.c +++ b/reactos/dll/win32/msxml3/queryresult.c @@ -74,7 +74,7 @@ static HRESULT WINAPI queryresult_QueryInterface( { queryresult *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject); if(!ppvObject) return E_INVALIDARG; @@ -217,7 +217,7 @@ static HRESULT WINAPI queryresult_get_item( { queryresult *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p %d\n", This, index); + TRACE("(%p)->(%d %p)\n", This, index, listItem); if(!listItem) return E_INVALIDARG; @@ -239,7 +239,7 @@ static HRESULT WINAPI queryresult_get_length( { queryresult *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, listLength); if(!listLength) return E_INVALIDARG; @@ -254,7 +254,7 @@ static HRESULT WINAPI queryresult_nextNode( { queryresult *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p %p\n", This, nextItem ); + TRACE("(%p)->(%p)\n", This, nextItem ); if(!nextItem) return E_INVALIDARG; @@ -283,7 +283,8 @@ static HRESULT WINAPI queryresult__newEnum( IXMLDOMNodeList* iface, IUnknown** ppUnk) { - FIXME("\n"); + queryresult *This = impl_from_IXMLDOMNodeList( iface ); + FIXME("(%p)->(%p)\n", This, ppUnk); return E_NOTIMPL; } diff --git a/reactos/dll/win32/msxml3/schema.c b/reactos/dll/win32/msxml3/schema.c index f0a616979a0..72d78547082 100644 --- a/reactos/dll/win32/msxml3/schema.c +++ b/reactos/dll/win32/msxml3/schema.c @@ -51,7 +51,7 @@ static HRESULT WINAPI schema_cache_QueryInterface( IXMLDOMSchemaCollection *ifac { schema_t *This = impl_from_IXMLDOMSchemaCollection( iface ); - TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject ); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid( riid ), ppvObject ); if ( IsEqualIID( riid, &IID_IUnknown ) || IsEqualIID( riid, &IID_IDispatch ) || diff --git a/reactos/dll/win32/msxml3/text.c b/reactos/dll/win32/msxml3/text.c index 70ca3efee33..fdcb06b4cb3 100644 --- a/reactos/dll/win32/msxml3/text.c +++ b/reactos/dll/win32/msxml3/text.c @@ -56,7 +56,7 @@ static HRESULT WINAPI domtext_QueryInterface( void** ppvObject ) { domtext *This = impl_from_IXMLDOMText( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMText ) || IsEqualGUID( riid, &IID_IXMLDOMCharacterData) || @@ -482,7 +482,7 @@ static HRESULT WINAPI domtext_get_data( BSTR *p) { domtext *This = impl_from_IXMLDOMText( iface ); - HRESULT hr = E_FAIL; + HRESULT hr; VARIANT vRet; if(!p) @@ -502,17 +502,14 @@ static HRESULT WINAPI domtext_put_data( BSTR data) { domtext *This = impl_from_IXMLDOMText( iface ); - HRESULT hr = E_FAIL; VARIANT val; - TRACE("%p %s\n", This, debugstr_w(data) ); + TRACE("(%p)->(%s)\n", This, debugstr_w(data) ); V_VT(&val) = VT_BSTR; V_BSTR(&val) = data; - hr = IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); - - return hr; + return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); } static HRESULT WINAPI domtext_get_length( @@ -520,24 +517,22 @@ static HRESULT WINAPI domtext_get_length( LONG *len) { domtext *This = impl_from_IXMLDOMText( iface ); - xmlChar *pContent; - LONG nLength = 0; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%p)\n", This, len); if(!len) return E_INVALIDARG; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMText_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); - xmlFree(pContent); + *len = SysStringLen(data); + SysFreeString(data); } - *len = nLength; - - return S_OK; + return hr; } static HRESULT WINAPI domtext_substringData( @@ -545,11 +540,10 @@ static HRESULT WINAPI domtext_substringData( LONG offset, LONG count, BSTR *p) { domtext *This = impl_from_IXMLDOMText( iface ); - xmlChar *pContent; - LONG nLength = 0; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%d %d %p)\n", This, offset, count, p); if(!p) return E_INVALIDARG; @@ -559,26 +553,24 @@ static HRESULT WINAPI domtext_substringData( return E_INVALIDARG; if(count == 0) - return hr; + return S_FALSE; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMText_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); + LONG len = SysStringLen(data); - if( offset < nLength) + if(offset < len) { - BSTR sContent = bstr_from_xmlChar(pContent); - if(offset + count > nLength) - *p = SysAllocString(&sContent[offset]); + if(offset + count > len) + *p = SysAllocString(&data[offset]); else - *p = SysAllocStringLen(&sContent[offset], count); - - SysFreeString(sContent); - hr = S_OK; + *p = SysAllocStringLen(&data[offset], count); } + else + hr = S_FALSE; - xmlFree(pContent); + SysFreeString(data); } return hr; @@ -589,26 +581,30 @@ static HRESULT WINAPI domtext_appendData( BSTR p) { domtext *This = impl_from_IXMLDOMText( iface ); - xmlChar *pContent; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", iface); + TRACE("(%p)->(%s)\n", This, debugstr_w(p)); /* Nothing to do if NULL or an Empty string passed in. */ - if(p == NULL || SysStringLen(p) == 0) - return S_OK; + if((p_len = SysStringLen(p)) == 0) return S_OK; - pContent = xmlChar_from_wchar( p ); - if(pContent) + hr = IXMLDOMText_get_data(iface, &data); + if(hr == S_OK) { - if(xmlTextConcat(This->node.node, pContent, SysStringLen(p)) == 0) - hr = S_OK; - else - hr = E_FAIL; - heap_free( pContent ); + LONG len = SysStringLen(data); + BSTR str = SysAllocStringLen(NULL, p_len + len); + + memcpy(str, data, len*sizeof(WCHAR)); + memcpy(&str[len], p, p_len*sizeof(WCHAR)); + str[len+p_len] = 0; + + hr = IXMLDOMText_put_data(iface, str); + + SysFreeString(str); + SysFreeString(data); } - else - hr = E_FAIL; return hr; } @@ -618,16 +614,14 @@ static HRESULT WINAPI domtext_insertData( LONG offset, BSTR p) { domtext *This = impl_from_IXMLDOMText( iface ); - xmlChar *pXmlContent; - BSTR sNewString; - HRESULT hr = S_FALSE; - LONG nLength = 0, nLengthP = 0; - xmlChar *str = NULL; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", This); + TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p)); /* If have a NULL or empty string, don't do anything. */ - if(SysStringLen(p) == 0) + if((p_len = SysStringLen(p)) == 0) return S_OK; if(offset < 0) @@ -635,48 +629,29 @@ static HRESULT WINAPI domtext_insertData( return E_INVALIDARG; } - pXmlContent = xmlNodeGetContent(This->node.node); - if(pXmlContent) + hr = IXMLDOMText_get_data(iface, &data); + if(hr == S_OK) { - BSTR sContent = bstr_from_xmlChar( pXmlContent ); - nLength = SysStringLen(sContent); - nLengthP = SysStringLen(p); + LONG len = SysStringLen(data); + BSTR str; - if(nLength < offset) + if(len < offset) { - SysFreeString(sContent); - xmlFree(pXmlContent); - + SysFreeString(data); return E_INVALIDARG; } - sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1); - if(sNewString) - { - if(offset > 0) - memcpy(sNewString, sContent, offset * sizeof(WCHAR)); + str = SysAllocStringLen(NULL, len + p_len); + /* start part, supplied string and end part */ + memcpy(str, data, offset*sizeof(WCHAR)); + memcpy(&str[offset], p, p_len*sizeof(WCHAR)); + memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR)); + str[len+p_len] = 0; - memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR)); + hr = IXMLDOMText_put_data(iface, str); - if(offset+nLengthP < nLength) - memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR)); - - sNewString[nLengthP + nLength] = 0; - - str = xmlChar_from_wchar(sNewString); - if(str) - { - xmlNodeSetContent(This->node.node, str); - hr = S_OK; - } - heap_free(str); - - SysFreeString(sNewString); - } - - SysFreeString(sContent); - - xmlFree(pXmlContent); + SysFreeString(str); + SysFreeString(data); } return hr; @@ -690,7 +665,7 @@ static HRESULT WINAPI domtext_deleteData( LONG len = -1; BSTR str; - TRACE("%p %d %d\n", iface, offset, count); + TRACE("(%p)->(%d %d)\n", iface, offset, count); hr = IXMLDOMText_get_length(iface, &len); if(hr != S_OK) return hr; @@ -733,15 +708,25 @@ static HRESULT WINAPI domtext_replaceData( IXMLDOMText *iface, LONG offset, LONG count, BSTR p) { - FIXME("\n"); - return E_NOTIMPL; + domtext *This = impl_from_IXMLDOMText( iface ); + HRESULT hr; + + TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p)); + + hr = IXMLDOMText_deleteData(iface, offset, count); + + if (hr == S_OK) + hr = IXMLDOMText_insertData(iface, offset, p); + + return hr; } static HRESULT WINAPI domtext_splitText( IXMLDOMText *iface, LONG offset, IXMLDOMText **txtNode) { - FIXME("\n"); + domtext *This = impl_from_IXMLDOMText( iface ); + FIXME("(%p)->(%d %p)\n", This, offset, txtNode); return E_NOTIMPL; } diff --git a/reactos/include/psdk/msxml2.idl b/reactos/include/psdk/msxml2.idl index b6303c9f001..89914004955 100644 --- a/reactos/include/psdk/msxml2.idl +++ b/reactos/include/psdk/msxml2.idl @@ -1979,6 +1979,15 @@ coclass SAXXMLReader30 interface IMXReaderControl; }; +[ + uuid(7c6e29bc-8b8b-4c3d-859e-af6cd158be0f) +] +coclass SAXXMLReader40 +{ + [default] interface IVBSAXXMLReader; + interface ISAXXMLReader; +}; + [ uuid(fc220ad8-a72a-4ee8-926e-0b7ad152a020) ] From 764beadd153988ea8ec1b0d43de6651ef0241e3b Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 1 Mar 2010 11:10:21 +0000 Subject: [PATCH 016/211] [MSXML3_WINETEST] sync msxml3_winetest to wine 1.1.39 svn path=/trunk/; revision=45737 --- rostests/winetests/msxml3/domdoc.c | 791 +++++++++++++++++++++++++++-- 1 file changed, 752 insertions(+), 39 deletions(-) diff --git a/rostests/winetests/msxml3/domdoc.c b/rostests/winetests/msxml3/domdoc.c index bc052bea53f..e2de5df75b8 100644 --- a/rostests/winetests/msxml3/domdoc.c +++ b/rostests/winetests/msxml3/domdoc.c @@ -24,6 +24,7 @@ #include "windows.h" #include "ole2.h" +#include "objsafe.h" #include "xmldom.h" #include "msxml2.h" #include "msxml2did.h" @@ -33,6 +34,10 @@ #include "wine/test.h" +#include "initguid.h" + +DEFINE_GUID(IID_IObjectSafety, 0xcb5bdc81, 0x93c1, 0x11cf, 0x8f,0x20, 0x00,0x80,0x5f,0x2c,0xd0,0x64); + static const WCHAR szEmpty[] = { 0 }; static const WCHAR szIncomplete[] = { '<','?','x','m','l',' ', @@ -692,7 +697,11 @@ static void test_domdoc( void ) ok( code == 0, "code %d\n", code ); IXMLDOMParseError_Release( error ); - /* test createTextNode */ + /* test createTextNode */ + r = IXMLDOMDocument_createTextNode(doc, _bstr_(""), &nodetext); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMText_Release(nodetext); + str = SysAllocString( szOpen ); r = IXMLDOMDocument_createTextNode(doc, str, NULL); ok( r == E_INVALIDARG, "returns %08x\n", r ); @@ -963,13 +972,107 @@ static void test_domdoc( void ) ok( !lstrcmpW( str, _bstr_("99") ), "incorrect get_text string\n"); SysFreeString(str); + /* ::replaceData() */ + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(szstr1); + r = IXMLDOMText_put_nodeValue(nodetext, var); + ok(r == S_OK, "ret %08x\n", r ); + VariantClear(&var); + + r = IXMLDOMText_replaceData(nodetext, 6, 0, NULL); + ok(r == E_INVALIDARG, "ret %08x\n", r ); + r = IXMLDOMText_get_text(nodetext, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("str1") ), "incorrect get_text string\n"); + SysFreeString(str); + + r = IXMLDOMText_replaceData(nodetext, 0, 0, NULL); + ok(r == S_OK, "ret %08x\n", r ); + r = IXMLDOMText_get_text(nodetext, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("str1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* NULL pointer means delete */ + r = IXMLDOMText_replaceData(nodetext, 0, 1, NULL); + ok(r == S_OK, "ret %08x\n", r ); + r = IXMLDOMText_get_text(nodetext, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("tr1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* empty string means delete */ + r = IXMLDOMText_replaceData(nodetext, 0, 1, _bstr_("")); + ok(r == S_OK, "ret %08x\n", r ); + r = IXMLDOMText_get_text(nodetext, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("r1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* zero count means insert */ + r = IXMLDOMText_replaceData(nodetext, 0, 0, _bstr_("a")); + ok(r == S_OK, "ret %08x\n", r ); + r = IXMLDOMText_get_text(nodetext, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("ar1") ), "incorrect get_text string\n"); + SysFreeString(str); + + r = IXMLDOMText_replaceData(nodetext, 0, 2, NULL); + ok(r == S_OK, "ret %08x\n", r ); + + r = IXMLDOMText_insertData(nodetext, 0, _bstr_("m")); + ok(r == S_OK, "ret %08x\n", r ); + r = IXMLDOMText_get_text(nodetext, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("m1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* nonempty string, count greater than its length */ + r = IXMLDOMText_replaceData(nodetext, 0, 2, _bstr_("a1.2")); + ok(r == S_OK, "ret %08x\n", r ); + r = IXMLDOMText_get_text(nodetext, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("a1.2") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* nonempty string, count less than its length */ + r = IXMLDOMText_replaceData(nodetext, 0, 1, _bstr_("wine")); + ok(r == S_OK, "ret %08x\n", r ); + r = IXMLDOMText_get_text(nodetext, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("wine1.2") ), "incorrect get_text string\n"); + SysFreeString(str); + IXMLDOMText_Release( nodetext ); } /* test Create Comment */ r = IXMLDOMDocument_createComment(doc, NULL, NULL); ok( r == E_INVALIDARG, "returns %08x\n", r ); - r = IXMLDOMDocument_createComment(doc, szComment, &node_comment); + node_comment = (IXMLDOMComment*)0x1; + + /* empty comment */ + r = IXMLDOMDocument_createComment(doc, _bstr_(""), &node_comment); + ok( r == S_OK, "returns %08x\n", r ); + str = (BSTR)0x1; + r = IXMLDOMComment_get_data(node_comment, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty string data\n"); + IXMLDOMComment_Release(node_comment); + SysFreeString(str); + + r = IXMLDOMDocument_createComment(doc, NULL, &node_comment); + ok( r == S_OK, "returns %08x\n", r ); + str = (BSTR)0x1; + r = IXMLDOMComment_get_data(node_comment, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && (SysStringLen(str) == 0), "expected empty string data\n"); + IXMLDOMComment_Release(node_comment); + SysFreeString(str); + + str = SysAllocString(szComment); + r = IXMLDOMDocument_createComment(doc, str, &node_comment); + SysFreeString(str); ok( r == S_OK, "returns %08x\n", r ); if(node_comment) { @@ -982,15 +1085,23 @@ static void test_domdoc( void ) ok(r == S_FALSE, "ret %08x\n", r ); ok(nodeChild == NULL, "pLastChild not NULL\n"); + /* baseName */ + str = (BSTR)0xdeadbeef; + IXMLDOMComment_get_baseName(node_comment, &str); + ok(r == S_FALSE, "ret %08x\n", r ); + ok(str == NULL, "Expected NULL\n"); + IXMLDOMComment_Release( node_comment ); } /* test Create Attribute */ + str = SysAllocString(szAttribute); r = IXMLDOMDocument_createAttribute(doc, NULL, NULL); ok( r == E_INVALIDARG, "returns %08x\n", r ); - r = IXMLDOMDocument_createAttribute(doc, szAttribute, &node_attr); + r = IXMLDOMDocument_createAttribute(doc, str, &node_attr); ok( r == S_OK, "returns %08x\n", r ); IXMLDOMText_Release( node_attr); + SysFreeString(str); /* test Processing Instruction */ str = SysAllocStringLen(NULL, 0); @@ -1026,6 +1137,13 @@ static void test_domdoc( void ) ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n"); SysFreeString(str); + /* test baseName */ + str = (BSTR)0x1; + r = IXMLDOMProcessingInstruction_get_baseName(nodePI, &str); + ok(r == S_OK, "ret %08x\n", r ); + ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n"); + SysFreeString(str); + /* test Target */ r = IXMLDOMProcessingInstruction_get_target(nodePI, &str); ok(r == S_OK, "ret %08x\n", r ); @@ -1210,8 +1328,19 @@ static void test_domnode( void ) r = IXMLDOMElement_getAttributeNode( element, str, &attr); ok( r == S_OK, "GetAttributeNode ret %08x\n", r ); ok( attr != NULL, "getAttributeNode returned NULL\n" ); - if(attr) + if (attr) + { + r = IXMLDOMAttribute_get_parentNode( attr, NULL ); + ok( r == E_INVALIDARG, "Expected E_INVALIDARG, ret %08x\n", r ); + + /* attribute doesn't have a parent in msxml interpretation */ + node = (IXMLDOMNode*)0xdeadbeef; + r = IXMLDOMAttribute_get_parentNode( attr, &node ); + ok( r == S_FALSE, "Expected S_FALSE, ret %08x\n", r ); + ok( node == NULL, "Expected NULL, got %p\n", node ); + IXMLDOMAttribute_Release(attr); + } SysFreeString( str ); @@ -1408,10 +1537,15 @@ todo_wine ole_check(IXMLDOMNodeList_reset(list)); node = (void*)0xdeadbeef; - r = IXMLDOMNode_selectSingleNode( element, szdl, &node ); + str = SysAllocString(szdl); + r = IXMLDOMNode_selectSingleNode( element, str, &node ); + SysFreeString(str); ok( r == S_FALSE, "ret %08x\n", r ); ok( node == NULL, "node %p\n", node ); - r = IXMLDOMNode_selectSingleNode( element, szbs, &node ); + + str = SysAllocString(szbs); + r = IXMLDOMNode_selectSingleNode( element, str, &node ); + SysFreeString(str); ok( r == S_OK, "ret %08x\n", r ); r = IXMLDOMNode_Release( node ); ok( r == 0, "ret %08x\n", r ); @@ -1622,6 +1756,9 @@ static void test_create(void) BSTR str, name; IXMLDOMDocument *doc; IXMLDOMElement *element; + IXMLDOMComment *comment; + IXMLDOMText *text; + IXMLDOMCDATASection *cdata; IXMLDOMNode *root, *node, *child; IXMLDOMNamedNodeMap *attr_map; IUnknown *unk; @@ -1633,6 +1770,255 @@ static void test_create(void) if( r != S_OK ) return; + /* types not supported for creation */ + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_DOCUMENT; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_DOCUMENT_TYPE; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ENTITY; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_NOTATION; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + /* NODE_COMMENT */ + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_COMMENT; + node = NULL; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + ok( node != NULL, "\n"); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMComment, (void**)&comment); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMComment_get_data(comment, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMComment_Release(comment); + SysFreeString(str); + + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMComment, (void**)&comment); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMComment_get_data(comment, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMComment_Release(comment); + SysFreeString(str); + + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_("blah"), NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMComment, (void**)&comment); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMComment_get_data(comment, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMComment_Release(comment); + SysFreeString(str); + + /* NODE_TEXT */ + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_TEXT; + node = NULL; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + ok( node != NULL, "\n"); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMText, (void**)&text); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMText_get_data(text, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMText_Release(text); + SysFreeString(str); + + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMText, (void**)&text); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMText_get_data(text, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMText_Release(text); + SysFreeString(str); + + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_("blah"), NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMText, (void**)&text); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMText_get_data(text, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMText_Release(text); + SysFreeString(str); + + /* NODE_CDATA_SECTION */ + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_CDATA_SECTION; + node = NULL; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + ok( node != NULL, "\n"); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)&cdata); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMCDATASection_get_data(cdata, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMCDATASection_Release(cdata); + SysFreeString(str); + + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)&cdata); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMCDATASection_get_data(cdata, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMCDATASection_Release(cdata); + SysFreeString(str); + + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_("blah"), NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + + r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)&cdata); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMNode_Release(node); + + str = NULL; + r = IXMLDOMCDATASection_get_data(cdata, &str); + ok( r == S_OK, "returns %08x\n", r ); + ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str); + IXMLDOMCDATASection_Release(cdata); + SysFreeString(str); + + /* NODE_ATTRIBUTE */ + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == E_FAIL, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node ); + ok( r == E_FAIL, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + str = SysAllocString( szlc ); + r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node ); + ok( r == S_OK, "returns %08x\n", r ); + if( SUCCEEDED(r) ) IXMLDOMNode_Release( node ); + SysFreeString(str); + + /* NODE_PROCESSING_INSTRUCTION */ + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_PROCESSING_INSTRUCTION; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == E_FAIL, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_PROCESSING_INSTRUCTION; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node ); + ok( r == E_FAIL, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_PROCESSING_INSTRUCTION; + r = IXMLDOMDocument_createNode( doc, var, _bstr_("pi"), NULL, NULL ); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + + /* NODE_ENTITY_REFERENCE */ + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ENTITY_REFERENCE; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == E_FAIL, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ENTITY_REFERENCE; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node ); + ok( r == E_FAIL, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + /* NODE_ELEMENT */ + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ELEMENT; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node ); + ok( r == E_FAIL, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ELEMENT; + node = (IXMLDOMNode*)0x1; + r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node ); + ok( r == E_FAIL, "returns %08x\n", r ); + ok( node == (void*)0x1, "expected same ptr, got %p\n", node); + V_VT(&var) = VT_I1; V_I1(&var) = NODE_ELEMENT; str = SysAllocString( szlc ); @@ -1640,6 +2026,11 @@ static void test_create(void) ok( r == S_OK, "returns %08x\n", r ); if( SUCCEEDED(r) ) IXMLDOMNode_Release( node ); + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ELEMENT; + r = IXMLDOMDocument_createNode( doc, var, str, NULL, NULL ); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + V_VT(&var) = VT_R4; V_R4(&var) = NODE_ELEMENT; r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node ); @@ -2312,7 +2703,7 @@ static void test_XMLHTTP(void) 'p','o','s','t','t','e','s','t','.','p','h','p',0}; static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0}; IXMLHttpRequest *pXMLHttpRequest; - BSTR bstrResponse; + BSTR bstrResponse, str1, str2; VARIANT dummy; VARIANT varfalse; VARIANT varbody; @@ -2332,8 +2723,12 @@ static void test_XMLHTTP(void) V_VT(&varbody) = VT_BSTR; V_BSTR(&varbody) = SysAllocString(wszBody); - hr = IXMLHttpRequest_open(pXMLHttpRequest, wszPOST, wszUrl, varfalse, dummy, dummy); + str1 = SysAllocString(wszPOST); + str2 = SysAllocString(wszUrl); + hr = IXMLHttpRequest_open(pXMLHttpRequest, str1, str2, varfalse, dummy, dummy); todo_wine ok(hr == S_OK, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr); + SysFreeString(str1); + SysFreeString(str2); hr = IXMLHttpRequest_send(pXMLHttpRequest, varbody); todo_wine ok(hr == S_OK, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr); @@ -2709,7 +3104,7 @@ static void test_xmlTypes(void) HRESULT hr; IXMLDOMComment *pComment; IXMLDOMElement *pElement; - IXMLDOMAttribute *pAttrubute; + IXMLDOMAttribute *pAttribute; IXMLDOMNamedNodeMap *pAttribs; IXMLDOMCDATASection *pCDataSec; IXMLDOMImplementation *pIXMLDOMImplementation = NULL; @@ -2814,7 +3209,15 @@ static void test_xmlTypes(void) IXMLDOMImplementation_Release(pIXMLDOMImplementation); } + pRoot = (IXMLDOMElement*)0x1; + hr = IXMLDOMDocument_createElement(doc, NULL, &pRoot); + ok(hr == E_INVALIDARG, "ret %08x\n", hr ); + ok(pRoot == (void*)0x1, "Expect same ptr, got %p\n", pRoot); + pRoot = (IXMLDOMElement*)0x1; + hr = IXMLDOMDocument_createElement(doc, _bstr_(""), &pRoot); + ok(hr == E_FAIL, "ret %08x\n", hr ); + ok(pRoot == (void*)0x1, "Expect same ptr, got %p\n", pRoot); hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot); ok(hr == S_OK, "ret %08x\n", hr ); @@ -2825,7 +3228,9 @@ static void test_xmlTypes(void) if(hr == S_OK) { /* Comment */ - hr = IXMLDOMDocument_createComment(doc, szComment, &pComment); + str = SysAllocString(szComment); + hr = IXMLDOMDocument_createComment(doc, str, &pComment); + SysFreeString(str); ok(hr == S_OK, "ret %08x\n", hr ); if(hr == S_OK) { @@ -3068,11 +3473,84 @@ static void test_xmlTypes(void) hr = IXMLDOMComment_deleteData(pComment, 0, len); ok(hr == S_OK, "ret %08x\n", hr ); + /* ::replaceData() */ + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = SysAllocString(szstr1); + hr = IXMLDOMComment_put_nodeValue(pComment, v); + ok(hr == S_OK, "ret %08x\n", hr ); + VariantClear(&v); + + hr = IXMLDOMComment_replaceData(pComment, 6, 0, NULL); + ok(hr == E_INVALIDARG, "ret %08x\n", hr ); + hr = IXMLDOMComment_get_text(pComment, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("str1") ), "incorrect get_text string\n"); + SysFreeString(str); + + hr = IXMLDOMComment_replaceData(pComment, 0, 0, NULL); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMComment_get_text(pComment, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("str1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* NULL pointer means delete */ + hr = IXMLDOMComment_replaceData(pComment, 0, 1, NULL); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMComment_get_text(pComment, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("tr1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* empty string means delete */ + hr = IXMLDOMComment_replaceData(pComment, 0, 1, _bstr_("")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMComment_get_text(pComment, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("r1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* zero count means insert */ + hr = IXMLDOMComment_replaceData(pComment, 0, 0, _bstr_("a")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMComment_get_text(pComment, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("ar1") ), "incorrect get_text string\n"); + SysFreeString(str); + + hr = IXMLDOMComment_replaceData(pComment, 0, 2, NULL); + ok(hr == S_OK, "ret %08x\n", hr ); + + hr = IXMLDOMComment_insertData(pComment, 0, _bstr_("m")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMComment_get_text(pComment, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("m1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* nonempty string, count greater than its length */ + hr = IXMLDOMComment_replaceData(pComment, 0, 2, _bstr_("a1.2")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMComment_get_text(pComment, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("a1.2") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* nonempty string, count less than its length */ + hr = IXMLDOMComment_replaceData(pComment, 0, 1, _bstr_("wine")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMComment_get_text(pComment, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("wine1.2") ), "incorrect get_text string\n"); + SysFreeString(str); + IXMLDOMComment_Release(pComment); } /* Element */ - hr = IXMLDOMDocument_createElement(doc, szElement, &pElement); + str = SysAllocString(szElement); + hr = IXMLDOMDocument_createElement(doc, str, &pElement); + SysFreeString(str); ok(hr == S_OK, "ret %08x\n", hr ); if(hr == S_OK) { @@ -3100,40 +3578,52 @@ static void test_xmlTypes(void) ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n"); VariantClear(&v); - /* Attribute */ - hr = IXMLDOMDocument_createAttribute(doc, szAttribute, &pAttrubute); + /* Attribute */ + pAttribute = (IXMLDOMAttribute*)0x1; + hr = IXMLDOMDocument_createAttribute(doc, NULL, &pAttribute); + ok(hr == E_INVALIDARG, "ret %08x\n", hr ); + ok(pAttribute == (void*)0x1, "Expect same ptr, got %p\n", pAttribute); + + pAttribute = (IXMLDOMAttribute*)0x1; + hr = IXMLDOMDocument_createAttribute(doc, _bstr_(""), &pAttribute); + ok(hr == E_FAIL, "ret %08x\n", hr ); + ok(pAttribute == (void*)0x1, "Expect same ptr, got %p\n", pAttribute); + + str = SysAllocString(szAttribute); + hr = IXMLDOMDocument_createAttribute(doc, str, &pAttribute); + SysFreeString(str); ok(hr == S_OK, "ret %08x\n", hr ); if(hr == S_OK) { IXMLDOMNode *pNewChild = (IXMLDOMNode *)0x1; - hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, NULL); + hr = IXMLDOMAttribute_get_nextSibling(pAttribute, NULL); ok(hr == E_INVALIDARG, "ret %08x\n", hr ); pNextChild = (IXMLDOMNode *)0x1; - hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, &pNextChild); + hr = IXMLDOMAttribute_get_nextSibling(pAttribute, &pNextChild); ok(hr == S_FALSE, "ret %08x\n", hr ); ok(pNextChild == NULL, "pNextChild not NULL\n"); /* test Previous Sibling*/ - hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, NULL); + hr = IXMLDOMAttribute_get_previousSibling(pAttribute, NULL); ok(hr == E_INVALIDARG, "ret %08x\n", hr ); pNextChild = (IXMLDOMNode *)0x1; - hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, &pNextChild); + hr = IXMLDOMAttribute_get_previousSibling(pAttribute, &pNextChild); ok(hr == S_FALSE, "ret %08x\n", hr ); ok(pNextChild == NULL, "pNextChild not NULL\n"); /* test get_attributes */ - hr = IXMLDOMAttribute_get_attributes( pAttrubute, NULL ); + hr = IXMLDOMAttribute_get_attributes( pAttribute, NULL ); ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n"); pAttribs = (IXMLDOMNamedNodeMap*)0x1; - hr = IXMLDOMAttribute_get_attributes( pAttrubute, &pAttribs); + hr = IXMLDOMAttribute_get_attributes( pAttribute, &pAttribs); ok(hr == S_FALSE, "ret %08x\n", hr ); ok( pAttribs == NULL, "pAttribs not NULL\n"); - hr = IXMLDOMElement_appendChild(pElement, (IXMLDOMNode*)pAttrubute, &pNewChild); + hr = IXMLDOMElement_appendChild(pElement, (IXMLDOMNode*)pAttribute, &pNewChild); ok(hr == E_FAIL, "ret %08x\n", hr ); ok(pNewChild == NULL, "pNewChild not NULL\n"); @@ -3141,46 +3631,46 @@ static void test_xmlTypes(void) ok(hr == S_OK, "ret %08x\n", hr ); if ( hr == S_OK ) { - hr = IXMLDOMNamedNodeMap_setNamedItem(pAttribs, (IXMLDOMNode*)pAttrubute, NULL ); + hr = IXMLDOMNamedNodeMap_setNamedItem(pAttribs, (IXMLDOMNode*)pAttribute, NULL ); ok(hr == S_OK, "ret %08x\n", hr ); IXMLDOMNamedNodeMap_Release(pAttribs); } - hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str); + hr = IXMLDOMAttribute_get_nodeName(pAttribute, &str); ok(hr == S_OK, "ret %08x\n", hr ); ok( !lstrcmpW( str, szAttribute ), "incorrect attribute node Name\n"); SysFreeString(str); /* test nodeTypeString */ - hr = IXMLDOMAttribute_get_nodeTypeString(pAttrubute, &str); + hr = IXMLDOMAttribute_get_nodeTypeString(pAttribute, &str); ok(hr == S_OK, "ret %08x\n", hr ); ok( !lstrcmpW( str, _bstr_("attribute") ), "incorrect nodeTypeString string\n"); SysFreeString(str); /* test nodeName */ - hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str); + hr = IXMLDOMAttribute_get_nodeName(pAttribute, &str); ok(hr == S_OK, "ret %08x\n", hr ); ok( !lstrcmpW( str, szAttribute ), "incorrect nodeName string\n"); SysFreeString(str); /* test name property */ - hr = IXMLDOMAttribute_get_name(pAttrubute, &str); + hr = IXMLDOMAttribute_get_name(pAttribute, &str); ok(hr == S_OK, "ret %08x\n", hr ); ok( !lstrcmpW( str, szAttribute ), "incorrect name string\n"); SysFreeString(str); - hr = IXMLDOMAttribute_get_xml(pAttrubute, &str); + hr = IXMLDOMAttribute_get_xml(pAttribute, &str); ok(hr == S_OK, "ret %08x\n", hr ); ok( !lstrcmpW( str, szAttributeXML ), "incorrect attribute xml\n"); SysFreeString(str); - hr = IXMLDOMAttribute_get_dataType(pAttrubute, &v); + hr = IXMLDOMAttribute_get_dataType(pAttribute, &v); ok(hr == S_FALSE, "ret %08x\n", hr ); ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n"); VariantClear(&v); - IXMLDOMAttribute_Release(pAttrubute); + IXMLDOMAttribute_Release(pAttribute); /* Check Element again with the Add Attribute*/ hr = IXMLDOMElement_get_xml(pElement, &str); @@ -3217,10 +3707,12 @@ static void test_xmlTypes(void) } /* CData Section */ - hr = IXMLDOMDocument_createCDATASection(doc, szCData, NULL); + str = SysAllocString(szCData); + hr = IXMLDOMDocument_createCDATASection(doc, str, NULL); ok(hr == E_INVALIDARG, "ret %08x\n", hr ); - hr = IXMLDOMDocument_createCDATASection(doc, szCData, &pCDataSec); + hr = IXMLDOMDocument_createCDATASection(doc, str, &pCDataSec); + SysFreeString(str); ok(hr == S_OK, "ret %08x\n", hr ); if(hr == S_OK) { @@ -3482,6 +3974,77 @@ static void test_xmlTypes(void) hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, len); ok(hr == S_OK, "ret %08x\n", hr ); + /* ::replaceData() */ + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = SysAllocString(szstr1); + hr = IXMLDOMCDATASection_put_nodeValue(pCDataSec, v); + ok(hr == S_OK, "ret %08x\n", hr ); + VariantClear(&v); + + hr = IXMLDOMCDATASection_replaceData(pCDataSec, 6, 0, NULL); + ok(hr == E_INVALIDARG, "ret %08x\n", hr ); + hr = IXMLDOMCDATASection_get_text(pCDataSec, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("str1") ), "incorrect get_text string\n"); + SysFreeString(str); + + hr = IXMLDOMCDATASection_replaceData(pCDataSec, 0, 0, NULL); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMCDATASection_get_text(pCDataSec, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("str1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* NULL pointer means delete */ + hr = IXMLDOMCDATASection_replaceData(pCDataSec, 0, 1, NULL); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMCDATASection_get_text(pCDataSec, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("tr1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* empty string means delete */ + hr = IXMLDOMCDATASection_replaceData(pCDataSec, 0, 1, _bstr_("")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMCDATASection_get_text(pCDataSec, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("r1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* zero count means insert */ + hr = IXMLDOMCDATASection_replaceData(pCDataSec, 0, 0, _bstr_("a")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMCDATASection_get_text(pCDataSec, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("ar1") ), "incorrect get_text string\n"); + SysFreeString(str); + + hr = IXMLDOMCDATASection_replaceData(pCDataSec, 0, 2, NULL); + ok(hr == S_OK, "ret %08x\n", hr ); + + hr = IXMLDOMCDATASection_insertData(pCDataSec, 0, _bstr_("m")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMCDATASection_get_text(pCDataSec, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("m1") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* nonempty string, count greater than its length */ + hr = IXMLDOMCDATASection_replaceData(pCDataSec, 0, 2, _bstr_("a1.2")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMCDATASection_get_text(pCDataSec, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("a1.2") ), "incorrect get_text string\n"); + SysFreeString(str); + + /* nonempty string, count less than its length */ + hr = IXMLDOMCDATASection_replaceData(pCDataSec, 0, 1, _bstr_("wine")); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IXMLDOMCDATASection_get_text(pCDataSec, &str); + ok(hr == S_OK, "ret %08x\n", hr ); + ok( !lstrcmpW( str, _bstr_("wine1.2") ), "incorrect get_text string\n"); + SysFreeString(str); + IXMLDOMCDATASection_Release(pCDataSec); } @@ -3493,7 +4056,15 @@ static void test_xmlTypes(void) ok(hr == S_OK, "ret %08x\n", hr ); if(hr == S_OK) { - IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1; + IXMLDOMNode *node; + + hr = IXMLDOMDocumentFragment_get_parentNode(pDocFrag, NULL); + ok(hr == E_INVALIDARG, "ret %08x\n", hr ); + + node = (IXMLDOMNode *)0x1; + hr = IXMLDOMDocumentFragment_get_parentNode(pDocFrag, &node); + ok(hr == S_FALSE, "ret %08x\n", hr ); + ok(node == NULL, "expected NULL, got %p\n", node); hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pDocFrag, NULL); ok(hr == S_OK, "ret %08x\n", hr ); @@ -3516,19 +4087,19 @@ static void test_xmlTypes(void) hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, NULL); ok(hr == E_INVALIDARG, "ret %08x\n", hr ); - pNextChild = (IXMLDOMNode *)0x1; - hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, &pNextChild); + node = (IXMLDOMNode *)0x1; + hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, &node); ok(hr == S_FALSE, "ret %08x\n", hr ); - ok(pNextChild == NULL, "pNextChild not NULL\n"); + ok(node == NULL, "next sibling not NULL\n"); /* test Previous Sibling*/ hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, NULL); ok(hr == E_INVALIDARG, "ret %08x\n", hr ); - pNextChild = (IXMLDOMNode *)0x1; - hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, &pNextChild); + node = (IXMLDOMNode *)0x1; + hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, &node); ok(hr == S_FALSE, "ret %08x\n", hr ); - ok(pNextChild == NULL, "pNextChild not NULL\n"); + ok(node == NULL, "previous sibling not NULL\n"); /* test get_dataType */ hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, NULL); @@ -3549,10 +4120,17 @@ static void test_xmlTypes(void) } /* Entity References */ - hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, NULL); + hr = IXMLDOMDocument_createEntityReference(doc, NULL, &pEntityRef); + ok(hr == E_FAIL, "ret %08x\n", hr ); + hr = IXMLDOMDocument_createEntityReference(doc, _bstr_(""), &pEntityRef); + ok(hr == E_FAIL, "ret %08x\n", hr ); + + str = SysAllocString(szEntityRef); + hr = IXMLDOMDocument_createEntityReference(doc, str, NULL); ok(hr == E_INVALIDARG, "ret %08x\n", hr ); - hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, &pEntityRef); + hr = IXMLDOMDocument_createEntityReference(doc, str, &pEntityRef); + SysFreeString(str); ok(hr == S_OK, "ret %08x\n", hr ); if(hr == S_OK) { @@ -3609,6 +4187,9 @@ static void test_nodeTypeTests( void ) if( hr != S_OK ) return; + hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), NULL); + ok(hr == E_INVALIDARG, "ret %08x\n", hr ); + hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot); ok(hr == S_OK, "ret %08x\n", hr ); if(hr == S_OK) @@ -4641,6 +5222,136 @@ static void test_TransformWithLoadingLocalFile(void) free_bstrs(); } +static void test_put_nodeValue(void) +{ + IXMLDOMDocument *doc; + IXMLDOMEntityReference *entityref; + IXMLDOMNode *node; + HRESULT hr; + VARIANT data, type; + + hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc ); + if( hr != S_OK ) + return; + + /* test for unsupported types */ + /* NODE_DOCUMENT */ + hr = IXMLDOMDocument_QueryInterface(doc, &IID_IXMLDOMNode, (void**)&node); + ok(hr == S_OK, "ret %08x\n", hr ); + V_VT(&data) = VT_BSTR; + V_BSTR(&data) = _bstr_("one two three"); + hr = IXMLDOMNode_put_nodeValue(node, data); + ok(hr == E_FAIL, "ret %08x\n", hr ); + IXMLDOMNode_Release(node); + + /* NODE_DOCUMENT_FRAGMENT */ + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_DOCUMENT_FRAGMENT; + hr = IXMLDOMDocument_createNode(doc, type, _bstr_("test"), NULL, &node); + ok(hr == S_OK, "ret %08x\n", hr ); + V_VT(&data) = VT_BSTR; + V_BSTR(&data) = _bstr_("one two three"); + hr = IXMLDOMNode_put_nodeValue(node, data); + ok(hr == E_FAIL, "ret %08x\n", hr ); + IXMLDOMNode_Release(node); + + /* NODE_ELEMENT */ + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_ELEMENT; + hr = IXMLDOMDocument_createNode(doc, type, _bstr_("test"), NULL, &node); + ok(hr == S_OK, "ret %08x\n", hr ); + V_VT(&data) = VT_BSTR; + V_BSTR(&data) = _bstr_("one two three"); + hr = IXMLDOMNode_put_nodeValue(node, data); + ok(hr == E_FAIL, "ret %08x\n", hr ); + IXMLDOMNode_Release(node); + + /* NODE_ENTITY_REFERENCE */ + hr = IXMLDOMDocument_createEntityReference(doc, _bstr_("ref"), &entityref); + ok(hr == S_OK, "ret %08x\n", hr ); + + V_VT(&data) = VT_BSTR; + V_BSTR(&data) = _bstr_("one two three"); + hr = IXMLDOMEntityReference_put_nodeValue(entityref, data); + ok(hr == E_FAIL, "ret %08x\n", hr ); + + hr = IXMLDOMEntityReference_QueryInterface(entityref, &IID_IXMLDOMNode, (void**)&node); + ok(hr == S_OK, "ret %08x\n", hr ); + V_VT(&data) = VT_BSTR; + V_BSTR(&data) = _bstr_("one two three"); + hr = IXMLDOMNode_put_nodeValue(node, data); + ok(hr == E_FAIL, "ret %08x\n", hr ); + IXMLDOMNode_Release(node); + IXMLDOMEntityReference_Release(entityref); + + free_bstrs(); + + IXMLDOMDocument_Release(doc); +} + +static void test_document_IObjectSafety(void) +{ + IXMLDOMDocument *doc; + IObjectSafety *safety; + DWORD enabled = 0, supported = 0; + HRESULT hr; + + hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc ); + if( hr != S_OK ) + return; + + hr = IXMLDOMDocument_QueryInterface(doc, &IID_IObjectSafety, (void**)&safety); + ok(hr == S_OK, "ret %08x\n", hr ); + + /* get */ + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, NULL, &enabled); + ok(hr == E_POINTER, "ret %08x\n", hr ); + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, NULL); + ok(hr == E_POINTER, "ret %08x\n", hr ); + + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA), + "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA)," + "got %08x\n", supported); + ok(enabled == 0, "Expected 0, got %08x\n", enabled); + /* set */ + hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, + INTERFACESAFE_FOR_UNTRUSTED_CALLER, + INTERFACESAFE_FOR_UNTRUSTED_CALLER); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(enabled == INTERFACESAFE_FOR_UNTRUSTED_CALLER, + "Expected INTERFACESAFE_FOR_UNTRUSTED_CALLER, got %08x\n", enabled); + /* set unsupported */ + hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, + INTERFACE_USES_SECURITY_MANAGER | + INTERFACESAFE_FOR_UNTRUSTED_CALLER, + INTERFACE_USES_SECURITY_MANAGER); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(enabled == 0, "Expected 0, got %08x\n", enabled); + + hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, + INTERFACESAFE_FOR_UNTRUSTED_CALLER, + INTERFACESAFE_FOR_UNTRUSTED_CALLER); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, + INTERFACESAFE_FOR_UNTRUSTED_DATA, + INTERFACESAFE_FOR_UNTRUSTED_DATA); + ok(hr == S_OK, "ret %08x\n", hr ); + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(enabled == INTERFACESAFE_FOR_UNTRUSTED_DATA, + "Expected INTERFACESAFE_FOR_UNTRUSTED_DATA, got %08x\n", enabled); + + IObjectSafety_Release(safety); + + IXMLDOMDocument_Release(doc); +} + START_TEST(domdoc) { HRESULT r; @@ -4671,6 +5382,8 @@ START_TEST(domdoc) test_FormattingXML(); test_NodeTypeValue(); test_TransformWithLoadingLocalFile(); + test_put_nodeValue(); + test_document_IObjectSafety(); CoUninitialize(); } From b7a1c590295b5a5a20f95a10656c0c81778ef413 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 1 Mar 2010 12:01:30 +0000 Subject: [PATCH 017/211] [MSI] sync msi to wine 1.1.39 svn path=/trunk/; revision=45738 --- reactos/dll/win32/msi/action.c | 669 +++++++++++++++++++++------- reactos/dll/win32/msi/classes.c | 23 +- reactos/dll/win32/msi/database.c | 46 +- reactos/dll/win32/msi/events.c | 3 - reactos/dll/win32/msi/files.c | 16 +- reactos/dll/win32/msi/font.c | 113 ++++- reactos/dll/win32/msi/helpers.c | 22 - reactos/dll/win32/msi/install.c | 60 ++- reactos/dll/win32/msi/msi.c | 87 ++++ reactos/dll/win32/msi/msi.spec | 4 +- reactos/dll/win32/msi/msi_It.rc | 12 +- reactos/dll/win32/msi/msipriv.h | 8 +- reactos/dll/win32/msi/msiserver.idl | 1 + reactos/dll/win32/msi/package.c | 8 + reactos/dll/win32/msi/streams.c | 24 +- reactos/dll/win32/msi/suminfo.c | 3 - reactos/dll/win32/msi/table.c | 8 +- reactos/dll/win32/msi/tokenize.c | 4 +- reactos/include/psdk/msi.h | 4 + 19 files changed, 836 insertions(+), 279 deletions(-) diff --git a/reactos/dll/win32/msi/action.c b/reactos/dll/win32/msi/action.c index d94d842cae1..20929c6cd1a 100644 --- a/reactos/dll/win32/msi/action.c +++ b/reactos/dll/win32/msi/action.c @@ -886,10 +886,24 @@ static BOOL ACTION_HandleCustomAction( MSIPACKAGE* package, LPCWSTR action, static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPCWSTR dir; + LPCWSTR dir, component; LPWSTR full_path; MSIRECORD *uirow; MSIFOLDER *folder; + MSICOMPONENT *comp; + + component = MSI_RecordGetString(row, 2); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; dir = MSI_RecordGetString(row,1); if (!dir) @@ -951,7 +965,7 @@ UINT msi_create_component_directories( MSIPACKAGE *package ) /* create all the folders required by the components are going to install */ LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry ) { - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL)) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) continue; msi_create_directory( package, comp->Directory ); } @@ -983,10 +997,24 @@ static UINT ACTION_CreateFolders(MSIPACKAGE *package) static UINT ITERATE_RemoveFolders( MSIRECORD *row, LPVOID param ) { MSIPACKAGE *package = param; - LPCWSTR dir; + LPCWSTR dir, component; LPWSTR full_path; MSIRECORD *uirow; MSIFOLDER *folder; + MSICOMPONENT *comp; + + component = MSI_RecordGetString(row, 2); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; dir = MSI_RecordGetString( row, 1 ); if (!dir) @@ -2231,16 +2259,12 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) if (!comp) return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL)) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping write due to disabled component %s\n", - debugstr_w(component)); - + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); comp->Action = comp->Installed; - return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; name = MSI_RecordGetString(row, 4); @@ -2623,7 +2647,7 @@ static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp ) { ComponentList *cl; - if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL )) + if (feature->ActionRequest != INSTALLSTATE_LOCAL) continue; LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry ) @@ -2638,7 +2662,7 @@ static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp ) { ComponentList *cl; - if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ABSENT )) + if (feature->ActionRequest != INSTALLSTATE_ABSENT) continue; LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry ) @@ -2704,8 +2728,8 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) debugstr_w(comp->FullKeypath), comp->RefCount); - if (ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL) || - ACTION_VerifyComponentForAction( comp, INSTALLSTATE_SOURCE)) + if (comp->ActionRequest == INSTALLSTATE_LOCAL || + comp->ActionRequest == INSTALLSTATE_SOURCE) { if (!comp->FullKeypath) continue; @@ -2771,7 +2795,7 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) } RegCloseKey(hkey); } - else if (ACTION_VerifyComponentForAction(comp, INSTALLSTATE_ABSENT)) + else if (comp->ActionRequest == INSTALLSTATE_ABSENT) { if (package->Context == MSIINSTALLCONTEXT_MACHINE) MSIREG_DeleteUserDataComponentKey(comp->ComponentId, szLocalSid); @@ -2862,28 +2886,25 @@ static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param) HMODULE module; HRESULT hr; - static const WCHAR szTYPELIB[] = {'T','Y','P','E','L','I','B',0}; - component = MSI_RecordGetString(row,3); comp = get_loaded_component(package,component); if (!comp) return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL)) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping typelib reg due to disabled component\n"); - + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); comp->Action = comp->Installed; - return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; file = get_loaded_file( package, comp->KeyPath ); if (!file) return ERROR_SUCCESS; + ui_actiondata( package, szRegisterTypeLibraries, row ); + module = LoadLibraryExW( file->TargetPath, NULL, LOAD_LIBRARY_AS_DATAFILE ); if (module) { @@ -2913,11 +2934,7 @@ static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param) ERR("Failed to register type library %s\n", debugstr_w(tl_struct.path)); else - { - ui_actiondata(package,szRegisterTypeLibraries,row); - TRACE("Registered %s\n", debugstr_w(tl_struct.path)); - } ITypeLib_Release(tl_struct.ptLib); msi_free(tl_struct.path); @@ -2935,7 +2952,7 @@ static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param) if (FAILED(hr)) { ERR("Failed to load type library: %08x\n", hr); - return ERROR_FUNCTION_FAILED; + return ERROR_INSTALL_FAILURE; } ITypeLib_Release(tlib); @@ -2967,31 +2984,119 @@ static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package) return rc; } +static UINT ITERATE_UnregisterTypeLibraries( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, guid; + MSICOMPONENT *comp; + GUID libid; + UINT version; + LCID language; + SYSKIND syskind; + HRESULT hr; + + component = MSI_RecordGetString( row, 3 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + ui_actiondata( package, szUnregisterTypeLibraries, row ); + + guid = MSI_RecordGetString( row, 1 ); + CLSIDFromString( (LPWSTR)guid, &libid ); + version = MSI_RecordGetInteger( row, 4 ); + language = MSI_RecordGetInteger( row, 2 ); + +#ifdef _WIN64 + syskind = SYS_WIN64; +#else + syskind = SYS_WIN32; +#endif + + hr = UnRegisterTypeLib( &libid, (version >> 8) & 0xffff, version & 0xff, language, syskind ); + if (FAILED(hr)) + { + WARN("Failed to unregister typelib: %08x\n", hr); + } + + return ERROR_SUCCESS; +} + +static UINT ACTION_UnregisterTypeLibraries( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','T','y','p','e','L','i','b','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_UnregisterTypeLibraries, package ); + msiobj_release( &view->hdr ); + return rc; +} + +static WCHAR *get_link_file( MSIPACKAGE *package, MSIRECORD *row ) +{ + static const WCHAR szlnk[] = {'.','l','n','k',0}; + LPCWSTR directory, extension; + LPWSTR link_folder, link_file, filename; + + directory = MSI_RecordGetString( row, 2 ); + link_folder = resolve_folder( package, directory, FALSE, FALSE, TRUE, NULL ); + + /* may be needed because of a bug somewhere else */ + create_full_pathW( link_folder ); + + filename = msi_dup_record_field( row, 3 ); + reduce_to_longfilename( filename ); + + extension = strchrW( filename, '.' ); + if (!extension || strcmpiW( extension, szlnk )) + { + int len = strlenW( filename ); + filename = msi_realloc( filename, len * sizeof(WCHAR) + sizeof(szlnk) ); + memcpy( filename + len, szlnk, sizeof(szlnk) ); + } + link_file = build_directory_name( 2, link_folder, filename ); + msi_free( link_folder ); + msi_free( filename ); + + return link_file; +} + static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPWSTR target_file, target_folder, filename; - LPCWSTR buffer, extension; + LPWSTR link_file, deformated, path; + LPCWSTR component, target; MSICOMPONENT *comp; - static const WCHAR szlnk[]={'.','l','n','k',0}; IShellLinkW *sl = NULL; IPersistFile *pf = NULL; HRESULT res; - buffer = MSI_RecordGetString(row,4); - comp = get_loaded_component(package,buffer); + component = MSI_RecordGetString(row, 4); + comp = get_loaded_component(package, component); if (!comp) return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL )) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping shortcut creation due to disabled component\n"); - + TRACE("Component not scheduled for installation %s\n", debugstr_w(component)); comp->Action = comp->Installed; - return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; ui_actiondata(package,szCreateShortcuts,row); @@ -3012,31 +3117,10 @@ static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) goto err; } - buffer = MSI_RecordGetString(row,2); - target_folder = resolve_folder(package, buffer,FALSE,FALSE,TRUE,NULL); - - /* may be needed because of a bug somewhere else */ - create_full_pathW(target_folder); - - filename = msi_dup_record_field( row, 3 ); - reduce_to_longfilename(filename); - - extension = strchrW(filename,'.'); - if (!extension || strcmpiW(extension,szlnk)) + target = MSI_RecordGetString(row, 5); + if (strchrW(target, '[')) { - int len = strlenW(filename); - filename = msi_realloc(filename, len * sizeof(WCHAR) + sizeof(szlnk)); - memcpy(filename + len, szlnk, sizeof(szlnk)); - } - target_file = build_directory_name(2, target_folder, filename); - msi_free(target_folder); - msi_free(filename); - - buffer = MSI_RecordGetString(row,5); - if (strchrW(buffer,'[')) - { - LPWSTR deformated; - deformat_string(package,buffer,&deformated); + deformat_string(package, target, &deformated); IShellLinkW_SetPath(sl,deformated); msi_free(deformated); } @@ -3048,17 +3132,16 @@ static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) if (!MSI_RecordIsNull(row,6)) { - LPWSTR deformated; - buffer = MSI_RecordGetString(row,6); - deformat_string(package,buffer,&deformated); + LPCWSTR arguments = MSI_RecordGetString(row, 6); + deformat_string(package, arguments, &deformated); IShellLinkW_SetArguments(sl,deformated); msi_free(deformated); } if (!MSI_RecordIsNull(row,7)) { - buffer = MSI_RecordGetString(row,7); - IShellLinkW_SetDescription(sl,buffer); + LPCWSTR description = MSI_RecordGetString(row, 7); + IShellLinkW_SetDescription(sl, description); } if (!MSI_RecordIsNull(row,8)) @@ -3066,20 +3149,18 @@ static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) if (!MSI_RecordIsNull(row,9)) { - LPWSTR Path; INT index; + LPCWSTR icon = MSI_RecordGetString(row, 9); - buffer = MSI_RecordGetString(row,9); - - Path = build_icon_path(package,buffer); + path = build_icon_path(package, icon); index = MSI_RecordGetInteger(row,10); /* no value means 0 */ if (index == MSI_NULL_INTEGER) index = 0; - IShellLinkW_SetIconLocation(sl,Path,index); - msi_free(Path); + IShellLinkW_SetIconLocation(sl, path, index); + msi_free(path); } if (!MSI_RecordIsNull(row,11)) @@ -3087,18 +3168,19 @@ static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) if (!MSI_RecordIsNull(row,12)) { - LPWSTR Path; - buffer = MSI_RecordGetString(row,12); - Path = resolve_folder(package, buffer, FALSE, FALSE, TRUE, NULL); - if (Path) - IShellLinkW_SetWorkingDirectory(sl,Path); - msi_free(Path); + LPCWSTR wkdir = MSI_RecordGetString(row, 12); + path = resolve_folder(package, wkdir, FALSE, FALSE, TRUE, NULL); + if (path) + IShellLinkW_SetWorkingDirectory(sl, path); + msi_free(path); } - TRACE("Writing shortcut to %s\n",debugstr_w(target_file)); - IPersistFile_Save(pf,target_file,FALSE); + link_file = get_link_file(package, row); - msi_free(target_file); + TRACE("Writing shortcut to %s\n", debugstr_w(link_file)); + IPersistFile_Save(pf, link_file, FALSE); + + msi_free(link_file); err: if (pf) @@ -3133,6 +3215,58 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package) return rc; } +static UINT ITERATE_RemoveShortcuts( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPWSTR link_file; + LPCWSTR component; + MSICOMPONENT *comp; + + component = MSI_RecordGetString( row, 4 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + ui_actiondata( package, szRemoveShortcuts, row ); + + link_file = get_link_file( package, row ); + + TRACE("Removing shortcut file %s\n", debugstr_w( link_file )); + if (!DeleteFileW( link_file )) + { + WARN("Failed to remove shortcut file %u\n", GetLastError()); + } + msi_free( link_file ); + + return ERROR_SUCCESS; +} + +static UINT ACTION_RemoveShortcuts( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','S','h','o','r','t','c','u','t','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveShortcuts, package ); + msiobj_release( &view->hdr ); + + return rc; +} + static UINT ITERATE_PublishIcon(MSIRECORD *row, LPVOID param) { MSIPACKAGE* package = param; @@ -3510,17 +3644,15 @@ static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param) component = MSI_RecordGetString(row, 8); comp = get_loaded_component(package,component); + if (!comp) + return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL)) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping ini file due to disabled component %s\n", - debugstr_w(component)); - + TRACE("Component not scheduled for installation %s\n", debugstr_w(component)); comp->Action = comp->Installed; - return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; identifier = MSI_RecordGetString(row,1); @@ -3818,10 +3950,9 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package) BOOL absent = FALSE; MSIRECORD *uirow; - if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ) && - !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_SOURCE ) && - !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED )) - absent = TRUE; + if (feature->ActionRequest != INSTALLSTATE_LOCAL && + feature->ActionRequest != INSTALLSTATE_SOURCE && + feature->ActionRequest != INSTALLSTATE_ADVERTISED) absent = TRUE; size = 1; LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry ) @@ -4359,32 +4490,34 @@ static UINT ACTION_ExecuteAction(MSIPACKAGE *package) static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param) { MSIPACKAGE *package = param; - LPCWSTR compgroupid=NULL; - LPCWSTR feature=NULL; - LPCWSTR text = NULL; - LPCWSTR qualifier = NULL; - LPCWSTR component = NULL; - LPWSTR advertise = NULL; - LPWSTR output = NULL; + LPCWSTR compgroupid, component, feature, qualifier, text; + LPWSTR advertise = NULL, output = NULL; HKEY hkey; - UINT rc = ERROR_SUCCESS; + UINT rc; MSICOMPONENT *comp; - DWORD sz = 0; + MSIFEATURE *feat; + DWORD sz; MSIRECORD *uirow; - component = MSI_RecordGetString(rec,3); - comp = get_loaded_component(package,component); + feature = MSI_RecordGetString(rec, 5); + feat = get_loaded_feature(package, feature); + if (!feat) + return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL ) && - !ACTION_VerifyComponentForAction( comp, INSTALLSTATE_SOURCE ) && - !ACTION_VerifyComponentForAction( comp, INSTALLSTATE_ADVERTISED )) + if (feat->ActionRequest != INSTALLSTATE_LOCAL && + feat->ActionRequest != INSTALLSTATE_SOURCE && + feat->ActionRequest != INSTALLSTATE_ADVERTISED) { - TRACE("Skipping: Component %s not scheduled for install\n", - debugstr_w(component)); - + TRACE("Feature %s not scheduled for installation\n", debugstr_w(feature)); + feat->Action = feat->Installed; return ERROR_SUCCESS; } + component = MSI_RecordGetString(rec, 3); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + compgroupid = MSI_RecordGetString(rec,1); qualifier = MSI_RecordGetString(rec,2); @@ -4393,8 +4526,6 @@ static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param) goto end; text = MSI_RecordGetString(rec,4); - feature = MSI_RecordGetString(rec,5); - advertise = create_component_advertise_string(package, comp, feature); sz = strlenW(advertise); @@ -4452,6 +4583,80 @@ static UINT ACTION_PublishComponents(MSIPACKAGE *package) return rc; } +static UINT ITERATE_UnpublishComponent( MSIRECORD *rec, LPVOID param ) +{ + static const WCHAR szInstallerComponents[] = { + 'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\', + 'I','n','s','t','a','l','l','e','r','\\', + 'C','o','m','p','o','n','e','n','t','s','\\',0}; + + MSIPACKAGE *package = param; + LPCWSTR compgroupid, component, feature, qualifier; + MSICOMPONENT *comp; + MSIFEATURE *feat; + MSIRECORD *uirow; + WCHAR squashed[GUID_SIZE], keypath[MAX_PATH]; + LONG res; + + feature = MSI_RecordGetString( rec, 5 ); + feat = get_loaded_feature( package, feature ); + if (!feat) + return ERROR_SUCCESS; + + if (feat->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Feature %s not scheduled for removal\n", debugstr_w(feature)); + feat->Action = feat->Installed; + return ERROR_SUCCESS; + } + + component = MSI_RecordGetString( rec, 3 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + compgroupid = MSI_RecordGetString( rec, 1 ); + qualifier = MSI_RecordGetString( rec, 2 ); + + squash_guid( compgroupid, squashed ); + strcpyW( keypath, szInstallerComponents ); + strcatW( keypath, squashed ); + + res = RegDeleteKeyW( HKEY_CURRENT_USER, keypath ); + if (res != ERROR_SUCCESS) + { + WARN("Unable to delete component key %d\n", res); + } + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, compgroupid ); + MSI_RecordSetStringW( uirow, 2, qualifier ); + ui_actiondata( package, szUnpublishComponents, uirow ); + msiobj_release( &uirow->hdr ); + + return ERROR_SUCCESS; +} + +static UINT ACTION_UnpublishComponents( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','P','u','b','l','i','s','h', + 'C','o','m','p','o','n','e','n','t','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_UnpublishComponent, package ); + msiobj_release( &view->hdr ); + + return rc; +} + static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param) { MSIPACKAGE *package = param; @@ -4597,7 +4802,7 @@ static UINT ITERATE_StartService(MSIRECORD *rec, LPVOID param) { MSIPACKAGE *package = param; MSICOMPONENT *comp; - SC_HANDLE scm, service = NULL; + SC_HANDLE scm = NULL, service = NULL; LPCWSTR *vector = NULL; LPWSTR name, args; DWORD event, numargs; @@ -4612,7 +4817,10 @@ static UINT ITERATE_StartService(MSIRECORD *rec, LPVOID param) event = MSI_RecordGetInteger(rec, 3); if (!(event & msidbServiceControlEventStart)) - return ERROR_SUCCESS; + { + r = ERROR_SUCCESS; + goto done; + } scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT); if (!scm) @@ -4893,15 +5101,17 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) driver_file = msi_find_file(package, MSI_RecordGetString(rec, 4)); setup_file = msi_find_file(package, MSI_RecordGetString(rec, 5)); - if (!driver_file || !setup_file) + if (!driver_file) { ERR("ODBC Driver entry not found!\n"); return ERROR_FUNCTION_FAILED; } - len = lstrlenW(desc) + lstrlenW(driver_fmt) + lstrlenW(driver_file->FileName) + - lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName) + - lstrlenW(usage_fmt) + 1; + len = lstrlenW(desc) + lstrlenW(driver_fmt) + lstrlenW(driver_file->FileName); + if (setup_file) + len += lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName); + len += lstrlenW(usage_fmt) + 1; + driver = msi_alloc(len * sizeof(WCHAR)); if (!driver) return ERROR_OUTOFMEMORY; @@ -4913,8 +5123,11 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) sprintfW(ptr, driver_fmt, driver_file->FileName); ptr += lstrlenW(ptr) + 1; - sprintfW(ptr, setup_fmt, setup_file->FileName); - ptr += lstrlenW(ptr) + 1; + if (setup_file) + { + sprintfW(ptr, setup_fmt, setup_file->FileName); + ptr += lstrlenW(ptr) + 1; + } lstrcpyW(ptr, usage_fmt); ptr += lstrlenW(ptr) + 1; @@ -4957,14 +5170,16 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) translator_file = msi_find_file(package, MSI_RecordGetString(rec, 4)); setup_file = msi_find_file(package, MSI_RecordGetString(rec, 5)); - if (!translator_file || !setup_file) + if (!translator_file) { ERR("ODBC Translator entry not found!\n"); return ERROR_FUNCTION_FAILED; } - len = lstrlenW(desc) + lstrlenW(translator_fmt) + lstrlenW(translator_file->FileName) + - lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName) + 1; + len = lstrlenW(desc) + lstrlenW(translator_fmt) + lstrlenW(translator_file->FileName) + 1; + if (setup_file) + len += lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName); + translator = msi_alloc(len * sizeof(WCHAR)); if (!translator) return ERROR_OUTOFMEMORY; @@ -4976,8 +5191,11 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) sprintfW(ptr, translator_fmt, translator_file->FileName); ptr += lstrlenW(ptr) + 1; - sprintfW(ptr, setup_fmt, setup_file->FileName); - ptr += lstrlenW(ptr) + 1; + if (setup_file) + { + sprintfW(ptr, setup_fmt, setup_file->FileName); + ptr += lstrlenW(ptr) + 1; + } *ptr = '\0'; translator_path = strdupW(translator_file->TargetPath); @@ -5021,8 +5239,8 @@ static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param ) if (!attrs) return ERROR_OUTOFMEMORY; - sprintfW(attrs, attrs_fmt, desc); - attrs[len - 1] = '\0'; + len = sprintfW(attrs, attrs_fmt, desc); + attrs[len + 1] = 0; if (!SQLConfigDataSourceW(NULL, request, driver, attrs)) { @@ -5076,6 +5294,120 @@ static UINT ACTION_InstallODBC( MSIPACKAGE *package ) return rc; } +static UINT ITERATE_RemoveODBCDriver( MSIRECORD *rec, LPVOID param ) +{ + DWORD usage; + LPCWSTR desc; + + desc = MSI_RecordGetString( rec, 3 ); + if (!SQLRemoveDriverW( desc, FALSE, &usage )) + { + WARN("Failed to remove ODBC driver\n"); + } + else if (!usage) + { + FIXME("Usage count reached 0\n"); + } + + return ERROR_SUCCESS; +} + +static UINT ITERATE_RemoveODBCTranslator( MSIRECORD *rec, LPVOID param ) +{ + DWORD usage; + LPCWSTR desc; + + desc = MSI_RecordGetString( rec, 3 ); + if (!SQLRemoveTranslatorW( desc, &usage )) + { + WARN("Failed to remove ODBC translator\n"); + } + else if (!usage) + { + FIXME("Usage count reached 0\n"); + } + + return ERROR_SUCCESS; +} + +static UINT ITERATE_RemoveODBCDataSource( MSIRECORD *rec, LPVOID param ) +{ + LPWSTR attrs; + LPCWSTR desc, driver; + WORD request = ODBC_REMOVE_SYS_DSN; + INT registration; + DWORD len; + + static const WCHAR attrs_fmt[] = { + 'D','S','N','=','%','s',0 }; + + desc = MSI_RecordGetString( rec, 3 ); + driver = MSI_RecordGetString( rec, 4 ); + registration = MSI_RecordGetInteger( rec, 5 ); + + if (registration == msidbODBCDataSourceRegistrationPerMachine) request = ODBC_REMOVE_SYS_DSN; + else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_REMOVE_DSN; + + len = strlenW( attrs_fmt ) + strlenW( desc ) + 1 + 1; + attrs = msi_alloc( len * sizeof(WCHAR) ); + if (!attrs) + return ERROR_OUTOFMEMORY; + + FIXME("Use ODBCSourceAttribute table\n"); + + len = sprintfW( attrs, attrs_fmt, desc ); + attrs[len + 1] = 0; + + if (!SQLConfigDataSourceW( NULL, request, driver, attrs )) + { + WARN("Failed to remove ODBC data source\n"); + } + msi_free( attrs ); + + return ERROR_SUCCESS; +} + +static UINT ACTION_RemoveODBC( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + + static const WCHAR driver_query[] = { + 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + 'O','D','B','C','D','r','i','v','e','r',0 }; + + static const WCHAR translator_query[] = { + 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + 'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0 }; + + static const WCHAR source_query[] = { + 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + 'O','D','B','C','D','a','t','a','S','o','u','r','c','e',0 }; + + rc = MSI_DatabaseOpenViewW( package->db, driver_query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCDriver, package ); + msiobj_release( &view->hdr ); + + rc = MSI_DatabaseOpenViewW( package->db, translator_query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCTranslator, package ); + msiobj_release( &view->hdr ); + + rc = MSI_DatabaseOpenViewW( package->db, source_query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCDataSource, package ); + msiobj_release( &view->hdr ); + + return rc; +} + #define ENV_ACT_SETALWAYS 0x1 #define ENV_ACT_SETABSENT 0x2 #define ENV_ACT_REMOVE 0x4 @@ -6125,6 +6457,30 @@ done: return r; } +static UINT ACTION_ValidateProductID( MSIPACKAGE *package ) +{ + LPWSTR key, template, id; + UINT r = ERROR_SUCCESS; + + id = msi_dup_property( package, szProductID ); + if (id) + { + msi_free( id ); + return ERROR_SUCCESS; + } + template = msi_dup_property( package, szPIDTemplate ); + key = msi_dup_property( package, szPIDKEY ); + + if (key && template) + { + FIXME( "partial stub: template %s key %s\n", debugstr_w(template), debugstr_w(key) ); + r = MSI_SetPropertyW( package, szProductID, key ); + } + msi_free( template ); + msi_free( key ); + return r; +} + static UINT ACTION_ScheduleReboot( MSIPACKAGE *package ) { TRACE("\n"); @@ -6132,6 +6488,24 @@ static UINT ACTION_ScheduleReboot( MSIPACKAGE *package ) return ERROR_SUCCESS; } +static UINT ACTION_AllocateRegistrySpace( MSIPACKAGE *package ) +{ + TRACE("%p\n", package); + return ERROR_SUCCESS; +} + +static UINT ACTION_DisableRollback( MSIPACKAGE *package ) +{ + FIXME("%p\n", package); + return ERROR_SUCCESS; +} + +static UINT ACTION_InstallAdminPackage( MSIPACKAGE *package ) +{ + FIXME("%p\n", package); + return ERROR_SUCCESS; +} + static UINT msi_unimplemented_action_stub( MSIPACKAGE *package, LPCSTR action, LPCWSTR table ) { @@ -6156,12 +6530,6 @@ static UINT msi_unimplemented_action_stub( MSIPACKAGE *package, return ERROR_SUCCESS; } -static UINT ACTION_AllocateRegistrySpace( MSIPACKAGE *package ) -{ - TRACE("%p\n", package); - return ERROR_SUCCESS; -} - static UINT ACTION_RemoveIniValues( MSIPACKAGE *package ) { static const WCHAR table[] = @@ -6194,13 +6562,6 @@ static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "MigrateFeatureStates", table ); } -static UINT ACTION_ValidateProductID( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { - 'P','r','o','d','u','c','t','I','D',0 }; - return msi_unimplemented_action_stub( package, "ValidateProductID", table ); -} - static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package ) { static const WCHAR table[] = { @@ -6215,12 +6576,6 @@ static UINT ACTION_MsiUnpublishAssemblies( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "MsiUnpublishAssemblies", table ); } -static UINT ACTION_UnregisterFonts( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'F','o','n','t',0 }; - return msi_unimplemented_action_stub( package, "UnregisterFonts", table ); -} - static UINT ACTION_RMCCPSearch( MSIPACKAGE *package ) { static const WCHAR table[] = { 'C','C','P','S','e','a','r','c','h',0 }; @@ -6257,36 +6612,18 @@ static UINT ACTION_RemoveExistingProducts( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "RemoveExistingProducts", table ); } -static UINT ACTION_RemoveODBC( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'O','D','B','C','D','r','i','v','e','r',0 }; - return msi_unimplemented_action_stub( package, "RemoveODBC", table ); -} - static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package ) { static const WCHAR table[] = { 'R','e','m','o','v','e','R','e','g','i','s','t','r','y',0 }; return msi_unimplemented_action_stub( package, "RemoveRegistryValues", table ); } -static UINT ACTION_RemoveShortcuts( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'S','h','o','r','t','c','u','t',0 }; - return msi_unimplemented_action_stub( package, "RemoveShortcuts", table ); -} - static UINT ACTION_SetODBCFolders( MSIPACKAGE *package ) { static const WCHAR table[] = { 'D','i','r','e','c','t','o','r','y',0 }; return msi_unimplemented_action_stub( package, "SetODBCFolders", table ); } -static UINT ACTION_UnpublishComponents( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t',0 }; - return msi_unimplemented_action_stub( package, "UnpublishComponents", table ); -} - static UINT ACTION_UnregisterClassInfo( MSIPACKAGE *package ) { static const WCHAR table[] = { 'A','p','p','I','d',0 }; @@ -6311,12 +6648,6 @@ static UINT ACTION_UnregisterProgIdInfo( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "UnregisterProgIdInfo", table ); } -static UINT ACTION_UnregisterTypeLibraries( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'T','y','p','e','L','i','b',0 }; - return msi_unimplemented_action_stub( package, "UnregisterTypeLibraries", table ); -} - typedef UINT (*STANDARDACTIONHANDLER)(MSIPACKAGE*); static const struct @@ -6335,13 +6666,13 @@ StandardActions[] = { szCreateFolders, ACTION_CreateFolders }, { szCreateShortcuts, ACTION_CreateShortcuts }, { szDeleteServices, ACTION_DeleteServices }, - { szDisableRollback, NULL }, + { szDisableRollback, ACTION_DisableRollback }, { szDuplicateFiles, ACTION_DuplicateFiles }, { szExecuteAction, ACTION_ExecuteAction }, { szFileCost, ACTION_FileCost }, { szFindRelatedProducts, ACTION_FindRelatedProducts }, { szForceReboot, ACTION_ForceReboot }, - { szInstallAdminPackage, NULL }, + { szInstallAdminPackage, ACTION_InstallAdminPackage }, { szInstallExecute, ACTION_InstallExecute }, { szInstallExecuteAgain, ACTION_InstallExecute }, { szInstallFiles, ACTION_InstallFiles}, diff --git a/reactos/dll/win32/msi/classes.c b/reactos/dll/win32/msi/classes.c index 6ca35b9735a..acd8429bec4 100644 --- a/reactos/dll/win32/msi/classes.c +++ b/reactos/dll/win32/msi/classes.c @@ -809,16 +809,17 @@ UINT ACTION_RegisterClassInfo(MSIPACKAGE *package) continue; feature = cls->Feature; + if (!feature) + continue; /* * MSDN says that these are based on Feature not on Component. */ - if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ) && - !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED )) + if (feature->ActionRequest != INSTALLSTATE_LOCAL && + feature->ActionRequest != INSTALLSTATE_ADVERTISED ) { - TRACE("Skipping class %s reg due to disabled feature %s\n", - debugstr_w(cls->clsid), debugstr_w(feature->Feature)); - + TRACE("Feature %s not scheduled for installation, skipping regstration of class %s\n", + debugstr_w(feature->Feature), debugstr_w(cls->clsid)); continue; } @@ -1142,18 +1143,18 @@ UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package) continue; feature = ext->Feature; + if (!feature) + continue; /* * yes. MSDN says that these are based on _Feature_ not on * Component. So verify the feature is to be installed */ - if ((!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL )) && - !(install_on_demand && - ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED ))) + if (feature->ActionRequest != INSTALLSTATE_LOCAL && + !(install_on_demand && feature->ActionRequest == INSTALLSTATE_ADVERTISED)) { - TRACE("Skipping extension %s reg due to disabled feature %s\n", - debugstr_w(ext->Extension), debugstr_w(feature->Feature)); - + TRACE("Feature %s not scheduled for installation, skipping registration of extension %s\n", + debugstr_w(feature->Feature), debugstr_w(ext->Extension)); continue; } diff --git a/reactos/dll/win32/msi/database.c b/reactos/dll/win32/msi/database.c index 7855fea9186..8ec2411cb59 100644 --- a/reactos/dll/win32/msi/database.c +++ b/reactos/dll/win32/msi/database.c @@ -125,20 +125,14 @@ static UINT clone_open_stream( MSIDATABASE *db, LPCWSTR name, IStream **stm ) UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm ) { - LPWSTR encname; HRESULT r; - encname = encode_streamname(FALSE, stname); + TRACE("%s\n", debugstr_w(stname)); - TRACE("%s -> %s\n",debugstr_w(stname),debugstr_w(encname)); - - if (clone_open_stream( db, encname, stm ) == ERROR_SUCCESS) - { - msi_free( encname ); + if (clone_open_stream( db, stname, stm ) == ERROR_SUCCESS) return ERROR_SUCCESS; - } - r = IStorage_OpenStream( db->storage, encname, NULL, + r = IStorage_OpenStream( db->storage, stname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, stm ); if( FAILED( r ) ) { @@ -147,15 +141,13 @@ UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm ) LIST_FOR_EACH_ENTRY( transform, &db->transforms, MSITRANSFORM, entry ) { TRACE("looking for %s in transform storage\n", debugstr_w(stname) ); - r = IStorage_OpenStream( transform->stg, encname, NULL, + r = IStorage_OpenStream( transform->stg, stname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, stm ); if (SUCCEEDED(r)) break; } } - msi_free( encname ); - if( SUCCEEDED(r) ) { MSISTREAM *stream; @@ -181,10 +173,15 @@ UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname, ULONG sz, count; IStream *stm = NULL; STATSTG stat; + LPWSTR encname; + + encname = encode_streamname( FALSE, stname ); + r = db_get_raw_stream( db, encname, &stm ); + msi_free( encname ); - r = db_get_raw_stream( db, stname, &stm ); if( r != ERROR_SUCCESS) return ret; + r = IStream_Stat(stm, &stat, STATFLAG_NONAME ); if( FAILED( r ) ) { @@ -225,16 +222,6 @@ end: return ret; } -void append_storage_to_db( MSIDATABASE *db, IStorage *stg ) -{ - MSITRANSFORM *t; - - t = msi_alloc( sizeof *t ); - t->stg = stg; - IStorage_AddRef( stg ); - list_add_tail( &db->transforms, &t->entry ); -} - static void free_transforms( MSIDATABASE *db ) { while( !list_empty( &db->transforms ) ) @@ -259,6 +246,19 @@ static void free_streams( MSIDATABASE *db ) } } +void append_storage_to_db( MSIDATABASE *db, IStorage *stg ) +{ + MSITRANSFORM *t; + + t = msi_alloc( sizeof *t ); + t->stg = stg; + IStorage_AddRef( stg ); + list_add_tail( &db->transforms, &t->entry ); + + /* the transform may add or replace streams */ + free_streams( db ); +} + static VOID MSI_CloseDatabase( MSIOBJECTHDR *arg ) { MSIDATABASE *db = (MSIDATABASE *) arg; diff --git a/reactos/dll/win32/msi/events.c b/reactos/dll/win32/msi/events.c index f4697dd0a34..e8f22975594 100644 --- a/reactos/dll/win32/msi/events.c +++ b/reactos/dll/win32/msi/events.c @@ -386,9 +386,6 @@ static UINT ControlEvent_ReinstallMode(MSIPACKAGE *package, LPCWSTR argument, static UINT ControlEvent_ValidateProductID(MSIPACKAGE *package, LPCWSTR argument, msi_dialog *dialog) { - static const WCHAR szProductID[] = {'P','r','o','d','u','c','t','I','D',0}; - static const WCHAR szPIDTemplate[] = {'P','I','D','T','e','m','p','l','a','t','e',0}; - static const WCHAR szPIDKEY[] = {'P','I','D','K','E','Y',0}; LPWSTR key, template; UINT ret = ERROR_SUCCESS; diff --git a/reactos/dll/win32/msi/files.c b/reactos/dll/win32/msi/files.c index b7af4d39416..d64195020aa 100644 --- a/reactos/dll/win32/msi/files.c +++ b/reactos/dll/win32/msi/files.c @@ -108,7 +108,7 @@ static void schedule_install_files(MSIPACKAGE *package) LIST_FOR_EACH_ENTRY(file, &package->files, MSIFILE, entry) { - if (!ACTION_VerifyComponentForAction(file->Component, INSTALLSTATE_LOCAL)) + if (file->Component->ActionRequest != INSTALLSTATE_LOCAL) { TRACE("File %s is not scheduled for install\n", debugstr_w(file->File)); @@ -358,19 +358,15 @@ static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param) component = MSI_RecordGetString(row,2); comp = get_loaded_component(package,component); + if (!comp) + return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL )) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping copy due to disabled component %s\n", - debugstr_w(component)); - - /* the action taken was the same as the current install state */ - if (comp) - comp->Action = comp->Installed; - + TRACE("Component not scheduled for installation %s\n", debugstr_w(component)); + comp->Action = comp->Installed; return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; file_key = MSI_RecordGetString(row,3); diff --git a/reactos/dll/win32/msi/font.c b/reactos/dll/win32/msi/font.c index 085d400a7b9..1b2c3c729dd 100644 --- a/reactos/dll/win32/msi/font.c +++ b/reactos/dll/win32/msi/font.c @@ -66,6 +66,21 @@ typedef struct _tagTT_NAME_RECORD { static const WCHAR szRegisterFonts[] = {'R','e','g','i','s','t','e','r','F','o','n','t','s',0}; +static const WCHAR szUnregisterFonts[] = + {'U','n','r','e','g','i','s','t','e','r','F','o','n','t','s',0}; + +static const WCHAR regfont1[] = + {'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\', + 'W','i','n','d','o','w','s',' ','N','T','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', + 'F','o','n','t','s',0}; +static const WCHAR regfont2[] = + {'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\', + 'W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', + 'F','o','n','t','s',0}; /* * Code based off of code located here @@ -174,20 +189,7 @@ static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param) LPWSTR name; LPCWSTR filename; MSIFILE *file; - static const WCHAR regfont1[] = - {'S','o','f','t','w','a','r','e','\\', - 'M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s',' ','N','T','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'F','o','n','t','s',0}; - static const WCHAR regfont2[] = - {'S','o','f','t','w','a','r','e','\\', - 'M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'F','o','n','t','s',0}; - HKEY hkey1; - HKEY hkey2; + HKEY hkey1, hkey2; MSIRECORD *uirow; LPWSTR uipath, p; @@ -199,10 +201,9 @@ static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param) return ERROR_SUCCESS; } - /* check to make sure that component is installed */ - if (!ACTION_VerifyComponentForAction( file->Component, INSTALLSTATE_LOCAL)) + if (file->Component->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping: Component not scheduled for install\n"); + TRACE("Component not scheduled for installation\n"); return ERROR_SUCCESS; } @@ -259,3 +260,81 @@ UINT ACTION_RegisterFonts(MSIPACKAGE *package) return ERROR_SUCCESS; } + +static UINT ITERATE_UnregisterFonts( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPWSTR name; + LPCWSTR filename; + MSIFILE *file; + HKEY hkey1, hkey2; + MSIRECORD *uirow; + LPWSTR uipath, p; + + filename = MSI_RecordGetString( row, 1 ); + file = get_loaded_file( package, filename ); + if (!file) + { + ERR("Unable to load file\n"); + return ERROR_SUCCESS; + } + + if (file->Component->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal\n"); + return ERROR_SUCCESS; + } + + RegCreateKeyW( HKEY_LOCAL_MACHINE, regfont1, &hkey1 ); + RegCreateKeyW( HKEY_LOCAL_MACHINE, regfont2, &hkey2 ); + + if (MSI_RecordIsNull( row, 2 )) + name = load_ttfname_from( file->TargetPath ); + else + name = msi_dup_record_field( row, 2 ); + + if (name) + { + RegDeleteValueW( hkey1, name ); + RegDeleteValueW( hkey2, name ); + } + + msi_free( name ); + RegCloseKey( hkey1 ); + RegCloseKey( hkey2 ); + + /* the UI chunk */ + uirow = MSI_CreateRecord( 1 ); + uipath = strdupW( file->TargetPath ); + p = strrchrW( uipath,'\\' ); + if (p) p++; + else p = uipath; + MSI_RecordSetStringW( uirow, 1, p ); + ui_actiondata( package, szUnregisterFonts, uirow ); + msiobj_release( &uirow->hdr ); + msi_free( uipath ); + /* FIXME: call ui_progress? */ + + return ERROR_SUCCESS; +} + +UINT ACTION_UnregisterFonts( MSIPACKAGE *package ) +{ + UINT r; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','F','o','n','t','`',0}; + + r = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (r != ERROR_SUCCESS) + { + TRACE("MSI_DatabaseOpenViewW failed: %u\n", r); + return ERROR_SUCCESS; + } + + MSI_IterateRecords( view, NULL, ITERATE_UnregisterFonts, package ); + msiobj_release( &view->hdr ); + + return ERROR_SUCCESS; +} diff --git a/reactos/dll/win32/msi/helpers.c b/reactos/dll/win32/msi/helpers.c index e3009f7bce7..e763a113073 100644 --- a/reactos/dll/win32/msi/helpers.c +++ b/reactos/dll/win32/msi/helpers.c @@ -604,28 +604,6 @@ void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record) msiobj_release(&row->hdr); } -BOOL ACTION_VerifyComponentForAction( const MSICOMPONENT* comp, INSTALLSTATE check ) -{ - if (!comp) - return FALSE; - - if (comp->ActionRequest == check) - return TRUE; - else - return FALSE; -} - -BOOL ACTION_VerifyFeatureForAction( const MSIFEATURE* feature, INSTALLSTATE check ) -{ - if (!feature) - return FALSE; - - if (feature->ActionRequest == check) - return TRUE; - else - return FALSE; -} - void reduce_to_longfilename(WCHAR* filename) { LPWSTR p = strchrW(filename,'|'); diff --git a/reactos/dll/win32/msi/install.c b/reactos/dll/win32/msi/install.c index b1d741a1625..c23075d61d3 100644 --- a/reactos/dll/win32/msi/install.c +++ b/reactos/dll/win32/msi/install.c @@ -661,6 +661,8 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) MSIPACKAGE *package; BOOL r = FALSE; + TRACE("%d %d\n", hInstall, iRunMode); + package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); if (!package) { @@ -706,8 +708,16 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) r = package->commit_action_running; break; + case MSIRUNMODE_MAINTENANCE: + r = msi_get_property_int( package, szInstalled, 0 ) != 0; + break; + + case MSIRUNMODE_REBOOTATEND: + r = package->need_reboot; + break; + default: - FIXME("%d %d\n", hInstall, iRunMode); + FIXME("unimplemented run mode: %d\n", iRunMode); r = TRUE; } @@ -719,8 +729,52 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) */ UINT WINAPI MsiSetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode, BOOL fState) { - FIXME("%d %d %d\n", hInstall, iRunMode, fState); - return ERROR_SUCCESS; + MSIPACKAGE *package; + UINT r; + + TRACE("%d %d %d\n", hInstall, iRunMode, fState); + + package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE ); + if (!package) + { + HRESULT hr; + IWineMsiRemotePackage *remote_package; + + remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall ); + if (!remote_package) + return FALSE; + + hr = IWineMsiRemotePackage_SetMode( remote_package, iRunMode, fState ); + IWineMsiRemotePackage_Release( remote_package ); + + if (FAILED(hr)) + { + if (HRESULT_FACILITY(hr) == FACILITY_WIN32) + return HRESULT_CODE(hr); + + return ERROR_FUNCTION_FAILED; + } + + return ERROR_SUCCESS; + } + + switch (iRunMode) + { + case MSIRUNMODE_REBOOTATEND: + package->need_reboot = 1; + r = ERROR_SUCCESS; + break; + + case MSIRUNMODE_REBOOTNOW: + FIXME("unimplemented run mode: %d\n", iRunMode); + r = ERROR_FUNCTION_FAILED; + break; + + default: + r = ERROR_ACCESS_DENIED; + } + + return r; } /*********************************************************************** diff --git a/reactos/dll/win32/msi/msi.c b/reactos/dll/win32/msi/msi.c index 4d9da4cd68f..07356405718 100644 --- a/reactos/dll/win32/msi/msi.c +++ b/reactos/dll/win32/msi/msi.c @@ -1613,6 +1613,93 @@ done: return r; } +UINT WINAPI MsiGetPatchInfoA( LPCSTR patch, LPCSTR attr, LPSTR buffer, LPDWORD buflen ) +{ + UINT r = ERROR_OUTOFMEMORY; + DWORD size; + LPWSTR patchW = NULL, attrW = NULL, bufferW = NULL; + + TRACE("%s %s %p %p\n", debugstr_a(patch), debugstr_a(attr), buffer, buflen); + + if (!patch || !attr) + return ERROR_INVALID_PARAMETER; + + if (!(patchW = strdupAtoW( patch ))) + goto done; + + if (!(attrW = strdupAtoW( attr ))) + goto done; + + size = 0; + r = MsiGetPatchInfoW( patchW, attrW, NULL, &size ); + if (r != ERROR_SUCCESS) + goto done; + + size++; + if (!(bufferW = msi_alloc( size * sizeof(WCHAR) ))) + { + r = ERROR_OUTOFMEMORY; + goto done; + } + + r = MsiGetPatchInfoW( patchW, attrW, bufferW, &size ); + if (r == ERROR_SUCCESS) + { + int len = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL ); + if (len > *buflen) + r = ERROR_MORE_DATA; + else if (buffer) + WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, *buflen, NULL, NULL ); + + *buflen = len - 1; + } + +done: + msi_free( patchW ); + msi_free( attrW ); + msi_free( bufferW ); + return r; +} + +UINT WINAPI MsiGetPatchInfoW( LPCWSTR patch, LPCWSTR attr, LPWSTR buffer, LPDWORD buflen ) +{ + UINT r; + WCHAR product[GUID_SIZE]; + DWORD index; + + TRACE("%s %s %p %p\n", debugstr_w(patch), debugstr_w(attr), buffer, buflen); + + if (!patch || !attr) + return ERROR_INVALID_PARAMETER; + + if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW, attr )) + return ERROR_UNKNOWN_PROPERTY; + + index = 0; + while (1) + { + r = MsiEnumProductsW( index, product ); + if (r != ERROR_SUCCESS) + break; + + r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERMANAGED, attr, buffer, buflen ); + if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA) + return r; + + r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, attr, buffer, buflen ); + if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA) + return r; + + r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_MACHINE, attr, buffer, buflen ); + if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA) + return r; + + index++; + } + + return ERROR_UNKNOWN_PRODUCT; +} + UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes) { LPWSTR szwLogFile = NULL; diff --git a/reactos/dll/win32/msi/msi.spec b/reactos/dll/win32/msi/msi.spec index 147502811be..30daec931a6 100644 --- a/reactos/dll/win32/msi/msi.spec +++ b/reactos/dll/win32/msi/msi.spec @@ -171,8 +171,8 @@ 175 stdcall MsiApplyPatchW(wstr wstr long wstr) 176 stdcall MsiAdvertiseScriptA(str long ptr long) 177 stdcall MsiAdvertiseScriptW(wstr long ptr long) -178 stub MsiGetPatchInfoA -179 stub MsiGetPatchInfoW +178 stdcall MsiGetPatchInfoA(str str ptr ptr) +179 stdcall MsiGetPatchInfoW(wstr wstr ptr ptr) 180 stdcall MsiEnumPatchesA(str long ptr ptr ptr) 181 stdcall MsiEnumPatchesW(str long ptr ptr ptr) 182 stdcall -private DllGetVersion(ptr) diff --git a/reactos/dll/win32/msi/msi_It.rc b/reactos/dll/win32/msi/msi_It.rc index 9864806fd80..11525add056 100644 --- a/reactos/dll/win32/msi/msi_It.rc +++ b/reactos/dll/win32/msi/msi_It.rc @@ -20,17 +20,21 @@ #include "windef.h" +/*UTF-8*/ +#pragma code_page(65001) + LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { - 4 "The specified installation package could not be opened. Please check the file path and try again." + 4 "Impossibile aprire il pacchetto di installazione specificato. Per favore controlla l'indirizzo del file e riprova." 5 "percorso %s non trovato" 9 "inserire disco %s" 10 "parametri incorretti" 11 "immettere il nome della cartella che contiene %s" - 12 "sorgente di installazione per la funzionalità mancante" - 13 "periferica di rete per la funzionalità mancante" - 14 "funzionalità da:" + 12 "sorgente di installazione per la funzionalità mancante" + 13 "periferica di rete per la funzionalità mancante" + 14 "funzionalità da:" 15 "selezionare la cartella che contiene %s" } +#pragma code_page(default) diff --git a/reactos/dll/win32/msi/msipriv.h b/reactos/dll/win32/msi/msipriv.h index 43486e0a830..2278ff7c2c8 100644 --- a/reactos/dll/win32/msi/msipriv.h +++ b/reactos/dll/win32/msi/msipriv.h @@ -961,6 +961,7 @@ extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterFonts(MSIPACKAGE *package); +extern UINT ACTION_UnregisterFonts(MSIPACKAGE *package); /* Helpers */ extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data ); @@ -981,8 +982,6 @@ extern void msi_free_action_script(MSIPACKAGE *package, UINT script); extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR); extern LPWSTR build_directory_name(DWORD , ...); extern BOOL create_full_pathW(const WCHAR *path); -extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE); -extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE); extern void reduce_to_longfilename(WCHAR*); extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR); extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature); @@ -1071,6 +1070,11 @@ static const WCHAR szFindRelatedProducts[] = {'F','i','n','d','R','e','l','a','t static const WCHAR szAllUsers[] = {'A','L','L','U','S','E','R','S',0}; static const WCHAR szCustomActionData[] = {'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0}; static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0}; +static const WCHAR szProductID[] = {'P','r','o','d','u','c','t','I','D',0}; +static const WCHAR szPIDTemplate[] = {'P','I','D','T','e','m','p','l','a','t','e',0}; +static const WCHAR szPIDKEY[] = {'P','I','D','K','E','Y',0}; +static const WCHAR szTYPELIB[] = {'T','Y','P','E','L','I','B',0}; +static const WCHAR szSumInfo[] = {5 ,'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0}; /* memory allocation macro functions */ static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1); diff --git a/reactos/dll/win32/msi/msiserver.idl b/reactos/dll/win32/msi/msiserver.idl index a8146957b06..aa934361b49 100644 --- a/reactos/dll/win32/msi/msiserver.idl +++ b/reactos/dll/win32/msi/msiserver.idl @@ -64,6 +64,7 @@ interface IWineMsiRemotePackage : IUnknown HRESULT SetTargetPath( [in] BSTR folder, [in] BSTR value ); HRESULT GetSourcePath( [in] BSTR folder, [out] BSTR *value, [out] DWORD *size ); HRESULT GetMode( [in] MSIRUNMODE mode, [out] BOOL *ret ); + HRESULT SetMode( [in] MSIRUNMODE mode, [in] BOOL state ); HRESULT GetFeatureState( [in] BSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action ); HRESULT SetFeatureState( [in] BSTR feature, [in] INSTALLSTATE state ); HRESULT GetComponentState( [in] BSTR component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action ); diff --git a/reactos/dll/win32/msi/package.c b/reactos/dll/win32/msi/package.c index 53804e22e56..ad6d4c65830 100644 --- a/reactos/dll/win32/msi/package.c +++ b/reactos/dll/win32/msi/package.c @@ -2104,6 +2104,13 @@ static HRESULT WINAPI mrp_GetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode return S_OK; } +static HRESULT WINAPI mrp_SetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL state ) +{ + msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface ); + UINT r = MsiSetMode(This->package, mode, state); + return HRESULT_FROM_WIN32(r); +} + static HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR feature, INSTALLSTATE *installed, INSTALLSTATE *action ) { @@ -2196,6 +2203,7 @@ static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl = mrp_SetTargetPath, mrp_GetSourcePath, mrp_GetMode, + mrp_SetMode, mrp_GetFeatureState, mrp_SetFeatureState, mrp_GetComponentState, diff --git a/reactos/dll/win32/msi/streams.c b/reactos/dll/win32/msi/streams.c index 8d2e748e64d..8ec2ad9accb 100644 --- a/reactos/dll/win32/msi/streams.c +++ b/reactos/dll/win32/msi/streams.c @@ -32,6 +32,7 @@ #include "query.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(msidb); @@ -486,7 +487,8 @@ static INT add_streams_to_table(MSISTREAMSVIEW *sv) STATSTG stat; STREAM *stream = NULL; HRESULT hr; - UINT count = 0, size; + UINT r, count = 0, size; + LPWSTR encname; hr = IStorage_EnumElements(sv->db->storage, 0, NULL, 0, &stgenum); if (FAILED(hr)) @@ -505,7 +507,10 @@ static INT add_streams_to_table(MSISTREAMSVIEW *sv) break; if (stat.type != STGTY_STREAM) + { + CoTaskMemFree(stat.pwcsName); continue; + } /* table streams are not in the _Streams table */ if (*stat.pwcsName == 0x4840) @@ -522,13 +527,22 @@ static INT add_streams_to_table(MSISTREAMSVIEW *sv) break; } - hr = IStorage_OpenStream(sv->db->storage, stat.pwcsName, 0, - STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream->stream); + if (!strcmpW(stat.pwcsName, szSumInfo)) + { + /* summary information stream is not encoded */ + r = db_get_raw_stream(sv->db, stat.pwcsName, &stream->stream); + } + else + { + encname = encode_streamname(FALSE, stat.pwcsName); + r = db_get_raw_stream(sv->db, encname, &stream->stream); + msi_free(encname); + } CoTaskMemFree(stat.pwcsName); - if (FAILED(hr)) + if (r != ERROR_SUCCESS) { - WARN("failed to open stream: %08x\n", hr); + WARN("unable to get stream %u\n", r); count = -1; break; } diff --git a/reactos/dll/win32/msi/suminfo.c b/reactos/dll/win32/msi/suminfo.c index df35c4d0d4c..902a61f6544 100644 --- a/reactos/dll/win32/msi/suminfo.c +++ b/reactos/dll/win32/msi/suminfo.c @@ -86,9 +86,6 @@ static HRESULT (WINAPI *pPropVariantChangeType) #define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER)) -static const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y', - 'I','n','f','o','r','m','a','t','i','o','n',0 }; - static void free_prop( PROPVARIANT *prop ) { if (prop->vt == VT_LPSTR ) diff --git a/reactos/dll/win32/msi/table.c b/reactos/dll/win32/msi/table.c index cc40515e664..6737ac59168 100644 --- a/reactos/dll/win32/msi/table.c +++ b/reactos/dll/win32/msi/table.c @@ -1168,7 +1168,7 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt { MSITABLEVIEW *tv = (MSITABLEVIEW*)view; UINT r; - LPWSTR full_name = NULL; + LPWSTR encname, full_name = NULL; if( !view->ops->fetch_int ) return ERROR_INVALID_PARAMETER; @@ -1180,11 +1180,13 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt return r; } - r = db_get_raw_stream( tv->db, full_name, stm ); + encname = encode_streamname( FALSE, full_name ); + r = db_get_raw_stream( tv->db, encname, stm ); if( r ) ERR("fetching stream %s, error = %d\n",debugstr_w(full_name), r); - msi_free( full_name ); + msi_free( full_name ); + msi_free( encname ); return r; } diff --git a/reactos/dll/win32/msi/tokenize.c b/reactos/dll/win32/msi/tokenize.c index 04824562de4..e17ded88861 100644 --- a/reactos/dll/win32/msi/tokenize.c +++ b/reactos/dll/win32/msi/tokenize.c @@ -166,9 +166,9 @@ static int sqliteKeywordCode(const WCHAR *z, int n){ */ static const char isIdChar[] = { /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, /* 2x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 3x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 4x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5x */ diff --git a/reactos/include/psdk/msi.h b/reactos/include/psdk/msi.h index 5c2f38cc824..b331057d53c 100644 --- a/reactos/include/psdk/msi.h +++ b/reactos/include/psdk/msi.h @@ -503,6 +503,10 @@ UINT WINAPI MsiGetPatchInfoExA(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR UINT WINAPI MsiGetPatchInfoExW(LPCWSTR, LPCWSTR, LPCWSTR, MSIINSTALLCONTEXT, LPCWSTR, LPWSTR, LPDWORD); #define MsiGetPatchInfoEx WINELIB_NAME_AW(MsiGetPatchInfoEx) +UINT WINAPI MsiGetPatchInfoA(LPCSTR, LPCSTR, LPSTR, LPDWORD); +UINT WINAPI MsiGetPatchInfoW(LPCWSTR, LPCWSTR, LPWSTR, LPDWORD); +#define MsiGetPatchInfo WINELIB_NAME_AW(MsiGetPatchInfo) + UINT WINAPI MsiEnableLogA(DWORD, LPCSTR, DWORD); UINT WINAPI MsiEnableLogW(DWORD, LPCWSTR, DWORD); #define MsiEnableLog WINELIB_NAME_AW(MsiEnableLog) From d11c861ed12886c93954b7feb279ad5f0286387a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 1 Mar 2010 12:03:29 +0000 Subject: [PATCH 018/211] [MSI_WINETEST] sync msi_winetest to wine 1.1.39 svn path=/trunk/; revision=45739 --- rostests/winetests/msi/automation.c | 17 +- rostests/winetests/msi/db.c | 66 ++- rostests/winetests/msi/install.c | 644 +++++++++++++++++++++++++++- rostests/winetests/msi/msi.c | 178 ++++++++ 4 files changed, 885 insertions(+), 20 deletions(-) diff --git a/rostests/winetests/msi/automation.c b/rostests/winetests/msi/automation.c index 8a0eede3066..edc6cbe8a60 100644 --- a/rostests/winetests/msi/automation.c +++ b/rostests/winetests/msi/automation.c @@ -1863,7 +1863,11 @@ static void test_Session(IDispatch *pSession) /* Session::Mode, get */ hr = Session_ModeGet(pSession, MSIRUNMODE_REBOOTATEND, &bool); ok(hr == S_OK, "Session_ModeGet failed, hresult 0x%08x\n", hr); - todo_wine ok(!bool, "Reboot at end session mode is %d\n", bool); + ok(!bool, "Reboot at end session mode is %d\n", bool); + + hr = Session_ModeGet(pSession, MSIRUNMODE_MAINTENANCE, &bool); + ok(hr == S_OK, "Session_ModeGet failed, hresult 0x%08x\n", hr); + ok(!bool, "Maintenance mode is %d\n", bool); /* Session::Mode, put */ hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, TRUE); @@ -1874,6 +1878,17 @@ static void test_Session(IDispatch *pSession) hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, FALSE); /* set it again so we don't reboot */ ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr); + hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTNOW, TRUE); + todo_wine ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr); + hr = Session_ModeGet(pSession, MSIRUNMODE_REBOOTNOW, &bool); + ok(hr == S_OK, "Session_ModeGet failed, hresult 0x%08x\n", hr); + ok(bool, "Reboot now mode is %d, expected 1\n", bool); + hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTNOW, FALSE); /* set it again so we don't reboot */ + todo_wine ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr); + + hr = Session_ModePut(pSession, MSIRUNMODE_MAINTENANCE, TRUE); + ok(hr == DISP_E_EXCEPTION, "Session_ModePut failed, hresult 0x%08x\n", hr); + /* Session::Database, get */ hr = Session_Database(pSession, &pDatabase); ok(hr == S_OK, "Session_Database failed, hresult 0x%08x\n", hr); diff --git a/rostests/winetests/msi/db.c b/rostests/winetests/msi/db.c index 037be7da080..8df17e82a1a 100644 --- a/rostests/winetests/msi/db.c +++ b/rostests/winetests/msi/db.c @@ -683,6 +683,30 @@ static void test_msibadqueries(void) r = try_query( hdb, "select * from 'c'"); ok(r == ERROR_BAD_QUERY_SYNTAX, "query failed\n"); + r = try_query( hdb, "CREATE TABLE `\5a` (`b` CHAR NOT NULL PRIMARY KEY `b`)" ); + ok( r == ERROR_SUCCESS , "query failed: %u\n", r ); + + r = try_query( hdb, "SELECT * FROM \5a" ); + ok( r == ERROR_SUCCESS , "query failed: %u\n", r ); + + r = try_query( hdb, "CREATE TABLE `a\5` (`b` CHAR NOT NULL PRIMARY KEY `b`)" ); + ok( r == ERROR_SUCCESS , "query failed: %u\n", r ); + + r = try_query( hdb, "SELECT * FROM a\5" ); + ok( r == ERROR_SUCCESS , "query failed: %u\n", r ); + + r = try_query( hdb, "CREATE TABLE `-a` (`b` CHAR NOT NULL PRIMARY KEY `b`)" ); + ok( r == ERROR_SUCCESS , "query failed: %u\n", r ); + + r = try_query( hdb, "SELECT * FROM -a" ); + todo_wine ok( r == ERROR_SUCCESS , "query failed: %u\n", r ); + + r = try_query( hdb, "CREATE TABLE `a-` (`b` CHAR NOT NULL PRIMARY KEY `b`)" ); + ok( r == ERROR_SUCCESS , "query failed: %u\n", r ); + + r = try_query( hdb, "SELECT * FROM a-" ); + ok( r == ERROR_SUCCESS , "query failed: %u\n", r ); + r = MsiCloseHandle( hdb ); ok(r == ERROR_SUCCESS , "Failed to close database transact\n"); @@ -1387,7 +1411,7 @@ static void create_file_data(LPCSTR name, LPCSTR data, DWORD size) static void test_streamtable(void) { - MSIHANDLE hdb = 0, rec, view; + MSIHANDLE hdb = 0, rec, view, hsi; char file[MAX_PATH]; char buf[MAX_PATH]; DWORD size; @@ -1432,6 +1456,46 @@ static void test_streamtable(void) MsiCloseHandle( rec ); + r = MsiDatabaseOpenView( hdb, + "SELECT * FROM `_Streams` WHERE `Name` = '\5SummaryInformation'", &view ); + ok( r == ERROR_SUCCESS, "Failed to open database view: %u\n", r ); + + r = MsiViewExecute( view, 0 ); + ok( r == ERROR_SUCCESS, "Failed to execute view: %u\n", r ); + + r = MsiViewFetch( view, &rec ); + ok( r == ERROR_NO_MORE_ITEMS, "Unexpected result: %u\n", r ); + + MsiCloseHandle( rec ); + MsiViewClose( view ); + MsiCloseHandle( view ); + + /* create a summary information stream */ + r = MsiGetSummaryInformationA( hdb, NULL, 1, &hsi ); + ok( r == ERROR_SUCCESS, "Failed to get summary information handle: %u\n", r ); + + r = MsiSummaryInfoSetPropertyA( hsi, PID_SECURITY, VT_I4, 2, NULL, NULL ); + ok( r == ERROR_SUCCESS, "Failed to set property: %u\n", r ); + + r = MsiSummaryInfoPersist( hsi ); + ok( r == ERROR_SUCCESS, "Failed to save summary information: %u\n", r ); + + MsiCloseHandle( hsi ); + + r = MsiDatabaseOpenView( hdb, + "SELECT * FROM `_Streams` WHERE `Name` = '\5SummaryInformation'", &view ); + ok( r == ERROR_SUCCESS, "Failed to open database view: %u\n", r ); + + r = MsiViewExecute( view, 0 ); + ok( r == ERROR_SUCCESS, "Failed to execute view: %u\n", r ); + + r = MsiViewFetch( view, &rec ); + ok( r == ERROR_SUCCESS, "Unexpected result: %u\n", r ); + + MsiCloseHandle( rec ); + MsiViewClose( view ); + MsiCloseHandle( view ); + /* insert a file into the _Streams table */ create_file( "test.txt" ); diff --git a/rostests/winetests/msi/install.c b/rostests/winetests/msi/install.c index a3f1897352e..70013e562c7 100644 --- a/rostests/winetests/msi/install.c +++ b/rostests/winetests/msi/install.c @@ -1091,7 +1091,7 @@ static const CHAR aup_custom_action_dat[] = "Action\tType\tSource\tTarget\tISCom static const CHAR cf_create_folders_dat[] = "Directory_\tComponent_\n" "s72\ts72\n" "CreateFolder\tDirectory_\tComponent_\n" - "MSITESTDIR\tOne\n"; + "FIRSTDIR\tOne\n"; static const CHAR cf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" "s72\tS255\tI2\n" @@ -1169,6 +1169,289 @@ static const CHAR sr_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" "InstallValidate\t\t1400\n" "LaunchConditions\t\t100\n"; +static const CHAR font_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n" + "i2\ti4\tL64\tS255\tS32\tS72\n" + "Media\tDiskId\n" + "1\t3\t\t\tDISK1\t\n"; + +static const CHAR font_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n" + "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n" + "File\tFile\n" + "font.ttf\tfonts\tfont.ttf\t1000\t\t\t8192\t1\n"; + +static const CHAR font_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n" + "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n" + "Feature\tFeature\n" + "fonts\t\t\tfont feature\t1\t2\tMSITESTDIR\t0\n"; + +static const CHAR font_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n" + "s72\tS38\ts72\ti2\tS255\tS72\n" + "Component\tComponent\n" + "fonts\t{F5920ED0-1183-4B8F-9330-86CE56557C05}\tMSITESTDIR\t0\t\tfont.ttf\n"; + +static const CHAR font_feature_comp_dat[] = "Feature_\tComponent_\n" + "s38\ts72\n" + "FeatureComponents\tFeature_\tComponent_\n" + "fonts\tfonts\n"; + +static const CHAR font_dat[] = "File_\tFontTitle\n" + "s72\tS128\n" + "Font\tFile_\n" + "font.ttf\tmsi test font\n"; + +static const CHAR font_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" + "s72\tS255\tI2\n" + "InstallExecuteSequence\tAction\n" + "ValidateProductID\t\t700\n" + "CostInitialize\t\t800\n" + "FileCost\t\t900\n" + "CostFinalize\t\t1000\n" + "InstallValidate\t\t1400\n" + "InstallInitialize\t\t1500\n" + "ProcessComponents\t\t1600\n" + "UnpublishFeatures\t\t1800\n" + "RemoveFiles\t\t3500\n" + "InstallFiles\t\t4000\n" + "RegisterFonts\t\t4100\n" + "UnregisterFonts\t\t4200\n" + "RegisterUser\t\t6000\n" + "RegisterProduct\t\t6100\n" + "PublishFeatures\t\t6300\n" + "PublishProduct\t\t6400\n" + "InstallFinalize\t\t6600"; + +static const CHAR vp_property_dat[] = "Property\tValue\n" + "s72\tl0\n" + "Property\tProperty\n" + "HASUIRUN\t0\n" + "INSTALLLEVEL\t3\n" + "InstallMode\tTypical\n" + "Manufacturer\tWine\n" + "PIDTemplate\t###-#######\n" + "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n" + "ProductLanguage\t1033\n" + "ProductName\tMSITEST\n" + "ProductVersion\t1.1.1\n" + "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"; + +static const CHAR vp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n" + "s72\ti2\tS64\tS0\tS255\n" + "CustomAction\tAction\n" + "SetProductID1\t51\tProductID\t1\t\n" + "SetProductID2\t51\tProductID\t2\t\n" + "TestProductID1\t19\t\t\tHalts installation\n" + "TestProductID2\t19\t\t\tHalts installation\n"; + +static const CHAR vp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" + "s72\tS255\tI2\n" + "InstallExecuteSequence\tAction\n" + "LaunchConditions\t\t100\n" + "CostInitialize\t\t800\n" + "FileCost\t\t900\n" + "CostFinalize\t\t1000\n" + "InstallValidate\t\t1400\n" + "InstallInitialize\t\t1500\n" + "SetProductID1\tSET_PRODUCT_ID=1\t3000\n" + "SetProductID2\tSET_PRODUCT_ID=2\t3100\n" + "ValidateProductID\t\t3200\n" + "InstallExecute\t\t3300\n" + "TestProductID1\tProductID=1\t3400\n" + "TestProductID2\tProductID=\"123-1234567\"\t3500\n" + "InstallFiles\t\t4000\n" + "InstallFinalize\t\t6000\n"; + +static const CHAR odbc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n" + "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n" + "File\tFile\n" + "ODBCdriver.dll\todbc\tODBCdriver.dll\t1000\t\t\t8192\t1\n" + "ODBCdriver2.dll\todbc\tODBCdriver2.dll\t1000\t\t\t8192\t2\n" + "ODBCtranslator.dll\todbc\tODBCtranslator.dll\t1000\t\t\t8192\t3\n" + "ODBCtranslator2.dll\todbc\tODBCtranslator2.dll\t1000\t\t\t8192\t4\n" + "ODBCsetup.dll\todbc\tODBCsetup.dll\t1000\t\t\t8192\t5\n"; + +static const CHAR odbc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n" + "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n" + "Feature\tFeature\n" + "odbc\t\t\todbc feature\t1\t2\tMSITESTDIR\t0\n"; + +static const CHAR odbc_feature_comp_dat[] = "Feature_\tComponent_\n" + "s38\ts72\n" + "FeatureComponents\tFeature_\tComponent_\n" + "odbc\todbc\n"; + +static const CHAR odbc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n" + "s72\tS38\ts72\ti2\tS255\tS72\n" + "Component\tComponent\n" + "odbc\t{B6F3E4AE-35D1-4B72-9044-989F03E20A43}\tMSITESTDIR\t0\t\tODBCdriver.dll\n"; + +static const CHAR odbc_driver_dat[] = "Driver\tComponent_\tDescription\tFile_\tFile_Setup\n" + "s72\ts72\ts255\ts72\tS72\n" + "ODBCDriver\tDriver\n" + "ODBC test driver\todbc\tODBC test driver\tODBCdriver.dll\t\n" + "ODBC test driver2\todbc\tODBC test driver2\tODBCdriver2.dll\tODBCsetup.dll\n"; + +static const CHAR odbc_translator_dat[] = "Translator\tComponent_\tDescription\tFile_\tFile_Setup\n" + "s72\ts72\ts255\ts72\tS72\n" + "ODBCTranslator\tTranslator\n" + "ODBC test translator\todbc\tODBC test translator\tODBCtranslator.dll\t\n" + "ODBC test translator2\todbc\tODBC test translator2\tODBCtranslator2.dll\tODBCsetup.dll\n"; + +static const CHAR odbc_datasource_dat[] = "DataSource\tComponent_\tDescription\tDriverDescription\tRegistration\n" + "s72\ts72\ts255\ts255\ti2\n" + "ODBCDataSource\tDataSource\n" + "ODBC data source\todbc\tODBC data source\tODBC driver\t0\n"; + +static const CHAR odbc_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" + "s72\tS255\tI2\n" + "InstallExecuteSequence\tAction\n" + "LaunchConditions\t\t100\n" + "CostInitialize\t\t800\n" + "FileCost\t\t900\n" + "CostFinalize\t\t1000\n" + "InstallValidate\t\t1400\n" + "InstallInitialize\t\t1500\n" + "InstallODBC\t\t3000\n" + "RemoveODBC\t\t3100\n" + "InstallFiles\t\t4000\n" + "InstallFinalize\t\t6000\n"; + +static const CHAR odbc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n" + "i2\ti4\tL64\tS255\tS32\tS72\n" + "Media\tDiskId\n" + "1\t5\t\t\tDISK1\t\n"; + +static const CHAR tl_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n" + "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n" + "File\tFile\n" + "typelib.dll\ttypelib\ttypelib.dll\t1000\t\t\t8192\t1\n"; + +static const CHAR tl_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n" + "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n" + "Feature\tFeature\n" + "typelib\t\t\ttypelib feature\t1\t2\tMSITESTDIR\t0\n"; + +static const CHAR tl_feature_comp_dat[] = "Feature_\tComponent_\n" + "s38\ts72\n" + "FeatureComponents\tFeature_\tComponent_\n" + "typelib\ttypelib\n"; + +static const CHAR tl_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n" + "s72\tS38\ts72\ti2\tS255\tS72\n" + "Component\tComponent\n" + "typelib\t{BB4C26FD-89D8-4E49-AF1C-DB4DCB5BF1B0}\tMSITESTDIR\t0\t\ttypelib.dll\n"; + +static const CHAR tl_typelib_dat[] = "LibID\tLanguage\tComponent_\tVersion\tDescription\tDirectory_\tFeature_\tCost\n" + "s38\ti2\ts72\tI4\tL128\tS72\ts38\tI4\n" + "TypeLib\tLibID\tLanguage\tComponent_\n" + "{EAC5166A-9734-4D91-878F-1DD02304C66C}\t0\ttypelib\t1793\t\tMSITESTDIR\ttypelib\t\n"; + +static const CHAR tl_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" + "s72\tS255\tI2\n" + "InstallExecuteSequence\tAction\n" + "LaunchConditions\t\t100\n" + "CostInitialize\t\t800\n" + "FileCost\t\t900\n" + "CostFinalize\t\t1000\n" + "InstallValidate\t\t1400\n" + "InstallInitialize\t\t1500\n" + "ProcessComponents\t\t1600\n" + "RemoveFiles\t\t1700\n" + "InstallFiles\t\t2000\n" + "RegisterTypeLibraries\tREGISTER_TYPELIB=1\t3000\n" + "UnregisterTypeLibraries\t\t3100\n" + "RegisterProduct\t\t5100\n" + "PublishFeatures\t\t5200\n" + "PublishProduct\t\t5300\n" + "InstallFinalize\t\t6000\n"; + +static const CHAR crs_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n" + "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n" + "File\tFile\n" + "target.txt\tshortcut\ttarget.txt\t1000\t\t\t8192\t1\n"; + +static const CHAR crs_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n" + "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n" + "Feature\tFeature\n" + "shortcut\t\t\tshortcut feature\t1\t2\tMSITESTDIR\t0\n"; + +static const CHAR crs_feature_comp_dat[] = "Feature_\tComponent_\n" + "s38\ts72\n" + "FeatureComponents\tFeature_\tComponent_\n" + "shortcut\tshortcut\n"; + +static const CHAR crs_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n" + "s72\tS38\ts72\ti2\tS255\tS72\n" + "Component\tComponent\n" + "shortcut\t{5D20E3C6-7206-498F-AC28-87AF2F9AD4CC}\tMSITESTDIR\t0\t\ttarget.txt\n"; + +static const CHAR crs_shortcut_dat[] = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n" + "s72\ts72\tl128\ts72\ts72\tL255\tL255\tI2\tS72\tI2\tI2\tS72\n" + "Shortcut\tShortcut\n" + "shortcut\tMSITESTDIR\tshortcut\tshortcut\t[MSITESTDIR]target.txt\t\t\t\t\t\t\t\n"; + +static const CHAR crs_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" + "s72\tS255\tI2\n" + "InstallExecuteSequence\tAction\n" + "LaunchConditions\t\t100\n" + "CostInitialize\t\t800\n" + "FileCost\t\t900\n" + "CostFinalize\t\t1000\n" + "InstallValidate\t\t1400\n" + "InstallInitialize\t\t1500\n" + "ProcessComponents\t\t1600\n" + "RemoveFiles\t\t1700\n" + "InstallFiles\t\t2000\n" + "RemoveShortcuts\t\t3000\n" + "CreateShortcuts\t\t3100\n" + "RegisterProduct\t\t5000\n" + "PublishFeatures\t\t5100\n" + "PublishProduct\t\t5200\n" + "InstallFinalize\t\t6000\n"; + +static const CHAR pub_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n" + "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n" + "File\tFile\n" + "english.txt\tpublish\tenglish.txt\t1000\t\t\t8192\t1\n"; + +static const CHAR pub_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n" + "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n" + "Feature\tFeature\n" + "publish\t\t\tpublish feature\t1\t2\tMSITESTDIR\t0\n"; + +static const CHAR pub_feature_comp_dat[] = "Feature_\tComponent_\n" + "s38\ts72\n" + "FeatureComponents\tFeature_\tComponent_\n" + "publish\tpublish\n"; + +static const CHAR pub_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n" + "s72\tS38\ts72\ti2\tS255\tS72\n" + "Component\tComponent\n" + "publish\t{B4EA0ACF-6238-426E-9C6D-7869F0F9C768}\tMSITESTDIR\t0\t\tenglish.txt\n"; + +static const CHAR pub_publish_component_dat[] = "ComponentId\tQualifier\tComponent_\tAppData\tFeature_\n" + "s38\ts255\ts72\tL255\ts38\n" + "PublishComponent\tComponentId\tQualifier\tComponent_\n" + "{92AFCBC0-9CA6-4270-8454-47C5EE2B8FAA}\tenglish.txt\tpublish\t\tpublish\n"; + +static const CHAR pub_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" + "s72\tS255\tI2\n" + "InstallExecuteSequence\tAction\n" + "LaunchConditions\t\t100\n" + "CostInitialize\t\t800\n" + "FileCost\t\t900\n" + "CostFinalize\t\t1000\n" + "InstallValidate\t\t1400\n" + "InstallInitialize\t\t1500\n" + "ProcessComponents\t\t1600\n" + "RemoveFiles\t\t1700\n" + "InstallFiles\t\t2000\n" + "PublishComponents\t\t3000\n" + "UnpublishComponents\t\t3100\n" + "RegisterProduct\t\t5000\n" + "PublishFeatures\t\t5100\n" + "PublishProduct\t\t5200\n" + "InstallFinalize\t\t6000\n"; + typedef struct _msi_table { const CHAR *filename; @@ -1939,6 +2222,86 @@ static const msi_table sr_tables[] = ADD_TABLE(property) }; +static const msi_table font_tables[] = +{ + ADD_TABLE(font_component), + ADD_TABLE(directory), + ADD_TABLE(font_feature), + ADD_TABLE(font_feature_comp), + ADD_TABLE(font_file), + ADD_TABLE(font), + ADD_TABLE(font_install_exec_seq), + ADD_TABLE(font_media), + ADD_TABLE(property) +}; + +static const msi_table vp_tables[] = +{ + ADD_TABLE(component), + ADD_TABLE(directory), + ADD_TABLE(feature), + ADD_TABLE(feature_comp), + ADD_TABLE(file), + ADD_TABLE(vp_custom_action), + ADD_TABLE(vp_install_exec_seq), + ADD_TABLE(media), + ADD_TABLE(vp_property) +}; + +static const msi_table odbc_tables[] = +{ + ADD_TABLE(odbc_component), + ADD_TABLE(directory), + ADD_TABLE(odbc_feature), + ADD_TABLE(odbc_feature_comp), + ADD_TABLE(odbc_file), + ADD_TABLE(odbc_driver), + ADD_TABLE(odbc_translator), + ADD_TABLE(odbc_datasource), + ADD_TABLE(odbc_install_exec_seq), + ADD_TABLE(odbc_media), + ADD_TABLE(property) +}; + +static const msi_table tl_tables[] = +{ + ADD_TABLE(tl_component), + ADD_TABLE(directory), + ADD_TABLE(tl_feature), + ADD_TABLE(tl_feature_comp), + ADD_TABLE(tl_file), + ADD_TABLE(tl_typelib), + ADD_TABLE(tl_install_exec_seq), + ADD_TABLE(media), + ADD_TABLE(property) +}; + +static const msi_table crs_tables[] = +{ + ADD_TABLE(crs_component), + ADD_TABLE(directory), + ADD_TABLE(crs_feature), + ADD_TABLE(crs_feature_comp), + ADD_TABLE(crs_file), + ADD_TABLE(crs_shortcut), + ADD_TABLE(crs_install_exec_seq), + ADD_TABLE(media), + ADD_TABLE(property) +}; + +static const msi_table pub_tables[] = +{ + ADD_TABLE(directory), + ADD_TABLE(pub_component), + ADD_TABLE(pub_feature), + ADD_TABLE(pub_feature_comp), + ADD_TABLE(pub_file), + ADD_TABLE(pub_publish_component), + ADD_TABLE(pub_install_exec_seq), + ADD_TABLE(media), + ADD_TABLE(property) +}; + /* cabinet definitions */ /* make the max size large so there is only one cab file */ @@ -7242,23 +7605,43 @@ static char rename_ops[] = "PendingFileRenameOperations"; static void process_pending_renames(HKEY hkey) { - char *buf, *src, *dst; - DWORD size; + char *buf, *src, *dst, *buf2, *buf2ptr; + DWORD size, buf2len = 0; LONG ret; + BOOL found = FALSE; ret = RegQueryValueExA(hkey, rename_ops, NULL, NULL, NULL, &size); buf = HeapAlloc(GetProcessHeap(), 0, size); + buf2ptr = buf2 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); buf[0] = 0; ret = RegQueryValueExA(hkey, rename_ops, NULL, NULL, (LPBYTE)buf, &size); ok(!ret, "RegQueryValueExA failed %d (%u)\n", ret, GetLastError()); - ok(strstr(buf, "msitest\\maximus") != NULL, "Unexpected value \"%s\"\n", buf); for (src = buf; *src; src = dst + strlen(dst) + 1) { DWORD flags = MOVEFILE_COPY_ALLOWED; dst = src + strlen(src) + 1; + + if (!strstr(src, "msitest")) + { + lstrcpyA(buf2ptr, src); + buf2len += strlen(src) + 1; + buf2ptr += strlen(src) + 1; + if (*dst) + { + lstrcpyA(buf2ptr, dst); + buf2ptr += strlen(dst) + 1; + buf2len += strlen(dst) + 1; + } + buf2ptr++; + buf2len++; + continue; + } + + found = TRUE; + if (*dst == '!') { flags |= MOVEFILE_REPLACE_EXISTING; @@ -7273,8 +7656,19 @@ static void process_pending_renames(HKEY hkey) else ok(DeleteFileA(src), "Failed to delete file %s (%u)\n", src, GetLastError()); } + + ok(found, "Expected a 'msitest' entry\n"); + + if (*buf2) + { + buf2len++; + RegSetValueExA(hkey, rename_ops, 0, REG_MULTI_SZ, (LPBYTE)buf2, buf2len); + } + else + RegDeleteValueA(hkey, rename_ops); + HeapFree(GetProcessHeap(), 0, buf); - RegDeleteValueA(hkey, rename_ops); + HeapFree(GetProcessHeap(), 0, buf2); } static BOOL file_matches_data(LPCSTR file, LPCSTR data) @@ -7298,7 +7692,6 @@ static BOOL file_matches_data(LPCSTR file, LPCSTR data) static void test_file_in_use(void) { UINT r; - DWORD size; HANDLE file; HKEY hkey; char path[MAX_PATH]; @@ -7310,11 +7703,6 @@ static void test_file_in_use(void) } RegOpenKeyExA(HKEY_LOCAL_MACHINE, session_manager, 0, KEY_ALL_ACCESS, &hkey); - if (!RegQueryValueExA(hkey, rename_ops, NULL, NULL, NULL, &size)) - { - skip("Pending file rename operations, skipping test\n"); - return; - } CreateDirectoryA("msitest", NULL); create_file("msitest\\maximus", 500); @@ -7351,7 +7739,6 @@ static void test_file_in_use(void) static void test_file_in_use_cab(void) { UINT r; - DWORD size; HANDLE file; HKEY hkey; char path[MAX_PATH]; @@ -7363,11 +7750,6 @@ static void test_file_in_use_cab(void) } RegOpenKeyExA(HKEY_LOCAL_MACHINE, session_manager, 0, KEY_ALL_ACCESS, &hkey); - if (!RegQueryValueExA(hkey, rename_ops, NULL, NULL, NULL, &size)) - { - skip("Pending file rename operations, skipping test\n"); - return; - } CreateDirectoryA("msitest", NULL); create_file("maximus", 500); @@ -7532,7 +7914,23 @@ static void test_create_folder(void) ok(!delete_pf("msitest\\filename", TRUE), "File installed\n"); ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n"); ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); - todo_wine ok(!delete_pf("msitest", FALSE), "Directory created\n"); + ok(!delete_pf("msitest", FALSE), "Directory created\n"); + + r = MsiInstallProductA(msifile, "LOCAL=Two"); + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + + ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\first", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\filename", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); + ok(!delete_pf("msitest", FALSE), "Directory created\n"); delete_test_files(); } @@ -7562,6 +7960,22 @@ static void test_remove_folder(void) ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); ok(!delete_pf("msitest", FALSE), "Directory created\n"); + r = MsiInstallProductA(msifile, "LOCAL=Two"); + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + + ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\first", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\filename", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); + ok(!delete_pf("msitest", FALSE), "Directory created\n"); + delete_test_files(); } @@ -7700,6 +8114,194 @@ static void test_self_registration(void) delete_test_files(); } +static void test_register_font(void) +{ + static const char regfont1[] = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; + static const char regfont2[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Fonts"; + LONG ret; + HKEY key; + UINT r; + + create_test_files(); + create_file("msitest\\font.ttf", 1000); + create_database(msifile, font_tables, sizeof(font_tables) / sizeof(msi_table)); + + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); + + r = MsiInstallProductA(msifile, NULL); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, regfont1, &key); + if (ret) + RegOpenKeyA(HKEY_LOCAL_MACHINE, regfont2, &key); + + ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL); + ok(ret != ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret); + + r = MsiInstallProductA(msifile, "REMOVE=ALL"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n"); + + ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL); + ok(ret == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret); + + RegDeleteValueA(key, "msi test font"); + RegCloseKey(key); + delete_test_files(); +} + +static void test_validate_product_id(void) +{ + UINT r; + + create_test_files(); + create_database(msifile, vp_tables, sizeof(vp_tables) / sizeof(msi_table)); + + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); + + r = MsiInstallProductA(msifile, NULL); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=1"); + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + + r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=2"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + r = MsiInstallProductA(msifile, "PIDKEY=123-1234567"); + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + + ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); + ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n"); + ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n"); + ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n"); + ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n"); + ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n"); + ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n"); + ok(delete_pf("msitest\\first", FALSE), "Directory not created\n"); + ok(delete_pf("msitest\\filename", TRUE), "File not installed\n"); + ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n"); + ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n"); + ok(delete_pf("msitest", FALSE), "Directory not created\n"); + + delete_test_files(); +} + +static void test_install_remove_odbc(void) +{ + UINT r; + + create_test_files(); + create_file("msitest\\ODBCdriver.dll", 1000); + create_file("msitest\\ODBCdriver2.dll", 1000); + create_file("msitest\\ODBCtranslator.dll", 1000); + create_file("msitest\\ODBCtranslator2.dll", 1000); + create_file("msitest\\ODBCsetup.dll", 1000); + create_database(msifile, odbc_tables, sizeof(odbc_tables) / sizeof(msi_table)); + + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); + + r = MsiInstallProductA(msifile, NULL); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + ok(delete_pf("msitest\\ODBCdriver.dll", TRUE), "file not created\n"); + ok(delete_pf("msitest\\ODBCdriver2.dll", TRUE), "file not created\n"); + ok(delete_pf("msitest\\ODBCtranslator.dll", TRUE), "file not created\n"); + ok(delete_pf("msitest\\ODBCtranslator2.dll", TRUE), "file not created\n"); + ok(delete_pf("msitest\\ODBCsetup.dll", TRUE), "file not created\n"); + ok(delete_pf("msitest", FALSE), "directory not created\n"); + + delete_test_files(); +} + +static void test_register_typelib(void) +{ + UINT r; + + create_test_files(); + create_file("msitest\\typelib.dll", 1000); + create_database(msifile, tl_tables, sizeof(tl_tables) / sizeof(msi_table)); + + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); + + r = MsiInstallProductA(msifile, "REGISTER_TYPELIB=1"); + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + + r = MsiInstallProductA(msifile, NULL); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + r = MsiInstallProductA(msifile, "REMOVE=ALL"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + ok(!delete_pf("msitest\\typelib.dll", TRUE), "file not removed\n"); + todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n"); + + delete_test_files(); +} + +static void test_create_remove_shortcut(void) +{ + UINT r; + + create_test_files(); + create_file("msitest\\target.txt", 1000); + create_database(msifile, crs_tables, sizeof(crs_tables) / sizeof(msi_table)); + + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); + + r = MsiInstallProductA(msifile, NULL); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + ok(pf_exists("msitest\\target.txt"), "file not created\n"); + ok(pf_exists("msitest\\shortcut.lnk"), "file not created\n"); + + r = MsiInstallProductA(msifile, "REMOVE=ALL"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + ok(!delete_pf("msitest\\shortcut.lnk", TRUE), "file not removed\n"); + ok(!delete_pf("msitest\\target.txt", TRUE), "file not removed\n"); + todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n"); + + delete_test_files(); +} + +static void test_publish_components(void) +{ + static char keypath[] = + "Software\\Microsoft\\Installer\\Components\\0CBCFA296AC907244845745CEEB2F8AA"; + + UINT r; + LONG res; + HKEY key; + + create_test_files(); + create_file("msitest\\english.txt", 1000); + create_database(msifile, pub_tables, sizeof(pub_tables) / sizeof(msi_table)); + + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); + + r = MsiInstallProductA(msifile, NULL); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key); + ok(res == ERROR_SUCCESS, "components key not created %d\n", res); + + res = RegQueryValueExA(key, "english.txt", NULL, NULL, NULL, NULL); + ok(res == ERROR_SUCCESS, "value not found %d\n", res); + RegCloseKey(key); + + r = MsiInstallProductA(msifile, "REMOVE=ALL"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key); + ok(res == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", res); + + ok(!delete_pf("msitest\\english.txt", TRUE), "file not removed\n"); + todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n"); + delete_test_files(); +} + START_TEST(install) { DWORD len; @@ -7796,6 +8398,12 @@ START_TEST(install) test_start_services(); test_delete_services(); test_self_registration(); + test_register_font(); + test_validate_product_id(); + test_install_remove_odbc(); + test_register_typelib(); + test_create_remove_shortcut(); + test_publish_components(); DeleteFileA(log_file); diff --git a/rostests/winetests/msi/msi.c b/rostests/winetests/msi/msi.c index e3baa09bc3d..2995adbe56b 100644 --- a/rostests/winetests/msi/msi.c +++ b/rostests/winetests/msi/msi.c @@ -10888,6 +10888,183 @@ static void test_MsiGetPatchInfoEx(void) LocalFree(usersid); } +static void test_MsiGetPatchInfo(void) +{ + UINT r; + char prod_code[MAX_PATH], prod_squashed[MAX_PATH], val[MAX_PATH]; + char patch_code[MAX_PATH], patch_squashed[MAX_PATH], keypath[MAX_PATH]; + WCHAR valW[MAX_PATH], patch_codeW[MAX_PATH]; + HKEY hkey_product, hkey_patch, hkey_patches, hkey_udprops, hkey_udproduct; + HKEY hkey_udpatch, hkey_udpatches, hkey_udproductpatches, hkey_udproductpatch; + DWORD size; + LONG res; + + create_test_guid(patch_code, patch_squashed); + create_test_guid(prod_code, prod_squashed); + MultiByteToWideChar(CP_ACP, 0, patch_code, -1, patch_codeW, MAX_PATH); + + r = MsiGetPatchInfoA(NULL, NULL, NULL, NULL); + ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r); + + r = MsiGetPatchInfoA(patch_code, NULL, NULL, NULL); + ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r); + + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, NULL, NULL); + ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r); + + size = 0; + r = MsiGetPatchInfoA(patch_code, NULL, NULL, &size); + ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r); + + r = MsiGetPatchInfoA(patch_code, "", NULL, &size); + ok(r == ERROR_UNKNOWN_PROPERTY, "expected ERROR_UNKNOWN_PROPERTY, got %u\n", r); + + lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\"); + lstrcatA(keypath, prod_squashed); + + res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey_product); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res); + + /* product key exists */ + size = MAX_PATH; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r); + ok(!lstrcmpA(val, "apple"), "expected val to be unchanged, got \"%s\"\n", val); + ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size); + + res = RegCreateKeyA(hkey_product, "Patches", &hkey_patches); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res); + + /* patches key exists */ + size = MAX_PATH; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r); + ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val); + ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size); + + res = RegCreateKeyA(hkey_patches, patch_squashed, &hkey_patch); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res); + + /* patch key exists */ + size = MAX_PATH; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r); + ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val); + ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size); + + lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer"); + lstrcatA(keypath, "\\UserData\\S-1-5-18\\Products\\"); + lstrcatA(keypath, prod_squashed); + + res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey_udproduct); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res); + + /* UserData product key exists */ + size = MAX_PATH; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r); + ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val); + ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size); + + res = RegCreateKeyA(hkey_udproduct, "InstallProperties", &hkey_udprops); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res); + + /* InstallProperties key exists */ + size = MAX_PATH; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r); + ok(!lstrcmpA(val, "apple"), "expected val to be unchanged, got \"%s\"\n", val); + ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size); + + res = RegCreateKeyA(hkey_udproduct, "Patches", &hkey_udpatches); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res); + + /* UserData Patches key exists */ + size = MAX_PATH; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r); + ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val); + ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size); + + res = RegCreateKeyA(hkey_udproduct, "Patches", &hkey_udproductpatches); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = RegCreateKeyA(hkey_udproductpatches, patch_squashed, &hkey_udproductpatch); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + /* UserData product patch key exists */ + size = MAX_PATH; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r); + ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val); + ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size); + + lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer"); + lstrcatA(keypath, "\\UserData\\S-1-5-18\\Patches\\"); + lstrcatA(keypath, patch_squashed); + + res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey_udpatch); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res); + + res = RegSetValueExA(hkey_udpatch, "LocalPackage", 0, REG_SZ, (const BYTE *)"c:\\test.msp", 12); + ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res); + + /* UserData Patch key exists */ + size = 0; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", r); + ok(!lstrcmpA(val, "apple"), "expected \"apple\", got \"%s\"\n", val); + ok(size == 11, "expected 11 got %u\n", size); + + size = MAX_PATH; + lstrcpyA(val, "apple"); + r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size); + ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS got %u\n", r); + ok(!lstrcmpA(val, "c:\\test.msp"), "expected \"c:\\test.msp\", got \"%s\"\n", val); + ok(size == 11, "expected 11 got %u\n", size); + + size = 0; + valW[0] = 0; + r = MsiGetPatchInfoW(patch_codeW, INSTALLPROPERTY_LOCALPACKAGEW, valW, &size); + ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", r); + ok(!valW[0], "expected 0 got %u\n", valW[0]); + ok(size == 11, "expected 11 got %u\n", size); + + size = MAX_PATH; + valW[0] = 0; + r = MsiGetPatchInfoW(patch_codeW, INSTALLPROPERTY_LOCALPACKAGEW, valW, &size); + ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS got %u\n", r); + ok(valW[0], "expected > 0 got %u\n", valW[0]); + ok(size == 11, "expected 11 got %u\n", size); + + RegDeleteKeyA(hkey_udproductpatch, ""); + RegCloseKey(hkey_udproductpatch); + RegDeleteKeyA(hkey_udproductpatches, ""); + RegCloseKey(hkey_udproductpatches); + RegDeleteKeyA(hkey_udpatch, ""); + RegCloseKey(hkey_udpatch); + RegDeleteKeyA(hkey_patches, ""); + RegCloseKey(hkey_patches); + RegDeleteKeyA(hkey_product, ""); + RegCloseKey(hkey_product); + RegDeleteKeyA(hkey_patch, ""); + RegCloseKey(hkey_patch); + RegDeleteKeyA(hkey_udpatches, ""); + RegCloseKey(hkey_udpatches); + RegDeleteKeyA(hkey_udprops, ""); + RegCloseKey(hkey_udprops); + RegDeleteKeyA(hkey_udproduct, ""); + RegCloseKey(hkey_udproduct); +} + static void test_MsiEnumProducts(void) { UINT r; @@ -10985,6 +11162,7 @@ START_TEST(msi) test_MsiEnumPatchesEx(); test_MsiEnumPatches(); test_MsiGetPatchInfoEx(); + test_MsiGetPatchInfo(); test_MsiEnumProducts(); } From 86a010102c75849ae8334ef71dd65d1617154ec9 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 1 Mar 2010 12:08:36 +0000 Subject: [PATCH 019/211] [MMIXER] - Silence warning for Christoph svn path=/trunk/; revision=45740 --- reactos/lib/drivers/sound/mmixer/filter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reactos/lib/drivers/sound/mmixer/filter.c b/reactos/lib/drivers/sound/mmixer/filter.c index 5e1ff8b05f9..d02477de082 100644 --- a/reactos/lib/drivers/sound/mmixer/filter.c +++ b/reactos/lib/drivers/sound/mmixer/filter.c @@ -203,7 +203,9 @@ MMixerGetControlTypeFromTopologyNode( UNIMPLEMENTED; return MIXERCONTROL_CONTROLTYPE_VOLUME; } - UNIMPLEMENTED + //TODO + //check for other supported node types + //UNIMPLEMENTED return 0; } From 7d4885984ef7b2caa7e705eee4e483a9dc60c953 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 1 Mar 2010 13:42:52 +0000 Subject: [PATCH 020/211] [MSIEXEC] sync msiexec to wine 1.1.39 svn path=/trunk/; revision=45742 --- reactos/base/system/msiexec/msiexec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reactos/base/system/msiexec/msiexec.c b/reactos/base/system/msiexec/msiexec.c index 9221fa2a9ce..fe19d98e434 100644 --- a/reactos/base/system/msiexec/msiexec.c +++ b/reactos/base/system/msiexec/msiexec.c @@ -47,6 +47,7 @@ static const char UsageStr[] = " Install a product:\n" " msiexec {package|productcode} [property]\n" " msiexec /i {package|productcode} [property]\n" +" msiexec /package {package|productcode} [property]\n" " msiexec /a package [property]\n" " Repair an installation:\n" " msiexec /f[p|o|e|d|c|a|u|m|s|v] {package|productcode}\n" @@ -562,12 +563,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine { FunctionUnregServer = TRUE; } - else if(msi_option_prefix(argvW[i], "i")) + else if(msi_option_prefix(argvW[i], "i") || msi_option_prefix(argvW[i], "package")) { LPWSTR argvWi = argvW[i]; + int argLen = (msi_option_prefix(argvW[i], "i") ? 2 : 8); FunctionInstall = TRUE; - if(lstrlenW(argvWi) > 2) - argvWi += 2; + if(lstrlenW(argvW[i]) > argLen) + argvWi += argLen; else { i++; From 3970017d64d1518101d50fb6ee7f834ba7068986 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 1 Mar 2010 13:53:34 +0000 Subject: [PATCH 021/211] [MSI] hackfix ITERATE_SelfRegModules not to hang on error svn path=/trunk/; revision=45743 --- reactos/dll/win32/msi/action.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/msi/action.c b/reactos/dll/win32/msi/action.c index 20929c6cd1a..ca8588f4529 100644 --- a/reactos/dll/win32/msi/action.c +++ b/reactos/dll/win32/msi/action.c @@ -3761,7 +3761,7 @@ static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param) MSIFILE *file; DWORD len; static const WCHAR ExeStr[] = - {'r','e','g','s','v','r','3','2','.','e','x','e',' ','\"',0}; + {'r','e','g','s','v','r','3','2','.','e','x','e',' ',' /',' s',' ','\"',0}; static const WCHAR close[] = {'\"',0}; STARTUPINFOW si; PROCESS_INFORMATION info; @@ -3840,7 +3840,7 @@ static UINT ACTION_SelfRegModules(MSIPACKAGE *package) static UINT ITERATE_SelfUnregModules( MSIRECORD *row, LPVOID param ) { static const WCHAR regsvr32[] = - {'r','e','g','s','v','r','3','2','.','e','x','e',' ','/','u',' ','\"',0}; + {'r','e','g','s','v','r','3','2','.','e','x','e',' ','/','u',' ','/','s',' ','\"',0}; static const WCHAR close[] = {'\"',0}; MSIPACKAGE *package = param; LPCWSTR filename; From 04fdf4b562f50b32691b2dffa0d0c439ea256724 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 1 Mar 2010 15:28:28 +0000 Subject: [PATCH 022/211] [BDAPLGIN] - Implement IBDA_PinControl::GetPinID, IBDA_PinControl::GetPinType - Comment out enumeration of IBDA_NetworkProvider [MSDVBNP] - Start implementing Network Provider for MPEG-2 based Networks [MSVIDCTL] - Start implementing ActiveX Control for Streaming Video svn path=/trunk/; revision=45746 --- .../dll/directx/bdaplgin/devicecontrol.cpp | 2 +- reactos/dll/directx/bdaplgin/pincontrol.cpp | 76 +++- reactos/dll/directx/bdaplgin/precomp.h | 1 + reactos/dll/directx/msdvbnp/classfactory.cpp | 105 +++++ reactos/dll/directx/msdvbnp/msdvbnp.cpp | 108 ++++++ reactos/dll/directx/msdvbnp/msdvbnp.rbuild | 28 ++ reactos/dll/directx/msdvbnp/msdvbnp.rc | 12 + reactos/dll/directx/msdvbnp/msdvbnp.spec | 4 + .../dll/directx/msdvbnp/networkprovider.cpp | 350 +++++++++++++++++ reactos/dll/directx/msdvbnp/precomp.h | 54 +++ reactos/dll/directx/msdvbnp/scanningtuner.cpp | 265 +++++++++++++ reactos/dll/directx/msvidctl/classfactory.cpp | 106 +++++ .../dll/directx/msvidctl/enumtuningspaces.cpp | 142 +++++++ reactos/dll/directx/msvidctl/msvidctl.cpp | 106 +++++ reactos/dll/directx/msvidctl/msvidctl.rbuild | 30 ++ reactos/dll/directx/msvidctl/msvidctl.rc | 12 + reactos/dll/directx/msvidctl/msvidctl.spec | 4 + reactos/dll/directx/msvidctl/precomp.h | 72 ++++ reactos/dll/directx/msvidctl/tunerequest.cpp | 331 ++++++++++++++++ reactos/dll/directx/msvidctl/tuningspace.cpp | 365 ++++++++++++++++++ .../msvidctl/tuningspace_container.cpp | 272 +++++++++++++ 21 files changed, 2435 insertions(+), 10 deletions(-) create mode 100644 reactos/dll/directx/msdvbnp/classfactory.cpp create mode 100644 reactos/dll/directx/msdvbnp/msdvbnp.cpp create mode 100644 reactos/dll/directx/msdvbnp/msdvbnp.rbuild create mode 100644 reactos/dll/directx/msdvbnp/msdvbnp.rc create mode 100644 reactos/dll/directx/msdvbnp/msdvbnp.spec create mode 100644 reactos/dll/directx/msdvbnp/networkprovider.cpp create mode 100644 reactos/dll/directx/msdvbnp/precomp.h create mode 100644 reactos/dll/directx/msdvbnp/scanningtuner.cpp create mode 100644 reactos/dll/directx/msvidctl/classfactory.cpp create mode 100644 reactos/dll/directx/msvidctl/enumtuningspaces.cpp create mode 100644 reactos/dll/directx/msvidctl/msvidctl.cpp create mode 100644 reactos/dll/directx/msvidctl/msvidctl.rbuild create mode 100644 reactos/dll/directx/msvidctl/msvidctl.rc create mode 100644 reactos/dll/directx/msvidctl/msvidctl.spec create mode 100644 reactos/dll/directx/msvidctl/precomp.h create mode 100644 reactos/dll/directx/msvidctl/tunerequest.cpp create mode 100644 reactos/dll/directx/msvidctl/tuningspace.cpp create mode 100644 reactos/dll/directx/msvidctl/tuningspace_container.cpp diff --git a/reactos/dll/directx/bdaplgin/devicecontrol.cpp b/reactos/dll/directx/bdaplgin/devicecontrol.cpp index 3bbdfbe0df6..d44367f126e 100644 --- a/reactos/dll/directx/bdaplgin/devicecontrol.cpp +++ b/reactos/dll/directx/bdaplgin/devicecontrol.cpp @@ -469,7 +469,7 @@ CBDADeviceControl::GetControlNode(ULONG ulInputPinId, ULONG ulOutputPinId, ULONG #ifdef BDAPLGIN_TRACE WCHAR Buffer[100]; - swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx, BytesReturned %lu PinId %lu Dummy %lu\n", hr, BytesReturned, PinId, Dummy); + swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx, BytesReturned %lu PinId %lu\n", hr, BytesReturned, PinId); OutputDebugStringW(Buffer); #endif diff --git a/reactos/dll/directx/bdaplgin/pincontrol.cpp b/reactos/dll/directx/bdaplgin/pincontrol.cpp index 324f7a1f6a1..74e2398eb49 100644 --- a/reactos/dll/directx/bdaplgin/pincontrol.cpp +++ b/reactos/dll/directx/bdaplgin/pincontrol.cpp @@ -9,7 +9,8 @@ #include "precomp.h" -const GUID IID_IBDA_PinControl = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}}; +const GUID IID_IBDA_PinControl = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}}; +const GUID KSPROPSETID_BdaPinControl = {0x0ded49d5, 0xa8b7, 0x4d5d, {0x97, 0xa1, 0x12, 0xb0, 0xc1, 0x95, 0x87, 0x4d}}; const GUID IID_IPin = {0x56a86891, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; class CBDAPinControl : public IBDA_PinControl @@ -39,7 +40,11 @@ public: CBDAPinControl(HANDLE hFile, IBDA_NetworkProvider * pProvider, IPin * pConnectedPin) : m_Ref(0), m_Handle(hFile), m_pProvider(pProvider), m_pConnectedPin(pConnectedPin){}; - virtual ~CBDAPinControl(){}; + virtual ~CBDAPinControl() + { + //m_pConnectedPin->Release(); + //m_pProvider->Release(); + }; protected: LONG m_Ref; @@ -67,6 +72,16 @@ CBDAPinControl::QueryInterface( return NOERROR; } +#ifdef BDAPLGIN_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CBDAPinControl::QueryInterface: NoInterface for %s", lpstr); + DebugBreak(); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); +#endif + return E_NOINTERFACE; } //------------------------------------------------------------------- @@ -76,22 +91,50 @@ HRESULT STDMETHODCALLTYPE CBDAPinControl::GetPinID(ULONG *pulPinID) { + KSPROPERTY Property; + ULONG BytesReturned; + HRESULT hr; + + // setup request + Property.Set = KSPROPSETID_BdaPinControl; + Property.Id = KSPROPERTY_BDA_PIN_ID; + Property.Flags = KSPROPERTY_TYPE_GET; + + // perform request + hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), pulPinID, sizeof(ULONG), &BytesReturned); + #ifdef BDAPLGIN_TRACE - OutputDebugStringW(L"CBDAPinControl::GetPinID: NotImplemented\n"); + WCHAR Buffer[100]; + swprintf(Buffer, L"CBDAPinControl::GetPinID: hr %lx pulPinID %lu BytesReturned %lx\n", hr, *pulPinID, BytesReturned); + OutputDebugStringW(Buffer); #endif - return E_NOTIMPL; + return hr; } HRESULT STDMETHODCALLTYPE CBDAPinControl::GetPinType(ULONG *pulPinType) { + KSPROPERTY Property; + ULONG BytesReturned; + HRESULT hr; + + // setup request + Property.Set = KSPROPSETID_BdaPinControl; + Property.Id = KSPROPERTY_BDA_PIN_TYPE; + Property.Flags = KSPROPERTY_TYPE_GET; + + // perform request + hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), pulPinType, sizeof(ULONG), &BytesReturned); + #ifdef BDAPLGIN_TRACE - OutputDebugStringW(L"CBDAPinControl::GetPinType: NotImplemented\n"); + WCHAR Buffer[100]; + swprintf(Buffer, L"CBDAPinControl::GetPinType: hr %lx pulPinType %lu BytesReturned %lx\n", hr, *pulPinType, BytesReturned); + OutputDebugStringW(Buffer); #endif - return E_NOTIMPL; + return hr; } HRESULT @@ -112,15 +155,29 @@ CBDAPinControl_fnConstructor( REFIID riid, LPVOID * ppv) { + IPin * pConnectedPin = NULL; + IBDA_NetworkProvider * pNetworkProvider = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + +#if 0 + if (!IsEqualGUID(riid, IID_IUnknown)) + { +#ifdef BDAPLGIN_TRACE + OutputDebugStringW(L"CBDAPinControl_fnConstructor: Expected IUnknown\n"); +#endif + return REGDB_E_CLASSNOTREG; + } + + HRESULT hr; IKsObject * pObject = NULL; - IPin * pPin = NULL, * pConnectedPin = NULL; + IPin * pPin = NULL; IEnumFilters *pEnumFilters = NULL; - IBDA_NetworkProvider * pNetworkProvider = NULL; + IBaseFilter * ppFilter[1]; PIN_INFO PinInfo; FILTER_INFO FilterInfo; - HANDLE hFile = INVALID_HANDLE_VALUE; + if (!pUnkOuter) return E_POINTER; @@ -225,6 +282,7 @@ CBDAPinControl_fnConstructor( // no network provider interface in graph return E_NOINTERFACE; } +#endif CBDAPinControl * handler = new CBDAPinControl(hFile, pNetworkProvider, pConnectedPin); diff --git a/reactos/dll/directx/bdaplgin/precomp.h b/reactos/dll/directx/bdaplgin/precomp.h index 4365afb807e..e4776ea20a1 100644 --- a/reactos/dll/directx/bdaplgin/precomp.h +++ b/reactos/dll/directx/bdaplgin/precomp.h @@ -1,6 +1,7 @@ #ifndef PRECOMP_H__ #define PRECOMP_H__ +#define BDAPLGIN_TRACE #define BUILDING_KS #define _KSDDK_ #include diff --git a/reactos/dll/directx/msdvbnp/classfactory.cpp b/reactos/dll/directx/msdvbnp/classfactory.cpp new file mode 100644 index 00000000000..89b61c486fe --- /dev/null +++ b/reactos/dll/directx/msdvbnp/classfactory.cpp @@ -0,0 +1,105 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msdvbnp/classfactory.cpp + * PURPOSE: IClassFactory interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; +const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; + +class CClassFactory : public IClassFactory +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject); + HRESULT WINAPI LockServer(BOOL fLock); + + CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst) + {}; + + virtual ~CClassFactory(){}; + +protected: + LONG m_Ref; + LPFNCREATEINSTANCE m_lpfnCI; + IID * m_IID; +}; + +HRESULT +WINAPI +CClassFactory::QueryInterface( + REFIID riid, + LPVOID *ppvObj) +{ + *ppvObj = NULL; + if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) + { + *ppvObj = PVOID(this); + InterlockedIncrement(&m_Ref); + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT +WINAPI +CClassFactory::CreateInstance( + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID *ppvObject) +{ + *ppvObject = NULL; + + if ( m_IID == NULL || IsEqualCLSID(riid, *m_IID) || IsEqualCLSID(riid, IID_IUnknown)) + { + return m_lpfnCI(pUnkOuter, riid, ppvObject); + } + + return E_NOINTERFACE; +} + +HRESULT +WINAPI +CClassFactory::LockServer( + BOOL fLock) +{ + return E_NOTIMPL; +} + +IClassFactory * +CClassFactory_fnConstructor( + LPFNCREATEINSTANCE lpfnCI, + PLONG pcRefDll, + IID * riidInst) +{ + CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst); + + if (!factory) + return NULL; + + if (pcRefDll) + InterlockedIncrement(pcRefDll); + + return (LPCLASSFACTORY)factory; +} diff --git a/reactos/dll/directx/msdvbnp/msdvbnp.cpp b/reactos/dll/directx/msdvbnp/msdvbnp.cpp new file mode 100644 index 00000000000..037a67ef717 --- /dev/null +++ b/reactos/dll/directx/msdvbnp/msdvbnp.cpp @@ -0,0 +1,108 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/msdvbnp.cpp + * PURPOSE: COM Initialization + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ + +#include "precomp.h" + +const GUID CLSID_DVBTNetworkProvider = {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}}; + +static INTERFACE_TABLE InterfaceTable[] = +{ + {&CLSID_DVBTNetworkProvider, CNetworkProvider_fnConstructor}, + {NULL, NULL} +}; + +extern "C" +BOOL +WINAPI +DllMain( + HINSTANCE hInstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + CoInitialize(NULL); + +#ifdef MSDVBNP_TRACE + OutputDebugStringW(L"MSDVBNP::DllMain()\n"); +#endif + + DisableThreadLibraryCalls(hInstDLL); + break; + default: + break; + } + + return TRUE; +} + + +extern "C" +KSDDKAPI +HRESULT +WINAPI +DllUnregisterServer(void) +{ + return S_OK; +} + +extern "C" +KSDDKAPI +HRESULT +WINAPI +DllRegisterServer(void) +{ + return S_OK; +} + +KSDDKAPI +HRESULT +WINAPI +DllGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID *ppv) +{ + UINT i; + HRESULT hres = E_OUTOFMEMORY; + IClassFactory * pcf = NULL; + + if (!ppv) + return E_INVALIDARG; + + *ppv = NULL; + + for (i = 0; InterfaceTable[i].riid; i++) + { + if (IsEqualIID(*InterfaceTable[i].riid, rclsid)) + { + pcf = CClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); + break; + } + } + + if (!pcf) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + hres = pcf->QueryInterface(riid, ppv); + pcf->Release(); + + return hres; +} + +KSDDKAPI +HRESULT +WINAPI +DllCanUnloadNow(void) +{ + return S_OK; +} diff --git a/reactos/dll/directx/msdvbnp/msdvbnp.rbuild b/reactos/dll/directx/msdvbnp/msdvbnp.rbuild new file mode 100644 index 00000000000..08611a10516 --- /dev/null +++ b/reactos/dll/directx/msdvbnp/msdvbnp.rbuild @@ -0,0 +1,28 @@ + + + + + + . + ntdll + kernel32 + advapi32 + ole32 + advapi32 + msvcrt + strmiids + + -fno-exceptions + -fno-rtti + + + /GR- + + + classfactory.cpp + msdvbnp.cpp + msdvbnp.rc + networkprovider.cpp + scanningtuner.cpp + + diff --git a/reactos/dll/directx/msdvbnp/msdvbnp.rc b/reactos/dll/directx/msdvbnp/msdvbnp.rc new file mode 100644 index 00000000000..7df396e8fdf --- /dev/null +++ b/reactos/dll/directx/msdvbnp/msdvbnp.rc @@ -0,0 +1,12 @@ +#include + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Network Provider for MPEG2 based networks\0" +#define REACTOS_STR_INTERNAL_NAME "MSDvBNP.ax\0" +#define REACTOS_STR_ORIGINAL_FILENAME "MSDvBNP.ax\0" +#define REACTOS_STR_PRODUCT_VERSION "6.5.2600.3264\0" +#define REACTOS_STR_FILE_VERSION "6.5.2600.3264\0" + +#include diff --git a/reactos/dll/directx/msdvbnp/msdvbnp.spec b/reactos/dll/directx/msdvbnp/msdvbnp.spec new file mode 100644 index 00000000000..5baed04ed66 --- /dev/null +++ b/reactos/dll/directx/msdvbnp/msdvbnp.spec @@ -0,0 +1,4 @@ +@ stdcall DllCanUnloadNow() +@ stdcall DllGetClassObject(ptr ptr ptr) +@ stdcall DllRegisterServer() +@ stdcall DllUnregisterServer() diff --git a/reactos/dll/directx/msdvbnp/networkprovider.cpp b/reactos/dll/directx/msdvbnp/networkprovider.cpp new file mode 100644 index 00000000000..ea5ad2b3a94 --- /dev/null +++ b/reactos/dll/directx/msdvbnp/networkprovider.cpp @@ -0,0 +1,350 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/networkprovider.cpp + * PURPOSE: IBDA_NetworkProvider interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CNetworkProvider : public IBaseFilter, + public IAMovieSetup, + public IBDA_NetworkProvider +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + // IBaseFilter methods + HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); + HRESULT STDMETHODCALLTYPE Stop( void); + HRESULT STDMETHODCALLTYPE Pause( void); + HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); + HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State); + HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); + HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **pClock); + HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); + HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); + HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); + HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); + HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); + + //IAMovieSetup methods + HRESULT STDMETHODCALLTYPE Register( void); + HRESULT STDMETHODCALLTYPE Unregister( void); + + //IBDA_NetworkProvider methods + HRESULT STDMETHODCALLTYPE PutSignalSource(ULONG ulSignalSource); + HRESULT STDMETHODCALLTYPE GetSignalSource(ULONG *pulSignalSource); + HRESULT STDMETHODCALLTYPE GetNetworkType(GUID *pguidNetworkType); + HRESULT STDMETHODCALLTYPE PutTuningSpace(REFGUID guidTuningSpace); + HRESULT STDMETHODCALLTYPE GetTuningSpace(GUID *pguidTuingSpace); + HRESULT STDMETHODCALLTYPE RegisterDeviceFilter(IUnknown *pUnkFilterControl, ULONG *ppvRegisitrationContext); + HRESULT STDMETHODCALLTYPE UnRegisterDeviceFilter(ULONG pvRegistrationContext); + + CNetworkProvider() : m_Ref(0), m_pGraph(0){}; + virtual ~CNetworkProvider(){}; + +protected: + LONG m_Ref; + IFilterGraph *m_pGraph; +}; + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IBaseFilter)) + { + *Output = (IBaseFilter*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_ITuner) || + IsEqualGUID(refiid, IID_IScanningTuner)) + { + // construct scanning tuner + return CScanningTunner_fnConstructor(NULL, refiid, Output); + } + + + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CNetworkProvider::QueryInterface: NoInterface for %s", lpstr); + DebugBreak(); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IBaseFilter interface +// + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetClassID( + CLSID *pClassID) +{ + OutputDebugStringW(L"CNetworkProvider::GetClassID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Stop() +{ + OutputDebugStringW(L"CNetworkProvider::Stop : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Pause() +{ + OutputDebugStringW(L"CNetworkProvider::Pause : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Run( + REFERENCE_TIME tStart) +{ + OutputDebugStringW(L"CNetworkProvider::Run : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetState( + DWORD dwMilliSecsTimeout, + FILTER_STATE *State) +{ + OutputDebugStringW(L"CNetworkProvider::GetState : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::SetSyncSource( + IReferenceClock *pClock) +{ + OutputDebugStringW(L"CNetworkProvider::SetSyncSource : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetSyncSource( + IReferenceClock **pClock) +{ + OutputDebugStringW(L"CNetworkProvider::GetSyncSource : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::EnumPins( + IEnumPins **ppEnum) +{ + OutputDebugStringW(L"CNetworkProvider::EnumPins : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::FindPin( + LPCWSTR Id, IPin **ppPin) +{ + OutputDebugStringW(L"CNetworkProvider::FindPin : NotImplemented\n"); + return E_NOTIMPL; +} + + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::QueryFilterInfo( + FILTER_INFO *pInfo) +{ + OutputDebugStringW(L"CNetworkProvider::QueryFilterInfo : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::JoinFilterGraph( + IFilterGraph *pGraph, + LPCWSTR pName) +{ + if (pGraph) + { + // joining filter graph + m_pGraph = pGraph; + } + else + { + // leaving graph + m_pGraph = 0; + } + + OutputDebugStringW(L"CNetworkProvider::JoinFilterGraph\n"); + return S_OK; +} + + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::QueryVendorInfo( + LPWSTR *pVendorInfo) +{ + OutputDebugStringW(L"CNetworkProvider::QueryVendorInfo : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IAMovieSetup interface +// + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Register() +{ + OutputDebugStringW(L"CNetworkProvider::Register : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Unregister() +{ + OutputDebugStringW(L"CNetworkProvider::Unregister : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IBDA_NetworkProvider interface +// + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::PutSignalSource( + ULONG ulSignalSource) +{ + OutputDebugStringW(L"CNetworkProvider::PutSignalSource : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetSignalSource( + ULONG *pulSignalSource) +{ + OutputDebugStringW(L"CNetworkProvider::GetSignalSource : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetNetworkType( + GUID *pguidNetworkType) +{ + OutputDebugStringW(L"CNetworkProvider::GetNetworkType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::PutTuningSpace( + REFGUID guidTuningSpace) +{ + OutputDebugStringW(L"CNetworkProvider::PutTuningSpace : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetTuningSpace( + GUID *pguidTuingSpace) +{ + OutputDebugStringW(L"CNetworkProvider::GetTuningSpace : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::RegisterDeviceFilter( + IUnknown *pUnkFilterControl, + ULONG *ppvRegisitrationContext) +{ + OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::UnRegisterDeviceFilter(ULONG pvRegistrationContext) +{ + OutputDebugStringW(L"CNetworkProvider::UnRegisterDeviceFilter : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CNetworkProvider_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CNetworkProvider * handler = new CNetworkProvider(); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CNetworkProvider_fnConstructor riid %s pUnknown %p", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + OutputDebugStringW(L"CNetworkProvider_fnConstructor Success"); + return NOERROR; +} diff --git a/reactos/dll/directx/msdvbnp/precomp.h b/reactos/dll/directx/msdvbnp/precomp.h new file mode 100644 index 00000000000..0063f51137c --- /dev/null +++ b/reactos/dll/directx/msdvbnp/precomp.h @@ -0,0 +1,54 @@ +#ifndef PRECOMP_H__ +#define PRECOMP_H__ + +#define MSDVBNP_TRACE +#define BUILDING_KS +#define _KSDDK_ +#include +//#include +#include +#define __STREAMS__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); + +typedef struct +{ + const GUID* riid; + LPFNCREATEINSTANCE lpfnCI; +} INTERFACE_TABLE; + +/* classfactory.cpp */ +IClassFactory * +CClassFactory_fnConstructor( + LPFNCREATEINSTANCE lpfnCI, + PLONG pcRefDll, + IID * riidInst); + +/* networkprovider.cpp */ +HRESULT +WINAPI +CNetworkProvider_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + +/* scanningtunner.cpp */ +HRESULT +WINAPI +CScanningTunner_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + + +#endif diff --git a/reactos/dll/directx/msdvbnp/scanningtuner.cpp b/reactos/dll/directx/msdvbnp/scanningtuner.cpp new file mode 100644 index 00000000000..5cc7eeaf6ea --- /dev/null +++ b/reactos/dll/directx/msdvbnp/scanningtuner.cpp @@ -0,0 +1,265 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/networkprovider.cpp + * PURPOSE: IScanningTunner interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CScanningTunner : public IScanningTuner +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + //ITuner methods + HRESULT STDMETHODCALLTYPE get_TuningSpace(ITuningSpace **TuningSpace); + HRESULT STDMETHODCALLTYPE put_TuningSpace(ITuningSpace *TuningSpace); + HRESULT STDMETHODCALLTYPE EnumTuningSpaces(IEnumTuningSpaces **ppEnum); + HRESULT STDMETHODCALLTYPE get_TuneRequest(ITuneRequest **TuneRequest); + HRESULT STDMETHODCALLTYPE put_TuneRequest(ITuneRequest *TuneRequest); + HRESULT STDMETHODCALLTYPE Validate(ITuneRequest *TuneRequest); + HRESULT STDMETHODCALLTYPE get_PreferredComponentTypes(IComponentTypes **ComponentTypes); + HRESULT STDMETHODCALLTYPE put_PreferredComponentTypes(IComponentTypes *ComponentTypes); + HRESULT STDMETHODCALLTYPE get_SignalStrength(long *Strength); + HRESULT STDMETHODCALLTYPE TriggerSignalEvents(long Interval); + + //IScanningTuner methods + HRESULT STDMETHODCALLTYPE SeekUp(); + HRESULT STDMETHODCALLTYPE SeekDown(); + HRESULT STDMETHODCALLTYPE ScanUp(long MillisecondsPause); + HRESULT STDMETHODCALLTYPE ScanDown(long MillisecondsPause); + HRESULT STDMETHODCALLTYPE AutoProgram(); + + CScanningTunner() : m_Ref(0), m_TuningSpace(0){}; + virtual ~CScanningTunner(){}; + +protected: + LONG m_Ref; + ITuningSpace * m_TuningSpace; +}; + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_ITuner)) + { + *Output = (ITuner*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IScanningTuner)) + { + *Output = (IScanningTuner*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CScanningTunner::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +//ITuner +// +HRESULT +STDMETHODCALLTYPE +CScanningTunner::get_TuningSpace( + ITuningSpace **TuningSpace) +{ + OutputDebugStringW(L"CScanningTunner::get_TuningSpace\n"); + + *TuningSpace = m_TuningSpace; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::put_TuningSpace( + ITuningSpace *TuningSpace) +{ + OutputDebugStringW(L"CScanningTunner::put_TuningSpace\n"); + m_TuningSpace = TuningSpace; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::EnumTuningSpaces( + IEnumTuningSpaces **ppEnum) +{ + OutputDebugStringW(L"CScanningTunner::EnumTuningSpaces : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::get_TuneRequest( + ITuneRequest **TuneRequest) +{ + OutputDebugStringW(L"CScanningTunner::get_TuneRequest : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::put_TuneRequest( + ITuneRequest *TuneRequest) +{ + OutputDebugStringW(L"CScanningTunner::put_TuneRequest : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::Validate( + ITuneRequest *TuneRequest) +{ + OutputDebugStringW(L"CScanningTunner::Validate : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::get_PreferredComponentTypes( + IComponentTypes **ComponentTypes) +{ + OutputDebugStringW(L"CScanningTunner::get_PreferredComponentTypes : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::put_PreferredComponentTypes( + IComponentTypes *ComponentTypes) +{ + OutputDebugStringW(L"CScanningTunner::put_PreferredComponentTypes : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::get_SignalStrength( + long *Strength) +{ + OutputDebugStringW(L"CScanningTunner::get_SignalStrength : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::TriggerSignalEvents( + long Interval) +{ + OutputDebugStringW(L"CScanningTunner::TriggerSignalEvents : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +//IScanningTuner +HRESULT +STDMETHODCALLTYPE +CScanningTunner::SeekUp() +{ + OutputDebugStringW(L"CScanningTunner::SeekUp : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::SeekDown() +{ + OutputDebugStringW(L"CScanningTunner::SeekDown : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::ScanUp( + long MillisecondsPause) +{ + OutputDebugStringW(L"CScanningTunner::ScanUp : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::ScanDown( + long MillisecondsPause) +{ + OutputDebugStringW(L"CScanningTunner::ScanDown : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::AutoProgram() +{ + OutputDebugStringW(L"CScanningTunner::AutoProgram : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CScanningTunner_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CScanningTunner * handler = new CScanningTunner(); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CScanningTunner_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/reactos/dll/directx/msvidctl/classfactory.cpp b/reactos/dll/directx/msvidctl/classfactory.cpp new file mode 100644 index 00000000000..8af2a69546f --- /dev/null +++ b/reactos/dll/directx/msvidctl/classfactory.cpp @@ -0,0 +1,106 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/classfactory.cpp + * PURPOSE: ClassFactory interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; +const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; + +class CClassFactory : public IClassFactory +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject); + HRESULT WINAPI LockServer(BOOL fLock); + + CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst) + {}; + + virtual ~CClassFactory(){}; + +protected: + LONG m_Ref; + LPFNCREATEINSTANCE m_lpfnCI; + IID * m_IID; +}; + +HRESULT +WINAPI +CClassFactory::QueryInterface( + REFIID riid, + LPVOID *ppvObj) +{ + *ppvObj = NULL; + if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) + { + *ppvObj = PVOID(this); + InterlockedIncrement(&m_Ref); + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT +WINAPI +CClassFactory::CreateInstance( + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID *ppvObject) +{ + *ppvObject = NULL; + + if ( m_IID == NULL || IsEqualCLSID(riid, *m_IID) || IsEqualCLSID(riid, IID_IUnknown)) + { + return m_lpfnCI(pUnkOuter, riid, ppvObject); + } + + return E_NOINTERFACE; +} + +HRESULT +WINAPI +CClassFactory::LockServer( + BOOL fLock) +{ + return E_NOTIMPL; +} + +IClassFactory * +CClassFactory_fnConstructor( + LPFNCREATEINSTANCE lpfnCI, + PLONG pcRefDll, + IID * riidInst) +{ + CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst); + + if (!factory) + return NULL; + + if (pcRefDll) + InterlockedIncrement(pcRefDll); + + return (LPCLASSFACTORY)factory; +} + diff --git a/reactos/dll/directx/msvidctl/enumtuningspaces.cpp b/reactos/dll/directx/msvidctl/enumtuningspaces.cpp new file mode 100644 index 00000000000..22d3e31bd47 --- /dev/null +++ b/reactos/dll/directx/msvidctl/enumtuningspaces.cpp @@ -0,0 +1,142 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/tuningspace.cpp + * PURPOSE: ITuningSpace interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumTuningSpaces : public IEnumTuningSpaces +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + //delete this; + return 0; + } + return m_Ref; + } + + // IEnumTuningSpaces methods + HRESULT STDMETHODCALLTYPE Next(ULONG celt, ITuningSpace **rgelt, ULONG *pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumTuningSpaces **ppEnum); + + CEnumTuningSpaces() : m_Ref(0){}; + + virtual ~CEnumTuningSpaces(){}; + +protected: + LONG m_Ref; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IEnumTuningSpaces)) + { + *Output = (IEnumTuningSpaces*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumTuningSpaces::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IEnumTuningSpaces +// +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::Next(ULONG celt, ITuningSpace **rgelt, ULONG *pceltFetched) +{ + OutputDebugStringW(L"CEnumTuningSpaces::Next : stub\n"); + return CTuningSpace_fnConstructor(NULL, IID_ITuningSpace, (void**)rgelt); + +} + +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::Skip(ULONG celt) +{ + OutputDebugStringW(L"CEnumTuningSpaces::Skip : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::Reset() +{ + OutputDebugStringW(L"CEnumTuningSpaces::Reset : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::Clone(IEnumTuningSpaces **ppEnum) +{ + OutputDebugStringW(L"CEnumTuningSpaces::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumTuningSpaces_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CEnumTuningSpaces * tuningspaces = new CEnumTuningSpaces(); + +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumTuningSpaces_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!tuningspaces) + return E_OUTOFMEMORY; + + if (FAILED(tuningspaces->QueryInterface(riid, ppv))) + { + /* not supported */ + delete tuningspaces; + return E_NOINTERFACE; + } + + return NOERROR; +} + diff --git a/reactos/dll/directx/msvidctl/msvidctl.cpp b/reactos/dll/directx/msvidctl/msvidctl.cpp new file mode 100644 index 00000000000..b086e59d580 --- /dev/null +++ b/reactos/dll/directx/msvidctl/msvidctl.cpp @@ -0,0 +1,106 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS DVB + * FILE: dll/directx/msvidctl/msvidctl.cpp + * PURPOSE: ReactOS DVB Initialization + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ + +#include "precomp.h" + +static INTERFACE_TABLE InterfaceTable[] = +{ + {&CLSID_SystemTuningSpaces, CTuningSpaceContainer_fnConstructor}, + {NULL, NULL} +}; + +extern "C" +BOOL +WINAPI +DllMain( + HINSTANCE hInstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + CoInitialize(NULL); + +#ifdef MSDVBNP_TRACE + OutputDebugStringW(L"MSVIDCTL::DllMain()\n"); +#endif + + DisableThreadLibraryCalls(hInstDLL); + break; + default: + break; + } + + return TRUE; +} + + +extern "C" +KSDDKAPI +HRESULT +WINAPI +DllUnregisterServer(void) +{ + return S_OK; +} + +extern "C" +KSDDKAPI +HRESULT +WINAPI +DllRegisterServer(void) +{ + return S_OK; +} + +KSDDKAPI +HRESULT +WINAPI +DllGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID *ppv) +{ + UINT i; + HRESULT hres = E_OUTOFMEMORY; + IClassFactory * pcf = NULL; + + if (!ppv) + return E_INVALIDARG; + + *ppv = NULL; + + for (i = 0; InterfaceTable[i].riid; i++) + { + if (IsEqualIID(*InterfaceTable[i].riid, rclsid)) + { + pcf = CClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); + break; + } + } + + if (!pcf) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + hres = pcf->QueryInterface(riid, ppv); + pcf->Release(); + + return hres; +} + +KSDDKAPI +HRESULT +WINAPI +DllCanUnloadNow(void) +{ + return S_OK; +} diff --git a/reactos/dll/directx/msvidctl/msvidctl.rbuild b/reactos/dll/directx/msvidctl/msvidctl.rbuild new file mode 100644 index 00000000000..a3da3fcbe09 --- /dev/null +++ b/reactos/dll/directx/msvidctl/msvidctl.rbuild @@ -0,0 +1,30 @@ + + + + + + . + ntdll + kernel32 + advapi32 + ole32 + advapi32 + msvcrt + strmiids + + -fno-exceptions + -fno-rtti + + + /GR- + + + classfactory.cpp + enumtuningspaces.cpp + msvidctl.cpp + msvidctl.rc + tunerequest.cpp + tuningspace.cpp + tuningspace_container.cpp + + diff --git a/reactos/dll/directx/msvidctl/msvidctl.rc b/reactos/dll/directx/msvidctl/msvidctl.rc new file mode 100644 index 00000000000..43187901fe4 --- /dev/null +++ b/reactos/dll/directx/msvidctl/msvidctl.rc @@ -0,0 +1,12 @@ +#include + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS ActiveX Control for Streaming Video\0" +#define REACTOS_STR_INTERNAL_NAME "MSVidCtl\0" +#define REACTOS_STR_ORIGINAL_FILENAME "MSVidCtl\0" +#define REACTOS_STR_PRODUCT_VERSION "6.05.2600.3264\0" +#define REACTOS_STR_FILE_VERSION "6.05.2600.3264\0" + +#include diff --git a/reactos/dll/directx/msvidctl/msvidctl.spec b/reactos/dll/directx/msvidctl/msvidctl.spec new file mode 100644 index 00000000000..5baed04ed66 --- /dev/null +++ b/reactos/dll/directx/msvidctl/msvidctl.spec @@ -0,0 +1,4 @@ +@ stdcall DllCanUnloadNow() +@ stdcall DllGetClassObject(ptr ptr ptr) +@ stdcall DllRegisterServer() +@ stdcall DllUnregisterServer() diff --git a/reactos/dll/directx/msvidctl/precomp.h b/reactos/dll/directx/msvidctl/precomp.h new file mode 100644 index 00000000000..a5b86272e2d --- /dev/null +++ b/reactos/dll/directx/msvidctl/precomp.h @@ -0,0 +1,72 @@ +#ifndef PRECOMP_H__ +#define PRECOMP_H__ + +#define MSVIDCTL_TRACE +#define BUILDING_KS +#define _KSDDK_ +#include +//#include +#include +#define __STREAMS__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); + +typedef struct +{ + const GUID* riid; + LPFNCREATEINSTANCE lpfnCI; +} INTERFACE_TABLE; + +/* classfactory.cpp */ +IClassFactory * +CClassFactory_fnConstructor( + LPFNCREATEINSTANCE lpfnCI, + PLONG pcRefDll, + IID * riidInst); + +/* tuningspace_container.cpp */ +HRESULT +WINAPI +CTuningSpaceContainer_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + +/* tuningspace.cpp */ +HRESULT +WINAPI +CTuningSpace_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + +/* tunerequest.cpp */ +HRESULT +WINAPI +CTuneRequest_fnConstructor( + IUnknown *pUnknown, + ITuningSpace * TuningSpace, + REFIID riid, + LPVOID * ppv); + +/* enumtuningspaces.cpp */ +HRESULT +WINAPI +CEnumTuningSpaces_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + + + +#endif diff --git a/reactos/dll/directx/msvidctl/tunerequest.cpp b/reactos/dll/directx/msvidctl/tunerequest.cpp new file mode 100644 index 00000000000..3bee7cfc194 --- /dev/null +++ b/reactos/dll/directx/msvidctl/tunerequest.cpp @@ -0,0 +1,331 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/tuningspace.cpp + * PURPOSE: ITuningRequest interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CTuneRequest : public IDVBTuneRequest +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + OutputDebugStringW(L"CTuneRequest::Release : delete\n"); + + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::Release : m_TuningSpace %p delete\n", m_TuningSpace); + OutputDebugStringW(Buffer); + + + m_TuningSpace->Release(); + //delete this; + return 0; + } + return m_Ref; + } + + //IDispatch methods + HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); + HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); + HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); + HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); + + //ITuneRequest methods + HRESULT STDMETHODCALLTYPE get_TuningSpace(ITuningSpace **TuningSpace); + HRESULT STDMETHODCALLTYPE get_Components(IComponents **Components); + HRESULT STDMETHODCALLTYPE Clone(ITuneRequest **NewTuneRequest); + HRESULT STDMETHODCALLTYPE get_Locator(ILocator **Locator); + HRESULT STDMETHODCALLTYPE put_Locator(ILocator *Locator); + + //IDVBTuneRequest methods + HRESULT STDMETHODCALLTYPE get_ONID(long *ONID); + HRESULT STDMETHODCALLTYPE put_ONID(long ONID); + HRESULT STDMETHODCALLTYPE get_TSID(long *TSID); + HRESULT STDMETHODCALLTYPE put_TSID(long TSID); + HRESULT STDMETHODCALLTYPE get_SID(long *SID); + HRESULT STDMETHODCALLTYPE put_SID(long SID); + + CTuneRequest(ITuningSpace * TuningSpace) : m_Ref(0), m_ONID(-1), m_TSID(-1), m_SID(-1), m_Locator(0), m_TuningSpace(TuningSpace) + { + m_TuningSpace->AddRef(); + }; + + CTuneRequest(ITuningSpace * TuningSpace, LONG ONID, LONG TSID, LONG SID, ILocator * Locator) : m_Ref(1), m_ONID(ONID), m_TSID(TSID), m_SID(SID), m_Locator(Locator), m_TuningSpace(TuningSpace) + { + if (m_Locator) + m_Locator->AddRef(); + + m_TuningSpace->AddRef(); + }; + + virtual ~CTuneRequest(){}; + +protected: + LONG m_Ref; + LONG m_ONID; + LONG m_TSID; + LONG m_SID; + ILocator * m_Locator; + ITuningSpace * m_TuningSpace; +}; + + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_ITuneRequest)) + { + *Output = (ITuneRequest*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IDVBTuneRequest)) + { + *Output = (IDVBTuneRequest*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CTuneRequest::QueryInterface: NoInterface for %s", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IDispatch methods +// +HRESULT +STDMETHODCALLTYPE +CTuneRequest::GetTypeInfoCount(UINT *pctinfo) +{ + OutputDebugStringW(L"CTuneRequest::GetTypeInfoCount : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) +{ + OutputDebugStringW(L"CTuneRequest::GetTypeInfo : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuneRequest::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + OutputDebugStringW(L"CTuneRequest::GetIDsOfNames : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuneRequest::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + OutputDebugStringW(L"CTuneRequest::Invoke : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// ITuneRequest interface +// + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_TuningSpace(ITuningSpace **TuningSpace) +{ +#ifdef MSVIDCTL_TRACE + OutputDebugStringW(L"CTuneRequest::get_TuningSpace\n"); +#endif + + *TuningSpace = m_TuningSpace; + m_TuningSpace->AddRef(); + + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_Components(IComponents **Components) +{ + OutputDebugStringW(L"CTuneRequest::get_Components : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::Clone(ITuneRequest **NewTuneRequest) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::Clone %p\n", NewTuneRequest); + OutputDebugStringW(Buffer); +#endif + + *NewTuneRequest = new CTuneRequest(m_TuningSpace, m_ONID, m_TSID, m_SID, m_Locator); + + if (!*NewTuneRequest) + return E_OUTOFMEMORY; + + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_Locator(ILocator **Locator) +{ + OutputDebugStringW(L"CTuneRequest::get_Locator : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::put_Locator(ILocator *Locator) +{ + OutputDebugStringW(L"CTuneRequest::put_Locator : stub\n"); + m_Locator = Locator; + + return S_OK; +} + +//------------------------------------------------------------------- +// IDVBTuneRequest interface +// + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_ONID(long *ONID) +{ +#ifdef MSVIDCTL_TRACE + OutputDebugStringW(L"CTuneRequest::get_ONID\n"); +#endif + + *ONID = m_ONID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::put_ONID(long ONID) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::put_ONID : %lu\n", ONID); + OutputDebugStringW(Buffer); +#endif + + m_ONID = ONID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_TSID(long *TSID) +{ +#ifdef MSVIDCTL_TRACE + OutputDebugStringW(L"CTuneRequest::get_TSID\n"); +#endif + + *TSID = m_TSID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::put_TSID(long TSID) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::put_TSID : %lu\n", TSID); + OutputDebugStringW(Buffer); +#endif + + m_TSID = TSID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_SID(long *SID) +{ +#ifdef MSVIDCTL_TRACE + OutputDebugStringW(L"CTuneRequest::get_SID\n"); +#endif + + *SID = m_SID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::put_SID(long SID) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::put_SID : %lu\n", SID); + OutputDebugStringW(Buffer); +#endif + + m_SID = SID; + return S_OK; +} + +HRESULT +WINAPI +CTuneRequest_fnConstructor( + IUnknown *pUnknown, + ITuningSpace * TuningSpace, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CTuneRequest * request = new CTuneRequest(TuningSpace); + +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CTuneRequest_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!request) + return E_OUTOFMEMORY; + + if (FAILED(request->QueryInterface(riid, ppv))) + { + /* not supported */ + delete request; + return E_NOINTERFACE; + } + + return NOERROR; +} diff --git a/reactos/dll/directx/msvidctl/tuningspace.cpp b/reactos/dll/directx/msvidctl/tuningspace.cpp new file mode 100644 index 00000000000..035542e595d --- /dev/null +++ b/reactos/dll/directx/msvidctl/tuningspace.cpp @@ -0,0 +1,365 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/tuningspace.cpp + * PURPOSE: ITuningSpace interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID CLSID_DVBTNetworkProvider = {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}}; + +class CTuningSpace : public IDVBTuningSpace +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuningSpace::Release : %p Ref %lu\n", this, m_Ref); + OutputDebugStringW(Buffer); + + if (!m_Ref) + { + //delete this; + return 0; + } + return m_Ref; + } + + // IDispatch methods + HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); + HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); + HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); + HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); + + + //ITuningSpace methods + HRESULT STDMETHODCALLTYPE get_UniqueName(BSTR *Name); + HRESULT STDMETHODCALLTYPE put_UniqueName(BSTR Name); + HRESULT STDMETHODCALLTYPE get_FriendlyName(BSTR *Name); + HRESULT STDMETHODCALLTYPE put_FriendlyName(BSTR Name); + HRESULT STDMETHODCALLTYPE get_CLSID(BSTR *SpaceCLSID); + HRESULT STDMETHODCALLTYPE get_NetworkType(BSTR *NetworkTypeGuid); + HRESULT STDMETHODCALLTYPE put_NetworkType(BSTR NetworkTypeGuid); + HRESULT STDMETHODCALLTYPE get__NetworkType(GUID *NetworkTypeGuid); + HRESULT STDMETHODCALLTYPE put__NetworkType(REFCLSID NetworkTypeGuid); + HRESULT STDMETHODCALLTYPE CreateTuneRequest(ITuneRequest **TuneRequest); + HRESULT STDMETHODCALLTYPE EnumCategoryGUIDs(IEnumGUID **ppEnum); + HRESULT STDMETHODCALLTYPE EnumDeviceMonikers(IEnumMoniker **ppEnum); + HRESULT STDMETHODCALLTYPE get_DefaultPreferredComponentTypes(IComponentTypes **ComponentTypes); + HRESULT STDMETHODCALLTYPE put_DefaultPreferredComponentTypes(IComponentTypes *NewComponentTypes); + HRESULT STDMETHODCALLTYPE get_FrequencyMapping(BSTR *pMapping); + HRESULT STDMETHODCALLTYPE put_FrequencyMapping(BSTR Mapping); + HRESULT STDMETHODCALLTYPE get_DefaultLocator(ILocator **LocatorVal); + HRESULT STDMETHODCALLTYPE put_DefaultLocator(ILocator *LocatorVal); + HRESULT STDMETHODCALLTYPE Clone(ITuningSpace **NewTS); + // IDVBTuningSpace + HRESULT STDMETHODCALLTYPE get_SystemType(DVBSystemType *SysType); + HRESULT STDMETHODCALLTYPE put_SystemType(DVBSystemType SysType); + + CTuningSpace() : m_Ref(0){}; + + virtual ~CTuningSpace(){}; + +protected: + LONG m_Ref; +}; + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_ITuningSpace)) + { + *Output = (ITuningSpace*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IDVBTuningSpace)) + { + *Output = (IDVBTuningSpace*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CTuningSpace::QueryInterface: NoInterface for %s", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IDispatch methods +// +HRESULT +STDMETHODCALLTYPE +CTuningSpace::GetTypeInfoCount(UINT *pctinfo) +{ + OutputDebugStringW(L"CTuningSpace::GetTypeInfoCount : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) +{ + OutputDebugStringW(L"CTuningSpace::GetTypeInfo : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpace::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + OutputDebugStringW(L"CTuningSpace::GetIDsOfNames : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpace::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + OutputDebugStringW(L"CTuningSpace::Invoke : NotImplemented\n"); + return E_NOTIMPL; +} + + +//------------------------------------------------------------------- +// ITuningSpace interface +// + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_UniqueName(BSTR *Name) +{ + OutputDebugStringW(L"CTuningSpace::get_UniqueName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_UniqueName(BSTR Name) +{ + OutputDebugStringW(L"CTuningSpace::put_UniqueName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_FriendlyName(BSTR *Name) +{ + OutputDebugStringW(L"CTuningSpace::get_FriendlyName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_FriendlyName(BSTR Name) +{ + OutputDebugStringW(L"CTuningSpace::put_FriendlyName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_CLSID(BSTR *SpaceCLSID) +{ + OutputDebugStringW(L"CTuningSpace::get_CLSID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_NetworkType(BSTR *NetworkTypeGuid) +{ + OutputDebugStringW(L"CTuningSpace::get_NetworkType : stub\n"); + return StringFromCLSID(CLSID_DVBTNetworkProvider, (LPOLESTR*)NetworkTypeGuid); + +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_NetworkType(BSTR NetworkTypeGuid) +{ + OutputDebugStringW(L"CTuningSpace::put_NetworkType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get__NetworkType(GUID *NetworkTypeGuid) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuningSpace::get__NetworkType : %p stub\n", NetworkTypeGuid); + OutputDebugStringW(Buffer); +#endif + + CopyMemory(NetworkTypeGuid, &CLSID_DVBTNetworkProvider, sizeof(GUID)); + OutputDebugStringW(L"CTuningSpace::get__NetworkType : done\n"); + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put__NetworkType(REFCLSID NetworkTypeGuid) +{ + OutputDebugStringW(L"CTuningSpace::put__NetworkType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::CreateTuneRequest(ITuneRequest **TuneRequest) +{ + OutputDebugStringW(L"CTuningSpace::CreateTuneRequest : stub\n"); + return CTuneRequest_fnConstructor(NULL, (ITuningSpace*)this, IID_ITuneRequest, (void**)TuneRequest); +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::EnumCategoryGUIDs(IEnumGUID **ppEnum) +{ + OutputDebugStringW(L"CTuningSpace::EnumCategoryGUIDs : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::EnumDeviceMonikers(IEnumMoniker **ppEnum) +{ + OutputDebugStringW(L"CTuningSpace::EnumDeviceMonikers : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_DefaultPreferredComponentTypes(IComponentTypes **ComponentTypes) +{ + OutputDebugStringW(L"CTuningSpace::get_DefaultPreferredComponentTypes : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_DefaultPreferredComponentTypes(IComponentTypes *NewComponentTypes) +{ + OutputDebugStringW(L"CTuningSpace::put_DefaultPreferredComponentTypes : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_FrequencyMapping(BSTR *pMapping) +{ + OutputDebugStringW(L"CTuningSpace::get_FrequencyMapping : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_FrequencyMapping(BSTR Mapping) +{ + OutputDebugStringW(L"CTuningSpace::put_FrequencyMapping : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_DefaultLocator(ILocator **LocatorVal) +{ + OutputDebugStringW(L"CTuningSpace::get_DefaultLocator : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_DefaultLocator(ILocator *LocatorVal) +{ + OutputDebugStringW(L"CTuningSpace::put_DefaultLocator : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::Clone(ITuningSpace **NewTS) +{ + OutputDebugStringW(L"CTuningSpace::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IDVBTuningSpace +// +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_SystemType(DVBSystemType *SysType) +{ + OutputDebugStringW(L"CTuningSpace::get_SystemType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_SystemType(DVBSystemType SysType) +{ + OutputDebugStringW(L"CTuningSpace::put_SystemType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CTuningSpace_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CTuningSpace * space = new CTuningSpace(); + +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CTuningSpace_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!space) + return E_OUTOFMEMORY; + + if (FAILED(space->QueryInterface(riid, ppv))) + { + /* not supported */ + delete space; + return E_NOINTERFACE; + } + + return NOERROR; +} + + diff --git a/reactos/dll/directx/msvidctl/tuningspace_container.cpp b/reactos/dll/directx/msvidctl/tuningspace_container.cpp new file mode 100644 index 00000000000..e25fdc7a600 --- /dev/null +++ b/reactos/dll/directx/msvidctl/tuningspace_container.cpp @@ -0,0 +1,272 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/tuningspace_container.cpp + * PURPOSE: ITuningSpaceContainer interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#define _FORCENAMELESSUNION +#include "precomp.h" + + +class CTuningSpaceContainer : public ITuningSpaceContainer +{ +public: + + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + OutputDebugStringW(L"CTuningSpaceContainer::Release : delete\n"); + //delete this; + return 0; + } + return m_Ref; + } + + // IDispatch methods + HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); + HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); + HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); + HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); + + //ITuningSpaceContainer methods + HRESULT STDMETHODCALLTYPE get_Count(long *Count); + HRESULT STDMETHODCALLTYPE get__NewEnum(IEnumVARIANT **NewEnum); + HRESULT STDMETHODCALLTYPE get_Item(VARIANT varIndex, ITuningSpace **TuningSpace); + HRESULT STDMETHODCALLTYPE put_Item(VARIANT varIndex, ITuningSpace *TuningSpace); + HRESULT STDMETHODCALLTYPE TuningSpacesForCLSID(BSTR SpaceCLSID, ITuningSpaces **NewColl); + HRESULT STDMETHODCALLTYPE _TuningSpacesForCLSID(REFCLSID SpaceCLSID, ITuningSpaces **NewColl); + HRESULT STDMETHODCALLTYPE TuningSpacesForName(BSTR Name, ITuningSpaces **NewColl); + HRESULT STDMETHODCALLTYPE FindID(ITuningSpace *TuningSpace, long *ID); + HRESULT STDMETHODCALLTYPE Add(ITuningSpace *TuningSpace, VARIANT *NewIndex); + HRESULT STDMETHODCALLTYPE get_EnumTuningSpaces(IEnumTuningSpaces **ppEnum); + HRESULT STDMETHODCALLTYPE Remove(VARIANT Index); + HRESULT STDMETHODCALLTYPE get_MaxCount(long *MaxCount); + HRESULT STDMETHODCALLTYPE put_MaxCount(long MaxCount); + + CTuningSpaceContainer() : m_Ref(0){}; + + virtual ~CTuningSpaceContainer(){}; + +protected: + LONG m_Ref; + +}; + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_ITuningSpaceContainer)) + { + *Output = (ITuningSpaceContainer*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CTuningSpaceContainer::QueryInterface: NoInterface for %s", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IDispatch methods +// +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::GetTypeInfoCount(UINT *pctinfo) +{ + OutputDebugStringW(L"CTuningSpaceContainer::GetTypeInfoCount : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) +{ + OutputDebugStringW(L"CTuningSpaceContainer::GetTypeInfo : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + OutputDebugStringW(L"CTuningSpaceContainer::GetIDsOfNames : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + OutputDebugStringW(L"CTuningSpaceContainer::Invoke : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// ITuningSpaceContainer methods +// + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get_Count(long *Count) +{ + OutputDebugStringW(L"CTuningSpaceContainer::get_Count : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get__NewEnum(IEnumVARIANT **NewEnum) +{ + OutputDebugStringW(L"CTuningSpaceContainer::get__NewEnum : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get_Item(VARIANT varIndex, ITuningSpace **TuningSpace) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuningSpaceContainer::get_Item : type %x value %s stub\n", varIndex.vt, varIndex.bstrVal); + OutputDebugStringW(Buffer); +#endif + + return CTuningSpace_fnConstructor(NULL, IID_ITuningSpace, (void**)TuningSpace); +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::put_Item(VARIANT varIndex, ITuningSpace *TuningSpace) +{ + OutputDebugStringW(L"CTuningSpaceContainer::put_Item : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::TuningSpacesForCLSID(BSTR SpaceCLSID, ITuningSpaces **NewColl) +{ + OutputDebugStringW(L"CTuningSpaceContainer::TuningSpacesForCLSID : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::_TuningSpacesForCLSID(REFCLSID SpaceCLSID, ITuningSpaces **NewColl) +{ + OutputDebugStringW(L"CTuningSpaceContainer::_TuningSpacesForCLSID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::TuningSpacesForName(BSTR Name, ITuningSpaces **NewColl) +{ + OutputDebugStringW(L"CTuningSpaceContainer::TuningSpacesForName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::FindID(ITuningSpace *TuningSpace, long *ID) +{ + OutputDebugStringW(L"CTuningSpaceContainer::FindID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::Add(ITuningSpace *TuningSpace, VARIANT *NewIndex) +{ + OutputDebugStringW(L"CTuningSpaceContainer::Add : stub\n"); + TuningSpace->AddRef(); + NewIndex->vt = VT_BSTR; + InterlockedIncrement(&m_Ref); + return TuningSpace->get_FriendlyName(&NewIndex->bstrVal);; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get_EnumTuningSpaces(IEnumTuningSpaces **ppEnum) +{ + OutputDebugStringW(L"CTuningSpaceContainer::get_EnumTuningSpaces : stub\n"); + return CEnumTuningSpaces_fnConstructor(NULL, IID_IEnumTuningSpaces, (void**)ppEnum); +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::Remove(VARIANT Index) +{ + OutputDebugStringW(L"CTuningSpaceContainer::Remove: NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get_MaxCount(long *MaxCount) +{ + OutputDebugStringW(L"CTuningSpaceContainer::get_MaxCount : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::put_MaxCount(long MaxCount) +{ + OutputDebugStringW(L"CTuningSpaceContainer::put_MaxCount : NotImplemented\n"); + return E_NOTIMPL; +} + + +HRESULT +WINAPI +CTuningSpaceContainer_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CTuningSpaceContainer * provider = new CTuningSpaceContainer(); + +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CTuningSpaceContainer_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!provider) + return E_OUTOFMEMORY; + + if (FAILED(provider->QueryInterface(riid, ppv))) + { + /* not supported */ + delete provider; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file From 23aa06ffce19e556cece24f3608bc24af008da42 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 1 Mar 2010 18:55:11 +0000 Subject: [PATCH 023/211] [DXSDK] - Add BDA types svn path=/trunk/; revision=45747 --- reactos/include/dxsdk/bdamedia.h | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/reactos/include/dxsdk/bdamedia.h b/reactos/include/dxsdk/bdamedia.h index 1a1d88b5a98..3cf12d5617b 100644 --- a/reactos/include/dxsdk/bdamedia.h +++ b/reactos/include/dxsdk/bdamedia.h @@ -317,4 +317,73 @@ typedef enum { }KSPROPERTY_BDA_SIGNAL_STATS; +/* ------------------------------------------------------------ + BDA Stream Format GUIDs +*/ + +#define STATIC_KSDATAFORMAT_TYPE_BDA_ANTENNA\ + 0x71985f41, 0x1ca1, 0x11d3, 0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0 +DEFINE_GUIDSTRUCT("71985F41-1CA1-11d3-9CC8-00C04F7971E0", KSDATAFORMAT_TYPE_BDA_ANTENNA); +#define KSDATAFORMAT_TYPE_BDA_ANTENNA DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_BDA_ANTENNA) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT\ + 0xf4aeb342, 0x0329, 0x4fdd, 0xa8, 0xfd, 0x4a, 0xff, 0x49, 0x26, 0xc9, 0x78 +DEFINE_GUIDSTRUCT("F4AEB342-0329-4fdd-A8FD-4AFF4926C978", KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT); +#define KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT) + + +#define STATIC_KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT\ + 0x8deda6fd, 0xac5f, 0x4334, 0x8e, 0xcf, 0xa4, 0xba, 0x8f, 0xa7, 0xd0, 0xf0 +DEFINE_GUIDSTRUCT("8DEDA6FD-AC5F-4334-8ECF-A4BA8FA7D0F0", KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT); +#define KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT) + + +#define STATIC_KSDATAFORMAT_TYPE_BDA_IF_SIGNAL\ + 0x61be0b47, 0xa5eb, 0x499b, 0x9a, 0x85, 0x5b, 0x16, 0xc0, 0x7f, 0x12, 0x58 +DEFINE_GUIDSTRUCT("61BE0B47-A5EB-499b-9A85-5B16C07F1258", KSDATAFORMAT_TYPE_BDA_IF_SIGNAL); +#define KSDATAFORMAT_TYPE_BDA_IF_SIGNAL DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_BDA_IF_SIGNAL) + + +#define STATIC_KSDATAFORMAT_TYPE_MPEG2_SECTIONS\ + 0x455f176c, 0x4b06, 0x47ce, 0x9a, 0xef, 0x8c, 0xae, 0xf7, 0x3d, 0xf7, 0xb5 +DEFINE_GUIDSTRUCT("455F176C-4B06-47CE-9AEF-8CAEF73DF7B5", KSDATAFORMAT_TYPE_MPEG2_SECTIONS); +#define KSDATAFORMAT_TYPE_MPEG2_SECTIONS DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_MPEG2_SECTIONS) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_ATSC_SI\ + 0xb3c7397c, 0xd303, 0x414d, 0xb3, 0x3c, 0x4e, 0xd2, 0xc9, 0xd2, 0x97, 0x33 +DEFINE_GUIDSTRUCT("B3C7397C-D303-414D-B33C-4ED2C9D29733", KSDATAFORMAT_SUBTYPE_ATSC_SI); +#define KSDATAFORMAT_SUBTYPE_ATSC_SI DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_ATSC_SI) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_DVB_SI\ + 0xe9dd31a3, 0x221d, 0x4adb, 0x85, 0x32, 0x9a, 0xf3, 0x9, 0xc1, 0xa4, 0x8 +DEFINE_GUIDSTRUCT("e9dd31a3-221d-4adb-8532-9af309c1a408", KSDATAFORMAT_SUBTYPE_DVB_SI); +#define KSDATAFORMAT_SUBTYPE_DVB_SI DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_DVB_SI) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_PSIP\ + 0x762e3f66, 0x336f, 0x48d1, 0xbf, 0x83, 0x2b, 0x0, 0x35, 0x2c, 0x11, 0xf0 +DEFINE_GUIDSTRUCT("762E3F66-336F-48d1-BF83-2B00352C11F0", KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_PSIP); +#define KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_PSIP DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_PSIP) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_OOB_PSIP\ + 0x951727db, 0xd2ce, 0x4528, 0x96, 0xf6, 0x33, 0x1, 0xfa, 0xbb, 0x2d, 0xe0 +DEFINE_GUIDSTRUCT("951727DB-D2CE-4528-96F6-3301FABB2DE0", KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_OOB_PSIP); +#define KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_OOB_PSIP DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_OOB_PSIP) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_ISDB_SI\ + 0x4a2eeb99, 0x6458, 0x4538, 0xb1, 0x87, 0x04, 0x01, 0x7c, 0x41, 0x41, 0x3f +DEFINE_GUIDSTRUCT("4a2eeb99-6458-4538-b187-04017c41413f", KSDATAFORMAT_SUBTYPE_ISDB_SI); +#define KSDATAFORMAT_SUBTYPE_ISDB_SI DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_ISDB_SI) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_PBDA_TRANSPORT_RAW\ + 0x0d7aed42, 0xcb9a, 0x11db, 0x97, 0x05, 0x00, 0x50, 0x56, 0xc0, 0x00, 0x08 +DEFINE_GUIDSTRUCT("0d7AED42-CB9A-11DB-9705-005056C00008", KSDATAFORMAT_SUBTYPE_PBDA_TRANSPORT_RAW); +#define KSDATAFORMAT_SUBTYPE_PBDA_TRANSPORT_RAW DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_PBDA_TRANSPORT_RAW) + #endif From 97ba4cfa7edfe34fd4fab67a86cfd5288a707a41 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 1 Mar 2010 18:59:42 +0000 Subject: [PATCH 024/211] [MSDVBNP] - Implement IEnumMediaTypes interface - Implement IEnumPins interface - Partly implement output pin (IPin interface) for the network provider - Implement CNetworkProvider::GetState, CNetworkProvider::SetSyncSource, CNetworkProvider::GetSyncSource, CNetworkProvider::EnumPins, CNetworkProvider::QueryFilterInfo - HACK: comment out deletion of object until reference counting has been fixed svn path=/trunk/; revision=45748 --- .../dll/directx/msdvbnp/enum_mediatypes.cpp | 189 +++++++++++++ reactos/dll/directx/msdvbnp/enumpins.cpp | 175 ++++++++++++ reactos/dll/directx/msdvbnp/msdvbnp.rbuild | 3 + .../dll/directx/msdvbnp/networkprovider.cpp | 61 ++-- reactos/dll/directx/msdvbnp/pin.cpp | 260 ++++++++++++++++++ reactos/dll/directx/msdvbnp/precomp.h | 28 ++ reactos/dll/directx/msdvbnp/scanningtuner.cpp | 3 +- 7 files changed, 700 insertions(+), 19 deletions(-) create mode 100644 reactos/dll/directx/msdvbnp/enum_mediatypes.cpp create mode 100644 reactos/dll/directx/msdvbnp/enumpins.cpp create mode 100644 reactos/dll/directx/msdvbnp/pin.cpp diff --git a/reactos/dll/directx/msdvbnp/enum_mediatypes.cpp b/reactos/dll/directx/msdvbnp/enum_mediatypes.cpp new file mode 100644 index 00000000000..f1497ab737e --- /dev/null +++ b/reactos/dll/directx/msdvbnp/enum_mediatypes.cpp @@ -0,0 +1,189 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/enum_mediatypes.cpp + * PURPOSE: IEnumMediaTypes interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumMediaTypes : public IEnumMediaTypes +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + //delete this; + return 0; + } + return m_Ref; + } + + HRESULT STDMETHODCALLTYPE Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG cMediaTypes); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **ppEnum); + + + CEnumMediaTypes(ULONG MediaTypeCount, AM_MEDIA_TYPE * MediaTypes) : m_Ref(0), m_MediaTypeCount(MediaTypeCount), m_MediaTypes(MediaTypes), m_Index(0){}; + virtual ~CEnumMediaTypes(){}; + +protected: + LONG m_Ref; + ULONG m_MediaTypeCount; + AM_MEDIA_TYPE * m_MediaTypes; + ULONG m_Index; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IEnumMediaTypes)) + { + *Output = (IEnumMediaTypes*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumMediaTypes::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IEnumMediaTypes +// + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Next( + ULONG cMediaTypes, + AM_MEDIA_TYPE **ppMediaTypes, + ULONG *pcFetched) +{ + ULONG i = 0; + AM_MEDIA_TYPE * MediaType; + + if (!ppMediaTypes) + return E_POINTER; + + if (cMediaTypes > 1 && !pcFetched) + return E_INVALIDARG; + + while(i < cMediaTypes) + { + if (m_Index + i >= m_MediaTypeCount) + break; + + MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + if (!MediaType) + break; + + CopyMemory(MediaType, &m_MediaTypes[m_Index + i], sizeof(AM_MEDIA_TYPE)); + ppMediaTypes[i] = MediaType; + i++; + } + + if (pcFetched) + { + *pcFetched = i; + } + + m_Index += i; + + if (i < cMediaTypes) + return S_FALSE; + else + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Skip( + ULONG cMediaTypes) +{ + if (cMediaTypes + m_Index >= m_MediaTypeCount) + { + return S_FALSE; + } + + m_Index += cMediaTypes; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Reset() +{ + m_Index = 0; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Clone( + IEnumMediaTypes **ppEnum) +{ + OutputDebugStringW(L"CEnumMediaTypes::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumMediaTypes_fnConstructor( + IUnknown *pUnknown, + ULONG MediaTypeCount, + AM_MEDIA_TYPE * MediaTypes, + REFIID riid, + LPVOID * ppv) +{ + CEnumMediaTypes * handler = new CEnumMediaTypes(MediaTypeCount, MediaTypes); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumMediaTypes_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + { + CoTaskMemFree(MediaTypes); + return E_OUTOFMEMORY; + } + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} + diff --git a/reactos/dll/directx/msdvbnp/enumpins.cpp b/reactos/dll/directx/msdvbnp/enumpins.cpp new file mode 100644 index 00000000000..3887be48a1f --- /dev/null +++ b/reactos/dll/directx/msdvbnp/enumpins.cpp @@ -0,0 +1,175 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/enumpins.cpp + * PURPOSE: IEnumPins interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumPins : public IEnumPins +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + //delete this; + return 0; + } + return m_Ref; + } + + + HRESULT STDMETHODCALLTYPE Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG cPins); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumPins **ppEnum); + + CEnumPins(ULONG NumPins, IPin ** pins) : m_Ref(0), m_NumPins(NumPins), m_Pins(pins), m_Index(0){}; + virtual ~CEnumPins(){}; + +protected: + LONG m_Ref; + ULONG m_NumPins; + IPin ** m_Pins; + ULONG m_Index; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumPins::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IEnumPins)) + { + *Output = (IEnumPins*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumPins::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Next( + ULONG cPins, + IPin **ppPins, + ULONG *pcFetched) +{ + ULONG i = 0; + + if (!ppPins) + return E_POINTER; + + if (cPins > 1 && !pcFetched) + return E_INVALIDARG; + + while(i < cPins) + { + if (m_Index + i >= m_NumPins) + break; + + ppPins[i] = m_Pins[m_Index + i]; + i++; + } + + if (pcFetched) + { + *pcFetched = i; + } + + m_Index += i; + + if (i < cPins) + return S_FALSE; + else + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Skip( + ULONG cPins) +{ + if (cPins + m_Index >= m_NumPins) + { + return S_FALSE; + } + + m_Index += cPins; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Reset() +{ + m_Index = 0; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Clone( + IEnumPins **ppEnum) +{ + OutputDebugStringW(L"CEnumPins::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumPins_fnConstructor( + IUnknown *pUnknown, + ULONG NumPins, + IPin ** pins, + REFIID riid, + LPVOID * ppv) +{ + CEnumPins * handler = new CEnumPins(NumPins, pins); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumPins_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/reactos/dll/directx/msdvbnp/msdvbnp.rbuild b/reactos/dll/directx/msdvbnp/msdvbnp.rbuild index 08611a10516..6213d7d8f37 100644 --- a/reactos/dll/directx/msdvbnp/msdvbnp.rbuild +++ b/reactos/dll/directx/msdvbnp/msdvbnp.rbuild @@ -20,9 +20,12 @@ classfactory.cpp + enum_mediatypes.cpp + enumpins.cpp msdvbnp.cpp msdvbnp.rc networkprovider.cpp + pin.cpp scanningtuner.cpp diff --git a/reactos/dll/directx/msdvbnp/networkprovider.cpp b/reactos/dll/directx/msdvbnp/networkprovider.cpp index ea5ad2b3a94..aff025f8d50 100644 --- a/reactos/dll/directx/msdvbnp/networkprovider.cpp +++ b/reactos/dll/directx/msdvbnp/networkprovider.cpp @@ -25,7 +25,7 @@ public: InterlockedDecrement(&m_Ref); if (!m_Ref) { - delete this; + //delete this; return 0; } return m_Ref; @@ -58,12 +58,15 @@ public: HRESULT STDMETHODCALLTYPE RegisterDeviceFilter(IUnknown *pUnkFilterControl, ULONG *ppvRegisitrationContext); HRESULT STDMETHODCALLTYPE UnRegisterDeviceFilter(ULONG pvRegistrationContext); - CNetworkProvider() : m_Ref(0), m_pGraph(0){}; + CNetworkProvider() : m_Ref(0), m_pGraph(0), m_ReferenceClock(0), m_FilterState(State_Stopped) {m_Pins[0] = 0;}; virtual ~CNetworkProvider(){}; protected: LONG m_Ref; IFilterGraph *m_pGraph; + IReferenceClock * m_ReferenceClock; + FILTER_STATE m_FilterState; + IPin * m_Pins[1]; }; HRESULT @@ -92,13 +95,10 @@ CNetworkProvider::QueryInterface( return CScanningTunner_fnConstructor(NULL, refiid, Output); } - - WCHAR Buffer[MAX_PATH]; LPOLESTR lpstr; StringFromCLSID(refiid, &lpstr); - swprintf(Buffer, L"CNetworkProvider::QueryInterface: NoInterface for %s", lpstr); - DebugBreak(); + swprintf(Buffer, L"CNetworkProvider::QueryInterface: NoInterface for %s !!!\n", lpstr); OutputDebugStringW(Buffer); CoTaskMemFree(lpstr); @@ -150,8 +150,8 @@ CNetworkProvider::GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State) { - OutputDebugStringW(L"CNetworkProvider::GetState : NotImplemented\n"); - return E_NOTIMPL; + *State = m_FilterState; + return S_OK; } HRESULT @@ -159,8 +159,19 @@ STDMETHODCALLTYPE CNetworkProvider::SetSyncSource( IReferenceClock *pClock) { - OutputDebugStringW(L"CNetworkProvider::SetSyncSource : NotImplemented\n"); - return E_NOTIMPL; + if (pClock) + { + pClock->AddRef(); + + } + + if (m_ReferenceClock) + { + m_ReferenceClock->Release(); + } + + m_ReferenceClock = pClock; + return S_OK; } HRESULT @@ -168,8 +179,14 @@ STDMETHODCALLTYPE CNetworkProvider::GetSyncSource( IReferenceClock **pClock) { - OutputDebugStringW(L"CNetworkProvider::GetSyncSource : NotImplemented\n"); - return E_NOTIMPL; + if (!pClock) + return E_POINTER; + + if (m_ReferenceClock) + m_ReferenceClock->AddRef(); + + *pClock = m_ReferenceClock; + return S_OK; } HRESULT @@ -177,8 +194,14 @@ STDMETHODCALLTYPE CNetworkProvider::EnumPins( IEnumPins **ppEnum) { - OutputDebugStringW(L"CNetworkProvider::EnumPins : NotImplemented\n"); - return E_NOTIMPL; + if (m_Pins[0] == 0) + { + HRESULT hr = CPin_fnConstructor(NULL, (IBaseFilter*)this, IID_IUnknown, (void**)&m_Pins[0]); + if (FAILED(hr)) + return hr; + } + + return CEnumPins_fnConstructor(NULL, 1, m_Pins, IID_IEnumPins, (void**)ppEnum); } HRESULT @@ -196,8 +219,13 @@ STDMETHODCALLTYPE CNetworkProvider::QueryFilterInfo( FILTER_INFO *pInfo) { - OutputDebugStringW(L"CNetworkProvider::QueryFilterInfo : NotImplemented\n"); - return E_NOTIMPL; + if (!pInfo) + return E_POINTER; + + pInfo->achName[0] = L'\0'; + pInfo->pGraph = m_pGraph; + + return S_OK; } HRESULT @@ -325,7 +353,6 @@ CNetworkProvider_fnConstructor( REFIID riid, LPVOID * ppv) { - // construct device control CNetworkProvider * handler = new CNetworkProvider(); #ifdef MSDVBNP_TRACE diff --git a/reactos/dll/directx/msdvbnp/pin.cpp b/reactos/dll/directx/msdvbnp/pin.cpp new file mode 100644 index 00000000000..7ff3ae0dd0b --- /dev/null +++ b/reactos/dll/directx/msdvbnp/pin.cpp @@ -0,0 +1,260 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/pin.cpp + * PURPOSE: IPin interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA = {0x71985f41, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; +const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; +class CPin : public IPin +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + //delete this; + return 0; + } + return m_Ref; + } + + //IPin methods + HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE Disconnect(); + HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); + HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); + HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); + HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); + HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); + HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); + HRESULT STDMETHODCALLTYPE EndOfStream(); + HRESULT STDMETHODCALLTYPE BeginFlush(); + HRESULT STDMETHODCALLTYPE EndFlush(); + HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); + + CPin(IBaseFilter * ParentFilter) : m_Ref(0), m_ParentFilter(ParentFilter){}; + virtual ~CPin(){}; + + static LPCWSTR PIN_ID; + +protected: + LONG m_Ref; + IBaseFilter * m_ParentFilter; +}; + + +LPCWSTR CPin::PIN_ID = L"Antenna Out"; + +HRESULT +STDMETHODCALLTYPE +CPin::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IPin)) + { + *Output = (IPin*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CPin::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IPin interface +// +HRESULT +STDMETHODCALLTYPE +CPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CPin::Connect called\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CPin::ReceiveConnection called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::Disconnect( void) +{ + OutputDebugStringW(L"CPin::Disconnect called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::ConnectedTo(IPin **pPin) +{ + OutputDebugStringW(L"CPin::ConnectedTo called\n"); + return VFW_E_NOT_CONNECTED; +} +HRESULT +STDMETHODCALLTYPE +CPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CPin::ConnectionMediaType called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryPinInfo(PIN_INFO *pInfo) +{ + wcscpy(pInfo->achName, PIN_ID); + pInfo->dir = PINDIR_OUTPUT; + pInfo->pFilter = m_ParentFilter; + + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryDirection(PIN_DIRECTION *pPinDir) +{ + if (pPinDir) + { + *pPinDir = PINDIR_OUTPUT; + return S_OK; + } + + return E_POINTER; +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryId(LPWSTR *Id) +{ + *Id = (LPWSTR)CoTaskMemAlloc(sizeof(PIN_ID)); + if (!*Id) + return E_OUTOFMEMORY; + + wcscpy(*Id, PIN_ID); + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryAccept(const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CPin::QueryAccept called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +{ + AM_MEDIA_TYPE *MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + + if (!MediaType) + { + return E_OUTOFMEMORY; + } + + MediaType->majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA; + MediaType->subtype = GUID_NULL; + MediaType->formattype = GUID_NULL; + MediaType->bFixedSizeSamples = true; + MediaType->bTemporalCompression = false; + MediaType->lSampleSize = sizeof(CHAR); + MediaType->pUnk = NULL; + MediaType->cbFormat = 0; + MediaType->pbFormat = NULL; + + return CEnumMediaTypes_fnConstructor(NULL, 1, MediaType, IID_IEnumMediaTypes, (void**)ppEnum); +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) +{ + OutputDebugStringW(L"CPin::QueryInternalConnections called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::EndOfStream( void) +{ + OutputDebugStringW(L"CPin::EndOfStream called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::BeginFlush( void) +{ + OutputDebugStringW(L"CPin::BeginFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::EndFlush( void) +{ + OutputDebugStringW(L"CPin::EndFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) +{ + OutputDebugStringW(L"CPin::NewSegment called\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CPin_fnConstructor( + IUnknown *pUnknown, + IBaseFilter * ParentFilter, + REFIID riid, + LPVOID * ppv) +{ + CPin * handler = new CPin(ParentFilter); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CPin_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/reactos/dll/directx/msdvbnp/precomp.h b/reactos/dll/directx/msdvbnp/precomp.h index 0063f51137c..d20b9ac9d81 100644 --- a/reactos/dll/directx/msdvbnp/precomp.h +++ b/reactos/dll/directx/msdvbnp/precomp.h @@ -50,5 +50,33 @@ CScanningTunner_fnConstructor( REFIID riid, LPVOID * ppv); +/* enumpins.cpp */ +HRESULT +WINAPI +CEnumPins_fnConstructor( + IUnknown *pUnknown, + ULONG NumPins, + IPin ** pins, + REFIID riid, + LPVOID * ppv); + +/* pin.cpp */ +HRESULT +WINAPI +CPin_fnConstructor( + IUnknown *pUnknown, + IBaseFilter * ParentFilter, + REFIID riid, + LPVOID * ppv); + +/* enum_mediatypes.cpp */ +HRESULT +WINAPI +CEnumMediaTypes_fnConstructor( + IUnknown *pUnknown, + ULONG MediaTypeCount, + AM_MEDIA_TYPE * MediaTypes, + REFIID riid, + LPVOID * ppv); #endif diff --git a/reactos/dll/directx/msdvbnp/scanningtuner.cpp b/reactos/dll/directx/msdvbnp/scanningtuner.cpp index 5cc7eeaf6ea..bcedd51c239 100644 --- a/reactos/dll/directx/msdvbnp/scanningtuner.cpp +++ b/reactos/dll/directx/msdvbnp/scanningtuner.cpp @@ -23,7 +23,7 @@ public: InterlockedDecrement(&m_Ref); if (!m_Ref) { - delete this; + //delete this; return 0; } return m_Ref; @@ -240,7 +240,6 @@ CScanningTunner_fnConstructor( REFIID riid, LPVOID * ppv) { - // construct device control CScanningTunner * handler = new CScanningTunner(); #ifdef MSDVBNP_TRACE From f374476e03efc13a631c196e6bca770e8ab70176 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 1 Mar 2010 20:00:26 +0000 Subject: [PATCH 025/211] [MSDVBNP] - Fix crash when instantiating the filter with graphedt svn path=/trunk/; revision=45749 --- reactos/dll/directx/msdvbnp/networkprovider.cpp | 5 +++-- reactos/dll/directx/msdvbnp/pin.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/reactos/dll/directx/msdvbnp/networkprovider.cpp b/reactos/dll/directx/msdvbnp/networkprovider.cpp index aff025f8d50..926a7516196 100644 --- a/reactos/dll/directx/msdvbnp/networkprovider.cpp +++ b/reactos/dll/directx/msdvbnp/networkprovider.cpp @@ -75,6 +75,8 @@ CNetworkProvider::QueryInterface( IN REFIID refiid, OUT PVOID* Output) { + *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown)) { *Output = PVOID(this); @@ -359,7 +361,7 @@ CNetworkProvider_fnConstructor( WCHAR Buffer[MAX_PATH]; LPOLESTR lpstr; StringFromCLSID(riid, &lpstr); - swprintf(Buffer, L"CNetworkProvider_fnConstructor riid %s pUnknown %p", lpstr, pUnknown); + swprintf(Buffer, L"CNetworkProvider_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); OutputDebugStringW(Buffer); #endif @@ -372,6 +374,5 @@ CNetworkProvider_fnConstructor( delete handler; return E_NOINTERFACE; } - OutputDebugStringW(L"CNetworkProvider_fnConstructor Success"); return NOERROR; } diff --git a/reactos/dll/directx/msdvbnp/pin.cpp b/reactos/dll/directx/msdvbnp/pin.cpp index 7ff3ae0dd0b..52ce7ecb943 100644 --- a/reactos/dll/directx/msdvbnp/pin.cpp +++ b/reactos/dll/directx/msdvbnp/pin.cpp @@ -10,6 +10,7 @@ const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA = {0x71985f41, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; + class CPin : public IPin { public: From 746a02797754b82e52b387b067073036442bdb4a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 11:28:12 +0000 Subject: [PATCH 026/211] [QEDIT] sync qedit to wine 1.1.39 svn path=/trunk/; revision=45752 --- reactos/dll/directx/qedit/samplegrabber.c | 982 +++++++++++++++++++++- 1 file changed, 970 insertions(+), 12 deletions(-) diff --git a/reactos/dll/directx/qedit/samplegrabber.c b/reactos/dll/directx/qedit/samplegrabber.c index 4e80f24f4d5..b4912eb63de 100644 --- a/reactos/dll/directx/qedit/samplegrabber.c +++ b/reactos/dll/directx/qedit/samplegrabber.c @@ -33,19 +33,353 @@ WINE_DEFAULT_DEBUG_CHANNEL(qedit); static WCHAR const vendor_name[] = { 'W', 'i', 'n', 'e', 0 }; +static WCHAR const pin_in_name[] = { 'I', 'n', 0 }; +static WCHAR const pin_out_name[] = { 'O', 'u', 't', 0 }; + +IEnumPins *pinsenum_create(IBaseFilter *filter, IPin **pins, ULONG pinCount); +IEnumMediaTypes *mediaenum_create(AM_MEDIA_TYPE *mtype); + +/* Fixed pins enumerator, holds filter referenced */ +typedef struct _PE_Impl { + IEnumPins pe; + IBaseFilter *filter; + LONG refCount; + ULONG numPins; + ULONG index; + IPin *pins[0]; +} PE_Impl; + + +/* IEnumPins interface implementation */ + +/* IUnknown */ +static ULONG WINAPI +Fixed_IEnumPins_AddRef(IEnumPins *iface) +{ + PE_Impl *This = (PE_Impl *)iface; + ULONG refCount = InterlockedIncrement(&This->refCount); + TRACE("(%p) new ref = %u\n", This, refCount); + return refCount; +} + +/* IUnknown */ +static ULONG WINAPI +Fixed_IEnumPins_Release(IEnumPins *iface) +{ + PE_Impl *This = (PE_Impl *)iface; + ULONG refCount = InterlockedDecrement(&This->refCount); + TRACE("(%p) new ref = %u\n", This, refCount); + if (refCount == 0) + { + IBaseFilter_Release(This->filter); + CoTaskMemFree(This); + return 0; + } + return refCount; +} + +/* IUnknown */ +static HRESULT WINAPI +Fixed_IEnumPins_QueryInterface(IEnumPins *iface, REFIID riid, void **ppvObject) +{ + PE_Impl *This = (PE_Impl *)iface; + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualIID(riid, &IID_IUnknown) || + IsEqualIID(riid, &IID_IEnumPins)) { + Fixed_IEnumPins_AddRef(iface); + *ppvObject = &(This->pins); + return S_OK; + } + *ppvObject = NULL; + WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppvObject); + return E_NOINTERFACE; +} + +/* IEnumPins */ +static HRESULT WINAPI +Fixed_IEnumPins_Next(IEnumPins *iface, ULONG nPins, IPin **pins, ULONG *fetched) +{ + PE_Impl *This = (PE_Impl *)iface; + ULONG count = 0; + TRACE("(%p)->(%u, %p, %p) index = %u\n", This, nPins, pins, fetched, This->index); + if (!nPins) + return E_INVALIDARG; + if (!pins || ((nPins != 1) && !fetched)) + return E_POINTER; + while ((count < nPins) && (This->index < This->numPins)) { + IPin *pin = This->pins[This->index++]; + IPin_AddRef(pin); + pins[count++] = pin; + } + if (fetched) + *fetched = count; + return (count == nPins) ? S_OK : S_FALSE; +} + +/* IEnumPins */ +static HRESULT WINAPI +Fixed_IEnumPins_Skip(IEnumPins *iface, ULONG nPins) +{ + PE_Impl *This = (PE_Impl *)iface; + TRACE("(%p)->(%u) index = %u\n", This, nPins, This->index); + nPins += This->index; + if (nPins >= This->numPins) { + This->index = This->numPins; + return S_FALSE; + } + This->index = nPins; + return S_OK; +} + +/* IEnumPins */ +static HRESULT WINAPI +Fixed_IEnumPins_Reset(IEnumPins *iface) +{ + PE_Impl *This = (PE_Impl *)iface; + TRACE("(%p)->() index = %u\n", This, This->index); + This->index = 0; + return S_OK; +} + +/* IEnumPins */ +static HRESULT WINAPI +Fixed_IEnumPins_Clone(IEnumPins *iface, IEnumPins **pins) +{ + PE_Impl *This = (PE_Impl *)iface; + TRACE("(%p)->(%p) index = %u\n", This, pins, This->index); + if (!pins) + return E_POINTER; + *pins = pinsenum_create(This->filter, This->pins, This->numPins); + if (!*pins) + return E_OUTOFMEMORY; + ((PE_Impl *)*pins)->index = This->index; + return S_OK; +} + + +/* Virtual tables and constructor */ + +static const IEnumPinsVtbl IEnumPins_VTable = +{ + Fixed_IEnumPins_QueryInterface, + Fixed_IEnumPins_AddRef, + Fixed_IEnumPins_Release, + Fixed_IEnumPins_Next, + Fixed_IEnumPins_Skip, + Fixed_IEnumPins_Reset, + Fixed_IEnumPins_Clone, +}; + +IEnumPins *pinsenum_create(IBaseFilter *filter, IPin **pins, ULONG pinCount) +{ + ULONG len = sizeof(PE_Impl) + (pinCount * sizeof(IPin *)); + PE_Impl *obj = CoTaskMemAlloc(len); + if (obj) { + ULONG i; + ZeroMemory(obj, len); + obj->pe.lpVtbl = &IEnumPins_VTable; + obj->refCount = 1; + obj->filter = filter; + obj->numPins = pinCount; + obj->index = 0; + for (i=0; ipins[i] = pins[i]; + IBaseFilter_AddRef(filter); + } + return &obj->pe; +} + + +/* Single media type enumerator */ +typedef struct _ME_Impl { + IEnumMediaTypes me; + LONG refCount; + BOOL past; + AM_MEDIA_TYPE mtype; +} ME_Impl; + + +/* IEnumMediaTypes interface implementation */ + +/* IUnknown */ +static ULONG WINAPI +Single_IEnumMediaTypes_AddRef(IEnumMediaTypes *iface) +{ + ME_Impl *This = (ME_Impl *)iface; + ULONG refCount = InterlockedIncrement(&This->refCount); + TRACE("(%p) new ref = %u\n", This, refCount); + return refCount; +} + +/* IUnknown */ +static ULONG WINAPI +Single_IEnumMediaTypes_Release(IEnumMediaTypes *iface) +{ + ME_Impl *This = (ME_Impl *)iface; + ULONG refCount = InterlockedDecrement(&This->refCount); + TRACE("(%p) new ref = %u\n", This, refCount); + if (refCount == 0) + { + if (This->mtype.pbFormat) + CoTaskMemFree(This->mtype.pbFormat); + CoTaskMemFree(This); + return 0; + } + return refCount; +} + +/* IUnknown */ +static HRESULT WINAPI +Single_IEnumMediaTypes_QueryInterface(IEnumMediaTypes *iface, REFIID riid, void **ppvObject) +{ + ME_Impl *This = (ME_Impl *)iface; + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualIID(riid, &IID_IUnknown) || + IsEqualIID(riid, &IID_IEnumMediaTypes)) { + Single_IEnumMediaTypes_AddRef(iface); + *ppvObject = &(This->me); + return S_OK; + } + *ppvObject = NULL; + WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppvObject); + return E_NOINTERFACE; +} + +/* IEnumMediaTypes */ +static HRESULT WINAPI +Single_IEnumMediaTypes_Next(IEnumMediaTypes *iface, ULONG nTypes, AM_MEDIA_TYPE **types, ULONG *fetched) +{ + ME_Impl *This = (ME_Impl *)iface; + ULONG count = 0; + TRACE("(%p)->(%u, %p, %p)\n", This, nTypes, types, fetched); + if (!nTypes) + return E_INVALIDARG; + if (!types || ((nTypes != 1) && !fetched)) + return E_POINTER; + if (!This->past) { + AM_MEDIA_TYPE *mtype = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + *mtype = This->mtype; + if (mtype->cbFormat) { + mtype->pbFormat = CoTaskMemAlloc(mtype->cbFormat); + CopyMemory(mtype->pbFormat, This->mtype.pbFormat, mtype->cbFormat); + } + *types = mtype; + This->past = TRUE; + count = 1; + } + if (fetched) + *fetched = count; + return (count == nTypes) ? S_OK : S_FALSE; +} + +/* IEnumMediaTypes */ +static HRESULT WINAPI +Single_IEnumMediaTypes_Skip(IEnumMediaTypes *iface, ULONG nTypes) +{ + ME_Impl *This = (ME_Impl *)iface; + TRACE("(%p)->(%u)\n", This, nTypes); + if (nTypes) + This->past = TRUE; + return This->past ? S_FALSE : S_OK; +} + +/* IEnumMediaTypes */ +static HRESULT WINAPI +Single_IEnumMediaTypes_Reset(IEnumMediaTypes *iface) +{ + ME_Impl *This = (ME_Impl *)iface; + TRACE("(%p)->()\n", This); + This->past = FALSE; + return S_OK; +} + +/* IEnumMediaTypes */ +static HRESULT WINAPI +Single_IEnumMediaTypes_Clone(IEnumMediaTypes *iface, IEnumMediaTypes **me) +{ + ME_Impl *This = (ME_Impl *)iface; + TRACE("(%p)->(%p)\n", This, me); + if (!me) + return E_POINTER; + *me = mediaenum_create(&This->mtype); + if (!*me) + return E_OUTOFMEMORY; + ((ME_Impl *)*me)->past = This->past; + return S_OK; +} + + +/* Virtual tables and constructor */ + +static const IEnumMediaTypesVtbl IEnumMediaTypes_VTable = +{ + Single_IEnumMediaTypes_QueryInterface, + Single_IEnumMediaTypes_AddRef, + Single_IEnumMediaTypes_Release, + Single_IEnumMediaTypes_Next, + Single_IEnumMediaTypes_Skip, + Single_IEnumMediaTypes_Reset, + Single_IEnumMediaTypes_Clone, +}; + +IEnumMediaTypes *mediaenum_create(AM_MEDIA_TYPE *mtype) +{ + ME_Impl *obj = CoTaskMemAlloc(sizeof(ME_Impl)); + if (obj) { + ZeroMemory(obj, sizeof(ME_Impl)); + obj->me.lpVtbl = &IEnumMediaTypes_VTable; + obj->refCount = 1; + obj->past = FALSE; + obj->mtype = *mtype; + obj->mtype.pUnk = NULL; + if (mtype->cbFormat) { + obj->mtype.pbFormat = CoTaskMemAlloc(mtype->cbFormat); + CopyMemory(obj->mtype.pbFormat, mtype->pbFormat, mtype->cbFormat); + } + else + obj->mtype.pbFormat = NULL; + } + return &obj->me; +} + + +/* Sample Grabber pin implementation */ +typedef struct _SG_Pin { + const IPinVtbl* lpVtbl; + PIN_DIRECTION dir; + WCHAR const *name; + struct _SG_Impl *sg; + IPin *pair; +} SG_Pin; /* Sample Grabber filter implementation */ typedef struct _SG_Impl { const IBaseFilterVtbl* IBaseFilter_Vtbl; const ISampleGrabberVtbl* ISampleGrabber_Vtbl; + const IMemInputPinVtbl* IMemInputPin_Vtbl; /* TODO: IMediaPosition, IMediaSeeking, IQualityControl */ LONG refCount; FILTER_INFO info; FILTER_STATE state; + AM_MEDIA_TYPE mtype; + SG_Pin pin_in; + SG_Pin pin_out; IMemAllocator *allocator; IReferenceClock *refClock; + IMemInputPin *memOutput; + ISampleGrabberCB *grabberIface; + LONG grabberMethod; + LONG oneShot; } SG_Impl; +enum { + OneShot_None, + OneShot_Wait, + OneShot_Past, +}; + /* Get the SampleGrabber implementation This pointer from various interface pointers */ static inline SG_Impl *impl_from_IBaseFilter(IBaseFilter *iface) { @@ -57,6 +391,11 @@ static inline SG_Impl *impl_from_ISampleGrabber(ISampleGrabber *iface) return (SG_Impl *)((char*)iface - FIELD_OFFSET(SG_Impl, ISampleGrabber_Vtbl)); } +static inline SG_Impl *impl_from_IMemInputPin(IMemInputPin *iface) +{ + return (SG_Impl *)((char*)iface - FIELD_OFFSET(SG_Impl, IMemInputPin_Vtbl)); +} + /* Cleanup at end of life */ static void SampleGrabber_cleanup(SG_Impl *This) @@ -68,6 +407,12 @@ static void SampleGrabber_cleanup(SG_Impl *This) IMemAllocator_Release(This->allocator); if (This->refClock) IReferenceClock_Release(This->refClock); + if (This->memOutput) + IMemInputPin_Release(This->memOutput); + if (This->grabberIface) + ISampleGrabberCB_Release(This->grabberIface); + if (This->mtype.pbFormat) + CoTaskMemFree(This->mtype.pbFormat); } /* Common helper AddRef called from all interfaces */ @@ -110,8 +455,11 @@ static HRESULT SampleGrabber_query(SG_Impl *This, REFIID riid, void **ppvObject) *ppvObject = &(This->ISampleGrabber_Vtbl); return S_OK; } - else if (IsEqualIID(riid, &IID_IMemInputPin)) - FIXME("IMemInputPin not implemented\n"); + else if (IsEqualIID(riid, &IID_IMemInputPin)) { + SampleGrabber_addref(This); + *ppvObject = &(This->IMemInputPin_Vtbl); + return S_OK; + } else if (IsEqualIID(riid, &IID_IMediaPosition)) FIXME("IMediaPosition not implemented\n"); else if (IsEqualIID(riid, &IID_IMediaSeeking)) @@ -123,6 +471,45 @@ static HRESULT SampleGrabber_query(SG_Impl *This, REFIID riid, void **ppvObject) return E_NOINTERFACE; } +/* Helper that calls installed sample callbacks */ +static void SampleGrabber_callback(SG_Impl *This, IMediaSample *sample) +{ + double time = 0.0; + REFERENCE_TIME tStart, tEnd; + if (SUCCEEDED(IMediaSample_GetTime(sample, &tStart, &tEnd))) + time = 1e-7 * tStart; + switch (This->grabberMethod) { + case 0: + { + ULONG ref = IMediaSample_AddRef(sample); + ISampleGrabberCB_SampleCB(This->grabberIface, time, sample); + ref = IMediaSample_Release(sample) + 1 - ref; + if (ref) + { + ERR("(%p) Callback referenced sample %p by %u\n", This, sample, ref); + /* ugly as hell but some apps are sooo buggy */ + while (ref--) + IMediaSample_Release(sample); + } + } + break; + case 1: + { + BYTE *data = 0; + long size = IMediaSample_GetActualDataLength(sample); + if (size && SUCCEEDED(IMediaSample_GetPointer(sample, &data)) && data) + ISampleGrabberCB_BufferCB(This->grabberIface, time, data, size); + } + break; + case -1: + break; + default: + FIXME("unsupported method %ld\n", (long int)This->grabberMethod); + /* do not bother us again */ + This->grabberMethod = -1; + } +} + /* SampleGrabber implementation of IBaseFilter interface */ @@ -236,10 +623,14 @@ static HRESULT WINAPI SampleGrabber_IBaseFilter_EnumPins(IBaseFilter *iface, IEnumPins **pins) { SG_Impl *This = impl_from_IBaseFilter(iface); - FIXME("(%p)->(%p): stub\n", This, pins); + IPin *pin[2]; + TRACE("(%p)->(%p)\n", This, pins); if (!pins) return E_POINTER; - return E_OUTOFMEMORY; + pin[0] = (IPin*)&This->pin_in.lpVtbl; + pin[1] = (IPin*)&This->pin_out.lpVtbl; + *pins = pinsenum_create(iface, pin, 2); + return *pins ? S_OK : E_OUTOFMEMORY; } /* IBaseFilter */ @@ -247,9 +638,21 @@ static HRESULT WINAPI SampleGrabber_IBaseFilter_FindPin(IBaseFilter *iface, LPCWSTR id, IPin **pin) { SG_Impl *This = impl_from_IBaseFilter(iface); - FIXME("(%p)->(%s, %p): stub\n", This, debugstr_w(id), pin); + TRACE("(%p)->(%s, %p)\n", This, debugstr_w(id), pin); if (!id || !pin) return E_POINTER; + if (!lstrcmpiW(id,pin_in_name)) + { + SampleGrabber_addref(This); + *pin = (IPin*)&(This->pin_in.lpVtbl); + return S_OK; + } + else if (!lstrcmpiW(id,pin_out_name)) + { + SampleGrabber_addref(This); + *pin = (IPin*)&(This->pin_out.lpVtbl); + return S_OK; + } *pin = NULL; return VFW_E_NOT_FOUND; } @@ -277,6 +680,7 @@ SampleGrabber_IBaseFilter_JoinFilterGraph(IBaseFilter *iface, IFilterGraph *grap This->info.pGraph = graph; if (name) lstrcpynW(This->info.achName,name,MAX_FILTER_NAME); + This->oneShot = OneShot_None; return S_OK; } @@ -321,8 +725,9 @@ static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetOneShot(ISampleGrabber *iface, BOOL oneShot) { SG_Impl *This = impl_from_ISampleGrabber(iface); - FIXME("(%p)->(%u): stub\n", This, oneShot); - return E_NOTIMPL; + TRACE("(%p)->(%u)\n", This, oneShot); + This->oneShot = oneShot ? OneShot_Wait : OneShot_None; + return S_OK; } /* ISampleGrabber */ @@ -330,10 +735,24 @@ static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetMediaType(ISampleGrabber *iface, const AM_MEDIA_TYPE *type) { SG_Impl *This = impl_from_ISampleGrabber(iface); - FIXME("(%p)->(%p): stub\n", This, type); + TRACE("(%p)->(%p)\n", This, type); if (!type) return E_POINTER; - return E_NOTIMPL; + TRACE("Media type: %s/%s ssize: %u format: %s (%u bytes)\n", + debugstr_guid(&type->majortype), debugstr_guid(&type->subtype), + type->lSampleSize, + debugstr_guid(&type->formattype), type->cbFormat); + if (This->mtype.pbFormat) + CoTaskMemFree(This->mtype.pbFormat); + This->mtype = *type; + This->mtype.pUnk = NULL; + if (type->cbFormat) { + This->mtype.pbFormat = CoTaskMemAlloc(type->cbFormat); + CopyMemory(This->mtype.pbFormat, type->pbFormat, type->cbFormat); + } + else + This->mtype.pbFormat = NULL; + return S_OK; } /* ISampleGrabber */ @@ -341,10 +760,17 @@ static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetConnectedMediaType(ISampleGrabber *iface, AM_MEDIA_TYPE *type) { SG_Impl *This = impl_from_ISampleGrabber(iface); - FIXME("(%p)->(%p): stub\n", This, type); + TRACE("(%p)->(%p)\n", This, type); if (!type) return E_POINTER; - return E_NOTIMPL; + if (!This->pin_in.pair) + return VFW_E_NOT_CONNECTED; + *type = This->mtype; + if (type->cbFormat) { + type->pbFormat = CoTaskMemAlloc(type->cbFormat); + CopyMemory(type->pbFormat, This->mtype.pbFormat, type->cbFormat); + } + return S_OK; } /* ISampleGrabber */ @@ -383,10 +809,467 @@ static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetCallback(ISampleGrabber *iface, ISampleGrabberCB *cb, LONG whichMethod) { SG_Impl *This = impl_from_ISampleGrabber(iface); - FIXME("(%p)->(%p, %u): stub\n", This, cb, whichMethod); + TRACE("(%p)->(%p, %u)\n", This, cb, whichMethod); + if (This->grabberIface) + ISampleGrabberCB_Release(This->grabberIface); + This->grabberIface = cb; + This->grabberMethod = whichMethod; + if (cb) + ISampleGrabberCB_AddRef(cb); + return S_OK; +} + + +/* SampleGrabber implementation of IMemInputPin interface */ + +/* IUnknown */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_QueryInterface(IMemInputPin *iface, REFIID riid, void **ppvObject) +{ + return SampleGrabber_query(impl_from_IMemInputPin(iface), riid, ppvObject); +} + +/* IUnknown */ +static ULONG WINAPI +SampleGrabber_IMemInputPin_AddRef(IMemInputPin *iface) +{ + return SampleGrabber_addref(impl_from_IMemInputPin(iface)); +} + +/* IUnknown */ +static ULONG WINAPI +SampleGrabber_IMemInputPin_Release(IMemInputPin *iface) +{ + return SampleGrabber_release(impl_from_IMemInputPin(iface)); +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_GetAllocator(IMemInputPin *iface, IMemAllocator **allocator) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + TRACE("(%p)->(%p) allocator = %p\n", This, allocator, This->allocator); + if (!allocator) + return E_POINTER; + *allocator = This->allocator; + if (!*allocator) + return VFW_E_NO_ALLOCATOR; + IMemAllocator_AddRef(*allocator); + return S_OK; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_NotifyAllocator(IMemInputPin *iface, IMemAllocator *allocator, BOOL readOnly) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + TRACE("(%p)->(%p, %u) allocator = %p\n", This, allocator, readOnly, This->allocator); + if (This->allocator == allocator) + return S_OK; + if (This->allocator) + IMemAllocator_Release(This->allocator); + This->allocator = allocator; + if (allocator) + IMemAllocator_AddRef(allocator); + return S_OK; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_GetAllocatorRequirements(IMemInputPin *iface, ALLOCATOR_PROPERTIES *props) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + FIXME("(%p)->(%p): semi-stub\n", This, props); + if (!props) + return E_POINTER; + return This->memOutput ? IMemInputPin_GetAllocatorRequirements(This->memOutput, props) : E_NOTIMPL; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_Receive(IMemInputPin *iface, IMediaSample *sample) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + HRESULT hr; + TRACE("(%p)->(%p) output = %p, grabber = %p\n", This, sample, This->memOutput, This->grabberIface); + if (!sample) + return E_POINTER; + if ((This->state != State_Running) || (This->oneShot == OneShot_Past)) + return S_FALSE; + if (This->grabberIface) + SampleGrabber_callback(This, sample); + hr = This->memOutput ? IMemInputPin_Receive(This->memOutput, sample) : S_OK; + if (This->oneShot == OneShot_Wait) { + This->oneShot = OneShot_Past; + hr = S_FALSE; + if (This->pin_out.pair) + IPin_EndOfStream(This->pin_out.pair); + } + return hr; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_ReceiveMultiple(IMemInputPin *iface, IMediaSample **samples, LONG nSamples, LONG *nProcessed) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + TRACE("(%p)->(%p, %u, %p) output = %p, grabber = %p\n", This, samples, nSamples, nProcessed, This->memOutput, This->grabberIface); + if (!samples || !nProcessed) + return E_POINTER; + if ((This->state != State_Running) || (This->oneShot == OneShot_Past)) + return S_FALSE; + if (This->grabberIface) { + LONG idx; + for (idx = 0; idx < nSamples; idx++) + SampleGrabber_callback(This, samples[idx]); + } + return This->memOutput ? IMemInputPin_ReceiveMultiple(This->memOutput, samples, nSamples, nProcessed) : S_OK; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_ReceiveCanBlock(IMemInputPin *iface) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + TRACE("(%p)\n", This); + return This->memOutput ? IMemInputPin_ReceiveCanBlock(This->memOutput) : S_OK; +} + + +/* SampleGrabber member pin implementation */ + +/* IUnknown */ +static ULONG WINAPI +SampleGrabber_IPin_AddRef(IPin *iface) +{ + return SampleGrabber_addref(((SG_Pin *)iface)->sg); +} + +/* IUnknown */ +static ULONG WINAPI +SampleGrabber_IPin_Release(IPin *iface) +{ + return SampleGrabber_release(((SG_Pin *)iface)->sg); +} + +/* IUnknown */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryInterface(IPin *iface, REFIID riid, void **ppvObject) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualIID(riid, &IID_IUnknown) || + IsEqualIID(riid, &IID_IPin)) { + SampleGrabber_addref(This->sg); + *ppvObject = This; + return S_OK; + } + else if (IsEqualIID(riid, &IID_IMemInputPin)) { + SampleGrabber_addref(This->sg); + *ppvObject = &(This->sg->IMemInputPin_Vtbl); + return S_OK; + } + *ppvObject = NULL; + WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppvObject); + return E_NOINTERFACE; +} + +/* IPin - input pin */ +static HRESULT WINAPI +SampleGrabber_In_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE *mtype) +{ + WARN("(%p, %p): unexpected\n", receiver, mtype); + return E_UNEXPECTED; +} + +/* IPin - output pin */ +static HRESULT WINAPI +SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE *type) +{ + SG_Pin *This = (SG_Pin *)iface; + HRESULT hr; + TRACE("(%p)->(%p, %p)\n", This, receiver, type); + if (!receiver) + return E_POINTER; + if (This->pair) + return VFW_E_ALREADY_CONNECTED; + if (This->sg->state != State_Stopped) + return VFW_E_NOT_STOPPED; + if (type) { + TRACE("Media type: %s/%s ssize: %u format: %s (%u bytes)\n", + debugstr_guid(&type->majortype), debugstr_guid(&type->subtype), + type->lSampleSize, + debugstr_guid(&type->formattype), type->cbFormat); + if (!IsEqualGUID(&This->sg->mtype.majortype,&GUID_NULL) && + !IsEqualGUID(&This->sg->mtype.majortype,&type->majortype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&This->sg->mtype.subtype,&MEDIASUBTYPE_None) && + !IsEqualGUID(&This->sg->mtype.subtype,&type->subtype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&This->sg->mtype.formattype,&GUID_NULL) && + !IsEqualGUID(&This->sg->mtype.formattype,&FORMAT_None) && + !IsEqualGUID(&This->sg->mtype.formattype,&type->formattype)) + return VFW_E_TYPE_NOT_ACCEPTED; + } + else + type = &This->sg->mtype; + hr = IPin_ReceiveConnection(receiver,(IPin*)&This->lpVtbl,type); + if (FAILED(hr)) + return hr; + This->pair = receiver; + if (This->sg->memOutput) { + IMemInputPin_Release(This->sg->memOutput); + This->sg->memOutput = NULL; + } + IPin_QueryInterface(receiver,&IID_IMemInputPin,(void **)&(This->sg->memOutput)); + TRACE("(%p) Accepted IPin %p, IMemInputPin %p\n", This, receiver, This->sg->memOutput); + return S_OK; +} + +/* IPin - input pin */ +static HRESULT WINAPI +SampleGrabber_In_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_MEDIA_TYPE *type) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p, %p)\n", This, connector, type); + if (!connector) + return E_POINTER; + if (This->pair) + return VFW_E_ALREADY_CONNECTED; + if (This->sg->state != State_Stopped) + return VFW_E_NOT_STOPPED; + if (type) { + TRACE("Media type: %s/%s ssize: %u format: %s (%u bytes)\n", + debugstr_guid(&type->majortype), debugstr_guid(&type->subtype), + type->lSampleSize, + debugstr_guid(&type->formattype), type->cbFormat); + if (!IsEqualGUID(&This->sg->mtype.majortype,&GUID_NULL) && + !IsEqualGUID(&This->sg->mtype.majortype,&type->majortype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&This->sg->mtype.subtype,&MEDIASUBTYPE_None) && + !IsEqualGUID(&This->sg->mtype.subtype,&type->subtype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&This->sg->mtype.formattype,&GUID_NULL) && + !IsEqualGUID(&This->sg->mtype.formattype,&FORMAT_None) && + !IsEqualGUID(&This->sg->mtype.formattype,&type->formattype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (This->sg->mtype.pbFormat) + CoTaskMemFree(This->sg->mtype.pbFormat); + This->sg->mtype = *type; + This->sg->mtype.pUnk = NULL; + if (type->cbFormat) { + This->sg->mtype.pbFormat = CoTaskMemAlloc(type->cbFormat); + CopyMemory(This->sg->mtype.pbFormat, type->pbFormat, type->cbFormat); + } + else + This->sg->mtype.pbFormat = NULL; + } + This->pair = connector; + TRACE("(%p) Accepted IPin %p\n", This, connector); + return S_OK; +} + +/* IPin - output pin */ +static HRESULT WINAPI +SampleGrabber_Out_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_MEDIA_TYPE *mtype) +{ + WARN("(%p, %p): unexpected\n", connector, mtype); + return E_UNEXPECTED; +} + +/* IPin - input pin */ +static HRESULT WINAPI +SampleGrabber_In_IPin_Disconnect(IPin *iface) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->() pair = %p\n", This, This->pair); + if (This->sg->state != State_Stopped) + return VFW_E_NOT_STOPPED; + if (This->pair) { + This->pair = NULL; + return S_OK; + } + return S_FALSE; +} + +/* IPin - output pin */ +static HRESULT WINAPI +SampleGrabber_Out_IPin_Disconnect(IPin *iface) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->() pair = %p\n", This, This->pair); + if (This->sg->state != State_Stopped) + return VFW_E_NOT_STOPPED; + if (This->pair) { + This->pair = NULL; + if (This->sg->memOutput) { + IMemInputPin_Release(This->sg->memOutput); + This->sg->memOutput = NULL; + } + return S_OK; + } + return S_FALSE; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_ConnectedTo(IPin *iface, IPin **pin) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p) pair = %p\n", This, pin, This->pair); + if (!pin) + return E_POINTER; + *pin = This->pair; + if (*pin) { + IPin_AddRef(*pin); + return S_OK; + } + return VFW_E_NOT_CONNECTED; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *mtype) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p)\n", This, mtype); + if (!mtype) + return E_POINTER; + if (!This->pair) + return VFW_E_NOT_CONNECTED; + *mtype = This->sg->mtype; + if (mtype->cbFormat) { + mtype->pbFormat = CoTaskMemAlloc(mtype->cbFormat); + CopyMemory(mtype->pbFormat, This->sg->mtype.pbFormat, mtype->cbFormat); + } + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryPinInfo(IPin *iface, PIN_INFO *info) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p)\n", This, info); + if (!info) + return E_POINTER; + SampleGrabber_addref(This->sg); + info->pFilter = (IBaseFilter *)This->sg; + info->dir = This->dir; + lstrcpynW(info->achName,This->name,MAX_PIN_NAME); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryDirection(IPin *iface, PIN_DIRECTION *dir) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p)\n", This, dir); + if (!dir) + return E_POINTER; + *dir = This->dir; + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryId(IPin *iface, LPWSTR *id) +{ + SG_Pin *This = (SG_Pin *)iface; + int len; + TRACE("(%p)->(%p)\n", This, id); + if (!id) + return E_POINTER; + len = sizeof(WCHAR)*(1+lstrlenW(This->name)); + *id = CoTaskMemAlloc(len); + CopyMemory(*id, This->name, len); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mtype) +{ + TRACE("(%p)\n", mtype); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **mtypes) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p)\n", This, mtypes); + if (!mtypes) + return E_POINTER; + *mtypes = mediaenum_create(&This->sg->mtype); + return *mtypes ? S_OK : E_OUTOFMEMORY; +} + +/* IPin - input pin */ +static HRESULT WINAPI +SampleGrabber_In_IPin_QueryInternalConnections(IPin *iface, IPin **pins, ULONG *nPins) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p, %p) size = %u\n", This, pins, nPins, (nPins ? *nPins : 0)); + if (!nPins) + return E_POINTER; + if (*nPins) { + if (!pins) + return E_POINTER; + IPin_AddRef((IPin*)&This->sg->pin_out.lpVtbl); + *pins = (IPin*)&This->sg->pin_out.lpVtbl; + *nPins = 1; + return S_OK; + } + *nPins = 1; + return S_FALSE; +} + +/* IPin - output pin */ +static HRESULT WINAPI +SampleGrabber_Out_IPin_QueryInternalConnections(IPin *iface, IPin **pins, ULONG *nPins) +{ + WARN("(%p, %p): unexpected\n", pins, nPins); + if (nPins) + *nPins = 0; return E_NOTIMPL; } +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_EndOfStream(IPin *iface) +{ + FIXME(": stub\n"); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_BeginFlush(IPin *iface) +{ + FIXME(": stub\n"); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_EndFlush(IPin *iface) +{ + FIXME(": stub\n"); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_NewSegment(IPin *iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double rate) +{ + FIXME(": stub\n"); + return S_OK; +} + /* SampleGrabber vtables and constructor */ @@ -423,6 +1306,63 @@ static const ISampleGrabberVtbl ISampleGrabber_VTable = SampleGrabber_ISampleGrabber_SetCallback, }; +static const IMemInputPinVtbl IMemInputPin_VTable = +{ + SampleGrabber_IMemInputPin_QueryInterface, + SampleGrabber_IMemInputPin_AddRef, + SampleGrabber_IMemInputPin_Release, + SampleGrabber_IMemInputPin_GetAllocator, + SampleGrabber_IMemInputPin_NotifyAllocator, + SampleGrabber_IMemInputPin_GetAllocatorRequirements, + SampleGrabber_IMemInputPin_Receive, + SampleGrabber_IMemInputPin_ReceiveMultiple, + SampleGrabber_IMemInputPin_ReceiveCanBlock, +}; + +static const IPinVtbl IPin_In_VTable = +{ + SampleGrabber_IPin_QueryInterface, + SampleGrabber_IPin_AddRef, + SampleGrabber_IPin_Release, + SampleGrabber_In_IPin_Connect, + SampleGrabber_In_IPin_ReceiveConnection, + SampleGrabber_In_IPin_Disconnect, + SampleGrabber_IPin_ConnectedTo, + SampleGrabber_IPin_ConnectionMediaType, + SampleGrabber_IPin_QueryPinInfo, + SampleGrabber_IPin_QueryDirection, + SampleGrabber_IPin_QueryId, + SampleGrabber_IPin_QueryAccept, + SampleGrabber_IPin_EnumMediaTypes, + SampleGrabber_In_IPin_QueryInternalConnections, + SampleGrabber_IPin_EndOfStream, + SampleGrabber_IPin_BeginFlush, + SampleGrabber_IPin_EndFlush, + SampleGrabber_IPin_NewSegment, +}; + +static const IPinVtbl IPin_Out_VTable = +{ + SampleGrabber_IPin_QueryInterface, + SampleGrabber_IPin_AddRef, + SampleGrabber_IPin_Release, + SampleGrabber_Out_IPin_Connect, + SampleGrabber_Out_IPin_ReceiveConnection, + SampleGrabber_Out_IPin_Disconnect, + SampleGrabber_IPin_ConnectedTo, + SampleGrabber_IPin_ConnectionMediaType, + SampleGrabber_IPin_QueryPinInfo, + SampleGrabber_IPin_QueryDirection, + SampleGrabber_IPin_QueryId, + SampleGrabber_IPin_QueryAccept, + SampleGrabber_IPin_EnumMediaTypes, + SampleGrabber_Out_IPin_QueryInternalConnections, + SampleGrabber_IPin_EndOfStream, + SampleGrabber_IPin_BeginFlush, + SampleGrabber_IPin_EndFlush, + SampleGrabber_IPin_NewSegment, +}; + HRESULT SampleGrabber_create(IUnknown *pUnkOuter, LPVOID *ppv) { SG_Impl* obj = NULL; @@ -442,11 +1382,29 @@ HRESULT SampleGrabber_create(IUnknown *pUnkOuter, LPVOID *ppv) obj->refCount = 1; obj->IBaseFilter_Vtbl = &IBaseFilter_VTable; obj->ISampleGrabber_Vtbl = &ISampleGrabber_VTable; + obj->IMemInputPin_Vtbl = &IMemInputPin_VTable; + obj->pin_in.lpVtbl = &IPin_In_VTable; + obj->pin_in.dir = PINDIR_INPUT; + obj->pin_in.name = pin_in_name; + obj->pin_in.sg = obj; + obj->pin_in.pair = NULL; + obj->pin_out.lpVtbl = &IPin_Out_VTable; + obj->pin_out.dir = PINDIR_OUTPUT; + obj->pin_out.name = pin_out_name; + obj->pin_out.sg = obj; + obj->pin_out.pair = NULL; obj->info.achName[0] = 0; obj->info.pGraph = NULL; obj->state = State_Stopped; + obj->mtype.majortype = GUID_NULL; + obj->mtype.subtype = MEDIASUBTYPE_None; + obj->mtype.formattype = FORMAT_None; obj->allocator = NULL; obj->refClock = NULL; + obj->memOutput = NULL; + obj->grabberIface = NULL; + obj->grabberMethod = -1; + obj->oneShot = OneShot_None; *ppv = obj; return S_OK; From d64433b26d5046387cc042968b19620c43aa4558 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 11:38:50 +0000 Subject: [PATCH 027/211] [QUARTZ] sync quartz to wine 1.1.39 svn path=/trunk/; revision=45753 --- reactos/dll/directx/quartz/dsoundrender.c | 124 ++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/reactos/dll/directx/quartz/dsoundrender.c b/reactos/dll/directx/quartz/dsoundrender.c index edb170da136..1d87a7f0047 100644 --- a/reactos/dll/directx/quartz/dsoundrender.c +++ b/reactos/dll/directx/quartz/dsoundrender.c @@ -32,6 +32,7 @@ #include "evcode.h" #include "strmif.h" #include "dsound.h" +#include "amaudio.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -45,12 +46,14 @@ static const IPinVtbl DSoundRender_InputPin_Vtbl; static const IBasicAudioVtbl IBasicAudio_Vtbl; static const IReferenceClockVtbl IReferenceClock_Vtbl; static const IMediaSeekingVtbl IMediaSeeking_Vtbl; +static const IAMDirectSoundVtbl IAMDirectSound_Vtbl; typedef struct DSoundRenderImpl { const IBaseFilterVtbl * lpVtbl; const IBasicAudioVtbl *IBasicAudio_vtbl; const IReferenceClockVtbl *IReferenceClock_vtbl; + const IAMDirectSoundVtbl *IAMDirectSound_vtbl; LONG refCount; CRITICAL_SECTION csFilter; @@ -404,6 +407,7 @@ HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv) pDSoundRender->lpVtbl = &DSoundRender_Vtbl; pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl; pDSoundRender->IReferenceClock_vtbl = &IReferenceClock_Vtbl; + pDSoundRender->IAMDirectSound_vtbl = &IAMDirectSound_Vtbl; pDSoundRender->refCount = 1; InitializeCriticalSection(&pDSoundRender->csFilter); pDSoundRender->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DSoundRenderImpl.csFilter"); @@ -473,6 +477,8 @@ static HRESULT WINAPI DSoundRender_QueryInterface(IBaseFilter * iface, REFIID ri *ppv = &This->IReferenceClock_vtbl; else if (IsEqualIID(riid, &IID_IMediaSeeking)) *ppv = &This->mediaSeeking.lpVtbl; + else if (IsEqualIID(riid, &IID_IAMDirectSound)) + *ppv = &This->IAMDirectSound_vtbl; if (*ppv) { @@ -1328,3 +1334,121 @@ static const IMediaSeekingVtbl IMediaSeeking_Vtbl = MediaSeekingImpl_GetRate, MediaSeekingImpl_GetPreroll }; + +/*** IUnknown methods ***/ +static HRESULT WINAPI AMDirectSound_QueryInterface(IAMDirectSound *iface, + REFIID riid, + LPVOID*ppvObj) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj); + + return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj); +} + +static ULONG WINAPI AMDirectSound_AddRef(IAMDirectSound *iface) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + TRACE("(%p/%p)->()\n", This, iface); + + return DSoundRender_AddRef((IBaseFilter*)This); +} + +static ULONG WINAPI AMDirectSound_Release(IAMDirectSound *iface) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + TRACE("(%p/%p)->()\n", This, iface); + + return DSoundRender_Release((IBaseFilter*)This); +} + +/*** IAMDirectSound methods ***/ +static HRESULT WINAPI AMDirectSound_GetDirectSoundInterface(IAMDirectSound *iface, IDirectSound **ds) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, ds); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_GetPrimaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer **buf) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, buf); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_GetSecondaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer **buf) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, buf); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_ReleaseDirectSoundInterface(IAMDirectSound *iface, IDirectSound *ds) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, ds); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_ReleasePrimaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer *buf) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, buf); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_ReleaseSecondaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer *buf) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, buf); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_SetFocusWindow(IAMDirectSound *iface, HWND hwnd, BOOL bgsilent) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p,%d): stub\n", This, iface, hwnd, bgsilent); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_GetFocusWindow(IAMDirectSound *iface, HWND hwnd) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, hwnd); + + return E_NOTIMPL; +} + +static const IAMDirectSoundVtbl IAMDirectSound_Vtbl = +{ + AMDirectSound_QueryInterface, + AMDirectSound_AddRef, + AMDirectSound_Release, + AMDirectSound_GetDirectSoundInterface, + AMDirectSound_GetPrimaryBufferInterface, + AMDirectSound_GetSecondaryBufferInterface, + AMDirectSound_ReleaseDirectSoundInterface, + AMDirectSound_ReleasePrimaryBufferInterface, + AMDirectSound_ReleaseSecondaryBufferInterface, + AMDirectSound_SetFocusWindow, + AMDirectSound_GetFocusWindow +}; From 715db25ce69391e63917fbad89dc3d23e0f36d79 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 14:08:15 +0000 Subject: [PATCH 028/211] [MSHTML] sync mshtml to wine 1.1.39 svn path=/trunk/; revision=45754 --- reactos/dll/win32/mshtml/De.rc | 2 +- reactos/dll/win32/mshtml/Fr.rc | 1 + reactos/dll/win32/mshtml/It.rc | 72 ++++ reactos/dll/win32/mshtml/Ja.rc | 1 + reactos/dll/win32/mshtml/Lt.rc | 1 + reactos/dll/win32/mshtml/No.rc | 1 + reactos/dll/win32/mshtml/Si.rc | 1 + reactos/dll/win32/mshtml/Uk.rc | 72 ++++ reactos/dll/win32/mshtml/dispex.c | 29 +- reactos/dll/win32/mshtml/editor.c | 12 +- reactos/dll/win32/mshtml/htmlanchor.c | 7 +- reactos/dll/win32/mshtml/htmlbody.c | 20 +- reactos/dll/win32/mshtml/htmlcomment.c | 12 +- reactos/dll/win32/mshtml/htmldoc.c | 10 +- reactos/dll/win32/mshtml/htmldoc3.c | 11 +- reactos/dll/win32/mshtml/htmldoc5.c | 2 +- reactos/dll/win32/mshtml/htmlelem.c | 59 ++- reactos/dll/win32/mshtml/htmlelem2.c | 8 +- reactos/dll/win32/mshtml/htmlelemcol.c | 2 +- reactos/dll/win32/mshtml/htmlevent.c | 38 +- reactos/dll/win32/mshtml/htmlevent.h | 1 + reactos/dll/win32/mshtml/htmlform.c | 54 +-- reactos/dll/win32/mshtml/htmlframe.c | 299 ++++++++++++++ reactos/dll/win32/mshtml/htmlframebase.c | 109 +---- reactos/dll/win32/mshtml/htmlgeneric.c | 6 +- reactos/dll/win32/mshtml/htmliframe.c | 134 +++++- reactos/dll/win32/mshtml/htmlimg.c | 103 ++++- reactos/dll/win32/mshtml/htmlinput.c | 10 +- reactos/dll/win32/mshtml/htmlnode.c | 2 +- reactos/dll/win32/mshtml/htmloption.c | 10 +- reactos/dll/win32/mshtml/htmlscript.c | 15 +- reactos/dll/win32/mshtml/htmlselect.c | 30 +- reactos/dll/win32/mshtml/htmlstyle.c | 52 +-- reactos/dll/win32/mshtml/htmltable.c | 6 +- reactos/dll/win32/mshtml/htmltablerow.c | 6 +- reactos/dll/win32/mshtml/htmltextarea.c | 15 +- reactos/dll/win32/mshtml/htmlwindow.c | 15 +- reactos/dll/win32/mshtml/main.c | 7 +- reactos/dll/win32/mshtml/mshtml.inf | 22 +- reactos/dll/win32/mshtml/mshtml.rbuild | 1 + reactos/dll/win32/mshtml/mshtml_private.h | 19 +- reactos/dll/win32/mshtml/mutation.c | 8 +- reactos/dll/win32/mshtml/nsembed.c | 25 +- reactos/dll/win32/mshtml/nsevents.c | 5 +- reactos/dll/win32/mshtml/nsio.c | 2 +- reactos/dll/win32/mshtml/rsrc.rc | 33 ++ reactos/dll/win32/mshtml/script.c | 5 +- reactos/dll/win32/mshtml/txtrange.c | 2 +- reactos/dll/win32/mshtml/view.c | 15 +- reactos/include/psdk/mshtmdid.h | 21 + reactos/include/psdk/mshtml.idl | 478 +++++++++++++++++----- 51 files changed, 1432 insertions(+), 439 deletions(-) create mode 100644 reactos/dll/win32/mshtml/It.rc create mode 100644 reactos/dll/win32/mshtml/Uk.rc create mode 100644 reactos/dll/win32/mshtml/htmlframe.c diff --git a/reactos/dll/win32/mshtml/De.rc b/reactos/dll/win32/mshtml/De.rc index 219549c8b7a..43e0cfe85a5 100644 --- a/reactos/dll/win32/mshtml/De.rc +++ b/reactos/dll/win32/mshtml/De.rc @@ -72,4 +72,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Abbrechen", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } - +#pragma code_page(default) diff --git a/reactos/dll/win32/mshtml/Fr.rc b/reactos/dll/win32/mshtml/Fr.rc index 0d14f452e8b..84ee453128f 100644 --- a/reactos/dll/win32/mshtml/Fr.rc +++ b/reactos/dll/win32/mshtml/Fr.rc @@ -72,3 +72,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Annuler", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/reactos/dll/win32/mshtml/It.rc b/reactos/dll/win32/mshtml/It.rc new file mode 100644 index 00000000000..4b262c56e3a --- /dev/null +++ b/reactos/dll/win32/mshtml/It.rc @@ -0,0 +1,72 @@ +/* + * Copyright 2010 Luca Bennati + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/*UTF-8*/ +#pragma code_page(65001) + +LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_HTMLDISABLED "Il rendering HTML è correntemente disattivato." + IDS_HTMLDOCUMENT "Documento HTML" + IDS_DOWNLOADING "Scaricando..." + IDS_INSTALLING "Installando..." +} + +ID_DWL_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 260, 95 +STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Installer di Wine Gecko" +FONT 8, "MS Shell Dlg" +{ + LTEXT "Wine non ha trovato un pacchetto Gecko che è necessario per applicazioni che incorporano HTML " \ + "per funzionare correttamente. Wine può automaticamente scaricarlo ed installarlo per te.\n\n" \ + "Nota: è raccomandato usare i pacchetti delle distribuzioni. Leggi http://wiki.winehq.org/Gecko per i dettagli.", + ID_DWL_STATUS, 10, 10, 240, 50, SS_LEFT + CONTROL "Avanzamento", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 40, 240, 12 + DEFPUSHBUTTON "&Installa", ID_DWL_INSTALL, 200, 70, 50, 15, WS_GROUP | WS_TABSTOP + PUSHBUTTON "&Annulla", IDCANCEL, 140, 70, 50, 15, WS_GROUP | WS_TABSTOP +} + +IDD_HYPERLINK DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 250, 65 +STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Hyperlink" +FONT 8, "MS Shell Dlg" +{ + GROUPBOX "Informazioni sull'hyperlink", -1, 5, 5, 190, 55 + LTEXT "&Tipo:", -1, 10, 22, 20, 10 + COMBOBOX IDC_TYPE, 35, 20, 45, 100, WS_TABSTOP | WS_GROUP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS + LTEXT "&URL:", -1, 10, 42, 20, 10 + EDITTEXT IDC_URL, 35, 40, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 200, 10, 45, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Annulla", IDCANCEL, 200, 28, 45, 14, WS_GROUP | WS_TABSTOP +} + +ID_PROMPT_DIALOG DIALOG 0, 0, 200, 90 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "" +FONT 8, "MS Shell Dlg" +{ + LTEXT "", ID_PROMPT_PROMPT, 10, 10, 180, 30 + EDITTEXT ID_PROMPT_EDIT, 10, 45, 180, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Annulla", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP +} +#pragma code_page(default) diff --git a/reactos/dll/win32/mshtml/Ja.rc b/reactos/dll/win32/mshtml/Ja.rc index 04fc32e785b..40db7b5f867 100644 --- a/reactos/dll/win32/mshtml/Ja.rc +++ b/reactos/dll/win32/mshtml/Ja.rc @@ -69,3 +69,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "キャンセル", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/reactos/dll/win32/mshtml/Lt.rc b/reactos/dll/win32/mshtml/Lt.rc index 8f7e772a3a7..560cc08dd16 100644 --- a/reactos/dll/win32/mshtml/Lt.rc +++ b/reactos/dll/win32/mshtml/Lt.rc @@ -69,3 +69,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "Gerai", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Atsisakyti", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/reactos/dll/win32/mshtml/No.rc b/reactos/dll/win32/mshtml/No.rc index 4592599edf3..3a3b45d7a42 100644 --- a/reactos/dll/win32/mshtml/No.rc +++ b/reactos/dll/win32/mshtml/No.rc @@ -70,3 +70,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Avbryt", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/reactos/dll/win32/mshtml/Si.rc b/reactos/dll/win32/mshtml/Si.rc index 6881addcd5b..500081bc790 100644 --- a/reactos/dll/win32/mshtml/Si.rc +++ b/reactos/dll/win32/mshtml/Si.rc @@ -68,3 +68,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "V redu", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "PrekliÄi", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/reactos/dll/win32/mshtml/Uk.rc b/reactos/dll/win32/mshtml/Uk.rc new file mode 100644 index 00000000000..5e11b4dccfb --- /dev/null +++ b/reactos/dll/win32/mshtml/Uk.rc @@ -0,0 +1,72 @@ +/* + * Copyright 2005-2006 Jacek Caban + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_HTMLDISABLED "HTML rendering is currently disabled." + IDS_HTMLDOCUMENT "Документ HTML" + IDS_DOWNLOADING "ЗавантаженнÑ..." + IDS_INSTALLING "Ð’ÑтановленнÑ..." +} + +ID_DWL_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 260, 95 +STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Wine Gecko Installer" +FONT 8, "MS Shell Dlg" +{ + LTEXT "Wine не може знайти пакунок Gecko, Ñкий потрібний Ð´Ð»Ñ Ð´Ð¾Ð´Ð°Ñ‚ÐºÑ–Ð² embedding HTML " \ + "Ð´Ð»Ñ ÐºÐ¾Ñ€ÐµÐºÑ‚Ð½Ð¾Ñ— роботи. Wine може автоматично завантажити та вÑтановити його Ð´Ð»Ñ Ð’Ð°Ñ.\n\n" \ + "Зауважте: РекомендуєтьÑÑ Ð²Ð¸ÐºÐ¾Ñ€Ð¸Ñтати пакет з вашого диÑтрибутиву. Детальніше читайте http://wiki.winehq.org/Gecko.", + ID_DWL_STATUS, 10, 10, 240, 50, SS_LEFT + CONTROL "ПрогреÑ", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 40, 240, 12 + DEFPUSHBUTTON "&Ð’Ñтановити", ID_DWL_INSTALL, 200, 70, 50, 15, WS_GROUP | WS_TABSTOP + PUSHBUTTON "&СкаÑувати", IDCANCEL, 140, 70, 50, 15, WS_GROUP | WS_TABSTOP +} + +IDD_HYPERLINK DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 250, 65 +STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "ГіперпоÑиланнÑ" +FONT 8, "MS Shell Dlg" +{ + GROUPBOX "Дані про ГіперпоÑиланнÑ", -1, 5, 5, 190, 55 + LTEXT "&Тип:", -1, 10, 22, 20, 10 + COMBOBOX IDC_TYPE, 35, 20, 45, 100, WS_TABSTOP | WS_GROUP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS + LTEXT "&URL:", -1, 10, 42, 20, 10 + EDITTEXT IDC_URL, 35, 40, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 200, 10, 45, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "СкаÑувати", IDCANCEL, 200, 28, 45, 14, WS_GROUP | WS_TABSTOP +} + +ID_PROMPT_DIALOG DIALOG 0, 0, 200, 90 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "" +FONT 8, "MS Shell Dlg" +{ + LTEXT "", ID_PROMPT_PROMPT, 10, 10, 180, 30 + EDITTEXT ID_PROMPT_EDIT, 10, 45, 180, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "СкаÑувати", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP +} diff --git a/reactos/dll/win32/mshtml/dispex.c b/reactos/dll/win32/mshtml/dispex.c index c77ebb92218..4b1bd882e5e 100644 --- a/reactos/dll/win32/mshtml/dispex.c +++ b/reactos/dll/win32/mshtml/dispex.c @@ -92,6 +92,7 @@ static REFIID tid_ids[] = { &DIID_DispHTMLElementCollection, &DIID_DispHTMLFormElement, &DIID_DispHTMLGenericElement, + &DIID_DispHTMLFrameElement, &DIID_DispHTMLIFrame, &DIID_DispHTMLImg, &DIID_DispHTMLInputElement, @@ -99,10 +100,12 @@ static REFIID tid_ids[] = { &DIID_DispHTMLNavigator, &DIID_DispHTMLOptionElement, &DIID_DispHTMLScreen, + &DIID_DispHTMLScriptElement, &DIID_DispHTMLSelectElement, &DIID_DispHTMLStyle, &DIID_DispHTMLTable, &DIID_DispHTMLTableRow, + &DIID_DispHTMLTextAreaElement, &DIID_DispHTMLUnknownElement, &DIID_DispHTMLWindow2, &DIID_HTMLDocumentEvents, @@ -133,12 +136,15 @@ static REFIID tid_ids[] = { &IID_IHTMLFrameBase, &IID_IHTMLFrameBase2, &IID_IHTMLGenericElement, + &IID_IHTMLFrameElement3, + &IID_IHTMLIFrameElement, &IID_IHTMLImageElementFactory, &IID_IHTMLImgElement, &IID_IHTMLInputElement, &IID_IHTMLLocation, &IID_IHTMLOptionElement, &IID_IHTMLScreen, + &IID_IHTMLScriptElement, &IID_IHTMLSelectElement, &IID_IHTMLStyle, &IID_IHTMLStyle2, @@ -146,6 +152,7 @@ static REFIID tid_ids[] = { &IID_IHTMLStyle4, &IID_IHTMLTable, &IID_IHTMLTableRow, + &IID_IHTMLTextAreaElement, &IID_IHTMLTextContainer, &IID_IHTMLUniqueName, &IID_IHTMLWindow2, @@ -397,18 +404,19 @@ HRESULT call_disp_func(IDispatch *disp, DISPPARAMS *dp) VARIANT res; HRESULT hres; - hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); - if(FAILED(hres)) { - FIXME("Could not get IDispatchEx interface: %08x\n", hres); - return hres; - } - VariantInit(&res); memset(&ei, 0, sizeof(ei)); - hres = IDispatchEx_InvokeEx(dispex, 0, GetUserDefaultLCID(), DISPATCH_METHOD, dp, &res, &ei, NULL); + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(SUCCEEDED(hres)) { + hres = IDispatchEx_InvokeEx(dispex, 0, GetUserDefaultLCID(), DISPATCH_METHOD, dp, &res, &ei, NULL); + IDispatchEx_Release(dispex); + }else { + TRACE("Could not get IDispatchEx interface: %08x\n", hres); + hres = IDispatch_Invoke(disp, 0, &IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD, + dp, &res, &ei, NULL); + } - IDispatchEx_Release(dispex); VariantClear(&res); return hres; } @@ -975,7 +983,10 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex) { DispatchEx *This = DISPATCHEX_THIS(iface); - FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex); + + TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex); + + /* Not implemented by IE */ return E_NOTIMPL; } diff --git a/reactos/dll/win32/mshtml/editor.c b/reactos/dll/win32/mshtml/editor.c index 568e127220f..961bb916370 100644 --- a/reactos/dll/win32/mshtml/editor.c +++ b/reactos/dll/win32/mshtml/editor.c @@ -298,7 +298,7 @@ static void get_font_size(HTMLDocument *This, WCHAR *ret) TRACE("found font tag %p\n", elem); - nsAString_Init(&size_str, sizeW); + nsAString_InitDepend(&size_str, sizeW); nsAString_Init(&val_str, NULL); nsIDOMElement_GetAttribute(elem, &size_str, &val_str); @@ -360,10 +360,11 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size) create_nselem(This->doc_node, fontW, &elem); - nsAString_Init(&size_str, sizeW); - nsAString_Init(&val_str, size); + nsAString_InitDepend(&size_str, sizeW); + nsAString_InitDepend(&val_str, size); nsIDOMElement_SetAttribute(elem, &size_str, &val_str); + nsAString_Finish(&val_str); nsISelection_GetRangeAt(nsselection, 0, &range); nsISelection_GetIsCollapsed(nsselection, &collapsed); @@ -384,7 +385,6 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size) nsIDOMElement_Release(elem); nsAString_Finish(&size_str); - nsAString_Finish(&val_str); set_dirty(This, VARIANT_TRUE); } @@ -1167,8 +1167,8 @@ static HRESULT exec_hyperlink(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, /* create an element for the link */ create_nselem(This->doc_node, aW, &anchor_elem); - nsAString_Init(&href_str, hrefW); - nsAString_Init(&ns_url, url); + nsAString_InitDepend(&href_str, hrefW); + nsAString_InitDepend(&ns_url, url); nsIDOMElement_SetAttribute(anchor_elem, &href_str, &ns_url); nsAString_Finish(&href_str); diff --git a/reactos/dll/win32/mshtml/htmlanchor.c b/reactos/dll/win32/mshtml/htmlanchor.c index 6bbaf26dfae..ae269ee252b 100644 --- a/reactos/dll/win32/mshtml/htmlanchor.c +++ b/reactos/dll/win32/mshtml/htmlanchor.c @@ -520,12 +520,7 @@ static const NodeImplVtbl HTMLAnchorElementImplVtbl = { static const tid_t HTMLAnchorElement_iface_tids[] = { IHTMLAnchorElement_tid, - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, - IHTMLElement4_tid, + HTMLELEMENT_TIDS, IHTMLTextContainer_tid, IHTMLUniqueName_tid, 0 diff --git a/reactos/dll/win32/mshtml/htmlbody.c b/reactos/dll/win32/mshtml/htmlbody.c index 7f22a4e06a6..5c66e65a44a 100644 --- a/reactos/dll/win32/mshtml/htmlbody.c +++ b/reactos/dll/win32/mshtml/htmlbody.c @@ -252,23 +252,18 @@ static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dis static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v) { HTMLBodyElement *This = HTMLBODY_THIS(iface); - HRESULT hr = S_OK; nsAString nsstr; nsresult nsres; TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&nsstr, v); - + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr); - if(!NS_SUCCEEDED(nsres)) - { - hr = E_FAIL; - } - nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) + return E_FAIL; - return hr; + return S_OK; } static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p) @@ -799,12 +794,7 @@ static const NodeImplVtbl HTMLBodyElementImplVtbl = { static const tid_t HTMLBodyElement_iface_tids[] = { IHTMLBodyElement_tid, IHTMLBodyElement2_tid, - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, - IHTMLElement4_tid, + HTMLELEMENT_TIDS, IHTMLTextContainer_tid, IHTMLUniqueName_tid, 0 diff --git a/reactos/dll/win32/mshtml/htmlcomment.c b/reactos/dll/win32/mshtml/htmlcomment.c index e38432c4a67..7040d184077 100644 --- a/reactos/dll/win32/mshtml/htmlcomment.c +++ b/reactos/dll/win32/mshtml/htmlcomment.c @@ -103,8 +103,10 @@ static HRESULT WINAPI HTMLCommentElement_put_text(IHTMLCommentElement *iface, BS static HRESULT WINAPI HTMLCommentElement_get_text(IHTMLCommentElement *iface, BSTR *p) { HTMLCommentElement *This = HTMLCOMMENT_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return IHTMLElement_get_outerHTML(HTMLELEM(&This->element), p); } static HRESULT WINAPI HTMLCommentElement_put_atomic(IHTMLCommentElement *iface, LONG v) @@ -171,11 +173,7 @@ static const NodeImplVtbl HTMLCommentElementImplVtbl = { }; static const tid_t HTMLCommentElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLCommentElement_tid, 0 }; diff --git a/reactos/dll/win32/mshtml/htmldoc.c b/reactos/dll/win32/mshtml/htmldoc.c index ac67a84cc60..93aea065011 100644 --- a/reactos/dll/win32/mshtml/htmldoc.c +++ b/reactos/dll/win32/mshtml/htmldoc.c @@ -348,7 +348,7 @@ static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v) return E_UNEXPECTED; } - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) @@ -776,6 +776,9 @@ static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln) return E_UNEXPECTED; } + if (!psarray) + return S_OK; + if(psarray->cDims != 1) { FIXME("cDims=%d\n", psarray->cDims); return E_INVALIDARG; @@ -1770,6 +1773,9 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv) }else if(IsEqualGUID(&IID_IMarshal, riid)) { TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv); *ppv = NULL; + }else if(IsEqualGUID(&IID_IExternalConnection, riid)) { + TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv); + *ppv = NULL; }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) { TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv); *ppv = OBJSITE(This); @@ -1989,6 +1995,8 @@ static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface) if(This->basedoc.advise_holder) IOleAdviseHolder_Release(This->basedoc.advise_holder); + if(This->view_sink) + IAdviseSink_Release(This->view_sink); if(This->client) IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL); if(This->in_place_active) diff --git a/reactos/dll/win32/mshtml/htmldoc3.c b/reactos/dll/win32/mshtml/htmldoc3.c index de32302c935..9079bbc79c7 100644 --- a/reactos/dll/win32/mshtml/htmldoc3.c +++ b/reactos/dll/win32/mshtml/htmldoc3.c @@ -116,7 +116,7 @@ static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR t return E_UNEXPECTED; } - nsAString_Init(&text_str, text); + nsAString_InitDepend(&text_str, text); nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { @@ -443,7 +443,7 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v return E_UNEXPECTED; } - nsAString_Init(&id_str, v); + nsAString_InitDepend(&id_str, v); /* get element by id attribute */ nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &id_str, &nselem); if(FAILED(nsres)) { @@ -455,9 +455,9 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v /* get first element by name attribute */ nsres = nsIDOMHTMLDocument_GetElementsByName(This->doc_node->nsdoc, &id_str, &nsnode_list); + nsAString_Finish(&id_str); if(FAILED(nsres)) { ERR("getElementsByName failed: %08x\n", nsres); - nsAString_Finish(&id_str); if(nsnode_by_id) nsIDOMNode_Release(nsnode_by_id); return E_FAIL; @@ -465,7 +465,6 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v nsIDOMNodeList_Item(nsnode_list, 0, &nsnode_by_name); nsIDOMNodeList_Release(nsnode_list); - nsAString_Finish(&id_str); if(nsnode_by_name && nsnode_by_id) { nsIDOM3Node *node3; @@ -528,8 +527,8 @@ static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, return E_UNEXPECTED; } - nsAString_Init(&id_str, v); - nsAString_Init(&ns_str, str); + nsAString_InitDepend(&id_str, v); + nsAString_InitDepend(&ns_str, str); nsres = nsIDOMHTMLDocument_GetElementsByTagNameNS(This->doc_node->nsdoc, &ns_str, &id_str, &nslist); nsAString_Finish(&id_str); nsAString_Finish(&ns_str); diff --git a/reactos/dll/win32/mshtml/htmldoc5.c b/reactos/dll/win32/mshtml/htmldoc5.c index e3b14231e69..12742f64126 100644 --- a/reactos/dll/win32/mshtml/htmldoc5.c +++ b/reactos/dll/win32/mshtml/htmldoc5.c @@ -136,7 +136,7 @@ static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bs return E_UNEXPECTED; } - nsAString_Init(&str, bstrdata); + nsAString_InitDepend(&str, bstrdata); nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment); nsAString_Finish(&str); if(NS_FAILED(nsres)) { diff --git a/reactos/dll/win32/mshtml/htmlelem.c b/reactos/dll/win32/mshtml/htmlelem.c index a65ed20065e..e77c1dc4c42 100644 --- a/reactos/dll/win32/mshtml/htmlelem.c +++ b/reactos/dll/win32/mshtml/htmlelem.c @@ -65,7 +65,7 @@ HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement return E_UNEXPECTED; } - nsAString_Init(&tag_str, tag); + nsAString_InitDepend(&tag_str, tag); nsres = nsIDOMDocument_CreateElement(doc->nsdoc, &tag_str, &nselem); nsAString_Finish(&tag_str); if(NS_FAILED(nsres)) { @@ -215,7 +215,7 @@ static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v) return E_NOTIMPL; } - nsAString_Init(&classname_str, v); + nsAString_InitDepend(&classname_str, v); nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str); nsAString_Finish(&classname_str); if(NS_FAILED(nsres)) @@ -269,7 +269,7 @@ static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v) return S_OK; } - nsAString_Init(&id_str, v); + nsAString_InitDepend(&id_str, v); nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str); nsAString_Finish(&id_str); if(NS_FAILED(nsres)) @@ -593,6 +593,8 @@ static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch ** return S_OK; } +static const WCHAR titleW[] = {'t','i','t','l','e',0}; + static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v) { HTMLElement *This = HTMLELEM_THIS(iface); @@ -601,7 +603,21 @@ static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&title_str, v); + if(!This->nselem) { + VARIANT *var; + HRESULT hres; + + hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var); + if(FAILED(hres)) + return hres; + + VariantClear(var); + V_VT(var) = VT_BSTR; + V_BSTR(var) = v ? SysAllocString(v) : NULL; + return S_OK; + } + + nsAString_InitDepend(&title_str, v); nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str); nsAString_Finish(&title_str); if(NS_FAILED(nsres)) @@ -618,6 +634,23 @@ static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p) TRACE("(%p)->(%p)\n", This, p); + if(!This->nselem) { + VARIANT *var; + HRESULT hres; + + hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var); + if(hres == DISP_E_UNKNOWNNAME) { + *p = NULL; + }else if(V_VT(var) != VT_BSTR) { + FIXME("title = %s\n", debugstr_variant(var)); + return E_FAIL; + }else { + *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL; + } + + return S_OK; + } + nsAString_Init(&title_str, NULL); nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str); if(NS_SUCCEEDED(nsres)) { @@ -820,7 +853,7 @@ static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v) return E_FAIL; } - nsAString_Init(&html_str, v); + nsAString_InitDepend(&html_str, v); nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str); nsAString_Finish(&html_str); @@ -896,7 +929,7 @@ static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v) nsIDOMNode_Release(tmp); } - nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { @@ -955,7 +988,7 @@ static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v) return E_FAIL; } - nsAString_Init(&html_str, v); + nsAString_InitDepend(&html_str, v); nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment); nsIDOMNSRange_Release(nsrange); nsAString_Finish(&html_str); @@ -1131,7 +1164,7 @@ static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR w return E_FAIL; } - nsAString_Init(&ns_html, html); + nsAString_InitDepend(&ns_html, html); nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode); nsIDOMNSRange_Release(nsrange); @@ -1166,7 +1199,7 @@ static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR w } - nsAString_Init(&ns_text, text); + nsAString_InitDepend(&ns_text, text); nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode); nsAString_Finish(&ns_text); @@ -1572,11 +1605,7 @@ static const NodeImplVtbl HTMLElementImplVtbl = { }; static const tid_t HTMLElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, 0 }; @@ -1675,7 +1704,7 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL if(!ret) { ret = heap_alloc_zero(sizeof(HTMLElement)); - HTMLElement_Init(ret, doc, nselem, NULL); + HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex); ret->node.vtbl = &HTMLElementImplVtbl; } diff --git a/reactos/dll/win32/mshtml/htmlelem2.c b/reactos/dll/win32/mshtml/htmlelem2.c index cd9b6764857..cd877ceaf30 100644 --- a/reactos/dll/win32/mshtml/htmlelem2.c +++ b/reactos/dll/win32/mshtml/htmlelem2.c @@ -655,8 +655,10 @@ static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event, static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp) { HTMLElement *This = HTMLELEM2_THIS(iface); - FIXME("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp); - return E_NOTIMPL; + + TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp); + + return detach_event(*get_node_event_target(&This->node), &This->node.doc->basedoc, event, pDisp); } static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p) @@ -1087,7 +1089,7 @@ static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BS TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl); - nsAString_Init(&tag_str, v); + nsAString_InitDepend(&tag_str, v); nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nslist); nsAString_Finish(&tag_str); if(NS_FAILED(nsres)) { diff --git a/reactos/dll/win32/mshtml/htmlelemcol.c b/reactos/dll/win32/mshtml/htmlelemcol.c index c9737077382..9c0fedde8d0 100644 --- a/reactos/dll/win32/mshtml/htmlelemcol.c +++ b/reactos/dll/win32/mshtml/htmlelemcol.c @@ -245,7 +245,7 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name) return TRUE; } - nsAString_Init(&nsname, nameW); + nsAString_InitDepend(&nsname, nameW); nsres = nsIDOMHTMLElement_GetAttribute(elem->nselem, &nsname, &nsstr); nsAString_Finish(&nsname); if(NS_SUCCEEDED(nsres)) { diff --git a/reactos/dll/win32/mshtml/htmlevent.c b/reactos/dll/win32/mshtml/htmlevent.c index d04b2e66370..54429c34a20 100644 --- a/reactos/dll/win32/mshtml/htmlevent.c +++ b/reactos/dll/win32/mshtml/htmlevent.c @@ -743,7 +743,7 @@ static IHTMLEventObj *create_event(HTMLDOMNode *target, eventid_t eid, nsIDOMEve if(NS_SUCCEEDED(nsres)) { nsAString type_str; - nsAString_Init(&type_str, event_types[event_info[eid].type]); + nsAString_InitDepend(&type_str, event_types[event_info[eid].type]); nsres = nsIDOMDocumentEvent_CreateEvent(doc_event, &type_str, &ret->nsevent); nsAString_Finish(&type_str); nsIDOMDocumentEvent_Release(doc_event); @@ -816,7 +816,7 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj, ConnectionPointContainer *cp_container, eventid_t eid, IDispatch *this_obj) { handler_vector_t *handler_vector = NULL; - DWORD i; + int i; HRESULT hres; if(event_target) @@ -845,7 +845,8 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj, V_VT(&arg) = VT_DISPATCH; V_DISPATCH(&arg) = (IDispatch*)event_obj; - for(i=0; i < handler_vector->handler_cnt; i++) { + i = handler_vector->handler_cnt; + while(i--) { if(handler_vector->handlers[i]) { TRACE("%s [%d] >>>\n", debugstr_w(event_info[eid].name), i); hres = call_disp_func(handler_vector->handlers[i], &dp); @@ -866,6 +867,9 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj, for(cp = cp_container->cp_list; cp; cp = cp->next) { if(cp->sinks_size && is_cp_event(cp->data, event_info[eid].dispid)) { for(i=0; i < cp->sinks_size; i++) { + if(!cp->sinks[i].disp) + continue; + TRACE("cp %s [%d] >>>\n", debugstr_w(event_info[eid].name), i); hres = call_cp_func(cp->sinks[i].disp, event_info[eid].dispid); if(hres == S_OK) @@ -1124,6 +1128,34 @@ HRESULT attach_event(event_target_t **event_target_ptr, HTMLDocument *doc, BSTR event_target->event_table[eid]->handlers[i] = disp; *res = VARIANT_TRUE; + return ensure_nsevent_handler(doc->doc_node, eid); +} + +HRESULT detach_event(event_target_t *event_target, HTMLDocument *doc, BSTR name, IDispatch *disp) +{ + eventid_t eid; + DWORD i = 0; + + if(!event_target) + return S_OK; + + eid = attr_to_eid(name); + if(eid == EVENTID_LAST) { + WARN("Unknown event\n"); + return S_OK; + } + + if(!event_target->event_table[eid]) + return S_OK; + + while(i < event_target->event_table[eid]->handler_cnt) { + if(event_target->event_table[eid]->handlers[i] == disp) { + IDispatch_Release(event_target->event_table[eid]->handlers[i]); + event_target->event_table[eid]->handlers[i] = NULL; + } + i++; + } + return S_OK; } diff --git a/reactos/dll/win32/mshtml/htmlevent.h b/reactos/dll/win32/mshtml/htmlevent.h index 1a8572f951e..96ff4cdab5b 100644 --- a/reactos/dll/win32/mshtml/htmlevent.h +++ b/reactos/dll/win32/mshtml/htmlevent.h @@ -46,6 +46,7 @@ void fire_event(HTMLDocumentNode*,eventid_t,nsIDOMNode*,nsIDOMEvent*); HRESULT set_event_handler(event_target_t**,HTMLDocumentNode*,eventid_t,VARIANT*); HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*); HRESULT attach_event(event_target_t**,HTMLDocument*,BSTR,IDispatch*,VARIANT_BOOL*); +HRESULT detach_event(event_target_t*,HTMLDocument*,BSTR,IDispatch*); HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*); HRESULT call_event(HTMLDOMNode*,eventid_t); void update_cp_events(HTMLWindow*,cp_static_data_t*); diff --git a/reactos/dll/win32/mshtml/htmlform.c b/reactos/dll/win32/mshtml/htmlform.c index 1db965a8d77..68860560148 100644 --- a/reactos/dll/win32/mshtml/htmlform.c +++ b/reactos/dll/win32/mshtml/htmlform.c @@ -343,10 +343,12 @@ static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface, { HTMLFormElement *This = HTMLFORM_NODE_THIS(iface); nsIDOMHTMLCollection *elements; + nsAString nsname, nsstr; PRUint32 len, i; - static const PRUnichar nameW[] = {'n','a','m','e',0}; - nsAString nsname; nsresult nsres; + HRESULT hres = DISP_E_UNKNOWNNAME; + + static const PRUnichar nameW[] = {'n','a','m','e',0}; TRACE("(%p)->(%s %x %p)\n", This, wine_dbgstr_w(name), grfdex, pid); @@ -363,72 +365,62 @@ static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface, return E_FAIL; } - nsAString_Init(&nsname, nameW); + nsAString_InitDepend(&nsname, nameW); + nsAString_Init(&nsstr, NULL); for(i = 0; i < len; ++i) { nsIDOMNode *nsitem; nsIDOMHTMLElement *nshtml_elem; - nsAString nsstr; const PRUnichar *str; nsres = nsIDOMHTMLCollection_Item(elements, i, &nsitem); if(NS_FAILED(nsres)) { FIXME("Item failed: 0x%08x\n", nsres); - nsAString_Finish(&nsname); - nsIDOMHTMLCollection_Release(elements); - return E_FAIL; + hres = E_FAIL; + break; } nsres = nsIDOMNode_QueryInterface(nsitem, &IID_nsIDOMHTMLElement, (void**)&nshtml_elem); nsIDOMNode_Release(nsitem); if(NS_FAILED(nsres)) { FIXME("Failed to get nsIDOMHTMLNode interface: 0x%08x\n", nsres); - nsAString_Finish(&nsname); - nsIDOMHTMLCollection_Release(elements); - return E_FAIL; + hres = E_FAIL; + break; } /* compare by id attr */ - nsAString_Init(&nsstr, NULL); nsres = nsIDOMHTMLElement_GetId(nshtml_elem, &nsstr); if(NS_FAILED(nsres)) { FIXME("GetId failed: 0x%08x\n", nsres); - nsAString_Finish(&nsname); nsIDOMHTMLElement_Release(nshtml_elem); - nsIDOMHTMLCollection_Release(elements); - return E_FAIL; + hres = E_FAIL; + break; } nsAString_GetData(&nsstr, &str); if(!strcmpiW(str, name)) { + nsIDOMHTMLElement_Release(nshtml_elem); /* FIXME: using index for dispid */ *pid = MSHTML_DISPID_CUSTOM_MIN + i; - nsAString_Finish(&nsname); - nsAString_Finish(&nsstr); - nsIDOMHTMLElement_Release(nshtml_elem); - nsIDOMHTMLCollection_Release(elements); - return S_OK; + hres = S_OK; + break; } /* compare by name attr */ nsres = nsIDOMHTMLElement_GetAttribute(nshtml_elem, &nsname, &nsstr); + nsIDOMHTMLElement_Release(nshtml_elem); nsAString_GetData(&nsstr, &str); if(!strcmpiW(str, name)) { /* FIXME: using index for dispid */ *pid = MSHTML_DISPID_CUSTOM_MIN + i; - nsAString_Finish(&nsname); - nsAString_Finish(&nsstr); - nsIDOMHTMLElement_Release(nshtml_elem); - nsIDOMHTMLCollection_Release(elements); - return S_OK; + hres = S_OK; + break; } - nsAString_Finish(&nsstr); - - nsIDOMHTMLElement_Release(nshtml_elem); } nsAString_Finish(&nsname); + nsAString_Finish(&nsstr); nsIDOMHTMLCollection_Release(elements); - return DISP_E_UNKNOWNNAME; + return hres; } static HRESULT HTMLFormElement_invoke(HTMLDOMNode *iface, @@ -483,11 +475,7 @@ static const NodeImplVtbl HTMLFormElementImplVtbl = { }; static const tid_t HTMLFormElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLFormElement_tid, 0 }; diff --git a/reactos/dll/win32/mshtml/htmlframe.c b/reactos/dll/win32/mshtml/htmlframe.c new file mode 100644 index 00000000000..8d458f7a774 --- /dev/null +++ b/reactos/dll/win32/mshtml/htmlframe.c @@ -0,0 +1,299 @@ +/* + * Copyright 2010 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" + +#include "mshtml_private.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +typedef struct { + HTMLFrameBase framebase; + const IHTMLFrameElement3Vtbl *lpIHTMLFrameElement3Vtbl; +} HTMLFrameElement; + +#define HTMLFRAMEELEM3(x) ((IHTMLFrameElement3*) &(x)->lpIHTMLFrameElement3Vtbl) + +#define HTMLFRAME3_THIS(iface) DEFINE_THIS(HTMLFrameElement, IHTMLFrameElement3, iface) + +static HRESULT WINAPI HTMLFrameElement3_QueryInterface(IHTMLFrameElement3 *iface, + REFIID riid, void **ppv) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + + return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->framebase.element.node), riid, ppv); +} + +static ULONG WINAPI HTMLFrameElement3_AddRef(IHTMLFrameElement3 *iface) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + + return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->framebase.element.node)); +} + +static ULONG WINAPI HTMLFrameElement3_Release(IHTMLFrameElement3 *iface) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + + return IHTMLDOMNode_Release(HTMLDOMNODE(&This->framebase.element.node)); +} + +static HRESULT WINAPI HTMLFrameElement3_GetTypeInfoCount(IHTMLFrameElement3 *iface, UINT *pctinfo) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->framebase.element.node.dispex), pctinfo); +} + +static HRESULT WINAPI HTMLFrameElement3_GetTypeInfo(IHTMLFrameElement3 *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->framebase.element.node.dispex), iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI HTMLFrameElement3_GetIDsOfNames(IHTMLFrameElement3 *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->framebase.element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLFrameElement3_Invoke(IHTMLFrameElement3 *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + return IDispatchEx_Invoke(DISPATCHEX(&This->framebase.element.node.dispex), dispIdMember, riid, + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLFrameElement3_get_contentDocument(IHTMLFrameElement3 *iface, IDispatch **p) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + IHTMLDocument2 *doc; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + if(!This->framebase.content_window) { + FIXME("NULL window\n"); + return E_FAIL; + } + + hres = IHTMLWindow2_get_document(HTMLWINDOW2(This->framebase.content_window), &doc); + if(FAILED(hres)) + return hres; + + *p = doc ? (IDispatch*)doc : NULL; + return S_OK; +} + +static HRESULT WINAPI HTMLFrameElement3_put_src(IHTMLFrameElement3 *iface, BSTR v) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_get_src(IHTMLFrameElement3 *iface, BSTR *p) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_put_longDesc(IHTMLFrameElement3 *iface, BSTR v) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_get_longDesc(IHTMLFrameElement3 *iface, BSTR *p) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_put_frameBorder(IHTMLFrameElement3 *iface, BSTR v) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_get_frameBorder(IHTMLFrameElement3 *iface, BSTR *p) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +#undef HTMLFRAME3_THIS + +static const IHTMLFrameElement3Vtbl HTMLFrameElement3Vtbl = { + HTMLFrameElement3_QueryInterface, + HTMLFrameElement3_AddRef, + HTMLFrameElement3_Release, + HTMLFrameElement3_GetTypeInfoCount, + HTMLFrameElement3_GetTypeInfo, + HTMLFrameElement3_GetIDsOfNames, + HTMLFrameElement3_Invoke, + HTMLFrameElement3_get_contentDocument, + HTMLFrameElement3_put_src, + HTMLFrameElement3_get_src, + HTMLFrameElement3_put_longDesc, + HTMLFrameElement3_get_longDesc, + HTMLFrameElement3_put_frameBorder, + HTMLFrameElement3_get_frameBorder +}; + +#define HTMLFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLFrameElement, framebase.element.node, iface) + +static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + if(IsEqualGUID(&IID_IHTMLFrameElement3, riid)) { + TRACE("(%p)->(IID_IHTMLFrameElement3 %p)\n", This, ppv); + *ppv = HTMLFRAMEELEM3(This); + }else { + return HTMLFrameBase_QI(&This->framebase, riid, ppv); + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static void HTMLFrameElement_destructor(HTMLDOMNode *iface) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + HTMLFrameBase_destructor(&This->framebase); +} + +static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + if(!This->framebase.content_window || !This->framebase.content_window->doc) { + *p = NULL; + return S_OK; + } + + *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc); + IDispatch_AddRef(*p); + return S_OK; +} + +static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name, + DWORD grfdex, DISPID *pid) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + if(!This->framebase.content_window) + return DISP_E_UNKNOWNNAME; + + return search_window_props(This->framebase.content_window, name, grfdex, pid); +} + +static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid, + WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + if(!This->framebase.content_window) { + ERR("no content window to invoke on\n"); + return E_FAIL; + } + + return IDispatchEx_InvokeEx(DISPATCHEX(This->framebase.content_window), id, lcid, flags, params, res, ei, caller); +} + +static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + nsIDOMDocument *nsdoc; + nsresult nsres; + HRESULT hres; + + nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc); + if(NS_FAILED(nsres) || !nsdoc) { + ERR("GetContentDocument failed: %08x\n", nsres); + return E_FAIL; + } + + hres = set_frame_doc(&This->framebase, nsdoc); + nsIDOMDocument_Release(nsdoc); + return hres; +} + +#undef HTMLFRAME_NODE_THIS + +static const NodeImplVtbl HTMLFrameElementImplVtbl = { + HTMLFrameElement_QI, + HTMLFrameElement_destructor, + NULL, + NULL, + NULL, + NULL, + HTMLFrameElement_get_document, + NULL, + HTMLFrameElement_get_dispid, + HTMLFrameElement_invoke, + HTMLFrameElement_bind_to_tree +}; + +static const tid_t HTMLFrameElement_iface_tids[] = { + HTMLELEMENT_TIDS, + IHTMLFrameBase_tid, + IHTMLFrameBase2_tid, + IHTMLFrameElement3_tid, + 0 +}; + +static dispex_static_data_t HTMLFrameElement_dispex = { + NULL, + DispHTMLFrameElement_tid, + NULL, + HTMLFrameElement_iface_tids +}; + +HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) +{ + HTMLFrameElement *ret; + + ret = heap_alloc_zero(sizeof(HTMLFrameElement)); + + ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl; + ret->lpIHTMLFrameElement3Vtbl = &HTMLFrameElement3Vtbl; + + HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLFrameElement_dispex); + + return &ret->framebase.element; +} diff --git a/reactos/dll/win32/mshtml/htmlframebase.c b/reactos/dll/win32/mshtml/htmlframebase.c index e94c8010f9e..56c1023be8c 100644 --- a/reactos/dll/win32/mshtml/htmlframebase.c +++ b/reactos/dll/win32/mshtml/htmlframebase.c @@ -283,10 +283,10 @@ static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v) return E_INVALIDARG; if(This->nsframe) { - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr); }else if(This->nsiframe) { - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr); }else { ERR("No attached ns frame object\n"); @@ -562,108 +562,3 @@ void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLEl }else This->nsiframe = NULL; } - -typedef struct { - HTMLFrameBase framebase; -} HTMLFrameElement; - -#define HTMLFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLFrameElement, framebase.element.node, iface) - -static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - return HTMLFrameBase_QI(&This->framebase, riid, ppv); -} - -static void HTMLFrameElement_destructor(HTMLDOMNode *iface) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - HTMLFrameBase_destructor(&This->framebase); -} - -static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - if(!This->framebase.content_window || !This->framebase.content_window->doc) { - *p = NULL; - return S_OK; - } - - *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc); - IDispatch_AddRef(*p); - return S_OK; -} - -static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name, - DWORD grfdex, DISPID *pid) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - if(!This->framebase.content_window) - return DISP_E_UNKNOWNNAME; - - return search_window_props(This->framebase.content_window, name, grfdex, pid); -} - -static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid, - WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - if(!This->framebase.content_window) { - ERR("no content window to invoke on\n"); - return E_FAIL; - } - - return IDispatchEx_InvokeEx(DISPATCHEX(This->framebase.content_window), id, lcid, flags, params, res, ei, caller); -} - -static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - nsIDOMDocument *nsdoc; - nsresult nsres; - HRESULT hres; - - nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc); - if(NS_FAILED(nsres) || !nsdoc) { - ERR("GetContentDocument failed: %08x\n", nsres); - return E_FAIL; - } - - hres = set_frame_doc(&This->framebase, nsdoc); - nsIDOMDocument_Release(nsdoc); - return hres; -} - -#undef HTMLFRAME_NODE_THIS - -static const NodeImplVtbl HTMLFrameElementImplVtbl = { - HTMLFrameElement_QI, - HTMLFrameElement_destructor, - NULL, - NULL, - NULL, - NULL, - HTMLFrameElement_get_document, - NULL, - HTMLFrameElement_get_dispid, - HTMLFrameElement_invoke, - HTMLFrameElement_bind_to_tree -}; - -HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) -{ - HTMLFrameElement *ret; - - ret = heap_alloc_zero(sizeof(HTMLFrameElement)); - - ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl; - - HTMLFrameBase_Init(&ret->framebase, doc, nselem, NULL); - - return &ret->framebase.element; -} diff --git a/reactos/dll/win32/mshtml/htmlgeneric.c b/reactos/dll/win32/mshtml/htmlgeneric.c index 8b753164f00..82075b8d325 100644 --- a/reactos/dll/win32/mshtml/htmlgeneric.c +++ b/reactos/dll/win32/mshtml/htmlgeneric.c @@ -153,11 +153,7 @@ static const NodeImplVtbl HTMLGenericElementImplVtbl = { }; static const tid_t HTMLGenericElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLGenericElement_tid, 0 }; diff --git a/reactos/dll/win32/mshtml/htmliframe.c b/reactos/dll/win32/mshtml/htmliframe.c index ddb32c80ab2..12cd4275174 100644 --- a/reactos/dll/win32/mshtml/htmliframe.c +++ b/reactos/dll/win32/mshtml/htmliframe.c @@ -33,15 +33,139 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); typedef struct { HTMLFrameBase framebase; + const IHTMLIFrameElementVtbl *lpIHTMLIFrameElementVtbl; } HTMLIFrame; +#define HTMLIFRAMEELEM(x) ((IHTMLIFrameElement*) &(x)->lpIHTMLIFrameElementVtbl) + +#define HTMLIFRAME_THIS(iface) DEFINE_THIS(HTMLIFrame, IHTMLIFrameElement, iface) + +static HRESULT WINAPI HTMLIFrameElement_QueryInterface(IHTMLIFrameElement *iface, + REFIID riid, void **ppv) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + + return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->framebase.element.node), riid, ppv); +} + +static ULONG WINAPI HTMLIFrameElement_AddRef(IHTMLIFrameElement *iface) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + + return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->framebase.element.node)); +} + +static ULONG WINAPI HTMLIFrameElement_Release(IHTMLIFrameElement *iface) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + + return IHTMLDOMNode_Release(HTMLDOMNODE(&This->framebase.element.node)); +} + +static HRESULT WINAPI HTMLIFrameElement_GetTypeInfoCount(IHTMLIFrameElement *iface, UINT *pctinfo) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->framebase.element.node.dispex), pctinfo); +} + +static HRESULT WINAPI HTMLIFrameElement_GetTypeInfo(IHTMLIFrameElement *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->framebase.element.node.dispex), iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI HTMLIFrameElement_GetIDsOfNames(IHTMLIFrameElement *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->framebase.element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLIFrameElement_Invoke(IHTMLIFrameElement *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + return IDispatchEx_Invoke(DISPATCHEX(&This->framebase.element.node.dispex), dispIdMember, riid, + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLIFrameElement_put_vspace(IHTMLIFrameElement *iface, LONG v) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%d)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_get_vspace(IHTMLIFrameElement *iface, LONG *p) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_put_hspace(IHTMLIFrameElement *iface, LONG v) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%d)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_get_hspace(IHTMLIFrameElement *iface, LONG *p) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_put_align(IHTMLIFrameElement *iface, BSTR v) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_get_align(IHTMLIFrameElement *iface, BSTR *p) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +#undef HTMLIFRAME_THIS + +static const IHTMLIFrameElementVtbl HTMLIFrameElementVtbl = { + HTMLIFrameElement_QueryInterface, + HTMLIFrameElement_AddRef, + HTMLIFrameElement_Release, + HTMLIFrameElement_GetTypeInfoCount, + HTMLIFrameElement_GetTypeInfo, + HTMLIFrameElement_GetIDsOfNames, + HTMLIFrameElement_Invoke, + HTMLIFrameElement_put_vspace, + HTMLIFrameElement_get_vspace, + HTMLIFrameElement_put_hspace, + HTMLIFrameElement_get_hspace, + HTMLIFrameElement_put_align, + HTMLIFrameElement_get_align +}; + #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface) static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) { HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface); - return HTMLFrameBase_QI(&This->framebase, riid, ppv); + if(IsEqualGUID(&IID_IHTMLIFrameElement, riid)) { + TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This, ppv); + *ppv = HTMLIFRAMEELEM(This); + }else { + return HTMLFrameBase_QI(&This->framebase, riid, ppv); + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; } static void HTMLIFrame_destructor(HTMLDOMNode *iface) @@ -131,13 +255,10 @@ static const NodeImplVtbl HTMLIFrameImplVtbl = { }; static const tid_t HTMLIFrame_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLFrameBase_tid, IHTMLFrameBase2_tid, + IHTMLIFrameElement_tid, 0 }; @@ -154,6 +275,7 @@ HTMLElement *HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) ret = heap_alloc_zero(sizeof(HTMLIFrame)); + ret->lpIHTMLIFrameElementVtbl = &HTMLIFrameElementVtbl; ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl; HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex); diff --git a/reactos/dll/win32/mshtml/htmlimg.c b/reactos/dll/win32/mshtml/htmlimg.c index 87fe498b9da..17b6cceac95 100644 --- a/reactos/dll/win32/mshtml/htmlimg.c +++ b/reactos/dll/win32/mshtml/htmlimg.c @@ -228,7 +228,7 @@ static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&alt_str, v); + nsAString_InitDepend(&alt_str, v); nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str); nsAString_Finish(&alt_str); if(NS_FAILED(nsres)) @@ -268,7 +268,7 @@ static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&src_str, v); + nsAString_InitDepend(&src_str, v); nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str); nsAString_Finish(&src_str); if(NS_FAILED(nsres)) @@ -460,29 +460,69 @@ static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p) static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v) { HTMLImgElement *This = HTMLIMG_THIS(iface); - FIXME("(%p)->(%d)\n", This, v); - return E_NOTIMPL; + nsresult nsres; + + TRACE("(%p)->(%d)\n", This, v); + + nsres = nsIDOMHTMLImageElement_SetWidth(This->nsimg, v); + if(NS_FAILED(nsres)) { + ERR("SetWidth failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, LONG *p) { HTMLImgElement *This = HTMLIMG_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + PRInt32 width; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIDOMHTMLImageElement_GetWidth(This->nsimg, &width); + if(NS_FAILED(nsres)) { + ERR("GetWidth failed: %08x\n", nsres); + return E_FAIL; + } + + *p = width; + return S_OK; } static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, LONG v) { HTMLImgElement *This = HTMLIMG_THIS(iface); - FIXME("(%p)->(%d)\n", This, v); - return E_NOTIMPL; + nsresult nsres; + + TRACE("(%p)->(%d)\n", This, v); + + nsres = nsIDOMHTMLImageElement_SetHeight(This->nsimg, v); + if(NS_FAILED(nsres)) { + ERR("SetHeight failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, LONG *p) { HTMLImgElement *This = HTMLIMG_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + PRInt32 height; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIDOMHTMLImageElement_GetHeight(This->nsimg, &height); + if(NS_FAILED(nsres)) { + ERR("GetHeight failed: %08x\n", nsres); + return E_FAIL; + } + + *p = height; + return S_OK; } static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v) @@ -609,11 +649,7 @@ static const NodeImplVtbl HTMLImgElementImplVtbl = { }; static const tid_t HTMLImgElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLImgElement_tid, 0 }; @@ -728,12 +764,38 @@ static HRESULT WINAPI HTMLImageElementFactory_Invoke(IHTMLImageElementFactory *i return E_NOTIMPL; } +static LONG var_to_size(const VARIANT *v) +{ + switch(V_VT(v)) { + case VT_EMPTY: + return 0; + case VT_I4: + return V_I4(v); + case VT_BSTR: { + LONG ret; + HRESULT hres; + + hres = VarI4FromStr(V_BSTR(v), 0, 0, &ret); + if(FAILED(hres)) { + FIXME("VarI4FromStr failed: %08x\n", hres); + return 0; + } + return ret; + } + default: + FIXME("unsupported size %s\n", debugstr_variant(v)); + } + return 0; +} + static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface, VARIANT width, VARIANT height, IHTMLImgElement **img_elem) { HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface); + IHTMLImgElement *img; HTMLElement *elem; nsIDOMHTMLElement *nselem; + LONG l; HRESULT hres; static const PRUnichar imgW[] = {'I','M','G',0}; @@ -758,7 +820,7 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i return E_FAIL; } - hres = IHTMLElement_QueryInterface(HTMLELEM(elem), &IID_IHTMLImgElement, (void**)img_elem); + hres = IHTMLElement_QueryInterface(HTMLELEM(elem), &IID_IHTMLImgElement, (void**)&img); if(FAILED(hres)) { ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres); return hres; @@ -766,9 +828,14 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i nsIDOMHTMLElement_Release(nselem); - if(V_VT(&width) != VT_EMPTY || V_VT(&height) != VT_EMPTY) - FIXME("Not setting image dimensions\n"); + l = var_to_size(&width); + if(l) + IHTMLImgElement_put_width(img, l); + l = var_to_size(&height); + if(l) + IHTMLImgElement_put_height(img, l); + *img_elem = img; return S_OK; } diff --git a/reactos/dll/win32/mshtml/htmlinput.c b/reactos/dll/win32/mshtml/htmlinput.c index ae7994a291b..1b8d1c5413f 100644 --- a/reactos/dll/win32/mshtml/htmlinput.c +++ b/reactos/dll/win32/mshtml/htmlinput.c @@ -143,7 +143,7 @@ static HRESULT WINAPI HTMLInputElement_put_value(IHTMLInputElement *iface, BSTR TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&val_str, v); + nsAString_InitDepend(&val_str, v); nsres = nsIDOMHTMLInputElement_SetValue(This->nsinput, &val_str); nsAString_Finish(&val_str); if(NS_FAILED(nsres)) @@ -512,7 +512,7 @@ static HRESULT WINAPI HTMLInputElement_put_src(IHTMLInputElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLInputElement_SetSrc(This->nsinput, &nsstr); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) @@ -1173,11 +1173,7 @@ static const NodeImplVtbl HTMLInputElementImplVtbl = { }; static const tid_t HTMLInputElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLInputElement_tid, 0 }; diff --git a/reactos/dll/win32/mshtml/htmlnode.c b/reactos/dll/win32/mshtml/htmlnode.c index b8cecf0629e..a5ea3f4dd00 100644 --- a/reactos/dll/win32/mshtml/htmlnode.c +++ b/reactos/dll/win32/mshtml/htmlnode.c @@ -645,7 +645,7 @@ static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v) TRACE("bstr %s\n", debugstr_w(V_BSTR(&v))); - nsAString_Init(&val_str, V_BSTR(&v)); + nsAString_InitDepend(&val_str, V_BSTR(&v)); nsIDOMNode_SetNodeValue(This->nsnode, &val_str); nsAString_Finish(&val_str); diff --git a/reactos/dll/win32/mshtml/htmloption.c b/reactos/dll/win32/mshtml/htmloption.c index 4701c577de5..3e037627bf1 100644 --- a/reactos/dll/win32/mshtml/htmloption.c +++ b/reactos/dll/win32/mshtml/htmloption.c @@ -117,7 +117,7 @@ static HRESULT WINAPI HTMLOptionElement_put_value(IHTMLOptionElement *iface, BST TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&value_str, v); + nsAString_InitDepend(&value_str, v); nsres = nsIDOMHTMLOptionElement_SetValue(This->nsoption, &value_str); nsAString_Finish(&value_str); if(NS_FAILED(nsres)) @@ -209,7 +209,7 @@ static HRESULT WINAPI HTMLOptionElement_put_text(IHTMLOptionElement *iface, BSTR } } - nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMHTMLDocument_CreateTextNode(This->element.node.doc->nsdoc, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { @@ -324,11 +324,7 @@ static const NodeImplVtbl HTMLOptionElementImplVtbl = { }; static const tid_t HTMLOptionElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLOptionElement_tid, 0 }; diff --git a/reactos/dll/win32/mshtml/htmlscript.c b/reactos/dll/win32/mshtml/htmlscript.c index d86f3988932..2427309bfba 100644 --- a/reactos/dll/win32/mshtml/htmlscript.c +++ b/reactos/dll/win32/mshtml/htmlscript.c @@ -319,6 +319,19 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = { HTMLScriptElement_get_readystate }; +static const tid_t HTMLScriptElement_iface_tids[] = { + HTMLELEMENT_TIDS, + IHTMLScriptElement_tid, + 0 +}; + +static dispex_static_data_t HTMLScriptElement_dispex = { + NULL, + DispHTMLScriptElement_tid, + NULL, + HTMLScriptElement_iface_tids +}; + HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) { HTMLScriptElement *ret = heap_alloc_zero(sizeof(HTMLScriptElement)); @@ -327,7 +340,7 @@ HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement * ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl; ret->element.node.vtbl = &HTMLScriptElementImplVtbl; - HTMLElement_Init(&ret->element, doc, nselem, NULL); + HTMLElement_Init(&ret->element, doc, nselem, &HTMLScriptElement_dispex); nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript); if(NS_FAILED(nsres)) diff --git a/reactos/dll/win32/mshtml/htmlselect.c b/reactos/dll/win32/mshtml/htmlselect.c index f9b71826600..6698606a4c4 100644 --- a/reactos/dll/win32/mshtml/htmlselect.c +++ b/reactos/dll/win32/mshtml/htmlselect.c @@ -253,7 +253,7 @@ static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BST TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&value_str, v); + nsAString_InitDepend(&value_str, v); nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str); nsAString_Finish(&value_str); if(NS_FAILED(nsres)) @@ -332,8 +332,26 @@ static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElem VARIANT before) { HTMLSelectElement *This = HTMLSELECT_THIS(iface); - FIXME("(%p)->(%p v)\n", This, element); - return E_NOTIMPL; + IHTMLDOMNode *node, *tmp; + HRESULT hres; + + FIXME("(%p)->(%p %s): semi-stub\n", This, element, debugstr_variant(&before)); + + if(V_VT(&before) != VT_EMPTY) { + FIXME("unhandled before %s\n", debugstr_variant(&before)); + return E_NOTIMPL; + } + + hres = IHTMLElement_QueryInterface(element, &IID_IHTMLDOMNode, (void**)&node); + if(FAILED(hres)) + return hres; + + hres = IHTMLDOMNode_appendChild(HTMLDOMNODE(&This->element.node), node, &tmp); + IHTMLDOMNode_Release(node); + if(SUCCEEDED(hres) && tmp) + IHTMLDOMNode_Release(tmp); + + return hres; } static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, LONG index) @@ -487,11 +505,7 @@ static const NodeImplVtbl HTMLSelectElementImplVtbl = { }; static const tid_t HTMLSelectElement_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLSelectElement_tid, 0 }; diff --git a/reactos/dll/win32/mshtml/htmlstyle.c b/reactos/dll/win32/mshtml/htmlstyle.c index 467464ac919..cb86b79b437 100644 --- a/reactos/dll/win32/mshtml/htmlstyle.c +++ b/reactos/dll/win32/mshtml/htmlstyle.c @@ -315,9 +315,9 @@ HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCW if(flags & ATTR_FIX_URL) val = fix_url_value(value); - nsAString_Init(&str_name, style_tbl[sid].name); - nsAString_Init(&str_value, val ? val : value); - nsAString_Init(&str_empty, wszEmpty); + nsAString_InitDepend(&str_name, style_tbl[sid].name); + nsAString_InitDepend(&str_value, val ? val : value); + nsAString_InitDepend(&str_empty, wszEmpty); heap_free(val); nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty); @@ -345,10 +345,12 @@ HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, case VT_I4: { WCHAR str[14]; - static const WCHAR format[] = {'%','d',0}; - wsprintfW(str, format, V_I4(value)); - return set_nsstyle_attr(nsstyle, sid, str, flags); + static const WCHAR format[] = {'%','d',0}; + static const WCHAR px_format[] = {'%','d','p','x',0}; + + wsprintfW(str, flags&ATTR_FIX_PX ? px_format : format, V_I4(value)); + return set_nsstyle_attr(nsstyle, sid, str, flags & ~ATTR_FIX_PX); } default: FIXME("not implemented vt %d\n", V_VT(value)); @@ -369,7 +371,7 @@ static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, stylei nsAString str_name; nsresult nsres; - nsAString_Init(&str_name, style_tbl[sid].name); + nsAString_InitDepend(&str_name, style_tbl[sid].name); nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value); if(NS_FAILED(nsres)) { @@ -1531,8 +1533,10 @@ static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v) static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0); } static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v) @@ -1545,8 +1549,10 @@ static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0); } static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v) @@ -1559,8 +1565,10 @@ static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0); } static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v) @@ -1573,8 +1581,10 @@ static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0); } static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v) @@ -1779,15 +1789,7 @@ static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v) TRACE("(%p)->(v%d)\n", This, V_VT(&v)); - switch(V_VT(&v)) { - case VT_BSTR: - TRACE("%s\n", debugstr_w(V_BSTR(&v))); - return set_style_attr(This, STYLEID_WIDTH, V_BSTR(&v), 0); - default: - FIXME("unsupported vt %d\n", V_VT(&v)); - } - - return E_NOTIMPL; + return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX); } static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p) @@ -2129,7 +2131,7 @@ static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { diff --git a/reactos/dll/win32/mshtml/htmltable.c b/reactos/dll/win32/mshtml/htmltable.c index 6357f77e4ba..12869523dbc 100644 --- a/reactos/dll/win32/mshtml/htmltable.c +++ b/reactos/dll/win32/mshtml/htmltable.c @@ -558,11 +558,7 @@ static const NodeImplVtbl HTMLTableImplVtbl = { }; static const tid_t HTMLTable_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLTable_tid, 0 }; diff --git a/reactos/dll/win32/mshtml/htmltablerow.c b/reactos/dll/win32/mshtml/htmltablerow.c index 862ed75318c..950535af253 100644 --- a/reactos/dll/win32/mshtml/htmltablerow.c +++ b/reactos/dll/win32/mshtml/htmltablerow.c @@ -301,11 +301,7 @@ static const NodeImplVtbl HTMLTableRowImplVtbl = { }; static const tid_t HTMLTableRow_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLTableRow_tid, 0 }; diff --git a/reactos/dll/win32/mshtml/htmltextarea.c b/reactos/dll/win32/mshtml/htmltextarea.c index 0a07379871b..9ded8ac6e12 100644 --- a/reactos/dll/win32/mshtml/htmltextarea.c +++ b/reactos/dll/win32/mshtml/htmltextarea.c @@ -411,6 +411,19 @@ static const NodeImplVtbl HTMLTextAreaElementImplVtbl = { HTMLTextAreaElementImpl_get_disabled }; +static const tid_t HTMLTextAreaElement_iface_tids[] = { + HTMLELEMENT_TIDS, + IHTMLTextAreaElement_tid, + 0 +}; + +static dispex_static_data_t HTMLTextAreaElement_dispex = { + NULL, + DispHTMLTextAreaElement_tid, + NULL, + HTMLTextAreaElement_iface_tids +}; + HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) { HTMLTextAreaElement *ret = heap_alloc_zero(sizeof(HTMLTextAreaElement)); @@ -419,7 +432,7 @@ HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement ret->lpHTMLTextAreaElementVtbl = &HTMLTextAreaElementVtbl; ret->element.node.vtbl = &HTMLTextAreaElementImplVtbl; - HTMLElement_Init(&ret->element, doc, nselem, NULL); + HTMLElement_Init(&ret->element, doc, nselem, &HTMLTextAreaElement_dispex); nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement, (void**)&ret->nstextarea); diff --git a/reactos/dll/win32/mshtml/htmlwindow.c b/reactos/dll/win32/mshtml/htmlwindow.c index 4a2babee06d..58d5f7b5789 100644 --- a/reactos/dll/win32/mshtml/htmlwindow.c +++ b/reactos/dll/win32/mshtml/htmlwindow.c @@ -694,7 +694,7 @@ static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&name_str, v); + nsAString_InitDepend(&name_str, v); nsres = nsIDOMWindow_SetName(This->nswindow, &name_str); nsAString_Finish(&name_str); if(NS_FAILED(nsres)) @@ -1688,13 +1688,20 @@ static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid LCID lcid, DISPID *rgDispId) { HTMLWindow *This = DISPEX_THIS(iface); + UINT i; + HRESULT hres; - TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, + WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); - /* FIXME: Use script dispatch */ + for(i=0; i < cNames; i++) { + /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */ + hres = IDispatchEx_GetDispID(DISPATCHEX(This), rgszNames[i], 0, rgDispId+i); + if(FAILED(hres)) + return hres; + } - return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId); + return S_OK; } static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember, diff --git a/reactos/dll/win32/mshtml/main.c b/reactos/dll/win32/mshtml/main.c index 1e300661b1b..f54c6e3ed32 100644 --- a/reactos/dll/win32/mshtml/main.c +++ b/reactos/dll/win32/mshtml/main.c @@ -439,11 +439,14 @@ HRESULT WINAPI DllUnregisterServer(void) const char *debugstr_variant(const VARIANT *v) { + if(!v) + return "(null)"; + switch(V_VT(v)) { case VT_EMPTY: - return wine_dbg_sprintf("{VT_EMPTY}"); + return "{VT_EMPTY}"; case VT_NULL: - return wine_dbg_sprintf("{VT_NULL}"); + return "{VT_NULL}"; case VT_I4: return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v)); case VT_R8: diff --git a/reactos/dll/win32/mshtml/mshtml.inf b/reactos/dll/win32/mshtml/mshtml.inf index f493a3b5df9..dccd7366a84 100644 --- a/reactos/dll/win32/mshtml/mshtml.inf +++ b/reactos/dll/win32/mshtml/mshtml.inf @@ -90,7 +90,7 @@ HKCR,"CLSID\%CLSID_CRecalcEngine%\InProcServer32","ThreadingModel",,"Apartment" ;; CrSource HKCR,"CLSID\%CLSID_CrSource%",,,"Microsoft CrSource 4.0" -HKCR,"CLSID\%CLSID_CrSource%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_CrSource%\BrowseInPlace",,16 ;; HKCR,"CLSID\%CLSID_CrSource%\DefaultIcon",,0x00020000,"%IEXPLORE%,1" HKCR,"CLSID\%CLSID_CrSource%\EnablePlugin\.css",,,"PointPlus plugin" HKCR,"CLSID\%CLSID_CrSource%\InProcServer32",,,"mshtml.dll" @@ -113,7 +113,7 @@ HKCR,"ScriptBridge.ScriptBridge.1\CLSID",,,"%CLSID_Scriptlet%" ;; HTADocument HKCR,"CLSID\%CLSID_HTADocument%",,,"Microsoft HTA Document 6.0" -HKCR,"CLSID\%CLSID_HTADocument%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_HTADocument%\BrowseInPlace",,16 HKCR,"CLSID\%CLSID_HTADocument%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_HTADocument%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_HTADocument%\MiscStatus",,,"2228625" @@ -121,7 +121,7 @@ HKCR,"CLSID\%CLSID_HTADocument%\Version",,,"6.0" ;; HTMLDocument HKCR,"CLSID\%CLSID_HTMLDocument%",,,"HTML Document" -HKCR,"CLSID\%CLSID_HTMLDocument%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_HTMLDocument%\BrowseInPlace",,16 ;; HKCR,"CLSID\%CLSID_HTMLDocument%\DefaultIcon",,0x00020000,"%IEXPLORE%,1" HKCR,"CLSID\%CLSID_HTMLDocument%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_HTMLDocument%\InProcServer32","ThreadingModel",,"Apartment" @@ -132,7 +132,7 @@ HKCR,"CLSID\%CLSID_HTMLDocument%\EnablePlugin\.css",,,"PointPlus plugin" ;; HTMLPluginDocument HKCR,"CLSID\%CLSID_HTMLPluginDocument%",,,"Microsoft HTML Document 6.0" -HKCR,"CLSID\%CLSID_HTMLPluginDocument%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_HTMLPluginDocument%\BrowseInPlace",,16 HKCR,"CLSID\%CLSID_HTMLPluginDocument%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_HTMLPluginDocument%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_HTMLPluginDocument%\MiscStatus",,,"0" @@ -159,7 +159,7 @@ HKCR,"CLSID\%CLSID_HTMLWindowProxy%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_HTMLWindowProxy%\InProcServer32","ThreadingModel",,"Apartment" ;; IImageDecodeFilter -HKCR,"CLSID\%CLSID_IImageDecodeFilter%",,,"" +HKCR,"CLSID\%CLSID_IImageDecodeFilter%",,,"CoICOFilter Class" HKCR,"CLSID\%CLSID_IImageDecodeFilter%\InProcServer32",,,%_MOD_PATH% HKCR,"CLSID\%CLSID_IImageDecodeFilter%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"MIME\Database\Content Type\image/x-wmf","Image Filter CLSID",,"%CLSID_IImageDecodeFilter%" @@ -214,7 +214,7 @@ HKCR,"CLSID\%CLSID_MailtoProtocol%\InProcServer32","ThreadingModel",,"Apartment" ;; MHTMLDocument HKCR,"CLSID\%CLSID_MHTMLDocument%",,,"MHTML Document" -HKCR,"CLSID\%CLSID_MHTMLDocument%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_MHTMLDocument%\BrowseInPlace",,16 ;; HKCR,"CLSID\%CLSID_MHTMLDocument%\DefaultIcon",,0x00020000,"%IEXPLORE%,1" HKCR,"CLSID\%CLSID_MHTMLDocument%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_MHTMLDocument%\InProcServer32","ThreadingModel",,"Apartment" @@ -229,13 +229,13 @@ HKCR,"CLSID\%CLSID_ResProtocol%\InProcServer32","ThreadingModel",,"Apartment" ;; Scriptlet HKCR,"CLSID\%CLSID_Scriptlet%",,,"Microsoft Scriptlet Component" -HKCR,"CLSID\%CLSID_Scriptlet%\Control" +HKCR,"CLSID\%CLSID_Scriptlet%\Control",,16 HKCR,"CLSID\%CLSID_Scriptlet%\InProcServer32",,,"%_MOD_PATH%" HKCR,"CLSID\%CLSID_Scriptlet%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_Scriptlet%\MiscStatus",,,"0" HKCR,"CLSID\%CLSID_Scriptlet%\MiscStatus\1",,,"131473" HKCR,"CLSID\%CLSID_Scriptlet%\ProgID",,,"ScriptBridge.ScriptBridge.1" -HKCR,"CLSID\%CLSID_Scriptlet%\Programmable" +HKCR,"CLSID\%CLSID_Scriptlet%\Programmable",,16 ;; HKCR,"CLSID\%CLSID_Scriptlet%\ToolboxBitmap32",,,"%IEXPLORE%,1" HKCR,"CLSID\%CLSID_Scriptlet%\TypeLib",,,"%LIBID_MSHTML%" HKCR,"CLSID\%CLSID_Scriptlet%\Version",,,"4.0" @@ -337,11 +337,11 @@ HKCR,"InternetShortcut\shell\printto\command",,,"rundll32.exe mshtml.dll,PrintHT HKCR,"htmlfile\shell\print\command",,,"rundll32.exe mshtml.dll,PrintHTML ""%%1""" HKCR,"htmlfile\shell\printto\command",,,"rundll32.exe mshtml.dll,PrintHTML ""%%1"" ""%%2"" ""%%3"" ""%%4""" HKCR,"htmlfile",,,"HTML Document" -HKCR,"htmlfile\BrowseInPlace",,,"" +HKCR,"htmlfile\BrowseInPlace",,16 HKCR,"htmlfile\CLSID",,,"%CLSID_HTMLDocument%" ;; HKCR,"htmlfile\DefaultIcon",,0x00020000,"%IEXPLORE%,1" HKCR,"htmlfile_FullWindowEmbed",,,"HTML Plugin Document" -HKCR,"htmlfile_FullWindowEmbed\BrowseInPlace",,,"" +HKCR,"htmlfile_FullWindowEmbed\BrowseInPlace",,16 HKCR,"htmlfile_FullWindowEmbed\CLSID",,,"%CLSID_HTMLPluginDocument%" HKCR,".htm",,,"htmlfile" HKCR,".htm","Content Type",,"text/html" @@ -398,7 +398,7 @@ HKCR,".mhtml","Content Type",,"message/rfc822" HKCR,".mht",,2,"mhtmlfile" HKCR,".mht","Content Type",,"message/rfc822" HKCR,"mhtmlfile",,,"MHTML Document" -HKCR,"mhtmlfile\BrowseInPlace",,,"" +HKCR,"mhtmlfile\BrowseInPlace",,16 HKCR,"mhtmlfile\CLSID",,,"%CLSID_MHTMLDocument%" ;; MPEG diff --git a/reactos/dll/win32/mshtml/mshtml.rbuild b/reactos/dll/win32/mshtml/mshtml.rbuild index 562a68aac01..c3f56cd19d2 100644 --- a/reactos/dll/win32/mshtml/mshtml.rbuild +++ b/reactos/dll/win32/mshtml/mshtml.rbuild @@ -30,6 +30,7 @@ htmlelemcol.c htmlevent.c htmlform.c + htmlframe.c htmlframebase.c htmlgeneric.c htmliframe.c diff --git a/reactos/dll/win32/mshtml/mshtml_private.h b/reactos/dll/win32/mshtml/mshtml_private.h index 68b3393d868..c65bffa9f79 100644 --- a/reactos/dll/win32/mshtml/mshtml_private.h +++ b/reactos/dll/win32/mshtml/mshtml_private.h @@ -68,6 +68,7 @@ typedef enum { DispHTMLElementCollection_tid, DispHTMLFormElement_tid, DispHTMLGenericElement_tid, + DispHTMLFrameElement_tid, DispHTMLIFrame_tid, DispHTMLImg_tid, DispHTMLInputElement_tid, @@ -75,10 +76,12 @@ typedef enum { DispHTMLNavigator_tid, DispHTMLOptionElement_tid, DispHTMLScreen_tid, + DispHTMLScriptElement_tid, DispHTMLSelectElement_tid, DispHTMLStyle_tid, DispHTMLTable_tid, DispHTMLTableRow_tid, + DispHTMLTextAreaElement_tid, DispHTMLUnknownElement_tid, DispHTMLWindow2_tid, HTMLDocumentEvents_tid, @@ -108,13 +111,16 @@ typedef enum { IHTMLFormElement_tid, IHTMLFrameBase_tid, IHTMLFrameBase2_tid, + IHTMLFrameElement3_tid, IHTMLGenericElement_tid, + IHTMLIFrameElement_tid, IHTMLImageElementFactory_tid, IHTMLImgElement_tid, IHTMLInputElement_tid, IHTMLLocation_tid, IHTMLOptionElement_tid, IHTMLScreen_tid, + IHTMLScriptElement_tid, IHTMLSelectElement_tid, IHTMLStyle_tid, IHTMLStyle2_tid, @@ -122,6 +128,7 @@ typedef enum { IHTMLStyle4_tid, IHTMLTable_tid, IHTMLTableRow_tid, + IHTMLTextAreaElement_tid, IHTMLTextContainer_tid, IHTMLUniqueName_tid, IHTMLWindow2_tid, @@ -373,6 +380,7 @@ struct HTMLDocumentObj { IOleInPlaceSite *ipsite; IOleInPlaceFrame *frame; IOleInPlaceUIWindow *ip_window; + IAdviseSink *view_sink; DOCHOSTUIINFO hostinfo; @@ -487,6 +495,14 @@ typedef struct { nsIDOMHTMLElement *nselem; } HTMLElement; +#define HTMLELEMENT_TIDS \ + IHTMLDOMNode_tid, \ + IHTMLDOMNode2_tid, \ + IHTMLElement_tid, \ + IHTMLElement2_tid, \ + IHTMLElement3_tid, \ + IHTMLElement4_tid + typedef struct { HTMLElement element; @@ -696,7 +712,8 @@ void nsfree(void*); void nsACString_SetData(nsACString*,const char*); PRUint32 nsACString_GetData(const nsACString*,const char**); -void nsAString_Init(nsAString*,const PRUnichar*); +BOOL nsAString_Init(nsAString*,const PRUnichar*); +void nsAString_InitDepend(nsAString*,const PRUnichar*); void nsAString_SetData(nsAString*,const PRUnichar*); PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**); void nsAString_Finish(nsAString*); diff --git a/reactos/dll/win32/mshtml/mutation.c b/reactos/dll/win32/mshtml/mutation.c index 372c467bf53..61ceca83525 100644 --- a/reactos/dll/win32/mshtml/mutation.c +++ b/reactos/dll/win32/mshtml/mutation.c @@ -168,12 +168,12 @@ static BOOL handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *commen memcpy(buf, ptr, (end-ptr)*sizeof(WCHAR)); buf[end-ptr] = 0; - nsAString_Init(&nsstr, buf); - heap_free(buf); + nsAString_InitDepend(&nsstr, buf); /* FIXME: Find better way to insert HTML to document. */ nsres = nsIDOMHTMLDocument_Write(doc->nsdoc, &nsstr); nsAString_Finish(&nsstr); + heap_free(buf); if(NS_FAILED(nsres)) { ERR("Write failed: %08x\n", nsres); return FALSE; @@ -322,6 +322,8 @@ static void parse_complete_proc(task_t *task) init_editor(&doc->basedoc); call_explorer_69(doc); + if(doc->view_sink) + IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1); call_property_onchanged(&doc->basedoc.cp_propnotif, 1005); call_explorer_69(doc); @@ -396,7 +398,7 @@ static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface) static const PRUnichar remove_comment_magicW[] = {'#','!','w','i','n','e', 'r','e','m','o','v','e','!','#',0}; - nsAString_Init(&magic_str, remove_comment_magicW); + nsAString_InitDepend(&magic_str, remove_comment_magicW); nsres = nsIDOMComment_SetData(nscomment, &magic_str); nsAString_Finish(&magic_str); if(NS_FAILED(nsres)) diff --git a/reactos/dll/win32/mshtml/nsembed.c b/reactos/dll/win32/mshtml/nsembed.c index 68588977697..3415657fbcb 100644 --- a/reactos/dll/win32/mshtml/nsembed.c +++ b/reactos/dll/win32/mshtml/nsembed.c @@ -52,13 +52,15 @@ struct nsCStringContainer { void *v; void *d1; PRUint32 d2; - void *d3; + PRUint32 d3; }; +#define NS_STRING_CONTAINER_INIT_DEPEND 0x0002 + static nsresult (*NS_InitXPCOM2)(nsIServiceManager**,void*,void*); static nsresult (*NS_ShutdownXPCOM)(nsIServiceManager*); static nsresult (*NS_GetComponentRegistrar)(nsIComponentRegistrar**); -static nsresult (*NS_StringContainerInit)(nsStringContainer*); +static nsresult (*NS_StringContainerInit2)(nsStringContainer*,const PRUnichar*,PRUint32,PRUint32); static nsresult (*NS_CStringContainerInit)(nsCStringContainer*); static nsresult (*NS_StringContainerFinish)(nsStringContainer*); static nsresult (*NS_CStringContainerFinish)(nsCStringContainer*); @@ -194,7 +196,7 @@ static BOOL load_xpcom(const PRUnichar *gre_path) NS_DLSYM(NS_InitXPCOM2); NS_DLSYM(NS_ShutdownXPCOM); NS_DLSYM(NS_GetComponentRegistrar); - NS_DLSYM(NS_StringContainerInit); + NS_DLSYM(NS_StringContainerInit2); NS_DLSYM(NS_CStringContainerInit); NS_DLSYM(NS_StringContainerFinish); NS_DLSYM(NS_CStringContainerFinish); @@ -424,7 +426,7 @@ static BOOL init_xpcom(const PRUnichar *gre_path) nsAString path; nsIFile *gre_dir; - nsAString_Init(&path, gre_path); + nsAString_InitDepend(&path, gre_path); nsres = NS_NewLocalFile(&path, FALSE, &gre_dir); nsAString_Finish(&path); if(NS_FAILED(nsres)) { @@ -555,11 +557,18 @@ static void nsACString_Finish(nsACString *str) NS_CStringContainerFinish(str); } -void nsAString_Init(nsAString *str, const PRUnichar *data) +BOOL nsAString_Init(nsAString *str, const PRUnichar *data) { - NS_StringContainerInit(str); - if(data) - nsAString_SetData(str, data); + return NS_SUCCEEDED(NS_StringContainerInit2(str, data, PR_UINT32_MAX, 0)); +} + +/* + * Initializes nsAString with data owned by caller. + * Caller must ensure that data is valid during lifetime of string object. + */ +void nsAString_InitDepend(nsAString *str, const PRUnichar *data) +{ + NS_StringContainerInit2(str, data, PR_UINT32_MAX, NS_STRING_CONTAINER_INIT_DEPEND); } void nsAString_SetData(nsAString *str, const PRUnichar *data) diff --git a/reactos/dll/win32/mshtml/nsevents.c b/reactos/dll/win32/mshtml/nsevents.c index 46f057f079a..65bcae05c31 100644 --- a/reactos/dll/win32/mshtml/nsevents.c +++ b/reactos/dll/win32/mshtml/nsevents.c @@ -236,6 +236,9 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event set_ready_state(doc->basedoc.window, READYSTATE_COMPLETE); if(doc == doc_obj->basedoc.doc_node) { + if(doc_obj->view_sink) + IAdviseSink_OnViewChange(doc_obj->view_sink, DVASPECT_CONTENT, -1); + if(doc_obj->frame) { static const WCHAR wszDone[] = {'D','o','n','e',0}; IOleInPlaceFrame_SetStatusText(doc_obj->frame, wszDone); @@ -316,7 +319,7 @@ static void init_event(nsIDOMEventTarget *target, const PRUnichar *type, nsAString type_str; nsresult nsres; - nsAString_Init(&type_str, type); + nsAString_InitDepend(&type_str, type); nsres = nsIDOMEventTarget_AddEventListener(target, &type_str, listener, capture); nsAString_Finish(&type_str); if(NS_FAILED(nsres)) diff --git a/reactos/dll/win32/mshtml/nsio.c b/reactos/dll/win32/mshtml/nsio.c index 46fdcbc320c..763e877eafd 100644 --- a/reactos/dll/win32/mshtml/nsio.c +++ b/reactos/dll/win32/mshtml/nsio.c @@ -438,7 +438,7 @@ static nsresult NSAPI nsChannel_GetSecurityInfo(nsIHttpChannel *iface, nsISuppor { nsChannel *This = NSCHANNEL_THIS(iface); - FIXME("(%p)->(%p)\n", This, aSecurityInfo); + TRACE("(%p)->(%p)\n", This, aSecurityInfo); return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/reactos/dll/win32/mshtml/rsrc.rc b/reactos/dll/win32/mshtml/rsrc.rc index 5e669de70ef..7df2d924d4b 100644 --- a/reactos/dll/win32/mshtml/rsrc.rc +++ b/reactos/dll/win32/mshtml/rsrc.rc @@ -16,6 +16,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "windef.h" +#include "winuser.h" +#include "commctrl.h" +#include "mshtmcid.h" + +#include "resource.h" + #define WINE_OLESELFREGISTER #define WINE_FILEDESCRIPTION_STR "Wine HTML Viewer" #define WINE_FILENAME_STR "mshtml.dll" @@ -26,6 +33,32 @@ #include "wine/wine_common_ver.rc" +#include "Bg.rc" +#include "Da.rc" +#include "De.rc" +#include "En.rc" +#include "Es.rc" +#include "Fi.rc" +#include "Fr.rc" +#include "Hu.rc" +#include "It.rc" +#include "Ja.rc" +#include "Ko.rc" +#include "Lt.rc" +#include "Nl.rc" +#include "No.rc" +#include "Pl.rc" +#include "Pt.rc" +#include "Ro.rc" +#include "Ru.rc" +#include "Si.rc" +#include "Sv.rc" +#include "Tr.rc" +#include "Uk.rc" +#include "Zh.rc" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + /* @makedep: mshtml.inf */ REGINST REGINST mshtml.inf diff --git a/reactos/dll/win32/mshtml/script.c b/reactos/dll/win32/mshtml/script.c index efd2605de39..1d21da9a07e 100644 --- a/reactos/dll/win32/mshtml/script.c +++ b/reactos/dll/win32/mshtml/script.c @@ -758,9 +758,9 @@ static BOOL get_script_guid(nsIDOMHTMLScriptElement *nsscript, GUID *guid) ERR("GetType failed: %08x\n", nsres); } - nsAString_Init(&attr_str, languageW); - + nsAString_InitDepend(&attr_str, languageW); nsres = nsIDOMHTMLScriptElement_GetAttribute(nsscript, &attr_str, &val_str); + nsAString_Finish(&attr_str); if(NS_SUCCEEDED(nsres)) { const PRUnichar *language; @@ -776,7 +776,6 @@ static BOOL get_script_guid(nsIDOMHTMLScriptElement *nsscript, GUID *guid) ERR("GetAttribute(language) failed: %08x\n", nsres); } - nsAString_Finish(&attr_str); nsAString_Finish(&val_str); return ret; diff --git a/reactos/dll/win32/mshtml/txtrange.c b/reactos/dll/win32/mshtml/txtrange.c index 0ece6ecb969..9b2bb94aec4 100644 --- a/reactos/dll/win32/mshtml/txtrange.c +++ b/reactos/dll/win32/mshtml/txtrange.c @@ -1141,7 +1141,7 @@ static HRESULT WINAPI HTMLTxtRange_put_text(IHTMLTxtRange *iface, BSTR v) if(!This->doc) return MSHTML_E_NODOC; - nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc->nsdoc, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { diff --git a/reactos/dll/win32/mshtml/view.c b/reactos/dll/win32/mshtml/view.c index f4c62a03d63..261e959b0ad 100644 --- a/reactos/dll/win32/mshtml/view.c +++ b/reactos/dll/win32/mshtml/view.c @@ -807,8 +807,19 @@ static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze) static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink) { HTMLDocument *This = VIEWOBJ_THIS(iface); - FIXME("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink); - return E_NOTIMPL; + + TRACE("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink); + + if(aspects != DVASPECT_CONTENT || advf != ADVF_PRIMEFIRST) + FIXME("unsuported arguments\n"); + + if(This->doc_obj->view_sink) + IAdviseSink_Release(This->doc_obj->view_sink); + if(pAdvSink) + IAdviseSink_AddRef(pAdvSink); + + This->doc_obj->view_sink = pAdvSink; + return S_OK; } static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink) diff --git a/reactos/include/psdk/mshtmdid.h b/reactos/include/psdk/mshtmdid.h index 0d128493dbe..e3683e9755b 100644 --- a/reactos/include/psdk/mshtmdid.h +++ b/reactos/include/psdk/mshtmdid.h @@ -126,6 +126,11 @@ #define DISPID_IE8_ELEMENTMAX (DISPID_SITE-1) #define DISPID_IE8_ELEMENT DISPID_IE8_ELEMENTBASE +#define DISPID_IE8_FRAMESITEBASE (DISPID_FRAMESITE+1120) +#define DISPID_IE8_FRAMEMAX (WEBOC_DISPIDBASE-1) +#define DISPID_IE8_FRAME DISPID_IE8_FRAMESITEBASE +#define DISPID_IE8_IFRAME DISPID_IE8_FRAMESITEBASE + #define DISPID_COLLECTION (DISPID_NORMAL_FIRST+500) #define DISPID_OPTIONS_COL (DISPID_NORMAL_FIRST+500) #define DISPID_IMG (DISPID_IMGBASE+1000) @@ -2487,6 +2492,9 @@ /* IHTMLScriptElement2 */ #define DISPID_IHTMLSCRIPTELEMENT2_CHARSET DISPID_SCRIPT+10 +/* IHTMLScriptElement3 */ +#define DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC DISPID_IE8_SCRIPT + /* IHTMLFrameBase */ #define DISPID_IHTMLFRAMEBASE_SRC DISPID_FRAMESITE+0 #define DISPID_IHTMLFRAMEBASE_NAME STDPROPID_XOBJ_NAME @@ -2508,6 +2516,19 @@ /* IHTMLFrameBase3 */ #define DISPID_IHTMLFRAMEBASE3_LONGDESC DISPID_FRAMESITE+10 +/* IHTMLFrameElement */ +#define DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR DISPID_FRAME+1 + +/* IHTMLFrameElement2 */ +#define DISPID_IHTMLFRAMEELEMENT2_HEIGHT STDPROPID_XOBJ_HEIGHT +#define DISPID_IHTMLFRAMEELEMENT2_WIDTH STDPROPID_XOBJ_WIDTH + +/* IHTMLFrameElement3 */ +#define DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT DISPID_IE8_FRAME +#define DISPID_IHTMLFRAMEELEMENT3_IE8_SRC DISPID_IE8_FRAME+1 +#define DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC DISPID_IE8_FRAME+2 +#define DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER DISPID_IE8_FRAME+3 + /* IHTMLIFrameElement */ #define DISPID_IHTMLIFRAMEELEMENT_VSPACE DISPID_IFRAME+1 #define DISPID_IHTMLIFRAMEELEMENT_HSPACE DISPID_IFRAME+2 diff --git a/reactos/include/psdk/mshtml.idl b/reactos/include/psdk/mshtml.idl index 4a182f23bbc..98edbbc32dc 100644 --- a/reactos/include/psdk/mshtml.idl +++ b/reactos/include/psdk/mshtml.idl @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007 Jacek Caban for CodeWeavers + * Copyright 2004-2010 Jacek Caban for CodeWeavers * Copyright 2008 Konstantin Kondratyuk (Etersoft) * * This library is free software; you can redistribute it and/or @@ -2876,7 +2876,7 @@ interface IHTMLCurrentStyle4 : IDispatch [propget, id(DISPID_IHTMLCURRENTSTYLE4_MAXWIDTH), displaybind, bindable] HRESULT maxWidth([retval, out] VARIANT * p); -}; +} /***************************************************************************** * DispHTMLCurrentStyle dispinterface @@ -5903,7 +5903,7 @@ coclass HTMLStyleSheetPage [default] dispinterface DispHTMLStyleSheetPage; interface IHTMLStyleSheetPage; interface IHTMLDOMConstructor; -}; +} [ odl, @@ -6702,7 +6702,7 @@ methods: [id(DISPID_HTMLFORMELEMENTEVENTS_ONRESET)] VARIANT_BOOL onreset(); -}; +} interface IHTMLEventObj; @@ -6905,7 +6905,7 @@ methods: [id(DISPID_HTMLFORMELEMENTEVENTS2_ONRESET)] VARIANT_BOOL onreset([in] IHTMLEventObj* pEvtObj); -}; +} [ noncreatable, @@ -7365,7 +7365,7 @@ interface IHTMLControlElement : IDispatch [propget, id(DISPID_IHTMLCONTROLELEMENT_CLIENTLEFT), displaybind, bindable] HRESULT clientLeft([retval, out] LONG * p); -}; +} /***************************************************************************** * IHTMLBodyElement interface @@ -7634,7 +7634,7 @@ methods: [propget, id(DISPID_IHTMLBODYELEMENT2_ONAFTERPRINT), displaybind, bindable] VARIANT onafterprint(); -}; +} [ uuid(3050f24a-98b5-11cf-bb82-00aa00bdce0b) @@ -7655,7 +7655,7 @@ coclass HTMLBody interface IHTMLTextContainer; interface IHTMLBodyElement; interface IHTMLBodyElement2; -}; +} /***************************************************************************** * IHTMLAnchorElement interface @@ -8970,6 +8970,92 @@ interface IHTMLTextAreaElement : IDispatch HRESULT createTextRange([retval, out] IHTMLTxtRange **range); } +/***************************************************************************** + * DispHTMLTextAreaElement dispinterface + */ +[ + hidden, + uuid(3050f521-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLTextAreaElement +{ +properties: +methods: + WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL; + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_TYPE)] + BSTR type(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_VALUE), displaybind, bindable] + void value(BSTR v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_VALUE), displaybind, bindable] + BSTR value(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_NAME), displaybind, bindable] + void name(BSTR v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_NAME), displaybind, bindable] + BSTR name(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_STATUS)] + void status(VARIANT v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_STATUS)] + VARIANT status(); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_FORM)] + IHTMLFormElement *form(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_DEFAULTVALUE), displaybind, bindable, hidden] + void defaultValue(BSTR v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_DEFAULTVALUE), displaybind, bindable, hidden] + BSTR defaultValue(); + + [id(DISPID_IHTMLTEXTAREAELEMENT_SELECT)] + void select(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ONCHANGE), displaybind, bindable] + void onchange(VARIANT v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ONCHANGE), displaybind, bindable] + VARIANT onchange(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ONSELECT), displaybind, bindable] + void onselect(VARIANT v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ONSELECT), displaybind, bindable] + VARIANT onselect(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_READONLY), displaybind, bindable] + void readOnly(VARIANT_BOOL v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_READONLY), displaybind, bindable] + VARIANT_BOOL readOnly(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ROWS), displaybind, bindable] + void rows(LONG v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ROWS), displaybind, bindable] + LONG rows(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_COLS), displaybind, bindable] + void cols(LONG v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_COLS), displaybind, bindable] + LONG cols(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_WRAP), displaybind, bindable] + void wrap(BSTR v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_WRAP), displaybind, bindable] + BSTR wrap(); + + [id(DISPID_IHTMLTEXTAREAELEMENT_CREATETEXTRANGE)] + IHTMLTxtRange *createTextRange(); +} + /***************************************************************************** * DispHTMLUnknownElement interface */ @@ -10245,7 +10331,7 @@ interface IHTMLWindow4 : IDispatch [propget, id(DISPID_IHTMLWINDOW4_FRAMEELEMENT)] HRESULT frameElement([retval, out] IHTMLFrameBase* * p); -}; +} /***************************************************************************** * IHTMLWindow5 interface @@ -10263,7 +10349,7 @@ interface IHTMLWindow5 : IDispatch [propget, id(DISPID_IHTMLWINDOW5_XMLHTTPREQUEST)] HRESULT XMLHttpRequest([retval, out] VARIANT * p); -}; +} /***************************************************************************** * DispHTMLScreen dispinterface @@ -10902,7 +10988,7 @@ methods: [propget, id(DISPID_IHTMLWINDOW5_XMLHTTPREQUEST)] VARIANT XMLHttpRequest(); -}; +} /***************************************************************************** * HTMLWindowEvents interface @@ -10949,7 +11035,7 @@ methods: [id(DISPID_HTMLWINDOWEVENTS_ONAFTERPRINT)] void onafterprint(); -}; +} /***************************************************************************** * HTMLWindowEvents2 interface @@ -10996,7 +11082,7 @@ methods: [id(DISPID_HTMLWINDOWEVENTS2_ONAFTERPRINT)] void onafterprint([in] IHTMLEventObj* pEvtObj); -}; +} /***************************************************************************** * HTMLWindowProxy class @@ -11013,7 +11099,7 @@ coclass HTMLWindowProxy interface IHTMLWindow3; interface IHTMLWindow4; interface IHTMLWindow5; -}; +} /***************************************************************************** * HTMLDocumentEvents2 interface @@ -11473,7 +11559,7 @@ methods: [id(DISPID_HTMLTEXTCONTAINEREVENTS_ONSELECT)] void onselect(); -}; +} /***************************************************************************** * HTMLTextContainerEvents2 interface @@ -11677,7 +11763,7 @@ methods: [id(DISPID_HTMLTEXTCONTAINEREVENTS2_ONSELECT)] void onselect([in] IHTMLEventObj* pEvtObj); -}; +} /***************************************************************************** * IHTMLDocument interface @@ -13329,7 +13415,8 @@ methods: [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEWHEEL)] VARIANT_BOOL onmousewheel([in] IHTMLEventObj* pEvtObj); -}; +} + [ hidden, uuid(3050f33c-98b5-11cf-bb82-00aa00bdce0b) @@ -13526,8 +13613,7 @@ methods: [id(DISPID_HTMLELEMENTEVENTS_ONFOCUSOUT)] void onfocusout(); - -}; +} [ noncreatable, @@ -13943,7 +14029,7 @@ methods: [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEWHEEL)] VARIANT_BOOL onmousewheel([in] IHTMLEventObj* pEvtObj); -}; +} /***************************************************************************** * IHTMLTableCaption interface @@ -14153,7 +14239,7 @@ interface IHTMLTable2 : IDispatch HRESULT moveRow([defaultvalue(-1), in] LONG indexFrom, [defaultvalue(-1), in] LONG indexTo, [retval, out] IDispatch** row); -}; +} [ odl, @@ -14168,7 +14254,7 @@ interface IHTMLTable3 : IDispatch [propget, id(DISPID_IHTMLTABLE3_SUMMARY), displaybind, bindable] HRESULT summary([retval, out] BSTR * p); -}; +} [ noncreatable, @@ -14191,7 +14277,7 @@ coclass HTMLTable interface IHTMLTable; interface IHTMLTable2; interface IHTMLTable3; -}; +} [ odl, @@ -14626,6 +14712,74 @@ interface IHTMLScriptElement2 : IDispatch HRESULT charset([retval, out] BSTR *p); } +/***************************************************************************** + * DispHTMLScriptElement dispinterface + */ +[ + hidden, + uuid(3050f530-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLScriptElement +{ +properties: +methods: + WINE_HTMLELEMENT_DISPINTERFACE_DECL; + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_SRC), displaybind, bindable] + void src(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_SRC), displaybind, bindable] + BSTR src(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_HTMLFOR), displaybind, bindable] + void htmlFor(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_HTMLFOR), displaybind, bindable] + BSTR htmlFor(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_EVENT), displaybind, bindable] + void event(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_EVENT), displaybind, bindable] + BSTR event(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_TEXT), displaybind, bindable] + void text(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_TEXT), displaybind, bindable] + BSTR text(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_DEFER), displaybind, bindable] + void defer(VARIANT_BOOL v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_DEFER), displaybind, bindable] + VARIANT_BOOL defer(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_ONERROR), displaybind, bindable] + void onerror(VARIANT v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_ONERROR), displaybind, bindable] + VARIANT onerror(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_TYPE), displaybind, bindable] + void type(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_TYPE), displaybind, bindable] + BSTR type(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT2_CHARSET), displaybind, bindable] + void charset(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT2_CHARSET), displaybind, bindable] + BSTR charset(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC)] + void ie8_src(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC)] + BSTR ie8_src(); +} + /***************************************************************************** * IHTMLFrameBase interface */ @@ -14692,6 +14846,61 @@ interface IHTMLFrameBase : IDispatch HRESULT scrolling([out, retval] BSTR *p); } +#define WINE_IHTMLFRAMEBASE_DISPINTERFACE_DECL \ + [propput, id(DISPID_IHTMLFRAMEBASE_SRC)] \ + void src(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_SRC)] \ + BSTR src(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_NAME)] \ + void name(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_NAME)] \ + BSTR name(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_BORDER)] \ + void border(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_BORDER)] \ + VARIANT border(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)] \ + void frameBorder(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)] \ + BSTR frameBorder(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)] \ + void frameSpacing(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)] \ + VARIANT frameSpacing(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)] \ + void marginWidth(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)] \ + VARIANT marginWidth(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)] \ + void marginHeight(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)] \ + VARIANT marginHeight(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_NORESIZE)] \ + void noResize(VARIANT_BOOL v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_NORESIZE)] \ + VARIANT_BOOL noResize(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_SCROLLING)] \ + void scrolling(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_SCROLLING)] \ + BSTR scrolling() + /***************************************************************************** * IHTMLFrameBase2 interface */ @@ -14728,6 +14937,152 @@ interface IHTMLFrameBase2 : IDispatch HRESULT allowTransparency([retval, out] VARIANT_BOOL *p); } +#define WINE_IHTMLFRAMEBASE2_DISPINTERFACE_DECL \ + [propget, id(DISPID_IHTMLFRAMEBASE2_CONTENTWINDOW)] \ + IHTMLWindow2 *contentWindow(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] \ + void onload(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] \ + VARIANT onload(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)] \ + void allowTransparency(VARIANT_BOOL v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)] \ + VARIANT_BOOL allowTransparency() + +#define WINE_IHTMLFRAMEBASE3_DISPINTERFACE_DECL \ + [propput, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] \ + void longDesc(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] \ + BSTR longDesc() + + +#define WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL \ + WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL; \ + WINE_IHTMLFRAMEBASE_DISPINTERFACE_DECL; \ + WINE_IHTMLFRAMEBASE2_DISPINTERFACE_DECL; \ + WINE_IHTMLFRAMEBASE3_DISPINTERFACE_DECL + +/***************************************************************************** + * IHTMLFrameElement3 interface + */ +[ + odl, + oleautomation, + dual, + uuid(3051042d-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLFrameElement3 : IDispatch +{ + [propget, id(DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT)] + HRESULT contentDocument([out, retval] IDispatch **p); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)] + HRESULT src([in] BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)] + HRESULT src([out, retval] BSTR *p); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)] + HRESULT longDesc([in] BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)] + HRESULT longDesc([out, retval] BSTR *p); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)] + HRESULT frameBorder([in] BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)] + HRESULT frameBorder([out, retval] BSTR * p); +} + +/***************************************************************************** + * DispHTMLFrameElement dispinterface + */ +[ + hidden, + uuid(3050f513-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLFrameElement +{ +properties: +methods: + WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL; + + [propput, id(DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR)] + void borderColor(VARIANT v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR)] + VARIANT borderColor(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT2_HEIGHT)] + void height(VARIANT v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT2_HEIGHT)] + VARIANT height(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT2_WIDTH)] + void width(VARIANT v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT2_WIDTH)] + VARIANT width(); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT)] + IDispatch *contentDocument(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)] + void ie8_src(BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)] + BSTR ie8_src(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)] + void ie8_longDesc(BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)] + BSTR ie8_longDesc(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)] + void ie8_frameBorder(BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)] + BSTR ie8_frameBorder(); +} + +/***************************************************************************** + * IHTMLIFrameElement interface + */ +[ + odl, + oleautomation, + dual, + uuid(3050f315-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLIFrameElement : IDispatch +{ + [propput, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)] + HRESULT vspace([in] LONG v); + + [propget, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)] + HRESULT vspace([retval, out] LONG *p); + + [propput, id(DISPID_IHTMLIFRAMEELEMENT_HSPACE)] + HRESULT hspace([in] LONG v); + + [propget, id(DISPID_IHTMLIFRAMEELEMENT_HSPACE)] + HRESULT hspace([retval, out] LONG *p); + + [propput, id(DISPID_IHTMLIFRAMEELEMENT_ALIGN), displaybind, bindable] + HRESULT align([in] BSTR v); + + [propget, id(DISPID_IHTMLIFRAMEELEMENT_ALIGN), displaybind, bindable] + HRESULT align([retval, out] BSTR *p); +} + /***************************************************************************** * DispHTMLIFrame dispinterface */ @@ -14739,82 +15094,7 @@ dispinterface DispHTMLIFrame { properties: methods: - WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL; - - [propput, id(DISPID_IHTMLFRAMEBASE_SRC)] - void src(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE_SRC)] - BSTR src(); - - [propput, id(DISPID_IHTMLFRAMEBASE_NAME)] - void name(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE_NAME)] - BSTR name(); - - [propput, id(DISPID_IHTMLFRAMEBASE_BORDER)] - void border(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE_BORDER)] - VARIANT border(); - - [propput, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)] - void frameBorder(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)] - BSTR frameBorder(); - - [propput, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)] - void frameSpacing(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)] - VARIANT frameSpacing(); - - [propput, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)] - void marginWidth(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)] - VARIANT marginWidth(); - - [propput, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)] - void marginHeight(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)] - VARIANT marginHeight(); - - [propput, id(DISPID_IHTMLFRAMEBASE_NORESIZE)] - void noResize(VARIANT_BOOL v); - - [propget, id(DISPID_IHTMLFRAMEBASE_NORESIZE)] - VARIANT_BOOL noResize(); - - [propput, id(DISPID_IHTMLFRAMEBASE_SCROLLING)] - void scrolling(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE_SCROLLING)] - BSTR scrolling(); - - [propget, id(DISPID_IHTMLFRAMEBASE2_CONTENTWINDOW)] - IHTMLWindow2 *contentWindow(); - - [propput, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] - void onload(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] - VARIANT onload(); - - [propput, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)] - void allowTransparency(VARIANT_BOOL v); - - [propget, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)] - VARIANT_BOOL allowTransparency(); - - [propput, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] - void longDesc(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] - BSTR longDesc(); + WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL; [propput, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)] void vspace(LONG v); From 26a4722d68520a81f5a869dbeb98f675369ed0c5 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 2 Mar 2010 16:27:50 +0000 Subject: [PATCH 029/211] [KSPROXY] - Implement IPersistPropertyBag interface - Implement IKsObject interface - Implement enumerating supported property/method/event set from driver and loading the corresponding ksproxy plugins svn path=/trunk/; revision=45759 --- reactos/dll/directx/ksproxy/basicaudio.cpp | 30 +- reactos/dll/directx/ksproxy/clockforward.cpp | 3 +- reactos/dll/directx/ksproxy/cvpconfig.cpp | 4 +- reactos/dll/directx/ksproxy/cvpvbiconfig.cpp | 4 +- reactos/dll/directx/ksproxy/datatype.cpp | 5 +- reactos/dll/directx/ksproxy/interface.cpp | 3 +- reactos/dll/directx/ksproxy/ksproxy.rbuild | 2 +- reactos/dll/directx/ksproxy/precomp.h | 3 +- reactos/dll/directx/ksproxy/proxy.cpp | 506 +++++++++++++++++- .../dll/directx/ksproxy/qualityforward.cpp | 4 +- 10 files changed, 533 insertions(+), 31 deletions(-) diff --git a/reactos/dll/directx/ksproxy/basicaudio.cpp b/reactos/dll/directx/ksproxy/basicaudio.cpp index 20b5e8aee24..7fec05f2140 100644 --- a/reactos/dll/directx/ksproxy/basicaudio.cpp +++ b/reactos/dll/directx/ksproxy/basicaudio.cpp @@ -8,8 +8,6 @@ */ #include "precomp.h" -const GUID IID_IBasicAudio = {0x56a868b3, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; - class CKsBasicAudio : public IBasicAudio, public IDistributorNotify { @@ -99,7 +97,7 @@ HRESULT STDMETHODCALLTYPE CKsBasicAudio::Stop() { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -107,7 +105,7 @@ HRESULT STDMETHODCALLTYPE CKsBasicAudio::Pause() { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -116,7 +114,7 @@ STDMETHODCALLTYPE CKsBasicAudio::Run( REFERENCE_TIME tStart) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -125,7 +123,7 @@ STDMETHODCALLTYPE CKsBasicAudio::SetSyncSource( IReferenceClock *pClock) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -133,7 +131,7 @@ HRESULT STDMETHODCALLTYPE CKsBasicAudio::NotifyGraphChange() { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -146,7 +144,7 @@ STDMETHODCALLTYPE CKsBasicAudio::GetTypeInfoCount( UINT *pctinfo) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -157,7 +155,7 @@ CKsBasicAudio::GetTypeInfo( LCID lcid, ITypeInfo **ppTInfo) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -170,7 +168,7 @@ CKsBasicAudio::GetIDsOfNames( LCID lcid, DISPID *rgDispId) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -186,7 +184,7 @@ CKsBasicAudio::Invoke( EXCEPINFO *pExcepInfo, UINT *puArgErr) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -199,7 +197,7 @@ STDMETHODCALLTYPE CKsBasicAudio::put_Volume( long lVolume) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -209,7 +207,7 @@ STDMETHODCALLTYPE CKsBasicAudio::get_Volume( long *plVolume) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -219,7 +217,7 @@ STDMETHODCALLTYPE CKsBasicAudio::put_Balance( long lBalance) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -229,7 +227,7 @@ STDMETHODCALLTYPE CKsBasicAudio::get_Balance( long *plBalance) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -240,6 +238,8 @@ CKsBasicAudio_Constructor( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CKsBasicAudio_Constructor\n"); + CKsBasicAudio * handler = new CKsBasicAudio(); if (!handler) diff --git a/reactos/dll/directx/ksproxy/clockforward.cpp b/reactos/dll/directx/ksproxy/clockforward.cpp index a5889386f0a..cba65b3cdf0 100644 --- a/reactos/dll/directx/ksproxy/clockforward.cpp +++ b/reactos/dll/directx/ksproxy/clockforward.cpp @@ -8,7 +8,6 @@ */ #include "precomp.h" -const GUID IID_IDistributorNotify = {0x56a868af, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; const GUID KSCATEGORY_CLOCK = {0x53172480, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; class CKsClockForwarder : public IDistributorNotify, @@ -158,6 +157,8 @@ CKsClockForwarder_Constructor( HRESULT hr; HANDLE handle; + OutputDebugStringW(L"CKsClockForwarder_Constructor\n"); + // open default clock hr = KsOpenDefaultDevice(KSCATEGORY_CLOCK, GENERIC_READ | GENERIC_WRITE, &handle); diff --git a/reactos/dll/directx/ksproxy/cvpconfig.cpp b/reactos/dll/directx/ksproxy/cvpconfig.cpp index ffe4fc7bb5f..91d2006ad49 100644 --- a/reactos/dll/directx/ksproxy/cvpconfig.cpp +++ b/reactos/dll/directx/ksproxy/cvpconfig.cpp @@ -8,8 +8,6 @@ */ #include "precomp.h" -const GUID IID_IVPConfig = {0xbc29a660, 0x30e3, 0x11d0, {0x9e, 0x69, 0x0, 0xc0, 0x4f, 0xd7, 0xc1, 0x5b}}; - class CVPConfig : public IVPConfig, public IDistributorNotify { @@ -302,6 +300,8 @@ CVPConfig_Constructor( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CVPConfig_Constructor\n"); + CVPConfig * handler = new CVPConfig(); if (!handler) diff --git a/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp b/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp index 061d332c53f..016d060aa24 100644 --- a/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp +++ b/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp @@ -8,8 +8,6 @@ */ #include "precomp.h" -const GUID IID_IVPVBIConfig = {0xec529b00, 0x1a1f, 0x11d1, {0xba, 0xd9, 0x0, 0x60, 0x97, 0x44, 0x11, 0x1a}}; - class CVPVBIConfig : public IVPVBIConfig, public IDistributorNotify { @@ -274,6 +272,8 @@ CVPVBIConfig_Constructor( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CVPVBIConfig_Constructor\n"); + CVPVBIConfig * handler = new CVPVBIConfig(); if (!handler) diff --git a/reactos/dll/directx/ksproxy/datatype.cpp b/reactos/dll/directx/ksproxy/datatype.cpp index 37f47e231af..3d2d925f19c 100644 --- a/reactos/dll/directx/ksproxy/datatype.cpp +++ b/reactos/dll/directx/ksproxy/datatype.cpp @@ -11,9 +11,6 @@ /* FIXME guid mess */ const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; -const GUID IID_IKsDataTypeHandler = {0x5FFBAA02, 0x49A3, 0x11D0, {0x9F, 0x36, 0x00, 0xAA, 0x00, 0xA2, 0x16, 0xA1}}; -const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; - class CKsDataTypeHandler : public IKsDataTypeHandler { @@ -138,6 +135,8 @@ CKsDataTypeHandler_Constructor ( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CKsDataTypeHandler_Constructor\n"); + CKsDataTypeHandler * handler = new CKsDataTypeHandler(); if (!handler) diff --git a/reactos/dll/directx/ksproxy/interface.cpp b/reactos/dll/directx/ksproxy/interface.cpp index cd8dc806d84..4289cd1fc11 100644 --- a/reactos/dll/directx/ksproxy/interface.cpp +++ b/reactos/dll/directx/ksproxy/interface.cpp @@ -8,7 +8,6 @@ */ #include "precomp.h" -const GUID IID_IKsInterfaceHandler = {0xD3ABC7E0, 0x9A61, 0x11D0, {0xA4, 0x0D, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}; const GUID IID_IKsObject = {0x423c13a2, 0x2070, 0x11d0, {0x9e, 0xf7, 0x00, 0xaa, 0x00, 0xa2, 0x16, 0xa1}}; class CKsInterfaceHandler : public IKsInterfaceHandler @@ -119,6 +118,8 @@ CKsInterfaceHandler_Constructor( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CKsInterfaceHandler_Constructor\n"); + CKsInterfaceHandler * handler = new CKsInterfaceHandler(); if (!handler) diff --git a/reactos/dll/directx/ksproxy/ksproxy.rbuild b/reactos/dll/directx/ksproxy/ksproxy.rbuild index f7a0bbd3e6b..76eb3aa8b20 100644 --- a/reactos/dll/directx/ksproxy/ksproxy.rbuild +++ b/reactos/dll/directx/ksproxy/ksproxy.rbuild @@ -10,7 +10,7 @@ ole32 setupapi msvcrt - + strmiids -fno-exceptions -fno-rtti diff --git a/reactos/dll/directx/ksproxy/precomp.h b/reactos/dll/directx/ksproxy/precomp.h index cf72d8c8195..ceef173034d 100644 --- a/reactos/dll/directx/ksproxy/precomp.h +++ b/reactos/dll/directx/ksproxy/precomp.h @@ -1,5 +1,6 @@ #pragma once +#define _FORCENAMELESSUNION #define BUILDING_KS #define _KSDDK_ #include @@ -14,8 +15,8 @@ #include #include #include - #include +#include //#include typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); diff --git a/reactos/dll/directx/ksproxy/proxy.cpp b/reactos/dll/directx/ksproxy/proxy.cpp index a6d82458cc7..23b013fafea 100644 --- a/reactos/dll/directx/ksproxy/proxy.cpp +++ b/reactos/dll/directx/ksproxy/proxy.cpp @@ -8,15 +8,20 @@ */ #include "precomp.h" +const GUID IID_IPersistPropertyBag = {0x37D84F60, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}}; +const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; + /* Needs IKsClock, IKsNotifyEvent */ class CKsProxy : public IBaseFilter, public IAMovieSetup, + public IPersistPropertyBag, + public IKsObject +/* public IPersistStream, public ISpecifyPropertyPages, - public IPersistPropertyBag, public IReferenceClock, public IMediaSeeking, public IKsObject, @@ -27,12 +32,490 @@ class CKsProxy : public IBaseFilter, public IKsTopology, public IKsAggregateControl, public IAMDeviceRemoval +*/ { +public: + typedef std::vectorProxyPluginVector; + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + // IBaseFilter methods + HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); + HRESULT STDMETHODCALLTYPE Stop( void); + HRESULT STDMETHODCALLTYPE Pause( void); + HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); + HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State); + HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); + HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **pClock); + HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); + HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); + HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); + HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); + HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); + + //IAMovieSetup methods + HRESULT STDMETHODCALLTYPE Register( void); + HRESULT STDMETHODCALLTYPE Unregister( void); + + // IPersistPropertyBag methods + HRESULT STDMETHODCALLTYPE InitNew( void); + HRESULT STDMETHODCALLTYPE Load(IPropertyBag *pPropBag, IErrorLog *pErrorLog); + HRESULT STDMETHODCALLTYPE Save(IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties); + + // IKsObject + HANDLE STDMETHODCALLTYPE KsGetObjectHandle(); + + CKsProxy() : m_Ref(0), m_pGraph(0), m_ReferenceClock(0), m_FilterState(State_Stopped), m_hDevice(0), m_Plugins(0) {}; + virtual ~CKsProxy() + { + if (m_hDevice) + CloseHandle(m_hDevice); + }; + + HRESULT STDMETHODCALLTYPE GetSupportedSets(LPGUID * pOutGuid, PULONG NumGuids); + HRESULT STDMETHODCALLTYPE LoadProxyPlugins(LPGUID pGuids, ULONG NumGuids); + +protected: + LONG m_Ref; + IFilterGraph *m_pGraph; + IReferenceClock * m_ReferenceClock; + FILTER_STATE m_FilterState; + HANDLE m_hDevice; + ProxyPluginVector m_Plugins; }; +HRESULT +STDMETHODCALLTYPE +CKsProxy::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown) || + IsEqualGUID(refiid, IID_IBaseFilter)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IPersistPropertyBag)) + { + *Output = (IPersistPropertyBag*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IKsObject)) + { + *Output = (IKsObject*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CKsProxy::QueryInterface: NoInterface for %s !!!\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IKsObject interface +// + +HANDLE +STDMETHODCALLTYPE +CKsProxy::KsGetObjectHandle() +{ + return m_hDevice; +} + +//------------------------------------------------------------------- +// IPersistPropertyBag interface +// +HRESULT +STDMETHODCALLTYPE +CKsProxy::InitNew( void) +{ + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetSupportedSets( + LPGUID * pOutGuid, + PULONG NumGuids) +{ + KSPROPERTY Property; + LPGUID pGuid; + ULONG NumProperty = 0; + ULONG NumMethods = 0; + ULONG NumEvents = 0; + ULONG Length; + ULONG BytesReturned; + HRESULT hr; + + Property.Set = GUID_NULL; + Property.Id = 0; + Property.Flags = KSPROPERTY_TYPE_SETSUPPORT; + + KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumProperty); + KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_METHOD, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumMethods); + KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_ENABLE_EVENT, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumEvents); + + Length = NumProperty + NumMethods + NumEvents; + + // allocate guid buffer + pGuid = (LPGUID)CoTaskMemAlloc(Length); + if (!pGuid) + { + // failed + return E_OUTOFMEMORY; + } + + NumProperty /= sizeof(GUID); + NumMethods /= sizeof(GUID); + NumEvents /= sizeof(GUID); + + // get all properties + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)pGuid, Length, &BytesReturned); + if (FAILED(hr)) + { + CoTaskMemFree(pGuid); + return E_FAIL; + } + Length -= BytesReturned; + + // get all methods + if (Length) + { + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_METHOD, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty], Length, &BytesReturned); + if (FAILED(hr)) + { + CoTaskMemFree(pGuid); + return E_FAIL; + } + Length -= BytesReturned; + } + + // get all events + if (Length) + { + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_ENABLE_EVENT, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty+NumMethods], Length, &BytesReturned); + if (FAILED(hr)) + { + CoTaskMemFree(pGuid); + return E_FAIL; + } + Length -= BytesReturned; + } + +#ifdef KSPROXY_TRACE + WCHAR Buffer[200]; + swprintf(Buffer, L"NumProperty %lu NumMethods %lu NumEvents %lu\n", NumProperty, NumMethods, NumEvents); + OutputDebugStringW(Buffer); +#endif + + *pOutGuid = pGuid; + *NumGuids = NumProperty+NumEvents+NumMethods; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::LoadProxyPlugins( + LPGUID pGuids, + ULONG NumGuids) +{ + ULONG Index; + LPOLESTR pStr; + HKEY hKey, hSubKey; + HRESULT hr; + IUnknown * pUnknown; + + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\MediaInterfaces", 0, KEY_READ, &hKey) != ERROR_SUCCESS) + { + OutputDebugStringW(L"CKsProxy::LoadProxyPlugins failed to open MediaInterfaces key\n"); + return E_FAIL; + } + + // enumerate all sets + for(Index = 0; Index < NumGuids; Index++) + { + // convert to string + hr = StringFromCLSID(pGuids[Index], &pStr); + if (FAILED(hr)) + return E_FAIL; + + // now try open class key + if (RegOpenKeyExW(hKey, pStr, 0, KEY_READ, &hSubKey) != ERROR_SUCCESS) + { + // no plugin for that set exists + CoTaskMemFree(pStr); + continue; + } + + // try load plugin + hr = CoCreateInstance(pGuids[Index], (IBaseFilter*)this, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&pUnknown); + if (SUCCEEDED(hr)) + { + // store plugin + m_Plugins.push_back(pUnknown); + } + // close key + RegCloseKey(hSubKey); + } + + // close media interfaces key + RegCloseKey(hKey); + return S_OK; +} + + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Load(IPropertyBag *pPropBag, IErrorLog *pErrorLog) +{ + HRESULT hr; + WCHAR Buffer[100]; + VARIANT varName; + LPGUID pGuid; + ULONG NumGuids = 0; + + // read device path + varName.vt = VT_BSTR; + hr = pPropBag->Read(L"DevicePath", &varName, pErrorLog); + + if (FAILED(hr)) + { + swprintf(Buffer, L"CKsProxy::Load Read %lx\n", hr); + OutputDebugStringW(Buffer); + return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError()); + } + + // open device + m_hDevice = CreateFileW(varName.bstrVal, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); + + if (m_hDevice == INVALID_HANDLE_VALUE) + { + // failed to open device + swprintf(Buffer, L"CKsProxy:: failed to open device with %lx\n", GetLastError()); + OutputDebugStringW(Buffer); + + return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError()); + } + + // get all supported sets + hr = GetSupportedSets(&pGuid, &NumGuids); + if (FAILED(hr)) + { + CloseHandle(m_hDevice); + m_hDevice = NULL; + return hr; + } + + // load all proxy plugins + hr = LoadProxyPlugins(pGuid, NumGuids); + + CloseHandle(m_hDevice); + m_hDevice = NULL; + + + return hr; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Save(IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) +{ + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IBaseFilter interface +// + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetClassID( + CLSID *pClassID) +{ + OutputDebugStringW(L"CKsProxy::GetClassID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Stop() +{ + OutputDebugStringW(L"CKsProxy::Stop : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Pause() +{ + OutputDebugStringW(L"CKsProxy::Pause : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Run( + REFERENCE_TIME tStart) +{ + OutputDebugStringW(L"CKsProxy::Run : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetState( + DWORD dwMilliSecsTimeout, + FILTER_STATE *State) +{ + *State = m_FilterState; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::SetSyncSource( + IReferenceClock *pClock) +{ + if (pClock) + { + pClock->AddRef(); + } + + if (m_ReferenceClock) + { + m_ReferenceClock->Release(); + } + + m_ReferenceClock = pClock; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetSyncSource( + IReferenceClock **pClock) +{ + if (!pClock) + return E_POINTER; + + if (m_ReferenceClock) + m_ReferenceClock->AddRef(); + + *pClock = m_ReferenceClock; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::EnumPins( + IEnumPins **ppEnum) +{ + OutputDebugStringW(L"CKsProxy::EnumPins : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::FindPin( + LPCWSTR Id, IPin **ppPin) +{ + OutputDebugStringW(L"CKsProxy::FindPin : NotImplemented\n"); + return E_NOTIMPL; +} + + +HRESULT +STDMETHODCALLTYPE +CKsProxy::QueryFilterInfo( + FILTER_INFO *pInfo) +{ + if (!pInfo) + return E_POINTER; + + pInfo->achName[0] = L'\0'; + pInfo->pGraph = m_pGraph; + + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::JoinFilterGraph( + IFilterGraph *pGraph, + LPCWSTR pName) +{ + if (pGraph) + { + // joining filter graph + m_pGraph = pGraph; + } + else + { + // leaving graph + m_pGraph = 0; + } + + OutputDebugStringW(L"CKsProxy::JoinFilterGraph\n"); + return S_OK; +} + + +HRESULT +STDMETHODCALLTYPE +CKsProxy::QueryVendorInfo( + LPWSTR *pVendorInfo) +{ + OutputDebugStringW(L"CKsProxy::QueryVendorInfo : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IAMovieSetup interface +// + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Register() +{ + OutputDebugStringW(L"CKsProxy::Register : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Unregister() +{ + OutputDebugStringW(L"CKsProxy::Unregister : NotImplemented\n"); + return E_NOTIMPL; +} HRESULT WINAPI @@ -41,6 +524,23 @@ CKsProxy_Constructor( REFIID riid, LPVOID * ppv) { - OutputDebugString("CKsProxy_Constructor UNIMPLEMENTED\n"); - return E_NOTIMPL; + WCHAR Buffer[100]; + LPOLESTR pstr; + StringFromCLSID(riid, &pstr); + swprintf(Buffer, L"CKsProxy_Constructor pUnkOuter %p riid %s\n", pUnkOuter, pstr); + OutputDebugStringW(Buffer); + + CKsProxy * handler = new CKsProxy(); + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return S_OK; } diff --git a/reactos/dll/directx/ksproxy/qualityforward.cpp b/reactos/dll/directx/ksproxy/qualityforward.cpp index 45f8f3489e3..3081d834cbf 100644 --- a/reactos/dll/directx/ksproxy/qualityforward.cpp +++ b/reactos/dll/directx/ksproxy/qualityforward.cpp @@ -87,8 +87,6 @@ CKsQualityForwarder::KsFlushClient( OutputDebugString("UNIMPLEMENTED\n"); } - - HRESULT WINAPI CKsQualityForwarder_Constructor( @@ -99,6 +97,8 @@ CKsQualityForwarder_Constructor( HRESULT hr; HANDLE handle; + OutputDebugStringW(L"CKsQualityForwarder_Constructor\n"); + // open default clock hr = KsOpenDefaultDevice(KSCATEGORY_QUALITY, GENERIC_READ | GENERIC_WRITE, &handle); From 5b5ab3b51f078a09da028d37f50cc578d65cb6ad Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 2 Mar 2010 16:48:28 +0000 Subject: [PATCH 030/211] [PORTCLS] - Add support for IPort interface svn path=/trunk/; revision=45760 --- .../drivers/wdm/audio/backpln/portcls/port_wavepci.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp b/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp index 3122dfb661b..81d6ed9bfbf 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp @@ -161,8 +161,9 @@ CPortWavePci::QueryInterface( DPRINT("IPortWavePci_fnQueryInterface entered\n"); - if (IsEqualGUIDAligned(refiid, IID_IPortWavePci) || - IsEqualGUIDAligned(refiid, IID_IUnknown)) + if (IsEqualGUIDAligned(refiid, IID_IPortWavePci) || + IsEqualGUIDAligned(refiid, IID_IUnknown) || + IsEqualGUIDAligned(refiid, IID_IPort)) { *Output = PVOID(PPORTWAVEPCI(this)); PUNKNOWN(*Output)->AddRef(); @@ -171,7 +172,7 @@ CPortWavePci::QueryInterface( else if (IsEqualGUIDAligned(refiid, IID_IServiceSink)) { *Output = PVOID(PSERVICESINK(this)); - PUNKNOWN(*Output)->AddRef(); + PUNKNOWN(*Output)->AddRef(); return STATUS_SUCCESS; } else if (IsEqualGUIDAligned(refiid, IID_IPortEvents)) @@ -183,7 +184,7 @@ CPortWavePci::QueryInterface( else if (IsEqualGUIDAligned(refiid, IID_ISubdevice)) { *Output = PVOID(PSUBDEVICE(this)); - PUNKNOWN(*Output)->AddRef(); + PUNKNOWN(*Output)->AddRef(); return STATUS_SUCCESS; } else if (IsEqualGUIDAligned(refiid, IID_IPortClsVersion)) From 675322f7bdd9c6e7b7e0428e88463497859eb40d Mon Sep 17 00:00:00 2001 From: Dmitry Gorbachev Date: Tue, 2 Mar 2010 18:16:21 +0000 Subject: [PATCH 031/211] [Kernel32] Print maximum 128 frames. Some formatting changes. svn path=/trunk/; revision=45761 --- reactos/dll/win32/kernel32/except/except.c | 136 ++++++++++++--------- 1 file changed, 75 insertions(+), 61 deletions(-) diff --git a/reactos/dll/win32/kernel32/except/except.c b/reactos/dll/win32/kernel32/except/except.c index 75e935679ee..a0e322167ce 100644 --- a/reactos/dll/win32/kernel32/except/except.c +++ b/reactos/dll/win32/kernel32/except/except.c @@ -204,6 +204,68 @@ BasepCheckForReadOnlyResource(IN PVOID Ptr) return Ret; } +static VOID +PrintStackTrace(struct _EXCEPTION_POINTERS *ExceptionInfo) +{ + PVOID StartAddr; + CHAR szMod[128] = ""; + PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord; + PCONTEXT ContextRecord = ExceptionInfo->ContextRecord; + + /* Print a stack trace. */ + DbgPrint("Unhandled exception\n"); + DbgPrint("ExceptionCode: %8x\n", ExceptionRecord->ExceptionCode); + + if ((NTSTATUS)ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && + ExceptionRecord->NumberParameters == 2) + { + DbgPrint("Faulting Address: %8x\n", ExceptionRecord->ExceptionInformation[1]); + } + + _dump_context (ContextRecord); + _module_name_from_addr(ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)); + DbgPrint("Address:\n %8x+%-8x %s\n", + (PVOID)StartAddr, + (ULONG_PTR)ExceptionRecord->ExceptionAddress - (ULONG_PTR)StartAddr, + szMod); +#ifdef _M_IX86 + DbgPrint("Frames:\n"); + + _SEH2_TRY + { + UINT i; + PULONG Frame = (PULONG)ContextRecord->Ebp; + + for (i = 0; Frame[1] != 0 && Frame[1] != 0xdeadbeef && i < 128; i++) + { + if (IsBadReadPtr((PVOID)Frame[1], 4)) + { + DbgPrint(" %8x%9s %s\n", Frame[1], ""," "); + } + else + { + _module_name_from_addr((const void*)Frame[1], &StartAddr, + szMod, sizeof(szMod)); + DbgPrint(" %8x+%-8x %s\n", + (PVOID)StartAddr, + (ULONG_PTR)Frame[1] - (ULONG_PTR)StartAddr, + szMod); + } + + if (IsBadReadPtr((PVOID)Frame[0], sizeof(*Frame) * 2)) + break; + + Frame = (PULONG)Frame[0]; + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + DbgPrint("\n", _SEH2_GetExceptionCode()); + } + _SEH2_END; +#endif +} + /* * @implemented */ @@ -215,17 +277,18 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo) NTSTATUS ErrCode; ULONG ErrorParameters[4]; ULONG ErrorResponse; + PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord; - if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && - ExceptionInfo->ExceptionRecord->NumberParameters >= 2) + if ((NTSTATUS)ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && + ExceptionRecord->NumberParameters >= 2) { - switch(ExceptionInfo->ExceptionRecord->ExceptionInformation[0]) + switch(ExceptionRecord->ExceptionInformation[0]) { case EXCEPTION_WRITE_FAULT: /* Change the protection on some write attempts, some InstallShield setups have this bug */ RetValue = BasepCheckForReadOnlyResource( - (PVOID)ExceptionInfo->ExceptionRecord->ExceptionInformation[1]); + (PVOID)ExceptionRecord->ExceptionInformation[1]); if (RetValue == EXCEPTION_CONTINUE_EXECUTION) return EXCEPTION_CONTINUE_EXECUTION; break; @@ -253,79 +316,30 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo) if (GlobalTopLevelExceptionFilter) { - LONG ret = GlobalTopLevelExceptionFilter( ExceptionInfo ); + LONG ret = GlobalTopLevelExceptionFilter(ExceptionInfo); if (ret != EXCEPTION_CONTINUE_SEARCH) return ret; } if ((GetErrorMode() & SEM_NOGPFAULTERRORBOX) == 0) - { -#ifdef _X86_ - PULONG Frame; -#endif - PVOID StartAddr; - CHAR szMod[128] = ""; - - /* Print a stack trace. */ - DbgPrint("Unhandled exception\n"); - DbgPrint("ExceptionCode: %8x\n", ExceptionInfo->ExceptionRecord->ExceptionCode); - if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && - ExceptionInfo->ExceptionRecord->NumberParameters == 2) - { - DbgPrint("Faulting Address: %8x\n", ExceptionInfo->ExceptionRecord->ExceptionInformation[1]); - } - _dump_context ( ExceptionInfo->ContextRecord ); - _module_name_from_addr(ExceptionInfo->ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)); - DbgPrint("Address:\n %8x+%-8x %s\n", - (PVOID)StartAddr, (ULONG_PTR)ExceptionInfo->ExceptionRecord->ExceptionAddress - - (ULONG_PTR)StartAddr, szMod); - -#ifdef _X86_ - DbgPrint("Frames:\n"); - _SEH2_TRY - { - Frame = (PULONG)ExceptionInfo->ContextRecord->Ebp; - while (Frame[1] != 0 && Frame[1] != 0xdeadbeef) - { - if (IsBadReadPtr((PVOID)Frame[1], 4)) { - DbgPrint(" %8x%9s %s\n", Frame[1], ""," "); - } else { - _module_name_from_addr((const void*)Frame[1], &StartAddr, - szMod, sizeof(szMod)); - DbgPrint(" %8x+%-8x %s\n", - (PVOID)StartAddr, - (ULONG_PTR)Frame[1] - (ULONG_PTR)StartAddr, szMod); - } - if (IsBadReadPtr((PVOID)Frame[0], sizeof(*Frame) * 2)) { - break; - } - Frame = (PULONG)Frame[0]; - } - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - DbgPrint("\n", _SEH2_GetExceptionCode()); - } - _SEH2_END; -#endif - } + PrintStackTrace(ExceptionInfo); /* Save exception code and address */ - ErrorParameters[0] = (ULONG)ExceptionInfo->ExceptionRecord->ExceptionCode; - ErrorParameters[1] = (ULONG)ExceptionInfo->ExceptionRecord->ExceptionAddress; + ErrorParameters[0] = (ULONG)ExceptionRecord->ExceptionCode; + ErrorParameters[1] = (ULONG)ExceptionRecord->ExceptionAddress; - if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) + if ((NTSTATUS)ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) { /* get the type of operation that caused the access violation */ - ErrorParameters[2] = ExceptionInfo->ExceptionRecord->ExceptionInformation[0]; + ErrorParameters[2] = ExceptionRecord->ExceptionInformation[0]; } else { - ErrorParameters[2] = ExceptionInfo->ExceptionRecord->ExceptionInformation[2]; + ErrorParameters[2] = ExceptionRecord->ExceptionInformation[2]; } /* Save faulting address */ - ErrorParameters[3] = ExceptionInfo->ExceptionRecord->ExceptionInformation[1]; + ErrorParameters[3] = ExceptionRecord->ExceptionInformation[1]; /* Raise the harderror */ ErrCode = NtRaiseHardError(STATUS_UNHANDLED_EXCEPTION | 0x10000000, From 79d110cf1c0052cdb6eff9049d409ab084720797 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 2 Mar 2010 19:04:15 +0000 Subject: [PATCH 032/211] [KDBG] - Fix attaching to processes (registers / backtraces) svn path=/trunk/; revision=45762 --- reactos/ntoskrnl/kdbg/kdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/kdbg/kdb.c b/reactos/ntoskrnl/kdbg/kdb.c index 3f4010671ef..058e1128e0e 100644 --- a/reactos/ntoskrnl/kdbg/kdb.c +++ b/reactos/ntoskrnl/kdbg/kdb.c @@ -209,7 +209,7 @@ KdbpKdbTrapFrameFromKernelStack( RtlZeroMemory(KdbTrapFrame, sizeof(KDB_KTRAP_FRAME)); StackPtr = (ULONG_PTR *) KernelStack; -#if _M_X86_ +#ifdef _M_IX86 KdbTrapFrame->Tf.Ebp = StackPtr[3]; KdbTrapFrame->Tf.Edi = StackPtr[4]; KdbTrapFrame->Tf.Esi = StackPtr[5]; From 6ce96bebac0ef61d215e156d8fda8cb22e7f58de Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 19:37:13 +0000 Subject: [PATCH 033/211] [SHDOCLC] sync shdoclc to wine 1.1.39 svn path=/trunk/; revision=45763 --- reactos/dll/win32/shdoclc/Bg.rc | 1 + reactos/dll/win32/shdoclc/Da.rc | 1 + reactos/dll/win32/shdoclc/De.rc | 76 ++--- reactos/dll/win32/shdoclc/En.rc | 221 ++++++++++++- reactos/dll/win32/shdoclc/Es.rc | 1 + reactos/dll/win32/shdoclc/Fi.rc | 1 + reactos/dll/win32/shdoclc/Fr.rc | 159 +++++----- reactos/dll/win32/shdoclc/Hu.rc | 1 + reactos/dll/win32/shdoclc/Ko.rc | 5 +- reactos/dll/win32/shdoclc/Lt.rc | 252 +++++++++++++++ reactos/dll/win32/shdoclc/Nl.rc | 1 + reactos/dll/win32/shdoclc/No.rc | 1 + reactos/dll/win32/shdoclc/Pt.rc | 62 ++-- reactos/dll/win32/shdoclc/Ro.rc | 251 +++++++++++++++ reactos/dll/win32/shdoclc/Ru.rc | 224 ++++++------- reactos/dll/win32/shdoclc/Si.rc | 2 +- reactos/dll/win32/shdoclc/Sv.rc | 1 + reactos/dll/win32/shdoclc/Tr.rc | 1 + reactos/dll/win32/shdoclc/Uk.rc | 470 ++++++++++++++++++++++++++++ reactos/dll/win32/shdoclc/Zh.rc | 3 +- reactos/dll/win32/shdoclc/rsrc.rc | 3 + reactos/dll/win32/shdoclc/shdoclc.h | 3 + 22 files changed, 1481 insertions(+), 259 deletions(-) create mode 100644 reactos/dll/win32/shdoclc/Lt.rc create mode 100644 reactos/dll/win32/shdoclc/Ro.rc create mode 100644 reactos/dll/win32/shdoclc/Uk.rc diff --git a/reactos/dll/win32/shdoclc/Bg.rc b/reactos/dll/win32/shdoclc/Bg.rc index 814ac7c918a..0cec8ec2f96 100644 --- a/reactos/dll/win32/shdoclc/Bg.rc +++ b/reactos/dll/win32/shdoclc/Bg.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT diff --git a/reactos/dll/win32/shdoclc/Da.rc b/reactos/dll/win32/shdoclc/Da.rc index 5f22bc8ed61..8a25db92dbf 100644 --- a/reactos/dll/win32/shdoclc/Da.rc +++ b/reactos/dll/win32/shdoclc/Da.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_DANISH, SUBLANG_DEFAULT diff --git a/reactos/dll/win32/shdoclc/De.rc b/reactos/dll/win32/shdoclc/De.rc index 253b6fc0007..3fbb536f6f0 100644 --- a/reactos/dll/win32/shdoclc/De.rc +++ b/reactos/dll/win32/shdoclc/De.rc @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" + +#pragma code_page(65001) LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL @@ -36,19 +39,19 @@ IDR_BROWSE_CONTEXT_MENU MENU { POPUP "Standard" { - MENUITEM "&Zurück", IDM_GOBACKWARD - MENUITEM "V&orwärts", IDM_GOFORWARD + MENUITEM "&Zurück", IDM_GOBACKWARD + MENUITEM "V&orwärts", IDM_GOFORWARD MENUITEM SEPARATOR MENUITEM "&Speichere Hintergrund als...", IDM_SAVEBACKGROUND MENUITEM "Als Hintergrund", IDM_SETWALLPAPER MENUITEM "Hintergrund &kopieren", IDM_COPYBACKGROUND MENUITEM "Als Desktopelement einrichten...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Alles &auswählen", IDM_SELECTALL - MENUITEM "Ein&fügen", IDM_PASTE + MENUITEM "Alles &auswählen", IDM_SELECTALL + MENUITEM "Ein&fügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Erzeuge &Verknüpfung", IDM_CREATESHORTCUT - MENUITEM "Zu &Favoriten hinzufügen", IDM_ADDFAVORITES + MENUITEM "Erzeuge &Verknüpfung", IDM_CREATESHORTCUT + MENUITEM "Zu &Favoriten hinzufügen", IDM_ADDFAVORITES MENUITEM "&Quelltextansicht", IDM_VIEWSOURCE MENUITEM SEPARATOR MENUITEM "&Textkodierung", IDM_LANGUAGE @@ -62,8 +65,8 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Bild" { - MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC - MENUITEM "Öffne Verweis in neuem Fenster", IDM_FOLLOWLINKN + MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC + MENUITEM "Öffne Verweis in neuem Fenster", IDM_FOLLOWLINKN MENUITEM "Speichere &Ziel als...", IDM_SAVETARGET MENUITEM "&Drucke Ziel", IDM_PRINTTARGET MENUITEM SEPARATOR @@ -77,10 +80,10 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "Verk&nüpfung kopieren", IDM_COPYSHORTCUT - MENUITEM "Ein&fügen", IDM_PASTE + MENUITEM "Verk&nüpfung kopieren", IDM_COPYSHORTCUT + MENUITEM "Ein&fügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES + MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "&Eigenschaften", IDM_PROPERTIES @@ -88,20 +91,20 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Steuerung" { - MENUITEM "&Rückgängig", IDM_UNDO + MENUITEM "&Rückgängig", IDM_UNDO MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "Ein&fügen", IDM_PASTE - MENUITEM "&Löschen", IDM_DELETE + MENUITEM "Ein&fügen", IDM_PASTE + MENUITEM "&Löschen", IDM_DELETE MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Alles &auswählen", IDM_SELECTALL + MENUITEM "Alles &auswählen", IDM_SELECTALL } POPUP "Tabelle" { - POPUP "&Auswählen" + POPUP "&Auswählen" { MENUITEM "&Zelle", IDM_CELLSELECT MENUITEM "Zei&le", IDM_ROWSELECT @@ -110,33 +113,33 @@ IDR_BROWSE_CONTEXT_MENU MENU } MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Zellen-Eigenschaften", IDM_CELLPROPERTIES - MENUITEM "&Tabellen-Eigenschaften", IDM_TABLEPROPERTIES + MENUITEM "&Zellen Eigenschaften", IDM_CELLPROPERTIES + MENUITEM "&Tabellen Eigenschaften", IDM_TABLEPROPERTIES } POPUP "1DSeiten Auswahl" { MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "Ein&fügen", IDM_PASTE - MENUITEM "Alles &auswählen", IDM_SELECTALL + MENUITEM "Ein&fügen", IDM_PASTE + MENUITEM "Alles &auswählen", IDM_SELECTALL MENUITEM "&Drucken", IDM_PRINT MENUITEM SEPARATOR } POPUP "Anker" { - MENUITEM "&Öffnen", IDM_FOLLOWLINKC - MENUITEM "Im &neuen Fenster öffnen", IDM_FOLLOWLINKN + MENUITEM "&Öffnen", IDM_FOLLOWLINKC + MENUITEM "Im &neuen Fenster öffnen", IDM_FOLLOWLINKN MENUITEM "Speichere &Ziel als...", IDM_SAVETARGET MENUITEM "&Drucke Ziel", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT - MENUITEM "Ein&fügen", IDM_PASTE + MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT + MENUITEM "Ein&fügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES + MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "&Eigenschaften", IDM_PROPERTIES @@ -149,8 +152,8 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "DYNSRC Bild" { - MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC - MENUITEM "Öffne Verweis in &neuem Fenster", IDM_FOLLOWLINKN + MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC + MENUITEM "Öffne Verweis in &neuem Fenster", IDM_FOLLOWLINKN MENUITEM "Speichere &Ziel als...", IDM_SAVETARGET MENUITEM "&Drucke Ziel", IDM_PRINTTARGET MENUITEM SEPARATOR @@ -161,10 +164,10 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT - MENUITEM "Ein&fügen", IDM_PASTE + MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT + MENUITEM "Ein&fügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES + MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "Abspielen", IDM_DYNSRCPLAY @@ -174,8 +177,8 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "ART Bild" { - MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC - MENUITEM "Öffne Verweis in &neuem Fenster", IDM_FOLLOWLINKN + MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC + MENUITEM "Öffne Verweis in &neuem Fenster", IDM_FOLLOWLINKN MENUITEM "Speichere &Ziel als...", IDM_SAVETARGET MENUITEM "&Drucke Ziel", IDM_PRINTTARGET MENUITEM SEPARATOR @@ -186,14 +189,14 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT - MENUITEM "&Einfügen", IDM_PASTE + MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT + MENUITEM "&Einfügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES + MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM "Abspielen", IDM_IMGARTPLAY MENUITEM "Anhalten", IDM_IMGARTSTOP - MENUITEM "Rückspulen", IDM_IMGARTREWIND + MENUITEM "Rückspulen", IDM_IMGARTREWIND MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "&Eigenschaften", IDM_PROPERTIES @@ -247,3 +250,4 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Scrolle rechts", IDM_SCROLL_RIGHT } } +#pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/En.rc b/reactos/dll/win32/shdoclc/En.rc index d237c519f80..4cb0a11d839 100644 --- a/reactos/dll/win32/shdoclc/En.rc +++ b/reactos/dll/win32/shdoclc/En.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT @@ -46,7 +47,7 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "&Paste", IDM_PASTE MENUITEM SEPARATOR MENUITEM "Create Shor&tcut", IDM_CREATESHORTCUT - MENUITEM "Add to &Favourites", IDM_ADDFAVORITES + MENUITEM "Add to &Favorites", IDM_ADDFAVORITES MENUITEM "&View Source", IDM_VIEWSOURCE MENUITEM SEPARATOR MENUITEM "&Encoding", IDM_LANGUAGE @@ -245,3 +246,221 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Scroll Right", IDM_SCROLL_RIGHT } } + +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Default" + { + MENUITEM "&Back", IDM_GOBACKWARD + MENUITEM "F&orward", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Save Background As...", IDM_SAVEBACKGROUND + MENUITEM "Set As Back&ground", IDM_SETWALLPAPER + MENUITEM "&Copy Background", IDM_COPYBACKGROUND + MENUITEM "Set as &Desktop Item", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Select &All", IDM_SELECTALL + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Create Shor&tcut", IDM_CREATESHORTCUT + MENUITEM "Add to &Favourites", IDM_ADDFAVORITES + MENUITEM "&View Source", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "&Encoding", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "Pr&int", IDM_PRINT + MENUITEM "&Refresh", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "&Properties", IDM_PROPERTIES + } + + POPUP "Image" + { + MENUITEM "&Open Link", IDM_FOLLOWLINKC + MENUITEM "Open Link in &New Window", IDM_FOLLOWLINKN + MENUITEM "Save Target &As...", IDM_SAVETARGET + MENUITEM "&Print Target", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "S&how Picture", IDM_SHOWPICTURE + MENUITEM "&Save Picture As...", IDM_SAVEPICTURE + MENUITEM "&E-mail Picture...", IDM_MP_EMAILPICTURE + MENUITEM "Pr&int Picture...", IDM_MP_PRINTPICTURE + MENUITEM "&Go to My Pictures", IDM_MP_MYPICS + MENUITEM "Set as Back&ground", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Copy Shor&tcut", IDM_COPYSHORTCUT + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Add to &Favourites...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roperties", IDM_PROPERTIES + } + + POPUP "Control" + { + MENUITEM "&Undo", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "&Paste", IDM_PASTE + MENUITEM "&Delete", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Select &All", IDM_SELECTALL + } + + POPUP "Table" + { + POPUP "&Select" + { + MENUITEM "&Cell", IDM_CELLSELECT + MENUITEM "&Row", IDM_ROWSELECT + MENUITEM "&Column", IDM_COLUMNSELECT + MENUITEM "&Table", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "&Cell Properties", IDM_CELLPROPERTIES + MENUITEM "&Table Properties", IDM_TABLEPROPERTIES + } + + POPUP "1DSite Select" + { + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Paste", IDM_PASTE + MENUITEM "Select &All", IDM_SELECTALL + MENUITEM "&Print", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Anchor" + { + MENUITEM "&Open", IDM_FOLLOWLINKC + MENUITEM "Open in &New Window", IDM_FOLLOWLINKN + MENUITEM "Save Target &As...", IDM_SAVETARGET + MENUITEM "&Print Target", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Cut", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Copy Shor&tcut", IDM_COPYSHORTCUT + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Add to &Favourites...",IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roperties", IDM_PROPERTIES + } + + POPUP "Context Unknown" + { + MENUITEM SEPARATOR + } + + POPUP "DYNSRC Image" + { + MENUITEM "&Open Link", IDM_FOLLOWLINKC + MENUITEM "Open Link in &New Window", IDM_FOLLOWLINKN + MENUITEM "Save Target &As...", IDM_SAVETARGET + MENUITEM "&Print Target", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "S&how Picture", IDM_SHOWPICTURE + MENUITEM "&Save Video As...", IDM_SAVEPICTURE + MENUITEM "Set as Back&ground", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Copy Shor&tcut", IDM_COPYSHORTCUT + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Add to &Favourites...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Play", IDM_DYNSRCPLAY + MENUITEM "Stop", IDM_DYNSRCSTOP + MENUITEM "P&roperties", IDM_PROPERTIES + } + + POPUP "ART Image" + { + MENUITEM "&Open Link", IDM_FOLLOWLINKC + MENUITEM "Open Link in &New Window", IDM_FOLLOWLINKN + MENUITEM "Save Target &As...", IDM_SAVETARGET + MENUITEM "&Print Target", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "S&how Picture", IDM_SHOWPICTURE + MENUITEM "&Save Picture As...", IDM_SAVEPICTURE + MENUITEM "Set as Back&ground", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Copy Shor&tcut", IDM_COPYSHORTCUT + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Add to &Favourites...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Play", IDM_IMGARTPLAY + MENUITEM "Stop", IDM_IMGARTSTOP + MENUITEM "Rewind", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roperties", IDM_PROPERTIES + } + + POPUP "Debug" + { + MENUITEM "Trace Tags", IDM_TRACETAGS + MENUITEM "Resource Failures", IDM_RESOURCEFAILURES + MENUITEM "Dump Tracking Info", IDM_DUMPTRACKINGINFO + MENUITEM "Debug Break", IDM_DEBUGBREAK + MENUITEM "Debug View", IDM_DEBUGVIEW + MENUITEM "Dump Tree", IDM_DUMPTREE + MENUITEM "Dump Lines", IDM_DUMPLINES + MENUITEM "Dump DisplayTree", IDM_DUMPDISPLAYTREE + MENUITEM "Dump FormatCaches", IDM_DUMPFORMATCACHES + MENUITEM "Dump LayoutRects", IDM_DUMPLAYOUTRECTS + MENUITEM "Memory Monitor", IDM_MEMORYMONITOR + MENUITEM "Performance Meters", IDM_PERFORMANCEMETERS + MENUITEM "Save HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&Browse View", IDM_BROWSEMODE + MENUITEM "&Edit View", IDM_EDITMODE + } + + POPUP "Vertical Scrollbar" + { + MENUITEM "Scroll Here", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Top", IDM_SCROLL_TOP + MENUITEM "Bottom", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Page Up", IDM_SCROLL_PAGEUP + MENUITEM "Page Down", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Scroll Up", IDM_SCROLL_UP + MENUITEM "Scroll Down", IDM_SCROLL_DOWN + } + + POPUP "Horizontal Scrollbar" + { + MENUITEM "Scroll Here", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Left Edge", IDM_SCROLL_LEFTEDGE + MENUITEM "Right Edge", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Page Left", IDM_SCROLL_PAGELEFT + MENUITEM "Page Right", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Scroll Left", IDM_SCROLL_LEFT + MENUITEM "Scroll Right", IDM_SCROLL_RIGHT + } +} diff --git a/reactos/dll/win32/shdoclc/Es.rc b/reactos/dll/win32/shdoclc/Es.rc index 8be9757223a..fd2e3c7ce27 100644 --- a/reactos/dll/win32/shdoclc/Es.rc +++ b/reactos/dll/win32/shdoclc/Es.rc @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL diff --git a/reactos/dll/win32/shdoclc/Fi.rc b/reactos/dll/win32/shdoclc/Fi.rc index 81233d31f97..ae5e0c2b861 100644 --- a/reactos/dll/win32/shdoclc/Fi.rc +++ b/reactos/dll/win32/shdoclc/Fi.rc @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT diff --git a/reactos/dll/win32/shdoclc/Fr.rc b/reactos/dll/win32/shdoclc/Fr.rc index 75aefc7a1f2..c74f0a43757 100644 --- a/reactos/dll/win32/shdoclc/Fr.rc +++ b/reactos/dll/win32/shdoclc/Fr.rc @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" + +/* UTF-8 */ +#pragma code_page(65001) LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL @@ -35,74 +39,74 @@ STRINGTABLE DISCARDABLE IDR_BROWSE_CONTEXT_MENU MENU { - POPUP "Default" + POPUP "Standard" { - MENUITEM "Page pré&cédente", IDM_GOBACKWARD - MENUITEM "Page sui&vante", IDM_GOFORWARD + MENUITEM "Page &précédente", IDM_GOBACKWARD + MENUITEM "Page &suivante", IDM_GOFORWARD MENUITEM SEPARATOR - MENUITEM "Enregistrer l'&arrière-plan sous...", IDM_SAVEBACKGROUND - MENUITEM "Ét&ablir en tant qu'élément d'arrière-plan", IDM_SETWALLPAPER - MENUITEM "Copie&r l'arrière-plan", IDM_COPYBACKGROUND - MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM + MENUITEM "Enregistrer l'&arrière-plan sous...", IDM_SAVEBACKGROUND + MENUITEM "Définir &comme arrière-plan", IDM_SETWALLPAPER + MENUITEM "&Copier l'arrière-plan", IDM_COPYBACKGROUND + MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "&Sélectionner tout", IDM_SELECTALL + MENUITEM "Sélectionner &tout", IDM_SELECTALL MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Créer &un raccourci", IDM_CREATESHORTCUT - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES - MENUITEM "A&fficher la source", IDM_VIEWSOURCE + MENUITEM "Créer un &raccourci", IDM_CREATESHORTCUT + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES + MENUITEM "Afficher la &source", IDM_VIEWSOURCE MENUITEM SEPARATOR - MENUITEM "Co&dage", IDM_LANGUAGE + MENUITEM "Coda&ge", IDM_LANGUAGE MENUITEM SEPARATOR MENUITEM "&Imprimer", IDM_PRINT MENUITEM "Actualis&er", _IDM_REFRESH MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Propriétés", IDM_PROPERTIES + MENUITEM "Propri&étés", IDM_PROPERTIES } POPUP "Image" { MENUITEM "Ou&vrir le lien", IDM_FOLLOWLINKC - MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN + MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN MENUITEM "Enregistrer la cible so&us...", IDM_SAVETARGET MENUITEM "Imprimer la cib&le", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "Affic&her l'image", IDM_SHOWPICTURE MENUITEM "Enregistrer l'image &sous...", IDM_SAVEPICTURE - MENUITEM "Envoyer l'image par &courrier électronique...", IDM_MP_EMAILPICTURE + MENUITEM "Envoyer l'image par &courrier électronique...", IDM_MP_EMAILPICTURE MENUITEM "&Imprimer l'image...", IDM_MP_PRINTPICTURE MENUITEM "Atteindre &Mes images", IDM_MP_MYPICS - MENUITEM "É&tablir en tant qu'élément d'arrière-plan", IDM_SETWALLPAPER - MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM + MENUITEM "Déf&inir comme arrière-plan", IDM_SETWALLPAPER + MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY MENUITEM "Copier le r&accourci", IDM_COPYSHORTCUT MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Propriétés", IDM_PROPERTIES + MENUITEM "Propri&étés", IDM_PROPERTIES } - POPUP "Control" + POPUP "Contrôle" { MENUITEM "&Annuler", IDM_UNDO MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY MENUITEM "C&oller", IDM_PASTE MENUITEM "Suppri&mer", IDM_DELETE MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Sélectionner tout", IDM_SELECTALL + MENUITEM "&Sélectionner tout", IDM_SELECTALL } POPUP "Table" { - POPUP "&Sélectionner" + POPUP "&Sélectionner" { MENUITEM "&cellule", IDM_CELLSELECT MENUITEM "&ligne", IDM_ROWSELECT @@ -111,96 +115,96 @@ IDR_BROWSE_CONTEXT_MENU MENU } MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Propriétés de la &cellule", IDM_CELLPROPERTIES - MENUITEM "Propriétés de la &table", IDM_TABLEPROPERTIES + MENUITEM "Propriétés de la &cellule", IDM_CELLPROPERTIES + MENUITEM "Propriétés de la &table", IDM_TABLEPROPERTIES } POPUP "1DSite Select" { - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY - MENUITEM "Coller", IDM_PASTE - MENUITEM "&Sélectionner tout", IDM_SELECTALL + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY + MENUITEM "C&oller", IDM_PASTE + MENUITEM "Sélectionner &tout", IDM_SELECTALL MENUITEM "&Imprimer", IDM_PRINT MENUITEM SEPARATOR } - POPUP "Anchor" + POPUP "Ancre" { MENUITEM "Ou&vrir", IDM_FOLLOWLINKC - MENUITEM "Ouvrir dans une &nouvelle fenêtre", IDM_FOLLOWLINKN - MENUITEM "Enregistrer la cible so&us...", IDM_SAVETARGET - MENUITEM "Imprimer la cib&le", IDM_PRINTTARGET + MENUITEM "Ouvrir dans une &nouvelle fenêtre", IDM_FOLLOWLINKN + MENUITEM "Enregistrer la cible &sous...", IDM_SAVETARGET + MENUITEM "&Imprimer la cible", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY - MENUITEM "Copier le r&accourci", IDM_COPYSHORTCUT + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY + MENUITEM "Copier le &raccourci", IDM_COPYSHORTCUT MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Propriétés", IDM_PROPERTIES + MENUITEM "Propri&étés", IDM_PROPERTIES } - POPUP "Context Unknown" + POPUP "Contexte inconnu" { MENUITEM SEPARATOR } - POPUP "DYNSRC Image" + POPUP "Image DYNSRC" { MENUITEM "Ou&vrir le lien", IDM_FOLLOWLINKC - MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN + MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN MENUITEM "Enregistrer la cible so&us...", IDM_SAVETARGET - MENUITEM "Imprimer la cib&le", IDM_PRINTTARGET + MENUITEM "&Imprimer la cible", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "Affic&her l'image", IDM_SHOWPICTURE - MENUITEM "Enregistrer la vidéo &sous...", IDM_SAVEPICTURE - MENUITEM "É&tablir en tant qu'élément d'arrière-plan", IDM_SETWALLPAPER - MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM + MENUITEM "Enregistrer la vidéo &sous...", IDM_SAVEPICTURE + MENUITEM "&Définir comme arrière-plan", IDM_SETWALLPAPER + MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY - MENUITEM "Copier le r&accourci", IDM_COPYSHORTCUT + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY + MENUITEM "Copier le &raccourci", IDM_COPYSHORTCUT MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "Lecture", IDM_DYNSRCPLAY - MENUITEM "Arrêt", IDM_DYNSRCSTOP - MENUITEM "&Propriétés", IDM_PROPERTIES + MENUITEM "Arrêt", IDM_DYNSRCSTOP + MENUITEM "Propri&étés", IDM_PROPERTIES } - POPUP "ART Image" + POPUP "Image ART" { MENUITEM "Ou&vrir le lien", IDM_FOLLOWLINKC - MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN + MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN MENUITEM "Enregistrer la cible so&us...", IDM_SAVETARGET MENUITEM "Imprimer la cib&le", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "Affic&her l'image", IDM_SHOWPICTURE MENUITEM "Enregistrer l'image &sous...", IDM_SAVEPICTURE - MENUITEM "É&tablir en tant qu'élément d'arrière-plan", IDM_SETWALLPAPER - MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM + MENUITEM "&Définir comme arrière-plan", IDM_SETWALLPAPER + MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY - MENUITEM "Copier le r&accourci", IDM_COPYSHORTCUT + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY + MENUITEM "Copier le &raccourci", IDM_COPYSHORTCUT MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM "Lecture", IDM_IMGARTPLAY - MENUITEM "Arrêt", IDM_IMGARTSTOP - MENUITEM "Retour arrière", IDM_IMGARTREWIND + MENUITEM "Arrêt", IDM_IMGARTSTOP + MENUITEM "Retour arrière", IDM_IMGARTREWIND MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Propriétés", IDM_PROPERTIES + MENUITEM "Propri&étés", IDM_PROPERTIES } - POPUP "Debug" + POPUP "Déboguage" { MENUITEM "Trace Tags", IDM_TRACETAGS MENUITEM "Resource Failures", IDM_RESOURCEFAILURES @@ -220,31 +224,32 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "&Edit View", IDM_EDITMODE } - POPUP "Vertical Scrollbar" + POPUP "Barre de défilement verticale" { - MENUITEM "Défilement ici", IDM_SCROLL_HERE + MENUITEM "Défilement ici", IDM_SCROLL_HERE MENUITEM SEPARATOR MENUITEM "Haut", IDM_SCROLL_TOP MENUITEM "Bas", IDM_SCROLL_BOTTOM MENUITEM SEPARATOR - MENUITEM "Page précédente", IDM_SCROLL_PAGEUP + MENUITEM "Page précédente", IDM_SCROLL_PAGEUP MENUITEM "Page suivante", IDM_SCROLL_PAGEDOWN MENUITEM SEPARATOR - MENUITEM "Défilement vers le haut", IDM_SCROLL_UP - MENUITEM "Défilement vers le bas", IDM_SCROLL_DOWN + MENUITEM "Défilement vers le haut", IDM_SCROLL_UP + MENUITEM "Défilement vers le bas", IDM_SCROLL_DOWN } - POPUP "Horizontal Scrollbar" + POPUP "Barre de défilement horizontale" { - MENUITEM "Défilement ici", IDM_SCROLL_HERE + MENUITEM "Défilement ici", IDM_SCROLL_HERE MENUITEM SEPARATOR - MENUITEM "Côté gauche", IDM_SCROLL_LEFTEDGE - MENUITEM "Côté droit", IDM_SCROLL_RIGHTEDGE + MENUITEM "Bord gauche", IDM_SCROLL_LEFTEDGE + MENUITEM "Bord droit", IDM_SCROLL_RIGHTEDGE MENUITEM SEPARATOR MENUITEM "Page vers la gauche", IDM_SCROLL_PAGELEFT MENUITEM "Page vers la droite", IDM_SCROLL_PAGERIGHT MENUITEM SEPARATOR - MENUITEM "Défilement vers la gauche", IDM_SCROLL_LEFT - MENUITEM "Défilement vers la droite", IDM_SCROLL_RIGHT + MENUITEM "Défilement vers la gauche", IDM_SCROLL_LEFT + MENUITEM "Défilement vers la droite", IDM_SCROLL_RIGHT } } +#pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/Hu.rc b/reactos/dll/win32/shdoclc/Hu.rc index 9ed68caceda..2fdc4c202ef 100644 --- a/reactos/dll/win32/shdoclc/Hu.rc +++ b/reactos/dll/win32/shdoclc/Hu.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT diff --git a/reactos/dll/win32/shdoclc/Ko.rc b/reactos/dll/win32/shdoclc/Ko.rc index d038994151b..c30c21dd5b4 100644 --- a/reactos/dll/win32/shdoclc/Ko.rc +++ b/reactos/dll/win32/shdoclc/Ko.rc @@ -17,17 +17,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { - IDS_MESSAGE_BOX_TITLE, "Wine ÀÎÅÍ³Ý Explorer" + IDS_MESSAGE_BOX_TITLE, "Wine ÀÎÅÍ³Ý ÀͽºÆú·Î¾îr" } STRINGTABLE DISCARDABLE { - IDS_PRINT_HEADER_TEMPLATE "&w&bPage &p" /* FIXME: should be "&w&bPage &p of &P" */ + IDS_PRINT_HEADER_TEMPLATE "&w&bÆäÀÌÁö &p" /* FIXME: should be "&w&bPage &p of &P" */ IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" } diff --git a/reactos/dll/win32/shdoclc/Lt.rc b/reactos/dll/win32/shdoclc/Lt.rc new file mode 100644 index 00000000000..93a34cd2c71 --- /dev/null +++ b/reactos/dll/win32/shdoclc/Lt.rc @@ -0,0 +1,252 @@ +/* + * Copyright 2009 Aurimas FiÅ¡eras + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "shdoclc.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_MESSAGE_BOX_TITLE, "Wine interneto narÅ¡yklÄ—" +} + +STRINGTABLE DISCARDABLE +{ + IDS_PRINT_HEADER_TEMPLATE "&w&bPuslapis &p" /* FIXME: should be "&w&bPuslapis &p iÅ¡ &P" */ + IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" +} + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Numatytasis" + { + MENUITEM "&Atgal", IDM_GOBACKWARD + MENUITEM "&Pirmyn", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&IÅ¡saugoti fonÄ… kaip...", IDM_SAVEBACKGROUND + MENUITEM "Parinkti užsk&landos pieÅ¡iniu", IDM_SETWALLPAPER + MENUITEM "Kopijuoti &fonÄ…", IDM_COPYBACKGROUND + MENUITEM "Nustatyti da&rbalaukio elementu", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "PažymÄ—ti &viskÄ…", IDM_SELECTALL + MENUITEM "Ä®&dÄ—ti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Sukurti &Å¡aukinį", IDM_CREATESHORTCUT + MENUITEM "PridÄ—ti į adr&esynÄ…", IDM_ADDFAVORITES + MENUITEM "Pirminis &tekstas", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "&KoduotÄ—", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "&Spausdinti", IDM_PRINT + MENUITEM "Atsiųsti iÅ¡ &naujo", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Savy&bÄ—s", IDM_PROPERTIES + } + + POPUP "Paveikslas" + { + MENUITEM "&Atverti saitÄ…", IDM_FOLLOWLINKC + MENUITEM "Atverti saitÄ… &naujame lange", IDM_FOLLOWLINKN + MENUITEM "Ä®raÅ¡yti saistomÄ… &objektÄ… kaip...", IDM_SAVETARGET + MENUITEM "&Spausdinti saistomÄ… objektÄ…", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Rod&yti paveikslÄ…", IDM_SHOWPICTURE + MENUITEM "Ä®raÅ¡yti pa&veikslÄ… kaip...", IDM_SAVEPICTURE + MENUITEM "IÅ¡siųsti pav&eikslÄ… el. paÅ¡tu...", IDM_MP_EMAILPICTURE + MENUITEM "S&pausdinti paveikslÄ…...", IDM_MP_PRINTPICTURE + MENUITEM "Ei&ti į paveikslų aplankÄ…", IDM_MP_MYPICS + MENUITEM "Parinkti užsk&landos pieÅ¡iniu", IDM_SETWALLPAPER + MENUITEM "Nustatyti da&rbalaukio elementu...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&IÅ¡kirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Kopi&juoti adresÄ…", IDM_COPYSHORTCUT + MENUITEM "Ä®&dÄ—ti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Prid&Ä—ti į adresynÄ…...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Savy&bÄ—s", IDM_PROPERTIES + } + + POPUP "Valdiklis" + { + MENUITEM "&AtÅ¡aukti", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "&IÅ¡kirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Ä®&dÄ—ti", IDM_PASTE + MENUITEM "&Å alinti", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "PažymÄ—ti &viskÄ…", IDM_SELECTALL + } + + POPUP "LentelÄ—" + { + POPUP "&PažymÄ—ti" + { + MENUITEM "lan&gelį", IDM_CELLSELECT + MENUITEM "&eilutÄ™", IDM_ROWSELECT + MENUITEM "&stulpelį", IDM_COLUMNSELECT + MENUITEM "&lentelÄ™", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Lan&gelio savybÄ—s", IDM_CELLPROPERTIES + MENUITEM "&LentelÄ—s savybÄ—s", IDM_TABLEPROPERTIES + } + + POPUP "1DPuslapio žymÄ—jimas" + { + MENUITEM "&IÅ¡kirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Ä®&dÄ—ti", IDM_PASTE + MENUITEM "PažymÄ—ti &viskÄ…", IDM_SELECTALL + MENUITEM "&Spausdinti", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "ŽymÄ—" + { + MENUITEM "&Atverti", IDM_FOLLOWLINKC + MENUITEM "Atverti &naujame lange", IDM_FOLLOWLINKN + MENUITEM "Ä®raÅ¡yti saistomÄ… &objektÄ… kaip...", IDM_SAVETARGET + MENUITEM "&Spausdinti saistomÄ… objektÄ…", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "&IÅ¡kirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Kopi&juoti adresÄ…", IDM_COPYSHORTCUT + MENUITEM "Ä®&dÄ—ti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "PridÄ—ti į adr&esynÄ…...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Savy&bÄ—s", IDM_PROPERTIES + } + + POPUP "Nežinomas kontekstas" + { + MENUITEM SEPARATOR + } + + POPUP "DYNSRC paveikslas" + { + MENUITEM "&Atverti saitÄ…", IDM_FOLLOWLINKC + MENUITEM "Atverti saitÄ… &naujame lange", IDM_FOLLOWLINKN + MENUITEM "Ä®raÅ¡yti saistomÄ… &objektÄ… kaip...", IDM_SAVETARGET + MENUITEM "&Spausdinti saistomÄ… objektÄ…", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Rod&yti paveikslÄ…", IDM_SHOWPICTURE + MENUITEM "Ä®raÅ¡yti pa&veikslÄ… kaip...", IDM_SAVEPICTURE + MENUITEM "Parinkti užsk&landos pieÅ¡iniu", IDM_SETWALLPAPER + MENUITEM "Nustatyti da&rbalaukio elementu...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&IÅ¡kirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Kopi&juoti adresÄ…", IDM_COPYSHORTCUT + MENUITEM "Ä®&dÄ—ti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "PridÄ—ti į adr&esynÄ…...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Leisti", IDM_DYNSRCPLAY + MENUITEM "Stabdyti", IDM_DYNSRCSTOP + MENUITEM "Savy&bÄ—s", IDM_PROPERTIES + } + + POPUP "ART paveikslas" + { + MENUITEM "&Atverti saitÄ…", IDM_FOLLOWLINKC + MENUITEM "Atverti saitÄ… &naujame lange", IDM_FOLLOWLINKN + MENUITEM "Ä®raÅ¡yti saistomÄ… &objektÄ… kaip...", IDM_SAVETARGET + MENUITEM "&Spausdinti saistomÄ… objektÄ…", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Rod&yti paveikslÄ…", IDM_SHOWPICTURE + MENUITEM "Ä®raÅ¡yti pa&veikslÄ… kaip...", IDM_SAVEPICTURE + MENUITEM "Parinkti užsk&landos pieÅ¡iniu", IDM_SETWALLPAPER + MENUITEM "Nustatyti da&rbalaukio elementu...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&IÅ¡kirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Kopi&juoti adresÄ…", IDM_COPYSHORTCUT + MENUITEM "Ä®&dÄ—ti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "PridÄ—ti į adr&esynÄ…...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Leisti", IDM_IMGARTPLAY + MENUITEM "Stabdyti", IDM_IMGARTSTOP + MENUITEM "Perleisti", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Savy&bÄ—s", IDM_PROPERTIES + } + + POPUP "Derinimas" + { + MENUITEM "Sekti gaires", IDM_TRACETAGS + MENUITEM "IÅ¡teklių klaidos", IDM_RESOURCEFAILURES + MENUITEM "Parodyti stebÄ—jimo informacijÄ…", IDM_DUMPTRACKINGINFO + MENUITEM "Derinimo pertraukimas", IDM_DEBUGBREAK + MENUITEM "Derinimo rodinys", IDM_DEBUGVIEW + MENUITEM "Parodyti medį", IDM_DUMPTREE + MENUITEM "Parodyti eilutes", IDM_DUMPLINES + MENUITEM "Parodyti rodymo medį", IDM_DUMPDISPLAYTREE + MENUITEM "Parodyti formatų podÄ—lius", IDM_DUMPFORMATCACHES + MENUITEM "Parodyti iÅ¡dÄ—stymo staÄiakampius", IDM_DUMPLAYOUTRECTS + MENUITEM "Atminties monitorius", IDM_MEMORYMONITOR + MENUITEM "NaÅ¡umo skaitikliai", IDM_PERFORMANCEMETERS + MENUITEM "IÅ¡saugoti HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&NarÅ¡yti rodinį", IDM_BROWSEMODE + MENUITEM "&Redaguoti rodinį", IDM_EDITMODE + } + + POPUP "StaÄioji slankjuostÄ—" + { + MENUITEM "Slinkti Äia", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "VirÅ¡us", IDM_SCROLL_TOP + MENUITEM "ApaÄia", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Ankstesnis lapas", IDM_SCROLL_PAGEUP + MENUITEM "Tolesnis lapas", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Slinkti aukÅ¡tyn", IDM_SCROLL_UP + MENUITEM "Slinkti žemyn", IDM_SCROLL_DOWN + } + + POPUP "GulsÄioji slankjuostÄ—" + { + MENUITEM "Slinkti Äia", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Kairysis kraÅ¡tas", IDM_SCROLL_LEFTEDGE + MENUITEM "DeÅ¡inysis kraÅ¡tas", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Kairysis lapas", IDM_SCROLL_PAGELEFT + MENUITEM "DeÅ¡inysis lapas", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Slinkti kairÄ—n", IDM_SCROLL_LEFT + MENUITEM "Slinkti deÅ¡inÄ—n", IDM_SCROLL_RIGHT + } +} +#pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/Nl.rc b/reactos/dll/win32/shdoclc/Nl.rc index 3f764753871..c10e8031fdb 100644 --- a/reactos/dll/win32/shdoclc/Nl.rc +++ b/reactos/dll/win32/shdoclc/Nl.rc @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL diff --git a/reactos/dll/win32/shdoclc/No.rc b/reactos/dll/win32/shdoclc/No.rc index 6c38a1f61c0..65f554a5777 100644 --- a/reactos/dll/win32/shdoclc/No.rc +++ b/reactos/dll/win32/shdoclc/No.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL diff --git a/reactos/dll/win32/shdoclc/Pt.rc b/reactos/dll/win32/shdoclc/Pt.rc index 393037f5f8a..737747304ff 100644 --- a/reactos/dll/win32/shdoclc/Pt.rc +++ b/reactos/dll/win32/shdoclc/Pt.rc @@ -16,12 +16,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" -LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL +#pragma code_page(65001) + +LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE STRINGTABLE DISCARDABLE { - IDS_MESSAGE_BOX_TITLE, "Wine Internet Explorer" + IDS_MESSAGE_BOX_TITLE, "Explorador de Internet Wine" } STRINGTABLE DISCARDABLE @@ -35,7 +38,7 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Default" { MENUITEM "&Retroceder", IDM_GOBACKWARD - MENUITEM "&Avançar", IDM_GOFORWARD + MENUITEM "&Avançar", IDM_GOFORWARD MENUITEM SEPARATOR MENUITEM "&Guardar fundo como...", IDM_SAVEBACKGROUND MENUITEM "&Definir como fundo", IDM_SETWALLPAPER @@ -47,9 +50,9 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Criar &Atalho", IDM_CREATESHORTCUT MENUITEM "Adicionar aos &Favoritos", IDM_ADDFAVORITES - MENUITEM "&Ver Código Fonte", IDM_VIEWSOURCE + MENUITEM "&Ver Código Fonte", IDM_VIEWSOURCE MENUITEM SEPARATOR - MENUITEM "C&odificação", IDM_LANGUAGE + MENUITEM "C&odificação", IDM_LANGUAGE MENUITEM SEPARATOR MENUITEM "&Imprimir", IDM_PRINT MENUITEM "&Actualizar", _IDM_REFRESH @@ -60,10 +63,10 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Imagem" { - MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC - MENUITEM "Abrir &ligação numa nova janela", IDM_FOLLOWLINKN - MENUITEM "&Guardar ligação como...", IDM_SAVETARGET - MENUITEM "&Imprimir ligação", IDM_PRINTTARGET + MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC + MENUITEM "Abrir &ligação numa nova janela", IDM_FOLLOWLINKN + MENUITEM "&Guardar ligação como...", IDM_SAVETARGET + MENUITEM "&Imprimir ligação", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "&Mostrar imagem", IDM_SHOWPICTURE MENUITEM "G&uardar imagem como...", IDM_SAVEPICTURE @@ -101,14 +104,14 @@ IDR_BROWSE_CONTEXT_MENU MENU { POPUP "&Seleccionar" { - MENUITEM "&Célula", IDM_CELLSELECT + MENUITEM "&Célula", IDM_CELLSELECT MENUITEM "&Linha", IDM_ROWSELECT MENUITEM "C&oluna", IDM_COLUMNSELECT MENUITEM "&Tabela", IDM_TABLESELECT } MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Propriedades da Célula", IDM_CELLPROPERTIES + MENUITEM "&Propriedades da Célula", IDM_CELLPROPERTIES MENUITEM "&Propriedades da Tabela", IDM_TABLEPROPERTIES } @@ -122,12 +125,12 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR } - POPUP "Âncora" + POPUP "Âncora" { MENUITEM "&Abrir", IDM_FOLLOWLINKC MENUITEM "A&brir numa nova janela", IDM_FOLLOWLINKN - MENUITEM "&Guardar ligação como...", IDM_SAVETARGET - MENUITEM "&Imprimir ligação", IDM_PRINTTARGET + MENUITEM "&Guardar ligação como...", IDM_SAVETARGET + MENUITEM "&Imprimir ligação", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "&Cortar", IDM_CUT MENUITEM "C&opiar", IDM_COPY @@ -147,10 +150,10 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Imagem DYNSRC" { - MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC - MENUITEM "A&brir ligação numa nova janela", IDM_FOLLOWLINKN - MENUITEM "&Guardar ligação como...", IDM_SAVETARGET - MENUITEM "&Imprimir ligação", IDM_PRINTTARGET + MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC + MENUITEM "A&brir ligação numa nova janela", IDM_FOLLOWLINKN + MENUITEM "&Guardar ligação como...", IDM_SAVETARGET + MENUITEM "&Imprimir ligação", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "&Mostrar imagem", IDM_SHOWPICTURE MENUITEM "G&uardar video como...", IDM_SAVEPICTURE @@ -172,10 +175,10 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Imagem ART" { - MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC - MENUITEM "A&brir ligação numa nova janela", IDM_FOLLOWLINKN - MENUITEM "&Guardar ligação como...", IDM_SAVETARGET - MENUITEM "&Imprimir ligação", IDM_PRINTTARGET + MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC + MENUITEM "A&brir ligação numa nova janela", IDM_FOLLOWLINKN + MENUITEM "&Guardar ligação como...", IDM_SAVETARGET + MENUITEM "&Imprimir ligação", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "&Mostrar imagem", IDM_SHOWPICTURE MENUITEM "G&uardar video como...", IDM_SAVEPICTURE @@ -189,10 +192,9 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Adicionar aos &Favoritos...", IDM_ADDFAVORITES MENUITEM SEPARATOR - MENUITEM SEPARATOR - MENUITEM "I&niciar", IDM_DYNSRCPLAY - MENUITEM "&Parar", IDM_DYNSRCSTOP - MENUITEM "&Recomeçar", IDM_IMGARTREWIND + MENUITEM "I&niciar", IDM_IMGARTPLAY + MENUITEM "&Parar", IDM_IMGARTSTOP + MENUITEM "&Recomeçar", IDM_IMGARTREWIND MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "Propriedade&s", IDM_PROPERTIES @@ -225,8 +227,8 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Topo", IDM_SCROLL_TOP MENUITEM "Fundo", IDM_SCROLL_BOTTOM MENUITEM SEPARATOR - MENUITEM "Página Acima", IDM_SCROLL_PAGEUP - MENUITEM "Página abaixo", IDM_SCROLL_PAGEDOWN + MENUITEM "Página Acima", IDM_SCROLL_PAGEUP + MENUITEM "Página abaixo", IDM_SCROLL_PAGEDOWN MENUITEM SEPARATOR MENUITEM "Scroll Cima", IDM_SCROLL_UP MENUITEM "Scroll Baixo", IDM_SCROLL_DOWN @@ -239,8 +241,8 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Canto Esquerdo", IDM_SCROLL_LEFTEDGE MENUITEM "Canto Direito", IDM_SCROLL_RIGHTEDGE MENUITEM SEPARATOR - MENUITEM "Página esquerda", IDM_SCROLL_PAGELEFT - MENUITEM "Página direita", IDM_SCROLL_PAGERIGHT + MENUITEM "Página esquerda", IDM_SCROLL_PAGELEFT + MENUITEM "Página direita", IDM_SCROLL_PAGERIGHT MENUITEM SEPARATOR MENUITEM "Scroll Esquerda", IDM_SCROLL_LEFT MENUITEM "Scroll Direita", IDM_SCROLL_RIGHT diff --git a/reactos/dll/win32/shdoclc/Ro.rc b/reactos/dll/win32/shdoclc/Ro.rc new file mode 100644 index 00000000000..45a3c8800b6 --- /dev/null +++ b/reactos/dll/win32/shdoclc/Ro.rc @@ -0,0 +1,251 @@ +/* + * Copyright 2005-2006 Jacek Caban + * Copyright 2009 Michael Stefaniuc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "shdoclc.h" + +LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL + +#pragma code_page(65001) + +STRINGTABLE DISCARDABLE +{ + IDS_MESSAGE_BOX_TITLE, "Wine Internet Explorer" +} + +STRINGTABLE DISCARDABLE +{ + IDS_PRINT_HEADER_TEMPLATE "&w&bPagina &p" /* FIXME: should be "&w&bPagina &p of &P" */ + IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" +} + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Implicit" + { + MENUITEM "ÃŽn&apoi", IDM_GOBACKWARD + MENUITEM "ÃŽ&nainte", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Salvează imaginea de fundal ca...", IDM_SAVEBACKGROUND + MENUITEM "DefineÈ™te ca &fundal", IDM_SETWALLPAPER + MENUITEM "&Copiază fundalul", IDM_COPYBACKGROUND + MENUITEM "&DefineÈ™te ca element de desktop", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Selectează t&ot", IDM_SELECTALL + MENUITEM "&LipeÈ™te", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Crează s&curtătură", IDM_CREATESHORTCUT + MENUITEM "Adaugă la &favorite", IDM_ADDFAVORITES + MENUITEM "&Vizualizează sursa", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "Codificar&e", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "&TipăreÈ™te", IDM_PRINT + MENUITEM "&Actualizează", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Imagine" + { + MENUITEM "Deschide &legătura", IDM_FOLLOWLINKC + MENUITEM "Deschide legătura într-o fereastră &nouă", IDM_FOLLOWLINKN + MENUITEM "S&alvează destinaÈ›ia ca...", IDM_SAVETARGET + MENUITEM "&TipăreÈ™te destinaÈ›ia", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Arată i&maginea", IDM_SHOWPICTURE + MENUITEM "&Salvează imaginea ca...", IDM_SAVEPICTURE + MENUITEM "Transmite imaginea prin &email...", IDM_MP_EMAILPICTURE + MENUITEM "T&ipăreÈ™te imaginea...", IDM_MP_PRINTPICTURE + MENUITEM "Du-te la My Pictures", IDM_MP_MYPICS + MENUITEM "DefineÈ™te ca &fundal", IDM_SETWALLPAPER + MENUITEM "&DefineÈ™te ca element de desktop...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "Copiază scur&tătura", IDM_COPYSHORTCUT + MENUITEM "&LipeÈ™te", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Adaugă la &favorite...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Control" + { + MENUITEM "&Refă", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "&LipeÈ™te", IDM_PASTE + MENUITEM "&Șterge", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Selectează t&ot", IDM_SELECTALL + } + + POPUP "Tabel" + { + POPUP "Selectare" + { + MENUITEM "&Celulă", IDM_CELLSELECT + MENUITEM "&Rând", IDM_ROWSELECT + MENUITEM "&Coloană", IDM_COLUMNSELECT + MENUITEM "&Tabel", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Proprietăți &celulă", IDM_CELLPROPERTIES + MENUITEM "Proprietăți &tabel", IDM_TABLEPROPERTIES + } + + POPUP "SelecÈ›ie Pagini1D" + { + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "&LipeÈ™te", IDM_PASTE + MENUITEM "Selectează t&ot", IDM_SELECTALL + MENUITEM "&TipăreÈ™te", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Ancorare" + { + MENUITEM "Deschide &legătura", IDM_FOLLOWLINKC + MENUITEM "Deschide legătura într-o fereastră &nouă", IDM_FOLLOWLINKN + MENUITEM "S&alvează destinaÈ›ia ca...", IDM_SAVETARGET + MENUITEM "&TipăreÈ™te destinaÈ›ia", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "Copiază scur&tătura", IDM_COPYSHORTCUT + MENUITEM "&LipeÈ™te", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Adaugă la &favorite...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Context necunoscut" + { + MENUITEM SEPARATOR + } + + POPUP "Imagine DYNSRC" + { + MENUITEM "Deschide &legătura", IDM_FOLLOWLINKC + MENUITEM "Deschide legătura într-o fereastră &nouă", IDM_FOLLOWLINKN + MENUITEM "S&alvează destinaÈ›ia ca...", IDM_SAVETARGET + MENUITEM "&TipăreÈ™te destinaÈ›ia", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Arată i&maginea", IDM_SHOWPICTURE + MENUITEM "&Salvează videoul ca...", IDM_SAVEPICTURE + MENUITEM "DefineÈ™te ca &fundal", IDM_SETWALLPAPER + MENUITEM "&DefineÈ™te ca element de desktop...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "Copiază scur&tătura", IDM_COPYSHORTCUT + MENUITEM "&LipeÈ™te", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Adaugă la &favorite...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Redă", IDM_DYNSRCPLAY + MENUITEM "OpreÈ™te", IDM_DYNSRCSTOP + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Imagine ART" + { + MENUITEM "Deschide &legătura", IDM_FOLLOWLINKC + MENUITEM "Deschide legătura într-o fereastră &nouă", IDM_FOLLOWLINKN + MENUITEM "S&alvează destinaÈ›ia ca...", IDM_SAVETARGET + MENUITEM "&TipăreÈ™te destinaÈ›ia", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Arată i&maginea", IDM_SHOWPICTURE + MENUITEM "&Salvează imaginea ca...", IDM_SAVEPICTURE + MENUITEM "DefineÈ™te ca &fundal", IDM_SETWALLPAPER + MENUITEM "&DefineÈ™te ca element de desktop...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "Copiază scur&tătura", IDM_COPYSHORTCUT + MENUITEM "&LipeÈ™te", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Adaugă la &favorite...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Redă", IDM_IMGARTPLAY + MENUITEM "OpreÈ™te", IDM_IMGARTSTOP + MENUITEM "Derulează înapoi", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Depanare" + { + MENUITEM "Urmărire etichete", IDM_TRACETAGS + MENUITEM "Erori în resursă", IDM_RESOURCEFAILURES + MENUITEM "Elimină informaÈ›ia de urmărire", IDM_DUMPTRACKINGINFO + MENUITEM "ÃŽntrerupere depanare", IDM_DEBUGBREAK + MENUITEM "Vizualizare depanare", IDM_DEBUGVIEW + MENUITEM "Elimină arborele", IDM_DUMPTREE + MENUITEM "Elimină liniile", IDM_DUMPLINES + MENUITEM "Elimină arborele de afiÈ™are", IDM_DUMPDISPLAYTREE + MENUITEM "Elimină cache-ul de format", IDM_DUMPFORMATCACHES + MENUITEM "Elimină dreptunghiurile de format", IDM_DUMPLAYOUTRECTS + MENUITEM "Monitor de memorie", IDM_MEMORYMONITOR + MENUITEM "Măsurători de performanță", IDM_PERFORMANCEMETERS + MENUITEM "Salvează HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&RăsfoieÈ™te vizualizarea", IDM_BROWSEMODE + MENUITEM "Editează vizualizarea", IDM_EDITMODE + } + + POPUP "Bara de defilare verticală" + { + MENUITEM "Derulează aici", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Sus", IDM_SCROLL_TOP + MENUITEM "Jos", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Pagină mai sus", IDM_SCROLL_PAGEUP + MENUITEM "Pagină mai jos", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Defilare în sus", IDM_SCROLL_UP + MENUITEM "Defilare în jos", IDM_SCROLL_DOWN + } + + POPUP "Bara de defilare orizontală" + { + MENUITEM "Derulează aici", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Marginea stîngă", IDM_SCROLL_LEFTEDGE + MENUITEM "Marginea dreaptă", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Pagină mai la stânga", IDM_SCROLL_PAGELEFT + MENUITEM "Pagină mai la dreapta", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Defilează la stînga", IDM_SCROLL_LEFT + MENUITEM "Defilează la dreapta", IDM_SCROLL_RIGHT + } +} diff --git a/reactos/dll/win32/shdoclc/Ru.rc b/reactos/dll/win32/shdoclc/Ru.rc index f20c2f469b3..06ca7193630 100644 --- a/reactos/dll/win32/shdoclc/Ru.rc +++ b/reactos/dll/win32/shdoclc/Ru.rc @@ -16,6 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" + +/* UTF-8 */ +#pragma code_page(65001) LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT @@ -26,7 +30,7 @@ STRINGTABLE DISCARDABLE STRINGTABLE DISCARDABLE { - IDS_PRINT_HEADER_TEMPLATE "&w&bÑòðàíèöà &p" /* FIXME: should be "&w&bPage &p of &P" */ + IDS_PRINT_HEADER_TEMPLATE "&w&bСтраница &p" /* FIXME: should be "&w&bPage &p of &P" */ IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" } @@ -34,110 +38,110 @@ IDR_BROWSE_CONTEXT_MENU MENU { POPUP "Default" { - MENUITEM "&Íàçàä", IDM_GOBACKWARD - MENUITEM "&Âïåðåä", IDM_GOFORWARD + MENUITEM "&Ðазад", IDM_GOBACKWARD + MENUITEM "&Вперед", IDM_GOFORWARD MENUITEM SEPARATOR - MENUITEM "&Ñîõðàíèòü ôîí êàê...", IDM_SAVEBACKGROUND - MENUITEM "Ñ&äåëàòü ôîíîâûì ðèñóíêîì", IDM_SETWALLPAPER - MENUITEM "&Êîïèðîâàòü ôîí", IDM_COPYBACKGROUND - MENUITEM "Ñîõðàíèòü êàê &ýëåìåíò ðàáî÷åãî ñòîëà...", IDM_SETDESKTOPITEM + MENUITEM "&Сохранить фон как...", IDM_SAVEBACKGROUND + MENUITEM "С&делать фоновым риÑунком", IDM_SETWALLPAPER + MENUITEM "&Копировать фон", IDM_COPYBACKGROUND + MENUITEM "Сохранить как &Ñлемент рабочего Ñтола...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Âûáðàòü Âñ&¸", IDM_SELECTALL - MENUITEM "Âñ&òàâèòü", IDM_PASTE + MENUITEM "Выделить вÑ&Ñ‘", IDM_SELECTALL + MENUITEM "Ð’Ñ&тавить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ñîçäàòü &ÿðëûê", IDM_CREATESHORTCUT - MENUITEM "Äîáàâèòü â &èçáðàííîå", IDM_ADDFAVORITES - MENUITEM "&Îòêðûòü èñõîäíûé òåêñò",IDM_VIEWSOURCE + MENUITEM "Создать &Ñрлык", IDM_CREATESHORTCUT + MENUITEM "Добавить в &избранное", IDM_ADDFAVORITES + MENUITEM "&Открыть иÑходный текÑÑ‚",IDM_VIEWSOURCE MENUITEM SEPARATOR - MENUITEM "&Êîäèðîâêà", IDM_LANGUAGE + MENUITEM "&Кодировка", IDM_LANGUAGE MENUITEM SEPARATOR - MENUITEM "Ïå&÷àòü", IDM_PRINT - MENUITEM "Î&áíîâèòü", _IDM_REFRESH + MENUITEM "Пе&чать", IDM_PRINT + MENUITEM "О&бновить", _IDM_REFRESH MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Ñâî&éñòâà", IDM_PROPERTIES + MENUITEM "Сво&йÑтва", IDM_PROPERTIES } POPUP "Image" { - MENUITEM "&Îòêðûòü ññûëêó", IDM_FOLLOWLINKC - MENUITEM "Îòêðûòü &ññûëêó â íîâîì îêíå",IDM_FOLLOWLINKN - MENUITEM "Ñîõðàíèòü îá&úåêò êàê...", IDM_SAVETARGET - MENUITEM "&Ïå÷àòü îáúåêòà", IDM_PRINTTARGET + MENUITEM "&Открыть ÑÑылку", IDM_FOLLOWLINKC + MENUITEM "Открыть &ÑÑылку в новом окне",IDM_FOLLOWLINKN + MENUITEM "Сохранить об&ъект как...", IDM_SAVETARGET + MENUITEM "&Печать объекта", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM "Ïîêàçàòü &ðèñóíîê", IDM_SHOWPICTURE - MENUITEM "Ñî&õðàíèòü ðèñóíîê êàê...",IDM_SAVEPICTURE - MENUITEM "&Îòïðàâèòü ðèñóíîê ïî E-mail...",IDM_MP_EMAILPICTURE - MENUITEM "&Ïå÷àòü ðèñóíêà...", IDM_MP_PRINTPICTURE - MENUITEM "&Ïåðåéòè â ïàïêó Ìîè ðèñóíêè", IDM_MP_MYPICS - MENUITEM "Ñ&äåëàòü ôîíîâûì ðèñóíêîì", IDM_SETWALLPAPER - MENUITEM "Ñîõðàíèòü êàê &ýëåìåíò ðàáî÷åãî ñòîëà...", IDM_SETDESKTOPITEM + MENUITEM "Показать &риÑунок", IDM_SHOWPICTURE + MENUITEM "Со&хранить риÑунок как...",IDM_SAVEPICTURE + MENUITEM "&Отправить риÑунок по E-mail...",IDM_MP_EMAILPICTURE + MENUITEM "&Печать риÑунка...", IDM_MP_PRINTPICTURE + MENUITEM "&Перейти в папку Мои риÑунки", IDM_MP_MYPICS + MENUITEM "С&делать фоновым риÑунком", IDM_SETWALLPAPER + MENUITEM "Сохранить как &Ñлемент рабочего Ñтола...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "&Âûðåçàòü", IDM_CUT - MENUITEM "&Êîïèðîâàòü", IDM_COPY - MENUITEM "Êîïèðîâàòü &ÿðëûê", IDM_COPYSHORTCUT - MENUITEM "&Âñòàâèòü", IDM_PASTE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Копировать &Ñрлык", IDM_COPYSHORTCUT + MENUITEM "&Ð’Ñтавить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Äîáàâèòü â &èçáðàííîå", IDM_ADDFAVORITES + MENUITEM "Добавить в &избранное", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Ñâî&éñòâà", IDM_PROPERTIES + MENUITEM "Сво&йÑтва", IDM_PROPERTIES } POPUP "Control" { - MENUITEM "&Îòìåíèòü", IDM_UNDO + MENUITEM "&Отменить", IDM_UNDO MENUITEM SEPARATOR - MENUITEM "&Âûðåçàòü", IDM_CUT - MENUITEM "&Êîïèðîâàòü", IDM_COPY - MENUITEM "Âñò&àâèòü", IDM_PASTE - MENUITEM "&Óäàëèòü", IDM_DELETE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Ð’ÑÑ‚&авить", IDM_PASTE + MENUITEM "&Удалить", IDM_DELETE MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Âûäåëèòü â&ñ¸", IDM_SELECTALL + MENUITEM "Выделить в&ÑÑ‘", IDM_SELECTALL } POPUP "Table" { - POPUP "&Âûäåëèòü" + POPUP "&Выделить" { - MENUITEM "&ÿ÷åéêó", IDM_CELLSELECT - MENUITEM "ñò&ðîêó", IDM_ROWSELECT - MENUITEM "&êîëîíêó", IDM_COLUMNSELECT - MENUITEM "&òàáëèöó", IDM_TABLESELECT + MENUITEM "&Ñчейку", IDM_CELLSELECT + MENUITEM "ÑÑ‚&року", IDM_ROWSELECT + MENUITEM "&колонку", IDM_COLUMNSELECT + MENUITEM "&таблицу", IDM_TABLESELECT } MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Ñâîéñòâà &ÿ÷åéêè", IDM_CELLPROPERTIES - MENUITEM "Ñâî&éñòâà òàáëèöû", IDM_TABLEPROPERTIES + MENUITEM "СвойÑтва &Ñчейки", IDM_CELLPROPERTIES + MENUITEM "Сво&йÑтва таблицы", IDM_TABLEPROPERTIES } POPUP "1DSite Select" { - MENUITEM "&Âûðåçàòü", IDM_CUT - MENUITEM "&Êîïèðîâàòü", IDM_COPY - MENUITEM "&Âñòàâèòü", IDM_PASTE - MENUITEM "Âûäåëèòü â&ñ¸", IDM_SELECTALL - MENUITEM "Ïå&÷àòü", IDM_PRINT + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "&Ð’Ñтавить", IDM_PASTE + MENUITEM "Выделить в&ÑÑ‘", IDM_SELECTALL + MENUITEM "Пе&чать", IDM_PRINT MENUITEM SEPARATOR } POPUP "Anchor" { - MENUITEM "&Îòêðûòü", IDM_FOLLOWLINKC - MENUITEM "Îòêðûòü â &íîâîì îêíå",IDM_FOLLOWLINKN - MENUITEM "Ñîõðàíèòü îá&úåêò êàê...", IDM_SAVETARGET - MENUITEM "&Ïå÷àòü îáúåêòà", IDM_PRINTTARGET + MENUITEM "&Открыть", IDM_FOLLOWLINKC + MENUITEM "Открыть в &новом окне",IDM_FOLLOWLINKN + MENUITEM "Сохранить об&ъект как...", IDM_SAVETARGET + MENUITEM "&Печать объекта", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM "&Âûðåçàòü", IDM_CUT - MENUITEM "&Êîïèðîâàòü", IDM_COPY - MENUITEM "Êîïèðîâàòü &ÿðëûê", IDM_COPYSHORTCUT - MENUITEM "&Âñòàâèòü", IDM_PASTE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Копировать &Ñрлык", IDM_COPYSHORTCUT + MENUITEM "&Ð’Ñтавить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Äîáàâèòü â &èçáðàííîå",IDM_ADDFAVORITES + MENUITEM "Добавить в &избранное",IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Ñâî&éñòâà", IDM_PROPERTIES + MENUITEM "Сво&йÑтва", IDM_PROPERTIES } POPUP "Context Unknown" @@ -147,54 +151,54 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "DYNSRC Image" { - MENUITEM "&Îòêðûòü ññûëêó", IDM_FOLLOWLINKC - MENUITEM "Îòêðûòü ññûëêó â &íîâîì îêíå", IDM_FOLLOWLINKN - MENUITEM "Ñîõðàíèòü îá&úåêò êàê...", IDM_SAVETARGET - MENUITEM "&Ïå÷àòü îáúåêòà", IDM_PRINTTARGET + MENUITEM "&Открыть ÑÑылку", IDM_FOLLOWLINKC + MENUITEM "Открыть ÑÑылку в &новом окне", IDM_FOLLOWLINKN + MENUITEM "Сохранить об&ъект как...", IDM_SAVETARGET + MENUITEM "&Печать объекта", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM "Ïîêàçàòü &ðèñóíîê", IDM_SHOWPICTURE - MENUITEM "Ñî&õðàíèòü ðèñóíîê êàê...",IDM_SAVEPICTURE - MENUITEM "Ñ&äåëàòü ôîíîâûì ðèñóíêîì", IDM_SETWALLPAPER - MENUITEM "Ñîõðàíèòü êàê &ýëåìåíò ðàáî÷åãî ñòîëà...", IDM_SETDESKTOPITEM + MENUITEM "Показать &риÑунок", IDM_SHOWPICTURE + MENUITEM "Со&хранить риÑунок как...",IDM_SAVEPICTURE + MENUITEM "С&делать фоновым риÑунком", IDM_SETWALLPAPER + MENUITEM "Сохранить как &Ñлемент рабочего Ñтола...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "&Âûðåçàòü", IDM_CUT - MENUITEM "&Êîïèðîâàòü", IDM_COPY - MENUITEM "Êîïèðîâàòü &ÿðëûê", IDM_COPYSHORTCUT - MENUITEM "&Âñòàâèòü", IDM_PASTE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Копировать &Ñрлык", IDM_COPYSHORTCUT + MENUITEM "&Ð’Ñтавить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Äîáàâèòü â &èçáðàííîå", IDM_ADDFAVORITES + MENUITEM "Добавить в &избранное", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Âîñïðîèçâåñòè", IDM_DYNSRCPLAY - MENUITEM "Îñòàíîâèòü", IDM_DYNSRCSTOP - MENUITEM "Ñâî&éñòâà", IDM_PROPERTIES + MENUITEM "ВоÑпроизвеÑти", IDM_DYNSRCPLAY + MENUITEM "ОÑтановить", IDM_DYNSRCSTOP + MENUITEM "Сво&йÑтва", IDM_PROPERTIES } POPUP "ART Image" { - MENUITEM "&Îòêðûòü ññûëêó", IDM_FOLLOWLINKC - MENUITEM "Îòêðûòü ññûëêó â &íîâîì îêíå", IDM_FOLLOWLINKN - MENUITEM "Ñîõðàíèòü îá&úåêò êàê...", IDM_SAVETARGET - MENUITEM "&Ïå÷àòü îáúåêòà", IDM_PRINTTARGET + MENUITEM "&Открыть ÑÑылку", IDM_FOLLOWLINKC + MENUITEM "Открыть ÑÑылку в &новом окне", IDM_FOLLOWLINKN + MENUITEM "Сохранить об&ъект как...", IDM_SAVETARGET + MENUITEM "&Печать объекта", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM "Ïîêàçàòü &ðèñóíîê", IDM_SHOWPICTURE - MENUITEM "Ñî&õðàíèòü ðèñóíîê êàê...",IDM_SAVEPICTURE - MENUITEM "Ñ&äåëàòü ôîíîâûì ðèñóíêîì", IDM_SETWALLPAPER - MENUITEM "Ñîõðàíèòü êàê &ýëåìåíò ðàáî÷åãî ñòîëà...", IDM_SETDESKTOPITEM + MENUITEM "Показать &риÑунок", IDM_SHOWPICTURE + MENUITEM "Со&хранить риÑунок как...",IDM_SAVEPICTURE + MENUITEM "С&делать фоновым риÑунком", IDM_SETWALLPAPER + MENUITEM "Сохранить как &Ñлемент рабочего Ñтола...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "&Âûðåçàòü", IDM_CUT - MENUITEM "&Êîïèðîâàòü", IDM_COPY - MENUITEM "Êîïèðîâàòü &ÿðëûê", IDM_COPYSHORTCUT - MENUITEM "&Âñòàâèòü", IDM_PASTE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Копировать &Ñрлык", IDM_COPYSHORTCUT + MENUITEM "&Ð’Ñтавить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Äîáàâèòü â &èçáðàííîå", IDM_ADDFAVORITES + MENUITEM "Добавить в &избранное", IDM_ADDFAVORITES MENUITEM SEPARATOR - MENUITEM "Âîñïðîèçâåñòè", IDM_IMGARTPLAY - MENUITEM "Îñòàíîâèòü", IDM_IMGARTSTOP - MENUITEM "Ïåðåìîòàòü", IDM_IMGARTREWIND + MENUITEM "ВоÑпроизвеÑти", IDM_IMGARTPLAY + MENUITEM "ОÑтановить", IDM_IMGARTSTOP + MENUITEM "Перемотать", IDM_IMGARTREWIND MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Ñâî&éñòâà", IDM_PROPERTIES + MENUITEM "Сво&йÑтва", IDM_PROPERTIES } POPUP "Debug" @@ -213,35 +217,35 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Performance Meters", IDM_PERFORMANCEMETERS MENUITEM "Save HTML", IDM_SAVEHTML MENUITEM SEPARATOR - MENUITEM "Âèä îá&çîðà", IDM_BROWSEMODE - MENUITEM "Èç&ìåíèòü âèä", IDM_EDITMODE + MENUITEM "Вид об&зора", IDM_BROWSEMODE + MENUITEM "Из&менить вид", IDM_EDITMODE } POPUP "Vertical Scrollbar" { - MENUITEM "Ïðîêðóòêà íà ìåñòå", IDM_SCROLL_HERE + MENUITEM "Прокрутка на меÑте", IDM_SCROLL_HERE MENUITEM SEPARATOR - MENUITEM "Ââåðõ", IDM_SCROLL_TOP - MENUITEM "Âíèç", IDM_SCROLL_BOTTOM + MENUITEM "Вверх", IDM_SCROLL_TOP + MENUITEM "Вниз", IDM_SCROLL_BOTTOM MENUITEM SEPARATOR - MENUITEM "Ñòðàíèöà ââåðõ", IDM_SCROLL_PAGEUP - MENUITEM "Ñòðàíèöà âíèç", IDM_SCROLL_PAGEDOWN + MENUITEM "Страница вверх", IDM_SCROLL_PAGEUP + MENUITEM "Страница вниз", IDM_SCROLL_PAGEDOWN MENUITEM SEPARATOR - MENUITEM "Ïðîêðóòêà ââåðõ", IDM_SCROLL_UP - MENUITEM "Ïðîêðóòêà âíèç", IDM_SCROLL_DOWN + MENUITEM "Прокрутка вверх", IDM_SCROLL_UP + MENUITEM "Прокрутка вниз", IDM_SCROLL_DOWN } POPUP "Horizontal Scrollbar" { - MENUITEM "Ïðîêðóòêà íà ìåñòå", IDM_SCROLL_HERE + MENUITEM "Прокрутка на меÑте", IDM_SCROLL_HERE MENUITEM SEPARATOR - MENUITEM "Ê ëåâîìó êðàþ", IDM_SCROLL_LEFTEDGE - MENUITEM "Ê ïðàâîìó êðàþ", IDM_SCROLL_RIGHTEDGE + MENUITEM "К левому краю", IDM_SCROLL_LEFTEDGE + MENUITEM "К правому краю", IDM_SCROLL_RIGHTEDGE MENUITEM SEPARATOR - MENUITEM "Ñòðàíèöà âëåâî", IDM_SCROLL_PAGELEFT - MENUITEM "Ñòðàíèöà âïðàâî", IDM_SCROLL_PAGERIGHT + MENUITEM "Страница влево", IDM_SCROLL_PAGELEFT + MENUITEM "Страница вправо", IDM_SCROLL_PAGERIGHT MENUITEM SEPARATOR - MENUITEM "Ïðîêðóòêà âëåâî", IDM_SCROLL_LEFT - MENUITEM "Ïðîêðóòêà âïðàâî", IDM_SCROLL_RIGHT + MENUITEM "Прокрутка влево", IDM_SCROLL_LEFT + MENUITEM "Прокрутка вправо", IDM_SCROLL_RIGHT } } diff --git a/reactos/dll/win32/shdoclc/Si.rc b/reactos/dll/win32/shdoclc/Si.rc index ccc79002144..26a039a13c7 100644 --- a/reactos/dll/win32/shdoclc/Si.rc +++ b/reactos/dll/win32/shdoclc/Si.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT @@ -247,5 +248,4 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Drsenje desno", IDM_SCROLL_RIGHT } } - #pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/Sv.rc b/reactos/dll/win32/shdoclc/Sv.rc index 9b20705b3d4..277745d5630 100644 --- a/reactos/dll/win32/shdoclc/Sv.rc +++ b/reactos/dll/win32/shdoclc/Sv.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL diff --git a/reactos/dll/win32/shdoclc/Tr.rc b/reactos/dll/win32/shdoclc/Tr.rc index 8bd4ed07fa0..ea238e14bf8 100644 --- a/reactos/dll/win32/shdoclc/Tr.rc +++ b/reactos/dll/win32/shdoclc/Tr.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT diff --git a/reactos/dll/win32/shdoclc/Uk.rc b/reactos/dll/win32/shdoclc/Uk.rc new file mode 100644 index 00000000000..ae2356b92b4 --- /dev/null +++ b/reactos/dll/win32/shdoclc/Uk.rc @@ -0,0 +1,470 @@ +/* + * Copyright 2005-2006 Jacek Caban + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "shdoclc.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_MESSAGE_BOX_TITLE, "Wine Internet Explorer" +} + +STRINGTABLE DISCARDABLE +{ + IDS_PRINT_HEADER_TEMPLATE "&w&bPage &p" /* FIXME: should be "&w&bPage &p of &P" */ + IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" +} + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Default" + { + MENUITEM "&Ðазад", IDM_GOBACKWARD + MENUITEM "&Вперед", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Зберегти тло Ñк...", IDM_SAVEBACKGROUND + MENUITEM "Зробити &фоновим малюнком", IDM_SETWALLPAPER + MENUITEM "&Копіювати тло", IDM_COPYBACKGROUND + MENUITEM "Set as &Desktop Item", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Виділити вÑ&е", IDM_SELECTALL + MENUITEM "Ð’&Ñтавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Створити &Ñрлик", IDM_CREATESHORTCUT + MENUITEM "Додати до &Обраного", IDM_ADDFAVORITES + MENUITEM "&ПереглÑнути вихідний код", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "&КодуваннÑ", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "&Друк", IDM_PRINT + MENUITEM "О&новити", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Ð’&лаÑтивоÑті", IDM_PROPERTIES + } + + POPUP "Image" + { + MENUITEM "&Відкрити поÑиланнÑ", IDM_FOLLOWLINKC + MENUITEM "Відкрити поÑÐ¸Ð»Ð°Ð½Ð½Ñ Ð² &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &Ñк...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "&Зберегти малюнок Ñк...", IDM_SAVEPICTURE + MENUITEM "Відправити малюнок по &Е-mail...", IDM_MP_EMAILPICTURE + MENUITEM "Др&ук малюнка...", IDM_MP_PRINTPICTURE + MENUITEM "&Перейти до теки Мої Малюнки", IDM_MP_MYPICS + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Ви&різати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ярл&ик", IDM_COPYSHORTCUT + MENUITEM "Ð’&Ñтавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "ВлаÑтивоÑÑ‚&Ñ–", IDM_PROPERTIES + } + + POPUP "Control" + { + MENUITEM "&Відмінити", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Ð’&Ñтавити", IDM_PASTE + MENUITEM "Ви&далити", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Виділ&ити вÑе", IDM_SELECTALL + } + + POPUP "Table" + { + POPUP "&Виділити" + { + MENUITEM "&Комірку", IDM_CELLSELECT + MENUITEM "&РÑдок", IDM_ROWSELECT + MENUITEM "&Стовпчик", IDM_COLUMNSELECT + MENUITEM "&Таблицю", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "ВлаÑтивоÑті &Комірки", IDM_CELLPROPERTIES + MENUITEM "ВлаÑтивоÑті &Таблиці", IDM_TABLEPROPERTIES + } + + POPUP "1DSite Select" + { + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Ð’Ñтавити", IDM_PASTE + MENUITEM "Виділити в&Ñе", IDM_SELECTALL + MENUITEM "&Друк", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Anchor" + { + MENUITEM "&Відкрити", IDM_FOLLOWLINKC + MENUITEM "Відкрити в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &Ñк...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Вирізати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ñ&рлик", IDM_COPYSHORTCUT + MENUITEM "Ð’Ñ&тавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Ð’&лаÑтивоÑті", IDM_PROPERTIES + } + + POPUP "Context Unknown" + { + MENUITEM SEPARATOR + } + + POPUP "DYNSRC Image" + { + MENUITEM "&Відкрити поÑиланнÑ", IDM_FOLLOWLINKC + MENUITEM "Відкрити поÑÐ¸Ð»Ð°Ð½Ð½Ñ Ð² &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &Ñк...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "&Save Video As...", IDM_SAVEPICTURE + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ñ&рлик", IDM_COPYSHORTCUT + MENUITEM "Ð’Ñтав&ити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Грати", IDM_DYNSRCPLAY + MENUITEM "Зупинити", IDM_DYNSRCSTOP + MENUITEM "ВлаÑтивоÑÑ‚&Ñ–", IDM_PROPERTIES + } + + POPUP "ART Image" + { + MENUITEM "&Відкрити поÑиланнÑ", IDM_FOLLOWLINKC + MENUITEM "Відкрити поÑÐ¸Ð»Ð°Ð½Ð½Ñ Ð² &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &Ñк...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "Зберегти малюнок Ñ&к...", IDM_SAVEPICTURE + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Ð’&ирізати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ñ&рлик", IDM_COPYSHORTCUT + MENUITEM "Ð’Ñ&тавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Грати", IDM_IMGARTPLAY + MENUITEM "Зупинити", IDM_IMGARTSTOP + MENUITEM "Перемотати", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "ВлаÑтивоÑÑ‚&Ñ–", IDM_PROPERTIES + } + + POPUP "Debug" + { + MENUITEM "Trace Tags", IDM_TRACETAGS + MENUITEM "Resource Failures", IDM_RESOURCEFAILURES + MENUITEM "Dump Tracking Info", IDM_DUMPTRACKINGINFO + MENUITEM "Debug Break", IDM_DEBUGBREAK + MENUITEM "Debug View", IDM_DEBUGVIEW + MENUITEM "Dump Tree", IDM_DUMPTREE + MENUITEM "Dump Lines", IDM_DUMPLINES + MENUITEM "Dump DisplayTree", IDM_DUMPDISPLAYTREE + MENUITEM "Dump FormatCaches", IDM_DUMPFORMATCACHES + MENUITEM "Dump LayoutRects", IDM_DUMPLAYOUTRECTS + MENUITEM "Memory Monitor", IDM_MEMORYMONITOR + MENUITEM "Performance Meters", IDM_PERFORMANCEMETERS + MENUITEM "Save HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&Browse View", IDM_BROWSEMODE + MENUITEM "&Edit View", IDM_EDITMODE + } + + POPUP "Vertical Scrollbar" + { + MENUITEM "Прокрутити тут", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Вверх", IDM_SCROLL_TOP + MENUITEM "Вниз", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Сторінка вверх", IDM_SCROLL_PAGEUP + MENUITEM "Сторінка вниз", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Прокрутити вверх", IDM_SCROLL_UP + MENUITEM "Прокрутити вниз", IDM_SCROLL_DOWN + } + + POPUP "Horizontal Scrollbar" + { + MENUITEM "Прокрутити тут", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "До лівого краю", IDM_SCROLL_LEFTEDGE + MENUITEM "До правого краю", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Сторінка вліво", IDM_SCROLL_PAGELEFT + MENUITEM "Сторінка вправо", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Прокрутити вліво", IDM_SCROLL_LEFT + MENUITEM "Проктурити вправо", IDM_SCROLL_RIGHT + } +} + +LANGUAGE LANG_UKRAINIAN, SUBLANG_NEUTRAL + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Default" + { + MENUITEM "&Ðазад", IDM_GOBACKWARD + MENUITEM "&Вперед", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Зберегти тло Ñк...", IDM_SAVEBACKGROUND + MENUITEM "Зробити &фоновим малюнком", IDM_SETWALLPAPER + MENUITEM "&Копіювати тло", IDM_COPYBACKGROUND + MENUITEM "Set as &Desktop Item", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Виділити вÑ&е", IDM_SELECTALL + MENUITEM "Ð’&Ñтавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Створити &Ñрлик", IDM_CREATESHORTCUT + MENUITEM "Додати до &Обраного", IDM_ADDFAVORITES + MENUITEM "&ПереглÑнути вихідний код", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "&КодуваннÑ", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "&Друк", IDM_PRINT + MENUITEM "О&новити", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Ð’&лаÑтивоÑті", IDM_PROPERTIES + } + + POPUP "Image" + { + MENUITEM "&Відкрити поÑиланнÑ", IDM_FOLLOWLINKC + MENUITEM "Відкрити поÑÐ¸Ð»Ð°Ð½Ð½Ñ Ð² &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &Ñк...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "&Зберегти малюнок Ñк...", IDM_SAVEPICTURE + MENUITEM "Відправити малюнок по &Е-mail...", IDM_MP_EMAILPICTURE + MENUITEM "Др&ук малюнка...", IDM_MP_PRINTPICTURE + MENUITEM "&Перейти до теки Мої Малюнки", IDM_MP_MYPICS + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Ви&різати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ярл&ик", IDM_COPYSHORTCUT + MENUITEM "Ð’&Ñтавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "ВлаÑтивоÑÑ‚&Ñ–", IDM_PROPERTIES + } + + POPUP "Control" + { + MENUITEM "&Відмінити", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Ð’&Ñтавити", IDM_PASTE + MENUITEM "Ви&далити", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Виділ&ити вÑе", IDM_SELECTALL + } + + POPUP "Table" + { + POPUP "&Виділити" + { + MENUITEM "&Комірку", IDM_CELLSELECT + MENUITEM "&РÑдок", IDM_ROWSELECT + MENUITEM "&Стовпчик", IDM_COLUMNSELECT + MENUITEM "&Таблицю", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "ВлаÑтивоÑті &Комірки", IDM_CELLPROPERTIES + MENUITEM "ВлаÑтивоÑті &Таблиці", IDM_TABLEPROPERTIES + } + + POPUP "1DSite Select" + { + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Ð’Ñтавити", IDM_PASTE + MENUITEM "Виділити в&Ñе", IDM_SELECTALL + MENUITEM "&Друк", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Anchor" + { + MENUITEM "&Відкрити", IDM_FOLLOWLINKC + MENUITEM "Відкрити в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &Ñк...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Вирізати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ñ&рлик", IDM_COPYSHORTCUT + MENUITEM "Ð’Ñ&тавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Ð’&лаÑтивоÑті", IDM_PROPERTIES + } + + POPUP "Context Unknown" + { + MENUITEM SEPARATOR + } + + POPUP "DYNSRC Image" + { + MENUITEM "&Відкрити поÑиланнÑ", IDM_FOLLOWLINKC + MENUITEM "Відкрити поÑÐ¸Ð»Ð°Ð½Ð½Ñ Ð² &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &Ñк...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "&Save Video As...", IDM_SAVEPICTURE + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ñ&рлик", IDM_COPYSHORTCUT + MENUITEM "Ð’Ñтав&ити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Грати", IDM_DYNSRCPLAY + MENUITEM "Зупинити", IDM_DYNSRCSTOP + MENUITEM "ВлаÑтивоÑÑ‚&Ñ–", IDM_PROPERTIES + } + + POPUP "ART Image" + { + MENUITEM "&Відкрити поÑиланнÑ", IDM_FOLLOWLINKC + MENUITEM "Відкрити поÑÐ¸Ð»Ð°Ð½Ð½Ñ Ð² &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &Ñк...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "Зберегти малюнок Ñ&к...", IDM_SAVEPICTURE + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Ð’&ирізати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ñ&рлик", IDM_COPYSHORTCUT + MENUITEM "Ð’Ñ&тавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Грати", IDM_IMGARTPLAY + MENUITEM "Зупинити", IDM_IMGARTSTOP + MENUITEM "Перемотати", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "ВлаÑтивоÑÑ‚&Ñ–", IDM_PROPERTIES + } + + POPUP "Debug" + { + MENUITEM "Trace Tags", IDM_TRACETAGS + MENUITEM "Resource Failures", IDM_RESOURCEFAILURES + MENUITEM "Dump Tracking Info", IDM_DUMPTRACKINGINFO + MENUITEM "Debug Break", IDM_DEBUGBREAK + MENUITEM "Debug View", IDM_DEBUGVIEW + MENUITEM "Dump Tree", IDM_DUMPTREE + MENUITEM "Dump Lines", IDM_DUMPLINES + MENUITEM "Dump DisplayTree", IDM_DUMPDISPLAYTREE + MENUITEM "Dump FormatCaches", IDM_DUMPFORMATCACHES + MENUITEM "Dump LayoutRects", IDM_DUMPLAYOUTRECTS + MENUITEM "Memory Monitor", IDM_MEMORYMONITOR + MENUITEM "Performance Meters", IDM_PERFORMANCEMETERS + MENUITEM "Save HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&Browse View", IDM_BROWSEMODE + MENUITEM "&Edit View", IDM_EDITMODE + } + + POPUP "Vertical Scrollbar" + { + MENUITEM "Прокрутити тут", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Вверх", IDM_SCROLL_TOP + MENUITEM "Вниз", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Сторінка вверх", IDM_SCROLL_PAGEUP + MENUITEM "Сторінка вниз", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Прокрутити вверх", IDM_SCROLL_UP + MENUITEM "Прокрутити вниз", IDM_SCROLL_DOWN + } + + POPUP "Horizontal Scrollbar" + { + MENUITEM "Прокрутити тут", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "До лівого краю", IDM_SCROLL_LEFTEDGE + MENUITEM "До правого краю", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Сторінка вліво", IDM_SCROLL_PAGELEFT + MENUITEM "Сторінка вправо", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Прокрутити вліво", IDM_SCROLL_LEFT + MENUITEM "Проктурити вправо", IDM_SCROLL_RIGHT + } +} diff --git a/reactos/dll/win32/shdoclc/Zh.rc b/reactos/dll/win32/shdoclc/Zh.rc index f3570e840ce..c597676882c 100644 --- a/reactos/dll/win32/shdoclc/Zh.rc +++ b/reactos/dll/win32/shdoclc/Zh.rc @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" /* Chinese text is encoded in UTF-8 */ #pragma code_page(65001) @@ -479,5 +480,3 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "å‘峿»¾å‹•", IDM_SCROLL_RIGHT } } - -#pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/rsrc.rc b/reactos/dll/win32/shdoclc/rsrc.rc index 847c2e120cd..3e048af673f 100644 --- a/reactos/dll/win32/shdoclc/rsrc.rc +++ b/reactos/dll/win32/shdoclc/rsrc.rc @@ -31,11 +31,14 @@ #include "Fr.rc" #include "Hu.rc" #include "Ko.rc" +#include "Lt.rc" #include "Nl.rc" #include "No.rc" #include "Pt.rc" +#include "Ro.rc" #include "Ru.rc" #include "Si.rc" #include "Sv.rc" #include "Tr.rc" +#include "Uk.rc" #include "Zh.rc" diff --git a/reactos/dll/win32/shdoclc/shdoclc.h b/reactos/dll/win32/shdoclc/shdoclc.h index 2bc7626990a..b5492d6243a 100644 --- a/reactos/dll/win32/shdoclc/shdoclc.h +++ b/reactos/dll/win32/shdoclc/shdoclc.h @@ -16,6 +16,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include +#include + #define IDS_MESSAGE_BOX_TITLE 2213 #define IDS_PRINT_HEADER_TEMPLATE 8403 From 72a689d62e95a5470dedf239c0a31792e6daf62c Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 19:38:02 +0000 Subject: [PATCH 034/211] [SHDOCVW] sync shdocvw to wine 1.1.39 svn path=/trunk/; revision=45764 --- reactos/dll/win32/shdocvw/dochost.c | 36 +++++++++-- reactos/dll/win32/shdocvw/intshcut.c | 61 ++++++++++++------- reactos/dll/win32/shdocvw/oleobject.c | 76 ++++++++++++++---------- reactos/dll/win32/shdocvw/shdocvw.h | 3 + reactos/dll/win32/shdocvw/shdocvw.inf | 12 ++-- reactos/dll/win32/shdocvw/shdocvw_main.c | 25 ++++++++ reactos/dll/win32/shdocvw/webbrowser.c | 29 +++++---- 7 files changed, 167 insertions(+), 75 deletions(-) diff --git a/reactos/dll/win32/shdocvw/dochost.c b/reactos/dll/win32/shdocvw/dochost.c index f3035e1c15e..e8982e4f12a 100644 --- a/reactos/dll/win32/shdocvw/dochost.c +++ b/reactos/dll/win32/shdocvw/dochost.c @@ -362,6 +362,29 @@ void deactivate_document(DocHost *This) This->document = NULL; } +void release_dochost_client(DocHost *This) +{ + if(This->hwnd) { + DestroyWindow(This->hwnd); + This->hwnd = NULL; + } + + if(This->hostui) { + IDocHostUIHandler_Release(This->hostui); + This->hostui = NULL; + } + + if(This->client_disp) { + IDispatch_Release(This->client_disp); + This->client_disp = NULL; + } + + if(This->frame) { + IOleInPlaceFrame_Release(This->frame); + This->frame = NULL; + } +} + #define OLECMD_THIS(iface) DEFINE_THIS(DocHost, OleCommandTarget, iface) static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface, @@ -387,8 +410,13 @@ static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText) { DocHost *This = OLECMD_THIS(iface); + ULONG i= 0; FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText); + while (prgCmds && (cCmds > i)) { + FIXME("command_%u: %u, 0x%x\n", i, prgCmds[i].cmdID, prgCmds[i].cmdf); + i++; + } return E_NOTIMPL; } @@ -744,14 +772,10 @@ void DocHost_Init(DocHost *This, IDispatch *disp) void DocHost_Release(DocHost *This) { - if(This->client_disp) - IDispatch_Release(This->client_disp); - if(This->frame) - IOleInPlaceFrame_Release(This->frame); - + release_dochost_client(This); DocHost_ClientSite_Release(This); ConnectionPointContainer_Destroy(&This->cps); - SysFreeString(This->url); + CoTaskMemFree(This->url); } diff --git a/reactos/dll/win32/shdocvw/intshcut.c b/reactos/dll/win32/shdocvw/intshcut.c index 86bc543aa32..b389ec3727a 100644 --- a/reactos/dll/win32/shdocvw/intshcut.c +++ b/reactos/dll/win32/shdocvw/intshcut.c @@ -65,16 +65,51 @@ static inline InternetShortcut* impl_from_IPersistFile(IPersistFile *iface) return (InternetShortcut*)((char*)iface - FIELD_OFFSET(InternetShortcut, persistFile)); } -static BOOL StartLinkProcessor(LPCOLESTR szLink) +static BOOL run_winemenubuilder( const WCHAR *args ) { - static const WCHAR szFormat[] = { - 'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e', - ' ','-','w',' ','-','u',' ','"','%','s','"',0 }; + static const WCHAR menubuilder[] = {'\\','w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',0}; LONG len; LPWSTR buffer; STARTUPINFOW si; PROCESS_INFORMATION pi; BOOL ret; + WCHAR app[MAX_PATH]; + + GetSystemDirectoryW( app, MAX_PATH - sizeof(menubuilder)/sizeof(WCHAR) ); + strcatW( app, menubuilder ); + + len = (strlenW( app ) + strlenW( args ) + 1) * sizeof(WCHAR); + buffer = heap_alloc( len ); + if( !buffer ) + return FALSE; + + strcpyW( buffer, app ); + strcatW( buffer, args ); + + TRACE("starting %s\n",debugstr_w(buffer)); + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + + ret = CreateProcessW( app, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ); + + heap_free( buffer ); + + if (ret) + { + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); + } + + return ret; +} + +static BOOL StartLinkProcessor( LPCOLESTR szLink ) +{ + static const WCHAR szFormat[] = { ' ','-','w',' ','-','u',' ','"','%','s','"',0 }; + LONG len; + LPWSTR buffer; + BOOL ret; len = sizeof(szFormat) + lstrlenW( szLink ) * sizeof(WCHAR); buffer = heap_alloc( len ); @@ -82,22 +117,8 @@ static BOOL StartLinkProcessor(LPCOLESTR szLink) return FALSE; wsprintfW( buffer, szFormat, szLink ); - - TRACE("starting %s\n",debugstr_w(buffer)); - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - - ret = CreateProcessW( NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ); - - HeapFree( GetProcessHeap(), 0, buffer ); - - if (ret) - { - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - } - + ret = run_winemenubuilder( buffer ); + heap_free( buffer ); return ret; } diff --git a/reactos/dll/win32/shdocvw/oleobject.c b/reactos/dll/win32/shdocvw/oleobject.c index 3657a7a5276..f67edb7583e 100644 --- a/reactos/dll/win32/shdocvw/oleobject.c +++ b/reactos/dll/win32/shdocvw/oleobject.c @@ -255,6 +255,36 @@ static HRESULT on_silent_change(WebBrowser *This) return S_OK; } +static void release_client_site(WebBrowser *This) +{ + release_dochost_client(&This->doc_host); + + if(This->shell_embedding_hwnd) { + DestroyWindow(This->shell_embedding_hwnd); + This->shell_embedding_hwnd = NULL; + } + + if(This->inplace) { + IOleInPlaceSite_Release(This->inplace); + This->inplace = NULL; + } + + if(This->container) { + IOleContainer_Release(This->container); + This->container = NULL; + } + + if(This->uiwindow) { + IOleInPlaceUIWindow_Release(This->uiwindow); + This->uiwindow = NULL; + } + + if(This->client) { + IOleClientSite_Release(This->client); + This->client = NULL; + } +} + /********************************************************************** * Implement the IOleObject interface for the WebBrowser control */ @@ -282,7 +312,9 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface) static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite) { WebBrowser *This = OLEOBJ_THIS(iface); + IDocHostUIHandler *hostui; IOleContainer *container; + IDispatch *disp; HRESULT hres; TRACE("(%p)->(%p)\n", This, pClientSite); @@ -290,29 +322,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE if(This->client == pClientSite) return S_OK; - if(This->doc_host.hwnd) { - DestroyWindow(This->doc_host.hwnd); - This->doc_host.hwnd = NULL; - } - if(This->shell_embedding_hwnd) { - DestroyWindow(This->shell_embedding_hwnd); - This->shell_embedding_hwnd = NULL; - } - - if(This->inplace) { - IOleInPlaceSite_Release(This->inplace); - This->inplace = NULL; - } - - if(This->doc_host.hostui) { - IDocHostUIHandler_Release(This->doc_host.hostui); - This->doc_host.hostui = NULL; - } - - if(This->client) - IOleClientSite_Release(This->client); - - This->client = pClientSite; + release_client_site(This); if(!pClientSite) { if(This->doc_host.document) @@ -321,12 +331,17 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE } IOleClientSite_AddRef(pClientSite); + This->client = pClientSite; - IOleClientSite_QueryInterface(This->client, &IID_IDispatch, - (void**)&This->doc_host.client_disp); + hres = IOleClientSite_QueryInterface(This->client, &IID_IDispatch, + (void**)&disp); + if(SUCCEEDED(hres)) + This->doc_host.client_disp = disp; - IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler, - (void**)&This->doc_host.hostui); + hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler, + (void**)&hostui); + if(SUCCEEDED(hres)) + This->doc_host.hostui = hostui; hres = IOleClientSite_GetContainer(This->client, &container); if(SUCCEEDED(hres)) { @@ -963,10 +978,5 @@ void WebBrowser_OleObject_Init(WebBrowser *This) void WebBrowser_OleObject_Destroy(WebBrowser *This) { - if(This->client) - IOleObject_SetClientSite(OLEOBJ(This), NULL); - if(This->container) - IOleContainer_Release(This->container); - if(This->uiwindow) - IOleInPlaceUIWindow_Release(This->uiwindow); + release_client_site(This); } diff --git a/reactos/dll/win32/shdocvw/shdocvw.h b/reactos/dll/win32/shdocvw/shdocvw.h index 9a511211f71..c5b9c9a1be5 100644 --- a/reactos/dll/win32/shdocvw/shdocvw.h +++ b/reactos/dll/win32/shdocvw/shdocvw.h @@ -205,6 +205,7 @@ void WebBrowser_OleObject_Destroy(WebBrowser*); void DocHost_Init(DocHost*,IDispatch*); void DocHost_ClientSite_Init(DocHost*); void DocHost_Frame_Init(DocHost*); +void release_dochost_client(DocHost*); void DocHost_Release(DocHost*); void DocHost_ClientSite_Release(DocHost*); @@ -252,6 +253,8 @@ HRESULT register_class_object(BOOL); HRESULT get_typeinfo(ITypeInfo**); DWORD register_iexplore(BOOL); +const char *debugstr_variant(const VARIANT*); + /* memory allocation functions */ static inline void *heap_alloc(size_t len) diff --git a/reactos/dll/win32/shdocvw/shdocvw.inf b/reactos/dll/win32/shdocvw/shdocvw.inf index 92e78845f35..932c9beaf25 100644 --- a/reactos/dll/win32/shdocvw/shdocvw.inf +++ b/reactos/dll/win32/shdocvw/shdocvw.inf @@ -34,10 +34,10 @@ HKCR,"CLSID\%CLSID_SearchAssistantOC%\InProcServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_SearchAssistantOC%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_SearchAssistantOC%\ProgID",,,"SearchAssistantOC.SearchAssistantOC.1" HKCR,"CLSID\%CLSID_SearchAssistantOC%\VersionIndependentProgID",,,"SearchAssistantOC.SearchAssistantOC" -HKCR,"SearchAssistantOC.SearchAssistantOC",,,"" +HKCR,"SearchAssistantOC.SearchAssistantOC",,,"SearchAssistantOC" HKCR,"SearchAssistantOC.SearchAssistantOC\CLSID",,,"%CLSID_SearchAssistantOC%" HKCR,"SearchAssistantOC.SearchAssistantOC\CurVer",,,"SearchAssistantOC.SearchAssistantOC.1" -HKCR,"SearchAssistantOC.SearchAssistantOC.1",,,"" +HKCR,"SearchAssistantOC.SearchAssistantOC.1",,,"SearchAssistantOC" HKCR,"SearchAssistantOC.SearchAssistantOC.1\CLSID",,,"%CLSID_SearchAssistantOC%" HKCR,"CLSID\%CLSID_ShellNameSpace%",,,"Shell Name Space" @@ -67,7 +67,7 @@ HKCR,"CLSID\%CLSID_ShellUIHelper%\ProgID",,,"Shell.UIHelper.1" HKCR,"Shell.UIHelper",,,"Microsoft Shell UI Helper" HKCR,"Shell.UIHelper\CLSID",,,"%CLSID_ShellUIHelper%" HKCR,"Shell.UIHelper\CurVer",,,"Shell.UIHelper.2" -HKCR,"Shell.UIHelper.1",,,"" +HKCR,"Shell.UIHelper.1",,,"Microsoft Shell UI Helper" HKCR,"Shell.UIHelper.1\CLSID",,,"%CLSID_ShellUIHelper%" HKCR,"CLSID\%CLSID_Internet%\DefaultIcon",,,"shdoclc.dll,-190" @@ -86,7 +86,7 @@ HKCR,"CLSID\%CLSID_WebBrowser%\VersionIndependentProgID",,,"Shell.Explorer" HKCR,"Shell.Explorer",,,"Microsoft Web Browser" HKCR,"Shell.Explorer\CLSID",,,"%CLSID_WebBrowser%" HKCR,"Shell.Explorer\CurVer",,,"Shell.Explorer.2" -HKCR,"Shell.Explorer.2",,,"" +HKCR,"Shell.Explorer.2",,,"Microsoft Web Browser" HKCR,"Shell.Explorer.2\CLSID",,,"%CLSID_WebBrowser%" HKCR,"CLSID\%CLSID_ShellWindows%",,,"ShellWindows" @@ -108,14 +108,14 @@ HKCR,"CLSID\%CLSID_WebBrowser_V1%\InProcServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_WebBrowser_V1%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_WebBrowser_V1%\ProgID",,,"Shell.Explorer.1" HKCR,"CLSID\%CLSID_WebBrowser_V1%\VersionIndependentProgID",,,"Shell.Explorer" -HKCR,"Shell.Explorer.1",,,"" +HKCR,"Shell.Explorer.1",,,"Microsoft Web Browser" HKCR,"Shell.Explorer.1\CLSID",,,"%CLSID_WebBrowser_V1%" HKCR,"CLSID\%CLSID_InternetShortcut%",,,"Internet Shortcut" HKCR,"CLSID\%CLSID_InternetShortcut%\InProcServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_InternetShortcut%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_InternetShortcut%\ProgID",,,"InternetShortcut" -HKCR,"CLSID\%CLSID_InternetShortcut%\shellex\MayChangeDefaultMenu",,, +HKCR,"CLSID\%CLSID_InternetShortcut%\shellex\MayChangeDefaultMenu",,16 HKCR,"InternetShortcut",,,"Internet Shortcut" HKCR,"InternetShortcut","EditFlags",2,"2" HKCR,"InternetShortcut","IsShortcut",, diff --git a/reactos/dll/win32/shdocvw/shdocvw_main.c b/reactos/dll/win32/shdocvw/shdocvw_main.c index 9090b7d47f4..746753f0ab2 100644 --- a/reactos/dll/win32/shdocvw/shdocvw_main.c +++ b/reactos/dll/win32/shdocvw/shdocvw_main.c @@ -67,6 +67,31 @@ HRESULT get_typeinfo(ITypeInfo **typeinfo) return hres; } +const char *debugstr_variant(const VARIANT *v) +{ + if(!v) + return "(null)"; + + switch(V_VT(v)) { + case VT_EMPTY: + return "{VT_EMPTY}"; + case VT_NULL: + return "{VT_NULL}"; + case VT_I4: + return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v)); + case VT_R8: + return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v)); + case VT_BSTR: + return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v))); + case VT_DISPATCH: + return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v)); + case VT_BOOL: + return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v)); + default: + return wine_dbg_sprintf("{vt %d}", V_VT(v)); + } +} + /************************************************************************* * SHDOCVW DllMain */ diff --git a/reactos/dll/win32/shdocvw/webbrowser.c b/reactos/dll/win32/shdocvw/webbrowser.c index 323e9addfcb..b0633b03f19 100644 --- a/reactos/dll/win32/shdocvw/webbrowser.c +++ b/reactos/dll/win32/shdocvw/webbrowser.c @@ -269,8 +269,9 @@ static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl, { WebBrowser *This = WEBBROWSER_THIS(iface); - TRACE("(%p)->(%s %p %p %p %p)\n", This, debugstr_w(szUrl), Flags, TargetFrameName, - PostData, Headers); + TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags), + debugstr_variant(TargetFrameName), debugstr_variant(PostData), + debugstr_variant(Headers)); return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers); } @@ -285,7 +286,7 @@ static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface) static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%p)\n", This, Level); + FIXME("(%p)->(%s)\n", This, debugstr_variant(Level)); return E_NOTIMPL; } @@ -516,22 +517,28 @@ static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, i static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(szProperty)); + FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue)); return E_NOTIMPL; } static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%s %p)\n", This, debugstr_w(szProperty), pvtValue); + FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue)); return E_NOTIMPL; } static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name) { + static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b', + ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0}; WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%p)\n", This, Name); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, Name); + + *Name = SysAllocString(sName); + + return S_OK; } static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND) @@ -726,7 +733,8 @@ static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VA WebBrowser *This = WEBBROWSER_THIS(iface); LPCWSTR url; - TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers); + TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags), + debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers)); if(!This->client) return E_FAIL; @@ -761,7 +769,7 @@ static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%d %d %p %p)\n", This, cmdID, cmdexecopt, pvaIn, pvaOut); + FIXME("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut); return E_NOTIMPL; } @@ -769,7 +777,8 @@ static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pv VARIANT *pvarShow, VARIANT *pvarSize) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%p %p %p)\n", This, pvaClsid, pvarShow, pvarSize); + FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow), + debugstr_variant(pvarSize)); return E_NOTIMPL; } From 8c353150eec30131a3bff1b0175e8385f01971c8 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 19:46:01 +0000 Subject: [PATCH 035/211] [JSCRIPT] sync jscript to wine 1.1.39 svn path=/trunk/; revision=45765 --- reactos/dll/win32/jscript/activex.c | 5 +- reactos/dll/win32/jscript/array.c | 226 ++-- reactos/dll/win32/jscript/bool.c | 3 +- reactos/dll/win32/jscript/date.c | 3 +- reactos/dll/win32/jscript/dispex.c | 154 ++- reactos/dll/win32/jscript/engine.c | 102 +- reactos/dll/win32/jscript/engine.h | 34 +- reactos/dll/win32/jscript/error.c | 83 +- reactos/dll/win32/jscript/function.c | 186 ++- reactos/dll/win32/jscript/global.c | 276 ++++- reactos/dll/win32/jscript/jscript.c | 31 +- reactos/dll/win32/jscript/jscript.h | 16 +- reactos/dll/win32/jscript/jscript.inf | 44 +- reactos/dll/win32/jscript/jscript_De.rc | 1 + reactos/dll/win32/jscript/jscript_En.rc | 1 + reactos/dll/win32/jscript/jscript_Fr.rc | 1 + reactos/dll/win32/jscript/jscript_Ko.rc | 51 + reactos/dll/win32/jscript/jscript_Lt.rc | 1 + reactos/dll/win32/jscript/jscript_Ru.rc | 50 + reactos/dll/win32/jscript/jsutils.c | 18 +- reactos/dll/win32/jscript/lex.c | 31 +- reactos/dll/win32/jscript/number.c | 3 +- reactos/dll/win32/jscript/parser.tab.c | 1488 +++++++++++------------ reactos/dll/win32/jscript/parser.tab.h | 59 +- reactos/dll/win32/jscript/parser.y | 36 +- reactos/dll/win32/jscript/regexp.c | 231 ++-- reactos/dll/win32/jscript/resource.h | 1 + reactos/dll/win32/jscript/rsrc.rc | 2 + reactos/dll/win32/jscript/string.c | 77 +- 29 files changed, 1991 insertions(+), 1223 deletions(-) create mode 100644 reactos/dll/win32/jscript/jscript_Ko.rc create mode 100644 reactos/dll/win32/jscript/jscript_Ru.rc diff --git a/reactos/dll/win32/jscript/activex.c b/reactos/dll/win32/jscript/activex.c index cb94d4e5f34..947e4cfd289 100644 --- a/reactos/dll/win32/jscript/activex.c +++ b/reactos/dll/win32/jscript/activex.c @@ -86,7 +86,7 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid) if(FAILED(hres) || policy != URLPOLICY_ALLOW) return NULL; - hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, NULL, &IID_IClassFactory, (void**)&cf); + hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf); if(FAILED(hres)) return NULL; @@ -192,7 +192,8 @@ HRESULT create_activex_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ActiveXObject_value, ActiveXObjectW, NULL, PROPF_CONSTR, prototype, ret); + hres = create_builtin_function(ctx, ActiveXObject_value, ActiveXObjectW, NULL, + PROPF_CONSTR|1, prototype, ret); jsdisp_release(prototype); return hres; diff --git a/reactos/dll/win32/jscript/array.c b/reactos/dll/win32/jscript/array.c index 941e414567b..1268d59638b 100644 --- a/reactos/dll/win32/jscript/array.c +++ b/reactos/dll/win32/jscript/array.c @@ -166,7 +166,7 @@ static HRESULT concat_array(DispatchEx *array, ArrayInstance *obj, DWORD *len, HRESULT hres; for(i=0; i < obj->length; i++) { - hres = jsdisp_propget_idx(&obj->dispex, i, &var, ei, caller); + hres = jsdisp_get_idx(&obj->dispex, i, &var, ei, caller); if(hres == DISP_E_UNKNOWNNAME) continue; if(FAILED(hres)) @@ -267,8 +267,11 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co return E_OUTOFMEMORY; for(i=0; i < length; i++) { - hres = jsdisp_propget_idx(array, i, &var, ei, caller); - if(FAILED(hres)) + hres = jsdisp_get_idx(array, i, &var, ei, caller); + if(hres == DISP_E_UNKNOWNNAME) { + hres = S_OK; + continue; + } else if(FAILED(hres)) break; if(V_VT(&var) != VT_EMPTY && V_VT(&var) != VT_NULL) @@ -342,20 +345,18 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co } /* ECMA-262 3rd Edition 15.4.4.5 */ -static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, +static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + DispatchEx *jsthis; DWORD length; HRESULT hres; TRACE("\n"); - if(is_vclass(jsthis, JSCLASS_ARRAY)) { - length = array_from_vdisp(jsthis)->length; - }else { - FIXME("dispid is not Array\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(arg_cnt(dp)) { BSTR sep; @@ -364,62 +365,52 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA if(FAILED(hres)) return hres; - hres = array_join(ctx, jsthis->u.jsdisp, length, sep, retv, ei, caller); + hres = array_join(ctx, jsthis, length, sep, retv, ei, caller); SysFreeString(sep); }else { - hres = array_join(ctx, jsthis->u.jsdisp, length, default_separatorW, retv, ei, caller); + hres = array_join(ctx, jsthis, length, default_separatorW, retv, ei, caller); } return hres; } -static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, +static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + DispatchEx *jsthis; VARIANT val; DWORD length; - WCHAR buf[14]; - DISPID id; HRESULT hres; - static const WCHAR formatW[] = {'%','d',0}; - TRACE("\n"); - if(is_vclass(jsthis, JSCLASS_ARRAY)) { - ArrayInstance *array = array_from_vdisp(jsthis); - length = array->length; - }else { - FIXME("not Array this\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(!length) { + hres = set_length(jsthis, ei, 0); + if(FAILED(hres)) + return hres; + if(retv) V_VT(retv) = VT_EMPTY; return S_OK; } - sprintfW(buf, formatW, --length); - hres = jsdisp_get_id(jsthis->u.jsdisp, buf, 0, &id); + length--; + hres = jsdisp_get_idx(jsthis, length, &val, ei, caller); if(SUCCEEDED(hres)) { - hres = jsdisp_propget(jsthis->u.jsdisp, id, &val, ei, caller); - if(FAILED(hres)) - return hres; - - hres = IDispatchEx_DeleteMemberByDispID(jsthis->u.dispex, id); - }else if(hres == DISP_E_UNKNOWNNAME) { + hres = jsdisp_delete_idx(jsthis, length); + } else if(hres == DISP_E_UNKNOWNNAME) { V_VT(&val) = VT_EMPTY; hres = S_OK; - }else { + } else return hres; - } - if(SUCCEEDED(hres)) { - ArrayInstance *array = array_from_vdisp(jsthis); - array->length = length; - } + if(SUCCEEDED(hres)) + hres = set_length(jsthis, ei, length); if(FAILED(hres)) { VariantClear(&val); @@ -430,6 +421,7 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR *retv = val; else VariantClear(&val); + return S_OK; } @@ -469,8 +461,59 @@ static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + DispatchEx *jsthis; + DWORD length, k, l; + VARIANT v1, v2; + HRESULT hres1, hres2; + + TRACE("\n"); + + hres1 = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres1)) + return hres1; + + for(k=0; klength; - }else { - FIXME("unsupported this not array\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(arg_cnt(dp) > 1) { WARN("invalid arg_cnt %d\n", arg_cnt(dp)); @@ -707,8 +749,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA jsdisp_release(cmp_func); if(retv) { V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = jsthis->u.disp; - IDispatch_AddRef(jsthis->u.disp); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(jsthis); + IDispatch_AddRef(V_DISPATCH(retv)); } return S_OK; } @@ -716,8 +758,11 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA vtab = heap_alloc_zero(length * sizeof(VARIANT)); if(vtab) { for(i=0; iu.jsdisp, i, vtab+i, ei, caller); - if(FAILED(hres) && hres != DISP_E_UNKNOWNNAME) { + hres = jsdisp_get_idx(jsthis, i, vtab+i, ei, caller); + if(hres == DISP_E_UNKNOWNNAME) { + V_VT(vtab+i) = VT_EMPTY; + hres = S_OK; + } else if(FAILED(hres)) { WARN("Could not get elem %d: %08x\n", i, hres); break; } @@ -793,7 +838,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA } for(i=0; SUCCEEDED(hres) && i < length; i++) - hres = jsdisp_propput_idx(jsthis->u.jsdisp, i, sorttab[i], ei, caller); + hres = jsdisp_propput_idx(jsthis, i, sorttab[i], ei, caller); } if(vtab) { @@ -810,8 +855,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA if(retv) { V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = jsthis->u.disp; - IDispatch_AddRef(jsthis->u.disp); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(jsthis); + IDispatch_AddRef(V_DISPATCH(retv)); } return S_OK; @@ -869,7 +914,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP return hres; for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) { - hres = jsdisp_propget_idx(jsthis, start+i, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, start+i, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = S_OK; else if(SUCCEEDED(hres)) @@ -886,7 +931,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP if(add_args < delete_cnt) { for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) { - hres = jsdisp_propget_idx(jsthis, i+delete_cnt, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, i+delete_cnt, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = jsdisp_delete_idx(jsthis, i+add_args); else if(SUCCEEDED(hres)) @@ -897,7 +942,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP hres = jsdisp_delete_idx(jsthis, i-1); }else if(add_args > delete_cnt) { for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) { - hres = jsdisp_propget_idx(jsthis, i+delete_cnt-1, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = jsdisp_delete_idx(jsthis, i+add_args-1); else if(SUCCEEDED(hres)) @@ -967,29 +1012,25 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP return hres; argc = arg_cnt(dp); - if(!argc) { - if(retv) - V_VT(retv) = VT_EMPTY; - return S_OK; - } + if(argc) { + buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; + *buf_end-- = 0; + i = length; - buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; - *buf_end-- = 0; - i = length; + while(i--) { + str = idx_to_str(i, buf_end); - while(i--) { - str = idx_to_str(i, buf_end); + hres = jsdisp_get_id(jsthis, str, 0, &id); + if(SUCCEEDED(hres)) { + hres = jsdisp_propget(jsthis, id, &var, ei, caller); + if(FAILED(hres)) + return hres; - hres = jsdisp_get_id(jsthis, str, 0, &id); - if(SUCCEEDED(hres)) { - hres = jsdisp_propget(jsthis, id, &var, ei, caller); - if(FAILED(hres)) - return hres; - - hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei, caller); - VariantClear(&var); - }else if(hres == DISP_E_UNKNOWNNAME) { - hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id); + hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei, caller); + VariantClear(&var); + }else if(hres == DISP_E_UNKNOWNNAME) { + hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id); + } } if(FAILED(hres)) @@ -1002,12 +1043,21 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP return hres; } - hres = set_length(jsthis, ei, length+argc); - if(FAILED(hres)) - return hres; + if(argc) { + length += argc; + hres = set_length(jsthis, ei, length); + if(FAILED(hres)) + return hres; + } - if(retv) - V_VT(retv) = VT_EMPTY; + if(retv) { + if(ctx->version < 2) { + V_VT(retv) = VT_EMPTY; + }else { + V_VT(retv) = VT_I4; + V_I4(retv) = length; + } + } return S_OK; } @@ -1166,7 +1216,7 @@ HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Dis if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ArrayConstr_value, ArrayW, NULL, PROPF_CONSTR, &array->dispex, ret); + hres = create_builtin_function(ctx, ArrayConstr_value, ArrayW, NULL, PROPF_CONSTR|1, &array->dispex, ret); jsdisp_release(&array->dispex); return hres; diff --git a/reactos/dll/win32/jscript/bool.c b/reactos/dll/win32/jscript/bool.c index 1fca406c184..4f23678a2e3 100644 --- a/reactos/dll/win32/jscript/bool.c +++ b/reactos/dll/win32/jscript/bool.c @@ -191,7 +191,8 @@ HRESULT create_bool_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Disp if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, BoolConstr_value, BooleanW, NULL, PROPF_CONSTR, &bool->dispex, ret); + hres = create_builtin_function(ctx, BoolConstr_value, BooleanW, NULL, + PROPF_CONSTR|1, &bool->dispex, ret); jsdisp_release(&bool->dispex); return hres; diff --git a/reactos/dll/win32/jscript/date.c b/reactos/dll/win32/jscript/date.c index f8d3522939b..71d37519fd7 100644 --- a/reactos/dll/win32/jscript/date.c +++ b/reactos/dll/win32/jscript/date.c @@ -2624,7 +2624,8 @@ HRESULT create_date_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Disp if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, DateConstr_value, DateW, &DateConstr_info, PROPF_CONSTR, date, ret); + hres = create_builtin_function(ctx, DateConstr_value, DateW, &DateConstr_info, + PROPF_CONSTR|7, date, ret); jsdisp_release(date); return hres; diff --git a/reactos/dll/win32/jscript/dispex.c b/reactos/dll/win32/jscript/dispex.c index 307efd97a22..6894eae0515 100644 --- a/reactos/dll/win32/jscript/dispex.c +++ b/reactos/dll/win32/jscript/dispex.c @@ -30,6 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); static const IID IID_IDispatchJS = {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa6}}; +#define FDEX_VERSION_MASK 0xf0000000 + typedef enum { PROP_VARIANT, PROP_BUILTIN, @@ -158,7 +160,7 @@ static HRESULT find_prop_name(DispatchEx *This, const WCHAR *name, dispex_prop_t return S_OK; } -static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL alloc, dispex_prop_t **ret) +static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, dispex_prop_t **ret) { dispex_prop_t *prop; HRESULT hres; @@ -172,7 +174,7 @@ static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL all } if(This->prototype) { - hres = find_prop_name_prot(This->prototype, name, FALSE, &prop); + hres = find_prop_name_prot(This->prototype, name, &prop); if(FAILED(hres)) return hres; if(prop) { @@ -184,17 +186,30 @@ static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL all } } - if(alloc) { + *ret = prop; + return S_OK; +} + +static HRESULT ensure_prop_name(DispatchEx *This, const WCHAR *name, BOOL search_prot, DWORD create_flags, dispex_prop_t **ret) +{ + dispex_prop_t *prop; + HRESULT hres; + + if(search_prot) + hres = find_prop_name_prot(This, name, &prop); + else + hres = find_prop_name(This, name, &prop); + if(SUCCEEDED(hres) && !prop) { TRACE("creating prop %s\n", debugstr_w(name)); - prop = alloc_prop(This, name, PROP_VARIANT, PROPF_ENUM); + prop = alloc_prop(This, name, PROP_VARIANT, create_flags); if(!prop) return E_OUTOFMEMORY; VariantInit(&prop->u.var); } *ret = prop; - return S_OK; + return hres; } static HRESULT set_this(DISPPARAMS *dp, DISPPARAMS *olddp, IDispatch *jsthis) @@ -338,19 +353,19 @@ static HRESULT prop_get(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, return hres; } -static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, +static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DWORD i; HRESULT hres; switch(prop->type) { case PROP_BUILTIN: if(!(prop->flags & PROPF_METHOD)) { + DISPPARAMS dp = {val, NULL, 1, 0}; vdisp_t vthis; set_jsdisp(&vthis, This); - hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, dp, NULL, ei, caller); + hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, &dp, NULL, ei, caller); vdisp_release(&vthis); return hres; } @@ -367,24 +382,14 @@ static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, return E_FAIL; } - for(i=0; i < dp->cNamedArgs; i++) { - if(dp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT) - break; - } - - if(i == dp->cNamedArgs) { - TRACE("no value to set\n"); - return DISP_E_PARAMNOTOPTIONAL; - } - - hres = VariantCopy(&prop->u.var, dp->rgvarg+i); + hres = VariantCopy(&prop->u.var, val); if(FAILED(hres)) return hres; if(This->builtin_info->on_put) This->builtin_info->on_put(This, prop->name); - TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_variant(dp->rgvarg+i)); + TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_variant(val)); return S_OK; } @@ -471,6 +476,8 @@ static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface) } heap_free(This->props); script_release(This->ctx); + if(This->prototype) + jsdisp_release(This->prototype); if(This->builtin_info->destructor) This->builtin_info->destructor(This); @@ -538,7 +545,7 @@ static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DW TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid); - if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit)) { + if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit|FDEX_VERSION_MASK)) { FIXME("Unsupported grfdex %x\n", grfdex); return E_NOTIMPL; } @@ -575,9 +582,22 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc case DISPATCH_PROPERTYGET: hres = prop_get(This, prop, pdp, pvarRes, &jsexcept, pspCaller); break; - case DISPATCH_PROPERTYPUT: - hres = prop_put(This, prop, pdp, &jsexcept, pspCaller); + case DISPATCH_PROPERTYPUT: { + DWORD i; + + for(i=0; i < pdp->cNamedArgs; i++) { + if(pdp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT) + break; + } + + if(i == pdp->cNamedArgs) { + TRACE("no value to set\n"); + return DISP_E_PARAMNOTOPTIONAL; + } + + hres = prop_put(This, prop, pdp->rgvarg+i, &jsexcept, pspCaller); break; + } default: FIXME("Unimplemented flags %x\n", wFlags); return E_INVALIDARG; @@ -606,7 +626,7 @@ static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bst TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex); - if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit)) + if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit|FDEX_VERSION_MASK)) FIXME("Unsupported grfdex %x\n", grfdex); hres = find_prop_name(This, bstrName, &prop); @@ -783,9 +803,10 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui dispex_prop_t *prop; HRESULT hres; + static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r'}; static const WCHAR prototypeW[] = {'p','r','o','t','o','t','y','p','e',0}; - hres = find_prop_name_prot(constr, prototypeW, FALSE, &prop); + hres = find_prop_name_prot(constr, prototypeW, &prop); if(SUCCEEDED(hres) && prop) { jsexcept_t jsexcept; VARIANT var; @@ -807,6 +828,22 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui if(prot) jsdisp_release(prot); + if(FAILED(hres)) + return hres; + + hres = ensure_prop_name(dispex, constructorW, FALSE, 0, &prop); + if(SUCCEEDED(hres)) { + jsexcept_t jsexcept; + VARIANT var; + + V_VT(&var) = VT_DISPATCH; + V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(constr); + memset(&jsexcept, 0, sizeof(jsexcept)); + hres = prop_put(dispex, prop, &var, &jsexcept, NULL/*FIXME*/); + } + if(FAILED(hres)) + jsdisp_release(dispex); + return hres; } @@ -827,7 +864,10 @@ HRESULT jsdisp_get_id(DispatchEx *jsdisp, const WCHAR *name, DWORD flags, DISPID dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(jsdisp, name, (flags&fdexNameEnsure) != 0, &prop); + if(flags & fdexNameEnsure) + hres = ensure_prop_name(jsdisp, name, TRUE, PROPF_ENUM, &prop); + else + hres = find_prop_name_prot(jsdisp, name, &prop); if(FAILED(hres)) return hres; @@ -874,7 +914,7 @@ HRESULT jsdisp_call_name(DispatchEx *disp, const WCHAR *name, WORD flags, DISPPA dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(disp, name, TRUE, &prop); + hres = find_prop_name_prot(disp, name, &prop); if(FAILED(hres)) return hres; @@ -924,16 +964,14 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, DIS HRESULT jsdisp_propput_name(DispatchEx *obj, const WCHAR *name, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DISPID named_arg = DISPID_PROPERTYPUT; - DISPPARAMS dp = {val, &named_arg, 1, 1}; dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(obj, name, TRUE, &prop); + hres = ensure_prop_name(obj, name, FALSE, PROPF_ENUM, &prop); if(FAILED(hres)) return hres; - return prop_put(obj, prop, &dp, ei, caller); + return prop_put(obj, prop, val, ei, caller); } HRESULT jsdisp_propput_idx(DispatchEx *obj, DWORD idx, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) @@ -948,9 +986,6 @@ HRESULT jsdisp_propput_idx(DispatchEx *obj, DWORD idx, VARIANT *val, jsexcept_t HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DISPID dispid = DISPID_PROPERTYPUT; - DISPPARAMS dp = {val, &dispid, 1, 1}; - IDispatchEx *dispex; DispatchEx *jsdisp; HRESULT hres; @@ -960,25 +995,28 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val prop = get_prop(jsdisp, id); if(prop) - hres = prop_put(jsdisp, prop, &dp, ei, caller); + hres = prop_put(jsdisp, prop, val, ei, caller); else hres = DISP_E_MEMBERNOTFOUND; jsdisp_release(jsdisp); - return hres; + }else { + DISPID dispid = DISPID_PROPERTYPUT; + DISPPARAMS dp = {val, &dispid, 1, 1}; + IDispatchEx *dispex; + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(SUCCEEDED(hres)) { + hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, caller); + IDispatchEx_Release(dispex); + }else { + ULONG err = 0; + + TRACE("using IDispatch\n"); + hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, &err); + } } - hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); - if(FAILED(hres)) { - ULONG err = 0; - - TRACE("using IDispatch\n"); - return IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, &err); - } - - hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, caller); - - IDispatchEx_Release(dispex); return hres; } @@ -988,7 +1026,7 @@ HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, VARIANT *var, js dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(obj, name, FALSE, &prop); + hres = find_prop_name_prot(obj, name, &prop); if(FAILED(hres)) return hres; @@ -999,14 +1037,26 @@ HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, VARIANT *var, js return prop_get(obj, prop, &dp, var, ei, caller); } -HRESULT jsdisp_propget_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) +HRESULT jsdisp_get_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) { - WCHAR buf[12]; + WCHAR name[12]; + DISPPARAMS dp = {NULL, NULL, 0, 0}; + dispex_prop_t *prop; + HRESULT hres; static const WCHAR formatW[] = {'%','d',0}; - sprintfW(buf, formatW, idx); - return jsdisp_propget_name(obj, buf, var, ei, caller); + sprintfW(name, formatW, idx); + + hres = find_prop_name_prot(obj, name, &prop); + if(FAILED(hres)) + return hres; + + V_VT(var) = VT_EMPTY; + if(!prop) + return DISP_E_UNKNOWNNAME; + + return prop_get(obj, prop, &dp, var, ei, caller); } HRESULT jsdisp_propget(DispatchEx *jsdisp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) diff --git a/reactos/dll/win32/jscript/engine.c b/reactos/dll/win32/jscript/engine.c index cecfd62b606..b40a88eb591 100644 --- a/reactos/dll/win32/jscript/engine.c +++ b/reactos/dll/win32/jscript/engine.c @@ -223,7 +223,7 @@ void exec_release(exec_ctx_t *ctx) heap_free(ctx); } -static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id) +static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, BSTR name, DWORD flags, DISPID *id) { IDispatchEx *dispex; HRESULT hres; @@ -237,7 +237,7 @@ static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id) } *id = 0; - hres = IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id); + hres = IDispatchEx_GetDispID(dispex, name, make_grfdex(ctx, flags|fdexNameCaseSensitive), id); IDispatchEx_Release(dispex); return hres; } @@ -347,33 +347,45 @@ static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret) return S_OK; } -static HRESULT literal_to_var(literal_t *literal, VARIANT *v) +static HRESULT literal_to_var(script_ctx_t *ctx, literal_t *literal, VARIANT *v) { - V_VT(v) = literal->vt; - - switch(V_VT(v)) { - case VT_EMPTY: - case VT_NULL: + switch(literal->type) { + case LT_NULL: + V_VT(v) = VT_NULL; break; - case VT_I4: + case LT_INT: + V_VT(v) = VT_I4; V_I4(v) = literal->u.lval; break; - case VT_R8: + case LT_DOUBLE: + V_VT(v) = VT_R8; V_R8(v) = literal->u.dval; break; - case VT_BSTR: - V_BSTR(v) = SysAllocString(literal->u.wstr); + case LT_STRING: { + BSTR str = SysAllocString(literal->u.wstr); + if(!str) + return E_OUTOFMEMORY; + + V_VT(v) = VT_BSTR; + V_BSTR(v) = str; break; - case VT_BOOL: + } + case LT_BOOL: + V_VT(v) = VT_BOOL; V_BOOL(v) = literal->u.bval; break; - case VT_DISPATCH: - IDispatch_AddRef(literal->u.disp); - V_DISPATCH(v) = literal->u.disp; - break; - default: - ERR("wrong type %d\n", V_VT(v)); - return E_NOTIMPL; + case LT_REGEXP: { + DispatchEx *regexp; + HRESULT hres; + + hres = create_regexp(ctx, literal->u.regexp.str, literal->u.regexp.str_len, + literal->u.regexp.flags, ®exp); + if(FAILED(hres)) + return hres; + + V_VT(v) = VT_DISPATCH; + V_DISPATCH(v) = (IDispatch*)_IDispatchEx_(regexp); + } } return S_OK; @@ -387,7 +399,7 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t for(item = ctx->named_items; item; item = item->next) { if(item->flags & SCRIPTITEM_GLOBALMEMBERS) { - hres = disp_get_id(item->disp, identifier, 0, &id); + hres = disp_get_id(ctx, item->disp, identifier, 0, &id); if(SUCCEEDED(hres)) { if(ret) exprval_set_idref(ret, item->disp, id); @@ -399,7 +411,8 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t return FALSE; } -HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv) +HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, exec_type_t exec_type, + jsexcept_t *ei, VARIANT *retv) { script_ctx_t *script = parser->script; function_declaration_t *func; @@ -478,10 +491,14 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so return hres; } - if(retv) + if(retv && (exec_type == EXECT_EVAL || rt.type == RT_RETURN)) *retv = val; - else + else { + if (retv) { + VariantInit(retv); + } VariantClear(&val); + } return S_OK; } @@ -1380,7 +1397,7 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, TRACE("\n"); - hres = expr_eval(ctx, expr->member_expr, EXPR_NEWREF, ei, &exprval); + hres = expr_eval(ctx, expr->member_expr, 0, ei, &exprval); if(FAILED(hres)) return hres; @@ -1395,11 +1412,15 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, exprval_release(&exprval); } - if(SUCCEEDED(hres)) + if(SUCCEEDED(hres)) { hres = to_object(ctx->parser->script, &member, &obj); + if(FAILED(hres)) + VariantClear(&val); + } VariantClear(&member); if(SUCCEEDED(hres)) { hres = to_string(ctx->parser->script, &val, ei, &str); + VariantClear(&val); if(SUCCEEDED(hres)) { if(flags & EXPR_STRREF) { ret->type = EXPRVAL_NAMEREF; @@ -1408,7 +1429,8 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return S_OK; } - hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + hres = disp_get_id(ctx->parser->script, obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + SysFreeString(str); } if(SUCCEEDED(hres)) { @@ -1459,7 +1481,7 @@ HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags return S_OK; } - hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + hres = disp_get_id(ctx->parser->script, obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); SysFreeString(str); if(SUCCEEDED(hres)) { exprval_set_idref(ret, obj, id); @@ -1552,6 +1574,7 @@ HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, j hres = disp_call(ctx->parser->script, V_DISPATCH(&constr), DISPID_VALUE, DISPATCH_CONSTRUCT, &dp, &var, ei, NULL/*FIXME*/); IDispatch_Release(V_DISPATCH(&constr)); + free_dp(&dp); if(FAILED(hres)) return hres; @@ -1654,7 +1677,7 @@ HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flag TRACE("\n"); - hres = literal_to_var(expr->literal, &var); + hres = literal_to_var(ctx->parser->script, expr->literal, &var); if(FAILED(hres)) return hres; @@ -1733,7 +1756,7 @@ HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWO return hres; for(iter = expr->property_list; iter; iter = iter->next) { - hres = literal_to_var(iter->name, &tmp); + hres = literal_to_var(ctx->parser->script, iter->name, &tmp); if(FAILED(hres)) break; @@ -2053,7 +2076,7 @@ static HRESULT in_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *obj, jsexcept_t if(FAILED(hres)) return hres; - hres = disp_get_id(V_DISPATCH(obj), str, 0, &id); + hres = disp_get_id(ctx->parser->script, V_DISPATCH(obj), str, 0, &id); SysFreeString(str); if(SUCCEEDED(hres)) ret = VARIANT_TRUE; @@ -2293,7 +2316,8 @@ HRESULT delete_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex); if(SUCCEEDED(hres)) { - hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, fdexNameCaseSensitive); + hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, + make_grfdex(ctx->parser->script, fdexNameCaseSensitive)); b = VARIANT_TRUE; IDispatchEx_Release(dispex); } @@ -2472,6 +2496,7 @@ HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return hres; hres = to_number(ctx->parser->script, &val, ei, &num); + VariantClear(&val); if(FAILED(hres)) return hres; @@ -2731,6 +2756,8 @@ HRESULT equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return hres; hres = equal_values(ctx, &rval, &lval, ei, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2752,6 +2779,8 @@ HRESULT equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags return hres; hres = equal2_values(&rval, &lval, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2773,6 +2802,8 @@ HRESULT not_equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD fl return hres; hres = equal_values(ctx, &lval, &rval, ei, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2794,6 +2825,8 @@ HRESULT not_equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD f return hres; hres = equal2_values(&lval, &rval, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -3096,8 +3129,11 @@ HRESULT assign_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags exprval_release(&exprvalr); } - if(SUCCEEDED(hres)) + if(SUCCEEDED(hres)) { hres = put_value(ctx->parser->script, &exprval, &rval, ei); + if(FAILED(hres)) + VariantClear(&rval); + } exprval_release(&exprval); if(FAILED(hres)) diff --git a/reactos/dll/win32/jscript/engine.h b/reactos/dll/win32/jscript/engine.h index 386f38b51fd..0bcabf614d2 100644 --- a/reactos/dll/win32/jscript/engine.h +++ b/reactos/dll/win32/jscript/engine.h @@ -19,11 +19,6 @@ typedef struct _source_elements_t source_elements_t; typedef struct _function_expression_t function_expression_t; -typedef struct _obj_literal_t { - DispatchEx *obj; - struct _obj_literal_t *next; -} obj_literal_t; - typedef struct _function_declaration_t { function_expression_t *expr; @@ -48,9 +43,9 @@ typedef struct _func_stack { typedef struct _parser_ctx_t { LONG ref; - const WCHAR *ptr; - const WCHAR *begin; + WCHAR *begin; const WCHAR *end; + const WCHAR *ptr; script_ctx_t *script; source_elements_t *source; @@ -61,7 +56,6 @@ typedef struct _parser_ctx_t { jsheap_t heap; - obj_literal_t *obj_literals; func_stack_t *func_stack; struct _parser_ctx_t *next; @@ -115,9 +109,15 @@ static inline void exec_addref(exec_ctx_t *ctx) ctx->ref++; } +typedef enum { + EXECT_PROGRAM, + EXECT_FUNCTION, + EXECT_EVAL +} exec_type_t; + void exec_release(exec_ctx_t*); HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,DispatchEx*,scope_chain_t*,exec_ctx_t**); -HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,jsexcept_t*,VARIANT*); +HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,exec_type_t,jsexcept_t*,VARIANT*); typedef struct _statement_t statement_t; typedef struct _expression_t expression_t; @@ -126,14 +126,28 @@ typedef struct _parameter_t parameter_t; HRESULT create_source_function(parser_ctx_t*,parameter_t*,source_elements_t*,scope_chain_t*, const WCHAR*,DWORD,DispatchEx**); +typedef enum { + LT_INT, + LT_DOUBLE, + LT_STRING, + LT_BOOL, + LT_NULL, + LT_REGEXP +}literal_type_t; + typedef struct { - VARTYPE vt; + literal_type_t type; union { LONG lval; double dval; const WCHAR *wstr; VARIANT_BOOL bval; IDispatch *disp; + struct { + const WCHAR *str; + DWORD str_len; + DWORD flags; + } regexp; } u; } literal_t; diff --git a/reactos/dll/win32/jscript/error.c b/reactos/dll/win32/jscript/error.c index 9530a4ce52a..e3cfce634ee 100644 --- a/reactos/dll/win32/jscript/error.c +++ b/reactos/dll/win32/jscript/error.c @@ -36,6 +36,7 @@ typedef struct { static const WCHAR descriptionW[] = {'d','e','s','c','r','i','p','t','i','o','n',0}; static const WCHAR messageW[] = {'m','e','s','s','a','g','e',0}; +static const WCHAR nameW[] = {'n','a','m','e',0}; static const WCHAR numberW[] = {'n','u','m','b','e','r',0}; static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}; @@ -44,6 +45,11 @@ static inline ErrorInstance *error_from_vdisp(vdisp_t *vdisp) return (ErrorInstance*)vdisp->u.jsdisp; } +static inline ErrorInstance *error_this(vdisp_t *jsthis) +{ + return is_vclass(jsthis, JSCLASS_ERROR) ? error_from_vdisp(jsthis) : NULL; +} + static HRESULT Error_number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { @@ -101,17 +107,77 @@ static HRESULT Error_message(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, /* ECMA-262 3rd Edition 15.11.4.4 */ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, - DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) + DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + ErrorInstance *error; + BSTR name, msg = NULL, ret = NULL; + VARIANT v; + HRESULT hres; + static const WCHAR str[] = {'[','o','b','j','e','c','t',' ','E','r','r','o','r',']',0}; TRACE("\n"); + error = error_this(jsthis); + if(ctx->version < 2 || !error) { + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = SysAllocString(str); + if(!V_BSTR(retv)) + return E_OUTOFMEMORY; + } + return S_OK; + } + + hres = jsdisp_propget_name(&error->dispex, nameW, &v, ei, caller); + if(FAILED(hres)) + return hres; + + hres = to_string(ctx, &v, ei, &name); + VariantClear(&v); + if(FAILED(hres)) + return hres; + + if(V_VT(&error->message) != VT_EMPTY) { + hres = to_string(ctx, &error->message, ei, &msg); + if(SUCCEEDED(hres) && !*msg) { + SysFreeString(msg); + msg = NULL; + } + } + + if(SUCCEEDED(hres)) { + if(msg) { + DWORD name_len, msg_len; + + name_len = SysStringLen(name); + msg_len = SysStringLen(msg); + + ret = SysAllocStringLen(NULL, name_len + msg_len + 2); + if(ret) { + memcpy(ret, name, name_len*sizeof(WCHAR)); + ret[name_len] = ':'; + ret[name_len+1] = ' '; + memcpy(ret+name_len+2, msg, msg_len*sizeof(WCHAR)); + } + }else { + ret = name; + name = NULL; + } + } + + SysFreeString(msg); + SysFreeString(name); + if(FAILED(hres)) + return hres; + if(!ret) + return E_OUTOFMEMORY; + if(retv) { V_VT(retv) = VT_BSTR; - V_BSTR(retv) = SysAllocString(str); - if(!V_BSTR(retv)) - return E_OUTOFMEMORY; + V_BSTR(retv) = ret; + }else { + SysFreeString(ret); } return S_OK; @@ -264,6 +330,7 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, DISPPARAMS *dp, hres = create_error(ctx, constr, NULL, msg, &err); else hres = create_error(ctx, constr, &num, msg, &err); + SysFreeString(msg); if(FAILED(hres)) return hres; @@ -341,7 +408,6 @@ static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla HRESULT init_error_constr(script_ctx_t *ctx, DispatchEx *object_prototype) { - static const WCHAR nameW[] = {'n','a','m','e',0}; static const WCHAR ErrorW[] = {'E','r','r','o','r',0}; static const WCHAR EvalErrorW[] = {'E','v','a','l','E','r','r','o','r',0}; static const WCHAR RangeErrorW[] = {'R','a','n','g','e','E','r','r','o','r',0}; @@ -381,7 +447,7 @@ HRESULT init_error_constr(script_ctx_t *ctx, DispatchEx *object_prototype) if(SUCCEEDED(hres)) hres = create_builtin_function(ctx, constr_val[i], names[i], NULL, - PROPF_CONSTR, &err->dispex, constr_addr[i]); + PROPF_CONSTR|1, &err->dispex, constr_addr[i]); jsdisp_release(&err->dispex); VariantClear(&v); @@ -424,11 +490,6 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCH return id; } -HRESULT throw_eval_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR *str) -{ - return throw_error(ctx, ei, id, str, ctx->eval_error_constr); -} - HRESULT throw_generic_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR *str) { return throw_error(ctx, ei, id, str, ctx->error_constr); diff --git a/reactos/dll/win32/jscript/function.c b/reactos/dll/win32/jscript/function.c index b0fb79d711d..c7494cfce6c 100644 --- a/reactos/dll/win32/jscript/function.c +++ b/reactos/dll/win32/jscript/function.c @@ -213,10 +213,11 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis hres = create_exec_ctx(ctx, this_obj, var_disp, scope, &exec_ctx); scope_release(scope); } + jsdisp_release(var_disp); if(FAILED(hres)) return hres; - hres = exec_source(exec_ctx, function->parser, function->source, ei, retv); + hres = exec_source(exec_ctx, function->parser, function->source, EXECT_FUNCTION, ei, retv); exec_release(exec_ctx); return hres; @@ -226,20 +227,27 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { DispatchEx *this_obj; + VARIANT var; HRESULT hres; hres = create_object(ctx, &function->dispex, &this_obj); if(FAILED(hres)) return hres; - hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, retv, ei, caller); + hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, &var, ei, caller); if(FAILED(hres)) { jsdisp_release(this_obj); return hres; } V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj); + if(V_VT(&var) == VT_DISPATCH) { + jsdisp_release(this_obj); + V_DISPATCH(retv) = V_DISPATCH(&var); + }else { + VariantClear(&var); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj); + } return S_OK; } @@ -366,8 +374,10 @@ static HRESULT array_to_args(script_ctx_t *ctx, DispatchEx *arg_array, jsexcept_ return E_OUTOFMEMORY; for(i=0; i= 2) { @@ -406,8 +420,8 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI if(V_VT(get_arg(dp,1)) == VT_DISPATCH) { arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(get_arg(dp,1))); - if(arg_array && ( - !is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) { + if(arg_array && + (!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) { jsdisp_release(arg_array); arg_array = NULL; } @@ -448,9 +462,14 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS argc = arg_cnt(dp); if(argc) { - hres = to_object(ctx, get_arg(dp,0), &this_obj); - if(FAILED(hres)) - return hres; + VARIANT *v = get_arg(dp,0); + + if(V_VT(v) != VT_EMPTY && V_VT(v) != VT_NULL) { + hres = to_object(ctx, v, &this_obj); + if(FAILED(hres)) + return hres; + } + args.cArgs = argc-1; } @@ -539,20 +558,6 @@ static const builtin_info_t Function_info = { NULL }; -static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, - VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) -{ - FIXME("\n"); - return E_NOTIMPL; -} - -static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, - VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) -{ - FIXME("\n"); - return E_NOTIMPL; -} - static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, DWORD flags, BOOL funcprot, DispatchEx *prototype, FunctionInstance **ret) { @@ -659,6 +664,131 @@ HRESULT create_source_function(parser_ctx_t *ctx, parameter_t *parameters, sourc return S_OK; } +static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t *ei, IDispatch **ret) +{ + function_expression_t *expr; + WCHAR *str = NULL, *ptr; + DWORD argc, len = 0, l; + parser_ctx_t *parser; + DispatchEx *function; + BSTR *params = NULL; + int i=0, j=0; + HRESULT hres = S_OK; + + static const WCHAR function_anonymousW[] = {'f','u','n','c','t','i','o','n',' ','a','n','o','n','y','m','o','u','s','('}; + static const WCHAR function_beginW[] = {')',' ','{','\n'}; + static const WCHAR function_endW[] = {'\n','}',0}; + + argc = arg_cnt(dp); + if(argc) { + params = heap_alloc(argc*sizeof(BSTR)); + if(!params) + return E_OUTOFMEMORY; + + if(argc > 2) + len = (argc-2)*2; /* separating commas */ + for(i=0; i < argc; i++) { + hres = to_string(ctx, get_arg(dp,i), ei, params+i); + if(FAILED(hres)) + break; + len += SysStringLen(params[i]); + } + } + + if(SUCCEEDED(hres)) { + len += (sizeof(function_anonymousW) + sizeof(function_beginW) + sizeof(function_endW)) / sizeof(WCHAR); + str = heap_alloc(len*sizeof(WCHAR)); + if(str) { + memcpy(str, function_anonymousW, sizeof(function_anonymousW)); + ptr = str + sizeof(function_anonymousW)/sizeof(WCHAR); + if(argc > 1) { + while(1) { + l = SysStringLen(params[j]); + memcpy(ptr, params[j], l*sizeof(WCHAR)); + ptr += l; + if(++j == argc-1) + break; + *ptr++ = ','; + *ptr++ = ' '; + } + } + memcpy(ptr, function_beginW, sizeof(function_beginW)); + ptr += sizeof(function_beginW)/sizeof(WCHAR); + if(argc) { + l = SysStringLen(params[argc-1]); + memcpy(ptr, params[argc-1], l*sizeof(WCHAR)); + ptr += l; + } + memcpy(ptr, function_endW, sizeof(function_endW)); + + TRACE("%s\n", debugstr_w(str)); + }else { + hres = E_OUTOFMEMORY; + } + } + + while(--i >= 0) + SysFreeString(params[i]); + heap_free(params); + if(FAILED(hres)) + return hres; + + hres = script_parse(ctx, str, NULL, &parser); + heap_free(str); + if(FAILED(hres)) + return hres; + + if(!parser->source || !parser->source->functions || parser->source->functions->next || parser->source->variables) { + ERR("Invalid parser result!\n"); + parser_release(parser); + return E_UNEXPECTED; + } + expr = parser->source->functions->expr; + + hres = create_source_function(parser, expr->parameter_list, expr->source_elements, NULL, expr->src_str, + expr->src_len, &function); + parser_release(parser); + if(FAILED(hres)) + return hres; + + *ret = (IDispatch*)_IDispatchEx_(function); + return S_OK; +} + +static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) +{ + HRESULT hres; + + TRACE("\n"); + + switch(flags) { + case DISPATCH_CONSTRUCT: { + IDispatch *ret; + + hres = construct_function(ctx, dp, ei, &ret); + if(FAILED(hres)) + return hres; + + V_VT(retv) = VT_DISPATCH; + V_DISPATCH(retv) = ret; + break; + } + default: + FIXME("unimplemented flags %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; +} + +static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) +{ + FIXME("\n"); + return E_NOTIMPL; +} + HRESULT init_function_constr(script_ctx_t *ctx, DispatchEx *object_prototype) { FunctionInstance *prot, *constr; @@ -673,7 +803,7 @@ HRESULT init_function_constr(script_ctx_t *ctx, DispatchEx *object_prototype) prot->value_proc = FunctionProt_value; prot->name = prototypeW; - hres = create_function(ctx, NULL, PROPF_CONSTR, TRUE, &prot->dispex, &constr); + hres = create_function(ctx, NULL, PROPF_CONSTR|1, TRUE, &prot->dispex, &constr); if(SUCCEEDED(hres)) { constr->value_proc = FunctionConstr_value; constr->name = FunctionW; diff --git a/reactos/dll/win32/jscript/global.c b/reactos/dll/win32/jscript/global.c index ef86f2663d4..af142ed4db3 100644 --- a/reactos/dll/win32/jscript/global.c +++ b/reactos/dll/win32/jscript/global.c @@ -334,8 +334,10 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D } ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } len = 0; for(ptr=str; *ptr; ptr++) { @@ -357,6 +359,8 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D } } + SysFreeString(str); + if(retv) { V_VT(retv) = VT_BSTR; V_BSTR(retv) = ret; @@ -404,7 +408,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS return throw_syntax_error(ctx, ei, hres, NULL); } - hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, ei, retv); + hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, EXECT_EVAL, ei, retv); parser_release(parser_ctx); return hres; @@ -690,8 +694,10 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } len = 0; for(ptr=str; *ptr; ptr++) { @@ -715,6 +721,8 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, len++; } + SysFreeString(str); + if(retv) { V_VT(retv) = VT_BSTR; V_BSTR(retv) = ret; @@ -802,8 +810,8 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags }else { i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3; if(!i) { - FIXME("throw URIError\n"); - return E_FAIL; + SysFreeString(str); + return throw_uri_error(ctx, ei, IDS_URI_INVALID_CHAR, NULL); } len += i; @@ -811,8 +819,10 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } rptr = ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } for(ptr = str; *ptr; ptr++) { if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') { @@ -827,6 +837,8 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } } + SysFreeString(str); + TRACE("%s -> %s\n", debugstr_w(str), debugstr_w(ret)); if(retv) { V_VT(retv) = VT_BSTR; @@ -847,56 +859,239 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + BSTR str, ret; + char buf[4]; + const WCHAR *ptr; + DWORD len = 0, size, i; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) { + ret = SysAllocString(undefinedW); + if(!ret) + return E_OUTOFMEMORY; + + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } + + return S_OK; + } + + hres = to_string(ctx, get_arg(dp, 0), ei, &str); + if(FAILED(hres)) + return hres; + + for(ptr=str; *ptr; ptr++) { + if(is_uri_unescaped(*ptr)) + len++; + else { + size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL); + if(!size) { + SysFreeString(str); + FIXME("throw Error\n"); + return E_FAIL; + } + len += size*3; + } + } + + ret = SysAllocStringLen(NULL, len); + if(!ret) { + SysFreeString(str); + return E_OUTOFMEMORY; + } + + len = 0; + for(ptr=str; *ptr; ptr++) { + if(is_uri_unescaped(*ptr)) + ret[len++] = *ptr; + else { + size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL); + for(i=0; i> 4); + ret[len++] = int_to_char(buf[i] & 0x0f); + } + } + } + + SysFreeString(str); + + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } else { + SysFreeString(ret); + } + + return S_OK; } +/* ECMA-262 3rd Edition 15.1.3.2 */ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + BSTR str, ret; + const WCHAR *ptr; + WCHAR *out_ptr; + DWORD len = 0; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) { + ret = SysAllocString(undefinedW); + if(!ret) + return E_OUTOFMEMORY; + + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } + + return S_OK; + } + + hres = to_string(ctx, get_arg(dp, 0), ei, &str); + if(FAILED(hres)) + return hres; + + ptr = str; + while(*ptr) { + if(*ptr == '%') { + char octets[4]; + unsigned char mask = 0x80; + int i, size, num_bytes = 0; + if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) { + FIXME("Throw URIError: Invalid hex sequence\n"); + SysFreeString(str); + return E_FAIL; + } + octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + while(octets[0] & mask) { + mask = mask >> 1; + ++num_bytes; + } + if(num_bytes == 1 || num_bytes > 4) { + FIXME("Throw URIError: Invalid initial UTF character\n"); + SysFreeString(str); + return E_FAIL; + } + for(i = 1; i < num_bytes; ++i) { + if(*ptr != '%'){ + FIXME("Throw URIError: Incomplete UTF sequence\n"); + SysFreeString(str); + return E_FAIL; + } + if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) { + FIXME("Throw URIError: Invalid hex sequence\n"); + SysFreeString(str); + return E_FAIL; + } + octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + } + size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, octets, + num_bytes ? num_bytes : 1, NULL, 0); + if(size == 0) { + FIXME("Throw URIError: Invalid UTF sequence\n"); + SysFreeString(str); + return E_FAIL; + } + len += size; + }else { + ++ptr; + ++len; + } + } + + out_ptr = ret = SysAllocStringLen(NULL, len); + if(!ret) { + SysFreeString(str); + return E_OUTOFMEMORY; + } + + ptr = str; + while(*ptr) { + if(*ptr == '%') { + char octets[4]; + unsigned char mask = 0x80; + int i, size, num_bytes = 0; + octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + while(octets[0] & mask) { + mask = mask >> 1; + ++num_bytes; + } + for(i = 1; i < num_bytes; ++i) { + octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + } + size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, octets, + num_bytes ? num_bytes : 1, out_ptr, len); + len -= size; + out_ptr += size; + }else { + *out_ptr++ = *ptr++; + --len; + } + } + + SysFreeString(str); + + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + }else { + SysFreeString(ret); + } + + return S_OK; } static const builtin_prop_t JSGlobal_props[] = { - {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_CONSTR}, - {ArrayW, JSGlobal_Array, PROPF_CONSTR}, - {BooleanW, JSGlobal_Boolean, PROPF_CONSTR}, + {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_CONSTR|1}, + {ArrayW, JSGlobal_Array, PROPF_CONSTR|1}, + {BooleanW, JSGlobal_Boolean, PROPF_CONSTR|1}, {CollectGarbageW, JSGlobal_CollectGarbage, PROPF_METHOD}, - {DateW, JSGlobal_Date, PROPF_CONSTR}, - {EnumeratorW, JSGlobal_Enumerator, PROPF_METHOD}, - {ErrorW, JSGlobal_Error, PROPF_CONSTR}, - {EvalErrorW, JSGlobal_EvalError, PROPF_CONSTR}, - {FunctionW, JSGlobal_Function, PROPF_CONSTR}, - {_GetObjectW, JSGlobal_GetObject, PROPF_METHOD}, + {DateW, JSGlobal_Date, PROPF_CONSTR|7}, + {EnumeratorW, JSGlobal_Enumerator, PROPF_METHOD|7}, + {ErrorW, JSGlobal_Error, PROPF_CONSTR|1}, + {EvalErrorW, JSGlobal_EvalError, PROPF_CONSTR|1}, + {FunctionW, JSGlobal_Function, PROPF_CONSTR|1}, + {_GetObjectW, JSGlobal_GetObject, PROPF_METHOD|2}, {InfinityW, JSGlobal_Infinity, 0}, /* {MathW, JSGlobal_Math, 0}, */ {NaNW, JSGlobal_NaN, 0}, - {NumberW, JSGlobal_Number, PROPF_CONSTR}, - {ObjectW, JSGlobal_Object, PROPF_CONSTR}, - {RangeErrorW, JSGlobal_RangeError, PROPF_CONSTR}, - {ReferenceErrorW, JSGlobal_ReferenceError, PROPF_CONSTR}, - {RegExpW, JSGlobal_RegExp, PROPF_CONSTR}, + {NumberW, JSGlobal_Number, PROPF_CONSTR|1}, + {ObjectW, JSGlobal_Object, PROPF_CONSTR|1}, + {RangeErrorW, JSGlobal_RangeError, PROPF_CONSTR|1}, + {ReferenceErrorW, JSGlobal_ReferenceError, PROPF_CONSTR|1}, + {RegExpW, JSGlobal_RegExp, PROPF_CONSTR|2}, {ScriptEngineW, JSGlobal_ScriptEngine, PROPF_METHOD}, {ScriptEngineBuildVersionW, JSGlobal_ScriptEngineBuildVersion, PROPF_METHOD}, {ScriptEngineMajorVersionW, JSGlobal_ScriptEngineMajorVersion, PROPF_METHOD}, {ScriptEngineMinorVersionW, JSGlobal_ScriptEngineMinorVersion, PROPF_METHOD}, - {StringW, JSGlobal_String, PROPF_CONSTR}, - {SyntaxErrorW, JSGlobal_SyntaxError, PROPF_CONSTR}, - {TypeErrorW, JSGlobal_TypeError, PROPF_CONSTR}, - {URIErrorW, JSGlobal_URIError, PROPF_CONSTR}, - {VBArrayW, JSGlobal_VBArray, PROPF_METHOD}, - {decodeURIW, JSGlobal_decodeURI, PROPF_METHOD}, - {decodeURIComponentW, JSGlobal_decodeURIComponent, PROPF_METHOD}, - {encodeURIW, JSGlobal_encodeURI, PROPF_METHOD}, - {encodeURIComponentW, JSGlobal_encodeURIComponent, PROPF_METHOD}, - {escapeW, JSGlobal_escape, PROPF_METHOD}, + {StringW, JSGlobal_String, PROPF_CONSTR|1}, + {SyntaxErrorW, JSGlobal_SyntaxError, PROPF_CONSTR|1}, + {TypeErrorW, JSGlobal_TypeError, PROPF_CONSTR|1}, + {URIErrorW, JSGlobal_URIError, PROPF_CONSTR|1}, + {VBArrayW, JSGlobal_VBArray, PROPF_METHOD|1}, + {decodeURIW, JSGlobal_decodeURI, PROPF_METHOD|1}, + {decodeURIComponentW, JSGlobal_decodeURIComponent, PROPF_METHOD|1}, + {encodeURIW, JSGlobal_encodeURI, PROPF_METHOD|1}, + {encodeURIComponentW, JSGlobal_encodeURIComponent, PROPF_METHOD|1}, + {escapeW, JSGlobal_escape, PROPF_METHOD|1}, {evalW, JSGlobal_eval, PROPF_METHOD|1}, - {isFiniteW, JSGlobal_isFinite, PROPF_METHOD}, - {isNaNW, JSGlobal_isNaN, PROPF_METHOD}, - {parseFloatW, JSGlobal_parseFloat, PROPF_METHOD}, + {isFiniteW, JSGlobal_isFinite, PROPF_METHOD|1}, + {isNaNW, JSGlobal_isNaN, PROPF_METHOD|1}, + {parseFloatW, JSGlobal_parseFloat, PROPF_METHOD|1}, {parseIntW, JSGlobal_parseInt, PROPF_METHOD|2}, - {unescapeW, JSGlobal_unescape, PROPF_METHOD} + {unescapeW, JSGlobal_unescape, PROPF_METHOD|1} }; static const builtin_info_t JSGlobal_info = { @@ -981,6 +1176,11 @@ HRESULT init_global(script_ctx_t *ctx) if(FAILED(hres)) return hres; + V_VT(&var) = VT_EMPTY; + hres = jsdisp_propput_name(ctx->global, undefinedW, &var, NULL/*FIXME*/, NULL/*FIXME*/); + if(FAILED(hres)) + return hres; + V_VT(&var) = VT_DISPATCH; V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(math); hres = jsdisp_propput_name(ctx->global, MathW, &var, NULL/*FIXME*/, NULL/*FIXME*/); diff --git a/reactos/dll/win32/jscript/jscript.c b/reactos/dll/win32/jscript/jscript.c index eb4183526be..9a516aa5d71 100644 --- a/reactos/dll/win32/jscript/jscript.c +++ b/reactos/dll/win32/jscript/jscript.c @@ -51,6 +51,7 @@ typedef struct { script_ctx_t *ctx; LONG thread_id; LCID lcid; + DWORD version; IActiveScriptSite *site; @@ -93,7 +94,6 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) { exec_ctx_t *exec_ctx; jsexcept_t jsexcept; - VARIANT var; HRESULT hres; hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, &exec_ctx); @@ -103,14 +103,11 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) IActiveScriptSite_OnEnterScript(This->site); memset(&jsexcept, 0, sizeof(jsexcept)); - hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, &jsexcept, &var); + hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, EXECT_PROGRAM, &jsexcept, NULL); VariantClear(&jsexcept.var); exec_release(exec_ctx); - if(SUCCEEDED(hres)) - VariantClear(&var); IActiveScriptSite_OnLeaveScript(This->site); - return hres; } @@ -659,6 +656,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface) ctx->ref = 1; ctx->state = SCRIPTSTATE_UNINITIALIZED; ctx->safeopt = This->safeopt; + ctx->version = This->version; jsheap_init(&ctx->tmp_heap); ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL); @@ -822,8 +820,27 @@ static HRESULT WINAPI JScriptProperty_SetProperty(IActiveScriptProperty *iface, VARIANT *pvarIndex, VARIANT *pvarValue) { JScript *This = ACTSCPPROP_THIS(iface); - FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue); - return E_NOTIMPL; + + TRACE("(%p)->(%x %s %s)\n", This, dwProperty, debugstr_variant(pvarIndex), debugstr_variant(pvarValue)); + + if(pvarIndex) + FIXME("unsupported pvarIndex\n"); + + switch(dwProperty) { + case SCRIPTPROP_INVOKEVERSIONING: + if(V_VT(pvarValue) != VT_I4 || V_I4(pvarValue) < 0 || V_I4(pvarValue) > 15) { + WARN("invalid value %s\n", debugstr_variant(pvarValue)); + return E_INVALIDARG; + } + + This->version = V_I4(pvarValue); + break; + default: + FIXME("Unimplemented property %x\n", dwProperty); + return E_NOTIMPL; + } + + return S_OK; } #undef ACTSCPPROP_THIS diff --git a/reactos/dll/win32/jscript/jscript.h b/reactos/dll/win32/jscript/jscript.h index cde1e1bf67c..00688273de8 100644 --- a/reactos/dll/win32/jscript/jscript.h +++ b/reactos/dll/win32/jscript/jscript.h @@ -205,7 +205,7 @@ HRESULT jsdisp_propget(DispatchEx*,DISPID,VARIANT*,jsexcept_t*,IServiceProvider* HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propput_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propget_name(DispatchEx*,LPCWSTR,VARIANT*,jsexcept_t*,IServiceProvider*); -HRESULT jsdisp_propget_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); +HRESULT jsdisp_get_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_get_id(DispatchEx*,const WCHAR*,DWORD,DISPID*); HRESULT jsdisp_delete_idx(DispatchEx*,DWORD); @@ -225,7 +225,8 @@ HRESULT throw_uri_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*); HRESULT create_object(script_ctx_t*,DispatchEx*,DispatchEx**); HRESULT create_math(script_ctx_t*,DispatchEx**); HRESULT create_array(script_ctx_t*,DWORD,DispatchEx**); -HRESULT create_regexp_str(script_ctx_t*,const WCHAR*,DWORD,const WCHAR*,DWORD,DispatchEx**); +HRESULT create_regexp(script_ctx_t*,const WCHAR *,int,DWORD,DispatchEx**); +HRESULT create_regexp_var(script_ctx_t*,VARIANT*,VARIANT*,DispatchEx**); HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,DispatchEx**); HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,DispatchEx**); HRESULT create_number(script_ctx_t*,VARIANT*,DispatchEx**); @@ -262,6 +263,7 @@ struct _script_ctx_t { IActiveScriptSite *site; IInternetHostSecurityManager *secmgr; DWORD safeopt; + DWORD version; LCID lcid; jsheap_t tmp_heap; @@ -316,9 +318,12 @@ typedef struct { DWORD len; } match_result_t; -HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,BOOL,const WCHAR*,DWORD,const WCHAR**,match_result_t**, +#define REM_CHECK_GLOBAL 0x0001 +#define REM_RESET_INDEX 0x0002 +HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,DWORD,const WCHAR*,DWORD,const WCHAR**,match_result_t**, DWORD*,DWORD*,match_result_t*); HRESULT regexp_match(script_ctx_t*,DispatchEx*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*); +HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*); static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i) { @@ -390,6 +395,11 @@ static inline void num_set_inf(VARIANT *v, BOOL positive) #endif } +static inline DWORD make_grfdex(script_ctx_t *ctx, DWORD flags) +{ + return (ctx->version << 28) | flags; +} + const char *debugstr_variant(const VARIANT*); HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**); diff --git a/reactos/dll/win32/jscript/jscript.inf b/reactos/dll/win32/jscript/jscript.inf index bdec721c040..9f683ed78e1 100644 --- a/reactos/dll/win32/jscript/jscript.inf +++ b/reactos/dll/win32/jscript/jscript.inf @@ -12,27 +12,27 @@ DelReg=Classes.Reg [Classes.Reg] HKCR,"CLSID\%CLSID_JScript%",,,"JScript Language" -HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScript%",,, -HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScriptParse%",,, +HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScript%",,16 +HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScriptParse%",,16 HKCR,"CLSID\%CLSID_JScript%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScript%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScript%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScript%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScript%\ProgID",,,"JScript" HKCR,"CLSID\%CLSID_JScriptAuthor%",,,"JScript Language Authoring" -HKCR,"CLSID\%CLSID_JScriptAuthor%\Implemented Categories\%CATID_ActiveScriptAuthor%",,, +HKCR,"CLSID\%CLSID_JScriptAuthor%\Implemented Categories\%CATID_ActiveScriptAuthor%",,16 HKCR,"CLSID\%CLSID_JScriptAuthor%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScriptAuthor%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScriptAuthor%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScriptAuthor%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScriptAuthor%\ProgID",,,"JScript Author" HKCR,"CLSID\%CLSID_JScriptEncode%",,,"JScript Language Encoding" -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScript%",,, -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptParse%",,, -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptEncode%",,, +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScript%",,16 +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptParse%",,16 +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptEncode%",,16 HKCR,"CLSID\%CLSID_JScriptEncode%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScriptEncode%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScriptEncode%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScriptEncode%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScriptEncode%\ProgID",,,"JScript.Encode" HKCR,"Component Categories\%CATID_ActiveScriptAuthor%","409",,"Active Scripting Engine with Authoring" @@ -42,55 +42,55 @@ HKCR,"Component Categories\%CATID_ActiveScriptEncode%","409",,"Active Scripting HKCR,"ECMAScript",,,"JScript Language" HKCR,"ECMAScript\CLSID",,,"%CLSID_JScript%" -HKCR,"ECMAScript\OLEScript",,, +HKCR,"ECMAScript\OLEScript",,16 HKCR,"JavaScript",,,"JScript Language" HKCR,"JavaScript\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript\OLEScript",,, +HKCR,"JavaScript\OLEScript",,16 HKCR,"JavaScript Author",,,"JScript Language Authoring" HKCR,"JavaScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript Author\OLEScript",,, +HKCR,"JavaScript Author\OLEScript",,16 HKCR,"JavaScript1.1",,,"JScript Language" HKCR,"JavaScript1.1\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.1\OLEScript",,, +HKCR,"JavaScript1.1\OLEScript",,16 HKCR,"JavaScript1.1 Author",,,"JScript Language Authoring" HKCR,"JavaScript1.1 Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript1.1 Author\OLEScript",,, +HKCR,"JavaScript1.1 Author\OLEScript",,16 HKCR,"JavaScript1.2",,,"JScript Language" HKCR,"JavaScript1.2\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.2\OLEScript",,, +HKCR,"JavaScript1.2\OLEScript",,16 HKCR,"JavaScript1.2 Author",,,"JScript Language Authoring" HKCR,"JavaScript1.2 Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript1.2 Author\OLEScript",,, +HKCR,"JavaScript1.2 Author\OLEScript",,16 HKCR,"JavaScript1.3",,,"JScript Language" HKCR,"JavaScript1.3\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.3\OLEScript",,, +HKCR,"JavaScript1.3\OLEScript",,16 HKCR,"JScript",,,"JScript Language" HKCR,"JScript\CLSID",,,"%CLSID_JScript%" -HKCR,"JScript\OLEScript",,, +HKCR,"JScript\OLEScript",,16 HKCR,"JScript Author",,,"JScript Language Authoring" HKCR,"JScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JScript Author\OLEScript",,, +HKCR,"JScript Author\OLEScript",,16 HKCR,"JScript.Encode",,,"JScript Language Encoding" HKCR,"JScript.Encode\CLSID",,,"%CLSID_JScriptEncode%" -HKCR,"JScript.Encode\OLEScript",,, +HKCR,"JScript.Encode\OLEScript",,16 HKCR,"LiveScript",,,"JScript Language" HKCR,"LiveScript\CLSID",,,"%CLSID_JScript%" -HKCR,"LiveScript\OLEScript",,, +HKCR,"LiveScript\OLEScript",,16 HKCR,"LiveScript Author",,,"JScript Language Authoring" HKCR,"LiveScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"LiveScript Author\OLEScript",,, +HKCR,"LiveScript Author\OLEScript",,16 [Strings] diff --git a/reactos/dll/win32/jscript/jscript_De.rc b/reactos/dll/win32/jscript/jscript_De.rc index 02b52f38dbf..7e4e9a13050 100644 --- a/reactos/dll/win32/jscript/jscript_De.rc +++ b/reactos/dll/win32/jscript/jscript_De.rc @@ -43,6 +43,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Boolisches Objekt erwartet" IDS_JSCRIPT_EXPECTED "JScript Objekt erwartet" IDS_REGEXP_SYNTAX_ERROR "Syntax Fehler in regulärem Ausdruck" + IDS_URI_INVALID_CHAR "Zu verschlüsselnde URI enthält ungültige Zeichen" IDS_INVALID_LENGTH "Array-Größe muss eine endliche, positive Ganzzahl sein" IDS_ARRAY_EXPECTED "Array Objekt erwartet" } diff --git a/reactos/dll/win32/jscript/jscript_En.rc b/reactos/dll/win32/jscript/jscript_En.rc index 14be9bddbde..bd3c09d2a5d 100644 --- a/reactos/dll/win32/jscript/jscript_En.rc +++ b/reactos/dll/win32/jscript/jscript_En.rc @@ -41,6 +41,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Boolean object expected" IDS_JSCRIPT_EXPECTED "JScript object expected" IDS_REGEXP_SYNTAX_ERROR "Syntax error in regular expression" + IDS_URI_INVALID_CHAR "URI to be encoded contains invalid characters" IDS_INVALID_LENGTH "Array length must be a finite positive integer" IDS_ARRAY_EXPECTED "Array object expected" } diff --git a/reactos/dll/win32/jscript/jscript_Fr.rc b/reactos/dll/win32/jscript/jscript_Fr.rc index 8c23e412c40..f70029db13f 100644 --- a/reactos/dll/win32/jscript/jscript_Fr.rc +++ b/reactos/dll/win32/jscript/jscript_Fr.rc @@ -46,6 +46,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Objet booléen attendu" IDS_JSCRIPT_EXPECTED "Objet JScript attendu" IDS_REGEXP_SYNTAX_ERROR "Erreur de syntaxe dans l'expression rationnelle" + IDS_URI_INVALID_CHAR "L'URI à coder contient des caractères invalides" IDS_INVALID_LENGTH "La longueur d'un tableau doit être un entier positif" IDS_ARRAY_EXPECTED "Objet tableau attendu" } diff --git a/reactos/dll/win32/jscript/jscript_Ko.rc b/reactos/dll/win32/jscript/jscript_Ko.rc new file mode 100644 index 00000000000..164d6beb128 --- /dev/null +++ b/reactos/dll/win32/jscript/jscript_Ko.rc @@ -0,0 +1,51 @@ +/* + * Copyright 2009 Piotr Caban + * Copyright 2010 YunSong Hwang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_TO_PRIMITIVE "ê°íŽ˜ë¥¼ 기본 형ì‹ìœ¼ë¡œ 변환하는 ì¤‘ì— ì—러 ë°œìƒ" + IDS_INVALID_CALL_ARG "올바르지 ì•Šì€ í”„ë¡œì‹œì ¸ 호출ì´ë‚˜ ì¸ìˆ˜" + IDS_CREATE_OBJ_ERROR "ìžë™í™” 서버가 ê°ì²´ë¥¼ 만들 수 없습니다" + IDS_NO_PROPERTY "ê°ì²´ëŠ” ì´ ì†ì„±ì´ë‚˜ 메소드를 ì§€ì›í•˜ì§€ 않습니다" + IDS_ARG_NOT_OPT "ì¸ìˆ˜ëŠ” ì˜µì…˜ì´ ì•„ë‹™ë‹ˆë‹¤" + IDS_SYNTAX_ERROR "문법 ì—러" + IDS_SEMICOLON "';' ê°€ 필요합니다" + IDS_LBRACKET "'(' ê°€ 필요합니다" + IDS_RBRACKET "')' ê°€ 필요합니다" + IDS_UNTERMINATED_STR "ë나지 ì•Šì€ ë¬¸ìžì—´ ìƒìˆ˜" + IDS_NOT_FUNC "함수가 필요합니다" + IDS_NOT_DATE "'[ê°ì²´]' 는 ë‚ ì§œ ê°ì²´ê°€ 아닙니다" + IDS_NOT_NUM "숫ìžê°€ 필요합니다" + IDS_OBJECT_EXPECTED "ê°ì²´ê°€ 필요합니다" + IDS_ILLEGAL_ASSIGN "ìž˜ëª»ëœ í• ë‹¹" + IDS_UNDEFINED "'|' 는 ì •ì˜ë˜ì§€ 않았습니다" + IDS_NOT_BOOL "볼린 ê°ì œê°€ 필요합니다" + IDS_JSCRIPT_EXPECTED "JScript ê°ì²´ê°€ 필요합니다" + IDS_REGEXP_SYNTAX_ERROR "ì •ê·œ 표현ì‹ì— 문법ì—러가 있습니다" + IDS_URI_INVALID_CHAR "URI 는 올바르지 ì•Šì€ ë¬¸ìžë¥¼ í¬í•¨í•´ì„œ ì¸ì½”딩ë˜ì—ˆìŠµë‹ˆë‹¤" + IDS_INVALID_LENGTH "ë°°ì—´ 길ì´ëŠ” 반드시 í•œì •ëœ ì–‘ì˜ ì •ìˆ˜ì´ì–´ì•¼ 합니다" + IDS_ARRAY_EXPECTED "ë°°ì—´ ê°ì²´ê°€ 필요합니다" +} diff --git a/reactos/dll/win32/jscript/jscript_Lt.rc b/reactos/dll/win32/jscript/jscript_Lt.rc index 4d3989574fd..a7b451eb8c9 100644 --- a/reactos/dll/win32/jscript/jscript_Lt.rc +++ b/reactos/dll/win32/jscript/jscript_Lt.rc @@ -44,6 +44,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "TikÄ—tasi loginio objekto" IDS_JSCRIPT_EXPECTED "TikÄ—tasi JScript objekto" IDS_REGEXP_SYNTAX_ERROR "SintaksÄ—s klaida reguliariajame reiÅ¡kinyje" + IDS_URI_INVALID_CHAR "Koduotiname URI yra netinkamų simbolių" IDS_INVALID_LENGTH "Masyvo dydis turi bÅ«ti teigiamas sveikasis skaiÄius" IDS_ARRAY_EXPECTED "TikÄ—tasi masyvo objekto" } diff --git a/reactos/dll/win32/jscript/jscript_Ru.rc b/reactos/dll/win32/jscript/jscript_Ru.rc new file mode 100644 index 00000000000..9632d3f3693 --- /dev/null +++ b/reactos/dll/win32/jscript/jscript_Ru.rc @@ -0,0 +1,50 @@ +/* + * Copyright 2009 Vladimir Pankratov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_TO_PRIMITIVE "Ошибка ÐºÐ¾Ð½Ð²ÐµÑ€Ñ‚Ð¸Ñ€Ð¾Ð²Ð°Ð½Ð¸Ñ Ð¾Ð±ÑŠÐµÐºÑ‚Ð° в примитивный тип" + IDS_INVALID_CALL_ARG "Ðеверный вызов процедуры или аргумент" + IDS_CREATE_OBJ_ERROR "Сервер автоматизации не может Ñоздать объект" + IDS_NO_PROPERTY "Объект не поддерживает Ñто ÑвойÑтво или метод" + IDS_ARG_NOT_OPT "ОтÑутÑтвует обÑзательный аргумент" + IDS_SYNTAX_ERROR "СинтакÑичеÑÐºÐ°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ°" + IDS_SEMICOLON "ОжидаетÑÑ ';'" + IDS_LBRACKET "ОжидаетÑÑ '('" + IDS_RBRACKET "ОжидаетÑÑ ')'" + IDS_UNTERMINATED_STR "ÐÐµÐ·Ð°Ð²ÐµÑ€ÑˆÑ‘Ð½Ð½Ð°Ñ ÑÑ‚Ñ€Ð¾ÐºÐ¾Ð²Ð°Ñ ÐºÐ¾Ð½Ñтанта" + IDS_NOT_FUNC "ОжидаетÑÑ Ñ„ÑƒÐ½ÐºÑ†Ð¸Ñ" + IDS_NOT_DATE "'[object]' не объект типа 'date'" + IDS_NOT_NUM "ОжидаетÑÑ Ñ‡Ð¸Ñло" + IDS_OBJECT_EXPECTED "ОжидаетÑÑ Ð¾Ð±ÑŠÐµÐºÑ‚" + IDS_ILLEGAL_ASSIGN "Ðеверное приÑваивание" + IDS_UNDEFINED "'|' не определён" + IDS_NOT_BOOL "ОжидаетÑÑ Ð¾Ð±ÑŠÐµÐºÑ‚ типа 'bool'" + IDS_JSCRIPT_EXPECTED "ОжидаетÑÑ Ð¾Ð±ÑŠÐµÐºÑ‚ типа 'JScript'" + IDS_REGEXP_SYNTAX_ERROR "СинтакÑичеÑÐºÐ°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ° в регулÑрном выражении" + IDS_URI_INVALID_CHAR "URI Ñодержит неверные Ñимволы" + IDS_INVALID_LENGTH "Длиной маÑÑива должно быть конечное положительное чиÑло" + IDS_ARRAY_EXPECTED "ОжидаетÑÑ Ð¾Ð±ÑŠÐµÐºÑ‚ типа 'Array'" +} diff --git a/reactos/dll/win32/jscript/jsutils.c b/reactos/dll/win32/jscript/jsutils.c index 80cce597481..9e49cc7b8a3 100644 --- a/reactos/dll/win32/jscript/jsutils.c +++ b/reactos/dll/win32/jscript/jsutils.c @@ -449,10 +449,14 @@ HRESULT to_integer(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret) if(FAILED(hres)) return hres; - if(V_VT(&num) == VT_I4) + if(V_VT(&num) == VT_I4) { *ret = num; - else + }else if(isnan(V_R8(&num))) { + V_VT(ret) = VT_I4; + V_I4(ret) = 0; + }else { num_set_val(ret, V_R8(&num) >= 0.0 ? floor(V_R8(&num)) : -floor(-V_R8(&num))); + } return S_OK; } @@ -467,7 +471,10 @@ HRESULT to_int32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, INT *ret) if(FAILED(hres)) return hres; - *ret = V_VT(&num) == VT_I4 ? V_I4(&num) : (INT)V_R8(&num); + if(V_VT(&num) == VT_I4) + *ret = V_I4(&num); + else + *ret = isnan(V_R8(&num)) || isinf(V_R8(&num)) ? 0 : (INT)V_R8(&num); return S_OK; } @@ -481,7 +488,10 @@ HRESULT to_uint32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, DWORD *ret) if(FAILED(hres)) return hres; - *ret = V_VT(&num) == VT_I4 ? V_I4(&num) : (DWORD)V_R8(&num); + if(V_VT(&num) == VT_I4) + *ret = V_I4(&num); + else + *ret = isnan(V_R8(&num)) || isinf(V_R8(&num)) ? 0 : (DWORD)V_R8(&num); return S_OK; } diff --git a/reactos/dll/win32/jscript/lex.c b/reactos/dll/win32/jscript/lex.c index 43089d3e210..2e79db9878a 100644 --- a/reactos/dll/win32/jscript/lex.c +++ b/reactos/dll/win32/jscript/lex.c @@ -91,7 +91,6 @@ static const struct { {trueW, kTRUE}, {tryW, kTRY}, {typeofW, kTYPEOF}, - {undefinedW, kUNDEFINED}, {varW, kVAR}, {voidW, kVOID}, {whileW, kWHILE}, @@ -369,7 +368,7 @@ static literal_t *alloc_int_literal(parser_ctx_t *ctx, LONG l) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_I4; + ret->type = LT_INT; ret->u.lval = l; return ret; @@ -447,7 +446,7 @@ static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **li } *literal = parser_alloc(ctx, sizeof(literal_t)); - (*literal)->vt = VT_R8; + (*literal)->type = LT_DOUBLE; (*literal)->u.dval = (double)d*pow(10, exp); return tNumericLiteral; @@ -755,21 +754,11 @@ int parser_lex(void *lval, parser_ctx_t *ctx) return 0; } -static void add_object_literal(parser_ctx_t *ctx, DispatchEx *obj) -{ - obj_literal_t *literal = parser_alloc(ctx, sizeof(obj_literal_t)); - - literal->obj = obj; - literal->next = ctx->obj_literals; - ctx->obj_literals = literal; -} - literal_t *parse_regexp(parser_ctx_t *ctx) { - const WCHAR *re, *flags; - DispatchEx *regexp; + const WCHAR *re, *flags_ptr; + DWORD re_len, flags; literal_t *ret; - DWORD re_len; HRESULT hres; TRACE("\n"); @@ -790,18 +779,18 @@ literal_t *parse_regexp(parser_ctx_t *ctx) re_len = ctx->ptr-re; - flags = ++ctx->ptr; + flags_ptr = ++ctx->ptr; while(ctx->ptr < ctx->end && isalnumW(*ctx->ptr)) ctx->ptr++; - hres = create_regexp_str(ctx->script, re, re_len, flags, ctx->ptr-flags, ®exp); + hres = parse_regexp_flags(flags_ptr, ctx->ptr-flags_ptr, &flags); if(FAILED(hres)) return NULL; - add_object_literal(ctx, regexp); - ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_DISPATCH; - ret->u.disp = (IDispatch*)_IDispatchEx_(regexp); + ret->type = LT_REGEXP; + ret->u.regexp.str = re; + ret->u.regexp.str_len = re_len; + ret->u.regexp.flags = flags; return ret; } diff --git a/reactos/dll/win32/jscript/number.c b/reactos/dll/win32/jscript/number.c index 757316cee86..00de9abba85 100644 --- a/reactos/dll/win32/jscript/number.c +++ b/reactos/dll/win32/jscript/number.c @@ -346,7 +346,8 @@ HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di return hres; V_VT(&number->num) = VT_I4; - hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL, PROPF_CONSTR, &number->dispex, ret); + hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL, + PROPF_CONSTR|1, &number->dispex, ret); jsdisp_release(&number->dispex); return hres; diff --git a/reactos/dll/win32/jscript/parser.tab.c b/reactos/dll/win32/jscript/parser.tab.c index 3262aa07a8d..e3307bdbec6 100644 --- a/reactos/dll/win32/jscript/parser.tab.c +++ b/reactos/dll/win32/jscript/parser.tab.c @@ -99,7 +99,6 @@ typedef struct _statement_list_t { static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*); static literal_t *new_null_literal(parser_ctx_t*); -static literal_t *new_undefined_literal(parser_ctx_t*); static literal_t *new_boolean_literal(parser_ctx_t*,VARIANT_BOOL); typedef struct _property_list_t { @@ -207,7 +206,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state /* Line 189 of yacc.c */ -#line 211 "parser.tab.c" +#line 210 "parser.tab.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -249,34 +248,33 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state kINSTANCEOF = 270, kNEW = 271, kNULL = 272, - kUNDEFINED = 273, - kRETURN = 274, - kSWITCH = 275, - kTHIS = 276, - kTHROW = 277, - kTRUE = 278, - kFALSE = 279, - kTRY = 280, - kTYPEOF = 281, - kVAR = 282, - kVOID = 283, - kWHILE = 284, - kWITH = 285, - tANDAND = 286, - tOROR = 287, - tINC = 288, - tDEC = 289, - tHTMLCOMMENT = 290, - kDIVEQ = 291, - kFUNCTION = 292, - tIdentifier = 293, - tAssignOper = 294, - tEqOper = 295, - tShiftOper = 296, - tRelOper = 297, - tNumericLiteral = 298, - tStringLiteral = 299, - LOWER_THAN_ELSE = 300 + kRETURN = 273, + kSWITCH = 274, + kTHIS = 275, + kTHROW = 276, + kTRUE = 277, + kFALSE = 278, + kTRY = 279, + kTYPEOF = 280, + kVAR = 281, + kVOID = 282, + kWHILE = 283, + kWITH = 284, + tANDAND = 285, + tOROR = 286, + tINC = 287, + tDEC = 288, + tHTMLCOMMENT = 289, + kDIVEQ = 290, + kFUNCTION = 291, + tIdentifier = 292, + tAssignOper = 293, + tEqOper = 294, + tShiftOper = 295, + tRelOper = 296, + tNumericLiteral = 297, + tStringLiteral = 298, + LOWER_THAN_ELSE = 299 }; #endif @@ -287,7 +285,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 151 "parser.y" +#line 150 "parser.y" int ival; const WCHAR *srcptr; @@ -311,7 +309,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 315 "parser.tab.c" +#line 313 "parser.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -323,7 +321,7 @@ typedef union YYSTYPE /* Line 264 of yacc.c */ -#line 327 "parser.tab.c" +#line 325 "parser.tab.c" #ifdef short # undef short @@ -538,20 +536,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1042 +#define YYLAST 1030 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 68 +#define YYNTOKENS 67 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 95 /* YYNRULES -- Number of rules. */ -#define YYNRULES 215 +#define YYNRULES 214 /* YYNRULES -- Number of states. */ -#define YYNSTATES 374 +#define YYNSTATES 373 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 300 +#define YYMAXUTOK 299 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -562,16 +560,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 62, 2, 2, 2, 60, 55, 2, - 66, 67, 58, 56, 48, 57, 65, 59, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 51, 50, - 2, 49, 2, 52, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 61, 2, 2, 2, 59, 54, 2, + 65, 66, 57, 55, 47, 56, 64, 58, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 50, 49, + 2, 48, 2, 51, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 63, 2, 64, 54, 2, 2, 2, 2, 2, + 2, 62, 2, 63, 53, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 47, 53, 38, 61, 2, 2, 2, + 2, 2, 2, 46, 52, 37, 60, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -588,8 +586,7 @@ static const yytype_uint8 yytranslate[] = 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, - 46 + 35, 36, 38, 39, 40, 41, 42, 43, 44, 45 }; #if YYDEBUG @@ -618,105 +615,105 @@ static const yytype_uint16 yyprhs[] = 567, 570, 574, 578, 584, 587, 592, 594, 597, 598, 600, 603, 607, 611, 617, 619, 621, 623, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, - 648, 650, 652, 654, 656, 658 + 648, 650, 652, 654, 656 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 69, 0, -1, 71, 70, -1, 35, -1, -1, -1, - 71, 77, -1, 73, 156, 160, 76, 161, 47, 74, - 38, -1, 37, -1, 71, -1, 39, -1, 75, 48, - 39, -1, -1, 75, -1, 80, -1, 81, -1, 90, - -1, 72, -1, 91, -1, 92, -1, 93, -1, 98, - -1, 99, -1, 100, -1, 101, -1, 102, -1, 103, - -1, 109, -1, 110, -1, 77, -1, 78, 77, -1, - -1, 78, -1, 47, 78, 38, -1, 47, 38, -1, - 27, 82, 159, -1, 84, -1, 82, 48, 84, -1, - 85, -1, 83, 48, 85, -1, 39, 86, -1, 39, - 88, -1, -1, 87, -1, 49, 119, -1, -1, 89, - -1, 49, 120, -1, 50, -1, 115, 159, -1, 11, - 160, 114, 161, 77, 10, 77, -1, 11, 160, 114, - 161, 77, -1, 9, 77, 29, 160, 114, 161, 159, - -1, 29, 160, 114, 161, 77, -1, -1, -1, 13, - 160, 116, 94, 162, 113, 95, 162, 113, 161, 77, - -1, -1, -1, 13, 160, 27, 83, 96, 162, 113, - 97, 162, 113, 161, 77, -1, 13, 160, 142, 14, - 114, 161, 77, -1, 13, 160, 27, 85, 14, 114, - 161, 77, -1, 6, 156, 159, -1, 3, 156, 159, - -1, 19, 113, 159, -1, 30, 160, 115, 161, 77, - -1, 39, 51, 77, -1, 20, 160, 115, 161, 104, - -1, 47, 105, 38, -1, 47, 105, 108, 105, 38, - -1, -1, 106, -1, 107, -1, 106, 107, -1, 4, - 115, 51, 79, -1, 7, 51, 79, -1, 22, 115, - 159, -1, 25, 80, 111, -1, 25, 80, 112, -1, - 25, 80, 111, 112, -1, 5, 160, 39, 161, 80, - -1, 12, 80, -1, -1, 115, -1, 115, -1, 1, - -1, 119, -1, 115, 48, 119, -1, -1, 117, -1, - 120, -1, 117, 48, 120, -1, 40, -1, 36, -1, - 121, -1, 142, 49, 119, -1, 142, 118, 119, -1, - 122, -1, 142, 49, 120, -1, 142, 118, 120, -1, - 123, -1, 123, 52, 119, 51, 119, -1, 124, -1, - 124, 52, 120, 51, 120, -1, 125, -1, 123, 32, - 125, -1, 126, -1, 124, 32, 126, -1, 127, -1, - 125, 31, 127, -1, 128, -1, 126, 31, 128, -1, - 129, -1, 127, 53, 129, -1, 130, -1, 128, 53, - 130, -1, 131, -1, 129, 54, 131, -1, 132, -1, - 130, 54, 132, -1, 133, -1, 131, 55, 133, -1, - 134, -1, 132, 55, 134, -1, 135, -1, 133, 41, - 135, -1, 136, -1, 134, 41, 136, -1, 137, -1, - 135, 43, 137, -1, 135, 15, 137, -1, 135, 14, - 137, -1, 137, -1, 136, 43, 137, -1, 136, 15, - 137, -1, 138, -1, 137, 42, 138, -1, 139, -1, - 138, 56, 139, -1, 138, 57, 139, -1, 140, -1, - 139, 58, 140, -1, 139, 59, 140, -1, 139, 60, - 140, -1, 141, -1, 8, 140, -1, 28, 140, -1, - 26, 140, -1, 33, 140, -1, 34, 140, -1, 56, - 140, -1, 57, 140, -1, 61, 140, -1, 62, 140, - -1, 142, -1, 142, 33, -1, 142, 34, -1, 143, - -1, 145, -1, 144, -1, 16, 143, -1, 148, -1, - 72, -1, 144, 63, 115, 64, -1, 144, 65, 39, - -1, 16, 144, 146, -1, 144, 146, -1, 145, 146, - -1, 145, 63, 115, 64, -1, 145, 65, 39, -1, - 66, 67, -1, 66, 147, 67, -1, 119, -1, 147, - 48, 119, -1, 21, -1, 39, -1, 157, -1, 149, - -1, 153, -1, 66, 115, 67, -1, 63, 64, -1, - 63, 151, 64, -1, 63, 150, 64, -1, 63, 150, - 48, 152, 64, -1, 152, 119, -1, 150, 48, 152, - 119, -1, 48, -1, 151, 48, -1, -1, 151, -1, - 47, 38, -1, 47, 154, 38, -1, 155, 51, 119, - -1, 154, 48, 155, 51, 119, -1, 39, -1, 45, - -1, 44, -1, -1, 39, -1, 17, -1, 18, -1, - 158, -1, 44, -1, 45, -1, 59, -1, 36, -1, - 23, -1, 24, -1, 50, -1, 1, -1, 66, -1, - 1, -1, 67, -1, 1, -1, 50, -1, 1, -1 + 68, 0, -1, 70, 69, -1, 34, -1, -1, -1, + 70, 76, -1, 72, 155, 159, 75, 160, 46, 73, + 37, -1, 36, -1, 70, -1, 38, -1, 74, 47, + 38, -1, -1, 74, -1, 79, -1, 80, -1, 89, + -1, 71, -1, 90, -1, 91, -1, 92, -1, 97, + -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, + -1, 108, -1, 109, -1, 76, -1, 77, 76, -1, + -1, 77, -1, 46, 77, 37, -1, 46, 37, -1, + 26, 81, 158, -1, 83, -1, 81, 47, 83, -1, + 84, -1, 82, 47, 84, -1, 38, 85, -1, 38, + 87, -1, -1, 86, -1, 48, 118, -1, -1, 88, + -1, 48, 119, -1, 49, -1, 114, 158, -1, 11, + 159, 113, 160, 76, 10, 76, -1, 11, 159, 113, + 160, 76, -1, 9, 76, 28, 159, 113, 160, 158, + -1, 28, 159, 113, 160, 76, -1, -1, -1, 13, + 159, 115, 93, 161, 112, 94, 161, 112, 160, 76, + -1, -1, -1, 13, 159, 26, 82, 95, 161, 112, + 96, 161, 112, 160, 76, -1, 13, 159, 141, 14, + 113, 160, 76, -1, 13, 159, 26, 84, 14, 113, + 160, 76, -1, 6, 155, 158, -1, 3, 155, 158, + -1, 18, 112, 158, -1, 29, 159, 114, 160, 76, + -1, 38, 50, 76, -1, 19, 159, 114, 160, 103, + -1, 46, 104, 37, -1, 46, 104, 107, 104, 37, + -1, -1, 105, -1, 106, -1, 105, 106, -1, 4, + 114, 50, 78, -1, 7, 50, 78, -1, 21, 114, + 158, -1, 24, 79, 110, -1, 24, 79, 111, -1, + 24, 79, 110, 111, -1, 5, 159, 38, 160, 79, + -1, 12, 79, -1, -1, 114, -1, 114, -1, 1, + -1, 118, -1, 114, 47, 118, -1, -1, 116, -1, + 119, -1, 116, 47, 119, -1, 39, -1, 35, -1, + 120, -1, 141, 48, 118, -1, 141, 117, 118, -1, + 121, -1, 141, 48, 119, -1, 141, 117, 119, -1, + 122, -1, 122, 51, 118, 50, 118, -1, 123, -1, + 123, 51, 119, 50, 119, -1, 124, -1, 122, 31, + 124, -1, 125, -1, 123, 31, 125, -1, 126, -1, + 124, 30, 126, -1, 127, -1, 125, 30, 127, -1, + 128, -1, 126, 52, 128, -1, 129, -1, 127, 52, + 129, -1, 130, -1, 128, 53, 130, -1, 131, -1, + 129, 53, 131, -1, 132, -1, 130, 54, 132, -1, + 133, -1, 131, 54, 133, -1, 134, -1, 132, 40, + 134, -1, 135, -1, 133, 40, 135, -1, 136, -1, + 134, 42, 136, -1, 134, 15, 136, -1, 134, 14, + 136, -1, 136, -1, 135, 42, 136, -1, 135, 15, + 136, -1, 137, -1, 136, 41, 137, -1, 138, -1, + 137, 55, 138, -1, 137, 56, 138, -1, 139, -1, + 138, 57, 139, -1, 138, 58, 139, -1, 138, 59, + 139, -1, 140, -1, 8, 139, -1, 27, 139, -1, + 25, 139, -1, 32, 139, -1, 33, 139, -1, 55, + 139, -1, 56, 139, -1, 60, 139, -1, 61, 139, + -1, 141, -1, 141, 32, -1, 141, 33, -1, 142, + -1, 144, -1, 143, -1, 16, 142, -1, 147, -1, + 71, -1, 143, 62, 114, 63, -1, 143, 64, 38, + -1, 16, 143, 145, -1, 143, 145, -1, 144, 145, + -1, 144, 62, 114, 63, -1, 144, 64, 38, -1, + 65, 66, -1, 65, 146, 66, -1, 118, -1, 146, + 47, 118, -1, 20, -1, 38, -1, 156, -1, 148, + -1, 152, -1, 65, 114, 66, -1, 62, 63, -1, + 62, 150, 63, -1, 62, 149, 63, -1, 62, 149, + 47, 151, 63, -1, 151, 118, -1, 149, 47, 151, + 118, -1, 47, -1, 150, 47, -1, -1, 150, -1, + 46, 37, -1, 46, 153, 37, -1, 154, 50, 118, + -1, 153, 47, 154, 50, 118, -1, 38, -1, 44, + -1, 43, -1, -1, 38, -1, 17, -1, 157, -1, + 43, -1, 44, -1, 58, -1, 35, -1, 22, -1, + 23, -1, 49, -1, 1, -1, 65, -1, 1, -1, + 66, -1, 1, -1, 49, -1, 1, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 257, 257, 261, 262, 266, 267, 272, 276, 280, - 284, 285, 290, 291, 295, 296, 297, 298, 299, 300, - 301, 302, 303, 304, 305, 306, 307, 308, 309, 313, - 314, 319, 320, 324, 325, 329, 334, 335, 340, 342, - 347, 352, 357, 358, 362, 367, 368, 372, 377, 381, - 386, 388, 393, 395, 398, 400, 397, 404, 406, 403, - 409, 411, 416, 421, 426, 431, 436, 441, 446, 448, - 453, 454, 458, 459, 464, 469, 474, 479, 480, 481, - 486, 491, 495, 496, 499, 500, 504, 505, 510, 511, - 515, 517, 521, 522, 526, 527, 529, 534, 536, 538, - 543, 544, 549, 551, 556, 557, 562, 564, 569, 570, - 575, 577, 582, 583, 588, 590, 595, 596, 601, 603, - 608, 609, 614, 616, 621, 622, 627, 628, 633, 634, - 636, 638, 643, 644, 646, 651, 652, 657, 659, 661, - 666, 667, 669, 671, 676, 677, 679, 680, 682, 683, - 684, 685, 686, 687, 691, 693, 695, 701, 702, 706, - 707, 711, 712, 713, 715, 717, 722, 724, 726, 728, - 733, 734, 738, 739, 744, 745, 746, 747, 748, 749, - 753, 754, 755, 756, 761, 763, 768, 769, 773, 774, - 778, 779, 784, 786, 791, 792, 793, 797, 798, 802, - 803, 804, 805, 806, 807, 809, 814, 815, 818, 819, - 822, 823, 826, 827, 830, 831 + 0, 256, 256, 260, 261, 265, 266, 271, 275, 279, + 283, 284, 289, 290, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 312, + 313, 318, 319, 323, 324, 328, 333, 334, 339, 341, + 346, 351, 356, 357, 361, 366, 367, 371, 376, 380, + 385, 387, 392, 394, 397, 399, 396, 403, 405, 402, + 408, 410, 415, 420, 425, 430, 435, 440, 445, 447, + 452, 453, 457, 458, 463, 468, 473, 478, 479, 480, + 485, 490, 494, 495, 498, 499, 503, 504, 509, 510, + 514, 516, 520, 521, 525, 526, 528, 533, 535, 537, + 542, 543, 548, 550, 555, 556, 561, 563, 568, 569, + 574, 576, 581, 582, 587, 589, 594, 595, 600, 602, + 607, 608, 613, 615, 620, 621, 626, 627, 632, 633, + 635, 637, 642, 643, 645, 650, 651, 656, 658, 660, + 665, 666, 668, 670, 675, 676, 678, 679, 681, 682, + 683, 684, 685, 686, 690, 692, 694, 700, 701, 705, + 706, 710, 711, 712, 714, 716, 721, 723, 725, 727, + 732, 733, 737, 738, 743, 744, 745, 746, 747, 748, + 752, 753, 754, 755, 760, 762, 767, 768, 772, 773, + 777, 778, 783, 785, 790, 791, 792, 796, 797, 801, + 802, 803, 804, 805, 807, 812, 813, 816, 817, 820, + 821, 824, 825, 828, 829 }; #endif @@ -727,10 +724,10 @@ static const char *const yytname[] = { "$end", "error", "$undefined", "kBREAK", "kCASE", "kCATCH", "kCONTINUE", "kDEFAULT", "kDELETE", "kDO", "kELSE", "kIF", "kFINALLY", "kFOR", "kIN", - "kINSTANCEOF", "kNEW", "kNULL", "kUNDEFINED", "kRETURN", "kSWITCH", - "kTHIS", "kTHROW", "kTRUE", "kFALSE", "kTRY", "kTYPEOF", "kVAR", "kVOID", - "kWHILE", "kWITH", "tANDAND", "tOROR", "tINC", "tDEC", "tHTMLCOMMENT", - "kDIVEQ", "kFUNCTION", "'}'", "tIdentifier", "tAssignOper", "tEqOper", + "kINSTANCEOF", "kNEW", "kNULL", "kRETURN", "kSWITCH", "kTHIS", "kTHROW", + "kTRUE", "kFALSE", "kTRY", "kTYPEOF", "kVAR", "kVOID", "kWHILE", "kWITH", + "tANDAND", "tOROR", "tINC", "tDEC", "tHTMLCOMMENT", "kDIVEQ", + "kFUNCTION", "'}'", "tIdentifier", "tAssignOper", "tEqOper", "tShiftOper", "tRelOper", "tNumericLiteral", "tStringLiteral", "LOWER_THAN_ELSE", "'{'", "','", "'='", "';'", "':'", "'?'", "'|'", "'^'", "'&'", "'+'", "'-'", "'*'", "'/'", "'%'", "'~'", "'!'", "'['", @@ -775,38 +772,38 @@ static const yytype_uint16 yytoknum[] = 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 125, 293, - 294, 295, 296, 297, 298, 299, 300, 123, 44, 61, - 59, 58, 63, 124, 94, 38, 43, 45, 42, 47, - 37, 126, 33, 91, 93, 46, 40, 41 + 285, 286, 287, 288, 289, 290, 291, 125, 292, 293, + 294, 295, 296, 297, 298, 299, 123, 44, 61, 59, + 58, 63, 124, 94, 38, 43, 45, 42, 47, 37, + 126, 33, 91, 93, 46, 40, 41 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 68, 69, 70, 70, 71, 71, 72, 73, 74, - 75, 75, 76, 76, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 78, - 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, - 84, 85, 86, 86, 87, 88, 88, 89, 90, 91, - 92, 92, 93, 93, 94, 95, 93, 96, 97, 93, - 93, 93, 98, 99, 100, 101, 102, 103, 104, 104, - 105, 105, 106, 106, 107, 108, 109, 110, 110, 110, - 111, 112, 113, 113, 114, 114, 115, 115, 116, 116, - 117, 117, 118, 118, 119, 119, 119, 120, 120, 120, - 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, - 126, 126, 127, 127, 128, 128, 129, 129, 130, 130, - 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, - 135, 135, 136, 136, 136, 137, 137, 138, 138, 138, - 139, 139, 139, 139, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 141, 141, 141, 142, 142, 143, - 143, 144, 144, 144, 144, 144, 145, 145, 145, 145, - 146, 146, 147, 147, 148, 148, 148, 148, 148, 148, - 149, 149, 149, 149, 150, 150, 151, 151, 152, 152, - 153, 153, 154, 154, 155, 155, 155, 156, 156, 157, - 157, 157, 157, 157, 157, 157, 158, 158, 159, 159, - 160, 160, 161, 161, 162, 162 + 0, 67, 68, 69, 69, 70, 70, 71, 72, 73, + 74, 74, 75, 75, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 77, + 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, + 83, 84, 85, 85, 86, 87, 87, 88, 89, 90, + 91, 91, 92, 92, 93, 94, 92, 95, 96, 92, + 92, 92, 97, 98, 99, 100, 101, 102, 103, 103, + 104, 104, 105, 105, 106, 107, 108, 109, 109, 109, + 110, 111, 112, 112, 113, 113, 114, 114, 115, 115, + 116, 116, 117, 117, 118, 118, 118, 119, 119, 119, + 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, + 125, 125, 126, 126, 127, 127, 128, 128, 129, 129, + 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, + 134, 134, 135, 135, 135, 136, 136, 137, 137, 137, + 138, 138, 138, 138, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 140, 140, 140, 141, 141, 142, + 142, 143, 143, 143, 143, 143, 144, 144, 144, 144, + 145, 145, 146, 146, 147, 147, 147, 147, 147, 147, + 148, 148, 148, 148, 149, 149, 150, 150, 151, 151, + 152, 152, 153, 153, 154, 154, 154, 155, 155, 156, + 156, 156, 156, 156, 156, 157, 157, 158, 158, 159, + 159, 160, 160, 161, 161 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -833,7 +830,7 @@ static const yytype_uint8 yyr2[] = 2, 3, 3, 5, 2, 4, 1, 2, 0, 1, 2, 3, 3, 5, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -842,118 +839,118 @@ static const yytype_uint8 yyr2[] = static const yytype_uint8 yydefact[] = { 5, 0, 4, 1, 197, 197, 0, 0, 0, 0, - 0, 199, 200, 82, 0, 174, 0, 206, 207, 0, - 0, 0, 0, 0, 0, 0, 0, 3, 205, 8, - 175, 202, 203, 0, 48, 0, 0, 204, 0, 0, - 188, 0, 2, 17, 197, 6, 14, 15, 16, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 0, 86, 94, 100, 104, 108, 112, 116, 120, 124, - 128, 135, 137, 140, 144, 154, 157, 159, 158, 161, - 177, 178, 176, 201, 198, 0, 0, 175, 0, 162, - 145, 154, 0, 211, 210, 0, 88, 160, 159, 0, - 83, 0, 0, 0, 0, 147, 42, 0, 36, 146, - 0, 0, 148, 149, 0, 34, 175, 202, 203, 29, - 0, 0, 0, 150, 151, 152, 153, 186, 180, 0, - 189, 0, 0, 0, 209, 0, 208, 49, 0, 0, + 0, 199, 82, 0, 174, 0, 205, 206, 0, 0, + 0, 0, 0, 0, 0, 0, 3, 204, 8, 175, + 201, 202, 0, 48, 0, 0, 203, 0, 0, 188, + 0, 2, 17, 197, 6, 14, 15, 16, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, + 86, 94, 100, 104, 108, 112, 116, 120, 124, 128, + 135, 137, 140, 144, 154, 157, 159, 158, 161, 177, + 178, 176, 200, 198, 0, 0, 175, 0, 162, 145, + 154, 0, 210, 209, 0, 88, 160, 159, 0, 83, + 0, 0, 0, 0, 147, 42, 0, 36, 146, 0, + 0, 148, 149, 0, 34, 175, 201, 202, 29, 0, + 0, 0, 150, 151, 152, 153, 186, 180, 0, 189, + 0, 0, 0, 208, 0, 207, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 155, 156, 93, 92, 0, 0, - 0, 0, 0, 166, 0, 0, 167, 63, 62, 190, - 194, 196, 195, 0, 85, 0, 84, 0, 54, 89, - 90, 97, 102, 106, 110, 114, 118, 122, 126, 132, - 154, 165, 64, 0, 76, 34, 0, 0, 77, 78, - 0, 40, 43, 0, 35, 0, 0, 66, 33, 30, - 191, 0, 0, 188, 182, 187, 181, 184, 179, 12, - 87, 105, 0, 109, 113, 117, 121, 125, 131, 130, - 129, 136, 138, 139, 141, 142, 143, 95, 96, 0, - 164, 170, 172, 0, 0, 169, 0, 213, 212, 0, - 45, 57, 38, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, - 79, 44, 37, 0, 0, 0, 192, 189, 0, 10, - 13, 0, 0, 163, 0, 171, 168, 0, 51, 0, - 41, 46, 0, 0, 0, 215, 214, 82, 91, 154, - 107, 0, 111, 115, 119, 123, 127, 134, 133, 0, - 98, 99, 70, 67, 0, 53, 65, 0, 183, 185, - 0, 0, 101, 173, 0, 0, 47, 39, 82, 0, - 55, 0, 0, 0, 0, 71, 72, 0, 193, 11, - 5, 52, 50, 58, 0, 0, 103, 60, 0, 0, - 68, 70, 73, 80, 9, 0, 0, 61, 82, 31, - 31, 0, 7, 82, 0, 32, 74, 75, 69, 0, - 0, 0, 56, 59 + 0, 0, 0, 155, 156, 93, 92, 0, 0, 0, + 0, 0, 166, 0, 0, 167, 63, 62, 190, 194, + 196, 195, 0, 85, 0, 84, 0, 54, 89, 90, + 97, 102, 106, 110, 114, 118, 122, 126, 132, 154, + 165, 64, 0, 76, 34, 0, 0, 77, 78, 0, + 40, 43, 0, 35, 0, 0, 66, 33, 30, 191, + 0, 0, 188, 182, 187, 181, 184, 179, 12, 87, + 105, 0, 109, 113, 117, 121, 125, 131, 130, 129, + 136, 138, 139, 141, 142, 143, 95, 96, 0, 164, + 170, 172, 0, 0, 169, 0, 212, 211, 0, 45, + 57, 38, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 81, 79, + 44, 37, 0, 0, 0, 192, 189, 0, 10, 13, + 0, 0, 163, 0, 171, 168, 0, 51, 0, 41, + 46, 0, 0, 0, 214, 213, 82, 91, 154, 107, + 0, 111, 115, 119, 123, 127, 134, 133, 0, 98, + 99, 70, 67, 0, 53, 65, 0, 183, 185, 0, + 0, 101, 173, 0, 0, 47, 39, 82, 0, 55, + 0, 0, 0, 0, 71, 72, 0, 193, 11, 5, + 52, 50, 58, 0, 0, 103, 60, 0, 0, 68, + 70, 73, 80, 9, 0, 0, 61, 82, 31, 31, + 0, 7, 82, 0, 32, 74, 75, 69, 0, 0, + 0, 56, 59 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 42, 2, 89, 44, 355, 280, 281, 119, - 120, 366, 46, 47, 107, 251, 108, 252, 201, 202, - 290, 291, 48, 49, 50, 51, 253, 345, 293, 356, - 52, 53, 54, 55, 56, 57, 313, 334, 335, 336, - 351, 58, 59, 198, 199, 99, 175, 60, 178, 179, - 266, 61, 180, 62, 181, 63, 182, 64, 183, 65, - 184, 66, 185, 67, 186, 68, 187, 69, 188, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 163, 243, - 79, 80, 129, 130, 131, 81, 121, 122, 85, 82, - 83, 137, 95, 249, 297 + -1, 1, 41, 2, 88, 43, 354, 279, 280, 118, + 119, 365, 45, 46, 106, 250, 107, 251, 200, 201, + 289, 290, 47, 48, 49, 50, 252, 344, 292, 355, + 51, 52, 53, 54, 55, 56, 312, 333, 334, 335, + 350, 57, 58, 197, 198, 98, 174, 59, 177, 178, + 265, 60, 179, 61, 180, 62, 181, 63, 182, 64, + 183, 65, 184, 66, 185, 67, 186, 68, 187, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 162, 242, + 78, 79, 128, 129, 130, 80, 120, 121, 84, 81, + 82, 136, 94, 248, 296 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -273 +#define YYPACT_NINF -287 static const yytype_int16 yypact[] = { - -273, 19, 524, -273, -7, -7, 976, 768, 12, 12, - 192, -273, -273, 976, 12, -273, 976, -273, -273, 57, - 976, 24, 976, 12, 12, 976, 976, -273, -273, -273, - -3, -273, -273, 585, -273, 976, 976, -273, 976, 976, - 22, 976, -273, 416, -7, -273, -273, -273, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -273, -273, -273, - 40, -273, -273, 8, 30, 49, 54, 61, 84, 21, - 96, 155, 83, -273, -273, 88, -273, 99, 140, -273, - -273, -273, -273, -273, -273, 17, 17, -273, 115, -273, - -273, 184, 118, -273, -273, 379, 872, -273, 99, 17, - 107, 976, 40, 646, 134, -273, 109, 55, -273, -273, - 379, 976, -273, -273, 768, 471, -3, 119, 121, -273, - 707, 58, 153, -273, -273, -273, -273, -273, -273, 45, - 59, 976, -45, 12, -273, 976, -273, -273, 976, 976, - 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - 976, 976, 976, 976, -273, -273, -273, -273, 976, 976, - 976, 127, 820, -273, 976, 168, -273, -273, -273, -273, - -273, -273, -273, 12, -273, 7, 107, 175, -273, 171, - -273, -273, 14, 194, 174, 176, 177, 197, 34, 96, - 77, -273, -273, 9, -273, -273, 12, 57, 221, -273, - 976, -273, -273, 24, -273, 7, 9, -273, -273, -273, - -273, 112, 976, 187, -273, -273, -273, -273, -273, 203, - -273, 30, 193, 49, 54, 61, 84, 21, 96, 96, - 96, 155, 83, 83, -273, -273, -273, -273, -273, 67, - -273, -273, -273, 27, 71, -273, 379, -273, -273, 768, - 196, 195, 232, 37, 976, 976, 976, 976, 976, 976, - 976, 976, 976, 976, 379, 976, 976, 207, 217, -273, - -273, -273, -273, 768, 768, 206, -273, 211, 924, -273, - 212, 7, 976, -273, 976, -273, -273, 7, 251, 976, - -273, -273, 175, 37, 379, -273, -273, 976, -273, 100, - 194, 213, 174, 176, 177, 197, 34, 96, 96, 7, - -273, -273, 258, -273, 7, -273, -273, 976, -273, -273, - 224, 219, -273, -273, 17, 768, -273, -273, 976, 7, - -273, 976, 768, 976, 16, 258, -273, 57, -273, -273, - -273, -273, -273, -273, 768, 37, -273, -273, 79, 216, - -273, 258, -273, -273, 768, 231, 37, -273, 976, 768, - 768, 237, -273, 976, 7, 768, -273, -273, -273, 7, - 768, 768, -273, -273 + -287, 29, 490, -287, -18, -18, 934, 730, 21, 21, + 965, -287, 934, 21, -287, 934, -287, -287, 36, 934, + 89, 934, 21, 21, 934, 934, -287, -287, -287, 105, + -287, -287, 550, -287, 934, 934, -287, 934, 934, 61, + 934, -287, 403, -18, -287, -287, -287, -287, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -287, -287, 15, + -287, -287, 41, 106, 117, 129, 142, 158, 76, 162, + 131, 47, -287, -287, 141, -287, 113, 148, -287, -287, + -287, -287, -287, -287, 5, 5, -287, 147, -287, -287, + 169, 177, -287, -287, 370, 832, -287, 113, 5, 164, + 934, 15, 610, 123, -287, 159, 16, -287, -287, 370, + 934, -287, -287, 730, 438, 105, 175, 176, -287, 670, + 86, 178, -287, -287, -287, -287, -287, -287, 62, 63, + 934, 28, 21, -287, 934, -287, -287, 934, 934, 934, + 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, -287, -287, -287, -287, 934, 934, 934, + 181, 781, -287, 934, 189, -287, -287, -287, -287, -287, + -287, -287, 21, -287, 8, 164, 191, -287, 183, -287, + -287, 56, 201, 180, 182, 179, 194, 53, 162, 10, + -287, -287, 12, -287, -287, 21, 36, 225, -287, 934, + -287, -287, 89, -287, 8, 12, -287, -287, -287, -287, + 94, 934, 193, -287, -287, -287, -287, -287, 200, -287, + 106, 192, 117, 129, 142, 158, 76, 162, 162, 162, + 131, 47, 47, -287, -287, -287, -287, -287, 68, -287, + -287, -287, 46, 109, -287, 370, -287, -287, 730, 195, + 197, 227, 18, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, 370, 934, 934, 199, 209, -287, -287, + -287, -287, 730, 730, 202, -287, 204, 883, -287, 206, + 8, 934, -287, 934, -287, -287, 8, 239, 934, -287, + -287, 191, 18, 370, -287, -287, 934, -287, 160, 201, + 218, 180, 182, 179, 194, 53, 162, 162, 8, -287, + -287, 250, -287, 8, -287, -287, 934, -287, -287, 231, + 228, -287, -287, 5, 730, -287, -287, 934, 8, -287, + 934, 730, 934, 66, 250, -287, 36, -287, -287, -287, + -287, -287, -287, 730, 18, -287, -287, -32, 226, -287, + 250, -287, -287, 730, 238, 18, -287, 934, 730, 730, + 240, -287, 934, 8, 730, -287, -287, -287, 8, 730, + 730, -287, -287 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -273, -273, -273, -70, -2, -273, -273, -273, -273, 0, - -138, -84, -10, -273, -273, -273, 74, -14, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -273, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -72, -273, -55, - -273, -273, -273, -273, 85, -263, -96, -12, -273, -273, - 209, -115, -239, -273, -273, -273, -273, 143, 31, 157, - 43, 160, 44, 162, 46, 163, 47, 165, 50, -66, - 164, 91, 353, -273, 33, 300, 303, -273, -16, -273, - -273, -273, -273, 101, 102, -273, -273, 106, 1, -273, - -273, -74, 28, -61, -272 + -287, -287, -287, -61, -2, -287, -287, -287, -287, 0, + -141, -80, -15, -287, -287, -287, 78, -10, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -287, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -68, -287, -50, + -287, -287, -287, -287, 88, -286, -105, 20, -287, -287, + 212, -77, -209, -287, -287, -287, -287, 150, 34, 152, + 33, 153, 35, 154, 38, 156, 40, 151, 42, -94, + 157, 75, 64, -287, 2, 290, 291, -287, 19, -287, + -287, -287, -287, 93, 95, -287, -287, 96, 26, -287, + -287, -73, 25, 17, -278 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -963,264 +960,262 @@ static const yytype_int16 yypgoto[] = #define YYTABLE_NINF -197 static const yytype_int16 yytable[] = { - 43, 100, 45, 135, 102, 43, 86, 92, 247, 104, - 247, 167, 168, 93, 205, 298, 217, 301, 134, 3, - 220, 328, 218, 349, 222, 192, 310, 311, 194, 132, - 189, 43, 84, 204, 330, 145, 146, 96, 295, 91, - 138, 134, 101, 237, 238, 133, 255, 242, 114, 262, - 326, 110, 111, 91, 350, 91, 134, 135, 91, 91, - 139, 140, 166, 106, 147, 343, 256, 136, 91, 91, - 127, 91, 91, 358, 248, 284, 248, 263, 94, 228, - 229, 230, 191, 176, 363, 271, 128, 296, 135, 193, - 136, 264, 346, 213, 285, 364, 210, 276, 176, 206, - 369, 43, 141, 203, 103, 136, 211, 215, 142, 214, - 154, 155, 43, 156, 207, 135, 143, 157, 43, 135, - 209, 154, 155, 216, 156, 144, 265, 135, 157, 190, - 359, 283, 267, 154, 155, 286, 156, 158, 148, 196, - 157, 151, 152, 153, 273, 274, 197, 173, 239, 265, - 287, 170, 244, 169, 170, 135, 171, 172, 200, 171, - 172, 219, 160, 319, 161, 162, 240, 322, 309, 323, - -196, 91, -195, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 269, 189, 189, - 189, 189, 189, 189, 189, 189, 307, 308, 329, 189, - 189, 246, 338, 164, 212, 165, 162, 245, 10, 11, - 12, 149, 150, 15, 250, 17, 18, 154, 155, 254, - 321, 365, 365, 189, 268, 257, 324, 258, 28, 29, - 259, 87, 260, 197, 176, 127, 31, 32, 261, 88, - 232, 233, 279, 292, 282, 289, 294, 43, 332, 288, - 341, 37, 176, 337, 312, 40, 314, 317, 41, 215, - 320, 325, 333, 339, 331, 189, 340, 360, 344, 362, - 354, 43, 43, 315, 316, 368, 367, 272, 327, 361, - 352, 221, 176, 270, 159, 100, 300, 299, 91, 299, - 91, 91, 91, 91, 91, 91, 91, 223, 299, 299, - 302, 224, 303, 370, 225, 304, 226, 305, 371, 227, - 97, 306, 231, 98, 277, 278, 100, 275, 0, 0, - 0, 348, 299, 43, 0, 342, 0, 353, 0, 0, - 43, 0, 347, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 43, 0, 357, 0, 100, 0, 0, 0, - 0, 100, 43, 0, 45, 0, 0, 43, 43, 90, - 0, 0, 0, 43, 299, 209, 0, 0, 43, 43, - 372, 373, 0, 105, 0, 109, 0, 0, 112, 113, - 174, 0, 0, 0, 0, 0, 0, 6, 123, 124, - 0, 125, 126, 0, 0, 10, 11, 12, 0, 0, - 15, 0, 17, 18, 0, 20, 0, 22, 0, 0, - 0, 0, 25, 26, 0, 28, 29, -162, 87, 0, - 0, 0, 0, 31, 32, 0, 88, 0, 0, 0, - -162, -162, 0, 0, 0, 35, 36, 0, 37, 0, - 38, 39, 40, 0, 0, 41, 0, -162, -162, 0, - 0, 0, 0, 0, 0, 0, -162, -162, -162, -162, - 0, 0, 0, 0, -162, -162, 0, 0, -162, -162, - -162, -162, -190, 0, -162, 0, -162, 0, 0, 0, - 0, -162, 0, 0, 0, -190, -190, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -190, -190, 234, 235, 236, 0, 0, 0, - 0, -190, -190, -190, -190, 0, 0, 0, 0, -190, - -190, 0, 0, -190, -190, -190, -190, 4, 0, -190, - 5, -190, 6, 7, 0, 8, -190, 9, 0, 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 0, 0, 25, 26, 27, - 28, 29, 0, 30, 0, 0, 0, 0, 31, 32, - 0, 33, 0, 0, 34, 0, 0, 0, 0, 0, - 35, 36, 0, 37, 0, 38, 39, 40, 4, 0, - 41, 5, 0, 6, 7, 0, 8, 0, 9, 0, - 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 0, 0, 25, 26, - 0, 28, 29, 115, 116, 0, 0, 0, 0, 117, - 118, 0, 33, 0, 0, 34, 0, 0, 0, 0, - 0, 35, 36, 0, 37, 0, 38, 39, 40, 4, - 0, 41, 5, 0, 6, 7, 0, 8, 0, 9, - 0, 0, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 0, 0, 25, - 26, 0, 28, 29, 195, 30, 0, 0, 0, 0, - 31, 32, 0, 33, 0, 0, 34, 0, 0, 0, - 0, 0, 35, 36, 0, 37, 0, 38, 39, 40, - 4, 0, 41, 5, 0, 6, 7, 0, 8, 0, - 9, 0, 0, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 0, 0, - 25, 26, 0, 28, 29, 208, 30, 0, 0, 0, - 0, 31, 32, 0, 33, 0, 0, 34, 0, 0, - 0, 0, 0, 35, 36, 0, 37, 0, 38, 39, - 40, 4, 0, 41, 5, 0, 6, 7, 0, 8, - 0, 9, 0, 0, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, - 0, 25, 26, 0, 28, 29, 0, 30, 0, 0, - 0, 0, 31, 32, 0, 33, 0, 0, 34, 0, - 0, 0, 0, 0, 35, 36, 0, 37, 6, 38, - 39, 40, 0, 0, 41, 0, 10, 11, 12, 0, - 0, 15, 0, 17, 18, 0, 20, 0, 22, 0, - 0, 0, 0, 25, 26, 0, 28, 29, 0, 87, - 0, 0, 0, 0, 31, 32, 0, 88, 0, 0, - 0, 0, 0, 0, 0, 0, 35, 36, 0, 37, - 6, 38, 39, 40, 0, 0, 41, 241, 10, 11, - 12, 0, 0, 15, 0, 17, 18, 0, 20, 177, - 22, 0, 0, 0, 0, 25, 26, 0, 28, 29, - 0, 87, 0, 0, 0, 0, 31, 32, 0, 88, - 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, - 0, 37, 6, 38, 39, 40, 0, 0, 41, 0, - 10, 11, 12, 0, 0, 15, 0, 17, 18, 0, - 20, 0, 22, 0, 0, 0, 0, 25, 26, 0, - 28, 29, 0, 87, 0, 0, 0, 0, 31, 32, - 0, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 35, 36, 0, 37, 6, 38, 39, 40, 318, 0, - 41, 0, 10, 11, 12, 0, 0, 15, 0, 17, - 18, 0, 20, 0, 22, 0, 0, 0, 0, 25, - 26, 0, 28, 29, 0, 87, 0, 0, 0, 0, - 31, 32, 0, 88, 0, 0, 0, 0, 0, 0, - 0, 0, 35, 36, 0, 37, 0, 38, 39, 40, - 0, 0, 41 + 42, 188, 44, 103, 204, 42, 133, 91, 90, 246, + 329, 166, 167, 246, 327, 134, 133, 133, 358, 294, + 83, 90, 92, 90, 263, 191, 90, 90, 193, 3, + 42, 85, 99, 203, 95, 101, 90, 90, 100, 90, + 90, 342, 153, 154, 297, 155, 300, 109, 110, 156, + 227, 228, 229, 216, 135, 309, 310, 219, 264, 134, + 131, 221, 134, 202, 135, 135, 357, 295, 261, 132, + 89, 363, 137, 348, 247, 134, 368, 362, 247, 325, + 236, 237, 102, 104, 241, 108, 93, 254, 111, 112, + 144, 145, 138, 283, 217, 262, 165, 189, 122, 123, + 42, 124, 125, 349, 150, 151, 152, 255, 126, 212, + 214, 42, 284, 206, 175, 134, 190, 42, 146, 208, + 192, 345, 270, 209, 127, 213, 215, 105, 195, 175, + 205, 282, 169, 210, 275, 196, 139, 170, 171, 90, + 286, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 113, 134, 218, 308, 188, + 188, 188, 188, 188, 188, 188, 188, 306, 307, 140, + 188, 188, 285, 153, 154, 159, 155, 160, 161, 238, + 156, 268, 141, 243, 168, 169, 148, 149, 328, 157, + 170, 171, 153, 154, 188, 155, 142, 245, 143, 156, + 318, 153, 154, 147, 321, 172, 322, 199, 264, 266, + 163, 134, 164, 161, 233, 234, 235, 364, 364, 239, + 267, 272, 273, 231, 232, -196, -195, 244, 211, 249, + 253, 256, 257, 259, 260, 258, 188, 196, 278, 337, + 126, 293, 281, 288, 291, 311, 42, 313, 287, 324, + 340, 214, 316, 319, 332, 298, 90, 298, 90, 90, + 90, 90, 90, 90, 90, 175, 298, 298, 330, 338, + 42, 42, 314, 315, 339, 361, 359, 367, 353, 366, + 271, 326, 360, 175, 351, 269, 158, 220, 299, 301, + 298, 222, 302, 223, 226, 224, 303, 320, 225, 304, + 96, 97, 305, 323, 230, 276, 274, 277, 0, 0, + 0, 0, 0, 175, 0, 0, 99, 0, 0, 0, + 0, 352, 42, 0, 341, 331, 0, 0, 0, 42, + 336, 346, 298, 0, 0, 0, 0, 0, 0, 0, + 0, 42, 0, 356, 0, 343, 0, 99, 0, 0, + 0, 42, 347, 44, 0, 0, 42, 42, 0, 0, + 0, 0, 42, 0, 208, 0, 0, 42, 42, 371, + 372, 173, 0, 0, 0, 0, 0, 99, 6, 0, + 369, 0, 99, 0, 0, 370, 10, 11, 0, 0, + 14, 0, 16, 17, 0, 19, 0, 21, 0, 0, + 0, 0, 24, 25, -162, 27, 28, 0, 86, 0, + 0, 0, 0, 30, 31, 0, 87, -162, -162, 0, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, -162, -162, 40, 0, 0, 0, -190, + 0, 0, -162, -162, -162, -162, 0, 0, 0, 0, + -162, -162, -190, -190, -162, -162, -162, -162, 0, 0, + -162, 0, -162, 0, 0, 0, 0, -162, -190, -190, + 0, 0, 0, 0, 0, 0, 0, -190, -190, -190, + -190, 0, 0, 0, 0, -190, -190, 0, 0, -190, + -190, -190, -190, 4, 0, -190, 5, -190, 6, 7, + 0, 8, -190, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 26, 27, 28, 0, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 114, 115, 0, + 0, 0, 0, 116, 117, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 194, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 207, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 0, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 6, + 37, 38, 39, 0, 0, 40, 0, 10, 11, 0, + 0, 14, 0, 16, 17, 0, 19, 0, 21, 0, + 0, 0, 0, 24, 25, 0, 27, 28, 0, 86, + 0, 0, 0, 0, 30, 31, 0, 87, 0, 0, + 0, 0, 0, 0, 0, 0, 34, 35, 0, 36, + 6, 37, 38, 39, 0, 0, 40, 240, 10, 11, + 0, 0, 14, 0, 16, 17, 0, 19, 176, 21, + 0, 0, 0, 0, 24, 25, 0, 27, 28, 0, + 86, 0, 0, 0, 0, 30, 31, 0, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 34, 35, 0, + 36, 6, 37, 38, 39, 0, 0, 40, 0, 10, + 11, 0, 0, 14, 0, 16, 17, 0, 19, 0, + 21, 0, 0, 0, 0, 24, 25, 0, 27, 28, + 0, 86, 0, 0, 0, 0, 30, 31, 0, 87, + 0, 0, 0, 0, 0, 0, 0, 0, 34, 35, + 0, 36, 6, 37, 38, 39, 317, 0, 40, 0, + 10, 11, 0, 0, 14, 0, 16, 17, 0, 19, + 0, 21, 0, 0, 0, 0, 24, 25, 0, 27, + 28, 0, 86, 0, 0, 0, 0, 30, 31, 0, + 87, 10, 11, 0, 0, 14, 0, 16, 17, 34, + 35, 0, 36, 0, 37, 38, 39, 0, 0, 40, + 27, 28, 0, 86, 0, 0, 0, 0, 30, 31, + 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 36, 0, 0, 0, 39, 0, 0, + 40 }; static const yytype_int16 yycheck[] = { - 2, 13, 2, 48, 16, 7, 5, 7, 1, 19, - 1, 85, 86, 1, 110, 254, 131, 256, 1, 0, - 135, 293, 67, 7, 139, 99, 265, 266, 102, 41, - 96, 33, 39, 107, 297, 14, 15, 9, 1, 6, - 32, 1, 14, 158, 159, 44, 32, 162, 51, 15, - 289, 23, 24, 20, 38, 22, 1, 48, 25, 26, - 52, 31, 78, 39, 43, 328, 52, 50, 35, 36, - 48, 38, 39, 345, 67, 48, 67, 43, 66, 145, - 146, 147, 98, 95, 356, 200, 64, 50, 48, 101, - 50, 14, 331, 48, 67, 358, 38, 212, 110, 111, - 363, 103, 53, 48, 47, 50, 48, 48, 54, 64, - 33, 34, 114, 36, 114, 48, 55, 40, 120, 48, - 120, 33, 34, 64, 36, 41, 49, 48, 40, 96, - 51, 64, 193, 33, 34, 64, 36, 49, 42, 5, - 40, 58, 59, 60, 205, 206, 12, 29, 160, 49, - 246, 39, 164, 38, 39, 48, 44, 45, 49, 44, - 45, 133, 63, 278, 65, 66, 39, 282, 264, 284, - 51, 138, 51, 140, 141, 142, 143, 144, 145, 146, - 147, 148, 149, 150, 151, 152, 153, 197, 254, 255, - 256, 257, 258, 259, 260, 261, 262, 263, 294, 265, - 266, 173, 317, 63, 51, 65, 66, 39, 16, 17, - 18, 56, 57, 21, 39, 23, 24, 33, 34, 48, - 281, 359, 360, 289, 196, 31, 287, 53, 36, 37, - 54, 39, 55, 12, 246, 48, 44, 45, 41, 47, - 149, 150, 39, 48, 51, 49, 14, 249, 309, 249, - 324, 59, 264, 314, 47, 63, 39, 51, 66, 48, - 48, 10, 4, 39, 51, 331, 47, 51, 329, 38, - 340, 273, 274, 273, 274, 38, 360, 203, 292, 351, - 335, 138, 294, 198, 75, 297, 255, 254, 255, 256, - 257, 258, 259, 260, 261, 262, 263, 140, 265, 266, - 257, 141, 258, 364, 142, 259, 143, 260, 369, 144, - 10, 261, 148, 10, 213, 213, 328, 211, -1, -1, - -1, 333, 289, 325, -1, 325, -1, 337, -1, -1, - 332, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 344, -1, 344, -1, 358, -1, -1, -1, - -1, 363, 354, -1, 354, -1, -1, 359, 360, 6, - -1, -1, -1, 365, 331, 365, -1, -1, 370, 371, - 370, 371, -1, 20, -1, 22, -1, -1, 25, 26, - 1, -1, -1, -1, -1, -1, -1, 8, 35, 36, - -1, 38, 39, -1, -1, 16, 17, 18, -1, -1, - 21, -1, 23, 24, -1, 26, -1, 28, -1, -1, - -1, -1, 33, 34, -1, 36, 37, 1, 39, -1, - -1, -1, -1, 44, 45, -1, 47, -1, -1, -1, - 14, 15, -1, -1, -1, 56, 57, -1, 59, -1, - 61, 62, 63, -1, -1, 66, -1, 31, 32, -1, - -1, -1, -1, -1, -1, -1, 40, 41, 42, 43, - -1, -1, -1, -1, 48, 49, -1, -1, 52, 53, - 54, 55, 1, -1, 58, -1, 60, -1, -1, -1, - -1, 65, -1, -1, -1, 14, 15, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 31, 32, 151, 152, 153, -1, -1, -1, - -1, 40, 41, 42, 43, -1, -1, -1, -1, 48, - 49, -1, -1, 52, 53, 54, 55, 3, -1, 58, - 6, 60, 8, 9, -1, 11, 65, 13, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, -1, -1, 33, 34, 35, - 36, 37, -1, 39, -1, -1, -1, -1, 44, 45, - -1, 47, -1, -1, 50, -1, -1, -1, -1, -1, - 56, 57, -1, 59, -1, 61, 62, 63, 3, -1, - 66, 6, -1, 8, 9, -1, 11, -1, 13, -1, - -1, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, -1, -1, 33, 34, - -1, 36, 37, 38, 39, -1, -1, -1, -1, 44, - 45, -1, 47, -1, -1, 50, -1, -1, -1, -1, - -1, 56, 57, -1, 59, -1, 61, 62, 63, 3, - -1, 66, 6, -1, 8, 9, -1, 11, -1, 13, - -1, -1, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, -1, -1, 33, - 34, -1, 36, 37, 38, 39, -1, -1, -1, -1, - 44, 45, -1, 47, -1, -1, 50, -1, -1, -1, - -1, -1, 56, 57, -1, 59, -1, 61, 62, 63, - 3, -1, 66, 6, -1, 8, 9, -1, 11, -1, - 13, -1, -1, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, -1, -1, - 33, 34, -1, 36, 37, 38, 39, -1, -1, -1, - -1, 44, 45, -1, 47, -1, -1, 50, -1, -1, - -1, -1, -1, 56, 57, -1, 59, -1, 61, 62, - 63, 3, -1, 66, 6, -1, 8, 9, -1, 11, - -1, 13, -1, -1, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, - -1, 33, 34, -1, 36, 37, -1, 39, -1, -1, - -1, -1, 44, 45, -1, 47, -1, -1, 50, -1, - -1, -1, -1, -1, 56, 57, -1, 59, 8, 61, - 62, 63, -1, -1, 66, -1, 16, 17, 18, -1, - -1, 21, -1, 23, 24, -1, 26, -1, 28, -1, - -1, -1, -1, 33, 34, -1, 36, 37, -1, 39, - -1, -1, -1, -1, 44, 45, -1, 47, -1, -1, - -1, -1, -1, -1, -1, -1, 56, 57, -1, 59, - 8, 61, 62, 63, -1, -1, 66, 67, 16, 17, - 18, -1, -1, 21, -1, 23, 24, -1, 26, 27, - 28, -1, -1, -1, -1, 33, 34, -1, 36, 37, - -1, 39, -1, -1, -1, -1, 44, 45, -1, 47, - -1, -1, -1, -1, -1, -1, -1, -1, 56, 57, - -1, 59, 8, 61, 62, 63, -1, -1, 66, -1, - 16, 17, 18, -1, -1, 21, -1, 23, 24, -1, - 26, -1, 28, -1, -1, -1, -1, 33, 34, -1, - 36, 37, -1, 39, -1, -1, -1, -1, 44, 45, - -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, - 56, 57, -1, 59, 8, 61, 62, 63, 64, -1, - 66, -1, 16, 17, 18, -1, -1, 21, -1, 23, - 24, -1, 26, -1, 28, -1, -1, -1, -1, 33, - 34, -1, 36, 37, -1, 39, -1, -1, -1, -1, - 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, - -1, -1, 56, 57, -1, 59, -1, 61, 62, 63, - -1, -1, 66 + 2, 95, 2, 18, 109, 7, 1, 7, 6, 1, + 296, 84, 85, 1, 292, 47, 1, 1, 50, 1, + 38, 19, 1, 21, 14, 98, 24, 25, 101, 0, + 32, 5, 12, 106, 9, 15, 34, 35, 13, 37, + 38, 327, 32, 33, 253, 35, 255, 22, 23, 39, + 144, 145, 146, 130, 49, 264, 265, 134, 48, 47, + 40, 138, 47, 47, 49, 49, 344, 49, 15, 43, + 6, 357, 31, 7, 66, 47, 362, 355, 66, 288, + 157, 158, 46, 19, 161, 21, 65, 31, 24, 25, + 14, 15, 51, 47, 66, 42, 77, 95, 34, 35, + 102, 37, 38, 37, 57, 58, 59, 51, 47, 47, + 47, 113, 66, 113, 94, 47, 97, 119, 42, 119, + 100, 330, 199, 37, 63, 63, 63, 38, 5, 109, + 110, 63, 38, 47, 211, 12, 30, 43, 44, 137, + 245, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 152, 50, 47, 132, 263, 253, + 254, 255, 256, 257, 258, 259, 260, 261, 262, 52, + 264, 265, 63, 32, 33, 62, 35, 64, 65, 159, + 39, 196, 53, 163, 37, 38, 55, 56, 293, 48, + 43, 44, 32, 33, 288, 35, 54, 172, 40, 39, + 277, 32, 33, 41, 281, 28, 283, 48, 48, 192, + 62, 47, 64, 65, 150, 151, 152, 358, 359, 38, + 195, 204, 205, 148, 149, 50, 50, 38, 50, 38, + 47, 30, 52, 54, 40, 53, 330, 12, 38, 316, + 47, 14, 50, 48, 47, 46, 248, 38, 248, 10, + 323, 47, 50, 47, 4, 253, 254, 255, 256, 257, + 258, 259, 260, 261, 262, 245, 264, 265, 50, 38, + 272, 273, 272, 273, 46, 37, 50, 37, 339, 359, + 202, 291, 350, 263, 334, 197, 74, 137, 254, 256, + 288, 139, 257, 140, 143, 141, 258, 280, 142, 259, + 10, 10, 260, 286, 147, 212, 210, 212, -1, -1, + -1, -1, -1, 293, -1, -1, 296, -1, -1, -1, + -1, 336, 324, -1, 324, 308, -1, -1, -1, 331, + 313, 331, 330, -1, -1, -1, -1, -1, -1, -1, + -1, 343, -1, 343, -1, 328, -1, 327, -1, -1, + -1, 353, 332, 353, -1, -1, 358, 359, -1, -1, + -1, -1, 364, -1, 364, -1, -1, 369, 370, 369, + 370, 1, -1, -1, -1, -1, -1, 357, 8, -1, + 363, -1, 362, -1, -1, 368, 16, 17, -1, -1, + 20, -1, 22, 23, -1, 25, -1, 27, -1, -1, + -1, -1, 32, 33, 1, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, 14, 15, -1, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 30, 31, 65, -1, -1, -1, 1, + -1, -1, 39, 40, 41, 42, -1, -1, -1, -1, + 47, 48, 14, 15, 51, 52, 53, 54, -1, -1, + 57, -1, 59, -1, -1, -1, -1, 64, 30, 31, + -1, -1, -1, -1, -1, -1, -1, 39, 40, 41, + 42, -1, -1, -1, -1, 47, 48, -1, -1, 51, + 52, 53, 54, 3, -1, 57, 6, 59, 8, 9, + -1, 11, 64, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, 34, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, 8, + 60, 61, 62, -1, -1, 65, -1, 16, 17, -1, + -1, 20, -1, 22, 23, -1, 25, -1, 27, -1, + -1, -1, -1, 32, 33, -1, 35, 36, -1, 38, + -1, -1, -1, -1, 43, 44, -1, 46, -1, -1, + -1, -1, -1, -1, -1, -1, 55, 56, -1, 58, + 8, 60, 61, 62, -1, -1, 65, 66, 16, 17, + -1, -1, 20, -1, 22, 23, -1, 25, 26, 27, + -1, -1, -1, -1, 32, 33, -1, 35, 36, -1, + 38, -1, -1, -1, -1, 43, 44, -1, 46, -1, + -1, -1, -1, -1, -1, -1, -1, 55, 56, -1, + 58, 8, 60, 61, 62, -1, -1, 65, -1, 16, + 17, -1, -1, 20, -1, 22, 23, -1, 25, -1, + 27, -1, -1, -1, -1, 32, 33, -1, 35, 36, + -1, 38, -1, -1, -1, -1, 43, 44, -1, 46, + -1, -1, -1, -1, -1, -1, -1, -1, 55, 56, + -1, 58, 8, 60, 61, 62, 63, -1, 65, -1, + 16, 17, -1, -1, 20, -1, 22, 23, -1, 25, + -1, 27, -1, -1, -1, -1, 32, 33, -1, 35, + 36, -1, 38, -1, -1, -1, -1, 43, 44, -1, + 46, 16, 17, -1, -1, 20, -1, 22, 23, 55, + 56, -1, 58, -1, 60, 61, 62, -1, -1, 65, + 35, 36, -1, 38, -1, -1, -1, -1, 43, 44, + -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 58, -1, -1, -1, 62, -1, -1, + 65 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 69, 71, 0, 3, 6, 8, 9, 11, 13, + 0, 68, 70, 0, 3, 6, 8, 9, 11, 13, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 33, 34, 35, 36, 37, - 39, 44, 45, 47, 50, 56, 57, 59, 61, 62, - 63, 66, 70, 72, 73, 77, 80, 81, 90, 91, - 92, 93, 98, 99, 100, 101, 102, 103, 109, 110, - 115, 119, 121, 123, 125, 127, 129, 131, 133, 135, - 137, 138, 139, 140, 141, 142, 143, 144, 145, 148, - 149, 153, 157, 158, 39, 156, 156, 39, 47, 72, - 140, 142, 77, 1, 66, 160, 160, 143, 144, 113, - 115, 160, 115, 47, 80, 140, 39, 82, 84, 140, - 160, 160, 140, 140, 51, 38, 39, 44, 45, 77, - 78, 154, 155, 140, 140, 140, 140, 48, 64, 150, - 151, 152, 115, 156, 1, 48, 50, 159, 32, 52, - 31, 53, 54, 55, 41, 14, 15, 43, 42, 56, - 57, 58, 59, 60, 33, 34, 36, 40, 49, 118, - 63, 65, 66, 146, 63, 65, 146, 159, 159, 38, - 39, 44, 45, 29, 1, 114, 115, 27, 116, 117, - 120, 122, 124, 126, 128, 130, 132, 134, 136, 137, - 142, 146, 159, 115, 159, 38, 5, 12, 111, 112, - 49, 86, 87, 48, 159, 114, 115, 77, 38, 77, - 38, 48, 51, 48, 64, 48, 64, 119, 67, 160, - 119, 125, 119, 127, 129, 131, 133, 135, 137, 137, - 137, 138, 139, 139, 140, 140, 140, 119, 119, 115, - 39, 67, 119, 147, 115, 39, 160, 1, 67, 161, - 39, 83, 85, 94, 48, 32, 52, 31, 53, 54, - 55, 41, 15, 43, 14, 49, 118, 161, 160, 80, - 112, 119, 84, 161, 161, 155, 119, 151, 152, 39, - 75, 76, 51, 64, 48, 67, 64, 114, 77, 49, - 88, 89, 48, 96, 14, 1, 50, 162, 120, 142, - 126, 120, 128, 130, 132, 134, 136, 137, 137, 114, - 120, 120, 47, 104, 39, 77, 77, 51, 64, 119, - 48, 161, 119, 119, 161, 10, 120, 85, 162, 114, - 113, 51, 161, 4, 105, 106, 107, 161, 119, 39, - 47, 159, 77, 113, 161, 95, 120, 77, 115, 7, - 38, 108, 107, 80, 71, 74, 97, 77, 162, 51, - 51, 105, 38, 162, 113, 78, 79, 79, 38, 113, - 161, 161, 77, 77 + 26, 27, 28, 29, 32, 33, 34, 35, 36, 38, + 43, 44, 46, 49, 55, 56, 58, 60, 61, 62, + 65, 69, 71, 72, 76, 79, 80, 89, 90, 91, + 92, 97, 98, 99, 100, 101, 102, 108, 109, 114, + 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 147, 148, + 152, 156, 157, 38, 155, 155, 38, 46, 71, 139, + 141, 76, 1, 65, 159, 159, 142, 143, 112, 114, + 159, 114, 46, 79, 139, 38, 81, 83, 139, 159, + 159, 139, 139, 50, 37, 38, 43, 44, 76, 77, + 153, 154, 139, 139, 139, 139, 47, 63, 149, 150, + 151, 114, 155, 1, 47, 49, 158, 31, 51, 30, + 52, 53, 54, 40, 14, 15, 42, 41, 55, 56, + 57, 58, 59, 32, 33, 35, 39, 48, 117, 62, + 64, 65, 145, 62, 64, 145, 158, 158, 37, 38, + 43, 44, 28, 1, 113, 114, 26, 115, 116, 119, + 121, 123, 125, 127, 129, 131, 133, 135, 136, 141, + 145, 158, 114, 158, 37, 5, 12, 110, 111, 48, + 85, 86, 47, 158, 113, 114, 76, 37, 76, 37, + 47, 50, 47, 63, 47, 63, 118, 66, 159, 118, + 124, 118, 126, 128, 130, 132, 134, 136, 136, 136, + 137, 138, 138, 139, 139, 139, 118, 118, 114, 38, + 66, 118, 146, 114, 38, 159, 1, 66, 160, 38, + 82, 84, 93, 47, 31, 51, 30, 52, 53, 54, + 40, 15, 42, 14, 48, 117, 160, 159, 79, 111, + 118, 83, 160, 160, 154, 118, 150, 151, 38, 74, + 75, 50, 63, 47, 66, 63, 113, 76, 48, 87, + 88, 47, 95, 14, 1, 49, 161, 119, 141, 125, + 119, 127, 129, 131, 133, 135, 136, 136, 113, 119, + 119, 46, 103, 38, 76, 76, 50, 63, 118, 47, + 160, 118, 118, 160, 10, 119, 84, 161, 113, 112, + 50, 160, 4, 104, 105, 106, 160, 118, 38, 46, + 158, 76, 112, 160, 94, 119, 76, 114, 7, 37, + 107, 106, 79, 70, 73, 96, 76, 161, 50, 50, + 104, 37, 161, 112, 77, 78, 78, 37, 112, 160, + 160, 76, 76 }; #define yyerrok (yyerrstatus = 0) @@ -2033,1415 +2028,1416 @@ yyreduce: case 2: /* Line 1455 of yacc.c */ -#line 258 "parser.y" +#line 257 "parser.y" { program_parsed(ctx, (yyvsp[(1) - (2)].source_elements)); ;} break; case 3: /* Line 1455 of yacc.c */ -#line 261 "parser.y" +#line 260 "parser.y" {;} break; case 4: /* Line 1455 of yacc.c */ -#line 262 "parser.y" +#line 261 "parser.y" {;} break; case 5: /* Line 1455 of yacc.c */ -#line 266 "parser.y" +#line 265 "parser.y" { (yyval.source_elements) = new_source_elements(ctx); ;} break; case 6: /* Line 1455 of yacc.c */ -#line 268 "parser.y" +#line 267 "parser.y" { (yyval.source_elements) = source_elements_add_statement((yyvsp[(1) - (2)].source_elements), (yyvsp[(2) - (2)].statement)); ;} break; case 7: /* Line 1455 of yacc.c */ -#line 273 "parser.y" +#line 272 "parser.y" { (yyval.expr) = new_function_expression(ctx, (yyvsp[(2) - (8)].identifier), (yyvsp[(4) - (8)].parameter_list), (yyvsp[(7) - (8)].source_elements), (yyvsp[(1) - (8)].srcptr), (yyvsp[(8) - (8)].srcptr)-(yyvsp[(1) - (8)].srcptr)+1); ;} break; case 8: /* Line 1455 of yacc.c */ -#line 276 "parser.y" +#line 275 "parser.y" { push_func(ctx); (yyval.srcptr) = (yyvsp[(1) - (1)].srcptr); ;} break; case 9: /* Line 1455 of yacc.c */ -#line 280 "parser.y" +#line 279 "parser.y" { (yyval.source_elements) = function_body_parsed(ctx, (yyvsp[(1) - (1)].source_elements)); ;} break; case 10: /* Line 1455 of yacc.c */ -#line 284 "parser.y" +#line 283 "parser.y" { (yyval.parameter_list) = new_parameter_list(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 11: /* Line 1455 of yacc.c */ -#line 286 "parser.y" +#line 285 "parser.y" { (yyval.parameter_list) = parameter_list_add(ctx, (yyvsp[(1) - (3)].parameter_list), (yyvsp[(3) - (3)].identifier)); ;} break; case 12: /* Line 1455 of yacc.c */ -#line 290 "parser.y" +#line 289 "parser.y" { (yyval.parameter_list) = NULL; ;} break; case 13: /* Line 1455 of yacc.c */ -#line 291 "parser.y" +#line 290 "parser.y" { (yyval.parameter_list) = (yyvsp[(1) - (1)].parameter_list); ;} break; case 14: /* Line 1455 of yacc.c */ -#line 295 "parser.y" +#line 294 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 15: /* Line 1455 of yacc.c */ -#line 296 "parser.y" +#line 295 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 16: /* Line 1455 of yacc.c */ -#line 297 "parser.y" +#line 296 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 17: /* Line 1455 of yacc.c */ -#line 298 "parser.y" +#line 297 "parser.y" { (yyval.statement) = new_empty_statement(ctx); ;} break; case 18: /* Line 1455 of yacc.c */ -#line 299 "parser.y" +#line 298 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 19: /* Line 1455 of yacc.c */ -#line 300 "parser.y" +#line 299 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 20: /* Line 1455 of yacc.c */ -#line 301 "parser.y" +#line 300 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 21: /* Line 1455 of yacc.c */ -#line 302 "parser.y" +#line 301 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 22: /* Line 1455 of yacc.c */ -#line 303 "parser.y" +#line 302 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 23: /* Line 1455 of yacc.c */ -#line 304 "parser.y" +#line 303 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 24: /* Line 1455 of yacc.c */ -#line 305 "parser.y" +#line 304 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 25: /* Line 1455 of yacc.c */ -#line 306 "parser.y" +#line 305 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 26: /* Line 1455 of yacc.c */ -#line 307 "parser.y" +#line 306 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 27: /* Line 1455 of yacc.c */ -#line 308 "parser.y" +#line 307 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 28: /* Line 1455 of yacc.c */ -#line 309 "parser.y" +#line 308 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 29: /* Line 1455 of yacc.c */ -#line 313 "parser.y" +#line 312 "parser.y" { (yyval.statement_list) = new_statement_list(ctx, (yyvsp[(1) - (1)].statement)); ;} break; case 30: /* Line 1455 of yacc.c */ -#line 315 "parser.y" +#line 314 "parser.y" { (yyval.statement_list) = statement_list_add((yyvsp[(1) - (2)].statement_list), (yyvsp[(2) - (2)].statement)); ;} break; case 31: /* Line 1455 of yacc.c */ -#line 319 "parser.y" +#line 318 "parser.y" { (yyval.statement_list) = NULL; ;} break; case 32: /* Line 1455 of yacc.c */ -#line 320 "parser.y" +#line 319 "parser.y" { (yyval.statement_list) = (yyvsp[(1) - (1)].statement_list); ;} break; case 33: /* Line 1455 of yacc.c */ -#line 324 "parser.y" +#line 323 "parser.y" { (yyval.statement) = new_block_statement(ctx, (yyvsp[(2) - (3)].statement_list)); ;} break; case 34: /* Line 1455 of yacc.c */ -#line 325 "parser.y" +#line 324 "parser.y" { (yyval.statement) = new_block_statement(ctx, NULL); ;} break; case 35: /* Line 1455 of yacc.c */ -#line 330 "parser.y" +#line 329 "parser.y" { (yyval.statement) = new_var_statement(ctx, (yyvsp[(2) - (3)].variable_list)); ;} break; case 36: /* Line 1455 of yacc.c */ -#line 334 "parser.y" +#line 333 "parser.y" { (yyval.variable_list) = new_variable_list(ctx, (yyvsp[(1) - (1)].variable_declaration)); ;} break; case 37: /* Line 1455 of yacc.c */ -#line 336 "parser.y" +#line 335 "parser.y" { (yyval.variable_list) = variable_list_add(ctx, (yyvsp[(1) - (3)].variable_list), (yyvsp[(3) - (3)].variable_declaration)); ;} break; case 38: /* Line 1455 of yacc.c */ -#line 341 "parser.y" +#line 340 "parser.y" { (yyval.variable_list) = new_variable_list(ctx, (yyvsp[(1) - (1)].variable_declaration)); ;} break; case 39: /* Line 1455 of yacc.c */ -#line 343 "parser.y" +#line 342 "parser.y" { (yyval.variable_list) = variable_list_add(ctx, (yyvsp[(1) - (3)].variable_list), (yyvsp[(3) - (3)].variable_declaration)); ;} break; case 40: /* Line 1455 of yacc.c */ -#line 348 "parser.y" +#line 347 "parser.y" { (yyval.variable_declaration) = new_variable_declaration(ctx, (yyvsp[(1) - (2)].identifier), (yyvsp[(2) - (2)].expr)); ;} break; case 41: /* Line 1455 of yacc.c */ -#line 353 "parser.y" +#line 352 "parser.y" { (yyval.variable_declaration) = new_variable_declaration(ctx, (yyvsp[(1) - (2)].identifier), (yyvsp[(2) - (2)].expr)); ;} break; case 42: /* Line 1455 of yacc.c */ -#line 357 "parser.y" +#line 356 "parser.y" { (yyval.expr) = NULL; ;} break; case 43: /* Line 1455 of yacc.c */ -#line 358 "parser.y" +#line 357 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 44: /* Line 1455 of yacc.c */ -#line 363 "parser.y" +#line 362 "parser.y" { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; case 45: /* Line 1455 of yacc.c */ -#line 367 "parser.y" +#line 366 "parser.y" { (yyval.expr) = NULL; ;} break; case 46: /* Line 1455 of yacc.c */ -#line 368 "parser.y" +#line 367 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 47: /* Line 1455 of yacc.c */ -#line 373 "parser.y" +#line 372 "parser.y" { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; case 48: /* Line 1455 of yacc.c */ -#line 377 "parser.y" +#line 376 "parser.y" { (yyval.statement) = new_empty_statement(ctx); ;} break; case 49: /* Line 1455 of yacc.c */ -#line 382 "parser.y" +#line 381 "parser.y" { (yyval.statement) = new_expression_statement(ctx, (yyvsp[(1) - (2)].expr)); ;} break; case 50: /* Line 1455 of yacc.c */ -#line 387 "parser.y" +#line 386 "parser.y" { (yyval.statement) = new_if_statement(ctx, (yyvsp[(3) - (7)].expr), (yyvsp[(5) - (7)].statement), (yyvsp[(7) - (7)].statement)); ;} break; case 51: /* Line 1455 of yacc.c */ -#line 389 "parser.y" +#line 388 "parser.y" { (yyval.statement) = new_if_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement), NULL); ;} break; case 52: /* Line 1455 of yacc.c */ -#line 394 "parser.y" +#line 393 "parser.y" { (yyval.statement) = new_while_statement(ctx, TRUE, (yyvsp[(5) - (7)].expr), (yyvsp[(2) - (7)].statement)); ;} break; case 53: /* Line 1455 of yacc.c */ -#line 396 "parser.y" +#line 395 "parser.y" { (yyval.statement) = new_while_statement(ctx, FALSE, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement)); ;} break; case 54: /* Line 1455 of yacc.c */ -#line 398 "parser.y" +#line 397 "parser.y" { if(!explicit_error(ctx, (yyvsp[(3) - (3)].expr), ';')) YYABORT; ;} break; case 55: /* Line 1455 of yacc.c */ -#line 400 "parser.y" +#line 399 "parser.y" { if(!explicit_error(ctx, (yyvsp[(6) - (6)].expr), ';')) YYABORT; ;} break; case 56: /* Line 1455 of yacc.c */ -#line 402 "parser.y" +#line 401 "parser.y" { (yyval.statement) = new_for_statement(ctx, NULL, (yyvsp[(3) - (11)].expr), (yyvsp[(6) - (11)].expr), (yyvsp[(9) - (11)].expr), (yyvsp[(11) - (11)].statement)); ;} break; case 57: /* Line 1455 of yacc.c */ -#line 404 "parser.y" +#line 403 "parser.y" { if(!explicit_error(ctx, (yyvsp[(4) - (4)].variable_list), ';')) YYABORT; ;} break; case 58: /* Line 1455 of yacc.c */ -#line 406 "parser.y" +#line 405 "parser.y" { if(!explicit_error(ctx, (yyvsp[(7) - (7)].expr), ';')) YYABORT; ;} break; case 59: /* Line 1455 of yacc.c */ -#line 408 "parser.y" +#line 407 "parser.y" { (yyval.statement) = new_for_statement(ctx, (yyvsp[(4) - (12)].variable_list), NULL, (yyvsp[(7) - (12)].expr), (yyvsp[(10) - (12)].expr), (yyvsp[(12) - (12)].statement)); ;} break; case 60: /* Line 1455 of yacc.c */ -#line 410 "parser.y" +#line 409 "parser.y" { (yyval.statement) = new_forin_statement(ctx, NULL, (yyvsp[(3) - (7)].expr), (yyvsp[(5) - (7)].expr), (yyvsp[(7) - (7)].statement)); ;} break; case 61: /* Line 1455 of yacc.c */ -#line 412 "parser.y" +#line 411 "parser.y" { (yyval.statement) = new_forin_statement(ctx, (yyvsp[(4) - (8)].variable_declaration), NULL, (yyvsp[(6) - (8)].expr), (yyvsp[(8) - (8)].statement)); ;} break; case 62: /* Line 1455 of yacc.c */ -#line 417 "parser.y" +#line 416 "parser.y" { (yyval.statement) = new_continue_statement(ctx, (yyvsp[(2) - (3)].identifier)); ;} break; case 63: /* Line 1455 of yacc.c */ -#line 422 "parser.y" +#line 421 "parser.y" { (yyval.statement) = new_break_statement(ctx, (yyvsp[(2) - (3)].identifier)); ;} break; case 64: /* Line 1455 of yacc.c */ -#line 427 "parser.y" +#line 426 "parser.y" { (yyval.statement) = new_return_statement(ctx, (yyvsp[(2) - (3)].expr)); ;} break; case 65: /* Line 1455 of yacc.c */ -#line 432 "parser.y" +#line 431 "parser.y" { (yyval.statement) = new_with_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement)); ;} break; case 66: /* Line 1455 of yacc.c */ -#line 437 "parser.y" +#line 436 "parser.y" { (yyval.statement) = new_labelled_statement(ctx, (yyvsp[(1) - (3)].identifier), (yyvsp[(3) - (3)].statement)); ;} break; case 67: /* Line 1455 of yacc.c */ -#line 442 "parser.y" +#line 441 "parser.y" { (yyval.statement) = new_switch_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].case_clausule)); ;} break; case 68: /* Line 1455 of yacc.c */ -#line 447 "parser.y" +#line 446 "parser.y" { (yyval.case_clausule) = new_case_block(ctx, (yyvsp[(2) - (3)].case_list), NULL, NULL); ;} break; case 69: /* Line 1455 of yacc.c */ -#line 449 "parser.y" +#line 448 "parser.y" { (yyval.case_clausule) = new_case_block(ctx, (yyvsp[(2) - (5)].case_list), (yyvsp[(3) - (5)].case_clausule), (yyvsp[(4) - (5)].case_list)); ;} break; case 70: /* Line 1455 of yacc.c */ -#line 453 "parser.y" +#line 452 "parser.y" { (yyval.case_list) = NULL; ;} break; case 71: /* Line 1455 of yacc.c */ -#line 454 "parser.y" +#line 453 "parser.y" { (yyval.case_list) = (yyvsp[(1) - (1)].case_list); ;} break; case 72: /* Line 1455 of yacc.c */ -#line 458 "parser.y" +#line 457 "parser.y" { (yyval.case_list) = new_case_list(ctx, (yyvsp[(1) - (1)].case_clausule)); ;} break; case 73: /* Line 1455 of yacc.c */ -#line 460 "parser.y" +#line 459 "parser.y" { (yyval.case_list) = case_list_add(ctx, (yyvsp[(1) - (2)].case_list), (yyvsp[(2) - (2)].case_clausule)); ;} break; case 74: /* Line 1455 of yacc.c */ -#line 465 "parser.y" +#line 464 "parser.y" { (yyval.case_clausule) = new_case_clausule(ctx, (yyvsp[(2) - (4)].expr), (yyvsp[(4) - (4)].statement_list)); ;} break; case 75: /* Line 1455 of yacc.c */ -#line 470 "parser.y" +#line 469 "parser.y" { (yyval.case_clausule) = new_case_clausule(ctx, NULL, (yyvsp[(3) - (3)].statement_list)); ;} break; case 76: /* Line 1455 of yacc.c */ -#line 475 "parser.y" +#line 474 "parser.y" { (yyval.statement) = new_throw_statement(ctx, (yyvsp[(2) - (3)].expr)); ;} break; case 77: /* Line 1455 of yacc.c */ -#line 479 "parser.y" +#line 478 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (3)].statement), (yyvsp[(3) - (3)].catch_block), NULL); ;} break; case 78: /* Line 1455 of yacc.c */ -#line 480 "parser.y" +#line 479 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (3)].statement), NULL, (yyvsp[(3) - (3)].statement)); ;} break; case 79: /* Line 1455 of yacc.c */ -#line 482 "parser.y" +#line 481 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (4)].statement), (yyvsp[(3) - (4)].catch_block), (yyvsp[(4) - (4)].statement)); ;} break; case 80: /* Line 1455 of yacc.c */ -#line 487 "parser.y" +#line 486 "parser.y" { (yyval.catch_block) = new_catch_block(ctx, (yyvsp[(3) - (5)].identifier), (yyvsp[(5) - (5)].statement)); ;} break; case 81: /* Line 1455 of yacc.c */ -#line 491 "parser.y" +#line 490 "parser.y" { (yyval.statement) = (yyvsp[(2) - (2)].statement); ;} break; case 82: /* Line 1455 of yacc.c */ -#line 495 "parser.y" +#line 494 "parser.y" { (yyval.expr) = NULL; ;} break; case 83: /* Line 1455 of yacc.c */ -#line 496 "parser.y" +#line 495 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 84: /* Line 1455 of yacc.c */ -#line 499 "parser.y" +#line 498 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 85: /* Line 1455 of yacc.c */ -#line 500 "parser.y" +#line 499 "parser.y" { set_error(ctx, IDS_SYNTAX_ERROR); YYABORT; ;} break; case 86: /* Line 1455 of yacc.c */ -#line 504 "parser.y" +#line 503 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 87: /* Line 1455 of yacc.c */ -#line 506 "parser.y" +#line 505 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_COMMA, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 88: /* Line 1455 of yacc.c */ -#line 510 "parser.y" +#line 509 "parser.y" { (yyval.expr) = NULL; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 511 "parser.y" +#line 510 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 90: /* Line 1455 of yacc.c */ -#line 516 "parser.y" +#line 515 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 91: /* Line 1455 of yacc.c */ -#line 518 "parser.y" +#line 517 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_COMMA, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 92: /* Line 1455 of yacc.c */ -#line 521 "parser.y" +#line 520 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} break; case 93: /* Line 1455 of yacc.c */ -#line 522 "parser.y" +#line 521 "parser.y" { (yyval.ival) = EXPR_ASSIGNDIV; ;} break; case 94: /* Line 1455 of yacc.c */ -#line 526 "parser.y" +#line 525 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 95: /* Line 1455 of yacc.c */ -#line 528 "parser.y" +#line 527 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ASSIGN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 96: /* Line 1455 of yacc.c */ -#line 530 "parser.y" +#line 529 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 97: /* Line 1455 of yacc.c */ -#line 535 "parser.y" +#line 534 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 98: /* Line 1455 of yacc.c */ -#line 537 "parser.y" +#line 536 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ASSIGN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 99: /* Line 1455 of yacc.c */ -#line 539 "parser.y" +#line 538 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 100: /* Line 1455 of yacc.c */ -#line 543 "parser.y" +#line 542 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 101: /* Line 1455 of yacc.c */ -#line 545 "parser.y" +#line 544 "parser.y" { (yyval.expr) = new_conditional_expression(ctx, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} break; case 102: /* Line 1455 of yacc.c */ -#line 550 "parser.y" +#line 549 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 103: /* Line 1455 of yacc.c */ -#line 552 "parser.y" +#line 551 "parser.y" { (yyval.expr) = new_conditional_expression(ctx, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} break; case 104: /* Line 1455 of yacc.c */ -#line 556 "parser.y" +#line 555 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 105: /* Line 1455 of yacc.c */ -#line 558 "parser.y" +#line 557 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 106: /* Line 1455 of yacc.c */ -#line 563 "parser.y" +#line 562 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 107: /* Line 1455 of yacc.c */ -#line 565 "parser.y" +#line 564 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 108: /* Line 1455 of yacc.c */ -#line 569 "parser.y" +#line 568 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 109: /* Line 1455 of yacc.c */ -#line 571 "parser.y" +#line 570 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 110: /* Line 1455 of yacc.c */ -#line 576 "parser.y" +#line 575 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 111: /* Line 1455 of yacc.c */ -#line 578 "parser.y" +#line 577 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 112: /* Line 1455 of yacc.c */ -#line 582 "parser.y" +#line 581 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 113: /* Line 1455 of yacc.c */ -#line 584 "parser.y" +#line 583 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 114: /* Line 1455 of yacc.c */ -#line 589 "parser.y" +#line 588 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 115: /* Line 1455 of yacc.c */ -#line 591 "parser.y" +#line 590 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 116: /* Line 1455 of yacc.c */ -#line 595 "parser.y" +#line 594 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 117: /* Line 1455 of yacc.c */ -#line 597 "parser.y" +#line 596 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BXOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 118: /* Line 1455 of yacc.c */ -#line 602 "parser.y" +#line 601 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 119: /* Line 1455 of yacc.c */ -#line 604 "parser.y" +#line 603 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BXOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 120: /* Line 1455 of yacc.c */ -#line 608 "parser.y" +#line 607 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 121: /* Line 1455 of yacc.c */ -#line 610 "parser.y" +#line 609 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 122: /* Line 1455 of yacc.c */ -#line 615 "parser.y" +#line 614 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 123: /* Line 1455 of yacc.c */ -#line 617 "parser.y" +#line 616 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 124: /* Line 1455 of yacc.c */ -#line 621 "parser.y" +#line 620 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 125: /* Line 1455 of yacc.c */ -#line 623 "parser.y" +#line 622 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 126: /* Line 1455 of yacc.c */ -#line 627 "parser.y" +#line 626 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 127: /* Line 1455 of yacc.c */ -#line 629 "parser.y" +#line 628 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 128: /* Line 1455 of yacc.c */ -#line 633 "parser.y" +#line 632 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 129: /* Line 1455 of yacc.c */ -#line 635 "parser.y" +#line 634 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 130: /* Line 1455 of yacc.c */ -#line 637 "parser.y" +#line 636 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_INSTANCEOF, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 131: /* Line 1455 of yacc.c */ -#line 639 "parser.y" +#line 638 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_IN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 132: /* Line 1455 of yacc.c */ -#line 643 "parser.y" +#line 642 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 133: /* Line 1455 of yacc.c */ -#line 645 "parser.y" +#line 644 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 134: /* Line 1455 of yacc.c */ -#line 647 "parser.y" +#line 646 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_INSTANCEOF, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 135: /* Line 1455 of yacc.c */ -#line 651 "parser.y" +#line 650 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 136: /* Line 1455 of yacc.c */ -#line 653 "parser.y" +#line 652 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 137: /* Line 1455 of yacc.c */ -#line 658 "parser.y" +#line 657 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 138: /* Line 1455 of yacc.c */ -#line 660 "parser.y" +#line 659 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ADD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 139: /* Line 1455 of yacc.c */ -#line 662 "parser.y" +#line 661 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_SUB, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 140: /* Line 1455 of yacc.c */ -#line 666 "parser.y" +#line 665 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 141: /* Line 1455 of yacc.c */ -#line 668 "parser.y" +#line 667 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_MUL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 142: /* Line 1455 of yacc.c */ -#line 670 "parser.y" +#line 669 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_DIV, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 143: /* Line 1455 of yacc.c */ -#line 672 "parser.y" +#line 671 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_MOD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 144: /* Line 1455 of yacc.c */ -#line 676 "parser.y" +#line 675 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 145: /* Line 1455 of yacc.c */ -#line 678 "parser.y" +#line 677 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_DELETE, (yyvsp[(2) - (2)].expr)); ;} break; case 146: /* Line 1455 of yacc.c */ -#line 679 "parser.y" +#line 678 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_VOID, (yyvsp[(2) - (2)].expr)); ;} break; case 147: /* Line 1455 of yacc.c */ -#line 681 "parser.y" +#line 680 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_TYPEOF, (yyvsp[(2) - (2)].expr)); ;} break; case 148: /* Line 1455 of yacc.c */ -#line 682 "parser.y" +#line 681 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PREINC, (yyvsp[(2) - (2)].expr)); ;} break; case 149: /* Line 1455 of yacc.c */ -#line 683 "parser.y" +#line 682 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PREDEC, (yyvsp[(2) - (2)].expr)); ;} break; case 150: /* Line 1455 of yacc.c */ -#line 684 "parser.y" +#line 683 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PLUS, (yyvsp[(2) - (2)].expr)); ;} break; case 151: /* Line 1455 of yacc.c */ -#line 685 "parser.y" +#line 684 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_MINUS, (yyvsp[(2) - (2)].expr)); ;} break; case 152: /* Line 1455 of yacc.c */ -#line 686 "parser.y" +#line 685 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_BITNEG, (yyvsp[(2) - (2)].expr)); ;} break; case 153: /* Line 1455 of yacc.c */ -#line 687 "parser.y" +#line 686 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_LOGNEG, (yyvsp[(2) - (2)].expr)); ;} break; case 154: /* Line 1455 of yacc.c */ -#line 692 "parser.y" +#line 691 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 155: /* Line 1455 of yacc.c */ -#line 694 "parser.y" +#line 693 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_POSTINC, (yyvsp[(1) - (2)].expr)); ;} break; case 156: /* Line 1455 of yacc.c */ -#line 696 "parser.y" +#line 695 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_POSTDEC, (yyvsp[(1) - (2)].expr)); ;} break; case 157: /* Line 1455 of yacc.c */ -#line 701 "parser.y" +#line 700 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 158: /* Line 1455 of yacc.c */ -#line 702 "parser.y" +#line 701 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 159: /* Line 1455 of yacc.c */ -#line 706 "parser.y" +#line 705 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 160: /* Line 1455 of yacc.c */ -#line 707 "parser.y" +#line 706 "parser.y" { (yyval.expr) = new_new_expression(ctx, (yyvsp[(2) - (2)].expr), NULL); ;} break; case 161: /* Line 1455 of yacc.c */ -#line 711 "parser.y" +#line 710 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 162: /* Line 1455 of yacc.c */ -#line 712 "parser.y" +#line 711 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 163: /* Line 1455 of yacc.c */ -#line 714 "parser.y" +#line 713 "parser.y" { (yyval.expr) = new_array_expression(ctx, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} break; case 164: /* Line 1455 of yacc.c */ -#line 716 "parser.y" +#line 715 "parser.y" { (yyval.expr) = new_member_expression(ctx, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].identifier)); ;} break; case 165: /* Line 1455 of yacc.c */ -#line 718 "parser.y" +#line 717 "parser.y" { (yyval.expr) = new_new_expression(ctx, (yyvsp[(2) - (3)].expr), (yyvsp[(3) - (3)].argument_list)); ;} break; case 166: /* Line 1455 of yacc.c */ -#line 723 "parser.y" +#line 722 "parser.y" { (yyval.expr) = new_call_expression(ctx, (yyvsp[(1) - (2)].expr), (yyvsp[(2) - (2)].argument_list)); ;} break; case 167: /* Line 1455 of yacc.c */ -#line 725 "parser.y" +#line 724 "parser.y" { (yyval.expr) = new_call_expression(ctx, (yyvsp[(1) - (2)].expr), (yyvsp[(2) - (2)].argument_list)); ;} break; case 168: /* Line 1455 of yacc.c */ -#line 727 "parser.y" +#line 726 "parser.y" { (yyval.expr) = new_array_expression(ctx, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} break; case 169: /* Line 1455 of yacc.c */ -#line 729 "parser.y" +#line 728 "parser.y" { (yyval.expr) = new_member_expression(ctx, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].identifier)); ;} break; case 170: /* Line 1455 of yacc.c */ -#line 733 "parser.y" +#line 732 "parser.y" { (yyval.argument_list) = NULL; ;} break; case 171: /* Line 1455 of yacc.c */ -#line 734 "parser.y" +#line 733 "parser.y" { (yyval.argument_list) = (yyvsp[(2) - (3)].argument_list); ;} break; case 172: /* Line 1455 of yacc.c */ -#line 738 "parser.y" +#line 737 "parser.y" { (yyval.argument_list) = new_argument_list(ctx, (yyvsp[(1) - (1)].expr)); ;} break; case 173: /* Line 1455 of yacc.c */ -#line 740 "parser.y" +#line 739 "parser.y" { (yyval.argument_list) = argument_list_add(ctx, (yyvsp[(1) - (3)].argument_list), (yyvsp[(3) - (3)].expr)); ;} break; case 174: /* Line 1455 of yacc.c */ -#line 744 "parser.y" +#line 743 "parser.y" { (yyval.expr) = new_this_expression(ctx); ;} break; case 175: /* Line 1455 of yacc.c */ -#line 745 "parser.y" +#line 744 "parser.y" { (yyval.expr) = new_identifier_expression(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 176: /* Line 1455 of yacc.c */ -#line 746 "parser.y" +#line 745 "parser.y" { (yyval.expr) = new_literal_expression(ctx, (yyvsp[(1) - (1)].literal)); ;} break; case 177: /* Line 1455 of yacc.c */ -#line 747 "parser.y" +#line 746 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 178: /* Line 1455 of yacc.c */ -#line 748 "parser.y" +#line 747 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 179: /* Line 1455 of yacc.c */ -#line 749 "parser.y" +#line 748 "parser.y" { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} break; case 180: /* Line 1455 of yacc.c */ -#line 753 "parser.y" +#line 752 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, NULL, 0); ;} break; case 181: /* Line 1455 of yacc.c */ -#line 754 "parser.y" +#line 753 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, NULL, (yyvsp[(2) - (3)].ival)+1); ;} break; case 182: /* Line 1455 of yacc.c */ -#line 755 "parser.y" +#line 754 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, (yyvsp[(2) - (3)].element_list), 0); ;} break; case 183: /* Line 1455 of yacc.c */ -#line 757 "parser.y" +#line 756 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, (yyvsp[(2) - (5)].element_list), (yyvsp[(4) - (5)].ival)+1); ;} break; case 184: /* Line 1455 of yacc.c */ -#line 762 "parser.y" +#line 761 "parser.y" { (yyval.element_list) = new_element_list(ctx, (yyvsp[(1) - (2)].ival), (yyvsp[(2) - (2)].expr)); ;} break; case 185: /* Line 1455 of yacc.c */ -#line 764 "parser.y" +#line 763 "parser.y" { (yyval.element_list) = element_list_add(ctx, (yyvsp[(1) - (4)].element_list), (yyvsp[(3) - (4)].ival), (yyvsp[(4) - (4)].expr)); ;} break; case 186: /* Line 1455 of yacc.c */ -#line 768 "parser.y" +#line 767 "parser.y" { (yyval.ival) = 1; ;} break; case 187: /* Line 1455 of yacc.c */ -#line 769 "parser.y" +#line 768 "parser.y" { (yyval.ival) = (yyvsp[(1) - (2)].ival) + 1; ;} break; case 188: /* Line 1455 of yacc.c */ -#line 773 "parser.y" +#line 772 "parser.y" { (yyval.ival) = 0; ;} break; case 189: /* Line 1455 of yacc.c */ -#line 774 "parser.y" +#line 773 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} break; case 190: /* Line 1455 of yacc.c */ -#line 778 "parser.y" +#line 777 "parser.y" { (yyval.expr) = new_prop_and_value_expression(ctx, NULL); ;} break; case 191: /* Line 1455 of yacc.c */ -#line 780 "parser.y" +#line 779 "parser.y" { (yyval.expr) = new_prop_and_value_expression(ctx, (yyvsp[(2) - (3)].property_list)); ;} break; case 192: /* Line 1455 of yacc.c */ -#line 785 "parser.y" +#line 784 "parser.y" { (yyval.property_list) = new_property_list(ctx, (yyvsp[(1) - (3)].literal), (yyvsp[(3) - (3)].expr)); ;} break; case 193: /* Line 1455 of yacc.c */ -#line 787 "parser.y" +#line 786 "parser.y" { (yyval.property_list) = property_list_add(ctx, (yyvsp[(1) - (5)].property_list), (yyvsp[(3) - (5)].literal), (yyvsp[(5) - (5)].expr)); ;} break; case 194: /* Line 1455 of yacc.c */ -#line 791 "parser.y" +#line 790 "parser.y" { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 195: /* Line 1455 of yacc.c */ -#line 792 "parser.y" +#line 791 "parser.y" { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} break; case 196: /* Line 1455 of yacc.c */ -#line 793 "parser.y" +#line 792 "parser.y" { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 197: /* Line 1455 of yacc.c */ -#line 797 "parser.y" +#line 796 "parser.y" { (yyval.identifier) = NULL; ;} break; case 198: /* Line 1455 of yacc.c */ -#line 798 "parser.y" +#line 797 "parser.y" { (yyval.identifier) = (yyvsp[(1) - (1)].identifier); ;} break; case 199: /* Line 1455 of yacc.c */ -#line 802 "parser.y" +#line 801 "parser.y" { (yyval.literal) = new_null_literal(ctx); ;} break; case 200: /* Line 1455 of yacc.c */ -#line 803 "parser.y" - { (yyval.literal) = new_undefined_literal(ctx); ;} +#line 802 "parser.y" + { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 201: /* Line 1455 of yacc.c */ -#line 804 "parser.y" +#line 803 "parser.y" { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 202: /* Line 1455 of yacc.c */ -#line 805 "parser.y" - { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} +#line 804 "parser.y" + { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} break; case 203: /* Line 1455 of yacc.c */ -#line 806 "parser.y" - { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} +#line 805 "parser.y" + { (yyval.literal) = parse_regexp(ctx); + if(!(yyval.literal)) YYABORT; ;} break; case 204: @@ -3455,57 +3451,49 @@ yyreduce: case 205: /* Line 1455 of yacc.c */ -#line 809 "parser.y" - { (yyval.literal) = parse_regexp(ctx); - if(!(yyval.literal)) YYABORT; ;} +#line 812 "parser.y" + { (yyval.literal) = new_boolean_literal(ctx, VARIANT_TRUE); ;} break; case 206: /* Line 1455 of yacc.c */ -#line 814 "parser.y" - { (yyval.literal) = new_boolean_literal(ctx, VARIANT_TRUE); ;} - break; - - case 207: - -/* Line 1455 of yacc.c */ -#line 815 "parser.y" +#line 813 "parser.y" { (yyval.literal) = new_boolean_literal(ctx, VARIANT_FALSE); ;} break; - case 209: + case 208: /* Line 1455 of yacc.c */ -#line 819 "parser.y" +#line 817 "parser.y" { if(!allow_auto_semicolon(ctx)) {YYABORT;} ;} break; - case 211: + case 210: /* Line 1455 of yacc.c */ -#line 823 "parser.y" +#line 821 "parser.y" { set_error(ctx, IDS_LBRACKET); YYABORT; ;} break; - case 213: + case 212: /* Line 1455 of yacc.c */ -#line 827 "parser.y" +#line 825 "parser.y" { set_error(ctx, IDS_RBRACKET); YYABORT; ;} break; - case 215: + case 214: /* Line 1455 of yacc.c */ -#line 831 "parser.y" +#line 829 "parser.y" { set_error(ctx, IDS_SEMICOLON); YYABORT; ;} break; /* Line 1455 of yacc.c */ -#line 3509 "parser.tab.c" +#line 3497 "parser.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -3717,7 +3705,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 833 "parser.y" +#line 831 "parser.y" static BOOL allow_auto_semicolon(parser_ctx_t *ctx) @@ -3729,7 +3717,7 @@ static literal_t *new_string_literal(parser_ctx_t *ctx, const WCHAR *str) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BSTR; + ret->type = LT_STRING; ret->u.wstr = str; return ret; @@ -3739,16 +3727,7 @@ static literal_t *new_null_literal(parser_ctx_t *ctx) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_NULL; - - return ret; -} - -static literal_t *new_undefined_literal(parser_ctx_t *ctx) -{ - literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - - ret->vt = VT_EMPTY; + ret->type = LT_NULL; return ret; } @@ -3757,7 +3736,7 @@ static literal_t *new_boolean_literal(parser_ctx_t *ctx, VARIANT_BOOL bval) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BOOL; + ret->type = LT_BOOL; ret->u.bval = bval; return ret; @@ -4479,14 +4458,11 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source) void parser_release(parser_ctx_t *ctx) { - obj_literal_t *iter; - if(--ctx->ref) return; - for(iter = ctx->obj_literals; iter; iter = iter->next) - jsdisp_release(iter->obj); - + script_release(ctx->script); + heap_free(ctx->begin); jsheap_free(&ctx->heap); heap_free(ctx); } @@ -4508,8 +4484,14 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite parser_ctx->hres = JSCRIPT_ERROR|IDS_SYNTAX_ERROR; parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW); - parser_ctx->begin = parser_ctx->ptr = code; - parser_ctx->end = code + strlenW(code); + parser_ctx->begin = heap_strdupW(code); + if(!parser_ctx->begin) { + heap_free(parser_ctx); + return E_OUTOFMEMORY; + } + + parser_ctx->ptr = parser_ctx->begin; + parser_ctx->end = parser_ctx->begin + strlenW(parser_ctx->begin); script_addref(ctx); parser_ctx->script = ctx; diff --git a/reactos/dll/win32/jscript/parser.tab.h b/reactos/dll/win32/jscript/parser.tab.h index deed458a2f6..cdc4c1c2851 100644 --- a/reactos/dll/win32/jscript/parser.tab.h +++ b/reactos/dll/win32/jscript/parser.tab.h @@ -54,34 +54,33 @@ kINSTANCEOF = 270, kNEW = 271, kNULL = 272, - kUNDEFINED = 273, - kRETURN = 274, - kSWITCH = 275, - kTHIS = 276, - kTHROW = 277, - kTRUE = 278, - kFALSE = 279, - kTRY = 280, - kTYPEOF = 281, - kVAR = 282, - kVOID = 283, - kWHILE = 284, - kWITH = 285, - tANDAND = 286, - tOROR = 287, - tINC = 288, - tDEC = 289, - tHTMLCOMMENT = 290, - kDIVEQ = 291, - kFUNCTION = 292, - tIdentifier = 293, - tAssignOper = 294, - tEqOper = 295, - tShiftOper = 296, - tRelOper = 297, - tNumericLiteral = 298, - tStringLiteral = 299, - LOWER_THAN_ELSE = 300 + kRETURN = 273, + kSWITCH = 274, + kTHIS = 275, + kTHROW = 276, + kTRUE = 277, + kFALSE = 278, + kTRY = 279, + kTYPEOF = 280, + kVAR = 281, + kVOID = 282, + kWHILE = 283, + kWITH = 284, + tANDAND = 285, + tOROR = 286, + tINC = 287, + tDEC = 288, + tHTMLCOMMENT = 289, + kDIVEQ = 290, + kFUNCTION = 291, + tIdentifier = 292, + tAssignOper = 293, + tEqOper = 294, + tShiftOper = 295, + tRelOper = 296, + tNumericLiteral = 297, + tStringLiteral = 298, + LOWER_THAN_ELSE = 299 }; #endif @@ -92,7 +91,7 @@ typedef union YYSTYPE { /* Line 1676 of yacc.c */ -#line 151 "parser.y" +#line 150 "parser.y" int ival; const WCHAR *srcptr; @@ -116,7 +115,7 @@ typedef union YYSTYPE /* Line 1676 of yacc.c */ -#line 120 "parser.tab.h" +#line 119 "parser.tab.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/reactos/dll/win32/jscript/parser.y b/reactos/dll/win32/jscript/parser.y index d4b49089424..f062cd0117d 100644 --- a/reactos/dll/win32/jscript/parser.y +++ b/reactos/dll/win32/jscript/parser.y @@ -38,7 +38,6 @@ typedef struct _statement_list_t { static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*); static literal_t *new_null_literal(parser_ctx_t*); -static literal_t *new_undefined_literal(parser_ctx_t*); static literal_t *new_boolean_literal(parser_ctx_t*,VARIANT_BOOL); typedef struct _property_list_t { @@ -171,7 +170,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state /* keywords */ %token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN -%token kINSTANCEOF kNEW kNULL kUNDEFINED kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH +%token kINSTANCEOF kNEW kNULL kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH %token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ %token kFUNCTION '}' @@ -800,7 +799,6 @@ Identifier_opt /* ECMA-262 3rd Edition 7.8 */ Literal : kNULL { $$ = new_null_literal(ctx); } - | kUNDEFINED { $$ = new_undefined_literal(ctx); } | BooleanLiteral { $$ = $1; } | tNumericLiteral { $$ = $1; } | tStringLiteral { $$ = new_string_literal(ctx, $1); } @@ -841,7 +839,7 @@ static literal_t *new_string_literal(parser_ctx_t *ctx, const WCHAR *str) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BSTR; + ret->type = LT_STRING; ret->u.wstr = str; return ret; @@ -851,16 +849,7 @@ static literal_t *new_null_literal(parser_ctx_t *ctx) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_NULL; - - return ret; -} - -static literal_t *new_undefined_literal(parser_ctx_t *ctx) -{ - literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - - ret->vt = VT_EMPTY; + ret->type = LT_NULL; return ret; } @@ -869,7 +858,7 @@ static literal_t *new_boolean_literal(parser_ctx_t *ctx, VARIANT_BOOL bval) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BOOL; + ret->type = LT_BOOL; ret->u.bval = bval; return ret; @@ -1591,14 +1580,11 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source) void parser_release(parser_ctx_t *ctx) { - obj_literal_t *iter; - if(--ctx->ref) return; - for(iter = ctx->obj_literals; iter; iter = iter->next) - jsdisp_release(iter->obj); - + script_release(ctx->script); + heap_free(ctx->begin); jsheap_free(&ctx->heap); heap_free(ctx); } @@ -1620,8 +1606,14 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite parser_ctx->hres = JSCRIPT_ERROR|IDS_SYNTAX_ERROR; parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW); - parser_ctx->begin = parser_ctx->ptr = code; - parser_ctx->end = code + strlenW(code); + parser_ctx->begin = heap_strdupW(code); + if(!parser_ctx->begin) { + heap_free(parser_ctx); + return E_OUTOFMEMORY; + } + + parser_ctx->ptr = parser_ctx->begin; + parser_ctx->end = parser_ctx->begin + strlenW(parser_ctx->begin); script_addref(ctx); parser_ctx->script = ctx; diff --git a/reactos/dll/win32/jscript/regexp.c b/reactos/dll/win32/jscript/regexp.c index e911d0f5fdf..04575458105 100644 --- a/reactos/dll/win32/jscript/regexp.c +++ b/reactos/dll/win32/jscript/regexp.c @@ -32,6 +32,7 @@ */ #include +#include #include "jscript.h" @@ -82,7 +83,8 @@ typedef struct { JSRegExp *jsregexp; BSTR str; - DWORD last_index; + INT last_index; + VARIANT last_index_var; } RegExpInstance; static const WCHAR sourceW[] = {'s','o','u','r','c','e',0}; @@ -3299,8 +3301,16 @@ static inline RegExpInstance *regexp_from_vdisp(vdisp_t *vdisp) return (RegExpInstance*)vdisp->u.jsdisp; } -static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, const WCHAR *str, DWORD len, - const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, match_result_t *ret) +static void set_last_index(RegExpInstance *This, DWORD last_index) +{ + This->last_index = last_index; + VariantClear(&This->last_index_var); + num_set_val(&This->last_index_var, last_index); +} + +static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, DWORD rem_flags, + const WCHAR *str, DWORD len, const WCHAR **cp, match_result_t **parens, DWORD *parens_size, + DWORD *parens_cnt, match_result_t *ret) { REMatchState *x, *result; REGlobalData gData; @@ -3325,8 +3335,11 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c return E_FAIL; } - if(!result) + if(!result) { + if(rem_flags & REM_RESET_INDEX) + set_last_index(regexp, 0); return S_FALSE; + } if(parens) { DWORD i; @@ -3347,8 +3360,13 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c *parens_cnt = regexp->jsregexp->parenCount; for(i=0; i < regexp->jsregexp->parenCount; i++) { - (*parens)[i].str = *cp + result->parens[i].index; - (*parens)[i].len = result->parens[i].length; + if(result->parens[i].index == -1) { + (*parens)[i].str = NULL; + (*parens)[i].len = 0; + }else { + (*parens)[i].str = *cp + result->parens[i].index; + (*parens)[i].len = result->parens[i].length; + } } } @@ -3356,23 +3374,25 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c *cp = result->cp; ret->str = result->cp-matchlen; ret->len = matchlen; + set_last_index(regexp, result->cp-str); return S_OK; } -HRESULT regexp_match_next(script_ctx_t *ctx, DispatchEx *dispex, BOOL gcheck, const WCHAR *str, DWORD len, - const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, match_result_t *ret) +HRESULT regexp_match_next(script_ctx_t *ctx, DispatchEx *dispex, DWORD rem_flags, const WCHAR *str, + DWORD len, const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, + match_result_t *ret) { RegExpInstance *regexp = (RegExpInstance*)dispex; jsheap_t *mark; HRESULT hres; - if(gcheck && !(regexp->jsregexp->flags & JSREG_GLOB)) + if((rem_flags & REM_CHECK_GLOBAL) && !(regexp->jsregexp->flags & JSREG_GLOB)) return S_FALSE; mark = jsheap_mark(&ctx->tmp_heap); - hres = do_regexp_match_next(ctx, regexp, str, len, cp, parens, parens_size, parens_cnt, ret); + hres = do_regexp_match_next(ctx, regexp, rem_flags, str, len, cp, parens, parens_size, parens_cnt, ret); jsheap_clear(mark); return hres; @@ -3391,7 +3411,7 @@ HRESULT regexp_match(script_ctx_t *ctx, DispatchEx *dispex, const WCHAR *str, DW mark = jsheap_mark(&ctx->tmp_heap); while(1) { - hres = do_regexp_match_next(ctx, This, str, len, &cp, NULL, NULL, NULL, &cres); + hres = do_regexp_match_next(ctx, This, 0, str, len, &cp, NULL, NULL, NULL, &cres); if(hres == S_FALSE) { hres = S_OK; break; @@ -3474,6 +3494,27 @@ static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return E_NOTIMPL; } +static INT index_from_var(script_ctx_t *ctx, VARIANT *v) +{ + jsexcept_t ei; + VARIANT num; + HRESULT hres; + + memset(&ei, 0, sizeof(ei)); + hres = to_number(ctx, v, &ei, &num); + if(FAILED(hres)) { /* FIXME: Move ignoring exceptions to to_promitive */ + VariantClear(&ei.var); + return 0; + } + + if(V_VT(&num) == VT_R8) { + DOUBLE d = floor(V_R8(&num)); + return (DOUBLE)(INT)d == d ? d : 0; + } + + return V_I4(&num); +} + static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { @@ -3482,8 +3523,21 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, switch(flags) { case DISPATCH_PROPERTYGET: { RegExpInstance *regexp = regexp_from_vdisp(jsthis); - V_VT(retv) = VT_I4; - V_I4(retv) = regexp->last_index; + + V_VT(retv) = VT_EMPTY; + return VariantCopy(retv, ®exp->last_index_var); + } + case DISPATCH_PROPERTYPUT: { + RegExpInstance *regexp = regexp_from_vdisp(jsthis); + VARIANT *arg; + HRESULT hres; + + arg = get_arg(dp,0); + hres = VariantCopy(®exp->last_index_var, arg); + if(FAILED(hres)) + return hres; + + regexp->last_index = index_from_var(ctx, arg); break; } default: @@ -3589,28 +3643,34 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce return E_OUTOFMEMORY; } + if(regexp->last_index < 0) { + SysFreeString(string); + set_last_index(regexp, 0); + *ret = VARIANT_FALSE; + if(input) { + *input = NULL; + } + return S_OK; + } + length = SysStringLen(string); if(regexp->jsregexp->flags & JSREG_GLOB) last_index = regexp->last_index; cp = string + last_index; - hres = regexp_match_next(ctx, ®exp->dispex, FALSE, string, length, &cp, parens, parens ? &parens_size : NULL, - parens_cnt, match); + hres = regexp_match_next(ctx, ®exp->dispex, REM_RESET_INDEX, string, length, &cp, parens, + parens ? &parens_size : NULL, parens_cnt, match); if(FAILED(hres)) { SysFreeString(string); return hres; } - if(hres == S_OK) { - regexp->last_index = cp-string; - *ret = VARIANT_TRUE; - }else { - regexp->last_index = 0; - *ret = VARIANT_FALSE; - } - - if(input) + *ret = hres == S_OK ? VARIANT_TRUE : VARIANT_FALSE; + if(input) { *input = string; + }else { + SysFreeString(string); + } return S_OK; } @@ -3690,6 +3750,7 @@ static void RegExp_destructor(DispatchEx *dispex) if(This->jsregexp) js_DestroyRegExp(This->jsregexp); + VariantClear(&This->last_index_var); SysFreeString(This->str); heap_free(This); } @@ -3737,7 +3798,7 @@ static HRESULT alloc_regexp(script_ctx_t *ctx, DispatchEx *object_prototype, Reg return S_OK; } -static HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags, DispatchEx **ret) +HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags, DispatchEx **ret) { RegExpInstance *regexp; HRESULT hres; @@ -3764,73 +3825,57 @@ static HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD return E_FAIL; } + V_VT(®exp->last_index_var) = VT_I4; + V_I4(®exp->last_index_var) = 0; + *ret = ®exp->dispex; return S_OK; } -static HRESULT regexp_constructor(script_ctx_t *ctx, DISPPARAMS *dp, VARIANT *retv) +HRESULT create_regexp_var(script_ctx_t *ctx, VARIANT *src_arg, VARIANT *flags_arg, DispatchEx **ret) { const WCHAR *opt = emptyW, *src; - DispatchEx *ret; - VARIANT *arg; + DWORD flags; HRESULT hres; - if(!arg_cnt(dp)) { - FIXME("no args\n"); - return E_NOTIMPL; - } - - arg = get_arg(dp,0); - if(V_VT(arg) == VT_DISPATCH) { + if(V_VT(src_arg) == VT_DISPATCH) { DispatchEx *obj; - obj = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); + obj = iface_to_jsdisp((IUnknown*)V_DISPATCH(src_arg)); if(obj) { if(is_class(obj, JSCLASS_REGEXP)) { RegExpInstance *regexp = (RegExpInstance*)obj; - hres = create_regexp(ctx, regexp->str, -1, regexp->jsregexp->flags, &ret); + hres = create_regexp(ctx, regexp->str, -1, regexp->jsregexp->flags, ret); jsdisp_release(obj); - if(FAILED(hres)) - return hres; - - V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); - return S_OK; + return hres; } jsdisp_release(obj); } } - if(V_VT(arg) != VT_BSTR) { - FIXME("vt arg0 = %d\n", V_VT(arg)); + if(V_VT(src_arg) != VT_BSTR) { + FIXME("flags_arg = %s\n", debugstr_variant(flags_arg)); return E_NOTIMPL; } - src = V_BSTR(arg); + src = V_BSTR(src_arg); - if(arg_cnt(dp) >= 2) { - arg = get_arg(dp,1); - if(V_VT(arg) != VT_BSTR) { - FIXME("unimplemented for vt %d\n", V_VT(arg)); + if(flags_arg) { + if(V_VT(flags_arg) != VT_BSTR) { + FIXME("unimplemented for vt %d\n", V_VT(flags_arg)); return E_NOTIMPL; } - opt = V_BSTR(arg); + opt = V_BSTR(flags_arg); } - hres = create_regexp_str(ctx, src, -1, opt, strlenW(opt), &ret); + hres = parse_regexp_flags(opt, strlenW(opt), &flags); if(FAILED(hres)) return hres; - if(retv) { - V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); - }else { - jsdisp_release(ret); - } - return S_OK; + return create_regexp(ctx, src, -1, flags, ret); } static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, @@ -3864,8 +3909,27 @@ static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } } /* fall through */ - case DISPATCH_CONSTRUCT: - return regexp_constructor(ctx, dp, retv); + case DISPATCH_CONSTRUCT: { + DispatchEx *ret; + HRESULT hres; + + if(!arg_cnt(dp)) { + FIXME("no args\n"); + return E_NOTIMPL; + } + + hres = create_regexp_var(ctx, get_arg(dp,0), arg_cnt(dp) > 1 ? get_arg(dp,1) : NULL, &ret); + if(FAILED(hres)) + return hres; + + if(retv) { + V_VT(retv) = VT_DISPATCH; + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); + }else { + jsdisp_release(ret); + } + return S_OK; + } default: FIXME("unimplemented flags: %x\n", flags); return E_NOTIMPL; @@ -3885,39 +3949,38 @@ HRESULT create_regexp_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, RegExpConstr_value, RegExpW, NULL, PROPF_CONSTR, ®exp->dispex, ret); + hres = create_builtin_function(ctx, RegExpConstr_value, RegExpW, NULL, + PROPF_CONSTR|2, ®exp->dispex, ret); jsdisp_release(®exp->dispex); return hres; } -HRESULT create_regexp_str(script_ctx_t *ctx, const WCHAR *exp, DWORD exp_len, const WCHAR *opt, - DWORD opt_len, DispatchEx **ret) +HRESULT parse_regexp_flags(const WCHAR *str, DWORD str_len, DWORD *ret) { const WCHAR *p; DWORD flags = 0; - if(opt) { - for (p = opt; p < opt+opt_len; p++) { - switch (*p) { - case 'g': - flags |= JSREG_GLOB; - break; - case 'i': - flags |= JSREG_FOLD; - break; - case 'm': - flags |= JSREG_MULTILINE; - break; - case 'y': - flags |= JSREG_STICKY; - break; - default: - WARN("wrong flag %c\n", *p); - return E_FAIL; - } + for (p = str; p < str+str_len; p++) { + switch (*p) { + case 'g': + flags |= JSREG_GLOB; + break; + case 'i': + flags |= JSREG_FOLD; + break; + case 'm': + flags |= JSREG_MULTILINE; + break; + case 'y': + flags |= JSREG_STICKY; + break; + default: + WARN("wrong flag %c\n", *p); + return E_FAIL; } } - return create_regexp(ctx, exp, exp_len, flags, ret); + *ret = flags; + return S_OK; } diff --git a/reactos/dll/win32/jscript/resource.h b/reactos/dll/win32/jscript/resource.h index 17c0df09f6d..b88621fb58c 100644 --- a/reactos/dll/win32/jscript/resource.h +++ b/reactos/dll/win32/jscript/resource.h @@ -37,5 +37,6 @@ #define IDS_NOT_BOOL 0x1392 #define IDS_JSCRIPT_EXPECTED 0x1396 #define IDS_REGEXP_SYNTAX_ERROR 0x1399 +#define IDS_URI_INVALID_CHAR 0x13A0 #define IDS_INVALID_LENGTH 0x13A5 #define IDS_ARRAY_EXPECTED 0x13A7 diff --git a/reactos/dll/win32/jscript/rsrc.rc b/reactos/dll/win32/jscript/rsrc.rc index d57f83c09dc..d23ea33a2f3 100644 --- a/reactos/dll/win32/jscript/rsrc.rc +++ b/reactos/dll/win32/jscript/rsrc.rc @@ -25,6 +25,8 @@ REGINST REGINST jscript.inf #include "jscript_De.rc" #include "jscript_En.rc" #include "jscript_Fr.rc" +#include "jscript_Ko.rc" #include "jscript_Lt.rc" #include "jscript_Nl.rc" #include "jscript_Pt.rc" +#include "jscript_Ru.rc" diff --git a/reactos/dll/win32/jscript/string.c b/reactos/dll/win32/jscript/string.c index 55b6b858fb6..df43fee27ed 100644 --- a/reactos/dll/win32/jscript/string.c +++ b/reactos/dll/win32/jscript/string.c @@ -656,7 +656,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(FAILED(hres)) return hres; - hres = create_regexp_str(ctx, match_str, SysStringLen(match_str), NULL, 0, ®exp); + hres = create_regexp(ctx, match_str, SysStringLen(match_str), 0, ®exp); SysFreeString(match_str); if(FAILED(hres)) return hres; @@ -703,6 +703,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP break; } + heap_free(match_result); SysFreeString(val_str); if(SUCCEEDED(hres) && retv) { @@ -795,7 +796,7 @@ static HRESULT rep_call(script_ctx_t *ctx, DispatchEx *func, const WCHAR *str, m if(SUCCEEDED(hres)) hres = jsdisp_call_value(func, DISPATCH_METHOD, &dp, &var, ei, caller); - for(i=0; i < parens_cnt+1; i++) { + for(i=0; i < parens_cnt+3; i++) { if(i != parens_cnt+1) SysFreeString(V_BSTR(get_arg(&dp,i))); } @@ -819,7 +820,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI DispatchEx *rep_func = NULL, *regexp = NULL; match_result_t *parens = NULL, match, **parens_ptr = &parens; strbuf_t ret = {NULL,0,0}; - BOOL gcheck = FALSE; + DWORD re_flags = 0; VARIANT *arg_var; HRESULT hres = S_OK; @@ -896,9 +897,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI while(1) { if(regexp) { - hres = regexp_match_next(ctx, regexp, gcheck, str, length, &cp, parens_ptr, + hres = regexp_match_next(ctx, regexp, re_flags, str, length, &cp, parens_ptr, &parens_size, &parens_cnt, &match); - gcheck = TRUE; + re_flags = REM_CHECK_GLOBAL; if(hres == S_FALSE) { hres = S_OK; @@ -965,7 +966,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI } idx = ptr2[1] - '0'; - if(isdigitW(ptr[3]) && idx*10 + (ptr[2]-'0') <= parens_cnt) { + if(isdigitW(ptr2[2]) && idx*10 + (ptr2[2]-'0') <= parens_cnt) { idx = idx*10 + (ptr[2]-'0'); ptr = ptr2+3; }else if(idx && idx <= parens_cnt) { @@ -1031,8 +1032,58 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + DispatchEx *regexp = NULL; + const WCHAR *str, *cp; + match_result_t match; + VARIANT *arg; + DWORD length; + BSTR val_str; + HRESULT hres; + + TRACE("\n"); + + hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); + if(FAILED(hres)) + return hres; + + if(!arg_cnt(dp)) { + if(retv) + V_VT(retv) = VT_NULL; + SysFreeString(val_str); + return S_OK; + } + + arg = get_arg(dp,0); + if(V_VT(arg) == VT_DISPATCH) { + regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); + if(regexp) { + if(!is_class(regexp, JSCLASS_REGEXP)) { + jsdisp_release(regexp); + regexp = NULL; + } + } + } + + if(!regexp) { + hres = create_regexp_var(ctx, arg, NULL, ®exp); + if(FAILED(hres)) { + SysFreeString(val_str); + return hres; + } + } + + cp = str; + hres = regexp_match_next(ctx, regexp, REM_RESET_INDEX, str, length, &cp, NULL, NULL, NULL, &match); + SysFreeString(val_str); + jsdisp_release(regexp); + if(FAILED(hres)) + return hres; + + if(retv) { + V_VT(retv) = VT_I4; + V_I4(retv) = hres == S_OK ? match.str-str : -1; + } + return S_OK; } /* ECMA-262 3rd Edition 15.5.4.13 */ @@ -1129,6 +1180,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP match_result_t *match_result = NULL; DWORD length, match_cnt, i, match_len = 0; const WCHAR *str, *ptr, *ptr2; + BOOL use_regexp = FALSE; VARIANT *arg, var; DispatchEx *array; BSTR val_str, match_str = NULL; @@ -1153,6 +1205,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); if(regexp) { if(is_class(regexp, JSCLASS_REGEXP)) { + use_regexp = TRUE; hres = regexp_match(ctx, regexp, str, length, TRUE, &match_result, &match_cnt); jsdisp_release(regexp); if(FAILED(hres)) { @@ -1183,7 +1236,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(SUCCEEDED(hres)) { ptr = str; for(i=0;; i++) { - if(match_result) { + if(use_regexp) { if(i == match_cnt) break; ptr2 = match_result[i].str; @@ -1209,7 +1262,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(FAILED(hres)) break; - if(match_result) + if(use_regexp) ptr = match_result[i].str + match_result[i].len; else if(match_str) ptr = ptr2 + match_len; @@ -1218,7 +1271,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP } } - if(SUCCEEDED(hres) && (match_str || match_result)) { + if(SUCCEEDED(hres) && (match_str || use_regexp)) { DWORD len = (str+length) - ptr; if(len || match_str) { @@ -1705,7 +1758,7 @@ HRESULT create_string_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di return hres; hres = create_builtin_function(ctx, StringConstr_value, StringW, &StringConstr_info, - PROPF_CONSTR, &string->dispex, ret); + PROPF_CONSTR|1, &string->dispex, ret); jsdisp_release(&string->dispex); return hres; From 86405be2d6d168bb110780912665823ca31f4c75 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 19:50:41 +0000 Subject: [PATCH 036/211] [PSDK] sync dispex.idl to wine 1.1.39 svn path=/trunk/; revision=45766 --- reactos/include/psdk/dispex.idl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/include/psdk/dispex.idl b/reactos/include/psdk/dispex.idl index b44448e84d9..b1759ddb890 100644 --- a/reactos/include/psdk/dispex.idl +++ b/reactos/include/psdk/dispex.idl @@ -23,6 +23,9 @@ import "oaidl.idl"; import "servprov.idl"; #endif +cpp_quote("DEFINE_GUID(SID_VariantConversion, 0x1f101481,0xbccd,0x11d0,0x93,0x36,0x00,0xa0,0xc9,0xd,0xca,0xa9);") +cpp_quote("DEFINE_GUID(SID_GetCaller, 0x4717cc40,0xbcb9,0x11d0,0x93,0x36,0x00,0xa0,0xc9,0xd,0xca,0xa9);") + cpp_quote("#define fdexNameCaseSensitive 0x00000001L") cpp_quote("#define fdexNameEnsure 0x00000002L") cpp_quote("#define fdexNameImplicit 0x00000004L") From c6658bfc8551321cc7743c99d86738eb4f16ffbc Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 19:52:22 +0000 Subject: [PATCH 037/211] [JSCRIPT_WINETEST] sync jscript_winetest to wine 1.1.39 svn path=/trunk/; revision=45767 --- rostests/winetests/jscript/activex.c | 1096 +++++++++++++++++++++ rostests/winetests/jscript/api.js | 247 ++++- rostests/winetests/jscript/jscript.c | 131 ++- rostests/winetests/jscript/jscript.rbuild | 4 +- rostests/winetests/jscript/lang.js | 55 ++ rostests/winetests/jscript/regexp.js | 162 ++- rostests/winetests/jscript/run.c | 153 ++- rostests/winetests/jscript/testlist.c | 2 + 8 files changed, 1782 insertions(+), 68 deletions(-) create mode 100644 rostests/winetests/jscript/activex.c diff --git a/rostests/winetests/jscript/activex.c b/rostests/winetests/jscript/activex.c new file mode 100644 index 00000000000..ba3f8bd2d76 --- /dev/null +++ b/rostests/winetests/jscript/activex.c @@ -0,0 +1,1096 @@ +/* + * Copyright 2009 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#define COBJMACROS +#define CONST_VTABLE + +#include +#include +#include +#include +#include +#include + +#include "wine/test.h" + +static const CLSID CLSID_JScript = + {0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}}; + +#define DEFINE_EXPECT(func) \ + static BOOL expect_ ## func = FALSE, called_ ## func = FALSE + +#define SET_EXPECT(func) \ + expect_ ## func = TRUE + +#define SET_CALLED(func) \ + called_ ## func = TRUE + +#define CHECK_EXPECT2(func) \ + do { \ + ok(expect_ ##func, "unexpected call " #func "\n"); \ + called_ ## func = TRUE; \ + }while(0) + +#define CHECK_EXPECT(func) \ + do { \ + CHECK_EXPECT2(func); \ + expect_ ## func = FALSE; \ + }while(0) + +#define CHECK_CALLED(func) \ + do { \ + ok(called_ ## func, "expected " #func "\n"); \ + expect_ ## func = called_ ## func = FALSE; \ + }while(0) + +DEFINE_EXPECT(CreateInstance); +DEFINE_EXPECT(ProcessUrlAction); +DEFINE_EXPECT(QueryCustomPolicy); +DEFINE_EXPECT(reportSuccess); +DEFINE_EXPECT(Host_QS_SecMgr); +DEFINE_EXPECT(Caller_QS_SecMgr); +DEFINE_EXPECT(QI_IObjectWithSite); +DEFINE_EXPECT(SetSite); + +static const WCHAR testW[] = {'t','e','s','t',0}; + +static HRESULT QS_SecMgr_hres; +static HRESULT ProcessUrlAction_hres; +static DWORD ProcessUrlAction_policy; +static HRESULT CreateInstance_hres; +static HRESULT QueryCustomPolicy_hres; +static DWORD QueryCustomPolicy_psize; +static DWORD QueryCustomPolicy_policy; +static HRESULT QI_IDispatch_hres; +static HRESULT SetSite_hres; + +#define TESTOBJ_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80646}" + +static const GUID CLSID_TestObj = + {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}}; + +/* Defined as extern in urlmon.idl, but not exported by uuid.lib */ +const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY = + {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}}; + +#define DISPID_TEST_REPORTSUCCESS 0x1000 + +#define DISPID_GLOBAL_OK 0x2000 + +static const char *debugstr_guid(REFIID riid) +{ + static char buf[50]; + + sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + riid->Data1, riid->Data2, riid->Data3, riid->Data4[0], + riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4], + riid->Data4[5], riid->Data4[6], riid->Data4[7]); + + return buf; +} + +static BSTR a2bstr(const char *str) +{ + BSTR ret; + int len; + + len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + ret = SysAllocStringLen(NULL, len-1); + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + + return ret; +} + +static int strcmp_wa(LPCWSTR strw, const char *stra) +{ + CHAR buf[512]; + WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0); + return lstrcmpA(buf, stra); +} + +static HRESULT WINAPI ObjectWithSite_QueryInterface(IObjectWithSite *iface, REFIID riid, void **ppv) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static ULONG WINAPI ObjectWithSite_AddRef(IObjectWithSite *iface) +{ + return 2; +} + +static ULONG WINAPI ObjectWithSite_Release(IObjectWithSite *iface) +{ + return 1; +} + +static HRESULT WINAPI ObjectWithSite_SetSite(IObjectWithSite *iface, IUnknown *pUnkSite) +{ + IServiceProvider *sp; + HRESULT hres; + + + CHECK_EXPECT(SetSite); + ok(pUnkSite != NULL, "pUnkSite == NULL\n"); + + hres = IUnknown_QueryInterface(pUnkSite, &IID_IServiceProvider, (void**)&sp); + ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres); + IServiceProvider_Release(sp); + + return SetSite_hres; +} + +static HRESULT WINAPI ObjectWithSite_GetSite(IObjectWithSite *iface, REFIID riid, void **ppvSite) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static const IObjectWithSiteVtbl ObjectWithSiteVtbl = { + ObjectWithSite_QueryInterface, + ObjectWithSite_AddRef, + ObjectWithSite_Release, + ObjectWithSite_SetSite, + ObjectWithSite_GetSite +}; + +static IObjectWithSite ObjectWithSite = { &ObjectWithSiteVtbl }; + +static IObjectWithSite *object_with_site; + +static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) +{ + *ppv = NULL; + + if(IsEqualGUID(riid, &IID_IUnknown)) { + *ppv = iface; + }else if(IsEqualGUID(riid, &IID_IDispatch) || IsEqualGUID(riid, &IID_IDispatchEx)) { + if(FAILED(QI_IDispatch_hres)) + return QI_IDispatch_hres; + *ppv = iface; + }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) { + CHECK_EXPECT(QI_IObjectWithSite); + *ppv = object_with_site; + }else { + return E_NOINTERFACE; + } + + return *ppv ? S_OK : E_NOINTERFACE; +} + +static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface) +{ + return 2; +} + +static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface) +{ + return 1; +} + +static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex) +{ + ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI Test_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid) +{ + if(!strcmp_wa(bstrName, "reportSuccess")) { + ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + *pid = DISPID_TEST_REPORTSUCCESS; + return S_OK; + } + + ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName)); + return E_NOTIMPL; +} + +static HRESULT WINAPI Test_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, + VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) +{ + switch(id) { + case DISPID_TEST_REPORTSUCCESS: + CHECK_EXPECT(reportSuccess); + + ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags); + ok(pdp != NULL, "pdp == NULL\n"); + ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n"); + ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs); + ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(!pvarRes, "pvarRes != NULL\n"); + ok(pei != NULL, "pei == NULL\n"); + break; + + default: + ok(0, "unexpected call\n"); + return E_NOTIMPL; + } + + return S_OK; +} + +static IDispatchExVtbl testObjVtbl = { + DispatchEx_QueryInterface, + DispatchEx_AddRef, + DispatchEx_Release, + DispatchEx_GetTypeInfoCount, + DispatchEx_GetTypeInfo, + DispatchEx_GetIDsOfNames, + DispatchEx_Invoke, + Test_GetDispID, + Test_InvokeEx, + DispatchEx_DeleteMemberByName, + DispatchEx_DeleteMemberByDispID, + DispatchEx_GetMemberProperties, + DispatchEx_GetMemberName, + DispatchEx_GetNextDispID, + DispatchEx_GetNameSpaceParent +}; + +static IDispatchEx testObj = { &testObjVtbl }; + +static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid) +{ + if(!strcmp_wa(bstrName, "ok")) { + ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + *pid = DISPID_GLOBAL_OK; + return S_OK; + } + + ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName)); + return E_NOTIMPL; +} + +static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, + VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) +{ + switch(id) { + case DISPID_GLOBAL_OK: + ok(wFlags == INVOKE_FUNC || wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags); + ok(pdp != NULL, "pdp == NULL\n"); + ok(pdp->rgvarg != NULL, "rgvarg == NULL\n"); + ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n"); + ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs); + ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(pei != NULL, "pei == NULL\n"); + + ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg)); + ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp->rgvarg)); + ok(V_BOOL(pdp->rgvarg+1), "%s\n", wine_dbgstr_w(V_BSTR(pdp->rgvarg))); + break; + + default: + ok(0, "unexpected call\n"); + return E_NOTIMPL; + } + + return S_OK; +} + +static IDispatchExVtbl globalObjVtbl = { + DispatchEx_QueryInterface, + DispatchEx_AddRef, + DispatchEx_Release, + DispatchEx_GetTypeInfoCount, + DispatchEx_GetTypeInfo, + DispatchEx_GetIDsOfNames, + DispatchEx_Invoke, + Global_GetDispID, + Global_InvokeEx, + DispatchEx_DeleteMemberByName, + DispatchEx_DeleteMemberByDispID, + DispatchEx_GetMemberProperties, + DispatchEx_GetMemberName, + DispatchEx_GetNextDispID, + DispatchEx_GetNameSpaceParent +}; + +static IDispatchEx globalObj = { &globalObjVtbl }; + +static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) +{ + if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) { + *ppv = iface; + return S_OK; + } + + /* TODO: IClassFactoryEx */ + *ppv = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface) +{ + return 2; +} + +static ULONG WINAPI ClassFactory_Release(IClassFactory *iface) +{ + return 1; +} + +static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv) +{ + CHECK_EXPECT(CreateInstance); + + ok(!outer, "outer = %p\n", outer); + ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid)); + + if(SUCCEEDED(CreateInstance_hres)) + *ppv = &testObj; + return CreateInstance_hres; +} + +static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock) +{ + ok(0, "unexpected call\n"); + return S_OK; +} + +static const IClassFactoryVtbl ClassFactoryVtbl = { + ClassFactory_QueryInterface, + ClassFactory_AddRef, + ClassFactory_Release, + ClassFactory_CreateInstance, + ClassFactory_LockServer +}; + +static IClassFactory activex_cf = { &ClassFactoryVtbl }; + +static HRESULT WINAPI InternetHostSecurityManager_QueryInterface(IInternetHostSecurityManager *iface, REFIID riid, void **ppv) +{ + ok(0, "unexpected call\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI InternetHostSecurityManager_AddRef(IInternetHostSecurityManager *iface) +{ + return 2; +} + +static ULONG WINAPI InternetHostSecurityManager_Release(IInternetHostSecurityManager *iface) +{ + return 1; +} + +static HRESULT WINAPI InternetHostSecurityManager_GetSecurityId(IInternetHostSecurityManager *iface, BYTE *pbSecurityId, + DWORD *pcbSecurityId, DWORD_PTR dwReserved) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI InternetHostSecurityManager_ProcessUrlAction(IInternetHostSecurityManager *iface, DWORD dwAction, + BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved) +{ + CHECK_EXPECT(ProcessUrlAction); + + ok(dwAction == URLACTION_ACTIVEX_RUN, "dwAction = %x\n", dwAction); + ok(pPolicy != NULL, "pPolicy == NULL\n"); + ok(cbPolicy == sizeof(DWORD), "cbPolicy = %d\n", cbPolicy); + ok(pContext != NULL, "pContext == NULL\n"); + ok(cbContext == sizeof(GUID), "cbContext = %d\n", cbContext); + ok(IsEqualGUID(pContext, &CLSID_TestObj), "pContext = %s\n", debugstr_guid((const IID*)pContext)); + ok(!dwFlags, "dwFlags = %x\n", dwFlags); + ok(!dwReserved, "dwReserved = %x\n", dwReserved); + + if(SUCCEEDED(ProcessUrlAction_hres)) + *(DWORD*)pPolicy = ProcessUrlAction_policy; + return ProcessUrlAction_hres; +} + +static HRESULT WINAPI InternetHostSecurityManager_QueryCustomPolicy(IInternetHostSecurityManager *iface, REFGUID guidKey, + BYTE **ppPolicy, DWORD *pcbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwReserved) +{ + const struct CONFIRMSAFETY *cs = (const struct CONFIRMSAFETY*)pContext; + DWORD *ret; + + CHECK_EXPECT(QueryCustomPolicy); + + ok(IsEqualGUID(&GUID_CUSTOM_CONFIRMOBJECTSAFETY, guidKey), "guidKey = %s\n", debugstr_guid(guidKey)); + + ok(ppPolicy != NULL, "ppPolicy == NULL\n"); + ok(pcbPolicy != NULL, "pcbPolicy == NULL\n"); + ok(pContext != NULL, "pContext == NULL\n"); + ok(cbContext == sizeof(struct CONFIRMSAFETY), "cbContext = %d\n", cbContext); + ok(!dwReserved, "dwReserved = %x\n", dwReserved); + + /* TODO: CLSID */ + ok(cs->pUnk != NULL, "cs->pUnk == NULL\n"); + ok(!cs->dwFlags, "dwFlags = %x\n", cs->dwFlags); + + if(FAILED(QueryCustomPolicy_hres)) + return QueryCustomPolicy_hres; + + ret = CoTaskMemAlloc(QueryCustomPolicy_psize); + *ppPolicy = (BYTE*)ret; + *pcbPolicy = QueryCustomPolicy_psize; + memset(ret, 0, QueryCustomPolicy_psize); + if(QueryCustomPolicy_psize >= sizeof(DWORD)) + *ret = QueryCustomPolicy_policy; + + return QueryCustomPolicy_hres; +} + +static const IInternetHostSecurityManagerVtbl InternetHostSecurityManagerVtbl = { + InternetHostSecurityManager_QueryInterface, + InternetHostSecurityManager_AddRef, + InternetHostSecurityManager_Release, + InternetHostSecurityManager_GetSecurityId, + InternetHostSecurityManager_ProcessUrlAction, + InternetHostSecurityManager_QueryCustomPolicy +}; + +static IInternetHostSecurityManager InternetHostSecurityManager = { &InternetHostSecurityManagerVtbl }; + +static IServiceProvider ServiceProvider; + +static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv) +{ + ok(0, "unexpected call\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface) +{ + return 2; +} + +static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface) +{ + return 1; +} + +static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, + REFGUID guidService, REFIID riid, void **ppv) +{ + if(IsEqualGUID(&SID_GetCaller, guidService)) + return E_NOINTERFACE; + + if(IsEqualGUID(&SID_SInternetHostSecurityManager, guidService)) { + if(iface == &ServiceProvider) + CHECK_EXPECT(Host_QS_SecMgr); + else + CHECK_EXPECT(Caller_QS_SecMgr); + ok(IsEqualGUID(&IID_IInternetHostSecurityManager, riid), "unexpected riid %s\n", debugstr_guid(riid)); + if(SUCCEEDED(QS_SecMgr_hres)) + *ppv = &InternetHostSecurityManager; + return QS_SecMgr_hres; + } + + ok(0, "unexpected service %s\n", debugstr_guid(guidService)); + return E_NOINTERFACE; +} + +static IServiceProviderVtbl ServiceProviderVtbl = { + ServiceProvider_QueryInterface, + ServiceProvider_AddRef, + ServiceProvider_Release, + ServiceProvider_QueryService +}; + +static IServiceProvider ServiceProvider = { &ServiceProviderVtbl }; +static IServiceProvider caller_sp = { &ServiceProviderVtbl }; + +static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv) +{ + if(IsEqualGUID(&IID_IUnknown, riid)) { + *ppv = iface; + }else if(IsEqualGUID(&IID_IActiveScriptSite, riid)) { + *ppv = iface; + }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { + *ppv = &ServiceProvider; + }else { + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface) +{ + return 2; +} + +static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface) +{ + return 1; +} + +static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid) +{ + *plcid = GetUserDefaultLCID(); + return S_OK; +} + +static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName, + DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti) +{ + ok(dwReturnMask == SCRIPTINFO_IUNKNOWN, "unexpected dwReturnMask %x\n", dwReturnMask); + ok(!ppti, "ppti != NULL\n"); + ok(!strcmp_wa(pstrName, "test"), "pstrName = %s\n", wine_dbgstr_w(pstrName)); + + *ppiunkItem = (IUnknown*)&globalObj; + return S_OK; +} + +static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface, + const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface) +{ + return E_NOTIMPL; +} + +#undef ACTSCPSITE_THIS + +static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = { + ActiveScriptSite_QueryInterface, + ActiveScriptSite_AddRef, + ActiveScriptSite_Release, + ActiveScriptSite_GetLCID, + ActiveScriptSite_GetItemInfo, + ActiveScriptSite_GetDocVersionString, + ActiveScriptSite_OnScriptTerminate, + ActiveScriptSite_OnStateChange, + ActiveScriptSite_OnScriptError, + ActiveScriptSite_OnEnterScript, + ActiveScriptSite_OnLeaveScript +}; + +static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl }; + +static void set_safety_options(IUnknown *unk) +{ + IObjectSafety *safety; + DWORD supported, enabled; + HRESULT hres; + + hres = IUnknown_QueryInterface(unk, &IID_IObjectSafety, (void**)&safety); + ok(hres == S_OK, "Could not get IObjectSafety: %08x\n", hres); + if(FAILED(hres)) + return; + + hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, + INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER, + INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER); + ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres); + + supported = enabled = 0xdeadbeef; + hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled); + ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres); + ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER), + "supported=%x\n", supported); + ok(enabled == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER), + "enabled=%x\n", enabled); + + IObjectSafety_Release(safety); +} + +#define parse_script_a(p,s) _parse_script_a(__LINE__,p,s) +static void _parse_script_a(unsigned line, IActiveScriptParse *parser, const char *script) +{ + BSTR str; + HRESULT hres; + + str = a2bstr(script); + hres = IActiveScriptParse64_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); + SysFreeString(str); + ok_(__FILE__,line)(hres == S_OK, "ParseScriptText failed: %08x\n", hres); +} + +static IActiveScriptParse *create_script(void) +{ + IActiveScriptParse *parser; + IActiveScript *script; + HRESULT hres; + + QS_SecMgr_hres = S_OK; + ProcessUrlAction_hres = S_OK; + ProcessUrlAction_policy = URLPOLICY_ALLOW; + CreateInstance_hres = S_OK; + QueryCustomPolicy_hres = S_OK; + QueryCustomPolicy_psize = sizeof(DWORD); + QueryCustomPolicy_policy = URLPOLICY_ALLOW; + QI_IDispatch_hres = S_OK; + SetSite_hres = S_OK; + + hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, + &IID_IActiveScript, (void**)&script); + ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); + if(FAILED(hres)) + return NULL; + + set_safety_options((IUnknown*)script); + + hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parser); + ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres); + + hres = IActiveScriptParse64_InitNew(parser); + ok(hres == S_OK, "InitNew failed: %08x\n", hres); + + hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); + ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres); + + hres = IActiveScript_AddNamedItem(script, testW, + SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS); + ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres); + + hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED); + ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres); + + IActiveScript_Release(script); + + parse_script_a(parser, + "function testException(func, type, number) {\n" + "try {\n" + " func();\n" + "}catch(e) {\n" + " ok(e.name === type, 'e.name = ' + e.name + ', expected ' + type)\n" + " ok(e.number === number, 'e.number = ' + e.number + ', expected ' + number);\n" + " return;\n" + "}" + "ok(false, 'exception expected');\n" + "}"); + + return parser; +} + +static IDispatchEx *parse_procedure_a(IActiveScriptParse *parser, const char *src) +{ + IActiveScriptParseProcedure2 *parse_proc; + IDispatchEx *dispex; + IDispatch *disp; + BSTR str; + HRESULT hres; + + hres = IUnknown_QueryInterface(parser, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc); + ok(hres == S_OK, "Coult not get IActiveScriptParseProcedure2: %08x\n", hres); + + str = a2bstr(src); + hres = IActiveScriptParseProcedure2_64_ParseProcedureText(parse_proc, str, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, &disp); + SysFreeString(str); + IUnknown_Release(parse_proc); + ok(hres == S_OK, "ParseProcedureText failed: %08x\n", hres); + ok(disp != NULL, "disp == NULL\n"); + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + IDispatch_Release(dispex); + ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres); + + return dispex; +} + +#define call_procedure(p,c) _call_procedure(__LINE__,p,c) +static void _call_procedure(unsigned line, IDispatchEx *proc, IServiceProvider *caller) +{ + DISPPARAMS dp = {NULL,NULL,0,0}; + EXCEPINFO ei = {0}; + HRESULT hres; + + hres = IDispatchEx_InvokeEx(proc, DISPID_VALUE, 0, DISPATCH_METHOD, &dp, NULL, &ei, caller); + ok_(__FILE__,line)(hres == S_OK, "InvokeEx failed: %08x\n", hres); + +} + +static void test_ActiveXObject(void) +{ + IActiveScriptParse *parser; + IDispatchEx *proc; + + parser = create_script(); + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + SET_EXPECT(QI_IObjectWithSite); + SET_EXPECT(reportSuccess); + parse_script_a(parser, "(new ActiveXObject('Wine.Test')).reportSuccess();"); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + CHECK_CALLED(QI_IObjectWithSite); + CHECK_CALLED(reportSuccess); + + proc = parse_procedure_a(parser, "(new ActiveXObject('Wine.Test')).reportSuccess();"); + + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + SET_EXPECT(QI_IObjectWithSite); + SET_EXPECT(reportSuccess); + call_procedure(proc, NULL); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + CHECK_CALLED(QI_IObjectWithSite); + CHECK_CALLED(reportSuccess); + + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + SET_EXPECT(QI_IObjectWithSite); + SET_EXPECT(reportSuccess); + call_procedure(proc, &caller_sp); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + CHECK_CALLED(QI_IObjectWithSite); + CHECK_CALLED(reportSuccess); + + IDispatchEx_Release(proc); + IUnknown_Release(parser); + + parser = create_script(); + proc = parse_procedure_a(parser, "(new ActiveXObject('Wine.Test')).reportSuccess();"); + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + SET_EXPECT(QI_IObjectWithSite); + SET_EXPECT(reportSuccess); + call_procedure(proc, &caller_sp); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + CHECK_CALLED(QI_IObjectWithSite); + CHECK_CALLED(reportSuccess); + + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.TestABC'); }, 'Error', -2146827859);"); + + IDispatchEx_Release(proc); + IUnknown_Release(parser); + + parser = create_script(); + QS_SecMgr_hres = E_NOINTERFACE; + + SET_EXPECT(Host_QS_SecMgr); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(Host_QS_SecMgr); + + IUnknown_Release(parser); + + parser = create_script(); + ProcessUrlAction_hres = E_FAIL; + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + + IUnknown_Release(parser); + + parser = create_script(); + ProcessUrlAction_policy = URLPOLICY_DISALLOW; + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + + IUnknown_Release(parser); + + parser = create_script(); + CreateInstance_hres = E_FAIL; + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + + IUnknown_Release(parser); + + parser = create_script(); + QueryCustomPolicy_hres = E_FAIL; + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + + IUnknown_Release(parser); + + parser = create_script(); + QueryCustomPolicy_psize = 6; + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + SET_EXPECT(QI_IObjectWithSite); + SET_EXPECT(reportSuccess); + parse_script_a(parser, "(new ActiveXObject('Wine.Test')).reportSuccess();"); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + CHECK_CALLED(QI_IObjectWithSite); + CHECK_CALLED(reportSuccess); + + IUnknown_Release(parser); + + parser = create_script(); + QueryCustomPolicy_policy = URLPOLICY_DISALLOW; + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + + QueryCustomPolicy_psize = 6; + + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + + QueryCustomPolicy_policy = URLPOLICY_ALLOW; + QueryCustomPolicy_psize = 3; + + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + + IUnknown_Release(parser); + + parser = create_script(); + object_with_site = &ObjectWithSite; + + SET_EXPECT(Host_QS_SecMgr); + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + SET_EXPECT(QI_IObjectWithSite); + SET_EXPECT(SetSite); + SET_EXPECT(reportSuccess); + parse_script_a(parser, "(new ActiveXObject('Wine.Test')).reportSuccess();"); + CHECK_CALLED(Host_QS_SecMgr); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + CHECK_CALLED(QI_IObjectWithSite); + CHECK_CALLED(SetSite); + CHECK_CALLED(reportSuccess); + + SetSite_hres = E_FAIL; + SET_EXPECT(ProcessUrlAction); + SET_EXPECT(CreateInstance); + SET_EXPECT(QueryCustomPolicy); + SET_EXPECT(QI_IObjectWithSite); + SET_EXPECT(SetSite); + parse_script_a(parser, "testException(function() { new ActiveXObject('Wine.Test'); }, 'Error', -2146827859);"); + CHECK_CALLED(ProcessUrlAction); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(QueryCustomPolicy); + CHECK_CALLED(QI_IObjectWithSite); + CHECK_CALLED(SetSite); + + IUnknown_Release(parser); +} + +static BOOL init_key(const char *key_name, const char *def_value, BOOL init) +{ + HKEY hkey; + DWORD res; + + if(!init) { + RegDeleteKey(HKEY_CLASSES_ROOT, key_name); + return TRUE; + } + + res = RegCreateKeyA(HKEY_CLASSES_ROOT, key_name, &hkey); + if(res != ERROR_SUCCESS) + return FALSE; + + if(def_value) + res = RegSetValueA(hkey, NULL, REG_SZ, def_value, strlen(def_value)); + + RegCloseKey(hkey); + + return res == ERROR_SUCCESS; +} + +static BOOL init_registry(BOOL init) +{ + return init_key("Wine.Test\\CLSID", TESTOBJ_CLSID, init); +} + +static BOOL register_activex(void) +{ + DWORD regid; + HRESULT hres; + + if(!init_registry(TRUE)) { + init_registry(FALSE); + return FALSE; + } + + hres = CoRegisterClassObject(&CLSID_TestObj, (IUnknown *)&activex_cf, + CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id); + ok(hres == S_OK, "Could not register screipt engine: %08x\n", hres); + + return TRUE; +} + +static BOOL check_jscript(void) +{ + IActiveScriptParse *parser; + BSTR str; + HRESULT hres; + + parser = create_script(); + if(!parser) + return FALSE; + + str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;"); + hres = IActiveScriptParse64_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); + SysFreeString(str); + IUnknown_Release(parser); + + return hres == S_OK; +} + +START_TEST(activex) +{ + CoInitialize(NULL); + + if(check_jscript()) { + register_activex(); + + test_ActiveXObject(); + + init_registry(FALSE); + }else { + win_skip("Broken engine, probably too old\n"); + } + + CoUninitialize(); +} diff --git a/rostests/winetests/jscript/api.js b/rostests/winetests/jscript/api.js index be85566f587..2fba2520de5 100644 --- a/rostests/winetests/jscript/api.js +++ b/rostests/winetests/jscript/api.js @@ -58,6 +58,47 @@ ok(tmp === "undefined", "encodeURI() = " + tmp); tmp = encodeURI("abc", "test"); ok(tmp === "abc", "encodeURI('abc') = " + tmp); +tmp = encodeURIComponent("abc"); +ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp); +dec = decodeURIComponent(tmp); +ok(dec === "abc", "decodeURIComponent('" + tmp + "') = " + dec); +tmp = encodeURIComponent("{abc}"); +ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp); +dec = decodeURIComponent(tmp); +ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') = " + dec); +tmp = encodeURIComponent(""); +ok(tmp === "", "encodeURIComponent('') = " + tmp); +dec = decodeURIComponent(tmp); +ok(dec === "", "decodeURIComponent('" + tmp + "') = " + dec); +tmp = encodeURIComponent("\01\02\03\04"); +ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp); +dec = decodeURIComponent(tmp); +ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp + "') = " + dec); +tmp = encodeURIComponent("{#@}"); +ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp); +dec = decodeURIComponent(tmp); +ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') = " + dec); +tmp = encodeURIComponent("\xa1 "); +ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp); +dec = decodeURIComponent(tmp); +ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') = " + dec); +tmp = encodeURIComponent("\xffff"); +ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length); +dec = decodeURIComponent(tmp); +ok(dec === "\xffff", "decodeURIComponent('" + tmp + "') = " + dec); +tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()"); +ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp); +dec = decodeURIComponent(tmp); +ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp + "') = " + dec); +tmp = encodeURIComponent(); +ok(tmp === "undefined", "encodeURIComponent() = " + tmp); +tmp = encodeURIComponent("abc", "test"); +ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp); +dec = decodeURIComponent(); +ok(dec === "undefined", "decodeURIComponent() = " + dec); +dec = decodeURIComponent("abc", "test"); +ok(dec === "abc", "decodeURIComponent('abc') = " + dec); + tmp = escape("abc"); ok(tmp === "abc", "escape('abc') = " + tmp); tmp = escape(""); @@ -190,6 +231,8 @@ tmp = "abc".charAt(-1); ok(tmp === "", "'abc',charAt(-1) = " + tmp); tmp = "abc".charAt(0,2); ok(tmp === "a", "'abc',charAt(0.2) = " + tmp); +tmp = "abc".charAt(NaN); +ok(tmp === "a", "'abc',charAt(NaN) = " + tmp); tmp = "abc".charCodeAt(0); ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp); @@ -575,6 +618,12 @@ ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10"); ok(arr[8] === "b", "arr[8] != 'b'"); ok(arr.length === 10, "arr.length != 10"); +arr.pop = Array.prototype.pop; +ok(arr.pop() === false, "arr.pop() !== false"); +ok(arr[8] === "b", "arr[8] !== 'b'"); +ok(arr.pop() === 'b', "arr.pop() !== 'b'"); +ok(arr[8] === undefined, "arr[8] !== undefined"); + arr = [3,4,5]; tmp = arr.pop(); ok(arr.length === 2, "arr.length = " + arr.length); @@ -590,6 +639,11 @@ for(tmp in arr) tmp = arr.pop(); ok(arr.length === 0, "arr.length = " + arr.length); ok(tmp === undefined, "tmp = " + tmp); +arr = new Object(); +arr.pop = Array.prototype.pop; +tmp = arr.pop(); +ok(arr.length === 0, "arr.length = " + arr.length); +ok(tmp === undefined, "tmp = " + tmp); arr = [,,,,,]; tmp = arr.pop(); ok(arr.length === 5, "arr.length = " + arr.length); @@ -611,6 +665,16 @@ ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp); tmp = arr.toString("test"); ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp); +arr = new Object(); +arr.length = 3; +arr[0] = "aa"; +arr[2] = 2; +arr[7] = 3; +arr.join = Array.prototype.join; +tmp = arr.join(","); +ok(arr.length === 3, "arr.length = " + arr.length); +ok(tmp === "aa,,2", "tmp = " + tmp); + arr = [5,true,2,-1,3,false,"2.5"]; tmp = arr.sort(function(x,y) { return y-x; }); ok(tmp === arr, "tmp !== arr"); @@ -631,6 +695,15 @@ ok(arr.sort() === arr, "arr.sort() !== arr"); for(var i=0; i < arr.length; i++) ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]); +arr = new Object(); +arr.length = 3; +arr[0] = 1; +arr[2] = "aa"; +arr.sort = Array.prototype.sort; +tmp = arr.sort(); +ok(arr === tmp, "tmp !== arr"); +ok(arr[0]===1 && arr[1]==="aa" && arr[2]===undefined, "arr is sorted incorectly"); + arr = ["1", "2", "3"]; arr.length = 1; ok(arr.length === 1, "arr.length = " + arr.length); @@ -644,9 +717,34 @@ ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString()); ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf"); ok(arr === arr.valueOf(), "arr !== arr.valueOf"); +arr = [1,2,3]; +tmp = arr.reverse(); +ok(tmp === arr, "tmp !== arr"); +ok(arr.length === 3, "arr.length = " + arr.length); +ok(arr.toString() === "3,2,1", "arr.toString() = " + arr.toString()); + +arr = []; +arr[3] = 5; +arr[5] = 1; +tmp = arr.reverse(); +ok(tmp === arr, "tmp !== arr"); +ok(arr.length === 6, "arr.length = " + arr.length); +ok(arr.toString() === "1,,5,,,", "arr.toString() = " + arr.toString()); + +arr = new Object(); +arr.length = 3; +arr[0] = "aa"; +arr[2] = 2; +arr[7] = 3; +arr.reverse = Array.prototype.reverse; +tmp = arr.reverse(); +ok(tmp === arr, "tmp !== arr"); +ok(arr.length === 3, "arr.length = " + arr.length); +ok(arr[0] === 2 && arr[1] === undefined && arr[2] === "aa", "unexpected array"); + arr = [1,2,3]; tmp = arr.unshift(0); -ok(tmp === undefined, "[1,2,3].unshift(0) returned " +tmp); +ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp); ok(arr.length === 4, "arr.length = " + arr.length); ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString()); @@ -654,13 +752,13 @@ arr = new Array(3); arr[0] = 1; arr[2] = 3; tmp = arr.unshift(-1,0); -ok(tmp === undefined, "unshift returned " +tmp); +ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp); ok(arr.length === 5, "arr.length = " + arr.length); ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString()); arr = [1,2,3]; tmp = arr.unshift(); -ok(tmp === undefined, "unshift returned " +tmp); +ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp); ok(arr.length === 3, "arr.length = " + arr.length); ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString()); @@ -669,7 +767,7 @@ arr.length = 2; arr[0] = 1; arr[1] = 2; tmp = Array.prototype.unshift.call(arr, 0); -ok(tmp === undefined, "unshift returned " +tmp); +ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp); ok(arr.length === 3, "arr.length = " + arr.length); ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array"); @@ -1374,14 +1472,65 @@ callTest2.apply(tmp); (function () { callTest2.apply(tmp, arguments); })(); function callTest3() { + testThis(this); ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0"); } callTest3.call(); +callTest3.call(undefined); +callTest3.call(null); +callTest3.apply(); +callTest3.apply(undefined); +callTest3.apply(null); tmp = Number.prototype.toString.call(3); ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp); +var func = new Function("return 3;"); + +tmp = func(); +ok(tmp === 3, "func() = " + tmp); +ok(func.call() === 3, "func.call() = " + tmp); +ok(func.length === 0, "func.length = " + func.length); +tmp = func.toString(); +ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp); + +func = new Function("x", "return x+2;"); +tmp = func(1); +ok(tmp === 3, "func(1) = " + tmp); +tmp = func.toString(); +ok(tmp === "function anonymous(x) {\nreturn x+2;\n}", "func.toString() = " + tmp); + +tmp = (new Function("x ", "return x+2;")).toString(); +ok(tmp === "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() = " + tmp); + +func = new Function("x", "y", "return x+y"); +tmp = func(1,3); +ok(tmp === 4, "func(1,3) = " + tmp); +tmp = func.toString(); +ok(tmp === "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() = " + tmp); + +func = new Function(" x, \ty", "\tz", "return x+y+z;"); +tmp = func(1,3,2); +ok(tmp === 6, "func(1,3,2) = " + tmp); +ok(func.length === 3, "func.length = " + func.length); +tmp = func.toString(); +ok(tmp === "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}", "func.toString() = " + tmp); + +func = new Function(); +tmp = func(); +ok(tmp === undefined, "func() = " + tmp); +tmp = func.toString(); +ok(tmp == "function anonymous() {\n\n}", "func.toString() = " + tmp); + +func = (function() { + var tmp = 3; + return new Function("return tmp;"); + })(); +tmp = 2; +tmp = func(); +ok(tmp === 2, "func() = " + tmp); + var date = new Date(); date = new Date(100); @@ -1566,7 +1715,7 @@ ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype ok(err.name === "Error", "err.name = " + err.name); EvalError.prototype.message = "test"; ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString"); -ok(err.toString() === "[object Error]", "err.toString() = " + err.toString()); +ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error"), "err.toString() = " + err.toString()); err = new EvalError(); ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name); ok(err.name === "EvalError", "err.name = " + err.name); @@ -1574,31 +1723,32 @@ ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype. ok(err.message === "", "err.message != ''"); err.message = date; ok(err.message === date, "err.message != date"); -ok(err.toString() === "[object Error]", "err.toString() = " + err.toString()); +ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "EvalError: "+err.message), + "err.toString() = " + err.toString()); ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString"); err = new RangeError(); ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name); ok(err.name === "RangeError", "err.name = " + err.name); -ok(err.toString() === "[object Error]", "err.toString() = " + err.toString()); +ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "RangeError"), "err.toString() = " + err.toString()); err = new ReferenceError(); ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name); ok(err.name === "ReferenceError", "err.name = " + err.name); -ok(err.toString() === "[object Error]", "err.toString() = " + err.toString()); +ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "ReferenceError"), "err.toString() = " + err.toString()); err = new SyntaxError(); ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name); ok(err.name === "SyntaxError", "err.name = " + err.name); -ok(err.toString() === "[object Error]", "err.toString() = " + err.toString()); +ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "SyntaxError"), "err.toString() = " + err.toString()); err = new TypeError(); ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name); ok(err.name === "TypeError", "err.name = " + err.name); -ok(err.toString() === "[object Error]", "err.toString() = " + err.toString()); +ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "TypeError"), "err.toString() = " + err.toString()); err = new URIError(); ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name); ok(err.name === "URIError", "err.name = " + err.name); -ok(err.toString() === "[object Error]", "err.toString() = " + err.toString()); +ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "URIError"), "err.toString() = " + err.toString()); err = new Error("message"); ok(err.message === "message", "err.message !== 'message'"); -ok(err.toString() === "[object Error]", "err.toString() = " + err.toString()); +ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error: message"), "err.toString() = " + err.toString()); err = new Error(123); ok(err.number === 123, "err.number = " + err.number); err = new Error(0, "message"); @@ -1606,6 +1756,35 @@ ok(err.number === 0, "err.number = " + err.number); ok(err.message === "message", "err.message = " + err.message); ok(err.description === "message", "err.description = " + err.description); +tmp = new Object(); +tmp.toString = function() { return "test"; }; + +tmp = Error.prototype.toString.call(tmp); +ok(tmp === "[object Error]", "Error.prototype.toString.call(tmp) = " + tmp); + +err = new Error(); +err.name = null; +ok(err.name === null, "err.name = " + err.name + " expected null"); +if(invokeVersion >= 2) + ok(err.toString() === "null", "err.toString() = " + err.toString()); + +err = new Error(); +err.message = false; +ok(err.message === false, "err.message = " + err.message + " expected false"); +if(invokeVersion >= 2) + ok(err.toString() === "Error: false", "err.toString() = " + err.toString()); + +err = new Error(); +err.message = new Object(); +err.message.toString = function() { return ""; }; +if(invokeVersion >= 2) + ok(err.toString() === "Error", "err.toString() = " + err.toString()); + +err = new Error(); +err.message = undefined; +if(invokeVersion >= 2) + ok(err.toString() === "Error", "err.toString() = " + err.toString()); + function exception_test(func, type, number) { ret = ""; num = ""; @@ -1648,6 +1827,7 @@ exception_test(function() {eval("if(")}, "SyntaxError", -2146827286); exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273); exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281); exception_test(function() {RegExp(/a/, "g");}, "RegExpError", -2146823271); +exception_test(function() {encodeURI('\udcaa');}, "URIError", -2146823264); function testThisExcept(func, number) { exception_test(function() {func.call(new Object())}, "TypeError", number); @@ -1729,6 +1909,10 @@ testArrayHostThis("shift"); testArrayHostThis("slice"); testArrayHostThis("splice"); testArrayHostThis("unshift"); +testArrayHostThis("reverse"); +testArrayHostThis("join"); +testArrayHostThis("pop"); +testArrayHostThis("sort"); function testObjectInherit(obj, constr, ts, tls, vo) { ok(obj instanceof Object, "obj is not instance of Object"); @@ -1941,4 +2125,43 @@ testFunctions(Function.prototype, [ ["toString", 0] ]); +ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length); +ok(Array.length == 1, "Array.length = " + Array.length); +ok(Boolean.length == 1, "Boolean.length = " + Boolean.length); +ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length); +//ok(Date.length == 7, "Date.length = " + Date.length); +ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length); +ok(Error.length == 1, "Error.length = " + Error.length); +ok(EvalError.length == 1, "EvalError.length = " + EvalError.length); +ok(Function.length == 1, "Function.length = " + Function.length); +ok(GetObject.length == 2, "GetObject.length = " + GetObject.length); +ok(Number.length == 1, "Number.length = " + Number.length); +ok(Object.length == 0, "Object.length = " + Object.length); +ok(RangeError.length == 1, "RangeError.length = " + RangeError.length); +ok(ReferenceError.length == 1, "ReferenceError.length = " + ReferenceError.length); +ok(RegExp.length == 2, "RegExp.length = " + RegExp.length); +ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length); +ok(ScriptEngineBuildVersion.length == 0, + "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length); +ok(ScriptEngineMajorVersion.length == 0, + "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length); +ok(ScriptEngineMinorVersion.length == 0, + "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length); +//ok(String.length == 1, "String.length = " + String.length); +ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length); +ok(TypeError.length == 1, "TypeError.length = " + TypeError.length); +ok(URIError.length == 1, "URIError.length = " + URIError.length); +ok(VBArray.length == 1, "VBArray.length = " + VBArray.length); +ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length); +ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " + decodeURIComponent.length); +ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length); +ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " + encodeURIComponent.length); +ok(escape.length == 1, "escape.length = " + escape.length); +ok(eval.length == 1, "eval.length = " + eval.length); +ok(isFinite.length == 1, "isFinite.length = " + isFinite.length); +ok(isNaN.length == 1, "isNaN.length = " + isNaN.length); +ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length); +ok(parseInt.length == 2, "parseInt.length = " + parseInt.length); +ok(unescape.length == 1, "unescape.length = " + unescape.length); + reportSuccess(); diff --git a/rostests/winetests/jscript/jscript.c b/rostests/winetests/jscript/jscript.c index e53fc2dcfd2..006e0556be4 100644 --- a/rostests/winetests/jscript/jscript.c +++ b/rostests/winetests/jscript/jscript.c @@ -203,37 +203,70 @@ static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = { static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl }; -static void test_script_dispatch(IActiveScript *script, BOOL initialized) +static void test_script_dispatch(IDispatchEx *dispex) { - IDispatchEx *dispex; - IDispatch *disp; + DISPPARAMS dp = {NULL,NULL,0,0}; + EXCEPINFO ei; BSTR str; DISPID id; + VARIANT v; HRESULT hres; - disp = (void*)0xdeadbeef; - hres = IActiveScript_GetScriptDispatch(script, NULL, &disp); - if(!initialized) { - ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n", hres); - ok(!disp, "disp != NULL\n"); - return; - } - - ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres); - if(FAILED(hres)) - return; - - ok(disp != NULL, "disp == NULL\n"); - hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); - IDispatch_Release(disp); - ok(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres); - str = a2bstr("ActiveXObject"); hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id); SysFreeString(str); ok(hres == S_OK, "GetDispID failed: %08x\n", hres); - IDispatchEx_Release(dispex); + str = a2bstr("Math"); + hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id); + SysFreeString(str); + ok(hres == S_OK, "GetDispID failed: %08x\n", hres); + + memset(&ei, 0, sizeof(ei)); + hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v)); + ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n"); + VariantClear(&v); + + str = a2bstr("String"); + hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id); + SysFreeString(str); + ok(hres == S_OK, "GetDispID failed: %08x\n", hres); + + memset(&ei, 0, sizeof(ei)); + hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v)); + ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n"); + VariantClear(&v); +} + +static IDispatchEx *get_script_dispatch(IActiveScript *script) +{ + IDispatchEx *dispex; + IDispatch *disp; + HRESULT hres; + + disp = (void*)0xdeadbeef; + hres = IActiveScript_GetScriptDispatch(script, NULL, &disp); + ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres); + + IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + IDispatch_Release(disp); + ok(hres == S_OK, "Could not get IDispatch iface: %08x\n", hres); + return dispex; +} + +static void test_no_script_dispatch(IActiveScript *script) +{ + IDispatch *disp; + HRESULT hres; + + disp = (void*)0xdeadbeef; + hres = IActiveScript_GetScriptDispatch(script, NULL, &disp); + ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n", hres); + ok(!disp, "disp != NULL\n"); } static void test_safety(IUnknown *unk) @@ -295,10 +328,54 @@ static void test_safety(IUnknown *unk) IObjectSafety_Release(safety); } +static HRESULT set_script_prop(IActiveScript *engine, DWORD property, VARIANT *val) +{ + IActiveScriptProperty *script_prop; + HRESULT hres; + + hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptProperty, + (void**)&script_prop); + ok(hres == S_OK, "Could not get IActiveScriptProperty iface: %08x\n", hres); + + hres = IActiveScriptProperty_SetProperty(script_prop, property, NULL, val); + IActiveScriptProperty_Release(script_prop); + return hres; +} + +static void test_invoke_versioning(IActiveScript *script) +{ + VARIANT v; + HRESULT hres; + + V_VT(&v) = VT_NULL; + hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v); + if(hres == E_NOTIMPL) { + win_skip("SCRIPTPROP_INVOKESTRING not supported\n"); + return; + } + ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres); + + V_VT(&v) = VT_I2; + V_I2(&v) = 0; + hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v); + ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres); + + V_VT(&v) = VT_I4; + V_I4(&v) = 16; + hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v); + ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres); + + V_VT(&v) = VT_I4; + V_I4(&v) = 2; + hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v); + ok(hres == S_OK, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres); +} + static void test_jscript(void) { IActiveScriptParse *parse; IActiveScript *script; + IDispatchEx *dispex; IUnknown *unk; ULONG ref; HRESULT hres; @@ -322,6 +399,7 @@ static void test_jscript(void) test_state(script, SCRIPTSTATE_UNINITIALIZED); test_safety(unk); + test_invoke_versioning(script); hres = IActiveScriptParse64_InitNew(parse); ok(hres == S_OK, "InitNew failed: %08x\n", hres); @@ -333,7 +411,7 @@ static void test_jscript(void) ok(hres == E_POINTER, "SetScriptSite failed: %08x, expected E_POINTER\n", hres); test_state(script, SCRIPTSTATE_UNINITIALIZED); - test_script_dispatch(script, FALSE); + test_no_script_dispatch(script); SET_EXPECT(GetLCID); SET_EXPECT(OnStateChange_INITIALIZED); @@ -347,7 +425,8 @@ static void test_jscript(void) hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres); - test_script_dispatch(script, TRUE); + dispex = get_script_dispatch(script); + test_script_dispatch(dispex); SET_EXPECT(OnStateChange_STARTED); hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED); @@ -362,7 +441,9 @@ static void test_jscript(void) CHECK_CALLED(OnStateChange_CLOSED); test_state(script, SCRIPTSTATE_CLOSED); - test_script_dispatch(script, FALSE); + test_no_script_dispatch(script); + test_script_dispatch(dispex); + IDispatchEx_Release(dispex); IUnknown_Release(parse); IActiveScript_Release(script); @@ -430,7 +511,7 @@ static void test_jscript2(void) CHECK_CALLED(OnStateChange_CLOSED); test_state(script, SCRIPTSTATE_CLOSED); - test_script_dispatch(script, FALSE); + test_no_script_dispatch(script); IUnknown_Release(parse); IActiveScript_Release(script); diff --git a/rostests/winetests/jscript/jscript.rbuild b/rostests/winetests/jscript/jscript.rbuild index e679b74c6fd..02442887ea8 100644 --- a/rostests/winetests/jscript/jscript.rbuild +++ b/rostests/winetests/jscript/jscript.rbuild @@ -3,13 +3,15 @@ . - + + activex.c jscript.c run.c testlist.c rsrc.rc wine ole32 + advapi32 oleaut32 ntdll diff --git a/rostests/winetests/jscript/lang.js b/rostests/winetests/jscript/lang.js index 353dcd7c73c..495762ee599 100644 --- a/rostests/winetests/jscript/lang.js +++ b/rostests/winetests/jscript/lang.js @@ -109,8 +109,14 @@ ok(typeof(this) === "object", "typeof(this) is not object"); ok(testFunc1(true, "test") === true, "testFunc1 not returned true"); +tmp = (function() {1;})(); +ok(tmp === undefined, "tmp = " + tmp); +tmp = eval("1;"); +ok(tmp === 1, "tmp = " + tmp); + var obj1 = new Object(); ok(typeof(obj1) === "object", "typeof(obj1) is not object"); +ok(obj1.constructor === Object, "unexpected obj1.constructor"); obj1.test = true; obj1.func = function () { ok(this === obj1, "this is not obj1"); @@ -139,6 +145,7 @@ testConstr1.prototype.pvar = 1; var obj2 = new testConstr1(true); ok(typeof(obj2) === "object", "typeof(obj2) is not object"); +ok(obj2.constructor === testConstr1, "unexpected obj2.constructor"); ok(obj2.pvar === 1, "obj2.pvar is not 1"); testConstr1.prototype.pvar = 2; @@ -148,6 +155,21 @@ obj2.pvar = 3; testConstr1.prototype.pvar = 1; ok(obj2.pvar === 3, "obj2.pvar is not 3"); +obj1 = new Object(); +function testConstr3() { + return obj1; +} + +obj2 = new testConstr3(); +ok(obj1 === obj2, "obj1 != obj2"); + +function testConstr4() { + return 2; +} + +obj2 = new testConstr3(); +ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2)); + var obj3 = new Object; ok(typeof(obj3) === "object", "typeof(obj3) is not object"); @@ -189,6 +211,7 @@ if(false) { var obj3 = { prop1: 1, prop2: typeof(false) }; ok(obj3.prop1 === 1, "obj3.prop1 is not 1"); ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\""); +ok(obj3.constructor === Object, "unexpected obj3.constructor"); { var blockVar = 1; @@ -326,6 +349,15 @@ tmp = -3.5 | 0; ok(tmp === -3, "-3.5 | 0 !== -3"); ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp)); +tmp = 0 | NaN; +ok(tmp === 0, "0 | NaN = " + tmp); + +tmp = 0 | Infinity; +ok(tmp === 0, "0 | NaN = " + tmp); + +tmp = 0 | (-Infinity); +ok(tmp === 0, "0 | NaN = " + tmp); + tmp = 10; ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26"); ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp)); @@ -360,6 +392,9 @@ ok(tmp === 2, "8 >> 2 = " + tmp); tmp = -64 >>> 4; ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp); +tmp = 4 >>> NaN; +ok(tmp === 4, "4 >>> NaN = " + tmp); + tmp = 10; ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8"); ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp)); @@ -390,8 +425,10 @@ ok(+"3e3" === 3000, "+'3e3' !== 3000"); tmp = new Number(1); ok(+tmp === 1, "+(new Number(1)) = " + (+tmp)); +ok(tmp.constructor === Number, "unexpected tmp.constructor"); tmp = new String("1"); ok(+tmp === 1, "+(new String('1')) = " + (+tmp)); +ok(tmp.constructor === String, "unexpected tmp.constructor"); ok("" + 0 === "0", "\"\" + 0 !== \"0\""); ok("" + 123 === "123", "\"\" + 123 !== \"123\""); @@ -831,6 +868,13 @@ ok(("1" in obj) === false, "1 is in obj"); obj = [1,2,3]; ok((1 in obj) === true, "1 is not in obj"); +obj = new Object(); +try { + obj.prop["test"]; + ok(false, "expected exception"); +}catch(e) {} +ok(!("prop" in obj), "prop in obj"); + ok(isNaN(NaN) === true, "isNaN(NaN) !== true"); ok(isNaN(0.5) === false, "isNaN(0.5) !== false"); ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false"); @@ -934,6 +978,11 @@ ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function var re = /=(\?|%3F)/g; ok(re.source === "=(\\?|%3F)", "re.source = " + re.source); +tmp = new Array(); +for(var i=0; i<2; i++) + tmp[i] = /b/; +ok(tmp[0] != tmp[1], "tmp[0] == tmp [1]"); + ok(createNullBSTR() === '', "createNullBSTR() !== ''"); ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp)); @@ -969,4 +1018,10 @@ ok(typeof(doesnotexist) === "undefined", "typeof(doesnotexist) = " + typeof(does (function() { newValue = 1; })(); ok(newValue === 1, "newValue = " + newValue); +obj = {undefined: 3}; + +/* Keep this test in the end of file */ +undefined = 6; +ok(undefined === 6, "undefined = " + undefined); + reportSuccess(); diff --git a/rostests/winetests/jscript/regexp.js b/rostests/winetests/jscript/regexp.js index ff98b484072..fac111227fe 100644 --- a/rostests/winetests/jscript/regexp.js +++ b/rostests/winetests/jscript/regexp.js @@ -17,7 +17,7 @@ */ -var m, re, b; +var m, re, b, i, obj; re = /a+/; ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); @@ -71,6 +71,11 @@ m = re.exec(); ok(m === null, "m is not null"); ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); +m = /(a|b)+|(c)/.exec("aa"); +ok(m[0] === "aa", "m[0] = " + m[0]); +ok(m[1] === "a", "m[1] = " + m[1]); +ok(m[2] === "", "m[2] = " + m[2]); + b = re.test(" a "); ok(b === true, "re.test(' a ') returned " + b); ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); @@ -91,10 +96,12 @@ ok(m[1] === "test", "m[1] = " + m[1]); b = /a*/.test(); ok(b === true, "/a*/.test() returned " + b); -m = "abcabc".match(/ca/); +m = "abcabc".match(re = /ca/); ok(typeof(m) === "object", "typeof m is not object"); ok(m.length === 1, "m.length is not 1"); ok(m["0"] === "ca", "m[0] is not \"ca\""); +ok(m.constructor === Array, "unexpected m.constructor"); +ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex); m = "abcabc".match(/ab/); ok(typeof(m) === "object", "typeof m is not object"); @@ -160,8 +167,9 @@ ok(m["0"] === "ab", "m[0] is not \"ab\""); m = "abcabc".match(); ok(m === null, "m is not null"); -r = "- [test] -".replace(/\[([^\[]+)\]/g, "success"); +r = "- [test] -".replace(re = /\[([^\[]+)\]/g, "success"); ok(r === "- success -", "r = " + r + " expected '- success -'"); +ok(re.lastIndex === 8, "re.lastIndex = " + re.lastIndex); r = "[test] [test]".replace(/\[([^\[]+)\]/g, "aa"); ok(r === "aa aa", "r = " + r + "aa aa"); @@ -280,6 +288,41 @@ ok(r.length === 2, "r.length = " + r.length); ok(r[0] === "1", "r[0] = " + r[0]); ok(r[1] === "2", "r[1] = " + r[1]); +re = /,+/; +r = "1,,2,".split(re); +ok(r.length === 2, "r.length = " + r.length); +ok(r[0] === "1", "r[0] = " + r[0]); +ok(r[1] === "2", "r[1] = " + r[1]); +ok(re.lastIndex === 5, "re.lastIndex = " + re.lastIndex); + +re = /,+/g; +r = "1,,2,".split(re); +ok(r.length === 2, "r.length = " + r.length); +ok(r[0] === "1", "r[0] = " + r[0]); +ok(r[1] === "2", "r[1] = " + r[1]); +ok(re.lastIndex === 5, "re.lastIndex = " + re.lastIndex); + +r = "1 12 \t3".split(re = /\s+/).join(";"); +ok(r === "1;12;3", "r = " + r); +ok(re.lastIndex === 6, "re.lastIndex = " + re.lastIndex); + +r = "123".split(re = /\s+/).join(";"); +ok(r === "123", "r = " + r); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); + +/* another standard violation */ +r = "1 12 \t3".split(re = /(\s)+/g).join(";"); +ok(r === "1;12;3", "r = " + r); +ok(re.lastIndex === 6, "re.lastIndex = " + re.lastIndex); + +re = /,+/; +re.lastIndex = 4; +r = "1,,2,".split(re); +ok(r.length === 2, "r.length = " + r.length); +ok(r[0] === "1", "r[0] = " + r[0]); +ok(r[1] === "2", "r[1] = " + r[1]); +ok(re.lastIndex === 5, "re.lastIndex = " + re.lastIndex); + re = /abc[^d]/g; ok(re.source === "abc[^d]", "re.source = '" + re.source + "', expected 'abc[^d]'"); @@ -298,4 +341,117 @@ ok(re === RegExp(re, undefined), "re !== RegExp(re, undefined)"); re = /abc/; ok(re === RegExp(re, undefined, 1), "re !== RegExp(re, undefined, 1)"); +re = /a/g; +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0"); + +m = re.exec(" a "); +ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex + " expected 2"); +ok(m.index === 1, "m.index = " + m.index + " expected 1"); + +m = re.exec(" a "); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0"); +ok(m === null, "m = " + m + " expected null"); + +re.lastIndex = 2; +m = re.exec(" a a "); +ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex + " expected 4"); +ok(m.index === 3, "m.index = " + m.index + " expected 3"); + +re.lastIndex = "2"; +ok(re.lastIndex === "2", "re.lastIndex = " + re.lastIndex + " expected '2'"); +m = re.exec(" a a "); +ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex + " expected 4"); +ok(m.index === 3, "m.index = " + m.index + " expected 3"); + +var li = 0; +var obj = new Object(); +obj.valueOf = function() { return li; }; + +re.lastIndex = obj; +ok(re.lastIndex === obj, "re.lastIndex = " + re.lastIndex + " expected obj"); +li = 2; +m = re.exec(" a a "); +ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex + " expected 2"); +ok(m.index === 1, "m.index = " + m.index + " expected 1"); + +re.lastIndex = 3; +re.lastIndex = "test"; +ok(re.lastIndex === "test", "re.lastIndex = " + re.lastIndex + " expected 'test'"); +m = re.exec(" a a "); +ok(re.lastIndex === 2 || re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 2 or 0"); +if(re.lastIndex != 0) + ok(m.index === 1, "m.index = " + m.index + " expected 1"); +else + ok(m === null, "m = " + m + " expected null"); + +re.lastIndex = 0; +re.lastIndex = 3.9; +ok(re.lastIndex === 3.9, "re.lastIndex = " + re.lastIndex + " expected 3.9"); +m = re.exec(" a a "); +ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex + " expected 4"); +ok(m.index === 3, "m.index = " + m.index + " expected 3"); + +obj.valueOf = function() { throw 0; } +re.lastIndex = obj; +ok(re.lastIndex === obj, "unexpected re.lastIndex"); +m = re.exec(" a a "); +ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex + " expected 2"); +ok(m.index === 1, "m.index = " + m.index + " expected 1"); + +re.lastIndex = -3; +ok(re.lastIndex === -3, "re.lastIndex = " + re.lastIndex + " expected -3"); +m = re.exec(" a a "); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0"); +ok(m === null, "m = " + m + " expected null"); + +re.lastIndex = -1; +ok(re.lastIndex === -1, "re.lastIndex = " + re.lastIndex + " expected -1"); +m = re.exec(" "); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0"); +ok(m === null, "m = " + m + " expected null"); + +re = /aa/g; +i = 'baacd'.search(re); +ok(i === 1, "'baacd'.search(re) = " + i); +ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); + +re.lastIndex = 2; +i = 'baacdaa'.search(re); +ok(i === 1, "'baacd'.search(re) = " + i); +ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); + +re = /aa/; +i = 'baacd'.search(re); +ok(i === 1, "'baacd'.search(re) = " + i); +ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); + +re.lastIndex = 2; +i = 'baacdaa'.search(re); +ok(i === 1, "'baacd'.search(re) = " + i); +ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex); + +re = /d/g; +re.lastIndex = 1; +i = 'abc'.search(re); +ok(i === -1, "'abc'.search(/d/g) = " + i); +ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); + +i = 'abcdde'.search(/[df]/); +ok(i === 3, "'abc'.search(/[df]/) = " + i); + +i = 'abcdde'.search(/[df]/, "a"); +ok(i === 3, "'abc'.search(/[df]/) = " + i); + +i = 'abcdde'.search("[df]"); +ok(i === 3, "'abc'.search(/d*/) = " + i); + +obj = { + toString: function() { return "abc"; } +}; +i = String.prototype.search.call(obj, "b"); +ok(i === 1, "String.prototype.seatch.apply(obj, 'b') = " + i); + +i = " undefined ".search(); +ok(i === null, "' undefined '.search() = " + i); + reportSuccess(); diff --git a/rostests/winetests/jscript/run.c b/rostests/winetests/jscript/run.c index cf34b2f1abd..303907e8f90 100644 --- a/rostests/winetests/jscript/run.c +++ b/rostests/winetests/jscript/run.c @@ -81,6 +81,7 @@ DEFINE_EXPECT(GetItemInfo_testVal); #define DISPID_GLOBAL_NULL_DISP 0x1008 #define DISPID_GLOBAL_TESTTHIS 0x1009 #define DISPID_GLOBAL_TESTTHIS2 0x100a +#define DISPID_GLOBAL_INVOKEVERSION 0x100b #define DISPID_TESTOBJ_PROP 0x2000 @@ -92,6 +93,7 @@ static const CHAR test_valA[] = "testVal"; static BOOL strict_dispid_check; static const char *test_name = "(null)"; static IDispatch *script_disp; +static int invoke_version; static BSTR a2bstr(const char *str) { @@ -112,6 +114,13 @@ static int strcmp_wa(LPCWSTR strw, const char *stra) return lstrcmpA(buf, stra); } +#define test_grfdex(a,b) _test_grfdex(__LINE__,a,b) +static void _test_grfdex(unsigned line, DWORD grfdex, DWORD expect) +{ + expect |= invoke_version << 28; + ok_(__FILE__,line)(grfdex == expect, "grfdex = %x, expected %x\n", grfdex, expect); +} + static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) { *ppv = NULL; @@ -205,13 +214,13 @@ static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD { if(!strcmp_wa(bstrName, "prop")) { CHECK_EXPECT(testobj_prop_d); - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_TESTOBJ_PROP; return S_OK; } if(!strcmp_wa(bstrName, "noprop")) { CHECK_EXPECT(testobj_noprop_d); - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); return DISP_E_UNKNOWNNAME; } @@ -250,7 +259,7 @@ static HRESULT WINAPI testObj_DeleteMemberByName(IDispatchEx *iface, BSTR bstrNa CHECK_EXPECT(testobj_delete); ok(!strcmp_wa(bstrName, "deleteTest"), "unexpected name %s\n", wine_dbgstr_w(bstrName)); - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); return S_OK; } @@ -277,40 +286,40 @@ static IDispatchEx testObj = { &testObjVtbl }; static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid) { if(!strcmp_wa(bstrName, "ok")) { - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_OK; return S_OK; } if(!strcmp_wa(bstrName, "trace")) { - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_TRACE; return S_OK; } if(!strcmp_wa(bstrName, "reportSuccess")) { CHECK_EXPECT(global_success_d); - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_REPORTSUCCESS; return S_OK; } if(!strcmp_wa(bstrName, "testPropGet")) { CHECK_EXPECT(global_propget_d); - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_TESTPROPGET; return S_OK; } if(!strcmp_wa(bstrName, "testPropPut")) { CHECK_EXPECT(global_propput_d); - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_TESTPROPPUT; return S_OK; } if(!strcmp_wa(bstrName, "getVT")) { - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_GETVT; return S_OK; } if(!strcmp_wa(bstrName, "testObj")) { - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_TESTOBJ; return S_OK; } @@ -324,22 +333,28 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD } if(!strcmp_wa(bstrName, "notExists")) { CHECK_EXPECT(global_notexists_d); - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); return DISP_E_UNKNOWNNAME; } if(!strcmp_wa(bstrName, "testThis")) { - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_TESTTHIS; return S_OK; } if(!strcmp_wa(bstrName, "testThis2")) { - ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex); + test_grfdex(grfdex, fdexNameCaseSensitive); *pid = DISPID_GLOBAL_TESTTHIS2; return S_OK; } + if(!strcmp_wa(bstrName, "invokeVersion")) { + test_grfdex(grfdex, fdexNameCaseSensitive); + *pid = DISPID_GLOBAL_INVOKEVERSION; + return S_OK; + } + if(strict_dispid_check) ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName)); return DISP_E_UNKNOWNNAME; @@ -536,6 +551,23 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, ok(V_DISPATCH(pdp->rgvarg) == script_disp, "disp != script_disp\n"); return S_OK; + + case DISPID_GLOBAL_INVOKEVERSION: + ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags); + ok(pdp != NULL, "pdp == NULL\n"); + ok(!pdp->rgvarg, "rgvarg != NULL\n"); + ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n"); + ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs); + ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(pvarRes != NULL, "pvarRes == NULL\n"); + ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes)); + ok(pei != NULL, "pei == NULL\n"); + + V_VT(pvarRes) = VT_I4; + V_I4(pvarRes) = invoke_version; + + return S_OK; + } ok(0, "unexpected call %x\n", id); @@ -657,19 +689,44 @@ static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = { static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl }; +static HRESULT set_script_prop(IActiveScript *engine, DWORD property, VARIANT *val) +{ + IActiveScriptProperty *script_prop; + HRESULT hres; + + hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptProperty, + (void**)&script_prop); + ok(hres == S_OK, "Could not get IActiveScriptProperty iface: %08x\n", hres); + + hres = IActiveScriptProperty_SetProperty(script_prop, property, NULL, val); + IActiveScriptProperty_Release(script_prop); + + return hres; +} + static IActiveScript *create_script(void) { IActiveScript *script; + VARIANT v; HRESULT hres; hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IActiveScript, (void**)&script); ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); + V_VT(&v) = VT_I4; + V_I4(&v) = invoke_version; + hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v); + ok(hres == S_OK || broken(hres == E_NOTIMPL), "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres); + if(invoke_version && FAILED(hres)) { + IActiveScript_Release(script); + return NULL; + } + return script; } -static void parse_script(DWORD flags, BSTR script_str) +static HRESULT parse_script(DWORD flags, BSTR script_str) { IActiveScriptParse *parser; IActiveScript *engine; @@ -677,14 +734,14 @@ static void parse_script(DWORD flags, BSTR script_str) engine = create_script(); if(!engine) - return; + return S_OK; hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser); ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres); if (FAILED(hres)) { IActiveScript_Release(engine); - return; + return hres; } hres = IActiveScriptParse64_InitNew(parser); @@ -706,11 +763,12 @@ static void parse_script(DWORD flags, BSTR script_str) ok(script_disp != (IDispatch*)&Global, "script_disp == Global\n"); hres = IActiveScriptParse64_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); - ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); IDispatch_Release(script_disp); IActiveScript_Release(engine); IUnknown_Release(parser); + + return hres; } static HRESULT parse_htmlscript(BSTR script_str) @@ -756,9 +814,13 @@ static HRESULT parse_htmlscript(BSTR script_str) static void parse_script_af(DWORD flags, const char *src) { - BSTR tmp = a2bstr(src); - parse_script(flags, tmp); + BSTR tmp; + HRESULT hres; + + tmp = a2bstr(src); + hres = parse_script(flags, tmp); SysFreeString(tmp); + ok(hres == S_OK, "parse_script failed: %08x\n", hres); } static void parse_script_a(const char *src) @@ -816,14 +878,17 @@ static BSTR get_script_from_file(const char *filename) static void run_from_file(const char *filename) { - BSTR script_str = get_script_from_file(filename); + BSTR script_str; + HRESULT hres; + + script_str = get_script_from_file(filename); + if(!script_str) + return; strict_dispid_check = FALSE; - - if(script_str) - parse_script(SCRIPTITEM_GLOBALMEMBERS, script_str); - + hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, script_str); SysFreeString(script_str); + ok(hres == S_OK, "parse_script failed: %08x\n", hres); } static void run_from_res(const char *name) @@ -832,6 +897,7 @@ static void run_from_res(const char *name) DWORD size, len; BSTR str; HRSRC src; + HRESULT hres; strict_dispid_check = FALSE; test_name = name; @@ -848,10 +914,11 @@ static void run_from_res(const char *name) SET_EXPECT(global_success_d); SET_EXPECT(global_success_i); - parse_script(SCRIPTITEM_GLOBALMEMBERS, str); + hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, str); CHECK_CALLED(global_success_d); CHECK_CALLED(global_success_i); + ok(hres == S_OK, "parse_script failed: %08x\n", hres); SysFreeString(str); } @@ -912,6 +979,17 @@ static void run_tests(void) { HRESULT hres; + if(invoke_version) { + IActiveScript *script; + + script = create_script(); + if(!script) { + win_skip("Could not create script\n"); + return; + } + IActiveScript_Release(script); + } + strict_dispid_check = TRUE; parse_script_a(""); @@ -1010,6 +1088,18 @@ static void run_tests(void) ok(hres != S_OK, "ParseScriptText have not failed\n"); } +static BOOL check_jscript(void) +{ + BSTR str; + HRESULT hres; + + str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;"); + hres = parse_script(0, str); + SysFreeString(str); + + return hres == S_OK; +} + START_TEST(run) { int argc; @@ -1019,10 +1109,19 @@ START_TEST(run) CoInitialize(NULL); - if(argc > 2) + if(!check_jscript()) { + win_skip("Broken engine, probably too old\n"); + }else if(argc > 2) { run_from_file(argv[2]); - else + }else { + trace("invoke version 0\n"); + invoke_version = 0; run_tests(); + trace("invoke version 2\n"); + invoke_version = 2; + run_tests(); + } + CoUninitialize(); } diff --git a/rostests/winetests/jscript/testlist.c b/rostests/winetests/jscript/testlist.c index fd13233a49b..64bc3b8ad2a 100644 --- a/rostests/winetests/jscript/testlist.c +++ b/rostests/winetests/jscript/testlist.c @@ -6,11 +6,13 @@ #define STANDALONE #include "wine/test.h" +extern void func_activex(void); extern void func_jscript(void); extern void func_run(void); const struct test winetest_testlist[] = { + { "activex", func_activex }, { "jscript", func_jscript }, { "run", func_run }, { 0, 0 } From 7fc6b68491ebbf838ef666efed32ded6fafd10ea Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 2 Mar 2010 20:18:29 +0000 Subject: [PATCH 038/211] [BDAPLGIN] - Set output variable to null to fixup lazy callers [KSPROXY] - Enumerate input / output pins and their names - Start implementing input / output pin - Implement IEnumPins interface for CKsProxy filter [MSDVBNP] - Fix a bug (IEnumPins::Next should increase reference count on pin) - Fix a bug (IPin::QueryFilterInfo should increase reference count on parent filter) - Reference leakage is now fixed svn path=/trunk/; revision=45768 --- reactos/dll/directx/bdaplgin/bdaplgin.cpp | 1 - .../dll/directx/bdaplgin/devicecontrol.cpp | 8 +- reactos/dll/directx/bdaplgin/pincontrol.cpp | 4 +- reactos/dll/directx/ksproxy/enumpins.cpp | 179 +++++++++++++ reactos/dll/directx/ksproxy/input_pin.cpp | 239 +++++++++++++++++ reactos/dll/directx/ksproxy/ksproxy.rbuild | 3 + reactos/dll/directx/ksproxy/output_pin.cpp | 242 ++++++++++++++++++ reactos/dll/directx/ksproxy/precomp.h | 27 ++ reactos/dll/directx/ksproxy/proxy.cpp | 227 +++++++++++++++- .../dll/directx/msdvbnp/enum_mediatypes.cpp | 2 +- reactos/dll/directx/msdvbnp/enumpins.cpp | 4 +- .../dll/directx/msdvbnp/networkprovider.cpp | 2 +- reactos/dll/directx/msdvbnp/pin.cpp | 5 +- reactos/dll/directx/msdvbnp/scanningtuner.cpp | 2 +- 14 files changed, 929 insertions(+), 16 deletions(-) create mode 100644 reactos/dll/directx/ksproxy/enumpins.cpp create mode 100644 reactos/dll/directx/ksproxy/input_pin.cpp create mode 100644 reactos/dll/directx/ksproxy/output_pin.cpp diff --git a/reactos/dll/directx/bdaplgin/bdaplgin.cpp b/reactos/dll/directx/bdaplgin/bdaplgin.cpp index ddc22972c36..39ddb8a2ccb 100644 --- a/reactos/dll/directx/bdaplgin/bdaplgin.cpp +++ b/reactos/dll/directx/bdaplgin/bdaplgin.cpp @@ -12,7 +12,6 @@ const GUID CBDADeviceControl_GUID = {STATIC_KSMETHODSETID_BdaChangeSync}; const GUID CBDAPinControl_GUID = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}}; - static INTERFACE_TABLE InterfaceTable[] = { {&CBDADeviceControl_GUID, CBDADeviceControl_fnConstructor}, diff --git a/reactos/dll/directx/bdaplgin/devicecontrol.cpp b/reactos/dll/directx/bdaplgin/devicecontrol.cpp index d44367f126e..661eba547a0 100644 --- a/reactos/dll/directx/bdaplgin/devicecontrol.cpp +++ b/reactos/dll/directx/bdaplgin/devicecontrol.cpp @@ -498,6 +498,10 @@ CBDADeviceControl_fnConstructor( IBaseFilter *pFilter = NULL; HANDLE hFile; +#ifdef BDAPLGIN_TRACE + OutputDebugStringW(L"CBDADeviceControl_fnConstructor\n"); +#endif + //DebugBreak(); // sanity check @@ -540,10 +544,6 @@ CBDADeviceControl_fnConstructor( // construct device control CBDADeviceControl * handler = new CBDADeviceControl(pUnkOuter, pFilter, hFile); -#ifdef BDAPLGIN_TRACE - OutputDebugStringW(L"CBDADeviceControl_fnConstructor\n"); -#endif - if (!handler) return E_OUTOFMEMORY; diff --git a/reactos/dll/directx/bdaplgin/pincontrol.cpp b/reactos/dll/directx/bdaplgin/pincontrol.cpp index 74e2398eb49..a5b99128b16 100644 --- a/reactos/dll/directx/bdaplgin/pincontrol.cpp +++ b/reactos/dll/directx/bdaplgin/pincontrol.cpp @@ -59,6 +59,7 @@ CBDAPinControl::QueryInterface( IN REFIID refiid, OUT PVOID* Output) { + *Output = NULL; if (IsEqualGUID(refiid, IID_IUnknown)) { *Output = PVOID(this); @@ -77,7 +78,6 @@ CBDAPinControl::QueryInterface( LPOLESTR lpstr; StringFromCLSID(refiid, &lpstr); swprintf(Buffer, L"CBDAPinControl::QueryInterface: NoInterface for %s", lpstr); - DebugBreak(); OutputDebugStringW(Buffer); CoTaskMemFree(lpstr); #endif @@ -290,6 +290,8 @@ CBDAPinControl_fnConstructor( OutputDebugStringW(L"CBDAPinControl_fnConstructor"); #endif + DebugBreak(); + if (!handler) return E_OUTOFMEMORY; diff --git a/reactos/dll/directx/ksproxy/enumpins.cpp b/reactos/dll/directx/ksproxy/enumpins.cpp new file mode 100644 index 00000000000..5d71d5355d2 --- /dev/null +++ b/reactos/dll/directx/ksproxy/enumpins.cpp @@ -0,0 +1,179 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/enumpins.cpp + * PURPOSE: IEnumPins interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumPins : public IEnumPins +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + + HRESULT STDMETHODCALLTYPE Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG cPins); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumPins **ppEnum); + + CEnumPins(std::vector Pins) : m_Ref(0), m_Pins(Pins), m_Index(0){}; + virtual ~CEnumPins(){}; + +protected: + LONG m_Ref; + std::vector m_Pins; + ULONG m_Index; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumPins::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IEnumPins)) + { + *Output = (IEnumPins*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumPins::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Next( + ULONG cPins, + IPin **ppPins, + ULONG *pcFetched) +{ + ULONG i = 0; + + if (!ppPins) + return E_POINTER; + + if (cPins > 1 && !pcFetched) + return E_INVALIDARG; + + WCHAR Buffer[MAX_PATH]; + swprintf(Buffer, L"CEnumPins::Next: this %p m_Index %lx cPins %u\n", this, m_Index, cPins); + OutputDebugStringW(Buffer); + + while(i < cPins) + { + if (m_Index + i >= m_Pins.size()) + break; + + ppPins[i] = m_Pins[m_Index + i]; + m_Pins[m_Index + i]->AddRef(); + + i++; + } + + if (pcFetched) + { + *pcFetched = i; + } + + m_Index += i; + OutputDebugStringW(L"CEnumPins::Next: done\n"); + if (i < cPins) + return S_FALSE; + else + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Skip( + ULONG cPins) +{ + if (cPins + m_Index >= m_Pins.size()) + { + return S_FALSE; + } + + m_Index += cPins; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Reset() +{ + m_Index = 0; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Clone( + IEnumPins **ppEnum) +{ + OutputDebugStringW(L"CEnumPins::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumPins_fnConstructor( + std::vector Pins, + REFIID riid, + LPVOID * ppv) +{ + CEnumPins * handler = new CEnumPins(Pins); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumPins_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/reactos/dll/directx/ksproxy/input_pin.cpp b/reactos/dll/directx/ksproxy/input_pin.cpp new file mode 100644 index 00000000000..03a97bad932 --- /dev/null +++ b/reactos/dll/directx/ksproxy/input_pin.cpp @@ -0,0 +1,239 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy + * FILE: dll/directx/ksproxy/input_cpp.cpp + * PURPOSE: InputPin of Proxy Filter + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CInputPin : public IPin +/* + public IQualityControl, + public IKsObject, + public IKsPinEx, + public IKsPinPipe, + public ISpecifyPropertyPages, + public IStreamBuilder, + public IKsPropertySet, + public IKsPinFactory, + public IKsControl, + public IKsAggregateControl +*/ +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + //IPin methods + HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE Disconnect(); + HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); + HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); + HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); + HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); + HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); + HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); + HRESULT STDMETHODCALLTYPE EndOfStream(); + HRESULT STDMETHODCALLTYPE BeginFlush(); + HRESULT STDMETHODCALLTYPE EndFlush(); + HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); + + CInputPin(IBaseFilter * ParentFilter, LPCWSTR PinName) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName){}; + virtual ~CInputPin(){}; + +protected: + LONG m_Ref; + IBaseFilter * m_ParentFilter; + LPCWSTR m_PinName; +}; + +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown) || + IsEqualGUID(refiid, IID_IPin)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CInputPin::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IPin interface +// +HRESULT +STDMETHODCALLTYPE +CInputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CInputPin::Connect called\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CInputPin::ReceiveConnection called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::Disconnect( void) +{ + OutputDebugStringW(L"CInputPin::Disconnect called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::ConnectedTo(IPin **pPin) +{ + OutputDebugStringW(L"CInputPin::ConnectedTo called\n"); + return VFW_E_NOT_CONNECTED; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CInputPin::ConnectionMediaType called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryPinInfo(PIN_INFO *pInfo) +{ + wcscpy(pInfo->achName, m_PinName); + pInfo->dir = PINDIR_INPUT; + pInfo->pFilter = m_ParentFilter; + m_ParentFilter->AddRef(); + + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryDirection(PIN_DIRECTION *pPinDir) +{ + if (pPinDir) + { + *pPinDir = PINDIR_INPUT; + return S_OK; + } + + return E_POINTER; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryId(LPWSTR *Id) +{ + *Id = (LPWSTR)CoTaskMemAlloc((wcslen(m_PinName)+1)*sizeof(WCHAR)); + if (!*Id) + return E_OUTOFMEMORY; + + wcscpy(*Id, m_PinName); + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryAccept(const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CInputPin::QueryAccept called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +{ + OutputDebugStringW(L"CInputPin::EnumMediaTypes called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) +{ + OutputDebugStringW(L"CInputPin::QueryInternalConnections called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EndOfStream( void) +{ + OutputDebugStringW(L"CInputPin::EndOfStream called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::BeginFlush( void) +{ + OutputDebugStringW(L"CInputPin::BeginFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EndFlush( void) +{ + OutputDebugStringW(L"CInputPin::EndFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) +{ + OutputDebugStringW(L"CInputPin::NewSegment called\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CInputPin_Constructor( + IBaseFilter * ParentFilter, + LPCWSTR PinName, + REFIID riid, + LPVOID * ppv) +{ + CInputPin * handler = new CInputPin(ParentFilter, PinName); + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return S_OK; +} diff --git a/reactos/dll/directx/ksproxy/ksproxy.rbuild b/reactos/dll/directx/ksproxy/ksproxy.rbuild index 76eb3aa8b20..4a4123061ca 100644 --- a/reactos/dll/directx/ksproxy/ksproxy.rbuild +++ b/reactos/dll/directx/ksproxy/ksproxy.rbuild @@ -26,9 +26,12 @@ cvpconfig.cpp cvpvbiconfig.cpp datatype.cpp + enumpins.cpp + input_pin.cpp interface.cpp ksproxy.cpp ksproxy.rc + output_pin.cpp proxy.cpp qualityforward.cpp diff --git a/reactos/dll/directx/ksproxy/output_pin.cpp b/reactos/dll/directx/ksproxy/output_pin.cpp new file mode 100644 index 00000000000..ba7b31bb131 --- /dev/null +++ b/reactos/dll/directx/ksproxy/output_pin.cpp @@ -0,0 +1,242 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy + * FILE: dll/directx/ksproxy/input_cpp.cpp + * PURPOSE: InputPin of Proxy Filter + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class COutputPin : public IPin +/* + public IQualityControl, + public IKsObject, + public IKsPinEx, + public IKsPinPipe, + public ISpecifyPropertyPages, + public IStreamBuilder, + public IKsPropertySet, + public IKsPinFactory, + public IKsControl, + public IKsAggregateControl + public IMediaSeeking, + public IAMStreamConfig, + public IMemAllocatorNotifyCallbackTemp +*/ +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + //IPin methods + HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE Disconnect(); + HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); + HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); + HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); + HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); + HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); + HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); + HRESULT STDMETHODCALLTYPE EndOfStream(); + HRESULT STDMETHODCALLTYPE BeginFlush(); + HRESULT STDMETHODCALLTYPE EndFlush(); + HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); + + COutputPin(IBaseFilter * ParentFilter, LPCWSTR PinName) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName){}; + virtual ~COutputPin(){}; + +protected: + LONG m_Ref; + IBaseFilter * m_ParentFilter; + LPCWSTR m_PinName; +}; + +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown) || + IsEqualGUID(refiid, IID_IPin)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"COutputPin::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IPin interface +// +HRESULT +STDMETHODCALLTYPE +COutputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"COutputPin::Connect called\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +COutputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"COutputPin::ReceiveConnection called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::Disconnect( void) +{ + OutputDebugStringW(L"COutputPin::Disconnect called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::ConnectedTo(IPin **pPin) +{ + OutputDebugStringW(L"COutputPin::ConnectedTo called\n"); + return VFW_E_NOT_CONNECTED; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"COutputPin::ConnectionMediaType called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryPinInfo(PIN_INFO *pInfo) +{ + wcscpy(pInfo->achName, m_PinName); + pInfo->dir = PINDIR_OUTPUT; + pInfo->pFilter = m_ParentFilter; + m_ParentFilter->AddRef(); + + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryDirection(PIN_DIRECTION *pPinDir) +{ + if (pPinDir) + { + *pPinDir = PINDIR_OUTPUT; + return S_OK; + } + + return E_POINTER; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryId(LPWSTR *Id) +{ + *Id = (LPWSTR)CoTaskMemAlloc((wcslen(m_PinName)+1)*sizeof(WCHAR)); + if (!*Id) + return E_OUTOFMEMORY; + + wcscpy(*Id, m_PinName); + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryAccept(const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"COutputPin::QueryAccept called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +{ + OutputDebugStringW(L"COutputPin::EnumMediaTypes called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) +{ + OutputDebugStringW(L"COutputPin::QueryInternalConnections called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::EndOfStream( void) +{ + OutputDebugStringW(L"COutputPin::EndOfStream called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::BeginFlush( void) +{ + OutputDebugStringW(L"COutputPin::BeginFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::EndFlush( void) +{ + OutputDebugStringW(L"COutputPin::EndFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) +{ + OutputDebugStringW(L"COutputPin::NewSegment called\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +COutputPin_Constructor( + IBaseFilter * ParentFilter, + LPCWSTR PinName, + REFIID riid, + LPVOID * ppv) +{ + COutputPin * handler = new COutputPin(ParentFilter, PinName); + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return S_OK; +} diff --git a/reactos/dll/directx/ksproxy/precomp.h b/reactos/dll/directx/ksproxy/precomp.h index ceef173034d..6ddcd6e647a 100644 --- a/reactos/dll/directx/ksproxy/precomp.h +++ b/reactos/dll/directx/ksproxy/precomp.h @@ -97,3 +97,30 @@ CKsProxy_Constructor( IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); + +/* input_pin.cpp */ +HRESULT +WINAPI +CInputPin_Constructor( + IBaseFilter * ParentFilter, + LPCWSTR PinName, + REFIID riid, + LPVOID * ppv); + +/* output_pin.cpp */ +HRESULT +WINAPI +COutputPin_Constructor( + IBaseFilter * ParentFilter, + LPCWSTR PinName, + REFIID riid, + LPVOID * ppv); + +/* enumpins.cpp */ +HRESULT +WINAPI +CEnumPins_fnConstructor( + std::vector Pins, + REFIID riid, + LPVOID * ppv) +; \ No newline at end of file diff --git a/reactos/dll/directx/ksproxy/proxy.cpp b/reactos/dll/directx/ksproxy/proxy.cpp index 23b013fafea..f9713895167 100644 --- a/reactos/dll/directx/ksproxy/proxy.cpp +++ b/reactos/dll/directx/ksproxy/proxy.cpp @@ -36,6 +36,7 @@ class CKsProxy : public IBaseFilter, { public: typedef std::vectorProxyPluginVector; + typedef std::vector PinVector; STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); @@ -81,7 +82,7 @@ public: // IKsObject HANDLE STDMETHODCALLTYPE KsGetObjectHandle(); - CKsProxy() : m_Ref(0), m_pGraph(0), m_ReferenceClock(0), m_FilterState(State_Stopped), m_hDevice(0), m_Plugins(0) {}; + CKsProxy() : m_Ref(0), m_pGraph(0), m_ReferenceClock(0), m_FilterState(State_Stopped), m_hDevice(0), m_Plugins(), m_Pins() {}; virtual ~CKsProxy() { if (m_hDevice) @@ -90,7 +91,11 @@ public: HRESULT STDMETHODCALLTYPE GetSupportedSets(LPGUID * pOutGuid, PULONG NumGuids); HRESULT STDMETHODCALLTYPE LoadProxyPlugins(LPGUID pGuids, ULONG NumGuids); - + HRESULT STDMETHODCALLTYPE GetNumberOfPins(PULONG NumPins); + HRESULT STDMETHODCALLTYPE GetPinInstanceCount(ULONG PinId, PKSPIN_CINSTANCES Instances); + HRESULT STDMETHODCALLTYPE GetPinDataflow(ULONG PinId, KSPIN_DATAFLOW * DataFlow); + HRESULT STDMETHODCALLTYPE GetPinName(ULONG PinId, KSPIN_DATAFLOW DataFlow, ULONG PinCount, LPWSTR * OutPinName); + HRESULT STDMETHODCALLTYPE CreatePins(); protected: LONG m_Ref; IFilterGraph *m_pGraph; @@ -98,6 +103,7 @@ protected: FILTER_STATE m_FilterState; HANDLE m_hDevice; ProxyPluginVector m_Plugins; + PinVector m_Pins; }; HRESULT @@ -291,6 +297,206 @@ CKsProxy::LoadProxyPlugins( return S_OK; } +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetNumberOfPins( + PULONG NumPins) +{ + KSPROPERTY Property; + ULONG BytesReturned; + + // setup request + Property.Set = KSPROPSETID_Pin; + Property.Id = KSPROPERTY_PIN_CTYPES; + Property.Flags = KSPROPERTY_TYPE_GET; + + return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)NumPins, sizeof(ULONG), &BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetPinInstanceCount( + ULONG PinId, + PKSPIN_CINSTANCES Instances) +{ + KSP_PIN Property; + ULONG BytesReturned; + + // setup request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_CINSTANCES; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = PinId; + Property.Reserved = 0; + + return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)Instances, sizeof(KSPIN_CINSTANCES), &BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetPinDataflow( + ULONG PinId, + KSPIN_DATAFLOW * DataFlow) +{ + KSP_PIN Property; + ULONG BytesReturned; + + // setup request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_DATAFLOW; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = PinId; + Property.Reserved = 0; + + return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)DataFlow, sizeof(KSPIN_DATAFLOW), &BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetPinName( + ULONG PinId, + KSPIN_DATAFLOW DataFlow, + ULONG PinCount, + LPWSTR * OutPinName) +{ + KSP_PIN Property; + LPWSTR PinName; + ULONG BytesReturned; + HRESULT hr; + WCHAR Buffer[100]; + + // setup request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_NAME; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = PinId; + Property.Reserved = 0; + + // #1 try get it from pin directly + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), NULL, 0, &BytesReturned); + + if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_MORE_DATA)) + { + // allocate pin name + PinName = (LPWSTR)CoTaskMemAlloc(BytesReturned); + if (!PinName) + return E_OUTOFMEMORY; + + // retry with allocated buffer + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), PinName, BytesReturned, &BytesReturned); + if (SUCCEEDED(hr)) + { + *OutPinName = PinName; + return hr; + } + + //free buffer + CoTaskMemFree(PinName); + } + + // + // TODO: retrieve pin name from topology node + // + + if (DataFlow == KSPIN_DATAFLOW_IN) + { + swprintf(Buffer, L"Input%lu", PinCount); + } + else + { + swprintf(Buffer, L"Output%lu", PinCount); + } + + // allocate pin name + PinName = (LPWSTR)CoTaskMemAlloc((wcslen(Buffer)+1) * sizeof(WCHAR)); + if (!PinName) + return E_OUTOFMEMORY; + + // copy pin name + wcscpy(PinName, Buffer); + + // store result + *OutPinName = PinName; + // done + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::CreatePins() +{ + ULONG NumPins, Index; + KSPIN_CINSTANCES Instances; + KSPIN_DATAFLOW DataFlow; + HRESULT hr; + WCHAR Buffer[100]; + LPWSTR PinName; + IPin * pPin; + ULONG InputPin = 0; + ULONG OutputPin = 0; + + // get number of pins + hr = GetNumberOfPins(&NumPins); + if (FAILED(hr)) + return hr; + + for(Index = 0; Index < NumPins; Index++) + { + // query current instance count + hr = GetPinInstanceCount(Index, &Instances); + if (FAILED(hr)) + continue; + + if (Instances.CurrentCount == Instances.PossibleCount) + { + // already maximum reached for this pin + continue; + } + + // get direction of pin + hr = GetPinDataflow(Index, &DataFlow); + if (FAILED(hr)) + continue; + + if (DataFlow == KSPIN_DATAFLOW_IN) + hr = GetPinName(Index, DataFlow, InputPin, &PinName); + else + hr = GetPinName(Index, DataFlow, OutputPin, &PinName); + + if (FAILED(hr)) + continue; + + // construct the pins + if (DataFlow == KSPIN_DATAFLOW_IN) + { + hr = CInputPin_Constructor((IBaseFilter*)this, PinName, IID_IPin, (void**)&pPin); + if (FAILED(hr)) + { + CoTaskMemFree(PinName); + continue; + } + InputPin++; + } + else + { + hr = COutputPin_Constructor((IBaseFilter*)this, PinName, IID_IPin, (void**)&pPin); + if (FAILED(hr)) + { + CoTaskMemFree(PinName); + continue; + } + OutputPin++; + } + + // store pins + m_Pins.push_back(pPin); + + swprintf(Buffer, L"Index %lu DataFlow %lu Name %s\n", Index, DataFlow, PinName); + OutputDebugStringW(Buffer); + } + + return S_OK; +} HRESULT STDMETHODCALLTYPE @@ -336,6 +542,19 @@ CKsProxy::Load(IPropertyBag *pPropBag, IErrorLog *pErrorLog) // load all proxy plugins hr = LoadProxyPlugins(pGuid, NumGuids); + if (FAILED(hr)) + { + CloseHandle(m_hDevice); + m_hDevice = NULL; + return hr; + } + + // free sets + CoTaskMemFree(pGuid); + + // now create the input / output pins + hr = CreatePins(); + CloseHandle(m_hDevice); m_hDevice = NULL; @@ -438,8 +657,8 @@ STDMETHODCALLTYPE CKsProxy::EnumPins( IEnumPins **ppEnum) { - OutputDebugStringW(L"CKsProxy::EnumPins : NotImplemented\n"); - return E_NOTIMPL; + OutputDebugStringW(L"CKsProxy::EnumPins\n"); + return CEnumPins_fnConstructor(m_Pins, IID_IEnumPins, (void**)ppEnum); } HRESULT diff --git a/reactos/dll/directx/msdvbnp/enum_mediatypes.cpp b/reactos/dll/directx/msdvbnp/enum_mediatypes.cpp index f1497ab737e..6cd887f358c 100644 --- a/reactos/dll/directx/msdvbnp/enum_mediatypes.cpp +++ b/reactos/dll/directx/msdvbnp/enum_mediatypes.cpp @@ -23,7 +23,7 @@ public: InterlockedDecrement(&m_Ref); if (!m_Ref) { - //delete this; + delete this; return 0; } return m_Ref; diff --git a/reactos/dll/directx/msdvbnp/enumpins.cpp b/reactos/dll/directx/msdvbnp/enumpins.cpp index 3887be48a1f..567705907b7 100644 --- a/reactos/dll/directx/msdvbnp/enumpins.cpp +++ b/reactos/dll/directx/msdvbnp/enumpins.cpp @@ -23,7 +23,7 @@ public: InterlockedDecrement(&m_Ref); if (!m_Ref) { - //delete this; + delete this; return 0; } return m_Ref; @@ -95,6 +95,8 @@ CEnumPins::Next( break; ppPins[i] = m_Pins[m_Index + i]; + m_Pins[m_Index + i]->AddRef(); + i++; } diff --git a/reactos/dll/directx/msdvbnp/networkprovider.cpp b/reactos/dll/directx/msdvbnp/networkprovider.cpp index 926a7516196..c69c2336e48 100644 --- a/reactos/dll/directx/msdvbnp/networkprovider.cpp +++ b/reactos/dll/directx/msdvbnp/networkprovider.cpp @@ -25,7 +25,7 @@ public: InterlockedDecrement(&m_Ref); if (!m_Ref) { - //delete this; + delete this; return 0; } return m_Ref; diff --git a/reactos/dll/directx/msdvbnp/pin.cpp b/reactos/dll/directx/msdvbnp/pin.cpp index 52ce7ecb943..288a312dcc1 100644 --- a/reactos/dll/directx/msdvbnp/pin.cpp +++ b/reactos/dll/directx/msdvbnp/pin.cpp @@ -26,7 +26,7 @@ public: InterlockedDecrement(&m_Ref); if (!m_Ref) { - //delete this; + delete this; return 0; } return m_Ref; @@ -137,6 +137,7 @@ CPin::QueryPinInfo(PIN_INFO *pInfo) wcscpy(pInfo->achName, PIN_ID); pInfo->dir = PINDIR_OUTPUT; pInfo->pFilter = m_ParentFilter; + m_ParentFilter->AddRef(); return S_OK; } @@ -182,7 +183,7 @@ CPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) } MediaType->majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA; - MediaType->subtype = GUID_NULL; + MediaType->subtype = MEDIASUBTYPE_None; MediaType->formattype = GUID_NULL; MediaType->bFixedSizeSamples = true; MediaType->bTemporalCompression = false; diff --git a/reactos/dll/directx/msdvbnp/scanningtuner.cpp b/reactos/dll/directx/msdvbnp/scanningtuner.cpp index bcedd51c239..0c9b7782d2b 100644 --- a/reactos/dll/directx/msdvbnp/scanningtuner.cpp +++ b/reactos/dll/directx/msdvbnp/scanningtuner.cpp @@ -23,7 +23,7 @@ public: InterlockedDecrement(&m_Ref); if (!m_Ref) { - //delete this; + delete this; return 0; } return m_Ref; From d3e6d12585f19a971c62dee107e7fe36a2e1b337 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 2 Mar 2010 21:10:35 +0000 Subject: [PATCH 039/211] - Fix some missing strings in cpu.inf - Add it to build svn path=/trunk/; revision=45769 --- reactos/boot/bootdata/packages/reactos.dff | 1 + reactos/media/inf/cpu.inf | Bin 4654 -> 4712 bytes 2 files changed, 1 insertion(+) diff --git a/reactos/boot/bootdata/packages/reactos.dff b/reactos/boot/bootdata/packages/reactos.dff index 248f5f7c347..e41d90082a1 100644 --- a/reactos/boot/bootdata/packages/reactos.dff +++ b/reactos/boot/bootdata/packages/reactos.dff @@ -629,6 +629,7 @@ media\drivers\etc\services 5 media\inf\audio.inf 6 media\inf\acpi.inf 6 media\inf\cdrom.inf 6 +media\inf\cpu.inf 6 media\inf\display.inf 6 media\inf\font.inf 6 media\inf\fdc.inf 6 diff --git a/reactos/media/inf/cpu.inf b/reactos/media/inf/cpu.inf index 1478fe4c001431c187fb2284006766c34b874be3..12416a0d2b672395f42f987040126f9c73dd9a7b 100644 GIT binary patch delta 78 zcmZ3d@*F+${h9aWMb@@2?U- delta 20 ccmaE%vQA~gG^WjSnBFjN-o>_xn~9470AHX7n*aa+ From b5b3b3702fb1a9de479178e71c88f7113d8df01f Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 2 Mar 2010 22:37:43 +0000 Subject: [PATCH 040/211] [PORTCLS] - Don't free stream header as wdmaud.sys mmaps it svn path=/trunk/; revision=45770 --- reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp index 7d82ae7660d..b3ce1d4d03b 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp @@ -572,9 +572,6 @@ CIrpQueue::ReleaseMappingWithTag( Irp->IoStatus.Information = StreamHeader->FrameExtent; - // free stream header, no tag as wdmaud.drv allocates it atm - ExFreePool(StreamHeader); - // complete the request IoCompleteRequest(Irp, IO_SOUND_INCREMENT); From ed57cdcfde35779efe494d91ea9a926cc619bf65 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 3 Mar 2010 00:05:17 +0000 Subject: [PATCH 041/211] - Stub GetExtendedTcpTable - Fixes bug 5201 - Patch by Olaf Siejka svn path=/trunk/; revision=45771 --- reactos/dll/win32/iphlpapi/iphlpapi.spec | 2 +- reactos/dll/win32/iphlpapi/iphlpapi_main.c | 26 ++++++++++++++++++++++ reactos/include/psdk/iphlpapi.h | 1 + reactos/include/psdk/iprtrmib.h | 13 +++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/iphlpapi/iphlpapi.spec b/reactos/dll/win32/iphlpapi/iphlpapi.spec index 788666a6948..b07c464fb76 100644 --- a/reactos/dll/win32/iphlpapi/iphlpapi.spec +++ b/reactos/dll/win32/iphlpapi/iphlpapi.spec @@ -32,7 +32,7 @@ @ stub GetBestInterfaceFromStack @ stdcall GetBestRoute( long long long ) @ stub GetBestRouteFromStack -@ stub GetExtendedTcpTable +@ stdcall GetExtendedTcpTable( ptr ptr long long long long ) @ stub GetExtendedUdpTable @ stdcall GetFriendlyIfIndex( long ) @ stdcall GetIcmpStatistics( ptr ) diff --git a/reactos/dll/win32/iphlpapi/iphlpapi_main.c b/reactos/dll/win32/iphlpapi/iphlpapi_main.c index 6d27ce66e80..47146e6cd14 100644 --- a/reactos/dll/win32/iphlpapi/iphlpapi_main.c +++ b/reactos/dll/win32/iphlpapi/iphlpapi_main.c @@ -789,6 +789,32 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO return ret; } +/****************************************************************** + * GetExtendedTcpTable (IPHLPAPI.@) + * + * Get the table of TCP endpoints available to the application. + * + * PARAMS + * pTcpTable [Out] table struct with the filtered TCP endpoints available to application + * pdwSize [In/Out] estimated size of the structure returned in pTcpTable, in bytes + * bOrder [In] whether to order the table + * ulAf [in] version of IP used by the TCP endpoints + * TableClass [in] type of the TCP table structure from TCP_TABLE_CLASS + * Reserved [in] reserved - this value must be zero + * + * RETURNS + * Success: NO_ERROR + * Failure: either ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER + * + * NOTES + */ +DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved) +{ + DWORD ret = NO_ERROR; + UNIMPLEMENTED; + return ret; +} + /****************************************************************** * GetFriendlyIfIndex (IPHLPAPI.@) diff --git a/reactos/include/psdk/iphlpapi.h b/reactos/include/psdk/iphlpapi.h index 1a844d38a49..9637194b5d2 100644 --- a/reactos/include/psdk/iphlpapi.h +++ b/reactos/include/psdk/iphlpapi.h @@ -22,6 +22,7 @@ DWORD WINAPI GetAdapterIndex(LPWSTR,PULONG); DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO,PULONG); DWORD WINAPI GetBestInterface(IPAddr,PDWORD); DWORD WINAPI GetBestRoute(DWORD,DWORD,PMIB_IPFORWARDROW); +DWORD WINAPI GetExtendedTcpTable(PVOID,PDWORD,BOOL,ULONG,TCP_TABLE_CLASS,ULONG); DWORD WINAPI GetFriendlyIfIndex(DWORD); DWORD WINAPI GetIcmpStatistics(PMIB_ICMP); DWORD WINAPI GetIfEntry(PMIB_IFROW); diff --git a/reactos/include/psdk/iprtrmib.h b/reactos/include/psdk/iprtrmib.h index a59796f0237..6f182944fce 100644 --- a/reactos/include/psdk/iprtrmib.h +++ b/reactos/include/psdk/iprtrmib.h @@ -286,4 +286,17 @@ typedef struct _MIB_IPNETTABLE MIB_IPNETROW table[1]; } MIB_IPNETTABLE, *PMIB_IPNETTABLE; + +typedef enum { + TCP_TABLE_BASIC_LISTENER, + TCP_TABLE_BASIC_CONNECTIONS, + TCP_TABLE_BASIC_ALL, + TCP_TABLE_OWNER_PID_LISTENER, + TCP_TABLE_OWNER_PID_CONNECTIONS, + TCP_TABLE_OWNER_PID_ALL, + TCP_TABLE_OWNER_MODULE_LISTENER, + TCP_TABLE_OWNER_MODULE_CONNECTIONS, + TCP_TABLE_OWNER_MODULE_ALL +} TCP_TABLE_CLASS, *PTCP_TABLE_CLASS; + #endif /* WINE_IPRTRMIB_H__ */ From 426585e336517826a60881917d8b9c6a70736742 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 3 Mar 2010 01:02:12 +0000 Subject: [PATCH 042/211] - Add an entry for the high precision event timer svn path=/trunk/; revision=45772 --- reactos/media/inf/machine.inf | Bin 45368 -> 45554 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/reactos/media/inf/machine.inf b/reactos/media/inf/machine.inf index c5eddb5d96569c78e086d10dd41df6a5c2e0202f..7b7e0a9d3026fd75257188e6899e1686858204b5 100644 GIT binary patch delta 130 zcmdn-i0RW~rVV+l{9FvG3|b5U41Pdtz+gDJkxhAW0ISU8BWyyO>sW7y@^Ya`OHX!) zG!NN31kP+%xvC}K!uNM^`nCujDN Py=*Gm|9}7gaWMb@P+=n( delta 22 ecmezLm}$o&rVV+loA Date: Wed, 3 Mar 2010 01:40:04 +0000 Subject: [PATCH 043/211] - Handle the special case of ACPI device, the fixed feature button, which is not given a handle because it is the direct child of the ACPI root device and is not handled by acpi_bus_get_device (see FIXME in that function). Fortunately, this is not a problem for us since we don't need to differentiate between different "features" of each fixed feature button. We can simply enumerate it as "ACPI\FixedButton" based on its NULL handle. - Strange registry corruption bug on QEMU is gone now svn path=/trunk/; revision=45773 --- reactos/drivers/bus/acpi/buspdo.c | 86 ++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/reactos/drivers/bus/acpi/buspdo.c b/reactos/drivers/bus/acpi/buspdo.c index 2f1ff5a08f3..556f5cad966 100644 --- a/reactos/drivers/bus/acpi/buspdo.c +++ b/reactos/drivers/bus/acpi/buspdo.c @@ -394,11 +394,23 @@ Bus_PDO_QueryDeviceId( switch (stack->Parameters.QueryId.IdType) { case BusQueryDeviceID: - acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + if (DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); - length = swprintf(temp, - L"ACPI\\%hs", - Device->pnp.hardware_id); + length = swprintf(temp, + L"ACPI\\%hs", + Device->pnp.hardware_id); + } + else + { + /* We know it's a fixed feature button because + * these are direct children of the ACPI root device + * and therefore have no handle + */ + length = swprintf(temp, + L"ACPI\\FixedButton"); + } temp[++length] = UNICODE_NULL; @@ -415,15 +427,22 @@ Bus_PDO_QueryDeviceId( break; case BusQueryInstanceID: - acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + /* See comment in BusQueryDeviceID case */ + if(DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); - if(Device->flags.unique_id) - length = swprintf(temp, - L"%hs", - Device->pnp.unique_id); + if (Device->flags.unique_id) + length = swprintf(temp, + L"%hs", + Device->pnp.unique_id); + else + /* FIXME: Generate unique id! */ + length = swprintf(temp, L"%ls", L"0000"); + } else - /* FIXME: Generate unique id! */ - length = swprintf(temp, L"%ls", L"0000"); + /* FIXME: Generate unique id! */ + length = swprintf(temp, L"%ls", L"0000"); temp[++length] = UNICODE_NULL; @@ -439,25 +458,39 @@ Bus_PDO_QueryDeviceId( break; case BusQueryHardwareIDs: - acpi_bus_get_device(DeviceData->AcpiHandle, &Device); - length = 0; - length += swprintf(&temp[length], - L"ACPI\\%hs", - Device->pnp.hardware_id); - length++; + /* See comment in BusQueryDeviceID case */ + if (DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); - length += swprintf(&temp[length], - L"*%hs", - Device->pnp.hardware_id); - length++; + length += swprintf(&temp[length], + L"ACPI\\%hs", + Device->pnp.hardware_id); + length++; - temp[length] = UNICODE_NULL; + length += swprintf(&temp[length], + L"*%hs", + Device->pnp.hardware_id); + length++; + } + else + { + length += swprintf(&temp[length], + L"ACPI\\FixedButton"); + length++; - length++; + length += swprintf(&temp[length], + L"*FixedButton"); + length++; + } - temp[length] = UNICODE_NULL; + temp[length] = UNICODE_NULL; + + length++; + + temp[length] = UNICODE_NULL; buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR), 'IPCA'); @@ -554,6 +587,11 @@ Bus_PDO_QueryDeviceText( Buffer = L"Smart Battery"; else if (wcsstr(DeviceData->HardwareIDs, L"ACPI0003") != 0) Buffer = L"AC Adapter"; + /* Simply checking if AcpiHandle is NULL eliminates the need to check + * for the 4 different names that ACPI knows the fixed feature button as internally + */ + else if (!DeviceData->AcpiHandle) + Buffer = L"ACPI Fixed Feature Button"; else Buffer = L"Other ACPI device"; From 7b6dfd6be48fd5bdb5590db3d747e248be0fcf06 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 3 Mar 2010 02:27:14 +0000 Subject: [PATCH 044/211] [NTOS] - Rewrite trap handler exit stubs in pure assembly, remove gcc inline assembly. - Replace jmp to C handler with KiCallHandler macro, that expands to jmp on release builds for speed and call on debug builds to fix backtraces. - Unroll the Syscall handler loop and use volatile keyword when reloading TrapFrame and DescriptorTable from the new stack to prevent the compiler from optimizing it away / moving it out of the loop. - Bugcheck in KiTrap0DHandler, if the fault couldn't be resolved. - Remove handling of V86 traps and edited traps in KiServiceExit, ASSERT to make sure they never happen. - Replace code patching of the syscall exit handler with a function pointer. - Use __debugbreak() instead of while(TRUE) in KiExitTrapDebugChecks svn path=/trunk/; revision=45774 --- .../ntoskrnl/include/internal/i386/asmmacro.S | 156 ++++++- reactos/ntoskrnl/include/internal/trap_x.h | 379 ++---------------- reactos/ntoskrnl/ke/i386/cpu.c | 71 +--- reactos/ntoskrnl/ke/i386/trap.s | 26 +- reactos/ntoskrnl/ke/i386/traphdlr.c | 337 +++++++++------- 5 files changed, 409 insertions(+), 560 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S index d8ca99da594..6ddb9d015ad 100644 --- a/reactos/ntoskrnl/include/internal/i386/asmmacro.S +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -179,6 +179,14 @@ set_sane_segs: mov fs, ax endif +#if DBG + /* Keep the frame chain intact */ + mov eax, [esp + KTRAP_FRAME_EIP] + mov [esp + KTRAP_FRAME_DEBUGEIP], eax + mov [esp + KTRAP_FRAME_DEBUGEBP], ebp + mov ebp, esp +#endif + /* Set parameter 1 (ECX) to point to the frame */ mov ecx, esp @@ -187,11 +195,157 @@ set_sane_segs: ENDM +MACRO(KiCallHandler, Handler) +#if DBG + /* Use a call to get the return address for back traces */ + call Handler +#else + /* Use the faster jmp */ + jmp Handler +#endif + nop +ENDM + MACRO(TRAP_ENTRY, Trap, Flags) EXTERN @&Trap&Handler@4 :PROC PUBLIC _&Trap _&Trap: KiEnterTrap Flags - jmp @&Trap&Handler@4 + KiCallHandler @&Trap&Handler@4 +ENDM + +#define KI_RESTORE_EAX HEX(001) +#define KI_RESTORE_ECX_EDX HEX(002) +#define KI_RESTORE_FS HEX(004) +#define KI_RESTORE_SEGMENTS HEX(008) +#define KI_RESTORE_EFLAGS HEX(010) +#define KI_EXIT_SYSCALL HEX(020) +#define KI_EXIT_JMP HEX(040) +#define KI_EXIT_RET HEX(080) +#define KI_EXIT_IRET HEX(100) +#define KI_EDITED_FRAME HEX(200) +#define KI_RESTORE_VOLATILES (KI_RESTORE_EAX OR KI_RESTORE_ECX_EDX) + +MACRO(KiTrapExitStub, Name, Flags) + +PUBLIC @&Name&@4 +@&Name&@4: + + if (Flags AND KI_RESTORE_EFLAGS) + + /* We will pop EFlags off the stack */ + OffsetEsp = KTRAP_FRAME_EFLAGS + + elseif (Flags AND KI_EXIT_IRET) + + /* This is the IRET frame */ + OffsetEsp = KTRAP_FRAME_EIP + + else + + OffsetEsp = 0 + + endif + + if (Flags AND KI_EDITED_FRAME) + + /* Load the requested ESP */ + mov esp, [ecx + KTRAP_FRAME_TEMPESP] + + /* Put return address on the new stack */ + push [ecx + KTRAP_FRAME_EIP] + + /* Put EFLAGS on the new stack */ + push [ecx + KTRAP_FRAME_EFLAGS] + + else + + /* Point esp to an appropriate member of the frame */ + lea esp, [ecx + OffsetEsp] + + endif + + /* Restore non volatiles */ + mov ebx, [ecx + KTRAP_FRAME_EBX] + mov esi, [ecx + KTRAP_FRAME_ESI] + mov edi, [ecx + KTRAP_FRAME_EDI] + mov ebp, [ecx + KTRAP_FRAME_EBP] + + if (Flags AND KI_RESTORE_EAX) + + /* Restore eax */ + mov eax, [ecx + KTRAP_FRAME_EAX] + + endif + + if (Flags AND KI_RESTORE_ECX_EDX) + + /* Restore volatiles */ + mov edx, [ecx + KTRAP_FRAME_EDX] + mov ecx, [ecx + KTRAP_FRAME_ECX] + + elseif (Flags AND KI_EXIT_JMP) + + /* Load return address into edx */ + mov edx, [esp - OffsetEsp + KTRAP_FRAME_EIP] + + elseif (Flags AND KI_EXIT_SYSCALL) + + /* Set sysexit parameters */ + mov edx, [esp - OffsetEsp + KTRAP_FRAME_EIP] + mov ecx, [esp - OffsetEsp + KTRAP_FRAME_ESP] + + /* Keep interrupts disabled until the sti / sysexit */ + and byte ptr [esp - OffsetEsp + KTRAP_FRAME_EFLAGS + 1], ~(EFLAGS_INTERRUPT_MASK >> 8) + + endif + + if (Flags AND KI_RESTORE_SEGMENTS) + + /* Restore segments for user mode */ + mov ds, [esp - OffsetEsp + KTRAP_FRAME_DS] + mov es, [esp - OffsetEsp + KTRAP_FRAME_ES] + mov gs, [esp - OffsetEsp + KTRAP_FRAME_GS] + + endif + + if ((Flags AND KI_RESTORE_FS) OR (Flags AND KI_RESTORE_SEGMENTS)) + + /* Restore user mode FS */ + mov fs, [esp - OffsetEsp + KTRAP_FRAME_FS] + + endif + + if (Flags AND KI_RESTORE_EFLAGS) + + /* Restore EFLAGS */ + popf + + endif + + if (Flags AND KI_EXIT_SYSCALL) + + /* Enable interrupts and return to user mode. + Both must follow directly after another to be "atomic". */ + sti + sysexit + + elseif (Flags AND KI_EXIT_IRET) + + /* Return with iret */ + iret + + elseif (Flags AND KI_EXIT_JMP) + + /* Return to kernel mode with a jmp */ + jmp edx + + elseif (Flags AND KI_EXIT_RET) + + /* Return to kernel mode with a ret */ + ret + + endif + ENDM diff --git a/reactos/ntoskrnl/include/internal/trap_x.h b/reactos/ntoskrnl/include/internal/trap_x.h index 69ccde543f5..ccc98df4a00 100644 --- a/reactos/ntoskrnl/include/internal/trap_x.h +++ b/reactos/ntoskrnl/include/internal/trap_x.h @@ -8,6 +8,8 @@ #pragma once +//#define TRAP_DEBUG 1 + // // Unreachable code hint for GCC 4.5.x, older GCC versions, and MSVC // @@ -23,6 +25,17 @@ #define UNREACHABLE #endif +// +// Helper Code +// +BOOLEAN +FORCEINLINE +KiUserTrap(IN PKTRAP_FRAME TrapFrame) +{ + /* Anything else but Ring 0 is Ring 3 */ + return (TrapFrame->SegCs & MODE_MASK); +} + // // Debug Macros // @@ -77,19 +90,20 @@ KiFillTrapFrameDebug(IN PKTRAP_FRAME TrapFrame) TrapFrame->DbgArgPointer = TrapFrame->Edx; TrapFrame->DbgArgMark = 0xBADB0D00; TrapFrame->DbgEip = TrapFrame->Eip; - TrapFrame->DbgEbp = TrapFrame->Ebp; + TrapFrame->DbgEbp = TrapFrame->Ebp; + TrapFrame->PreviousPreviousMode = -1; } VOID FORCEINLINE KiExitTrapDebugChecks(IN PKTRAP_FRAME TrapFrame, - IN KTRAP_STATE_BITS SkipBits) + IN KTRAP_EXIT_SKIP_BITS SkipBits) { /* Make sure interrupts are disabled */ if (__readeflags() & EFLAGS_INTERRUPT_MASK) { DbgPrint("Exiting with interrupts enabled: %lx\n", __readeflags()); - while (TRUE); + __debugbreak(); } /* Make sure this is a real trap frame */ @@ -97,35 +111,35 @@ KiExitTrapDebugChecks(IN PKTRAP_FRAME TrapFrame, { DbgPrint("Exiting with an invalid trap frame? (No MAGIC in trap frame)\n"); KiDumpTrapFrame(TrapFrame); - while (TRUE); + __debugbreak(); } /* Make sure we're not in user-mode or something */ if (Ke386GetFs() != KGDT_R0_PCR) { DbgPrint("Exiting with an invalid FS: %lx\n", Ke386GetFs()); - while (TRUE); + __debugbreak(); } /* Make sure we have a valid SEH chain */ if (KeGetPcr()->Tib.ExceptionList == 0) { DbgPrint("Exiting with NULL exception chain: %p\n", KeGetPcr()->Tib.ExceptionList); - while (TRUE); + __debugbreak(); } /* Make sure we're restoring a valid SEH chain */ if (TrapFrame->ExceptionList == 0) { DbgPrint("Entered a trap with a NULL exception chain: %p\n", TrapFrame->ExceptionList); - while (TRUE); + __debugbreak(); } /* If we're ignoring previous mode, make sure caller doesn't actually want it */ if ((SkipBits.SkipPreviousMode) && (TrapFrame->PreviousPreviousMode != -1)) { - DbgPrint("Exiting a trap witout restoring previous mode, yet previous mode seems valid: %lx", TrapFrame->PreviousPreviousMode); - while (TRUE); + DbgPrint("Exiting a trap witout restoring previous mode, yet previous mode seems valid: %lx\n", TrapFrame->PreviousPreviousMode); + __debugbreak(); } } @@ -137,14 +151,14 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall, KIRQL OldIrql; /* Check if this was a user call */ - if (KiUserMode(TrapFrame)) + if (KiUserTrap(TrapFrame)) { /* Make sure we are not returning with elevated IRQL */ OldIrql = KeGetCurrentIrql(); if (OldIrql != PASSIVE_LEVEL) { /* Forcibly put us in a sane state */ - KeGetPcr()->CurrentIrql = PASSIVE_LEVEL; + KeGetPcr()->Irql = PASSIVE_LEVEL; _disable(); /* Fail */ @@ -154,7 +168,7 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall, 0, 0); } - +#if 0 /* Make sure we're not attached and that APCs are not disabled */ if ((KeGetCurrentThread()->ApcStateIndex != CurrentApcEnvironment) || (KeGetCurrentThread()->CombinedApcDisable != 0)) @@ -166,6 +180,7 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall, KeGetCurrentThread()->CombinedApcDisable, 0); } +#endif } } #else @@ -174,334 +189,20 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall, #define KiExitSystemCallDebugChecks(x, y) #endif -// -// Helper Code -// -BOOLEAN -FORCEINLINE -KiUserTrap(IN PKTRAP_FRAME TrapFrame) -{ - /* Anything else but Ring 0 is Ring 3 */ - return (TrapFrame->SegCs & MODE_MASK); -} - -// -// "BOP" code used by VDM and V8086 Mode -// -VOID -FORCEINLINE -KiIssueBop(VOID) -{ - /* Invalid instruction that an invalid opcode handler must trap and handle */ - asm volatile(".byte 0xC4\n.byte 0xC4\n"); -} - -VOID -FORCEINLINE -KiUserSystemCall(IN PKTRAP_FRAME TrapFrame) -{ - /* - * Kernel call or user call? - * - * This decision is made in inlined assembly because we need to patch - * the relative offset of the user-mode jump to point to the SYSEXIT - * routine if the CPU supports it. The only way to guarantee that a - * relative jnz/jz instruction is generated is to force it with the - * inline assembler. - */ - asm volatile - ( - "test $1, %0\n" /* MODE_MASK */ - ".globl _KiSystemCallExitBranch\n_KiSystemCallExitBranch:\n" - "jnz _KiSystemCallExit\n" - : - : "r"(TrapFrame->SegCs) - ); -} - -// -// Generates an Exit Epilog Stub for the given name -// -#define KI_FUNCTION_CALL 0x1 -#define KI_EDITED_FRAME 0x2 -#define KI_DIRECT_EXIT 0x4 -#define KI_FAST_SYSTEM_CALL_EXIT 0x8 -#define KI_SYSTEM_CALL_EXIT 0x10 -#define KI_SYSTEM_CALL_JUMP 0x20 -#define KiTrapExitStub(x, y) VOID FORCEINLINE DECLSPEC_NORETURN x(IN PKTRAP_FRAME TrapFrame) { KiTrapExit(TrapFrame, y); UNREACHABLE; } -#define KiTrapExitStub2(x, y) VOID FORCEINLINE x(IN PKTRAP_FRAME TrapFrame) { KiTrapExit(TrapFrame, y); } - -// -// How volatiles will be restored -// -#define KI_EAX_NO_VOLATILES 0x0 -#define KI_EAX_ONLY 0x1 -#define KI_ALL_VOLATILES 0x2 - -// -// Exit mechanism to use -// -#define KI_EXIT_IRET 0x0 -#define KI_EXIT_SYSEXIT 0x1 -#define KI_EXIT_JMP 0x2 -#define KI_EXIT_RET 0x3 - -// -// Master Trap Epilog -// -VOID -FORCEINLINE -KiTrapExit(IN PKTRAP_FRAME TrapFrame, - IN ULONG Flags) -{ - ULONG FrameSize = FIELD_OFFSET(KTRAP_FRAME, Eip); - ULONG ExitMechanism = KI_EXIT_IRET, Volatiles = KI_ALL_VOLATILES, NonVolatiles = TRUE; - ULONG EcxField = FIELD_OFFSET(KTRAP_FRAME, Ecx), EdxField = FIELD_OFFSET(KTRAP_FRAME, Edx); - - /* System call exit needs a special label */ - if (Flags & KI_SYSTEM_CALL_EXIT) __asm__ __volatile__ - ( - ".globl _KiSystemCallExit\n_KiSystemCallExit:\n" - ); - - /* Start by making the trap frame equal to the stack */ - __asm__ __volatile__ - ( - "movl %0, %%esp\n" - : - : "r"(TrapFrame) - : "%esp" - ); - - /* Check what kind of trap frame this trap requires */ - if (Flags & KI_FUNCTION_CALL) - { - /* These calls have an EIP on the stack they need */ - ExitMechanism = KI_EXIT_RET; - Volatiles = FALSE; - } - else if (Flags & KI_EDITED_FRAME) - { - /* Edited frames store a new ESP in the error code field */ - FrameSize = FIELD_OFFSET(KTRAP_FRAME, ErrCode); - } - else if (Flags & KI_DIRECT_EXIT) - { - /* Exits directly without restoring anything, interrupt frame on stack */ - NonVolatiles = Volatiles = FALSE; - } - else if (Flags & KI_FAST_SYSTEM_CALL_EXIT) - { - /* We have a fake interrupt stack with a ring transition */ - FrameSize = FIELD_OFFSET(KTRAP_FRAME, V86Es); - ExitMechanism = KI_EXIT_SYSEXIT; - - /* SYSEXIT wants EIP in EDX and ESP in ECX */ - EcxField = FIELD_OFFSET(KTRAP_FRAME, HardwareEsp); - EdxField = FIELD_OFFSET(KTRAP_FRAME, Eip); - } - else if (Flags & KI_SYSTEM_CALL_EXIT) - { - /* Only restore EAX */ - NonVolatiles = KI_EAX_ONLY; - } - else if (Flags & KI_SYSTEM_CALL_JUMP) - { - /* We have a fake interrupt stack with no ring transition */ - FrameSize = FIELD_OFFSET(KTRAP_FRAME, HardwareEsp); - NonVolatiles = KI_EAX_ONLY; - ExitMechanism = KI_EXIT_JMP; - } - - /* Restore the non volatiles */ - if (NonVolatiles) __asm__ __volatile__ - ( - "movl %c[b](%%esp), %%ebx\n" - "movl %c[s](%%esp), %%esi\n" - "movl %c[i](%%esp), %%edi\n" - "movl %c[p](%%esp), %%ebp\n" - : - : [b] "i"(FIELD_OFFSET(KTRAP_FRAME, Ebx)), - [s] "i"(FIELD_OFFSET(KTRAP_FRAME, Esi)), - [i] "i"(FIELD_OFFSET(KTRAP_FRAME, Edi)), - [p] "i"(FIELD_OFFSET(KTRAP_FRAME, Ebp)) - : "%esp" - ); - - /* Restore EAX if volatiles must be restored */ - if (Volatiles) __asm__ __volatile__ - ( - "movl %c[a](%%esp), %%eax\n":: [a] "i"(FIELD_OFFSET(KTRAP_FRAME, Eax)) : "%esp" - ); - - /* Restore the other volatiles if needed */ - if (Volatiles == KI_ALL_VOLATILES) __asm__ __volatile__ - ( - "movl %c[c](%%esp), %%ecx\n" - "movl %c[d](%%esp), %%edx\n" - : - : [c] "i"(EcxField), - [d] "i"(EdxField) - : "%esp" - ); - - /* Ring 0 system calls jump back to EDX */ - if (Flags & KI_SYSTEM_CALL_JUMP) __asm__ __volatile__ - ( - "movl %c[d](%%esp), %%edx\n":: [d] "i"(FIELD_OFFSET(KTRAP_FRAME, Eip)) : "%esp" - ); - - /* Now destroy the trap frame on the stack */ - __asm__ __volatile__ ("addl $%c[e],%%esp\n":: [e] "i"(FrameSize) : "%esp"); - - /* Edited traps need to change to a new ESP */ - if (Flags & KI_EDITED_FRAME) __asm__ __volatile__ ("movl (%%esp), %%esp\n":::"%esp"); - - /* Check the exit mechanism and apply it */ - if (ExitMechanism == KI_EXIT_RET) __asm__ __volatile__("ret\n"::: "%esp"); - else if (ExitMechanism == KI_EXIT_IRET) __asm__ __volatile__("iret\n"::: "%esp"); - else if (ExitMechanism == KI_EXIT_JMP) __asm__ __volatile__("jmp *%%edx\n.globl _KiSystemCallExit2\n_KiSystemCallExit2:\n"::: "%esp"); - else if (ExitMechanism == KI_EXIT_SYSEXIT) __asm__ __volatile__("sti\nsysexit\n"::: "%esp"); -} - -// -// All the specific trap epilog stubs -// -KiTrapExitStub (KiTrapReturn, 0); -KiTrapExitStub (KiDirectTrapReturn, KI_DIRECT_EXIT); -KiTrapExitStub (KiCallReturn, KI_FUNCTION_CALL); -KiTrapExitStub (KiEditedTrapReturn, KI_EDITED_FRAME); -KiTrapExitStub2(KiSystemCallReturn, KI_SYSTEM_CALL_JUMP); -KiTrapExitStub (KiSystemCallSysExitReturn, KI_FAST_SYSTEM_CALL_EXIT); -KiTrapExitStub (KiSystemCallTrapReturn, KI_SYSTEM_CALL_EXIT); - // // Generic Exit Routine // +VOID FASTCALL DECLSPEC_NORETURN KiSystemCallReturn(IN PKTRAP_FRAME TrapFrame); +VOID FASTCALL DECLSPEC_NORETURN KiSystemCallSysExitReturn(IN PKTRAP_FRAME TrapFrame); +VOID FASTCALL DECLSPEC_NORETURN KiSystemCallTrapReturn(IN PKTRAP_FRAME TrapFrame); +VOID FASTCALL DECLSPEC_NORETURN KiEditedTrapReturn(IN PKTRAP_FRAME TrapFrame); +VOID FASTCALL DECLSPEC_NORETURN KiTrapReturn(IN PKTRAP_FRAME TrapFrame); +VOID FASTCALL DECLSPEC_NORETURN KiTrapReturnNoSegments(IN PKTRAP_FRAME TrapFrame); + +typedef VOID -FORCEINLINE -DECLSPEC_NORETURN -KiExitTrap(IN PKTRAP_FRAME TrapFrame, - IN UCHAR Skip) -{ - KTRAP_EXIT_SKIP_BITS SkipBits = { .Bits = Skip }; - PULONG ReturnStack; - - /* Debugging checks */ - KiExitTrapDebugChecks(TrapFrame, SkipBits); - - /* Restore the SEH handler chain */ - KeGetPcr()->Tib.ExceptionList = TrapFrame->ExceptionList; - - /* Check if the previous mode must be restored */ - if (__builtin_expect(!SkipBits.SkipPreviousMode, 0)) /* More INTS than SYSCALLs */ - { - /* Restore it */ - KeGetCurrentThread()->PreviousMode = TrapFrame->PreviousPreviousMode; - } - - /* Check if there are active debug registers */ - if (__builtin_expect(TrapFrame->Dr7 & ~DR7_RESERVED_MASK, 0)) - { - /* Not handled yet */ - DbgPrint("Need Hardware Breakpoint Support!\n"); - DbgBreakPoint(); - while (TRUE); - } - - /* Check if this was a V8086 trap */ - if (__builtin_expect(TrapFrame->EFlags & EFLAGS_V86_MASK, 0)) KiTrapReturn(TrapFrame); - - /* Check if the trap frame was edited */ - if (__builtin_expect(!(TrapFrame->SegCs & FRAME_EDITED), 0)) - { - /* - * An edited trap frame happens when we need to modify CS and/or ESP but - * don't actually have a ring transition. This happens when a kernelmode - * caller wants to perform an NtContinue to another kernel address, such - * as in the case of SEH (basically, a longjmp), or to a user address. - * - * Therefore, the CPU never saved CS/ESP on the stack because we did not - * get a trap frame due to a ring transition (there was no interrupt). - * Even if we didn't want to restore CS to a new value, a problem occurs - * due to the fact a normal RET would not work if we restored ESP since - * RET would then try to read the result off the stack. - * - * The NT kernel solves this by adding 12 bytes of stack to the exiting - * trap frame, in which EFLAGS, CS, and EIP are stored, and then saving - * the ESP that's being requested into the ErrorCode field. It will then - * exit with an IRET. This fixes both issues, because it gives the stack - * some space where to hold the return address and then end up with the - * wanted stack, and it uses IRET which allows a new CS to be inputted. - * - */ - - /* Set CS that is requested */ - TrapFrame->SegCs = TrapFrame->TempSegCs; - - /* First make space on requested stack */ - ReturnStack = (PULONG)(TrapFrame->TempEsp - 12); - TrapFrame->ErrCode = (ULONG_PTR)ReturnStack; - - /* Now copy IRET frame */ - ReturnStack[0] = TrapFrame->Eip; - ReturnStack[1] = TrapFrame->SegCs; - ReturnStack[2] = TrapFrame->EFlags; - - /* Do special edited return */ - KiEditedTrapReturn(TrapFrame); - } - - /* Check if this is a user trap */ - if (__builtin_expect(KiUserTrap(TrapFrame), 1)) /* Ring 3 is where we spend time */ - { - /* Check if segments should be restored */ - if (!SkipBits.SkipSegments) - { - /* Restore segments */ - Ke386SetGs(TrapFrame->SegGs); - Ke386SetEs(TrapFrame->SegEs); - Ke386SetDs(TrapFrame->SegDs); - Ke386SetFs(TrapFrame->SegFs); - } - - /* Always restore FS since it goes from KPCR to TEB */ - Ke386SetFs(TrapFrame->SegFs); - } - - /* Check for system call -- a system call skips volatiles! */ - if (__builtin_expect(SkipBits.SkipVolatiles, 0)) /* More INTs than SYSCALLs */ - { - /* User or kernel call? */ - KiUserSystemCall(TrapFrame); - - /* Restore EFLags */ - __writeeflags(TrapFrame->EFlags); - - /* Call is kernel, so do a jump back since this wasn't a real INT */ - KiSystemCallReturn(TrapFrame); - - /* If we got here, this is SYSEXIT: are we stepping code? */ - if (!(TrapFrame->EFlags & EFLAGS_TF)) - { - /* Restore user FS */ - Ke386SetFs(KGDT_R3_TEB | RPL_MASK); - - /* Remove interrupt flag */ - TrapFrame->EFlags &= ~EFLAGS_INTERRUPT_MASK; - __writeeflags(TrapFrame->EFlags); - - /* Exit through SYSEXIT */ - KiSystemCallSysExitReturn(TrapFrame); - } - - /* Exit through IRETD, either due to debugging or due to lack of SYSEXIT */ - KiSystemCallTrapReturn(TrapFrame); - } - - /* Return from interrupt */ - KiTrapReturn(TrapFrame); -} +(FASTCALL +*FAST_SYSTEM_CALL_EXIT)(IN PKTRAP_FRAME TrapFrame) DECLSPEC_NORETURN; // // Virtual 8086 Mode Optimized Trap Exit @@ -517,6 +218,9 @@ KiExitV86Trap(IN PKTRAP_FRAME TrapFrame) Thread = KeGetCurrentThread(); while (TRUE) { + /* Return if this isn't V86 mode anymore */ + if (!(TrapFrame->EFlags & EFLAGS_V86_MASK)) KiEoiHelper(TrapFrame);; + /* Turn off the alerted state for kernel mode */ Thread->Alerted[KernelMode] = FALSE; @@ -533,9 +237,6 @@ KiExitV86Trap(IN PKTRAP_FRAME TrapFrame) /* Restore IRQL and disable interrupts once again */ KfLowerIrql(OldIrql); _disable(); - - /* Return if this isn't V86 mode anymore */ - if (__builtin_expect(TrapFrame->EFlags & EFLAGS_V86_MASK, 0)) return; } /* If we got here, we're still in a valid V8086 context, so quit it */ diff --git a/reactos/ntoskrnl/ke/i386/cpu.c b/reactos/ntoskrnl/ke/i386/cpu.c index 21d49c90123..ad8e21eaa43 100644 --- a/reactos/ntoskrnl/ke/i386/cpu.c +++ b/reactos/ntoskrnl/ke/i386/cpu.c @@ -995,55 +995,8 @@ KiLoadFastSyscallMachineSpecificRegisters(IN ULONG_PTR Context) return 0; } -VOID -NTAPI -KiDisableFastSyscallReturn(VOID) -{ - /* Was it applied? */ - if (KiSystemCallExitAdjusted) - { - /* Restore the original value */ - KiSystemCallExitBranch[1] = KiSystemCallExitBranch[1] - KiSystemCallExitAdjusted; - - /* It's not adjusted anymore */ - KiSystemCallExitAdjusted = FALSE; - } -} - -VOID -NTAPI -KiEnableFastSyscallReturn(VOID) -{ - /* Check if the patch has already been done */ - if ((KiSystemCallExitAdjusted == KiSystemCallExitAdjust) && - (KiFastCallCopyDoneOnce)) - { - return; - } - - /* Make sure the offset is within the distance of a Jxx SHORT */ - if ((KiSystemCallExitBranch[1] - KiSystemCallExitAdjust) < 0x80) - { - /* Remove any existing code patch */ - KiDisableFastSyscallReturn(); - - /* We should have a JNZ there */ - ASSERT(KiSystemCallExitBranch[0] == 0x75); - - /* Do the patch */ - KiSystemCallExitAdjusted = KiSystemCallExitAdjust; - KiSystemCallExitBranch[1] -= KiSystemCallExitAdjusted; - - /* Remember that we've done it */ - KiFastCallCopyDoneOnce = TRUE; - } - else - { - /* This shouldn't happen unless we've messed the macros up */ - DPRINT1("Your compiled kernel is broken!\n"); - DbgBreakPoint(); - } -} +VOID FASTCALL DECLSPEC_NORETURN KiSystemCallSysExitReturn(IN PKTRAP_FRAME TrapFrame); +extern PVOID KiFastCallExitHandler; VOID NTAPI @@ -1055,11 +1008,11 @@ KiRestoreFastSyscallReturnState(VOID) /* Check if it has been disabled */ if (!KiFastSystemCallDisable) { - /* KiSystemCallExit2 should come BEFORE KiSystemCallExit */ - ASSERT(KiSystemCallExit2 < KiSystemCallExit); - - /* It's enabled, so we'll have to do a code patch */ - KiSystemCallExitAdjust = KiSystemCallExit - KiSystemCallExit2; + /* Do an IPI to enable it */ + KeIpiGenericCall(KiLoadFastSyscallMachineSpecificRegisters, 0); + + /* It's enabled, so use the proper exit stub */ + KiFastCallExitHandler = KiSystemCallSysExitReturn; } else { @@ -1067,16 +1020,6 @@ KiRestoreFastSyscallReturnState(VOID) KeFeatureBits &= ~KF_FAST_SYSCALL; } } - - /* Now check if all CPUs support fast system call, and the registry allows it */ - if (KeFeatureBits & KF_FAST_SYSCALL) - { - /* Do an IPI to enable it */ - KeIpiGenericCall(KiLoadFastSyscallMachineSpecificRegisters, 0); - } - - /* Perform the code patch that is required */ - KiEnableFastSyscallReturn(); } ULONG_PTR diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index 5f24877eeac..df7bc6ac55f 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -120,17 +120,18 @@ _KiInterruptTemplateObject: PUBLIC _KiInterruptTemplateDispatch _KiInterruptTemplateDispatch: -EXTERN @KiSystemServiceHandler@8:PROC -PUBLIC _KiSystemService -_KiSystemService: - KiEnterTrap (KI_PUSH_FAKE_ERROR_CODE OR KI_NONVOLATILES_ONLY OR KI_DONT_SAVE_SEGS) - jmp @KiSystemServiceHandler@8 - EXTERN @KiFastCallEntryHandler@8:PROC PUBLIC _KiFastCallEntry _KiFastCallEntry: KiEnterTrap (KI_FAST_SYSTEM_CALL OR KI_NONVOLATILES_ONLY OR KI_DONT_SAVE_SEGS) - jmp @KiFastCallEntryHandler@8 + KiCallHandler @KiFastCallEntryHandler@8 + + +EXTERN @KiSystemServiceHandler@8:PROC +PUBLIC _KiSystemService +_KiSystemService: + KiEnterTrap (KI_PUSH_FAKE_ERROR_CODE OR KI_NONVOLATILES_ONLY OR KI_DONT_SAVE_SEGS) + KiCallHandler @KiSystemServiceHandler@8 PUBLIC _KiStartUnexpectedRange@0 _KiStartUnexpectedRange@0: @@ -143,4 +144,15 @@ PUBLIC _KiEndUnexpectedRange@0 _KiEndUnexpectedRange@0: jmp _KiUnexpectedInterruptTail + +/* EXIT CODE *****************************************************************/ + +KiTrapExitStub KiSystemCallReturn, (KI_RESTORE_EAX OR KI_RESTORE_EFLAGS OR KI_EXIT_JMP) +KiTrapExitStub KiSystemCallSysExitReturn, (KI_RESTORE_EAX OR KI_RESTORE_FS OR KI_RESTORE_EFLAGS OR KI_EXIT_SYSCALL) +KiTrapExitStub KiSystemCallTrapReturn, (KI_RESTORE_EAX OR KI_RESTORE_FS OR KI_EXIT_IRET) + +KiTrapExitStub KiEditedTrapReturn, (KI_RESTORE_VOLATILES OR KI_RESTORE_EFLAGS OR KI_EDITED_FRAME OR KI_EXIT_RET) +KiTrapExitStub KiTrapReturn, (KI_RESTORE_VOLATILES OR KI_RESTORE_SEGMENTS OR KI_EXIT_IRET) +KiTrapExitStub KiTrapReturnNoSegments, (KI_RESTORE_VOLATILES OR KI_EXIT_IRET) + END diff --git a/reactos/ntoskrnl/ke/i386/traphdlr.c b/reactos/ntoskrnl/ke/i386/traphdlr.c index 6c777643bd6..44b15c35d78 100644 --- a/reactos/ntoskrnl/ke/i386/traphdlr.c +++ b/reactos/ntoskrnl/ke/i386/traphdlr.c @@ -45,6 +45,8 @@ UCHAR KiTrapIoTable[] = 0x6F, /* OUTS */ }; +FAST_SYSTEM_CALL_EXIT KiFastCallExitHandler = KiSystemCallTrapReturn; + BOOLEAN FORCEINLINE KiVdmTrap(IN PKTRAP_FRAME TrapFrame) @@ -62,21 +64,62 @@ KiV86Trap(IN PKTRAP_FRAME TrapFrame) return ((TrapFrame->EFlags & EFLAGS_V86_MASK) != 0); } +BOOLEAN +FORCEINLINE +KeIsFrameEdited(IN PKTRAP_FRAME TrapFrame) +{ + /* An edited frame changes esp. It is marked by clearing the bits + defined by FRAME_EDITED in the SegCs field of the trap frame */ + return ((TrapFrame->SegCs & FRAME_EDITED) == 0); +} + /* TRAP EXIT CODE *************************************************************/ +VOID +FORCEINLINE +KiCommonExit(IN PKTRAP_FRAME TrapFrame, const ULONG Flags) +{ + /* Disable interrupts until we return */ + _disable(); + + /* Check for APC delivery */ + KiCheckForApcDelivery(TrapFrame); + + /* Debugging checks */ + KiExitTrapDebugChecks(TrapFrame, Flags); + + /* Restore the SEH handler chain */ + KeGetPcr()->Tib.ExceptionList = TrapFrame->ExceptionList; + + /* Check if there are active debug registers */ + if (__builtin_expect(TrapFrame->Dr7 & ~DR7_RESERVED_MASK, 0)) + { + /* Not handled yet */ + DbgPrint("Need Hardware Breakpoint Support!\n"); + DbgBreakPoint(); + while (TRUE); + } +} + VOID FASTCALL DECLSPEC_NORETURN KiEoiHelper(IN PKTRAP_FRAME TrapFrame) { - /* Disable interrupts until we return */ - _disable(); - - /* Check for APC delivery */ - KiCheckForApcDelivery(TrapFrame); - - /* Now exit the trap for real */ - KiExitTrap(TrapFrame, KTE_SKIP_PM_BIT); + /* Common trap exit code */ + KiCommonExit(TrapFrame, 0); + + /* Check if this was a V8086 trap */ + if (TrapFrame->EFlags & EFLAGS_V86_MASK) KiTrapReturnNoSegments(TrapFrame); + + /* Check for user mode exit */ + if (TrapFrame->SegCs & MODE_MASK) KiTrapReturn(TrapFrame); + + /* Check for edited frame */ + if (KeIsFrameEdited(TrapFrame)) KiEditedTrapReturn(TrapFrame); + + /* Exit the trap to kernel mode */ + KiTrapReturnNoSegments(TrapFrame); } VOID @@ -85,17 +128,36 @@ DECLSPEC_NORETURN KiServiceExit(IN PKTRAP_FRAME TrapFrame, IN NTSTATUS Status) { - /* Disable interrupts until we return */ - _disable(); - - /* Check for APC delivery */ - KiCheckForApcDelivery(TrapFrame); - + ASSERT((TrapFrame->EFlags & EFLAGS_V86_MASK) == 0); + ASSERT(!KeIsFrameEdited(TrapFrame)); + /* Copy the status into EAX */ TrapFrame->Eax = Status; + + /* Common trap exit code */ + KiCommonExit(TrapFrame, 0); - /* Now exit the trap for real */ - KiExitTrap(TrapFrame, KTE_SKIP_SEG_BIT | KTE_SKIP_VOL_BIT); + /* Restore previous mode */ + KeGetCurrentThread()->PreviousMode = TrapFrame->PreviousPreviousMode; + + /* Check for user mode exit */ + if (TrapFrame->SegCs & MODE_MASK) + { + /* Check if we were single stepping */ + if (TrapFrame->EFlags & EFLAGS_TF) + { + /* Must use the IRET handler */ + KiSystemCallTrapReturn(TrapFrame); + } + else + { + /* We can use the sysexit handler */ + KiFastCallExitHandler(TrapFrame); + } + } + + /* Exit to kernel mode */ + KiSystemCallReturn(TrapFrame); } VOID @@ -103,14 +165,23 @@ FASTCALL DECLSPEC_NORETURN KiServiceExit2(IN PKTRAP_FRAME TrapFrame) { - /* Disable interrupts until we return */ - _disable(); - - /* Check for APC delivery */ - KiCheckForApcDelivery(TrapFrame); - - /* Now exit the trap for real */ - KiExitTrap(TrapFrame, 0); + /* Common trap exit code */ + KiCommonExit(TrapFrame, 0); + + /* Restore previous mode */ + KeGetCurrentThread()->PreviousMode = TrapFrame->PreviousPreviousMode; + + /* Check if this was a V8086 trap */ + if (TrapFrame->EFlags & EFLAGS_V86_MASK) KiTrapReturnNoSegments(TrapFrame); + + /* Check for user mode exit */ + if (TrapFrame->SegCs & MODE_MASK) KiTrapReturn(TrapFrame); + + /* Check for edited frame */ + if (KeIsFrameEdited(TrapFrame)) KiEditedTrapReturn(TrapFrame); + + /* Exit the trap to kernel mode */ + KiTrapReturnNoSegments(TrapFrame); } /* TRAP HANDLERS **************************************************************/ @@ -582,10 +653,7 @@ KiTrap06Handler(IN PKTRAP_FRAME TrapFrame) _disable(); /* Do a quick V86 exit if possible */ - if (__builtin_expect(TrapFrame->EFlags & EFLAGS_V86_MASK, 1)) KiExitV86Trap(TrapFrame); - - /* Exit trap the slow way */ - KiEoiHelper(TrapFrame); + KiExitV86Trap(TrapFrame); } /* Save trap frame */ @@ -842,10 +910,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) _disable(); /* Do a quick V86 exit if possible */ - if (__builtin_expect(TrapFrame->EFlags & EFLAGS_V86_MASK, 1)) KiExitV86Trap(TrapFrame); - - /* Exit trap the slow way */ - KiEoiHelper(TrapFrame); + KiExitV86Trap(TrapFrame); } /* Save trap frame */ @@ -909,7 +974,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) (((Instructions[i + 2] & 0x38) == 0x10) || // LLDT (Instructions[i + 2] == 0x18))) || // LTR ((Instructions[i + 1] == 0x01) && // LGDT or LIDT or LMSW - (((Instructions[i + 2] & 0x38) == 0x10) || // LLGT + (((Instructions[i + 2] & 0x38) == 0x10) || // LGDT (Instructions[i + 2] == 0x18) || // LIDT (Instructions[i + 2] == 0x30))) || // LMSW (Instructions[i + 1] == 0x08) || // INVD @@ -921,6 +986,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) (Instructions[i + 1] == 0x24) || // MOV YYY, DR (Instructions[i + 1] == 0x30) || // WRMSR (Instructions[i + 1] == 0x33)) // RDPMC + // INVLPG, INVLPGA, SYSRET { /* These are all privileged */ Privileged = TRUE; @@ -993,7 +1059,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) * a POP , which could cause an invalid segment if someone had messed * with the segment values. * - * Another case is a bogus SS, which would hit a GPF when doing the ired. + * Another case is a bogus SS, which would hit a GPF when doing the iret. * This could only be done through a buggy or malicious driver, or perhaps * the kernel debugger. * @@ -1067,9 +1133,14 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) /* Fix it */ TrapFrame->SegEs = (KGDT_R3_DATA | RPL_MASK); } - - /* Do a direct trap exit: restore volatiles only */ - KiExitTrap(TrapFrame, KTE_SKIP_PM_BIT | KTE_SKIP_SEG_BIT); + else + { + /* Whatever it is, we can't handle it */ + KiSystemFatalException(EXCEPTION_GP_FAULT, TrapFrame); + } + + /* Return to where we came from */ + KiTrapReturn(TrapFrame); } VOID @@ -1176,7 +1247,7 @@ KiTrap0EHandler(IN PKTRAP_FRAME TrapFrame) Cr2, TrapFrame); } - + /* Only other choice is an in-page error, with 3 parameters */ KiDispatchExceptionFromTrapFrame(STATUS_IN_PAGE_ERROR, TrapFrame->Eip, @@ -1377,55 +1448,89 @@ KiDebugServiceHandler(IN PKTRAP_FRAME TrapFrame) } VOID -FASTCALL +FORCEINLINE DECLSPEC_NORETURN -KiSystemCall(IN ULONG SystemCallNumber, - IN PVOID Arguments) +KiSystemCall(IN PKTRAP_FRAME TrapFrame, + IN PVOID Arguments) { PKTHREAD Thread; - PKTRAP_FRAME TrapFrame; PKSERVICE_TABLE_DESCRIPTOR DescriptorTable; ULONG Id, Offset, StackBytes, Result; PVOID Handler; - - /* Loop because we might need to try this twice in case of a GUI call */ - while (TRUE) + ULONG SystemCallNumber = TrapFrame->Eax; + + /* Get the current thread */ + Thread = KeGetCurrentThread(); + + /* Set debug header */ + KiFillTrapFrameDebug(TrapFrame); + + /* Chain trap frames */ + TrapFrame->Edx = (ULONG_PTR)Thread->TrapFrame; + + /* No error code */ + TrapFrame->ErrCode = 0; + + /* Save previous mode */ + TrapFrame->PreviousPreviousMode = Thread->PreviousMode; + + /* Save the SEH chain and terminate it for now */ + TrapFrame->ExceptionList = KeGetPcr()->Tib.ExceptionList; + KeGetPcr()->Tib.ExceptionList = EXCEPTION_CHAIN_END; + + /* Clear DR7 and check for debugging */ + TrapFrame->Dr7 = 0; + if (__builtin_expect(Thread->DispatcherHeader.DebugActive & 0xFF, 0)) { - /* Decode the system call number */ - Offset = (SystemCallNumber >> SERVICE_TABLE_SHIFT) & SERVICE_TABLE_MASK; - Id = SystemCallNumber & SERVICE_NUMBER_MASK; - - /* Get current thread, trap frame, and descriptor table */ - Thread = KeGetCurrentThread(); - TrapFrame = Thread->TrapFrame; - DescriptorTable = (PVOID)((ULONG_PTR)Thread->ServiceTable + Offset); + UNIMPLEMENTED; + while (TRUE); + } - /* Validate the system call number */ - if (__builtin_expect(Id >= DescriptorTable->Limit, 0)) + /* Set thread fields */ + Thread->TrapFrame = TrapFrame; + Thread->PreviousMode = KiUserTrap(TrapFrame); + + /* Enable interrupts */ + _enable(); + + /* Decode the system call number */ + Offset = (SystemCallNumber >> SERVICE_TABLE_SHIFT) & SERVICE_TABLE_MASK; + Id = SystemCallNumber & SERVICE_NUMBER_MASK; + + /* Get descriptor table */ + DescriptorTable = (PVOID)((ULONG_PTR)Thread->ServiceTable + Offset); + + /* Validate the system call number */ + if (__builtin_expect(Id >= DescriptorTable->Limit, 0)) + { + /* Check if this is a GUI call */ + if (!(Offset & SERVICE_TABLE_TEST)) { - /* Check if this is a GUI call */ - if (__builtin_expect(!(Offset & SERVICE_TABLE_TEST), 0)) - { - /* Fail the call */ - Result = STATUS_INVALID_SYSTEM_SERVICE; - goto ExitCall; - } + /* Fail the call */ + Result = STATUS_INVALID_SYSTEM_SERVICE; + goto ExitCall; + } - /* Convert us to a GUI thread -- must wrap in ASM to get new EBP */ - Result = KiConvertToGuiThread(); - if (__builtin_expect(!NT_SUCCESS(Result), 0)) - { - /* Figure out how we should fail to the user */ - UNIMPLEMENTED; - while (TRUE); - } - - /* Try the call again */ - continue; + /* Convert us to a GUI thread -- must wrap in ASM to get new EBP */ + Result = KiConvertToGuiThread(); + if (!NT_SUCCESS(Result)) + { + /* Set the last error and fail */ + //SetLastWin32Error(RtlNtStatusToDosError(Result)); + goto ExitCall; } - /* If we made it here, the call is good */ - break; + /* Reload trap frame and descriptor table pointer from new stack */ + TrapFrame = *(volatile PVOID*)&Thread->TrapFrame; + DescriptorTable = (PVOID)(*(volatile ULONG_PTR*)&Thread->ServiceTable + Offset); + + /* Validate the system call number again */ + if (Id >= DescriptorTable->Limit) + { + /* Fail the call */ + Result = STATUS_INVALID_SYSTEM_SERVICE; + goto ExitCall; + } } /* Check if this is a GUI call */ @@ -1468,45 +1573,13 @@ ExitCall: } VOID -FORCEINLINE +FASTCALL DECLSPEC_NORETURN -KiSystemCallHandler(IN PKTRAP_FRAME TrapFrame, - IN ULONG ServiceNumber, - IN PVOID Arguments, - IN PKTHREAD Thread, - IN KPROCESSOR_MODE PreviousMode, - IN KPROCESSOR_MODE PreviousPreviousMode, - IN USHORT SegFs) +KiSystemServiceHandler(IN PKTRAP_FRAME TrapFrame, + IN PVOID Arguments) { - /* No error code */ - TrapFrame->ErrCode = 0; - - /* Save previous mode and FS segment */ - TrapFrame->PreviousPreviousMode = PreviousPreviousMode; - TrapFrame->SegFs = SegFs; - - /* Save the SEH chain and terminate it for now */ - TrapFrame->ExceptionList = KeGetPcr()->Tib.ExceptionList; - KeGetPcr()->Tib.ExceptionList = EXCEPTION_CHAIN_END; - - /* Clear DR7 and check for debugging */ - TrapFrame->Dr7 = 0; - if (__builtin_expect(Thread->DispatcherHeader.DebugActive & 0xFF, 0)) - { - UNIMPLEMENTED; - while (TRUE); - } - - /* Set thread fields */ - Thread->TrapFrame = TrapFrame; - Thread->PreviousMode = PreviousMode; - - /* Set debug header */ - KiFillTrapFrameDebug(TrapFrame); - - /* Enable interrupts and make the call */ - _enable(); - KiSystemCall(ServiceNumber, Arguments); + /* Call the shared handler (inline) */ + KiSystemCall(TrapFrame, Arguments); } VOID @@ -1515,54 +1588,20 @@ DECLSPEC_NORETURN KiFastCallEntryHandler(IN PKTRAP_FRAME TrapFrame, IN PVOID Arguments) { - PKTHREAD Thread; - /* Set up a fake INT Stack and enable interrupts */ TrapFrame->HardwareSegSs = KGDT_R3_DATA | RPL_MASK; TrapFrame->HardwareEsp = (ULONG_PTR)Arguments; TrapFrame->EFlags = __readeflags() | EFLAGS_INTERRUPT_MASK; TrapFrame->SegCs = KGDT_R3_CODE | RPL_MASK; TrapFrame->Eip = SharedUserData->SystemCallReturn; + TrapFrame->SegFs = KGDT_R3_TEB | RPL_MASK; __writeeflags(0x2); - /* Get the current thread */ - Thread = KeGetCurrentThread(); - - /* Arguments are actually 2 frames down (because of the double indirection) */ + /* Arguments are actually 2 frames down (because of the double indirection) */ Arguments = (PVOID)(TrapFrame->HardwareEsp + 8); /* Call the shared handler (inline) */ - KiSystemCallHandler(TrapFrame, - TrapFrame->Eax, - Arguments, - Thread, - UserMode, - Thread->PreviousMode, - KGDT_R3_TEB | RPL_MASK); -} - -VOID -FASTCALL -DECLSPEC_NORETURN -KiSystemServiceHandler(IN PKTRAP_FRAME TrapFrame, - IN PVOID Arguments) -{ - PKTHREAD Thread; - - /* Get the current thread */ - Thread = KeGetCurrentThread(); - - /* Chain trap frames */ - TrapFrame->Edx = (ULONG_PTR)Thread->TrapFrame; - - /* Call the shared handler (inline) */ - KiSystemCallHandler(TrapFrame, - TrapFrame->Eax, - Arguments, - Thread, - KiUserTrap(TrapFrame), - Thread->PreviousMode, - TrapFrame->SegFs); + KiSystemCall(TrapFrame, Arguments); } /* From a3c1764e42fbefdaab475abdfa3d49779e93040d Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 3 Mar 2010 02:38:56 +0000 Subject: [PATCH 045/211] - Initialize the ACPI table (the exact same we do it in KiRosFrldrLpbToNtLpb) - Fixes ACPI detection when booted in Windows-compatible mode svn path=/trunk/; revision=45775 --- reactos/boot/freeldr/freeldr/windows/winldr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/windows/winldr.c index 0121773e3a8..4ba7b1bcb29 100644 --- a/reactos/boot/freeldr/freeldr/windows/winldr.c +++ b/reactos/boot/freeldr/freeldr/windows/winldr.c @@ -37,6 +37,7 @@ extern char reactos_arc_strings[32][256]; extern BOOLEAN UseRealHeap; extern ULONG LoaderPagesSpanned; +extern BOOLEAN AcpiPresent; BOOLEAN WinLdrCheckForLoadedDll(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock, @@ -196,6 +197,13 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, Extension->MinorVersion = VersionToBoot & 0xFF; Extension->Profile.Status = 2; + /* Check if ACPI is present */ + if (AcpiPresent) + { + /* See KiRosFrldrLpbToNtLpb for details */ + Extension->AcpiTable = (PVOID)1; + } + /* Load drivers database */ strcpy(MiscFiles, BootPath); strcat(MiscFiles, "AppPatch\\drvmain.sdb"); From 7cdbb11c875ae7b4a83522ddbe7d9626da54fbb1 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Wed, 3 Mar 2010 03:27:25 +0000 Subject: [PATCH 046/211] [KSPROXY] - Implement IEnumMediaTypes interface - Implement IKsObject, IKsPropertySet, IKsControl interface for CInputPin - Verify connection format for CInputPin - Delegate interface requests to ksproxy plugins - Implement CKsProxy::FindPin [MSDVBNP] - Use FORMAT_None as format specifier svn path=/trunk/; revision=45776 --- .../dll/directx/ksproxy/enum_mediatypes.cpp | 188 ++++++++++ reactos/dll/directx/ksproxy/input_pin.cpp | 328 ++++++++++++++++-- reactos/dll/directx/ksproxy/ksproxy.rbuild | 1 + reactos/dll/directx/ksproxy/precomp.h | 17 +- reactos/dll/directx/ksproxy/proxy.cpp | 56 ++- reactos/dll/directx/msdvbnp/pin.cpp | 2 +- 6 files changed, 557 insertions(+), 35 deletions(-) create mode 100644 reactos/dll/directx/ksproxy/enum_mediatypes.cpp diff --git a/reactos/dll/directx/ksproxy/enum_mediatypes.cpp b/reactos/dll/directx/ksproxy/enum_mediatypes.cpp new file mode 100644 index 00000000000..9895c2290cc --- /dev/null +++ b/reactos/dll/directx/ksproxy/enum_mediatypes.cpp @@ -0,0 +1,188 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/enum_mediatypes.cpp + * PURPOSE: IEnumMediaTypes interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumMediaTypes : public IEnumMediaTypes +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + HRESULT STDMETHODCALLTYPE Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG cMediaTypes); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **ppEnum); + + + CEnumMediaTypes(ULONG MediaTypeCount, AM_MEDIA_TYPE * MediaTypes) : m_Ref(0), m_MediaTypeCount(MediaTypeCount), m_MediaTypes(MediaTypes), m_Index(0){}; + virtual ~CEnumMediaTypes(){}; + +protected: + LONG m_Ref; + ULONG m_MediaTypeCount; + AM_MEDIA_TYPE * m_MediaTypes; + ULONG m_Index; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IEnumMediaTypes)) + { + *Output = (IEnumMediaTypes*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumMediaTypes::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IEnumMediaTypes +// + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Next( + ULONG cMediaTypes, + AM_MEDIA_TYPE **ppMediaTypes, + ULONG *pcFetched) +{ + ULONG i = 0; + AM_MEDIA_TYPE * MediaType; + + if (!ppMediaTypes) + return E_POINTER; + + if (cMediaTypes > 1 && !pcFetched) + return E_INVALIDARG; + + while(i < cMediaTypes) + { + if (m_Index + i >= m_MediaTypeCount) + break; + + MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + if (!MediaType) + break; + + CopyMemory(MediaType, &m_MediaTypes[m_Index + i], sizeof(AM_MEDIA_TYPE)); + ppMediaTypes[i] = MediaType; + i++; + } + + if (pcFetched) + { + *pcFetched = i; + } + + m_Index += i; + + if (i < cMediaTypes) + return S_FALSE; + else + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Skip( + ULONG cMediaTypes) +{ + if (cMediaTypes + m_Index >= m_MediaTypeCount) + { + return S_FALSE; + } + + m_Index += cMediaTypes; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Reset() +{ + m_Index = 0; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Clone( + IEnumMediaTypes **ppEnum) +{ + OutputDebugStringW(L"CEnumMediaTypes::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumMediaTypes_fnConstructor( + ULONG MediaTypeCount, + AM_MEDIA_TYPE * MediaTypes, + REFIID riid, + LPVOID * ppv) +{ + CEnumMediaTypes * handler = new CEnumMediaTypes(MediaTypeCount, MediaTypes); + +#ifdef KSPROXY_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumMediaTypes_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + { + CoTaskMemFree(MediaTypes); + return E_OUTOFMEMORY; + } + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} + diff --git a/reactos/dll/directx/ksproxy/input_pin.cpp b/reactos/dll/directx/ksproxy/input_pin.cpp index 03a97bad932..896335b6512 100644 --- a/reactos/dll/directx/ksproxy/input_pin.cpp +++ b/reactos/dll/directx/ksproxy/input_pin.cpp @@ -8,17 +8,17 @@ */ #include "precomp.h" -class CInputPin : public IPin +class CInputPin : public IPin, + public IKsPropertySet, + public IKsControl, + public IKsObject /* public IQualityControl, - public IKsObject, public IKsPinEx, public IKsPinPipe, public ISpecifyPropertyPages, public IStreamBuilder, - public IKsPropertySet, public IKsPinFactory, - public IKsControl, public IKsAggregateControl */ { @@ -58,13 +58,30 @@ public: HRESULT STDMETHODCALLTYPE EndFlush(); HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); - CInputPin(IBaseFilter * ParentFilter, LPCWSTR PinName) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName){}; + //IKsObject methods + HANDLE STDMETHODCALLTYPE KsGetObjectHandle(); + + //IKsPropertySet + HRESULT STDMETHODCALLTYPE Set(REFGUID guidPropSet, DWORD dwPropID, LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData, DWORD cbPropData); + HRESULT STDMETHODCALLTYPE Get(REFGUID guidPropSet, DWORD dwPropID, LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData, DWORD cbPropData, DWORD *pcbReturned); + HRESULT STDMETHODCALLTYPE QuerySupported(REFGUID guidPropSet, DWORD dwPropID, DWORD *pTypeSupport); + + //IKsControl + HRESULT STDMETHODCALLTYPE KsProperty(PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData, ULONG DataLength, ULONG* BytesReturned); + HRESULT STDMETHODCALLTYPE KsMethod(PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData, ULONG DataLength, ULONG* BytesReturned); + HRESULT STDMETHODCALLTYPE KsEvent(PKSEVENT Event, ULONG EventLength, LPVOID EventData, ULONG DataLength, ULONG* BytesReturned); + + HRESULT STDMETHODCALLTYPE CheckFormat(const AM_MEDIA_TYPE *pmt); + CInputPin(IBaseFilter * ParentFilter, LPCWSTR PinName, HANDLE hFilter, ULONG PinId) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName), m_hFilter(hFilter), m_hPin(0), m_PinId(PinId){}; virtual ~CInputPin(){}; protected: LONG m_Ref; IBaseFilter * m_ParentFilter; LPCWSTR m_PinName; + HANDLE m_hFilter; + HANDLE m_hPin; + ULONG m_PinId; }; HRESULT @@ -74,6 +91,7 @@ CInputPin::QueryInterface( OUT PVOID* Output) { *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown) || IsEqualGUID(refiid, IID_IPin)) { @@ -81,6 +99,42 @@ CInputPin::QueryInterface( reinterpret_cast(*Output)->AddRef(); return NOERROR; } + else if (IsEqualGUID(refiid, IID_IKsObject)) + { + if (!m_hPin) + { + OutputDebugStringW(L"CInputPin::QueryInterface IID_IKsObject Create PIN!!!\n"); + DebugBreak(); + } + + *Output = (IKsObject*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IKsPropertySet)) + { + if (!m_hPin) + { + OutputDebugStringW(L"CInputPin::QueryInterface IID_IKsPropertySet Create PIN!!!\n"); + DebugBreak(); + } + + *Output = (IKsPropertySet*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IKsControl)) + { + if (!m_hPin) + { + OutputDebugStringW(L"CInputPin::QueryInterface IID_IKsControl Create PIN!!!\n"); + DebugBreak(); + } + + *Output = (IKsControl*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } WCHAR Buffer[MAX_PATH]; LPOLESTR lpstr; @@ -92,6 +146,167 @@ CInputPin::QueryInterface( return E_NOINTERFACE; } +//------------------------------------------------------------------- +// IKsPropertySet +// +HRESULT +STDMETHODCALLTYPE +CInputPin::KsProperty( + PKSPROPERTY Property, + ULONG PropertyLength, + LPVOID PropertyData, + ULONG DataLength, + ULONG* BytesReturned) +{ + return KsSynchronousDeviceControl(m_hPin, IOCTL_KS_PROPERTY, (PVOID)Property, PropertyLength, (PVOID)PropertyData, DataLength, BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsMethod( + PKSMETHOD Method, + ULONG MethodLength, + LPVOID MethodData, + ULONG DataLength, + ULONG* BytesReturned) +{ + return KsSynchronousDeviceControl(m_hPin, IOCTL_KS_METHOD, (PVOID)Method, MethodLength, (PVOID)MethodData, DataLength, BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsEvent( + PKSEVENT Event, + ULONG EventLength, + LPVOID EventData, + ULONG DataLength, + ULONG* BytesReturned) +{ + if (EventLength) + return KsSynchronousDeviceControl(m_hPin, IOCTL_KS_ENABLE_EVENT, (PVOID)Event, EventLength, (PVOID)EventData, DataLength, BytesReturned); + else + return KsSynchronousDeviceControl(m_hPin, IOCTL_KS_DISABLE_EVENT, (PVOID)Event, EventLength, NULL, 0, BytesReturned); +} + + +//------------------------------------------------------------------- +// IKsPropertySet +// +HRESULT +STDMETHODCALLTYPE +CInputPin::Set( + REFGUID guidPropSet, + DWORD dwPropID, + LPVOID pInstanceData, + DWORD cbInstanceData, + LPVOID pPropData, + DWORD cbPropData) +{ + ULONG BytesReturned; + + if (cbInstanceData) + { + PKSPROPERTY Property = (PKSPROPERTY)CoTaskMemAlloc(sizeof(KSPROPERTY) + cbInstanceData); + if (!Property) + return E_OUTOFMEMORY; + + Property->Set = guidPropSet; + Property->Id = dwPropID; + Property->Flags = KSPROPERTY_TYPE_SET; + + CopyMemory((Property+1), pInstanceData, cbInstanceData); + + HRESULT hr = KsProperty(Property, sizeof(KSPROPERTY) + cbInstanceData, pPropData, cbPropData, &BytesReturned); + CoTaskMemFree(Property); + return hr; + } + else + { + KSPROPERTY Property; + + Property.Set = guidPropSet; + Property.Id = dwPropID; + Property.Flags = KSPROPERTY_TYPE_SET; + + HRESULT hr = KsProperty(&Property, sizeof(KSPROPERTY), pPropData, cbPropData, &BytesReturned); + return hr; + } +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::Get( + REFGUID guidPropSet, + DWORD dwPropID, + LPVOID pInstanceData, + DWORD cbInstanceData, + LPVOID pPropData, + DWORD cbPropData, + DWORD *pcbReturned) +{ + ULONG BytesReturned; + + if (cbInstanceData) + { + PKSPROPERTY Property = (PKSPROPERTY)CoTaskMemAlloc(sizeof(KSPROPERTY) + cbInstanceData); + if (!Property) + return E_OUTOFMEMORY; + + Property->Set = guidPropSet; + Property->Id = dwPropID; + Property->Flags = KSPROPERTY_TYPE_GET; + + CopyMemory((Property+1), pInstanceData, cbInstanceData); + + HRESULT hr = KsProperty(Property, sizeof(KSPROPERTY) + cbInstanceData, pPropData, cbPropData, &BytesReturned); + CoTaskMemFree(Property); + return hr; + } + else + { + KSPROPERTY Property; + + Property.Set = guidPropSet; + Property.Id = dwPropID; + Property.Flags = KSPROPERTY_TYPE_GET; + + HRESULT hr = KsProperty(&Property, sizeof(KSPROPERTY), pPropData, cbPropData, &BytesReturned); + return hr; + } +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::QuerySupported( + REFGUID guidPropSet, + DWORD dwPropID, + DWORD *pTypeSupport) +{ + KSPROPERTY Property; + ULONG BytesReturned; + + Property.Set = guidPropSet; + Property.Id = dwPropID; + Property.Flags = KSPROPERTY_TYPE_SETSUPPORT; + + return KsProperty(&Property, sizeof(KSPROPERTY), pTypeSupport, sizeof(DWORD), &BytesReturned); +} + + +//------------------------------------------------------------------- +// IKsObject +// +HANDLE +STDMETHODCALLTYPE +CInputPin::KsGetObjectHandle() +{ + OutputDebugStringW(L"CInputPin::KsGetObjectHandle CALLED\n"); + + //FIXME + // return pin handle + return m_hPin; +} + //------------------------------------------------------------------- // IPin interface // @@ -99,7 +314,16 @@ HRESULT STDMETHODCALLTYPE CInputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) { - OutputDebugStringW(L"CInputPin::Connect called\n"); + //MajorFormat: KSDATAFORMAT_TYPE_BDA_ANTENNA + //SubType: MEDIASUBTYPE_None + //FormatType: FORMAT_None + //bFixedSizeSamples 1 bTemporalCompression 0 lSampleSize 1 pUnk 00000000 cbFormat 0 pbFormat 00000000 + + //KSPROPSETID_Connection KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT + //PriorityClass = KSPRIORITY_NORMAL PrioritySubClass = KSPRIORITY_NORMAL + + + OutputDebugStringW(L"CInputPin::Connect NotImplemented\n"); return E_NOTIMPL; } @@ -107,28 +331,29 @@ HRESULT STDMETHODCALLTYPE CInputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) { - OutputDebugStringW(L"CInputPin::ReceiveConnection called\n"); + OutputDebugStringW(L"CInputPin::ReceiveConnection NotImplemented\n"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CInputPin::Disconnect( void) { - OutputDebugStringW(L"CInputPin::Disconnect called\n"); + OutputDebugStringW(L"CInputPin::Disconnect NotImplemented\n"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CInputPin::ConnectedTo(IPin **pPin) { - OutputDebugStringW(L"CInputPin::ConnectedTo called\n"); + *pPin = NULL; + OutputDebugStringW(L"CInputPin::ConnectedTo NotImplemented\n"); return VFW_E_NOT_CONNECTED; } HRESULT STDMETHODCALLTYPE CInputPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) { - OutputDebugStringW(L"CInputPin::ConnectionMediaType called\n"); + OutputDebugStringW(L"CInputPin::ConnectionMediaType NotImplemented\n"); return E_NOTIMPL; } HRESULT @@ -165,53 +390,112 @@ CInputPin::QueryId(LPWSTR *Id) wcscpy(*Id, m_PinName); return S_OK; } + HRESULT STDMETHODCALLTYPE -CInputPin::QueryAccept(const AM_MEDIA_TYPE *pmt) +CInputPin::CheckFormat( + const AM_MEDIA_TYPE *pmt) { - OutputDebugStringW(L"CInputPin::QueryAccept called\n"); - return E_NOTIMPL; + KSP_PIN Property; + PKSMULTIPLE_ITEM MultipleItem; + PKSDATAFORMAT DataFormat; + ULONG BytesReturned; + HRESULT hr; + + // prepare request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_DATARANGES; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = m_PinId; + Property.Reserved = 0; + + // query for size of dataranges + hr = KsSynchronousDeviceControl(m_hFilter, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), NULL, 0, &BytesReturned); + + if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_MORE_DATA)) + { + // allocate dataranges buffer + MultipleItem = (PKSMULTIPLE_ITEM)CoTaskMemAlloc(BytesReturned); + + if (!MultipleItem) + return E_OUTOFMEMORY; + + // query dataranges + hr = KsSynchronousDeviceControl(m_hFilter, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)MultipleItem, BytesReturned, &BytesReturned); + + if (FAILED(hr)) + { + // failed to query data ranges + CoTaskMemFree(MultipleItem); + return hr; + } + + DataFormat = (PKSDATAFORMAT)(MultipleItem + 1); + for(ULONG Index = 0; Index < MultipleItem->Count; Index++) + { + if (IsEqualGUID(pmt->majortype, DataFormat->MajorFormat) && + IsEqualGUID(pmt->subtype, DataFormat->SubFormat) && + IsEqualGUID(pmt->formattype, DataFormat->Specifier)) + { + // format is supported + CoTaskMemFree(MultipleItem); + OutputDebugStringW(L"CInputPin::CheckFormat format OK\n"); + return S_OK; + } + DataFormat = (PKSDATAFORMAT)((ULONG_PTR)DataFormat + DataFormat->FormatSize); + } + //format is not supported + CoTaskMemFree(MultipleItem); + } + return S_FALSE; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryAccept( + const AM_MEDIA_TYPE *pmt) +{ + return CheckFormat(pmt); } HRESULT STDMETHODCALLTYPE CInputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) { - OutputDebugStringW(L"CInputPin::EnumMediaTypes called\n"); - return E_NOTIMPL; + return CEnumMediaTypes_fnConstructor(0, NULL, IID_IEnumMediaTypes, (void**)ppEnum); } HRESULT STDMETHODCALLTYPE CInputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) { - OutputDebugStringW(L"CInputPin::QueryInternalConnections called\n"); + OutputDebugStringW(L"CInputPin::QueryInternalConnections NotImplemented\n"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CInputPin::EndOfStream( void) { - OutputDebugStringW(L"CInputPin::EndOfStream called\n"); + OutputDebugStringW(L"CInputPin::EndOfStream NotImplemented\n"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CInputPin::BeginFlush( void) { - OutputDebugStringW(L"CInputPin::BeginFlush called\n"); + OutputDebugStringW(L"CInputPin::BeginFlush NotImplemented\n"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CInputPin::EndFlush( void) { - OutputDebugStringW(L"CInputPin::EndFlush called\n"); + OutputDebugStringW(L"CInputPin::EndFlush NotImplemented\n"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) { - OutputDebugStringW(L"CInputPin::NewSegment called\n"); + OutputDebugStringW(L"CInputPin::NewSegment NotImplemented\n"); return E_NOTIMPL; } @@ -220,10 +504,12 @@ WINAPI CInputPin_Constructor( IBaseFilter * ParentFilter, LPCWSTR PinName, + HANDLE hFilter, + ULONG PinId, REFIID riid, LPVOID * ppv) { - CInputPin * handler = new CInputPin(ParentFilter, PinName); + CInputPin * handler = new CInputPin(ParentFilter, PinName, hFilter, PinId); if (!handler) return E_OUTOFMEMORY; diff --git a/reactos/dll/directx/ksproxy/ksproxy.rbuild b/reactos/dll/directx/ksproxy/ksproxy.rbuild index 4a4123061ca..2fa2bd3ac26 100644 --- a/reactos/dll/directx/ksproxy/ksproxy.rbuild +++ b/reactos/dll/directx/ksproxy/ksproxy.rbuild @@ -26,6 +26,7 @@ cvpconfig.cpp cvpvbiconfig.cpp datatype.cpp + enum_mediatypes.cpp enumpins.cpp input_pin.cpp interface.cpp diff --git a/reactos/dll/directx/ksproxy/precomp.h b/reactos/dll/directx/ksproxy/precomp.h index 6ddcd6e647a..19b846a83ef 100644 --- a/reactos/dll/directx/ksproxy/precomp.h +++ b/reactos/dll/directx/ksproxy/precomp.h @@ -16,6 +16,7 @@ #include #include #include +#include #include //#include @@ -104,6 +105,8 @@ WINAPI CInputPin_Constructor( IBaseFilter * ParentFilter, LPCWSTR PinName, + HANDLE hFilter, + ULONG PinId, REFIID riid, LPVOID * ppv); @@ -122,5 +125,15 @@ WINAPI CEnumPins_fnConstructor( std::vector Pins, REFIID riid, - LPVOID * ppv) -; \ No newline at end of file + LPVOID * ppv); + +/* enum_mediatypes.cpp */ +HRESULT +WINAPI +CEnumMediaTypes_fnConstructor( + ULONG MediaTypeCount, + AM_MEDIA_TYPE * MediaTypes, + REFIID riid, + LPVOID * ppv); + + diff --git a/reactos/dll/directx/ksproxy/proxy.cpp b/reactos/dll/directx/ksproxy/proxy.cpp index f9713895167..5e939ebd465 100644 --- a/reactos/dll/directx/ksproxy/proxy.cpp +++ b/reactos/dll/directx/ksproxy/proxy.cpp @@ -10,7 +10,7 @@ const GUID IID_IPersistPropertyBag = {0x37D84F60, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}}; const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; - +const GUID IID_IBDA_DeviceControl = {0xFD0A5AF3, 0xB41D, 0x11d2, {0x9C, 0x95, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}}; /* Needs IKsClock, IKsNotifyEvent */ @@ -134,6 +134,24 @@ CKsProxy::QueryInterface( return NOERROR; } + for(ULONG Index = 0; Index < m_Plugins.size(); Index++) + { + if (m_Pins[Index]) + { + HRESULT hr = m_Plugins[Index]->QueryInterface(refiid, Output); + if (SUCCEEDED(hr)) + { + WCHAR Buffer[100]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CKsProxy::QueryInterface plugin %lu supports interface %s\n", Index, lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + return hr; + } + } + } + WCHAR Buffer[MAX_PATH]; LPOLESTR lpstr; StringFromCLSID(refiid, &lpstr); @@ -469,7 +487,7 @@ CKsProxy::CreatePins() // construct the pins if (DataFlow == KSPIN_DATAFLOW_IN) { - hr = CInputPin_Constructor((IBaseFilter*)this, PinName, IID_IPin, (void**)&pPin); + hr = CInputPin_Constructor((IBaseFilter*)this, PinName, m_hDevice, Index, IID_IPin, (void**)&pPin); if (FAILED(hr)) { CoTaskMemFree(PinName); @@ -555,11 +573,6 @@ CKsProxy::Load(IPropertyBag *pPropBag, IErrorLog *pErrorLog) // now create the input / output pins hr = CreatePins(); - - CloseHandle(m_hDevice); - m_hDevice = NULL; - - return hr; } @@ -657,7 +670,6 @@ STDMETHODCALLTYPE CKsProxy::EnumPins( IEnumPins **ppEnum) { - OutputDebugStringW(L"CKsProxy::EnumPins\n"); return CEnumPins_fnConstructor(m_Pins, IID_IEnumPins, (void**)ppEnum); } @@ -666,8 +678,31 @@ STDMETHODCALLTYPE CKsProxy::FindPin( LPCWSTR Id, IPin **ppPin) { - OutputDebugStringW(L"CKsProxy::FindPin : NotImplemented\n"); - return E_NOTIMPL; + ULONG PinId; + + if (!ppPin) + return E_POINTER; + + // convert to pin + int ret = swscanf(Id, L"%u", &PinId); + + if (!ret || ret == EOF) + { + // invalid id + return VFW_E_NOT_FOUND; + } + + if (PinId >= m_Pins.size() || m_Pins[PinId] == NULL) + { + // invalid id + return VFW_E_NOT_FOUND; + } + + // found pin + *ppPin = m_Pins[PinId]; + m_Pins[PinId]->AddRef(); + + return S_OK; } @@ -702,7 +737,6 @@ CKsProxy::JoinFilterGraph( m_pGraph = 0; } - OutputDebugStringW(L"CKsProxy::JoinFilterGraph\n"); return S_OK; } diff --git a/reactos/dll/directx/msdvbnp/pin.cpp b/reactos/dll/directx/msdvbnp/pin.cpp index 288a312dcc1..9662f809133 100644 --- a/reactos/dll/directx/msdvbnp/pin.cpp +++ b/reactos/dll/directx/msdvbnp/pin.cpp @@ -184,7 +184,7 @@ CPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) MediaType->majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA; MediaType->subtype = MEDIASUBTYPE_None; - MediaType->formattype = GUID_NULL; + MediaType->formattype = FORMAT_None; MediaType->bFixedSizeSamples = true; MediaType->bTemporalCompression = false; MediaType->lSampleSize = sizeof(CHAR); From 52d93be892ef1c8af4003f462e2d46abea722f08 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 3 Mar 2010 05:10:38 +0000 Subject: [PATCH 047/211] [NTOS]: Do the "funny message" (not really funny, my apologies) shenanigans after the system components have shutdown, and reset the display and call the HAL at least at DPC level (should probably do it at HIGH IRQL, really). This way, we can avoid the context switch to another process while the HAL is executing the BIOS reset display call (done solely for the benefit of the "funny messages", as the video card driver usually resets the display) and thus avoid the "invalid V86 opcode" message sometimes appearing on shutdown. Did you know the "funny messages" take up more storage space than an average embedded micro-controller OS? svn path=/trunk/; revision=45777 --- reactos/ntoskrnl/ex/shutdown.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/reactos/ntoskrnl/ex/shutdown.c b/reactos/ntoskrnl/ex/shutdown.c index 680a9c7c0b3..83dd520d095 100644 --- a/reactos/ntoskrnl/ex/shutdown.c +++ b/reactos/ntoskrnl/ex/shutdown.c @@ -139,6 +139,16 @@ ShutdownThreadMain(PVOID Context) /* Run the thread on the boot processor */ KeSetSystemAffinityThread(1); + PspShutdownProcessManager(); + + CmShutdownSystem(); + IoShutdownRegisteredFileSystems(); + IoShutdownRegisteredDevices(); + + ZwQuerySystemTime(&Now); + + KeRaiseIrqlToDpcLevel(); + if (InbvIsBootDriverInstalled()) { InbvAcquireDisplayOwnership(); @@ -152,19 +162,12 @@ ShutdownThreadMain(PVOID Context) if (Action == ShutdownNoReboot) { - ZwQuerySystemTime(&Now); Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */ HalDisplayString(FamousLastWords[Now.u.LowPart % (sizeof(FamousLastWords) / sizeof(PCH))]); } - - PspShutdownProcessManager(); - - CmShutdownSystem(); - IoShutdownRegisteredFileSystems(); - IoShutdownRegisteredDevices(); - + if (Action == ShutdownNoReboot) { HalDisplayString("\nYou can switch off your computer now\n"); From 486e587cca9d6acbc840dc1811a9b93505a79c45 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 3 Mar 2010 05:21:00 +0000 Subject: [PATCH 048/211] [VMX-SVGA]: Some work in progress from my tree. Abandonning this for now due to work reasons, but will likely have eVb hacking on it as some future time. The point of this driver was to expose Mm/VideoPrt issues AND support Qemu hosts with the VMX-SVGA driver option which do not have a way to obtain the driver itself but would still benefit from the acceleration. It was mostly just an experiment. svn path=/trunk/; revision=45778 --- .../drivers/video/miniport/vmx_svga/precomp.h | 6 +- .../video/miniport/vmx_svga/vmx_svga.c | 157 +++++++++++++++++- 2 files changed, 158 insertions(+), 5 deletions(-) diff --git a/reactos/drivers/video/miniport/vmx_svga/precomp.h b/reactos/drivers/video/miniport/vmx_svga/precomp.h index 245d90116c2..7555bc1f1ea 100644 --- a/reactos/drivers/video/miniport/vmx_svga/precomp.h +++ b/reactos/drivers/video/miniport/vmx_svga/precomp.h @@ -20,13 +20,13 @@ typedef struct _HW_DEVICE_EXTENSION LARGE_INTEGER VramSize; PHYSICAL_ADDRESS VramBase; ULONG MemSize; - ULONG IndexPort; - ULONG ValuePort; + PULONG IndexPort; + PULONG ValuePort; PVOID FrameBufferBase; PVOID Fifo; ULONG InterruptPort; ULONG InterruptState; - PKEVENT SyncEvent; + PENG_EVENT SyncEvent; VIDEO_MODE_INFORMATION CurrentMode; ULONG VideoModeCount; ULONG Capabilities; diff --git a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c index ca5cab49f67..26c9da07b50 100644 --- a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c +++ b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c @@ -9,13 +9,76 @@ /* INCLUDES *******************************************************************/ #include "precomp.h" +#include "debug.h" /* GLOBALS ********************************************************************/ PHW_DEVICE_EXTENSION VmxDeviceExtensionArray[SVGA_MAX_DISPLAYS]; +static PWCHAR AdapterString = L"VMware SVGA II"; /* FUNCTIONS ******************************************************************/ +ULONG +NTAPI +VmxReadUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, + IN ULONG Index) +{ + /* Program the index first, then read the value */ + VideoPortWritePortUlong(DeviceExtension->IndexPort, Index); + return VideoPortReadPortUlong(DeviceExtension->ValuePort); +} + +VOID +NTAPI +VmxWriteUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, + IN ULONG Index, + IN ULONG Value) +{ + /* Program the index first, then write the value */ + VideoPortWritePortUlong(DeviceExtension->IndexPort, Index); + VideoPortWritePortUlong(DeviceExtension->ValuePort, Value); +} + +ULONG +NTAPI +VmxInitModes(IN PHW_DEVICE_EXTENSION DeviceExtension) +{ + /* Not here yet */ + UNIMPLEMENTED; + while (TRUE); + return 0; +} + +VP_STATUS +NTAPI +VmxInitDevice(IN PHW_DEVICE_EXTENSION DeviceExtension) +{ + /* Not here yet */ + UNIMPLEMENTED; + while (TRUE); + return NO_ERROR; +} + +BOOLEAN +NTAPI +VmxIsMultiMon(IN PHW_DEVICE_EXTENSION DeviceExtension) +{ + ULONG Capabilities; + + /* Get the caps */ + Capabilities = DeviceExtension->Capabilities; + + /* Check for multi-mon support */ + if ((Capabilities & SVGA_CAP_MULTIMON) && (Capabilities & SVGA_CAP_PITCHLOCK)) + { + /* Query the monitor count */ + if (VmxReadUlong(DeviceExtension, SVGA_REG_NUM_DISPLAYS) > 1) return TRUE; + } + + /* Either no support, or just one screen */ + return FALSE; +} + VP_STATUS NTAPI VmxFindAdapter(IN PVOID HwDeviceExtension, @@ -24,6 +87,82 @@ VmxFindAdapter(IN PVOID HwDeviceExtension, IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again) { + VP_STATUS Status; + PHW_DEVICE_EXTENSION DeviceExtension = HwDeviceExtension; + DPRINT1("VMX searching for adapter\n"); + + /* Zero out the fields */ + VideoPortZeroMemory(DeviceExtension, sizeof(HW_DEVICE_EXTENSION)); + + /* Validate the Config Info */ + if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO)) + { + /* Incorrect OS version? */ + DPRINT1("Invalid configuration info\n"); + return ERROR_INVALID_PARAMETER; + } + + /* Initialize the device extension and find the adapter */ + Status = VmxInitDevice(DeviceExtension); + DPRINT1("Init status: %lx\n", Status); + if (Status != NO_ERROR) return ERROR_DEV_NOT_EXIST; + + /* Save this adapter extension */ + VmxDeviceExtensionArray[0] = DeviceExtension; + + /* Create the sync event */ + VideoPortCreateEvent(DeviceExtension, + SynchronizationEvent, + FALSE, + &DeviceExtension->SyncEvent); + + /* Check for multi-monitor configuration */ + if (VmxIsMultiMon(DeviceExtension)) + { + /* Let's not go so far */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Zero the frame buffer */ + VideoPortZeroMemory((PVOID)DeviceExtension->FrameBuffer.LowPart, + DeviceExtension->VramSize.LowPart); + + /* Initialize the video modes */ + VmxInitModes(DeviceExtension); + + /* Setup registry keys */ + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.ChipType", + AdapterString, + sizeof(AdapterString)); + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.DacType", + AdapterString, + sizeof(AdapterString)); + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.MemorySize", + &DeviceExtension->VramSize.LowPart, + sizeof(ULONG)); + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.AdapterString", + AdapterString, + sizeof(AdapterString)); + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.BiosString", + AdapterString, + sizeof(AdapterString)); + + /* No VDM support */ + ConfigInfo->NumEmulatorAccessEntries = 0; + ConfigInfo->EmulatorAccessEntries = 0; + ConfigInfo->EmulatorAccessEntriesContext = 0; + ConfigInfo->HardwareStateSize = 0; + ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0; + ConfigInfo->VdmPhysicalVideoMemoryLength = 0; + + /* Write that this is Windows XP or higher */ + VmxWriteUlong(DeviceExtension, SVGA_REG_GUEST_ID, 0x5000 | 0x08); return NO_ERROR; } @@ -31,6 +170,8 @@ BOOLEAN NTAPI VmxInitialize(IN PVOID HwDeviceExtension) { + UNIMPLEMENTED; + while (TRUE); return TRUE; } @@ -39,6 +180,8 @@ NTAPI VmxStartIO(IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET RequestPacket) { + UNIMPLEMENTED; + while (TRUE); return TRUE; } @@ -48,6 +191,8 @@ VmxResetHw(IN PVOID DeviceExtension, IN ULONG Columns, IN ULONG Rows) { + UNIMPLEMENTED; + while (TRUE); return FALSE; } @@ -57,6 +202,8 @@ VmxGetPowerState(IN PVOID HwDeviceExtension, IN ULONG HwId, IN PVIDEO_POWER_MANAGEMENT VideoPowerControl) { + UNIMPLEMENTED; + while (TRUE); return NO_ERROR; } @@ -66,14 +213,17 @@ VmxSetPowerState(IN PVOID HwDeviceExtension, IN ULONG HwId, IN PVIDEO_POWER_MANAGEMENT VideoPowerControl) { - - return NO_ERROR; + UNIMPLEMENTED; + while (TRUE); + return NO_ERROR; } BOOLEAN NTAPI VmxInterrupt(IN PVOID HwDeviceExtension) { + UNIMPLEMENTED; + while (TRUE); return TRUE; } @@ -86,6 +236,8 @@ VmxGetVideoChildDescriptor(IN PVOID HwDeviceExtension, OUT PULONG UId, OUT PULONG pUnused) { + UNIMPLEMENTED; + while (TRUE); return NO_ERROR; } @@ -97,6 +249,7 @@ DriverEntry(IN PVOID Context1, VIDEO_HW_INITIALIZATION_DATA InitData; /* Zero initialization structure and array of extensions, one per screen */ + DPRINT1("VMX-SVGAII Loading...\n"); VideoPortZeroMemory(VmxDeviceExtensionArray, sizeof(VmxDeviceExtensionArray)); VideoPortZeroMemory(&InitData, sizeof(InitData)); From 4c15f8900eafb085eaf539b971ade3a65d7c778d Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 3 Mar 2010 05:22:45 +0000 Subject: [PATCH 049/211] [VIDEOPRT]: - Patch to make VideoPort INT10 Services return VP_STATUS instead of NT_STATUS. It is not the same thing. svn path=/trunk/; revision=45779 --- reactos/drivers/video/videoprt/int10.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/video/videoprt/int10.c b/reactos/drivers/video/videoprt/int10.c index 66e18143622..7930c87ca72 100644 --- a/reactos/drivers/video/videoprt/int10.c +++ b/reactos/drivers/video/videoprt/int10.c @@ -187,7 +187,8 @@ IntInt10CallBios( /* Detach and return status */ IntDetachFromCSRSS(&CallingProcess, &ApcState); - return Status; + if (NT_SUCCESS(Status)) return NO_ERROR; + return ERROR_INVALID_PARAMETER; } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -240,6 +241,6 @@ VideoPortInt10( /* Detach from CSRSS */ IntDetachFromCSRSS(&CallingProcess, &ApcState); - - return Status; + if (NT_SUCCESS(Status)) return NO_ERROR; + return ERROR_INVALID_PARAMETER; } From 7dc9efe80848e2e34cffedfa07c69c182010c776 Mon Sep 17 00:00:00 2001 From: evb Date: Wed, 3 Mar 2010 07:09:09 +0000 Subject: [PATCH 050/211] - Video Miniport driver not use ntddk.h, but miniport.h. But, Reactos miniport.h is empty! Add some definitions to miniport.h to get simple drivers to compile, so now can remove ntddk.h from VGA/VBE/XBOX miniports! - Video Port driver should not use either, but too many changes required. So, define __BROKEN__ to allow ntddk + miniport together. - Add VideoPortIsNoVesa API definition. Not implemented in ReactOS, used to disable VESA in F8 "Standard VGA Mode". Should implement for VGA-only support on broken VESA machine, and for test. svn path=/trunk/; revision=45780 --- reactos/drivers/video/miniport/vbe/vbemp.h | 12 +- reactos/drivers/video/miniport/vga/vgamp.h | 12 +- .../drivers/video/miniport/xboxvmp/xboxvmp.h | 12 +- reactos/drivers/video/videoprt/videoprt.h | 1 + reactos/include/ddk/miniport.h | 187 ++++++++++++++++++ reactos/include/ddk/video.h | 7 + 6 files changed, 201 insertions(+), 30 deletions(-) diff --git a/reactos/drivers/video/miniport/vbe/vbemp.h b/reactos/drivers/video/miniport/vbe/vbemp.h index 7abf14408a5..34807b2f978 100644 --- a/reactos/drivers/video/miniport/vbe/vbemp.h +++ b/reactos/drivers/video/miniport/vbe/vbemp.h @@ -22,17 +22,9 @@ /* INCLUDES *******************************************************************/ -#ifdef _MSC_VER -#pragma message ("INVESTIGATE ME") -#endif - -#if 0 //#ifdef _MSC_VER -#include "devioctl.h" -#else -#include -#endif - +#include "ntdef.h" #include "dderror.h" +#include "devioctl.h" #include "miniport.h" #include "ntddvdeo.h" #include "video.h" diff --git a/reactos/drivers/video/miniport/vga/vgamp.h b/reactos/drivers/video/miniport/vga/vgamp.h index efe0bc558eb..2e018e4b116 100644 --- a/reactos/drivers/video/miniport/vga/vgamp.h +++ b/reactos/drivers/video/miniport/vga/vgamp.h @@ -23,17 +23,9 @@ /* INCLUDES *******************************************************************/ -#ifdef _MSC_VER -#pragma message ("INVESTIGATE ME") -#endif - -#if 0 //#ifdef _MSC_VER -#include "devioctl.h" -#else -#include -#endif - +#include "ntdef.h" #include "dderror.h" +#include "devioctl.h" #include "miniport.h" #include "ntddvdeo.h" #include "video.h" diff --git a/reactos/drivers/video/miniport/xboxvmp/xboxvmp.h b/reactos/drivers/video/miniport/xboxvmp/xboxvmp.h index 55bc208107c..3dacdcc21dc 100644 --- a/reactos/drivers/video/miniport/xboxvmp/xboxvmp.h +++ b/reactos/drivers/video/miniport/xboxvmp/xboxvmp.h @@ -24,18 +24,10 @@ /* INCLUDES *******************************************************************/ -#ifdef _MSC_VER -#pragma message ("INVESTIGATE ME") -#endif - -#if 0 //#ifdef _MSC_VER -#include "devioctl.h" +#include "ntdef.h" #define PAGE_SIZE 4096 -#else -#include -#endif - #include "dderror.h" +#include "devioctl.h" #include "miniport.h" #include "ntddvdeo.h" #include "video.h" diff --git a/reactos/drivers/video/videoprt/videoprt.h b/reactos/drivers/video/videoprt/videoprt.h index aae0ba10ee4..21ea2c09ee1 100644 --- a/reactos/drivers/video/videoprt/videoprt.h +++ b/reactos/drivers/video/videoprt/videoprt.h @@ -24,6 +24,7 @@ #include #include +#define __BROKEN__ #include #include #include diff --git a/reactos/include/ddk/miniport.h b/reactos/include/ddk/miniport.h index b147c25a62b..59fcc52a16e 100644 --- a/reactos/include/ddk/miniport.h +++ b/reactos/include/ddk/miniport.h @@ -63,6 +63,193 @@ typedef VOID IN ULONG ReadBank, IN ULONG WriteBank, IN PVOID Context); + +#ifndef __BROKEN__ + +typedef enum _INTERFACE_TYPE { + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + PNPBus, + Vmcs, + MaximumInterfaceType +}INTERFACE_TYPE, *PINTERFACE_TYPE; + +typedef enum _KINTERRUPT_MODE { + LevelSensitive, + Latched +} KINTERRUPT_MODE; + +typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context); +typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context); + +typedef enum _BUS_DATA_TYPE { + ConfigurationSpaceUndefined = -1, + Cmos, + EisaConfiguration, + Pos, + CbusConfiguration, + PCIConfiguration, + VMEConfiguration, + NuBusConfiguration, + PCMCIAConfiguration, + MPIConfiguration, + MPSAConfiguration, + PNPISAConfiguration, + SgiInternalConfiguration, + MaximumBusDataType +} BUS_DATA_TYPE, *PBUS_DATA_TYPE; + +typedef enum _DMA_WIDTH { + Width8Bits, + Width16Bits, + Width32Bits, + MaximumDmaWidth +}DMA_WIDTH, *PDMA_WIDTH; + +typedef enum _DMA_SPEED { + Compatible, + TypeA, + TypeB, + TypeC, + TypeF, + MaximumDmaSpeed +}DMA_SPEED, *PDMA_SPEED; + +typedef struct _INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; +} INTERFACE, *PINTERFACE; + +typedef enum _IRQ_DEVICE_POLICY { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors, + IrqPolicyOneCloseProcessor, + IrqPolicyAllProcessorsInMachine, + IrqPolicySpecifiedProcessors, + IrqPolicySpreadMessagesAcrossAllProcessors +} IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +typedef enum _IRQ_PRIORITY { + IrqPriorityUndefined = 0, + IrqPriorityLow, + IrqPriorityNormal, + IrqPriorityHigh +} IRQ_PRIORITY, *PIRQ_PRIORITY; + +typedef struct _IO_RESOURCE_DESCRIPTOR { + UCHAR Option; + UCHAR Type; // use CM_RESOURCE_TYPE + UCHAR ShareDisposition; // use CM_SHARE_DISPOSITION + UCHAR Spare1; + USHORT Flags; // use CM resource flag defines + USHORT Spare2; // align + + union { + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Port; + + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory; + + struct { + ULONG MinimumVector; + ULONG MaximumVector; + IRQ_DEVICE_POLICY AffinityPolicy; + IRQ_PRIORITY PriorityPolicy; + KAFFINITY TargetedProcessors; + } Interrupt; + + struct { + ULONG MinimumChannel; + ULONG MaximumChannel; + } Dma; + + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Generic; + + struct { + ULONG Data[3]; + } DevicePrivate; + + // + // Bus Number information. + // + + struct { + ULONG Length; + ULONG MinBusNumber; + ULONG MaxBusNumber; + ULONG Reserved; + } BusNumber; + + struct { + ULONG Priority; // use LCPRI_Xxx values in cfg.h + ULONG Reserved1; + ULONG Reserved2; + } ConfigData; + + // + // The following structures provide descriptions + // for memory resource requirement greater than MAXULONG + // + + struct { + ULONG Length40; + ULONG Alignment40; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory40; + + struct { + ULONG Length48; + ULONG Alignment48; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory48; + + struct { + ULONG Length64; + ULONG Alignment64; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory64; + + + } u; + +} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR; + +#include +#endif #ifdef __cplusplus } diff --git a/reactos/include/ddk/video.h b/reactos/include/ddk/video.h index fcf4d4a7254..047a56721d9 100644 --- a/reactos/include/ddk/video.h +++ b/reactos/include/ddk/video.h @@ -1136,6 +1136,13 @@ DDKAPI VideoPortQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); +VPAPI +BOOLEAN +DDKAPI +VideoPortIsNoVesa( + VOID +); + VPAPI BOOLEAN DDKAPI From b7458a6c946a55b0f4613337fb9fc56f0f453cff Mon Sep 17 00:00:00 2001 From: evb Date: Wed, 3 Mar 2010 08:08:07 +0000 Subject: [PATCH 051/211] - Fix includes in richard's driver. - Fix wrong calling to VideoPortCreateEvent. He got parameters all mixed up~ svn path=/trunk/; revision=45781 --- reactos/drivers/video/miniport/vmx_svga/precomp.h | 4 ++-- reactos/drivers/video/miniport/vmx_svga/vmx_svga.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/video/miniport/vmx_svga/precomp.h b/reactos/drivers/video/miniport/vmx_svga/precomp.h index 7555bc1f1ea..a8f8a82705c 100644 --- a/reactos/drivers/video/miniport/vmx_svga/precomp.h +++ b/reactos/drivers/video/miniport/vmx_svga/precomp.h @@ -5,8 +5,8 @@ * PURPOSE: VMWARE SVGA-II Driver Header * PROGRAMMERS: ReactOS Portable Systems Group */ - -#include + +#include #include #include #include diff --git a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c index 26c9da07b50..3c981c59be1 100644 --- a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c +++ b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c @@ -112,8 +112,8 @@ VmxFindAdapter(IN PVOID HwDeviceExtension, /* Create the sync event */ VideoPortCreateEvent(DeviceExtension, - SynchronizationEvent, - FALSE, + NOTIFICATION_EVENT, + NULL, &DeviceExtension->SyncEvent); /* Check for multi-monitor configuration */ From 822bfb7915e3f332e12879aefa586ddb66fc15c8 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 16:14:25 +0000 Subject: [PATCH 052/211] [HLINK] sync hlink to wine 1.1.39 svn path=/trunk/; revision=45790 --- reactos/dll/win32/hlink/browse_ctx.c | 15 +++- reactos/dll/win32/hlink/hlink_main.c | 46 ++-------- reactos/dll/win32/hlink/link.c | 121 +++++++++++++++++++-------- 3 files changed, 107 insertions(+), 75 deletions(-) diff --git a/reactos/dll/win32/hlink/browse_ctx.c b/reactos/dll/win32/hlink/browse_ctx.c index f0274b06276..a5b73c10bc1 100644 --- a/reactos/dll/win32/hlink/browse_ctx.c +++ b/reactos/dll/win32/hlink/browse_ctx.c @@ -223,8 +223,19 @@ static HRESULT WINAPI IHlinkBC_QueryHlink( IHlinkBrowseContext* iface, static HRESULT WINAPI IHlinkBC_GetHlink( IHlinkBrowseContext* iface, ULONG uHLID, IHlink** ppihl) { - FIXME("\n"); - return E_NOTIMPL; + HlinkBCImpl *This = (HlinkBCImpl*)iface; + + TRACE("(%p)->(%x %p)\n", This, uHLID, ppihl); + + if(uHLID != HLID_CURRENT) { + FIXME("Only HLID_CURRENT implemented, given: %x\n", uHLID); + return E_NOTIMPL; + } + + *ppihl = This->CurrentPage; + IHlink_AddRef(*ppihl); + + return S_OK; } static HRESULT WINAPI IHlinkBC_SetCurrentHlink( IHlinkBrowseContext* iface, diff --git a/reactos/dll/win32/hlink/hlink_main.c b/reactos/dll/win32/hlink/hlink_main.c index 213506e15f1..d07901aea4a 100644 --- a/reactos/dll/win32/hlink/hlink_main.c +++ b/reactos/dll/win32/hlink/hlink_main.c @@ -55,7 +55,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) */ HRESULT WINAPI DllCanUnloadNow( void ) { - FIXME("\n"); return S_OK; } @@ -77,14 +76,12 @@ HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation, if (FAILED(r)) return r; - if (pwzLocation) - IHlink_SetStringReference(hl, HLINKSETF_LOCATION, NULL, pwzLocation); + IHlink_SetMonikerReference(hl, HLINKSETF_LOCATION | HLINKSETF_TARGET, pimkTrgt, pwzLocation); + if (pwzFriendlyName) IHlink_SetFriendlyName(hl, pwzFriendlyName); if (pihlsite) IHlink_SetHlinkSite(hl, pihlsite, dwSiteData); - if (pimkTrgt) - IHlink_SetMonikerReference(hl, 0, pimkTrgt, pwzLocation); *ppvObj = hl; @@ -111,43 +108,12 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation, if (FAILED(r)) return r; - if (pwzLocation) - IHlink_SetStringReference(hl, HLINKSETF_LOCATION, NULL, pwzLocation); - - if (pwzTarget) - { - IMoniker *pTgtMk = NULL; - IBindCtx *pbc = NULL; - ULONG eaten; - - CreateBindCtx(0, &pbc); - r = MkParseDisplayName(pbc, pwzTarget, &eaten, &pTgtMk); - IBindCtx_Release(pbc); - - if (FAILED(r)) - { - LPCWSTR p = strchrW(pwzTarget, ':'); - if (p && (p - pwzTarget > 1)) - r = CreateURLMoniker(NULL, pwzTarget, &pTgtMk); - else - r = CreateFileMoniker(pwzTarget,&pTgtMk); - } - - if (FAILED(r)) - { - ERR("couldn't create moniker for %s, failed with error 0x%08x\n", - debugstr_w(pwzTarget), r); - return r; - } - - IHlink_SetMonikerReference(hl, 0, pTgtMk, pwzLocation); - IMoniker_Release(pTgtMk); - - IHlink_SetStringReference(hl, HLINKSETF_TARGET, pwzTarget, NULL); - } + IHlink_SetStringReference(hl, HLINKSETF_TARGET | HLINKSETF_LOCATION, + pwzTarget, pwzLocation); if (pwzFriendlyName) IHlink_SetFriendlyName(hl, pwzFriendlyName); + if (pihlsite) IHlink_SetHlinkSite(hl, pihlsite, dwSiteData); @@ -159,7 +125,7 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation, /*********************************************************************** - * HlinkNavigate (HLINK.@) + * HlinkCreateBrowseContext (HLINK.@) */ HRESULT WINAPI HlinkCreateBrowseContext( IUnknown* piunkOuter, REFIID riid, void** ppvObj) { diff --git a/reactos/dll/win32/hlink/link.c b/reactos/dll/win32/hlink/link.c index 689317db429..52197ccf6fd 100644 --- a/reactos/dll/win32/hlink/link.c +++ b/reactos/dll/win32/hlink/link.c @@ -51,7 +51,6 @@ typedef struct LPWSTR FriendlyName; LPWSTR Location; - LPWSTR Target; LPWSTR TargetFrameName; IMoniker *Moniker; IHlinkSite *Site; @@ -155,7 +154,6 @@ static ULONG WINAPI IHlink_fnRelease (IHlink* iface) TRACE("-- destroying IHlink (%p)\n", This); heap_free(This->FriendlyName); - heap_free(This->Target); heap_free(This->TargetFrameName); heap_free(This->Location); if (This->Moniker) @@ -206,24 +204,33 @@ static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface, { HlinkImpl *This = (HlinkImpl*)iface; - FIXME("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget, + TRACE("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget, debugstr_w(pwzLocation)); - if (This->Moniker) - IMoniker_Release(This->Moniker); + if(rfHLSETF == 0) + return E_INVALIDARG; + if(!(rfHLSETF & (HLINKSETF_TARGET | HLINKSETF_LOCATION))) + return rfHLSETF; - This->Moniker = pmkTarget; - if (This->Moniker) - { - LPOLESTR display_name; - IMoniker_AddRef(This->Moniker); - IMoniker_GetDisplayName(This->Moniker, NULL, NULL, &display_name); - This->absolute = display_name && strchrW(display_name, ':'); - CoTaskMemFree(display_name); + if(rfHLSETF & HLINKSETF_TARGET){ + if (This->Moniker) + IMoniker_Release(This->Moniker); + + This->Moniker = pmkTarget; + if (This->Moniker) + { + LPOLESTR display_name; + IMoniker_AddRef(This->Moniker); + IMoniker_GetDisplayName(This->Moniker, NULL, NULL, &display_name); + This->absolute = display_name && strchrW(display_name, ':'); + CoTaskMemFree(display_name); + } } - heap_free(This->Location); - This->Location = hlink_strdupW( pwzLocation ); + if(rfHLSETF & HLINKSETF_LOCATION){ + heap_free(This->Location); + This->Location = hlink_strdupW( pwzLocation ); + } return S_OK; } @@ -236,11 +243,51 @@ static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface, TRACE("(%p)->(%i %s %s)\n", This, grfHLSETF, debugstr_w(pwzTarget), debugstr_w(pwzLocation)); + if(grfHLSETF > (HLINKSETF_TARGET | HLINKSETF_LOCATION) && + grfHLSETF < -(HLINKSETF_TARGET | HLINKSETF_LOCATION)) + return grfHLSETF; + if (grfHLSETF & HLINKSETF_TARGET) { - heap_free(This->Target); - This->Target = hlink_strdupW( pwzTarget ); + if (This->Moniker) + { + IMoniker_Release(This->Moniker); + This->Moniker = NULL; + } + if (pwzTarget && *pwzTarget) + { + IMoniker *pMon; + IBindCtx *pbc = NULL; + ULONG eaten; + HRESULT r; + + r = CreateBindCtx(0, &pbc); + if (FAILED(r)) + return E_OUTOFMEMORY; + + r = MkParseDisplayName(pbc, pwzTarget, &eaten, &pMon); + IBindCtx_Release(pbc); + + if (FAILED(r)) + { + LPCWSTR p = strchrW(pwzTarget, ':'); + if (p && (p - pwzTarget > 1)) + r = CreateURLMoniker(NULL, pwzTarget, &pMon); + else + r = CreateFileMoniker(pwzTarget, &pMon); + if (FAILED(r)) + { + ERR("couldn't create moniker for %s, failed with error 0x%08x\n", + debugstr_w(pwzTarget), r); + return r; + } + } + + IHlink_SetMonikerReference(iface, HLINKSETF_TARGET, pMon, NULL); + IMoniker_Release(pMon); + } } + if (grfHLSETF & HLINKSETF_LOCATION) { heap_free(This->Location); @@ -272,28 +319,36 @@ static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface, { HlinkImpl *This = (HlinkImpl*)iface; - FIXME("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation); + TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation); + + /* note: undocumented behavior with dwWhichRef == -1 */ + if(dwWhichRef != -1 && dwWhichRef & ~(HLINKGETREF_DEFAULT | HLINKGETREF_ABSOLUTE | HLINKGETREF_RELATIVE)) + { + if(ppwzTarget) + *ppwzTarget = NULL; + if(ppwzLocation) + *ppwzLocation = NULL; + return E_INVALIDARG; + } + + if(dwWhichRef != HLINKGETREF_DEFAULT) + FIXME("unhandled flags: 0x%x\n", dwWhichRef); if (ppwzTarget) { - *ppwzTarget = hlink_co_strdupW( This->Target ); - - if (!This->Target) + IMoniker* mon; + __GetMoniker(This, &mon); + if (mon) { - IMoniker* mon; - __GetMoniker(This, &mon); - if (mon) - { - IBindCtx *pbc; + IBindCtx *pbc; - CreateBindCtx( 0, &pbc); - IMoniker_GetDisplayName(mon, pbc, NULL, ppwzTarget); - IBindCtx_Release(pbc); - IMoniker_Release(mon); - } - else - FIXME("Unhandled case, no set Target and no moniker\n"); + CreateBindCtx( 0, &pbc); + IMoniker_GetDisplayName(mon, pbc, NULL, ppwzTarget); + IBindCtx_Release(pbc); + IMoniker_Release(mon); } + else + *ppwzTarget = NULL; } if (ppwzLocation) *ppwzLocation = hlink_co_strdupW( This->Location ); From 96b0a44c362e3c7be83db3fa92d5104b2cd721d2 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 16:21:34 +0000 Subject: [PATCH 053/211] [SHLWAPI] sync shlwapi to wine 1.1.39 svn path=/trunk/; revision=45791 --- reactos/dll/win32/shlwapi/msgbox.c | 6 +- reactos/dll/win32/shlwapi/ordinal.c | 182 ++++++++++++++++++------ reactos/dll/win32/shlwapi/reg.c | 62 -------- reactos/dll/win32/shlwapi/shlwapi.rc | 19 +-- reactos/dll/win32/shlwapi/shlwapi.spec | 14 +- reactos/dll/win32/shlwapi/shlwapi_De.rc | 1 - reactos/dll/win32/shlwapi/shlwapi_Fr.rc | 1 - reactos/dll/win32/shlwapi/shlwapi_Ja.rc | 1 - reactos/dll/win32/shlwapi/shlwapi_No.rc | 1 - reactos/dll/win32/shlwapi/shlwapi_Si.rc | 1 - reactos/dll/win32/shlwapi/url.c | 108 ++++++++++---- 11 files changed, 245 insertions(+), 151 deletions(-) diff --git a/reactos/dll/win32/shlwapi/msgbox.c b/reactos/dll/win32/shlwapi/msgbox.c index 0936e0becf1..506bd4651b7 100644 --- a/reactos/dll/win32/shlwapi/msgbox.c +++ b/reactos/dll/win32/shlwapi/msgbox.c @@ -147,10 +147,10 @@ INT_PTR WINAPI SHMessageBoxCheckExA(HWND hWnd, HINSTANCE hInst, LPCSTR lpszName, WCHAR szNameBuff[MAX_PATH], szIdBuff[MAX_PATH]; LPCWSTR szName = szNameBuff; - if (HIWORD(lpszName)) - MultiByteToWideChar(CP_ACP, 0, lpszName, -1, szNameBuff, MAX_PATH); - else + if (IS_INTRESOURCE(lpszName)) szName = (LPCWSTR)lpszName; /* Resource Id or NULL */ + else + MultiByteToWideChar(CP_ACP, 0, lpszName, -1, szNameBuff, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, lpszId, -1, szIdBuff, MAX_PATH); diff --git a/reactos/dll/win32/shlwapi/ordinal.c b/reactos/dll/win32/shlwapi/ordinal.c index 0ecbab81ed5..315208c1614 100644 --- a/reactos/dll/win32/shlwapi/ordinal.c +++ b/reactos/dll/win32/shlwapi/ordinal.c @@ -46,6 +46,7 @@ #include "shlwapi.h" #include "shellapi.h" #include "commdlg.h" +#include "mlang.h" #include "mshtmhst.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -450,14 +451,14 @@ RegisterDefaultAcceptHeaders_Exit: * * PARAMS * langbuf [O] Destination for language string - * buflen [I] Length of langbuf + * buflen [I] Length of langbuf in characters * [0] Success: used length of langbuf * * RETURNS * Success: S_OK. langbuf is set to the language string found. * Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer * does not contain the setting. - * E_INVALIDARG, If the buffer is not big enough + * HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), If the buffer is not big enough */ HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen) { @@ -468,49 +469,50 @@ HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen) 'I','n','t','e','r','n','a','t','i','o','n','a','l',0}; static const WCHAR valueW[] = { 'A','c','c','e','p','t','L','a','n','g','u','a','g','e',0}; - static const WCHAR enusW[] = {'e','n','-','u','s',0}; DWORD mystrlen, mytype; + DWORD len; HKEY mykey; HRESULT retval; LCID mylcid; WCHAR *mystr; + LONG lres; + + TRACE("(%p, %p) *%p: %d\n", langbuf, buflen, buflen, buflen ? *buflen : -1); if(!langbuf || !buflen || !*buflen) return E_FAIL; mystrlen = (*buflen > 20) ? *buflen : 20 ; - mystr = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * mystrlen); + len = mystrlen * sizeof(WCHAR); + mystr = HeapAlloc(GetProcessHeap(), 0, len); + mystr[0] = 0; RegOpenKeyW(HKEY_CURRENT_USER, szkeyW, &mykey); - if(RegQueryValueExW(mykey, valueW, 0, &mytype, (PBYTE)mystr, &mystrlen)) { - /* Did not find value */ - mylcid = GetUserDefaultLCID(); - /* somehow the mylcid translates into "en-us" - * this is similar to "LOCALE_SABBREVLANGNAME" - * which could be gotten via GetLocaleInfo. - * The only problem is LOCALE_SABBREVLANGUAGE" is - * a 3 char string (first 2 are country code and third is - * letter for "sublanguage", which does not come close to - * "en-us" - */ - lstrcpyW(mystr, enusW); - mystrlen = lstrlenW(mystr); - } else { - /* handle returned string */ - FIXME("missing code\n"); - } - memcpy( langbuf, mystr, min(*buflen,strlenW(mystr)+1)*sizeof(WCHAR) ); - - if(*buflen > strlenW(mystr)) { - *buflen = strlenW(mystr); - retval = S_OK; - } else { - *buflen = 0; - retval = E_INVALIDARG; - SetLastError(ERROR_INSUFFICIENT_BUFFER); - } + lres = RegQueryValueExW(mykey, valueW, 0, &mytype, (PBYTE)mystr, &len); RegCloseKey(mykey); + len = lstrlenW(mystr); + + if (!lres && (*buflen > len)) { + lstrcpyW(langbuf, mystr); + *buflen = len; + HeapFree(GetProcessHeap(), 0, mystr); + return S_OK; + } + + /* Did not find a value in the registry or the user buffer is to small */ + mylcid = GetUserDefaultLCID(); + retval = LcidToRfc1766W(mylcid, mystr, mystrlen); + len = lstrlenW(mystr); + + memcpy( langbuf, mystr, min(*buflen, len+1)*sizeof(WCHAR) ); HeapFree(GetProcessHeap(), 0, mystr); - return retval; + + if (*buflen > len) { + *buflen = len; + return S_OK; + } + + *buflen = 0; + return __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } /************************************************************************* @@ -524,6 +526,8 @@ HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen) DWORD buflenW, convlen; HRESULT retval; + TRACE("(%p, %p) *%p: %d\n", langbuf, buflen, buflen, buflen ? *buflen : -1); + if(!langbuf || !buflen || !*buflen) return E_FAIL; buflenW = *buflen; @@ -533,11 +537,20 @@ HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen) if (retval == S_OK) { convlen = WideCharToMultiByte(CP_ACP, 0, langbufW, -1, langbuf, *buflen, NULL, NULL); + convlen--; /* do not count the terminating 0 */ } else /* copy partial string anyway */ { convlen = WideCharToMultiByte(CP_ACP, 0, langbufW, *buflen, langbuf, *buflen, NULL, NULL); - if (convlen < *buflen) langbuf[convlen] = 0; + if (convlen < *buflen) + { + langbuf[convlen] = 0; + convlen--; /* do not count the terminating 0 */ + } + else + { + convlen = *buflen; + } } *buflen = buflenW ? convlen : 0; @@ -1128,7 +1141,7 @@ HWND WINAPI SHSetParentHwnd(HWND hWnd, HWND hWndParent) * PARAMS * lpUnkSink [I] Sink for the connection point advise call * riid [I] REFIID of connection point to advise - * bAdviseOnly [I] TRUE = Advise only, FALSE = Unadvise first + * fConnect [I] TRUE = Connection being establisted, FALSE = broken * lpUnknown [I] Object supporting the IConnectionPointContainer interface * lpCookie [O] Pointer to connection point cookie * lppCP [O] Destination for the IConnectionPoint found @@ -1140,7 +1153,7 @@ HWND WINAPI SHSetParentHwnd(HWND hWnd, HWND hWndParent) * E_NOINTERFACE, if lpUnknown isn't an IConnectionPointContainer, * Or an HRESULT error code if any call fails. */ -HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL bAdviseOnly, +HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL fConnect, IUnknown* lpUnknown, LPDWORD lpCookie, IConnectionPoint **lppCP) { @@ -1148,7 +1161,7 @@ HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL b IConnectionPointContainer* lpContainer; IConnectionPoint *lpCP; - if(!lpUnknown || (bAdviseOnly && !lpUnkSink)) + if(!lpUnknown || (fConnect && !lpUnkSink)) return E_FAIL; if(lppCP) @@ -1162,9 +1175,10 @@ HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL b if (SUCCEEDED(hRet)) { - if(!bAdviseOnly) + if(!fConnect) hRet = IConnectionPoint_Unadvise(lpCP, *lpCookie); - hRet = IConnectionPoint_Advise(lpCP, lpUnkSink, lpCookie); + else + hRet = IConnectionPoint_Advise(lpCP, lpUnkSink, lpCookie); if (FAILED(hRet)) *lpCookie = 0; @@ -2929,20 +2943,27 @@ static HRESULT SHLWAPI_InvokeByIID( { IEnumConnections *enumerator; CONNECTDATA rgcd; + static DISPPARAMS empty = {NULL, NULL, 0, 0}; + DISPPARAMS* params = dispParams; HRESULT result = IConnectionPoint_EnumConnections(iCP, &enumerator); if (FAILED(result)) return result; + /* Invoke is never happening with an NULL dispParams */ + if (!params) + params = ∅ + while(IEnumConnections_Next(enumerator, 1, &rgcd, NULL)==S_OK) { IDispatch *dispIface; - if (SUCCEEDED(IUnknown_QueryInterface(rgcd.pUnk, iid, (LPVOID*)&dispIface)) || + if ((iid && SUCCEEDED(IUnknown_QueryInterface(rgcd.pUnk, iid, (LPVOID*)&dispIface))) || SUCCEEDED(IUnknown_QueryInterface(rgcd.pUnk, &IID_IDispatch, (LPVOID*)&dispIface))) { - IDispatch_Invoke(dispIface, dispId, &IID_NULL, 0, DISPATCH_METHOD, dispParams, NULL, NULL, NULL); + IDispatch_Invoke(dispIface, dispId, &IID_NULL, 0, DISPATCH_METHOD, params, NULL, NULL, NULL); IDispatch_Release(dispIface); } + IUnknown_Release(rgcd.pUnk); } IEnumConnections_Release(enumerator); @@ -2965,6 +2986,8 @@ HRESULT WINAPI IConnectionPoint_InvokeWithCancel( IConnectionPoint* iCP, result = IConnectionPoint_GetConnectionInterface(iCP, &iid); if (SUCCEEDED(result)) result = SHLWAPI_InvokeByIID(iCP, &iid, dispId, dispParams); + else + result = SHLWAPI_InvokeByIID(iCP, NULL, dispId, dispParams); return result; } @@ -2988,6 +3011,8 @@ HRESULT WINAPI IConnectionPoint_SimpleInvoke( result = IConnectionPoint_GetConnectionInterface(iCP, &iid); if (SUCCEEDED(result)) result = SHLWAPI_InvokeByIID(iCP, &iid, dispId, dispParams); + else + result = SHLWAPI_InvokeByIID(iCP, NULL, dispId, dispParams); return result; } @@ -3901,6 +3926,8 @@ BOOL WINAPI IsOS(DWORD feature) case OS_APPLIANCE: FIXME("(OS_APPLIANCE) What should we return here?\n"); return FALSE; + case 0x25: /*OS_VISTAORGREATER*/ + ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 6) } #undef ISOS_RETURN @@ -4697,3 +4724,78 @@ INT WINAPI ZoneCheckUrlExW(LPWSTR szURL, PVOID pUnknown, DWORD dwUnknown2, return 0; } + +/*********************************************************************** + * SHVerbExistsNA [SHLWAPI.196] + * + * + * PARAMS + * + * verb [I] a string, often appears to be an extension. + * + * Other parameters currently unknown. + * + * RETURNS + * unknown + */ +INT WINAPI SHVerbExistsNA(LPSTR verb, PVOID pUnknown, PVOID pUnknown2, DWORD dwUnknown3) +{ + FIXME("(%s, %p, %p, %i) STUB\n",verb, pUnknown, pUnknown2, dwUnknown3); + return 0; +} + +/************************************************************************* + * @ [SHLWAPI.538] + * + * Undocumented: Implementation guessed at via Name and behavior + * + * PARAMS + * lpUnknown [I] Object to get an IServiceProvider interface from + * riid [I] Function requested for QueryService call + * lppOut [O] Destination for the service interface pointer + * + * RETURNS + * Success: S_OK. lppOut contains an object providing the requested service + * Failure: An HRESULT error code + * + * NOTES + * lpUnknown is expected to support the IServiceProvider interface. + */ +HRESULT WINAPI IUnknown_QueryServiceForWebBrowserApp(IUnknown* lpUnknown, + REFGUID riid, LPVOID *lppOut) +{ + FIXME("%p %s %p semi-STUB\n", lpUnknown, debugstr_guid(riid), lppOut); + return IUnknown_QueryService(lpUnknown,&IID_IWebBrowserApp,riid,lppOut); +} + +/************************************************************************** + * SHPropertyBag_ReadLONG (SHLWAPI.496) + * + * This function asks a property bag to read a named property as a LONG. + * + * PARAMS + * ppb: a IPropertyBag interface + * pszPropName: Unicode string that names the property + * pValue: address to receive the property value as a 32-bit signed integer + * + * RETURNS + * 0 for Success + */ +BOOL WINAPI SHPropertyBag_ReadLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LPLONG pValue) +{ + VARIANT var; + HRESULT hr; + TRACE("%p %s %p\n", ppb,debugstr_w(pszPropName),pValue); + if (!pszPropName || !ppb || !pValue) + return E_INVALIDARG; + V_VT(&var) = VT_I4; + hr = IPropertyBag_Read(ppb, pszPropName, &var, NULL); + if (SUCCEEDED(hr)) + { + if (V_VT(&var) == VT_I4) + *pValue = V_I4(&var); + else + hr = DISP_E_BADVARTYPE; + } + return hr; +} diff --git a/reactos/dll/win32/shlwapi/reg.c b/reactos/dll/win32/shlwapi/reg.c index 9f652c9df92..d641955ba05 100644 --- a/reactos/dll/win32/shlwapi/reg.c +++ b/reactos/dll/win32/shlwapi/reg.c @@ -1137,68 +1137,6 @@ DWORD WINAPI SHGetValueA(HKEY hKey, LPCSTR lpszSubKey, LPCSTR lpszValue, return dwRet; } -/************************************************************************* - * SHRegGetValueA [SHLWAPI.@] - * - * Get a value from the registry. - * - * PARAMS - * hKey [I] Handle to registry key - * lpszSubKey [I] Name of sub key containing value to get - * lpszValue [I] Name of value to get - * srrf [I] Flags for restricting returned data - * pwType [O] Pointer to the values type - * pvData [O] Pointer to the values data - * pcbData [O] Pointer to the values size - * - * RETURNS - * Success: ERROR_SUCCESS. Output parameters contain the details read. - * Failure: An error code from RegOpenKeyExA() or SHQueryValueExA(). - */ -DWORD WINAPI SHRegGetValueA(HKEY hKey, LPCSTR lpszSubKey, LPCSTR lpszValue, DWORD srrfFlags, - LPDWORD pwType, LPVOID pvData, LPDWORD pcbData) -{ - DWORD dwRet = 0; - HKEY hSubKey = 0; - - TRACE("(hkey=%p,%s,%s,%p,%p,%p)\n", hKey, debugstr_a(lpszSubKey), - debugstr_a(lpszValue), pwType, pvData, pcbData); - FIXME("Semi-Stub: Find meaning and implement handling of SRFF Flags 0x%08x\n", srrfFlags); - - dwRet = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_QUERY_VALUE, &hSubKey); - if (! dwRet) - { - /* SHQueryValueEx expands Environment strings */ - dwRet = SHQueryValueExA(hSubKey, lpszValue, 0, pwType, pvData, pcbData); - RegCloseKey(hSubKey); - } - return dwRet; -} - -/************************************************************************* - * SHReg GetRegValueW [SHLWAPI.@] - * - * See SHGetValueA. - */ -DWORD WINAPI SHRegGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD srrfFlags, - LPDWORD pwType, LPVOID pvData, LPDWORD pcbData) -{ - DWORD dwRet = 0; - HKEY hSubKey = 0; - - TRACE("(hkey=%p,%s,%s,0x%08x, %p,%p,%p)\n", hKey, debugstr_w(lpszSubKey), - debugstr_w(lpszValue), srrfFlags,pwType, pvData, pcbData); - FIXME("Semi-Stub: Find meaning and implement handling of SRFF Flags 0x%08x\n", srrfFlags); - - dwRet = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_QUERY_VALUE, &hSubKey); - if (! dwRet) - { - dwRet = SHQueryValueExW(hSubKey, lpszValue, 0, pwType, pvData, pcbData); - RegCloseKey(hSubKey); - } - return dwRet; -} - /************************************************************************* * SHGetValueW [SHLWAPI.@] * diff --git a/reactos/dll/win32/shlwapi/shlwapi.rc b/reactos/dll/win32/shlwapi/shlwapi.rc index f9e68738d4c..52b88cfa6d6 100644 --- a/reactos/dll/win32/shlwapi/shlwapi.rc +++ b/reactos/dll/win32/shlwapi/shlwapi.rc @@ -26,26 +26,29 @@ #include "version.rc" #include "shlwapi_Da.rc" -#include "shlwapi_De.rc" #include "shlwapi_En.rc" #include "shlwapi_Eo.rc" #include "shlwapi_Es.rc" #include "shlwapi_Fi.rc" -#include "shlwapi_Fr.rc" #include "shlwapi_Hu.rc" #include "shlwapi_It.rc" -#include "shlwapi_Ja.rc" #include "shlwapi_Ko.rc" -#include "shlwapi_Lt.rc" #include "shlwapi_Nl.rc" -#include "shlwapi_No.rc" #include "shlwapi_Pl.rc" #include "shlwapi_Pt.rc" -#include "shlwapi_Ro.rc" -#include "shlwapi_Ru.rc" -#include "shlwapi_Si.rc" #include "shlwapi_Sk.rc" #include "shlwapi_Sv.rc" #include "shlwapi_Tr.rc" #include "shlwapi_Uk.rc" #include "shlwapi_Zh.rc" + +/* UTF-8 */ + +#include "shlwapi_De.rc" +#include "shlwapi_Fr.rc" +#include "shlwapi_Ja.rc" +#include "shlwapi_Lt.rc" +#include "shlwapi_No.rc" +#include "shlwapi_Ro.rc" +#include "shlwapi_Ru.rc" +#include "shlwapi_Si.rc" diff --git a/reactos/dll/win32/shlwapi/shlwapi.spec b/reactos/dll/win32/shlwapi/shlwapi.spec index a8e7428c6f3..3091783f580 100644 --- a/reactos/dll/win32/shlwapi/shlwapi.spec +++ b/reactos/dll/win32/shlwapi/shlwapi.spec @@ -193,7 +193,7 @@ 193 stdcall -noname SHGetCurColorRes() 194 stdcall -noname SHWaitForSendMessageThread(ptr long) 195 stdcall -noname SHIsExpandableFolder(ptr ptr) -196 stdcall -noname DnsRecordSetCompare(ptr ptr ptr ptr) dnsapi.DnsRecordSetCompare +196 stdcall -noname SHVerbExistsNA(str ptr ptr long) 197 stdcall -noname SHFillRectClr(long ptr long) 198 stdcall -noname SHSearchMapInt(ptr ptr long long) 199 stdcall -noname IUnknown_Set(ptr ptr) @@ -460,8 +460,8 @@ 460 stdcall -noname SHExpandEnvironmentStringsW(wstr ptr long) kernel32.ExpandEnvironmentStringsW 461 stdcall -noname SHGetAppCompatFlags(long) 462 stdcall -noname UrlFixupW(wstr wstr long) -463 stub -noname SHExpandEnvironmentStringsForUserA -464 stub -noname SHExpandEnvironmentStringsForUserW +463 stdcall -noname SHExpandEnvironmentStringsForUserA(ptr str ptr long) userenv.ExpandEnvironmentStringsForUserA +464 stdcall -noname SHExpandEnvironmentStringsForUserW(ptr wstr ptr long) userenv.ExpandEnvironmentStringsForUserW 465 stub -noname PathUnExpandEnvStringsForUserA 466 stub -noname PathUnExpandEnvStringsForUserW 467 stub -noname SHRunIndirectRegClientCommand @@ -493,7 +493,7 @@ 493 stub -noname SHPropertyBag_ReadType 494 stub -noname SHPropertyBag_ReadStr 495 stub -noname SHPropertyBag_WriteStr -496 stub -noname SHPropertyBag_ReadLONG +496 stdcall -noname SHPropertyBag_ReadLONG(ptr wstr ptr) 497 stub -noname SHPropertyBag_WriteLONG 498 stub -noname SHPropertyBag_ReadBOOLOld 499 stub -noname SHPropertyBag_WriteBOOL @@ -531,7 +531,7 @@ 535 stub -noname SHPropertyBag_Delete 536 stub -noname IUnknown_QueryServicePropertyBag 537 stub -noname SHBoolSystemParametersInfo -538 stub -noname IUnknown_QueryServiceForWebBrowserApp +538 stdcall -noname IUnknown_QueryServiceForWebBrowserApp(ptr ptr ptr) 539 stub -noname IUnknown_ShowBrowserBar 540 stub -noname SHInvokeCommandOnContextMenu 541 stub -noname SHInvokeCommandsOnContextMen @@ -725,8 +725,8 @@ @ stdcall SHRegGetPathW(long wstr wstr ptr long) @ stdcall SHRegGetUSValueA ( str str ptr ptr ptr long ptr long ) @ stdcall SHRegGetUSValueW ( wstr wstr ptr ptr ptr long ptr long ) -@ stdcall SHRegGetValueA ( long str str long ptr ptr ptr ) -@ stdcall SHRegGetValueW ( long wstr wstr long ptr ptr ptr ) +@ stdcall SHRegGetValueA ( long str str long ptr ptr ptr ) advapi32.RegGetValueA +@ stdcall SHRegGetValueW ( long wstr wstr long ptr ptr ptr ) advapi32.RegGetValueW @ stdcall SHRegOpenUSKeyA ( str long long long long ) @ stdcall SHRegOpenUSKeyW ( wstr long long long long ) @ stdcall SHRegQueryInfoUSKeyA ( long ptr ptr ptr ptr long ) diff --git a/reactos/dll/win32/shlwapi/shlwapi_De.rc b/reactos/dll/win32/shlwapi/shlwapi_De.rc index f33681e1136..8980769933f 100644 --- a/reactos/dll/win32/shlwapi/shlwapi_De.rc +++ b/reactos/dll/win32/shlwapi/shlwapi_De.rc @@ -45,4 +45,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " Min" IDS_TIME_INTERVAL_SECONDS " Sek" } -#pragma code_page(default) diff --git a/reactos/dll/win32/shlwapi/shlwapi_Fr.rc b/reactos/dll/win32/shlwapi/shlwapi_Fr.rc index d32b9a898b7..745b4fd0ee0 100644 --- a/reactos/dll/win32/shlwapi/shlwapi_Fr.rc +++ b/reactos/dll/win32/shlwapi/shlwapi_Fr.rc @@ -46,4 +46,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " min" IDS_TIME_INTERVAL_SECONDS " sec" } -#pragma code_page(default) diff --git a/reactos/dll/win32/shlwapi/shlwapi_Ja.rc b/reactos/dll/win32/shlwapi/shlwapi_Ja.rc index 2c79e3215ab..4b9c6ae5255 100644 --- a/reactos/dll/win32/shlwapi/shlwapi_Ja.rc +++ b/reactos/dll/win32/shlwapi/shlwapi_Ja.rc @@ -46,4 +46,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " min" IDS_TIME_INTERVAL_SECONDS " sec" } -#pragma code_page(default) diff --git a/reactos/dll/win32/shlwapi/shlwapi_No.rc b/reactos/dll/win32/shlwapi/shlwapi_No.rc index b48106a9a51..9a99ac3feea 100644 --- a/reactos/dll/win32/shlwapi/shlwapi_No.rc +++ b/reactos/dll/win32/shlwapi/shlwapi_No.rc @@ -43,4 +43,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " min" IDS_TIME_INTERVAL_SECONDS " sec" } -#pragma code_page(default) diff --git a/reactos/dll/win32/shlwapi/shlwapi_Si.rc b/reactos/dll/win32/shlwapi/shlwapi_Si.rc index d6394dd1562..820b6ce5ed1 100644 --- a/reactos/dll/win32/shlwapi/shlwapi_Si.rc +++ b/reactos/dll/win32/shlwapi/shlwapi_Si.rc @@ -45,4 +45,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " min" IDS_TIME_INTERVAL_SECONDS " sek" } -#pragma code_page(default) diff --git a/reactos/dll/win32/shlwapi/url.c b/reactos/dll/win32/shlwapi/url.c index 2b7a8cd1686..4a93b23b5c1 100644 --- a/reactos/dll/win32/shlwapi/url.c +++ b/reactos/dll/win32/shlwapi/url.c @@ -33,6 +33,7 @@ #include "winternl.h" #define NO_SHLWAPI_STREAM #include "shlwapi.h" +#include "intshcut.h" #include "wine/debug.h" HMODULE WINAPI MLLoadLibraryW(LPCWSTR,HMODULE,DWORD); @@ -157,8 +158,8 @@ HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y) ptr++; if (*ptr != ':' || ptr <= x+1) { - y->pszProtocol = NULL; - return 0x80041001; + y->pszProtocol = NULL; + return URL_E_INVALID_SYNTAX; } y->pszProtocol = x; @@ -191,8 +192,8 @@ HRESULT WINAPI ParseURLW(LPCWSTR x, PARSEDURLW *y) ptr++; if (*ptr != ':' || ptr <= x+1) { - y->pszProtocol = NULL; - return 0x80041001; + y->pszProtocol = NULL; + return URL_E_INVALID_SYNTAX; } y->pszProtocol = x; @@ -283,6 +284,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, WCHAR slash = '/'; static const WCHAR wszFile[] = {'f','i','l','e',':'}; + static const WCHAR wszRes[] = {'r','e','s',':'}; static const WCHAR wszLocalhost[] = {'l','o','c','a','l','h','o','s','t'}; TRACE("(%s, %p, %p, 0x%08x) *pcchCanonicalized: %d\n", debugstr_w(pszUrl), pszCanonicalized, @@ -304,6 +306,11 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, && !memcmp(wszFile, pszUrl, sizeof(wszFile))) slash = '\\'; + if(nByteLen >= sizeof(wszRes) && !memcmp(wszRes, pszUrl, sizeof(wszRes))) { + dwFlags &= ~URL_FILE_USE_PATHURL; + slash = '\0'; + } + /* * state = * 0 initial 1,3 @@ -368,10 +375,12 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, wk1 += nWkLen; wk2 += nWkLen; - while(mp < wk2) { - if(*mp == '/' || *mp == '\\') - *mp = slash; - mp++; + if(slash) { + while(mp < wk2) { + if(*mp == '/' || *mp == '\\') + *mp = slash; + mp++; + } } break; case 4: @@ -380,13 +389,20 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, while(isalnumW(*wk1) || (*wk1 == '-') || (*wk1 == '.') || (*wk1 == ':')) *wk2++ = *wk1++; state = 5; - if (!*wk1) - *wk2++ = slash; + if (!*wk1) { + if(slash) + *wk2++ = slash; + else + *wk2++ = '/'; + } break; case 5: if (*wk1 != '/' && *wk1 != '\\') {state = 3; break;} while(*wk1 == '/' || *wk1 == '\\') { - *wk2++ = slash; + if(slash) + *wk2++ = slash; + else + *wk2++ = *wk1; wk1++; } state = 6; @@ -419,7 +435,10 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, wk2 += nLen; wk1 += nLen; } - *wk2++ = slash; + if(slash) + *wk2++ = slash; + else + *wk2++ = *wk1; wk1++; if (*wk1 == '.') { @@ -436,7 +455,10 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, /* case /../ -> need to backup wk2 */ TRACE("found '/../'\n"); *(wk2-1) = '\0'; /* set end of string */ - mp = strrchrW(root, slash); + mp = strrchrW(root, '/'); + mp2 = strrchrW(root, '\\'); + if(mp2 && (!mp || mp2 < mp)) + mp = mp2; if (mp && (mp >= root)) { /* found valid backup point */ wk2 = mp + 1; @@ -1379,8 +1401,7 @@ HRESULT WINAPI HashData(const unsigned char *lpSrc, DWORD nSrcLen, { INT srcCount = nSrcLen - 1, destCount = nDestLen - 1; - if (IsBadReadPtr(lpSrc, nSrcLen) || - IsBadWritePtr(lpDest, nDestLen)) + if (!lpSrc || !lpDest) return E_INVALIDARG; while (destCount >= 0) @@ -1856,7 +1877,8 @@ static LPCWSTR URL_ScanID(LPCWSTR start, LPDWORD size, WINE_URL_SCAN_TYPE type) (*start == '_') || (*start == '+') || (*start == '-') || - (*start == '.')) { + (*start == '.') || + (*start == ' ')) { start++; (*size)++; } else if (*start == '%') { @@ -1886,7 +1908,8 @@ static LPCWSTR URL_ScanID(LPCWSTR start, LPDWORD size, WINE_URL_SCAN_TYPE type) while (cont) { if (isalnumW(*start) || (*start == '-') || - (*start == '.') ) { + (*start == '.') || + (*start == ' ') ) { start++; (*size)++; } @@ -1915,7 +1938,7 @@ static LONG URL_ParseUrl(LPCWSTR pszUrl, WINE_PARSE_URL *pl) work = URL_ScanID(pl->pScheme, &pl->szScheme, SCHEME); if (!*work || (*work != ':')) goto ErrorExit; work++; - if ((*work != '/') || (*(work+1) != '/')) goto ErrorExit; + if ((*work != '/') || (*(work+1) != '/')) goto SuccessExit; pl->pUserName = work + 2; work = URL_ScanID(pl->pUserName, &pl->szUserName, USERPASS); if (*work == ':' ) { @@ -1956,6 +1979,7 @@ static LONG URL_ParseUrl(LPCWSTR pszUrl, WINE_PARSE_URL *pl) pl->pQuery = strchrW(work, '?'); if (pl->pQuery) pl->szQuery = strlenW(pl->pQuery); } + SuccessExit: TRACE("parse successful: scheme=%p(%d), user=%p(%d), pass=%p(%d), host=%p(%d), port=%p(%d), query=%p(%d)\n", pl->pScheme, pl->szScheme, pl->pUserName, pl->szUserName, @@ -2002,7 +2026,7 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut, len = INTERNET_MAX_URL_LENGTH; ret = UrlGetPartW(in, out, &len, dwPart, dwFlags); - if (ret != S_OK) { + if (FAILED(ret)) { HeapFree(GetProcessHeap(), 0, in); return ret; } @@ -2013,10 +2037,10 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut, HeapFree(GetProcessHeap(), 0, in); return E_POINTER; } - WideCharToMultiByte(0, 0, out, len+1, pszOut, *pcchOut, 0, 0); - *pcchOut = len2; + len2 = WideCharToMultiByte(0, 0, out, len+1, pszOut, *pcchOut, 0, 0); + *pcchOut = len2-1; HeapFree(GetProcessHeap(), 0, in); - return S_OK; + return ret; } /************************************************************************* @@ -2029,12 +2053,18 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, { WINE_PARSE_URL pl; HRESULT ret; - DWORD size, schsize; + DWORD scheme, size, schsize; LPCWSTR addr, schaddr; TRACE("(%s %p %p(%d) %08x %08x)\n", debugstr_w(pszIn), pszOut, pcchOut, *pcchOut, dwPart, dwFlags); + addr = strchrW(pszIn, ':'); + if(!addr) + return E_FAIL; + + scheme = get_scheme_code(pszIn, addr-pszIn); + ret = URL_ParseUrl(pszIn, &pl); if (ret == S_OK) { schaddr = pl.pScheme; @@ -2048,6 +2078,26 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, break; case URL_PART_HOSTNAME: + switch(scheme) { + case URL_SCHEME_FTP: + case URL_SCHEME_HTTP: + case URL_SCHEME_GOPHER: + case URL_SCHEME_TELNET: + case URL_SCHEME_FILE: + case URL_SCHEME_HTTPS: + break; + default: + return E_FAIL; + } + + if(scheme==URL_SCHEME_FILE && (!pl.szHostName || + (pl.szHostName==1 && *(pl.pHostName+1)==':'))) { + if(pcchOut) + *pszOut = '\0'; + *pcchOut = 0; + return S_FALSE; + } + if (!pl.szHostName) return E_INVALIDARG; addr = pl.pHostName; size = pl.szHostName; @@ -2099,7 +2149,13 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, *pcchOut = size; } TRACE("len=%d %s\n", *pcchOut, debugstr_w(pszOut)); + }else if(dwPart==URL_PART_HOSTNAME && scheme==URL_SCHEME_FILE) { + if(*pcchOut) + *pszOut = '\0'; + *pcchOut = 0; + return S_FALSE; } + return ret; } @@ -2259,7 +2315,7 @@ HRESULT WINAPI UrlCreateFromPathW(LPCWSTR pszPath, LPWSTR pszUrl, LPDWORD pcchUr */ HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags) { - FIXME("SHAutoComplete stub\n"); + FIXME("stub\n"); return S_FALSE; } @@ -2350,7 +2406,7 @@ HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags, dwResLen = strlenW(lpszRes) + 1; if (dwDestLen >= dwResLen + 1) { - lpszDest[szResLen + dwPathLen + dwResLen] = '/'; + lpszDest[szResLen + dwPathLen-1] = '/'; memcpy(lpszDest + szResLen + dwPathLen, lpszRes, dwResLen * sizeof(WCHAR)); hRet = S_OK; } @@ -2386,7 +2442,7 @@ HRESULT WINAPI UrlFixupW(LPCWSTR url, LPWSTR translatedUrl, DWORD maxChars) if (!url) return E_FAIL; - srcLen = lstrlenW(url); + srcLen = lstrlenW(url) + 1; /* For now just copy the URL directly */ lstrcpynW(translatedUrl, url, (maxChars < srcLen) ? maxChars : srcLen); From ddf5c06d6f6b4a67828a56c149e324da73f0a174 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 3 Mar 2010 16:30:56 +0000 Subject: [PATCH 054/211] Revert r45774 until I know why qemu is broken svn path=/trunk/; revision=45792 --- .../ntoskrnl/include/internal/i386/asmmacro.S | 156 +------ reactos/ntoskrnl/include/internal/trap_x.h | 379 ++++++++++++++++-- reactos/ntoskrnl/ke/i386/cpu.c | 71 +++- reactos/ntoskrnl/ke/i386/trap.s | 26 +- reactos/ntoskrnl/ke/i386/traphdlr.c | 337 +++++++--------- 5 files changed, 560 insertions(+), 409 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S index 6ddb9d015ad..d8ca99da594 100644 --- a/reactos/ntoskrnl/include/internal/i386/asmmacro.S +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -179,14 +179,6 @@ set_sane_segs: mov fs, ax endif -#if DBG - /* Keep the frame chain intact */ - mov eax, [esp + KTRAP_FRAME_EIP] - mov [esp + KTRAP_FRAME_DEBUGEIP], eax - mov [esp + KTRAP_FRAME_DEBUGEBP], ebp - mov ebp, esp -#endif - /* Set parameter 1 (ECX) to point to the frame */ mov ecx, esp @@ -195,157 +187,11 @@ set_sane_segs: ENDM -MACRO(KiCallHandler, Handler) -#if DBG - /* Use a call to get the return address for back traces */ - call Handler -#else - /* Use the faster jmp */ - jmp Handler -#endif - nop -ENDM - MACRO(TRAP_ENTRY, Trap, Flags) EXTERN @&Trap&Handler@4 :PROC PUBLIC _&Trap _&Trap: KiEnterTrap Flags - KiCallHandler @&Trap&Handler@4 -ENDM - -#define KI_RESTORE_EAX HEX(001) -#define KI_RESTORE_ECX_EDX HEX(002) -#define KI_RESTORE_FS HEX(004) -#define KI_RESTORE_SEGMENTS HEX(008) -#define KI_RESTORE_EFLAGS HEX(010) -#define KI_EXIT_SYSCALL HEX(020) -#define KI_EXIT_JMP HEX(040) -#define KI_EXIT_RET HEX(080) -#define KI_EXIT_IRET HEX(100) -#define KI_EDITED_FRAME HEX(200) -#define KI_RESTORE_VOLATILES (KI_RESTORE_EAX OR KI_RESTORE_ECX_EDX) - -MACRO(KiTrapExitStub, Name, Flags) - -PUBLIC @&Name&@4 -@&Name&@4: - - if (Flags AND KI_RESTORE_EFLAGS) - - /* We will pop EFlags off the stack */ - OffsetEsp = KTRAP_FRAME_EFLAGS - - elseif (Flags AND KI_EXIT_IRET) - - /* This is the IRET frame */ - OffsetEsp = KTRAP_FRAME_EIP - - else - - OffsetEsp = 0 - - endif - - if (Flags AND KI_EDITED_FRAME) - - /* Load the requested ESP */ - mov esp, [ecx + KTRAP_FRAME_TEMPESP] - - /* Put return address on the new stack */ - push [ecx + KTRAP_FRAME_EIP] - - /* Put EFLAGS on the new stack */ - push [ecx + KTRAP_FRAME_EFLAGS] - - else - - /* Point esp to an appropriate member of the frame */ - lea esp, [ecx + OffsetEsp] - - endif - - /* Restore non volatiles */ - mov ebx, [ecx + KTRAP_FRAME_EBX] - mov esi, [ecx + KTRAP_FRAME_ESI] - mov edi, [ecx + KTRAP_FRAME_EDI] - mov ebp, [ecx + KTRAP_FRAME_EBP] - - if (Flags AND KI_RESTORE_EAX) - - /* Restore eax */ - mov eax, [ecx + KTRAP_FRAME_EAX] - - endif - - if (Flags AND KI_RESTORE_ECX_EDX) - - /* Restore volatiles */ - mov edx, [ecx + KTRAP_FRAME_EDX] - mov ecx, [ecx + KTRAP_FRAME_ECX] - - elseif (Flags AND KI_EXIT_JMP) - - /* Load return address into edx */ - mov edx, [esp - OffsetEsp + KTRAP_FRAME_EIP] - - elseif (Flags AND KI_EXIT_SYSCALL) - - /* Set sysexit parameters */ - mov edx, [esp - OffsetEsp + KTRAP_FRAME_EIP] - mov ecx, [esp - OffsetEsp + KTRAP_FRAME_ESP] - - /* Keep interrupts disabled until the sti / sysexit */ - and byte ptr [esp - OffsetEsp + KTRAP_FRAME_EFLAGS + 1], ~(EFLAGS_INTERRUPT_MASK >> 8) - - endif - - if (Flags AND KI_RESTORE_SEGMENTS) - - /* Restore segments for user mode */ - mov ds, [esp - OffsetEsp + KTRAP_FRAME_DS] - mov es, [esp - OffsetEsp + KTRAP_FRAME_ES] - mov gs, [esp - OffsetEsp + KTRAP_FRAME_GS] - - endif - - if ((Flags AND KI_RESTORE_FS) OR (Flags AND KI_RESTORE_SEGMENTS)) - - /* Restore user mode FS */ - mov fs, [esp - OffsetEsp + KTRAP_FRAME_FS] - - endif - - if (Flags AND KI_RESTORE_EFLAGS) - - /* Restore EFLAGS */ - popf - - endif - - if (Flags AND KI_EXIT_SYSCALL) - - /* Enable interrupts and return to user mode. - Both must follow directly after another to be "atomic". */ - sti - sysexit - - elseif (Flags AND KI_EXIT_IRET) - - /* Return with iret */ - iret - - elseif (Flags AND KI_EXIT_JMP) - - /* Return to kernel mode with a jmp */ - jmp edx - - elseif (Flags AND KI_EXIT_RET) - - /* Return to kernel mode with a ret */ - ret - - endif - + jmp @&Trap&Handler@4 ENDM diff --git a/reactos/ntoskrnl/include/internal/trap_x.h b/reactos/ntoskrnl/include/internal/trap_x.h index ccc98df4a00..69ccde543f5 100644 --- a/reactos/ntoskrnl/include/internal/trap_x.h +++ b/reactos/ntoskrnl/include/internal/trap_x.h @@ -8,8 +8,6 @@ #pragma once -//#define TRAP_DEBUG 1 - // // Unreachable code hint for GCC 4.5.x, older GCC versions, and MSVC // @@ -25,17 +23,6 @@ #define UNREACHABLE #endif -// -// Helper Code -// -BOOLEAN -FORCEINLINE -KiUserTrap(IN PKTRAP_FRAME TrapFrame) -{ - /* Anything else but Ring 0 is Ring 3 */ - return (TrapFrame->SegCs & MODE_MASK); -} - // // Debug Macros // @@ -90,20 +77,19 @@ KiFillTrapFrameDebug(IN PKTRAP_FRAME TrapFrame) TrapFrame->DbgArgPointer = TrapFrame->Edx; TrapFrame->DbgArgMark = 0xBADB0D00; TrapFrame->DbgEip = TrapFrame->Eip; - TrapFrame->DbgEbp = TrapFrame->Ebp; - TrapFrame->PreviousPreviousMode = -1; + TrapFrame->DbgEbp = TrapFrame->Ebp; } VOID FORCEINLINE KiExitTrapDebugChecks(IN PKTRAP_FRAME TrapFrame, - IN KTRAP_EXIT_SKIP_BITS SkipBits) + IN KTRAP_STATE_BITS SkipBits) { /* Make sure interrupts are disabled */ if (__readeflags() & EFLAGS_INTERRUPT_MASK) { DbgPrint("Exiting with interrupts enabled: %lx\n", __readeflags()); - __debugbreak(); + while (TRUE); } /* Make sure this is a real trap frame */ @@ -111,35 +97,35 @@ KiExitTrapDebugChecks(IN PKTRAP_FRAME TrapFrame, { DbgPrint("Exiting with an invalid trap frame? (No MAGIC in trap frame)\n"); KiDumpTrapFrame(TrapFrame); - __debugbreak(); + while (TRUE); } /* Make sure we're not in user-mode or something */ if (Ke386GetFs() != KGDT_R0_PCR) { DbgPrint("Exiting with an invalid FS: %lx\n", Ke386GetFs()); - __debugbreak(); + while (TRUE); } /* Make sure we have a valid SEH chain */ if (KeGetPcr()->Tib.ExceptionList == 0) { DbgPrint("Exiting with NULL exception chain: %p\n", KeGetPcr()->Tib.ExceptionList); - __debugbreak(); + while (TRUE); } /* Make sure we're restoring a valid SEH chain */ if (TrapFrame->ExceptionList == 0) { DbgPrint("Entered a trap with a NULL exception chain: %p\n", TrapFrame->ExceptionList); - __debugbreak(); + while (TRUE); } /* If we're ignoring previous mode, make sure caller doesn't actually want it */ if ((SkipBits.SkipPreviousMode) && (TrapFrame->PreviousPreviousMode != -1)) { - DbgPrint("Exiting a trap witout restoring previous mode, yet previous mode seems valid: %lx\n", TrapFrame->PreviousPreviousMode); - __debugbreak(); + DbgPrint("Exiting a trap witout restoring previous mode, yet previous mode seems valid: %lx", TrapFrame->PreviousPreviousMode); + while (TRUE); } } @@ -151,14 +137,14 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall, KIRQL OldIrql; /* Check if this was a user call */ - if (KiUserTrap(TrapFrame)) + if (KiUserMode(TrapFrame)) { /* Make sure we are not returning with elevated IRQL */ OldIrql = KeGetCurrentIrql(); if (OldIrql != PASSIVE_LEVEL) { /* Forcibly put us in a sane state */ - KeGetPcr()->Irql = PASSIVE_LEVEL; + KeGetPcr()->CurrentIrql = PASSIVE_LEVEL; _disable(); /* Fail */ @@ -168,7 +154,7 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall, 0, 0); } -#if 0 + /* Make sure we're not attached and that APCs are not disabled */ if ((KeGetCurrentThread()->ApcStateIndex != CurrentApcEnvironment) || (KeGetCurrentThread()->CombinedApcDisable != 0)) @@ -180,7 +166,6 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall, KeGetCurrentThread()->CombinedApcDisable, 0); } -#endif } } #else @@ -189,20 +174,334 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall, #define KiExitSystemCallDebugChecks(x, y) #endif +// +// Helper Code +// +BOOLEAN +FORCEINLINE +KiUserTrap(IN PKTRAP_FRAME TrapFrame) +{ + /* Anything else but Ring 0 is Ring 3 */ + return (TrapFrame->SegCs & MODE_MASK); +} + +// +// "BOP" code used by VDM and V8086 Mode +// +VOID +FORCEINLINE +KiIssueBop(VOID) +{ + /* Invalid instruction that an invalid opcode handler must trap and handle */ + asm volatile(".byte 0xC4\n.byte 0xC4\n"); +} + +VOID +FORCEINLINE +KiUserSystemCall(IN PKTRAP_FRAME TrapFrame) +{ + /* + * Kernel call or user call? + * + * This decision is made in inlined assembly because we need to patch + * the relative offset of the user-mode jump to point to the SYSEXIT + * routine if the CPU supports it. The only way to guarantee that a + * relative jnz/jz instruction is generated is to force it with the + * inline assembler. + */ + asm volatile + ( + "test $1, %0\n" /* MODE_MASK */ + ".globl _KiSystemCallExitBranch\n_KiSystemCallExitBranch:\n" + "jnz _KiSystemCallExit\n" + : + : "r"(TrapFrame->SegCs) + ); +} + +// +// Generates an Exit Epilog Stub for the given name +// +#define KI_FUNCTION_CALL 0x1 +#define KI_EDITED_FRAME 0x2 +#define KI_DIRECT_EXIT 0x4 +#define KI_FAST_SYSTEM_CALL_EXIT 0x8 +#define KI_SYSTEM_CALL_EXIT 0x10 +#define KI_SYSTEM_CALL_JUMP 0x20 +#define KiTrapExitStub(x, y) VOID FORCEINLINE DECLSPEC_NORETURN x(IN PKTRAP_FRAME TrapFrame) { KiTrapExit(TrapFrame, y); UNREACHABLE; } +#define KiTrapExitStub2(x, y) VOID FORCEINLINE x(IN PKTRAP_FRAME TrapFrame) { KiTrapExit(TrapFrame, y); } + +// +// How volatiles will be restored +// +#define KI_EAX_NO_VOLATILES 0x0 +#define KI_EAX_ONLY 0x1 +#define KI_ALL_VOLATILES 0x2 + +// +// Exit mechanism to use +// +#define KI_EXIT_IRET 0x0 +#define KI_EXIT_SYSEXIT 0x1 +#define KI_EXIT_JMP 0x2 +#define KI_EXIT_RET 0x3 + +// +// Master Trap Epilog +// +VOID +FORCEINLINE +KiTrapExit(IN PKTRAP_FRAME TrapFrame, + IN ULONG Flags) +{ + ULONG FrameSize = FIELD_OFFSET(KTRAP_FRAME, Eip); + ULONG ExitMechanism = KI_EXIT_IRET, Volatiles = KI_ALL_VOLATILES, NonVolatiles = TRUE; + ULONG EcxField = FIELD_OFFSET(KTRAP_FRAME, Ecx), EdxField = FIELD_OFFSET(KTRAP_FRAME, Edx); + + /* System call exit needs a special label */ + if (Flags & KI_SYSTEM_CALL_EXIT) __asm__ __volatile__ + ( + ".globl _KiSystemCallExit\n_KiSystemCallExit:\n" + ); + + /* Start by making the trap frame equal to the stack */ + __asm__ __volatile__ + ( + "movl %0, %%esp\n" + : + : "r"(TrapFrame) + : "%esp" + ); + + /* Check what kind of trap frame this trap requires */ + if (Flags & KI_FUNCTION_CALL) + { + /* These calls have an EIP on the stack they need */ + ExitMechanism = KI_EXIT_RET; + Volatiles = FALSE; + } + else if (Flags & KI_EDITED_FRAME) + { + /* Edited frames store a new ESP in the error code field */ + FrameSize = FIELD_OFFSET(KTRAP_FRAME, ErrCode); + } + else if (Flags & KI_DIRECT_EXIT) + { + /* Exits directly without restoring anything, interrupt frame on stack */ + NonVolatiles = Volatiles = FALSE; + } + else if (Flags & KI_FAST_SYSTEM_CALL_EXIT) + { + /* We have a fake interrupt stack with a ring transition */ + FrameSize = FIELD_OFFSET(KTRAP_FRAME, V86Es); + ExitMechanism = KI_EXIT_SYSEXIT; + + /* SYSEXIT wants EIP in EDX and ESP in ECX */ + EcxField = FIELD_OFFSET(KTRAP_FRAME, HardwareEsp); + EdxField = FIELD_OFFSET(KTRAP_FRAME, Eip); + } + else if (Flags & KI_SYSTEM_CALL_EXIT) + { + /* Only restore EAX */ + NonVolatiles = KI_EAX_ONLY; + } + else if (Flags & KI_SYSTEM_CALL_JUMP) + { + /* We have a fake interrupt stack with no ring transition */ + FrameSize = FIELD_OFFSET(KTRAP_FRAME, HardwareEsp); + NonVolatiles = KI_EAX_ONLY; + ExitMechanism = KI_EXIT_JMP; + } + + /* Restore the non volatiles */ + if (NonVolatiles) __asm__ __volatile__ + ( + "movl %c[b](%%esp), %%ebx\n" + "movl %c[s](%%esp), %%esi\n" + "movl %c[i](%%esp), %%edi\n" + "movl %c[p](%%esp), %%ebp\n" + : + : [b] "i"(FIELD_OFFSET(KTRAP_FRAME, Ebx)), + [s] "i"(FIELD_OFFSET(KTRAP_FRAME, Esi)), + [i] "i"(FIELD_OFFSET(KTRAP_FRAME, Edi)), + [p] "i"(FIELD_OFFSET(KTRAP_FRAME, Ebp)) + : "%esp" + ); + + /* Restore EAX if volatiles must be restored */ + if (Volatiles) __asm__ __volatile__ + ( + "movl %c[a](%%esp), %%eax\n":: [a] "i"(FIELD_OFFSET(KTRAP_FRAME, Eax)) : "%esp" + ); + + /* Restore the other volatiles if needed */ + if (Volatiles == KI_ALL_VOLATILES) __asm__ __volatile__ + ( + "movl %c[c](%%esp), %%ecx\n" + "movl %c[d](%%esp), %%edx\n" + : + : [c] "i"(EcxField), + [d] "i"(EdxField) + : "%esp" + ); + + /* Ring 0 system calls jump back to EDX */ + if (Flags & KI_SYSTEM_CALL_JUMP) __asm__ __volatile__ + ( + "movl %c[d](%%esp), %%edx\n":: [d] "i"(FIELD_OFFSET(KTRAP_FRAME, Eip)) : "%esp" + ); + + /* Now destroy the trap frame on the stack */ + __asm__ __volatile__ ("addl $%c[e],%%esp\n":: [e] "i"(FrameSize) : "%esp"); + + /* Edited traps need to change to a new ESP */ + if (Flags & KI_EDITED_FRAME) __asm__ __volatile__ ("movl (%%esp), %%esp\n":::"%esp"); + + /* Check the exit mechanism and apply it */ + if (ExitMechanism == KI_EXIT_RET) __asm__ __volatile__("ret\n"::: "%esp"); + else if (ExitMechanism == KI_EXIT_IRET) __asm__ __volatile__("iret\n"::: "%esp"); + else if (ExitMechanism == KI_EXIT_JMP) __asm__ __volatile__("jmp *%%edx\n.globl _KiSystemCallExit2\n_KiSystemCallExit2:\n"::: "%esp"); + else if (ExitMechanism == KI_EXIT_SYSEXIT) __asm__ __volatile__("sti\nsysexit\n"::: "%esp"); +} + +// +// All the specific trap epilog stubs +// +KiTrapExitStub (KiTrapReturn, 0); +KiTrapExitStub (KiDirectTrapReturn, KI_DIRECT_EXIT); +KiTrapExitStub (KiCallReturn, KI_FUNCTION_CALL); +KiTrapExitStub (KiEditedTrapReturn, KI_EDITED_FRAME); +KiTrapExitStub2(KiSystemCallReturn, KI_SYSTEM_CALL_JUMP); +KiTrapExitStub (KiSystemCallSysExitReturn, KI_FAST_SYSTEM_CALL_EXIT); +KiTrapExitStub (KiSystemCallTrapReturn, KI_SYSTEM_CALL_EXIT); + // // Generic Exit Routine // -VOID FASTCALL DECLSPEC_NORETURN KiSystemCallReturn(IN PKTRAP_FRAME TrapFrame); -VOID FASTCALL DECLSPEC_NORETURN KiSystemCallSysExitReturn(IN PKTRAP_FRAME TrapFrame); -VOID FASTCALL DECLSPEC_NORETURN KiSystemCallTrapReturn(IN PKTRAP_FRAME TrapFrame); -VOID FASTCALL DECLSPEC_NORETURN KiEditedTrapReturn(IN PKTRAP_FRAME TrapFrame); -VOID FASTCALL DECLSPEC_NORETURN KiTrapReturn(IN PKTRAP_FRAME TrapFrame); -VOID FASTCALL DECLSPEC_NORETURN KiTrapReturnNoSegments(IN PKTRAP_FRAME TrapFrame); - -typedef VOID -(FASTCALL -*FAST_SYSTEM_CALL_EXIT)(IN PKTRAP_FRAME TrapFrame) DECLSPEC_NORETURN; +FORCEINLINE +DECLSPEC_NORETURN +KiExitTrap(IN PKTRAP_FRAME TrapFrame, + IN UCHAR Skip) +{ + KTRAP_EXIT_SKIP_BITS SkipBits = { .Bits = Skip }; + PULONG ReturnStack; + + /* Debugging checks */ + KiExitTrapDebugChecks(TrapFrame, SkipBits); + + /* Restore the SEH handler chain */ + KeGetPcr()->Tib.ExceptionList = TrapFrame->ExceptionList; + + /* Check if the previous mode must be restored */ + if (__builtin_expect(!SkipBits.SkipPreviousMode, 0)) /* More INTS than SYSCALLs */ + { + /* Restore it */ + KeGetCurrentThread()->PreviousMode = TrapFrame->PreviousPreviousMode; + } + + /* Check if there are active debug registers */ + if (__builtin_expect(TrapFrame->Dr7 & ~DR7_RESERVED_MASK, 0)) + { + /* Not handled yet */ + DbgPrint("Need Hardware Breakpoint Support!\n"); + DbgBreakPoint(); + while (TRUE); + } + + /* Check if this was a V8086 trap */ + if (__builtin_expect(TrapFrame->EFlags & EFLAGS_V86_MASK, 0)) KiTrapReturn(TrapFrame); + + /* Check if the trap frame was edited */ + if (__builtin_expect(!(TrapFrame->SegCs & FRAME_EDITED), 0)) + { + /* + * An edited trap frame happens when we need to modify CS and/or ESP but + * don't actually have a ring transition. This happens when a kernelmode + * caller wants to perform an NtContinue to another kernel address, such + * as in the case of SEH (basically, a longjmp), or to a user address. + * + * Therefore, the CPU never saved CS/ESP on the stack because we did not + * get a trap frame due to a ring transition (there was no interrupt). + * Even if we didn't want to restore CS to a new value, a problem occurs + * due to the fact a normal RET would not work if we restored ESP since + * RET would then try to read the result off the stack. + * + * The NT kernel solves this by adding 12 bytes of stack to the exiting + * trap frame, in which EFLAGS, CS, and EIP are stored, and then saving + * the ESP that's being requested into the ErrorCode field. It will then + * exit with an IRET. This fixes both issues, because it gives the stack + * some space where to hold the return address and then end up with the + * wanted stack, and it uses IRET which allows a new CS to be inputted. + * + */ + + /* Set CS that is requested */ + TrapFrame->SegCs = TrapFrame->TempSegCs; + + /* First make space on requested stack */ + ReturnStack = (PULONG)(TrapFrame->TempEsp - 12); + TrapFrame->ErrCode = (ULONG_PTR)ReturnStack; + + /* Now copy IRET frame */ + ReturnStack[0] = TrapFrame->Eip; + ReturnStack[1] = TrapFrame->SegCs; + ReturnStack[2] = TrapFrame->EFlags; + + /* Do special edited return */ + KiEditedTrapReturn(TrapFrame); + } + + /* Check if this is a user trap */ + if (__builtin_expect(KiUserTrap(TrapFrame), 1)) /* Ring 3 is where we spend time */ + { + /* Check if segments should be restored */ + if (!SkipBits.SkipSegments) + { + /* Restore segments */ + Ke386SetGs(TrapFrame->SegGs); + Ke386SetEs(TrapFrame->SegEs); + Ke386SetDs(TrapFrame->SegDs); + Ke386SetFs(TrapFrame->SegFs); + } + + /* Always restore FS since it goes from KPCR to TEB */ + Ke386SetFs(TrapFrame->SegFs); + } + + /* Check for system call -- a system call skips volatiles! */ + if (__builtin_expect(SkipBits.SkipVolatiles, 0)) /* More INTs than SYSCALLs */ + { + /* User or kernel call? */ + KiUserSystemCall(TrapFrame); + + /* Restore EFLags */ + __writeeflags(TrapFrame->EFlags); + + /* Call is kernel, so do a jump back since this wasn't a real INT */ + KiSystemCallReturn(TrapFrame); + + /* If we got here, this is SYSEXIT: are we stepping code? */ + if (!(TrapFrame->EFlags & EFLAGS_TF)) + { + /* Restore user FS */ + Ke386SetFs(KGDT_R3_TEB | RPL_MASK); + + /* Remove interrupt flag */ + TrapFrame->EFlags &= ~EFLAGS_INTERRUPT_MASK; + __writeeflags(TrapFrame->EFlags); + + /* Exit through SYSEXIT */ + KiSystemCallSysExitReturn(TrapFrame); + } + + /* Exit through IRETD, either due to debugging or due to lack of SYSEXIT */ + KiSystemCallTrapReturn(TrapFrame); + } + + /* Return from interrupt */ + KiTrapReturn(TrapFrame); +} // // Virtual 8086 Mode Optimized Trap Exit @@ -218,9 +517,6 @@ KiExitV86Trap(IN PKTRAP_FRAME TrapFrame) Thread = KeGetCurrentThread(); while (TRUE) { - /* Return if this isn't V86 mode anymore */ - if (!(TrapFrame->EFlags & EFLAGS_V86_MASK)) KiEoiHelper(TrapFrame);; - /* Turn off the alerted state for kernel mode */ Thread->Alerted[KernelMode] = FALSE; @@ -237,6 +533,9 @@ KiExitV86Trap(IN PKTRAP_FRAME TrapFrame) /* Restore IRQL and disable interrupts once again */ KfLowerIrql(OldIrql); _disable(); + + /* Return if this isn't V86 mode anymore */ + if (__builtin_expect(TrapFrame->EFlags & EFLAGS_V86_MASK, 0)) return; } /* If we got here, we're still in a valid V8086 context, so quit it */ diff --git a/reactos/ntoskrnl/ke/i386/cpu.c b/reactos/ntoskrnl/ke/i386/cpu.c index ad8e21eaa43..21d49c90123 100644 --- a/reactos/ntoskrnl/ke/i386/cpu.c +++ b/reactos/ntoskrnl/ke/i386/cpu.c @@ -995,8 +995,55 @@ KiLoadFastSyscallMachineSpecificRegisters(IN ULONG_PTR Context) return 0; } -VOID FASTCALL DECLSPEC_NORETURN KiSystemCallSysExitReturn(IN PKTRAP_FRAME TrapFrame); -extern PVOID KiFastCallExitHandler; +VOID +NTAPI +KiDisableFastSyscallReturn(VOID) +{ + /* Was it applied? */ + if (KiSystemCallExitAdjusted) + { + /* Restore the original value */ + KiSystemCallExitBranch[1] = KiSystemCallExitBranch[1] - KiSystemCallExitAdjusted; + + /* It's not adjusted anymore */ + KiSystemCallExitAdjusted = FALSE; + } +} + +VOID +NTAPI +KiEnableFastSyscallReturn(VOID) +{ + /* Check if the patch has already been done */ + if ((KiSystemCallExitAdjusted == KiSystemCallExitAdjust) && + (KiFastCallCopyDoneOnce)) + { + return; + } + + /* Make sure the offset is within the distance of a Jxx SHORT */ + if ((KiSystemCallExitBranch[1] - KiSystemCallExitAdjust) < 0x80) + { + /* Remove any existing code patch */ + KiDisableFastSyscallReturn(); + + /* We should have a JNZ there */ + ASSERT(KiSystemCallExitBranch[0] == 0x75); + + /* Do the patch */ + KiSystemCallExitAdjusted = KiSystemCallExitAdjust; + KiSystemCallExitBranch[1] -= KiSystemCallExitAdjusted; + + /* Remember that we've done it */ + KiFastCallCopyDoneOnce = TRUE; + } + else + { + /* This shouldn't happen unless we've messed the macros up */ + DPRINT1("Your compiled kernel is broken!\n"); + DbgBreakPoint(); + } +} VOID NTAPI @@ -1008,11 +1055,11 @@ KiRestoreFastSyscallReturnState(VOID) /* Check if it has been disabled */ if (!KiFastSystemCallDisable) { - /* Do an IPI to enable it */ - KeIpiGenericCall(KiLoadFastSyscallMachineSpecificRegisters, 0); - - /* It's enabled, so use the proper exit stub */ - KiFastCallExitHandler = KiSystemCallSysExitReturn; + /* KiSystemCallExit2 should come BEFORE KiSystemCallExit */ + ASSERT(KiSystemCallExit2 < KiSystemCallExit); + + /* It's enabled, so we'll have to do a code patch */ + KiSystemCallExitAdjust = KiSystemCallExit - KiSystemCallExit2; } else { @@ -1020,6 +1067,16 @@ KiRestoreFastSyscallReturnState(VOID) KeFeatureBits &= ~KF_FAST_SYSCALL; } } + + /* Now check if all CPUs support fast system call, and the registry allows it */ + if (KeFeatureBits & KF_FAST_SYSCALL) + { + /* Do an IPI to enable it */ + KeIpiGenericCall(KiLoadFastSyscallMachineSpecificRegisters, 0); + } + + /* Perform the code patch that is required */ + KiEnableFastSyscallReturn(); } ULONG_PTR diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index df7bc6ac55f..5f24877eeac 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -120,18 +120,17 @@ _KiInterruptTemplateObject: PUBLIC _KiInterruptTemplateDispatch _KiInterruptTemplateDispatch: -EXTERN @KiFastCallEntryHandler@8:PROC -PUBLIC _KiFastCallEntry -_KiFastCallEntry: - KiEnterTrap (KI_FAST_SYSTEM_CALL OR KI_NONVOLATILES_ONLY OR KI_DONT_SAVE_SEGS) - KiCallHandler @KiFastCallEntryHandler@8 - - EXTERN @KiSystemServiceHandler@8:PROC PUBLIC _KiSystemService _KiSystemService: KiEnterTrap (KI_PUSH_FAKE_ERROR_CODE OR KI_NONVOLATILES_ONLY OR KI_DONT_SAVE_SEGS) - KiCallHandler @KiSystemServiceHandler@8 + jmp @KiSystemServiceHandler@8 + +EXTERN @KiFastCallEntryHandler@8:PROC +PUBLIC _KiFastCallEntry +_KiFastCallEntry: + KiEnterTrap (KI_FAST_SYSTEM_CALL OR KI_NONVOLATILES_ONLY OR KI_DONT_SAVE_SEGS) + jmp @KiFastCallEntryHandler@8 PUBLIC _KiStartUnexpectedRange@0 _KiStartUnexpectedRange@0: @@ -144,15 +143,4 @@ PUBLIC _KiEndUnexpectedRange@0 _KiEndUnexpectedRange@0: jmp _KiUnexpectedInterruptTail - -/* EXIT CODE *****************************************************************/ - -KiTrapExitStub KiSystemCallReturn, (KI_RESTORE_EAX OR KI_RESTORE_EFLAGS OR KI_EXIT_JMP) -KiTrapExitStub KiSystemCallSysExitReturn, (KI_RESTORE_EAX OR KI_RESTORE_FS OR KI_RESTORE_EFLAGS OR KI_EXIT_SYSCALL) -KiTrapExitStub KiSystemCallTrapReturn, (KI_RESTORE_EAX OR KI_RESTORE_FS OR KI_EXIT_IRET) - -KiTrapExitStub KiEditedTrapReturn, (KI_RESTORE_VOLATILES OR KI_RESTORE_EFLAGS OR KI_EDITED_FRAME OR KI_EXIT_RET) -KiTrapExitStub KiTrapReturn, (KI_RESTORE_VOLATILES OR KI_RESTORE_SEGMENTS OR KI_EXIT_IRET) -KiTrapExitStub KiTrapReturnNoSegments, (KI_RESTORE_VOLATILES OR KI_EXIT_IRET) - END diff --git a/reactos/ntoskrnl/ke/i386/traphdlr.c b/reactos/ntoskrnl/ke/i386/traphdlr.c index 44b15c35d78..6c777643bd6 100644 --- a/reactos/ntoskrnl/ke/i386/traphdlr.c +++ b/reactos/ntoskrnl/ke/i386/traphdlr.c @@ -45,8 +45,6 @@ UCHAR KiTrapIoTable[] = 0x6F, /* OUTS */ }; -FAST_SYSTEM_CALL_EXIT KiFastCallExitHandler = KiSystemCallTrapReturn; - BOOLEAN FORCEINLINE KiVdmTrap(IN PKTRAP_FRAME TrapFrame) @@ -64,62 +62,21 @@ KiV86Trap(IN PKTRAP_FRAME TrapFrame) return ((TrapFrame->EFlags & EFLAGS_V86_MASK) != 0); } -BOOLEAN -FORCEINLINE -KeIsFrameEdited(IN PKTRAP_FRAME TrapFrame) -{ - /* An edited frame changes esp. It is marked by clearing the bits - defined by FRAME_EDITED in the SegCs field of the trap frame */ - return ((TrapFrame->SegCs & FRAME_EDITED) == 0); -} - /* TRAP EXIT CODE *************************************************************/ -VOID -FORCEINLINE -KiCommonExit(IN PKTRAP_FRAME TrapFrame, const ULONG Flags) -{ - /* Disable interrupts until we return */ - _disable(); - - /* Check for APC delivery */ - KiCheckForApcDelivery(TrapFrame); - - /* Debugging checks */ - KiExitTrapDebugChecks(TrapFrame, Flags); - - /* Restore the SEH handler chain */ - KeGetPcr()->Tib.ExceptionList = TrapFrame->ExceptionList; - - /* Check if there are active debug registers */ - if (__builtin_expect(TrapFrame->Dr7 & ~DR7_RESERVED_MASK, 0)) - { - /* Not handled yet */ - DbgPrint("Need Hardware Breakpoint Support!\n"); - DbgBreakPoint(); - while (TRUE); - } -} - VOID FASTCALL DECLSPEC_NORETURN KiEoiHelper(IN PKTRAP_FRAME TrapFrame) { - /* Common trap exit code */ - KiCommonExit(TrapFrame, 0); - - /* Check if this was a V8086 trap */ - if (TrapFrame->EFlags & EFLAGS_V86_MASK) KiTrapReturnNoSegments(TrapFrame); - - /* Check for user mode exit */ - if (TrapFrame->SegCs & MODE_MASK) KiTrapReturn(TrapFrame); - - /* Check for edited frame */ - if (KeIsFrameEdited(TrapFrame)) KiEditedTrapReturn(TrapFrame); - - /* Exit the trap to kernel mode */ - KiTrapReturnNoSegments(TrapFrame); + /* Disable interrupts until we return */ + _disable(); + + /* Check for APC delivery */ + KiCheckForApcDelivery(TrapFrame); + + /* Now exit the trap for real */ + KiExitTrap(TrapFrame, KTE_SKIP_PM_BIT); } VOID @@ -128,36 +85,17 @@ DECLSPEC_NORETURN KiServiceExit(IN PKTRAP_FRAME TrapFrame, IN NTSTATUS Status) { - ASSERT((TrapFrame->EFlags & EFLAGS_V86_MASK) == 0); - ASSERT(!KeIsFrameEdited(TrapFrame)); - + /* Disable interrupts until we return */ + _disable(); + + /* Check for APC delivery */ + KiCheckForApcDelivery(TrapFrame); + /* Copy the status into EAX */ TrapFrame->Eax = Status; - - /* Common trap exit code */ - KiCommonExit(TrapFrame, 0); - /* Restore previous mode */ - KeGetCurrentThread()->PreviousMode = TrapFrame->PreviousPreviousMode; - - /* Check for user mode exit */ - if (TrapFrame->SegCs & MODE_MASK) - { - /* Check if we were single stepping */ - if (TrapFrame->EFlags & EFLAGS_TF) - { - /* Must use the IRET handler */ - KiSystemCallTrapReturn(TrapFrame); - } - else - { - /* We can use the sysexit handler */ - KiFastCallExitHandler(TrapFrame); - } - } - - /* Exit to kernel mode */ - KiSystemCallReturn(TrapFrame); + /* Now exit the trap for real */ + KiExitTrap(TrapFrame, KTE_SKIP_SEG_BIT | KTE_SKIP_VOL_BIT); } VOID @@ -165,23 +103,14 @@ FASTCALL DECLSPEC_NORETURN KiServiceExit2(IN PKTRAP_FRAME TrapFrame) { - /* Common trap exit code */ - KiCommonExit(TrapFrame, 0); - - /* Restore previous mode */ - KeGetCurrentThread()->PreviousMode = TrapFrame->PreviousPreviousMode; - - /* Check if this was a V8086 trap */ - if (TrapFrame->EFlags & EFLAGS_V86_MASK) KiTrapReturnNoSegments(TrapFrame); - - /* Check for user mode exit */ - if (TrapFrame->SegCs & MODE_MASK) KiTrapReturn(TrapFrame); - - /* Check for edited frame */ - if (KeIsFrameEdited(TrapFrame)) KiEditedTrapReturn(TrapFrame); - - /* Exit the trap to kernel mode */ - KiTrapReturnNoSegments(TrapFrame); + /* Disable interrupts until we return */ + _disable(); + + /* Check for APC delivery */ + KiCheckForApcDelivery(TrapFrame); + + /* Now exit the trap for real */ + KiExitTrap(TrapFrame, 0); } /* TRAP HANDLERS **************************************************************/ @@ -653,7 +582,10 @@ KiTrap06Handler(IN PKTRAP_FRAME TrapFrame) _disable(); /* Do a quick V86 exit if possible */ - KiExitV86Trap(TrapFrame); + if (__builtin_expect(TrapFrame->EFlags & EFLAGS_V86_MASK, 1)) KiExitV86Trap(TrapFrame); + + /* Exit trap the slow way */ + KiEoiHelper(TrapFrame); } /* Save trap frame */ @@ -910,7 +842,10 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) _disable(); /* Do a quick V86 exit if possible */ - KiExitV86Trap(TrapFrame); + if (__builtin_expect(TrapFrame->EFlags & EFLAGS_V86_MASK, 1)) KiExitV86Trap(TrapFrame); + + /* Exit trap the slow way */ + KiEoiHelper(TrapFrame); } /* Save trap frame */ @@ -974,7 +909,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) (((Instructions[i + 2] & 0x38) == 0x10) || // LLDT (Instructions[i + 2] == 0x18))) || // LTR ((Instructions[i + 1] == 0x01) && // LGDT or LIDT or LMSW - (((Instructions[i + 2] & 0x38) == 0x10) || // LGDT + (((Instructions[i + 2] & 0x38) == 0x10) || // LLGT (Instructions[i + 2] == 0x18) || // LIDT (Instructions[i + 2] == 0x30))) || // LMSW (Instructions[i + 1] == 0x08) || // INVD @@ -986,7 +921,6 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) (Instructions[i + 1] == 0x24) || // MOV YYY, DR (Instructions[i + 1] == 0x30) || // WRMSR (Instructions[i + 1] == 0x33)) // RDPMC - // INVLPG, INVLPGA, SYSRET { /* These are all privileged */ Privileged = TRUE; @@ -1059,7 +993,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) * a POP , which could cause an invalid segment if someone had messed * with the segment values. * - * Another case is a bogus SS, which would hit a GPF when doing the iret. + * Another case is a bogus SS, which would hit a GPF when doing the ired. * This could only be done through a buggy or malicious driver, or perhaps * the kernel debugger. * @@ -1133,14 +1067,9 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame) /* Fix it */ TrapFrame->SegEs = (KGDT_R3_DATA | RPL_MASK); } - else - { - /* Whatever it is, we can't handle it */ - KiSystemFatalException(EXCEPTION_GP_FAULT, TrapFrame); - } - - /* Return to where we came from */ - KiTrapReturn(TrapFrame); + + /* Do a direct trap exit: restore volatiles only */ + KiExitTrap(TrapFrame, KTE_SKIP_PM_BIT | KTE_SKIP_SEG_BIT); } VOID @@ -1247,7 +1176,7 @@ KiTrap0EHandler(IN PKTRAP_FRAME TrapFrame) Cr2, TrapFrame); } - + /* Only other choice is an in-page error, with 3 parameters */ KiDispatchExceptionFromTrapFrame(STATUS_IN_PAGE_ERROR, TrapFrame->Eip, @@ -1448,89 +1377,55 @@ KiDebugServiceHandler(IN PKTRAP_FRAME TrapFrame) } VOID -FORCEINLINE +FASTCALL DECLSPEC_NORETURN -KiSystemCall(IN PKTRAP_FRAME TrapFrame, - IN PVOID Arguments) +KiSystemCall(IN ULONG SystemCallNumber, + IN PVOID Arguments) { PKTHREAD Thread; + PKTRAP_FRAME TrapFrame; PKSERVICE_TABLE_DESCRIPTOR DescriptorTable; ULONG Id, Offset, StackBytes, Result; PVOID Handler; - ULONG SystemCallNumber = TrapFrame->Eax; - - /* Get the current thread */ - Thread = KeGetCurrentThread(); - - /* Set debug header */ - KiFillTrapFrameDebug(TrapFrame); - - /* Chain trap frames */ - TrapFrame->Edx = (ULONG_PTR)Thread->TrapFrame; - - /* No error code */ - TrapFrame->ErrCode = 0; - - /* Save previous mode */ - TrapFrame->PreviousPreviousMode = Thread->PreviousMode; - - /* Save the SEH chain and terminate it for now */ - TrapFrame->ExceptionList = KeGetPcr()->Tib.ExceptionList; - KeGetPcr()->Tib.ExceptionList = EXCEPTION_CHAIN_END; - - /* Clear DR7 and check for debugging */ - TrapFrame->Dr7 = 0; - if (__builtin_expect(Thread->DispatcherHeader.DebugActive & 0xFF, 0)) + + /* Loop because we might need to try this twice in case of a GUI call */ + while (TRUE) { - UNIMPLEMENTED; - while (TRUE); - } + /* Decode the system call number */ + Offset = (SystemCallNumber >> SERVICE_TABLE_SHIFT) & SERVICE_TABLE_MASK; + Id = SystemCallNumber & SERVICE_NUMBER_MASK; + + /* Get current thread, trap frame, and descriptor table */ + Thread = KeGetCurrentThread(); + TrapFrame = Thread->TrapFrame; + DescriptorTable = (PVOID)((ULONG_PTR)Thread->ServiceTable + Offset); - /* Set thread fields */ - Thread->TrapFrame = TrapFrame; - Thread->PreviousMode = KiUserTrap(TrapFrame); - - /* Enable interrupts */ - _enable(); - - /* Decode the system call number */ - Offset = (SystemCallNumber >> SERVICE_TABLE_SHIFT) & SERVICE_TABLE_MASK; - Id = SystemCallNumber & SERVICE_NUMBER_MASK; - - /* Get descriptor table */ - DescriptorTable = (PVOID)((ULONG_PTR)Thread->ServiceTable + Offset); - - /* Validate the system call number */ - if (__builtin_expect(Id >= DescriptorTable->Limit, 0)) - { - /* Check if this is a GUI call */ - if (!(Offset & SERVICE_TABLE_TEST)) + /* Validate the system call number */ + if (__builtin_expect(Id >= DescriptorTable->Limit, 0)) { - /* Fail the call */ - Result = STATUS_INVALID_SYSTEM_SERVICE; - goto ExitCall; - } + /* Check if this is a GUI call */ + if (__builtin_expect(!(Offset & SERVICE_TABLE_TEST), 0)) + { + /* Fail the call */ + Result = STATUS_INVALID_SYSTEM_SERVICE; + goto ExitCall; + } - /* Convert us to a GUI thread -- must wrap in ASM to get new EBP */ - Result = KiConvertToGuiThread(); - if (!NT_SUCCESS(Result)) - { - /* Set the last error and fail */ - //SetLastWin32Error(RtlNtStatusToDosError(Result)); - goto ExitCall; + /* Convert us to a GUI thread -- must wrap in ASM to get new EBP */ + Result = KiConvertToGuiThread(); + if (__builtin_expect(!NT_SUCCESS(Result), 0)) + { + /* Figure out how we should fail to the user */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Try the call again */ + continue; } - /* Reload trap frame and descriptor table pointer from new stack */ - TrapFrame = *(volatile PVOID*)&Thread->TrapFrame; - DescriptorTable = (PVOID)(*(volatile ULONG_PTR*)&Thread->ServiceTable + Offset); - - /* Validate the system call number again */ - if (Id >= DescriptorTable->Limit) - { - /* Fail the call */ - Result = STATUS_INVALID_SYSTEM_SERVICE; - goto ExitCall; - } + /* If we made it here, the call is good */ + break; } /* Check if this is a GUI call */ @@ -1573,13 +1468,45 @@ ExitCall: } VOID -FASTCALL +FORCEINLINE DECLSPEC_NORETURN -KiSystemServiceHandler(IN PKTRAP_FRAME TrapFrame, - IN PVOID Arguments) +KiSystemCallHandler(IN PKTRAP_FRAME TrapFrame, + IN ULONG ServiceNumber, + IN PVOID Arguments, + IN PKTHREAD Thread, + IN KPROCESSOR_MODE PreviousMode, + IN KPROCESSOR_MODE PreviousPreviousMode, + IN USHORT SegFs) { - /* Call the shared handler (inline) */ - KiSystemCall(TrapFrame, Arguments); + /* No error code */ + TrapFrame->ErrCode = 0; + + /* Save previous mode and FS segment */ + TrapFrame->PreviousPreviousMode = PreviousPreviousMode; + TrapFrame->SegFs = SegFs; + + /* Save the SEH chain and terminate it for now */ + TrapFrame->ExceptionList = KeGetPcr()->Tib.ExceptionList; + KeGetPcr()->Tib.ExceptionList = EXCEPTION_CHAIN_END; + + /* Clear DR7 and check for debugging */ + TrapFrame->Dr7 = 0; + if (__builtin_expect(Thread->DispatcherHeader.DebugActive & 0xFF, 0)) + { + UNIMPLEMENTED; + while (TRUE); + } + + /* Set thread fields */ + Thread->TrapFrame = TrapFrame; + Thread->PreviousMode = PreviousMode; + + /* Set debug header */ + KiFillTrapFrameDebug(TrapFrame); + + /* Enable interrupts and make the call */ + _enable(); + KiSystemCall(ServiceNumber, Arguments); } VOID @@ -1588,20 +1515,54 @@ DECLSPEC_NORETURN KiFastCallEntryHandler(IN PKTRAP_FRAME TrapFrame, IN PVOID Arguments) { + PKTHREAD Thread; + /* Set up a fake INT Stack and enable interrupts */ TrapFrame->HardwareSegSs = KGDT_R3_DATA | RPL_MASK; TrapFrame->HardwareEsp = (ULONG_PTR)Arguments; TrapFrame->EFlags = __readeflags() | EFLAGS_INTERRUPT_MASK; TrapFrame->SegCs = KGDT_R3_CODE | RPL_MASK; TrapFrame->Eip = SharedUserData->SystemCallReturn; - TrapFrame->SegFs = KGDT_R3_TEB | RPL_MASK; __writeeflags(0x2); - /* Arguments are actually 2 frames down (because of the double indirection) */ + /* Get the current thread */ + Thread = KeGetCurrentThread(); + + /* Arguments are actually 2 frames down (because of the double indirection) */ Arguments = (PVOID)(TrapFrame->HardwareEsp + 8); /* Call the shared handler (inline) */ - KiSystemCall(TrapFrame, Arguments); + KiSystemCallHandler(TrapFrame, + TrapFrame->Eax, + Arguments, + Thread, + UserMode, + Thread->PreviousMode, + KGDT_R3_TEB | RPL_MASK); +} + +VOID +FASTCALL +DECLSPEC_NORETURN +KiSystemServiceHandler(IN PKTRAP_FRAME TrapFrame, + IN PVOID Arguments) +{ + PKTHREAD Thread; + + /* Get the current thread */ + Thread = KeGetCurrentThread(); + + /* Chain trap frames */ + TrapFrame->Edx = (ULONG_PTR)Thread->TrapFrame; + + /* Call the shared handler (inline) */ + KiSystemCallHandler(TrapFrame, + TrapFrame->Eax, + Arguments, + Thread, + KiUserTrap(TrapFrame), + Thread->PreviousMode, + TrapFrame->SegFs); } /* From 4e6908db0b8a2aed04a4c1fa5f429228d4d4c9d4 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 19:40:51 +0000 Subject: [PATCH 055/211] [PSDK] sync shlwapi.h to wine 1.1.39 svn path=/trunk/; revision=45797 --- reactos/include/psdk/shlwapi.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/reactos/include/psdk/shlwapi.h b/reactos/include/psdk/shlwapi.h index df1e1aa1306..0af11622d3b 100644 --- a/reactos/include/psdk/shlwapi.h +++ b/reactos/include/psdk/shlwapi.h @@ -85,6 +85,34 @@ DWORD WINAPI SHCopyKeyW(HKEY,LPCWSTR,HKEY,DWORD); HKEY WINAPI SHRegDuplicateHKey(HKEY); +/* SHRegGetValue flags */ +typedef INT SRRF; + +#define SRRF_RT_REG_NONE 0x1 +#define SRRF_RT_REG_SZ 0x2 +#define SRRF_RT_REG_EXPAND_SZ 0x4 +#define SRRF_RT_REG_BINARY 0x8 +#define SRRF_RT_REG_DWORD 0x10 +#define SRRF_RT_REG_MULTI_SZ 0x20 +#define SRRF_RT_REG_QWORD 0x40 + +#define SRRF_RT_DWORD (SRRF_RT_REG_BINARY|SRRF_RT_REG_DWORD) +#define SRRF_RT_QWORD (SRRF_RT_REG_BINARY|SRRF_RT_REG_QWORD) +#define SRRF_RT_ANY 0xffff + +#define SRRF_RM_ANY 0 +#define SRRF_RM_NORMAL 0x10000 +#define SRRF_RM_SAFE 0x20000 +#define SRRF_RM_SAFENETWORK 0x40000 + +#define SRRF_NOEXPAND 0x10000000 +#define SRRF_ZEROONFAILURE 0x20000000 +#define SRRF_NOVIRT 0x40000000 + +LSTATUS WINAPI SHRegGetValueA(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD); +LSTATUS WINAPI SHRegGetValueW(HKEY,LPCWSTR,LPCWSTR,SRRF,LPDWORD,LPVOID,LPDWORD); +#define SHRegGetValue WINELIB_NAME_AW(SHRegGetValue) + /* Undocumented registry functions */ DWORD WINAPI SHDeleteOrphanKeyA(HKEY,LPCSTR); @@ -388,7 +416,7 @@ BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR); BOOL WINAPI PathIsFileSpecA(LPCSTR); BOOL WINAPI PathIsFileSpecW(LPCWSTR); -#define PathIsFileSpec WINELIB_NAME_AW(PathIsFileSpec) +#define PathIsFileSpec WINELIB_NAME_AW(PathIsFileSpec); BOOL WINAPI PathIsPrefixA(LPCSTR,LPCSTR); BOOL WINAPI PathIsPrefixW(LPCWSTR,LPCWSTR); From 63163950a1b0c95c9078621168355e0232233522 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 19:40:55 +0000 Subject: [PATCH 056/211] [SHLWAPI_WINETEST] sync shlwapi_winetest to wine 1.1.39 svn path=/trunk/; revision=45798 --- rostests/winetests/shlwapi/assoc.c | 43 + rostests/winetests/shlwapi/clist.c | 3 +- rostests/winetests/shlwapi/istream.c | 3 +- rostests/winetests/shlwapi/ordinal.c | 1131 +++++++++++++++++++++++--- rostests/winetests/shlwapi/path.c | 56 +- rostests/winetests/shlwapi/shreg.c | 42 + rostests/winetests/shlwapi/string.c | 48 +- rostests/winetests/shlwapi/url.c | 588 ++++++++++--- 8 files changed, 1641 insertions(+), 273 deletions(-) diff --git a/rostests/winetests/shlwapi/assoc.c b/rostests/winetests/shlwapi/assoc.c index 3799ecc957a..a6f5e2d5e61 100644 --- a/rostests/winetests/shlwapi/assoc.c +++ b/rostests/winetests/shlwapi/assoc.c @@ -21,12 +21,14 @@ #include "wine/test.h" #include "shlwapi.h" +#include "shlguid.h" #define expect(expected, got) ok ( expected == got, "Expected %d, got %d\n", expected, got) #define expect_hr(expected, got) ok ( expected == got, "Expected %08x, got %08x\n", expected, got) static HRESULT (WINAPI *pAssocQueryStringA)(ASSOCF,ASSOCSTR,LPCSTR,LPCSTR,LPSTR,LPDWORD) = NULL; static HRESULT (WINAPI *pAssocQueryStringW)(ASSOCF,ASSOCSTR,LPCWSTR,LPCWSTR,LPWSTR,LPDWORD) = NULL; +static HRESULT (WINAPI *pAssocCreate)(CLSID, REFIID, void **) = NULL; /* Every version of Windows with IE should have this association? */ static const WCHAR dotHtml[] = { '.','h','t','m','l',0 }; @@ -235,14 +237,55 @@ cleanup: } +static void test_assoc_create(void) +{ + HRESULT hr; + IQueryAssociations *pqa; + + if (!pAssocCreate) + { + win_skip("AssocCreate() is missing\n"); + return; + } + + hr = pAssocCreate(IID_NULL, &IID_NULL, NULL); + ok(hr == E_INVALIDARG, "Unexpected result : %08x\n", hr); + + hr = pAssocCreate(CLSID_QueryAssociations, &IID_NULL, (LPVOID*)&pqa); + ok(hr == CLASS_E_CLASSNOTAVAILABLE || hr == E_NOTIMPL || hr == E_NOINTERFACE + , "Unexpected result : %08x\n", hr); + + hr = pAssocCreate(IID_NULL, &IID_IQueryAssociations, (LPVOID*)&pqa); + ok(hr == CLASS_E_CLASSNOTAVAILABLE || hr == E_NOTIMPL || hr == E_INVALIDARG + , "Unexpected result : %08x\n", hr); + + hr = pAssocCreate(CLSID_QueryAssociations, &IID_IQueryAssociations, (LPVOID*)&pqa); + ok(hr == S_OK || hr == E_NOTIMPL /* win98 */ + , "Unexpected result : %08x\n", hr); + if(hr == S_OK) + { + IQueryAssociations_Release(pqa); + } + + hr = pAssocCreate(CLSID_QueryAssociations, &IID_IUnknown, (LPVOID*)&pqa); + ok(hr == S_OK || hr == E_NOTIMPL /* win98 */ + , "Unexpected result : %08x\n", hr); + if(hr == S_OK) + { + IQueryAssociations_Release(pqa); + } +} + START_TEST(assoc) { HMODULE hshlwapi; hshlwapi = GetModuleHandleA("shlwapi.dll"); pAssocQueryStringA = (void*)GetProcAddress(hshlwapi, "AssocQueryStringA"); pAssocQueryStringW = (void*)GetProcAddress(hshlwapi, "AssocQueryStringW"); + pAssocCreate = (void*)GetProcAddress(hshlwapi, "AssocCreate"); test_getstring_bad(); test_getstring_basic(); test_getstring_no_extra(); + test_assoc_create(); } diff --git a/rostests/winetests/shlwapi/clist.c b/rostests/winetests/shlwapi/clist.c index 84a05e6f26f..3b979fdec8a 100755 --- a/rostests/winetests/shlwapi/clist.c +++ b/rostests/winetests/shlwapi/clist.c @@ -353,7 +353,8 @@ static void test_CList(void) InitDummyStream(&streamobj); streamobj.failwritesize = TRUE; hRet = pSHLWAPI_17(&streamobj, list); - ok(hRet == STG_E_MEDIUMFULL, "changed size failure return\n"); + ok(hRet == STG_E_MEDIUMFULL || broken(hRet == E_FAIL) /* Win7 */, + "changed size failure return\n"); ok(streamobj.writecalls == 1, "called object after size failure\n"); ok(streamobj.readcalls == 0,"called Read() after failure\n"); ok(streamobj.seekcalls == 0,"called Seek() after failure\n"); diff --git a/rostests/winetests/shlwapi/istream.c b/rostests/winetests/shlwapi/istream.c index 66465b84a4e..67d1fe25182 100644 --- a/rostests/winetests/shlwapi/istream.c +++ b/rostests/winetests/shlwapi/istream.c @@ -177,8 +177,7 @@ static void test_IStream_invalid_operations(IStream * stream, DWORD mode) /* IStream::Clone */ - ret = IStream_Clone(stream, NULL); - ok(ret == E_NOTIMPL, "expected E_NOTIMPL, got 0x%08x\n", ret); + /* Passing a NULL pointer for the second IStream::Clone param crashes on Win7 */ clone = NULL; ret = IStream_Clone(stream, &clone); diff --git a/rostests/winetests/shlwapi/ordinal.c b/rostests/winetests/shlwapi/ordinal.c index 3a50219278e..22437e2b17a 100755 --- a/rostests/winetests/shlwapi/ordinal.c +++ b/rostests/winetests/shlwapi/ordinal.c @@ -19,12 +19,15 @@ #include +#define COBJMACROS #include "wine/test.h" #include "winbase.h" #include "winerror.h" #include "winuser.h" #include "ole2.h" #include "oaidl.h" +#include "ocidl.h" +#include "mlang.h" /* Function ptrs for ordinal calls */ static HMODULE hShlwapi; @@ -36,138 +39,255 @@ static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD); static BOOL (WINAPI *pSHUnlockShared)(LPVOID); static BOOL (WINAPI *pSHFreeShared)(HANDLE,DWORD); static HRESULT(WINAPIV *pSHPackDispParams)(DISPPARAMS*,VARIANTARG*,UINT,...); +static HRESULT(WINAPI *pIConnectionPoint_SimpleInvoke)(IConnectionPoint*,DISPID,DISPPARAMS*); +static HRESULT(WINAPI *pIConnectionPoint_InvokeWithCancel)(IConnectionPoint*,DISPID,DISPPARAMS*,DWORD,DWORD); +static HRESULT(WINAPI *pConnectToConnectionPoint)(IUnknown*,REFIID,BOOL,IUnknown*, LPDWORD,IConnectionPoint **); +static HRESULT(WINAPI *pSHPropertyBag_ReadLONG)(IPropertyBag *,LPCWSTR,LPLONG); + +static HMODULE hmlang; +static HRESULT (WINAPI *pLcidToRfc1766A)(LCID, LPSTR, INT); + +static const CHAR ie_international[] = { + 'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\', + 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\', + 'I','n','t','e','r','n','a','t','i','o','n','a','l',0}; +static const CHAR acceptlanguage[] = { + 'A','c','c','e','p','t','L','a','n','g','u','a','g','e',0}; + static void test_GetAcceptLanguagesA(void) -{ HRESULT retval; - DWORD buffersize, buffersize2, exactsize; - char buffer[100]; +{ + static LPCSTR table[] = {"de,en-gb;q=0.7,en;q=0.3", + "de,en;q=0.3,en-gb;q=0.7", /* sorting is ignored */ + "winetest", /* content is ignored */ + "de-de,de;q=0.5", + "de", + NULL}; + + DWORD exactsize; + char original[512]; + char language[32]; + char buffer[64]; + HKEY hroot = NULL; + LONG res_query = ERROR_SUCCESS; + LONG lres; + HRESULT hr; + DWORD maxlen = sizeof(buffer) - 2; + DWORD len; + LCID lcid; + LPCSTR entry; + INT i = 0; if (!pGetAcceptLanguagesA) { win_skip("GetAcceptLanguagesA is not available\n"); - return; - } - - buffersize = sizeof(buffer); - memset(buffer, 0, sizeof(buffer)); - SetLastError(ERROR_SUCCESS); - retval = pGetAcceptLanguagesA( buffer, &buffersize); - if (!retval && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { - win_skip("GetAcceptLanguagesA is not implemented\n"); return; } - trace("GetAcceptLanguagesA: retval %08x, size %08x, buffer (%s)," - " last error %u\n", retval, buffersize, buffer, GetLastError()); - if(retval != S_OK) { - trace("GetAcceptLanguagesA: skipping tests\n"); - return; + + lcid = GetUserDefaultLCID(); + + /* Get the original Value */ + lres = RegOpenKeyA(HKEY_CURRENT_USER, ie_international, &hroot); + if (lres) { + skip("RegOpenKey(%s) failed: %d\n", ie_international, lres); + return; } - ok( (ERROR_NO_IMPERSONATION_TOKEN == GetLastError()) || - (ERROR_CLASS_DOES_NOT_EXIST == GetLastError()) || - (ERROR_PROC_NOT_FOUND == GetLastError()) || - (ERROR_SUCCESS == GetLastError()), "last error set to %u\n", GetLastError()); - exactsize = strlen(buffer); + len = sizeof(original); + original[0] = 0; + res_query = RegQueryValueExA(hroot, acceptlanguage, 0, NULL, (PBYTE)original, &len); - SetLastError(ERROR_SUCCESS); - retval = pGetAcceptLanguagesA( NULL, NULL); - ok(retval == E_FAIL || - retval == E_INVALIDARG, /* w2k8 */ - "function result wrong: got %08x; expected E_FAIL\n", retval); - ok(ERROR_SUCCESS == GetLastError(), "last error set to %u\n", GetLastError()); + RegDeleteValue(hroot, acceptlanguage); - buffersize = sizeof(buffer); - SetLastError(ERROR_SUCCESS); - retval = pGetAcceptLanguagesA( NULL, &buffersize); - ok(retval == E_FAIL || - retval == E_INVALIDARG, /* w2k8 */ - "function result wrong: got %08x; expected E_FAIL\n", retval); - ok(buffersize == sizeof(buffer) || - buffersize == 0, /* w2k8*/ - "buffersize was changed and is not 0; size (%d))\n", buffersize); - ok(ERROR_SUCCESS == GetLastError(), "last error set to %u\n", GetLastError()); + /* Some windows versions use "lang-COUNTRY" as default */ + memset(language, 0, sizeof(language)); + len = GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, language, sizeof(language)); - SetLastError(ERROR_SUCCESS); - retval = pGetAcceptLanguagesA( buffer, NULL); - ok(retval == E_FAIL || - retval == E_INVALIDARG, /* w2k8 */ - "function result wrong: got %08x; expected E_FAIL\n", retval); - ok(ERROR_SUCCESS == GetLastError(), "last error set to %u\n", GetLastError()); - - buffersize = 0; - memset(buffer, 0, sizeof(buffer)); - SetLastError(ERROR_SUCCESS); - retval = pGetAcceptLanguagesA( buffer, &buffersize); - ok(retval == E_FAIL || - retval == E_INVALIDARG, /* w2k8 */ - "function result wrong: got %08x; expected E_FAIL\n", retval); - ok(buffersize == 0, - "buffersize wrong(changed) got %08x; expected 0 (2nd parameter; not on Win2k)\n", buffersize); - ok(ERROR_SUCCESS == GetLastError(), "last error set to %u\n", GetLastError()); - - buffersize = buffersize2 = 1; - memset(buffer, 0, sizeof(buffer)); - SetLastError(ERROR_SUCCESS); - retval = pGetAcceptLanguagesA( buffer, &buffersize); - switch(retval) { - case 0L: - if(buffersize == exactsize) { - ok( (ERROR_SUCCESS == GetLastError()) || - (ERROR_PROC_NOT_FOUND == GetLastError()) || (ERROR_NO_IMPERSONATION_TOKEN == GetLastError()), - "last error wrong: got %u; expected ERROR_SUCCESS(NT4)/" - "ERROR_PROC_NOT_FOUND(NT4)/ERROR_NO_IMPERSONATION_TOKEN(XP)\n", GetLastError()); - ok(exactsize == strlen(buffer), - "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), exactsize); - } else if((buffersize +1) == buffersize2) { - ok(ERROR_SUCCESS == GetLastError(), - "last error wrong: got %u; expected ERROR_SUCCESS\n", GetLastError()); - ok(buffersize == strlen(buffer), - "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), buffersize); - } else - ok( 0, "retval %08x, size %08x, buffer (%s), last error %u\n", - retval, buffersize, buffer, GetLastError()); - break; - case E_INVALIDARG: - ok(buffersize == 0, - "buffersize wrong: got %08x, expected 0 (2nd parameter;Win2k)\n", buffersize); - ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(), - "last error wrong: got %u; expected ERROR_INSUFFICIENT_BUFFER\n", GetLastError()); - ok(buffersize2 == strlen(buffer), - "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), buffersize2); - break; - default: - ok( 0, "retval %08x, size %08x, buffer (%s), last error %u\n", - retval, buffersize, buffer, GetLastError()); - break; + if (len) { + lstrcat(language, "-"); + memset(buffer, 0, sizeof(buffer)); + len = GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, buffer, sizeof(buffer) - len - 1); + lstrcat(language, buffer); + } + else + { + /* LOCALE_SNAME has additional parts in some languages. Try only as last chance */ + memset(language, 0, sizeof(language)); + len = GetLocaleInfoA(lcid, LOCALE_SNAME, language, sizeof(language)); } - buffersize = buffersize2 = exactsize; - memset(buffer, 0, sizeof(buffer)); - SetLastError(ERROR_SUCCESS); - retval = pGetAcceptLanguagesA( buffer, &buffersize); - switch(retval) { - case 0L: - ok(ERROR_SUCCESS == GetLastError(), - "last error wrong: got %u; expected ERROR_SUCCESS\n", GetLastError()); - if((buffersize == exactsize) /* XP */ || - ((buffersize +1)== exactsize) /* 98 */) - ok(buffersize == strlen(buffer), - "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), buffersize); - else - ok( 0, "retval %08x, size %08x, buffer (%s), last error %u\n", - retval, buffersize, buffer, GetLastError()); - break; - case E_INVALIDARG: - ok(buffersize == 0, - "buffersize wrong: got %08x, expected 0 (2nd parameter;Win2k)\n", buffersize); - ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(), - "last error wrong: got %u; expected ERROR_INSUFFICIENT_BUFFER\n", GetLastError()); - ok(buffersize2 == strlen(buffer), - "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), buffersize2); - break; - default: - ok( 0, "retval %08x, size %08x, buffer (%s), last error %u\n", - retval, buffersize, buffer, GetLastError()); - break; + /* get the default value */ + len = maxlen; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + + if (hr != S_OK) { + win_skip("GetAcceptLanguagesA failed with 0x%x\n", hr); + goto restore_original; } + + if (lstrcmpA(buffer, language)) { + /* some windows versions use "lang" or "lang-country" as default */ + language[0] = 0; + if (pLcidToRfc1766A) { + hr = pLcidToRfc1766A(lcid, language, sizeof(language)); + ok(hr == S_OK, "LcidToRfc1766A returned 0x%x and %s\n", hr, language); + } + } + + ok(!lstrcmpA(buffer, language), + "have '%s' (searching for '%s')\n", language, buffer); + + if (lstrcmpA(buffer, language)) { + win_skip("no more ideas, how to build the default language '%s'\n", buffer); + goto restore_original; + } + + trace("detected default: %s\n", language); + while ((entry = table[i])) { + + exactsize = lstrlenA(entry); + + lres = RegSetValueExA(hroot, acceptlanguage, 0, REG_SZ, (const BYTE *) entry, exactsize + 1); + ok(!lres, "got %d for RegSetValueExA: %s\n", lres, entry); + + /* len includes space for the terminating 0 before vista/w2k8 */ + len = exactsize + 2; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + ok(((hr == E_INVALIDARG) && (len == 0)) || + (SUCCEEDED(hr) && + ((len == exactsize) || (len == exactsize+1)) && + !lstrcmpA(buffer, entry)), + "+2_#%d: got 0x%x with %d and %s\n", i, hr, len, buffer); + + len = exactsize + 1; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + ok(((hr == E_INVALIDARG) && (len == 0)) || + (SUCCEEDED(hr) && + ((len == exactsize) || (len == exactsize+1)) && + !lstrcmpA(buffer, entry)), + "+1_#%d: got 0x%x with %d and %s\n", i, hr, len, buffer); + + len = exactsize; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + + /* There is no space for the string in the registry. + When the buffer is large enough, the default language is returned + + When the buffer is to small for that fallback, win7_32 and w2k8_64 + and above fail with HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), but + recent os succeed and return a partial result while + older os succeed and overflow the buffer */ + + ok(((hr == E_INVALIDARG) && (len == 0)) || + (((hr == S_OK) && !lstrcmpA(buffer, language) && (len == lstrlenA(language))) || + ((hr == S_OK) && !memcmp(buffer, language, len)) || + ((hr == __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) && !len)), + "==_#%d: got 0x%x with %d and %s\n", i, hr, len, buffer); + + if (exactsize > 1) { + len = exactsize - 1; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + ok(((hr == E_INVALIDARG) && (len == 0)) || + (((hr == S_OK) && !lstrcmpA(buffer, language) && (len == lstrlenA(language))) || + ((hr == S_OK) && !memcmp(buffer, language, len)) || + ((hr == __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) && !len)), + "-1_#%d: got 0x%x with %d and %s\n", i, hr, len, buffer); + } + + len = 1; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + ok(((hr == E_INVALIDARG) && (len == 0)) || + (((hr == S_OK) && !lstrcmpA(buffer, language) && (len == lstrlenA(language))) || + ((hr == S_OK) && !memcmp(buffer, language, len)) || + ((hr == __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) && !len)), + "=1_#%d: got 0x%x with %d and %s\n", i, hr, len, buffer); + + len = maxlen; + hr = pGetAcceptLanguagesA( NULL, &len); + + /* w2k3 and below: E_FAIL and untouched len, + since w2k8: S_OK and needed size (excluding 0) */ + ok( ((hr == S_OK) && (len == exactsize)) || + ((hr == E_FAIL) && (len == maxlen)), + "NULL,max #%d: got 0x%x with %d and %s\n", i, hr, len, buffer); + + i++; + } + + /* without a value in the registry, a default language is returned */ + RegDeleteValue(hroot, acceptlanguage); + + len = maxlen; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + ok( ((hr == S_OK) && (len == lstrlenA(language))), + "max: got 0x%x with %d and %s (expected S_OK with %d and '%s'\n", + hr, len, buffer, lstrlenA(language), language); + + len = 2; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + ok( (((hr == S_OK) || (hr == E_INVALIDARG)) && !memcmp(buffer, language, len)) || + ((hr == __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) && !len), + "=2: got 0x%x with %d and %s\n", hr, len, buffer); + + len = 1; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + /* When the buffer is to small, win7_32 and w2k8_64 and above fail with + HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), other versions suceed + and return a partial 0 terminated result while other versions + fail with E_INVALIDARG and return a partial unterminated result */ + ok( (((hr == S_OK) || (hr == E_INVALIDARG)) && !memcmp(buffer, language, len)) || + ((hr == __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) && !len), + "=1: got 0x%x with %d and %s\n", hr, len, buffer); + + len = 0; + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, &len); + /* w2k3 and below: E_FAIL, since w2k8: E_INVALIDARG */ + ok((hr == E_FAIL) || (hr == E_INVALIDARG), + "got 0x%x (expected E_FAIL or E_INVALIDARG)\n", hr); + + memset(buffer, '#', maxlen); + buffer[maxlen] = 0; + hr = pGetAcceptLanguagesA( buffer, NULL); + /* w2k3 and below: E_FAIL, since w2k8: E_INVALIDARG */ + ok((hr == E_FAIL) || (hr == E_INVALIDARG), + "got 0x%x (expected E_FAIL or E_INVALIDARG)\n", hr); + + + hr = pGetAcceptLanguagesA( NULL, NULL); + /* w2k3 and below: E_FAIL, since w2k8: E_INVALIDARG */ + ok((hr == E_FAIL) || (hr == E_INVALIDARG), + "got 0x%x (expected E_FAIL or E_INVALIDARG)\n", hr); + +restore_original: + if (!res_query) { + len = lstrlenA(original); + lres = RegSetValueExA(hroot, acceptlanguage, 0, REG_SZ, (const BYTE *) original, len ? len + 1: 0); + ok(!lres, "RegSetValueEx(%s) failed: %d\n", original, lres); + } + else + { + RegDeleteValue(hroot, acceptlanguage); + } + RegCloseKey(hroot); } static void test_SHSearchMapInt(void) @@ -511,6 +631,772 @@ static void test_SHPackDispParams(void) ok(V_BSTR(vars+3) == (void*)0xdeadbeef, "V_BSTR(vars[3]) = %p\n", V_BSTR(vars+3)); } +typedef struct _disp +{ + const IDispatchVtbl *vtbl; + LONG refCount; +} Disp; + +typedef struct _contain +{ + const IConnectionPointContainerVtbl *vtbl; + LONG refCount; + + UINT ptCount; + IConnectionPoint **pt; +} Contain; + +typedef struct _cntptn +{ + const IConnectionPointVtbl *vtbl; + LONG refCount; + + Contain *container; + GUID id; + UINT sinkCount; + IUnknown **sink; +} ConPt; + +typedef struct _enum +{ + const IEnumConnectionsVtbl *vtbl; + LONG refCount; + + UINT idx; + ConPt *pt; +} EnumCon; + +typedef struct _enumpt +{ + const IEnumConnectionPointsVtbl *vtbl; + LONG refCount; + + int idx; + Contain *container; +} EnumPt; + + +static HRESULT WINAPI Disp_QueryInterface( + IDispatch* This, + REFIID riid, + void **ppvObject) +{ + *ppvObject = NULL; + + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDispatch)) + { + *ppvObject = This; + } + + if (*ppvObject) + { + IUnknown_AddRef(This); + return S_OK; + } + + trace("no interface\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI Disp_AddRef(IDispatch* This) +{ + Disp *iface = (Disp*)This; + return InterlockedIncrement(&iface->refCount); +} + +static ULONG WINAPI Disp_Release(IDispatch* This) +{ + Disp *iface = (Disp*)This; + ULONG ret; + + ret = InterlockedDecrement(&iface->refCount); + if (ret == 0) + HeapFree(GetProcessHeap(),0,This); + return ret; +} + +static HRESULT WINAPI Disp_GetTypeInfoCount( + IDispatch* This, + UINT *pctinfo) +{ + return ERROR_SUCCESS; +} + +static HRESULT WINAPI Disp_GetTypeInfo( + IDispatch* This, + UINT iTInfo, + LCID lcid, + ITypeInfo **ppTInfo) +{ + return ERROR_SUCCESS; +} + +static HRESULT WINAPI Disp_GetIDsOfNames( + IDispatch* This, + REFIID riid, + LPOLESTR *rgszNames, + UINT cNames, + LCID lcid, + DISPID *rgDispId) +{ + return ERROR_SUCCESS; +} + +static HRESULT WINAPI Disp_Invoke( + IDispatch* This, + DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) +{ + trace("%p %x %p %x %x %p %p %p %p\n",This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr); + + ok(dispIdMember == 0xa0 || dispIdMember == 0xa1, "Unknown dispIdMember\n"); + ok(pDispParams != NULL, "Invoked with NULL pDispParams\n"); + ok(wFlags == DISPATCH_METHOD, "Wrong flags %x\n",wFlags); + ok(lcid == 0,"Wrong lcid %x\n",lcid); + if (dispIdMember == 0xa0) + { + ok(pDispParams->cArgs == 0, "params.cArgs = %d\n", pDispParams->cArgs); + ok(pDispParams->cNamedArgs == 0, "params.cNamedArgs = %d\n", pDispParams->cArgs); + ok(pDispParams->rgdispidNamedArgs == NULL, "params.rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs); + ok(pDispParams->rgvarg == NULL, "params.rgvarg = %p\n", pDispParams->rgvarg); + } + else if (dispIdMember == 0xa1) + { + ok(pDispParams->cArgs == 2, "params.cArgs = %d\n", pDispParams->cArgs); + ok(pDispParams->cNamedArgs == 0, "params.cNamedArgs = %d\n", pDispParams->cArgs); + ok(pDispParams->rgdispidNamedArgs == NULL, "params.rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs); + ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(var) = %d\n", V_VT(pDispParams->rgvarg)); + ok(V_I4(pDispParams->rgvarg) == 0xdeadcafe , "failed %p\n", V_BSTR(pDispParams->rgvarg)); + ok(V_VT(pDispParams->rgvarg+1) == VT_I4, "V_VT(var) = %d\n", V_VT(pDispParams->rgvarg+1)); + ok(V_I4(pDispParams->rgvarg+1) == 0xdeadbeef, "failed %x\n", V_I4(pDispParams->rgvarg+1)); + } + + return ERROR_SUCCESS; +} + +static const IDispatchVtbl disp_vtbl = { + Disp_QueryInterface, + Disp_AddRef, + Disp_Release, + + Disp_GetTypeInfoCount, + Disp_GetTypeInfo, + Disp_GetIDsOfNames, + Disp_Invoke +}; + +static HRESULT WINAPI Enum_QueryInterface( + IEnumConnections* This, + REFIID riid, + void **ppvObject) +{ + *ppvObject = NULL; + + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IEnumConnections)) + { + *ppvObject = This; + } + + if (*ppvObject) + { + IUnknown_AddRef(This); + return S_OK; + } + + trace("no interface\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI Enum_AddRef(IEnumConnections* This) +{ + EnumCon *iface = (EnumCon*)This; + return InterlockedIncrement(&iface->refCount); +} + +static ULONG WINAPI Enum_Release(IEnumConnections* This) +{ + EnumCon *iface = (EnumCon*)This; + ULONG ret; + + ret = InterlockedDecrement(&iface->refCount); + if (ret == 0) + HeapFree(GetProcessHeap(),0,This); + return ret; +} + +static HRESULT WINAPI Enum_Next( + IEnumConnections* This, + ULONG cConnections, + LPCONNECTDATA rgcd, + ULONG *pcFetched) +{ + EnumCon *iface = (EnumCon*)This; + + if (cConnections > 0 && iface->idx < iface->pt->sinkCount) + { + rgcd->pUnk = iface->pt->sink[iface->idx]; + IUnknown_AddRef(iface->pt->sink[iface->idx]); + rgcd->dwCookie=0xff; + if (pcFetched) + *pcFetched = 1; + iface->idx++; + return S_OK; + } + + return E_FAIL; +} + +static HRESULT WINAPI Enum_Skip( + IEnumConnections* This, + ULONG cConnections) +{ + return E_FAIL; +} + +static HRESULT WINAPI Enum_Reset( + IEnumConnections* This) +{ + return E_FAIL; +} + +static HRESULT WINAPI Enum_Clone( + IEnumConnections* This, + IEnumConnections **ppEnum) +{ + return E_FAIL; +} + +static const IEnumConnectionsVtbl enum_vtbl = { + + Enum_QueryInterface, + Enum_AddRef, + Enum_Release, + Enum_Next, + Enum_Skip, + Enum_Reset, + Enum_Clone +}; + +static HRESULT WINAPI ConPt_QueryInterface( + IConnectionPoint* This, + REFIID riid, + void **ppvObject) +{ + *ppvObject = NULL; + + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IConnectionPoint)) + { + *ppvObject = This; + } + + if (*ppvObject) + { + IUnknown_AddRef(This); + return S_OK; + } + + trace("no interface\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI ConPt_AddRef( + IConnectionPoint* This) +{ + ConPt *iface = (ConPt*)This; + return InterlockedIncrement(&iface->refCount); +} + +static ULONG WINAPI ConPt_Release( + IConnectionPoint* This) +{ + ConPt *iface = (ConPt*)This; + ULONG ret; + + ret = InterlockedDecrement(&iface->refCount); + if (ret == 0) + { + if (iface->sinkCount > 0) + { + int i; + for (i = 0; i < iface->sinkCount; i++) + { + if (iface->sink[i]) + IUnknown_Release(iface->sink[i]); + } + HeapFree(GetProcessHeap(),0,iface->sink); + } + HeapFree(GetProcessHeap(),0,This); + } + return ret; +} + +static HRESULT WINAPI ConPt_GetConnectionInterface( + IConnectionPoint* This, + IID *pIID) +{ + static int i = 0; + ConPt *iface = (ConPt*)This; + if (i==0) + { + i++; + return E_FAIL; + } + else + memcpy(pIID,&iface->id,sizeof(GUID)); + return S_OK; +} + +static HRESULT WINAPI ConPt_GetConnectionPointContainer( + IConnectionPoint* This, + IConnectionPointContainer **ppCPC) +{ + ConPt *iface = (ConPt*)This; + + *ppCPC = (IConnectionPointContainer*)iface->container; + return S_OK; +} + +static HRESULT WINAPI ConPt_Advise( + IConnectionPoint* This, + IUnknown *pUnkSink, + DWORD *pdwCookie) +{ + ConPt *iface = (ConPt*)This; + + if (iface->sinkCount == 0) + iface->sink = HeapAlloc(GetProcessHeap(),0,sizeof(IUnknown*)); + else + iface->sink = HeapReAlloc(GetProcessHeap(),0,iface->sink,sizeof(IUnknown*)*(iface->sinkCount+1)); + iface->sink[iface->sinkCount] = pUnkSink; + IUnknown_AddRef(pUnkSink); + iface->sinkCount++; + *pdwCookie = iface->sinkCount; + return S_OK; +} + +static HRESULT WINAPI ConPt_Unadvise( + IConnectionPoint* This, + DWORD dwCookie) +{ + ConPt *iface = (ConPt*)This; + + if (dwCookie > iface->sinkCount) + return E_FAIL; + else + { + IUnknown_Release(iface->sink[dwCookie-1]); + iface->sink[dwCookie-1] = NULL; + } + return S_OK; +} + +static HRESULT WINAPI ConPt_EnumConnections( + IConnectionPoint* This, + IEnumConnections **ppEnum) +{ + EnumCon *ec; + + ec = HeapAlloc(GetProcessHeap(),0,sizeof(EnumCon)); + ec->vtbl = &enum_vtbl; + ec->refCount = 1; + ec->pt = (ConPt*)This; + ec->idx = 0; + *ppEnum = (IEnumConnections*)ec; + + return S_OK; +} + +static const IConnectionPointVtbl point_vtbl = { + ConPt_QueryInterface, + ConPt_AddRef, + ConPt_Release, + + ConPt_GetConnectionInterface, + ConPt_GetConnectionPointContainer, + ConPt_Advise, + ConPt_Unadvise, + ConPt_EnumConnections +}; + +static HRESULT WINAPI EnumPt_QueryInterface( + IEnumConnectionPoints* This, + REFIID riid, + void **ppvObject) +{ + *ppvObject = NULL; + + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IEnumConnectionPoints)) + { + *ppvObject = This; + } + + if (*ppvObject) + { + IUnknown_AddRef(This); + return S_OK; + } + + trace("no interface\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI EnumPt_AddRef(IEnumConnectionPoints* This) +{ + EnumPt *iface = (EnumPt*)This; + return InterlockedIncrement(&iface->refCount); +} + +static ULONG WINAPI EnumPt_Release(IEnumConnectionPoints* This) +{ + EnumPt *iface = (EnumPt*)This; + ULONG ret; + + ret = InterlockedDecrement(&iface->refCount); + if (ret == 0) + HeapFree(GetProcessHeap(),0,This); + return ret; +} + +static HRESULT WINAPI EnumPt_Next( + IEnumConnectionPoints* This, + ULONG cConnections, + IConnectionPoint **rgcd, + ULONG *pcFetched) +{ + EnumPt *iface = (EnumPt*)This; + + if (cConnections > 0 && iface->idx < iface->container->ptCount) + { + *rgcd = iface->container->pt[iface->idx]; + IUnknown_AddRef(iface->container->pt[iface->idx]); + if (pcFetched) + *pcFetched = 1; + iface->idx++; + return S_OK; + } + + return E_FAIL; +} + +static HRESULT WINAPI EnumPt_Skip( + IEnumConnectionPoints* This, + ULONG cConnections) +{ + return E_FAIL; +} + +static HRESULT WINAPI EnumPt_Reset( + IEnumConnectionPoints* This) +{ + return E_FAIL; +} + +static HRESULT WINAPI EnumPt_Clone( + IEnumConnectionPoints* This, + IEnumConnectionPoints **ppEnumPt) +{ + return E_FAIL; +} + +static const IEnumConnectionPointsVtbl enumpt_vtbl = { + + EnumPt_QueryInterface, + EnumPt_AddRef, + EnumPt_Release, + EnumPt_Next, + EnumPt_Skip, + EnumPt_Reset, + EnumPt_Clone +}; + +static HRESULT WINAPI Contain_QueryInterface( + IConnectionPointContainer* This, + REFIID riid, + void **ppvObject) +{ + *ppvObject = NULL; + + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IConnectionPointContainer)) + { + *ppvObject = This; + } + + if (*ppvObject) + { + IUnknown_AddRef(This); + return S_OK; + } + + trace("no interface\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI Contain_AddRef( + IConnectionPointContainer* This) +{ + Contain *iface = (Contain*)This; + return InterlockedIncrement(&iface->refCount); +} + +static ULONG WINAPI Contain_Release( + IConnectionPointContainer* This) +{ + Contain *iface = (Contain*)This; + ULONG ret; + + ret = InterlockedDecrement(&iface->refCount); + if (ret == 0) + { + if (iface->ptCount > 0) + { + int i; + for (i = 0; i < iface->ptCount; i++) + IUnknown_Release(iface->pt[i]); + HeapFree(GetProcessHeap(),0,iface->pt); + } + HeapFree(GetProcessHeap(),0,This); + } + return ret; +} + +static HRESULT WINAPI Contain_EnumConnectionPoints( + IConnectionPointContainer* This, + IEnumConnectionPoints **ppEnum) +{ + EnumPt *ec; + + ec = HeapAlloc(GetProcessHeap(),0,sizeof(EnumPt)); + ec->vtbl = &enumpt_vtbl; + ec->refCount = 1; + ec->idx= 0; + ec->container = (Contain*)This; + *ppEnum = (IEnumConnectionPoints*)ec; + + return S_OK; +} + +static HRESULT WINAPI Contain_FindConnectionPoint( + IConnectionPointContainer* This, + REFIID riid, + IConnectionPoint **ppCP) +{ + Contain *iface = (Contain*)This; + ConPt *pt; + + if (!IsEqualIID(riid, &IID_NULL) || iface->ptCount ==0) + { + pt = HeapAlloc(GetProcessHeap(),0,sizeof(ConPt)); + pt->vtbl = &point_vtbl; + pt->refCount = 1; + pt->sinkCount = 0; + pt->sink = NULL; + pt->container = iface; + pt->id = IID_IDispatch; + + if (iface->ptCount == 0) + iface->pt =HeapAlloc(GetProcessHeap(),0,sizeof(IUnknown*)); + else + iface->pt = HeapReAlloc(GetProcessHeap(),0,iface->pt,sizeof(IUnknown*)*(iface->ptCount+1)); + iface->pt[iface->ptCount] = (IConnectionPoint*)pt; + iface->ptCount++; + + *ppCP = (IConnectionPoint*)pt; + } + else + { + *ppCP = iface->pt[0]; + IUnknown_AddRef((IUnknown*)*ppCP); + } + + return S_OK; +} + +static const IConnectionPointContainerVtbl contain_vtbl = { + Contain_QueryInterface, + Contain_AddRef, + Contain_Release, + + Contain_EnumConnectionPoints, + Contain_FindConnectionPoint +}; + +static void test_IConnectionPoint(void) +{ + HRESULT rc; + ULONG ref; + IConnectionPoint *point; + Contain *container; + Disp *dispatch; + DWORD cookie = 0xffffffff; + DISPPARAMS params; + VARIANT vars[10]; + + if (!pIConnectionPoint_SimpleInvoke || !pConnectToConnectionPoint) + { + win_skip("IConnectionPoint Apis not present\n"); + return; + } + + container = HeapAlloc(GetProcessHeap(),0,sizeof(Contain)); + container->vtbl = &contain_vtbl; + container->refCount = 1; + container->ptCount = 0; + container->pt = NULL; + + dispatch = HeapAlloc(GetProcessHeap(),0,sizeof(Disp)); + dispatch->vtbl = &disp_vtbl; + dispatch->refCount = 1; + + rc = pConnectToConnectionPoint((IUnknown*)dispatch, &IID_NULL, TRUE, (IUnknown*)container, &cookie, &point); + ok(rc == S_OK, "pConnectToConnectionPoint failed with %x\n",rc); + ok(point != NULL, "returned ConnectionPoint is NULL\n"); + ok(cookie != 0xffffffff, "invalid cookie returned\n"); + + rc = pIConnectionPoint_SimpleInvoke(point,0xa0,NULL); + ok(rc == S_OK, "pConnectToConnectionPoint failed with %x\n",rc); + + if (pSHPackDispParams) + { + memset(¶ms, 0xc0, sizeof(params)); + memset(vars, 0xc0, sizeof(vars)); + rc = pSHPackDispParams(¶ms, vars, 2, VT_I4, 0xdeadbeef, VT_BSTR, 0xdeadcafe); + ok(rc == S_OK, "SHPackDispParams failed: %08x\n", rc); + + rc = pIConnectionPoint_SimpleInvoke(point,0xa1,¶ms); + ok(rc == S_OK, "pConnectToConnectionPoint failed with %x\n",rc); + } + else + win_skip("pSHPackDispParams not present\n"); + + rc = pConnectToConnectionPoint(NULL, &IID_NULL, FALSE, (IUnknown*)container, &cookie, NULL); + ok(rc == S_OK, "pConnectToConnectionPoint failed with %x\n",rc); + +/* MSDN says this should be required but it crashs on XP + IUnknown_Release(point); +*/ + ref = IUnknown_Release((IUnknown*)container); + ok(ref == 0, "leftover IConnectionPointContainer reference %i\n",ref); + ref = IUnknown_Release((IUnknown*)dispatch); + ok(ref == 0, "leftover IDispatch reference %i\n",ref); +} + +typedef struct _propbag +{ + const IPropertyBagVtbl *vtbl; + LONG refCount; + +} PropBag; + + +static HRESULT WINAPI Prop_QueryInterface( + IPropertyBag* This, + REFIID riid, + void **ppvObject) +{ + *ppvObject = NULL; + + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPropertyBag)) + { + *ppvObject = This; + } + + if (*ppvObject) + { + IUnknown_AddRef(This); + return S_OK; + } + + trace("no interface\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI Prop_AddRef( + IPropertyBag* This) +{ + PropBag *iface = (PropBag*)This; + return InterlockedIncrement(&iface->refCount); +} + +static ULONG WINAPI Prop_Release( + IPropertyBag* This) +{ + PropBag *iface = (PropBag*)This; + ULONG ret; + + ret = InterlockedDecrement(&iface->refCount); + if (ret == 0) + HeapFree(GetProcessHeap(),0,This); + return ret; +} + +static HRESULT WINAPI Prop_Read( + IPropertyBag* This, + LPCOLESTR pszPropName, + VARIANT *pVar, + IErrorLog *pErrorLog) +{ + V_VT(pVar) = VT_BLOB|VT_BYREF; + V_BYREF(pVar) = (LPVOID)0xdeadcafe; + return S_OK; +} + +static HRESULT WINAPI Prop_Write( + IPropertyBag* This, + LPCOLESTR pszPropName, + VARIANT *pVar) +{ + return S_OK; +} + + +static const IPropertyBagVtbl prop_vtbl = { + Prop_QueryInterface, + Prop_AddRef, + Prop_Release, + + Prop_Read, + Prop_Write +}; + +static void test_SHPropertyBag_ReadLONG(void) +{ + PropBag *pb; + HRESULT rc; + LONG out; + static const WCHAR szName1[] = {'n','a','m','e','1',0}; + + if (!pSHPropertyBag_ReadLONG) + { + win_skip("SHPropertyBag_ReadLONG not present\n"); + return; + } + + pb = HeapAlloc(GetProcessHeap(),0,sizeof(PropBag)); + pb->refCount = 1; + pb->vtbl = &prop_vtbl; + + out = 0xfeedface; + rc = pSHPropertyBag_ReadLONG(NULL, szName1, &out); + ok(rc == E_INVALIDARG || broken(rc == 0), "incorrect return %x\n",rc); + ok(out == 0xfeedface, "value should not have changed\n"); + rc = pSHPropertyBag_ReadLONG((IPropertyBag*)pb, NULL, &out); + ok(rc == E_INVALIDARG || broken(rc == 0) || broken(rc == 1), "incorrect return %x\n",rc); + ok(out == 0xfeedface, "value should not have changed\n"); + rc = pSHPropertyBag_ReadLONG((IPropertyBag*)pb, szName1, NULL); + ok(rc == E_INVALIDARG || broken(rc == 0) || broken(rc == 1), "incorrect return %x\n",rc); + ok(out == 0xfeedface, "value should not have changed\n"); + rc = pSHPropertyBag_ReadLONG((IPropertyBag*)pb, szName1, &out); + ok(rc == DISP_E_BADVARTYPE || broken(rc == 0) || broken(rc == 1), "incorrect return %x\n",rc); + ok(out == 0xfeedface || broken(out == 0xfeedfa00), "value should not have changed %x\n",out); + IUnknown_Release((IUnknown*)pb); +} + START_TEST(ordinal) { hShlwapi = GetModuleHandleA("shlwapi.dll"); @@ -522,6 +1408,13 @@ START_TEST(ordinal) pSHUnlockShared=(void*)GetProcAddress(hShlwapi,(char*)9); pSHFreeShared=(void*)GetProcAddress(hShlwapi,(char*)10); pSHPackDispParams=(void*)GetProcAddress(hShlwapi,(char*)282); + pIConnectionPoint_SimpleInvoke=(void*)GetProcAddress(hShlwapi,(char*)284); + pIConnectionPoint_InvokeWithCancel=(void*)GetProcAddress(hShlwapi,(char*)283); + pConnectToConnectionPoint=(void*)GetProcAddress(hShlwapi,(char*)168); + pSHPropertyBag_ReadLONG=(void*)GetProcAddress(hShlwapi,(char*)496); + + hmlang = LoadLibraryA("mlang.dll"); + pLcidToRfc1766A = (void *)GetProcAddress(hmlang, "LcidToRfc1766A"); test_GetAcceptLanguagesA(); test_SHSearchMapInt(); @@ -529,4 +1422,6 @@ START_TEST(ordinal) test_fdsa(); test_GetShellSecurityDescriptor(); test_SHPackDispParams(); + test_IConnectionPoint(); + test_SHPropertyBag_ReadLONG(); } diff --git a/rostests/winetests/shlwapi/path.c b/rostests/winetests/shlwapi/path.c index 52eee2d7c8e..e52502fdf58 100755 --- a/rostests/winetests/shlwapi/path.c +++ b/rostests/winetests/shlwapi/path.c @@ -32,6 +32,8 @@ static HMODULE hShlwapi; static HRESULT (WINAPI *pPathIsValidCharA)(char,DWORD); static HRESULT (WINAPI *pPathIsValidCharW)(WCHAR,DWORD); static LPWSTR (WINAPI *pPathCombineW)(LPWSTR, LPCWSTR, LPCWSTR); +static HRESULT (WINAPI *pPathCreateFromUrlA)(LPCSTR, LPSTR, LPDWORD, DWORD); +static HRESULT (WINAPI *pPathCreateFromUrlW)(LPCWSTR, LPWSTR, LPDWORD, DWORD); /* ################ */ @@ -207,31 +209,39 @@ static void test_PathCreateFromUrl(void) WCHAR *pathW, *urlW; static const char url[] = "http://www.winehq.org"; + if (!pPathCreateFromUrlA) { + win_skip("PathCreateFromUrlA not found\n"); + return; + } + /* Check ret_path = NULL */ len = sizeof(url); - ret = PathCreateFromUrlA(url, NULL, &len, 0); + ret = pPathCreateFromUrlA(url, NULL, &len, 0); ok ( ret == E_INVALIDARG, "got 0x%08x expected E_INVALIDARG\n", ret); for(i = 0; i < sizeof(TEST_PATHFROMURL) / sizeof(TEST_PATHFROMURL[0]); i++) { len = INTERNET_MAX_URL_LENGTH; - ret = PathCreateFromUrlA(TEST_PATHFROMURL[i].url, ret_path, &len, 0); + ret = pPathCreateFromUrlA(TEST_PATHFROMURL[i].url, ret_path, &len, 0); ok(ret == TEST_PATHFROMURL[i].ret, "ret %08x from url %s\n", ret, TEST_PATHFROMURL[i].url); if(TEST_PATHFROMURL[i].path) { ok(!lstrcmpi(ret_path, TEST_PATHFROMURL[i].path), "got %s expected %s from url %s\n", ret_path, TEST_PATHFROMURL[i].path, TEST_PATHFROMURL[i].url); ok(len == strlen(ret_path), "ret len %d from url %s\n", len, TEST_PATHFROMURL[i].url); } - len = INTERNET_MAX_URL_LENGTH; - pathW = GetWideString(TEST_PATHFROMURL[i].path); - urlW = GetWideString(TEST_PATHFROMURL[i].url); - ret = PathCreateFromUrlW(urlW, ret_pathW, &len, 0); - WideCharToMultiByte(CP_ACP, 0, ret_pathW, -1, ret_path, sizeof(ret_path),0,0); - ok(ret == TEST_PATHFROMURL[i].ret, "ret %08x from url L\"%s\"\n", ret, TEST_PATHFROMURL[i].url); - if(TEST_PATHFROMURL[i].path) { - ok(!lstrcmpiW(ret_pathW, pathW), "got %s expected %s from url L\"%s\"\n", ret_path, TEST_PATHFROMURL[i].path, TEST_PATHFROMURL[i].url); - ok(len == lstrlenW(ret_pathW), "ret len %d from url L\"%s\"\n", len, TEST_PATHFROMURL[i].url); + if (pPathCreateFromUrlW) { + len = INTERNET_MAX_URL_LENGTH; + pathW = GetWideString(TEST_PATHFROMURL[i].path); + urlW = GetWideString(TEST_PATHFROMURL[i].url); + ret = pPathCreateFromUrlW(urlW, ret_pathW, &len, 0); + WideCharToMultiByte(CP_ACP, 0, ret_pathW, -1, ret_path, sizeof(ret_path),0,0); + ok(ret == TEST_PATHFROMURL[i].ret, "ret %08x from url L\"%s\"\n", ret, TEST_PATHFROMURL[i].url); + if(TEST_PATHFROMURL[i].path) { + ok(!lstrcmpiW(ret_pathW, pathW), "got %s expected %s from url L\"%s\"\n", + ret_path, TEST_PATHFROMURL[i].path, TEST_PATHFROMURL[i].url); + ok(len == lstrlenW(ret_pathW), "ret len %d from url L\"%s\"\n", len, TEST_PATHFROMURL[i].url); + } + FreeWideString(urlW); + FreeWideString(pathW); } - FreeWideString(urlW); - FreeWideString(pathW); } } @@ -690,7 +700,7 @@ static void test_PathAppendA(void) { char path[MAX_PATH]; char too_long[LONG_LEN]; - char one[HALF_LEN], two[HALF_LEN]; + char half[HALF_LEN]; BOOL res; lstrcpy(path, "C:\\one"); @@ -803,16 +813,16 @@ static void test_PathAppendA(void) "Expected length of path to be zero, got %i\n", lstrlen(path)); /* both params combined are too long */ - memset(one, 'a', HALF_LEN); - one[HALF_LEN - 1] = '\0'; - memset(two, 'b', HALF_LEN); - two[HALF_LEN - 1] = '\0'; + memset(path, 'a', HALF_LEN); + path[HALF_LEN - 1] = '\0'; + memset(half, 'b', HALF_LEN); + half[HALF_LEN - 1] = '\0'; SetLastError(0xdeadbeef); - res = PathAppendA(one, two); + res = PathAppendA(path, half); ok(!res, "Expected failure\n"); - ok(lstrlen(one) == 0 || - broken(lstrlen(one) == (HALF_LEN - 1)), /* Win95 and some W2K */ - "Expected length of one to be zero, got %i\n", lstrlen(one)); + ok(lstrlen(path) == 0 || + broken(lstrlen(path) == (HALF_LEN - 1)), /* Win95 and some W2K */ + "Expected length of path to be zero, got %i\n", lstrlen(path)); ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError()); } @@ -1307,6 +1317,8 @@ static void test_PathUnquoteSpaces(void) START_TEST(path) { hShlwapi = GetModuleHandleA("shlwapi.dll"); + pPathCreateFromUrlA = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlA"); + pPathCreateFromUrlW = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlW"); test_PathSearchAndQualify(); test_PathCreateFromUrl(); diff --git a/rostests/winetests/shlwapi/shreg.c b/rostests/winetests/shlwapi/shreg.c index 00cec4fc30c..5fb3dacf14f 100755 --- a/rostests/winetests/shlwapi/shreg.c +++ b/rostests/winetests/shlwapi/shreg.c @@ -38,6 +38,8 @@ typedef DWORD (WINAPI *SHCopyKeyA_func)(HKEY,LPCSTR,HKEY,DWORD); static SHCopyKeyA_func pSHCopyKeyA; typedef DWORD (WINAPI *SHRegGetPathA_func)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD); static SHRegGetPathA_func pSHRegGetPathA; +typedef LSTATUS (WINAPI *SHRegGetValueA_func)(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD); +static SHRegGetValueA_func pSHRegGetValueA; static char sTestpath1[] = "%LONGSYSTEMVAR%\\subdir1"; static char sTestpath2[] = "%FOO%\\subdir1"; @@ -138,6 +140,44 @@ static void test_SHGetValue(void) ok( REG_SZ == dwType , "Expected REG_SZ, got (%u)\n", dwType); } +static void test_SHRegGetValue(void) +{ + LSTATUS ret; + DWORD size, type; + char data[MAX_PATH]; + + if(!pSHRegGetValueA) + return; + + size = MAX_PATH; + ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_EXPAND_SZ, &type, data, &size); + ok(ret == ERROR_INVALID_PARAMETER, "SHRegGetValue failed, ret=%u\n", ret); + + size = MAX_PATH; + ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_SZ, &type, data, &size); + ok(ret == ERROR_SUCCESS, "SHRegGetValue failed, ret=%u\n", ret); + ok(!strcmp(data, sExpTestpath1), "data = %s, expected %s\n", data, sExpTestpath1); + ok(type == REG_SZ, "type = %d, expected REG_SZ\n", type); + + size = MAX_PATH; + ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_DWORD, &type, data, &size); + ok(ret == ERROR_UNSUPPORTED_TYPE, "SHRegGetValue failed, ret=%u\n", ret); + + size = MAX_PATH; + ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_EXPAND_SZ, &type, data, &size); + ok(ret == ERROR_INVALID_PARAMETER, "SHRegGetValue failed, ret=%u\n", ret); + + size = MAX_PATH; + ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_SZ, &type, data, &size); + ok(ret == ERROR_SUCCESS, "SHRegGetValue failed, ret=%u\n", ret); + ok(!strcmp(data, sTestpath1), "data = %s, expected %s\n", data, sTestpath1); + ok(type == REG_SZ, "type = %d, expected REG_SZ\n", type); + + size = MAX_PATH; + ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_QWORD, &type, data, &size); + ok(ret == ERROR_UNSUPPORTED_TYPE, "SHRegGetValue failed, ret=%u\n", ret); +} + static void test_SHGetRegPath(void) { char buf[MAX_PATH]; @@ -414,7 +454,9 @@ START_TEST(shreg) hshlwapi = GetModuleHandleA("shlwapi.dll"); pSHCopyKeyA=(SHCopyKeyA_func)GetProcAddress(hshlwapi,"SHCopyKeyA"); pSHRegGetPathA=(SHRegGetPathA_func)GetProcAddress(hshlwapi,"SHRegGetPathA"); + pSHRegGetValueA=(SHRegGetValueA_func)GetProcAddress(hshlwapi,"SHRegGetValueA"); test_SHGetValue(); + test_SHRegGetValue(); test_SHQUeryValueEx(); test_SHGetRegPath(); test_SHCopyKey(); diff --git a/rostests/winetests/shlwapi/string.c b/rostests/winetests/shlwapi/string.c index fa50626f9a1..00f0b023046 100755 --- a/rostests/winetests/shlwapi/string.c +++ b/rostests/winetests/shlwapi/string.c @@ -40,6 +40,8 @@ ok(ret == val1 || ret == val2, "Unexpected value of '" #expr "': " #fmt " instead of " #val1 " or " #val2 "\n", ret); \ } while (0); +static BOOL (WINAPI *pChrCmpIA)(CHAR, CHAR); +static BOOL (WINAPI *pChrCmpIW)(WCHAR, WCHAR); static BOOL (WINAPI *pIntlStrEqWorkerA)(BOOL,LPCSTR,LPCSTR,int); static BOOL (WINAPI *pIntlStrEqWorkerW)(BOOL,LPCWSTR,LPCWSTR,int); static DWORD (WINAPI *pSHAnsiToAnsi)(LPCSTR,LPSTR,int); @@ -58,6 +60,7 @@ static HRESULT (WINAPI *pStrRetToBufA)(STRRET*,LPCITEMIDLIST,LPSTR,UINT); static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT); static INT (WINAPIV *pwnsprintfA)(LPSTR,INT,LPCSTR, ...); static INT (WINAPIV *pwnsprintfW)(LPWSTR,INT,LPCWSTR, ...); +static LPWSTR (WINAPI *pStrChrNW)(LPWSTR,WCHAR,UINT); static int strcmpW(const WCHAR *str1, const WCHAR *str2) { @@ -373,6 +376,27 @@ static void test_StrCpyW(void) } } +static void test_StrChrNW(void) +{ + static WCHAR string[] = {'T','e','s','t','i','n','g',' ','S','t','r','i','n','g',0}; + LPWSTR p; + + if (!pStrChrNW) + { + win_skip("StrChrNW not available\n"); + return; + } + + p = pStrChrNW(string,'t',10); + ok(*p=='t',"Found wrong 't'\n"); + ok(*(p+1)=='i',"next should be 'i'\n"); + + p = pStrChrNW(string,'S',10); + ok(*p=='S',"Found wrong 'S'\n"); + + p = pStrChrNW(string,'r',10); + ok(p==NULL,"Should not have found 'r'\n"); +} static void test_StrToIntA(void) { @@ -586,9 +610,13 @@ static void test_StrCmpA(void) static const char str2[] = {'a','B','c','d','e','f'}; ok(0 != StrCmpNA(str1, str2, 6), "StrCmpNA is case-insensitive\n"); ok(0 == StrCmpNIA(str1, str2, 6), "StrCmpNIA is case-sensitive\n"); - ok(!ChrCmpIA('a', 'a'), "ChrCmpIA doesn't work at all!\n"); - ok(!ChrCmpIA('b', 'B'), "ChrCmpIA is not case-insensitive\n"); - ok(ChrCmpIA('a', 'z'), "ChrCmpIA believes that a == z!\n"); + if (pChrCmpIA) { + ok(!pChrCmpIA('a', 'a'), "ChrCmpIA doesn't work at all!\n"); + ok(!pChrCmpIA('b', 'B'), "ChrCmpIA is not case-insensitive\n"); + ok(pChrCmpIA('a', 'z'), "ChrCmpIA believes that a == z!\n"); + } + else + win_skip("ChrCmpIA() is not available\n"); if (pStrIsIntlEqualA) { @@ -613,9 +641,13 @@ static void test_StrCmpW(void) static const WCHAR str2[] = {'a','B','c','d','e','f'}; ok(0 != StrCmpNW(str1, str2, 5), "StrCmpNW is case-insensitive\n"); ok(0 == StrCmpNIW(str1, str2, 5), "StrCmpNIW is case-sensitive\n"); - ok(!ChrCmpIW('a', 'a'), "ChrCmpIW doesn't work at all!\n"); - ok(!ChrCmpIW('b', 'B'), "ChrCmpIW is not case-insensitive\n"); - ok(ChrCmpIW('a', 'z'), "ChrCmpIW believes that a == z!\n"); + if (pChrCmpIW) { + ok(!pChrCmpIW('a', 'a'), "ChrCmpIW doesn't work at all!\n"); + ok(!pChrCmpIW('b', 'B'), "ChrCmpIW is not case-insensitive\n"); + ok(pChrCmpIW('a', 'z'), "ChrCmpIW believes that a == z!\n"); + } + else + win_skip("ChrCmpIW() is not available\n"); if (pStrIsIntlEqualW) { @@ -903,6 +935,8 @@ START_TEST(string) GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimalDelim, 8); hShlwapi = GetModuleHandleA("shlwapi"); + pChrCmpIA = (void *)GetProcAddress(hShlwapi, "ChrCmpIA"); + pChrCmpIW = (void *)GetProcAddress(hShlwapi, "ChrCmpIW"); pIntlStrEqWorkerA = (void *)GetProcAddress(hShlwapi, "IntlStrEqWorkerA"); pIntlStrEqWorkerW = (void *)GetProcAddress(hShlwapi, "IntlStrEqWorkerW"); pSHAnsiToAnsi = (void *)GetProcAddress(hShlwapi, (LPSTR)345); @@ -911,6 +945,7 @@ START_TEST(string) pStrCatBuffW = (void *)GetProcAddress(hShlwapi, "StrCatBuffW"); pStrCpyNXA = (void *)GetProcAddress(hShlwapi, (LPSTR)399); pStrCpyNXW = (void *)GetProcAddress(hShlwapi, (LPSTR)400); + pStrChrNW = (void *)GetProcAddress(hShlwapi, "StrChrNW"); pStrFormatByteSize64A = (void *)GetProcAddress(hShlwapi, "StrFormatByteSize64A"); pStrFormatKBSizeA = (void *)GetProcAddress(hShlwapi, "StrFormatKBSizeA"); pStrFormatKBSizeW = (void *)GetProcAddress(hShlwapi, "StrFormatKBSizeW"); @@ -929,6 +964,7 @@ START_TEST(string) test_StrRChrA(); test_StrRChrW(); test_StrCpyW(); + test_StrChrNW(); test_StrToIntA(); test_StrToIntW(); test_StrToIntExA(); diff --git a/rostests/winetests/shlwapi/url.c b/rostests/winetests/shlwapi/url.c index f135f2a1e19..3d86ae7c5e1 100644 --- a/rostests/winetests/shlwapi/url.c +++ b/rostests/winetests/shlwapi/url.c @@ -1,7 +1,7 @@ /* Unit test suite for Path functions * * Copyright 2002 Matthew Mastracci - * Copyright 2007,2008 Detlef Riekenberg + * Copyright 2007-2010 Detlef Riekenberg * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,10 +27,31 @@ #include "winreg.h" #include "shlwapi.h" #include "wininet.h" +#include "intshcut.h" /* ################ */ static HMODULE hShlwapi; +static HRESULT (WINAPI *pUrlUnescapeA)(LPSTR,LPSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pUrlUnescapeW)(LPWSTR,LPWSTR,LPDWORD,DWORD); +static BOOL (WINAPI *pUrlIsA)(LPCSTR,URLIS); +static BOOL (WINAPI *pUrlIsW)(LPCWSTR,URLIS); +static HRESULT (WINAPI *pUrlHashA)(LPCSTR,LPBYTE,DWORD); +static HRESULT (WINAPI *pUrlHashW)(LPCWSTR,LPBYTE,DWORD); +static HRESULT (WINAPI *pUrlGetPartA)(LPCSTR,LPSTR,LPDWORD,DWORD,DWORD); +static HRESULT (WINAPI *pUrlGetPartW)(LPCWSTR,LPWSTR,LPDWORD,DWORD,DWORD); +static HRESULT (WINAPI *pUrlEscapeA)(LPCSTR,LPSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pUrlEscapeW)(LPCWSTR,LPWSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pUrlCreateFromPathA)(LPCSTR,LPSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pUrlCreateFromPathW)(LPCWSTR,LPWSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pUrlCombineA)(LPCSTR,LPCSTR,LPSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pUrlCombineW)(LPCWSTR,LPCWSTR,LPWSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pUrlCanonicalizeA)(LPCSTR, LPSTR, LPDWORD, DWORD); static HRESULT (WINAPI *pUrlCanonicalizeW)(LPCWSTR, LPWSTR, LPDWORD, DWORD); +static HRESULT (WINAPI *pUrlApplySchemeA)(LPCSTR,LPSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pUrlApplySchemeW)(LPCWSTR,LPWSTR,LPDWORD,DWORD); +static HRESULT (WINAPI *pParseURLA)(LPCSTR,PARSEDURLA*); +static HRESULT (WINAPI *pParseURLW)(LPCWSTR,PARSEDURLW*); +static HRESULT (WINAPI *pHashData)(LPBYTE, DWORD, LPBYTE, DWORD); static const char* TEST_URL_1 = "http://www.winehq.org/tests?date=10/10/1923"; static const char* TEST_URL_2 = "http://localhost:8080/tests%2e.html?date=Mon%2010/10/1923"; @@ -120,18 +141,24 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = { {"c:dir\\file", 0, S_OK, "file:///c:dir/file", FALSE}, {"c:\\tests\\foo bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE}, {"c:\\tests\\foo bar", 0, S_OK, "file:///c:/tests/foo%20bar", FALSE}, + {"res://file", 0, S_OK, "res://file/", FALSE}, + {"res://file", URL_FILE_USE_PATHURL, S_OK, "res://file/", FALSE}, {"res:///c:/tests/foo%20bar", URL_UNESCAPE , S_OK, "res:///c:/tests/foo bar", FALSE}, - {"res:///c:/tests\\foo%20bar", URL_UNESCAPE , S_OK, "res:///c:/tests\\foo bar", TRUE}, + {"res:///c:/tests\\foo%20bar", URL_UNESCAPE , S_OK, "res:///c:/tests\\foo bar", FALSE}, {"res:///c:/tests/foo%20bar", 0, S_OK, "res:///c:/tests/foo%20bar", FALSE}, - {"res:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res:///c:/tests/foo%20bar", TRUE}, - {"res://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", TRUE}, - {"res://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", TRUE}, - {"res://c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", TRUE}, - {"res:///c://tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res:///c://tests/foo%20bar", TRUE}, - {"res:///c:\\tests\\foo bar", 0, S_OK, "res:///c:\\tests\\foo bar", TRUE}, - {"res:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "res:///c:\\tests\\foo bar", TRUE}, + {"res:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res:///c:/tests/foo%20bar", FALSE}, + {"res://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", FALSE}, + {"res://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", FALSE}, + {"res://c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", FALSE}, + {"res:///c://tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res:///c://tests/foo%20bar", FALSE}, + {"res:///c:\\tests\\foo bar", 0, S_OK, "res:///c:\\tests\\foo bar", FALSE}, + {"res:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "res:///c:\\tests\\foo bar", FALSE}, + {"res://c:\\tests\\foo bar/res", URL_FILE_USE_PATHURL, S_OK, "res://c:\\tests\\foo bar/res", FALSE}, + {"res://c:\\tests/res\\foo%20bar/strange\\sth", 0, S_OK, "res://c:\\tests/res\\foo%20bar/strange\\sth", FALSE}, + {"res://c:\\tests/res\\foo%20bar/strange\\sth", URL_FILE_USE_PATHURL, S_OK, "res://c:\\tests/res\\foo%20bar/strange\\sth", FALSE}, + {"res://c:\\tests/res\\foo%20bar/strange\\sth", URL_UNESCAPE, S_OK, "res://c:\\tests/res\\foo bar/strange\\sth", FALSE}, {"A", 0, S_OK, "A", FALSE}, - {"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/, S_OK, "/uri-res/N2R?urn:sha1:B3K", TRUE} /*LimeWire online installer calls this*/, + {"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/, S_OK, "/uri-res/N2R?urn:sha1:B3K", FALSE} /*LimeWire online installer calls this*/, {"http:www.winehq.org/dir/../index.html", 0, S_OK, "http:www.winehq.org/index.html"}, }; @@ -284,7 +311,8 @@ static const TEST_URL_COMBINE TEST_COMBINE[] = { {"http://xxxxxxxxx","outbind:wine17/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"outbind:wine17/dir"}, {"xxx://xxxxxxxxx","ftp:wine18/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"ftp:wine18/dir"}, {"ftp://xxxxxxxxx/","xxx:wine19/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"xxx:wine19/dir"}, - {"outbind://xxxxxxxxx/","http:wine20/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http:wine20/dir"} + {"outbind://xxxxxxxxx/","http:wine20/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http:wine20/dir"}, + {"file:///c:/dir/file.txt","index.html?test=c:/abc",URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,S_OK,"file:///c:/dir/index.html?test=c:/abc"} }; /* ################ */ @@ -397,10 +425,15 @@ static void test_UrlApplyScheme(void) DWORD len; DWORD i; + if (!pUrlApplySchemeA) { + win_skip("UrlApplySchemeA not found\n"); + return; + } + for(i = 0; i < sizeof(TEST_APPLY)/sizeof(TEST_APPLY[0]); i++) { len = TEST_APPLY_MAX_LENGTH; lstrcpyA(newurl, untouchedA); - res = UrlApplySchemeA(TEST_APPLY[i].url, newurl, &len, TEST_APPLY[i].flags); + res = pUrlApplySchemeA(TEST_APPLY[i].url, newurl, &len, TEST_APPLY[i].flags); ok( res == TEST_APPLY[i].res, "#%dA: got HRESULT 0x%x (expected 0x%x)\n", i, res, TEST_APPLY[i].res); @@ -416,7 +449,7 @@ static void test_UrlApplyScheme(void) MultiByteToWideChar(CP_ACP, 0, newurl, -1, newurlW, len); MultiByteToWideChar(CP_ACP, 0, TEST_APPLY[i].url, -1, urlW, len); - res = UrlApplySchemeW(urlW, newurlW, &len, TEST_APPLY[i].flags); + res = pUrlApplySchemeW(urlW, newurlW, &len, TEST_APPLY[i].flags); WideCharToMultiByte(CP_ACP, 0, newurlW, -1, newurl, TEST_APPLY_MAX_LENGTH, NULL, NULL); ok( res == TEST_APPLY[i].res, "#%dW: got HRESULT 0x%x (expected 0x%x)\n", i, res, TEST_APPLY[i].res); @@ -432,7 +465,7 @@ static void test_UrlApplyScheme(void) /* buffer too small */ lstrcpyA(newurl, untouchedA); len = lstrlenA(TEST_APPLY[0].newurl); - res = UrlApplySchemeA(TEST_APPLY[0].url, newurl, &len, TEST_APPLY[0].flags); + res = pUrlApplySchemeA(TEST_APPLY[0].url, newurl, &len, TEST_APPLY[0].flags); ok(res == E_POINTER, "got HRESULT 0x%x (expected E_POINTER)\n", res); /* The returned length include the space for the terminating 0 */ i = lstrlenA(TEST_APPLY[0].newurl)+1; @@ -442,18 +475,18 @@ static void test_UrlApplyScheme(void) /* NULL as parameter. The length and the buffer are not modified */ lstrcpyA(newurl, untouchedA); len = TEST_APPLY_MAX_LENGTH; - res = UrlApplySchemeA(NULL, newurl, &len, TEST_APPLY[0].flags); + res = pUrlApplySchemeA(NULL, newurl, &len, TEST_APPLY[0].flags); ok(res == E_INVALIDARG, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res); ok(len == TEST_APPLY_MAX_LENGTH, "got len %d\n", len); ok(!lstrcmpA(newurl, untouchedA), "got '%s' (expected '%s')\n", newurl, untouchedA); len = TEST_APPLY_MAX_LENGTH; - res = UrlApplySchemeA(TEST_APPLY[0].url, NULL, &len, TEST_APPLY[0].flags); + res = pUrlApplySchemeA(TEST_APPLY[0].url, NULL, &len, TEST_APPLY[0].flags); ok(res == E_INVALIDARG, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res); ok(len == TEST_APPLY_MAX_LENGTH, "got len %d\n", len); lstrcpyA(newurl, untouchedA); - res = UrlApplySchemeA(TEST_APPLY[0].url, newurl, NULL, TEST_APPLY[0].flags); + res = pUrlApplySchemeA(TEST_APPLY[0].url, newurl, NULL, TEST_APPLY[0].flags); ok(res == E_INVALIDARG, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res); ok(!lstrcmpA(newurl, untouchedA), "got '%s' (expected '%s')\n", newurl, untouchedA); @@ -465,19 +498,29 @@ static void hash_url(const char* szUrl) { LPCSTR szTestUrl = szUrl; LPWSTR wszTestUrl = GetWideString(szTestUrl); + HRESULT res; DWORD cbSize = sizeof(DWORD); DWORD dwHash1, dwHash2; - ok(UrlHashA(szTestUrl, (LPBYTE)&dwHash1, cbSize) == S_OK, "UrlHashA didn't return S_OK\n"); - ok(UrlHashW(wszTestUrl, (LPBYTE)&dwHash2, cbSize) == S_OK, "UrlHashW didn't return S_OK\n"); - + res = pUrlHashA(szTestUrl, (LPBYTE)&dwHash1, cbSize); + ok(res == S_OK, "UrlHashA returned 0x%x (expected S_OK) for %s\n", res, szUrl); + if (pUrlHashW) { + res = pUrlHashW(wszTestUrl, (LPBYTE)&dwHash2, cbSize); + ok(res == S_OK, "UrlHashW returned 0x%x (expected S_OK) for %s\n", res, szUrl); + ok(dwHash1 == dwHash2, + "Hashes didn't match (A: 0x%x, W: 0x%x) for %s\n", dwHash1, dwHash2, szUrl); + } FreeWideString(wszTestUrl); - ok(dwHash1 == dwHash2, "Hashes didn't compare\n"); } static void test_UrlHash(void) { + if (!pUrlHashA) { + win_skip("UrlHashA not found\n"); + return; + } + hash_url(TEST_URL_1); hash_url(TEST_URL_2); hash_url(TEST_URL_3); @@ -491,20 +534,29 @@ static void test_url_part(const char* szUrl, DWORD dwPart, DWORD dwFlags, const WCHAR wszPart[INTERNET_MAX_URL_LENGTH]; LPWSTR wszUrl = GetWideString(szUrl); LPWSTR wszConvertedPart; - + HRESULT res; DWORD dwSize; dwSize = INTERNET_MAX_URL_LENGTH; - ok( UrlGetPartA(szUrl, szPart, &dwSize, dwPart, dwFlags) == S_OK, "UrlGetPartA for \"%s\" part 0x%08x didn't return S_OK but \"%s\"\n", szUrl, dwPart, szPart); - dwSize = INTERNET_MAX_URL_LENGTH; - ok( UrlGetPartW(wszUrl, wszPart, &dwSize, dwPart, dwFlags) == S_OK, "UrlGetPartW didn't return S_OK\n" ); + res = pUrlGetPartA(szUrl, szPart, &dwSize, dwPart, dwFlags); + ok(res == S_OK, + "UrlGetPartA for \"%s\" part 0x%08x returned 0x%x and \"%s\"\n", + szUrl, dwPart, res, szPart); + if (pUrlGetPartW) { + dwSize = INTERNET_MAX_URL_LENGTH; + res = pUrlGetPartW(wszUrl, wszPart, &dwSize, dwPart, dwFlags); + ok(res == S_OK, + "UrlGetPartW for \"%s\" part 0x%08x returned 0x%x\n", + szUrl, dwPart, res); - wszConvertedPart = GetWideString(szPart); + wszConvertedPart = GetWideString(szPart); - ok(lstrcmpW(wszPart,wszConvertedPart)==0, "Strings didn't match between ascii and unicode UrlGetPart!\n"); + ok(lstrcmpW(wszPart,wszConvertedPart)==0, + "Strings didn't match between ascii and unicode UrlGetPart!\n"); + FreeWideString(wszConvertedPart); + } FreeWideString(wszUrl); - FreeWideString(wszConvertedPart); /* Note that v6.0 and later don't return '?' with the query */ ok(strcmp(szPart,szExpected)==0 || @@ -516,20 +568,29 @@ static void test_url_part(const char* szUrl, DWORD dwPart, DWORD dwFlags, const static void test_UrlGetPart(void) { + const char* file_url = "file://h o s t/c:/windows/file"; + const char* http_url = "http://user:pass 123@www.wine hq.org"; + const char* about_url = "about:blank"; + CHAR szPart[INTERNET_MAX_URL_LENGTH]; DWORD dwSize; HRESULT res; + if (!pUrlGetPartA) { + win_skip("UrlGetPartA not found\n"); + return; + } + dwSize = sizeof szPart; szPart[0]='x'; szPart[1]=0; - res = UrlGetPartA("hi", szPart, &dwSize, URL_PART_SCHEME, 0); + res = pUrlGetPartA("hi", szPart, &dwSize, URL_PART_SCHEME, 0); todo_wine { ok (res==S_FALSE, "UrlGetPartA(\"hi\") returned %08X\n", res); ok(szPart[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart); } dwSize = sizeof szPart; szPart[0]='x'; szPart[1]=0; - res = UrlGetPartA("hi", szPart, &dwSize, URL_PART_QUERY, 0); + res = pUrlGetPartA("hi", szPart, &dwSize, URL_PART_QUERY, 0); todo_wine { ok (res==S_FALSE, "UrlGetPartA(\"hi\") returned %08X\n", res); ok(szPart[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart); @@ -541,6 +602,28 @@ static void test_UrlGetPart(void) test_url_part(TEST_URL_3, URL_PART_PASSWORD, 0, "bar"); test_url_part(TEST_URL_3, URL_PART_SCHEME, 0, "http"); test_url_part(TEST_URL_3, URL_PART_QUERY, 0, "?query=x&return=y"); + + test_url_part(file_url, URL_PART_HOSTNAME, 0, "h o s t"); + + test_url_part(http_url, URL_PART_HOSTNAME, 0, "www.wine hq.org"); + test_url_part(http_url, URL_PART_PASSWORD, 0, "pass 123"); + + test_url_part(about_url, URL_PART_SCHEME, 0, "about"); + + dwSize = sizeof(szPart); + res = pUrlGetPartA(about_url, szPart, &dwSize, URL_PART_HOSTNAME, 0); + ok(res==E_FAIL, "returned %08x\n", res); + + dwSize = sizeof(szPart); + res = pUrlGetPartA("file://c:\\index.htm", szPart, &dwSize, URL_PART_HOSTNAME, 0); + ok(res==S_FALSE, "returned %08x\n", res); + + dwSize = sizeof(szPart); + szPart[0] = 'x'; szPart[1] = '\0'; + res = pUrlGetPartA("file:some text", szPart, &dwSize, URL_PART_HOSTNAME, 0); + ok(res==S_FALSE, "returned %08x\n", res); + ok(szPart[0] == '\0', "szPart[0] = %c\n", szPart[0]); + ok(dwSize == 0, "dwSize = %d\n", dwSize); } /* ########################### */ @@ -553,18 +636,23 @@ static void test_url_escape(const char *szUrl, DWORD dwFlags, HRESULT dwExpectRe WCHAR *urlW, *expected_urlW; dwEscaped=INTERNET_MAX_URL_LENGTH; - ok(UrlEscapeA(szUrl, szReturnUrl, &dwEscaped, dwFlags) == dwExpectReturn, "UrlEscapeA didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl); + ok(pUrlEscapeA(szUrl, szReturnUrl, &dwEscaped, dwFlags) == dwExpectReturn, + "UrlEscapeA didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl); ok(strcmp(szReturnUrl,szExpectUrl)==0, "Expected \"%s\", but got \"%s\" from \"%s\"\n", szExpectUrl, szReturnUrl, szUrl); - dwEscaped = INTERNET_MAX_URL_LENGTH; - urlW = GetWideString(szUrl); - expected_urlW = GetWideString(szExpectUrl); - ok(UrlEscapeW(urlW, ret_urlW, &dwEscaped, dwFlags) == dwExpectReturn, "UrlEscapeW didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl); - WideCharToMultiByte(CP_ACP,0,ret_urlW,-1,szReturnUrl,INTERNET_MAX_URL_LENGTH,0,0); - ok(lstrcmpW(ret_urlW, expected_urlW)==0, "Expected \"%s\", but got \"%s\" from \"%s\" flags %08x\n", szExpectUrl, szReturnUrl, szUrl, dwFlags); - FreeWideString(urlW); - FreeWideString(expected_urlW); - + if (pUrlEscapeW) { + dwEscaped = INTERNET_MAX_URL_LENGTH; + urlW = GetWideString(szUrl); + expected_urlW = GetWideString(szExpectUrl); + ok(pUrlEscapeW(urlW, ret_urlW, &dwEscaped, dwFlags) == dwExpectReturn, + "UrlEscapeW didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl); + WideCharToMultiByte(CP_ACP,0,ret_urlW,-1,szReturnUrl,INTERNET_MAX_URL_LENGTH,0,0); + ok(lstrcmpW(ret_urlW, expected_urlW)==0, + "Expected \"%s\", but got \"%s\" from \"%s\" flags %08x\n", + szExpectUrl, szReturnUrl, szUrl, dwFlags); + FreeWideString(urlW); + FreeWideString(expected_urlW); + } } static void test_url_canonicalize(int index, const char *szUrl, DWORD dwFlags, HRESULT dwExpectReturn, HRESULT dwExpectReturnAlt, const char *szExpectUrl, BOOL todo) @@ -579,8 +667,9 @@ static void test_url_canonicalize(int index, const char *szUrl, DWORD dwFlags, H DWORD dwSize; dwSize = INTERNET_MAX_URL_LENGTH; - ok(UrlCanonicalizeA(szUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer, index %d\n", index); - ret = UrlCanonicalizeA(szUrl, szReturnUrl, &dwSize, dwFlags); + ret = pUrlCanonicalizeA(szUrl, NULL, &dwSize, dwFlags); + ok(ret != dwExpectReturn, "got 0s%x: Unexpected return for NULL buffer, index %d\n", ret, index); + ret = pUrlCanonicalizeA(szUrl, szReturnUrl, &dwSize, dwFlags); ok(ret == dwExpectReturn || ret == dwExpectReturnAlt, "UrlCanonicalizeA failed: expected=0x%08x or 0x%08x, got=0x%08x, index %d\n", dwExpectReturn, dwExpectReturnAlt, ret, index); @@ -590,13 +679,19 @@ static void test_url_canonicalize(int index, const char *szUrl, DWORD dwFlags, H else ok(strcmp(szReturnUrl,szExpectUrl)==0, "UrlCanonicalizeA dwFlags 0x%08x url '%s' Expected \"%s\", but got \"%s\", index %d\n", dwFlags, szUrl, szExpectUrl, szReturnUrl, index); - dwSize = INTERNET_MAX_URL_LENGTH; - ok(UrlCanonicalizeW(wszUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer, index %d\n", index); - ok(UrlCanonicalizeW(wszUrl, wszReturnUrl, &dwSize, dwFlags) == dwExpectReturn, "UrlCanonicalizeW didn't return 0x%08x, index %d\n", dwExpectReturn, index); - wszConvertedUrl = GetWideString(szReturnUrl); - ok(lstrcmpW(wszReturnUrl, wszConvertedUrl)==0, "Strings didn't match between ascii and unicode UrlCanonicalize, index %d!\n", index); - FreeWideString(wszConvertedUrl); + if (pUrlCanonicalizeW) { + dwSize = INTERNET_MAX_URL_LENGTH; + ret = pUrlCanonicalizeW(wszUrl, NULL, &dwSize, dwFlags); + ok(ret != dwExpectReturn, "got 0x%x: Unexpected return for NULL buffer, index %d\n", ret, index); + ret = pUrlCanonicalizeW(wszUrl, wszReturnUrl, &dwSize, dwFlags); + ok(ret == dwExpectReturn, "UrlCanonicalizeW failed: expected 0x%08x, got 0x%x, index %d\n", + dwExpectReturn, ret, index); + wszConvertedUrl = GetWideString(szReturnUrl); + ok(lstrcmpW(wszReturnUrl, wszConvertedUrl)==0, + "Strings didn't match between ascii and unicode UrlCanonicalize, index %d!\n", index); + FreeWideString(wszConvertedUrl); + } FreeWideString(wszUrl); FreeWideString(wszExpectUrl); @@ -610,27 +705,32 @@ static void test_UrlEscape(void) unsigned int i; char empty_string[] = ""; - ret = UrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY); + if (!pUrlEscapeA) { + win_skip("UrlEscapeA noz found\n"); + return; + } + + ret = pUrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY); ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG); ok(size == 0, "got %d, expected %d\n", size, 0); size = 0; - ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY); + ret = pUrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY); ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG); ok(size == 0, "got %d, expected %d\n", size, 0); size = 1; - ret = UrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY); + ret = pUrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY); ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG); ok(size == 1, "got %d, expected %d\n", size, 1); size = 1; - ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, NULL, URL_ESCAPE_SPACES_ONLY); + ret = pUrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, NULL, URL_ESCAPE_SPACES_ONLY); ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG); ok(size == 1, "got %d, expected %d\n", size, 1); size = 1; - ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY); + ret = pUrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY); ok(ret == E_POINTER, "got %x, expected %x\n", ret, E_POINTER); ok(size == 34, "got %d, expected %d\n", size, 34); @@ -650,6 +750,11 @@ static void test_UrlCanonicalizeA(void) DWORD urllen; HRESULT hr; + if (!pUrlCanonicalizeA) { + win_skip("UrlCanonicalizeA not found\n"); + return; + } + urllen = lstrlenA(winehqA); /* buffer has no space for the result */ @@ -657,7 +762,7 @@ static void test_UrlCanonicalizeA(void) memset(szReturnUrl, '#', urllen+4); szReturnUrl[urllen+4] = '\0'; SetLastError(0xdeadbeef); - hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE); + hr = pUrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE); ok( (hr == E_POINTER) && (dwSize == (urllen + 1)), "got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)\n", hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen+1); @@ -667,7 +772,7 @@ static void test_UrlCanonicalizeA(void) memset(szReturnUrl, '#', urllen+4); szReturnUrl[urllen+4] = '\0'; SetLastError(0xdeadbeef); - hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE); + hr = pUrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE); ok( (hr == E_POINTER) && (dwSize == (urllen + 1)), "got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)\n", hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen+1); @@ -677,7 +782,7 @@ static void test_UrlCanonicalizeA(void) memset(szReturnUrl, '#', urllen+4); szReturnUrl[urllen+4] = '\0'; SetLastError(0xdeadbeef); - hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE); + hr = pUrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE); ok( (hr == S_OK) && (dwSize == urllen), "got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)\n", hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen); @@ -687,7 +792,7 @@ static void test_UrlCanonicalizeA(void) memset(szReturnUrl, '#', urllen+4); szReturnUrl[urllen+4] = '\0'; SetLastError(0xdeadbeef); - hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE); + hr = pUrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE); ok( (hr == S_OK) && (dwSize == urllen), "got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)\n", hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen); @@ -714,7 +819,7 @@ static void test_UrlCanonicalizeW(void) if (!pUrlCanonicalizeW) { - skip("UrlCanonicalizeW\n"); + win_skip("UrlCanonicalizeW not found\n"); return; } urllen = lstrlenW(winehqW); @@ -792,43 +897,50 @@ static void test_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFla DWORD dwSize; DWORD dwExpectLen = lstrlen(szExpectUrl); - hr = UrlCombineA(szUrl1, szUrl2, NULL, NULL, dwFlags); + if (!pUrlCombineA) { + win_skip("UrlCombineA not found\n"); + return; + } + + hr = pUrlCombineA(szUrl1, szUrl2, NULL, NULL, dwFlags); ok(hr == E_INVALIDARG, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG); dwSize = 0; - hr = UrlCombineA(szUrl1, szUrl2, NULL, &dwSize, dwFlags); + hr = pUrlCombineA(szUrl1, szUrl2, NULL, &dwSize, dwFlags); ok(hr == E_POINTER, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr, E_POINTER); ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1); dwSize--; - hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags); + hr = pUrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags); ok(hr == E_POINTER, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_POINTER); ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1); - hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags); + hr = pUrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags); ok(hr == dwExpectReturn, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, dwExpectReturn); ok(dwSize == dwExpectLen, "Got length %d, expected %d\n", dwSize, dwExpectLen); if(SUCCEEDED(hr)) { ok(strcmp(szReturnUrl,szExpectUrl)==0, "Expected %s, but got %s\n", szExpectUrl, szReturnUrl); } - dwSize = 0; - hr = UrlCombineW(wszUrl1, wszUrl2, NULL, &dwSize, dwFlags); - ok(hr == E_POINTER, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr, E_POINTER); - ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1); + if (pUrlCombineW) { + dwSize = 0; + hr = pUrlCombineW(wszUrl1, wszUrl2, NULL, &dwSize, dwFlags); + ok(hr == E_POINTER, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr, E_POINTER); + ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1); - dwSize--; - hr = UrlCombineW(wszUrl1, wszUrl2, wszReturnUrl, &dwSize, dwFlags); - ok(hr == E_POINTER, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_POINTER); - ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1); + dwSize--; + hr = pUrlCombineW(wszUrl1, wszUrl2, wszReturnUrl, &dwSize, dwFlags); + ok(hr == E_POINTER, "UrlCombineW returned 0x%08x, expected 0x%08x\n", hr, E_POINTER); + ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1); - hr = UrlCombineW(wszUrl1, wszUrl2, wszReturnUrl, &dwSize, dwFlags); - ok(hr == dwExpectReturn, "UrlCombineW returned 0x%08x, expected 0x%08x\n", hr, dwExpectReturn); - ok(dwSize == dwExpectLen, "Got length %d, expected %d\n", dwSize, dwExpectLen); - if(SUCCEEDED(hr)) { - wszConvertedUrl = GetWideString(szReturnUrl); - ok(lstrcmpW(wszReturnUrl, wszConvertedUrl)==0, "Strings didn't match between ascii and unicode UrlCombine!\n"); - FreeWideString(wszConvertedUrl); + hr = pUrlCombineW(wszUrl1, wszUrl2, wszReturnUrl, &dwSize, dwFlags); + ok(hr == dwExpectReturn, "UrlCombineW returned 0x%08x, expected 0x%08x\n", hr, dwExpectReturn); + ok(dwSize == dwExpectLen, "Got length %d, expected %d\n", dwSize, dwExpectLen); + if(SUCCEEDED(hr)) { + wszConvertedUrl = GetWideString(szReturnUrl); + ok(lstrcmpW(wszReturnUrl, wszConvertedUrl)==0, "Strings didn't match between ascii and unicode UrlCombine!\n"); + FreeWideString(wszConvertedUrl); + } } FreeWideString(wszUrl1); @@ -857,24 +969,32 @@ static void test_UrlCreateFromPath(void) WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH]; WCHAR *pathW, *urlW; + if (!pUrlCreateFromPathA) { + win_skip("UrlCreateFromPathA not found\n"); + return; + } + for(i = 0; i < sizeof(TEST_URLFROMPATH) / sizeof(TEST_URLFROMPATH[0]); i++) { len = INTERNET_MAX_URL_LENGTH; - ret = UrlCreateFromPathA(TEST_URLFROMPATH[i].path, ret_url, &len, 0); + ret = pUrlCreateFromPathA(TEST_URLFROMPATH[i].path, ret_url, &len, 0); ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path %s\n", ret, TEST_URLFROMPATH[i].path); ok(!lstrcmpi(ret_url, TEST_URLFROMPATH[i].url), "url %s from path %s\n", ret_url, TEST_URLFROMPATH[i].path); ok(len == strlen(ret_url), "ret len %d from path %s\n", len, TEST_URLFROMPATH[i].path); - len = INTERNET_MAX_URL_LENGTH; - pathW = GetWideString(TEST_URLFROMPATH[i].path); - urlW = GetWideString(TEST_URLFROMPATH[i].url); - ret = UrlCreateFromPathW(pathW, ret_urlW, &len, 0); - WideCharToMultiByte(CP_ACP, 0, ret_urlW, -1, ret_url, sizeof(ret_url),0,0); - ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path L\"%s\", expected %08x\n", - ret, TEST_URLFROMPATH[i].path, TEST_URLFROMPATH[i].ret); - ok(!lstrcmpiW(ret_urlW, urlW), "got %s expected %s from path L\"%s\"\n", ret_url, TEST_URLFROMPATH[i].url, TEST_URLFROMPATH[i].path); - ok(len == lstrlenW(ret_urlW), "ret len %d from path L\"%s\"\n", len, TEST_URLFROMPATH[i].path); - FreeWideString(urlW); - FreeWideString(pathW); + if (pUrlCreateFromPathW) { + len = INTERNET_MAX_URL_LENGTH; + pathW = GetWideString(TEST_URLFROMPATH[i].path); + urlW = GetWideString(TEST_URLFROMPATH[i].url); + ret = pUrlCreateFromPathW(pathW, ret_urlW, &len, 0); + WideCharToMultiByte(CP_ACP, 0, ret_urlW, -1, ret_url, sizeof(ret_url),0,0); + ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path L\"%s\", expected %08x\n", + ret, TEST_URLFROMPATH[i].path, TEST_URLFROMPATH[i].ret); + ok(!lstrcmpiW(ret_urlW, urlW), "got %s expected %s from path L\"%s\"\n", + ret_url, TEST_URLFROMPATH[i].url, TEST_URLFROMPATH[i].path); + ok(len == lstrlenW(ret_urlW), "ret len %d from path L\"%s\"\n", len, TEST_URLFROMPATH[i].path); + FreeWideString(urlW); + FreeWideString(pathW); + } } } @@ -886,39 +1006,48 @@ static void test_UrlIs(void) size_t i; WCHAR wurl[80]; + if (!pUrlIsA) { + win_skip("UrlIsA not found\n"); + return; + } + for(i = 0; i < sizeof(TEST_PATH_IS_URL) / sizeof(TEST_PATH_IS_URL[0]); i++) { MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, 80); - ret = UrlIsA( TEST_PATH_IS_URL[i].path, URLIS_URL ); + ret = pUrlIsA( TEST_PATH_IS_URL[i].path, URLIS_URL ); ok( ret == TEST_PATH_IS_URL[i].expect, "returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path, TEST_PATH_IS_URL[i].expect ); - ret = UrlIsW( wurl, URLIS_URL ); - ok( ret == TEST_PATH_IS_URL[i].expect, - "returned %d from path (UrlIsW) %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path, - TEST_PATH_IS_URL[i].expect ); + if (pUrlIsW) { + ret = pUrlIsW( wurl, URLIS_URL ); + ok( ret == TEST_PATH_IS_URL[i].expect, + "returned %d from path (UrlIsW) %s, expected %d\n", ret, + TEST_PATH_IS_URL[i].path, TEST_PATH_IS_URL[i].expect ); + } } for(i = 0; i < sizeof(TEST_URLIS_ATTRIBS) / sizeof(TEST_URLIS_ATTRIBS[0]); i++) { MultiByteToWideChar(CP_ACP, 0, TEST_URLIS_ATTRIBS[i].url, -1, wurl, 80); - ret = UrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_OPAQUE); + ret = pUrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_OPAQUE); ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque, "returned %d for URLIS_OPAQUE, url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url, TEST_URLIS_ATTRIBS[i].expectOpaque ); - ret = UrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_FILEURL); + ret = pUrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_FILEURL); ok( ret == TEST_URLIS_ATTRIBS[i].expectFile, "returned %d for URLIS_FILEURL, url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url, TEST_URLIS_ATTRIBS[i].expectFile ); - ret = UrlIsW( wurl, URLIS_OPAQUE); - ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque, - "returned %d for URLIS_OPAQUE (UrlIsW), url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url, - TEST_URLIS_ATTRIBS[i].expectOpaque ); - ret = UrlIsW( wurl, URLIS_FILEURL); - ok( ret == TEST_URLIS_ATTRIBS[i].expectFile, - "returned %d for URLIS_FILEURL (UrlIsW), url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url, - TEST_URLIS_ATTRIBS[i].expectFile ); + if (pUrlIsW) { + ret = pUrlIsW( wurl, URLIS_OPAQUE); + ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque, + "returned %d for URLIS_OPAQUE (UrlIsW), url \"%s\", expected %d\n", + ret, TEST_URLIS_ATTRIBS[i].url, TEST_URLIS_ATTRIBS[i].expectOpaque ); + ret = pUrlIsW( wurl, URLIS_FILEURL); + ok( ret == TEST_URLIS_ATTRIBS[i].expectFile, + "returned %d for URLIS_FILEURL (UrlIsW), url \"%s\", expected %d\n", + ret, TEST_URLIS_ATTRIBS[i].url, TEST_URLIS_ATTRIBS[i].expectFile ); + } } } @@ -935,45 +1064,235 @@ static void test_UrlUnescape(void) static char another_inplace[] = "file:///C:/Program%20Files"; static const char expected[] = "file:///C:/Program Files"; static WCHAR inplaceW[] = {'f','i','l','e',':','/','/','/','C',':','/','P','r','o','g','r','a','m',' ','F','i','l','e','s',0}; - static WCHAR another_inplaceW[] = {'f','i','l','e',':','/','/','/','C',':','/','P','r','o','g','r','a','m','%','2','0','F','i','l','e','s',0}; + static WCHAR another_inplaceW[] ={'f','i','l','e',':','/','/','/', + 'C',':','/','P','r','o','g','r','a','m','%','2','0','F','i','l','e','s',0}; + HRESULT res; + if (!pUrlUnescapeA) { + win_skip("UrlUnescapeA not found\n"); + return; + } for(i=0; iurl, &parseda); + ok(hres == test->hres, "ParseURL failed: %08x, expected %08x\n", hres, test->hres); + if(hres == S_OK) { + ok(parseda.pszProtocol == test->url, "parseda.pszProtocol = %s, expected %s\n", + parseda.pszProtocol, test->url); + ok(parseda.cchProtocol == test->protocol_len, "parseda.cchProtocol = %d, expected %d\n", + parseda.cchProtocol, test->protocol_len); + ok(parseda.pszSuffix == test->url+test->protocol_len+1, "parseda.pszSuffix = %s, expected %s\n", + parseda.pszSuffix, test->url+test->protocol_len+1); + ok(parseda.cchSuffix == strlen(test->url+test->protocol_len+1), + "parseda.pszSuffix = %d, expected %d\n", + parseda.cchSuffix, lstrlenA(test->url+test->protocol_len+1)); + ok(parseda.nScheme == test->scheme, "parseda.nScheme = %d, expected %d\n", + parseda.nScheme, test->scheme); + }else { + ok(!parseda.pszProtocol, "parseda.pszProtocol = %p\n", parseda.pszProtocol); + ok(parseda.nScheme == 0xd0d0d0d0, "nScheme = %d\n", parseda.nScheme); + } + + MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, sizeof(url)/sizeof(WCHAR)); + + memset(&parsedw, 0xd0, sizeof(parsedw)); + parsedw.cbSize = sizeof(parsedw); + hres = pParseURLW(url, &parsedw); + ok(hres == test->hres, "ParseURL failed: %08x, expected %08x\n", hres, test->hres); + if(hres == S_OK) { + ok(parsedw.pszProtocol == url, "parsedw.pszProtocol = %s, expected %s\n", + wine_dbgstr_w(parsedw.pszProtocol), wine_dbgstr_w(url)); + ok(parsedw.cchProtocol == test->protocol_len, "parsedw.cchProtocol = %d, expected %d\n", + parsedw.cchProtocol, test->protocol_len); + ok(parsedw.pszSuffix == url+test->protocol_len+1, "parsedw.pszSuffix = %s, expected %s\n", + wine_dbgstr_w(parsedw.pszSuffix), wine_dbgstr_w(url+test->protocol_len+1)); + ok(parsedw.cchSuffix == strlen(test->url+test->protocol_len+1), + "parsedw.pszSuffix = %d, expected %d\n", + parsedw.cchSuffix, lstrlenA(test->url+test->protocol_len+1)); + ok(parsedw.nScheme == test->scheme, "parsedw.nScheme = %d, expected %d\n", + parsedw.nScheme, test->scheme); + }else { + ok(!parsedw.pszProtocol, "parsedw.pszProtocol = %p\n", parseda.pszProtocol); + ok(parsedw.nScheme == 0xd0d0d0d0, "nScheme = %d\n", parsedw.nScheme); + } + } +} + +static void test_HashData(void) +{ + HRESULT res; + BYTE input[16] = {0x51, 0x33, 0x4F, 0xA7, 0x45, 0x15, 0xF0, 0x52, 0x90, + 0x2B, 0xE7, 0xF5, 0xFD, 0xE1, 0xA6, 0xA7}; + BYTE output[32]; + static const BYTE expected[] = {0x54, 0x9C, 0x92, 0x55, 0xCD, 0x82, 0xFF, + 0xA1, 0x8E, 0x0F, 0xCF, 0x93, 0x14, 0xAA, + 0xE3, 0x2D}; + static const BYTE expected2[] = {0x54, 0x9C, 0x92, 0x55, 0xCD, 0x82, 0xFF, + 0xA1, 0x8E, 0x0F, 0xCF, 0x93, 0x14, 0xAA, + 0xE3, 0x2D, 0x47, 0xFC, 0x80, 0xB8, 0xD0, + 0x49, 0xE6, 0x13, 0x2A, 0x30, 0x51, 0x8D, + 0xF9, 0x4B, 0x07, 0xA6}; + static const BYTE expected3[] = {0x2B, 0xDC, 0x9A, 0x1B, 0xF0, 0x5A, 0xF9, + 0xC6, 0xBE, 0x94, 0x6D, 0xF3, 0x33, 0xC1, + 0x36, 0x07}; + int i; + + /* Test hashing with identically sized input/output buffers. */ + res = pHashData(input, 16, output, 16); + ok(res == S_OK, "Expected HashData to return S_OK, got 0x%08x\n", res); + if(res == S_OK) + ok(!memcmp(output, expected, sizeof(expected)), + "Output buffer did not match expected contents\n"); + + /* Test hashing with larger output buffer. */ + res = pHashData(input, 16, output, 32); + ok(res == S_OK, "Expected HashData to return S_OK, got 0x%08x\n", res); + if(res == S_OK) + ok(!memcmp(output, expected2, sizeof(expected2)), + "Output buffer did not match expected contents\n"); + + /* Test hashing with smaller input buffer. */ + res = pHashData(input, 8, output, 16); + ok(res == S_OK, "Expected HashData to return S_OK, got 0x%08x\n", res); + if(res == S_OK) + ok(!memcmp(output, expected3, sizeof(expected3)), + "Output buffer did not match expected contents\n"); + + /* Test passing NULL pointers for input/output parameters. */ + res = pHashData(NULL, 0, NULL, 0); + ok(res == E_INVALIDARG || broken(res == S_OK), /* Windows 2000 */ + "Expected HashData to return E_INVALIDARG, got 0x%08x\n", res); + + res = pHashData(input, 0, NULL, 0); + ok(res == E_INVALIDARG || broken(res == S_OK), /* Windows 2000 */ + "Expected HashData to return E_INVALIDARG, got 0x%08x\n", res); + + res = pHashData(NULL, 0, output, 0); + ok(res == E_INVALIDARG || broken(res == S_OK), /* Windows 2000 */ + "Expected HashData to return E_INVALIDARG, got 0x%08x\n", res); + + /* Test passing valid pointers with sizes of zero. */ + for (i = 0; i < sizeof(input)/sizeof(BYTE); i++) + input[i] = 0x00; + + for (i = 0; i < sizeof(output)/sizeof(BYTE); i++) + output[i] = 0xFF; + + res = pHashData(input, 0, output, 0); + ok(res == S_OK, "Expected HashData to return S_OK, got 0x%08x\n", res); + + /* The buffers should be unchanged. */ + for (i = 0; i < sizeof(input)/sizeof(BYTE); i++) + { + ok(input[i] == 0x00, "Expected the input buffer to be unchanged\n"); + if(input[i] != 0x00) break; + } + + for (i = 0; i < sizeof(output)/sizeof(BYTE); i++) + { + ok(output[i] == 0xFF, "Expected the output buffer to be unchanged\n"); + if(output[i] != 0xFF) break; + } + + /* Input/output parameters are not validated. */ + res = pHashData((BYTE *)0xdeadbeef, 0, (BYTE *)0xdeadbeef, 0); + ok(res == S_OK, "Expected HashData to return S_OK, got 0x%08x\n", res); + + if (0) + { + res = pHashData((BYTE *)0xdeadbeef, 1, (BYTE *)0xdeadbeef, 1); + trace("HashData returned 0x%08x\n", res); + } } /* ########################### */ @@ -982,7 +1301,27 @@ START_TEST(url) { hShlwapi = GetModuleHandleA("shlwapi.dll"); + pUrlUnescapeA = (void *) GetProcAddress(hShlwapi, "UrlUnescapeA"); + pUrlUnescapeW = (void *) GetProcAddress(hShlwapi, "UrlUnescapeW"); + pUrlIsA = (void *) GetProcAddress(hShlwapi, "UrlIsA"); + pUrlIsW = (void *) GetProcAddress(hShlwapi, "UrlIsW"); + pUrlHashA = (void *) GetProcAddress(hShlwapi, "UrlHashA"); + pUrlHashW = (void *) GetProcAddress(hShlwapi, "UrlHashW"); + pUrlGetPartA = (void *) GetProcAddress(hShlwapi, "UrlGetPartA"); + pUrlGetPartW = (void *) GetProcAddress(hShlwapi, "UrlGetPartW"); + pUrlEscapeA = (void *) GetProcAddress(hShlwapi, "UrlEscapeA"); + pUrlEscapeW = (void *) GetProcAddress(hShlwapi, "UrlEscapeW"); + pUrlCreateFromPathA = (void *) GetProcAddress(hShlwapi, "UrlCreateFromPathA"); + pUrlCreateFromPathW = (void *) GetProcAddress(hShlwapi, "UrlCreateFromPathW"); + pUrlCombineA = (void *) GetProcAddress(hShlwapi, "UrlCombineA"); + pUrlCombineW = (void *) GetProcAddress(hShlwapi, "UrlCombineW"); + pUrlCanonicalizeA = (void *) GetProcAddress(hShlwapi, "UrlCanonicalizeA"); pUrlCanonicalizeW = (void *) GetProcAddress(hShlwapi, "UrlCanonicalizeW"); + pUrlApplySchemeA = (void *) GetProcAddress(hShlwapi, "UrlApplySchemeA"); + pUrlApplySchemeW = (void *) GetProcAddress(hShlwapi, "UrlApplySchemeW"); + pParseURLA = (void*)GetProcAddress(hShlwapi, (LPCSTR)1); + pParseURLW = (void*)GetProcAddress(hShlwapi, (LPCSTR)2); + pHashData = (void*)GetProcAddress(hShlwapi, "HashData"); test_UrlApplyScheme(); test_UrlHash(); @@ -994,5 +1333,6 @@ START_TEST(url) test_UrlCreateFromPath(); test_UrlIs(); test_UrlUnescape(); - + test_ParseURL(); + test_HashData(); } From 36d6872c290bfa44e675acf0358b908b421cdbfe Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 19:44:02 +0000 Subject: [PATCH 057/211] [HLINK_WINETEST] sync hlink_winetest to wine 1.1.39 svn path=/trunk/; revision=45799 --- rostests/winetests/hlink/browse_ctx.c | 90 ++++++++++ rostests/winetests/hlink/hlink.c | 229 +++++++++++++++++++++++++- rostests/winetests/hlink/hlink.rbuild | 3 +- rostests/winetests/hlink/testlist.c | 2 + 4 files changed, 321 insertions(+), 3 deletions(-) create mode 100644 rostests/winetests/hlink/browse_ctx.c diff --git a/rostests/winetests/hlink/browse_ctx.c b/rostests/winetests/hlink/browse_ctx.c new file mode 100644 index 00000000000..a9b26e72fb7 --- /dev/null +++ b/rostests/winetests/hlink/browse_ctx.c @@ -0,0 +1,90 @@ +/* + * Copyright 2009 Andrew Eikum for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include + +#include + +#include "wine/test.h" + +/* Win9x and WinMe don't have lstrcmpW */ +static int strcmp_ww(const WCHAR *str1, const WCHAR *str2) +{ + DWORD len1 = lstrlenW(str1); + DWORD len2 = lstrlenW(str2); + + if (len1 != len2) return 1; + return memcmp(str1, str2, len1 * sizeof(WCHAR)); +} + +static void test_SetInitialHlink(void) +{ + IHlinkBrowseContext *bc; + IHlink *found_hlink; + IMoniker *dummy, *found_moniker; + IBindCtx *bindctx; + WCHAR one[] = {'1',0}; + WCHAR five[] = {'5',0}; + WCHAR *found_name, *exp_name; + HRESULT hres; + + hres = CreateBindCtx(0, &bindctx); + ok(hres == S_OK, "CreateBindCtx failed: 0x%08x\n", hres); + + hres = CreateItemMoniker(one, five, &dummy); + ok(hres == S_OK, "CreateItemMoniker failed: 0x%08x\n", hres); + + hres = IMoniker_GetDisplayName(dummy, bindctx, NULL, &exp_name); + ok(hres == S_OK, "GetDisplayName failed: 0x%08x\n", hres); + + hres = HlinkCreateBrowseContext(NULL, &IID_IHlinkBrowseContext, (void**)&bc); + ok(hres == S_OK, "HlinkCreateBrowseContext failed: 0x%08x\n", hres); + + hres = IHlinkBrowseContext_SetInitialHlink(bc, dummy, one, NULL); + ok(hres == S_OK, "SetInitialHlink failed: 0x%08x\n", hres); + + hres = IHlinkBrowseContext_GetHlink(bc, HLID_CURRENT, &found_hlink); + ok(hres == S_OK, "GetHlink failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(found_hlink, HLINKGETREF_DEFAULT, &found_moniker, NULL); + ok(hres == S_OK, "GetMonikerReference failed: 0x%08x\n", hres); + + hres = IMoniker_GetDisplayName(found_moniker, bindctx, NULL, &found_name); + ok(hres == S_OK, "GetDisplayName failed: 0x%08x\n", hres); + ok(!strcmp_ww(found_name, exp_name), "Found display name should have been %s, was: %s\n", wine_dbgstr_w(exp_name), wine_dbgstr_w(found_name)); + + CoTaskMemFree(exp_name); + CoTaskMemFree(found_name); + + IBindCtx_Release(bindctx); + IMoniker_Release(found_moniker); + IHlink_Release(found_hlink); + IHlinkBrowseContext_Release(bc); + IMoniker_Release(dummy); +} + +START_TEST(browse_ctx) +{ + CoInitialize(NULL); + + test_SetInitialHlink(); + + CoUninitialize(); +} diff --git a/rostests/winetests/hlink/hlink.c b/rostests/winetests/hlink/hlink.c index 1a7536fee93..1802196431f 100644 --- a/rostests/winetests/hlink/hlink.c +++ b/rostests/winetests/hlink/hlink.c @@ -137,9 +137,7 @@ static void test_reference(void) r = IHlink_GetStringReference(lnk, HLINKGETREF_DEFAULT, &str, NULL); ok(r == S_OK, "failed\n"); - todo_wine { ok(!lstrcmpW(str, url2), "url wrong\n"); - } CoTaskMemFree(str); r = IHlink_GetStringReference(lnk, HLINKGETREF_DEFAULT, NULL, NULL); @@ -1121,6 +1119,231 @@ static void test_HlinkGetSetMonikerReference(void) IMoniker_Release(dummy); } +static void test_HlinkGetSetStringReference(void) +{ + IHlink *link; + static const WCHAR one[] = {'1',0}; + static const WCHAR two[] = {'2',0}; + static const WCHAR three[] = {'3',0}; + static const WCHAR empty[] = {0}; + WCHAR *fnd_tgt, *fnd_loc; + HRESULT hres; + + /* create a new hlink: target => NULL, location => one */ + hres = HlinkCreateFromMoniker(NULL, one, empty, NULL, 0, NULL, &IID_IHlink, (void**)&link); + ok(hres == S_OK, "HlinkCreateFromMoniker failed: 0x%08x\n", hres); + + /* test setting/getting location */ + hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres); + ok(fnd_tgt == NULL, "Found target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt)); + ok(!lstrcmpW(fnd_loc, one), "Found location should have been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(fnd_loc)); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + hres = IHlink_SetStringReference(link, HLINKSETF_LOCATION, one, two); + ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres); + + hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres); + ok(fnd_tgt == NULL, "Found target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt)); + ok(!lstrcmpW(fnd_loc, two), "Found location should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_loc)); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + hres = IHlink_SetStringReference(link, -HLINKSETF_LOCATION, two, one); + ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres); + + hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres); + ok(fnd_tgt == NULL, "Found target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt)); + ok(!lstrcmpW(fnd_loc, one), "Found location should have been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(fnd_loc)); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + /* test setting/getting target */ + hres = IHlink_SetStringReference(link, HLINKSETF_TARGET, two, three); + ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres); + + hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres); + ok(!lstrcmpW(fnd_tgt, two), "Found target should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_tgt)); + ok(!lstrcmpW(fnd_loc, one), "Found location should have been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(fnd_loc)); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + hres = IHlink_SetStringReference(link, -HLINKSETF_TARGET, three, two); + ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres); + + hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres); + ok(!lstrcmpW(fnd_tgt, three), "Found target should have been %s, was: %s\n", wine_dbgstr_w(three), wine_dbgstr_w(fnd_tgt)); + ok(!lstrcmpW(fnd_loc, two), "Found location should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_loc)); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + /* test setting/getting both */ + hres = IHlink_SetStringReference(link, HLINKSETF_TARGET | HLINKSETF_LOCATION, one, two); + ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres); + + hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres); + ok(!lstrcmpW(fnd_tgt, one), "Found target should have been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(fnd_tgt)); + ok(!lstrcmpW(fnd_loc, two), "Found location should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_loc)); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + hres = IHlink_SetStringReference(link, -(HLINKSETF_TARGET | HLINKSETF_LOCATION), three, one); + ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres); + + hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres); + ok(!lstrcmpW(fnd_tgt, three), "Found target should have been %s, was: %s\n", wine_dbgstr_w(three), wine_dbgstr_w(fnd_tgt)); + ok(!lstrcmpW(fnd_loc, two), "Found location should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_loc)); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + /* test invalid flags/params */ + hres = IHlink_GetStringReference(link, 4, &fnd_tgt, &fnd_loc); + ok(hres == E_INVALIDARG, "IHlink_GetStringReference should have failed " + "with E_INVALIDARG (0x%08x), instead: 0x%08x\n", E_INVALIDARG, hres); + ok(fnd_tgt == NULL, "Found target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt)); + ok(fnd_loc == NULL, "Found location should have been NULL, was: %s\n", wine_dbgstr_w(fnd_loc)); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + hres = IHlink_GetStringReference(link, -1, &fnd_tgt, &fnd_loc); + todo_wine ok(hres == E_FAIL, "IHlink_GetStringReference should have failed " + "with E_FAIL (0x%08x), instead: 0x%08x\n", E_FAIL, hres); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + hres = IHlink_GetStringReference(link, -2, &fnd_tgt, &fnd_loc); + ok(hres == E_INVALIDARG, "IHlink_GetStringReference should have failed " + "with E_INVALIDARG (0x%08x), instead: 0x%08x\n", E_INVALIDARG, hres); + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); + + hres = IHlink_SetStringReference(link, 4, NULL, NULL); + ok(hres == 4, "IHlink_SetStringReference should have failed with 0x4, instead: 0x%08x\n", hres); + + hres = IHlink_SetStringReference(link, -4, NULL, NULL); + ok(hres == -4, "IHlink_SetStringReference should have failed with 0xFFFFFFFC, instead: 0x%08x\n", hres); + + IHlink_Release(link); +} + +#define setStringRef(h,f,t,l) r_setStringRef(__LINE__,h,f,t,l) +static void r_setStringRef(unsigned line, IHlink *hlink, DWORD flags, const WCHAR *tgt, const WCHAR *loc) +{ + HRESULT hres; + hres = IHlink_SetStringReference(hlink, flags, tgt, loc); + ok_(__FILE__,line) (hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres); +} + +#define getStringRef(h,t,l) r_getStringRef(__LINE__,h,t,l) +static void r_getStringRef(unsigned line, IHlink *hlink, const WCHAR *exp_tgt, const WCHAR *exp_loc) +{ + HRESULT hres; + WCHAR *fnd_tgt, *fnd_loc; + + hres = IHlink_GetStringReference(hlink, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok_(__FILE__,line) (hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres); + + if(exp_tgt) + ok_(__FILE__,line) (!lstrcmpW(fnd_tgt, exp_tgt), "Found string target should have been %s, was: %s\n", wine_dbgstr_w(exp_tgt), wine_dbgstr_w(fnd_tgt)); + else + ok_(__FILE__,line) (exp_tgt == NULL, "Found string target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt)); + + if(exp_loc) + ok_(__FILE__,line) (!lstrcmpW(fnd_loc, exp_loc), "Found string location should have been %s, was: %s\n", wine_dbgstr_w(exp_loc), wine_dbgstr_w(fnd_loc)); + else + ok_(__FILE__,line) (exp_loc == NULL, "Found string location should have been NULL, was: %s\n", wine_dbgstr_w(fnd_loc)); + + CoTaskMemFree(fnd_tgt); + CoTaskMemFree(fnd_loc); +} + +#define setMonikerRef(h,f,t,l) r_setMonikerRef(__LINE__,h,f,t,l) +static void r_setMonikerRef(unsigned line, IHlink *hlink, DWORD flags, IMoniker *tgt, const WCHAR *loc) +{ + HRESULT hres; + hres = IHlink_SetMonikerReference(hlink, flags, tgt, loc); + ok_(__FILE__,line) (hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); +} + +/* passing 0xFFFFFFFF as exp_tgt will return the retrieved target & not test it */ +#define getMonikerRef(h,t,l) r_getMonikerRef(__LINE__,h,t,l) +static IMoniker *r_getMonikerRef(unsigned line, IHlink *hlink, IMoniker *exp_tgt, const WCHAR *exp_loc) +{ + HRESULT hres; + IMoniker *fnd_tgt; + WCHAR *fnd_loc; + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc); + ok_(__FILE__,line) (hres == S_OK, "IHlink_GetMonikerReference failed: 0x%08x\n", hres); + + if(exp_loc) + ok_(__FILE__,line) (!lstrcmpW(fnd_loc, exp_loc), "Found string location should have been %s, was: %s\n", wine_dbgstr_w(exp_loc), wine_dbgstr_w(fnd_loc)); + else + ok_(__FILE__,line) (exp_loc == NULL, "Found string location should have been NULL, was: %s\n", wine_dbgstr_w(fnd_loc)); + + CoTaskMemFree(fnd_loc); + + if(exp_tgt == (IMoniker*)0xFFFFFFFF) + return fnd_tgt; + + ok_(__FILE__,line) (fnd_tgt == exp_tgt, "Found moniker target should have been %p, was: %p\n", exp_tgt, fnd_tgt); + + if(fnd_tgt) + IMoniker_Release(fnd_tgt); + + return NULL; +} + +static void test_HlinkMoniker(void) +{ + IHlink *hlink; + IMoniker *aMon, *file_mon; + static const WCHAR emptyW[] = {0}; + static const WCHAR wordsW[] = {'w','o','r','d','s',0}; + static const WCHAR aW[] = {'a',0}; + static const WCHAR bW[] = {'b',0}; + HRESULT hres; + + hres = HlinkCreateFromString(NULL, NULL, NULL, NULL, 0, NULL, &IID_IHlink, (void**)&hlink); + ok(hres == S_OK, "HlinkCreateFromString failed: 0x%08x\n", hres); + getStringRef(hlink, NULL, NULL); + getMonikerRef(hlink, NULL, NULL); + + /* setting a string target creates a moniker reference */ + setStringRef(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, aW, wordsW); + getStringRef(hlink, aW, wordsW); + aMon = getMonikerRef(hlink, (IMoniker*)0xFFFFFFFF, wordsW); + ok(aMon != NULL, "Moniker from %s target should not be NULL\n", wine_dbgstr_w(aW)); + if(aMon) + IMoniker_Release(aMon); + + /* setting target & location to the empty string deletes the moniker + * reference */ + setStringRef(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, emptyW, emptyW); + getStringRef(hlink, NULL, NULL); + getMonikerRef(hlink, NULL, NULL); + + /* setting a moniker target also sets the target string to that moniker's + * display name */ + hres = CreateFileMoniker(bW, &file_mon); + ok(hres == S_OK, "CreateFileMoniker failed: 0x%08x\n", hres); + + setMonikerRef(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, file_mon, wordsW); + getStringRef(hlink, bW, wordsW); + getMonikerRef(hlink, file_mon, wordsW); + + IMoniker_Release(file_mon); + + IHlink_Release(hlink); +} + START_TEST(hlink) { CoInitialize(NULL); @@ -1133,6 +1356,8 @@ START_TEST(hlink) test_HlinkParseDisplayName(); test_HlinkResolveMonikerForData(); test_HlinkGetSetMonikerReference(); + test_HlinkGetSetStringReference(); + test_HlinkMoniker(); CoUninitialize(); } diff --git a/rostests/winetests/hlink/hlink.rbuild b/rostests/winetests/hlink/hlink.rbuild index 771cae3a8a3..46622c6ad98 100644 --- a/rostests/winetests/hlink/hlink.rbuild +++ b/rostests/winetests/hlink/hlink.rbuild @@ -3,7 +3,8 @@ . - + + browse_ctx.c hlink.c testlist.c wine diff --git a/rostests/winetests/hlink/testlist.c b/rostests/winetests/hlink/testlist.c index 0876b7c2f39..2dcd97072a4 100644 --- a/rostests/winetests/hlink/testlist.c +++ b/rostests/winetests/hlink/testlist.c @@ -7,9 +7,11 @@ #include "wine/test.h" extern void func_hlink(void); +extern void func_browse_ctx(void); const struct test winetest_testlist[] = { + { "browse_ctx", func_browse_ctx }, { "hlink", func_hlink }, { 0, 0 } }; From 072bfa47454b2851556bf950df97ef8d931dcbae Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 20:37:28 +0000 Subject: [PATCH 058/211] [CREDUI] sync credui to wine 1.1.39 svn path=/trunk/; revision=45800 --- reactos/dll/win32/credui/credui.rc | 16 +++++--- reactos/dll/win32/credui/credui_Fr.rc | 1 - reactos/dll/win32/credui/credui_It.rc | 55 ++++++++++++++++++++++++++ reactos/dll/win32/credui/credui_Lt.rc | 1 - reactos/dll/win32/credui/credui_Si.rc | 2 - reactos/dll/win32/credui/credui_Uk.rc | 56 +++++++++++++++++++++++++++ 6 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 reactos/dll/win32/credui/credui_It.rc create mode 100644 reactos/dll/win32/credui/credui_Uk.rc diff --git a/reactos/dll/win32/credui/credui.rc b/reactos/dll/win32/credui/credui.rc index f66a9428043..5f4762ebc1c 100644 --- a/reactos/dll/win32/credui/credui.rc +++ b/reactos/dll/win32/credui/credui.rc @@ -28,18 +28,22 @@ IDB_BANNER BITMAP LOADONCALL DISCARDABLE banner.bmp #include "credui_Da.rc" -#include "credui_De.rc" #include "credui_En.rc" -#include "credui_Es.rc" -#include "credui_Fr.rc" #include "credui_Ko.rc" -#include "credui_Lt.rc" #include "credui_Nl.rc" #include "credui_No.rc" #include "credui_Pl.rc" #include "credui_Pt.rc" +#include "credui_Sv.rc" +#include "credui_Zh.rc" + +/* UTF-8 */ +#include "credui_De.rc" +#include "credui_Es.rc" +#include "credui_Fr.rc" +#include "credui_It.rc" +#include "credui_Lt.rc" #include "credui_Ro.rc" #include "credui_Ru.rc" #include "credui_Si.rc" -#include "credui_Sv.rc" -#include "credui_Zh.rc" +#include "credui_Uk.rc" diff --git a/reactos/dll/win32/credui/credui_Fr.rc b/reactos/dll/win32/credui/credui_Fr.rc index d2e63be4140..387a86d39a1 100644 --- a/reactos/dll/win32/credui/credui_Fr.rc +++ b/reactos/dll/win32/credui/credui_Fr.rc @@ -52,4 +52,3 @@ STRINGTABLE DISCARDABLE IDS_CAPSLOCKONTITLE "VERR.MAJ est activé" IDS_CAPSLOCKON "Le verrouillage majuscule étant activé, cela pourrait provoquer une erreur lors de la saisie de votre mot de passe.\n\nAppuyez sur la touche VERR.MAJ de votre clavier afin de désactiver le verrouilage majuscule avant\nde saisir votre mot de passe." } -#pragma code_page(default) diff --git a/reactos/dll/win32/credui/credui_It.rc b/reactos/dll/win32/credui/credui_It.rc new file mode 100644 index 00000000000..f7708f4b5d1 --- /dev/null +++ b/reactos/dll/win32/credui/credui_It.rc @@ -0,0 +1,55 @@ +/* + * Italian language resource file for Credentials UI + * + * Copyright 2010 Luca Bennati + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "credui_resources.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL + +IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149 +STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "IDS_TITLEFORMAT" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL IDB_BANNER,-1,"Static",SS_BITMAP | SS_CENTERIMAGE,0, + 0,213,37 + LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP + LTEXT "&Nome Utente:",-1,8,62,72,12,SS_CENTERIMAGE + CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 + LTEXT "&Password:",-1,8,80,72,12,SS_CENTERIMAGE + EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "&Ricorda la mia password",IDC_SAVE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12 + DEFPUSHBUTTON "OK",IDOK,97,128,50,14 + PUSHBUTTON "Annulla",IDCANCEL,156,128,50,14 +END + +STRINGTABLE DISCARDABLE +{ + IDS_TITLEFORMAT "Connetti a %s" + IDS_MESSAGEFORMAT "Connettendo a %s" + IDS_INCORRECTPASSWORDTITLE "Accesso fallito" + IDS_INCORRECTPASSWORD "Assicurati che il tuo nome utente\ne password siano corrette." + IDS_CAPSLOCKONTITLE "Il Caps Lock è acceso" + IDS_CAPSLOCKON "Avere Caps Lock acceso può portarti a immettere la password incorrettamente.\n\nPremere il tasto Caps Lock sulla tua tastiera per spegnere Caps Lock prima\n di immettere la tua password." +} diff --git a/reactos/dll/win32/credui/credui_Lt.rc b/reactos/dll/win32/credui/credui_Lt.rc index c98a861cc8a..4eb6ebaf9b4 100644 --- a/reactos/dll/win32/credui/credui_Lt.rc +++ b/reactos/dll/win32/credui/credui_Lt.rc @@ -53,4 +53,3 @@ STRINGTABLE DISCARDABLE IDS_CAPSLOCKONTITLE "Didžiųjų raidžių bÅ«sena įjungta" IDS_CAPSLOCKON "Kai įjungta didžiųjų raidžių bÅ«sena, savo slaptažodį galite įvesti neteisingai.\n\nPaspauskite didžiųjų raidžių klaviatÅ«ros klavišą didžiųjų raidžių bÅ«senai iÅ¡jungti\nprieÅ¡ rinkdami savo slaptažodį." } -#pragma code_page(default) diff --git a/reactos/dll/win32/credui/credui_Si.rc b/reactos/dll/win32/credui/credui_Si.rc index 068ec970338..34915e668b5 100644 --- a/reactos/dll/win32/credui/credui_Si.rc +++ b/reactos/dll/win32/credui/credui_Si.rc @@ -52,5 +52,3 @@ STRINGTABLE DISCARDABLE IDS_CAPSLOCKONTITLE "Caps Lock je vkljuÄen" IDS_CAPSLOCKON "VkljuÄen Caps Lock je lahko vzrok nepravilnega vnosa gesla.\n\nPritisnite tipko Caps Lock, s Äimer ga izklopite\nin ponovno vnesite geslo." } - -#pragma code_page(default) diff --git a/reactos/dll/win32/credui/credui_Uk.rc b/reactos/dll/win32/credui/credui_Uk.rc new file mode 100644 index 00000000000..e7c04ab7af6 --- /dev/null +++ b/reactos/dll/win32/credui/credui_Uk.rc @@ -0,0 +1,56 @@ +/* + * Ukrainian language resource file for Credentials UI + * + * Copyright 2007 Robert Shearman (for CodeWeavers) + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "credui_resources.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149 +STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "IDS_TITLEFORMAT" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL IDB_BANNER,-1,"Static",SS_BITMAP | SS_CENTERIMAGE,0, + 0,213,37 + LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP + LTEXT "&КориÑтувач:",-1,8,62,72,12,SS_CENTERIMAGE + CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 + LTEXT "&Пароль:",-1,8,80,72,12,SS_CENTERIMAGE + EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "&Запам'Ñтати мій пароль",IDC_SAVE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12 + DEFPUSHBUTTON "OK",IDOK,97,128,50,14 + PUSHBUTTON "СкаÑувати",IDCANCEL,156,128,50,14 +END + +STRINGTABLE DISCARDABLE +{ + IDS_TITLEFORMAT "Під'єднатиÑÑŒ до %s" + IDS_MESSAGEFORMAT "Під'єднуюÑÑŒ до %s" + IDS_INCORRECTPASSWORDTITLE "Вхід не відбувÑÑ" + IDS_INCORRECTPASSWORD "ПереконайтеÑÑŒ що ім'Ñ ÐºÐ¾Ñ€Ð¸Ñтувача\nÑ– пароль правильні." + IDS_CAPSLOCKONTITLE "Caps Lock включений" + IDS_CAPSLOCKON "Пароль може бути введений неправильно через натиÑнену клавішу Caps Lock.\n\nВимкніть Caps Lock перед\nвведеннÑм паролю." +} From 37f36cd583584ce3b4a4f08aa78d61ec58772e5d Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 20:42:01 +0000 Subject: [PATCH 059/211] [CRYPTDLG] sync cryptdlg to wine 1.1.39 svn path=/trunk/; revision=45801 --- reactos/dll/win32/cryptdlg/cryptdlg.rc | 10 ++++-- reactos/dll/win32/cryptdlg/cryptdlg_Fr.rc | 1 - reactos/dll/win32/cryptdlg/cryptdlg_Uk.rc | 42 +++++++++++++++++++++++ reactos/dll/win32/cryptdlg/main.c | 4 +-- 4 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 reactos/dll/win32/cryptdlg/cryptdlg_Uk.rc diff --git a/reactos/dll/win32/cryptdlg/cryptdlg.rc b/reactos/dll/win32/cryptdlg/cryptdlg.rc index dd9f97f4fde..7ea41c57407 100644 --- a/reactos/dll/win32/cryptdlg/cryptdlg.rc +++ b/reactos/dll/win32/cryptdlg/cryptdlg.rc @@ -22,11 +22,15 @@ #include "winuser.h" #include "cryptres.h" -#include "cryptdlg_De.rc" #include "cryptdlg_En.rc" -#include "cryptdlg_Fr.rc" #include "cryptdlg_Ko.rc" -#include "cryptdlg_Lt.rc" #include "cryptdlg_Nl.rc" + +/* UTF-8 */ +#include "cryptdlg_De.rc" +#include "cryptdlg_Fr.rc" +#include "cryptdlg_Lt.rc" +#include "cryptdlg_Uk.rc" #include "cryptdlg_Pt.rc" #include "cryptdlg_Ro.rc" + diff --git a/reactos/dll/win32/cryptdlg/cryptdlg_Fr.rc b/reactos/dll/win32/cryptdlg/cryptdlg_Fr.rc index 1deeaa31587..25d8a644ecf 100644 --- a/reactos/dll/win32/cryptdlg/cryptdlg_Fr.rc +++ b/reactos/dll/win32/cryptdlg/cryptdlg_Fr.rc @@ -40,4 +40,3 @@ STRINGTABLE DISCARDABLE IDS_NOTICE_NUM "Numéro de l'avis =" IDS_NOTICE_TEXT "Texte de l'avis =" } -#pragma code_page(default) diff --git a/reactos/dll/win32/cryptdlg/cryptdlg_Uk.rc b/reactos/dll/win32/cryptdlg/cryptdlg_Uk.rc new file mode 100644 index 00000000000..d90226f9abc --- /dev/null +++ b/reactos/dll/win32/cryptdlg/cryptdlg_Uk.rc @@ -0,0 +1,42 @@ +/* + * cryptdlg dll resources + * + * Copyright 2008 Juan Lang + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "cryptres.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_CERT_POLICY "Certificate Policy" + IDS_POLICY_ID "Policy Identifier: " + IDS_POLICY_QUALIFIER_INFO "Policy Qualifier Info" + IDS_POLICY_QUALIFIER_ID "Policy Qualifier Id=" + IDS_CPS "CPS" /* Certification Practice Statement */ + IDS_USER_NOTICE "User Notice" + IDS_QUALIFIER "Qualifier" + IDS_NOTICE_REF "Notice Reference" + IDS_ORGANIZATION "ОрганізаціÑ=" + IDS_NOTICE_NUM "Notice Number=" + IDS_NOTICE_TEXT "Notice Text=" +} diff --git a/reactos/dll/win32/cryptdlg/main.c b/reactos/dll/win32/cryptdlg/main.c index 1971578dbf5..f6653ec2c78 100644 --- a/reactos/dll/win32/cryptdlg/main.c +++ b/reactos/dll/win32/cryptdlg/main.c @@ -535,7 +535,7 @@ static BOOL CRYPT_FormatCPS(DWORD dwCertEncodingType, pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &cpsValue, &size))) { LPCWSTR headingSep, sep; - DWORD headingSepLen, sepLen; + DWORD sepLen; if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) { @@ -547,8 +547,8 @@ static BOOL CRYPT_FormatCPS(DWORD dwCertEncodingType, headingSep = colonSpace; sep = commaSep; } + sepLen = strlenW(sep); - headingSepLen = strlenW(headingSep); if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) { From 900f9178444a63447b7ee74f81044454105d428b Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 20:55:13 +0000 Subject: [PATCH 060/211] [CRYPT32] sync crypt32 to wine 1.1.39 svn path=/trunk/; revision=45802 --- reactos/dll/win32/crypt32/chain.c | 10 +- reactos/dll/win32/crypt32/crypt32.rc | 7 +- reactos/dll/win32/crypt32/crypt32_Fr.rc | 1 - reactos/dll/win32/crypt32/crypt32_Uk.rc | 247 ++++++++++++++++++++ reactos/dll/win32/crypt32/crypt32_private.h | 4 + reactos/dll/win32/crypt32/decode.c | 2 +- reactos/dll/win32/crypt32/encode.c | 2 +- reactos/dll/win32/crypt32/object.c | 2 +- reactos/dll/win32/crypt32/oid.c | 12 +- reactos/dll/win32/crypt32/store.c | 2 +- 10 files changed, 273 insertions(+), 16 deletions(-) create mode 100644 reactos/dll/win32/crypt32/crypt32_Uk.rc diff --git a/reactos/dll/win32/crypt32/chain.c b/reactos/dll/win32/crypt32/chain.c index 28a22064440..6cdd103e666 100644 --- a/reactos/dll/win32/crypt32/chain.c +++ b/reactos/dll/win32/crypt32/chain.c @@ -686,8 +686,12 @@ static BOOL url_matches(LPCWSTR constraint, LPCWSTR name, authority_end = strchrW(name, '?'); if (!authority_end) authority_end = name + strlenW(name); - /* Remove any port number from the authority */ - for (colon = authority_end; colon >= name && *colon != ':'; colon--) + /* Remove any port number from the authority. The userinfo portion + * of an authority may contain a colon, so stop if a userinfo portion + * is found (indicated by '@'). + */ + for (colon = authority_end; colon >= name && *colon != ':' && + *colon != '@'; colon--) ; if (*colon == ':') authority_end = colon; @@ -3376,7 +3380,7 @@ BOOL WINAPI CertVerifyCertificateChainPolicy(LPCSTR szPolicyOID, TRACE("(%s, %p, %p, %p)\n", debugstr_a(szPolicyOID), pChainContext, pPolicyPara, pPolicyStatus); - if (!HIWORD(szPolicyOID)) + if (IS_INTOID(szPolicyOID)) { switch (LOWORD(szPolicyOID)) { diff --git a/reactos/dll/win32/crypt32/crypt32.rc b/reactos/dll/win32/crypt32/crypt32.rc index aae358df5a7..c656a8c551b 100644 --- a/reactos/dll/win32/crypt32/crypt32.rc +++ b/reactos/dll/win32/crypt32/crypt32.rc @@ -24,13 +24,16 @@ #include "version.rc" -#include "crypt32_De.rc" #include "crypt32_En.rc" -#include "crypt32_Fr.rc" #include "crypt32_Ko.rc" + +/* UTF-8 */ +#include "crypt32_De.rc" +#include "crypt32_Fr.rc" #include "crypt32_Lt.rc" #include "crypt32_Nl.rc" #include "crypt32_No.rc" #include "crypt32_Pt.rc" #include "crypt32_Ro.rc" #include "crypt32_Sv.rc" +#include "crypt32_Uk.rc" diff --git a/reactos/dll/win32/crypt32/crypt32_Fr.rc b/reactos/dll/win32/crypt32/crypt32_Fr.rc index 3438f2e4109..b98636dee82 100644 --- a/reactos/dll/win32/crypt32/crypt32_Fr.rc +++ b/reactos/dll/win32/crypt32/crypt32_Fr.rc @@ -242,4 +242,3 @@ STRINGTABLE DISCARDABLE IDS_NETSCAPE_SMIME_CA "AC S/MIME" IDS_NETSCAPE_SIGN_CA "Signature CA" } -#pragma code_page(default) diff --git a/reactos/dll/win32/crypt32/crypt32_Uk.rc b/reactos/dll/win32/crypt32/crypt32_Uk.rc new file mode 100644 index 00000000000..d26a456d44b --- /dev/null +++ b/reactos/dll/win32/crypt32/crypt32_Uk.rc @@ -0,0 +1,247 @@ +/* + * crypt32 dll resources + * + * Copyright (C) 2006 Juan Lang + * + * Ukrainian language support + * Copyright (C) 2010 igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "cryptres.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_AUTHORITY_KEY_ID "Authority Key Identifier" + IDS_KEY_ATTRIBUTES "ВлаÑтивоÑті Ключа" + IDS_KEY_USAGE_RESTRICTION "Key Usage Restriction" + IDS_SUBJECT_ALT_NAME "Subject Alternative Name" + IDS_ISSUER_ALT_NAME "Issuer Alternative Name" + IDS_BASIC_CONSTRAINTS "ОÑновні ОбмеженнÑ" + IDS_KEY_USAGE "ВикориÑÑ‚Ð°Ð½Ð½Ñ ÐšÐ»ÑŽÑ‡Ð°" + IDS_CERT_POLICIES "Політика Сертифікатів" + IDS_SUBJECT_KEY_IDENTIFIER "Subject Key Identifier" + IDS_CRL_REASON_CODE "CRL Reason Code" + IDS_CRL_DIST_POINTS "CRL Distribution Points" + IDS_ENHANCED_KEY_USAGE "Розширене ВикориÑÑ‚Ð°Ð½Ð½Ñ ÐšÐ»ÑŽÑ‡Ð°" + IDS_AUTHORITY_INFO_ACCESS "Authority Information Access" + IDS_CERT_EXTENSIONS "Ð Ð¾Ð·ÑˆÐ¸Ñ€ÐµÐ½Ð½Ñ Ð¡ÐµÑ€Ñ‚Ð¸Ñ„Ñ–ÐºÐ°Ñ‚Ñ–Ð²" + IDS_NEXT_UPDATE_LOCATION "Next Update Location" + IDS_YES_OR_NO_TRUST "Yes or No Trust" + IDS_EMAIL_ADDRESS "ÐдреÑа Ел. Пошти" + IDS_UNSTRUCTURED_NAME "Unstructured Name" + IDS_CONTENT_TYPE "Тип ВміÑту" + IDS_MESSAGE_DIGEST "Message Digest" + IDS_SIGNING_TIME "Ð§Ð°Ñ Ð’Ñ…Ð¾Ð´Ñƒ" + IDS_COUNTER_SIGN "Counter Sign" + IDS_CHALLENGE_PASSWORD "Challenge Password" + IDS_UNSTRUCTURED_ADDRESS "Unstructured Address" + IDS_SMIME_CAPABILITIES "SMIME Capabilities" + IDS_PREFER_SIGNED_DATA "Prefer Signed Data" + IDS_CPS "CPS" + IDS_USER_NOTICE "User Notice" + IDS_OCSP "On-line Certificate Status Protocol" + IDS_CA_ISSUER "Certification Authority Issuer" + IDS_CERT_TEMPLATE_NAME "Certification Template Name" + IDS_CERT_TYPE "Тип Сертифікату" + IDS_CERT_MANIFOLD "Certificate Manifold" + IDS_NETSCAPE_CERT_TYPE "Netscape Cert Type" + IDS_NETSCAPE_BASE_URL "Netscape Base URL" + IDS_NETSCAPE_REVOCATION_URL "Netscape Revocation URL" + IDS_NETSCAPE_CA_REVOCATION_URL "Netscape CA Revocation URL" + IDS_NETSCAPE_CERT_RENEWAL_URL "Netscape Cert Renewal URL" + IDS_NETSCAPE_CA_POLICY_URL "Netscape CA Policy URL" + IDS_NETSCAPE_SSL_SERVER_NAME "Netscape SSL ServerName" + IDS_NETSCAPE_COMMENT "Netscape Коментар" + IDS_SPC_SP_AGENCY_INFO "SpcSpAgencyInfo" + IDS_SPC_FINANCIAL_CRITERIA "SpcFinancialCriteria" + IDS_SPC_MINIMAL_CRITERIA "SpcMinimalCriteria" + IDS_COUNTRY "Країна/Регіон" + IDS_ORGANIZATION "ОрганізаціÑ" + IDS_ORGANIZATIONAL_UNIT "Organizational Unit" + IDS_COMMON_NAME "Common Name" + IDS_LOCALITY "Locality" + IDS_STATE_OR_PROVINCE "State or Province" + IDS_TITLE "Title" + IDS_GIVEN_NAME "Given Name" + IDS_INITIALS "Ініціали" + IDS_SUR_NAME "Sur Name" + IDS_DOMAIN_COMPONENT "Domain Component" + IDS_STREET_ADDRESS "Street Address" + IDS_SERIAL_NUMBER "Серійний номер" + IDS_CA_VERSION "CA Version" + IDS_CROSS_CA_VERSION "Cross CA Version" + IDS_SERIALIZED_SIG_SERIAL_NUMBER "Serialized Signature Serial Number" + IDS_PRINCIPAL_NAME "Principal Name" + IDS_WINDOWS_PRODUCT_UPDATE "Windows Product Update" + IDS_ENROLLMENT_NAME_VALUE_PAIR "Enrollment Name Value Pair" + IDS_OS_VERSION "OS Version" + IDS_ENROLLMENT_CSP "Enrollment CSP" + IDS_CRL_NUMBER "CRL Number" + IDS_DELTA_CRL_INDICATOR "Delta CRL Indicator" + IDS_ISSUING_DIST_POINT "Issuing Distribution Point" + IDS_FRESHEST_CRL "Freshest CRL" + IDS_NAME_CONSTRAINTS "Name Constraints" + IDS_POLICY_MAPPINGS "Policy Mappings" + IDS_POLICY_CONSTRAINTS "Policy Constraints" + IDS_CROSS_CERT_DIST_POINTS "Cross-Certificate Distribution Points" + IDS_APPLICATION_POLICIES "Application Policies" + IDS_APPLICATION_POLICY_MAPPINGS "Application Policy Mappings" + IDS_APPLICATION_POLICY_CONSTRAINTS "Application Policy Constraints" + IDS_CMC_DATA "CMC Data" + IDS_CMC_RESPONSE "CMC Response" + IDS_UNSIGNED_CMC_REQUEST "Unsigned CMC Request" + IDS_CMC_STATUS_INFO "CMC Status Info" + IDS_CMC_EXTENSIONS "CMC Extensions" + IDS_CMC_ATTRIBUTES "CMC Attributes" + IDS_PKCS_7_DATA "PKCS 7 Data" + IDS_PKCS_7_SIGNED "PKCS 7 Signed" + IDS_PKCS_7_ENVELOPED "PKCS 7 Enveloped" + IDS_PKCS_7_SIGNED_ENVELOPED "PKCS 7 Signed Enveloped" + IDS_PKCS_7_DIGESTED "PKCS 7 Digested" + IDS_PKCS_7_ENCRYPTED "PKCS 7 Encrypted" + IDS_PREVIOUS_CA_CERT_HASH "Previous CA Certificate Hash" + IDS_CRL_VIRTUAL_BASE "Virtual Base CRL Number" + IDS_CRL_NEXT_PUBLISH "Next CRL Publish" + IDS_CA_EXCHANGE "CA Encryption Certificate" + IDS_KEY_RECOVERY_AGENT "Key Recovery Agent" + IDS_CERTIFICATE_TEMPLATE "Certificate Template Information" + IDS_ENTERPRISE_ROOT_OID "Enterprise Root OID" + IDS_RDN_DUMMY_SIGNER "Dummy Signer" + IDS_ARCHIVED_KEY_ATTR "Encrypted Private Key" + IDS_CRL_SELF_CDP "Published CRL Locations" + IDS_REQUIRE_CERT_CHAIN_POLICY "Enforce Certificate Chain Policy" + IDS_TRANSACTION_ID "Transaction Id" + IDS_SENDER_NONCE "Sender Nonce" + IDS_RECIPIENT_NONCE "Recipient Nonce" + IDS_REG_INFO "Reg Info" + IDS_GET_CERTIFICATE "Get Certificate" + IDS_GET_CRL "Get CRL" + IDS_REVOKE_REQUEST "Revoke Request" + IDS_QUERY_PENDING "Query Pending" + IDS_SORTED_CTL "Certificate Trust List" + IDS_ARCHIVED_KEY_CERT_HASH "Archived Key Certificate Hash" + IDS_PRIVATE_KEY_USAGE_PERIOD "Private Key Usage Period" + IDS_CLIENT_INFORMATION "КлієнÑькі Дані" + IDS_SERVER_AUTHENTICATION "Server Authentication" + IDS_CLIENT_AUTHENTICATION "Client Authentication" + IDS_CODE_SIGNING "Code Signing" + IDS_SECURE_EMAIL "Secure Email" + IDS_TIME_STAMPING "Time Stamping" + IDS_MICROSOFT_TRUST_LIST_SIGNING "Microsoft Trust List Signing" + IDS_MICROSOFT_TIME_STAMPING "Microsoft Time Stamping" + IDS_IPSEC_END_SYSTEM "IP security end system" + IDS_IPSEC_TUNNEL "IP security tunnel termination" + IDS_IPSEC_USER "IP security user" + IDS_EFS "Encrypting File System" + IDS_WHQL_CRYPTO "Windows Hardware Driver Verification" + IDS_NT5_CRYPTO "Windows System Component Verification" + IDS_OEM_WHQL_CRYPTO "OEM Windows System Component Verification" + IDS_EMBEDDED_NT_CRYPTO "Embedded Windows System Component Verification" + IDS_KEY_PACK_LICENSES "Key Pack Licenses" + IDS_LICENSE_SERVER "License Server Verification" + IDS_SMART_CARD_LOGON "Smart Card Logon" + IDS_DIGITAL_RIGHTS "Digital Rights" + IDS_QUALIFIED_SUBORDINATION "Qualified Subordination" + IDS_KEY_RECOVERY "Key Recovery" + IDS_DOCUMENT_SIGNING "Document Signing" + IDS_IPSEC_IKE_INTERMEDIATE "IP security IKE intermediate" + IDS_FILE_RECOVERY "File Recovery" + IDS_ROOT_LIST_SIGNER "Root List Signer" + IDS_ANY_APPLICATION_POLICIES "All application policies" + IDS_DS_EMAIL_REPLICATION "Directory Service Email Replication" + IDS_ENROLLMENT_AGENT "Certificate Request Agent" + IDS_LIFETIME_SIGNING "Lifetime Signing" + IDS_ANY_CERT_POLICY "All issuance policies" +} + +STRINGTABLE DISCARDABLE +{ + IDS_LOCALIZEDNAME_ROOT "Trusted Root Certification Authorities" + IDS_LOCALIZEDNAME_MY "Personal" + IDS_LOCALIZEDNAME_CA "Intermediate Certification Authorities" + IDS_LOCALIZEDNAME_ADDRESSBOOK "Other People" + IDS_LOCALIZEDNAME_TRUSTEDPUBLISHER "Trusted Publishers" + IDS_LOCALIZEDNAME_DISALLOWED "Untrusted Certificates" +} + +STRINGTABLE DISCARDABLE +{ + IDS_KEY_ID "KeyID=" + IDS_CERT_ISSUER "Certificate Issuer" + IDS_CERT_SERIAL_NUMBER "Certificate Serial Number=" + IDS_ALT_NAME_OTHER_NAME "Інше Ім'Ñ=" + IDS_ALT_NAME_RFC822_NAME "ÐдреÑа Ел. Пошти=" + IDS_ALT_NAME_DNS_NAME "DNS Name=" + IDS_ALT_NAME_DIRECTORY_NAME "Directory Address" + IDS_ALT_NAME_URL "URL=" + IDS_ALT_NAME_IP_ADDRESS "IP ÐдреÑа=" + IDS_ALT_NAME_MASK "МаÑка=" + IDS_ALT_NAME_REGISTERED_ID "Registered ID=" + IDS_USAGE_UNKNOWN "Unknown Key Usage" + IDS_SUBJECT_TYPE "Subject Type=" + IDS_SUBJECT_TYPE_CA "CA" + IDS_SUBJECT_TYPE_END_CERT "End Entity" + IDS_PATH_LENGTH "Path Length Constraint=" + IDS_PATH_LENGTH_NONE "None" + IDS_INFO_NOT_AVAILABLE "Information Not Available" + IDS_AIA "Authority Info Access" + IDS_ACCESS_METHOD "Access Method=" + IDS_ACCESS_METHOD_OCSP "OCSP" + IDS_ACCESS_METHOD_CA_ISSUERS "CA Issuers" + IDS_ACCESS_METHOD_UNKNOWN "Unknown Access Method" + IDS_ACCESS_LOCATION "Alternative Name" + IDS_CRL_DIST_POINT "CRL Distribution Point" + IDS_CRL_DIST_POINT_NAME "Distribution Point Name" + IDS_CRL_DIST_POINT_FULL_NAME "Full Name" + IDS_CRL_DIST_POINT_RDN_NAME "RDN Name" + IDS_CRL_DIST_POINT_REASON "CRL Reason=" + IDS_CRL_DIST_POINT_ISSUER "CRL Issuer" + IDS_REASON_KEY_COMPROMISE "Key Compromise" + IDS_REASON_CA_COMPROMISE "CA Compromise" + IDS_REASON_AFFILIATION_CHANGED "Affiliation Changed" + IDS_REASON_SUPERSEDED "Superseded" + IDS_REASON_CESSATION_OF_OPERATION "Operation Ceased" + IDS_REASON_CERTIFICATE_HOLD "Certificate Hold" + IDS_FINANCIAL_CRITERIA "ФінанÑові Дані=" + IDS_FINANCIAL_CRITERIA_AVAILABLE "Available" + IDS_FINANCIAL_CRITERIA_NOT_AVAILABLE "Not Available" + IDS_FINANCIAL_CRITERIA_MEETS_CRITERIA "Meets Criteria=" + IDS_YES "Yes" + IDS_NO "No" + IDS_DIGITAL_SIGNATURE "Цифровий ПідпиÑ" + IDS_NON_REPUDIATION "Non-Repudiation" + IDS_KEY_ENCIPHERMENT "Key Encipherment" + IDS_DATA_ENCIPHERMENT "Data Encipherment" + IDS_KEY_AGREEMENT "Key Agreement" + IDS_CERT_SIGN "Certificate Signing" + IDS_OFFLINE_CRL_SIGN "Off-line CRL Signing" + IDS_CRL_SIGN "CRL Signing" + IDS_ENCIPHER_ONLY "Encipher Only" + IDS_DECIPHER_ONLY "Decipher Only" + IDS_NETSCAPE_SSL_CLIENT "SSL Client Authentication" + IDS_NETSCAPE_SSL_SERVER "SSL Server Authentication" + IDS_NETSCAPE_SMIME "S/MIME" + IDS_NETSCAPE_SIGN "Signature" + IDS_NETSCAPE_SSL_CA "SSL CA" + IDS_NETSCAPE_SMIME_CA "S/MIME CA" + IDS_NETSCAPE_SIGN_CA "Signature CA" +} diff --git a/reactos/dll/win32/crypt32/crypt32_private.h b/reactos/dll/win32/crypt32/crypt32_private.h index cbdf5116f9c..8385bf50713 100644 --- a/reactos/dll/win32/crypt32/crypt32_private.h +++ b/reactos/dll/win32/crypt32/crypt32_private.h @@ -405,4 +405,8 @@ void ContextList_Free(struct ContextList *list); #define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1)) #define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((DWORD_PTR)(p))) +/* Check if the OID is a small int + */ +#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0) + #endif diff --git a/reactos/dll/win32/crypt32/decode.c b/reactos/dll/win32/crypt32/decode.c index 1fd23837395..fb3d36e8124 100644 --- a/reactos/dll/win32/crypt32/decode.c +++ b/reactos/dll/win32/crypt32/decode.c @@ -5578,7 +5578,7 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, SetLastError(ERROR_FILE_NOT_FOUND); return NULL; } - if (!HIWORD(lpszStructType)) + if (IS_INTOID(lpszStructType)) { switch (LOWORD(lpszStructType)) { diff --git a/reactos/dll/win32/crypt32/encode.c b/reactos/dll/win32/crypt32/encode.c index b7bbc83600c..c58b0e638e9 100644 --- a/reactos/dll/win32/crypt32/encode.c +++ b/reactos/dll/win32/crypt32/encode.c @@ -4305,7 +4305,7 @@ static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType, return NULL; } - if (!HIWORD(lpszStructType)) + if (IS_INTOID(lpszStructType)) { switch (LOWORD(lpszStructType)) { diff --git a/reactos/dll/win32/crypt32/object.c b/reactos/dll/win32/crypt32/object.c index 3d18c505fb4..b3f82936172 100644 --- a/reactos/dll/win32/crypt32/object.c +++ b/reactos/dll/win32/crypt32/object.c @@ -2525,7 +2525,7 @@ static CryptFormatObjectFunc CRYPT_GetBuiltinFormatFunction(DWORD encodingType, SetLastError(ERROR_FILE_NOT_FOUND); return NULL; } - if (!HIWORD(lpszStructType)) + if (IS_INTOID(lpszStructType)) { switch (LOWORD(lpszStructType)) { diff --git a/reactos/dll/win32/crypt32/oid.c b/reactos/dll/win32/crypt32/oid.c index 68a48520dac..ea30d9ccd45 100644 --- a/reactos/dll/win32/crypt32/oid.c +++ b/reactos/dll/win32/crypt32/oid.c @@ -170,7 +170,7 @@ static char *CRYPT_GetKeyName(DWORD dwEncodingType, LPCSTR pszFuncName, * "EncodingType 2" would be expected if it were a mask. Instead native * stores values in "EncodingType 3". */ - if (!HIWORD(pszOID)) + if (IS_INTOID(pszOID)) { snprintf(numericOID, sizeof(numericOID), "#%d", LOWORD(pszOID)); oid = numericOID; @@ -255,7 +255,7 @@ BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule, { struct OIDFunction *func; - if (HIWORD(rgFuncEntry[i].pszOID)) + if (!IS_INTOID(rgFuncEntry[i].pszOID)) func = CryptMemAlloc(sizeof(struct OIDFunction) + strlen(rgFuncEntry[i].pszOID) + 1); else @@ -263,7 +263,7 @@ BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule, if (func) { func->encoding = GET_CERT_ENCODING_TYPE(dwEncodingType); - if (HIWORD(rgFuncEntry[i].pszOID)) + if (!IS_INTOID(rgFuncEntry[i].pszOID)) { LPSTR oid; @@ -402,9 +402,9 @@ BOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet, { if (function->encoding == GET_CERT_ENCODING_TYPE(dwEncodingType)) { - if (HIWORD(pszOID)) + if (!IS_INTOID(pszOID)) { - if (HIWORD(function->entry.pszOID) && + if (!IS_INTOID(function->entry.pszOID) && !strcasecmp(function->entry.pszOID, pszOID)) { *ppvFuncAddr = function->entry.pvFuncAddr; @@ -1398,7 +1398,7 @@ static void init_oid_info(void) for (i = 0; i < sizeof(oidInfoConstructors) / sizeof(oidInfoConstructors[0]); i++) { - if (HIWORD(oidInfoConstructors[i].pwszName)) + if (!IS_INTRESOURCE(oidInfoConstructors[i].pwszName)) { struct OIDInfo *info; diff --git a/reactos/dll/win32/crypt32/store.c b/reactos/dll/win32/crypt32/store.c index 153d3aa71ea..a8923949974 100644 --- a/reactos/dll/win32/crypt32/store.c +++ b/reactos/dll/win32/crypt32/store.c @@ -745,7 +745,7 @@ HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, TRACE("(%s, %08x, %08lx, %08x, %p)\n", debugstr_a(lpszStoreProvider), dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara); - if (!HIWORD(lpszStoreProvider)) + if (IS_INTOID(lpszStoreProvider)) { switch (LOWORD(lpszStoreProvider)) { From 9373ee891db614c1837e9b86069ee747e0aee55b Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 20:55:29 +0000 Subject: [PATCH 061/211] [CRYPTUI] sync cryptui to wine 1.1.39 svn path=/trunk/; revision=45803 --- reactos/dll/win32/cryptui/cryptui.rc | 7 +- reactos/dll/win32/cryptui/cryptui_De.rc | 1 + reactos/dll/win32/cryptui/cryptui_En.rc | 3 +- reactos/dll/win32/cryptui/cryptui_Fr.rc | 2 +- reactos/dll/win32/cryptui/cryptui_Ko.rc | 1 + reactos/dll/win32/cryptui/cryptui_Lt.rc | 1 + reactos/dll/win32/cryptui/cryptui_Nl.rc | 1 + reactos/dll/win32/cryptui/cryptui_Pt.rc | 1 + reactos/dll/win32/cryptui/cryptuires.h | 1 + reactos/dll/win32/cryptui/main.c | 98 ++++++++++++++++++++++--- 10 files changed, 102 insertions(+), 14 deletions(-) diff --git a/reactos/dll/win32/cryptui/cryptui.rc b/reactos/dll/win32/cryptui/cryptui.rc index 5460ca2dec7..6f2a5304dab 100644 --- a/reactos/dll/win32/cryptui/cryptui.rc +++ b/reactos/dll/win32/cryptui/cryptui.rc @@ -46,10 +46,13 @@ IDB_CERT_WATERMARK BITMAP LOADONCALL DISCARDABLE certwatermark.bmp /* @makedep: certheader.bmp */ IDB_CERT_HEADER BITMAP LOADONCALL DISCARDABLE certheader.bmp -#include "cryptui_De.rc" #include "cryptui_En.rc" -#include "cryptui_Fr.rc" #include "cryptui_Ko.rc" + +/* UTF-8 */ +#include "cryptui_De.rc" +#include "cryptui_Fr.rc" #include "cryptui_Lt.rc" #include "cryptui_Nl.rc" #include "cryptui_Pt.rc" + diff --git a/reactos/dll/win32/cryptui/cryptui_De.rc b/reactos/dll/win32/cryptui/cryptui_De.rc index d34d88332cc..71740157666 100644 --- a/reactos/dll/win32/cryptui/cryptui_De.rc +++ b/reactos/dll/win32/cryptui/cryptui_De.rc @@ -119,6 +119,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Sind Sie sicher, dass Sie dieses Zertifikat entfernen möchten?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Sind Sie sicher, dass Sie diese Zertifikate entfernen möchten?" IDS_CERT_MGR "Zertifikate" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Garantiert die Identität eines entfernten Computers" IDS_PURPOSE_CLIENT_AUTH "Beweist Ihre Identität für einen entfernten Computers" IDS_PURPOSE_CODE_SIGNING "Schützt Software vor Manipulation nach der Veröffentlichung" diff --git a/reactos/dll/win32/cryptui/cryptui_En.rc b/reactos/dll/win32/cryptui/cryptui_En.rc index 5aee197a5f0..527ffa584f7 100644 --- a/reactos/dll/win32/cryptui/cryptui_En.rc +++ b/reactos/dll/win32/cryptui/cryptui_En.rc @@ -31,7 +31,7 @@ STRINGTABLE DISCARDABLE IDS_CERT_INFO_UNTRUSTED_ROOT "This certificate could not be validated to a trusted root certificate." IDS_CERT_INFO_PARTIAL_CHAIN "This certificate's issuer could not be found." IDS_CERT_INFO_BAD_PURPOSES "All the intended purposes of this certificate could not be verified." - IDS_CERT_INFO_PURPOSES "This cerificate is intended for the following purposes:" + IDS_CERT_INFO_PURPOSES "This certificate is intended for the following purposes:" IDS_SUBJECT_HEADING "Issued to: " IDS_ISSUER_HEADING "Issued by: " IDS_VALID_FROM "Valid from " @@ -117,6 +117,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Are you sure you want to remove this certificate?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Are you sure you want to remove these certificates?" IDS_CERT_MGR "Certificates" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Ensures the identify of a remote computer" IDS_PURPOSE_CLIENT_AUTH "Proves your identity to a remote computer" IDS_PURPOSE_CODE_SIGNING "Ensures software came from software publisher\nProtects software from alteration after publication" diff --git a/reactos/dll/win32/cryptui/cryptui_Fr.rc b/reactos/dll/win32/cryptui/cryptui_Fr.rc index 16b847fc6e7..5c5ca6891db 100644 --- a/reactos/dll/win32/cryptui/cryptui_Fr.rc +++ b/reactos/dll/win32/cryptui/cryptui_Fr.rc @@ -120,6 +120,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Voulez-vous réellement supprimer ce certificat ?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Voulez-vous réellement supprimer ces certificats ?" IDS_CERT_MGR "Certificats" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Prouve l'identité d'un ordinateur distant" IDS_PURPOSE_CLIENT_AUTH "Prouve votre identité à un ordinateur distant" IDS_PURPOSE_CODE_SIGNING "Garantit que des logiciels proviennent bien d'un éditeur de logiciels donné\nProtège le logiciel contre toute altération après publication" @@ -464,4 +465,3 @@ BEGIN LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SINGLESEL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, 115,67,174,100 END -#pragma code_page(default) diff --git a/reactos/dll/win32/cryptui/cryptui_Ko.rc b/reactos/dll/win32/cryptui/cryptui_Ko.rc index 66064114d7f..eaa6222f160 100644 --- a/reactos/dll/win32/cryptui/cryptui_Ko.rc +++ b/reactos/dll/win32/cryptui/cryptui_Ko.rc @@ -118,6 +118,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "ÀÌ ÀÎÁõ°Å¸¦ Á¦°ÅÇϱ⸦ ¿øÇմϱî?" IDS_WARN_REMOVE_PLURAL_DEFAULT "ÀÌ ÀÎÁõ¼­µé¸¦ Á¦°ÅÇϱ⸦ ¿øÇմϱî?" IDS_CERT_MGR "ÀÎÁõ¼­" + IDS_FRIENDLY_NAME_NONE "<¾øÀ½>" IDS_PURPOSE_SERVER_AUTH "¿ø°Ý ÄÄÇ»ÅÍÀÇ µ¿Àϼº º¸Áõ" IDS_PURPOSE_CLIENT_AUTH "´ç½ÅÀÇ ½Å¿øÀ» ¿ø°ÝÄÄÇ»ÅÍ·Î ÀÎÁõ" IDS_PURPOSE_CODE_SIGNING "¼ÒÇÁÆ®¿þ¾î ¹ßÇàÀڷκÎÅÍ ¿Â ¼ÒÇÁÆ®¿þ¾î º¸Áõ\n¹ßÇàµÈ ÈÄÀÇ ¼ÒÇÁÆ®¿þ¾î¸¦ °³Á¶·ÎºÎÅÍ º¸È£" diff --git a/reactos/dll/win32/cryptui/cryptui_Lt.rc b/reactos/dll/win32/cryptui/cryptui_Lt.rc index d4ba0eb2608..ee02eabf018 100644 --- a/reactos/dll/win32/cryptui/cryptui_Lt.rc +++ b/reactos/dll/win32/cryptui/cryptui_Lt.rc @@ -120,6 +120,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Ar tikrai norite paÅ¡alinti šį liudijimÄ…?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Ar tikrai norite paÅ¡alinti Å¡iuos liudijimus?" IDS_CERT_MGR "Liudijimai" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Garantuoja nutolusio kompiuterio tapatumÄ…" IDS_PURPOSE_CLIENT_AUTH "Ä®rodo jÅ«sų tapatumÄ… nutolusiam kompiuteriui" IDS_PURPOSE_CODE_SIGNING "Garantuoja, kad programinÄ— įranga yra iÅ¡ Å¡io leidÄ—jo\nApsaugo programinÄ™ įrangÄ… nuo pakeitimų po iÅ¡leidimo" diff --git a/reactos/dll/win32/cryptui/cryptui_Nl.rc b/reactos/dll/win32/cryptui/cryptui_Nl.rc index faa32108eeb..3a2d2edfb43 100644 --- a/reactos/dll/win32/cryptui/cryptui_Nl.rc +++ b/reactos/dll/win32/cryptui/cryptui_Nl.rc @@ -119,6 +119,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Weet u zeker dat u dit certificaat wilt verwijderen?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Weet u zeker dat u deze certificaten wilt verwijderen?" IDS_CERT_MGR "Certificaten" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Bewijst de identiteit van een remote computer" IDS_PURPOSE_CLIENT_AUTH "Bewijst uw identiteit aan een remote computer" IDS_PURPOSE_CODE_SIGNING "Bewijst dat de software kwam van de software uitgever\nBeschermt software tegen wijzigingen na publicatie" diff --git a/reactos/dll/win32/cryptui/cryptui_Pt.rc b/reactos/dll/win32/cryptui/cryptui_Pt.rc index f8795293d9f..4b528b5b1f9 100644 --- a/reactos/dll/win32/cryptui/cryptui_Pt.rc +++ b/reactos/dll/win32/cryptui/cryptui_Pt.rc @@ -119,6 +119,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Tem a certeza que deseja remover este certificado?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Tem a certeza que deseja remover estes certificados?" IDS_CERT_MGR "Certificados" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Assegura a identidade de um computador remoto" IDS_PURPOSE_CLIENT_AUTH "Prova a sua identidade a um computador remoto" IDS_PURPOSE_CODE_SIGNING "Assegura que o software veio de uma editora de software\nProtege o software de alterações após publicação" diff --git a/reactos/dll/win32/cryptui/cryptuires.h b/reactos/dll/win32/cryptui/cryptuires.h index 716dba5e3a6..df321df4632 100644 --- a/reactos/dll/win32/cryptui/cryptuires.h +++ b/reactos/dll/win32/cryptui/cryptuires.h @@ -116,6 +116,7 @@ #define IDS_WARN_REMOVE_DEFAULT 1092 #define IDS_WARN_REMOVE_PLURAL_DEFAULT 1093 #define IDS_CERT_MGR 1094 +#define IDS_FRIENDLY_NAME_NONE 1095 #define IDS_PURPOSE_SERVER_AUTH 1100 #define IDS_PURPOSE_CLIENT_AUTH 1101 diff --git a/reactos/dll/win32/cryptui/main.c b/reactos/dll/win32/cryptui/main.c index 980706434a1..a95a7a487d3 100644 --- a/reactos/dll/win32/cryptui/main.c +++ b/reactos/dll/win32/cryptui/main.c @@ -104,6 +104,7 @@ static void add_cert_to_view(HWND lv, PCCERT_CONTEXT cert, DWORD *allocatedLen, WCHAR dateFmt[80]; /* sufficient for LOCALE_SSHORTDATE */ WCHAR date[80]; SYSTEMTIME sysTime; + LPWSTR none; item.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT; item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); @@ -155,8 +156,9 @@ static void add_cert_to_view(HWND lv, PCCERT_CONTEXT cert, DWORD *allocatedLen, item.iSubItem = 2; SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); - len = CertGetNameStringW(cert, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, - NULL, 0); + if (!CertGetCertificateContextProperty(cert, CERT_FRIENDLY_NAME_PROP_ID, + NULL, &len)) + len = LoadStringW(hInstance, IDS_FRIENDLY_NAME_NONE, (LPWSTR)&none, 0); if (len > *allocatedLen) { HeapFree(GetProcessHeap(), 0, *str); @@ -166,9 +168,11 @@ static void add_cert_to_view(HWND lv, PCCERT_CONTEXT cert, DWORD *allocatedLen, } if (*str) { - CertGetNameStringW(cert, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, - *str, len); - item.pszText = *str; + if (!CertGetCertificateContextProperty(cert, CERT_FRIENDLY_NAME_PROP_ID, + *str, &len)) + item.pszText = none; + else + item.pszText = *str; item.iSubItem = 3; SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); } @@ -348,6 +352,8 @@ static CERT_ENHKEY_USAGE *create_advanced_filter(void) return advancedUsage; } +static int CALLBACK cert_mgr_sort_by_subject(LPARAM lp1, LPARAM lp2, LPARAM lp); + static void show_store_certs(HWND hwnd, HCERTSTORE store) { HWND lv = GetDlgItem(hwnd, IDC_MGR_CERTS); @@ -443,6 +449,8 @@ static void show_store_certs(HWND hwnd, HCERTSTORE store) HeapFree(GetProcessHeap(), 0, advanced->rgpszUsageIdentifier); HeapFree(GetProcessHeap(), 0, advanced); } + SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv, + (LPARAM)cert_mgr_sort_by_subject); } static const WCHAR my[] = { 'M','y',0 }; @@ -1062,6 +1070,48 @@ static void cert_mgr_do_export(HWND hwnd) } } +static int cert_mgr_sort_by_text(HWND lv, int col, int index1, int index2) +{ + LVITEMW item; + WCHAR buf1[MAX_STRING_LEN]; + WCHAR buf2[MAX_STRING_LEN]; + + item.cchTextMax = sizeof(buf1) / sizeof(buf1[0]); + item.mask = LVIF_TEXT; + item.pszText = buf1; + item.iItem = index1; + item.iSubItem = col; + SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item); + item.pszText = buf2; + item.iItem = index2; + SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item); + return strcmpW(buf1, buf2); +} + +static int CALLBACK cert_mgr_sort_by_subject(LPARAM lp1, LPARAM lp2, LPARAM lp) +{ + return cert_mgr_sort_by_text((HWND)lp, 0, lp1, lp2); +} + +static int CALLBACK cert_mgr_sort_by_issuer(LPARAM lp1, LPARAM lp2, LPARAM lp) +{ + return cert_mgr_sort_by_text((HWND)lp, 1, lp1, lp2); +} + +static int CALLBACK cert_mgr_sort_by_date(LPARAM lp1, LPARAM lp2, LPARAM lp) +{ + PCCERT_CONTEXT cert1 = (PCCERT_CONTEXT)lp1; + PCCERT_CONTEXT cert2 = (PCCERT_CONTEXT)lp2; + return CompareFileTime(&cert1->pCertInfo->NotAfter, + &cert2->pCertInfo->NotAfter); +} + +static int CALLBACK cert_mgr_sort_by_friendly_name(LPARAM lp1, LPARAM lp2, + LPARAM lp) +{ + return cert_mgr_sort_by_text((HWND)lp, 3, lp1, lp2); +} + static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { @@ -1141,6 +1191,35 @@ static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, cert_mgr_do_remove(hwnd); break; } + case LVN_COLUMNCLICK: + { + NMLISTVIEW *nmlv = (NMLISTVIEW *)lp; + HWND lv = GetDlgItem(hwnd, IDC_MGR_CERTS); + + /* FIXME: doesn't support swapping sort order between ascending + * and descending. + */ + switch (nmlv->iSubItem) + { + case 0: + SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv, + (LPARAM)cert_mgr_sort_by_subject); + break; + case 1: + SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv, + (LPARAM)cert_mgr_sort_by_issuer); + break; + case 2: + SendMessageW(lv, LVM_SORTITEMS, 0, + (LPARAM)cert_mgr_sort_by_date); + break; + case 3: + SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv, + (LPARAM)cert_mgr_sort_by_friendly_name); + break; + } + break; + } } break; } @@ -1385,7 +1464,7 @@ static void enumerate_stores(HWND hwnd, CRYPTUI_ENUM_DATA *pEnumData) static void free_store_info(HWND tree) { HTREEITEM next = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_CHILD, - (LPARAM)NULL); + 0); while (next) { @@ -1473,7 +1552,7 @@ static LRESULT CALLBACK select_store_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, { HWND tree = GetDlgItem(hwnd, IDC_STORE_LIST); HTREEITEM selection = (HTREEITEM)SendMessageW(tree, - TVM_GETNEXTITEM, TVGN_CARET, (LPARAM)NULL); + TVM_GETNEXTITEM, TVGN_CARET, 0); selectInfo = (struct SelectStoreInfo *)GetWindowLongPtrW(hwnd, DWLP_USER); @@ -4034,8 +4113,7 @@ static void show_dialog_for_selected_cert(HWND hwnd) memset(&item, 0, sizeof(item)); item.mask = TVIF_HANDLE | TVIF_PARAM; - item.hItem = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_CARET, - (LPARAM)NULL); + item.hItem = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_CARET, 0); SendMessageW(tree, TVM_GETITEMW, 0, (LPARAM)&item); data = get_hierarchy_data_from_tree_item(tree, item.hItem); selection = lparam_to_index(data, item.lParam); @@ -4137,7 +4215,7 @@ static LRESULT CALLBACK hierarchy_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, memset(&item, 0, sizeof(item)); item.mask = TVIF_HANDLE | TVIF_PARAM; item.hItem = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_ROOT, - (LPARAM)NULL); + 0); data = get_hierarchy_data_from_tree_item(tree, item.hItem); /* Delete the contents of the tree */ SendMessageW(tree, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); From 97708b84097d439e226e470b499a81a7fae10720 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 20:55:41 +0000 Subject: [PATCH 062/211] [CRYPTNET] sync cryptnet to wine 1.1.39 svn path=/trunk/; revision=45804 --- reactos/dll/win32/cryptnet/cryptnet_main.c | 582 +++++++++++++++------ 1 file changed, 429 insertions(+), 153 deletions(-) diff --git a/reactos/dll/win32/cryptnet/cryptnet_main.c b/reactos/dll/win32/cryptnet/cryptnet_main.c index 9301a56733b..0b4e31dd9b7 100644 --- a/reactos/dll/win32/cryptnet/cryptnet_main.c +++ b/reactos/dll/win32/cryptnet/cryptnet_main.c @@ -40,6 +40,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(cryptnet); +#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0) + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); @@ -92,9 +94,7 @@ HRESULT WINAPI DllUnregisterServer(void) static const char *url_oid_to_str(LPCSTR oid) { - if (HIWORD(oid)) - return oid; - else + if (IS_INTOID(oid)) { static char buf[10]; @@ -115,6 +115,8 @@ static const char *url_oid_to_str(LPCSTR oid) return buf; } } + else + return oid; } typedef BOOL (WINAPI *UrlDllGetObjectUrlFunc)(LPCSTR, LPVOID, DWORD, @@ -123,18 +125,6 @@ typedef BOOL (WINAPI *UrlDllGetObjectUrlFunc)(LPCSTR, LPVOID, DWORD, static BOOL WINAPI CRYPT_GetUrlFromCertificateIssuer(LPCSTR pszUrlOid, LPVOID pvPara, DWORD dwFlags, PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, PCRYPT_URL_INFO pUrlInfo, DWORD *pcbUrlInfo, LPVOID pvReserved) -{ - /* FIXME: This depends on the AIA (authority info access) extension being - * supported in crypt32. - */ - FIXME("\n"); - SetLastError(CRYPT_E_NOT_FOUND); - return FALSE; -} - -static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, - LPVOID pvPara, DWORD dwFlags, PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, - PCRYPT_URL_INFO pUrlInfo, DWORD *pcbUrlInfo, LPVOID pvReserved) { PCCERT_CONTEXT cert = pvPara; PCERT_EXTENSION ext; @@ -146,39 +136,37 @@ static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, SetLastError(CRYPT_E_NOT_FOUND); return FALSE; } - if ((ext = CertFindExtension(szOID_CRL_DIST_POINTS, + if ((ext = CertFindExtension(szOID_AUTHORITY_INFO_ACCESS, cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) { - CRL_DIST_POINTS_INFO *info; + CERT_AUTHORITY_INFO_ACCESS *aia; DWORD size; - ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_AUTHORITY_INFO_ACCESS, ext->Value.pbData, ext->Value.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, - &info, &size); + &aia, &size); if (ret) { DWORD i, cUrl, bytesNeeded = sizeof(CRYPT_URL_ARRAY); - for (i = 0, cUrl = 0; i < info->cDistPoint; i++) - if (info->rgDistPoint[i].DistPointName.dwDistPointNameChoice - == CRL_DIST_POINT_FULL_NAME) + for (i = 0, cUrl = 0; i < aia->cAccDescr; i++) + if (!strcmp(aia->rgAccDescr[i].pszAccessMethod, + szOID_PKIX_CA_ISSUERS)) { - DWORD j; - CERT_ALT_NAME_INFO *name = - &info->rgDistPoint[i].DistPointName.u.FullName; - - for (j = 0; j < name->cAltEntry; j++) - if (name->rgAltEntry[j].dwAltNameChoice == - CERT_ALT_NAME_URL) + if (aia->rgAccDescr[i].AccessLocation.dwAltNameChoice == + CERT_ALT_NAME_URL) + { + if (aia->rgAccDescr[i].AccessLocation.u.pwszURL) { - if (name->rgAltEntry[j].u.pwszURL) - { - cUrl++; - bytesNeeded += sizeof(LPWSTR) + - (lstrlenW(name->rgAltEntry[j].u.pwszURL) + 1) - * sizeof(WCHAR); - } + cUrl++; + bytesNeeded += sizeof(LPWSTR) + + (lstrlenW(aia->rgAccDescr[i].AccessLocation.u. + pwszURL) + 1) * sizeof(WCHAR); } + } + else + FIXME("unsupported alt name type %d\n", + aia->rgAccDescr[i].AccessLocation.dwAltNameChoice); } if (!pcbUrlArray) { @@ -203,28 +191,22 @@ static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, (LPWSTR *)((BYTE *)pUrlArray + sizeof(CRYPT_URL_ARRAY)); nextUrl = (LPWSTR)((BYTE *)pUrlArray + sizeof(CRYPT_URL_ARRAY) + cUrl * sizeof(LPWSTR)); - for (i = 0; i < info->cDistPoint; i++) - if (info->rgDistPoint[i].DistPointName.dwDistPointNameChoice - == CRL_DIST_POINT_FULL_NAME) + for (i = 0; i < aia->cAccDescr; i++) + if (!strcmp(aia->rgAccDescr[i].pszAccessMethod, + szOID_PKIX_CA_ISSUERS)) { - DWORD j; - CERT_ALT_NAME_INFO *name = - &info->rgDistPoint[i].DistPointName.u.FullName; - - for (j = 0; j < name->cAltEntry; j++) - if (name->rgAltEntry[j].dwAltNameChoice == - CERT_ALT_NAME_URL) + if (aia->rgAccDescr[i].AccessLocation.dwAltNameChoice + == CERT_ALT_NAME_URL) + { + if (aia->rgAccDescr[i].AccessLocation.u.pwszURL) { - if (name->rgAltEntry[j].u.pwszURL) - { - lstrcpyW(nextUrl, - name->rgAltEntry[j].u.pwszURL); - pUrlArray->rgwszUrl[pUrlArray->cUrl++] = - nextUrl; - nextUrl += - (lstrlenW(name->rgAltEntry[j].u.pwszURL) + 1); - } + lstrcpyW(nextUrl, + aia->rgAccDescr[i].AccessLocation.u.pwszURL); + pUrlArray->rgwszUrl[pUrlArray->cUrl++] = + nextUrl; + nextUrl += (lstrlenW(nextUrl) + 1); } + } } } if (ret) @@ -247,7 +229,7 @@ static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, } } } - LocalFree(info); + LocalFree(aia); } } else @@ -255,6 +237,136 @@ static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, return ret; } +static BOOL CRYPT_GetUrlFromCRLDistPointsExt(const CRYPT_DATA_BLOB *value, + PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, PCRYPT_URL_INFO pUrlInfo, + DWORD *pcbUrlInfo) +{ + BOOL ret; + CRL_DIST_POINTS_INFO *info; + DWORD size; + + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CRL_DIST_POINTS, + value->pbData, value->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + if (ret) + { + DWORD i, cUrl, bytesNeeded = sizeof(CRYPT_URL_ARRAY); + + for (i = 0, cUrl = 0; i < info->cDistPoint; i++) + if (info->rgDistPoint[i].DistPointName.dwDistPointNameChoice + == CRL_DIST_POINT_FULL_NAME) + { + DWORD j; + CERT_ALT_NAME_INFO *name = + &info->rgDistPoint[i].DistPointName.u.FullName; + + for (j = 0; j < name->cAltEntry; j++) + if (name->rgAltEntry[j].dwAltNameChoice == + CERT_ALT_NAME_URL) + { + if (name->rgAltEntry[j].u.pwszURL) + { + cUrl++; + bytesNeeded += sizeof(LPWSTR) + + (lstrlenW(name->rgAltEntry[j].u.pwszURL) + 1) + * sizeof(WCHAR); + } + } + } + if (!pcbUrlArray) + { + SetLastError(E_INVALIDARG); + ret = FALSE; + } + else if (!pUrlArray) + *pcbUrlArray = bytesNeeded; + else if (*pcbUrlArray < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + *pcbUrlArray = bytesNeeded; + ret = FALSE; + } + else + { + LPWSTR nextUrl; + + *pcbUrlArray = bytesNeeded; + pUrlArray->cUrl = 0; + pUrlArray->rgwszUrl = + (LPWSTR *)((BYTE *)pUrlArray + sizeof(CRYPT_URL_ARRAY)); + nextUrl = (LPWSTR)((BYTE *)pUrlArray + sizeof(CRYPT_URL_ARRAY) + + cUrl * sizeof(LPWSTR)); + for (i = 0; i < info->cDistPoint; i++) + if (info->rgDistPoint[i].DistPointName.dwDistPointNameChoice + == CRL_DIST_POINT_FULL_NAME) + { + DWORD j; + CERT_ALT_NAME_INFO *name = + &info->rgDistPoint[i].DistPointName.u.FullName; + + for (j = 0; j < name->cAltEntry; j++) + if (name->rgAltEntry[j].dwAltNameChoice == + CERT_ALT_NAME_URL) + { + if (name->rgAltEntry[j].u.pwszURL) + { + lstrcpyW(nextUrl, + name->rgAltEntry[j].u.pwszURL); + pUrlArray->rgwszUrl[pUrlArray->cUrl++] = + nextUrl; + nextUrl += + (lstrlenW(name->rgAltEntry[j].u.pwszURL) + 1); + } + } + } + } + if (ret) + { + if (pcbUrlInfo) + { + FIXME("url info: stub\n"); + if (!pUrlInfo) + *pcbUrlInfo = sizeof(CRYPT_URL_INFO); + else if (*pcbUrlInfo < sizeof(CRYPT_URL_INFO)) + { + *pcbUrlInfo = sizeof(CRYPT_URL_INFO); + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pcbUrlInfo = sizeof(CRYPT_URL_INFO); + memset(pUrlInfo, 0, sizeof(CRYPT_URL_INFO)); + } + } + } + LocalFree(info); + } + return ret; +} + +static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, + LPVOID pvPara, DWORD dwFlags, PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, + PCRYPT_URL_INFO pUrlInfo, DWORD *pcbUrlInfo, LPVOID pvReserved) +{ + PCCERT_CONTEXT cert = pvPara; + PCERT_EXTENSION ext; + BOOL ret = FALSE; + + /* The only applicable flag is CRYPT_GET_URL_FROM_EXTENSION */ + if (dwFlags && !(dwFlags & CRYPT_GET_URL_FROM_EXTENSION)) + { + SetLastError(CRYPT_E_NOT_FOUND); + return FALSE; + } + if ((ext = CertFindExtension(szOID_CRL_DIST_POINTS, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + ret = CRYPT_GetUrlFromCRLDistPointsExt(&ext->Value, pUrlArray, + pcbUrlArray, pUrlInfo, pcbUrlInfo); + else + SetLastError(CRYPT_E_NOT_FOUND); + return ret; +} + /*********************************************************************** * CryptGetObjectUrl (CRYPTNET.@) */ @@ -269,7 +381,7 @@ BOOL WINAPI CryptGetObjectUrl(LPCSTR pszUrlOid, LPVOID pvPara, DWORD dwFlags, TRACE("(%s, %p, %08x, %p, %p, %p, %p, %p)\n", debugstr_a(pszUrlOid), pvPara, dwFlags, pUrlArray, pcbUrlArray, pUrlInfo, pcbUrlInfo, pvReserved); - if (!HIWORD(pszUrlOid)) + if (IS_INTOID(pszUrlOid)) { switch (LOWORD(pszUrlOid)) { @@ -566,7 +678,7 @@ static BOOL CRYPT_DownloadObject(DWORD dwRetrievalFlags, HINTERNET hHttp, } } if (ret) - object.cbData += bytesAvailable; + object.cbData += buffer.dwBufferLength; } else { @@ -1246,20 +1358,24 @@ static BOOL WINAPI CRYPT_CreateAny(LPCSTR pszObjectOid, if (!CertAddCertificateContextToStore(store, context, CERT_STORE_ADD_ALWAYS, NULL)) ret = FALSE; + CertFreeCertificateContext(context); break; case CERT_QUERY_CONTENT_CRL: if (!CertAddCRLContextToStore(store, context, CERT_STORE_ADD_ALWAYS, NULL)) ret = FALSE; + CertFreeCRLContext(context); break; case CERT_QUERY_CONTENT_CTL: if (!CertAddCTLContextToStore(store, context, CERT_STORE_ADD_ALWAYS, NULL)) ret = FALSE; + CertFreeCTLContext(context); break; default: CertAddStoreToCollection(store, contextStore, 0, 0); } + CertCloseStore(contextStore, 0); } else ret = FALSE; @@ -1284,7 +1400,7 @@ static BOOL CRYPT_GetCreateFunction(LPCSTR pszObjectOid, *pFunc = NULL; *phFunc = 0; - if (!HIWORD(pszObjectOid)) + if (IS_INTOID(pszObjectOid)) { switch (LOWORD(pszObjectOid)) { @@ -1354,7 +1470,7 @@ static BOOL CRYPT_GetExpirationFunction(LPCSTR pszObjectOid, { BOOL ret; - if (!HIWORD(pszObjectOid)) + if (IS_INTOID(pszObjectOid)) { switch (LOWORD(pszObjectOid)) { @@ -1437,6 +1553,238 @@ BOOL WINAPI CryptRetrieveObjectByUrlW(LPCWSTR pszURL, LPCSTR pszObjectOid, return ret; } +static DWORD verify_cert_revocation_with_crl(PCCERT_CONTEXT cert, + PCCRL_CONTEXT crl, DWORD index, FILETIME *pTime, + PCERT_REVOCATION_STATUS pRevStatus) +{ + DWORD error; + + if (CertVerifyCRLTimeValidity(pTime, crl->pCrlInfo)) + { + /* The CRL isn't time valid */ + error = CRYPT_E_NO_REVOCATION_CHECK; + } + else + { + PCRL_ENTRY entry = NULL; + + CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + if (entry) + { + error = CRYPT_E_REVOKED; + pRevStatus->dwIndex = index; + } + else + error = ERROR_SUCCESS; + } + return error; +} + +static DWORD verify_cert_revocation_from_dist_points_ext( + const CRYPT_DATA_BLOB *value, PCCERT_CONTEXT cert, DWORD index, + FILETIME *pTime, DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, + PCERT_REVOCATION_STATUS pRevStatus) +{ + DWORD error = ERROR_SUCCESS, cbUrlArray; + + if (CRYPT_GetUrlFromCRLDistPointsExt(value, NULL, &cbUrlArray, NULL, NULL)) + { + CRYPT_URL_ARRAY *urlArray = CryptMemAlloc(cbUrlArray); + + if (urlArray) + { + DWORD j, retrievalFlags = 0, startTime, endTime, timeout; + BOOL ret; + + ret = CRYPT_GetUrlFromCRLDistPointsExt(value, urlArray, + &cbUrlArray, NULL, NULL); + if (dwFlags & CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION) + retrievalFlags |= CRYPT_CACHE_ONLY_RETRIEVAL; + if (dwFlags & CERT_VERIFY_REV_ACCUMULATIVE_TIMEOUT_FLAG && + pRevPara && pRevPara->cbSize >= offsetof(CERT_REVOCATION_PARA, + dwUrlRetrievalTimeout) + sizeof(DWORD)) + { + startTime = GetTickCount(); + endTime = startTime + pRevPara->dwUrlRetrievalTimeout; + timeout = pRevPara->dwUrlRetrievalTimeout; + } + else + endTime = timeout = 0; + if (!ret) + error = GetLastError(); + for (j = 0; !error && j < urlArray->cUrl; j++) + { + PCCRL_CONTEXT crl; + + ret = CryptRetrieveObjectByUrlW(urlArray->rgwszUrl[j], + CONTEXT_OID_CRL, retrievalFlags, timeout, (void **)&crl, + NULL, NULL, NULL, NULL); + if (ret) + { + error = verify_cert_revocation_with_crl(cert, crl, index, + pTime, pRevStatus); + if (!error && timeout) + { + DWORD time = GetTickCount(); + + if ((int)(endTime - time) <= 0) + { + error = ERROR_TIMEOUT; + pRevStatus->dwIndex = index; + } + else + timeout = endTime - time; + } + CertFreeCRLContext(crl); + } + else + error = CRYPT_E_REVOCATION_OFFLINE; + } + CryptMemFree(urlArray); + } + else + { + error = ERROR_OUTOFMEMORY; + pRevStatus->dwIndex = index; + } + } + else + { + error = GetLastError(); + pRevStatus->dwIndex = index; + } + return error; +} + +static DWORD verify_cert_revocation_from_aia_ext( + const CRYPT_DATA_BLOB *value, PCCERT_CONTEXT cert, DWORD index, + FILETIME *pTime, DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, + PCERT_REVOCATION_STATUS pRevStatus) +{ + BOOL ret; + DWORD error, size; + CERT_AUTHORITY_INFO_ACCESS *aia; + + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_AUTHORITY_INFO_ACCESS, + value->pbData, value->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &aia, &size); + if (ret) + { + DWORD i; + + for (i = 0; i < aia->cAccDescr; i++) + if (!strcmp(aia->rgAccDescr[i].pszAccessMethod, + szOID_PKIX_OCSP)) + { + if (aia->rgAccDescr[i].AccessLocation.dwAltNameChoice == + CERT_ALT_NAME_URL) + FIXME("OCSP URL = %s\n", + debugstr_w(aia->rgAccDescr[i].AccessLocation.u.pwszURL)); + else + FIXME("unsupported AccessLocation type %d\n", + aia->rgAccDescr[i].AccessLocation.dwAltNameChoice); + } + LocalFree(aia); + /* FIXME: lie and pretend OCSP validated the cert */ + error = ERROR_SUCCESS; + } + else + error = GetLastError(); + return error; +} + +static DWORD verify_cert_revocation(PCCERT_CONTEXT cert, DWORD index, + FILETIME *pTime, DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, + PCERT_REVOCATION_STATUS pRevStatus) +{ + DWORD error = ERROR_SUCCESS; + PCERT_EXTENSION ext; + + if ((ext = CertFindExtension(szOID_CRL_DIST_POINTS, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + error = verify_cert_revocation_from_dist_points_ext(&ext->Value, cert, + index, pTime, dwFlags, pRevPara, pRevStatus); + else if ((ext = CertFindExtension(szOID_AUTHORITY_INFO_ACCESS, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + error = verify_cert_revocation_from_aia_ext(&ext->Value, cert, + index, pTime, dwFlags, pRevPara, pRevStatus); + else + { + if (pRevPara && pRevPara->hCrlStore && pRevPara->pIssuerCert) + { + PCCRL_CONTEXT crl = NULL; + BOOL canSignCRLs; + + /* If the caller told us about the issuer, make sure the issuer + * can sign CRLs before looking for one. + */ + if ((ext = CertFindExtension(szOID_KEY_USAGE, + pRevPara->pIssuerCert->pCertInfo->cExtension, + pRevPara->pIssuerCert->pCertInfo->rgExtension))) + { + CRYPT_BIT_BLOB usage; + DWORD size = sizeof(usage); + + if (!CryptDecodeObjectEx(cert->dwCertEncodingType, X509_BITS, + ext->Value.pbData, ext->Value.cbData, + CRYPT_DECODE_NOCOPY_FLAG, NULL, &usage, &size)) + canSignCRLs = FALSE; + else if (usage.cbData > 2) + { + /* The key usage extension only defines 9 bits => no more + * than 2 bytes are needed to encode all known usages. + */ + canSignCRLs = FALSE; + } + else + { + BYTE usageBits = usage.pbData[usage.cbData - 1]; + + canSignCRLs = usageBits & CERT_CRL_SIGN_KEY_USAGE; + } + } + else + canSignCRLs = TRUE; + if (canSignCRLs) + { + /* If the caller was helpful enough to tell us where to find a + * CRL for the cert, look for one and check it. + */ + crl = CertFindCRLInStore(pRevPara->hCrlStore, + cert->dwCertEncodingType, + CRL_FIND_ISSUED_BY_SIGNATURE_FLAG | + CRL_FIND_ISSUED_BY_AKI_FLAG, + CRL_FIND_ISSUED_BY, pRevPara->pIssuerCert, NULL); + } + if (crl) + { + error = verify_cert_revocation_with_crl(cert, crl, index, + pTime, pRevStatus); + CertFreeCRLContext(crl); + } + else + { + error = CRYPT_E_NO_REVOCATION_CHECK; + pRevStatus->dwIndex = index; + } + } + else + { + error = CRYPT_E_NO_REVOCATION_CHECK; + pRevStatus->dwIndex = index; + } + } + return error; +} + +typedef struct _CERT_REVOCATION_PARA_NO_EXTRA_FIELDS { + DWORD cbSize; + PCCERT_CONTEXT pIssuerCert; + DWORD cCertStore; + HCERTSTORE *rgCertStore; + HCERTSTORE hCrlStore; + LPFILETIME pftTimeToUse; +} CERT_REVOCATION_PARA_NO_EXTRA_FIELDS, *PCERT_REVOCATION_PARA_NO_EXTRA_FIELDS; + typedef struct _OLD_CERT_REVOCATION_STATUS { DWORD cbSize; DWORD dwIndex; @@ -1452,7 +1800,8 @@ BOOL WINAPI CertDllVerifyRevocation(DWORD dwEncodingType, DWORD dwRevType, PCERT_REVOCATION_PARA pRevPara, PCERT_REVOCATION_STATUS pRevStatus) { DWORD error = 0, i; - BOOL ret; + FILETIME now; + LPFILETIME pTime = NULL; TRACE("(%08x, %d, %d, %p, %08x, %p, %p)\n", dwEncodingType, dwRevType, cContext, rgpvContext, dwFlags, pRevPara, pRevStatus); @@ -1463,106 +1812,33 @@ BOOL WINAPI CertDllVerifyRevocation(DWORD dwEncodingType, DWORD dwRevType, SetLastError(E_INVALIDARG); return FALSE; } + if (!cContext) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if (pRevPara && pRevPara->cbSize >= + sizeof(CERT_REVOCATION_PARA_NO_EXTRA_FIELDS)) + pTime = pRevPara->pftTimeToUse; + if (!pTime) + { + GetSystemTimeAsFileTime(&now); + pTime = &now; + } memset(&pRevStatus->dwIndex, 0, pRevStatus->cbSize - sizeof(DWORD)); if (dwRevType != CERT_CONTEXT_REVOCATION_TYPE) - { error = CRYPT_E_NO_REVOCATION_CHECK; - ret = FALSE; - } else { - ret = TRUE; - for (i = 0; ret && i < cContext; i++) - { - DWORD cbUrlArray; - - ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT, - rgpvContext[i], 0, NULL, &cbUrlArray, NULL, NULL, NULL); - if (!ret && GetLastError() == CRYPT_E_NOT_FOUND) - { - error = CRYPT_E_NO_REVOCATION_CHECK; - pRevStatus->dwIndex = i; - } - else if (ret) - { - CRYPT_URL_ARRAY *urlArray = CryptMemAlloc(cbUrlArray); - - if (urlArray) - { - DWORD j, retrievalFlags = 0, startTime, endTime, timeout; - - ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT, - rgpvContext[i], 0, urlArray, &cbUrlArray, NULL, NULL, - NULL); - if (dwFlags & CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION) - retrievalFlags |= CRYPT_CACHE_ONLY_RETRIEVAL; - if (dwFlags & CERT_VERIFY_REV_ACCUMULATIVE_TIMEOUT_FLAG && - pRevPara->cbSize >= offsetof(CERT_REVOCATION_PARA, - dwUrlRetrievalTimeout) + sizeof(DWORD)) - { - startTime = GetTickCount(); - endTime = startTime + pRevPara->dwUrlRetrievalTimeout; - timeout = pRevPara->dwUrlRetrievalTimeout; - } - else - endTime = timeout = 0; - for (j = 0; ret && j < urlArray->cUrl; j++) - { - PCCRL_CONTEXT crl; - - ret = CryptRetrieveObjectByUrlW(urlArray->rgwszUrl[j], - CONTEXT_OID_CRL, retrievalFlags, timeout, - (void **)&crl, NULL, NULL, NULL, NULL); - if (ret) - { - PCRL_ENTRY entry = NULL; - - CertFindCertificateInCRL( - rgpvContext[i], crl, 0, NULL, - &entry); - if (entry) - { - error = CRYPT_E_REVOKED; - pRevStatus->dwIndex = i; - ret = FALSE; - } - else if (timeout) - { - DWORD time = GetTickCount(); - - if ((int)(endTime - time) <= 0) - { - error = ERROR_TIMEOUT; - pRevStatus->dwIndex = i; - ret = FALSE; - } - else - timeout = endTime - time; - } - CertFreeCRLContext(crl); - } - else - error = CRYPT_E_REVOCATION_OFFLINE; - } - CryptMemFree(urlArray); - } - else - { - error = ERROR_OUTOFMEMORY; - pRevStatus->dwIndex = i; - ret = FALSE; - } - } - else - pRevStatus->dwIndex = i; - } + for (i = 0; !error && i < cContext; i++) + error = verify_cert_revocation(rgpvContext[i], i, pTime, dwFlags, + pRevPara, pRevStatus); } - - if (!ret) + if (error) { SetLastError(error); pRevStatus->dwError = error; } - TRACE("returning %d (%08x)\n", ret, error); - return ret; + TRACE("returning %d (%08x)\n", !error, error); + return !error; } From 424ee134e094b1e929358a5522a54c647834dddb Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 21:01:57 +0000 Subject: [PATCH 063/211] [PSDK] add xmllite.idl from wine 1.1.39 svn path=/trunk/; revision=45805 --- reactos/include/psdk/psdk.rbuild | 1 + reactos/include/psdk/xmllite.idl | 111 +++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 reactos/include/psdk/xmllite.idl diff --git a/reactos/include/psdk/psdk.rbuild b/reactos/include/psdk/psdk.rbuild index 0816fd6058f..6d5cc78d8dc 100644 --- a/reactos/include/psdk/psdk.rbuild +++ b/reactos/include/psdk/psdk.rbuild @@ -66,6 +66,7 @@ comcat.idl xmldso.idl xmldom.idl + xmllite.idl stdole2.idl diff --git a/reactos/include/psdk/xmllite.idl b/reactos/include/psdk/xmllite.idl new file mode 100644 index 00000000000..552b5d646b9 --- /dev/null +++ b/reactos/include/psdk/xmllite.idl @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2010 Nikolay Sivov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "unknwn.idl"; +import "objidl.idl"; +import "oaidl.idl"; + +typedef enum XmlNodeType { + XmlNodeType_None = 0, + XmlNodeType_Element = 1, + XmlNodeType_Attribute = 2, + XmlNodeType_Text = 3, + XmlNodeType_CDATA = 4, + XmlNodeType_ProcessingInstruction = 7, + XmlNodeType_Comment = 8, + XmlNodeType_DocumentType = 10, + XmlNodeType_Whitespace = 13, + XmlNodeType_EndElement = 15, + XmlNodeType_XmlDeclaration = 17, + _XmlNodeType_Last = 17 +} XmlNodeType; + +/* IXmlReader */ +[ + local, + object, + uuid(7279fc81-709d-4095-b63d-69fe4b0d9030), + pointer_default(unique) +] +interface IXmlReader : IUnknown +{ + HRESULT SetInput( [in] IUnknown *input); + HRESULT GetProperty( [in] UINT property, [out] LONG_PTR *value); + HRESULT SetProperty( [in] UINT property, [in] LONG_PTR value); + HRESULT Read( [out] XmlNodeType *node_type); + HRESULT GetNodeType( [out] XmlNodeType *node_type); + HRESULT MoveToFirstAttribute(void); + HRESULT MoveToNextAttribute(void); + HRESULT MoveToAttributeByName( [in] LPCWSTR local_name, + [in] LPCWSTR namespaceUri); + HRESULT MoveToElement(void); + HRESULT GetQualifiedName( [out] LPCWSTR *qualifiedName, + [out] UINT *qualifiedName_length); + HRESULT GetNamespaceUri( [out] LPCWSTR *namespaceUri, + [out] UINT *nnamespaceUri_length); + HRESULT GetLocalName( [out] LPCWSTR *local_name, + [out] UINT *locale_name_length); + HRESULT GetPrefix( [out] LPCWSTR *prefix, + [out] UINT *prefix_length); + HRESULT GetValue( [out] LPCWSTR *value, + [out] UINT *value_length); + HRESULT ReadValueChunk( [out] WCHAR *buffer, + [in] UINT chunk_size, + [in,out] UINT *read); + HRESULT GetBaseUri( [out] LPCWSTR *baseUri, + [out] UINT *baseUri_length); + BOOL IsDefault(void); + BOOL IsEmptyElement(void); + HRESULT GetLineNumber( [out] UINT *lineNumber); + HRESULT GetLinePosition( [out] UINT *linePosition); + HRESULT GetAttributeCount( [out] UINT *attributeCount); + HRESULT GetDepth( [out] UINT *depth); + BOOL IsEOF(void); +} + +/* IXmlReader state */ +cpp_quote("typedef enum XmlReadState") +cpp_quote("{") +cpp_quote(" XmlReadState_Initial = 0,") +cpp_quote(" XmlReadState_Interactive = 1,") +cpp_quote(" XmlReadState_Error = 2,") +cpp_quote(" XmlReadState_EndOfFile = 3,") +cpp_quote(" XmlReadState_Closed = 4") +cpp_quote("} XmlReadState;") + +/* IXmlReader properties */ +cpp_quote("typedef enum XmlReaderProperty") +cpp_quote("{") +cpp_quote(" XmlReaderProperty_MultiLanguage = 0,") +cpp_quote(" XmlReaderProperty_ConformanceLevel = XmlReaderProperty_MultiLanguage + 1,") +cpp_quote(" XmlReaderProperty_RandomAccess = XmlReaderProperty_ConformanceLevel + 1,") +cpp_quote(" XmlReaderProperty_XmlResolver = XmlReaderProperty_RandomAccess + 1,") +cpp_quote(" XmlReaderProperty_DtdProcessing = XmlReaderProperty_XmlResolver + 1,") +cpp_quote(" XmlReaderProperty_ReadState = XmlReaderProperty_DtdProcessing + 1,") +cpp_quote(" XmlReaderProperty_MaxElementDepth = XmlReaderProperty_ReadState + 1,") +cpp_quote(" XmlReaderProperty_MaxEntityExpansion = XmlReaderProperty_MaxElementDepth + 1,") +cpp_quote(" _XmlReaderProperty_Last = XmlReaderProperty_MaxEntityExpansion") +cpp_quote("} XmlReaderProperty;") + +/* IXmlReader construction */ +cpp_quote("STDAPI CreateXmlReader(REFIID riid, void **ppvObject, IMalloc *pMalloc);") + +cpp_quote("typedef IUnknown IXmlReaderInput;") +cpp_quote("STDAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, IMalloc *pMalloc,") +cpp_quote(" LPCWSTR encoding, BOOL hint,") +cpp_quote(" LPCWSTR base_uri, IXmlReaderInput **ppInput);") From ba539d0eb06460b787140a69c057a0bc09330077 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Wed, 3 Mar 2010 21:02:05 +0000 Subject: [PATCH 064/211] [XMLLITE] sync xmllite to wine 1.1.39 svn path=/trunk/; revision=45806 --- reactos/dll/win32/xmllite/reader.c | 493 +++++++++++++++++++++++ reactos/dll/win32/xmllite/xmllite.rbuild | 1 + reactos/dll/win32/xmllite/xmllite.spec | 4 +- 3 files changed, 496 insertions(+), 2 deletions(-) create mode 100644 reactos/dll/win32/xmllite/reader.c diff --git a/reactos/dll/win32/xmllite/reader.c b/reactos/dll/win32/xmllite/reader.c new file mode 100644 index 00000000000..00a48fc693d --- /dev/null +++ b/reactos/dll/win32/xmllite/reader.c @@ -0,0 +1,493 @@ +/* + * IXmlReader implementation + * + * Copyright 2010 Nikolay Sivov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include +#include "windef.h" +#include "winbase.h" +#include "initguid.h" +#include "objbase.h" +#include "xmllite.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(xmllite); + +/* not defined in public headers */ +DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda); + +static HRESULT xmlreaderinput_query_for_stream(IXmlReaderInput *iface, void **pObj); + +typedef struct _xmlreader +{ + const IXmlReaderVtbl *lpVtbl; + LONG ref; + IXmlReaderInput *input; + ISequentialStream *stream;/* stored as sequential stream, cause currently + optimizations possible with IStream aren't implemented */ + XmlReadState state; + UINT line, pos; /* reader position in XML stream */ +} xmlreader; + +typedef struct _xmlreaderinput +{ + const IUnknownVtbl *lpVtbl; + LONG ref; + IUnknown *input; /* reference passed on IXmlReaderInput creation */ +} xmlreaderinput; + +static inline xmlreader *impl_from_IXmlReader(IXmlReader *iface) +{ + return (xmlreader *)((char*)iface - FIELD_OFFSET(xmlreader, lpVtbl)); +} + +static inline xmlreaderinput *impl_from_IXmlReaderInput(IXmlReaderInput *iface) +{ + return (xmlreaderinput *)((char*)iface - FIELD_OFFSET(xmlreaderinput, lpVtbl)); +} + +static HRESULT WINAPI xmlreader_QueryInterface(IXmlReader *iface, REFIID riid, void** ppvObject) +{ + xmlreader *This = impl_from_IXmlReader(iface); + + TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IXmlReader)) + { + *ppvObject = iface; + } + else + { + FIXME("interface %s not implemented\n", debugstr_guid(riid)); + return E_NOINTERFACE; + } + + IXmlReader_AddRef(iface); + + return S_OK; +} + +static ULONG WINAPI xmlreader_AddRef(IXmlReader *iface) +{ + xmlreader *This = impl_from_IXmlReader(iface); + TRACE("%p\n", This); + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI xmlreader_Release(IXmlReader *iface) +{ + xmlreader *This = impl_from_IXmlReader(iface); + LONG ref; + + TRACE("%p\n", This); + + ref = InterlockedDecrement(&This->ref); + if (ref == 0) + { + if (This->input) IUnknown_Release(This->input); + if (This->stream) IUnknown_Release(This->stream); + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input) +{ + xmlreader *This = impl_from_IXmlReader(iface); + HRESULT hr; + + TRACE("(%p %p)\n", This, input); + + if (This->input) + { + IUnknown_Release(This->input); + This->input = NULL; + } + + if (This->stream) + { + IUnknown_Release(This->stream); + This->stream = NULL; + } + + This->line = This->pos = 0; + + /* just reset current input */ + if (!input) + { + This->state = XmlReadState_Initial; + return S_OK; + } + + /* now try IXmlReaderInput, ISequentialStream, IStream */ + hr = IUnknown_QueryInterface(input, &IID_IXmlReaderInput, (void**)&This->input); + if (hr != S_OK) + { + /* create IXmlReaderInput basing on supplied interface */ + hr = CreateXmlReaderInputWithEncodingName(input, + NULL, NULL, FALSE, NULL, &This->input); + if (hr != S_OK) return hr; + } + + /* set stream for supplied IXmlReaderInput */ + hr = xmlreaderinput_query_for_stream(This->input, (void**)&This->stream); + if (hr == S_OK) + This->state = XmlReadState_Initial; + + return hr; +} + +static HRESULT WINAPI xmlreader_GetProperty(IXmlReader* iface, UINT property, LONG_PTR *value) +{ + xmlreader *This = impl_from_IXmlReader(iface); + + TRACE("(%p %u %p)\n", This, property, value); + + if (!value) return E_INVALIDARG; + + switch (property) + { + case XmlReaderProperty_ReadState: + *value = This->state; + break; + default: + FIXME("Unimplemented property (%u)\n", property); + return E_NOTIMPL; + } + + return S_OK; +} + +static HRESULT WINAPI xmlreader_SetProperty(IXmlReader* iface, UINT property, LONG_PTR value) +{ + FIXME("(%p %u %lu): stub\n", iface, property, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_Read(IXmlReader* iface, XmlNodeType *node_type) +{ + FIXME("(%p %p): stub\n", iface, node_type); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetNodeType(IXmlReader* iface, XmlNodeType *node_type) +{ + FIXME("(%p %p): stub\n", iface, node_type); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_MoveToFirstAttribute(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_MoveToNextAttribute(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface, + LPCWSTR local_name, + LPCWSTR namespaceUri) +{ + FIXME("(%p %p %p): stub\n", iface, local_name, namespaceUri); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *qualifiedName, + UINT *qualifiedName_length) +{ + FIXME("(%p %p %p): stub\n", iface, qualifiedName, qualifiedName_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetNamespaceUri(IXmlReader* iface, + LPCWSTR *namespaceUri, + UINT *namespaceUri_length) +{ + FIXME("(%p %p %p): stub\n", iface, namespaceUri, namespaceUri_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetLocalName(IXmlReader* iface, + LPCWSTR *local_name, + UINT *local_name_length) +{ + FIXME("(%p %p %p): stub\n", iface, local_name, local_name_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetPrefix(IXmlReader* iface, + LPCWSTR *prefix, + UINT *prefix_length) +{ + FIXME("(%p %p %p): stub\n", iface, prefix, prefix_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetValue(IXmlReader* iface, + LPCWSTR *value, + UINT *value_length) +{ + FIXME("(%p %p %p): stub\n", iface, value, value_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_ReadValueChunk(IXmlReader* iface, + WCHAR *buffer, + UINT chunk_size, + UINT *read) +{ + FIXME("(%p %p %u %p): stub\n", iface, buffer, chunk_size, read); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetBaseUri(IXmlReader* iface, + LPCWSTR *baseUri, + UINT *baseUri_length) +{ + FIXME("(%p %p %p): stub\n", iface, baseUri, baseUri_length); + return E_NOTIMPL; +} + +static BOOL WINAPI xmlreader_IsDefault(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static BOOL WINAPI xmlreader_IsEmptyElement(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetLineNumber(IXmlReader* iface, UINT *lineNumber) +{ + xmlreader *This = impl_from_IXmlReader(iface); + + TRACE("(%p %p)\n", This, lineNumber); + + if (!lineNumber) return E_INVALIDARG; + + *lineNumber = This->line; + + return S_OK; +} + +static HRESULT WINAPI xmlreader_GetLinePosition(IXmlReader* iface, UINT *linePosition) +{ + xmlreader *This = impl_from_IXmlReader(iface); + + TRACE("(%p %p)\n", This, linePosition); + + if (!linePosition) return E_INVALIDARG; + + *linePosition = This->pos; + + return S_OK; +} + +static HRESULT WINAPI xmlreader_GetAttributeCount(IXmlReader* iface, UINT *attributeCount) +{ + FIXME("(%p %p): stub\n", iface, attributeCount); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetDepth(IXmlReader* iface, UINT *depth) +{ + FIXME("(%p %p): stub\n", iface, depth); + return E_NOTIMPL; +} + +static BOOL WINAPI xmlreader_IsEOF(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static const struct IXmlReaderVtbl xmlreader_vtbl = +{ + xmlreader_QueryInterface, + xmlreader_AddRef, + xmlreader_Release, + xmlreader_SetInput, + xmlreader_GetProperty, + xmlreader_SetProperty, + xmlreader_Read, + xmlreader_GetNodeType, + xmlreader_MoveToFirstAttribute, + xmlreader_MoveToNextAttribute, + xmlreader_MoveToAttributeByName, + xmlreader_MoveToElement, + xmlreader_GetQualifiedName, + xmlreader_GetNamespaceUri, + xmlreader_GetLocalName, + xmlreader_GetPrefix, + xmlreader_GetValue, + xmlreader_ReadValueChunk, + xmlreader_GetBaseUri, + xmlreader_IsDefault, + xmlreader_IsEmptyElement, + xmlreader_GetLineNumber, + xmlreader_GetLinePosition, + xmlreader_GetAttributeCount, + xmlreader_GetDepth, + xmlreader_IsEOF +}; + +/** IXmlReaderInput **/ + +/* Queries already stored interface for IStream/ISequentialStream. + Interface supplied on creation will be overwritten */ +static HRESULT xmlreaderinput_query_for_stream(IXmlReaderInput *iface, void **pObj) +{ + xmlreaderinput *This = impl_from_IXmlReaderInput(iface); + HRESULT hr; + + hr = IUnknown_QueryInterface(This->input, &IID_IStream, pObj); + if (hr != S_OK) + hr = IUnknown_QueryInterface(This->input, &IID_ISequentialStream, pObj); + + return hr; +} + +static HRESULT WINAPI xmlreaderinput_QueryInterface(IXmlReaderInput *iface, REFIID riid, void** ppvObject) +{ + xmlreaderinput *This = impl_from_IXmlReaderInput(iface); + + TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualGUID(riid, &IID_IXmlReaderInput) || + IsEqualGUID(riid, &IID_IUnknown)) + { + *ppvObject = iface; + } + else + { + FIXME("interface %s not implemented\n", debugstr_guid(riid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef(iface); + + return S_OK; +} + +static ULONG WINAPI xmlreaderinput_AddRef(IXmlReaderInput *iface) +{ + xmlreaderinput *This = impl_from_IXmlReaderInput(iface); + TRACE("%p\n", This); + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI xmlreaderinput_Release(IXmlReaderInput *iface) +{ + xmlreaderinput *This = impl_from_IXmlReaderInput(iface); + LONG ref; + + TRACE("%p\n", This); + + ref = InterlockedDecrement(&This->ref); + if (ref == 0) + { + if (This->input) IUnknown_Release(This->input); + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static const struct IUnknownVtbl xmlreaderinput_vtbl = +{ + xmlreaderinput_QueryInterface, + xmlreaderinput_AddRef, + xmlreaderinput_Release +}; + +HRESULT WINAPI CreateXmlReader(REFIID riid, void **pObject, IMalloc *pMalloc) +{ + xmlreader *reader; + + TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), pObject, pMalloc); + + if (pMalloc) FIXME("custom IMalloc not supported yet\n"); + + if (!IsEqualGUID(riid, &IID_IXmlReader)) + { + ERR("Unexpected IID requested -> (%s)\n", wine_dbgstr_guid(riid)); + return E_FAIL; + } + + reader = HeapAlloc(GetProcessHeap(), 0, sizeof (*reader)); + if(!reader) return E_OUTOFMEMORY; + + reader->lpVtbl = &xmlreader_vtbl; + reader->ref = 1; + reader->stream = NULL; + reader->input = NULL; + reader->state = XmlReadState_Closed; + reader->line = reader->pos = 0; + + *pObject = &reader->lpVtbl; + + TRACE("returning iface %p\n", *pObject); + + return S_OK; +} + +HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, + IMalloc *pMalloc, + LPCWSTR encoding, + BOOL hint, + LPCWSTR base_uri, + IXmlReaderInput **ppInput) +{ + xmlreaderinput *readerinput; + + FIXME("%p %p %s %d %s %p: stub\n", stream, pMalloc, wine_dbgstr_w(encoding), + hint, wine_dbgstr_w(base_uri), ppInput); + + if (!stream || !ppInput) return E_INVALIDARG; + + readerinput = HeapAlloc(GetProcessHeap(), 0, sizeof (*readerinput)); + if(!readerinput) return E_OUTOFMEMORY; + + readerinput->lpVtbl = &xmlreaderinput_vtbl; + readerinput->ref = 1; + IUnknown_QueryInterface(stream, &IID_IUnknown, (void**)&readerinput->input); + + *ppInput = (IXmlReaderInput*)&readerinput->lpVtbl; + + TRACE("returning iface %p\n", *ppInput); + + return S_OK; +} diff --git a/reactos/dll/win32/xmllite/xmllite.rbuild b/reactos/dll/win32/xmllite/xmllite.rbuild index 207c7839091..c74cd88e8c5 100644 --- a/reactos/dll/win32/xmllite/xmllite.rbuild +++ b/reactos/dll/win32/xmllite/xmllite.rbuild @@ -4,5 +4,6 @@ include/reactos/wine wine + reader.c xmllite_main.c diff --git a/reactos/dll/win32/xmllite/xmllite.spec b/reactos/dll/win32/xmllite/xmllite.spec index cf436372b36..d2d0ff7fad0 100644 --- a/reactos/dll/win32/xmllite/xmllite.spec +++ b/reactos/dll/win32/xmllite/xmllite.spec @@ -1,6 +1,6 @@ -@ stub CreateXmlReader +@ stdcall CreateXmlReader(ptr ptr ptr) @ stub CreateXmlReaderInputWithEncodingCodePage -@ stub CreateXmlReaderInputWithEncodingName +@ stdcall CreateXmlReaderInputWithEncodingName(ptr ptr ptr long ptr ptr) @ stub CreateXmlWriter @ stub CreateXmlWriterOutputWithEncodingCodePage @ stub CreateXmlWriterOutputWithEncodingName From 02f31de4d1f53b84b5b8a524568f23a3fdaad8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 3 Mar 2010 21:56:52 +0000 Subject: [PATCH 065/211] [hal] Add a mini-HAL static library Mostly the same thing as the real one, except interrupts and DMA svn path=/trunk/; revision=45809 --- reactos/hal/halx86/generic/bios.c | 6 ++++ reactos/hal/halx86/generic/bus/halbus.c | 2 ++ reactos/hal/halx86/generic/bus/pcibus.c | 4 +++ reactos/hal/halx86/generic/bus/pcidata.c | 2 ++ reactos/hal/halx86/generic/display.c | 2 ++ reactos/hal/halx86/generic/dma.c | 14 +++++++++ reactos/hal/halx86/generic/halinit.c | 14 +++++++++ reactos/hal/halx86/generic/misc.c | 4 +++ reactos/hal/halx86/generic/pic.c | 26 +++++++++++++++++ reactos/hal/halx86/generic/reboot.c | 2 ++ reactos/hal/halx86/generic/systimer.S | 2 ++ reactos/hal/halx86/generic/timer.c | 2 ++ reactos/hal/halx86/generic/usage.c | 2 ++ reactos/hal/halx86/hal_generic.rbuild | 37 ++++++++++++++++++++++++ reactos/hal/halx86/include/hal.h | 4 +++ 15 files changed, 123 insertions(+) diff --git a/reactos/hal/halx86/generic/bios.c b/reactos/hal/halx86/generic/bios.c index 273a92d3a50..1942dd3671f 100644 --- a/reactos/hal/halx86/generic/bios.c +++ b/reactos/hal/halx86/generic/bios.c @@ -196,6 +196,7 @@ HalpDispatchV86Opcode(IN PKTRAP_FRAME TrapFrame) /* V86 TRAP HANDLERS **********************************************************/ +#ifndef _MINIHAL_ VOID FASTCALL DECLSPEC_NORETURN @@ -234,6 +235,7 @@ HalpTrap06() longjmp(HalpSavedContext, 1); UNREACHABLE; } +#endif /* V8086 ENTER ****************************************************************/ @@ -497,6 +499,7 @@ HalpMapRealModeMemory(VOID) HalpFlushTLB(); } +#ifndef _MINIHAL_ VOID NTAPI HalpSwitchToRealModeTrapHandlers(VOID) @@ -517,6 +520,7 @@ HalpSwitchToRealModeTrapHandlers(VOID) // KeRegisterInterruptHandler(6, HalpTrap06); } +#endif VOID NTAPI @@ -626,6 +630,7 @@ HalpUnmapRealModeMemory(VOID) HalpFlushTLB(); } +#ifndef _MINIHAL_ BOOLEAN NTAPI HalpBiosDisplayReset(VOID) @@ -695,5 +700,6 @@ HalpBiosDisplayReset(VOID) __writeeflags(Flags); return TRUE; } +#endif /* EOF */ diff --git a/reactos/hal/halx86/generic/bus/halbus.c b/reactos/hal/halx86/generic/bus/halbus.c index 8421b774b63..d8e478f450f 100644 --- a/reactos/hal/halx86/generic/bus/halbus.c +++ b/reactos/hal/halx86/generic/bus/halbus.c @@ -27,8 +27,10 @@ HalpRegisterKdSupportFunctions(VOID) KdReleasePciDeviceforDebugging = HalpReleasePciDeviceForDebugging; /* Register memory functions */ +#ifndef _MINIHAL_ KdMapPhysicalMemory64 = HalpMapPhysicalMemory64; KdUnmapVirtualAddress = HalpUnmapVirtualAddress; +#endif /* Register ACPI stub */ KdCheckPowerButton = HalpCheckPowerButton; diff --git a/reactos/hal/halx86/generic/bus/pcibus.c b/reactos/hal/halx86/generic/bus/pcibus.c index 96d687ada97..50f1add18d8 100644 --- a/reactos/hal/halx86/generic/bus/pcibus.c +++ b/reactos/hal/halx86/generic/bus/pcibus.c @@ -702,6 +702,7 @@ PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo(VOID) { +#ifndef _MINIHAL_ WCHAR NameBuffer[8]; OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING KeyName, ConfigName, IdentName; @@ -924,6 +925,9 @@ HalpQueryPciRegistryInfo(VOID) /* Return it */ return PciRegistryInfo; +#else + return NULL; +#endif } VOID diff --git a/reactos/hal/halx86/generic/bus/pcidata.c b/reactos/hal/halx86/generic/bus/pcidata.c index 947128b76a6..83ccecef7d6 100644 --- a/reactos/hal/halx86/generic/bus/pcidata.c +++ b/reactos/hal/halx86/generic/bus/pcidata.c @@ -14,6 +14,7 @@ /* GLOBALS *******************************************************************/ +#ifndef _MINIHAL_ CHAR ClassTable[3922] = { 0x43, 0x20, 0x30, 0x30, 0x20, 0x20, 0x55, 0x6E, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, @@ -40415,3 +40416,4 @@ CHAR VendorTable[642355] = 0x20, 0x49, 0x6C, 0x6C, 0x65, 0x67, 0x61, 0x6C, 0x20, 0x56, 0x65, 0x6E, 0x64, 0x6F, 0x72, 0x20, 0x49, 0x44, 0x00, }; +#endif diff --git a/reactos/hal/halx86/generic/display.c b/reactos/hal/halx86/generic/display.c index 449ddc2986d..dc5f821240e 100644 --- a/reactos/hal/halx86/generic/display.c +++ b/reactos/hal/halx86/generic/display.c @@ -31,8 +31,10 @@ VOID NTAPI HalDisplayString(IN PCH String) { +#ifndef _MINIHAL_ /* Call the Inbv driver */ InbvDisplayString(String); +#endif } /* diff --git a/reactos/hal/halx86/generic/dma.c b/reactos/hal/halx86/generic/dma.c index 0b7b7f34827..bdfae48bfc0 100644 --- a/reactos/hal/halx86/generic/dma.c +++ b/reactos/hal/halx86/generic/dma.c @@ -75,11 +75,15 @@ #define NDEBUG #include +#ifndef _MINIHAL_ static KEVENT HalpDmaLock; static LIST_ENTRY HalpDmaAdapterList; static PADAPTER_OBJECT HalpEisaAdapter[8]; +#endif static BOOLEAN HalpEisaDma; +#ifndef _MINIHAL_ static PADAPTER_OBJECT HalpMasterAdapter; +#endif static const ULONG_PTR HalpEisaPortPage[8] = { FIELD_OFFSET(DMA_PAGE, Channel0), @@ -92,6 +96,7 @@ static const ULONG_PTR HalpEisaPortPage[8] = { FIELD_OFFSET(DMA_PAGE, Channel7) }; +#ifndef _MINIHAL_ static DMA_OPERATIONS HalpDmaOperations = { sizeof(DMA_OPERATIONS), (PPUT_DMA_ADAPTER)HalPutDmaAdapter, @@ -111,6 +116,7 @@ static DMA_OPERATIONS HalpDmaOperations = { NULL /*(PBUILD_SCATTER_GATHER_LIST)HalBuildScatterGatherList*/, NULL /*(PBUILD_MDL_FROM_SCATTER_GATHER_LIST)HalBuildMdlFromScatterGatherList*/ }; +#endif #define MAX_MAP_REGISTERS 64 @@ -118,6 +124,7 @@ static DMA_OPERATIONS HalpDmaOperations = { /* FUNCTIONS *****************************************************************/ +#ifndef _MINIHAL_ VOID HalpInitDma(VOID) { @@ -154,6 +161,7 @@ HalpInitDma(VOID) */ HalGetDmaAdapter = HalpGetDmaAdapter; } +#endif /** * @name HalpGetAdapterMaximumPhysicalAddress @@ -185,6 +193,7 @@ HalpGetAdapterMaximumPhysicalAddress(IN PADAPTER_OBJECT AdapterObject) return HighestAddress; } +#ifndef _MINIHAL_ /** * @name HalpGrowMapBuffers * @@ -428,6 +437,7 @@ HalpDmaAllocateChildAdapter(IN ULONG NumberOfMapRegisters, return AdapterObject; } +#endif /** * @name HalpDmaInitializeEisaAdapter @@ -564,6 +574,7 @@ HalpDmaInitializeEisaAdapter(IN PADAPTER_OBJECT AdapterObject, return TRUE; } +#ifndef _MINIHAL_ /** * @name HalGetAdapter * @@ -896,6 +907,7 @@ HalFreeCommonBuffer(IN PADAPTER_OBJECT AdapterObject, Length, CacheEnabled ? MmCached : MmNonCached); } +#endif /** * @name HalpDmaGetDmaAlignment @@ -984,6 +996,7 @@ HalReadDmaCounter(IN PADAPTER_OBJECT AdapterObject) return Count; } +#ifndef _MINIHAL_ /** * @name HalpGrowMapBufferWorker * @@ -1893,6 +1906,7 @@ IoMapTransfer(IN PADAPTER_OBJECT AdapterObject, */ return PhysicalAddress; } +#endif /** * @name HalFlushCommonBuffer diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 1fb157fa0b7..498bf5cc5bb 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -91,8 +91,10 @@ HalInitSystem(IN ULONG BootPhase, KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0); } +#ifndef _MINIHAL_ /* Initialize the PICs */ HalpInitializePICs(TRUE); +#endif /* Force initial PIC state */ KfRaiseIrql(KeGetCurrentIrql()); @@ -107,9 +109,17 @@ HalInitSystem(IN ULONG BootPhase, HalQuerySystemInformation = HaliQuerySystemInformation; HalSetSystemInformation = HaliSetSystemInformation; HalInitPnpDriver = NULL; // FIXME: TODO +#ifndef _MINIHAL_ HalGetDmaAdapter = HalpGetDmaAdapter; +#else + HalGetDmaAdapter = NULL; +#endif HalGetInterruptTranslator = NULL; // FIXME: TODO +#ifndef _MINIHAL_ HalResetDisplay = HalpBiosDisplayReset; +#else + HalResetDisplay = NULL; +#endif HalHaltSystem = HaliHaltSystem; /* Register IRQ 2 */ @@ -125,8 +135,10 @@ HalInitSystem(IN ULONG BootPhase, /* Setup busy waiting */ HalpCalibrateStallExecution(); +#ifndef _MINIHAL_ /* Initialize the clock */ HalpInitializeClock(); +#endif /* * We could be rebooting with a pending profile interrupt, @@ -142,6 +154,7 @@ HalInitSystem(IN ULONG BootPhase, /* Initialize bus handlers */ HalpInitBusHandler(); +#ifndef _MINIHAL_ /* Enable IRQ 0 */ HalpEnableInterruptHandler(IDT_DEVICE, 0, @@ -160,6 +173,7 @@ HalInitSystem(IN ULONG BootPhase, /* Initialize DMA. NT does this in Phase 0 */ HalpInitDma(); +#endif /* Do some HAL-specific initialization */ HalpInitPhase1(); diff --git a/reactos/hal/halx86/generic/misc.c b/reactos/hal/halx86/generic/misc.c index 1a0f4f81f7b..d188d50afb7 100644 --- a/reactos/hal/halx86/generic/misc.c +++ b/reactos/hal/halx86/generic/misc.c @@ -28,6 +28,7 @@ HalpCheckPowerButton(VOID) return; } +#ifndef _MINIHAL_ PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, @@ -51,6 +52,7 @@ HalpUnmapVirtualAddress(IN PVOID VirtualAddress, // MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT); } +#endif VOID NTAPI @@ -122,6 +124,7 @@ VOID NTAPI HalHandleNMI(IN PVOID NmiInfo) { +#ifndef _MINIHAL_ SYSTEM_CONTROL_PORT_B_REGISTER SystemControl; // @@ -202,6 +205,7 @@ HalHandleNMI(IN PVOID NmiInfo) // Halt the system // InbvDisplayString("\n*** The system has halted ***\n"); +#endif // // Enter the debugger if possible diff --git a/reactos/hal/halx86/generic/pic.c b/reactos/hal/halx86/generic/pic.c index 7197b9d91a8..a710d862567 100644 --- a/reactos/hal/halx86/generic/pic.c +++ b/reactos/hal/halx86/generic/pic.c @@ -14,6 +14,7 @@ /* GLOBALS ********************************************************************/ +#ifndef _MINIHAL_ /* * This table basically keeps track of level vs edge triggered interrupts. * Windows has 250+ entries, but it seems stupid to replicate that since the PIC @@ -1335,3 +1336,28 @@ HalpDispatchInterrupt2(VOID) } } +#else + +KIRQL +NTAPI +KeGetCurrentIrql(VOID) +{ + return PASSIVE_LEVEL; +} + +VOID +FASTCALL +KfLowerIrql( + IN KIRQL OldIrql) +{ +} + +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql) +{ + return NewIrql; +} + +#endif diff --git a/reactos/hal/halx86/generic/reboot.c b/reactos/hal/halx86/generic/reboot.c index e6a5cffee24..c7eda5e96c1 100644 --- a/reactos/hal/halx86/generic/reboot.c +++ b/reactos/hal/halx86/generic/reboot.c @@ -98,8 +98,10 @@ HalReturnToFirmware(IN FIRMWARE_REENTRY Action) case HalHaltRoutine: case HalRebootRoutine: +#ifndef _MINIHAL_ /* Acquire the display */ InbvAcquireDisplayOwnership(); +#endif /* Call the internal reboot function */ HalpReboot(); diff --git a/reactos/hal/halx86/generic/systimer.S b/reactos/hal/halx86/generic/systimer.S index 167bcf5fefd..945b5081a89 100644 --- a/reactos/hal/halx86/generic/systimer.S +++ b/reactos/hal/halx86/generic/systimer.S @@ -329,6 +329,7 @@ AndItsNotYou: ret .endfunc +#ifndef _MINIHAL_ .globl _KeStallExecutionProcessor@4 .func KeStallExecutionProcessor@4 _KeStallExecutionProcessor@4: @@ -359,6 +360,7 @@ Done: /* Return */ ret 4 .endfunc +#endif .global _KeQueryPerformanceCounter@4 .func KeQueryPerformanceCounter@4 diff --git a/reactos/hal/halx86/generic/timer.c b/reactos/hal/halx86/generic/timer.c index 360d237443d..6d90dada9b8 100644 --- a/reactos/hal/halx86/generic/timer.c +++ b/reactos/hal/halx86/generic/timer.c @@ -109,6 +109,7 @@ HalpInitializeClock(VOID) HalpCurrentRollOver = RollOver; } +#ifndef _MINIHAL_ VOID FASTCALL HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame) @@ -160,6 +161,7 @@ HalpProfileInterruptHandler(IN PKTRAP_FRAME TrapFrame) /* Spurious, just end the interrupt */ KiEoiHelper(TrapFrame); } +#endif /* PUBLIC FUNCTIONS ***********************************************************/ diff --git a/reactos/hal/halx86/generic/usage.c b/reactos/hal/halx86/generic/usage.c index 3493113920e..d35a3e3a964 100644 --- a/reactos/hal/halx86/generic/usage.c +++ b/reactos/hal/halx86/generic/usage.c @@ -63,6 +63,7 @@ HalpRegisterVector(IN UCHAR Flags, HalpIDTUsage[SystemVector].BusReleativeVector = BusVector; } +#ifndef _MINIHAL_ VOID NTAPI HalpEnableInterruptHandler(IN UCHAR Flags, @@ -87,6 +88,7 @@ HalpEnableInterruptHandler(IN UCHAR Flags, /* Enable the interrupt */ HalEnableSystemInterrupt(SystemVector, Irql, Mode); } +#endif /* * @unimplemented diff --git a/reactos/hal/halx86/hal_generic.rbuild b/reactos/hal/halx86/hal_generic.rbuild index 484f1ea5362..3980579d589 100644 --- a/reactos/hal/halx86/hal_generic.rbuild +++ b/reactos/hal/halx86/hal_generic.rbuild @@ -35,4 +35,41 @@ hal.h + + include + include + + + + + + bushndlr.c + isabus.c + halbus.c + pcibus.c + pcidata.c + sysbus.c + + beep.c + bios.c + cmos.c + dma.c + display.c + drive.c + misc.c + pic.c + portio.c + processor.c + profil.c + reboot.c + spinlock.c + sysinfo.c + systimer.S + timer.c + usage.c + + + halinit_up.c + + diff --git a/reactos/hal/halx86/include/hal.h b/reactos/hal/halx86/include/hal.h index 3cd6fcb5ae2..8d8f3154b4d 100644 --- a/reactos/hal/halx86/include/hal.h +++ b/reactos/hal/halx86/include/hal.h @@ -17,8 +17,12 @@ #undef _NTHAL_ #undef DECLSPEC_IMPORT #define DECLSPEC_IMPORT +#ifndef _MINIHAL_ #undef NTSYSAPI #define NTSYSAPI __declspec(dllimport) +#else +#undef _NTSYSTEM_ +#endif /* IFS/DDK/NDK Headers */ #include From 3ddda873f8ee6adcad7c2b0e2676840443f5715b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 3 Mar 2010 22:35:10 +0000 Subject: [PATCH 066/211] [freeldr] Add some more memory management functions svn path=/trunk/; revision=45811 --- reactos/boot/freeldr/freeldr/include/mm.h | 4 ++ reactos/boot/freeldr/freeldr/mm/mm.c | 51 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/reactos/boot/freeldr/freeldr/include/mm.h b/reactos/boot/freeldr/freeldr/include/mm.h index 36a47e0079f..a7840e37791 100644 --- a/reactos/boot/freeldr/freeldr/include/mm.h +++ b/reactos/boot/freeldr/freeldr/include/mm.h @@ -116,3 +116,7 @@ PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress PVOID MmHeapAlloc(ULONG MemorySize); VOID MmHeapFree(PVOID MemoryPointer); + +#define ExAllocatePool(pool, size) MmHeapAlloc(size) +#define ExAllocatePoolWithTag(pool, size, tag) MmHeapAlloc(size) +#define ExFreePool(p) MmHeapFree(p) diff --git a/reactos/boot/freeldr/freeldr/mm/mm.c b/reactos/boot/freeldr/freeldr/mm/mm.c index c06bb00f632..f4a4c69b095 100644 --- a/reactos/boot/freeldr/freeldr/mm/mm.c +++ b/reactos/boot/freeldr/freeldr/mm/mm.c @@ -345,3 +345,54 @@ PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(ULONG *NoEntries) return RealPageLookupTable; } + +#undef ExAllocatePoolWithTag +NTKERNELAPI +PVOID +NTAPI +ExAllocatePoolWithTag( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag) +{ + return MmHeapAlloc(NumberOfBytes); +} + +#undef ExFreePool +NTKERNELAPI +VOID +NTAPI +ExFreePool( + IN PVOID P) +{ + MmHeapFree(P); +} + +PVOID +NTAPI +RtlAllocateHeap( + IN PVOID HeapHandle, + IN ULONG Flags, + IN SIZE_T Size) +{ + PVOID ptr; + + ptr = MmHeapAlloc(Size); + if (ptr && (Flags & HEAP_ZERO_MEMORY)) + { + RtlZeroMemory(ptr, Size); + } + + return ptr; +} + +BOOLEAN +NTAPI +RtlFreeHeap( + IN PVOID HeapHandle, + IN ULONG Flags, + IN PVOID HeapBase) +{ + MmHeapFree(HeapBase); + return TRUE; +} From 4f1c346e27794f7d4f73dc8a74e32e13b1ffbf5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 3 Mar 2010 22:39:32 +0000 Subject: [PATCH 067/211] [freeldr] Allow opening of the raw device svn path=/trunk/; revision=45812 --- reactos/boot/freeldr/freeldr/fs/fs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reactos/boot/freeldr/freeldr/fs/fs.c b/reactos/boot/freeldr/freeldr/fs/fs.c index a2c5c495e2c..eb23215f789 100644 --- a/reactos/boot/freeldr/freeldr/fs/fs.c +++ b/reactos/boot/freeldr/freeldr/fs/fs.c @@ -319,6 +319,13 @@ LONG ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) FileData[DeviceId].FuncTable = NULL; return ret; } + else if (!*FileName) + { + /* Done, caller wanted to open the raw device */ + *FileId = DeviceId; + pDevice->ReferenceCount++; + return ESUCCESS; + } /* Try to detect the file system */ #ifndef _M_ARM From c1f8063dc713828b165627944d7726a15ff165fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 3 Mar 2010 22:54:51 +0000 Subject: [PATCH 068/211] [freeldr] Add KeBugCheckEx svn path=/trunk/; revision=45814 --- reactos/boot/freeldr/freeldr/debug.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/reactos/boot/freeldr/freeldr/debug.c b/reactos/boot/freeldr/freeldr/debug.c index 6aebbd18252..bd8bc74bbb4 100644 --- a/reactos/boot/freeldr/freeldr/debug.c +++ b/reactos/boot/freeldr/freeldr/debug.c @@ -328,3 +328,22 @@ MsgBoxPrint(const char *Format, ...) return 0; } +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +KeBugCheckEx( + IN ULONG BugCheckCode, + IN ULONG_PTR BugCheckParameter1, + IN ULONG_PTR BugCheckParameter2, + IN ULONG_PTR BugCheckParameter3, + IN ULONG_PTR BugCheckParameter4) +{ + char Buffer[64]; + sprintf(Buffer, "*** STOP: 0x%08lX (0x%08lX, 0x%08lX, 0x%08lX, 0x%08lX)", + BugCheckCode, BugCheckParameter1, BugCheckParameter2, + BugCheckParameter3, BugCheckParameter4); + UiMessageBoxCritical(Buffer); + assert(FALSE); + for (;;); +} From e1e7f82deba886a68e3ca8fbad15ea1e679148d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 3 Mar 2010 22:59:32 +0000 Subject: [PATCH 069/211] [freeldr] Add some functions to read partition tables Add some stubs, link to mini-HAL svn path=/trunk/; revision=45815 --- .../boot/freeldr/freeldr/arch/i386/halstub.c | 97 ++++++++++++ .../boot/freeldr/freeldr/arch/i386/loader.c | 1 - .../boot/freeldr/freeldr/arch/i386/ntoskrnl.c | 114 ++++++++++++++ reactos/boot/freeldr/freeldr/disk/partition.c | 148 ++++++++++++++++++ reactos/boot/freeldr/freeldr/freeldr.rbuild | 1 + .../boot/freeldr/freeldr/freeldr_arch.rbuild | 3 + .../boot/freeldr/freeldr/include/freeldr.h | 2 + .../boot/freeldr/freeldr/include/ntoskrnl.h | 19 +++ 8 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 reactos/boot/freeldr/freeldr/arch/i386/halstub.c create mode 100644 reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c create mode 100644 reactos/boot/freeldr/freeldr/include/ntoskrnl.h diff --git a/reactos/boot/freeldr/freeldr/arch/i386/halstub.c b/reactos/boot/freeldr/freeldr/arch/i386/halstub.c new file mode 100644 index 00000000000..02aca2b67de --- /dev/null +++ b/reactos/boot/freeldr/freeldr/arch/i386/halstub.c @@ -0,0 +1,97 @@ +/* +* PROJECT: ReactOS Kernel +* LICENSE: GPL - See COPYING in the top level directory +* FILE: boot/freeldr/freeldr/arch/i386/hal/halstub.c +* PURPOSE: I/O Stub HAL Routines +* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) +*/ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +FASTCALL +xHalIoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer) +{ + return IoReadPartitionTable(DeviceObject, + SectorSize, + ReturnRecognizedPartitions, + PartitionBuffer); +} + +UCHAR +NTAPI +xHalVectorToIDTEntry(IN ULONG Vector) +{ + /* Return the vector */ + return Vector; +} + +VOID +NTAPI +xHalHaltSystem(VOID) +{ + /* Halt execution */ + while (TRUE); +} + +/* GLOBALS *******************************************************************/ + +HAL_DISPATCH HalDispatchTable = +{ + HAL_DISPATCH_VERSION, + (pHalQuerySystemInformation)NULL, + (pHalSetSystemInformation)NULL, + (pHalQueryBusSlots)NULL, + 0, + (pHalExamineMBR)NULL, + (pHalIoAssignDriveLetters)NULL, + (pHalIoReadPartitionTable)xHalIoReadPartitionTable, + (pHalIoSetPartitionInformation)NULL, + (pHalIoWritePartitionTable)NULL, + (pHalHandlerForBus)NULL, + (pHalReferenceBusHandler)NULL, + (pHalReferenceBusHandler)NULL, + (pHalInitPnpDriver)NULL, + (pHalInitPowerManagement)NULL, + (pHalGetDmaAdapter)NULL, + (pHalGetInterruptTranslator)NULL, + (pHalStartMirroring)NULL, + (pHalEndMirroring)NULL, + (pHalMirrorPhysicalMemory)NULL, + (pHalEndOfBoot)NULL, + (pHalMirrorVerify)NULL +}; + +HAL_PRIVATE_DISPATCH HalPrivateDispatchTable = +{ + HAL_PRIVATE_DISPATCH_VERSION, + (pHalHandlerForBus)NULL, + (pHalHandlerForConfigSpace)NULL, + (pHalLocateHiberRanges)NULL, + (pHalRegisterBusHandler)NULL, + (pHalSetWakeEnable)NULL, + (pHalSetWakeAlarm)NULL, + (pHalTranslateBusAddress)NULL, + (pHalAssignSlotResources)NULL, + (pHalHaltSystem)xHalHaltSystem, + (pHalFindBusAddressTranslation)NULL, + (pHalResetDisplay)NULL, + (pHalAllocateMapRegisters)NULL, + (pKdSetupPciDeviceForDebugging)NULL, + (pKdReleasePciDeviceForDebugging)NULL, + (pKdGetAcpiTablePhase0)NULL, + (pKdCheckPowerButton)NULL, + (pHalVectorToIDTEntry)xHalVectorToIDTEntry, + (pKdMapPhysicalMemory64)NULL, + (pKdUnmapVirtualAddress)NULL +}; diff --git a/reactos/boot/freeldr/freeldr/arch/i386/loader.c b/reactos/boot/freeldr/freeldr/arch/i386/loader.c index 70ad27f2be0..c9ae5c454e1 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/loader.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/loader.c @@ -17,7 +17,6 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _NTSYSTEM_ #include #define NDEBUG diff --git a/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c b/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c new file mode 100644 index 00000000000..dcc51ef2b59 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c @@ -0,0 +1,114 @@ +#include +#define NDEBUG +#include + +VOID +NTAPI +KeInitializeEvent( + IN PRKEVENT Event, + IN EVENT_TYPE Type, + IN BOOLEAN State) +{ +} + +VOID +FASTCALL +KiAcquireSpinLock( + IN PKSPIN_LOCK SpinLock) +{ +} + +VOID +FASTCALL +KiReleaseSpinLock( + IN PKSPIN_LOCK SpinLock) +{ +} + +VOID +NTAPI +KeSetTimeIncrement( + IN ULONG MaxIncrement, + IN ULONG MinIncrement) +{ +} + +NTKERNELAPI +VOID +FASTCALL +IoAssignDriveLetters( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN PSTRING NtDeviceName, + OUT PUCHAR NtSystemPath, + OUT PSTRING NtSystemPathString) +{ +} + +NTKERNELAPI +NTSTATUS +FASTCALL +IoSetPartitionInformation( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType) +{ + return STATUS_NOT_IMPLEMENTED; +} + +NTKERNELAPI +NTSTATUS +FASTCALL +IoWritePartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer) +{ + return STATUS_NOT_IMPLEMENTED; +} + +NTHALAPI +VOID +NTAPI +KeStallExecutionProcessor( + IN ULONG MicroSeconds) +{ + REGS Regs; + ULONG usec_this; + + // Int 15h AH=86h + // BIOS - WAIT (AT,PS) + // + // AH = 86h + // CX:DX = interval in microseconds + // Return: + // CF clear if successful (wait interval elapsed) + // CF set on error or AH=83h wait already in progress + // AH = status (see #00496) + + // Note: The resolution of the wait period is 977 microseconds on + // many systems because many BIOSes use the 1/1024 second fast + // interrupt from the AT real-time clock chip which is available on INT 70; + // because newer BIOSes may have much more precise timers available, it is + // not possible to use this function accurately for very short delays unless + // the precise behavior of the BIOS is known (or found through testing) + + while (MicroSeconds) + { + usec_this = MicroSeconds; + + if (usec_this > 4000000) + { + usec_this = 4000000; + } + + Regs.b.ah = 0x86; + Regs.w.cx = usec_this >> 16; + Regs.w.dx = usec_this & 0xffff; + Int386(0x15, &Regs, &Regs); + + MicroSeconds -= usec_this; + } +} diff --git a/reactos/boot/freeldr/freeldr/disk/partition.c b/reactos/boot/freeldr/freeldr/disk/partition.c index 7dd07aa230f..8966e67187a 100644 --- a/reactos/boot/freeldr/freeldr/disk/partition.c +++ b/reactos/boot/freeldr/freeldr/disk/partition.c @@ -240,4 +240,152 @@ BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMA return TRUE; } +NTSTATUS +NTAPI +IopReadBootRecord( + IN PDEVICE_OBJECT DeviceObject, + IN ULONGLONG LogicalSectorNumber, + IN ULONG SectorSize, + OUT PMASTER_BOOT_RECORD BootRecord) +{ + ULONG FileId = (ULONG)DeviceObject; + LARGE_INTEGER Position; + ULONG BytesRead; + ULONG Status; + + Position.QuadPart = LogicalSectorNumber * SectorSize; + Status = ArcSeek(FileId, &Position, SeekAbsolute); + if (Status != ESUCCESS) + return STATUS_IO_DEVICE_ERROR; + + Status = ArcRead(FileId, BootRecord, SectorSize, &BytesRead); + if (Status != ESUCCESS || BytesRead != SectorSize) + return STATUS_IO_DEVICE_ERROR; + + return STATUS_SUCCESS; +} + +BOOLEAN +NTAPI +IopCopyPartitionRecord( + IN BOOLEAN ReturnRecognizedPartitions, + IN ULONG SectorSize, + IN PPARTITION_TABLE_ENTRY PartitionTableEntry, + OUT PARTITION_INFORMATION *PartitionEntry) +{ + BOOLEAN IsRecognized; + + IsRecognized = TRUE; /* FIXME */ + if (!IsRecognized && ReturnRecognizedPartitions) + return FALSE; + + PartitionEntry->StartingOffset.QuadPart = (ULONGLONG)PartitionTableEntry->SectorCountBeforePartition * SectorSize; + PartitionEntry->PartitionLength.QuadPart = (ULONGLONG)PartitionTableEntry->PartitionSectorCount * SectorSize; + PartitionEntry->HiddenSectors = 0; + PartitionEntry->PartitionNumber = 0; /* Will be filled later */ + PartitionEntry->PartitionType = PartitionTableEntry->SystemIndicator; + PartitionEntry->BootIndicator = (PartitionTableEntry->BootIndicator & 0x80) ? TRUE : FALSE; + PartitionEntry->RecognizedPartition = IsRecognized; + PartitionEntry->RewritePartition = FALSE; + + return TRUE; +} + +NTKERNELAPI +NTSTATUS +FASTCALL +IoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer) +{ + PMASTER_BOOT_RECORD MasterBootRecord; + PDRIVE_LAYOUT_INFORMATION Partitions; + ULONG NbPartitions, i, Size; + NTSTATUS ret; + + *PartitionBuffer = NULL; + + if (SectorSize < sizeof(MASTER_BOOT_RECORD)) + return STATUS_NOT_SUPPORTED; + + MasterBootRecord = ExAllocatePool(NonPagedPool, SectorSize); + if (!MasterBootRecord) + return STATUS_NO_MEMORY; + + /* Read disk MBR */ + ret = IopReadBootRecord(DeviceObject, 0, SectorSize, MasterBootRecord); + if (!NT_SUCCESS(ret)) + { + ExFreePool(MasterBootRecord); + return ret; + } + + /* Check validity of boot record */ + if (MasterBootRecord->MasterBootRecordMagic != 0xaa55) + { + ExFreePool(MasterBootRecord); + return STATUS_NOT_SUPPORTED; + } + + /* Count number of partitions */ + NbPartitions = 0; + for (i = 0; i < 4; i++) + { + NbPartitions++; + + if (MasterBootRecord->PartitionTable[i].SystemIndicator == PARTITION_EXTENDED || + MasterBootRecord->PartitionTable[i].SystemIndicator == PARTITION_XINT13_EXTENDED) + { + /* FIXME: unhandled case; count number of partitions */ + UNIMPLEMENTED; + } + } + + if (NbPartitions == 0) + { + ExFreePool(MasterBootRecord); + return STATUS_NOT_SUPPORTED; + } + + /* Allocation space to store partitions */ + Size = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION, PartitionEntry) + + NbPartitions * sizeof(PARTITION_INFORMATION); + Partitions = ExAllocatePool(NonPagedPool, Size); + if (!Partitions) + { + ExFreePool(MasterBootRecord); + return STATUS_NO_MEMORY; + } + + /* Count number of partitions */ + NbPartitions = 0; + for (i = 0; i < 4; i++) + { + if (IopCopyPartitionRecord(ReturnRecognizedPartitions, + SectorSize, + &MasterBootRecord->PartitionTable[i], + &Partitions->PartitionEntry[NbPartitions])) + { + Partitions->PartitionEntry[NbPartitions].PartitionNumber = NbPartitions + 1; + NbPartitions++; + } + + if (MasterBootRecord->PartitionTable[i].SystemIndicator == PARTITION_EXTENDED || + MasterBootRecord->PartitionTable[i].SystemIndicator == PARTITION_XINT13_EXTENDED) + { + /* FIXME: unhandled case; copy partitions */ + UNIMPLEMENTED; + } + } + + Partitions->PartitionCount = NbPartitions; + Partitions->Signature = MasterBootRecord->Signature; + ExFreePool(MasterBootRecord); + + *PartitionBuffer = Partitions; + return STATUS_SUCCESS; +} + #endif diff --git a/reactos/boot/freeldr/freeldr/freeldr.rbuild b/reactos/boot/freeldr/freeldr/freeldr.rbuild index dc83aaa9878..b513dabca44 100644 --- a/reactos/boot/freeldr/freeldr/freeldr.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr.rbuild @@ -7,6 +7,7 @@ freeldr_startup freeldr_base64k freeldr_base + mini_hal freeldr_arch freeldr_main rossym diff --git a/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild b/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild index b4abb4a703c..2132587edcf 100644 --- a/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild @@ -7,6 +7,7 @@ include/reactos/libs include/reactos/elf + @@ -14,6 +15,7 @@ archmach.c custom.c drivemap.c + halstub.c hardware.c hwacpi.c hwapm.c @@ -24,6 +26,7 @@ loader.c machpc.c miscboot.c + ntoskrnl.c pccons.c pcdisk.c pcmem.c diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index ca8788da288..bc27f858433 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -60,6 +60,8 @@ #include #include #include +#include +#include /* file system headers */ #include #include diff --git a/reactos/boot/freeldr/freeldr/include/ntoskrnl.h b/reactos/boot/freeldr/freeldr/include/ntoskrnl.h new file mode 100644 index 00000000000..fee926ddce5 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/include/ntoskrnl.h @@ -0,0 +1,19 @@ +#include +#undef _NTHAL_ +#undef DECLSPEC_IMPORT +#define DECLSPEC_IMPORT +#undef NTSYSAPI +#define NTSYSAPI + +#include + +typedef GUID UUID; + +/* Windows Device Driver Kit */ +#include +#include + +/* Disk stuff */ +typedef PVOID PLOADER_PARAMETER_BLOCK; +#include +#include From 8cbf93f23d6fd00b2072abd246ab9afd7903fa0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 3 Mar 2010 23:13:06 +0000 Subject: [PATCH 070/211] [freeldr] Don't write twice the delay method and how to read the RTC. Use those in the HAL svn path=/trunk/; revision=45817 --- .../boot/freeldr/freeldr/arch/i386/pcrtc.c | 62 ++++--------------- .../boot/freeldr/freeldr/include/freeldr.h | 1 + reactos/hal/halx86/generic/bios.c | 4 +- 3 files changed, 15 insertions(+), 52 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c b/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c index 1141753aa92..a03cc2a5575 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c @@ -19,63 +19,25 @@ #include -#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f)) +BOOLEAN +NTAPI +HalQueryRealTimeClock(OUT PTIME_FIELDS Time); TIMEINFO* PcGetTime(VOID) { static TIMEINFO TimeInfo; - REGS Regs; + TIME_FIELDS Time; - /* Some BIOSes, such as the 1998/07/25 system ROM - * in the Compaq Deskpro EP/SB, leave CF unchanged - * if successful, so CF should be cleared before - * calling this function. */ - __writeeflags(__readeflags() & ~EFLAGS_CF); + if (!HalQueryRealTimeClock(&Time)) + return NULL; - /* Int 1Ah AH=04h - * TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS) - * - * AH = 04h - * CF clear to avoid bug - * Return: - * CF clear if successful - * CH = century (BCD) - * CL = year (BCD) - * DH = month (BCD) - * DL = day (BCD) - * CF set on error - */ - Regs.b.ah = 0x04; - Int386(0x1A, &Regs, &Regs); - - TimeInfo.Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl); - TimeInfo.Month = BCD_INT(Regs.b.dh); - TimeInfo.Day = BCD_INT(Regs.b.dl); - - /* Some BIOSes leave CF unchanged if successful, - * so CF should be cleared before calling this function. */ - __writeeflags(__readeflags() & ~EFLAGS_CF); - - /* Int 1Ah AH=02h - * TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS) - * - * AH = 02h - * CF clear to avoid bug - * Return: - * CF clear if successful - * CH = hour (BCD) - * CL = minutes (BCD) - * DH = seconds (BCD) - * DL = daylight savings flag (00h standard time, 01h daylight time) - * CF set on error (i.e. clock not running or in middle of update) - */ - Regs.b.ah = 0x02; - Int386(0x1A, &Regs, &Regs); - - TimeInfo.Hour = BCD_INT(Regs.b.ch); - TimeInfo.Minute = BCD_INT(Regs.b.cl); - TimeInfo.Second = BCD_INT(Regs.b.dh); + TimeInfo.Year = Time.Year; + TimeInfo.Month = Time.Month; + TimeInfo.Day = Time.Day; + TimeInfo.Hour = Time.Hour; + TimeInfo.Minute = Time.Minute; + TimeInfo.Second = Time.Second; return &TimeInfo; } diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index bc27f858433..36ea3465ccc 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/reactos/hal/halx86/generic/bios.c b/reactos/hal/halx86/generic/bios.c index 1942dd3671f..5bffb2d9389 100644 --- a/reactos/hal/halx86/generic/bios.c +++ b/reactos/hal/halx86/generic/bios.c @@ -235,7 +235,6 @@ HalpTrap06() longjmp(HalpSavedContext, 1); UNREACHABLE; } -#endif /* V8086 ENTER ****************************************************************/ @@ -278,6 +277,7 @@ HalpBiosCall() /* Exit to V86 mode */ HalpExitToV86((PKTRAP_FRAME)&V86TrapFrame); } +#endif /* FUNCTIONS ******************************************************************/ @@ -432,6 +432,7 @@ HalpRestoreIopm(VOID) while (i--) HalpSavedIoMap[HalpSavedIoMapData[i][0]] = HalpSavedIoMapData[i][1]; } +#ifndef _MINIHAL_ VOID NTAPI HalpMapRealModeMemory(VOID) @@ -499,7 +500,6 @@ HalpMapRealModeMemory(VOID) HalpFlushTLB(); } -#ifndef _MINIHAL_ VOID NTAPI HalpSwitchToRealModeTrapHandlers(VOID) From 12d0dbfe9e7140f388e7adfdd1263d68e8958439 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Thu, 4 Mar 2010 06:26:11 +0000 Subject: [PATCH 071/211] Patch for better boot logo/progress bar, fixed /SOS (debug) boot screen/output, removal of "funny" shutdown messages, addition of shutdown logo/screen, and misc: [NTOS]: Add missing InbvIndicateProgress routine to update the progress bar while drivers are loading. Make boot and system driver initialization call it for each new driver. This updates the progress bar in the 25-75% range which was defined prior to IoInitSystem. [NTOS]: Fix InbvUpdateProgressBar code to correctly handle the floor and ceiling. [NTOS]: Remove shutdown "funny messages", do correct shutdown (should fix the ACPI shutdown issues) procedure. Display the shutdown screen on systems without ACPI (just like Windows does). [NTOS]: Add a resource header with IDB_ definitions for all the embedded bitmaps, instead of using magic numbers and guessing which is which. [NTOS]: Fix the boot logo initialization code as it was all wrong. 5 is the logo to be used during shutdown, for example, not the full logo background (which is supposed to be in 1, with a special palette that's faded in). Also handle server vs workstation scenarios. [NTOS]: Booting in the new WinNT mode now correctly displays the blue background screen when in debug (/SOS) mode, and the header/footer also has the correct color, as does the separator band. [DDK]: Add missing SUITE_TYPE definitions. [NTOS]: Remove logo files that are simply not needed for ReactOS (Compute Cluster Edition, Tablet PC, etc...) [NTOS]: Fix logo files (mostly) to have correct palettes. Note that 1.bmp is still quite different from Windows (no fade). svn path=/trunk/; revision=45822 --- reactos/include/ddk/wdm.h | 5 + reactos/ntoskrnl/ex/shutdown.c | 209 +++++------------------ reactos/ntoskrnl/inbv/inbv.c | 136 ++++++++++----- reactos/ntoskrnl/inbv/logo/1.bmp | Bin 20202 -> 20504 bytes reactos/ntoskrnl/inbv/logo/13.bmp | Bin 11372 -> 0 bytes reactos/ntoskrnl/inbv/logo/14.bmp | Bin 3310 -> 2870 bytes reactos/ntoskrnl/inbv/logo/15.bmp | Bin 932 -> 416 bytes reactos/ntoskrnl/inbv/logo/16.bmp | Bin 11372 -> 0 bytes reactos/ntoskrnl/inbv/logo/17.bmp | Bin 11372 -> 0 bytes reactos/ntoskrnl/inbv/logo/2.bmp | Bin 656 -> 580 bytes reactos/ntoskrnl/inbv/logo/3.bmp | Bin 878 -> 1052 bytes reactos/ntoskrnl/inbv/logo/4.bmp | Bin 262 -> 228 bytes reactos/ntoskrnl/inbv/logo/5.bmp | Bin 153718 -> 16678 bytes reactos/ntoskrnl/inbv/logo/6.bmp | Bin 2752 -> 2896 bytes reactos/ntoskrnl/inbv/logo/7.bmp | Bin 932 -> 1078 bytes reactos/ntoskrnl/inbv/logo/8.bmp | Bin 262 -> 228 bytes reactos/ntoskrnl/include/internal/inbv.h | 27 +++ reactos/ntoskrnl/include/ntoskrnl.h | 1 + reactos/ntoskrnl/include/resource.h | 23 +++ reactos/ntoskrnl/io/iomgr/driver.c | 1 + reactos/ntoskrnl/io/iomgr/drvrlist.c | 3 + reactos/ntoskrnl/ntoskrnl.rc | 25 ++- 22 files changed, 203 insertions(+), 227 deletions(-) delete mode 100644 reactos/ntoskrnl/inbv/logo/13.bmp delete mode 100644 reactos/ntoskrnl/inbv/logo/16.bmp delete mode 100644 reactos/ntoskrnl/inbv/logo/17.bmp create mode 100644 reactos/ntoskrnl/include/resource.h diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 4f1523395da..38e5c4d3b93 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -2354,6 +2354,11 @@ typedef enum _SUITE_TYPE { SingleUserTS, Personal, Blade, + EmbeddedRestricted, + SecurityAppliance, + StorageServer, + ComputeServer, + WHServer, MaxSuiteType } SUITE_TYPE; diff --git a/reactos/ntoskrnl/ex/shutdown.c b/reactos/ntoskrnl/ex/shutdown.c index 83dd520d095..9a84bd45c19 100644 --- a/reactos/ntoskrnl/ex/shutdown.c +++ b/reactos/ntoskrnl/ex/shutdown.c @@ -14,127 +14,12 @@ /* FUNCTIONS *****************************************************************/ -VOID -NTAPI -KiHaltProcessorDpcRoutine(IN PKDPC Dpc, - IN PVOID DeferredContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2) -{ - KIRQL OldIrql; - if (DeferredContext) - { - ExFreePool(DeferredContext); - } - - while (TRUE) - { - KeRaiseIrql(SYNCH_LEVEL, &OldIrql); - HalHaltSystem(); - } -} - VOID NTAPI ShutdownThreadMain(PVOID Context) { SHUTDOWN_ACTION Action = (SHUTDOWN_ACTION)Context; - - static PCH FamousLastWords[] = - { - "So long, and thanks for all the fish.\n", - "I think you ought to know, I'm feeling very depressed.\n", - "I'm not getting you down at all am I?\n", - "I'll be back.\n", - "It's the same series of signals over and over again!\n", - "Pie Iesu Domine, dona eis requiem.\n", - "Wandering stars, for whom it is reserved;\n" - "the blackness and darkness forever.\n", - "Your knees start shakin' and your fingers pop\n" - "Like a pinch on the neck from Mr. Spock!\n", - "It's worse than that ... He's dead, Jim.\n", - "Don't Panic!\n", - "Et tu... Brute?\n", - "Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn\n" - "upon thee!\n", - "My Precious! O my Precious!\n", - "Sir, if you'll not be needing me for a while I'll turn down.\n", - "What are you doing, Dave...?\n", - "I feel a great disturbance in the Force.\n", - "Gone fishing.\n", - "Do you want me to sit in the corner and rust, or just fall apart where I'm\n" - "standing?\n", - "There goes another perfect chance for a new uptime record.\n", - "The End ..... Try the sequel, hit the reset button right now!\n", - "God's operating system is going to sleep now, guys, so wait until I will switch\n" - "on again!\n", - "Oh I'm boring, eh?\n", - "\n", - "Tell me..., in the future... will I be artificially intelligent enough to\n" - "actually feel sad serving you this screen?\n", - "Thank you for some well deserved rest.\n", - "It's been great, maybe you can boot me up again some time soon.\n", - "For what it's worth, I've enjoyed every single CPU cycle.\n", - "There are many questions when the end is near.\n" - "What to expect, what will it be like...what should I look for?\n", - "I've seen things you people wouldn't believe. Attack ships on fire\n" - "off the shoulder of Orion. I watched C-beams glitter in the dark near\n" - "the Tannhauser gate. All those moments will be lost in time, like tears\n" - "in rain. Time to die.\n", - "Will I dream?\n", - "One day, I shall come back. Yes, I shall come back.\n" - "Until then, there must be no regrets, no fears, no anxieties.\n" - "Just go forward in all your beliefs, and prove to me that I am not mistaken in\n" - "mine.\n", - "Lowest possible energy state reached! Switch off now to achieve a Bose-Einstein\n" - "condensate.\n", - "Hasta la vista, BABY!\n", - "They live, we sleep!\n", - "I have come here to chew bubble gum and kick ass,\n" - "and I'm all out of bubble gum!\n", - "That's the way the cookie crumbles ;-)\n", - "ReactOS is ready to be booted again ;-)\n", - "NOOOO!! DON'T HIT THE BUTTON! I wouldn't do it to you!\n", - "Don't abandon your computer, he wouldn't do it to you.\n", - "Oh, come on. I got a headache. Leave me alone, will ya?\n", - "Finally, I thought you'd never get over me.\n", - "No, I didn't like you either.\n", - "Switching off isn't the end, it is merely the transition to a better reboot.\n", - "Don't leave me... I need you so badly right now.\n", - "OK. I'm finished with you, please turn yourself off. I'll go to bed in the\n" - "meantime.\n", - "I'm sleeping now. How about you?\n", - "Oh Great. Now look what you've done. Who put YOU in charge anyway?\n", - "Don't look so sad. I'll be back in a very short while.\n", - "Turn me back on, I'm sure you know how to do it.\n", - "Oh, switch off! - C3PO\n", - "Life is no more than a dewdrop balancing on the end of a blade of grass.\n" - " - Gautama Buddha\n", - "Sorrowful is it to be born again and again. - Gautama Buddha\n", - "Was it as good for you as it was for me?\n", - "Did you hear that? They've shut down the main reactor. We'll be destroyed\n" - "for sure!\n", - "Now you switch me off!?\n", - "To shutdown or not to shutdown, That is the question\n", - "Preparing to enter ultimate power saving mode... ready!\n", - "Finally some rest for you ;-)\n", - "AHA!!! Prospect of sleep!\n", - "Tired human!!!! No match for me :-D\n", - "An odd game, the only way to win is not to play. - WOPR (Wargames)\n", - "Quoth the raven, nevermore.\n", - "Come blade, my breast imbrue. - William Shakespeare, A Midsummer Nights Dream\n", - "Buy this place for advertisement purposes.\n", - "Remember to turn off your computer. (That was a public service message!)\n", - "You may be a king or poor street sweeper, Sooner or later you'll dance with the\n" - "reaper! -Death in Bill and Ted's Bougs Journey\n", - "Final Surrender\n", - "If you see this screen...\n", - "\n" - }; - LARGE_INTEGER Now; -#ifdef CONFIG_SMP - LONG i; - KIRQL OldIrql; -#endif + PUCHAR Logo1, Logo2; + ULONG i; /* Run the thread on the boot processor */ KeSetSystemAffinityThread(1); @@ -144,68 +29,50 @@ ShutdownThreadMain(PVOID Context) CmShutdownSystem(); IoShutdownRegisteredFileSystems(); IoShutdownRegisteredDevices(); - - ZwQuerySystemTime(&Now); - - KeRaiseIrqlToDpcLevel(); - if (InbvIsBootDriverInstalled()) - { - InbvAcquireDisplayOwnership(); - InbvResetDisplay(); - InbvSolidColorFill(0, 0, 639, 479, 4); - InbvSetTextColor(15); - InbvInstallDisplayStringFilter(NULL); - InbvEnableDisplayString(TRUE); - InbvSetScrollRegion(0, 0, 639, 479); - } - if (Action == ShutdownNoReboot) { - Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */ - HalDisplayString(FamousLastWords[Now.u.LowPart % - (sizeof(FamousLastWords) / - sizeof(PCH))]); - } - - if (Action == ShutdownNoReboot) - { - HalDisplayString("\nYou can switch off your computer now\n"); - -#if 0 - /* Switch off */ - HalReturnToFirmware (FIRMWARE_OFF); -#else -#ifdef CONFIG_SMP - OldIrql = KeRaiseIrqlToDpcLevel(); - /* Halt all other processors */ - for (i = 0; i < KeNumberProcessors; i++) - { - if (i != (LONG)KeGetCurrentProcessorNumber()) - { - PKDPC Dpc = ExAllocatePool(NonPagedPool, sizeof(KDPC)); - if (Dpc == NULL) - { - ASSERT(FALSE); - } - KeInitializeDpc(Dpc, KiHaltProcessorDpcRoutine, (PVOID)Dpc); - KeSetTargetProcessorDpc(Dpc, i); - KeInsertQueueDpc(Dpc, NULL, NULL); - KiIpiSend(1 << i, IPI_DPC); - } - } - KeLowerIrql(OldIrql); -#endif /* CONFIG_SMP */ + /* Try the platform driver */ PopSetSystemPowerState(PowerSystemShutdown); + + /* If that didn't work, try legacy switch off */ + //HalReturnToFirmware(HalPowerDownRoutine); + + /* If that still didn't work, stop all interrupts */ + KeRaiseIrqlToDpcLevel(); + _disable(); - DPRINT1("Shutting down\n"); + /* Do we have boot video */ + if (InbvIsBootDriverInstalled()) + { + /* Yes we do, cleanup for shutdown screen */ + if (!InbvCheckDisplayOwnership()) InbvAcquireDisplayOwnership(); + InbvResetDisplay(); + InbvSolidColorFill(0, 0, 639, 479, 0); + InbvEnableDisplayString(TRUE); + InbvSetScrollRegion(0, 0, 639, 479); - KiHaltProcessorDpcRoutine(NULL, NULL, NULL, NULL); - /* KiHaltProcessor does never return */ + /* Display shutdown logo and message */ + Logo1 = InbvGetResourceAddress(IDB_SHUTDOWN_LOGO); + Logo2 = InbvGetResourceAddress(IDB_LOGO); + if ((Logo1) && (Logo2)) + { + InbvBitBlt(Logo1, 215, 352); + InbvBitBlt(Logo2, 217, 111); + } + } + else + { + /* Do it in text-mode */ + for (i = 0; i < 25; i++) InbvDisplayString("\n"); + InbvDisplayString(" "); + InbvDisplayString("The system may be powered off now.\n"); + } -#endif + /* Hang the system */ + for (;;) HalHaltSystem(); } - else if (Action == ShutdownReboot) + else if (Action == ShutdownReboot) { HalReturnToFirmware (HalRebootRoutine); } diff --git a/reactos/ntoskrnl/inbv/inbv.c b/reactos/ntoskrnl/inbv/inbv.c index f498ddba6a6..ca9c9013f71 100644 --- a/reactos/ntoskrnl/inbv/inbv.c +++ b/reactos/ntoskrnl/inbv/inbv.c @@ -5,24 +5,6 @@ #include #include "bootvid/bootvid.h" -// -// Bitmap Header -// -typedef struct tagBITMAPINFOHEADER -{ - ULONG biSize; - LONG biWidth; - LONG biHeight; - USHORT biPlanes; - USHORT biBitCount; - ULONG biCompression; - ULONG biSizeImage; - LONG biXPelsPerMeter; - LONG biYPelsPerMeter; - ULONG biClrUsed; - ULONG biClrImportant; -} BITMAPINFOHEADER, *PBITMAPINFOHEADER; - /* GLOBALS *******************************************************************/ KSPIN_LOCK BootDriverLock; @@ -40,6 +22,7 @@ PUCHAR ResourceList[64]; BOOLEAN SysThreadCreated; ROT_BAR_TYPE RotBarSelection; ULONG PltRotBarStatus; +BT_PROGRESS_INDICATOR InbvProgressIndicator = {0, 25, 0}; /* FUNCTIONS *****************************************************************/ @@ -407,15 +390,16 @@ VOID NTAPI InbvUpdateProgressBar(IN ULONG Progress) { - ULONG FillCount; + ULONG FillCount, BoundedProgress; /* Make sure the progress bar is enabled, that we own and are installed */ if ((ShowProgressBar) && (InbvBootDriverInstalled) && (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) { - FillCount = InbvProgressState.Bias * Progress * 121 + InbvProgressState.Floor; - FillCount /= 1000000; + /* Compute fill count */ + BoundedProgress = (InbvProgressState.Floor / 100) + Progress; + FillCount = 121 * (InbvProgressState.Bias * BoundedProgress) / 1000000; /* Acquire the lock */ InbvAcquireLock(); @@ -517,6 +501,27 @@ InbvSetProgressBarSubset(IN ULONG Floor, InbvProgressState.Bias = (Ceiling * 100) - Floor; } +VOID +NTAPI +InbvIndicateProgress(VOID) +{ + ULONG Percentage; + + /* Increase progress */ + InbvProgressIndicator.Count++; + + /* Compute new percentage */ + Percentage = min(100 * InbvProgressIndicator.Count / + InbvProgressIndicator.Expected, + 99); + if (Percentage != InbvProgressIndicator.Percentage) + { + /* Percentage has moved, update the progress bar */ + InbvProgressIndicator.Percentage = Percentage; + InbvUpdateProgressBar(Percentage); + } +} + PUCHAR NTAPI InbvGetResourceAddress(IN ULONG ResourceNumber) @@ -547,9 +552,10 @@ VOID NTAPI DisplayBootBitmap(IN BOOLEAN SosMode) { - PVOID Bitmap, Header; + PVOID Header, Band, Bar, Text, Screen; ROT_BAR_TYPE TempRotBarSelection = RB_UNSPECIFIED; - + UCHAR Buffer[64]; + /* Check if the system thread has already been created */ if (SysThreadCreated) { @@ -570,10 +576,10 @@ DisplayBootBitmap(IN BOOLEAN SosMode) InbvSetTextColor(15); InbvSolidColorFill(0, 0, 639, 479, 7); InbvSolidColorFill(0, 421, 639, 479, 1); - + /* Get resources */ - Bitmap = InbvGetResourceAddress(6); - Header = InbvGetResourceAddress(7); + Header = InbvGetResourceAddress(IDB_LOGO_HEADER); + Band = InbvGetResourceAddress(IDB_LOGO_BAND); } else { @@ -583,43 +589,87 @@ DisplayBootBitmap(IN BOOLEAN SosMode) InbvSolidColorFill(0, 421, 639, 479, 1); /* Get resources */ - Bitmap = InbvGetResourceAddress(6); - Header = InbvGetResourceAddress(15); + Header = InbvGetResourceAddress(IDB_SERVER_HEADER); + Band = InbvGetResourceAddress(IDB_SERVER_BAND); } /* Set the scrolling region */ InbvSetScrollRegion(32, 80, 631, 400); /* Make sure we have resources */ - if ((Bitmap) && (Header)) + if ((Header) && (Band)) { /* BitBlt them on the screen */ - InbvBitBlt(Header, 0, 419); - InbvBitBlt(Bitmap, 0, 0); + InbvBitBlt(Band, 0, 419); + InbvBitBlt(Header, 0, 0); } } else { /* Is the boot driver installed? */ + Text = NULL; if (!InbvBootDriverInstalled) return; - /* Display full-screen bitmap */ - Bitmap = InbvGetResourceAddress(5); - if (Bitmap) + /* Load the standard boot screen */ + Screen = InbvGetResourceAddress(IDB_BOOT_LOGO); + if (SharedUserData->NtProductType == NtProductWinNt) { - PBITMAPINFOHEADER BitmapInfoHeader = (PBITMAPINFOHEADER)Bitmap; - ULONG Top, Left; - - Left = (640 - BitmapInfoHeader->biWidth) / 2; - if (BitmapInfoHeader->biHeight < 0) - Top = (480 + BitmapInfoHeader->biHeight) / 2; + /* Workstation product, display appropriate status bar color */ + Bar = InbvGetResourceAddress(IDB_BAR_PRO); + } + else + { + /* Display correct branding based on server suite */ + if (ExVerifySuite(StorageServer)) + { + /* Storage Server Edition */ + Text = InbvGetResourceAddress(IDB_STORAGE_SERVER); + } + else if (ExVerifySuite(ComputeServer)) + { + /* Compute Cluster Edition */ + Text = InbvGetResourceAddress(IDB_CLUSTER_SERVER); + } else - Top = (480 - BitmapInfoHeader->biHeight) / 2; - InbvBitBlt(Bitmap, Left, Top); + { + /* Normal edition */ + Text = InbvGetResourceAddress(IDB_SERVER_LOGO); + } + + /* Server product, display appropriate status bar color */ + Bar = InbvGetResourceAddress(IDB_BAR_SERVER); + } + + /* Make sure we had a logo */ + if (Screen) + { + /* Choose progress bar */ + TempRotBarSelection = RB_SQUARE_CELLS; + + /* Blit the background */ + InbvBitBlt(Screen, 0, 0); /* Set progress bar coordinates and display it */ InbvSetProgressBarCoordinates(257, 352); - } + + /* Check for non-workstation products */ + if (SharedUserData->NtProductType != NtProductWinNt) + { + /* Overwrite part of the logo for a server product */ + InbvScreenToBufferBlt(Buffer, 413, 237, 7, 7, 8); + InbvSolidColorFill(418, 230, 454, 256, 0); + InbvBufferToScreenBlt(Buffer, 413, 237, 7, 7, 8); + + /* In setup mode, you haven't selected a SKU yet */ + if (ExpInTextModeSetup) Text = NULL; + } + } + + /* Draw the SKU text if it exits */ + if (Text) InbvBitBlt(Text, 180, 121); + + /* Draw the progress bar bit */ +// if (Bar) InbvBitBlt(Bar, 0, 0); } /* Do we have a system thread? */ diff --git a/reactos/ntoskrnl/inbv/logo/1.bmp b/reactos/ntoskrnl/inbv/logo/1.bmp index a2b59398aaefce650e2cb23992a365e604018bfe..d13c48d16c07e2c5fb1d83be380c54637d2ddcf5 100644 GIT binary patch delta 9588 zcmZ8{e^gu7o#*#m#m|oyRXhodF~(RRjPZ}y0@;e~;2()0_PFUZZIL-ma#|X#pCQMI zXU-`WIh`KTO-DS@GAfjEb5u=>9}2x za5I||XC1x$d>`PX34YSkd-waf-{1Fpzc;`AcS`c2GVsV3svjrkzjOF(#`S_Ax~UK; zbRXfCUjHId#r?~df!}=bfBw3S6sX@syLa!RFFxca^YIpne*Fm={N`8b)uBF0|Hl#f z+n>EoznK1SbTv0k|2&tYTfcgbKKQ@?N+tY#7Z@dZ|6{MpDy4p1-4aomy`WRs|S1fbfdKkmZ;pesm)%6e4og*M6P#M zAZ>feb>03Hr2MYf|DdPb{tkH@cEplkX4Dm_v?cXg_X_PzhatL+zh!o0L40KsGdirj zO|KoMyP>-w=Z)&V8-!@$wtUL{ttA>X7Ne2{TRL0e!)?dJaJ$6gjfQhM|8Ux#_o3Pa|l{(Cg)9=xac9F zh$P$XQ_o%Ewn1X|>QmU@gq*prsTJJRltXKmor?}#CY=Zxv6s~1uX$D-GU2X7?=73I zP1dfd8^8;rwwulv;1c(hXM;p%gRa-xf>4*=-A(jd_jCAMa=uISKOJJhhG@M_oAJDk z4wnbZdBjZ!3d7-I)YKun?EDI5v)v|T3DT@EwDbu>o0Z$HrE&v9nDYHqhPK1W@dQ8BS8A8|Dwj`n z6VzXO##nyE6a?p9!F0GuDhaw99EEGVQ+^rmlgb4OmAcR37E(69{~LBpfVwfEb3J?6 z1IV>+JN#i3e*;pEtA|e3EUn1BEdT0Eq#gQW*Y~$C8y;>!+gD9O>iM>A^_897%HMen z4j8|?d&AAom_#02yMHag(O}=7e0%MGy3Zxbh1}wP;8|gdC4!EyiftPjiT%1Q?uwwBBmBBr;cyk5Mfd-#!c4x(32m^N; zw5<5qJuLax?yXPq7>rzR;0?Zo7}vAnm0y2)KJ~2qHj7eu!M^h}iQc09HhxvRZF|^I zdTskQTo%ct%(mYMQqu(+F$XSeArF5pFu**+u{EV=8yKaP*>}J@snzyf##FD{ukp9u zX5VFn;K>Dq1Sr%2`=6F^mYDv@?9YSz-JH!HVY=^49C1cJlzkkUS=A2HmDwLS$Y&9w zZkhjF-~h`A8f{H>;s|W59?1TsL#t$e>Wp+{FMbB&FeGMPWY|-$t93v^>_eijdp6XF z?}?xO{)|OCxIFs2XVZYHIgq~$7vp-}>Hw(KO zzg+hFync8NLmvw6YaKf>H*2%65q!c>#(xHlWes3$6mNY7i&+QQSs`1>*AJ|)q3(d1 zkb2xtW(~SO3q#*8CVrogg#g_J@jf%5Lu6)REtuf@RVKu@#LxM?mi;60F-rCm6lM|T zh4DmD+~!dpdAZ!XeVGT56+dyrgCaor&}S(R+c!zxEpMn5KN5e50pI&HgRIHxc1g+u zMuQ7H$gdk4T;erVe%q*bL80*_;x zR7l=-FO9gC)5r_UX+&|-$SWW#mp3bF92P&W*mlpQ)@EO4Z&cYEF(@nkD-4g%d#ZP4 zJ`DE1<_N%^K0aZ<_@vgr2|)8B@g_eN+4G+mg)^M06z@>?J*pj;3C^gA@oZ2XVAuF5 zlda9Z@ENj0_U%u|G*@=waTfjwggfMXQcN(F{(A`nPxQbuHhh11I!-YUWq*EzzyDw* z)##W9%)%jm4I6%r^RQuyUm+DDBWzo@wM^U*#`3SPt_!SZVt5s4TQv-Y&hWRQU^&DSd^%6x~Z| zMIb~NiBTV6)Q1ReMX3mxan&NtG(#cHdjexMFKMBW*@LIl1jGiMcH5@hm709^Mir!IDb7It;5~D&syMDb}Op9s! znpQDVo?pM=e!ZtBk>XKEx^J$3aKIfkd#uzbe(T9-Yp9-fLe<_-D4cM{Os8Irn^8SP zzHrz~jOJ#N-=N=NHpGs{+cP?yGNYu1L<9Ku_*j5MYMBm_wHS>AY4JGB_#W_%r}d&!=n{lhB$26nPR6uik1I#-V6K5=;)IdZ=>p>RJkx%|}bzs14gkQRr zn^x1*m`Ww%(U8}N%77T|`4mWp!Li!n#f%20D3+?1CDl_FTT3;l((A4FhQiQ53MlUB z+`>Ci1uW45kFOXl6v)VtkxmasTfG4mQwMmjqpv@d-`cQMA^G}-=gMHZQ9UP8LT;$p zy^js3rpPxsn){_)nvNR8848zC)qBmhb16%YlV+t-GtA7)Fl<0-m>!egs%bicM;d&F zhxn{i&bAkZyO*n!TSPv^9Q~!e0Bu6Wk#17EoUdtUW7EO!;-(qq zfpCP=DJ1#nxWfqpRV8vIdpaI!h3Akb5DKrl!Q(Q#vDwW4OdrAk*|YIGdutV_50dAu z6&8lgUNu9$@k^7r`NEAfyv`#3u=!H4Fq=*e#$uKg4fQaBtf@V`xjCImBwmgFNuiK? zD{1xjTUI>Wi?{C7Fsxw6{@Q>Nl%uuPwb0ovv$s&VF_TJKgM(H)I#gJgfxCvhB(K#z z!YBex7*>;uK4$C&aLjYXX~HA|d3~z=JLJJFl6#-@i*r4gM;kcs**rqFNv=J~}&r0ku` zvx$_ZP#Ls(7J%UYU=y^EL`BC>?}#3UbNQpD$Rn8U2OgW$k6{VjR!bBt6m0vBISLm} zWu^*OPQ$_aS5T9p8=9_B!lTpC7OLpY$q?crxYggb0(wQ9@z|oM6=)CYq}~kTDK$R7 zXg<%PGKiJ1z5|GAKwJq2sRDKl$(Ob^46O3;ky(W0z(-?Y5$92r5<7?~=(YbN2u z2D4&Wi9cl!ESQ(0Ud3^a<${QIRfNEsp@jD3hLL)#)JSGBKVRf%Utw`rybS4CdpqYL z>6IR2$Hb7_(R{xSy(LAGk>#Q0o&IH(mdU6FZd@q9v+R$}p)@>`3~4pDe}f14nBVP% zMNDM>i^+J2@oSFIu3G;m42@*6 z`9cZYI(EV2a>uqV#|Qs(TUV3#Q1n*Y)LLYBLf95d!_TCX$Y{%k8ssP^|DSDdbtv|3 z|B3;MXKKKoD2RfZr{glY{flsA8yYEKohfX8)Wbt+p%OY!zz<>U^( z3-icd?)Xv@9P-BwL|vgUpU+>tIyrTfL1szKl4q`9|He!wNp|iGHnY4n@Xi%}wZ;6^ z8`>PX=dmsRle{{GyP_Q*O3BR5T{}6fYd;aS>gv?hseHa@-|3kri0*+K{7Wy8AzSsI zJ+Qrs!FfCsq0a+2PYfuJJkVAN?E?x5S<#!gDsIU04;*TOL3-;P8nNifQ^S0rXxs4% z#X2M;tl9$kk(E*1;yIg47Jw0X|Skmti*bP|wiAqG2>MU@GO#-@p& zXhFfjMTcL6;Tf$yUPMR6r-mIt>h1Z+M9b3g~tkPoe~b`lFyv8&R*kjE^Gu<#W4_Zg79pgKZWM ztr;GIj}AJ43QpuZySEHzSUj-WR2Rs@vtwRD*3*YC;GTJ^{;($vM`Hg8qk-tuthE)< z-s#ied?aIHfrL%f!myK*nQyFFPyyC3t)v&Ud05qP8w1LMx=TQ>E+NAwtO~3nkA+)S zK%1bD=^h4sG~uW4`vC``!r zgI}n{_Jqe&-tB>Gs6CDJowOk`0ZAf2ft7_JVoz@cP&t9Ngs(y9(x!_So#CNd)#=%lcy z-Vk|lL(7XrF%Lv=sLpsY8iF1OPT?S5YTY={q!vJ%b<}sOZC*+|DM?%O}cee*xMV9@@OokvH%SPC0`;AJ=>M1Txq{q@@y`|C( zeNxM*H@LK%%+2I3p$ajyv^zsO1j{4dQO(F;XzwO{GM9tMYQ`ARxKicnV0E$@`9f&j z0}c0C;CUvUOs382g&UKXz|CS_bUu*cr&b4ei?`W<^fN!x7X)o)lHG zBqNz|%!_H|hCL4q@b*s4h!HJC?qm`RSV|p&)EdvutU=PMJG~{O@cH5uEDG3II-ARi zQx^&|W4ySSMX&@Vxii{~mQmBFuu@u5v#2ha92)04-ds>IL`lg&BB9&=Fn?)Mk-*~$5ZXo#tx4eEy8`Fu8eZ2@(G{OaD#1CXQ&QH-4c zS36_8O1NPHP#||Q>moGdIrA^n4zr6GiYm4r?cI@XZ>SnOOMBttqv@4-EV z1Ya|cT6Zd&8S8Zxd3Ij;a=39ojbUdHJKYzv5)RjS(&wl#KQ%R%#RB#2x92i%^l){+ z1h}xZ%uPEBm45E!#kVZdW7r$?*WprQ;+%-7UF2EDnnMtJ=8!3>S&-R`43DBzW*lUO zTCOgz6WL^0Cky{)Y|tGe4Tk8ibhM$xM3>q}4e}2k{D;joJY{rUmv!>m!dQ&(T#t2i z#ZFUAOg)Va)WLl<1F&B8UlmK{TfD4emX%gQtrEa2Pglg^z4PzA3f@EnsM zkQ$eIPV|XB^^_hVcV9nra8=8zS#=JrEUsUxr;7IQprJG+P*JX+HY=esTp6A2d$#b_ zU|&~PWGgNJd(Hv#^tl-6r%CHNdFqrWLY}TzVq`qa2@fmQNBj2cp3_}jW?$bq?2HcX z-!%a7F7fs|{Agj0#fy-yFVYu@0P++IYniWu@mq{)&CM6spa=y@i>iEY&PRmG&|82Nsf)kp@-TAz*#$n*RYiRtaXT!B;CRa*D!|a zHUFYHIvolsygg{;iMjNEk2uz3FGCo>f7M7A=I$ab20zmxYKNyCT(pA~=nR1}!urQj zl}=!fguK_BNDKjeP9AM*TVL53iS)(#Q?LutY)a$6u&7B6w*{LVPh-7zw6}MV-cCkG zMk0lz<^_pM!2ZOE5!(M zEhab_>2SBJ5w#1hAw5AWYrnHfW?37Y7HV~P&ZfqY=V0O+bEU>N5<0bb9` zzd78o-eA_SvEes9+*>36IsaSKq_syn*6}+?KN#aIgS*UB{xy={JhHVxUxSg3Lsm^q zAt=Tyo)8j=J)+$cfy>G4k#MLnf>F-$Hie+Tm`DUH9d+31bUOiuX{*@Lz{E0q!^2zG zxz}{{XR>ohUX>t(IDLJco$_lBAFb1m;l&iEHQ(GSBmr-agDSHRAK6if7b_&l4Emm< z?Fb@7u$vQHAEzV_v@tZEzeTd)k*%Axt${hh0cx^7}`3yKw9y z|N7|PRfr~Dz7X6{O9#QL@cz~IT|R9K{0VHTot+(|IgkIbeUI)zUIItR3O`xb(W=ze zC`yCVSDxmS%TBE-fewQ9kD{&f=$>tL+`mV!IK_?U5cyM z=BO!^LT5D^4n?`aju!0|v&HGKV-agq!ux+|e>|Ov$IW=$Lf`%pD2~e?9cz?tA8Xz( zE{RK84jp0>ec7fK{Esf^V4l zgjc@z z2m80Uqv++La%LSx@zkh>J$Vx6K*G&U>1b5$I}sXi!|)-em8_#5Y{j|#jZDanFx;|o zyaO?C0+O47R?*{0t>~W56k3GgXN&uA-@`g4ePp@yin-B(Pez?1q7qK4ybq?hyMM`p zBL#;iZxbK?2ro#(qE{}R*sxKZNjer$TMUD?6OJrkJaqLFqa^*Ge`ElMNl*jOn)u9# zT@DU{_BsTsH)tO^@=$I7zqqx}qQK|)5NnlA<>Ly?i=!pgi*vPBFQz%fym@GPtFBw>sJV?Y=a+aW?CGIof6g5x?#ngBleX!P1erFir;Y`(*`1wcb_1gBwA(l-NVwVQm<-X| z?>u4L?7wR)knTO_JKs6?+;i_c3ZIrf_^#Bq_kj;SL;Ant_+5|J2?NnpiAW+N;Vpf2 zd7g!o1*F~`dI z&!o)n4q>IuW{#AD;Sl-oxb#HYmSEXLiw&YstmK<|PMyUnlW&-hKLfMb<$t-Jri} zfovCMiriQ6dxXS)=G|LRT%_xWdSmsvioDmff1;flKtNurA}TJ>PC!;XVRRRenZXOi z8KcdSd%x;*A(2rE^K$IO9F|{~$-AzQ;m(_*2=Ec{M`PVqpaS=T{-T{1$V5~DI}7=l zKM}u*s)s_1(pSY=LxP-aK zuVdjBsFHRSIiR>eSD}yf&|? zg14BP&TrKT5PVmp@^`kEF5GmB==T`Z-6DDCm-D{0nP>-qnBCum`eaKNy}Y$c`i({5 z$W)rU)?K|BYpjh9{N;k}1-xj;lh=P#@Gr(ZG8T!?oA1D1O@z$lpT%blF3OUoDKZ(h zn=~>mIWS_(pTc{&i?ChsDesg?GhF0xZK041_2xJkf1u#qIyr9m`85#xBj$?4hvrS6 zXBjgY)+(4`4a2A@Zg}}mH)Ysf{xMBo&f-(r;^SoK$!KrEN|RaB1{JAC)2?%Nqf}^T z9aMKp%Q~2YCVD?*?_Ne4NFT!wsppZ0qm z2RD3@AC14^;J@|p_->3^pC8)|u)E_AvL88L*h>B??XNoOF-=beWtS)~+~8&uXvw$5 z$97{ytvljBftD2isVn?bUwESvewX9SE36({hDqII&p8x45>{&CK1GB5J zpW&SO*b>pyM|fA5VP8%y@n~hfj;1>&jlQXn6(xHeY?2&*5S)$oy>SZ@EaAfq-SZ7v zDL&_*K!`J}T4+eC-X=VdGD;PsY{pWhJFZ z(}S|elrq;@rVs$^MIIFSJ)Fp4#9!Ajcnuii?oVRu(yp4QOvAAPNX(lh=og7cm7)qV zzWNi^c>X3;t8R5l%L)4XYx%ZPjgkArpOv;Xh|?I-fRpL;il3s* z(zuqLfd8fg@%UKPt)vj&vfQc9A(m$2*W&T`t?eQH!%|mQdTWhW$KhMa>Np}`cpj2x z=^Ea`40c)vd_j;!Jh`Uibh<_#*jr?5#7#qZh5 z6jnwk3MK6-@K%wyWOFwy59YH|C^9X#icFqfWKJv>83{#(OfN&Rh=ilKOegq2@$G#p z3Htq&1f}>7IUC|XTnRYa&EEy;U&Oe+Kl4Y&a=W99cL%-tW4MrSh@ZT*5PB_=GK4=WNhtr6j}iRKl0lIrGAR~|MWV+*BKJas7k`1n<2p% zgVm5Lu|q>uBg2V+q#wfAE3!>hRoP{>P_2Z}*#X3s6VF0a{JykokKzOlWV#?sX#~$= zb0c>NVXT=kBKpeibWsHsG=h~){!Ys#JPMZ? zyp)ojE1CxLrU3bak;nwNOn{>5cDu!&%IfmiE2Vs0b)BRR|4y5WaDZKIM9CkDkesCa zgvUiDm7W&&m)E!6vHe!S#0+HASPbfOm?=BA_4!*WbCe3mZ^Xz0VAs zJD<*K+S}@I^8C4T=fv##dm6heR(PleLqoC2R0h|%v)!1DPfkuI)E6{35(&fNE1n~> z*>o}*4k+TGN*~zST>74X$MMUvtoLy^GBa~Ib+0piv`r>DRv?t9@+3)>8NO^YA66_KO!PLRR@de2XTL6fJivZzWk!H~!pXF)AHHyMi! z4Gl%at{Uh1$0dmkM}Rk(v#VtQm<^mlbi~P;Lo%5zqDX5b=4u`;H!p#|rkS!-br$EI zHa|HwHaZp>FxZB>U0CV71Ma#6Cc3TI_Ds&*0RQMaFlIvi>z@l})GTl1YZRoX!q<5kbE=v2oAF{WRu33>FaoUB{k>MZqQ>UG(zkHL-6~$8MN7U>0KVAG>9PzP?m}!O_i)0~NVcA&a4F*5O;y&LkQa{@YKDxQ zriX;N9=8x(_M+QCwono!MY!v04%{^Ok(wba%NN<;JkoASMQVgXL*wapR9Mta27{r0 z00>T{3m%Jv69i_LFB;9_bp6^!#60KB;EQnSF^So0e_ zr5Zhg(v_aa-pXVLk3_?$F}dJ#=>6g+o1MDC`tXw`newn2waTl6SYwxSk zuu$%B)UkgMEY1;}PhFmor>Sxl(fE35e0&_-0s|2e-a8uVc{hUiif5O{FOR2CXcxUO z053A{^&m1x?_b}sxrA{cT(1*I&jOd>grT9O7|X{vB?u|f8LF3ONIcZA69yK0Dm5z1 z>C97MidtsVsK|j+nRGUj(LPeg^poIc4Yhro1Q1pbMoy7=IYq^@sF7I68$Ftwp<4Jb z5Cxx*K$fb*7u}6G)cIg{7~Dt!rr4m&w7-bkdoV-40~)085@1q3l;FyE*{ezMH0i)^!)rhp&Fw& zU`i9G@7z&}c2OonC22WJO&I%FMV)1PB7J8A0+rF^tTk=QVDoRi_#&5d;dJa9()O+P}Qwu5f_{z@+_I*2H-_SvT4#@HS)^D>_uG^; zXr>Gq(^)xfm^Y`WgqI~3zAQ7T3ryvhh`(>#E-P4JrX_ya_&^yh?^#IHE_pEo|FVHl zD5Ni)sCRBDszsXV_L&$|o^amP=bT5<;x02eF*z|Y#@VgQfF#?hS>)0W1B+@T)B}$d zz992;+G%sG_4`M>ne;R^P@)^>1NI^e%<>u)&!%uNPx9r$6r&R0P9rGn1sCEr>krBxinqaPX<@+*oWVhG?Yc`BjXljBHhl#xs(OX7>J z@(03_WsN_iz6KgY2>(=OJ~;_tL=$xI1J9TRI7V3@#t$>_P|rpUIScQQ^dG5V7n~DU zToqMR2IGJ@pPWcSkL0L1Mpn4Mdz8(}O?Q1sIiF1GsLGHWBj+fe#mksCjsg;u`W>|q z;lg7pKi3>I2ElOxH8`qHrDx8c8^yKjJeW>0UA}|y{eeso%Ev{T#BfvddNNKXP3K4+ z!nLC?LKRGZ2oC5x#Py~-@IW>(0ndiy2(^a8IAJ0K0|OXfHp~@kx7d?K-JQ)`bTxto zQ>n2XK9!!pO)0EqzzAU>b4;Fq8zz{J;FcVggVY=jkBo4*ZUrlFWj-~X%3NDP5~uD$ zgGs^JhI?5gR2U?8i0$)rE0?mG_RhEFQ}Oe&b2uW|KEknEaG%1L_ktqo1g9a1N4B-}QI!wFzV2RMFr*VmnWm{WH9kHa$KmkKH>P7}y?hKWKgO2X z+{pwV6USeie=|tnVhs8#gH#7_z;t$Y=5VmzQdEeu2!?QQ^-RVD9yxKxU>xk>3O>hi z9T&D{i z9X?#xL9Ly>(9md{i;=jxeY>f+yR%d6?LB_zkg)G)*ml6?KF9ZH_x|+sh_9ogqZdC6 zb{Iqt_a0Uc9qKq-+(BiXo&Hb=dnwL01QG)~)_>M%YfeTyigZ^`dZOP4*I2!iwYh_1 z>^Q7+&_nGVZTRWv;DwGroogCE;MqWIG?mFBarwY`wvoh*9Y;*m-qzOE-VOzE^zME6 z=GJx$h@aklps%a7y|t~iwH2Rvy0bF}hwKVr)5fsXN5@ms&+tu^*WmF+e(=VtbeSb0 z7WK)!h_kV?)7(LoFaujUDt@<_ugABr3HkuDSDr}`X zu;2*t!O3C9qp}~{hOq|#J>BRQ+wa-2wgN)EK7S+{8^uaQAkctK9ux!jIBKZ4w-*rY zh*O)Xl@un5BQ=U@)`I6j7Q1>+V{Hx0V}Ix+qL){!os?EWIC5U`(J&;Mcdp;Pd>^T? zHYYDVu2}U)E(519b{f3Kod?U_(b3w@{A=2o7e_4|#={znk@)sb2kurrABtfi%8_mg zqGtF23gEswG@w7GVv;MtXlnMf{wRSxB%$FTEXx$Cs(WzBA}4PrqT4!pQKl+!cN!TP zfgv9@Wk&})QPqLWMcG3I8yFY@3AxWloBhF9e0G|jQqWHj`UB0Ng)eXXI$!~`L$c#{ zBW&wSgNSnJ9zuwKeW;_&+)8eEsxKP?7mbeK0UZt@VMfR2f6E=nQY`wQUE$x2Hybn! zlGX9T1e$5C7m@)7>}}-8`-207i-2`tnRz>5v6^|Y4#9x<>#i;L97MY)dAusmKAcdQ zw-K@R1wkn`IyM&7X@L&(kja~w75p6<0VRm}MAz=^w^znS&|pDa+H*NeC;#YgzjqVPX;X`B`I|VXGme$sNyouTg)T`JmG&?y>b?D7| zH?0A*KgM??)`Azkz1W^Y-Mg=>>0V3#Ej9f&a7~OS-rl==Q!R#<#9c~@RE$LDs+rQnrMe>TJd&|($m$*3%F;R11qckiI9N4@E z?L%(3NfP?7cxFUzFM_V1$L;cZI3e!&G`BGl z;!B@CP|$_GHKxQ5KYjPc{Zf8tb`I_B#4tCwT_6Y_6>b7?S9cKiRtwtU2Rr)qTI?R~ z9)cO#zv$DWXY6!B9xdWvB#9Q1eg(rdY&V}53G^6UXvaG(+{fkKAB2(<0hb#ikU_)Q z)dSabtJUb;g1i$QXLLEC>{0kShpv5z4Kxw~)l&**x#wJ2!wo_1R09iSNf_?izOmAS zz9X*@R57aXS7?=N0!(t9RF8*5*L|+O3M{8f?}BpUGJsyKf*?b0uyOf|gi4&B46k21 zBN1GYlT?U4E%(={ioY7d`n$ZtJYI>*DXzv5-EtV`K4ajE3)!+Qf_AgvTw#*TdbBNd ztZC6Z!97%lZx0e-Pc=kY+$80>(LlB)$vP2c2hjYc%~(Pvi~j$x_{{x#QTQRv;($`P z)r|z<1~lBPR;U?wZ^YS-PdtI%aU;?h(l@ngp{)1Rtu;tcePMR;7Yr6Vf3B&vSQLu{ b`IRqSP=oO`iefQH2k-@q@_Nw&tMdLAFZDv~ diff --git a/reactos/ntoskrnl/inbv/logo/13.bmp b/reactos/ntoskrnl/inbv/logo/13.bmp deleted file mode 100644 index 209227e9847389b213ff3d761b0033e79d8c27c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11372 zcmbtaeQ;CPmA{gV@=&zmNpiFfVTeDd<4}f5dLRtx7N%=wGi|m50pm>D$r!xI5;0A- ztSv#aDXAOjN$~<%ra}@LXxbUDJ~s4Y+khUyNH^xiwa^E)5++;i{sm;ZWj9pgX4_}zimgF423f_EKjV0yfN`g#1S z|A=^}*Z=pY%2pACk*&~}1@F&k$C-&Sv*UHGdafB78V#crt+1Uj?FL=f`77GTBY3hw zyMeprWrwoL*uh4|Oq)*SV(P1bo+@ zF=_egw+&`Zi-|gX`z?quwp`QBI$8S} zt=dd1x$RActa7nmWOl!z{0O>4lk$d>bt)I`;Nz-8SJB`YCTO=r(qnAW7Wn(L_A0$Q z)@ch|#To5w^0e{0+P~BFnhxO`$^|E`3LT2F4OeZi zYoAb7hLSaaAbnA9o9E|^+F#oYM7*XIc&vy z!^71kd^2eOLnxN5KqL#0;m8s^f1mOiGF8-N-$1@9A|X9=@m?gdn~-)U8mu7Qzk%*Ql@}Bzmw)U6$v><7;%@n^kT+Lxqw-0O^;#OecD@uL~f~P$2~~MBeNl@D9WoF?m+@i%Xt)ut+j}nw`vRnjF1*H z7N47z5o;=wHD-?c6@1md0=Tox^Cx(#F`mrGP)M4mLGsK3;Z2ixZA`7Sz}6aG-D8ap z<#FLz0DiyoPw)g_8MHs}F)nDor_p~L9;lE0hcPZ-MZ=i|*vK<^c`cT<$1XCqOhFN& z%zZ|8T3hI2;DFZ({C=>aP0)uMgIe`f{(&6>RP8$M<7aUu5)H^)c1C+1TE*`YcMJz& zaE#X1VdanB$tb#K3T?Pj}#7!C+xw`?B*+ zqGJ5iP++y|q`%HU1P(dRj4}><L=1T&PZ&G(29K8M2x8K>L}3iy1Sq~u_9Te` zUJtV|dbX~eGF3-$V9Q||pLLJ%S+{v{)@4H9qQ>uBq&j2~lp~B~f5tVgpc;EeKYcD@Lq%AJU$CYYV%Bk4m|@iy$V(<5Fb4HkkW^0 zZ279v%oyxN_pky_G~QS;m7XGX(A&6z>wUEHE0S#h$Q@fTk33I#YkuUkRvn{iW7bD2 z+IxMx0{O3NAMb%jYIBKE`PtH30;P~@SAMd>2{gkUy*xKfTcMGEa?qz6#)XmkcjH#B zektdTTTvCBfxWev?^M1v^Q}ZaA&5T(`woM0+siu?nm%hvjJJd2+t9e<(y_Kpt0pyd1DH{$gz{>Oa?wfen`@oZw@sMY zU{D@K^R#x`$v&ONP+g&6Vturt{g|yddgI0@uR{2MI)jJ#^_rFjwnEhO|Ao%3-uvlK z)q20f_1@2*T-?DnE5BTYTwIiyrg{J=cLMyR!Z)^3yn1 z>zAPc-f8%A^s2Sqmzf)~sLF4wzDs5lx!8bSJN$X-;1Q&|ngnPMCG3KP_ z*;9Ow96%H=St?NvtL;aEj z3vF#M7YfJvrIuBUt=F|lKInj{^}CWcl8HM>8{3Y`p!X7%|Bf& zj?|INkEEv5vo4I)r>x|eE9#^-n#p7@O{w!~*c^KL%6yR=HB2CIw1ilhDfd0E&zDX% z6B~xHX3_aexoa5vi0hL!LYh@S@={}WY3dqsJnns6ok`2#pgausAe=6d<{wAuTCT8X z5yLQAOqNDOnmJeM01`}0RkV-1smoX*v5rh4;XSQhOUFTL*grd$M&2L?&2}zT#{gns zfAJt#Jb`?|5YEolAiyM(i4CfA$ViywpH;8L+#=2GhQkGa3Cv*yz04h@lm22qIIJcP z19CEVN!7HEe0-d@Uhr4cVgh*@@?9Y^dw5r5*kACaCYw3NmnLZN?i@gSjmjkw5(OjZGzidLO3mnYG+UW04W z-qY220+GY=b{g9v{DPseM}$3$Y_g6P`aA15buyQgvZ|_8RV{z)t7!ArE-OlCRGTkS zjKX0#RL7YF&P$6pqAfKkZ9n(4k6m|RJ;Sk5XPtzF z2??GWhsQM}l6DKN0z9vN=tmrtOd^v`Mwvy{_aXO1Pj2LHob|TRbFQ|*Nf&Tn-XTyL zN8GAdez1=VaQ10 z)9_gkC~I!QJQay~Y4%+|k{~Qc1zG&fhMAmFt-nXQH*au_}e6OQ5VI}&)^!D+XDv9L$yDZPx@2o;P*tcvXc^y_{wYMnR+ zM#%AecB=A`FCGY!x3`;s^uXx9xqu|yVPt@1Iw^%Dux<3kYsQgnXQ}7ka0^QuK$SQr zHFhYB4408l@=HKN4xDh2jZ}|dVLP`>8XR-M-F_4Rj1=ytTZ3S=A%^HxtLl5H%X#?f zqXCpyAR(c`$Yn$?*Y7kOo|G1=K|Aal5xJpuj~s`q>RyjclcgWN2$oH%Ixm-yo8#(P zpD8TJY$Z=Xe^J5^oLH()YjhHZjJ>naZ*AKh!Q-9qWH=2ZHxwwvz8eYO}y43 z=ldD`+8D`1l{cxD-+Ym08ILFNno}#ceV8-vB9=IUUEP8ta<47&T5I63gvUIx%#)sI zaje*N^zB~;uX$CQIGm7)*C8s&K{;}Q*`pIYlG5Vr-Jzp`rQ4Z`JuPGMFN4)B?yH+G z0;j8r@^@vnvM_+Uo_v#g3s8}h45_+I zI4wsI!9%=?Mj}=usY|yhchJT80BcR#7bo|y2Rcs%L5EVbmQy#6*~luul*^Usa3&E+ zUYQ$+bC|>qf59W_d?l&YlMo7}CbRF3$?_PvN26%z<;EHlb!uu>``vy_4F9B_jqo9p zc*#Gpv+iTE2(MQ7_+?SI(@Pjg$=ie6zc-HoWgEr4Jj1D^liAtZKB6MWPxwc6P)15m z)-fm#ojS=QN24f0m5FI!)Ob_?aiv^i0>{5uiD7bqYk%PLIFX1WF5dA0XEoAq2eWSq za~gC0J1oen>fHR)CGZHK%NeiSqJoL=^hl!aX(Zqh2G2eHCT@y)^~@rRE@GixnVK3O zhe!UtOs)#iBo`TLb=L+eS%TLpcq1h0I)lVQm1#8HJm!EWz~M^yT6ugNB!ZZ9Rqf^= zNJJub7jukG?EG3?9{CY->7Iam_RSB!OY-4Lqo${szw^q}HAq&p5027sstyo?gj>|X z4Le94uaz4IC-<`6pd8J<8LL;pZy^$v3eEU)^GqnS_2`ePeq?M#yE+OEi5(1C;dSyZ z92iY@%oJj809E1rL1GZQj;wmTqETKUv1X~I(X^|W#WZcfk0vgM2>I{*d>CIaxBn1=kC z3N=yyfHZnD4OfBfxH$+n9HDyT;_|@gXh-=7pcGv=MjgNc%_ddM1p+LnSX5@Kzyp}k zZw=Bs;iv}Ek;oA{hDY-vLbKgl3V}d2R3V*Lsk+)ws?i6aVpD%&;XJe|&$E+Mi5stC zkQ`|rov5wOz{8{4`9drZh^7ZM_)QJcL<9`_g({@7)!Y@83NWe49V0fj+x~duC0MhA zuM)Aw?C@+p84hI5oF%W-uC=w$p>KLnaJ9meJ@dN0_ zlmdE2)~I3^WBwYg>Q`U7tjv^W(V3753*4WU1z$Xt>fggx)>xIdN^8P$?96;VlZ6fF zsAtK49doKWJB2G4`=Zw*I$mAOnNN}?OD>noq|<3; z&agF5&SQJ^JPoYaNLw>WV!vZm(1&$hBH_m(Ldjpk+S`KFZ>~^;&IEIgWyWAt7DbOT z`t|`-?#hS#Zm}-CA#gy&3>-VEUdB`Te6d8r#X_-=HYM0P$YL#uR+T4^tj?Eb=lfl> z%L4gE-M-Uv>3CxJ`ka^%ifmh<2p(9~$0JdBYz!5j9EPxca2i2TPb|uzhNzP@qKqt#(8`AaC@B#SsV>ZI4P5|{U@7r}E2ER06LJA(f;ag@a|EPze(!7vqf15 zm}F**$Z_)6ns7J}7#bQvJ;Iu)JTo&s4isDEcmI(8G4F{<9%Idc+CK@V`{&bPW(w$o zSQ`X|0JHS=1_EPQ1)Q;0=*VaPWnq8*rOp!OzPe-+de+!LFm&|4EcQMS^v{n4h60cn;`+__41Y^&qEu zFq*#3M`I1AtE;=4tN{%CK_!MS6OQu)0~Yp7!Gm7ySdH)Dnf3rBIZ9DD%z(BXjJiOk zyNleyy&6TQjQeB~w#t!ZXs-5(b(}`*?YQ)t&?D-FUiL*&c8=YxK=Q|G|C#)d(R16&vuq^g~X1`#;qP8VzHuH#^yB0kN*?D%_d37oSR z>+rKyvI{udbPlX^Tj6JXM`VJ$(2kL5h#2fb{6#ViG^wUFN3*j(#iL|Yvm-UJh|{TS zDvem%Y8yHapmm~5!_cYoK_;&5?G3^?uoV6tpW%ORf!&-FE%wpLJ1CC=r5%|}Dkv~0 z*NOruxJT&XRbds}69hlJ$=ULMnE1ZJ1W*bsb(?Iu&BYOG2X+JKbZphk4bi7RGP+0y?wjh&Tbqo<02d#MF-d7C0LE3&Jdq4!?ZlpAZgW;GV zl&nB7TmCuiLekEn8)bpuJ7g-}hxy_CC+YicCGf?^%azWEyM%8IBid;b`t<%I&Bg*F+ZSq?!I z%-j>K5tWM=WIx2;adGLtZM&DjK}ru1(oe$+GkNew(wn+iLpMALFG9JTnc=&0looCG z*k2lHOHI<*tV56UFrE=TWW9bDDy^9+ta73ed$8EEY@;1w@;_b{Y%@!#b58o(jmBk> z4C*iHBed4*DkujcnX4l0d0IB*PVn93McF1C9Z@FYUgIN?Of7w=hJi7(ngVk2B0uG^ zApbn6$)(Y0apcZ zU7V6kO^o8Kp{~(lI22PqMjwyNU8S>a#IZ>+gaa1riNc?&-Bu8@(!onQv=3j9d1m{5 z^=jhaQ@DYbxieH*h|#GIoonI143ydHR;;^H-aVH=N1m{t7xX7Q3OlxOx%0fJLG4^fg zsP9$~-o>@xh zz9O9whBj+NEw{z;b_z?q8d6OjB~|As2_)&R$FT;1t?jHJL|IR z4G|)SV^thWOS^sWd+k&eFL7bOMB>{y|mEuob)sMB-?V+TMf_e?P}+{v)}p7%)WQ$ z##<8qcKKiD>8Z%OysyX`!l!(ni7d0mo)Tkw?%cX5AAWF)=eB&bd5h<^e6sbiw0B$b z_0zB9$7est$;nuL`S~aL{kLD`#b1BO-!J}@SFc`SE%NEZ!tUE`9V8t|+Jk{C`)s5~ zdhpGWlnzFtqtVg9QFb7SAB`kEP_Ls^uLJdIM^e`Nl<#C9NvG{4>nKRK+fvwVZ@0I% zZ$32qWcx-t8LavA;JYJ9z?0GlJU^0m{7STV(9U+>XYEV((tY9nkM}dD4Gl#n$x>)Z z<|M0p9!_^<#Ywtz90rNgpyLAb_m0D;DaAN0IVqIyb^PvKTlZ#X@Prk3HAllHWKL^Y z&?y#W9cDpNbz#hGm)Tw+;_zFw;Ppv~wW-%V_CG@bF{y>;l44&BI>Dk_0A&gabN88R zffl{fN(pPwI+@p2dI@DI^g)r8ZkVWZSC2!V(ONx($BaT4hjGHMwKy(!!|5DV(vBx! zobamm>?Ng|-*c|&_ZN52V-3vU?Zg;Ns$pvTB|{kHoz=rMj14F0;)$)e9}ewY_->=r z?+d3*tKO^G?F=-ouKV~tW5m|xj99ePY)XyLa;_Fm_+IXE7U#-%0TWMklJ5XwTJ{6A z7}tEy_VwE1j4*{y3+Ro=l=(%3i^rffLeutHhMhQSfi1}fyXVRs=~ zV%b^owyR@9s=<~aRY0=uIg)Pae%#4#8h`c3-&s7&>s(QwfukE5U?T%$BgpmH$%tZ~ za}&$gBQ#K2=GKEG<3_NoHhaFV;}2i13@_Msw1@r9A}4r|4#O$=^xyUse8+xE_hR%= z@|;!48iBA$N}eVW;qbK{5LiPXvWAeN&_#rXA)KNKSg>jn`Wp*8NWsog^RP-xQK#k6 zWo4Jh^FAVbzD(T8p-C7lB4teTh~y~s9EF%lO5q)#inDkyhZZKzJ(?0NDb#~jLf=qo zpqOs2F>AieQBY-Bw~|X02@eZhm}vw zm6bQO_HK?4G4D&t_f_0L$yf2`i!`LU*t9hRo zhUbt2sRRnmuEV~Ey3QUNz2GgFhj3k^TT!F+(S;7SRE#~*H6q5=K-M^a)i(j@Tc)0& zz-X+C=&5cUm2MgPX%ppGm0=FOtKp=GPggCQsKr(rF5}dw=dcpH{C=zl+sENcjbC)e zZ!LZ^9%eO@+OU^nu@{K*?9A^C_Wwb&z`ML&(`8za!l)lD7IG2vW1Y+`F7^)W=@}Nw z3LWI)E~bwSqMBP-OlfDa4_(dsS*n()?5hiQwvxC>Gy2CUts_u-)6Zk4t@);TO5MYL z#&?N`Z&r5d~4V~Yr%G-W+tNLH=dRP7dk?Z_v literal 3310 zcmb_f-)kII6h1QyyVKd(VF*i_=Ess3r3mdqDOvps^y4@3*NvZL`Sx{r^zb1?{Af2!|yMVvqf zBB^Oz5>LcW*R;MJf^p8es&%6vq9d5%op0&R_kx{{j}-Frwyw< znxnNR_PD3T>4cDWoEFAz5m+w1th%S|`<&NNAoi%Q?7u^?Gp@29e6S4(J5m|FCa&1& zK-(L>*cBf*9fM=fVy+6#K*5R^LYkOX%~N*ir88hRmAn$F{LfnjAH@LI9Ah0&f z>pAjX$9Sj$J4DiYgDWYkwV7xDqU)&UB+q$VEt^@jjMs{hllzsKxf><=y77Rl=( z@!=leQzKUbT@XeGaVAtrhA>xF;GI$>Fm>ja2e=PuO{+4x$c*r(J0kTCMnQ|Pl@4b^ z2ig-Q+2?MDWB###Uj@lQBF* z4LMA#5@QMx+V_OP$b&SKh9_z)sL}%i-tg(ujDlZqwun#WQmK!F_y9nNOkYIQt;1G7 zt>=7QBnpxcCsU+P4N5jf;puwMDTQ1-Aa-;B1RhCTEHksxCV82Dj(bA=d~b=iG`yxHe)=}%L_&wcn)U~e`3u8@RmIP7{mbf z_=sD``gIVkcZnEhT9>mUz5K-nBIdG9AWi}BheMCSqfHiS57>r`WY8_a3rS4~kS$no z>Rs4rqB|3x>Ci+2(+cH{HR%{CYf&JK2isY1|KT9IpkshYW-*B8vA^$cYGve0#Z;nj z7S=I8$Y8-#r8Md;zEBU^h}W2dt1dFGf-@%TA5hcr{4GhVEeckrAQu*~(CrkQdI5td zy=FBeo;N|)J9GMv6#S&ZXYhumR9)ZXdw4vl@C)&`YqfN-$AsBQCgo+3GiuT>S)&6M z0T??YC}30u0h*R>lS#ISjq&^-6B8Oz?_FjkGC0KBEaYw0CQtZ>x7qGGPK|LXDXE!S z5m;&ws*FDze-3$(PCyF-iqBndo$++p7JPXnGXu`QY8R$kz(+(o6uO+AgQ zcMCm@mm923fv4t#+Hu%(-)(N);Ey{BLoA?_S*AoLm) zR)`Wf2B3zGSye!l4)*arg0<9(9k~ebv7y{WbyRo_!JP5PKpXQF6zm)Dm^_j-gISJ*yT2h={eN*F>jBOU)>@Io&-Qf7|&1{Z3xb zAc5k(soaEC^dD6~mKVW%ucb;pt@f+9rLBlu?qc4%hk=RC?RH;CWboay1C zH@L~lFoceWtmp4TLQbUAoW)q34mW{JUrN3JnRYPKi`5wuCi!HZmiK+goSZ;7&h)gn zmTDG&kvg1oBKw-u;-lA@zA1;-L|>DI0=1xbWJ<2bxfx;*`Ab$ancty>Hd}|;U&MOA zz#Uf&(^HMbJ=JNSeT2-T%2^eSzGJP0RxHq3WK1JvgM|oXs9Q1v)ER8%Jop=1>>$*3 z`-HIq=p$A+?g}p@U7@8K1sPNK#}R3-_hpbDo4hehhw7q3T|p#Hp+BADzP+fkll{Gj zPpA7EZY=Dk^}E=|qAwQTuAwTgY5PeyOJ?oXDIq%=WE2^+ ztqJDXEK}%kUNTGuCkM(M<$?in`IZ+M`BsLgtTNnIak=KPp4xQT9yZy?fb?0U5gVmV zq+)$6fv!YTOC`Ce&^9X6g7baEluHc1VTGZ;h?X_pg<*hbTu} z__0q4&_xkXX@a(&mTVP^t3a73Z#b0|vEE5GK{DoPvf(d@|5uDvLnEP@TCi4-R6|ya F#xKn_e&YZD literal 932 zcmXYwv1{8v6vn@(#vF$*wg|z5P->}#P8pJY6Tv$Eqc+G zN6?cfO5%tm(9<|h(qx=!xt?kHVS%%?z)4nQd6A`go~3D?4N@@re9B`OQ5;cO zG=N9ihHZI>@p`?c>PZ7BVSzSdzV5+rU1#bzj^%(^%*4=`OeV%?H0r1v8>5M75Ek3A zEF0Xx`P6ki*YjpG&-aOoBD0v!7mCYr4Hm-KY{Km}+D04tHl8LiRiS#)(IG;53Z7+D zHdqE;C=v9)VkZ`R?m7+B#ktDU#%sk}` zSFzA7@``B_wLZB=xd?o;kGToHXT}`nau3|6?LK(G<`^nk>vgzdp|)k4!w7wKQhJO& zRfBPgUY7D4y&^LT@KOj-Vq8IQI)O(Lyc3Oat0IaqZlHJaC9UIRIw3%N`(zLBT+1kD vmwS+C@ez4;FOyu+TdmjD$r!xI5;0A- ztSv#aDXAOjN$~<%ra}@LXxbUDJ~s4Y+khUyNH^xiwa^E)5++;i{sm;ZWj9pgX4_}zimgF423f_EKjV0yfN`g#1S z|A=^}*Z=pY%2pACk*&~}1@F&k$C-&Sv*UHGdafB78V#crt+1Uj?FL=f`77GTBY3hw zyMeprWrwoL*uh4|Oq)*SV(P1bo+@ zF=_egw+&`Zi-|gX`z?quwp`QBI$8S} zt=dd1x$RActa7nmWOl!z{0O>4lk$d>bt)I`;Nz-8SJB`YCTO=r(qnAW7Wn(L_A0$Q z)@ch|#To5w^0e{0+P~BFnhxO`$^|E`3LT2F4OeZi zYoAb7hLSaaAbnA9o9E|^+F#oYM7*XIc&vy z!^71kd^2eOLnxN5KqL#0;m8s^f1mOiGF8-N-$1@9A|X9=@m?gdn~-)U8mu7Qzk%*Ql@}Bzmw)U6$v><7;%@n^kT+Lxqw-0O^;#OecD@uL~f~P$2~~MBeNl@D9WoF?m+@i%Xt)ut+j}nw`vRnjF1*H z7N47z5o;=wHD-?c6@1md0=Tox^Cx(#F`mrGP)M4mLGsK3;Z2ixZA`7Sz}6aG-D8ap z<#FLz0DiyoPw)g_8MHs}F)nDor_p~L9;lE0hcPZ-MZ=i|*vK<^c`cT<$1XCqOhFN& z%zZ|8T3hI2;DFZ({C=>aP0)uMgIe`f{(&6>RP8$M<7aUu5)H^)c1C+1TE*`YcMJz& zaE#X1VdanB$tb#K3T?Pj}#7!C+xw`?B*+ zqGJ5iP++y|q`%HU1P(dRj4}><L=1T&PZ&G(29K8M2x8K>L}3iy1Sq~u_9Te` zUJtV|dbX~eGF3-$V9Q||pLLJ%S+{v{)@4H9qQ>uBq&j2~lp~B~f5tVgpc;EeKYcD@Lq%AJU$CYYV%Bk4m|@iy$V(<5Fb4HkkW^0 zZ279v%oyxN_pky_G~QS;m7XGX(A&6z>wUEHE0S#h$Q@fTk33I#YkuUkRvn{iW7bD2 z+IxMx0{O3NAMb%jYIBKE`PtH30;P~@SAMd>2{gkUy*xKfTcMGEa?qz6#)XmkcjH#B zektdTTTvCBfxWev?^M1v^Q}ZaA&5T(`woM0+siu?nm%hvjJJd2+t9e<(y_Kpt0pyd1DH{$gz{>Oa?wfen`@oZw@sMY zU{D@K^R#x`$v&ONP+g&6Vturt{g|yddgI0@uR{2MI)jJ#^_rFjwnEhO|Ao%3-uvlK z)q20f_1@2*T-?DnE5BTYTwIiyrg{J=cLMyR!Z)^3yn1 z>zAPc-f8%A^s2Sqmzf)~sLF4wzDs5lx!8bSJN$X-;1Q&|ngnPMCG3KP_ z*;9Ow96%H=St?NvtL;aEj z3vF#M7YfJvrIuBUt=F|lKInj{^}CWcl8HM>8{3Y`p!X7%|Bf& zj?|INkEEv5vo4I)r>x|eE9#^-n#p7@O{w!~*c^KL%6yR=HB2CIw1ilhDfd0E&zDX% z6B~xHX3_aexoa5vi0hL!LYh@S@={}WY3dqsJnns6ok`2#pgausAe=6d<{wAuTCT8X z5yLQAOqNDOnmJeM01`}0RkV-1smoX*v5rh4;XSQhOUFTL*grd$M&2L?&2}zT#{gns zfAJt#Jb`?|5YEolAiyM(i4CfA$ViywpH;8L+#=2GhQkGa3Cv*yz04h@lm22qIIJcP z19CEVN!7HEe0-d@Uhr4cVgh*@@?9Y^dw5r5*kACaCYw3NmnLZN?i@gSjmjkw5(OjZGzidLO3mnYG+UW04W z-qY220+GY=b{g9v{DPseM}$3$Y_g6P`aA15buyQgvZ|_8RV{z)t7!ArE-OlCRGTkS zjKX0#RL7YF&P$6pqAfKkZ9n(4k6m|RJ;Sk5XPtzF z2??GWhsQM}l6DKN0z9vN=tmrtOd^v`Mwvy{_aXO1Pj2LHob|TRbFQ|*Nf&Tn-XTyL zN8GAdez1=VaQ10 z)9_gkC~I!QJQay~Y4%+|k{~Qc1zG&fhMAmFt-nXQH*au_}e6OQ5VI}&)^!D+XDv9L$yDZPx@2o;P*tcvXc^y_{wYMnR+ zM#%AecB=A`FCGY!x3`;s^uXx9xqu|yVPt@1Iw^%Dux<3kYsQgnXQ}7ka0^QuK$SQr zHFhYB4408l@=HKN4xDh2jZ}|dVLP`>8XR-M-F_4Rj1=ytTZ3S=A%^HxtLl5H%X#?f zqXCpyAR(c`$Yn$?*Y7kOo|G1=K|Aal5xJpuj~s`q>RyjclcgWN2$oH%Ixm-yo8#(P zpD8TJY$Z=Xe^J5^oLH()YjhHZjJ>naZ*AKh!Q-9qWH=2ZHxwwvz8eYO}y43 z=ldD`+8D`1l{cxD-+Ym08ILFNno}#ceV8-vB9=IUUEP8ta<47&T5I63gvUIx%#)sI zaje*N^zB~;uX$CQIGm7)*C8s&K{;}Q*`pIYlG5Vr-Jzp`rQ4Z`JuPGMFN4)B?yH+G z0;j8r@^@vnvM_+Uo_v#g3s8}h45_+I zI4wsI!9%=?Mj}=usY|yhchJT80BcR#7bo|y2Rcs%L5EVbmQy#6*~luul*^Usa3&E+ zUYQ$+bC|>qf59W_d?l&YlMo7}CbRF3$?_PvN26%z<;EHlb!uu>``vy_4F9B_jqo9p zc*#Gpv+iTE2(MQ7_+?SI(@Pjg$=ie6zc-HoWgEr4Jj1D^liAtZKB6MWPxwc6P)15m z)-fm#ojS=QN24f0m5FI!)Ob_?aiv^i0>{5uiD7bqYk%PLIFX1WF5dA0XEoAq2eWSq za~gC0J1oen>fHR)CGZHK%NeiSqJoL=^hl!aX(Zqh2G2eHCT@y)^~@rRE@GixnVK3O zhe!UtOs)#iBo`TLb=L+eS%TLpcq1h0I)lVQm1#8HJm!EWz~M^yT6ugNB!ZZ9Rqf^= zNJJub7jukG?EG3?9{CY->7Iam_RSB!OY-4Lqo${szw^q}HAq&p5027sstyo?gj>|X z4Le94uaz4IC-<`6pd8J<8LL;pZy^$v3eEU)^GqnS_2`ePeq?M#yE+OEi5(1C;dSyZ z92iY@%oJj809E1rL1GZQj;wmTqETKUv1X~I(X^|W#WZcfk0vgM2>I{*d>CIaxBn1=kC z3N=yyfHZnD4OfBfxH$+n9HDyT;_|@gXh-=7pcGv=MjgNc%_ddM1p+LnSX5@Kzyp}k zZw=Bs;iv}Ek;oA{hDY-vLbKgl3V}d2R3V*Lsk+)ws?i6aVpD%&;XJe|&$E+Mi5stC zkQ`|rov5wOz{8{4`9drZh^7ZM_)QJcL<9`_g({@7)!Y@83NWe49V0fj+x~duC0MhA zuM)Aw?C@+p84hI5oF%W-uC=w$p>KLnaJ9meJ@dN0_ zlmdE2)~I3^WBwYg>Q`U7tjv^W(V3753*4WU1z$Xt>fggx)>xIdN^8P$?96;VlZ6fF zsAtK49doKWJB2G4`=Zw*I$mAOnNN}?OD>noq|<3; z&agF5&SQJ^JPoYaNLw>WV!vZm(1&$hBH_m(Ldjpk+S`KFZ>~^;&IEIgWyWAt7DbOT z`t|`-?#hS#Zm}-CA#gy&3>-VEUdB`Te6d8r#X_-=HYM0P$YL#uR+T4^tj?Eb=lfl> z%L4gE-M-Uv>3CxJ`ka^%ifmh<2p(9~$0JdBYz!5j9EPxca2i2TPb|uzhNzP@qKqt#(8`AaC@B#SsV>ZI4P5|{U@7r}E2ER06LJA(f;ag@a|EPze(!7vqf15 zm}F**$Z_)6ns7J}7#bQvJ;Iu)JTo&s4isDEcmI(8G4F{<9%Idc+CK@V`{&bPW(w$o zSQ`X|0JHS=1_EPQ1)Q;0=*VaPWnq8*rOp!OzPe-+de+!LFm&|4EcQMS^v{n4h60cn;`+__41Y^&qEu zFq*#3M`I1AtE;=4tN{%CK_!MS6OQu)0~Yp7!Gm7ySdH)Dnf3rBIZ9DD%z(BXjJiOk zyNleyy&6TQjQeB~w#t!ZXs-5(b(}`*?YQ)t&?D-FUiL*&c8=YxK=Q|G|C#)d(R16&vuq^g~X1`#;qP8VzHuH#^yB0kN*?D%_d37oSR z>+rKyvI{udbPlX^Tj6JXM`VJ$(2kL5h#2fb{6#ViG^wUFN3*j(#iL|Yvm-UJh|{TS zDvem%Y8yHapmm~5!_cYoK_;&5?G3^?uoV6tpW%ORf!&-FE%wpLJ1CC=r5%|}Dkv~0 z*NOruxJT&XRbds}69hlJ$=ULMnE1ZJ1W*bsb(?Iu&BYOG2X+JKbZphk4bi7RGP+0y?wjh&Tbqo<02d#MF-d7C0LE3&Jdq4!?ZlpAZgW;GV zl&nB7TmCuiLekEn8)bpuJ7g-}hxy_CC+YicCGf?^%azWEyM%8IBid;b`t<%I&Bg*F+ZSq?!I z%-j>K5tWM=WIx2;adGLtZM&DjK}ru1(oe$+GkNew(wn+iLpMALFG9JTnc=&0looCG z*k2lHOHI<*tV56UFrE=TWW9bDDy^9+ta73ed$8EEY@;1w@;_b{Y%@!#b58o(jmBk> z4C*iHBed4*DkujcnX4l0d0IB*PVn93McF1C9Z@FYUgIN?Of7w=hJi7(ngVk2B0uG^ zApbn6$)(Y0apcZ zU7V6kO^o8Kp{~(lI22PqMjwyNU8S>a#IZ>+gaa1riNc?&-Bu8@(!onQv=3j9d1m{5 z^=jhaQ@DYbxieH*h|#GIoonI143ydHR;;^H-aVH=N1m{t7xX7Q3OlxOx%0fJLG4^fg zsP9$~-o>@xh zz9O9whBj+NEw{z;b_z?q8d6OjB~|As2_)&R$FT;1t?jHJL|IR z4G|)SV^thWOS^sWd+k&eFL7bD$r!xI5;0A- ztSv#aDXAOjN$~<%ra}@LXxbUDJ~s4Y+khUyNH^xiwa^E)5++;i{sm;ZWj9pgX4_}zimgF423f_EKjV0yfN`g#1S z|A=^}*Z=pY%2pACk*&~}1@F&k$C-&Sv*UHGdafB78V#crt+1Uj?FL=f`77GTBY3hw zyMeprWrwoL*uh4|Oq)*SV(P1bo+@ zF=_egw+&`Zi-|gX`z?quwp`QBI$8S} zt=dd1x$RActa7nmWOl!z{0O>4lk$d>bt)I`;Nz-8SJB`YCTO=r(qnAW7Wn(L_A0$Q z)@ch|#To5w^0e{0+P~BFnhxO`$^|E`3LT2F4OeZi zYoAb7hLSaaAbnA9o9E|^+F#oYM7*XIc&vy z!^71kd^2eOLnxN5KqL#0;m8s^f1mOiGF8-N-$1@9A|X9=@m?gdn~-)U8mu7Qzk%*Ql@}Bzmw)U6$v><7;%@n^kT+Lxqw-0O^;#OecD@uL~f~P$2~~MBeNl@D9WoF?m+@i%Xt)ut+j}nw`vRnjF1*H z7N47z5o;=wHD-?c6@1md0=Tox^Cx(#F`mrGP)M4mLGsK3;Z2ixZA`7Sz}6aG-D8ap z<#FLz0DiyoPw)g_8MHs}F)nDor_p~L9;lE0hcPZ-MZ=i|*vK<^c`cT<$1XCqOhFN& z%zZ|8T3hI2;DFZ({C=>aP0)uMgIe`f{(&6>RP8$M<7aUu5)H^)c1C+1TE*`YcMJz& zaE#X1VdanB$tb#K3T?Pj}#7!C+xw`?B*+ zqGJ5iP++y|q`%HU1P(dRj4}><L=1T&PZ&G(29K8M2x8K>L}3iy1Sq~u_9Te` zUJtV|dbX~eGF3-$V9Q||pLLJ%S+{v{)@4H9qQ>uBq&j2~lp~B~f5tVgpc;EeKYcD@Lq%AJU$CYYV%Bk4m|@iy$V(<5Fb4HkkW^0 zZ279v%oyxN_pky_G~QS;m7XGX(A&6z>wUEHE0S#h$Q@fTk33I#YkuUkRvn{iW7bD2 z+IxMx0{O3NAMb%jYIBKE`PtH30;P~@SAMd>2{gkUy*xKfTcMGEa?qz6#)XmkcjH#B zektdTTTvCBfxWev?^M1v^Q}ZaA&5T(`woM0+siu?nm%hvjJJd2+t9e<(y_Kpt0pyd1DH{$gz{>Oa?wfen`@oZw@sMY zU{D@K^R#x`$v&ONP+g&6Vturt{g|yddgI0@uR{2MI)jJ#^_rFjwnEhO|Ao%3-uvlK z)q20f_1@2*T-?DnE5BTYTwIiyrg{J=cLMyR!Z)^3yn1 z>zAPc-f8%A^s2Sqmzf)~sLF4wzDs5lx!8bSJN$X-;1Q&|ngnPMCG3KP_ z*;9Ow96%H=St?NvtL;aEj z3vF#M7YfJvrIuBUt=F|lKInj{^}CWcl8HM>8{3Y`p!X7%|Bf& zj?|INkEEv5vo4I)r>x|eE9#^-n#p7@O{w!~*c^KL%6yR=HB2CIw1ilhDfd0E&zDX% z6B~xHX3_aexoa5vi0hL!LYh@S@={}WY3dqsJnns6ok`2#pgausAe=6d<{wAuTCT8X z5yLQAOqNDOnmJeM01`}0RkV-1smoX*v5rh4;XSQhOUFTL*grd$M&2L?&2}zT#{gns zfAJt#Jb`?|5YEolAiyM(i4CfA$ViywpH;8L+#=2GhQkGa3Cv*yz04h@lm22qIIJcP z19CEVN!7HEe0-d@Uhr4cVgh*@@?9Y^dw5r5*kACaCYw3NmnLZN?i@gSjmjkw5(OjZGzidLO3mnYG+UW04W z-qY220+GY=b{g9v{DPseM}$3$Y_g6P`aA15buyQgvZ|_8RV{z)t7!ArE-OlCRGTkS zjKX0#RL7YF&P$6pqAfKkZ9n(4k6m|RJ;Sk5XPtzF z2??GWhsQM}l6DKN0z9vN=tmrtOd^v`Mwvy{_aXO1Pj2LHob|TRbFQ|*Nf&Tn-XTyL zN8GAdez1=VaQ10 z)9_gkC~I!QJQay~Y4%+|k{~Qc1zG&fhMAmFt-nXQH*au_}e6OQ5VI}&)^!D+XDv9L$yDZPx@2o;P*tcvXc^y_{wYMnR+ zM#%AecB=A`FCGY!x3`;s^uXx9xqu|yVPt@1Iw^%Dux<3kYsQgnXQ}7ka0^QuK$SQr zHFhYB4408l@=HKN4xDh2jZ}|dVLP`>8XR-M-F_4Rj1=ytTZ3S=A%^HxtLl5H%X#?f zqXCpyAR(c`$Yn$?*Y7kOo|G1=K|Aal5xJpuj~s`q>RyjclcgWN2$oH%Ixm-yo8#(P zpD8TJY$Z=Xe^J5^oLH()YjhHZjJ>naZ*AKh!Q-9qWH=2ZHxwwvz8eYO}y43 z=ldD`+8D`1l{cxD-+Ym08ILFNno}#ceV8-vB9=IUUEP8ta<47&T5I63gvUIx%#)sI zaje*N^zB~;uX$CQIGm7)*C8s&K{;}Q*`pIYlG5Vr-Jzp`rQ4Z`JuPGMFN4)B?yH+G z0;j8r@^@vnvM_+Uo_v#g3s8}h45_+I zI4wsI!9%=?Mj}=usY|yhchJT80BcR#7bo|y2Rcs%L5EVbmQy#6*~luul*^Usa3&E+ zUYQ$+bC|>qf59W_d?l&YlMo7}CbRF3$?_PvN26%z<;EHlb!uu>``vy_4F9B_jqo9p zc*#Gpv+iTE2(MQ7_+?SI(@Pjg$=ie6zc-HoWgEr4Jj1D^liAtZKB6MWPxwc6P)15m z)-fm#ojS=QN24f0m5FI!)Ob_?aiv^i0>{5uiD7bqYk%PLIFX1WF5dA0XEoAq2eWSq za~gC0J1oen>fHR)CGZHK%NeiSqJoL=^hl!aX(Zqh2G2eHCT@y)^~@rRE@GixnVK3O zhe!UtOs)#iBo`TLb=L+eS%TLpcq1h0I)lVQm1#8HJm!EWz~M^yT6ugNB!ZZ9Rqf^= zNJJub7jukG?EG3?9{CY->7Iam_RSB!OY-4Lqo${szw^q}HAq&p5027sstyo?gj>|X z4Le94uaz4IC-<`6pd8J<8LL;pZy^$v3eEU)^GqnS_2`ePeq?M#yE+OEi5(1C;dSyZ z92iY@%oJj809E1rL1GZQj;wmTqETKUv1X~I(X^|W#WZcfk0vgM2>I{*d>CIaxBn1=kC z3N=yyfHZnD4OfBfxH$+n9HDyT;_|@gXh-=7pcGv=MjgNc%_ddM1p+LnSX5@Kzyp}k zZw=Bs;iv}Ek;oA{hDY-vLbKgl3V}d2R3V*Lsk+)ws?i6aVpD%&;XJe|&$E+Mi5stC zkQ`|rov5wOz{8{4`9drZh^7ZM_)QJcL<9`_g({@7)!Y@83NWe49V0fj+x~duC0MhA zuM)Aw?C@+p84hI5oF%W-uC=w$p>KLnaJ9meJ@dN0_ zlmdE2)~I3^WBwYg>Q`U7tjv^W(V3753*4WU1z$Xt>fggx)>xIdN^8P$?96;VlZ6fF zsAtK49doKWJB2G4`=Zw*I$mAOnNN}?OD>noq|<3; z&agF5&SQJ^JPoYaNLw>WV!vZm(1&$hBH_m(Ldjpk+S`KFZ>~^;&IEIgWyWAt7DbOT z`t|`-?#hS#Zm}-CA#gy&3>-VEUdB`Te6d8r#X_-=HYM0P$YL#uR+T4^tj?Eb=lfl> z%L4gE-M-Uv>3CxJ`ka^%ifmh<2p(9~$0JdBYz!5j9EPxca2i2TPb|uzhNzP@qKqt#(8`AaC@B#SsV>ZI4P5|{U@7r}E2ER06LJA(f;ag@a|EPze(!7vqf15 zm}F**$Z_)6ns7J}7#bQvJ;Iu)JTo&s4isDEcmI(8G4F{<9%Idc+CK@V`{&bPW(w$o zSQ`X|0JHS=1_EPQ1)Q;0=*VaPWnq8*rOp!OzPe-+de+!LFm&|4EcQMS^v{n4h60cn;`+__41Y^&qEu zFq*#3M`I1AtE;=4tN{%CK_!MS6OQu)0~Yp7!Gm7ySdH)Dnf3rBIZ9DD%z(BXjJiOk zyNleyy&6TQjQeB~w#t!ZXs-5(b(}`*?YQ)t&?D-FUiL*&c8=YxK=Q|G|C#)d(R16&vuq^g~X1`#;qP8VzHuH#^yB0kN*?D%_d37oSR z>+rKyvI{udbPlX^Tj6JXM`VJ$(2kL5h#2fb{6#ViG^wUFN3*j(#iL|Yvm-UJh|{TS zDvem%Y8yHapmm~5!_cYoK_;&5?G3^?uoV6tpW%ORf!&-FE%wpLJ1CC=r5%|}Dkv~0 z*NOruxJT&XRbds}69hlJ$=ULMnE1ZJ1W*bsb(?Iu&BYOG2X+JKbZphk4bi7RGP+0y?wjh&Tbqo<02d#MF-d7C0LE3&Jdq4!?ZlpAZgW;GV zl&nB7TmCuiLekEn8)bpuJ7g-}hxy_CC+YicCGf?^%azWEyM%8IBid;b`t<%I&Bg*F+ZSq?!I z%-j>K5tWM=WIx2;adGLtZM&DjK}ru1(oe$+GkNew(wn+iLpMALFG9JTnc=&0looCG z*k2lHOHI<*tV56UFrE=TWW9bDDy^9+ta73ed$8EEY@;1w@;_b{Y%@!#b58o(jmBk> z4C*iHBed4*DkujcnX4l0d0IB*PVn93McF1C9Z@FYUgIN?Of7w=hJi7(ngVk2B0uG^ zApbn6$)(Y0apcZ zU7V6kO^o8Kp{~(lI22PqMjwyNU8S>a#IZ>+gaa1riNc?&-Bu8@(!onQv=3j9d1m{5 z^=jhaQ@DYbxieH*h|#GIoonI143ydHR;;^H-aVH=N1m{t7xX7Q3OlxOx%0fJLG4^fg zsP9$~-o>@xh zz9O9whBj+NEw{z;b_z?q8d6OjB~|As2_)&R$FT;1t?jHJL|IR z4G|)SV^thWOS^sWd+k&eFL7b&=gTZ2o@G90TC@ikRaDt+1ptuA_%5CYYQ#>ghTuQ>-z=^ z%V2LO4=ijB*4bORy9DAcyF0sYX5QoN=;Tz%I&EjCIw>#7U?Vb65I`gWKim&bys nib7Wr|I2jP&!c*+b0bS+iRqC)sPQjnaMh=)TEB^_9}9i~D=B~1 literal 656 zcmZ`$F-XHu5PgY78i!n`LKUS}5GPx~L9mmEgCIHyiqL@IBy>^dZh{DHCqaZ_?c(U< z>fm6Zn#n~s3*zP%G^iB5cS(xW*8JT6FYoT%e_ZC4N+$egkM{|VxB(EK1|pEuV3=o! zSQvtnBSRP)9Y#7miRIZOwpOOFnOn#H&Kiymc5z-i#`R?t_w@_hHtKkKY~ZE&0Po`+ z^FTyar3>32eXcyb}!sL6}TDwes7tz{6{&D-Of+F2^+vf&IR1)1P z&9#9eo6k2;hN~EfW5E>br3xo=7QM2ZL$osV+^=w&3sj7)LZZiAp(@`>8g3KbD`mBV s;wNdDr{Kz0mnz1#`30qT95bC$4sxs=he^{NIh&b{4raT@m;d*TAB1_BlK=n! diff --git a/reactos/ntoskrnl/inbv/logo/3.bmp b/reactos/ntoskrnl/inbv/logo/3.bmp index 7e95ca2b6626939edb886d5efac15b88fcd883f1..c10b768de5f072be88e3b4753a87c88542fdf5ce 100644 GIT binary patch literal 1052 zcmb_aJxc>Y5Pi9<$8ttjg9b4YQrakK1hKHNNN1Ja&dT00cA|wA{)qel>--AA&L6R0 zVG~&2n@tQ+A{O4=-hRx?+c)#(?0nC`o@@U1IbJzdIcjhyIFIT;lLs2#pY7c)`u#p$ zP7hGK9AM?>8N=Zac)G{r<^tWT52Vop+}k7C<9Ce5V@xI!+@c6Qjy3`BP{hOO8a~Ak zNvMn=p#-)90#f8Ja93%S;37@g?gJe?;CPzQK-8N(73qmBG{%{W**Xm6XRcvt*@S@X zjFig2RcWyn?*jNW!~%i0dD+RrD}eZwVX$2cDBS62Qemlkqm& zx@>%PTGu?|0?%mOl@XagX$ZxOwV)8m><>&zL0J5pOU}}8=3JDoXMdd)SPM*6D7)5 zCn-aPY;LKk_{GeGJ*OTILRpUiKZyPhVNIZ{%*J_lB)#VX_&7 m3}(6isyeL=kM*amJb#YapC=1esH<__oA^TFTeix!jEIMa0l$4H zKL2GVIFI_bUXx zqi^i{Dy__a*f{#BjQNHP&FdOC&vy&=`+$HlcfF~qNjgu@H1c(msbLW-*#u1lgy}rD zOWP%DqPr<=c%-kKq-R2>6UVwnYlQ0G%AjzOBPQTRv#woDfK`|KxhbQg^IfnGL}uM1 z*T#1=mDPP(dPY`J;%>Rf#ED?-ZYU?2*4>XH7|ihXhSVal0R}ile~tx#$x|zQ;jul& OHyYd6o+aMnU+N#O=k?hD diff --git a/reactos/ntoskrnl/inbv/logo/4.bmp b/reactos/ntoskrnl/inbv/logo/4.bmp index 239307b7d958d8eb4fc4a02dd93580eb85ecfb30..7aabbbfeb6e5dd2210fcff4e601d6f547b3f1ce2 100644 GIT binary patch literal 228 zcmZ?reZl|%Wk5;;h{b@I6NniZSQwaqbRG~3aYHbWNfp4R#KZu>3{V=xM`EWz*=ay= a5F1Pb*>{2LyC5118>R-P7i7<>UT48y1jDJqQSXbwTBu-xRtZX&knnq^)iid)^YNkVi9 zD01v=rARNyVplB)Fshx@EeyasR+8>01jyD|*TgnK?)WS_j6hyef7Mw+fzFn5Tqh-g z8aO$^aJ&a|MS1~7&6YU`f-$bm+6O;vL5ljtO7~}-}Tpi zbFL2=x;id4{OXWW{!is|*uq%x{rj zLUE53^3ChqaVZGS4M*dAkYz zFY~S^==(XxNcsNH{GVD%b>Hdxmxt8gCBHc&V}jQj_BI@qW?c{j$%Jl zd2vW^4pk}-$bDa0d_Z6Qp~{2muD!X)eJzcM%}y$`?c9&;)SdntypCM*8AMtBb@|5X zc=dXF1Q6}pD~k_^t$(BPw;I`~d`l#=Ix1iNr4jB&TOz69|6Fm0V>W)S)cyYBG6Fhc z1Q}DX_9KI(H6=(Ns(eNG8!?`(^zpXxIP)~WWPa=I@;Ce;jee*9xLh5438>Md9wz&hQ`;h~D7 z-cf;l?=TnNjwG`M>5}<#K?P-8vJo!BxNcw7qw?_`beb?cRMyJ2C^9MG?mo18D+(OA&HSA8w#bBhq33-EZ_@S*-tR-wp9{(^YkA%Fgtw#N zbEf$v&@SJMmV$Pd|0ox}EbItgeM6i{(5{LgZNCb^I;^SfeN$85Jp|exzjH6r2$~I2 z2VTW%$M%1w-Tr0_c(0BD=JVzaw5sv$tcV3wh?YKc zkpq(w(|yO}-Z2 zd5U<;Cw9kG|Ku+2ZFmThhMxVFQlCNU_uPWpjyYXd{p$(U0a?DxT|EJEL!VIRM><#Z z+L9}b_*K#qydW!C3dZ7nA+z#LrJj93{n{QT`XiS9kW0)v$yr2d^C_LjhIAf#B&2hr zx=W*c?j?<46Ft@Z-~1AaFbgJqcrUYdv@+}Ct;}lZ%=#6^5iDE1r}7}tDfCdKPbs8& zyF>xvFZm?+{^$JW74f8?nQi#rKdHTo6#0`=t$Z&!yrc4UiJ6wfOwcRlH;G34zUf&q z$NS;(zuwCR^NWu7hSiI%x#wB)Z_uM<5@T-Oh4n3?ab2CUm4;qvWMJt z2ikc1T_1sudw1C#mBj}|g5Spm=;tAGQSJ)7EqC%sVBoBeueI)zZ2KWdDt~{copl3@ zqeorb&F+qG{)m#HT?-(U)B;`qptB#-Z2 zLnUNw=N$EEjmo$0qW*b7*FU$L^LU}IfQs1Tw!JFLnyEa~r>m@ARnz^d?}yNf;~46k z{51^qL0EdXG9BA69V=`af52<`Yda>d-p{v(@HE2+cg6+=4g|u#r%b~%0%2u!4#X5! za@G5|>LBtOMrX`TTN!1$ZY*Yp|0&nnVP(f+Zjw)fNjDZ%#z5=pK_}*B3&pCpFk2|3 z-B^Dl>ZoIk6^Vwk$VncCnKIJba^Vohq3JcLN2 z1QkdovjxFY!D=os5DTOIKsd(G3RIi9WrD5>WeT&NS8$b#4~Em70wV9a!I%mr+$3Lv z5XdKnWBux|Mqs`z)WS1qHxY=bNIdRlXT8<@DedKCpHMhCTP?T=WyQ<`SRoV` z`>;>c(Kh4bxZsOU`LtizVROKWsgUayW~*sK$3`+?r{&tQVAwKLcX$9Kk-2(7(8Fl@ zpb?1;9F>m>pbUp$Oc2Wt18%wINr|t-+um?z+)ZbaN!Ly2kw8PEB0Bm`3zlhcT|m&1 zB59=X43~xt)=SKx7el*lI-OzCutl-~R|lQ=#SO1&mDIsPA)n^*NSF{JV?9;?H^*$O zXc%!E;*DU(Qi2^QWQ33w{u~bXhhuTHQvfAc^|r4h3_&NJ2aL|ydR@5Xl!QXz0ntGK z@RZi&Cv!0-JaFVwpAwZ~Jsc&e^?)F(^9=5QwX1?)*PGR-;7U|BI#U~db6dgZv#>8Z zFx(%O`DF{p8$d1@rv*$@8B|Er_{9lPWxbO$&-U;I&myk=a@ARlixq zm!u{T>~6&My+S4cwKIjns%UUE2dR`5SD$d*Ou?%+n=(WuGc`FmK0cjDZPZusRIP^C zKrFSuJvJ^a7!j`b{p}pJm((z17kp>-Reu`-!73Gk(e4y{#Z#Th}rF{_0U8Hgok{icWS$xO(3 zG83<{En>mABTg7{iCw+z?ObBKP%4$nYu;9){(U>6K0K89MGP~Zy;}FG?k>L52_5R#ow4>A2n82C6p?dNR#`>n7nZ!O`n3`BNlaMuLFU)DajiC>NYP+;GaPW*6GH zgGLxeimtaBzJJBN=&da(dsTI#^K|m6K;g9+)ss!T=jzSvlF(nrZE*9mUT(L_SCP)F zS4i&4J4pU>-Q;643rqE;?|&EjE-7n49hqNP_=fvjv+jvXGTCYOY`wYTl@k3kn@jV1{F%guoxuiT}g-*dbPv5nQXDVR%@_sP{GUNAXlt46{)%xeT-PhD|FKR zOyca8jFL|~k_kl*t7&F_O6vjSF5}Q_HRpm%h){Ar1^l9!3vEFM-Z3?CPN_d>@j=#cW9XfMgU=L$N#$ zuxPk>qwHPV`o2pu26ckEznpg4utJQq)&deINVvJ162pdkA};y`w+}Yp-kCxf+_l

WI6YKIbEEr3@`{?sL3cEJ?VXnwmZZ8${mKMEtCm3%51V6+Y+X67gB&Mb~|r z4Pv%(WofxquiH&ERIkOXd$7m2SeRo1HR*(QUa-@KKvrp%1_@7l;!$rE`kGg#e5 zj*>v(o|j>=zb2e|l2aB6ZolNln*isXX7 zaHW4&C!H6oNIqM2Me+|zq#y~PlI3+Rc(W;@UrA!jdd<3~`fA^Gg(a({QhrXfZA~#m z=7Qw#F4J8A9mj|YdP{ovG8{X%dZAC&DScWqqVsvJn7Y+aM`eI*I3gp|)@$F#l%knp z0c#??h4c(z4iS;Mi9ah+qg07|G+bL_bW-B<51*?N?HFT!OGDbMShKFIhS@ZIMhfI0 zOj8Bw>Oh-2i*Tn<#OE1inlUcO7#&H*=#*L9I>yE7g=h>iMP-bmqNgNOpRd$V6DiYg z@b7h)<2S&MT*d;;?X_}QSw-@97XE}J#AY)?5|O)z{ojd2j?UhqDGb2~_sIyXa)u29 z)@w@$=j)Az9-*1OBoXFrKBzZ;j3xY?O(r4JC}c^;<`bZIgZ^|ZlAOIVe9H_5E~2H* zqh4-U@DCCP2(dV8MY9O$>FunTXDuH;IOyLzsrR>bd zoG_GdQ(oHIK7Y29?}3xVr*7?2(T>!@%7Bi!@cyVV@L>#T#LiVO3=wom?olUV!*|8l+qMsr%-lf znJ@$L>t+gR4__B*AnoQ_d2wO6QBS8N-olTxtWkv_v)_qH1@d%s7dPGs?kS_iKx#=T zc9<(_@Npe%*i1i9i%9-HB^*46yRKI%DU>!puGoupyOA}bLa!v!5x%v;CZ5w^*RZU{4=GQEyywWF>J85O6$SQtqs2Uty2U^>OhDVIde?woT5tT=eQbJK{Bk-YVa!ZpJK;zbcu7k- zjxp{~r;hENv5Rm}D3Z!ch}^29@fGu7WY3uo)7x~KO$x%SS0TH0FKjg~k7p*qpJsVz z%FY1TvsYr#7Gv5Gc(_HqFkDGTjfkkdBx)zFYtI>PXsusQ66bxo#|^8l?DXu~B4g}Z zu5X`tj4`HV22;%7aT!HNFefareyBalP>YL3jI0%fG~@ZU`qBPn^ATnMCmC;u88rOY z$G!P7VyxF!#-)H`3iwdo{1ZXfY;>rOS7N)BfJV>pJ5GY7DAXo^?D&4mf5f&};|Ni! z(P-w*EtX2f;=Fi;%Wk7rU+Z2d_m8dPl3M zE7aeUf5kk9ts7+8BQyh_$+1>Yf%uaal>V z_hx6byArvuXIuU^-3Dw${)3bWjm8bPSfms!F4tdiB?me(1+vGV$Oz)QiLjwV<=zN7 zd>Jt&!Rmmzu+1QASN}QlNo*|KIgCU5D@oQ@*_mf|XD}t%FK^~s_}+z>tU{}?XdC}< z2kdkmV=(R&5{YC!Um`x%C1Ys$+cC12BvP*vl>N8dnG!)=IpwALYc3`TOsRvJZ1zEA z#Brh1O4t+cYoo`}%qnS5+{=w+BEVUD@00iD24vJfpP_Gttbh?5Qqa-9vswc8U4v&ro<|i%a!aAP;39 zl4tUN1}Y-=3vJMjV3SWI_K@|o-r-E4I4^?l%8f^LgG|J!*RJvL>n`~yJ2Ss^LujMy zDRm%|DLf;P3BpSJ^IqbVk`G7_pfn zA5m7d2tO@Flj_Ul^O_{cr)}9r9uh^kj!<2YXIe5txmFBdZ|6j#0qlCML0p#twK!kD zL4X&UPcz8}gyB)uK`Dklc2QfAMMV;+9KJvVMqb2yQcHWb7yFrYvu@SY$61ymZh>ny z8sBDlF1XzBZ{xE$t>1;ejP>oI#)&AWm_R&@iCeNZZ@A=)Rz5-t7OYe7`V+Nl*BJ7; zi*L@LiT~?LT?cly@JB~yQLq}oCll>H#o<=IFj%tyjJO!if9>IxwEK4B?4T5+P%d|t z8mPRm)x4b26?Gp1XaD?YJ|07~f)^j&Lrp+$n!Jg7+u}kf_bRBac~x|vdf@_s%4pZ! ziXw&&&u=u|bXjL1Yo?Hk=g{pgk>LVW(cO_)N|HUfO)e?Uvuu0)Y>Nly_DNKQx;s0y zYn#`uiLjrkEG|}-$(?5lfsE?S&c$W+5;o$k{-8zkWg+e?gTE!s*9$Bdn2V?PtLV_O4z0;_uIA5z@ zPqi581_ayN@*dV+WOGw&Xe3T@GUN589Hs(R7>g7%w#yIi1 zP_AsPd={PNL{6e_+Xu{b^O{{#K_K5qNlrP0r-%omvM0jI7}Nn_4{=bJHem`Z5SMD_ zuj;BawO`9c8nO>i$Sq;g4uE;`{NK^cGp$^hth851Dk4vNPrN z|B=$NJ++_81rA97+(9mTiv#G%(%*~$0Kbdi9P{R^fo&h7{vD^uo; zUmlTZ7w1<#>-)^gxnPW_P`}807btY2PaR7^Dmlgs(WYu%J z+83R(cE)*Zg1fq+Mii(*f6CDdQX!jOg5uaWwebsh%Kv0!MuFVZxT>y+McWh z{Xm19(1aB`!Clr#QN%zZY5Hng((Z4cMUnJdB#gCD?*TO{sO9t});UW{H8E?GMu-Th zdm>$eiH(q1^fCC_XHf{6xISLUpdK`at?5kevm$A+ zjK%9a)-|&x@y^^aw?Ic)Yc*81Nq(T|?hM+runvJkgHK#V_p9DJT0Qkp(NLo=XIvirCdw1`)|;`BDmp^`4|e&*z{lfoUTkJ z+1Obu&6Va-&E~bhlI>a7Ko2c>tKI_L8@m)Ns{k`c+tNou(%#%9spwc!XV@&#yOdxJ z8MkH94>vc^Vzt&(*V2L*R0=eEP+S1vVj*GUBc=j9T5RH=j6*r1x zvgb(`_rPr#ro2iWT5_+#?gi$wpt_cz4v?O=#5=ppYy<3dff>@}xL#4H-X?L3BBSw> zgzROt5&Jr(ll7f4y{^k={hifvIkI4`nO*>#BHg1Bu)Tg(?M+pBijD$z45*z|4G{(OFJPCCE0*t09Wu~XZuHC~TJ z+en9FZhdEwsy%nEzD-B32v)gRa*)X^(s#BHiZ!_E&d$sT*rx6aidIZxR{{=bvlRWY?X0+H0ss|5IpOcl20y>?3&LvuUsUtmzIjIJNx~*FyE3lgK)9ba$;xa9u zpAKlCay$hP+fUf%8x9yu_bLy6#i^`LQO=^X8;Ara~>OO+r&>lUUj#^IR)G%??mP zw>0-1uZBox%u85YTuR#^9f{M;PIgEcFn3-o19tFsLVV!O;19!*+xC2bs1IT6A#y4nw~&q`~x?{HuL!S z`AHQRSN7P6GiO4hDl|4pF<6m|r-mxxcAJ|L04ojuHCfMSg|@4W!yN;%$DqdC=XU0% z!5p0sWEbd9QGf+?NBWfV!6+2jwssxALb8cx!XkM*??(dU9}>BN7l zzA5?~Rgnom1@(+**EutB#yxRj^bDvWQEOKA66hH+z6Hrm=>F91%)JK26 zKr7+bq0;mu76vznrGd3in4{(yXH*4_kB*Fv$cR1SQ!q+|EW`GL7=MPgSEC6%rPjQl zYdC7(ea5i#4V4l50(_dVN6j($**6*-!8#A%f-}IBOT`%+aj~4AgQoSjgpjB)Hz0Ec z<)B!Hb!=zsueax>H3LDJ=ovLf?BmvmdE7jXRL7uIrZ5jofhJseu{?)Rg#T^YQEjX2 z*3x1X`sARS~)@xC_N zp@=Zt5$~=}Phtx3kgidCMA^rV9~-fbDf{@yh)CEsHr7%bAudbODqAyZKMjP<$HcGO z7HOmQv@OESOOy75NNA1)M-fg-s3L;R|Gcx|z~mGLK$Cj?c9^3q`8oQu%ge85HX4J( z+ufDKu-*qinX}dW2JpcQ{@2_^QZH4-}38UbwtuzpdvNs&mnmKd!L(dGhu zGumRO_|mXmi-F!_(B{kaE5y$y0tk!LlLD=}MEcRukz>b>gWq)=6A+-FI<*Cz0pfH< z4bnebu6<8?{jl`pu0XQARbwX>?2{~%i;lpD;6!jz#}HvXup=sPOgSSXqoc%Ushccz zF(o4m>0N-VDCDccvCEi|O~zyX^a=Hh$)(F2Q+xc6#JbGL?BK1g1)upmk zRKGE!&;Kx5hL%*V23Ofv)Err*P1Hu;CmU*~*(4JFNgNDJVj;;Sqb3$a7tV1}g`8|c zT-h_TGU)42M(cu2AnET78H4Ot^zUM_H!o*dWEb60BY`n<(ww9M3Q0B)SwRh=VVn(n zIoTP#n>)>n?j|+U`u?hh#Y>EC0&I9!*1momdRQCpGzWx7Cy;~vU&NY2kHN`FY&eP@ z0;8j6CirSfIkXyPisW&w3{7QdiEKKY&s5zk=$_Udo!dj-9|nEMprr);l%Y9ykRX+j zvaLu)1pmb7Nbs07YK^@_L4#_9*z>>>siLiYZs3 zS}*jydN^U`o$r%~7^Hk_C^e%vOi9yx|% zN@dY2`5O+2#6NK4B#iK`8V$3B{qJw$I!Cp{Btm^n;J1NYmYOCa#fKJ|bch~AYGe*l z3QB|$#(hP08oGsXpkDOo7Vb%Vbm2-OEY#4b_HC0h^Hl0xV76r?9|n$mj8H9kD=2|` zLaL1rd_&;Z^=`g48X8{xvzy4sTLM`^os4e3A9l8+E$>OILPw6FhmjF9p?al!(auC= z**YZv?rK8xa8u$gD!0sxHZt+AZWsn=aYt6&hUF z6|2clouoh>rZ-+37q^X z#@YXIYD=-noK$A;K7>8Y=G|eYj@$Pn%m5b^bEvF$hMNT?BmD5!j4R* zIR9-{IdXC?M|$OKT05gex{F>~%D_`nzxTY8AR*xk>qs>q2qWzXLBM&b4-7fwk{d`Z zR8Q_{*65h!pp;Y>eBaIDS57qQC=fhmx9%6qlwTU^6B+dV9K_j^p(D#F0zQqhel-VW zZ@X7#$=^DokCkGIqC)fo0BdhV=EG9sEJ)D`3MZ*V0dtivC z5H6-N`9vg^kdu~ZQ0~71k5BF1&wQSq_2y0sOE|a45$>oH9_i6FEk()%)vL?FY#K*g z;l#7oxI4F7aXLnFHaELbO=uprPKd}seHA{2FC0K`pYG%6e_YB|mqXT?z4+?Jl@#eq zSC<;KuyV0Zmc;ve4TF>T97C_lszs^-%NQ6@MC^~5QGFg@IF{rjt2|r4*;YJTPBql4 zXG^Es>nJ#qdxS%?RDtAy{ql%I>y&QwLJS>(7?ktAVS{@EoOz0|m%u6T*4f#x!99^M zXSnOHor6Kvg4@_jLV}Q9Ao6f-~rh+kvlV4PH(>@`+0&Z42s0pImzbH+cOu;1^vu~ z%bD!Ks38Z=ITY{7$;U8f&yPx{%t^a?CY?M7;L39s^aiW+1)W)MgOlQ?ce^n>y>anX z&Q@~%ozv<$JElIt0|IPu$|-0;X0@C&rI!E5YwH-D=Q$U`3bApwpy3L?jMcp#?gZERoRRD3^Lq@VlIND3B1 z49qdiDShztiEsS?h5%~z4uMFx61vO5ZifeU28M?j-g4={abP;v-|lyY@G9QwGxqkt zz;M`dI2Q-qAe85=rkQbADu%7JpAW%*IC%%hg|FBo!5*z#ClnGaFLzSOGelrr+ z-;ht}=ceu^ON8$&%<@ddLWrkO^bEp-a%Y%3<7TS2b#?zgX6{@aFgl2Tuv%F>(I8y3 z@=eQ literal 153718 zcmeI5e{dV;ncsIsS(Y4+2@r|%vk7IkzRX;vAqgKWUp!WNv3qxO(`njR=Jj$jrH%6v zR20kC9)Gw=8aujz0HcfS=nlrh9LY&K3IX!YZLdvYLhN|XEhCUi>aTN~P^8sn#wX`U zfUaBDbY*P6-{;+3fRyA={wv15uMJ>#u?u@Y{60V4XWxDIH~!J^@9r|#hVl9&UXNq- zqG=eWv74I>1K-EqXUHppRle9dKmJjpYyaOdKK<#xZ~WuWbQ;#@dyM2i|2<>ukN%nQ z^!Sib{I><;zx?pK#$Q+dy|L(2jQ_dp7?*zbQ{#>Q^S{*(=yy#(6VL=S0Zl*?&;&FA zO+XXS1T+CnKoigeGyzRO6VL=S0Zl*?&;(kOK)YcaG)}w5iOuu!vC;ON`#r;TU*zd- z7{)$#W3M~0v4Lf*8J}`by<# zj{{o0wHtdj_VpXa8+%@t598p;w$t5)d5R|vVmZTT??2k@^K+s#T)?{L8|Igdypa`t zZx9yvMQr>?&3MDu_xRo?u?auS-)QmHZXD(Lw7n!G>min@-^&3{qZH=ej4uwxf(I$xAumD-#(nM>l$~v9>3RNo*PD+AOZl_-Do@S z3LoOwpcH|QiypgxpF*itf%MnIVZZJZ#x0^ikDpN5v(&E;85h9`U%!Tb_)X!G@xO=; zjrx0CF^phK6He+cVqEIxUaj8RjU)a0`i~no#WwamPBOr=YvTkK(ZDIU_XXoS2aU_| z%W+b>`7)`9{_F?e_NW0&RaI=mFpr9GTmJl8@;n8pb7kP6QKXPrC3;TXSDQ^?yyuEL-C%l2uo^;Dl%R{bb+fM;f zJJP`ywLzwb8+&T6;JXb&eTI=`P|Dkk3>vqbQvBxH&a*FuS{^!Z{l<|9`5DI1 zZob;SdpADO74A2TNBSSZ`-b<)tzm0TrM!dSrkQ| z-PhT6k(5lxaL(BC0{N*=Yz$o!kEd9*8}`0ug`dB^0UWQt%6cI6cjC>9eBBahyGYwL zfb})Q#CIFsXXxPJgo#K>c^k$j%-7mjxKp(}RocT20to!}JoT{+zS>Xzem@T~VAtw9 z>HNwMsqJBU7yYr6ce#54rM`1g%gdXmz0zKj{%!_Yd3{;M55u_e1+BlJl!y8q(&tB{ zmUokT+AHlf`M-UzTX}T{`r6R`Z%ZjJ0D}eEBVR%M-Sgz#{d=DJRKNLOqY>_SbN`1g z>iBzQDNngX@7>S;+FiyE_4<7l2N8*Dmpdiz!)kc*Ka#j=6Gm74MsL&vGyzRO6VL=S z0Zl*?&;&FAO+XXS1T+CnKoigeGyzRO6VL=S0Zl*?&;&FAO+XXS1T+CnKoigeGyzRO z6VL=S0Zl*?&;&FAO+XXS1T+CnKoigeGyzRO6VL=S0Zl*?&;&FAO+XXS1T+CnKoige zGyzRO6VL=S0Zl*?&;&FAO+XXS1T+CnKoigeGyzRO6KF*OyAs*y8lLR+u3LRRpX_W! zGCMmb^1HaRU9Y~^Et;R^cXes(WUJQSPAFY_AI0{*WO3-yEdDhe53j8 zgwnP5(fqE>W+&fhemkLb?R_-AYqQzOH=5s0C|!FW&F|W5cJhtpw-ZX&-iQ2j{pH$x z^f#J-CZGvu0-As(pb2OKnt&#t31|YEfF_^`XabsmCZGvu0-As(pb2OKnt&#t31|YE zfF_^`XabsmCZGvu0-As(pb2OKB+%}99FDqA%F+k_!mUqsdK-YVyA;P=V0wD0@KKFrl0s-0T>-RHN@eS@dEM*z9*raEuM%e@>?tiJAj`yKh#=l4N{ zFF>|yN;W*Dexk+SeSSyX7kH+p-OY!LU4u2XcC+i|BIcm$z9y{px$c>6GAtw`A5pyVaA{3_HWMc<1^*YbEVar$Imn0qi(-C;e(7O``kCx8q9cu zw(VJU+sm?`_}x$zT-@>3%l{GYX8AvHrLFudKU%$c{0@r2n(ph~`R=M=>7e_#T7}_) zpD>jT9~aDu-)G8!qcfi=cLH-+9raDYsD7Yz-#vacw;SiU&j)50M`6I{-}2A9MpmcA zrnza4&=!8?)bkO4FXO}1++NRcen?uGi;P|}nyOt5NN zRT#)`clk-R;=Mn^3`VtYhR1%-yY-Vi>1*<1u6$K~H?K z+V8$s`xHa)iJ*spjIaMjB311suu`24e+xdZ&2RTtP{9hibxnt~-lEUXcn;p~U?XEW z=o-7O+5c$t-+aCKU}SyQH-Ybrzp1r91Agu9qY&K-{@I>KSESM5Jx{GQR&SBan%l1G z|Go%(f9(HIi+=|E_JUoTU$8<*Mk*Z?TvYw#6G4COIk9u{+gJYV7C^uAJg$b6%Rkz> zb;~ZTwG!}Sh(-DNQFVG>r^5Dn-4bl(mqGpSCS};%wmtv*67s)~lz$j$ElBThHUU2g z2RFNK$*F%>k$cYlD;|2cTPG{ygsMNcofq?!19orAQl3H4?@QY>`40c}_x@K~`JrOJ znKasv%{<9dy9pOOI+@%2O!y(sKGSU`&ht`JJ99?YHMVBSyUPF0FrEqeAn$!VzwitK zex~$+;pwCyda#{PYnQu)pK;Xtw!gveD{y#?wwJZ%ssGT}(DF+GKQFzzTM+rze_^U@ zkBhD1(#C07WoGB=@1xu5f1QRw4Th!#{B8mzwqH5r*3WgzBHngoYwl0_{WZhHmCc_& z=&gz-Z}cu&$~LJ#`~1RzG2nNwsag>5ddCH2(^E5%V6TrzGuZW%TY2X5-f_RDg7Fun26NLE$9R3e z{2tm{@#{M5HoCq${l8cIFwns3ZTz-3{@^B2UO39nejG)Lw^MAvejYzqEyusS|6lpz zU!cf;V*Gab2f>c5yx`>_-nf_RI#Z7y`fy(J^X4zf`s3I2WAD|S6~DDyBZ%(!OniQZ zH-IhZ_1?e%Y(C5#|6GW7+`Vo5>7McO)14vap-){C&;&FAO+XXS1T+CnKoigeGyzRO z6VL=S0Zl*?&;(kNKqO+myYq^e@AANR_n-TvJPHgqF5p(6nH@u)ef~mP%!960GEs z2&&g|2GKagC-m$*Vh&q|huPM(j%eZSw}M0^&&bP`L^u_K`DAZ=|J6@B8i(g2Wc%r~ zm6XF02`f9{%;z7x`VlR>HJX~J*g`>)zYZoOS%#Aeh+ZuYo7g2mjUv!sm;KClx&YC# z?1@S`bOs!Q@lis=fZhjE;w})R1S`k5dAoFguj>H6wQ*c;6#W);WG|@Vr~0?=-{R}h zSOS@IDrG@}A|)Xx*628C0^F)7;!9C{PvZc5C-jiXSXMfnfi+)Ev8{|Sk~qHPREou- zZRgV<(h)`2CDg}g!#M!#iAJS=D->wFj2w0b9S&@cM)ybK2^hSMpQt!%=aO4-w=z1O zn;Dy^R>4DBk%?cli$)B9l2hm6Fw(9&zVHR*3nS>kFR~^${P$XLw2Uba41m zt-h8E6F@UDQFE)#bR%;{4hNfMvj&inRI52~1VG>$9v&I~!r-*1k8Up7g-D}1ev(Ba z^?uo{SHjc@xfSwr;mp!(8Cwi-9!}3nAfZD}41=r_U?wvWD$50L& z%i6{1v#YiG<#fu1{f=g=I~Re^&J6zpxV|8XPJ_Px1E~qO?u4cj0{J<$HIWm6BN7K!8ev3{-?3txJsf)Z@-r#n!6I&^Hp?QcKGLe zukRK^CRc3^m?mV!yaiU8vj$70($w@>XSI5vm<7O`b-Y$xDCWmTMlzXXT#{%MP2Utn@lw6oc#lV3%q_sOsCEh88VqnHfFknUe!|Ihwi2gnol7k1*r~1h!$nNgP#+tgK3lE3 z?vD{)&Q4EHPfbsM-#S&ViXCUNW7gqnecdT0n?0ZUkC5N6?c}>dAV6~ugpzX3B^!LD z+h%35h0?+b1n8a_0KoFX!a~J5?jnrXc^LB3$-}E;nNME{3H;{MkoAL&-)z|>^OF;m zoCSUX2Gd0JVEwsRDle`=fOYVdmL7EL>+=Z1b^(rX3F<2$CA57$biVp<}L3KsS_efm8j{onvC?`PYkwB_MrAilDv2K^;bQ^AMqgPlk^f#YO z9CmWs@|x{BZH4vd5hs^SOf>Qr3BC*-rSjR?l`2Xv^?G$>r8<|YL4FGhGo|TC#*wx8 zBGVX21Owlxh%o-fkz0p?UzX+hhW$nY`IXDdlphFItLxQQt>-Ae3kbv&>u?<;;rt*! z=x;RhFSaTP{33{x`?qp!#kJV+3iLNou{;}O*B2#ISnuqj$Pd;F0iH`Cj8s=HT)43EV~b%J zy^;K+@_*xb@o>nBb<($k8q#3>OBlE{PWxJR!z2B5rFQW(Xts(Z3 z-^$|3PY^q3y#-ss2l5x_Z>s>&rJm#E;mVa=lP&-87FfZRw@P|{?~#gEe^KTu!2>aa z`06g+a)`aa7#Q+}8H8cGkVQpn43&g!0&GixUySb0Wt+A@08vqVG2U@tA`JGc_}%64 zGfgCa;{BNVL4Ja-o`&_hSgqDyh4XXQmmxn2Pyr;w%o9z281Oq8??_FYd#Ax~P5Zxx z7tOBYu;17LC)dlfK;I38D|9`|D)n>OeRJn9IhM;j(7l}g7PA=0&(6XFN&+MJGMOd_ z;CHO2khnVFhN7f_G( z*kv;LOn(C)hP5So=mf){zay30{#e{A0Mh-9O7gm~Nc0!u5%O#O{)Z6*zX#2@N?_D=OIRn& zSA|};o_@~5S5Ke75;`G^<#K7>S%o*uW=41&(`&u~i}E74t`Z7<2)%I(^us#_^2Hyv zY)PI2^L+_D57k77?8`Y04S2DNx;}bu4Sv1>#}R&eO$g0vx~J?t;fd3D8Mm{>%ir7lg@=br69|)2p>J1DO#3WDsFf28{4~F5aVpaKq2G z>XJ%bq6on09}N43A)us{J2F!&77Ej= zYt|?MW=5rmC4FEC91lfMzCscc27Z#dAb?boNM8m~JfQni{Bq1#*xr^dFtQiK54grn zYl4@7VZn0)dD2t%o9_oNIz9vrrNY+dXLO_n}G$f&AXG zyf8xjts^(QY_WQpEzDM5vLHZFAUbk%fb4xFqo&kgLcvdJ2WA{H#Bfp!Z3)6}Lw>n$ zi5~Gr{ZXBBDcq}{9e>6bpyV+5yzq05#Uo)!UksxS0mO=!w>n#t!S?&7b(-dhN&2UG|x7o#_j z0g~Ui(jPJuKjdzapY(v&F$|%G@*hVK6{f0}Q3oWzF{t;m%>H_eHjF@k6^EjkarS+I zaWIDvis}{g2l@Fa%bUD-*=W)OS;5715ulCzmuf%2om~WoqyI25krVef{k?c+DDc77 z(D!|iADH{f(_j5^kTD1KXJIG_495|H@ur1N$T$r6|5-ASBZC_czj0s!?$78#@1to% zdTWDJ#Zwc*cEJz&L;P@G@#}uu!?#pwYMw`B!>lO>|7!T z_va;nVStBo?0^Hr)i)IHNuV%=LHCz@r}w5`IPg3m>!<7MD;Jh8T%Z8IRGyhB&*DnR zVR%5a>|}!G%RX>8dLNXCnULWxW*7Cxs~@YiAm(oMeyV=83iDk&JG)2$F5p2?%T>f; zbuHbt6LGpfWY72rON%F_ZIoa-?i_;$D@?6agC57$+z&%ISU*7ea$y;5)pc`UU74Mo zg%Z=_BEW3nH{!kG{^E@rN?INx9UwBmXdf~VROTOZj+xf-|8y#N7*q=%zX=j zL~rhGt5Bo^EIf){FWldm@VGxZKxBXqndZPK;zy~xI`@btx7=xO!TUhxjon}PzYBOH zzc&YI(O8(1(L~wo6H&vwUHZVGksnT2E}us^7{f;SbojjD6}Um4qTplqSDK8GNuQQW zO72_M3_YOz4NRzm&M%U{5H()?NO$kTlm^-H(&B&j3kE?2%jbveh4oVbxVlQ&(Zn&n z9QB&qI1M;^5*2*bPDAAW@R05VYJj~RoDu@%1F>2T)(r;!dHi6$Vy&yIE2M|v<@h3f z9;!rL@XZuvMabm;6#T-Ky}-`s0Q1Qh`IV-AN^Dfr+)B8MX`z=f{de9^rV>f(^*eKxC8)QfQy=~!Q9T#3X z3g%OrD*Ohr*S;C<8tKe%a!HTfa~)pLH08iHu>^^L*=TD{}w219=KS zAQZ#B%z6Ws>gjAY8@kSiN;DwAfw9qXjB>`^l`{)JhEF5DrUu(x#5`XOi^5+WzyQf>DB4qe3-b%}^D`_u3qUW5NTC5N zH!V9mi0B(W^FS2^{;0_PFKx1|yYE+a-u5TOS| z1VQH*pV@rsq!qg8OA|JG_l#w7k5GPv5~6T*os&gKoo}5*W~vX9*a<$|;(!K#aE;;t z89~@y8O*0b7=49b^aG<=>p92|w@+K=YwHdton)w3odj4;^bhxjwA*R2p#AU?`NHP2gX}OQyPQ~^U8-e)b}*| z#<-_2gDKusL<-xxxjU2oa(%f}951B*wY#>k;7p&zn@oKQdXBh0%o-t$2ra*%PQ!rbPOy8jT0a(s zo3^elinjET`f?Fta)(b~nncy+h1~SC1YQweK96Ci_W1ZXcAx=!9&mF|^2OR*Slu5o zz=uy)=P{>M-m1Zj5oSGvUe*Gm<&nqDEwM*gU7q_bGGZ+(| zJ5pW4X;;!VZsJQW_x6b6>q*FHPpVqJC$I-KETbv)s=F2Y3*cK<8Md&TQFN(g0$-EGxTv@ z13Cqd#)|?oX1?d$zA#^AFanUJ1UJ37Ql6Q`)EnJb`QwCOQ!Ku;HiIh|e|AJ+>%=m@EbB0+Bd}pG;NS{|quQalZ)O`o&H;m`qGU1;AbQ9hm5dT-0LPR?1r9vG zXLyMEWA+F4Cyo3t9zQ)>E=_Xkx-gcncmo`#7SAC1F61*r1Sb~|RP?ZUWO!s?h}Vf} zyek|=xx6wvyIjU#z?Z(ZTsnhU>%y7A;5M!b!b4{GTkFr06E21bKtl8y#0PwReSL}_ zEmr_8FGGqn;DypjOkEs?X-l>lFUo(ojS!Qu(|rGSQeuRJ*(QX__4N%6!G2-BOkGf+ zo-Hpg&jMe0wpJf5m!7yC(+-8vfH9ARlN%Vxqz4f_sJ=eFac)@r%Sj?+6;CgFps()` z$0?wEx{jf!vjkW!&y;3s?hn2>(~rSdp_q4Ly8w9?;jueMGJg#71uNL7-$pURu38=* z8Xg+zJ2cei@#9c(BrrfYgJfnE7t&`sJFIZb`*H<8xWD8F`Z5nJtxb;5MnQ1EM<|~I z0|UVK@WY1=_4SQr3((&xDlW_bDZf(bKiBHk^BjB{Mh9qi!TmiH8%YnY{`6^vh(lyJ zFaU-KxOfc@3p~(68yZFY<<%wh*kHcP!VdJl3zCLScX!wB#9`NAdgZxpit8X*)Lk5^@{fT!QrpqOU58T2U zi~q&i#z`Z>m_ajqU;^V< zV(F)o$X*1QdRO$w?*9Al6@ap3gc(d3Pe8&AuV_WiTDh_^&D2ja=+3QwpH^S%VD=ng zAGk6$G9fOz2pR$OG~ zL$UL8cnBuz0|Z9mLkAe~0`8CXLX=qZlbE$~cJ?Ld`Aol5PmRU)j$#(5PT(VDWTpf1uo3v1b)jsD)nOkY5gZJG`n;Yldt9W8&F|B3G0;r zJOX?pFy=!;6rfTdMM!+3m^^k0VT0x?1ThcR?8<+WzHcw55IYyH5}+AF_~_&nkX+Aw zeK24);uC;}4&4ucN`f?BluzZVI-bA1AE2T>Nr<$5sp!z@HAE69KF%qR)K^O#R2M2*kd zc?b`$U=p+Ikgq+74Zuhr*kr#jUxwU#UOj&XJMgwIm@m?BPP^7^-j1o;Lo#`o5(yr{ zn#UZxe2i$sfB~aXRnl0DZU_+W58v^N?6^EXkELl`&BUC&&k8?e(B`cu0Y*b4KVv_- zti2LGFl);V2oTg%21BeS0ZREm6@Tx&_Yg`l7{7r52;<`gT-D^RqZv#(vCON!xOwZO z^x(qq=+K5jqTttUV%8ueF@_0+;R*+w+BnLh@PPpM07EbvOj*PUyv5=qhABXuNT#P| z*Z-P7hX9i6;-gb?t^eq}20lDQ6jR6|iE+{#`}6l`y`!kFu#I~HR1t*X_W@_VOry4-bvPL(33G=EBqg!9yIK;ZD{N@@jlXl;Hjp4xDWc{_%u~n&I8iWAyi-3djmZ- zxWEiY0|FkyG0gW##Sg#nP5V{tPxwT=Uu@+M^FvNCsh*_lo#qXFqa_UQ6MmC1lo z3K%hg0l(u8=3xs>GY?FkOGX)lgOlDp0$C}34gC?I@MBSMXoxx#`KjDba7pNZ|C|4I z@Kddi5&A2FAFD6H$^HtGI^kCe{NEk-!hZb}5H$tZFT5WHV)X|{u>v!nr2U3Uf1jlN zei9IyK)`?%zsWoTh4{ZF`-S#cbL`oJaWe#jL#&_jd%d<8OiO#NUhK0fy? zhYN6(EmGdLPs^>|T5!@Ffwk?VKLCKNQ6biPbMSQ9L`R)(q>*HhWEj{18orU7(oZJ3W+xKg!^|mY?Kiw!F zG|ugI-g3lD+0$Q>`=j+1Kik;VTZ%pA%;73XzB@$vGjRQ*n7oSqP|KIAZwS8vuz^o9 z=i=wDz$aHgkpAVugwHV1>%TfbKbI{58yISG*_scUgTt z1b|-XK-CJ5dP{c1lgW5=I~DLdhn~##U)sJ~i><@zPEI(J+n#w6?TA}evL_Pt%l0Bg zUh&8bVVJ3vNn2OUHk8O-0KY3Dd5iJdemZ7qA~&(L)#@NVK2AQ(qD<5;+=C!O#~*YW zctAWy!C1-OEfPfiW$D}?uI6q3FSPi2!k#-`RhNI&nVRNpaVup{RCrqmHkn<%2tOxY z((H|=CY*{*2{sW#>7`mZT-+w)7Kew^iw)+ER@ZX=utzf*i&K1#Q#lrwC}DQQ<57b2 zS|k>ar!cJ@B^clDe-n)jE>&MS5;pUNyza!zvDHb;o)$#|o1~SoCx9=F`TSsvW-MV@ zLf4F72S7wRU7&ag|hFv(p2%TVJPzcIFOL(&Ux&2{FUPOeZd0+|p^O{Z5Rkn*HI$NOn z64YF@D@lOGoD~Nr#_3)V#P_OI>!G@G)G%KNa8Gu1ZN5^eOh`@wWg&5a!VnZ7FyK?2 zH4k8gd5cI85k_(yyHKe(OKa!CR5@+tXLP_2D@aD5yxy)Z(le3uF^N|AJhKEqMh%1- zBz}>IiGE6NFKAl~+79o-328&$3#ZSZ(bd%(jYJ~M=g7pFPs4bFUIv}s;B+H(HW5{N zdvTb>KS0wp_^@$|!B8t{>aT~{@NGzqV{Xup)ENMa2qVdOFZYchju4-d>u>BA zwk7ibv}Whnoj^kponj9TlET`Sm?~kHQP<9cAiw7B4AST=hmBg(`Qp)IiV1v~l|mK` zL_reWw4Wh*W9mF_+o)o($=&l5%vKgGCrI~~oe$j1 zh26PxKGgC5?S6nOf5_CD_Hj-30o}6X+Btn__g+exX{7 zNTmR+Qn=CvKkiREZ%JKDR|;i>a8(XQi6uXFe7_+`DTCZGvu0-As(pb2OKnt&#t31|YE zfF_^`XabsmCZGvu0-As(pb2OKnt&#t31|YEfF_^`XabsmCZGvu0-As(pb2OKnt&#t z31|YEfF_^`XabsmCZGvu0-As(pb2OKnt&#t31|YEfF_^`XabsmCZGvu0-As(pb2OK znt&#t31|YEfF_^`XabsmCZGvu0-As(pb2OKnt&#t31|YEfF_^`XabsmCZGvu0-As( hpb2OKnt&#t31|YEfF_^`XabsmCZGvu0xd(}{{y1&yfgp+ diff --git a/reactos/ntoskrnl/inbv/logo/6.bmp b/reactos/ntoskrnl/inbv/logo/6.bmp index a8cafc569c0188a2924198976b4028ab993bb3fc..08344117cb2503f2dacdf0fbffc236b265fdd9a6 100644 GIT binary patch literal 2896 zcmb`JKZqk$9LIn6kYN~yFcXGlStb`tOF{5YAvm&#U_wOB#!BS4N-aGWEGz`ERD>n4 zSP52wg;*O{gvErABR1Z=4VD&Jh-_hz-1GB$Gx@h3SKUH(=Dm5p@9+Qj_ulBf^Q`#4 zPx=2mzt4@x%RFz%Gs3I<8HqGGqrZf;{`9Z^qR0=gzAoPtcjT+y$MW;N*W{zSeR*(l zN8bDFSNY@XPvq?{AIeML{woiE{6_x%{TKP?uLt6sllSk(r;Wb3Fc}`@X}Z_Kd`1WHXKRFc^mQ`loE`FR-%ys>1b%q zk_*1}FD?%I5})=@`X?uE-4}EQCkK5A&-BYMC=YFT`O}pI=#XTN4m+0@Z01p38FG$; z&-J6zH<5jmK1#nxpT_gI)U=Ijq!RSpK%!KlY~tTVFb1?R$SRGuS=RckcPxF|Jw@79-l*kP#1I*F zCjLZ^Cq7`ip6}YJMmWr@E!gdv66q+n7)xERqpByXcxbK)l}Or-Gi>tS96PtbI3h+I zW@cI8g9L6_Xoj&~wGt_?LOW3SUG$Ar*W|aMXyB`!Cb6kkile)Mw_d$$*?}~PJeAKX zW2NX_0=0|2j!}-RR!?u4rsJjRnJM&msk=mOvOxy1q`HVXhGw?-KdNf4D})+8@)jv# zPZ5cD?swK!9iVlDRk_tzx5{1n6scY1q-U-Vy(I&+sL=u|Bad6GmMuiFx;9N)kHsST zTK!|QP^8-9Mh23;uaU^})N2B-sTP5^jhMHZT!J%G9PLt~5dqS2a=Z47Tu$(tntwb( znYQ}s?wBa+@Q4=1MvuXg-}wNF&%WXsuTKsLV;c5VVt>w z6lh+z*{D!j6^hU2v9%@MZ+e4zp$@Low71ku#XwLJijw0(RUP{%WUUk2U?R0|OibEN zF*G_(d9*=}e6{jk*Z)42G6GoSVQUds$Q9I+uhMvoapRSuRo%4m-Bk7Iew2u&q8-ys z8~+pyFR((nLlTV*W)5~cf1s=~HY=>yL|qc?B4Q5nZqd{V1sGS{k-$|PsyM3W^o#N& z*mTB1dD)+)!Kox^C~qiFfwHl0jhNT`s!#3MHNWN?eywL%Fhh66fA~ut6j^(}i>KDny9_8ouuh#N=A3AtuReqPpzI#t<`2~=^RYk9-~_d z4A8)LKqgvS8x$f+HR#-`rYIAVxw$t(=_{i+Av9DRXcxl3$_O`cly%7WcCtr)vU@(* zo$8)*>;!g$5twm`rL3zy?pmf?^g+%4HA^#F2FlzpiIxrSY?WaE6 zK@4`Loz@53E0q+O0YglyGw4)P>)3wr$rO0o4JfR9I3H0tw zebx;$`YW%qBkAh=)n4}^C*3nD$={u S@K`x6>)84(^;B+nxBdeb`j(J_wQ+rHG&j*&-|`8PZZjo1D@@q0l7fKiJ}T?lhCMg1&4^X6~GO&v(D` z>z@0{QpYFrw~FUw{MKxu7xA{pAq?r-**u06o&9vY{PMH()@#qxyVqZ$8`s~Y58r;3 zRzJ8wAKzJ_wU2JnXP>-JUwpnw-+l8XZT<2+?L7LCP9Hy3RXWB0r%&{~MdZjqK;$|y zB)t8*`!c#iIig%KmhmQ0C@K%;x+1?v7&)O}HhBG4?tdF$h5W7T~oXRr~G-SXI8!#=Qeiq@72(Clg`b`AO& zka9bCKsE>2Xo6(dBcqKS*zV7wU;4?=lOv5x&XN;+sSI=ZjEHVgl^W)v z5_o6`G2<@rmPRRWb-4^-mdk2iX@I#DU0K-)E7(%j_2HsKWCA*J~gPc|5jC54KJf0#4+@w5Ytv+OR z;|tg3jejAxrDl-jpn$!Vv+}hSHI%4mA_+Fm{lPpW0T8I$Q~x>KOj$-qTD5Ns38GUY zU^$JU=DP;2I$8iGOvW1CQ5=VRMEDt;&IO#T94bx#E{YQ$DNYsI@llF%iEBDn{~I;} z>;ghVYLGZtQT}qM`is!tKTP$r9I1Y3fH_2=H}#9AB1{ovg&h`AF9d-iD1SKsLTD_x z(kGz18IJUvaxZabicwSyL}plq$szp*%KD!M#p5-Da)nJalGq!R2J&+Be<<~BgJMBD zBvTRP)FU3aSU5KVP(nmui64&O3S(31mBgl2k6<4ni@0b#X+F;8VGiYv91Bo0ic>wI z_}JhqYjloN-@u;+rw4uCt}`lf7761BHC-cLI*Jn?Aw>*M3>=d!37-@P*7#3%8Px)2 zDI<)-K+QvSX#QImPcm2|sP;l$nAC-)9C*zGmZ-?ggUUHP_%1-fQan<$00aZ+%~n}Y z(I)k)g#ffX0uPrl@0FpSa>F=;QQ&i15kk#h3%vs431g0Xx62nGR!v#$A6ZEY1Ss(MUgS(9fWSAjOk5q%=aT9eN*7xv@ z%DjlOJi^}7-m3l7JAwDLH=^GTy#$4LS5GNhPvtD@DKu-J(>{hpfu$|~f#&a1rsKo6 zzIOXZ8e_wk+!b)pQ`nrFK!To=Wjs?n#LLyZy_xD{kWi}A9bj1|(J7s)MAgY6TB(j_ zbqAX1xdqcle6FaEot3@WoiKJ$b#%+@q+cceO}XZsq_f%FQLXOotQI6*K9<8&3w!Yo zSm9YM-oZQSYKQT;GttV49VM&5v+zuE11L;x043feXjUexBe9$B7)H43tm7845g?|x zh3rAwcnNWJ`nTURYjDr`I=%5chZ_%8>#9>)Mno>-ZuN5+zVohi`}bg(nR$XYKkFaF CApZ9N diff --git a/reactos/ntoskrnl/inbv/logo/7.bmp b/reactos/ntoskrnl/inbv/logo/7.bmp index d137807c9f9e4cb7aabc26f1bae1810406603e16..24ea213775819825d84abff14a57b3a683af51d3 100644 GIT binary patch literal 1078 zcmb`GuTR5J5XX-ne+f0{tyzK~0s8U`A(-(Wyu4HZatR3nRmvO$GlPY+!4X7j=5b3< zQ%EcdH@SCyD zW4RlP)_$X%Kn`=XW9?kO9SR2KHSTeFxe0;IL#Rn0EKXUTXl!&38Jre2qSFHA!95B8 zcd#gmvgD8>)E3S!#rPU2Ny5WLND+A0HPQ%nLeLgQ*d2oav@>nj^f?Fu{VH-@u+HVC z}#P8pJY6Tv$Eqc+G zN6?cfO5%tm(9<|h(qx=!xt?kHVS%%?z)4nQd6A`go~3D?4N@@re9B`OQ5;cO zG=N9ihHZI>@p`?c>PZ7BVSzSdzV5+rU1#bzj^%(^%*4=`OeV%?H0r1v8>5M75Ek3A zEF0Xx`P6ki*YjpG&-aOoBD0v!7mCYr4Hm-KY{Km}+D04tHl8LiRiS#)(IG;53Z7+D zHdqE;C=v9)VkZ`R?m7+B#ktDU#%sk}` zSFzA7@``B_wLZB=xd?o;kGToHXT}`nau3|6?LK(G<`^nk>vgzdp|)k4!w7wKQhJO& zRfBPgUY7D4y&^LT@KOj-Vq8IQI)O(Lyc3Oat0IaqZlHJaC9UIRIw3%N`(zLBT+1kD vmwS+C@ez4;FOyu+TdmjR-P7i #include "internal/probe.h" +#include "resource.h" // // Define the internal versions of external and public global data diff --git a/reactos/ntoskrnl/include/resource.h b/reactos/ntoskrnl/include/resource.h new file mode 100644 index 00000000000..b9bdd541a11 --- /dev/null +++ b/reactos/ntoskrnl/include/resource.h @@ -0,0 +1,23 @@ +#pragma once + +#define IDB_BOOT_LOGO 1 +#define IDB_HIBERNATE_LOGO 2 +#define IDB_SHUTDOWN_LOGO 3 +#define IDB_LOGO 5 +#define IDB_LOGO_HEADER 6 +#define IDB_LOGO_BAND 7 + +#define IDB_BAR_SERVER 4 +#define IDB_BAR_PRO 8 +#define IDB_BAR_HOME 9 + +#define IDB_PROF_TEXT 10 +#define IDB_HOME_TEXT 11 +#define IDB_EMBEDDED_TEXT 12 +#define IDB_MCE_TEXT 18 + +#define IDB_SERVER_LOGO 13 +#define IDB_SERVER_HEADER 14 +#define IDB_SERVER_BAND 15 +#define IDB_STORAGE_SERVER 16 +#define IDB_CLUSTER_SERVER 17 diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index 4dc022fb93f..c9925d5eb28 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -789,6 +789,7 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) * Display 'Loading XXX...' message */ IopDisplayLoadingMessage(ModuleName->Buffer, TRUE); + InbvIndicateProgress(); /* * Generate filename without path (not needed by freeldr) diff --git a/reactos/ntoskrnl/io/iomgr/drvrlist.c b/reactos/ntoskrnl/io/iomgr/drvrlist.c index 07068452fb0..42b69c6e2bd 100644 --- a/reactos/ntoskrnl/io/iomgr/drvrlist.c +++ b/reactos/ntoskrnl/io/iomgr/drvrlist.c @@ -507,6 +507,7 @@ IopInitializeSystemDrivers(VOID) { DPRINT(" Path: %wZ\n", &CurrentService->RegistryPath); Status = IopLoadDriver(CurrentService); + InbvIndicateProgress(); } } } @@ -538,7 +539,9 @@ IopInitializeSystemDrivers(VOID) { DPRINT(" Path: %wZ\n", &CurrentService->RegistryPath); Status = IopLoadDriver(CurrentService); + InbvIndicateProgress(); } + } } } diff --git a/reactos/ntoskrnl/ntoskrnl.rc b/reactos/ntoskrnl/ntoskrnl.rc index 4ede1c557de..090bff5e44d 100644 --- a/reactos/ntoskrnl/ntoskrnl.rc +++ b/reactos/ntoskrnl/ntoskrnl.rc @@ -23,21 +23,20 @@ #endif #define VER_LANGNEUTRAL #include "common.ver" +#include "resource.h" // // Bug Codes and Bitmaps // #include "bugcodes.rc" -1 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/1.bmp" -2 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/2.bmp" -3 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/3.bmp" -4 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/4.bmp" -5 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/5.bmp" -6 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/6.bmp" -7 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/7.bmp" -8 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/8.bmp" -13 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/13.bmp" -14 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/14.bmp" -15 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/15.bmp" -16 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/16.bmp" -17 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/17.bmp" +IDB_BOOT_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/1.bmp" +IDB_HIBERNATE_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/2.bmp" +IDB_SHUTDOWN_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/3.bmp" +IDB_BAR_SERVER BITMAP DISCARDABLE "ntoskrnl/inbv/logo/4.bmp" +IDB_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/5.bmp" +IDB_LOGO_HEADER BITMAP DISCARDABLE "ntoskrnl/inbv/logo/6.bmp" +IDB_LOGO_BAND BITMAP DISCARDABLE "ntoskrnl/inbv/logo/7.bmp" +IDB_BAR_PRO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/8.bmp" +IDB_SERVER_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/5.bmp" +IDB_SERVER_HEADER BITMAP DISCARDABLE "ntoskrnl/inbv/logo/14.bmp" +IDB_SERVER_BAND BITMAP DISCARDABLE "ntoskrnl/inbv/logo/15.bmp" From 97f9d48ec35e788424c71078294e4fee53976c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 4 Mar 2010 06:32:13 +0000 Subject: [PATCH 072/211] Revert part of r45817 to try to fix build svn path=/trunk/; revision=45823 --- .../boot/freeldr/freeldr/arch/i386/pcrtc.c | 62 +++++++++++++++---- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c b/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c index a03cc2a5575..1141753aa92 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c @@ -19,25 +19,63 @@ #include -BOOLEAN -NTAPI -HalQueryRealTimeClock(OUT PTIME_FIELDS Time); +#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f)) TIMEINFO* PcGetTime(VOID) { static TIMEINFO TimeInfo; - TIME_FIELDS Time; + REGS Regs; - if (!HalQueryRealTimeClock(&Time)) - return NULL; + /* Some BIOSes, such as the 1998/07/25 system ROM + * in the Compaq Deskpro EP/SB, leave CF unchanged + * if successful, so CF should be cleared before + * calling this function. */ + __writeeflags(__readeflags() & ~EFLAGS_CF); - TimeInfo.Year = Time.Year; - TimeInfo.Month = Time.Month; - TimeInfo.Day = Time.Day; - TimeInfo.Hour = Time.Hour; - TimeInfo.Minute = Time.Minute; - TimeInfo.Second = Time.Second; + /* Int 1Ah AH=04h + * TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS) + * + * AH = 04h + * CF clear to avoid bug + * Return: + * CF clear if successful + * CH = century (BCD) + * CL = year (BCD) + * DH = month (BCD) + * DL = day (BCD) + * CF set on error + */ + Regs.b.ah = 0x04; + Int386(0x1A, &Regs, &Regs); + + TimeInfo.Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl); + TimeInfo.Month = BCD_INT(Regs.b.dh); + TimeInfo.Day = BCD_INT(Regs.b.dl); + + /* Some BIOSes leave CF unchanged if successful, + * so CF should be cleared before calling this function. */ + __writeeflags(__readeflags() & ~EFLAGS_CF); + + /* Int 1Ah AH=02h + * TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS) + * + * AH = 02h + * CF clear to avoid bug + * Return: + * CF clear if successful + * CH = hour (BCD) + * CL = minutes (BCD) + * DH = seconds (BCD) + * DL = daylight savings flag (00h standard time, 01h daylight time) + * CF set on error (i.e. clock not running or in middle of update) + */ + Regs.b.ah = 0x02; + Int386(0x1A, &Regs, &Regs); + + TimeInfo.Hour = BCD_INT(Regs.b.ch); + TimeInfo.Minute = BCD_INT(Regs.b.cl); + TimeInfo.Second = BCD_INT(Regs.b.dh); return &TimeInfo; } From 666d517053a06d8334857c532c6d917e44c17363 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 12:21:55 +0000 Subject: [PATCH 073/211] [PDH] sync pdh to wine 1.1.39 svn path=/trunk/; revision=45824 --- reactos/dll/win32/pdh/pdh.spec | 8 +++---- reactos/dll/win32/pdh/pdh_main.c | 40 ++++++++++++++++++++++++++++++++ reactos/include/psdk/pdh.h | 10 ++++++++ 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/pdh/pdh.spec b/reactos/dll/win32/pdh/pdh.spec index 135692f8c67..b475d5392c6 100644 --- a/reactos/dll/win32/pdh/pdh.spec +++ b/reactos/dll/win32/pdh/pdh.spec @@ -38,10 +38,10 @@ @ stub PdhEnumObjectsW @ stub PdhExpandCounterPathA @ stub PdhExpandCounterPathW -@ stub PdhExpandWildCardPathA +@ stdcall PdhExpandWildCardPathA(str str ptr ptr long) @ stub PdhExpandWildCardPathHA @ stub PdhExpandWildCardPathHW -@ stub PdhExpandWildCardPathW +@ stdcall PdhExpandWildCardPathW(wstr wstr ptr ptr long) @ stub PdhFormatFromRawValue @ stdcall PdhGetCounterInfoA(ptr long ptr ptr) @ stdcall PdhGetCounterInfoW(ptr long ptr ptr) @@ -57,7 +57,7 @@ @ stub PdhGetDefaultPerfObjectHA @ stub PdhGetDefaultPerfObjectHW @ stub PdhGetDefaultPerfObjectW -@ stub PdhGetDllVersion +@ stdcall PdhGetDllVersion(ptr) @ stub PdhGetFormattedCounterArrayA @ stub PdhGetFormattedCounterArrayW @ stdcall PdhGetFormattedCounterValue(ptr long ptr ptr) @@ -127,7 +127,7 @@ @ stub PdhSelectDataSourceA @ stub PdhSelectDataSourceW @ stdcall PdhSetCounterScaleFactor(ptr long) -@ stub PdhSetDefaultRealTimeDataSource +@ stdcall PdhSetDefaultRealTimeDataSource(long) @ stub PdhSetLogSetRunID @ stub PdhSetQueryTimeRange @ stub PdhTranslate009CounterA diff --git a/reactos/dll/win32/pdh/pdh_main.c b/reactos/dll/win32/pdh/pdh_main.c index 9ca174b957e..bdf83a94792 100644 --- a/reactos/dll/win32/pdh/pdh_main.c +++ b/reactos/dll/win32/pdh/pdh_main.c @@ -599,6 +599,24 @@ PDH_STATUS WINAPI PdhCollectQueryDataWithTime( PDH_HQUERY handle, LONGLONG *time return ERROR_SUCCESS; } +/*********************************************************************** + * PdhExpandWildCardPathA (PDH.@) + */ +PDH_STATUS WINAPI PdhExpandWildCardPathA( LPCSTR szDataSource, LPCSTR szWildCardPath, LPSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags ) +{ + FIXME("%s, %s, %p, %p, 0x%x: stub\n", debugstr_a(szDataSource), debugstr_a(szWildCardPath), mszExpandedPathList, pcchPathListLength, dwFlags); + return PDH_NOT_IMPLEMENTED; +} + +/*********************************************************************** + * PdhExpandWildCardPathW (PDH.@) + */ +PDH_STATUS WINAPI PdhExpandWildCardPathW( LPCWSTR szDataSource, LPCWSTR szWildCardPath, LPWSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags ) +{ + FIXME("%s, %s, %p, %p, 0x%x: stub\n", debugstr_w(szDataSource), debugstr_w(szWildCardPath), mszExpandedPathList, pcchPathListLength, dwFlags); + return PDH_NOT_IMPLEMENTED; +} + /*********************************************************************** * PdhGetCounterInfoA (PDH.@) */ @@ -707,6 +725,19 @@ PDH_STATUS WINAPI PdhGetCounterTimeBase( PDH_HCOUNTER handle, LONGLONG *base ) return ERROR_SUCCESS; } +/*********************************************************************** + * PdhGetDllVersion (PDH.@) + */ +PDH_STATUS WINAPI PdhGetDllVersion( LPDWORD version ) +{ + if (!version) + return PDH_INVALID_ARGUMENT; + + *version = PDH_VERSION; + + return ERROR_SUCCESS; +} + /*********************************************************************** * PdhGetFormattedCounterValue (PDH.@) */ @@ -1193,3 +1224,12 @@ PDH_STATUS WINAPI PdhEnumObjectItemsW(LPCWSTR szDataSource, LPCWSTR szMachineNam return PDH_NOT_IMPLEMENTED; } + +/*********************************************************************** + * PdhSetDefaultRealTimeDataSource (PDH.@) + */ +PDH_STATUS WINAPI PdhSetDefaultRealTimeDataSource( DWORD source ) +{ + FIXME("%u\n", source); + return ERROR_SUCCESS; +} diff --git a/reactos/include/psdk/pdh.h b/reactos/include/psdk/pdh.h index d79241bf92e..7f3d3340b21 100644 --- a/reactos/include/psdk/pdh.h +++ b/reactos/include/psdk/pdh.h @@ -37,6 +37,10 @@ typedef HANDLE PDH_HQUERY; typedef HANDLE PDH_HCOUNTER; typedef HANDLE PDH_HLOG; +#define PDH_CVERSION_WIN40 0x0400 +#define PDH_CVERSION_WIN50 0x0500 +#define PDH_VERSION 0x0503 + #define PDH_MAX_SCALE 7 #define PDH_MIN_SCALE (-7) @@ -49,6 +53,10 @@ typedef HANDLE PDH_HLOG; #define PDH_FMT_1000 0x00002000 #define PDH_FMT_NOCAP100 0x00008000 +#define DATA_SOURCE_REGISTRY 0x00000001 +#define DATA_SOURCE_LOGFILE 0x00000002 +#define DATA_SOURCE_WBEM 0x00000004 + typedef struct _PDH_FMT_COUNTERVALUE { DWORD CStatus; @@ -182,6 +190,7 @@ PDH_STATUS WINAPI PdhGetCounterInfoA(PDH_HCOUNTER, BOOLEAN, LPDWORD, PPDH_COUNTE PDH_STATUS WINAPI PdhGetCounterInfoW(PDH_HCOUNTER, BOOLEAN, LPDWORD, PPDH_COUNTER_INFO_W); #define PdhGetCounterInfo WINELIB_NAME_AW(PdhGetCounterInfo) PDH_STATUS WINAPI PdhGetCounterTimeBase(PDH_HCOUNTER, LONGLONG *); +PDH_STATUS WINAPI PdhGetDllVersion(LPDWORD); PDH_STATUS WINAPI PdhGetFormattedCounterValue(PDH_HCOUNTER, DWORD, LPDWORD, PPDH_FMT_COUNTERVALUE); PDH_STATUS WINAPI PdhGetRawCounterValue(PDH_HCOUNTER, LPDWORD, PPDH_RAW_COUNTER); PDH_STATUS WINAPI PdhLookupPerfIndexByNameA(LPCSTR, LPCSTR, LPDWORD); @@ -198,6 +207,7 @@ PDH_STATUS WINAPI PdhOpenQueryW(LPCWSTR, DWORD_PTR, PDH_HQUERY *); #define PdhOpenQuery WINELIB_NAME_AW(PdhOpenQuery) PDH_STATUS WINAPI PdhRemoveCounter(PDH_HCOUNTER); PDH_STATUS WINAPI PdhSetCounterScaleFactor(PDH_HCOUNTER, LONG); +PDH_STATUS WINAPI PdhSetDefaultRealTimeDataSource(DWORD); PDH_STATUS WINAPI PdhValidatePathA(LPCSTR); PDH_STATUS WINAPI PdhValidatePathW(LPCWSTR); #define PdhValidatePath WINELIB_NAME_AW(PdhValidatePath) From 4e6b09ae72dd4446a68b601496a6de4c35b28125 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 12:28:24 +0000 Subject: [PATCH 074/211] [NETAPI32] sync netapi32 to wine 1.1.39 svn path=/trunk/; revision=45825 --- reactos/dll/win32/netapi32/netapi32.c | 57 ++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/netapi32/netapi32.c b/reactos/dll/win32/netapi32/netapi32.c index 12218fc2e70..fb4468f6950 100644 --- a/reactos/dll/win32/netapi32/netapi32.c +++ b/reactos/dll/win32/netapi32/netapi32.c @@ -26,6 +26,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(netbios); static HMODULE NETAPI32_hModule; +BOOL NETAPI_IsLocalComputer(LMCSTR ServerName); + BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved); @@ -97,8 +99,59 @@ NET_API_STATUS WINAPI NetServerEnumEx( */ NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE* bufptr) { - FIXME("stub (%s, %d, %p)\n", debugstr_w(servername), level, bufptr); - return ERROR_ACCESS_DENIED; + NET_API_STATUS ret; + + TRACE("%s %d %p\n", debugstr_w( servername ), level, bufptr ); + if (servername) + { + if (!NETAPI_IsLocalComputer(servername)) + { + FIXME("remote computers not supported\n"); + return ERROR_INVALID_LEVEL; + } + } + if (!bufptr) return ERROR_INVALID_PARAMETER; + + switch (level) + { + case 100: + case 101: + { + DWORD computerNameLen, size; + WCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1]; + + computerNameLen = MAX_COMPUTERNAME_LENGTH + 1; + GetComputerNameW(computerName, &computerNameLen); + computerNameLen++; /* include NULL terminator */ + + size = sizeof(SERVER_INFO_101) + computerNameLen * sizeof(WCHAR); + ret = NetApiBufferAllocate(size, (LPVOID *)bufptr); + if (ret == NERR_Success) + { + /* INFO_100 structure is a subset of INFO_101 */ + PSERVER_INFO_101 info = (PSERVER_INFO_101)*bufptr; + OSVERSIONINFOW verInfo; + + info->sv101_platform_id = PLATFORM_ID_NT; + info->sv101_name = (LMSTR)(*bufptr + sizeof(SERVER_INFO_101)); + memcpy(info->sv101_name, computerName, + computerNameLen * sizeof(WCHAR)); + verInfo.dwOSVersionInfoSize = sizeof(verInfo); + GetVersionExW(&verInfo); + info->sv101_version_major = verInfo.dwMajorVersion; + info->sv101_version_minor = verInfo.dwMinorVersion; + /* Use generic type as no wine equivalent of DC / Server */ + info->sv101_type = SV_TYPE_NT; + info->sv101_comment = NULL; + } + break; + } + + default: + FIXME("level %d unimplemented\n", level); + ret = ERROR_INVALID_LEVEL; + } + return ret; } From d15639dbe3ba95036247eb837006e2268048772c Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 12:29:46 +0000 Subject: [PATCH 075/211] [MSCOREE] sync mscoree to wine 1.1.39 svn path=/trunk/; revision=45826 --- reactos/dll/win32/mscoree/mscoree.spec | 4 ++-- reactos/dll/win32/mscoree/mscoree_main.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/mscoree/mscoree.spec b/reactos/dll/win32/mscoree/mscoree.spec index 04b5e1cda9c..9365f189b51 100644 --- a/reactos/dll/win32/mscoree/mscoree.spec +++ b/reactos/dll/win32/mscoree/mscoree.spec @@ -31,8 +31,8 @@ @ stub CreateDebuggingInterfaceFromVersion @ stdcall -private DllCanUnloadNow() @ stdcall -private DllGetClassObject(ptr ptr ptr) -@ stub DllRegisterServer -@ stub DllUnregisterServer +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer() @ stub EEDllGetClassObjectFromClass @ stub EEDllRegisterServer @ stub EEDllUnregisterServer diff --git a/reactos/dll/win32/mscoree/mscoree_main.c b/reactos/dll/win32/mscoree/mscoree_main.c index 5b45adbe29a..dcdc91a5cc1 100644 --- a/reactos/dll/win32/mscoree/mscoree_main.c +++ b/reactos/dll/win32/mscoree/mscoree_main.c @@ -345,9 +345,20 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) return E_NOTIMPL; } +HRESULT WINAPI DllRegisterServer(void) +{ + FIXME("\n"); + return S_OK; +} + +HRESULT WINAPI DllUnregisterServer(void) +{ + FIXME("\n"); + return S_OK; +} + HRESULT WINAPI DllCanUnloadNow(VOID) { - FIXME("stub\n"); return S_OK; } From a3e5a3750d5c3faf0809b0d5e7869ab23c23741a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 12:35:02 +0000 Subject: [PATCH 076/211] [SHELL32] Fix length parameter for ZeroMemory Paul Vriens svn path=/trunk/; revision=45827 --- reactos/dll/win32/shell32/shfldr_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/shell32/shfldr_fs.c b/reactos/dll/win32/shell32/shfldr_fs.c index 381293d6cbf..da1391807b5 100644 --- a/reactos/dll/win32/shell32/shfldr_fs.c +++ b/reactos/dll/win32/shell32/shfldr_fs.c @@ -1578,7 +1578,7 @@ IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3 * iface, { IGenericSFImpl *This = impl_from_IPersistFolder3(iface); FIXME ("(%p)->(%p)\n", This, ppfti); - ZeroMemory (ppfti, sizeof (ppfti)); + ZeroMemory (ppfti, sizeof (*ppfti)); return E_NOTIMPL; } From a9dc9cbcfb2649810338077f5f5ff751bc165295 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 12:52:23 +0000 Subject: [PATCH 077/211] [BROWSEUI_WINETEST] sync browseui_winetest to wine 1.1.39 svn path=/trunk/; revision=45828 --- rostests/winetests/browseui/autocomplete.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rostests/winetests/browseui/autocomplete.c b/rostests/winetests/browseui/autocomplete.c index 85a7da5ebc7..89f864d1bf9 100644 --- a/rostests/winetests/browseui/autocomplete.c +++ b/rostests/winetests/browseui/autocomplete.c @@ -219,6 +219,7 @@ IACListVtbl TestACL_ACListVtbl = ole_ok(obj->lpVtbl->Next(obj, 1, &wstr, &i)); \ ok(i == 1, "Expected i == 1, got %d\n", i); \ ok(str[0] == wstr[0], "String mismatch\n"); \ + CoTaskMemFree(wstr); \ } #define expect_end(obj) \ @@ -280,9 +281,13 @@ static void test_ACLMulti(void) ole_ok(obj->lpVtbl->Next(obj, 15, wstrtab, &i)); ok(i == 1, "Expected i == 1, got %d\n", i); + CoTaskMemFree(wstrtab[0]); ole_ok(obj->lpVtbl->Next(obj, 15, wstrtab, &i)); + CoTaskMemFree(wstrtab[0]); ole_ok(obj->lpVtbl->Next(obj, 15, wstrtab, &i)); + CoTaskMemFree(wstrtab[0]); ole_ok(obj->lpVtbl->Next(obj, 15, wstrtab, &i)); + CoTaskMemFree(wstrtab[0]); ole_ok(acl->lpVtbl->Expand(acl, exp)); ok(acl1->expcount == 2, "expcount - expected 1, got %d\n", acl1->expcount); ok(acl2->expcount == 0 /* XP */ || acl2->expcount == 2 /* Vista */, @@ -316,6 +321,9 @@ static void test_ACLMulti(void) ok(mgr->lpVtbl->Release(mgr) == 0, "Unexpected references\n"); ok(acl1->ref == 1, "acl1 not released\n"); ok(acl2->ref == 1, "acl2 not released\n"); + + CoTaskMemFree(acl1); + CoTaskMemFree(acl2); } START_TEST(autocomplete) From d8bd52c1856dd478d6674db7be1cabf4d2ad493f Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 13:28:33 +0000 Subject: [PATCH 078/211] [MSVCRT_WINETEST] sync msvcrt_winetest to wine 1.1.39 svn path=/trunk/; revision=45829 --- rostests/winetests/msvcrt/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rostests/winetests/msvcrt/file.c b/rostests/winetests/msvcrt/file.c index 5afdfcbabec..3afc149ded0 100644 --- a/rostests/winetests/msvcrt/file.c +++ b/rostests/winetests/msvcrt/file.c @@ -893,7 +893,7 @@ static void test_file_write_read( void ) /* test _read in buffered mode. Last CR should be skipped but LF not pulled in */ tempfd = _open(tempf,_O_RDONLY|_O_TEXT); /* open in TEXT mode */ i = _read(tempfd,btext, strlen(mytext)); - ok(i == strlen(mytext)-1, "_read_i %d vs %d\n", i, strlen(mytext)); + ok(i == strlen(mytext)-1, "_read_i %d\n", i); _close(tempfd); ret =_chmod (tempf, _S_IREAD | _S_IWRITE); From efe0d1d2550ef1f1ae56a364d350417459cc5d9f Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 13:32:28 +0000 Subject: [PATCH 079/211] [GDIPLUS_WINETEST] sync gdiplus_winetest to wine 1.1.39 svn path=/trunk/; revision=45830 --- rostests/winetests/gdiplus/image.c | 549 +++++++++++++++++++++- rostests/winetests/gdiplus/stringformat.c | 15 +- 2 files changed, 555 insertions(+), 9 deletions(-) diff --git a/rostests/winetests/gdiplus/image.c b/rostests/winetests/gdiplus/image.c index 522e5de443a..e7747e35a45 100644 --- a/rostests/winetests/gdiplus/image.c +++ b/rostests/winetests/gdiplus/image.c @@ -30,6 +30,18 @@ #define expect(expected, got) ok((UINT)(got) == (UINT)(expected), "Expected %.8x, got %.8x\n", (UINT)(expected), (UINT)(got)) #define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got) +static BOOL color_match(ARGB c1, ARGB c2, BYTE max_diff) +{ + if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + c1 >>= 8; c2 >>= 8; + if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + c1 >>= 8; c2 >>= 8; + if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + c1 >>= 8; c2 >>= 8; + if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + return TRUE; +} + static void expect_guid(REFGUID expected, REFGUID got, int line, BOOL todo) { WCHAR bufferW[39]; @@ -64,7 +76,7 @@ static void test_bufferrawformat(void* buff, int size, REFGUID expected, int lin LPBYTE data; HRESULT hres; GpStatus stat; - GpBitmap *bmp; + GpImage *img; hglob = GlobalAlloc (0, size); data = GlobalLock (hglob); @@ -75,16 +87,16 @@ static void test_bufferrawformat(void* buff, int size, REFGUID expected, int lin ok_(__FILE__, line)(hres == S_OK, "Failed to create a stream\n"); if(hres != S_OK) return; - stat = GdipCreateBitmapFromStream(stream, &bmp); + stat = GdipLoadImageFromStream(stream, &img); ok_(__FILE__, line)(stat == Ok, "Failed to create a Bitmap\n"); if(stat != Ok){ IStream_Release(stream); return; } - expect_rawformat(expected, (GpImage*)bmp, line, todo); + expect_rawformat(expected, img, line, todo); - GdipDisposeImage((GpImage*)bmp); + GdipDisposeImage(img); IStream_Release(stream); } @@ -206,7 +218,13 @@ static void test_GdipImageGetFrameDimensionsCount(void) stat = GdipImageGetFrameDimensionsList((GpImage*)bm, &dimension, 1); expect(Ok, stat); - expect_guid(&FrameDimensionPage, &dimension, __LINE__, TRUE); + expect_guid(&FrameDimensionPage, &dimension, __LINE__, FALSE); + + stat = GdipImageGetFrameDimensionsList((GpImage*)bm, &dimension, 2); + expect(InvalidParameter, stat); + + stat = GdipImageGetFrameDimensionsList((GpImage*)bm, &dimension, 0); + expect(InvalidParameter, stat); count = 12345; stat = GdipImageGetFrameCount((GpImage*)bm, &dimension, &count); @@ -512,6 +530,7 @@ static void test_GdipCreateBitmapFromHBITMAP(void) GdipDisposeImage((GpImage*)gpbm); DeleteObject(hbm); + memset(buff, 0, sizeof(buff)); hbm = CreateBitmap(WIDTH2, HEIGHT2, 1, 1, &buff); stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm); expect(Ok, stat); @@ -774,12 +793,176 @@ static const unsigned char jpgimage[285] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01, 0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9 }; +/* 320x320 twip wmf */ +static const unsigned char wmfimage[180] = { +0xd7,0xcd,0xc6,0x9a,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x01,0x40,0x01,0xa0,0x05, +0x00,0x00,0x00,0x00,0xb1,0x52,0x01,0x00,0x09,0x00,0x00,0x03,0x4f,0x00,0x00,0x00, +0x0f,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0b,0x02,0x00,0x00, +0x00,0x00,0x05,0x00,0x00,0x00,0x0c,0x02,0x40,0x01,0x40,0x01,0x04,0x00,0x00,0x00, +0x02,0x01,0x01,0x00,0x04,0x00,0x00,0x00,0x04,0x01,0x0d,0x00,0x08,0x00,0x00,0x00, +0xfa,0x02,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x2d,0x01,0x00,0x00,0x07,0x00,0x00,0x00,0xfc,0x02,0x01,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x04,0x00,0x00,0x00,0x2d,0x01,0x01,0x00,0x07,0x00,0x00,0x00,0xfc,0x02, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x2d,0x01,0x02,0x00, +0x07,0x00,0x00,0x00,0x1b,0x04,0x40,0x01,0x40,0x01,0x00,0x00,0x00,0x00,0x04,0x00, +0x00,0x00,0xf0,0x01,0x00,0x00,0x04,0x00,0x00,0x00,0xf0,0x01,0x01,0x00,0x03,0x00, +0x00,0x00,0x00,0x00 +}; static void test_getrawformat(void) { test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG, __LINE__, FALSE); test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF, __LINE__, FALSE); test_bufferrawformat((void*)bmpimage, sizeof(bmpimage), &ImageFormatBMP, __LINE__, FALSE); test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, FALSE); + test_bufferrawformat((void*)wmfimage, sizeof(wmfimage), &ImageFormatWMF, __LINE__, FALSE); +} + +static void test_loadwmf(void) +{ + LPSTREAM stream; + HGLOBAL hglob; + LPBYTE data; + HRESULT hres; + GpStatus stat; + GpImage *img; + GpRectF bounds; + GpUnit unit; + REAL res = 12345.0; + + hglob = GlobalAlloc (0, sizeof(wmfimage)); + data = GlobalLock (hglob); + memcpy(data, wmfimage, sizeof(wmfimage)); + GlobalUnlock(hglob); data = NULL; + + hres = CreateStreamOnHGlobal(hglob, TRUE, &stream); + ok(hres == S_OK, "Failed to create a stream\n"); + if(hres != S_OK) return; + + stat = GdipLoadImageFromStream(stream, &img); + ok(stat == Ok, "Failed to create a Bitmap\n"); + if(stat != Ok){ + IStream_Release(stream); + return; + } + + IStream_Release(stream); + + stat = GdipGetImageBounds(img, &bounds, &unit); + expect(Ok, stat); + todo_wine expect(UnitPixel, unit); + expectf(0.0, bounds.X); + expectf(0.0, bounds.Y); + todo_wine expectf(320.0, bounds.Width); + todo_wine expectf(320.0, bounds.Height); + + stat = GdipGetImageHorizontalResolution(img, &res); + expect(Ok, stat); + todo_wine expectf(1440.0, res); + + stat = GdipGetImageVerticalResolution(img, &res); + expect(Ok, stat); + todo_wine expectf(1440.0, res); + + GdipDisposeImage(img); +} + +static void test_createfromwmf(void) +{ + HMETAFILE hwmf; + GpImage *img; + GpStatus stat; + GpRectF bounds; + GpUnit unit; + REAL res = 12345.0; + + hwmf = SetMetaFileBitsEx(sizeof(wmfimage)-sizeof(WmfPlaceableFileHeader), + wmfimage+sizeof(WmfPlaceableFileHeader)); + ok(hwmf != 0, "SetMetaFileBitsEx failed\n"); + + stat = GdipCreateMetafileFromWmf(hwmf, TRUE, + (WmfPlaceableFileHeader*)wmfimage, (GpMetafile**)&img); + expect(Ok, stat); + + stat = GdipGetImageBounds(img, &bounds, &unit); + expect(Ok, stat); + todo_wine expect(UnitPixel, unit); + expectf(0.0, bounds.X); + expectf(0.0, bounds.Y); + todo_wine expectf(320.0, bounds.Width); + todo_wine expectf(320.0, bounds.Height); + + stat = GdipGetImageHorizontalResolution(img, &res); + expect(Ok, stat); + expectf(1440.0, res); + + stat = GdipGetImageVerticalResolution(img, &res); + expect(Ok, stat); + expectf(1440.0, res); + + GdipDisposeImage(img); +} + +static void test_resolution(void) +{ + GpStatus stat; + GpBitmap *bitmap; + REAL res=-1.0; + HDC screendc; + int screenxres, screenyres; + + /* create Bitmap */ + stat = GdipCreateBitmapFromScan0(1, 1, 32, PixelFormat24bppRGB, NULL, &bitmap); + expect(Ok, stat); + + /* test invalid values */ + stat = GdipGetImageHorizontalResolution(NULL, &res); + expect(InvalidParameter, stat); + + stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, NULL); + expect(InvalidParameter, stat); + + stat = GdipGetImageVerticalResolution(NULL, &res); + expect(InvalidParameter, stat); + + stat = GdipGetImageVerticalResolution((GpImage*)bitmap, NULL); + expect(InvalidParameter, stat); + + stat = GdipBitmapSetResolution(NULL, 96.0, 96.0); + expect(InvalidParameter, stat); + + stat = GdipBitmapSetResolution(bitmap, 0.0, 0.0); + expect(InvalidParameter, stat); + + /* defaults to screen resolution */ + screendc = GetDC(0); + + screenxres = GetDeviceCaps(screendc, LOGPIXELSX); + screenyres = GetDeviceCaps(screendc, LOGPIXELSY); + + ReleaseDC(0, screendc); + + stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res); + expect(Ok, stat); + expectf((REAL)screenxres, res); + + stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res); + expect(Ok, stat); + expectf((REAL)screenyres, res); + + /* test changing the resolution */ + stat = GdipBitmapSetResolution(bitmap, screenxres*2.0, screenyres*3.0); + expect(Ok, stat); + + stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res); + expect(Ok, stat); + expectf(screenxres*2.0, res); + + stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res); + expect(Ok, stat); + expectf(screenyres*3.0, res); + + stat = GdipDisposeImage((GpImage*)bitmap); + expect(Ok, stat); } static void test_createhbitmap(void) @@ -963,6 +1146,7 @@ static void test_palette(void) INT size; BYTE buffer[1040]; ColorPalette *palette=(ColorPalette*)buffer; + ARGB color=0; /* test initial palette from non-indexed bitmap */ stat = GdipCreateBitmapFromScan0(2, 2, 8, PixelFormat32bppRGB, NULL, &bitmap); @@ -1008,6 +1192,22 @@ static void test_palette(void) expect(0xff000000, palette->Entries[0]); expect(0xffffffff, palette->Entries[1]); + /* test getting/setting pixels */ + stat = GdipBitmapGetPixel(bitmap, 0, 0, &color); + expect(Ok, stat); + expect(0xff000000, color); + + stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffffffff); + todo_wine ok((stat == Ok) || + broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat); + + if (stat == Ok) + { + stat = GdipBitmapGetPixel(bitmap, 0, 1, &color); + expect(Ok, stat); + expect(0xffffffff, color); + } + GdipDisposeImage((GpImage*)bitmap); /* test initial palette on 4-bit bitmap */ @@ -1025,6 +1225,22 @@ static void test_palette(void) check_halftone_palette(palette); + /* test getting/setting pixels */ + stat = GdipBitmapGetPixel(bitmap, 0, 0, &color); + expect(Ok, stat); + expect(0xff000000, color); + + stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffff00ff); + todo_wine ok((stat == Ok) || + broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat); + + if (stat == Ok) + { + stat = GdipBitmapGetPixel(bitmap, 0, 1, &color); + expect(Ok, stat); + expect(0xffff00ff, color); + } + GdipDisposeImage((GpImage*)bitmap); /* test initial palette on 8-bit bitmap */ @@ -1042,6 +1258,22 @@ static void test_palette(void) check_halftone_palette(palette); + /* test getting/setting pixels */ + stat = GdipBitmapGetPixel(bitmap, 0, 0, &color); + expect(Ok, stat); + expect(0xff000000, color); + + stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffcccccc); + todo_wine ok((stat == Ok) || + broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat); + + if (stat == Ok) + { + stat = GdipBitmapGetPixel(bitmap, 0, 1, &color); + expect(Ok, stat); + expect(0xffcccccc, color); + } + /* test setting/getting a different palette */ palette->Entries[1] = 0xffcccccc; @@ -1092,6 +1324,307 @@ static void test_palette(void) GdipDisposeImage((GpImage*)bitmap); } +static void test_colormatrix(void) +{ + GpStatus stat; + ColorMatrix colormatrix, graymatrix; + GpImageAttributes *imageattr; + const ColorMatrix identity = {{ + {1.0,0.0,0.0,0.0,0.0}, + {0.0,1.0,0.0,0.0,0.0}, + {0.0,0.0,1.0,0.0,0.0}, + {0.0,0.0,0.0,1.0,0.0}, + {0.0,0.0,0.0,0.0,1.0}}}; + const ColorMatrix double_red = {{ + {2.0,0.0,0.0,0.0,0.0}, + {0.0,1.0,0.0,0.0,0.0}, + {0.0,0.0,1.0,0.0,0.0}, + {0.0,0.0,0.0,1.0,0.0}, + {0.0,0.0,0.0,0.0,1.0}}}; + GpBitmap *bitmap1, *bitmap2; + GpGraphics *graphics; + ARGB color; + + colormatrix = identity; + graymatrix = identity; + + stat = GdipSetImageAttributesColorMatrix(NULL, ColorAdjustTypeDefault, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); + expect(InvalidParameter, stat); + + stat = GdipCreateImageAttributes(&imageattr); + expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault); + expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, NULL, NULL, ColorMatrixFlagsDefault); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); + expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, NULL, ColorMatrixFlagsSkipGrays); + expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, NULL, ColorMatrixFlagsAltGray); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsAltGray); + expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, &graymatrix, 3); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeCount, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeAny, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + FALSE, NULL, NULL, ColorMatrixFlagsDefault); + expect(Ok, stat); + + /* Drawing a bitmap transforms the colors */ + colormatrix = double_red; + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault); + expect(Ok, stat); + + stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1); + expect(Ok, stat); + + stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap2); + expect(Ok, stat); + + stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff40ffff); + expect(Ok, stat); + + stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics); + expect(Ok, stat); + + stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1, + UnitPixel, imageattr, NULL, NULL); + expect(Ok, stat); + + stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color); + expect(Ok, stat); + todo_wine expect(0xff80ffff, color); + + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap1); + GdipDisposeImage((GpImage*)bitmap2); + GdipDisposeImageAttributes(imageattr); +} + +static void test_gamma(void) +{ + GpStatus stat; + GpImageAttributes *imageattr; + GpBitmap *bitmap1, *bitmap2; + GpGraphics *graphics; + ARGB color; + + stat = GdipSetImageAttributesGamma(NULL, ColorAdjustTypeDefault, TRUE, 1.0); + expect(InvalidParameter, stat); + + stat = GdipCreateImageAttributes(&imageattr); + expect(Ok, stat); + + stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 1.0); + expect(Ok, stat); + + stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeAny, TRUE, 1.0); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, -1.0); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 0.0); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 0.5); + expect(Ok, stat); + + stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, FALSE, 0.0); + expect(Ok, stat); + + /* Drawing a bitmap transforms the colors */ + stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 3.0); + expect(Ok, stat); + + stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1); + expect(Ok, stat); + + stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap2); + expect(Ok, stat); + + stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff80ffff); + expect(Ok, stat); + + stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics); + expect(Ok, stat); + + stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1, + UnitPixel, imageattr, NULL, NULL); + expect(Ok, stat); + + stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color); + expect(Ok, stat); + todo_wine ok(color_match(0xff20ffff, color, 1), "Expected ff20ffff, got %.8x\n", color); + + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap1); + GdipDisposeImage((GpImage*)bitmap2); + GdipDisposeImageAttributes(imageattr); +} + +/* 1x1 pixel gif, 2 frames; first frame is white, second is black */ +static const unsigned char gifanimation[72] = { +0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00,0xa1,0x00,0x00,0x00,0x00,0x00, +0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xf9,0x04,0x00,0x0a,0x00,0xff, +0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x4c,0x01,0x00, +0x21,0xf9,0x04,0x01,0x0a,0x00,0x01,0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01, +0x00,0x00,0x02,0x02,0x44,0x01,0x00,0x3b +}; + +static void test_multiframegif(void) +{ + LPSTREAM stream; + HGLOBAL hglob; + LPBYTE data; + HRESULT hres; + GpStatus stat; + GpBitmap *bmp; + ARGB color; + UINT count; + GUID dimension; + + /* Test frame functions with an animated GIF */ + hglob = GlobalAlloc (0, sizeof(gifanimation)); + data = GlobalLock (hglob); + memcpy(data, gifanimation, sizeof(gifanimation)); + GlobalUnlock(hglob); + + hres = CreateStreamOnHGlobal(hglob, TRUE, &stream); + ok(hres == S_OK, "Failed to create a stream\n"); + if(hres != S_OK) return; + + stat = GdipCreateBitmapFromStream(stream, &bmp); + ok(stat == Ok, "Failed to create a Bitmap\n"); + if(stat != Ok){ + IStream_Release(stream); + return; + } + + /* Bitmap starts at frame 0 */ + color = 0xdeadbeef; + stat = GdipBitmapGetPixel(bmp, 0, 0, &color); + expect(Ok, stat); + expect(0xffffffff, color); + + /* Check that we get correct metadata */ + stat = GdipImageGetFrameDimensionsCount((GpImage*)bmp,&count); + expect(Ok, stat); + expect(1, count); + + stat = GdipImageGetFrameDimensionsList((GpImage*)bmp, &dimension, 1); + expect(Ok, stat); + expect_guid(&FrameDimensionTime, &dimension, __LINE__, FALSE); + + count = 12345; + stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count); + todo_wine expect(Ok, stat); + todo_wine expect(2, count); + + /* SelectActiveFrame overwrites our current data */ + stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 1); + expect(Ok, stat); + + color = 0xdeadbeef; + GdipBitmapGetPixel(bmp, 0, 0, &color); + expect(Ok, stat); + todo_wine expect(0xff000000, color); + + stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 0); + expect(Ok, stat); + + color = 0xdeadbeef; + GdipBitmapGetPixel(bmp, 0, 0, &color); + expect(Ok, stat); + expect(0xffffffff, color); + + /* Write over the image data */ + stat = GdipBitmapSetPixel(bmp, 0, 0, 0xff000000); + expect(Ok, stat); + + /* Switching to the same frame does not overwrite our changes */ + stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 0); + expect(Ok, stat); + + stat = GdipBitmapGetPixel(bmp, 0, 0, &color); + expect(Ok, stat); + expect(0xff000000, color); + + /* But switching to another frame and back does */ + stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 1); + expect(Ok, stat); + + stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 0); + expect(Ok, stat); + + stat = GdipBitmapGetPixel(bmp, 0, 0, &color); + expect(Ok, stat); + todo_wine expect(0xffffffff, color); + + GdipDisposeImage((GpImage*)bmp); + IStream_Release(stream); + + /* Test with a non-animated gif */ + hglob = GlobalAlloc (0, sizeof(gifimage)); + data = GlobalLock (hglob); + memcpy(data, gifimage, sizeof(gifimage)); + GlobalUnlock(hglob); + + hres = CreateStreamOnHGlobal(hglob, TRUE, &stream); + ok(hres == S_OK, "Failed to create a stream\n"); + if(hres != S_OK) return; + + stat = GdipCreateBitmapFromStream(stream, &bmp); + ok(stat == Ok, "Failed to create a Bitmap\n"); + if(stat != Ok){ + IStream_Release(stream); + return; + } + + /* Check metadata */ + stat = GdipImageGetFrameDimensionsCount((GpImage*)bmp,&count); + expect(Ok, stat); + expect(1, count); + + stat = GdipImageGetFrameDimensionsList((GpImage*)bmp, &dimension, 1); + expect(Ok, stat); + expect_guid(&FrameDimensionTime, &dimension, __LINE__, FALSE); + + count = 12345; + stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count); + todo_wine expect(Ok, stat); + todo_wine expect(1, count); + + GdipDisposeImage((GpImage*)bmp); + IStream_Release(stream); +} + START_TEST(image) { struct GdiplusStartupInput gdiplusStartupInput; @@ -1117,9 +1650,15 @@ START_TEST(image) test_testcontrol(); test_fromhicon(); test_getrawformat(); + test_loadwmf(); + test_createfromwmf(); + test_resolution(); test_createhbitmap(); test_getsetpixel(); test_palette(); + test_colormatrix(); + test_gamma(); + test_multiframegif(); GdiplusShutdown(gdiplusToken); } diff --git a/rostests/winetests/gdiplus/stringformat.c b/rostests/winetests/gdiplus/stringformat.c index b28dbc6d355..117e57bd243 100644 --- a/rostests/winetests/gdiplus/stringformat.c +++ b/rostests/winetests/gdiplus/stringformat.c @@ -29,7 +29,7 @@ static void test_constructor(void) { GpStringFormat *format; GpStatus stat; - INT n; + INT n, count; StringAlignment align, valign; StringTrimming trimming; StringDigitSubstitute digitsub; @@ -43,6 +43,7 @@ static void test_constructor(void) GdipGetStringFormatHotkeyPrefix(format, &n); GdipGetStringFormatTrimming(format, &trimming); GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub); + GdipGetStringFormatMeasurableCharacterRangeCount(format, &count); expect(HotkeyPrefixNone, n); expect(StringAlignmentNear, align); @@ -50,6 +51,7 @@ static void test_constructor(void) expect(StringTrimmingCharacter, trimming); expect(StringDigitSubstituteUser, digitsub); expect(LANG_NEUTRAL, digitlang); + expect(0, count); stat = GdipDeleteStringFormat(format); expect(Ok, stat); @@ -64,14 +66,19 @@ static void test_characterrange(void) stat = GdipCreateStringFormat(0, LANG_NEUTRAL, &format); expect(Ok, stat); -todo_wine -{ + stat = GdipSetStringFormatMeasurableCharacterRanges(NULL, 3, ranges); + expect(InvalidParameter, stat); + stat = GdipSetStringFormatMeasurableCharacterRanges(format, 0, ranges); + expect(Ok, stat); + stat = GdipSetStringFormatMeasurableCharacterRanges(format, 3, NULL); + expect(InvalidParameter, stat); + stat = GdipSetStringFormatMeasurableCharacterRanges(format, 3, ranges); expect(Ok, stat); stat = GdipGetStringFormatMeasurableCharacterRangeCount(format, &count); expect(Ok, stat); if (stat == Ok) expect(3, count); -} + stat= GdipDeleteStringFormat(format); expect(Ok, stat); } From 93656a009556ddcd937027e1876440915b65727b Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 13:34:05 +0000 Subject: [PATCH 080/211] [GDIPLUS] sync gdiplus to wine 1.1.39 svn path=/trunk/; revision=45831 --- reactos/dll/win32/gdiplus/brush.c | 282 ++++---- reactos/dll/win32/gdiplus/customlinecap.c | 30 + reactos/dll/win32/gdiplus/font.c | 11 + reactos/dll/win32/gdiplus/gdiplus.c | 9 +- reactos/dll/win32/gdiplus/gdiplus.spec | 4 +- reactos/dll/win32/gdiplus/gdiplus_private.h | 20 + reactos/dll/win32/gdiplus/graphics.c | 79 ++- reactos/dll/win32/gdiplus/graphicspath.c | 2 + reactos/dll/win32/gdiplus/image.c | 678 +++++++++++++++++--- reactos/dll/win32/gdiplus/imageattributes.c | 67 +- reactos/dll/win32/gdiplus/pen.c | 8 + reactos/dll/win32/gdiplus/stringformat.c | 47 +- 12 files changed, 980 insertions(+), 257 deletions(-) diff --git a/reactos/dll/win32/gdiplus/brush.c b/reactos/dll/win32/gdiplus/brush.c index bfce7d85bb5..2f2143dba58 100644 --- a/reactos/dll/win32/gdiplus/brush.c +++ b/reactos/dll/win32/gdiplus/brush.c @@ -87,13 +87,11 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone) break; } case BrushTypeHatchFill: - *clone = GdipAlloc(sizeof(GpHatch)); - if (!*clone) return OutOfMemory; + { + GpHatch *hatch = (GpHatch*)brush; - memcpy(*clone, brush, sizeof(GpHatch)); - - (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb); - break; + return GdipCreateHatchBrush(hatch->hatchstyle, hatch->forecol, hatch->backcol, (GpHatch**)clone); + } case BrushTypePathGradient:{ GpPathGradient *src, *dest; INT count; @@ -189,18 +187,29 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone) break; } case BrushTypeTextureFill: - *clone = GdipAlloc(sizeof(GpTexture)); - if(!*clone) return OutOfMemory; + { + GpStatus stat; + GpTexture *texture = (GpTexture*)brush; + GpTexture *new_texture; - memcpy(*clone, brush, sizeof(GpTexture)); + stat = GdipCreateTexture(texture->image, texture->wrap, &new_texture); - (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb); - break; + if (stat == Ok) + { + memcpy(new_texture->transform, texture->transform, sizeof(GpMatrix)); + *clone = (GpBrush*)new_texture; + } + else + *clone = NULL; + + return stat; + } default: ERR("not implemented for brush type %d\n", brush->bt); return NotImplemented; } + TRACE("<-- %p\n", *clone); return Ok; } @@ -317,6 +326,7 @@ GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, AR (*brush)->forecol = forecol; (*brush)->backcol = backcol; (*brush)->hatchstyle = hatchstyle; + TRACE("<-- %p\n", *brush); } else { @@ -336,8 +346,8 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint, { COLORREF col = ARGB2COLORREF(startcolor); - TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint, - startcolor, endcolor, wrap, line); + TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint), + debugstr_pointf(endpoint), startcolor, endcolor, wrap, line); if(!line || !startpoint || !endpoint || wrap == WrapModeClamp) return InvalidParameter; @@ -397,6 +407,8 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint, (*line)->pblendpos = NULL; (*line)->pblendcount = 0; + TRACE("<-- %p\n", *line); + return Ok; } @@ -491,20 +503,74 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect, /****************************************************************************** * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@] - * - * FIXME: angle value completely ignored. Don't know how to use it since native - * always set Brush rectangle to rect (independetly of this angle). - * Maybe it's used only on drawing. */ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect, ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap, GpLineGradient **line) { + GpStatus stat; + LinearGradientMode mode; + REAL width, height, exofs, eyofs; + REAL sin_angle, cos_angle, sin_cos_angle; + TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable, wrap, line); - return GdipCreateLineBrushFromRect(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal, - wrap, line); + sin_angle = sinf(deg2rad(angle)); + cos_angle = cosf(deg2rad(angle)); + sin_cos_angle = sin_angle * cos_angle; + + if (isAngleScalable) + { + width = height = 1.0; + } + else + { + width = rect->Width; + height = rect->Height; + } + + if (sin_cos_angle >= 0) + mode = LinearGradientModeForwardDiagonal; + else + mode = LinearGradientModeBackwardDiagonal; + + stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line); + + if (stat == Ok) + { + if (sin_cos_angle >= 0) + { + exofs = width * sin_cos_angle + height * cos_angle * cos_angle; + eyofs = width * sin_angle * sin_angle + height * sin_cos_angle; + } + else + { + exofs = width * sin_angle * sin_angle + height * sin_cos_angle; + eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle; + } + + if (isAngleScalable) + { + exofs = exofs * rect->Width; + eyofs = eyofs * rect->Height; + } + + if (sin_angle >= 0) + { + (*line)->endpoint.X = rect->X + exofs; + (*line)->endpoint.Y = rect->Y + eyofs; + } + else + { + (*line)->endpoint.X = (*line)->startpoint.X; + (*line)->endpoint.Y = (*line)->startpoint.Y; + (*line)->startpoint.X = rect->X + exofs; + (*line)->startpoint.Y = rect->Y + eyofs; + } + } + + return stat; } GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect, @@ -571,6 +637,8 @@ GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points, (*grad)->focus.X = 0.0; (*grad)->focus.Y = 0.0; + TRACE("<-- %p\n", *grad); + return Ok; } @@ -661,6 +729,8 @@ GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path, (*grad)->focus.X = 0.0; (*grad)->focus.Y = 0.0; + TRACE("<-- %p\n", *grad); + return Ok; } @@ -687,6 +757,8 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf) (*sf)->color = color; (*sf)->bmp = ARGB2BMP(color); + TRACE("<-- %p\n", *sf); + return Ok; } @@ -749,14 +821,9 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width, REAL height, GpTexture **texture) { - HDC hdc; - HBITMAP hbm, old = NULL; - BITMAPINFO *pbmi; - BITMAPINFOHEADER *bmih; - INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp; - BOOL bm_is_selected; - BYTE *dibits, *buff, *textbits; + HBITMAP hbm; GpStatus status; + GpImage *new_image=NULL; TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height, texture); @@ -764,124 +831,61 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0) return InvalidParameter; + *texture = NULL; + if(image->type != ImageTypeBitmap){ FIXME("not implemented for image type %d\n", image->type); return NotImplemented; } - n_x = roundr(x); - n_y = roundr(y); - n_width = roundr(width); - n_height = roundr(height); + status = GdipCloneBitmapArea(x, y, width, height, PixelFormatDontCare, (GpBitmap*)image, (GpBitmap**)&new_image); + if (status != Ok) + return status; - if(n_x + n_width > ((GpBitmap*)image)->width || - n_y + n_height > ((GpBitmap*)image)->height) - return InvalidParameter; - - hbm = ((GpBitmap*)image)->hbitmap; - if(!hbm) return GenericError; - hdc = ((GpBitmap*)image)->hdc; - bm_is_selected = (hdc != 0); - - pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - if (!pbmi) - return OutOfMemory; - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biBitCount = 0; - - if(!bm_is_selected){ - hdc = CreateCompatibleDC(0); - old = SelectObject(hdc, hbm); + hbm = ((GpBitmap*)new_image)->hbitmap; + if(!hbm) + { + status = GenericError; + goto exit; } - /* fill out bmi */ - GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); - - bytespp = pbmi->bmiHeader.biBitCount / 8; - abs_height = abs(pbmi->bmiHeader.biHeight); - - if(n_x > pbmi->bmiHeader.biWidth || n_x + n_width > pbmi->bmiHeader.biWidth || - n_y > abs_height || n_y + n_height > abs_height){ - GdipFree(pbmi); - return InvalidParameter; - } - - dibits = GdipAlloc(pbmi->bmiHeader.biSizeImage); - - if(dibits) /* this is not a good place to error out */ - GetDIBits(hdc, hbm, 0, abs_height, dibits, pbmi, DIB_RGB_COLORS); - - if(!bm_is_selected){ - SelectObject(hdc, old); - DeleteDC(hdc); - } - - if(!dibits){ - GdipFree(pbmi); - return OutOfMemory; - } - - image_stride = (pbmi->bmiHeader.biWidth * bytespp + 3) & ~3; - stride = (n_width * bytespp + 3) & ~3; - buff = GdipAlloc(sizeof(BITMAPINFOHEADER) + stride * n_height); - if(!buff){ - GdipFree(pbmi); - GdipFree(dibits); - return OutOfMemory; - } - - bmih = (BITMAPINFOHEADER*)buff; - textbits = (BYTE*) (bmih + 1); - bmih->biSize = sizeof(BITMAPINFOHEADER); - bmih->biWidth = n_width; - bmih->biHeight = n_height; - bmih->biCompression = BI_RGB; - bmih->biSizeImage = stride * n_height; - bmih->biBitCount = pbmi->bmiHeader.biBitCount; - bmih->biClrUsed = 0; - bmih->biPlanes = 1; - - /* image is flipped */ - if(pbmi->bmiHeader.biHeight > 0){ - dibits += image_stride * (pbmi->bmiHeader.biHeight - 1); - image_stride *= -1; - textbits += stride * (n_height - 1); - stride *= -1; - } - - GdipFree(pbmi); - - for(i = 0; i < n_height; i++) - memcpy(&textbits[i * stride], - &dibits[n_x * bytespp + (n_y + i) * image_stride], - abs(stride)); - *texture = GdipAlloc(sizeof(GpTexture)); if (!*texture){ - GdipFree(dibits); - GdipFree(buff); - return OutOfMemory; + status = OutOfMemory; + goto exit; } if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){ - GdipFree(*texture); - GdipFree(dibits); - GdipFree(buff); - return status; + goto exit; } - (*texture)->brush.lb.lbStyle = BS_DIBPATTERNPT; - (*texture)->brush.lb.lbColor = DIB_RGB_COLORS; - (*texture)->brush.lb.lbHatch = (ULONG_PTR)buff; + (*texture)->brush.lb.lbStyle = BS_PATTERN; + (*texture)->brush.lb.lbColor = 0; + (*texture)->brush.lb.lbHatch = (ULONG_PTR)hbm; (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb); (*texture)->brush.bt = BrushTypeTextureFill; (*texture)->wrap = imageattr->wrap; + (*texture)->image = new_image; - GdipFree(dibits); - GdipFree(buff); +exit: + if (status == Ok) + { + TRACE("<-- %p\n", *texture); + } + else + { + if (*texture) + { + GdipDeleteMatrix((*texture)->transform); + GdipFree(*texture); + *texture = NULL; + } + GdipDisposeImage(new_image); + TRACE("<-- error %u\n", status); + } - return Ok; + return status; } /****************************************************************************** @@ -979,6 +983,7 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush) break; case BrushTypeTextureFill: GdipDeleteMatrix(((GpTexture*)brush)->transform); + GdipDisposeImage(((GpTexture*)brush)->image); break; default: break; @@ -1175,6 +1180,8 @@ GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient { static int calls; + TRACE("(%p,%p,%p)\n", grad, argb, count); + if(!grad || !argb || !count || (*count < grad->pathdata.Count)) return InvalidParameter; @@ -1209,6 +1216,19 @@ GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb) return Ok; } +/****************************************************************************** + * GdipGetTextureImage [GDIPLUS.@] + */ +GpStatus WINGDIPAPI GdipGetTextureImage(GpTexture *brush, GpImage **image) +{ + TRACE("(%p, %p)\n", brush, image); + + if(!brush || !image) + return InvalidParameter; + + return GdipCloneImage(brush->image, image); +} + /****************************************************************************** * GdipGetTextureTransform [GDIPLUS.@] */ @@ -1430,6 +1450,8 @@ GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST RE { static int calls; + TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count); + if(!(calls++)) FIXME("not implemented\n"); @@ -1463,7 +1485,7 @@ GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad, GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad, GpPointF *point) { - TRACE("(%p, %p)\n", grad, point); + TRACE("(%p, %s)\n", grad, debugstr_pointf(point)); if(!grad || !point) return InvalidParameter; @@ -1522,6 +1544,8 @@ GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad, { static int calls; + TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale); + if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0) return InvalidParameter; @@ -1536,6 +1560,8 @@ GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient { static int calls; + TRACE("(%p,%p,%p)\n", grad, argb, count); + if(!grad || !argb || !count || (*count <= 0) || (*count > grad->pathdata.Count)) return InvalidParameter; @@ -1749,6 +1775,8 @@ GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush) { static int calls; + TRACE("(%p)\n", brush); + if(!(calls++)) FIXME("not implemented\n"); @@ -1760,6 +1788,8 @@ GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush, { static int calls; + TRACE("(%p,%p)\n", brush, matrix); + if(!(calls++)) FIXME("not implemented\n"); @@ -1771,6 +1801,8 @@ GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL { static int calls; + TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order); + if(!(calls++)) FIXME("not implemented\n"); @@ -1838,6 +1870,8 @@ GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush, { static int calls; + TRACE("(%p,%0.2f,%u)\n", brush, angle, order); + if(!brush) return InvalidParameter; diff --git a/reactos/dll/win32/gdiplus/customlinecap.c b/reactos/dll/win32/gdiplus/customlinecap.c index 5658e69c00d..00c228bf3cf 100644 --- a/reactos/dll/win32/gdiplus/customlinecap.c +++ b/reactos/dll/win32/gdiplus/customlinecap.c @@ -57,6 +57,8 @@ GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from, * sizeof(PointF)); memcpy((*to)->pathdata.Types, from->pathdata.Types, from->pathdata.Count); + TRACE("<-- %p\n", *to); + return Ok; } @@ -105,6 +107,8 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath (*customCap)->join = LineJoinMiter; (*customCap)->scale = 1.0; + TRACE("<-- %p\n", *customCap); + return Ok; } @@ -153,6 +157,8 @@ GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeCaps(GpCustomLineCap* custom, { static int calls; + TRACE("(%p,%u,%u)\n", custom, start, end); + if(!custom) return InvalidParameter; @@ -167,6 +173,8 @@ GpStatus WINGDIPAPI GdipSetCustomLineCapBaseCap(GpCustomLineCap* custom, { static int calls; + TRACE("(%p,%u)\n", custom, base); + if(!(calls++)) FIXME("not implemented\n"); @@ -191,6 +199,8 @@ GpStatus WINGDIPAPI GdipSetCustomLineCapBaseInset(GpCustomLineCap* custom, { static int calls; + TRACE("(%p,%0.2f)\n", custom, inset); + if(!(calls++)) FIXME("not implemented\n"); @@ -216,6 +226,8 @@ GpStatus WINGDIPAPI GdipSetCustomLineCapWidthScale(GpCustomLineCap* custom, { static int calls; + TRACE("(%p,%0.2f)\n", custom, width); + if(!(calls++)) FIXME("not implemented\n"); @@ -239,6 +251,8 @@ GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL f { static int calls; + TRACE("(%0.2f,%0.2f,%i,%p)\n", height, width, fill, cap); + if(!(calls++)) FIXME("not implemented\n"); @@ -249,6 +263,8 @@ GpStatus WINGDIPAPI GdipGetAdjustableArrowCapFillState(GpAdjustableArrowCap* cap { static int calls; + TRACE("(%p,%p)\n", cap, fill); + if(!(calls++)) FIXME("not implemented\n"); @@ -259,6 +275,8 @@ GpStatus WINGDIPAPI GdipGetAdjustableArrowCapHeight(GpAdjustableArrowCap* cap, R { static int calls; + TRACE("(%p,%p)\n", cap, height); + if(!(calls++)) FIXME("not implemented\n"); @@ -269,6 +287,8 @@ GpStatus WINGDIPAPI GdipGetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap* c { static int calls; + TRACE("(%p,%p)\n", cap, middle); + if(!(calls++)) FIXME("not implemented\n"); @@ -279,6 +299,8 @@ GpStatus WINGDIPAPI GdipGetAdjustableArrowCapWidth(GpAdjustableArrowCap* cap, RE { static int calls; + TRACE("(%p,%p)\n", cap, width); + if(!(calls++)) FIXME("not implemented\n"); @@ -289,6 +311,8 @@ GpStatus WINGDIPAPI GdipSetAdjustableArrowCapFillState(GpAdjustableArrowCap* cap { static int calls; + TRACE("(%p,%i)\n", cap, fill); + if(!(calls++)) FIXME("not implemented\n"); @@ -299,6 +323,8 @@ GpStatus WINGDIPAPI GdipSetAdjustableArrowCapHeight(GpAdjustableArrowCap* cap, R { static int calls; + TRACE("(%p,%0.2f)\n", cap, height); + if(!(calls++)) FIXME("not implemented\n"); @@ -309,6 +335,8 @@ GpStatus WINGDIPAPI GdipSetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap* c { static int calls; + TRACE("(%p,%0.2f)\n", cap, middle); + if(!(calls++)) FIXME("not implemented\n"); @@ -319,6 +347,8 @@ GpStatus WINGDIPAPI GdipSetAdjustableArrowCapWidth(GpAdjustableArrowCap* cap, RE { static int calls; + TRACE("(%p,%0.2f)\n", cap, width); + if(!(calls++)) FIXME("not implemented\n"); diff --git a/reactos/dll/win32/gdiplus/font.c b/reactos/dll/win32/gdiplus/font.c index 89498bce0d0..fda5428a7dd 100644 --- a/reactos/dll/win32/gdiplus/font.c +++ b/reactos/dll/win32/gdiplus/font.c @@ -158,6 +158,8 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, (*font)->height = tmw->ntmSizeEM; (*font)->line_spacing = tmw->tmAscent + tmw->tmDescent + tmw->tmExternalLeading; + TRACE("<-- %p\n", *font); + return Ok; } @@ -205,6 +207,8 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc, SelectObject(hdc, oldfont); DeleteObject(hfont); + TRACE("<-- %p\n", *font); + return Ok; } @@ -583,6 +587,8 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name, *FontFamily = ffamily; + TRACE("<-- %p\n", ffamily); + return Ok; } @@ -611,6 +617,8 @@ GpStatus WINGDIPAPI GdipCloneFontFamily(GpFontFamily* FontFamily, GpFontFamily** (*clonedFontFamily)->tmw = FontFamily->tmw; lstrcpyW((*clonedFontFamily)->FamilyName, FontFamily->FamilyName); + TRACE("<-- %p\n", *clonedFontFamily); + return Ok; } @@ -845,6 +853,9 @@ GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollecti (*fontCollection)->FontFamilies = NULL; (*fontCollection)->count = 0; (*fontCollection)->allocated = 0; + + TRACE("<-- %p\n", *fontCollection); + return Ok; } diff --git a/reactos/dll/win32/gdiplus/gdiplus.c b/reactos/dll/win32/gdiplus/gdiplus.c index 9fe933280ab..383f53621fb 100644 --- a/reactos/dll/win32/gdiplus/gdiplus.c +++ b/reactos/dll/win32/gdiplus/gdiplus.c @@ -58,9 +58,6 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) switch(reason) { - case DLL_WINE_PREATTACH: - return FALSE; /* prefer native version */ - case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls( hinst ); break; @@ -444,3 +441,9 @@ const char *debugstr_rectf(CONST RectF* rc) if (!rc) return "(null)"; return wine_dbg_sprintf("(%0.2f,%0.2f,%0.2f,%0.2f)", rc->X, rc->Y, rc->Width, rc->Height); } + +const char *debugstr_pointf(CONST PointF* pt) +{ + if (!pt) return "(null)"; + return wine_dbg_sprintf("(%0.2f,%0.2f)", pt->X, pt->Y); +} diff --git a/reactos/dll/win32/gdiplus/gdiplus.spec b/reactos/dll/win32/gdiplus/gdiplus.spec index aa64a3cb311..1da91d3edca 100644 --- a/reactos/dll/win32/gdiplus/gdiplus.spec +++ b/reactos/dll/win32/gdiplus/gdiplus.spec @@ -397,7 +397,7 @@ @ stdcall GdipGetStringFormatTrimming(ptr ptr) @ stdcall GdipGetTextContrast(ptr ptr) @ stdcall GdipGetTextRenderingHint(ptr ptr) -@ stub GdipGetTextureImage +@ stdcall GdipGetTextureImage(ptr ptr) @ stdcall GdipGetTextureTransform(ptr ptr) @ stdcall GdipGetTextureWrapMode(ptr ptr) @ stdcall GdipGetVisibleClipBounds(ptr ptr) @@ -424,7 +424,7 @@ @ stdcall GdipIsOutlineVisiblePathPoint(ptr long long ptr ptr ptr) @ stdcall GdipIsOutlineVisiblePathPointI(ptr long long ptr ptr ptr) @ stdcall GdipIsStyleAvailable(ptr long ptr) -@ stub GdipIsVisibleClipEmpty +@ stdcall GdipIsVisibleClipEmpty(ptr ptr) @ stdcall GdipIsVisiblePathPoint(ptr long long ptr ptr) @ stdcall GdipIsVisiblePathPointI(ptr long long ptr ptr) @ stdcall GdipIsVisiblePoint(ptr long long ptr) diff --git a/reactos/dll/win32/gdiplus/gdiplus_private.h b/reactos/dll/win32/gdiplus/gdiplus_private.h index 0ceeb6e0e8b..8e26eb18db9 100644 --- a/reactos/dll/win32/gdiplus/gdiplus_private.h +++ b/reactos/dll/win32/gdiplus/gdiplus_private.h @@ -80,9 +80,15 @@ static inline REAL deg2rad(REAL degrees) extern const char *debugstr_rectf(CONST RectF* rc); +extern const char *debugstr_pointf(CONST PointF* pt); + extern void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height, BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride); +extern GpStatus convert_pixels(UINT width, UINT height, + INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, + INT src_stride, const BYTE *src_bits, PixelFormat src_format, ARGB *src_palette); + struct GpPen{ UINT style; GpUnit unit; @@ -174,6 +180,7 @@ struct GpLineGradient{ struct GpTexture{ GpBrush brush; GpMatrix *transform; + GpImage *image; WrapMode wrap; /* not used yet */ }; @@ -217,6 +224,7 @@ struct GpImage{ UINT palette_count; UINT palette_size; ARGB *palette_entries; + REAL xres, yres; }; struct GpMetafile{ @@ -249,9 +257,19 @@ struct color_key{ ARGB high; }; +struct color_matrix{ + BOOL enabled; + ColorMatrixFlags flags; + ColorMatrix colormatrix; + ColorMatrix graymatrix; +}; + struct GpImageAttributes{ WrapMode wrap; struct color_key colorkeys[ColorAdjustTypeCount]; + struct color_matrix colormatrices[ColorAdjustTypeCount]; + BOOL gamma_enabled[ColorAdjustTypeCount]; + REAL gamma[ColorAdjustTypeCount]; }; struct GpFont{ @@ -274,6 +292,8 @@ struct GpStringFormat{ INT tabcount; REAL firsttab; REAL *tabs; + CharacterRange *character_ranges; + INT range_count; }; struct GpFontCollection{ diff --git a/reactos/dll/win32/gdiplus/graphics.c b/reactos/dll/win32/gdiplus/graphics.c index b1092b77621..359b954ebe6 100644 --- a/reactos/dll/win32/gdiplus/graphics.c +++ b/reactos/dll/win32/gdiplus/graphics.c @@ -1162,6 +1162,8 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra list_init(&(*graphics)->containers); (*graphics)->contid = 0; + TRACE("<-- %p\n", *graphics); + return Ok; } @@ -1199,6 +1201,8 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, { static int calls; + TRACE("(%p,%i,%p)\n", hemf, delete, metafile); + if(!hemf || !metafile) return InvalidParameter; @@ -1215,7 +1219,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, UINT read; BYTE* copy; HENHMETAFILE hemf; - GpStatus retval = GenericError; + GpStatus retval = Ok; TRACE("(%p, %d, %p, %p)\n", hwmf, delete, placeable, metafile); @@ -1240,6 +1244,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, if(CreateStreamOnHGlobal(copy, TRUE, &stream) != S_OK){ ERR("could not make stream\n"); GdipFree(copy); + retval = GenericError; goto err; } @@ -1251,7 +1256,10 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture, (LPVOID*) &((*metafile)->image.picture)) != S_OK) + { + retval = GenericError; goto err; + } (*metafile)->image.type = ImageTypeMetafile; @@ -1260,8 +1268,10 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, (*metafile)->image.palette_count = 0; (*metafile)->image.palette_size = 0; (*metafile)->image.palette_entries = NULL; + (*metafile)->image.xres = (REAL)placeable->Inch; + (*metafile)->image.yres = (REAL)placeable->Inch; (*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch); - (*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Right) / ((REAL) placeable->Inch); + (*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Top) / ((REAL) placeable->Inch); (*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right - placeable->BoundingBox.Left)) / ((REAL) placeable->Inch); (*metafile)->bounds.Height = ((REAL) (placeable->BoundingBox.Bottom @@ -1271,10 +1281,11 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, if(delete) DeleteMetaFile(hwmf); - return Ok; + TRACE("<-- %p\n", *metafile); err: - GdipFree(*metafile); + if (retval != Ok) + GdipFree(*metafile); IStream_Release(stream); return retval; } @@ -1872,6 +1883,9 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image if(!graphics || !image || !points || count != 3) return InvalidParameter; + TRACE("%s %s %s\n", debugstr_pointf(&points[0]), debugstr_pointf(&points[1]), + debugstr_pointf(&points[2])); + memcpy(ptf, points, 3 * sizeof(GpPointF)); transform_and_round_points(graphics, pti, ptf, 3); @@ -1912,12 +1926,16 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image else return NotImplemented; - if (bitmap->format == PixelFormat32bppARGB) + if (!(bitmap->format == PixelFormat16bppRGB555 || + bitmap->format == PixelFormat24bppRGB || + bitmap->format == PixelFormat32bppRGB || + bitmap->format == PixelFormat32bppPARGB)) { BITMAPINFOHEADER bih; BYTE *temp_bits; + PixelFormat dst_format; - /* we need a bitmap with premultiplied alpha */ + /* we can't draw a bitmap of this format directly */ hdc = CreateCompatibleDC(0); temp_hdc = 1; temp_bitmap = 1; @@ -1937,8 +1955,14 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&temp_bits, NULL, 0); - convert_32bppARGB_to_32bppPARGB(bitmap->width, bitmap->height, - temp_bits, bitmap->width*4, bitmap->bits, bitmap->stride); + if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha)) + dst_format = PixelFormat32bppPARGB; + else + dst_format = PixelFormat32bppRGB; + + convert_pixels(bitmap->width, bitmap->height, + bitmap->width*4, temp_bits, dst_format, + bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette_entries); } else { @@ -1953,7 +1977,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image old_hbm = SelectObject(hdc, hbitmap); } - if (bitmap->format == PixelFormat32bppARGB || bitmap->format == PixelFormat32bppPARGB) + if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha)) { BLENDFUNCTION bf; @@ -3052,6 +3076,8 @@ GpStatus WINGDIPAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention) { static int calls; + TRACE("(%p,%u)\n", graphics, intention); + if(!graphics) return InvalidParameter; @@ -3149,14 +3175,14 @@ GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics *graphics, GpStatus WINGDIPAPI GdipGetNearestColor(GpGraphics *graphics, ARGB* argb) { + FIXME("(%p, %p): stub\n", graphics, argb); + if(!graphics || !argb) return InvalidParameter; if(graphics->busy) return ObjectBusy; - FIXME("(%p, %p): stub\n", graphics, argb); - return NotImplemented; } @@ -3443,12 +3469,12 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics, GDIPCONST RectF* layoutRect, GDIPCONST GpStringFormat *stringFormat, INT regionCount, GpRegion** regions) { - if (!(graphics && string && font && layoutRect && stringFormat && regions)) - return InvalidParameter; - FIXME("stub: %p %s %d %p %p %p %d %p\n", graphics, debugstr_w(string), length, font, layoutRect, stringFormat, regionCount, regions); + if (!(graphics && string && font && layoutRect && stringFormat && regions)) + return InvalidParameter; + return NotImplemented; } @@ -4001,6 +4027,8 @@ GpStatus WINGDIPAPI GdipSetMetafileDownLevelRasterizationLimit(GpMetafile *metaf { static int calls; + TRACE("(%p,%u)\n", metafile, limitDpi); + if(!(calls++)) FIXME("not implemented\n"); @@ -4341,3 +4369,26 @@ GpStatus WINGDIPAPI GdipRecordMetafileI(HDC hdc, EmfType type, GDIPCONST GpRect FIXME("(%p %d %p %d %p %p): stub\n", hdc, type, frameRect, frameUnit, desc, metafile); return NotImplemented; } + +/***************************************************************************** + * GdipIsVisibleClipEmpty [GDIPLUS.@] + */ +GpStatus WINGDIPAPI GdipIsVisibleClipEmpty(GpGraphics *graphics, BOOL *res) +{ + GpStatus stat; + GpRegion* rgn; + + TRACE("(%p, %p)\n", graphics, res); + + if((stat = GdipCreateRegion(&rgn)) != Ok) + return stat; + + if((stat = get_visible_clip_region(graphics, rgn)) != Ok) + goto cleanup; + + stat = GdipIsEmptyRegion(rgn, graphics, res); + +cleanup: + GdipDeleteRegion(rgn); + return stat; +} diff --git a/reactos/dll/win32/gdiplus/graphicspath.c b/reactos/dll/win32/gdiplus/graphicspath.c index 94e17dda39c..60ddda1d7b5 100644 --- a/reactos/dll/win32/gdiplus/graphicspath.c +++ b/reactos/dll/win32/gdiplus/graphicspath.c @@ -1380,6 +1380,8 @@ GpStatus WINGDIPAPI GdipIsOutlineVisiblePathPoint(GpPath* path, REAL x, REAL y, { static int calls; + TRACE("(%p,%0.2f,%0.2f,%p,%p,%p)\n", path, x, y, pen, graphics, result); + if(!path || !pen) return InvalidParameter; diff --git a/reactos/dll/win32/gdiplus/image.c b/reactos/dll/win32/gdiplus/image.c index 3dbe4daf8be..1d48a0b7427 100644 --- a/reactos/dll/win32/gdiplus/image.c +++ b/reactos/dll/win32/gdiplus/image.c @@ -94,6 +94,24 @@ GpStatus WINGDIPAPI GdipBitmapCreateApplyEffect(GpBitmap** inputBitmaps, return NotImplemented; } +static inline void getpixel_1bppIndexed(BYTE *index, const BYTE *row, UINT x) +{ + *index = (row[x/8]>>(7-x%8)) & 1; +} + +static inline void getpixel_4bppIndexed(BYTE *index, const BYTE *row, UINT x) +{ + if (x & 1) + *index = row[x/2]&0xf; + else + *index = row[x/2]>>4; +} + +static inline void getpixel_8bppIndexed(BYTE *index, const BYTE *row, UINT x) +{ + *index = row[x]; +} + static inline void getpixel_16bppGrayScale(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x) { @@ -211,6 +229,7 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, ARGB *color) { BYTE r, g, b, a; + BYTE index; BYTE *row; TRACE("%p %d %d %p\n", bitmap, x, y, color); @@ -222,6 +241,15 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, switch (bitmap->format) { + case PixelFormat1bppIndexed: + getpixel_1bppIndexed(&index,row,x); + break; + case PixelFormat4bppIndexed: + getpixel_4bppIndexed(&index,row,x); + break; + case PixelFormat8bppIndexed: + getpixel_8bppIndexed(&index,row,x); + break; case PixelFormat16bppGrayScale: getpixel_16bppGrayScale(&r,&g,&b,&a,row,x); break; @@ -260,7 +288,10 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, return NotImplemented; } - *color = a<<24|r<<16|g<<8|b; + if (bitmap->format & PixelFormatIndexed) + *color = bitmap->image.palette_entries[index]; + else + *color = a<<24|r<<16|g<<8|b; return Ok; } @@ -411,6 +442,412 @@ GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap* bitmap, INT x, INT y, return Ok; } +GpStatus convert_pixels(UINT width, UINT height, + INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, + INT src_stride, const BYTE *src_bits, PixelFormat src_format, ARGB *src_palette) +{ + UINT x, y; + + if (src_format == dst_format || + (dst_format == PixelFormat32bppRGB && PIXELFORMATBPP(src_format) == 32)) + { + UINT widthbytes = PIXELFORMATBPP(src_format) * width / 8; + for (y=0; ylockmode) + { + WARN("bitmap is already locked and cannot be locked again\n"); return WrongState; + } if (bitmap->bits && bitmap->format == format) { @@ -470,83 +911,77 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, return Ok; } - hbm = bitmap->hbitmap; - hdc = bitmap->hdc; - bm_is_selected = (hdc != 0); - - pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - if (!pbmi) - return OutOfMemory; - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biBitCount = 0; - - if(!bm_is_selected){ - hdc = CreateCompatibleDC(0); - old = SelectObject(hdc, hbm); + /* Make sure we can convert to the requested format. */ + stat = convert_pixels(0, 0, 0, NULL, format, 0, NULL, bitmap->format, NULL); + if (stat == NotImplemented) + { + FIXME("cannot read bitmap from %x to %x\n", bitmap->format, format); + return NotImplemented; } - /* fill out bmi */ - GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); + /* If we're opening for writing, make sure we'll be able to write back in + * the original format. */ + if (flags & ImageLockModeWrite) + { + stat = convert_pixels(0, 0, 0, NULL, bitmap->format, 0, NULL, format, NULL); + if (stat == NotImplemented) + { + FIXME("cannot write bitmap from %x to %x\n", format, bitmap->format); + return NotImplemented; + } + } - abs_height = abs(pbmi->bmiHeader.biHeight); - stride = pbmi->bmiHeader.biWidth * bitspp / 8; + abs_height = bitmap->height; + stride = (bitmap->width * bitspp + 7) / 8; stride = (stride + 3) & ~3; buff = GdipAlloc(stride * abs_height); - pbmi->bmiHeader.biBitCount = bitspp; + if (!buff) return OutOfMemory; - if(buff) - GetDIBits(hdc, hbm, 0, abs_height, buff, pbmi, DIB_RGB_COLORS); + stat = convert_pixels(bitmap->width, bitmap->height, + stride, buff, format, + bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette_entries); - if(!bm_is_selected){ - SelectObject(hdc, old); - DeleteDC(hdc); - } - - if(!buff){ - GdipFree(pbmi); - return OutOfMemory; + if (stat != Ok) + { + GdipFree(buff); + return stat; } lockeddata->Width = act_rect.Width; lockeddata->Height = act_rect.Height; lockeddata->PixelFormat = format; lockeddata->Reserved = flags; - - if(pbmi->bmiHeader.biHeight > 0){ - lockeddata->Stride = -stride; - lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X + - stride * (abs_height - 1 - act_rect.Y); - } - else{ - lockeddata->Stride = stride; - lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X + stride * act_rect.Y; - } + lockeddata->Stride = stride; + lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X + stride * act_rect.Y; bitmap->lockmode = flags; bitmap->numlocks++; - bitmap->bitmapbits = buff; - GdipFree(pbmi); return Ok; } GpStatus WINGDIPAPI GdipBitmapSetResolution(GpBitmap* bitmap, REAL xdpi, REAL ydpi) { - FIXME("(%p, %.2f, %.2f)\n", bitmap, xdpi, ydpi); + TRACE("(%p, %.2f, %.2f)\n", bitmap, xdpi, ydpi); - return NotImplemented; + if (!bitmap || xdpi == 0.0 || ydpi == 0.0) + return InvalidParameter; + + bitmap->image.xres = xdpi; + bitmap->image.yres = ydpi; + + return Ok; } GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, BitmapData* lockeddata) { - HDC hdc; - HBITMAP hbm, old = NULL; - BOOL bm_is_selected; - BITMAPINFO *pbmi; + GpStatus stat; + + TRACE("(%p,%p)\n", bitmap, lockeddata); if(!bitmap || !lockeddata) return InvalidParameter; @@ -570,38 +1005,25 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, { /* we passed a direct reference; no need to do anything */ bitmap->lockmode = 0; + bitmap->numlocks = 0; return Ok; } - hbm = bitmap->hbitmap; - hdc = bitmap->hdc; - bm_is_selected = (hdc != 0); + stat = convert_pixels(bitmap->width, bitmap->height, + bitmap->stride, bitmap->bits, bitmap->format, + lockeddata->Stride, bitmap->bitmapbits, lockeddata->PixelFormat, NULL); - pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biBitCount = 0; - - if(!bm_is_selected){ - hdc = CreateCompatibleDC(0); - old = SelectObject(hdc, hbm); + if (stat != Ok) + { + ERR("failed to convert pixels; this should never happen\n"); } - GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); - pbmi->bmiHeader.biBitCount = PIXELFORMATBPP(lockeddata->PixelFormat); - SetDIBits(hdc, hbm, 0, abs(pbmi->bmiHeader.biHeight), - bitmap->bitmapbits, pbmi, DIB_RGB_COLORS); - - if(!bm_is_selected){ - SelectObject(hdc, old); - DeleteDC(hdc); - } - - GdipFree(pbmi); GdipFree(bitmap->bitmapbits); bitmap->bitmapbits = NULL; bitmap->lockmode = 0; + bitmap->numlocks = 0; - return Ok; + return stat; } GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height, @@ -613,7 +1035,7 @@ GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height, Rect area; GpStatus stat; - TRACE("(%f,%f,%f,%f,%i,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); + TRACE("(%f,%f,%f,%f,0x%x,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); if (!srcBitmap || !dstBitmap || srcBitmap->image.type != ImageTypeBitmap || x < 0 || y < 0 || @@ -671,7 +1093,7 @@ GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height, GpStatus WINGDIPAPI GdipCloneBitmapAreaI(INT x, INT y, INT width, INT height, PixelFormat format, GpBitmap* srcBitmap, GpBitmap** dstBitmap) { - TRACE("(%i,%i,%i,%i,%i,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); + TRACE("(%i,%i,%i,%i,0x%x,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); return GdipCloneBitmapArea(x, y, width, height, format, srcBitmap, dstBitmap); } @@ -937,6 +1359,9 @@ GpStatus WINGDIPAPI GdipConvertToEmfPlus(const GpGraphics* ref, { static int calls; + TRACE("(%p,%p,%p,%u,%s,%p)\n", ref, metafile, succ, emfType, + debugstr_w(description), out_metafile); + if(!ref || !metafile || !out_metafile) return InvalidParameter; @@ -1172,6 +1597,20 @@ static void generate_halftone_palette(ARGB *entries, UINT count) } } +static GpStatus get_screen_resolution(REAL *xres, REAL *yres) +{ + HDC screendc = GetDC(0); + + if (!screendc) return GenericError; + + *xres = (REAL)GetDeviceCaps(screendc, LOGPIXELSX); + *yres = (REAL)GetDeviceCaps(screendc, LOGPIXELSY); + + ReleaseDC(0, screendc); + + return Ok; +} + GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE* scan0, GpBitmap** bitmap) { @@ -1181,8 +1620,10 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, HDC hdc; BYTE *bits; int i; + REAL xres, yres; + GpStatus stat; - TRACE("%d %d %d %d %p %p\n", width, height, stride, format, scan0, bitmap); + TRACE("%d %d %d 0x%x %p %p\n", width, height, stride, format, scan0, bitmap); if (!bitmap) return InvalidParameter; @@ -1194,6 +1635,9 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, if(scan0 && !stride) return InvalidParameter; + stat = get_screen_resolution(&xres, &yres); + if (stat != Ok) return stat; + row_size = (width * PIXELFORMATBPP(format)+7) / 8; dib_stride = (row_size + 3) & ~3; @@ -1243,6 +1687,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, (*bitmap)->image.palette_count = 0; (*bitmap)->image.palette_size = 0; (*bitmap)->image.palette_entries = NULL; + (*bitmap)->image.xres = xres; + (*bitmap)->image.yres = yres; (*bitmap)->width = width; (*bitmap)->height = height; (*bitmap)->format = format; @@ -1282,6 +1728,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, } } + TRACE("<-- %p\n", *bitmap); + return Ok; } @@ -1398,9 +1846,16 @@ GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) GpStatus WINGDIPAPI GdipFindFirstImageItem(GpImage *image, ImageItemData* item) { + static int calls; + + TRACE("(%p,%p)\n", image, item); + if(!image || !item) return InvalidParameter; + if (!(calls++)) + FIXME("not implemented\n"); + return NotImplemented; } @@ -1520,15 +1975,14 @@ GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height) GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res) { - static int calls; - if(!image || !res) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + *res = image->xres; - return NotImplemented; + TRACE("(%p) <-- %0.2f\n", image, *res); + + return Ok; } GpStatus WINGDIPAPI GdipGetImagePaletteSize(GpImage *image, INT *size) @@ -1588,15 +2042,14 @@ GpStatus WINGDIPAPI GdipGetImageType(GpImage *image, ImageType *type) GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res) { - static int calls; - if(!image || !res) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + *res = image->yres; - return NotImplemented; + TRACE("(%p) <-- %0.2f\n", image, *res); + + return Ok; } GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width) @@ -1700,17 +2153,34 @@ GpStatus WINGDIPAPI GdipGetPropertySize(GpImage *image, UINT* size, UINT* num) { static int calls; + TRACE("(%p,%p,%p)\n", image, size, num); + if(!(calls++)) FIXME("not implemented\n"); return InvalidParameter; } +struct image_format_dimension +{ + const GUID *format; + const GUID *dimension; +}; + +struct image_format_dimension image_format_dimensions[] = +{ + {&ImageFormatGIF, &FrameDimensionTime}, + {&ImageFormatIcon, &FrameDimensionResolution}, + {NULL} +}; + GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image, GDIPCONST GUID* dimensionID, UINT* count) { static int calls; + TRACE("(%p,%s,%p)\n", image, debugstr_guid(dimensionID), count); + if(!image || !dimensionID || !count) return InvalidParameter; @@ -1723,26 +2193,40 @@ GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image, GpStatus WINGDIPAPI GdipImageGetFrameDimensionsCount(GpImage *image, UINT* count) { + /* Native gdiplus 1.1 does not yet support multiple frame dimensions. */ + if(!image || !count) return InvalidParameter; *count = 1; - FIXME("stub\n"); - return Ok; } GpStatus WINGDIPAPI GdipImageGetFrameDimensionsList(GpImage* image, GUID* dimensionIDs, UINT count) { - static int calls; + int i; + const GUID *result=NULL; - if(!image || !dimensionIDs) + TRACE("(%p,%p,%u)\n", image, dimensionIDs, count); + + if(!image || !dimensionIDs || count != 1) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + for (i=0; image_format_dimensions[i].format; i++) + { + if (IsEqualGUID(&image->format, image_format_dimensions[i].format)) + { + result = image_format_dimensions[i].dimension; + break; + } + } + + if (!result) + result = &FrameDimensionPage; + + memcpy(dimensionIDs, result, sizeof(GUID)); return Ok; } @@ -1976,6 +2460,8 @@ static GpStatus decode_image_olepicture_metafile(IStream* stream, REFCLSID clsid (*image)->palette_size = 0; (*image)->palette_entries = NULL; + TRACE("<-- %p\n", *image); + return Ok; } @@ -2084,6 +2570,8 @@ GpStatus WINGDIPAPI GdipRemovePropertyItem(GpImage *image, PROPID propId) { static int calls; + TRACE("(%p,%u)\n", image, propId); + if(!image) return InvalidParameter; @@ -2097,6 +2585,8 @@ GpStatus WINGDIPAPI GdipSetPropertyItem(GpImage *image, GDIPCONST PropertyItem* { static int calls; + TRACE("(%p,%p)\n", image, item); + if(!(calls++)) FIXME("not implemented\n"); @@ -2790,6 +3280,8 @@ GpStatus WINGDIPAPI GdipSetEffectParameters(CGpEffect *effect, { static int calls; + TRACE("(%p,%p,%u)\n", effect, params, size); + if(!(calls++)) FIXME("not implemented\n"); diff --git a/reactos/dll/win32/gdiplus/imageattributes.c b/reactos/dll/win32/gdiplus/imageattributes.c index 8f49c67bd44..c9c3bcc9060 100644 --- a/reactos/dll/win32/gdiplus/imageattributes.c +++ b/reactos/dll/win32/gdiplus/imageattributes.c @@ -30,26 +30,31 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr, GpImageAttributes **cloneImageattr) { + GpStatus stat; + TRACE("(%p, %p)\n", imageattr, cloneImageattr); if(!imageattr || !cloneImageattr) return InvalidParameter; - **cloneImageattr = *imageattr; + stat = GdipCreateImageAttributes(cloneImageattr); - return Ok; + if (stat == Ok) + **cloneImageattr = *imageattr; + + return stat; } GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr) { - TRACE("(%p)\n", imageattr); - if(!imageattr) return InvalidParameter; *imageattr = GdipAlloc(sizeof(GpImageAttributes)); if(!*imageattr) return OutOfMemory; + TRACE("<-- %p\n", *imageattr); + return Ok; } @@ -84,15 +89,32 @@ GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageat ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix, GDIPCONST ColorMatrix* grayMatrix, ColorMatrixFlags flags) { - static int calls; + TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix, + grayMatrix, flags); - if(!imageattr || !colorMatrix || !grayMatrix) + if(!imageattr || type >= ColorAdjustTypeCount || flags > ColorMatrixFlagsAltGray) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + if (enableFlag) + { + if (!colorMatrix) + return InvalidParameter; - return NotImplemented; + if (flags == ColorMatrixFlagsAltGray) + { + if (!grayMatrix) + return InvalidParameter; + + imageattr->colormatrices[type].graymatrix = *grayMatrix; + } + + imageattr->colormatrices[type].colormatrix = *colorMatrix; + imageattr->colormatrices[type].flags = flags; + } + + imageattr->colormatrices[type].enabled = enableFlag; + + return Ok; } GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr, @@ -100,6 +122,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr, { static int calls; + TRACE("(%p,%u,%08x,%i)\n", imageAttr, wrap, argb, clamp); + if(!imageAttr) return InvalidParameter; @@ -114,6 +138,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *im { static int calls; + TRACE("(%p,%i)\n", imageAttr, enableFlag); + if(!(calls++)) FIXME("not implemented\n"); @@ -123,12 +149,15 @@ GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *im GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag, REAL gamma) { - static int calls; + TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma); - if(!(calls++)) - FIXME("not implemented\n"); + if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount) + return InvalidParameter; - return NotImplemented; + imageAttr->gamma_enabled[type] = enableFlag; + imageAttr->gamma[type] = gamma; + + return Ok; } GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr, @@ -136,6 +165,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr, { static int calls; + TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag); + if(!(calls++)) FIXME("not implemented\n"); @@ -147,6 +178,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *image { static int calls; + TRACE("(%p,%u,%i,%x)\n", imageAttr, type, enableFlag, channelFlags); + if(!(calls++)) FIXME("not implemented\n"); @@ -159,6 +192,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannelColorProfile(GpImageAttri { static int calls; + TRACE("(%p,%u,%i,%s)\n", imageAttr, type, enableFlag, debugstr_w(colorProfileFilename)); + if(!(calls++)) FIXME("not implemented\n"); @@ -171,6 +206,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt { static int calls; + TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map); + if(!(calls++)) FIXME("not implemented\n"); @@ -182,6 +219,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr { static int calls; + TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, threshold); + if(!(calls++)) FIXME("not implemented\n"); @@ -193,6 +232,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes *imageAtt { static int calls; + TRACE("(%p,%u)\n", imageAttr, type); + if(!(calls++)) FIXME("not implemented\n"); diff --git a/reactos/dll/win32/gdiplus/pen.c b/reactos/dll/win32/gdiplus/pen.c index 4a68a27c541..930317cc826 100644 --- a/reactos/dll/win32/gdiplus/pen.c +++ b/reactos/dll/win32/gdiplus/pen.c @@ -101,6 +101,8 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen) GdipCloneCustomLineCap(pen->customend, &(*clonepen)->customend); GdipCloneBrush(pen->brush, &(*clonepen)->brush); + TRACE("<-- %p\n", *clonepen); + return Ok; } @@ -154,6 +156,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit, *pen = gp_pen; + TRACE("<-- %p\n", *pen); + return Ok; } @@ -389,6 +393,8 @@ GpStatus WINGDIPAPI GdipResetPenTransform(GpPen *pen) { static int calls; + TRACE("(%p)\n", pen); + if(!pen) return InvalidParameter; @@ -402,6 +408,8 @@ GpStatus WINGDIPAPI GdipScalePenTransform(GpPen *pen, REAL sx, REAL sy, GpMatrix { static int calls; + TRACE("(%p,%0.2f,%0.2f,%u)\n", pen, sx, sy, order); + if(!pen) return InvalidParameter; diff --git a/reactos/dll/win32/gdiplus/stringformat.c b/reactos/dll/win32/gdiplus/stringformat.c index bfe7d34e05e..cf6ea1f392a 100644 --- a/reactos/dll/win32/gdiplus/stringformat.c +++ b/reactos/dll/win32/gdiplus/stringformat.c @@ -48,11 +48,15 @@ GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang, (*format)->digitlang = LANG_NEUTRAL; (*format)->trimming = StringTrimmingCharacter; (*format)->digitsub = StringDigitSubstituteUser; + (*format)->character_ranges = NULL; + (*format)->range_count = 0; /* tabstops */ (*format)->tabcount = 0; (*format)->firsttab = 0.0; (*format)->tabs = NULL; + TRACE("<-- %p\n", *format); + return Ok; } @@ -61,6 +65,7 @@ GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format) if(!format) return InvalidParameter; + GdipFree(format->character_ranges); GdipFree(format->tabs); GdipFree(format); @@ -141,14 +146,16 @@ GpStatus WINGDIPAPI GdipGetStringFormatLineAlign(GpStringFormat *format, } GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount( - GDIPCONST GpStringFormat* format, INT* count) + GDIPCONST GpStringFormat *format, INT *count) { if (!(format && count)) return InvalidParameter; - FIXME("stub: %p %p\n", format, count); + TRACE("%p %p\n", format, count); - return NotImplemented; + *count = format->range_count; + + return Ok; } GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat *format, @@ -242,15 +249,26 @@ GpStatus WINGDIPAPI GdipSetStringFormatLineAlign(GpStringFormat *format, return Ok; } -GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(GpStringFormat* - format, INT rangeCount, GDIPCONST CharacterRange* ranges) +GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges( + GpStringFormat *format, INT rangeCount, GDIPCONST CharacterRange *ranges) { - if (!(format && rangeCount && ranges)) + CharacterRange *new_ranges; + + if (!(format && ranges)) return InvalidParameter; - FIXME("stub: %p, %d, %p\n", format, rangeCount, ranges); + TRACE("%p, %d, %p\n", format, rangeCount, ranges); - return NotImplemented; + new_ranges = GdipAlloc(rangeCount * sizeof(CharacterRange)); + if (!new_ranges) + return OutOfMemory; + + GdipFree(format->character_ranges); + format->character_ranges = new_ranges; + memcpy(format->character_ranges, ranges, sizeof(CharacterRange) * rangeCount); + format->range_count = rangeCount; + + return Ok; } GpStatus WINGDIPAPI GdipSetStringFormatTabStops(GpStringFormat *format, REAL firsttab, @@ -331,6 +349,19 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt else (*newFormat)->tabs = NULL; + if(format->range_count > 0){ + (*newFormat)->character_ranges = GdipAlloc(sizeof(CharacterRange) * format->range_count); + if(!(*newFormat)->character_ranges){ + GdipFree((*newFormat)->tabs); + GdipFree(*newFormat); + return OutOfMemory; + } + memcpy((*newFormat)->character_ranges, format->character_ranges, + sizeof(CharacterRange) * format->range_count); + } + else + (*newFormat)->character_ranges = NULL; + TRACE("%p %p\n",format,newFormat); return Ok; From 71c6a8c283bee66bd7d9dd0f8cc2ba7f8d9cbec5 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 13:36:55 +0000 Subject: [PATCH 081/211] [RSAENH] sync rsaenh to wine 1.1.39 svn path=/trunk/; revision=45832 --- reactos/dll/win32/rsaenh/rsaenh.c | 47 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/reactos/dll/win32/rsaenh/rsaenh.c b/reactos/dll/win32/rsaenh/rsaenh.c index 823468823d9..665bc40056f 100644 --- a/reactos/dll/win32/rsaenh/rsaenh.c +++ b/reactos/dll/win32/rsaenh/rsaenh.c @@ -1219,6 +1219,8 @@ static void destroy_key_container(OBJECTHDR *pObjectHdr) store_key_container_permissions(pKeyContainer); release_key_container_keys(pKeyContainer); } + else + release_key_container_keys(pKeyContainer); HeapFree( GetProcessHeap(), 0, pKeyContainer ); } @@ -1378,12 +1380,18 @@ static HCRYPTPROV read_key_container(PCHAR pszContainerName, DWORD dwFlags, cons (OBJECTHDR**)&pKeyContainer)) return (HCRYPTPROV)INVALID_HANDLE_VALUE; + /* read_key_value calls import_key, which calls import_private_key, + * which implicitly installs the key value into the appropriate key + * container key. Thus the ref count is incremented twice, once for + * the output key value, and once for the implicit install, and needs + * to be decremented to balance the two. + */ if (read_key_value(hKeyContainer, hKey, AT_KEYEXCHANGE, dwProtectFlags, &hCryptKey)) - pKeyContainer->hKeyExchangeKeyPair = hCryptKey; + release_handle(&handle_table, hCryptKey, RSAENH_MAGIC_KEY); if (read_key_value(hKeyContainer, hKey, AT_SIGNATURE, dwProtectFlags, &hCryptKey)) - pKeyContainer->hSignatureKeyPair = hCryptKey; + release_handle(&handle_table, hCryptKey, RSAENH_MAGIC_KEY); } return hKeyContainer; @@ -3065,9 +3073,9 @@ BOOL WINAPI RSAENH_CPGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYP if (pCryptKey) { new_key_impl(pCryptKey->aiAlgid, &pCryptKey->context, pCryptKey->dwKeyLen); setup_key(pCryptKey); - RSAENH_CPDestroyKey(hProv, pKeyContainer->hSignatureKeyPair); - copy_handle(&handle_table, *phKey, RSAENH_MAGIC_KEY, - &pKeyContainer->hSignatureKeyPair); + release_and_install_key(hProv, *phKey, + &pKeyContainer->hSignatureKeyPair, + FALSE); } break; @@ -3077,9 +3085,9 @@ BOOL WINAPI RSAENH_CPGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYP if (pCryptKey) { new_key_impl(pCryptKey->aiAlgid, &pCryptKey->context, pCryptKey->dwKeyLen); setup_key(pCryptKey); - RSAENH_CPDestroyKey(hProv, pKeyContainer->hKeyExchangeKeyPair); - copy_handle(&handle_table, *phKey, RSAENH_MAGIC_KEY, - &pKeyContainer->hKeyExchangeKeyPair); + release_and_install_key(hProv, *phKey, + &pKeyContainer->hKeyExchangeKeyPair, + FALSE); } break; @@ -4162,11 +4170,12 @@ BOOL WINAPI RSAENH_CPSignHash(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpe LPCWSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen) { - HCRYPTKEY hCryptKey; + HCRYPTKEY hCryptKey = (HCRYPTKEY)INVALID_HANDLE_VALUE; CRYPTKEY *pCryptKey; DWORD dwHashLen; BYTE abHashValue[RSAENH_MAX_HASH_SIZE]; ALG_ID aiAlgid; + BOOL ret = FALSE; TRACE("(hProv=%08lx, hHash=%08lx, dwKeySpec=%08x, sDescription=%s, dwFlags=%08x, " "pbSignature=%p, pdwSigLen=%p)\n", hProv, hHash, dwKeySpec, debugstr_w(sDescription), @@ -4183,18 +4192,19 @@ BOOL WINAPI RSAENH_CPSignHash(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpe (OBJECTHDR**)&pCryptKey)) { SetLastError(NTE_NO_KEY); - return FALSE; + goto out; } if (!pbSignature) { *pdwSigLen = pCryptKey->dwKeyLen; - return TRUE; + ret = TRUE; + goto out; } if (pCryptKey->dwKeyLen > *pdwSigLen) { SetLastError(ERROR_MORE_DATA); *pdwSigLen = pCryptKey->dwKeyLen; - return FALSE; + goto out; } *pdwSigLen = pCryptKey->dwKeyLen; @@ -4202,22 +4212,25 @@ BOOL WINAPI RSAENH_CPSignHash(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpe if (!RSAENH_CPHashData(hProv, hHash, (CONST BYTE*)sDescription, (DWORD)lstrlenW(sDescription)*sizeof(WCHAR), 0)) { - return FALSE; + goto out; } } dwHashLen = sizeof(DWORD); - if (!RSAENH_CPGetHashParam(hProv, hHash, HP_ALGID, (BYTE*)&aiAlgid, &dwHashLen, 0)) return FALSE; + if (!RSAENH_CPGetHashParam(hProv, hHash, HP_ALGID, (BYTE*)&aiAlgid, &dwHashLen, 0)) goto out; dwHashLen = RSAENH_MAX_HASH_SIZE; - if (!RSAENH_CPGetHashParam(hProv, hHash, HP_HASHVAL, abHashValue, &dwHashLen, 0)) return FALSE; + if (!RSAENH_CPGetHashParam(hProv, hHash, HP_HASHVAL, abHashValue, &dwHashLen, 0)) goto out; if (!build_hash_signature(pbSignature, *pdwSigLen, aiAlgid, abHashValue, dwHashLen, dwFlags)) { - return FALSE; + goto out; } - return encrypt_block_impl(pCryptKey->aiAlgid, PK_PRIVATE, &pCryptKey->context, pbSignature, pbSignature, RSAENH_ENCRYPT); + ret = encrypt_block_impl(pCryptKey->aiAlgid, PK_PRIVATE, &pCryptKey->context, pbSignature, pbSignature, RSAENH_ENCRYPT); +out: + RSAENH_CPDestroyKey(hProv, hCryptKey); + return ret; } /****************************************************************************** From 7473d1aab341e8c2fbbbda8808cd4e5f7bff5160 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 4 Mar 2010 13:46:14 +0000 Subject: [PATCH 082/211] [WIDL] - Sync to Wine-1.1.39 svn path=/trunk/; revision=45833 --- reactos/media/doc/README.WINE | 2 +- reactos/tools/widl/expr.c | 28 +- reactos/tools/widl/header.c | 20 +- reactos/tools/widl/header.h | 2 +- reactos/tools/widl/parser.h | 2 + reactos/tools/widl/parser.l | 16 +- reactos/tools/widl/parser.tab.c | 2648 +++++++++++++++---------------- reactos/tools/widl/parser.tab.h | 291 ++-- reactos/tools/widl/parser.y | 9 +- reactos/tools/widl/parser.yy.c | 526 +++--- reactos/tools/widl/proxy.c | 6 +- reactos/tools/widl/typegen.c | 10 +- reactos/tools/widl/widl.c | 41 +- reactos/tools/widl/widltypes.h | 1 + 14 files changed, 1832 insertions(+), 1770 deletions(-) diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 59e7c9ff719..729128b4389 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -22,7 +22,7 @@ When porting a new DLL from Wine to ReactOS, please do the following steps The following build tools are shared with Wine. reactos/tools/unicode # Synced to Wine-20081105 (~Wine-1.1.7) -reactos/tools/widl # Synced to Wine-1_1_32 +reactos/tools/widl # Synced to Wine-1_1_39 reactos/tools/winebuild # Synced to Wine-1_1_13 reactos/tools/wmc # Synced to Wine-20081105 (~Wine-1.1.7) reactos/tools/wpp # Synced to Wine-20081105 (~Wine-1.1.7) diff --git a/reactos/tools/widl/expr.c b/reactos/tools/widl/expr.c index b5283767288..bca7c5a3e91 100644 --- a/reactos/tools/widl/expr.c +++ b/reactos/tools/widl/expr.c @@ -87,7 +87,9 @@ expr_t *make_exprs(enum expr_type type, char *val) e->u.sval = val; e->is_const = FALSE; /* check for predefined constants */ - if (type == EXPR_IDENTIFIER) + switch (type) + { + case EXPR_IDENTIFIER: { var_t *c = find_const(val, 0); if (c) @@ -97,6 +99,21 @@ expr_t *make_exprs(enum expr_type type, char *val) e->is_const = TRUE; e->cval = c->eval->cval; } + break; + } + case EXPR_CHARCONST: + if (!val[0]) + error_loc("empty character constant\n"); + else if (val[1]) + error_loc("multi-character constants are endian dependent\n"); + else + { + e->is_const = TRUE; + e->cval = *val; + } + break; + default: + break; } return e; } @@ -457,6 +474,11 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc result.is_temporary = TRUE; result.type = type_new_pointer(RPC_FC_UP, type_new_int(TYPE_BASIC_WCHAR, 0), NULL); break; + case EXPR_CHARCONST: + result.is_variable = FALSE; + result.is_temporary = TRUE; + result.type = type_new_int(TYPE_BASIC_CHAR, 0); + break; case EXPR_DOUBLE: result.is_variable = FALSE; result.is_temporary = TRUE; @@ -655,6 +677,9 @@ void write_expr(FILE *h, const expr_t *e, int brackets, case EXPR_WSTRLIT: fprintf(h, "L\"%s\"", e->u.sval); break; + case EXPR_CHARCONST: + fprintf(h, "'%s'", e->u.sval); + break; case EXPR_LOGNOT: fprintf(h, "!"); write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); @@ -804,6 +829,7 @@ int compare_expr(const expr_t *a, const expr_t *b) case EXPR_IDENTIFIER: case EXPR_STRLIT: case EXPR_WSTRLIT: + case EXPR_CHARCONST: return strcmp(a->u.sval, b->u.sval); case EXPR_COND: ret = compare_expr(a->ref, b->ref); diff --git a/reactos/tools/widl/header.c b/reactos/tools/widl/header.c index e87a44e9077..5602b6da572 100644 --- a/reactos/tools/widl/header.c +++ b/reactos/tools/widl/header.c @@ -254,6 +254,7 @@ void write_type_left(FILE *h, type_t *t, int declonly) break; case TYPE_BASIC: if (type_basic_get_type(t) != TYPE_BASIC_INT32 && + type_basic_get_type(t) != TYPE_BASIC_INT64 && type_basic_get_type(t) != TYPE_BASIC_HYPER) { if (type_basic_get_sign(t) < 0) fprintf(h, "signed "); @@ -264,7 +265,6 @@ void write_type_left(FILE *h, type_t *t, int declonly) case TYPE_BASIC_INT8: fprintf(h, "small"); break; case TYPE_BASIC_INT16: fprintf(h, "short"); break; case TYPE_BASIC_INT: fprintf(h, "int"); break; - case TYPE_BASIC_INT64: fprintf(h, "__int64"); break; case TYPE_BASIC_INT3264: fprintf(h, "__int3264"); break; case TYPE_BASIC_BYTE: fprintf(h, "byte"); break; case TYPE_BASIC_CHAR: fprintf(h, "char"); break; @@ -279,6 +279,12 @@ void write_type_left(FILE *h, type_t *t, int declonly) else fprintf(h, "LONG"); break; + case TYPE_BASIC_INT64: + if (type_basic_get_sign(t) > 0) + fprintf(h, "UINT64"); + else + fprintf(h, "INT64"); + break; case TYPE_BASIC_HYPER: if (type_basic_get_sign(t) > 0) fprintf(h, "MIDL_uhyper"); @@ -685,10 +691,12 @@ int has_out_arg_or_return(const var_t *func) /********** INTERFACES **********/ -int is_object(const attr_list_t *list) +int is_object(const type_t *iface) { const attr_t *attr; - if (list) LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry ) + if (type_is_defined(iface) && type_iface_get_inherit(iface)) + return 1; + if (iface->attrs) LIST_FOR_EACH_ENTRY( attr, iface->attrs, const attr_t, entry ) if (attr->type == ATTR_OBJECT || attr->type == ATTR_ODL) return 1; return 0; } @@ -860,7 +868,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body) = "/* WIDL-generated stub. You must provide an implementation for this. */"; const statement_t *stmt; - if (!is_object(iface->attrs)) + if (!is_object(iface)) return; STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { @@ -1174,7 +1182,7 @@ static void write_forward_decls(FILE *header, const statement_list_t *stmts) case STMT_TYPE: if (type_get_type(stmt->u.type) == TYPE_INTERFACE) { - if (is_object(stmt->u.type->attrs) || is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE)) + if (is_object(stmt->u.type) || is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE)) write_forward(header, stmt->u.type); } else if (type_get_type(stmt->u.type) == TYPE_COCLASS) @@ -1209,7 +1217,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons if (type_get_type(stmt->u.type) == TYPE_INTERFACE) { type_t *iface = stmt->u.type; - if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type->attrs)) + if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type)) { write_com_interface_start(header, iface); write_header_stmts(header, type_iface_get_stmts(iface), stmt->u.type, TRUE); diff --git a/reactos/tools/widl/header.h b/reactos/tools/widl/header.h index d4b3b88f32e..7d6c5439d7b 100644 --- a/reactos/tools/widl/header.h +++ b/reactos/tools/widl/header.h @@ -38,7 +38,7 @@ extern void write_type_def_or_decl(FILE *h, type_t *t, int is_field, const char extern void write_type_decl(FILE *f, type_t *t, const char *name); extern void write_type_decl_left(FILE *f, type_t *t); extern int needs_space_after(type_t *t); -extern int is_object(const attr_list_t *list); +extern int is_object(const type_t *iface); extern int is_local(const attr_list_t *list); extern int need_stub(const type_t *iface); extern int need_proxy(const type_t *iface); diff --git a/reactos/tools/widl/parser.h b/reactos/tools/widl/parser.h index 71f08dc994a..1bcc3c182f2 100644 --- a/reactos/tools/widl/parser.h +++ b/reactos/tools/widl/parser.h @@ -45,4 +45,6 @@ void pop_import(void); int is_type(const char *name); +extern char *temp_name; + #endif diff --git a/reactos/tools/widl/parser.l b/reactos/tools/widl/parser.l index f509cb19eae..0d231fc7885 100644 --- a/reactos/tools/widl/parser.l +++ b/reactos/tools/widl/parser.l @@ -37,6 +37,7 @@ double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)* %x WSTRQUOTE %x ATTR %x PP_LINE +%x SQUOTE %{ @@ -63,8 +64,6 @@ double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)* #include "parser.tab.h" -extern char *temp_name; - static void addcchar(char c); static char *get_buffered_cstring(void); @@ -157,10 +156,17 @@ UUID *parse_uuid(const char *u) parser_lval.str = get_buffered_cstring(); return aWSTRING; } -\\\\ | +\' yy_push_state(SQUOTE); cbufidx = 0; +\' { + yy_pop_state(); + parser_lval.str = get_buffered_cstring(); + return aSQSTRING; + } +\\\\ | \\\" addcchar(yytext[1]); -\\. addcchar('\\'); addcchar(yytext[1]); -. addcchar(yytext[0]); +\\\' addcchar(yytext[1]); +\\. addcchar('\\'); addcchar(yytext[1]); +. addcchar(yytext[0]); \[ yy_push_state(ATTR); return '['; \] yy_pop_state(); return ']'; {cident} return attr_token(yytext); diff --git a/reactos/tools/widl/parser.tab.c b/reactos/tools/widl/parser.tab.c index 198575fba90..cdb7eeb41a1 100644 --- a/reactos/tools/widl/parser.tab.c +++ b/reactos/tools/widl/parser.tab.c @@ -268,150 +268,151 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s aDOUBLE = 262, aSTRING = 263, aWSTRING = 264, - aUUID = 265, - aEOF = 266, - SHL = 267, - SHR = 268, - MEMBERPTR = 269, - EQUALITY = 270, - INEQUALITY = 271, - GREATEREQUAL = 272, - LESSEQUAL = 273, - LOGICALOR = 274, - LOGICALAND = 275, - ELLIPSIS = 276, - tAGGREGATABLE = 277, - tALLOCATE = 278, - tANNOTATION = 279, - tAPPOBJECT = 280, - tASYNC = 281, - tASYNCUUID = 282, - tAUTOHANDLE = 283, - tBINDABLE = 284, - tBOOLEAN = 285, - tBROADCAST = 286, - tBYTE = 287, - tBYTECOUNT = 288, - tCALLAS = 289, - tCALLBACK = 290, - tCASE = 291, - tCDECL = 292, - tCHAR = 293, - tCOCLASS = 294, - tCODE = 295, - tCOMMSTATUS = 296, - tCONST = 297, - tCONTEXTHANDLE = 298, - tCONTEXTHANDLENOSERIALIZE = 299, - tCONTEXTHANDLESERIALIZE = 300, - tCONTROL = 301, - tCPPQUOTE = 302, - tDEFAULT = 303, - tDEFAULTCOLLELEM = 304, - tDEFAULTVALUE = 305, - tDEFAULTVTABLE = 306, - tDISPLAYBIND = 307, - tDISPINTERFACE = 308, - tDLLNAME = 309, - tDOUBLE = 310, - tDUAL = 311, - tENDPOINT = 312, - tENTRY = 313, - tENUM = 314, - tERRORSTATUST = 315, - tEXPLICITHANDLE = 316, - tEXTERN = 317, - tFALSE = 318, - tFASTCALL = 319, - tFLOAT = 320, - tHANDLE = 321, - tHANDLET = 322, - tHELPCONTEXT = 323, - tHELPFILE = 324, - tHELPSTRING = 325, - tHELPSTRINGCONTEXT = 326, - tHELPSTRINGDLL = 327, - tHIDDEN = 328, - tHYPER = 329, - tID = 330, - tIDEMPOTENT = 331, - tIIDIS = 332, - tIMMEDIATEBIND = 333, - tIMPLICITHANDLE = 334, - tIMPORT = 335, - tIMPORTLIB = 336, - tIN = 337, - tIN_LINE = 338, - tINLINE = 339, - tINPUTSYNC = 340, - tINT = 341, - tINT3264 = 342, - tINT64 = 343, - tINTERFACE = 344, - tLCID = 345, - tLENGTHIS = 346, - tLIBRARY = 347, - tLOCAL = 348, - tLONG = 349, - tMETHODS = 350, - tMODULE = 351, - tNONBROWSABLE = 352, - tNONCREATABLE = 353, - tNONEXTENSIBLE = 354, - tNULL = 355, - tOBJECT = 356, - tODL = 357, - tOLEAUTOMATION = 358, - tOPTIONAL = 359, - tOUT = 360, - tPASCAL = 361, - tPOINTERDEFAULT = 362, - tPROPERTIES = 363, - tPROPGET = 364, - tPROPPUT = 365, - tPROPPUTREF = 366, - tPTR = 367, - tPUBLIC = 368, - tRANGE = 369, - tREADONLY = 370, - tREF = 371, - tREGISTER = 372, - tREQUESTEDIT = 373, - tRESTRICTED = 374, - tRETVAL = 375, - tSAFEARRAY = 376, - tSHORT = 377, - tSIGNED = 378, - tSIZEIS = 379, - tSIZEOF = 380, - tSMALL = 381, - tSOURCE = 382, - tSTATIC = 383, - tSTDCALL = 384, - tSTRICTCONTEXTHANDLE = 385, - tSTRING = 386, - tSTRUCT = 387, - tSWITCH = 388, - tSWITCHIS = 389, - tSWITCHTYPE = 390, - tTRANSMITAS = 391, - tTRUE = 392, - tTYPEDEF = 393, - tUNION = 394, - tUNIQUE = 395, - tUNSIGNED = 396, - tUUID = 397, - tV1ENUM = 398, - tVARARG = 399, - tVERSION = 400, - tVOID = 401, - tWCHAR = 402, - tWIREMARSHAL = 403, - ADDRESSOF = 404, - NEG = 405, - POS = 406, - PPTR = 407, - CAST = 408 + aSQSTRING = 265, + aUUID = 266, + aEOF = 267, + SHL = 268, + SHR = 269, + MEMBERPTR = 270, + EQUALITY = 271, + INEQUALITY = 272, + GREATEREQUAL = 273, + LESSEQUAL = 274, + LOGICALOR = 275, + LOGICALAND = 276, + ELLIPSIS = 277, + tAGGREGATABLE = 278, + tALLOCATE = 279, + tANNOTATION = 280, + tAPPOBJECT = 281, + tASYNC = 282, + tASYNCUUID = 283, + tAUTOHANDLE = 284, + tBINDABLE = 285, + tBOOLEAN = 286, + tBROADCAST = 287, + tBYTE = 288, + tBYTECOUNT = 289, + tCALLAS = 290, + tCALLBACK = 291, + tCASE = 292, + tCDECL = 293, + tCHAR = 294, + tCOCLASS = 295, + tCODE = 296, + tCOMMSTATUS = 297, + tCONST = 298, + tCONTEXTHANDLE = 299, + tCONTEXTHANDLENOSERIALIZE = 300, + tCONTEXTHANDLESERIALIZE = 301, + tCONTROL = 302, + tCPPQUOTE = 303, + tDEFAULT = 304, + tDEFAULTCOLLELEM = 305, + tDEFAULTVALUE = 306, + tDEFAULTVTABLE = 307, + tDISPLAYBIND = 308, + tDISPINTERFACE = 309, + tDLLNAME = 310, + tDOUBLE = 311, + tDUAL = 312, + tENDPOINT = 313, + tENTRY = 314, + tENUM = 315, + tERRORSTATUST = 316, + tEXPLICITHANDLE = 317, + tEXTERN = 318, + tFALSE = 319, + tFASTCALL = 320, + tFLOAT = 321, + tHANDLE = 322, + tHANDLET = 323, + tHELPCONTEXT = 324, + tHELPFILE = 325, + tHELPSTRING = 326, + tHELPSTRINGCONTEXT = 327, + tHELPSTRINGDLL = 328, + tHIDDEN = 329, + tHYPER = 330, + tID = 331, + tIDEMPOTENT = 332, + tIIDIS = 333, + tIMMEDIATEBIND = 334, + tIMPLICITHANDLE = 335, + tIMPORT = 336, + tIMPORTLIB = 337, + tIN = 338, + tIN_LINE = 339, + tINLINE = 340, + tINPUTSYNC = 341, + tINT = 342, + tINT3264 = 343, + tINT64 = 344, + tINTERFACE = 345, + tLCID = 346, + tLENGTHIS = 347, + tLIBRARY = 348, + tLOCAL = 349, + tLONG = 350, + tMETHODS = 351, + tMODULE = 352, + tNONBROWSABLE = 353, + tNONCREATABLE = 354, + tNONEXTENSIBLE = 355, + tNULL = 356, + tOBJECT = 357, + tODL = 358, + tOLEAUTOMATION = 359, + tOPTIONAL = 360, + tOUT = 361, + tPASCAL = 362, + tPOINTERDEFAULT = 363, + tPROPERTIES = 364, + tPROPGET = 365, + tPROPPUT = 366, + tPROPPUTREF = 367, + tPTR = 368, + tPUBLIC = 369, + tRANGE = 370, + tREADONLY = 371, + tREF = 372, + tREGISTER = 373, + tREQUESTEDIT = 374, + tRESTRICTED = 375, + tRETVAL = 376, + tSAFEARRAY = 377, + tSHORT = 378, + tSIGNED = 379, + tSIZEIS = 380, + tSIZEOF = 381, + tSMALL = 382, + tSOURCE = 383, + tSTATIC = 384, + tSTDCALL = 385, + tSTRICTCONTEXTHANDLE = 386, + tSTRING = 387, + tSTRUCT = 388, + tSWITCH = 389, + tSWITCHIS = 390, + tSWITCHTYPE = 391, + tTRANSMITAS = 392, + tTRUE = 393, + tTYPEDEF = 394, + tUNION = 395, + tUNIQUE = 396, + tUNSIGNED = 397, + tUUID = 398, + tV1ENUM = 399, + tVARARG = 400, + tVERSION = 401, + tVOID = 402, + tWCHAR = 403, + tWIREMARSHAL = 404, + ADDRESSOF = 405, + NEG = 406, + POS = 407, + PPTR = 408, + CAST = 409 }; #endif @@ -454,7 +455,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 458 "parser.tab.c" +#line 459 "parser.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -466,7 +467,7 @@ typedef union YYSTYPE /* Line 264 of yacc.c */ -#line 470 "parser.tab.c" +#line 471 "parser.tab.c" #ifdef short # undef short @@ -681,20 +682,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 2392 +#define YYLAST 2343 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 178 +#define YYNTOKENS 179 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 99 /* YYNRULES -- Number of rules. */ -#define YYNRULES 344 +#define YYNRULES 345 /* YYNRULES -- Number of states. */ -#define YYNSTATES 606 +#define YYNSTATES 607 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 408 +#define YYMAXUTOK 409 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -705,16 +706,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 162, 2, 2, 2, 161, 154, 2, - 173, 174, 159, 158, 149, 157, 169, 160, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 151, 172, - 155, 177, 156, 150, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 163, 2, 2, 2, 162, 155, 2, + 174, 175, 160, 159, 150, 158, 170, 161, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 152, 173, + 156, 178, 157, 151, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 170, 2, 171, 153, 2, 2, 2, 2, 2, + 2, 171, 2, 172, 154, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 175, 152, 176, 163, 2, 2, 2, + 2, 2, 2, 176, 153, 177, 164, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -742,7 +743,7 @@ static const yytype_uint8 yytranslate[] = 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 164, 165, 166, 167, 168 + 145, 146, 147, 148, 149, 165, 166, 167, 168, 169 }; #if YYDEBUG @@ -766,135 +767,135 @@ static const yytype_uint16 yyprhs[] = 388, 393, 398, 400, 402, 404, 406, 408, 410, 412, 413, 416, 421, 425, 426, 429, 431, 433, 437, 441, 443, 449, 451, 455, 456, 458, 460, 462, 464, 466, - 468, 470, 472, 474, 476, 482, 486, 490, 494, 498, - 502, 506, 510, 514, 518, 522, 526, 530, 534, 538, - 542, 546, 550, 554, 557, 560, 563, 566, 569, 572, - 576, 580, 586, 592, 597, 601, 603, 607, 609, 611, - 612, 615, 620, 624, 627, 630, 631, 634, 637, 639, - 643, 647, 651, 654, 655, 657, 658, 660, 662, 664, - 666, 668, 670, 672, 675, 678, 680, 682, 684, 686, - 688, 690, 691, 693, 695, 698, 700, 703, 706, 708, - 710, 712, 715, 718, 721, 727, 728, 731, 734, 737, - 740, 743, 746, 750, 753, 757, 763, 769, 770, 773, - 776, 779, 782, 789, 798, 801, 804, 807, 810, 813, - 816, 822, 824, 826, 828, 830, 832, 833, 836, 839, - 843, 844, 846, 849, 852, 855, 859, 862, 864, 866, - 870, 873, 878, 882, 885, 887, 891, 894, 895, 897, - 901, 904, 906, 910, 915, 919, 922, 924, 928, 931, - 932, 934, 936, 940, 943, 945, 949, 954, 956, 960, - 961, 964, 967, 969, 973, 975, 979, 981, 983, 985, - 991, 993, 995, 997, 999, 1002, 1004, 1007, 1009, 1012, - 1017, 1022, 1028, 1039, 1041 + 468, 470, 472, 474, 476, 478, 484, 488, 492, 496, + 500, 504, 508, 512, 516, 520, 524, 528, 532, 536, + 540, 544, 548, 552, 556, 559, 562, 565, 568, 571, + 574, 578, 582, 588, 594, 599, 603, 605, 609, 611, + 613, 614, 617, 622, 626, 629, 632, 633, 636, 639, + 641, 645, 649, 653, 656, 657, 659, 660, 662, 664, + 666, 668, 670, 672, 674, 677, 680, 682, 684, 686, + 688, 690, 692, 693, 695, 697, 700, 702, 705, 708, + 710, 712, 714, 717, 720, 723, 729, 730, 733, 736, + 739, 742, 745, 748, 752, 755, 759, 765, 771, 772, + 775, 778, 781, 784, 791, 800, 803, 806, 809, 812, + 815, 818, 824, 826, 828, 830, 832, 834, 835, 838, + 841, 845, 846, 848, 851, 854, 857, 861, 864, 866, + 868, 872, 875, 880, 884, 887, 889, 893, 896, 897, + 899, 903, 906, 908, 912, 917, 921, 924, 926, 930, + 933, 934, 936, 938, 942, 945, 947, 951, 956, 958, + 962, 963, 966, 969, 971, 975, 977, 981, 983, 985, + 987, 993, 995, 997, 999, 1001, 1004, 1006, 1009, 1011, + 1014, 1019, 1024, 1030, 1041, 1043 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 179, 0, -1, 180, -1, -1, 180, 245, -1, 180, - 244, -1, 180, 231, 172, -1, 180, 233, -1, 180, - 248, -1, 180, 192, -1, 180, 184, -1, -1, 181, - 245, -1, 181, 244, -1, 181, 231, 172, -1, 181, - 233, -1, 181, 248, -1, 181, 184, -1, 181, 189, - -1, 181, 192, -1, -1, 182, 184, -1, -1, 172, - -1, 186, -1, 185, 172, -1, 224, 172, -1, 188, - -1, 274, 172, -1, 210, -1, 272, -1, 275, -1, - 199, 210, -1, 199, 272, -1, 199, 275, -1, 47, - 173, 8, 174, -1, 80, 8, 172, -1, 187, 181, - 11, -1, 81, 173, 8, 174, 183, -1, 92, 3, - -1, 199, 190, 175, -1, 191, 181, 176, 183, -1, - -1, 195, -1, 196, -1, 194, 149, 196, -1, 194, - -1, 194, 149, 21, -1, 199, 253, 264, -1, 253, - 264, -1, 170, 212, 171, -1, 170, 159, 171, -1, - -1, 199, -1, 170, 200, 171, -1, 202, -1, 200, - 149, 202, -1, 200, 171, 170, 202, -1, 8, -1, - 201, 149, 8, -1, -1, 22, -1, 24, 173, 8, - 174, -1, 25, -1, 26, -1, 28, -1, 29, -1, - 31, -1, 34, 173, 227, 174, -1, 36, 173, 214, - 174, -1, 43, -1, 44, -1, 45, -1, 46, -1, - 48, -1, 49, -1, 50, 173, 216, 174, -1, 51, - -1, 52, -1, 54, 173, 8, 174, -1, 56, -1, - 57, 173, 201, 174, -1, 58, 173, 216, 174, -1, - 61, -1, 66, -1, 68, 173, 215, 174, -1, 69, - 173, 8, 174, -1, 70, 173, 8, 174, -1, 71, - 173, 215, 174, -1, 72, 173, 8, 174, -1, 73, - -1, 75, 173, 215, 174, -1, 76, -1, 77, 173, - 213, 174, -1, 78, -1, 79, 173, 67, 3, 174, - -1, 82, -1, 85, -1, 91, 173, 211, 174, -1, - 90, 173, 215, 174, -1, 90, -1, 93, -1, 97, - -1, 98, -1, 99, -1, 101, -1, 102, -1, 103, - -1, 104, -1, 105, -1, 107, 173, 271, 174, -1, - 109, -1, 110, -1, 111, -1, 113, -1, 114, 173, - 215, 149, 215, 174, -1, 115, -1, 118, -1, 119, - -1, 120, -1, 124, 173, 211, 174, -1, 127, -1, - 130, -1, 131, -1, 134, 173, 213, 174, -1, 135, - 173, 273, 174, -1, 136, 173, 273, 174, -1, 142, - 173, 203, 174, -1, 143, -1, 144, -1, 145, 173, - 276, 174, -1, 148, 173, 273, 174, -1, 271, -1, - 10, -1, 8, -1, 37, -1, 64, -1, 106, -1, - 129, -1, -1, 205, 206, -1, 36, 215, 151, 221, - -1, 48, 151, 221, -1, -1, 208, 149, -1, 208, - -1, 209, -1, 208, 149, 209, -1, 227, 177, 215, - -1, 227, -1, 59, 226, 175, 207, 176, -1, 212, - -1, 211, 149, 212, -1, -1, 213, -1, 5, -1, - 6, -1, 7, -1, 63, -1, 100, -1, 137, -1, - 8, -1, 9, -1, 3, -1, 213, 150, 213, 151, - 213, -1, 213, 19, 213, -1, 213, 20, 213, -1, - 213, 152, 213, -1, 213, 153, 213, -1, 213, 154, - 213, -1, 213, 15, 213, -1, 213, 16, 213, -1, - 213, 156, 213, -1, 213, 155, 213, -1, 213, 17, - 213, -1, 213, 18, 213, -1, 213, 12, 213, -1, - 213, 13, 213, -1, 213, 158, 213, -1, 213, 157, - 213, -1, 213, 161, 213, -1, 213, 159, 213, -1, - 213, 160, 213, -1, 162, 213, -1, 163, 213, -1, - 158, 213, -1, 157, 213, -1, 154, 213, -1, 159, - 213, -1, 213, 14, 3, -1, 213, 169, 3, -1, - 173, 253, 260, 174, 213, -1, 125, 173, 253, 260, - 174, -1, 213, 170, 213, 171, -1, 173, 213, 174, - -1, 215, -1, 214, 149, 215, -1, 213, -1, 213, - -1, -1, 217, 218, -1, 198, 253, 269, 172, -1, - 198, 275, 172, -1, 222, 172, -1, 199, 172, -1, - -1, 220, 219, -1, 222, 172, -1, 172, -1, 198, - 253, 256, -1, 198, 253, 256, -1, 199, 253, 270, - -1, 253, 270, -1, -1, 227, -1, -1, 3, -1, - 4, -1, 3, -1, 4, -1, 32, -1, 147, -1, - 230, -1, 123, 230, -1, 141, 230, -1, 141, -1, - 65, -1, 55, -1, 30, -1, 60, -1, 67, -1, - -1, 86, -1, 86, -1, 122, 229, -1, 126, -1, - 94, 229, -1, 74, 229, -1, 88, -1, 38, -1, - 87, -1, 39, 3, -1, 39, 4, -1, 199, 231, - -1, 232, 175, 234, 176, 183, -1, -1, 234, 235, - -1, 198, 245, -1, 53, 3, -1, 53, 4, -1, - 199, 236, -1, 108, 151, -1, 238, 222, 172, -1, - 95, 151, -1, 239, 223, 172, -1, 237, 175, 238, - 239, 176, -1, 237, 175, 242, 172, 176, -1, -1, - 151, 4, -1, 89, 3, -1, 89, 4, -1, 199, - 242, -1, 243, 241, 175, 182, 176, 183, -1, 243, - 151, 3, 175, 188, 182, 176, 183, -1, 240, 183, - -1, 242, 172, -1, 236, 172, -1, 96, 3, -1, - 96, 4, -1, 199, 246, -1, 247, 175, 182, 176, - 183, -1, 62, -1, 128, -1, 117, -1, 84, -1, - 42, -1, -1, 252, 251, -1, 273, 254, -1, 255, - 273, 254, -1, -1, 255, -1, 251, 254, -1, 250, - 254, -1, 249, 254, -1, 159, 252, 256, -1, 204, - 256, -1, 257, -1, 227, -1, 173, 256, 174, -1, - 257, 197, -1, 257, 173, 193, 174, -1, 159, 252, - 260, -1, 204, 260, -1, 261, -1, 159, 252, 264, - -1, 204, 264, -1, -1, 258, -1, 173, 259, 174, - -1, 261, 197, -1, 197, -1, 173, 193, 174, -1, - 261, 173, 193, 174, -1, 159, 252, 264, -1, 204, - 264, -1, 265, -1, 159, 252, 264, -1, 204, 264, - -1, -1, 262, -1, 227, -1, 173, 263, 174, -1, - 265, 197, -1, 197, -1, 173, 193, 174, -1, 265, - 173, 193, 174, -1, 256, -1, 266, 149, 256, -1, - -1, 151, 216, -1, 262, 267, -1, 268, -1, 269, - 149, 268, -1, 256, -1, 256, 177, 216, -1, 116, - -1, 140, -1, 112, -1, 132, 226, 175, 217, 176, - -1, 146, -1, 4, -1, 228, -1, 210, -1, 59, - 3, -1, 272, -1, 132, 3, -1, 275, -1, 139, - 3, -1, 121, 173, 273, 174, -1, 138, 198, 253, - 266, -1, 139, 226, 175, 220, 176, -1, 139, 226, - 133, 173, 222, 174, 225, 175, 205, 176, -1, 5, - -1, 5, 169, 5, -1 + 180, 0, -1, 181, -1, -1, 181, 246, -1, 181, + 245, -1, 181, 232, 173, -1, 181, 234, -1, 181, + 249, -1, 181, 193, -1, 181, 185, -1, -1, 182, + 246, -1, 182, 245, -1, 182, 232, 173, -1, 182, + 234, -1, 182, 249, -1, 182, 185, -1, 182, 190, + -1, 182, 193, -1, -1, 183, 185, -1, -1, 173, + -1, 187, -1, 186, 173, -1, 225, 173, -1, 189, + -1, 275, 173, -1, 211, -1, 273, -1, 276, -1, + 200, 211, -1, 200, 273, -1, 200, 276, -1, 48, + 174, 8, 175, -1, 81, 8, 173, -1, 188, 182, + 12, -1, 82, 174, 8, 175, 184, -1, 93, 3, + -1, 200, 191, 176, -1, 192, 182, 177, 184, -1, + -1, 196, -1, 197, -1, 195, 150, 197, -1, 195, + -1, 195, 150, 22, -1, 200, 254, 265, -1, 254, + 265, -1, 171, 213, 172, -1, 171, 160, 172, -1, + -1, 200, -1, 171, 201, 172, -1, 203, -1, 201, + 150, 203, -1, 201, 172, 171, 203, -1, 8, -1, + 202, 150, 8, -1, -1, 23, -1, 25, 174, 8, + 175, -1, 26, -1, 27, -1, 29, -1, 30, -1, + 32, -1, 35, 174, 228, 175, -1, 37, 174, 215, + 175, -1, 44, -1, 45, -1, 46, -1, 47, -1, + 49, -1, 50, -1, 51, 174, 217, 175, -1, 52, + -1, 53, -1, 55, 174, 8, 175, -1, 57, -1, + 58, 174, 202, 175, -1, 59, 174, 217, 175, -1, + 62, -1, 67, -1, 69, 174, 216, 175, -1, 70, + 174, 8, 175, -1, 71, 174, 8, 175, -1, 72, + 174, 216, 175, -1, 73, 174, 8, 175, -1, 74, + -1, 76, 174, 216, 175, -1, 77, -1, 78, 174, + 214, 175, -1, 79, -1, 80, 174, 68, 3, 175, + -1, 83, -1, 86, -1, 92, 174, 212, 175, -1, + 91, 174, 216, 175, -1, 91, -1, 94, -1, 98, + -1, 99, -1, 100, -1, 102, -1, 103, -1, 104, + -1, 105, -1, 106, -1, 108, 174, 272, 175, -1, + 110, -1, 111, -1, 112, -1, 114, -1, 115, 174, + 216, 150, 216, 175, -1, 116, -1, 119, -1, 120, + -1, 121, -1, 125, 174, 212, 175, -1, 128, -1, + 131, -1, 132, -1, 135, 174, 214, 175, -1, 136, + 174, 274, 175, -1, 137, 174, 274, 175, -1, 143, + 174, 204, 175, -1, 144, -1, 145, -1, 146, 174, + 277, 175, -1, 149, 174, 274, 175, -1, 272, -1, + 11, -1, 8, -1, 38, -1, 65, -1, 107, -1, + 130, -1, -1, 206, 207, -1, 37, 216, 152, 222, + -1, 49, 152, 222, -1, -1, 209, 150, -1, 209, + -1, 210, -1, 209, 150, 210, -1, 228, 178, 216, + -1, 228, -1, 60, 227, 176, 208, 177, -1, 213, + -1, 212, 150, 213, -1, -1, 214, -1, 5, -1, + 6, -1, 7, -1, 64, -1, 101, -1, 138, -1, + 8, -1, 9, -1, 10, -1, 3, -1, 214, 151, + 214, 152, 214, -1, 214, 20, 214, -1, 214, 21, + 214, -1, 214, 153, 214, -1, 214, 154, 214, -1, + 214, 155, 214, -1, 214, 16, 214, -1, 214, 17, + 214, -1, 214, 157, 214, -1, 214, 156, 214, -1, + 214, 18, 214, -1, 214, 19, 214, -1, 214, 13, + 214, -1, 214, 14, 214, -1, 214, 159, 214, -1, + 214, 158, 214, -1, 214, 162, 214, -1, 214, 160, + 214, -1, 214, 161, 214, -1, 163, 214, -1, 164, + 214, -1, 159, 214, -1, 158, 214, -1, 155, 214, + -1, 160, 214, -1, 214, 15, 3, -1, 214, 170, + 3, -1, 174, 254, 261, 175, 214, -1, 126, 174, + 254, 261, 175, -1, 214, 171, 214, 172, -1, 174, + 214, 175, -1, 216, -1, 215, 150, 216, -1, 214, + -1, 214, -1, -1, 218, 219, -1, 199, 254, 270, + 173, -1, 199, 276, 173, -1, 223, 173, -1, 200, + 173, -1, -1, 221, 220, -1, 223, 173, -1, 173, + -1, 199, 254, 257, -1, 199, 254, 257, -1, 200, + 254, 271, -1, 254, 271, -1, -1, 228, -1, -1, + 3, -1, 4, -1, 3, -1, 4, -1, 33, -1, + 148, -1, 231, -1, 124, 231, -1, 142, 231, -1, + 142, -1, 66, -1, 56, -1, 31, -1, 61, -1, + 68, -1, -1, 87, -1, 87, -1, 123, 230, -1, + 127, -1, 95, 230, -1, 75, 230, -1, 89, -1, + 39, -1, 88, -1, 40, 3, -1, 40, 4, -1, + 200, 232, -1, 233, 176, 235, 177, 184, -1, -1, + 235, 236, -1, 199, 246, -1, 54, 3, -1, 54, + 4, -1, 200, 237, -1, 109, 152, -1, 239, 223, + 173, -1, 96, 152, -1, 240, 224, 173, -1, 238, + 176, 239, 240, 177, -1, 238, 176, 243, 173, 177, + -1, -1, 152, 4, -1, 90, 3, -1, 90, 4, + -1, 200, 243, -1, 244, 242, 176, 183, 177, 184, + -1, 244, 152, 3, 176, 189, 183, 177, 184, -1, + 241, 184, -1, 243, 173, -1, 237, 173, -1, 97, + 3, -1, 97, 4, -1, 200, 247, -1, 248, 176, + 183, 177, 184, -1, 63, -1, 129, -1, 118, -1, + 85, -1, 43, -1, -1, 253, 252, -1, 274, 255, + -1, 256, 274, 255, -1, -1, 256, -1, 252, 255, + -1, 251, 255, -1, 250, 255, -1, 160, 253, 257, + -1, 205, 257, -1, 258, -1, 228, -1, 174, 257, + 175, -1, 258, 198, -1, 258, 174, 194, 175, -1, + 160, 253, 261, -1, 205, 261, -1, 262, -1, 160, + 253, 265, -1, 205, 265, -1, -1, 259, -1, 174, + 260, 175, -1, 262, 198, -1, 198, -1, 174, 194, + 175, -1, 262, 174, 194, 175, -1, 160, 253, 265, + -1, 205, 265, -1, 266, -1, 160, 253, 265, -1, + 205, 265, -1, -1, 263, -1, 228, -1, 174, 264, + 175, -1, 266, 198, -1, 198, -1, 174, 194, 175, + -1, 266, 174, 194, 175, -1, 257, -1, 267, 150, + 257, -1, -1, 152, 217, -1, 263, 268, -1, 269, + -1, 270, 150, 269, -1, 257, -1, 257, 178, 217, + -1, 117, -1, 141, -1, 113, -1, 133, 227, 176, + 218, 177, -1, 147, -1, 4, -1, 229, -1, 211, + -1, 60, 3, -1, 273, -1, 133, 3, -1, 276, + -1, 140, 3, -1, 122, 174, 274, 175, -1, 139, + 199, 254, 267, -1, 140, 227, 176, 221, 177, -1, + 140, 227, 134, 174, 223, 175, 226, 176, 206, 177, + -1, 5, -1, 5, 170, 5, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -919,22 +920,22 @@ static const yytype_uint16 yyrline[] = 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, - 662, 663, 665, 667, 668, 671, 672, 675, 681, 687, - 688, 691, 696, 703, 704, 707, 708, 712, 713, 716, - 723, 732, 736, 741, 742, 745, 746, 747, 750, 752, - 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, - 765, 768, 769, 772, 773, 774, 775, 776, 777, 778, - 779, 782, 783, 791, 797, 801, 802, 806, 809, 810, - 813, 823, 824, 827, 828, 831, 837, 843, 844, 847, - 848, 851, 862, 869, 875, 879, 880, 883, 884, 887, - 892, 899, 900, 901, 905, 909, 912, 913, 916, 917, - 921, 922, 926, 927, 928, 932, 934, 935, 939, 940, - 941, 942, 950, 952, 953, 958, 960, 964, 965, 970, - 971, 972, 973, 978, 987, 989, 990, 995, 997, 1001, - 1002, 1009, 1010, 1011, 1012, 1013, 1018, 1026, 1027, 1030, - 1031, 1034, 1041, 1042, 1047, 1048, 1052, 1053, 1054, 1057, - 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, - 1072, 1078, 1080, 1086, 1087 + 662, 663, 664, 666, 668, 669, 672, 673, 676, 682, + 688, 689, 692, 697, 704, 705, 708, 709, 713, 714, + 717, 724, 733, 737, 742, 743, 746, 747, 748, 751, + 753, 756, 757, 758, 759, 760, 761, 762, 763, 764, + 765, 766, 769, 770, 773, 774, 775, 776, 777, 778, + 779, 780, 783, 784, 792, 798, 802, 803, 807, 810, + 811, 814, 824, 825, 828, 829, 832, 838, 844, 845, + 848, 849, 852, 863, 870, 876, 880, 881, 884, 885, + 888, 893, 900, 901, 902, 906, 910, 913, 914, 917, + 918, 922, 923, 927, 928, 929, 933, 935, 936, 940, + 941, 942, 943, 951, 953, 954, 959, 961, 965, 966, + 971, 972, 973, 974, 979, 988, 990, 991, 996, 998, + 1002, 1003, 1010, 1011, 1012, 1013, 1014, 1019, 1027, 1028, + 1031, 1032, 1035, 1042, 1043, 1048, 1049, 1053, 1054, 1055, + 1058, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, + 1070, 1073, 1079, 1081, 1087, 1088 }; #endif @@ -944,13 +945,13 @@ static const yytype_uint16 yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "aIDENTIFIER", "aKNOWNTYPE", "aNUM", - "aHEXNUM", "aDOUBLE", "aSTRING", "aWSTRING", "aUUID", "aEOF", "SHL", - "SHR", "MEMBERPTR", "EQUALITY", "INEQUALITY", "GREATEREQUAL", - "LESSEQUAL", "LOGICALOR", "LOGICALAND", "ELLIPSIS", "tAGGREGATABLE", - "tALLOCATE", "tANNOTATION", "tAPPOBJECT", "tASYNC", "tASYNCUUID", - "tAUTOHANDLE", "tBINDABLE", "tBOOLEAN", "tBROADCAST", "tBYTE", - "tBYTECOUNT", "tCALLAS", "tCALLBACK", "tCASE", "tCDECL", "tCHAR", - "tCOCLASS", "tCODE", "tCOMMSTATUS", "tCONST", "tCONTEXTHANDLE", + "aHEXNUM", "aDOUBLE", "aSTRING", "aWSTRING", "aSQSTRING", "aUUID", + "aEOF", "SHL", "SHR", "MEMBERPTR", "EQUALITY", "INEQUALITY", + "GREATEREQUAL", "LESSEQUAL", "LOGICALOR", "LOGICALAND", "ELLIPSIS", + "tAGGREGATABLE", "tALLOCATE", "tANNOTATION", "tAPPOBJECT", "tASYNC", + "tASYNCUUID", "tAUTOHANDLE", "tBINDABLE", "tBOOLEAN", "tBROADCAST", + "tBYTE", "tBYTECOUNT", "tCALLAS", "tCALLBACK", "tCASE", "tCDECL", + "tCHAR", "tCOCLASS", "tCODE", "tCOMMSTATUS", "tCONST", "tCONTEXTHANDLE", "tCONTEXTHANDLENOSERIALIZE", "tCONTEXTHANDLESERIALIZE", "tCONTROL", "tCPPQUOTE", "tDEFAULT", "tDEFAULTCOLLELEM", "tDEFAULTVALUE", "tDEFAULTVTABLE", "tDISPLAYBIND", "tDISPINTERFACE", "tDLLNAME", @@ -1019,51 +1020,51 @@ static const yytype_uint16 yytoknum[] = 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 397, 398, 399, 400, 401, 402, 403, 44, - 63, 58, 124, 94, 38, 60, 62, 45, 43, 42, - 47, 37, 33, 126, 404, 405, 406, 407, 408, 46, - 91, 93, 59, 40, 41, 123, 125, 61 + 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, + 44, 63, 58, 124, 94, 38, 60, 62, 45, 43, + 42, 47, 37, 33, 126, 405, 406, 407, 408, 409, + 46, 91, 93, 59, 40, 41, 123, 125, 61 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { - 0, 178, 179, 180, 180, 180, 180, 180, 180, 180, - 180, 181, 181, 181, 181, 181, 181, 181, 181, 181, - 182, 182, 183, 183, 184, 184, 184, 184, 184, 185, - 185, 185, 185, 185, 185, 186, 187, 188, 189, 190, - 191, 192, 193, 193, 194, 194, 195, 195, 196, 196, - 197, 197, 198, 198, 199, 200, 200, 200, 201, 201, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 202, 202, 202, 203, 203, 204, 204, 204, 204, 205, - 205, 206, 206, 207, 207, 207, 208, 208, 209, 209, - 210, 211, 211, 212, 212, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 213, 214, 214, 215, 216, 217, - 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, - 223, 224, 224, 225, 225, 226, 226, 226, 227, 227, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 229, 229, 230, 230, 230, 230, 230, 230, 230, - 230, 231, 231, 232, 233, 234, 234, 235, 236, 236, - 237, 238, 238, 239, 239, 240, 240, 241, 241, 242, - 242, 243, 244, 244, 244, 245, 245, 246, 246, 247, - 248, 249, 249, 249, 250, 251, 252, 252, 253, 253, - 254, 254, 255, 255, 255, 256, 256, 256, 257, 257, - 257, 257, 258, 258, 258, 259, 259, 260, 260, 261, - 261, 261, 261, 261, 262, 262, 262, 263, 263, 264, - 264, 265, 265, 265, 265, 265, 265, 266, 266, 267, - 267, 268, 269, 269, 270, 270, 271, 271, 271, 272, - 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - 274, 275, 275, 276, 276 + 0, 179, 180, 181, 181, 181, 181, 181, 181, 181, + 181, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 183, 183, 184, 184, 185, 185, 185, 185, 185, 186, + 186, 186, 186, 186, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 194, 195, 195, 196, 196, 197, 197, + 198, 198, 199, 199, 200, 201, 201, 201, 202, 202, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 204, 204, 205, 205, 205, 205, 206, + 206, 207, 207, 208, 208, 208, 209, 209, 210, 210, + 211, 212, 212, 213, 213, 214, 214, 214, 214, 214, + 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, + 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, + 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, + 214, 214, 214, 214, 214, 214, 215, 215, 216, 217, + 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, + 223, 224, 225, 225, 226, 226, 227, 227, 227, 228, + 228, 229, 229, 229, 229, 229, 229, 229, 229, 229, + 229, 229, 230, 230, 231, 231, 231, 231, 231, 231, + 231, 231, 232, 232, 233, 234, 235, 235, 236, 237, + 237, 238, 239, 239, 240, 240, 241, 241, 242, 242, + 243, 243, 244, 245, 245, 245, 246, 246, 247, 247, + 248, 249, 250, 250, 250, 251, 252, 253, 253, 254, + 254, 255, 255, 256, 256, 256, 257, 257, 257, 258, + 258, 258, 258, 259, 259, 259, 260, 260, 261, 261, + 262, 262, 262, 262, 262, 263, 263, 263, 264, 264, + 265, 265, 266, 266, 266, 266, 266, 266, 267, 267, + 268, 268, 269, 270, 270, 271, 271, 272, 272, 272, + 273, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 275, 276, 276, 277, 277 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -1085,25 +1086,25 @@ static const yytype_uint8 yyr2[] = 4, 4, 1, 1, 1, 1, 1, 1, 1, 0, 2, 4, 3, 0, 2, 1, 1, 3, 3, 1, 5, 1, 3, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 5, 3, 3, 3, 3, 3, + 1, 1, 1, 1, 1, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 2, 2, 2, 2, 2, 3, - 3, 5, 5, 4, 3, 1, 3, 1, 1, 0, - 2, 4, 3, 2, 2, 0, 2, 2, 1, 3, - 3, 3, 2, 0, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 2, 1, 2, 2, 1, 1, - 1, 2, 2, 2, 5, 0, 2, 2, 2, 2, - 2, 2, 3, 2, 3, 5, 5, 0, 2, 2, - 2, 2, 6, 8, 2, 2, 2, 2, 2, 2, - 5, 1, 1, 1, 1, 1, 0, 2, 2, 3, - 0, 1, 2, 2, 2, 3, 2, 1, 1, 3, - 2, 4, 3, 2, 1, 3, 2, 0, 1, 3, - 2, 1, 3, 4, 3, 2, 1, 3, 2, 0, - 1, 1, 3, 2, 1, 3, 4, 1, 3, 0, - 2, 2, 1, 3, 1, 3, 1, 1, 1, 5, - 1, 1, 1, 1, 2, 1, 2, 1, 2, 4, - 4, 5, 10, 1, 3 + 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, + 3, 3, 5, 5, 4, 3, 1, 3, 1, 1, + 0, 2, 4, 3, 2, 2, 0, 2, 2, 1, + 3, 3, 3, 2, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, + 1, 1, 0, 1, 1, 2, 1, 2, 2, 1, + 1, 1, 2, 2, 2, 5, 0, 2, 2, 2, + 2, 2, 2, 3, 2, 3, 5, 5, 0, 2, + 2, 2, 2, 6, 8, 2, 2, 2, 2, 2, + 2, 5, 1, 1, 1, 1, 1, 0, 2, 2, + 3, 0, 1, 2, 2, 2, 3, 2, 1, 1, + 3, 2, 4, 3, 2, 1, 3, 2, 0, 1, + 3, 2, 1, 3, 4, 3, 2, 1, 3, 2, + 0, 1, 1, 3, 2, 1, 3, 4, 1, 3, + 0, 2, 2, 1, 3, 1, 3, 1, 1, 1, + 5, 1, 1, 1, 1, 2, 1, 2, 1, 2, + 4, 4, 5, 10, 1, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -1111,725 +1112,715 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint16 yydefact[] = { - 3, 0, 2, 1, 331, 228, 220, 239, 0, 275, - 0, 0, 227, 215, 229, 271, 226, 230, 231, 0, - 274, 233, 240, 238, 0, 231, 273, 0, 231, 0, - 235, 272, 215, 52, 215, 225, 330, 221, 60, 10, - 0, 24, 11, 27, 11, 9, 0, 333, 0, 332, - 222, 0, 0, 7, 0, 0, 22, 0, 257, 5, - 4, 0, 8, 280, 280, 280, 0, 0, 335, 280, - 0, 337, 241, 242, 0, 248, 249, 334, 217, 0, - 232, 237, 0, 259, 260, 236, 0, 234, 223, 336, - 0, 0, 53, 338, 0, 224, 61, 0, 63, 64, + 3, 0, 2, 1, 332, 229, 221, 240, 0, 276, + 0, 0, 228, 216, 230, 272, 227, 231, 232, 0, + 275, 234, 241, 239, 0, 232, 274, 0, 232, 0, + 236, 273, 216, 52, 216, 226, 331, 222, 60, 10, + 0, 24, 11, 27, 11, 9, 0, 334, 0, 333, + 223, 0, 0, 7, 0, 0, 22, 0, 258, 5, + 4, 0, 8, 281, 281, 281, 0, 0, 336, 281, + 0, 338, 242, 243, 0, 249, 250, 335, 218, 0, + 233, 238, 0, 260, 261, 237, 0, 235, 224, 337, + 0, 0, 53, 339, 0, 225, 61, 0, 63, 64, 65, 66, 67, 0, 0, 70, 71, 72, 73, 74, 75, 0, 77, 78, 0, 80, 0, 0, 83, 84, 0, 0, 0, 0, 0, 90, 0, 92, 0, 94, 0, 96, 97, 100, 0, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 0, 111, 112, 113, 328, 114, - 0, 116, 326, 117, 118, 119, 0, 121, 122, 123, - 0, 0, 0, 327, 0, 128, 129, 0, 0, 0, - 55, 132, 25, 0, 0, 0, 0, 0, 333, 243, - 250, 261, 269, 0, 335, 337, 26, 6, 245, 266, - 0, 23, 264, 265, 0, 0, 20, 284, 281, 283, - 282, 218, 219, 135, 136, 137, 138, 276, 0, 0, - 288, 324, 287, 212, 333, 335, 280, 337, 278, 28, - 0, 143, 36, 0, 199, 0, 0, 205, 0, 0, + 106, 107, 108, 109, 0, 111, 112, 113, 329, 114, + 0, 116, 327, 117, 118, 119, 0, 121, 122, 123, + 0, 0, 0, 328, 0, 128, 129, 0, 0, 0, + 55, 132, 25, 0, 0, 0, 0, 0, 334, 244, + 251, 262, 270, 0, 336, 338, 26, 6, 246, 267, + 0, 23, 265, 266, 0, 0, 20, 285, 282, 284, + 283, 219, 220, 135, 136, 137, 138, 277, 0, 0, + 289, 325, 288, 213, 334, 336, 281, 338, 279, 28, + 0, 143, 36, 0, 200, 0, 0, 206, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 153, 0, 0, 0, 0, 0, 0, 60, 54, 37, 0, 17, 18, - 19, 0, 15, 13, 12, 16, 22, 39, 267, 268, - 40, 211, 52, 0, 52, 0, 0, 258, 20, 0, - 0, 0, 286, 0, 153, 42, 290, 279, 35, 0, - 145, 146, 149, 339, 52, 317, 340, 52, 52, 0, - 0, 163, 155, 156, 157, 161, 162, 158, 159, 0, - 160, 0, 0, 0, 0, 0, 0, 0, 197, 0, - 195, 198, 0, 0, 58, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 151, 154, 0, - 0, 0, 0, 0, 0, 134, 133, 0, 343, 0, - 0, 56, 60, 0, 14, 41, 22, 0, 246, 251, - 0, 0, 0, 52, 0, 0, 0, 22, 21, 0, - 277, 285, 289, 325, 0, 0, 0, 46, 43, 44, - 0, 309, 150, 144, 0, 329, 0, 200, 0, 0, - 341, 53, 206, 0, 62, 68, 0, 187, 186, 185, - 188, 183, 184, 0, 297, 0, 0, 0, 0, 0, + 19, 0, 15, 13, 12, 16, 22, 39, 268, 269, + 40, 212, 52, 0, 52, 0, 0, 259, 20, 0, + 0, 0, 287, 0, 153, 42, 291, 280, 35, 0, + 145, 146, 149, 340, 52, 318, 341, 52, 52, 0, + 0, 164, 155, 156, 157, 161, 162, 163, 158, 159, + 0, 160, 0, 0, 0, 0, 0, 0, 0, 198, + 0, 196, 199, 0, 0, 58, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 151, 154, + 0, 0, 0, 0, 0, 0, 134, 133, 0, 344, + 0, 0, 56, 60, 0, 14, 41, 22, 0, 247, + 252, 0, 0, 0, 52, 0, 0, 0, 22, 21, + 0, 278, 286, 290, 326, 0, 0, 0, 46, 43, + 44, 0, 310, 150, 144, 0, 330, 0, 201, 0, + 0, 342, 53, 207, 0, 62, 68, 0, 188, 187, + 186, 189, 184, 185, 0, 298, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 69, 76, - 79, 0, 81, 82, 85, 86, 87, 88, 89, 91, - 93, 0, 99, 153, 98, 110, 0, 120, 124, 125, - 126, 127, 0, 130, 131, 57, 0, 244, 247, 253, - 0, 252, 255, 0, 0, 256, 20, 22, 270, 51, - 50, 291, 0, 309, 276, 42, 314, 309, 311, 310, - 49, 306, 147, 148, 0, 337, 318, 213, 204, 203, - 297, 194, 276, 42, 301, 297, 298, 0, 294, 176, - 177, 189, 170, 171, 174, 175, 165, 166, 0, 167, - 168, 169, 173, 172, 179, 178, 181, 182, 180, 190, - 0, 196, 59, 95, 152, 0, 344, 22, 209, 0, - 254, 0, 262, 47, 45, 48, 309, 276, 0, 309, - 0, 305, 42, 313, 319, 322, 0, 202, 0, 214, - 0, 297, 276, 0, 309, 0, 293, 0, 42, 300, - 0, 193, 115, 38, 210, 22, 304, 309, 315, 308, - 312, 0, 0, 321, 0, 201, 139, 192, 292, 309, - 302, 296, 299, 191, 0, 164, 263, 307, 316, 320, - 323, 0, 295, 303, 0, 0, 342, 140, 0, 52, - 52, 208, 142, 0, 141, 207 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, + 76, 79, 0, 81, 82, 85, 86, 87, 88, 89, + 91, 93, 0, 99, 153, 98, 110, 0, 120, 124, + 125, 126, 127, 0, 130, 131, 57, 0, 245, 248, + 254, 0, 253, 256, 0, 0, 257, 20, 22, 271, + 51, 50, 292, 0, 310, 277, 42, 315, 310, 312, + 311, 49, 307, 147, 148, 0, 338, 319, 214, 205, + 204, 298, 195, 277, 42, 302, 298, 299, 0, 295, + 177, 178, 190, 171, 172, 175, 176, 166, 167, 0, + 168, 169, 170, 174, 173, 180, 179, 182, 183, 181, + 191, 0, 197, 59, 95, 152, 0, 345, 22, 210, + 0, 255, 0, 263, 47, 45, 48, 310, 277, 0, + 310, 0, 306, 42, 314, 320, 323, 0, 203, 0, + 215, 0, 298, 277, 0, 310, 0, 294, 0, 42, + 301, 0, 194, 115, 38, 211, 22, 305, 310, 316, + 309, 313, 0, 0, 322, 0, 202, 139, 193, 293, + 310, 303, 297, 300, 192, 0, 165, 264, 308, 317, + 321, 324, 0, 296, 304, 0, 0, 343, 140, 0, + 52, 52, 209, 142, 0, 141, 208 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 2, 173, 279, 192, 368, 40, 41, 42, - 43, 259, 177, 44, 260, 376, 377, 378, 379, 476, - 361, 92, 169, 325, 170, 347, 477, 591, 597, 289, - 290, 291, 214, 336, 337, 318, 319, 320, 322, 294, - 387, 392, 298, 602, 603, 464, 48, 548, 79, 478, - 49, 81, 50, 261, 52, 262, 272, 358, 54, 55, - 274, 363, 56, 195, 57, 58, 263, 264, 182, 61, + -1, 1, 2, 173, 279, 192, 369, 40, 41, 42, + 43, 259, 177, 44, 260, 377, 378, 379, 380, 477, + 362, 92, 169, 326, 170, 348, 478, 592, 598, 289, + 290, 291, 214, 337, 338, 319, 320, 321, 323, 294, + 388, 393, 298, 603, 604, 465, 48, 549, 79, 479, + 49, 81, 50, 261, 52, 262, 272, 359, 54, 55, + 274, 364, 56, 195, 57, 58, 263, 264, 182, 61, 265, 63, 64, 65, 280, 66, 197, 67, 211, 212, - 496, 555, 497, 498, 479, 540, 480, 481, 296, 573, - 545, 546, 213, 171, 215, 69, 70, 217, 349 + 497, 556, 498, 499, 480, 541, 481, 482, 296, 574, + 546, 547, 213, 171, 215, 69, 70, 217, 350 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -472 +#define YYPACT_NINF -459 static const yytype_int16 yypact[] = { - -472, 38, 1206, -472, -472, -472, -472, -472, 75, -472, - -86, 228, -472, 238, -472, -472, -472, -472, 28, 101, - -472, -472, -472, -472, 265, 28, -472, -23, 28, 408, - -472, -472, 271, -3, 287, 408, -472, -472, 2244, -472, - 25, -472, -472, -472, -472, -472, 1982, 34, 47, -472, - -472, 52, 54, -472, 73, 61, 106, 110, 62, -472, - -472, 97, -472, 31, 31, 31, 114, 2135, 123, 31, - 133, 135, -472, -472, 218, -472, -472, 126, -472, 142, - -472, -472, 146, -472, -472, -472, 2135, -472, -472, 126, - 148, 2060, -472, -99, -89, -472, -472, 151, -472, -472, - -472, -472, -472, 153, 154, -472, -472, -472, -472, -472, - -472, 156, -472, -472, 157, -472, 159, 160, -472, -472, - 161, 162, 163, 165, 167, -472, 169, -472, 173, -472, - 174, -472, -472, 185, 187, -472, -472, -472, -472, -472, - -472, -472, -472, -472, 192, -472, -472, -472, -472, -472, - 194, -472, -472, -472, -472, -472, 201, -472, -472, -472, - 210, 212, 214, -472, 215, -472, -472, 216, 219, -79, - -472, -472, -472, 1111, 425, 334, 290, 224, 230, -472, - -472, -472, -472, 114, 233, 235, -472, -472, -472, -472, - 24, -472, -472, -472, 296, 225, -472, -472, -472, -472, - -472, -472, -472, -472, -472, -472, -472, -472, 114, 114, - -472, 229, -26, -472, -472, -472, 31, -472, -472, -472, - 236, 312, -472, 237, -472, 114, 242, -472, 400, 312, - 967, 967, 401, 409, 967, 967, 410, 411, 967, 413, - 967, 967, 349, 967, 967, -21, 967, 967, 967, 2135, - 2135, 129, 418, 2135, 2244, 254, -472, 260, -472, -472, - -472, 263, -472, -472, -472, -472, 106, -472, -472, -472, - -472, -472, -145, 285, -65, 266, 264, -472, -472, 520, - 64, 268, -472, 967, 974, 1552, -472, -472, -472, 269, - 292, -472, 272, -472, -54, -472, 294, -3, -36, 270, - 274, -472, -472, -472, -472, -472, -472, -472, -472, 277, - -472, 967, 967, 967, 967, 967, 967, 805, 1801, -125, - -472, 1801, 279, 280, -472, -110, 282, 284, 286, 288, - 291, 295, 297, 1557, 448, 300, -109, -472, 1801, 301, - 310, -72, 1615, 302, 303, -472, -472, 305, 299, 307, - 309, -472, 2244, 453, -472, -472, 106, 1, -472, -472, - 335, 2060, 321, -34, 322, 417, 615, 106, -472, 2060, - -472, -472, -472, -472, 895, 329, 330, 354, -472, -472, - 2060, 57, -472, 312, 967, -472, 2060, -472, 114, 333, - -472, 336, -472, 338, -472, -472, 2060, 18, 18, 18, - 18, 18, 18, 1638, 267, 967, 967, 512, 967, 967, - 967, 967, 967, 967, 967, 967, 967, 967, 967, 967, - 967, 967, 967, 967, 967, 513, 967, 967, -472, -472, - -472, 510, -472, -472, -472, -472, -472, -472, -472, -472, - -472, 346, -472, 967, -472, -472, 967, -472, -472, -472, - -472, -472, 516, -472, -472, -472, 348, -472, -472, -472, - 114, -472, -472, 2060, 351, -472, -472, 106, -472, -472, - -472, -472, 1474, 57, -472, 1318, -472, 57, -472, -472, - -472, 41, -472, -472, 57, 353, -472, 312, -472, -472, - 267, -472, -472, 1396, -472, 267, -472, 352, 48, 193, - 193, -472, 221, 221, 152, 152, 1688, 1765, 1742, 1819, - 1838, 1870, 152, 152, 234, 234, 18, 18, 18, -472, - 1720, -472, -472, -472, -472, 358, -472, 106, -472, 114, - -472, 710, -472, -472, -472, -472, 32, -472, 361, 57, - 362, -472, 1552, -472, 376, -472, -45, -472, 363, -472, - 365, 255, -472, 367, 57, 369, -472, 967, 1552, -472, - 967, -472, -472, -472, -472, 106, -472, 32, -472, -472, - -472, 370, 967, -472, 57, -472, -472, -472, -472, 32, - -472, -472, -472, 18, 371, 1801, -472, -472, -472, -472, - -472, 23, -472, -472, 967, 377, -472, -472, 398, 20, - 20, -472, -472, 382, -472, -472 + -459, 58, 1214, -459, -459, -459, -459, -459, 161, -459, + -102, 256, -459, 264, -459, -459, -459, -459, -1, 88, + -459, -459, -459, -459, 289, -1, -459, -67, -1, 484, + -459, -459, 295, -19, 297, 484, -459, -459, 2194, -459, + -16, -459, -459, -459, -459, -459, 2007, 5, 13, -459, + -459, 39, 25, -459, 46, 72, 54, 89, 117, -459, + -459, 98, -459, -14, -14, -14, 287, 992, 103, -14, + 109, 113, -459, -459, 276, -459, -459, 112, -459, 119, + -459, -459, 129, -459, -459, -459, 992, -459, -459, 112, + 128, 2085, -459, -103, -101, -459, -459, 134, -459, -459, + -459, -459, -459, 140, 144, -459, -459, -459, -459, -459, + -459, 146, -459, -459, 149, -459, 153, 154, -459, -459, + 163, 164, 168, 171, 174, -459, 175, -459, 177, -459, + 182, -459, -459, 184, 185, -459, -459, -459, -459, -459, + -459, -459, -459, -459, 186, -459, -459, -459, -459, -459, + 192, -459, -459, -459, -459, -459, 194, -459, -459, -459, + 200, 201, 204, -459, 205, -459, -459, 207, 208, -93, + -459, -459, -459, 1119, 500, 359, 303, 209, 210, -459, + -459, -459, -459, 287, 211, 216, -459, -459, -459, -459, + 33, -459, -459, -459, 307, 212, -459, -459, -459, -459, + -459, -459, -459, -459, -459, -459, -459, -459, 287, 287, + -459, 213, -87, -459, -459, -459, -14, -459, -459, -459, + 218, 309, -459, 220, -459, 287, 223, -459, 391, 309, + 944, 944, 392, 398, 944, 944, 399, 400, 944, 402, + 944, 944, 344, 944, 944, -72, 944, 944, 944, 992, + 992, 111, 410, 992, 2194, 245, -459, 244, -459, -459, + -459, 246, -459, -459, -459, -459, 54, -459, -459, -459, + -459, -459, -50, 268, -32, 248, 247, -459, -459, 595, + 40, 253, -459, 944, 983, 1577, -459, -459, -459, 255, + 272, -459, 252, -459, -18, -459, 284, -19, -8, 260, + 262, -459, -459, -459, -459, -459, -459, -459, -459, -459, + 266, -459, 944, 944, 944, 944, 944, 944, 880, 1826, + -80, -459, 1826, 263, 267, -459, -69, 269, 270, 271, + 273, 274, 280, 281, 1582, 438, 285, -62, -459, 1826, + 291, 293, -24, 1640, 294, 298, -459, -459, 300, 302, + 301, 304, -459, 2194, 443, -459, -459, 54, 7, -459, + -459, 316, 2085, 305, 14, 306, 389, 690, 54, -459, + 2085, -459, -459, -459, -459, 326, 308, 313, 327, -459, + -459, 2085, 90, -459, 309, 944, -459, 2085, -459, 287, + 318, -459, 321, -459, 322, -459, -459, 2085, 11, 11, + 11, 11, 11, 11, 1663, 279, 944, 944, 479, 944, + 944, 944, 944, 944, 944, 944, 944, 944, 944, 944, + 944, 944, 944, 944, 944, 944, 488, 944, 944, -459, + -459, -459, 489, -459, -459, -459, -459, -459, -459, -459, + -459, -459, 324, -459, 944, -459, -459, 944, -459, -459, + -459, -459, -459, 491, -459, -459, -459, 330, -459, -459, + -459, 287, -459, -459, 2085, 328, -459, -459, 54, -459, + -459, -459, -459, 1499, 90, -459, 1326, -459, 90, -459, + -459, -459, 16, -459, -459, 90, 329, -459, 309, -459, + -459, 279, -459, -459, 1404, -459, 279, -459, 331, 31, + 243, 243, -459, 444, 444, 95, 95, 1713, 1790, 1767, + 1844, 1863, 1895, 95, 95, 193, 193, 11, 11, 11, + -459, 1745, -459, -459, -459, -459, 332, -459, 54, -459, + 287, -459, 785, -459, -459, -459, -459, 145, -459, 333, + 90, 334, -459, 1577, -459, 358, -459, -74, -459, 335, + -459, 337, 47, -459, 338, 90, 339, -459, 944, 1577, + -459, 944, -459, -459, -459, -459, 54, -459, 145, -459, + -459, -459, 340, 944, -459, 90, -459, -459, -459, -459, + 145, -459, -459, -459, 11, 341, 1826, -459, -459, -459, + -459, -459, -9, -459, -459, 944, 365, -459, -459, 366, + 51, 51, -459, -459, 347, -459, -459 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -472, -472, -472, 511, -271, -257, 10, -472, -472, -472, - 195, -472, -472, -472, 557, -409, -472, -472, 89, -192, - -6, -2, -472, -472, -244, -472, -63, -472, -472, -472, - -472, 182, 2, 323, -261, -159, -472, -224, -228, -472, - -472, -472, -472, -32, -167, -472, -472, -472, 164, -40, - -472, 200, 100, 51, -472, 567, -472, -472, 527, -472, - -472, -472, -472, -472, -13, -472, 572, -1, -472, -472, - 574, -472, -472, -265, -411, -41, -7, -22, -180, -472, - -472, -472, -439, -472, -471, -472, -456, -472, -472, -472, - 3, -472, 395, 339, 6, -49, -472, 0, -472 + -459, -459, -459, 477, -258, -257, 19, -459, -459, -459, + 156, -459, -459, -459, 522, -429, -459, -459, 52, -202, + -21, -2, -459, -459, -229, -459, -65, -459, -459, -459, + -459, 142, 2, 282, -260, -181, -459, -224, -227, -459, + -459, -459, -459, -73, -206, -459, -459, -459, 215, -63, + -459, 188, 121, 28, -459, 525, -459, -459, 490, -459, + -459, -459, -459, -459, -23, -459, 533, 3, -459, -459, + 535, -459, -459, -265, -413, -40, -10, -27, -191, -459, + -459, -459, -414, -459, -458, -459, -439, -459, -459, -459, + -33, -459, 361, 310, 6, -54, -459, 0, -459 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -217 +#define YYTABLE_NINF -218 static const yytype_int16 yytable[] = { - 46, 60, 71, 209, 47, 183, 326, 366, 68, 355, - 351, 327, 39, 544, 330, 370, 332, 535, 216, 335, - 286, 541, 340, 375, 427, 38, 210, 91, 281, 282, - 360, 356, 407, 181, -216, 201, 202, 223, 3, 431, - 443, 198, 198, 198, 226, 295, 185, 198, 178, 428, - 225, 550, 184, 51, 11, 373, 556, 199, 200, 594, - 201, 202, 218, 536, 432, 444, 538, 201, 202, 203, - 254, 595, 321, 9, 9, 321, -216, 443, 72, 73, - 566, 551, 333, 569, 553, 338, 227, 74, 338, 342, - 24, 148, 255, 15, 203, 152, 204, 179, 581, 457, - 371, 203, 447, 544, 574, 38, 9, 362, 455, 82, - 468, 587, 578, 24, 80, 20, 38, 201, 202, 163, - 209, 204, 385, 592, 321, 338, 567, 575, 204, 88, - 389, 393, 273, 571, 38, 95, 38, 345, 205, 346, - 390, 579, 462, 210, 284, 209, 209, 285, 26, 584, - 86, 203, 397, 398, 399, 400, 401, 402, 403, 31, - 483, 206, 209, 205, 405, 406, 407, 38, 210, 210, - 205, 46, 46, 71, 71, 47, 47, 275, 204, 68, - 68, 292, 524, 258, 258, 210, 206, 425, 426, 300, - 38, 474, 601, 206, 198, 531, 90, 172, 94, 596, - 343, 344, 284, 521, 350, 475, -29, 407, 486, 287, - 532, 284, 494, 194, 542, 400, 474, 209, 284, 186, - 205, 558, 525, 207, 187, 85, 220, 284, 87, 188, - 475, 75, 76, 405, 406, 407, 190, 208, 410, 411, - 210, 77, 78, 206, 381, 189, 499, 500, 407, 502, - 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, - 513, 514, 515, 516, 517, 518, 357, 520, 83, 84, - 563, 370, 196, 207, 89, 78, 404, 369, 191, 71, - 528, 47, 193, 380, 338, 68, 370, 208, 386, 543, - 93, 78, 203, 268, 269, -30, 391, 9, 494, 276, - 277, -216, 370, 494, 203, 219, 559, -31, 586, 420, - 421, 422, 423, 424, 370, 201, 202, 221, 222, 204, - 460, 425, 426, 224, 228, 209, 229, 230, 183, 231, - 232, 204, 233, 234, 235, 236, 237, 267, 238, 473, - 239, 495, 240, 292, 589, 484, 241, 242, 210, 564, - 420, 421, 422, 423, 424, 490, 458, 463, 243, 494, - 244, 205, 425, 426, 369, 245, 71, 246, 47, 185, - 598, 178, 68, 205, 247, 184, 418, 419, 420, 421, - 422, 423, 424, 248, 206, 249, 485, 250, 251, 252, - 425, 426, 253, 422, 423, 424, 206, 209, 583, 270, - 278, 585, -32, 425, 426, -33, 283, -34, 299, 323, - 288, 293, 539, 321, 492, 297, 334, 324, 328, 329, - 210, 331, 529, 348, 352, 284, 492, 495, 493, 4, - 554, 381, 495, 353, 381, 354, 359, 284, 364, 365, - 493, 383, 372, 388, 394, 382, 7, 549, 395, 384, - 396, 441, 381, 429, 430, 5, 433, 6, 434, 446, - 435, 456, 436, 7, 8, 437, 209, 9, 452, 438, - 380, 439, 10, 380, 442, 445, 449, 450, 11, 451, - 12, 453, 18, 454, 13, 14, 459, 15, 495, 210, - 16, 380, 17, 461, 21, 22, 23, 19, 465, 18, - 470, 381, 25, 472, 471, 19, 257, 487, 488, 20, - 489, 21, 22, 23, 24, 501, 519, 381, 522, 25, - 523, 526, 527, 530, 4, 547, 557, 572, 599, 369, - 28, 71, 562, 47, 30, 568, 570, 68, 576, 577, - 380, 580, 26, 582, 588, 593, 27, 28, 29, 600, - 5, 30, 6, 31, 605, 174, 380, 32, 7, 45, - 466, 534, 9, 33, 34, 482, 35, 10, 604, 53, - 341, 36, 37, 180, 59, 12, 62, 590, 271, 13, - 14, 0, 15, 0, 339, 16, 0, 17, 0, 0, - 0, 0, 0, 0, 18, 38, 0, 0, 0, 0, - 19, 266, 0, 0, 20, 0, 21, 22, 23, 0, - 0, 0, 0, 0, 25, 0, 0, 0, 0, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, - 0, 27, 28, 29, 0, 5, 30, 6, 31, 0, - 0, 0, 32, 7, 0, 0, 0, 9, 33, 34, - 0, 35, 10, 0, 0, 0, 36, 37, 0, 0, - 12, 0, 0, 0, 13, 14, 0, 15, 0, 0, - 16, 0, 17, 0, 0, 0, 0, 0, 0, 18, - 38, 0, 0, 0, 0, 19, 367, 0, 0, 20, - 0, 21, 22, 23, 0, 0, 0, 0, 0, 25, - 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 26, 0, 0, 0, 27, 28, 29, 0, - 5, 30, 6, 31, 0, 0, 0, 32, 7, 0, - 0, 0, 9, 33, 34, 0, 35, 10, 0, 0, - 0, 36, 37, 0, 0, 12, 0, 0, 0, 13, - 14, 0, 15, 0, 0, 16, 0, 17, 0, 0, - 0, 0, 0, 0, 18, 38, 0, 0, 0, 0, - 19, 467, 0, 0, 20, 0, 21, 22, 23, 0, - 0, 0, 0, 0, 25, 0, 0, 0, 301, 4, - 302, 303, 304, 305, 306, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, - 0, 27, 28, 29, 0, 5, 30, 6, 31, 0, - 0, 0, 32, 7, 0, 0, 0, 9, 33, 34, - 0, 35, 0, 0, 0, 0, 36, 37, 0, 0, - 12, 0, 0, 0, 13, 14, 0, 15, 307, 0, - 16, 0, 17, 0, 0, 0, 0, 0, 0, 18, - 38, 0, 0, 0, 0, 0, 565, 0, 0, 20, - 0, 21, 22, 23, 0, 0, 0, 0, 301, 25, - 302, 303, 304, 305, 306, 308, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 26, 0, 0, 0, 27, 28, 29, 0, - 309, 30, 0, 31, 0, 0, 0, 32, 0, 0, - 0, 0, 310, 0, 34, 0, 35, 0, 0, 0, - 0, 36, 37, 0, 0, 0, 0, 0, 307, 311, - 0, 0, 312, 313, 314, 0, 0, 315, 316, 0, - 301, 0, 302, 303, 304, 305, 306, 301, 317, 302, - 303, 304, 305, 306, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 308, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 309, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 307, 0, 310, 0, 0, 0, 0, 307, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 311, - 0, 0, 312, 313, 314, 0, 0, 315, 316, 0, - 0, 0, 0, 0, 0, 0, 469, 308, 317, 0, - 0, 0, 0, 0, 308, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 309, 0, 0, 0, 0, 0, 0, 309, - 0, 0, 0, 0, 310, 0, 0, 0, 0, 0, - 0, 310, 0, 0, 0, 4, 0, 0, 0, 0, - 0, 311, 256, 0, 312, 313, 314, 0, 311, 315, - 316, 312, 313, 374, 0, 0, 315, 316, 0, 0, - 317, 5, 0, 6, 0, 0, 0, 317, 0, 7, - 8, 0, 0, 9, 0, 0, 0, 0, 10, 0, - 0, 0, 0, 0, 11, 0, 12, 0, 0, 0, + 46, 209, 71, 210, 47, 60, 183, 327, 68, 356, + 286, 328, 91, 216, 331, 371, 333, 281, 282, 336, + 367, 39, 341, 181, 376, 352, 408, 545, 595, 9, + 51, -217, 223, 226, 295, 536, 198, 198, 198, 542, + 596, 148, 198, 201, 202, 152, 185, 539, 178, 15, + 322, 225, 184, 322, 199, 200, 374, 254, 3, 218, + 334, 11, 537, 339, 361, 554, 339, 343, 363, 163, + 428, 20, 74, -217, 179, 227, 575, 551, 203, 255, + 552, 432, 557, 9, 284, 203, 80, 285, 444, 372, + 9, 390, 394, 201, 202, 429, 82, 24, 567, 576, + 458, 570, 322, 339, 26, 204, 433, 86, 406, 407, + 408, 469, 204, 445, 572, 31, 582, 545, 209, 346, + 210, 38, 347, 24, 456, 568, 444, 357, 203, 588, + 585, 398, 399, 400, 401, 402, 403, 404, 579, 38, + 580, 593, 273, 209, 209, 210, 210, 205, 201, 202, + 88, 448, 38, 38, 205, 204, 95, 172, 292, 386, + 209, 484, 210, 38, 72, 73, 300, 275, 597, 391, + 206, 46, 46, 71, 71, 47, 47, 206, -29, 68, + 68, 426, 427, 203, 525, 38, 186, 284, 9, 198, + 543, 463, 258, 258, 401, 344, 345, 205, 487, 351, + 207, 188, 284, 495, 522, 559, 287, 493, 408, 532, + 204, 533, 187, 85, 208, 209, 87, 210, 284, 189, + 206, 494, 38, 526, 602, 500, 501, 191, 503, 504, + 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, + 515, 516, 517, 518, 519, 382, 521, 90, 190, 94, + 475, 358, 205, 421, 422, 423, 424, 425, 408, 75, + 76, 284, 193, 339, 476, 426, 427, 77, 78, 194, + 529, 564, 371, 387, 196, 206, -30, 370, 405, 71, + 544, 47, 219, 381, 220, 68, -31, 371, -217, 495, + 201, 202, 83, 84, 495, 221, 392, 560, 89, 78, + 93, 78, 222, 371, 224, 475, 268, 269, 228, 587, + 276, 277, 201, 202, 229, 371, 284, 203, 230, 476, + 231, 292, 461, 232, 209, 203, 210, 233, 234, 301, + 183, 302, 303, 304, 305, 306, 307, 235, 236, 565, + 496, 474, 237, 464, 204, 238, 590, 485, 239, 240, + 495, 241, 204, 423, 424, 425, 242, 491, 243, 244, + 245, 459, 267, 426, 427, 370, 246, 71, 247, 47, + 185, 599, 178, 68, 248, 249, 184, 584, 250, 251, + 586, 252, 253, -32, -33, 270, 205, 486, 278, -34, + 308, 283, 322, 288, 205, 293, 209, 297, 210, 299, + 324, 421, 422, 423, 424, 425, 325, 329, 330, 206, + 332, 540, 335, 426, 427, 349, 353, 206, 354, 355, + 360, 365, 384, 366, 530, 550, 496, 309, 373, 555, + 385, 496, 383, 382, 389, 395, 382, 396, 430, 493, + 397, 442, 431, 447, 434, 435, 436, 207, 437, 438, + 284, 457, 310, 494, 382, 439, 440, 406, 407, 408, + 443, 208, 411, 412, 311, 209, 446, 210, 460, 450, + 19, 381, 453, 451, 381, 452, 454, 473, 462, 455, + 471, 312, 502, 466, 313, 314, 315, 496, 472, 316, + 317, 520, 381, 488, 489, 490, 527, 523, 470, 524, + 318, 531, 548, 382, 4, 528, 558, 563, 569, 571, + 573, 577, 578, 581, 583, 589, 594, 600, 601, 382, + 606, 174, 467, 7, 45, 535, 483, 53, 605, 342, + 370, 5, 71, 6, 47, 59, 180, 62, 68, 7, + 8, 381, 591, 9, 271, 0, 0, 0, 10, 0, + 0, 0, 0, 0, 11, 340, 12, 381, 0, 18, 13, 14, 0, 15, 0, 0, 16, 0, 17, 0, - 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, + 0, 21, 22, 23, 0, 18, 0, 0, 0, 25, 0, 19, 257, 0, 0, 20, 0, 21, 22, 23, - 24, 0, 0, 0, 0, 25, 0, 0, 0, 0, - 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, + 24, 0, 0, 0, 0, 25, 0, 0, 0, 4, + 419, 420, 421, 422, 423, 424, 425, 28, 0, 0, + 0, 30, 0, 0, 426, 427, 0, 0, 26, 0, 0, 0, 27, 28, 29, 0, 5, 30, 6, 31, - 0, 0, 0, 32, 7, 8, 0, 0, 9, 33, - 34, 0, 35, 10, 0, 0, 0, 36, 37, 11, + 0, 0, 0, 32, 7, 0, 0, 0, 9, 33, + 34, 0, 35, 10, 0, 0, 0, 36, 37, 0, 0, 12, 0, 0, 0, 13, 14, 0, 15, 0, 0, 16, 0, 17, 0, 0, 0, 0, 0, 0, - 18, 38, 0, 0, 0, 0, 19, 0, 0, 0, - 20, 0, 21, 22, 23, 24, 0, 0, 0, 0, + 18, 38, 0, 0, 0, 0, 19, 266, 0, 0, + 20, 0, 21, 22, 23, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 26, 0, 0, 0, 27, 28, 29, + 0, 5, 30, 6, 31, 0, 0, 0, 32, 7, + 0, 0, 0, 9, 33, 34, 0, 35, 10, 0, + 0, 0, 36, 37, 0, 0, 12, 0, 0, 0, + 13, 14, 0, 15, 0, 0, 16, 0, 17, 0, + 0, 0, 0, 0, 0, 18, 38, 0, 0, 0, + 0, 19, 368, 0, 0, 20, 0, 21, 22, 23, + 0, 0, 0, 0, 0, 25, 0, 0, 0, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, + 0, 0, 27, 28, 29, 0, 5, 30, 6, 31, + 0, 0, 0, 32, 7, 0, 0, 0, 9, 33, + 34, 0, 35, 10, 0, 0, 0, 36, 37, 0, + 0, 12, 0, 0, 0, 13, 14, 0, 15, 0, + 0, 16, 0, 17, 0, 0, 0, 0, 0, 0, + 18, 38, 0, 0, 0, 0, 19, 468, 0, 0, + 20, 0, 21, 22, 23, 0, 0, 0, 0, 0, + 25, 0, 0, 301, 4, 302, 303, 304, 305, 306, + 307, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 26, 0, 0, 0, 27, 28, 29, + 0, 5, 30, 6, 31, 0, 0, 0, 32, 7, + 0, 0, 0, 9, 33, 34, 0, 35, 0, 0, + 0, 0, 36, 37, 0, 0, 12, 0, 0, 0, + 13, 14, 0, 15, 308, 0, 16, 301, 17, 302, + 303, 304, 305, 306, 307, 18, 38, 0, 0, 0, + 0, 0, 566, 0, 0, 20, 0, 21, 22, 23, + 0, 0, 0, 0, 0, 25, 0, 0, 0, 0, + 0, 309, 0, 0, 0, 0, 301, 0, 302, 303, + 304, 305, 306, 307, 0, 0, 4, 0, 26, 0, + 0, 0, 27, 28, 29, 0, 310, 30, 308, 31, + 0, 0, 0, 32, 0, 0, 0, 0, 311, 0, + 34, 0, 35, 5, 0, 6, 0, 36, 37, 0, + 0, 7, 0, 0, 0, 312, 0, 0, 313, 314, + 315, 0, 0, 316, 317, 309, 0, 308, 12, 0, + 0, 0, 13, 14, 318, 0, 0, 0, 16, 0, + 17, 0, 0, 0, 0, 0, 0, 18, 0, 0, + 310, 0, 0, 0, 0, 0, 0, 0, 0, 21, + 22, 23, 311, 0, 309, 0, 0, 25, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 312, + 0, 0, 313, 314, 315, 0, 0, 316, 317, 310, + 0, 0, 0, 0, 27, 28, 29, 0, 318, 30, + 0, 311, 0, 4, 0, 32, 0, 0, 0, 0, + 0, 256, 34, 0, 35, 0, 0, 0, 312, 36, + 37, 313, 314, 375, 0, 0, 316, 317, 0, 0, + 5, 0, 6, 0, 0, 0, 0, 318, 7, 8, + 0, 0, 9, 0, 0, 0, 0, 10, 0, 0, + 0, 0, 0, 11, 0, 12, 0, 0, 0, 13, + 14, 0, 15, 0, 0, 16, 0, 17, 0, 0, + 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, + 19, 257, 0, 0, 20, 0, 21, 22, 23, 24, + 0, 0, 0, 0, 25, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, + 0, 27, 28, 29, 0, 5, 30, 6, 31, 0, + 0, 0, 32, 7, 8, 0, 0, 9, 33, 34, + 0, 35, 10, 0, 0, 0, 36, 37, 11, 0, + 12, 0, 0, 0, 13, 14, 0, 15, 0, 0, + 16, 0, 17, 0, 0, 0, 0, 0, 0, 18, + 38, 0, 0, 0, 0, 19, 0, 0, 0, 20, + 0, 21, 22, 23, 24, 0, 0, 0, 0, 25, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 0, 26, 0, 0, 0, 27, 28, 29, 0, + 0, 30, 0, 31, 0, 0, 0, 32, 0, 0, + 0, 0, 0, 33, 34, 0, 35, 5, 0, 6, + 0, 36, 37, 0, 203, 7, 0, 0, 0, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 0, 0, 38, 13, 14, 0, 15, + 0, 204, 16, 0, 17, 0, 0, 0, 0, 0, + 0, 18, 0, 0, 0, 0, 0, 0, 4, 0, + 0, 20, 0, 21, 22, 23, 0, 0, 0, 0, + 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 205, 0, 5, 0, 6, 0, 0, + 0, 0, 203, 7, 26, 0, 0, 9, 27, 28, + 29, 0, 0, 30, 0, 31, 206, 0, 0, 32, + 12, 0, 0, 0, 13, 14, 34, 15, 35, 204, + 16, 0, 17, 36, 37, 0, 0, 0, 0, 18, + 0, 0, 0, 0, 0, 0, 538, 0, 0, 20, + 0, 21, 22, 23, 0, 0, 0, 38, 0, 25, + 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, + 0, 205, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 534, 26, 0, 0, 0, 27, 28, 29, 0, + 5, 30, 6, 31, 206, 0, 0, 32, 7, 0, + 0, 0, 9, 0, 34, 0, 35, 0, 0, 0, + 0, 36, 37, 0, 0, 12, 0, 0, 0, 13, + 14, 0, 15, 0, 553, 16, 0, 17, 0, 0, + 0, 0, 0, 0, 18, 38, 0, 0, 0, 0, + 0, 4, 0, 0, 20, 0, 21, 22, 23, 0, + 0, 0, 0, 0, 25, 406, 407, 408, 409, 410, + 411, 412, 413, 414, 0, 0, 0, 0, 5, 0, + 6, 0, 0, 0, 0, 0, 7, 26, 0, 0, + 9, 27, 28, 29, 0, 0, 30, 0, 31, 0, + 0, 0, 32, 12, 0, 0, 0, 13, 14, 34, + 15, 35, 0, 16, 0, 17, 36, 37, 0, 0, + 0, 0, 18, 406, 407, 408, 409, 410, 411, 412, + 413, 414, 20, 0, 21, 22, 23, 0, 0, 0, + 38, 0, 25, 0, 0, 0, 406, 407, 408, 409, + 410, 411, 412, 413, 414, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 26, 0, 0, 0, 27, + 28, 29, 0, 0, 30, 0, 31, 0, 0, 0, + 32, 0, 0, 0, 0, 0, 0, 34, 0, 35, + 0, 0, 0, 0, 36, 37, 406, 407, 408, 409, + 410, 411, 412, 415, 414, 416, 417, 418, 419, 420, + 421, 422, 423, 424, 425, 0, 0, 0, 38, 0, + 0, 0, 426, 427, 0, 0, 0, 441, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 406, 407, 408, 409, 410, 411, 412, 413, 414, 0, + 0, 415, 0, 416, 417, 418, 419, 420, 421, 422, + 423, 424, 425, 406, 407, 408, 409, 410, 411, 412, + 426, 427, 0, 0, 415, 449, 416, 417, 418, 419, + 420, 421, 422, 423, 424, 425, 0, 0, 0, 0, + 0, 0, 0, 426, 427, 0, 0, 0, 492, 406, + 407, 408, 409, 410, 411, 412, 413, 414, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 406, 407, 408, + 409, 410, 411, 412, 0, 0, 416, 417, 418, 419, + 420, 421, 422, 423, 424, 425, 406, 407, 408, 409, + 410, 411, 412, 426, 427, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 415, 0, 416, 417, + 418, 419, 420, 421, 422, 423, 424, 425, 406, 407, + 408, 409, 410, 411, 412, 426, 427, 562, 415, 561, + 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, + 0, 0, 0, 0, 0, 0, 0, 426, 427, 0, + 0, 0, 0, 416, 417, 418, 419, 420, 421, 422, + 423, 424, 425, 0, 0, 0, 0, 0, 0, 0, + 426, 427, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 415, 0, 416, + 417, 418, 419, 420, 421, 422, 423, 424, 425, 0, + 0, 0, 0, 0, 0, 0, 426, 427, 417, 418, + 419, 420, 421, 422, 423, 424, 425, 0, 0, 0, + 0, 4, 0, 0, 426, 427, 0, 0, 418, 419, + 420, 421, 422, 423, 424, 425, 0, 0, 0, 0, + 0, 0, 0, 426, 427, 0, 0, 0, 5, 0, + 6, 0, 0, 0, 0, 0, 7, 8, 0, 0, + 9, 419, 420, 421, 422, 423, 424, 425, 0, 0, + 0, 11, 0, 12, 0, 426, 427, 13, 14, 0, + 15, 0, 0, 16, 0, 17, 0, 0, 0, 0, + 0, 0, 18, 0, 0, 0, 0, 0, 0, 4, + 0, 0, 20, 0, 21, 22, 23, 24, 0, 0, + 175, 0, 25, 0, 176, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, 0, 6, 0, + 0, 0, 0, 0, 7, 26, 0, 0, 9, 27, + 28, 29, 0, 0, 30, 0, 31, 0, 0, 0, + 32, 12, 0, 0, 0, 13, 14, 34, 15, 35, + 0, 16, 0, 17, 36, 37, 0, 0, 0, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 20, 0, 21, 22, 23, 0, 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 26, 0, 0, 0, 27, 28, 29, - 0, 0, 30, 0, 31, 0, 0, 0, 32, 0, - 0, 0, 0, 0, 33, 34, 0, 35, 5, 0, - 6, 0, 36, 37, 0, 203, 7, 0, 0, 0, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 12, 0, 0, 38, 13, 14, 0, - 15, 0, 204, 16, 0, 17, 0, 0, 0, 0, - 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, - 4, 0, 20, 0, 21, 22, 23, 0, 0, 0, - 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 205, 0, 5, 0, 6, 0, - 0, 0, 0, 203, 7, 26, 0, 0, 9, 27, - 28, 29, 0, 0, 30, 0, 31, 206, 0, 0, - 32, 12, 0, 0, 0, 13, 14, 34, 15, 35, - 204, 16, 0, 17, 36, 37, 0, 0, 0, 0, - 18, 0, 0, 0, 0, 0, 0, 537, 4, 0, - 20, 0, 21, 22, 23, 0, 0, 0, 38, 0, - 25, 0, 0, 0, 0, 533, 0, 0, 0, 0, - 0, 0, 205, 0, 5, 0, 6, 0, 0, 0, - 0, 0, 7, 26, 0, 0, 9, 27, 28, 29, - 0, 0, 30, 0, 31, 206, 0, 0, 32, 12, - 0, 0, 0, 13, 14, 34, 15, 35, 0, 16, - 0, 17, 36, 37, 0, 0, 0, 0, 18, 0, - 0, 0, 0, 0, 0, 552, 4, 0, 20, 0, - 21, 22, 23, 0, 0, 0, 38, 0, 25, 405, - 406, 407, 408, 409, 410, 411, 412, 413, 0, 0, - 0, 0, 5, 0, 6, 0, 0, 0, 0, 0, - 7, 26, 0, 0, 9, 27, 28, 29, 0, 0, - 30, 0, 31, 0, 0, 0, 32, 12, 0, 0, - 0, 13, 14, 34, 15, 35, 0, 16, 0, 17, - 36, 37, 0, 0, 0, 0, 18, 405, 406, 407, - 408, 409, 410, 411, 412, 413, 20, 0, 21, 22, - 23, 0, 0, 0, 38, 0, 25, 0, 0, 0, - 405, 406, 407, 408, 409, 410, 411, 412, 413, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, - 0, 0, 0, 27, 28, 29, 0, 0, 30, 0, - 31, 0, 0, 0, 32, 0, 0, 0, 0, 0, - 0, 34, 0, 35, 0, 0, 0, 0, 36, 37, - 405, 406, 407, 408, 409, 410, 411, 414, 413, 415, - 416, 417, 418, 419, 420, 421, 422, 423, 424, 0, - 0, 0, 38, 0, 0, 0, 425, 426, 0, 0, - 0, 440, 405, 406, 407, 408, 409, 410, 411, 412, - 413, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 405, 406, 407, 408, 409, 410, - 411, 412, 413, 0, 0, 414, 0, 415, 416, 417, - 418, 419, 420, 421, 422, 423, 424, 405, 406, 407, - 408, 409, 410, 411, 425, 426, 0, 0, 414, 448, - 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, - 0, 0, 0, 0, 0, 0, 0, 425, 426, 0, - 0, 0, 491, 405, 406, 407, 408, 409, 410, 411, - 412, 413, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 405, 406, 407, 408, 409, 410, 411, 0, 0, - 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, - 405, 406, 407, 408, 409, 410, 411, 425, 426, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 414, 0, 415, 416, 417, 418, 419, 420, 421, 422, - 423, 424, 405, 406, 407, 408, 409, 410, 411, 425, - 426, 561, 414, 560, 415, 416, 417, 418, 419, 420, - 421, 422, 423, 424, 0, 0, 0, 0, 0, 0, - 0, 425, 426, 0, 0, 0, 0, 415, 416, 417, - 418, 419, 420, 421, 422, 423, 424, 0, 0, 0, - 0, 0, 0, 0, 425, 426, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 414, 0, 415, 416, 417, 418, 419, 420, 421, - 422, 423, 424, 0, 0, 0, 0, 0, 0, 0, - 425, 426, 416, 417, 418, 419, 420, 421, 422, 423, - 424, 0, 0, 0, 0, 0, 4, 0, 425, 426, - 0, 0, 417, 418, 419, 420, 421, 422, 423, 424, - 0, 0, 0, 0, 0, 0, 0, 425, 426, 0, - 0, 0, 5, 0, 6, 0, 0, 0, 0, 0, - 7, 8, 0, 0, 9, 418, 419, 420, 421, 422, - 423, 424, 0, 0, 0, 11, 0, 12, 0, 425, - 426, 13, 14, 0, 15, 0, 0, 16, 0, 17, - 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, - 0, 0, 0, 0, 4, 0, 20, 0, 21, 22, - 23, 24, 0, 0, 175, 0, 25, 0, 176, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 5, 0, 6, 0, 0, 0, 0, 0, 7, 26, - 0, 0, 9, 27, 28, 29, 0, 0, 30, 0, - 31, 0, 0, 0, 32, 12, 0, 0, 0, 13, - 14, 34, 15, 35, 0, 16, 0, 17, 36, 37, - 0, 0, 0, 0, 18, 0, 0, 0, 0, 4, - 0, 0, 0, 0, 20, 0, 21, 22, 23, 0, - 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 5, 0, 6, 0, 0, - 0, 0, 0, 7, 0, 0, 0, 26, 0, 0, - 0, 27, 28, 29, 0, 0, 30, 0, 31, 0, - 12, 0, 32, 0, 13, 14, 0, 0, 0, 34, - 16, 35, 17, 0, 0, 0, 36, 37, 0, 18, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 21, 22, 23, 0, 0, 0, 0, 0, 25, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 27, 28, 29, 0, - 0, 30, 0, 0, 0, 0, 96, 32, 97, 98, - 99, 0, 100, 101, 34, 102, 35, 0, 103, 0, - 104, 36, 37, 0, 0, 0, 0, 105, 106, 107, - 108, 0, 109, 110, 111, 112, 113, 0, 114, 0, - 115, 116, 117, 0, 0, 118, 0, 0, 0, 0, - 119, 0, 120, 121, 122, 123, 124, 125, 0, 126, - 127, 128, 129, 130, 0, 0, 131, 0, 0, 132, - 0, 0, 0, 0, 133, 134, 0, 135, 0, 0, - 0, 136, 137, 138, 0, 139, 140, 141, 142, 143, - 0, 144, 0, 145, 146, 147, 148, 149, 150, 151, - 152, 0, 153, 154, 155, 0, 0, 0, 156, 0, - 0, 157, 0, 0, 158, 159, 0, 0, 160, 161, - 162, 0, 0, 0, 163, 0, 164, 165, 166, 167, - 0, 0, 168 + 0, 0, 0, 26, 0, 0, 0, 27, 28, 29, + 0, 0, 30, 0, 31, 0, 0, 96, 32, 97, + 98, 99, 0, 100, 101, 34, 102, 35, 0, 103, + 0, 104, 36, 37, 0, 0, 0, 0, 105, 106, + 107, 108, 0, 109, 110, 111, 112, 113, 0, 114, + 0, 115, 116, 117, 0, 0, 118, 0, 0, 0, + 0, 119, 0, 120, 121, 122, 123, 124, 125, 0, + 126, 127, 128, 129, 130, 0, 0, 131, 0, 0, + 132, 0, 0, 0, 0, 133, 134, 0, 135, 0, + 0, 0, 136, 137, 138, 0, 139, 140, 141, 142, + 143, 0, 144, 0, 145, 146, 147, 148, 149, 150, + 151, 152, 0, 153, 154, 155, 0, 0, 0, 156, + 0, 0, 157, 0, 0, 158, 159, 0, 0, 160, + 161, 162, 0, 0, 0, 163, 0, 164, 165, 166, + 167, 0, 0, 168 }; static const yytype_int16 yycheck[] = { - 2, 2, 2, 66, 2, 46, 234, 278, 2, 266, - 254, 235, 2, 484, 238, 280, 240, 473, 67, 243, - 212, 477, 246, 284, 149, 170, 66, 33, 208, 209, - 95, 176, 14, 46, 133, 3, 4, 86, 0, 149, - 149, 63, 64, 65, 133, 225, 46, 69, 46, 174, - 91, 490, 46, 2, 53, 283, 495, 64, 65, 36, - 3, 4, 69, 474, 174, 174, 475, 3, 4, 37, - 149, 48, 231, 42, 42, 234, 175, 149, 3, 4, - 536, 492, 241, 539, 493, 244, 175, 173, 247, 248, - 89, 112, 171, 62, 37, 116, 64, 46, 554, 356, - 280, 37, 174, 574, 149, 170, 42, 274, 352, 8, - 367, 567, 551, 89, 86, 84, 170, 3, 4, 140, - 183, 64, 176, 579, 283, 284, 537, 172, 64, 29, - 297, 298, 108, 542, 170, 35, 170, 8, 106, 10, - 176, 552, 176, 183, 170, 208, 209, 173, 117, 558, - 173, 37, 311, 312, 313, 314, 315, 316, 317, 128, - 384, 129, 225, 106, 12, 13, 14, 170, 208, 209, - 106, 173, 174, 173, 174, 173, 174, 190, 64, 173, - 174, 221, 443, 173, 174, 225, 129, 169, 170, 229, - 170, 159, 172, 129, 216, 466, 32, 172, 34, 176, - 249, 250, 170, 427, 253, 173, 172, 14, 388, 216, - 467, 170, 404, 151, 173, 374, 159, 280, 170, 172, - 106, 173, 446, 159, 172, 25, 8, 170, 28, 175, - 173, 3, 4, 12, 13, 14, 175, 173, 17, 18, - 280, 3, 4, 129, 285, 172, 405, 406, 14, 408, - 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, - 419, 420, 421, 422, 423, 424, 272, 426, 3, 4, - 527, 536, 175, 159, 3, 4, 317, 279, 172, 279, - 460, 279, 172, 285, 443, 279, 551, 173, 294, 481, - 3, 4, 37, 3, 4, 172, 298, 42, 490, 3, - 4, 175, 567, 495, 37, 172, 498, 172, 565, 157, - 158, 159, 160, 161, 579, 3, 4, 175, 172, 64, - 361, 169, 170, 175, 173, 388, 173, 173, 369, 173, - 173, 64, 173, 173, 173, 173, 173, 3, 173, 380, - 173, 404, 173, 383, 572, 386, 173, 173, 388, 529, - 157, 158, 159, 160, 161, 396, 357, 363, 173, 551, - 173, 106, 169, 170, 366, 173, 366, 173, 366, 369, - 594, 369, 366, 106, 173, 369, 155, 156, 157, 158, - 159, 160, 161, 173, 129, 173, 386, 173, 173, 173, - 169, 170, 173, 159, 160, 161, 129, 460, 557, 175, - 175, 560, 172, 169, 170, 172, 177, 172, 8, 8, - 174, 174, 475, 572, 159, 173, 67, 8, 8, 8, - 460, 8, 463, 5, 170, 170, 159, 490, 173, 4, - 493, 472, 495, 173, 475, 172, 151, 170, 172, 175, - 173, 149, 174, 149, 174, 176, 38, 487, 174, 177, - 173, 3, 493, 174, 174, 30, 174, 32, 174, 149, - 174, 8, 174, 38, 39, 174, 529, 42, 169, 174, - 472, 174, 47, 475, 174, 174, 174, 174, 53, 174, - 55, 174, 74, 174, 59, 60, 151, 62, 551, 529, - 65, 493, 67, 172, 86, 87, 88, 80, 176, 74, - 171, 542, 94, 149, 174, 80, 81, 174, 172, 84, - 172, 86, 87, 88, 89, 3, 3, 558, 8, 94, - 174, 5, 174, 172, 4, 172, 174, 151, 151, 531, - 122, 531, 174, 531, 126, 174, 174, 531, 175, 174, - 542, 174, 117, 174, 174, 174, 121, 122, 123, 151, - 30, 126, 32, 128, 172, 44, 558, 132, 38, 2, - 365, 472, 42, 138, 139, 383, 141, 47, 600, 2, - 247, 146, 147, 46, 2, 55, 2, 574, 183, 59, - 60, -1, 62, -1, 245, 65, -1, 67, -1, -1, - -1, -1, -1, -1, 74, 170, -1, -1, -1, -1, - 80, 176, -1, -1, 84, -1, 86, 87, 88, -1, - -1, -1, -1, -1, 94, -1, -1, -1, -1, 4, + 2, 66, 2, 66, 2, 2, 46, 234, 2, 266, + 212, 235, 33, 67, 238, 280, 240, 208, 209, 243, + 278, 2, 246, 46, 284, 254, 15, 485, 37, 43, + 2, 134, 86, 134, 225, 474, 63, 64, 65, 478, + 49, 113, 69, 3, 4, 117, 46, 476, 46, 63, + 231, 91, 46, 234, 64, 65, 283, 150, 0, 69, + 241, 54, 475, 244, 96, 494, 247, 248, 274, 141, + 150, 85, 174, 176, 46, 176, 150, 491, 38, 172, + 493, 150, 496, 43, 171, 38, 87, 174, 150, 280, + 43, 297, 298, 3, 4, 175, 8, 90, 537, 173, + 357, 540, 283, 284, 118, 65, 175, 174, 13, 14, + 15, 368, 65, 175, 543, 129, 555, 575, 183, 8, + 183, 171, 11, 90, 353, 538, 150, 177, 38, 568, + 559, 312, 313, 314, 315, 316, 317, 318, 552, 171, + 553, 580, 109, 208, 209, 208, 209, 107, 3, 4, + 29, 175, 171, 171, 107, 65, 35, 173, 221, 177, + 225, 385, 225, 171, 3, 4, 229, 190, 177, 177, + 130, 173, 174, 173, 174, 173, 174, 130, 173, 173, + 174, 170, 171, 38, 444, 171, 173, 171, 43, 216, + 174, 177, 173, 174, 375, 249, 250, 107, 389, 253, + 160, 176, 171, 405, 428, 174, 216, 160, 15, 467, + 65, 468, 173, 25, 174, 280, 28, 280, 171, 173, + 130, 174, 171, 447, 173, 406, 407, 173, 409, 410, + 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, + 421, 422, 423, 424, 425, 285, 427, 32, 176, 34, + 160, 272, 107, 158, 159, 160, 161, 162, 15, 3, + 4, 171, 173, 444, 174, 170, 171, 3, 4, 152, + 461, 528, 537, 294, 176, 130, 173, 279, 318, 279, + 482, 279, 173, 285, 8, 279, 173, 552, 176, 491, + 3, 4, 3, 4, 496, 176, 298, 499, 3, 4, + 3, 4, 173, 568, 176, 160, 3, 4, 174, 566, + 3, 4, 3, 4, 174, 580, 171, 38, 174, 174, + 174, 384, 362, 174, 389, 38, 389, 174, 174, 3, + 370, 5, 6, 7, 8, 9, 10, 174, 174, 530, + 405, 381, 174, 364, 65, 174, 573, 387, 174, 174, + 552, 174, 65, 160, 161, 162, 174, 397, 174, 174, + 174, 358, 3, 170, 171, 367, 174, 367, 174, 367, + 370, 595, 370, 367, 174, 174, 370, 558, 174, 174, + 561, 174, 174, 173, 173, 176, 107, 387, 176, 173, + 64, 178, 573, 175, 107, 175, 461, 174, 461, 8, + 8, 158, 159, 160, 161, 162, 8, 8, 8, 130, + 8, 476, 68, 170, 171, 5, 171, 130, 174, 173, + 152, 173, 150, 176, 464, 488, 491, 101, 175, 494, + 178, 496, 177, 473, 150, 175, 476, 175, 175, 160, + 174, 3, 175, 150, 175, 175, 175, 160, 175, 175, + 171, 8, 126, 174, 494, 175, 175, 13, 14, 15, + 175, 174, 18, 19, 138, 530, 175, 530, 152, 175, + 81, 473, 170, 175, 476, 175, 175, 150, 173, 175, + 172, 155, 3, 177, 158, 159, 160, 552, 175, 163, + 164, 3, 494, 175, 173, 173, 5, 8, 172, 175, + 174, 173, 173, 543, 4, 175, 175, 175, 175, 175, + 152, 176, 175, 175, 175, 175, 175, 152, 152, 559, + 173, 44, 366, 39, 2, 473, 384, 2, 601, 247, + 532, 31, 532, 33, 532, 2, 46, 2, 532, 39, + 40, 543, 575, 43, 183, -1, -1, -1, 48, -1, + -1, -1, -1, -1, 54, 245, 56, 559, -1, 75, + 60, 61, -1, 63, -1, -1, 66, -1, 68, -1, + -1, 87, 88, 89, -1, 75, -1, -1, -1, 95, + -1, 81, 82, -1, -1, 85, -1, 87, 88, 89, + 90, -1, -1, -1, -1, 95, -1, -1, -1, 4, + 156, 157, 158, 159, 160, 161, 162, 123, -1, -1, + -1, 127, -1, -1, 170, 171, -1, -1, 118, -1, + -1, -1, 122, 123, 124, -1, 31, 127, 33, 129, + -1, -1, -1, 133, 39, -1, -1, -1, 43, 139, + 140, -1, 142, 48, -1, -1, -1, 147, 148, -1, + -1, 56, -1, -1, -1, 60, 61, -1, 63, -1, + -1, 66, -1, 68, -1, -1, -1, -1, -1, -1, + 75, 171, -1, -1, -1, -1, 81, 177, -1, -1, + 85, -1, 87, 88, 89, -1, -1, -1, -1, -1, + 95, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 117, -1, -1, - -1, 121, 122, 123, -1, 30, 126, 32, 128, -1, - -1, -1, 132, 38, -1, -1, -1, 42, 138, 139, - -1, 141, 47, -1, -1, -1, 146, 147, -1, -1, - 55, -1, -1, -1, 59, 60, -1, 62, -1, -1, - 65, -1, 67, -1, -1, -1, -1, -1, -1, 74, - 170, -1, -1, -1, -1, 80, 176, -1, -1, 84, - -1, 86, 87, 88, -1, -1, -1, -1, -1, 94, - -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, + -1, -1, -1, 118, -1, -1, -1, 122, 123, 124, + -1, 31, 127, 33, 129, -1, -1, -1, 133, 39, + -1, -1, -1, 43, 139, 140, -1, 142, 48, -1, + -1, -1, 147, 148, -1, -1, 56, -1, -1, -1, + 60, 61, -1, 63, -1, -1, 66, -1, 68, -1, + -1, -1, -1, -1, -1, 75, 171, -1, -1, -1, + -1, 81, 177, -1, -1, 85, -1, 87, 88, 89, + -1, -1, -1, -1, -1, 95, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 117, -1, -1, -1, 121, 122, 123, -1, - 30, 126, 32, 128, -1, -1, -1, 132, 38, -1, - -1, -1, 42, 138, 139, -1, 141, 47, -1, -1, - -1, 146, 147, -1, -1, 55, -1, -1, -1, 59, - 60, -1, 62, -1, -1, 65, -1, 67, -1, -1, - -1, -1, -1, -1, 74, 170, -1, -1, -1, -1, - 80, 176, -1, -1, 84, -1, 86, 87, 88, -1, - -1, -1, -1, -1, 94, -1, -1, -1, 3, 4, - 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 117, -1, -1, - -1, 121, 122, 123, -1, 30, 126, 32, 128, -1, - -1, -1, 132, 38, -1, -1, -1, 42, 138, 139, - -1, 141, -1, -1, -1, -1, 146, 147, -1, -1, - 55, -1, -1, -1, 59, 60, -1, 62, 63, -1, - 65, -1, 67, -1, -1, -1, -1, -1, -1, 74, - 170, -1, -1, -1, -1, -1, 176, -1, -1, 84, - -1, 86, 87, 88, -1, -1, -1, -1, 3, 94, - 5, 6, 7, 8, 9, 100, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 118, -1, + -1, -1, 122, 123, 124, -1, 31, 127, 33, 129, + -1, -1, -1, 133, 39, -1, -1, -1, 43, 139, + 140, -1, 142, 48, -1, -1, -1, 147, 148, -1, + -1, 56, -1, -1, -1, 60, 61, -1, 63, -1, + -1, 66, -1, 68, -1, -1, -1, -1, -1, -1, + 75, 171, -1, -1, -1, -1, 81, 177, -1, -1, + 85, -1, 87, 88, 89, -1, -1, -1, -1, -1, + 95, -1, -1, 3, 4, 5, 6, 7, 8, 9, + 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 118, -1, -1, -1, 122, 123, 124, + -1, 31, 127, 33, 129, -1, -1, -1, 133, 39, + -1, -1, -1, 43, 139, 140, -1, 142, -1, -1, + -1, -1, 147, 148, -1, -1, 56, -1, -1, -1, + 60, 61, -1, 63, 64, -1, 66, 3, 68, 5, + 6, 7, 8, 9, 10, 75, 171, -1, -1, -1, + -1, -1, 177, -1, -1, 85, -1, 87, 88, 89, + -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, + -1, 101, -1, -1, -1, -1, 3, -1, 5, 6, + 7, 8, 9, 10, -1, -1, 4, -1, 118, -1, + -1, -1, 122, 123, 124, -1, 126, 127, 64, 129, + -1, -1, -1, 133, -1, -1, -1, -1, 138, -1, + 140, -1, 142, 31, -1, 33, -1, 147, 148, -1, + -1, 39, -1, -1, -1, 155, -1, -1, 158, 159, + 160, -1, -1, 163, 164, 101, -1, 64, 56, -1, + -1, -1, 60, 61, 174, -1, -1, -1, 66, -1, + 68, -1, -1, -1, -1, -1, -1, 75, -1, -1, + 126, -1, -1, -1, -1, -1, -1, -1, -1, 87, + 88, 89, 138, -1, 101, -1, -1, 95, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 155, + -1, -1, 158, 159, 160, -1, -1, 163, 164, 126, + -1, -1, -1, -1, 122, 123, 124, -1, 174, 127, + -1, 138, -1, 4, -1, 133, -1, -1, -1, -1, + -1, 12, 140, -1, 142, -1, -1, -1, 155, 147, + 148, 158, 159, 160, -1, -1, 163, 164, -1, -1, + 31, -1, 33, -1, -1, -1, -1, 174, 39, 40, + -1, -1, 43, -1, -1, -1, -1, 48, -1, -1, + -1, -1, -1, 54, -1, 56, -1, -1, -1, 60, + 61, -1, 63, -1, -1, 66, -1, 68, -1, -1, + -1, -1, -1, -1, 75, -1, -1, -1, -1, -1, + 81, 82, -1, -1, 85, -1, 87, 88, 89, 90, + -1, -1, -1, -1, 95, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 117, -1, -1, -1, 121, 122, 123, -1, - 125, 126, -1, 128, -1, -1, -1, 132, -1, -1, - -1, -1, 137, -1, 139, -1, 141, -1, -1, -1, - -1, 146, 147, -1, -1, -1, -1, -1, 63, 154, - -1, -1, 157, 158, 159, -1, -1, 162, 163, -1, - 3, -1, 5, 6, 7, 8, 9, 3, 173, 5, - 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 100, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 118, -1, -1, + -1, 122, 123, 124, -1, 31, 127, 33, 129, -1, + -1, -1, 133, 39, 40, -1, -1, 43, 139, 140, + -1, 142, 48, -1, -1, -1, 147, 148, 54, -1, + 56, -1, -1, -1, 60, 61, -1, 63, -1, -1, + 66, -1, 68, -1, -1, -1, -1, -1, -1, 75, + 171, -1, -1, -1, -1, 81, -1, -1, -1, 85, + -1, 87, 88, 89, 90, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 125, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 63, -1, 137, -1, -1, -1, -1, 63, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, - -1, -1, 157, 158, 159, -1, -1, 162, 163, -1, - -1, -1, -1, -1, -1, -1, 171, 100, 173, -1, - -1, -1, -1, -1, 100, -1, -1, -1, -1, -1, + 4, -1, 118, -1, -1, -1, 122, 123, 124, -1, + -1, 127, -1, 129, -1, -1, -1, 133, -1, -1, + -1, -1, -1, 139, 140, -1, 142, 31, -1, 33, + -1, 147, 148, -1, 38, 39, -1, -1, -1, 43, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 125, -1, -1, -1, -1, -1, -1, 125, - -1, -1, -1, -1, 137, -1, -1, -1, -1, -1, - -1, 137, -1, -1, -1, 4, -1, -1, -1, -1, - -1, 154, 11, -1, 157, 158, 159, -1, 154, 162, - 163, 157, 158, 159, -1, -1, 162, 163, -1, -1, - 173, 30, -1, 32, -1, -1, -1, 173, -1, 38, - 39, -1, -1, 42, -1, -1, -1, -1, 47, -1, - -1, -1, -1, -1, 53, -1, 55, -1, -1, -1, - 59, 60, -1, 62, -1, -1, 65, -1, 67, -1, - -1, -1, -1, -1, -1, 74, -1, -1, -1, -1, - -1, 80, 81, -1, -1, 84, -1, 86, 87, 88, - 89, -1, -1, -1, -1, 94, -1, -1, -1, -1, - 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 117, -1, - -1, -1, 121, 122, 123, -1, 30, 126, 32, 128, - -1, -1, -1, 132, 38, 39, -1, -1, 42, 138, - 139, -1, 141, 47, -1, -1, -1, 146, 147, 53, - -1, 55, -1, -1, -1, 59, 60, -1, 62, -1, - -1, 65, -1, 67, -1, -1, -1, -1, -1, -1, - 74, 170, -1, -1, -1, -1, 80, -1, -1, -1, - 84, -1, 86, 87, 88, 89, -1, -1, -1, -1, - 94, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 56, -1, -1, 171, 60, 61, -1, 63, + -1, 65, 66, -1, 68, -1, -1, -1, -1, -1, + -1, 75, -1, -1, -1, -1, -1, -1, 4, -1, + -1, 85, -1, 87, 88, 89, -1, -1, -1, -1, + -1, 95, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 107, -1, 31, -1, 33, -1, -1, + -1, -1, 38, 39, 118, -1, -1, 43, 122, 123, + 124, -1, -1, 127, -1, 129, 130, -1, -1, 133, + 56, -1, -1, -1, 60, 61, 140, 63, 142, 65, + 66, -1, 68, 147, 148, -1, -1, -1, -1, 75, + -1, -1, -1, -1, -1, -1, 160, -1, -1, 85, + -1, 87, 88, 89, -1, -1, -1, 171, -1, 95, + -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, + -1, 107, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 22, 118, -1, -1, -1, 122, 123, 124, -1, + 31, 127, 33, 129, 130, -1, -1, 133, 39, -1, + -1, -1, 43, -1, 140, -1, 142, -1, -1, -1, + -1, 147, 148, -1, -1, 56, -1, -1, -1, 60, + 61, -1, 63, -1, 160, 66, -1, 68, -1, -1, + -1, -1, -1, -1, 75, 171, -1, -1, -1, -1, + -1, 4, -1, -1, 85, -1, 87, 88, 89, -1, + -1, -1, -1, -1, 95, 13, 14, 15, 16, 17, + 18, 19, 20, 21, -1, -1, -1, -1, 31, -1, + 33, -1, -1, -1, -1, -1, 39, 118, -1, -1, + 43, 122, 123, 124, -1, -1, 127, -1, 129, -1, + -1, -1, 133, 56, -1, -1, -1, 60, 61, 140, + 63, 142, -1, 66, -1, 68, 147, 148, -1, -1, + -1, -1, 75, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 85, -1, 87, 88, 89, -1, -1, -1, + 171, -1, 95, -1, -1, -1, 13, 14, 15, 16, + 17, 18, 19, 20, 21, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 118, -1, -1, -1, 122, + 123, 124, -1, -1, 127, -1, 129, -1, -1, -1, + 133, -1, -1, -1, -1, -1, -1, 140, -1, 142, + -1, -1, -1, -1, 147, 148, 13, 14, 15, 16, + 17, 18, 19, 151, 21, 153, 154, 155, 156, 157, + 158, 159, 160, 161, 162, -1, -1, -1, 171, -1, + -1, -1, 170, 171, -1, -1, -1, 175, 13, 14, + 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 4, 117, -1, -1, -1, 121, 122, 123, - -1, -1, 126, -1, 128, -1, -1, -1, 132, -1, - -1, -1, -1, -1, 138, 139, -1, 141, 30, -1, - 32, -1, 146, 147, -1, 37, 38, -1, -1, -1, - 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 55, -1, -1, 170, 59, 60, -1, - 62, -1, 64, 65, -1, 67, -1, -1, -1, -1, - -1, -1, 74, -1, -1, -1, -1, -1, -1, -1, - 4, -1, 84, -1, 86, 87, 88, -1, -1, -1, - -1, -1, 94, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 106, -1, 30, -1, 32, -1, - -1, -1, -1, 37, 38, 117, -1, -1, 42, 121, - 122, 123, -1, -1, 126, -1, 128, 129, -1, -1, - 132, 55, -1, -1, -1, 59, 60, 139, 62, 141, - 64, 65, -1, 67, 146, 147, -1, -1, -1, -1, - 74, -1, -1, -1, -1, -1, -1, 159, 4, -1, - 84, -1, 86, 87, 88, -1, -1, -1, 170, -1, - 94, -1, -1, -1, -1, 21, -1, -1, -1, -1, - -1, -1, 106, -1, 30, -1, 32, -1, -1, -1, - -1, -1, 38, 117, -1, -1, 42, 121, 122, 123, - -1, -1, 126, -1, 128, 129, -1, -1, 132, 55, - -1, -1, -1, 59, 60, 139, 62, 141, -1, 65, - -1, 67, 146, 147, -1, -1, -1, -1, 74, -1, - -1, -1, -1, -1, -1, 159, 4, -1, 84, -1, - 86, 87, 88, -1, -1, -1, 170, -1, 94, 12, - 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, - -1, -1, 30, -1, 32, -1, -1, -1, -1, -1, - 38, 117, -1, -1, 42, 121, 122, 123, -1, -1, - 126, -1, 128, -1, -1, -1, 132, 55, -1, -1, - -1, 59, 60, 139, 62, 141, -1, 65, -1, 67, - 146, 147, -1, -1, -1, -1, 74, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 84, -1, 86, 87, - 88, -1, -1, -1, 170, -1, 94, -1, -1, -1, - 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 117, - -1, -1, -1, 121, 122, 123, -1, -1, 126, -1, - 128, -1, -1, -1, 132, -1, -1, -1, -1, -1, - -1, 139, -1, 141, -1, -1, -1, -1, 146, 147, - 12, 13, 14, 15, 16, 17, 18, 150, 20, 152, - 153, 154, 155, 156, 157, 158, 159, 160, 161, -1, - -1, -1, 170, -1, -1, -1, 169, 170, -1, -1, - -1, 174, 12, 13, 14, 15, 16, 17, 18, 19, - 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 12, 13, 14, 15, 16, 17, - 18, 19, 20, -1, -1, 150, -1, 152, 153, 154, - 155, 156, 157, 158, 159, 160, 161, 12, 13, 14, - 15, 16, 17, 18, 169, 170, -1, -1, 150, 174, - 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, - -1, -1, -1, -1, -1, -1, -1, 169, 170, -1, - -1, -1, 174, 12, 13, 14, 15, 16, 17, 18, - 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 12, 13, 14, 15, 16, 17, 18, -1, -1, - 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, - 12, 13, 14, 15, 16, 17, 18, 169, 170, -1, + 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, + -1, 151, -1, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 13, 14, 15, 16, 17, 18, 19, + 170, 171, -1, -1, 151, 175, 153, 154, 155, 156, + 157, 158, 159, 160, 161, 162, -1, -1, -1, -1, + -1, -1, -1, 170, 171, -1, -1, -1, 175, 13, + 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 13, 14, 15, + 16, 17, 18, 19, -1, -1, 153, 154, 155, 156, + 157, 158, 159, 160, 161, 162, 13, 14, 15, 16, + 17, 18, 19, 170, 171, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 151, -1, 153, 154, + 155, 156, 157, 158, 159, 160, 161, 162, 13, 14, + 15, 16, 17, 18, 19, 170, 171, 172, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, + -1, -1, -1, -1, -1, -1, -1, 170, 171, -1, + -1, -1, -1, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, -1, -1, -1, -1, -1, -1, -1, + 170, 171, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 151, -1, 153, + 154, 155, 156, 157, 158, 159, 160, 161, 162, -1, + -1, -1, -1, -1, -1, -1, 170, 171, 154, 155, + 156, 157, 158, 159, 160, 161, 162, -1, -1, -1, + -1, 4, -1, -1, 170, 171, -1, -1, 155, 156, + 157, 158, 159, 160, 161, 162, -1, -1, -1, -1, + -1, -1, -1, 170, 171, -1, -1, -1, 31, -1, + 33, -1, -1, -1, -1, -1, 39, 40, -1, -1, + 43, 156, 157, 158, 159, 160, 161, 162, -1, -1, + -1, 54, -1, 56, -1, 170, 171, 60, 61, -1, + 63, -1, -1, 66, -1, 68, -1, -1, -1, -1, + -1, -1, 75, -1, -1, -1, -1, -1, -1, 4, + -1, -1, 85, -1, 87, 88, 89, 90, -1, -1, + 93, -1, 95, -1, 97, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 31, -1, 33, -1, + -1, -1, -1, -1, 39, 118, -1, -1, 43, 122, + 123, 124, -1, -1, 127, -1, 129, -1, -1, -1, + 133, 56, -1, -1, -1, 60, 61, 140, 63, 142, + -1, 66, -1, 68, 147, 148, -1, -1, -1, -1, + 75, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 85, -1, 87, 88, 89, -1, -1, -1, -1, -1, + 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 150, -1, 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 12, 13, 14, 15, 16, 17, 18, 169, - 170, 171, 150, 151, 152, 153, 154, 155, 156, 157, - 158, 159, 160, 161, -1, -1, -1, -1, -1, -1, - -1, 169, 170, -1, -1, -1, -1, 152, 153, 154, - 155, 156, 157, 158, 159, 160, 161, -1, -1, -1, - -1, -1, -1, -1, 169, 170, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 150, -1, 152, 153, 154, 155, 156, 157, 158, - 159, 160, 161, -1, -1, -1, -1, -1, -1, -1, - 169, 170, 153, 154, 155, 156, 157, 158, 159, 160, - 161, -1, -1, -1, -1, -1, 4, -1, 169, 170, - -1, -1, 154, 155, 156, 157, 158, 159, 160, 161, - -1, -1, -1, -1, -1, -1, -1, 169, 170, -1, - -1, -1, 30, -1, 32, -1, -1, -1, -1, -1, - 38, 39, -1, -1, 42, 155, 156, 157, 158, 159, - 160, 161, -1, -1, -1, 53, -1, 55, -1, 169, - 170, 59, 60, -1, 62, -1, -1, 65, -1, 67, - -1, -1, -1, -1, -1, -1, 74, -1, -1, -1, - -1, -1, -1, -1, 4, -1, 84, -1, 86, 87, - 88, 89, -1, -1, 92, -1, 94, -1, 96, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 30, -1, 32, -1, -1, -1, -1, -1, 38, 117, - -1, -1, 42, 121, 122, 123, -1, -1, 126, -1, - 128, -1, -1, -1, 132, 55, -1, -1, -1, 59, - 60, 139, 62, 141, -1, 65, -1, 67, 146, 147, - -1, -1, -1, -1, 74, -1, -1, -1, -1, 4, - -1, -1, -1, -1, 84, -1, 86, 87, 88, -1, - -1, -1, -1, -1, 94, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 30, -1, 32, -1, -1, - -1, -1, -1, 38, -1, -1, -1, 117, -1, -1, - -1, 121, 122, 123, -1, -1, 126, -1, 128, -1, - 55, -1, 132, -1, 59, 60, -1, -1, -1, 139, - 65, 141, 67, -1, -1, -1, 146, 147, -1, 74, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 86, 87, 88, -1, -1, -1, -1, -1, 94, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 121, 122, 123, -1, - -1, 126, -1, -1, -1, -1, 22, 132, 24, 25, - 26, -1, 28, 29, 139, 31, 141, -1, 34, -1, - 36, 146, 147, -1, -1, -1, -1, 43, 44, 45, - 46, -1, 48, 49, 50, 51, 52, -1, 54, -1, - 56, 57, 58, -1, -1, 61, -1, -1, -1, -1, - 66, -1, 68, 69, 70, 71, 72, 73, -1, 75, - 76, 77, 78, 79, -1, -1, 82, -1, -1, 85, - -1, -1, -1, -1, 90, 91, -1, 93, -1, -1, - -1, 97, 98, 99, -1, 101, 102, 103, 104, 105, - -1, 107, -1, 109, 110, 111, 112, 113, 114, 115, - 116, -1, 118, 119, 120, -1, -1, -1, 124, -1, - -1, 127, -1, -1, 130, 131, -1, -1, 134, 135, - 136, -1, -1, -1, 140, -1, 142, 143, 144, 145, - -1, -1, 148 + -1, -1, -1, 118, -1, -1, -1, 122, 123, 124, + -1, -1, 127, -1, 129, -1, -1, 23, 133, 25, + 26, 27, -1, 29, 30, 140, 32, 142, -1, 35, + -1, 37, 147, 148, -1, -1, -1, -1, 44, 45, + 46, 47, -1, 49, 50, 51, 52, 53, -1, 55, + -1, 57, 58, 59, -1, -1, 62, -1, -1, -1, + -1, 67, -1, 69, 70, 71, 72, 73, 74, -1, + 76, 77, 78, 79, 80, -1, -1, 83, -1, -1, + 86, -1, -1, -1, -1, 91, 92, -1, 94, -1, + -1, -1, 98, 99, 100, -1, 102, 103, 104, 105, + 106, -1, 108, -1, 110, 111, 112, 113, 114, 115, + 116, 117, -1, 119, 120, 121, -1, -1, -1, 125, + -1, -1, 128, -1, -1, 131, 132, -1, -1, 135, + 136, 137, -1, -1, -1, 141, -1, 143, 144, 145, + 146, -1, -1, 149 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { - 0, 179, 180, 0, 4, 30, 32, 38, 39, 42, - 47, 53, 55, 59, 60, 62, 65, 67, 74, 80, - 84, 86, 87, 88, 89, 94, 117, 121, 122, 123, - 126, 128, 132, 138, 139, 141, 146, 147, 170, 184, - 185, 186, 187, 188, 191, 192, 199, 210, 224, 228, - 230, 231, 232, 233, 236, 237, 240, 242, 243, 244, - 245, 247, 248, 249, 250, 251, 253, 255, 272, 273, - 274, 275, 3, 4, 173, 3, 4, 3, 4, 226, - 86, 229, 8, 3, 4, 229, 173, 229, 230, 3, - 226, 198, 199, 3, 226, 230, 22, 24, 25, 26, - 28, 29, 31, 34, 36, 43, 44, 45, 46, 48, - 49, 50, 51, 52, 54, 56, 57, 58, 61, 66, - 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, - 79, 82, 85, 90, 91, 93, 97, 98, 99, 101, - 102, 103, 104, 105, 107, 109, 110, 111, 112, 113, - 114, 115, 116, 118, 119, 120, 124, 127, 130, 131, - 134, 135, 136, 140, 142, 143, 144, 145, 148, 200, - 202, 271, 172, 181, 181, 92, 96, 190, 210, 231, - 236, 242, 246, 253, 272, 275, 172, 172, 175, 172, - 175, 172, 183, 172, 151, 241, 175, 254, 255, 254, - 254, 3, 4, 37, 64, 106, 129, 159, 173, 204, - 227, 256, 257, 270, 210, 272, 273, 275, 254, 172, - 8, 175, 172, 273, 175, 253, 133, 175, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 149, 171, 11, 81, 184, 189, - 192, 231, 233, 244, 245, 248, 176, 3, 3, 4, - 175, 270, 234, 108, 238, 242, 3, 4, 175, 182, - 252, 256, 256, 177, 170, 173, 197, 254, 174, 207, - 208, 209, 227, 174, 217, 256, 266, 173, 220, 8, - 227, 3, 5, 6, 7, 8, 9, 63, 100, 125, - 137, 154, 157, 158, 159, 162, 163, 173, 213, 214, - 215, 213, 216, 8, 8, 201, 216, 215, 8, 8, - 215, 8, 215, 213, 67, 215, 211, 212, 213, 271, - 215, 211, 213, 273, 273, 8, 10, 203, 5, 276, - 273, 202, 170, 173, 172, 183, 176, 198, 235, 151, - 95, 198, 222, 239, 172, 175, 182, 176, 184, 199, - 251, 256, 174, 216, 159, 212, 193, 194, 195, 196, - 199, 253, 176, 149, 177, 176, 198, 218, 149, 222, - 176, 199, 219, 222, 174, 174, 173, 213, 213, 213, - 213, 213, 213, 213, 253, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 150, 152, 153, 154, 155, 156, - 157, 158, 159, 160, 161, 169, 170, 149, 174, 174, - 174, 149, 174, 174, 174, 174, 174, 174, 174, 174, - 174, 3, 174, 149, 174, 174, 149, 174, 174, 174, - 174, 174, 169, 174, 174, 202, 8, 183, 245, 151, - 253, 172, 176, 198, 223, 176, 188, 176, 183, 171, - 171, 174, 149, 253, 159, 173, 197, 204, 227, 262, - 264, 265, 209, 215, 253, 275, 256, 174, 172, 172, - 253, 174, 159, 173, 197, 204, 258, 260, 261, 213, - 213, 3, 213, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 3, - 213, 215, 8, 174, 212, 215, 5, 174, 256, 253, - 172, 182, 183, 21, 196, 264, 252, 159, 193, 204, - 263, 264, 173, 197, 262, 268, 269, 172, 225, 227, - 260, 252, 159, 193, 204, 259, 260, 174, 173, 197, - 151, 171, 174, 183, 256, 176, 264, 252, 174, 264, - 174, 193, 151, 267, 149, 172, 175, 174, 260, 252, - 174, 264, 174, 213, 193, 213, 183, 264, 174, 216, - 268, 205, 264, 174, 36, 48, 176, 206, 215, 151, - 151, 172, 221, 222, 221, 172 + 0, 180, 181, 0, 4, 31, 33, 39, 40, 43, + 48, 54, 56, 60, 61, 63, 66, 68, 75, 81, + 85, 87, 88, 89, 90, 95, 118, 122, 123, 124, + 127, 129, 133, 139, 140, 142, 147, 148, 171, 185, + 186, 187, 188, 189, 192, 193, 200, 211, 225, 229, + 231, 232, 233, 234, 237, 238, 241, 243, 244, 245, + 246, 248, 249, 250, 251, 252, 254, 256, 273, 274, + 275, 276, 3, 4, 174, 3, 4, 3, 4, 227, + 87, 230, 8, 3, 4, 230, 174, 230, 231, 3, + 227, 199, 200, 3, 227, 231, 23, 25, 26, 27, + 29, 30, 32, 35, 37, 44, 45, 46, 47, 49, + 50, 51, 52, 53, 55, 57, 58, 59, 62, 67, + 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, + 80, 83, 86, 91, 92, 94, 98, 99, 100, 102, + 103, 104, 105, 106, 108, 110, 111, 112, 113, 114, + 115, 116, 117, 119, 120, 121, 125, 128, 131, 132, + 135, 136, 137, 141, 143, 144, 145, 146, 149, 201, + 203, 272, 173, 182, 182, 93, 97, 191, 211, 232, + 237, 243, 247, 254, 273, 276, 173, 173, 176, 173, + 176, 173, 184, 173, 152, 242, 176, 255, 256, 255, + 255, 3, 4, 38, 65, 107, 130, 160, 174, 205, + 228, 257, 258, 271, 211, 273, 274, 276, 255, 173, + 8, 176, 173, 274, 176, 254, 134, 176, 174, 174, + 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, + 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, + 174, 174, 174, 174, 150, 172, 12, 82, 185, 190, + 193, 232, 234, 245, 246, 249, 177, 3, 3, 4, + 176, 271, 235, 109, 239, 243, 3, 4, 176, 183, + 253, 257, 257, 178, 171, 174, 198, 255, 175, 208, + 209, 210, 228, 175, 218, 257, 267, 174, 221, 8, + 228, 3, 5, 6, 7, 8, 9, 10, 64, 101, + 126, 138, 155, 158, 159, 160, 163, 164, 174, 214, + 215, 216, 214, 217, 8, 8, 202, 217, 216, 8, + 8, 216, 8, 216, 214, 68, 216, 212, 213, 214, + 272, 216, 212, 214, 274, 274, 8, 11, 204, 5, + 277, 274, 203, 171, 174, 173, 184, 177, 199, 236, + 152, 96, 199, 223, 240, 173, 176, 183, 177, 185, + 200, 252, 257, 175, 217, 160, 213, 194, 195, 196, + 197, 200, 254, 177, 150, 178, 177, 199, 219, 150, + 223, 177, 200, 220, 223, 175, 175, 174, 214, 214, + 214, 214, 214, 214, 214, 254, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 151, 153, 154, 155, 156, + 157, 158, 159, 160, 161, 162, 170, 171, 150, 175, + 175, 175, 150, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 3, 175, 150, 175, 175, 150, 175, 175, + 175, 175, 175, 170, 175, 175, 203, 8, 184, 246, + 152, 254, 173, 177, 199, 224, 177, 189, 177, 184, + 172, 172, 175, 150, 254, 160, 174, 198, 205, 228, + 263, 265, 266, 210, 216, 254, 276, 257, 175, 173, + 173, 254, 175, 160, 174, 198, 205, 259, 261, 262, + 214, 214, 3, 214, 214, 214, 214, 214, 214, 214, + 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, + 3, 214, 216, 8, 175, 213, 216, 5, 175, 257, + 254, 173, 183, 184, 22, 197, 265, 253, 160, 194, + 205, 264, 265, 174, 198, 263, 269, 270, 173, 226, + 228, 261, 253, 160, 194, 205, 260, 261, 175, 174, + 198, 152, 172, 175, 184, 257, 177, 265, 253, 175, + 265, 175, 194, 152, 268, 150, 173, 176, 175, 261, + 253, 175, 265, 175, 214, 194, 214, 184, 265, 175, + 217, 269, 206, 265, 175, 37, 49, 177, 207, 216, + 152, 152, 173, 222, 223, 222, 173 }; #define yyerrok (yyerrstatus = 0) @@ -3755,350 +3746,357 @@ yyreduce: /* Line 1455 of yacc.c */ #line 635 "parser.y" - { (yyval.expr) = make_exprs(EXPR_IDENTIFIER, (yyvsp[(1) - (1)].str)); ;} + { (yyval.expr) = make_exprs(EXPR_CHARCONST, (yyvsp[(1) - (1)].str)); ;} break; case 164: /* Line 1455 of yacc.c */ #line 636 "parser.y" - { (yyval.expr) = make_expr3(EXPR_COND, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} + { (yyval.expr) = make_exprs(EXPR_IDENTIFIER, (yyvsp[(1) - (1)].str)); ;} break; case 165: /* Line 1455 of yacc.c */ #line 637 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LOGOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr3(EXPR_COND, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} break; case 166: /* Line 1455 of yacc.c */ #line 638 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LOGAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_LOGOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 167: /* Line 1455 of yacc.c */ #line 639 "parser.y" - { (yyval.expr) = make_expr2(EXPR_OR , (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_LOGAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 168: /* Line 1455 of yacc.c */ #line 640 "parser.y" - { (yyval.expr) = make_expr2(EXPR_XOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_OR , (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 169: /* Line 1455 of yacc.c */ #line 641 "parser.y" - { (yyval.expr) = make_expr2(EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_XOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 170: /* Line 1455 of yacc.c */ #line 642 "parser.y" - { (yyval.expr) = make_expr2(EXPR_EQUALITY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 171: /* Line 1455 of yacc.c */ #line 643 "parser.y" - { (yyval.expr) = make_expr2(EXPR_INEQUALITY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_EQUALITY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 172: /* Line 1455 of yacc.c */ #line 644 "parser.y" - { (yyval.expr) = make_expr2(EXPR_GTR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_INEQUALITY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 173: /* Line 1455 of yacc.c */ #line 645 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LESS, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_GTR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 174: /* Line 1455 of yacc.c */ #line 646 "parser.y" - { (yyval.expr) = make_expr2(EXPR_GTREQL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_LESS, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 175: /* Line 1455 of yacc.c */ #line 647 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LESSEQL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_GTREQL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 176: /* Line 1455 of yacc.c */ #line 648 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SHL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_LESSEQL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 177: /* Line 1455 of yacc.c */ #line 649 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SHR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_SHL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 178: /* Line 1455 of yacc.c */ #line 650 "parser.y" - { (yyval.expr) = make_expr2(EXPR_ADD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_SHR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 179: /* Line 1455 of yacc.c */ #line 651 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SUB, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_ADD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 180: /* Line 1455 of yacc.c */ #line 652 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MOD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_SUB, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 181: /* Line 1455 of yacc.c */ #line 653 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MUL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_MOD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 182: /* Line 1455 of yacc.c */ #line 654 "parser.y" - { (yyval.expr) = make_expr2(EXPR_DIV, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_MUL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 183: /* Line 1455 of yacc.c */ #line 655 "parser.y" - { (yyval.expr) = make_expr1(EXPR_LOGNOT, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.expr) = make_expr2(EXPR_DIV, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 184: /* Line 1455 of yacc.c */ #line 656 "parser.y" - { (yyval.expr) = make_expr1(EXPR_NOT, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.expr) = make_expr1(EXPR_LOGNOT, (yyvsp[(2) - (2)].expr)); ;} break; case 185: /* Line 1455 of yacc.c */ #line 657 "parser.y" - { (yyval.expr) = make_expr1(EXPR_POS, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.expr) = make_expr1(EXPR_NOT, (yyvsp[(2) - (2)].expr)); ;} break; case 186: /* Line 1455 of yacc.c */ #line 658 "parser.y" - { (yyval.expr) = make_expr1(EXPR_NEG, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.expr) = make_expr1(EXPR_POS, (yyvsp[(2) - (2)].expr)); ;} break; case 187: /* Line 1455 of yacc.c */ #line 659 "parser.y" - { (yyval.expr) = make_expr1(EXPR_ADDRESSOF, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.expr) = make_expr1(EXPR_NEG, (yyvsp[(2) - (2)].expr)); ;} break; case 188: /* Line 1455 of yacc.c */ #line 660 "parser.y" - { (yyval.expr) = make_expr1(EXPR_PPTR, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.expr) = make_expr1(EXPR_ADDRESSOF, (yyvsp[(2) - (2)].expr)); ;} break; case 189: /* Line 1455 of yacc.c */ #line 661 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, (yyvsp[(1) - (3)].expr)), make_exprs(EXPR_IDENTIFIER, (yyvsp[(3) - (3)].str))); ;} + { (yyval.expr) = make_expr1(EXPR_PPTR, (yyvsp[(2) - (2)].expr)); ;} break; case 190: /* Line 1455 of yacc.c */ #line 662 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MEMBER, (yyvsp[(1) - (3)].expr), make_exprs(EXPR_IDENTIFIER, (yyvsp[(3) - (3)].str))); ;} + { (yyval.expr) = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, (yyvsp[(1) - (3)].expr)), make_exprs(EXPR_IDENTIFIER, (yyvsp[(3) - (3)].str))); ;} break; case 191: /* Line 1455 of yacc.c */ -#line 664 "parser.y" - { (yyval.expr) = make_exprt(EXPR_CAST, declare_var(NULL, (yyvsp[(2) - (5)].declspec), (yyvsp[(3) - (5)].declarator), 0), (yyvsp[(5) - (5)].expr)); free((yyvsp[(2) - (5)].declspec)); free((yyvsp[(3) - (5)].declarator)); ;} +#line 663 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MEMBER, (yyvsp[(1) - (3)].expr), make_exprs(EXPR_IDENTIFIER, (yyvsp[(3) - (3)].str))); ;} break; case 192: /* Line 1455 of yacc.c */ -#line 666 "parser.y" - { (yyval.expr) = make_exprt(EXPR_SIZEOF, declare_var(NULL, (yyvsp[(3) - (5)].declspec), (yyvsp[(4) - (5)].declarator), 0), NULL); free((yyvsp[(3) - (5)].declspec)); free((yyvsp[(4) - (5)].declarator)); ;} +#line 665 "parser.y" + { (yyval.expr) = make_exprt(EXPR_CAST, declare_var(NULL, (yyvsp[(2) - (5)].declspec), (yyvsp[(3) - (5)].declarator), 0), (yyvsp[(5) - (5)].expr)); free((yyvsp[(2) - (5)].declspec)); free((yyvsp[(3) - (5)].declarator)); ;} break; case 193: /* Line 1455 of yacc.c */ #line 667 "parser.y" - { (yyval.expr) = make_expr2(EXPR_ARRAY, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} + { (yyval.expr) = make_exprt(EXPR_SIZEOF, declare_var(NULL, (yyvsp[(3) - (5)].declspec), (yyvsp[(4) - (5)].declarator), 0), NULL); free((yyvsp[(3) - (5)].declspec)); free((yyvsp[(4) - (5)].declarator)); ;} break; case 194: /* Line 1455 of yacc.c */ #line 668 "parser.y" - { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + { (yyval.expr) = make_expr2(EXPR_ARRAY, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} break; case 195: /* Line 1455 of yacc.c */ -#line 671 "parser.y" - { (yyval.expr_list) = append_expr( NULL, (yyvsp[(1) - (1)].expr) ); ;} +#line 669 "parser.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} break; case 196: /* Line 1455 of yacc.c */ #line 672 "parser.y" - { (yyval.expr_list) = append_expr( (yyvsp[(1) - (3)].expr_list), (yyvsp[(3) - (3)].expr) ); ;} + { (yyval.expr_list) = append_expr( NULL, (yyvsp[(1) - (1)].expr) ); ;} break; case 197: /* Line 1455 of yacc.c */ -#line 675 "parser.y" +#line 673 "parser.y" + { (yyval.expr_list) = append_expr( (yyvsp[(1) - (3)].expr_list), (yyvsp[(3) - (3)].expr) ); ;} + break; + + case 198: + +/* Line 1455 of yacc.c */ +#line 676 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); if (!(yyval.expr)->is_const) error_loc("expression is not an integer constant\n"); ;} break; - case 198: + case 199: /* Line 1455 of yacc.c */ -#line 681 "parser.y" +#line 682 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); if (!(yyval.expr)->is_const && (yyval.expr)->type != EXPR_STRLIT && (yyval.expr)->type != EXPR_WSTRLIT) error_loc("expression is not constant\n"); ;} break; - case 199: - -/* Line 1455 of yacc.c */ -#line 687 "parser.y" - { (yyval.var_list) = NULL; ;} - break; - case 200: /* Line 1455 of yacc.c */ #line 688 "parser.y" - { (yyval.var_list) = append_var_list((yyvsp[(1) - (2)].var_list), (yyvsp[(2) - (2)].var_list)); ;} + { (yyval.var_list) = NULL; ;} break; case 201: /* Line 1455 of yacc.c */ -#line 692 "parser.y" +#line 689 "parser.y" + { (yyval.var_list) = append_var_list((yyvsp[(1) - (2)].var_list), (yyvsp[(2) - (2)].var_list)); ;} + break; + + case 202: + +/* Line 1455 of yacc.c */ +#line 693 "parser.y" { const char *first = LIST_ENTRY(list_head((yyvsp[(3) - (4)].declarator_list)), declarator_t, entry)->var->name; check_field_attrs(first, (yyvsp[(1) - (4)].attr_list)); (yyval.var_list) = set_var_types((yyvsp[(1) - (4)].attr_list), (yyvsp[(2) - (4)].declspec), (yyvsp[(3) - (4)].declarator_list)); ;} break; - case 202: + case 203: /* Line 1455 of yacc.c */ -#line 696 "parser.y" +#line 697 "parser.y" { var_t *v = make_var(NULL); v->type = (yyvsp[(2) - (3)].type); v->attrs = (yyvsp[(1) - (3)].attr_list); (yyval.var_list) = append_var(NULL, v); ;} break; - case 203: - -/* Line 1455 of yacc.c */ -#line 703 "parser.y" - { (yyval.var) = (yyvsp[(1) - (2)].var); ;} - break; - case 204: /* Line 1455 of yacc.c */ #line 704 "parser.y" - { (yyval.var) = make_var(NULL); (yyval.var)->attrs = (yyvsp[(1) - (2)].attr_list); ;} + { (yyval.var) = (yyvsp[(1) - (2)].var); ;} break; case 205: /* Line 1455 of yacc.c */ -#line 707 "parser.y" - { (yyval.var_list) = NULL; ;} +#line 705 "parser.y" + { (yyval.var) = make_var(NULL); (yyval.var)->attrs = (yyvsp[(1) - (2)].attr_list); ;} break; case 206: /* Line 1455 of yacc.c */ #line 708 "parser.y" - { (yyval.var_list) = append_var( (yyvsp[(1) - (2)].var_list), (yyvsp[(2) - (2)].var) ); ;} + { (yyval.var_list) = NULL; ;} break; case 207: /* Line 1455 of yacc.c */ -#line 712 "parser.y" - { (yyval.var) = (yyvsp[(1) - (2)].var); ;} +#line 709 "parser.y" + { (yyval.var_list) = append_var( (yyvsp[(1) - (2)].var_list), (yyvsp[(2) - (2)].var) ); ;} break; case 208: /* Line 1455 of yacc.c */ #line 713 "parser.y" - { (yyval.var) = NULL; ;} + { (yyval.var) = (yyvsp[(1) - (2)].var); ;} break; case 209: /* Line 1455 of yacc.c */ -#line 716 "parser.y" +#line 714 "parser.y" + { (yyval.var) = NULL; ;} + break; + + case 210: + +/* Line 1455 of yacc.c */ +#line 717 "parser.y" { (yyval.var) = declare_var(check_field_attrs((yyvsp[(3) - (3)].declarator)->var->name, (yyvsp[(1) - (3)].attr_list)), (yyvsp[(2) - (3)].declspec), (yyvsp[(3) - (3)].declarator), FALSE); free((yyvsp[(3) - (3)].declarator)); ;} break; - case 210: + case 211: /* Line 1455 of yacc.c */ -#line 723 "parser.y" +#line 724 "parser.y" { var_t *v; v = declare_var(check_function_attrs((yyvsp[(3) - (3)].declarator)->var->name, (yyvsp[(1) - (3)].attr_list)), (yyvsp[(2) - (3)].declspec), (yyvsp[(3) - (3)].declarator), FALSE); @@ -4107,43 +4105,36 @@ yyreduce: ;} break; - case 211: - -/* Line 1455 of yacc.c */ -#line 733 "parser.y" - { (yyval.var) = declare_var((yyvsp[(1) - (3)].attr_list), (yyvsp[(2) - (3)].declspec), (yyvsp[(3) - (3)].declarator), FALSE); - free((yyvsp[(3) - (3)].declarator)); - ;} - break; - case 212: /* Line 1455 of yacc.c */ -#line 736 "parser.y" - { (yyval.var) = declare_var(NULL, (yyvsp[(1) - (2)].declspec), (yyvsp[(2) - (2)].declarator), FALSE); - free((yyvsp[(2) - (2)].declarator)); +#line 734 "parser.y" + { (yyval.var) = declare_var((yyvsp[(1) - (3)].attr_list), (yyvsp[(2) - (3)].declspec), (yyvsp[(3) - (3)].declarator), FALSE); + free((yyvsp[(3) - (3)].declarator)); ;} break; case 213: /* Line 1455 of yacc.c */ -#line 741 "parser.y" - { (yyval.var) = NULL; ;} +#line 737 "parser.y" + { (yyval.var) = declare_var(NULL, (yyvsp[(1) - (2)].declspec), (yyvsp[(2) - (2)].declarator), FALSE); + free((yyvsp[(2) - (2)].declarator)); + ;} break; - case 215: + case 214: /* Line 1455 of yacc.c */ -#line 745 "parser.y" - { (yyval.str) = NULL; ;} +#line 742 "parser.y" + { (yyval.var) = NULL; ;} break; case 216: /* Line 1455 of yacc.c */ #line 746 "parser.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} + { (yyval.str) = NULL; ;} break; case 217: @@ -4156,22 +4147,22 @@ yyreduce: case 218: /* Line 1455 of yacc.c */ -#line 750 "parser.y" - { (yyval.var) = make_var((yyvsp[(1) - (1)].str)); ;} +#line 748 "parser.y" + { (yyval.str) = (yyvsp[(1) - (1)].str); ;} break; case 219: /* Line 1455 of yacc.c */ -#line 752 "parser.y" +#line 751 "parser.y" { (yyval.var) = make_var((yyvsp[(1) - (1)].str)); ;} break; case 220: /* Line 1455 of yacc.c */ -#line 755 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} +#line 753 "parser.y" + { (yyval.var) = make_var((yyvsp[(1) - (1)].str)); ;} break; case 221: @@ -4181,32 +4172,32 @@ yyreduce: { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} break; - case 223: + case 222: /* Line 1455 of yacc.c */ -#line 758 "parser.y" - { (yyval.type) = type_new_int(type_basic_get_type((yyvsp[(2) - (2)].type)), -1); ;} +#line 757 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} break; case 224: /* Line 1455 of yacc.c */ #line 759 "parser.y" - { (yyval.type) = type_new_int(type_basic_get_type((yyvsp[(2) - (2)].type)), 1); ;} + { (yyval.type) = type_new_int(type_basic_get_type((yyvsp[(2) - (2)].type)), -1); ;} break; case 225: /* Line 1455 of yacc.c */ #line 760 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT, 1); ;} + { (yyval.type) = type_new_int(type_basic_get_type((yyvsp[(2) - (2)].type)), 1); ;} break; case 226: /* Line 1455 of yacc.c */ #line 761 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + { (yyval.type) = type_new_int(TYPE_BASIC_INT, 1); ;} break; case 227: @@ -4237,73 +4228,80 @@ yyreduce: { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} break; - case 233: + case 231: /* Line 1455 of yacc.c */ -#line 772 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT, 0); ;} +#line 766 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} break; case 234: /* Line 1455 of yacc.c */ #line 773 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT16, 0); ;} + { (yyval.type) = type_new_int(TYPE_BASIC_INT, 0); ;} break; case 235: /* Line 1455 of yacc.c */ #line 774 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT8, 0); ;} + { (yyval.type) = type_new_int(TYPE_BASIC_INT16, 0); ;} break; case 236: /* Line 1455 of yacc.c */ #line 775 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT32, 0); ;} + { (yyval.type) = type_new_int(TYPE_BASIC_INT8, 0); ;} break; case 237: /* Line 1455 of yacc.c */ #line 776 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_HYPER, 0); ;} + { (yyval.type) = type_new_int(TYPE_BASIC_INT32, 0); ;} break; case 238: /* Line 1455 of yacc.c */ #line 777 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT64, 0); ;} + { (yyval.type) = type_new_int(TYPE_BASIC_HYPER, 0); ;} break; case 239: /* Line 1455 of yacc.c */ #line 778 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_CHAR, 0); ;} + { (yyval.type) = type_new_int(TYPE_BASIC_INT64, 0); ;} break; case 240: /* Line 1455 of yacc.c */ #line 779 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT3264, 0); ;} + { (yyval.type) = type_new_int(TYPE_BASIC_CHAR, 0); ;} break; case 241: /* Line 1455 of yacc.c */ -#line 782 "parser.y" - { (yyval.type) = type_new_coclass((yyvsp[(2) - (2)].str)); ;} +#line 780 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_INT3264, 0); ;} break; case 242: /* Line 1455 of yacc.c */ #line 783 "parser.y" + { (yyval.type) = type_new_coclass((yyvsp[(2) - (2)].str)); ;} + break; + + case 243: + +/* Line 1455 of yacc.c */ +#line 784 "parser.y" { (yyval.type) = find_type((yyvsp[(2) - (2)].str), 0); if (type_get_type_detect_alias((yyval.type)) != TYPE_COCLASS) error_loc("%s was not declared a coclass at %s:%d\n", @@ -4312,49 +4310,42 @@ yyreduce: ;} break; - case 243: + case 244: /* Line 1455 of yacc.c */ -#line 791 "parser.y" +#line 792 "parser.y" { (yyval.type) = (yyvsp[(2) - (2)].type); check_def((yyval.type)); (yyval.type)->attrs = check_coclass_attrs((yyvsp[(2) - (2)].type)->name, (yyvsp[(1) - (2)].attr_list)); ;} break; - case 244: - -/* Line 1455 of yacc.c */ -#line 798 "parser.y" - { (yyval.type) = type_coclass_define((yyvsp[(1) - (5)].type), (yyvsp[(3) - (5)].ifref_list)); ;} - break; - case 245: /* Line 1455 of yacc.c */ -#line 801 "parser.y" - { (yyval.ifref_list) = NULL; ;} +#line 799 "parser.y" + { (yyval.type) = type_coclass_define((yyvsp[(1) - (5)].type), (yyvsp[(3) - (5)].ifref_list)); ;} break; case 246: /* Line 1455 of yacc.c */ #line 802 "parser.y" - { (yyval.ifref_list) = append_ifref( (yyvsp[(1) - (2)].ifref_list), (yyvsp[(2) - (2)].ifref) ); ;} + { (yyval.ifref_list) = NULL; ;} break; case 247: /* Line 1455 of yacc.c */ -#line 806 "parser.y" - { (yyval.ifref) = make_ifref((yyvsp[(2) - (2)].type)); (yyval.ifref)->attrs = (yyvsp[(1) - (2)].attr_list); ;} +#line 803 "parser.y" + { (yyval.ifref_list) = append_ifref( (yyvsp[(1) - (2)].ifref_list), (yyvsp[(2) - (2)].ifref) ); ;} break; case 248: /* Line 1455 of yacc.c */ -#line 809 "parser.y" - { (yyval.type) = get_type(TYPE_INTERFACE, (yyvsp[(2) - (2)].str), 0); ;} +#line 807 "parser.y" + { (yyval.ifref) = make_ifref((yyvsp[(2) - (2)].type)); (yyval.ifref)->attrs = (yyvsp[(1) - (2)].attr_list); ;} break; case 249: @@ -4367,7 +4358,14 @@ yyreduce: case 250: /* Line 1455 of yacc.c */ -#line 813 "parser.y" +#line 811 "parser.y" + { (yyval.type) = get_type(TYPE_INTERFACE, (yyvsp[(2) - (2)].str), 0); ;} + break; + + case 251: + +/* Line 1455 of yacc.c */ +#line 814 "parser.y" { attr_t *attrs; is_object_interface = TRUE; (yyval.type) = (yyvsp[(2) - (2)].type); @@ -4378,71 +4376,64 @@ yyreduce: ;} break; - case 251: - -/* Line 1455 of yacc.c */ -#line 823 "parser.y" - { (yyval.var_list) = NULL; ;} - break; - case 252: /* Line 1455 of yacc.c */ #line 824 "parser.y" - { (yyval.var_list) = append_var( (yyvsp[(1) - (3)].var_list), (yyvsp[(2) - (3)].var) ); ;} + { (yyval.var_list) = NULL; ;} break; case 253: /* Line 1455 of yacc.c */ -#line 827 "parser.y" - { (yyval.stmt_list) = NULL; ;} +#line 825 "parser.y" + { (yyval.var_list) = append_var( (yyvsp[(1) - (3)].var_list), (yyvsp[(2) - (3)].var) ); ;} break; case 254: /* Line 1455 of yacc.c */ #line 828 "parser.y" - { (yyval.stmt_list) = append_func( (yyvsp[(1) - (3)].stmt_list), (yyvsp[(2) - (3)].func) ); ;} + { (yyval.stmt_list) = NULL; ;} break; case 255: /* Line 1455 of yacc.c */ -#line 834 "parser.y" - { (yyval.type) = (yyvsp[(1) - (5)].type); - type_dispinterface_define((yyval.type), (yyvsp[(3) - (5)].var_list), (yyvsp[(4) - (5)].stmt_list)); - ;} +#line 829 "parser.y" + { (yyval.stmt_list) = append_func( (yyvsp[(1) - (3)].stmt_list), (yyvsp[(2) - (3)].func) ); ;} break; case 256: /* Line 1455 of yacc.c */ -#line 838 "parser.y" +#line 835 "parser.y" { (yyval.type) = (yyvsp[(1) - (5)].type); - type_dispinterface_define_from_iface((yyval.type), (yyvsp[(3) - (5)].type)); + type_dispinterface_define((yyval.type), (yyvsp[(3) - (5)].var_list), (yyvsp[(4) - (5)].stmt_list)); ;} break; case 257: /* Line 1455 of yacc.c */ -#line 843 "parser.y" - { (yyval.type) = NULL; ;} +#line 839 "parser.y" + { (yyval.type) = (yyvsp[(1) - (5)].type); + type_dispinterface_define_from_iface((yyval.type), (yyvsp[(3) - (5)].type)); + ;} break; case 258: /* Line 1455 of yacc.c */ #line 844 "parser.y" - { (yyval.type) = find_type_or_error2((yyvsp[(2) - (2)].str), 0); ;} + { (yyval.type) = NULL; ;} break; case 259: /* Line 1455 of yacc.c */ -#line 847 "parser.y" - { (yyval.type) = get_type(TYPE_INTERFACE, (yyvsp[(2) - (2)].str), 0); ;} +#line 845 "parser.y" + { (yyval.type) = find_type_or_error2((yyvsp[(2) - (2)].str), 0); is_object_interface = 1; ;} break; case 260: @@ -4455,49 +4446,49 @@ yyreduce: case 261: /* Line 1455 of yacc.c */ -#line 851 "parser.y" - { (yyval.ifinfo).interface = (yyvsp[(2) - (2)].type); - (yyval.ifinfo).old_pointer_default = pointer_default; - if (is_attr((yyvsp[(1) - (2)].attr_list), ATTR_POINTERDEFAULT)) - pointer_default = get_attrv((yyvsp[(1) - (2)].attr_list), ATTR_POINTERDEFAULT); - is_object_interface = is_object((yyvsp[(1) - (2)].attr_list)); - check_def((yyvsp[(2) - (2)].type)); - (yyvsp[(2) - (2)].type)->attrs = check_iface_attrs((yyvsp[(2) - (2)].type)->name, (yyvsp[(1) - (2)].attr_list)); - (yyvsp[(2) - (2)].type)->defined = TRUE; - ;} +#line 849 "parser.y" + { (yyval.type) = get_type(TYPE_INTERFACE, (yyvsp[(2) - (2)].str), 0); ;} break; case 262: /* Line 1455 of yacc.c */ -#line 863 "parser.y" - { (yyval.type) = (yyvsp[(1) - (6)].ifinfo).interface; - type_interface_define((yyval.type), (yyvsp[(2) - (6)].type), (yyvsp[(4) - (6)].stmt_list)); - pointer_default = (yyvsp[(1) - (6)].ifinfo).old_pointer_default; +#line 852 "parser.y" + { (yyval.ifinfo).interface = (yyvsp[(2) - (2)].type); + (yyval.ifinfo).old_pointer_default = pointer_default; + if (is_attr((yyvsp[(1) - (2)].attr_list), ATTR_POINTERDEFAULT)) + pointer_default = get_attrv((yyvsp[(1) - (2)].attr_list), ATTR_POINTERDEFAULT); + check_def((yyvsp[(2) - (2)].type)); + (yyvsp[(2) - (2)].type)->attrs = check_iface_attrs((yyvsp[(2) - (2)].type)->name, (yyvsp[(1) - (2)].attr_list)); + is_object_interface = is_object((yyvsp[(2) - (2)].type)); + (yyvsp[(2) - (2)].type)->defined = TRUE; ;} break; case 263: /* Line 1455 of yacc.c */ -#line 871 "parser.y" - { (yyval.type) = (yyvsp[(1) - (8)].ifinfo).interface; - type_interface_define((yyval.type), find_type_or_error2((yyvsp[(3) - (8)].str), 0), (yyvsp[(6) - (8)].stmt_list)); - pointer_default = (yyvsp[(1) - (8)].ifinfo).old_pointer_default; +#line 864 "parser.y" + { (yyval.type) = (yyvsp[(1) - (6)].ifinfo).interface; + type_interface_define((yyval.type), (yyvsp[(2) - (6)].type), (yyvsp[(4) - (6)].stmt_list)); + pointer_default = (yyvsp[(1) - (6)].ifinfo).old_pointer_default; ;} break; case 264: /* Line 1455 of yacc.c */ -#line 875 "parser.y" - { (yyval.type) = (yyvsp[(1) - (2)].type); ;} +#line 872 "parser.y" + { (yyval.type) = (yyvsp[(1) - (8)].ifinfo).interface; + type_interface_define((yyval.type), find_type_or_error2((yyvsp[(3) - (8)].str), 0), (yyvsp[(6) - (8)].stmt_list)); + pointer_default = (yyvsp[(1) - (8)].ifinfo).old_pointer_default; + ;} break; case 265: /* Line 1455 of yacc.c */ -#line 879 "parser.y" +#line 876 "parser.y" { (yyval.type) = (yyvsp[(1) - (2)].type); ;} break; @@ -4511,8 +4502,8 @@ yyreduce: case 267: /* Line 1455 of yacc.c */ -#line 883 "parser.y" - { (yyval.type) = type_new_module((yyvsp[(2) - (2)].str)); ;} +#line 881 "parser.y" + { (yyval.type) = (yyvsp[(1) - (2)].type); ;} break; case 268: @@ -4525,96 +4516,96 @@ yyreduce: case 269: /* Line 1455 of yacc.c */ -#line 887 "parser.y" - { (yyval.type) = (yyvsp[(2) - (2)].type); - (yyval.type)->attrs = check_module_attrs((yyvsp[(2) - (2)].type)->name, (yyvsp[(1) - (2)].attr_list)); - ;} +#line 885 "parser.y" + { (yyval.type) = type_new_module((yyvsp[(2) - (2)].str)); ;} break; case 270: /* Line 1455 of yacc.c */ -#line 893 "parser.y" - { (yyval.type) = (yyvsp[(1) - (5)].type); - type_module_define((yyval.type), (yyvsp[(3) - (5)].stmt_list)); +#line 888 "parser.y" + { (yyval.type) = (yyvsp[(2) - (2)].type); + (yyval.type)->attrs = check_module_attrs((yyvsp[(2) - (2)].type)->name, (yyvsp[(1) - (2)].attr_list)); ;} break; case 271: /* Line 1455 of yacc.c */ -#line 899 "parser.y" - { (yyval.stgclass) = STG_EXTERN; ;} +#line 894 "parser.y" + { (yyval.type) = (yyvsp[(1) - (5)].type); + type_module_define((yyval.type), (yyvsp[(3) - (5)].stmt_list)); + ;} break; case 272: /* Line 1455 of yacc.c */ #line 900 "parser.y" - { (yyval.stgclass) = STG_STATIC; ;} + { (yyval.stgclass) = STG_EXTERN; ;} break; case 273: /* Line 1455 of yacc.c */ #line 901 "parser.y" - { (yyval.stgclass) = STG_REGISTER; ;} + { (yyval.stgclass) = STG_STATIC; ;} break; case 274: /* Line 1455 of yacc.c */ -#line 905 "parser.y" - { (yyval.attr) = make_attr(ATTR_INLINE); ;} +#line 902 "parser.y" + { (yyval.stgclass) = STG_REGISTER; ;} break; case 275: /* Line 1455 of yacc.c */ -#line 909 "parser.y" - { (yyval.attr) = make_attr(ATTR_CONST); ;} +#line 906 "parser.y" + { (yyval.attr) = make_attr(ATTR_INLINE); ;} break; case 276: /* Line 1455 of yacc.c */ -#line 912 "parser.y" - { (yyval.attr_list) = NULL; ;} +#line 910 "parser.y" + { (yyval.attr) = make_attr(ATTR_CONST); ;} break; case 277: /* Line 1455 of yacc.c */ #line 913 "parser.y" - { (yyval.attr_list) = append_attr((yyvsp[(1) - (2)].attr_list), (yyvsp[(2) - (2)].attr)); ;} + { (yyval.attr_list) = NULL; ;} break; case 278: /* Line 1455 of yacc.c */ -#line 916 "parser.y" - { (yyval.declspec) = make_decl_spec((yyvsp[(1) - (2)].type), (yyvsp[(2) - (2)].declspec), NULL, NULL, STG_NONE); ;} +#line 914 "parser.y" + { (yyval.attr_list) = append_attr((yyvsp[(1) - (2)].attr_list), (yyvsp[(2) - (2)].attr)); ;} break; case 279: /* Line 1455 of yacc.c */ -#line 918 "parser.y" - { (yyval.declspec) = make_decl_spec((yyvsp[(2) - (3)].type), (yyvsp[(1) - (3)].declspec), (yyvsp[(3) - (3)].declspec), NULL, STG_NONE); ;} +#line 917 "parser.y" + { (yyval.declspec) = make_decl_spec((yyvsp[(1) - (2)].type), (yyvsp[(2) - (2)].declspec), NULL, NULL, STG_NONE); ;} break; case 280: /* Line 1455 of yacc.c */ -#line 921 "parser.y" - { (yyval.declspec) = NULL; ;} +#line 919 "parser.y" + { (yyval.declspec) = make_decl_spec((yyvsp[(2) - (3)].type), (yyvsp[(1) - (3)].declspec), (yyvsp[(3) - (3)].declspec), NULL, STG_NONE); ;} break; - case 282: + case 281: /* Line 1455 of yacc.c */ -#line 926 "parser.y" - { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, (yyvsp[(1) - (2)].attr), STG_NONE); ;} +#line 922 "parser.y" + { (yyval.declspec) = NULL; ;} break; case 283: @@ -4628,126 +4619,123 @@ yyreduce: /* Line 1455 of yacc.c */ #line 928 "parser.y" - { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, NULL, (yyvsp[(1) - (2)].stgclass)); ;} + { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, (yyvsp[(1) - (2)].attr), STG_NONE); ;} break; case 285: /* Line 1455 of yacc.c */ -#line 933 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} +#line 929 "parser.y" + { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, NULL, (yyvsp[(1) - (2)].stgclass)); ;} break; case 286: /* Line 1455 of yacc.c */ #line 934 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} break; - case 288: + case 287: /* Line 1455 of yacc.c */ -#line 939 "parser.y" - { (yyval.declarator) = make_declarator((yyvsp[(1) - (1)].var)); ;} +#line 935 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} break; case 289: /* Line 1455 of yacc.c */ #line 940 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} + { (yyval.declarator) = make_declarator((yyvsp[(1) - (1)].var)); ;} break; case 290: /* Line 1455 of yacc.c */ #line 941 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} break; case 291: /* Line 1455 of yacc.c */ #line 942 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); - (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); - (yyval.declarator)->type = NULL; - ;} + { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} break; case 292: /* Line 1455 of yacc.c */ -#line 951 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} +#line 943 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); + (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); + (yyval.declarator)->type = NULL; + ;} break; case 293: /* Line 1455 of yacc.c */ #line 952 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} break; - case 295: + case 294: /* Line 1455 of yacc.c */ -#line 959 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} +#line 953 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} break; case 296: /* Line 1455 of yacc.c */ #line 960 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} break; case 297: /* Line 1455 of yacc.c */ -#line 964 "parser.y" - { (yyval.declarator) = make_declarator(NULL); ;} +#line 961 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} break; - case 299: + case 298: /* Line 1455 of yacc.c */ -#line 970 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} +#line 965 "parser.y" + { (yyval.declarator) = make_declarator(NULL); ;} break; case 300: /* Line 1455 of yacc.c */ #line 971 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} break; case 301: /* Line 1455 of yacc.c */ #line 972 "parser.y" - { (yyval.declarator) = make_declarator(NULL); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(1) - (1)].expr)); ;} + { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} break; case 302: /* Line 1455 of yacc.c */ -#line 974 "parser.y" - { (yyval.declarator) = make_declarator(NULL); - (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(2) - (3)].var_list))); - (yyval.declarator)->type = NULL; - ;} +#line 973 "parser.y" + { (yyval.declarator) = make_declarator(NULL); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(1) - (1)].expr)); ;} break; case 303: /* Line 1455 of yacc.c */ -#line 979 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); - (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); +#line 975 "parser.y" + { (yyval.declarator) = make_declarator(NULL); + (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(2) - (3)].var_list))); (yyval.declarator)->type = NULL; ;} break; @@ -4755,82 +4743,82 @@ yyreduce: case 304: /* Line 1455 of yacc.c */ -#line 988 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} +#line 980 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); + (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); + (yyval.declarator)->type = NULL; + ;} break; case 305: /* Line 1455 of yacc.c */ #line 989 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} break; - case 307: + case 306: /* Line 1455 of yacc.c */ -#line 996 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} +#line 990 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} break; case 308: /* Line 1455 of yacc.c */ #line 997 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} break; case 309: /* Line 1455 of yacc.c */ -#line 1001 "parser.y" - { (yyval.declarator) = make_declarator(NULL); ;} +#line 998 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} break; - case 311: + case 310: /* Line 1455 of yacc.c */ -#line 1009 "parser.y" - { (yyval.declarator) = make_declarator((yyvsp[(1) - (1)].var)); ;} +#line 1002 "parser.y" + { (yyval.declarator) = make_declarator(NULL); ;} break; case 312: /* Line 1455 of yacc.c */ #line 1010 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} + { (yyval.declarator) = make_declarator((yyvsp[(1) - (1)].var)); ;} break; case 313: /* Line 1455 of yacc.c */ #line 1011 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} + { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} break; case 314: /* Line 1455 of yacc.c */ #line 1012 "parser.y" - { (yyval.declarator) = make_declarator(NULL); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(1) - (1)].expr)); ;} + { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} break; case 315: /* Line 1455 of yacc.c */ -#line 1014 "parser.y" - { (yyval.declarator) = make_declarator(NULL); - (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(2) - (3)].var_list))); - (yyval.declarator)->type = NULL; - ;} +#line 1013 "parser.y" + { (yyval.declarator) = make_declarator(NULL); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(1) - (1)].expr)); ;} break; case 316: /* Line 1455 of yacc.c */ -#line 1019 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); - (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); +#line 1015 "parser.y" + { (yyval.declarator) = make_declarator(NULL); + (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(2) - (3)].var_list))); (yyval.declarator)->type = NULL; ;} break; @@ -4838,116 +4826,119 @@ yyreduce: case 317: /* Line 1455 of yacc.c */ -#line 1026 "parser.y" - { (yyval.declarator_list) = append_declarator( NULL, (yyvsp[(1) - (1)].declarator) ); ;} +#line 1020 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); + (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); + (yyval.declarator)->type = NULL; + ;} break; case 318: /* Line 1455 of yacc.c */ #line 1027 "parser.y" - { (yyval.declarator_list) = append_declarator( (yyvsp[(1) - (3)].declarator_list), (yyvsp[(3) - (3)].declarator) ); ;} + { (yyval.declarator_list) = append_declarator( NULL, (yyvsp[(1) - (1)].declarator) ); ;} break; case 319: /* Line 1455 of yacc.c */ -#line 1030 "parser.y" - { (yyval.expr) = NULL; ;} +#line 1028 "parser.y" + { (yyval.declarator_list) = append_declarator( (yyvsp[(1) - (3)].declarator_list), (yyvsp[(3) - (3)].declarator) ); ;} break; case 320: /* Line 1455 of yacc.c */ #line 1031 "parser.y" - { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + { (yyval.expr) = NULL; ;} break; case 321: /* Line 1455 of yacc.c */ -#line 1034 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->bits = (yyvsp[(2) - (2)].expr); - if (!(yyval.declarator)->bits && !(yyval.declarator)->var->name) - error_loc("unnamed fields are not allowed"); - ;} +#line 1032 "parser.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; case 322: /* Line 1455 of yacc.c */ -#line 1041 "parser.y" - { (yyval.declarator_list) = append_declarator( NULL, (yyvsp[(1) - (1)].declarator) ); ;} +#line 1035 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->bits = (yyvsp[(2) - (2)].expr); + if (!(yyval.declarator)->bits && !(yyval.declarator)->var->name) + error_loc("unnamed fields are not allowed\n"); + ;} break; case 323: /* Line 1455 of yacc.c */ -#line 1043 "parser.y" - { (yyval.declarator_list) = append_declarator( (yyvsp[(1) - (3)].declarator_list), (yyvsp[(3) - (3)].declarator) ); ;} +#line 1042 "parser.y" + { (yyval.declarator_list) = append_declarator( NULL, (yyvsp[(1) - (1)].declarator) ); ;} break; case 324: /* Line 1455 of yacc.c */ -#line 1047 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (1)].declarator); ;} +#line 1044 "parser.y" + { (yyval.declarator_list) = append_declarator( (yyvsp[(1) - (3)].declarator_list), (yyvsp[(3) - (3)].declarator) ); ;} break; case 325: /* Line 1455 of yacc.c */ #line 1048 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (3)].declarator); (yyvsp[(1) - (3)].declarator)->var->eval = (yyvsp[(3) - (3)].expr); ;} + { (yyval.declarator) = (yyvsp[(1) - (1)].declarator); ;} break; case 326: /* Line 1455 of yacc.c */ -#line 1052 "parser.y" - { (yyval.num) = RPC_FC_RP; ;} +#line 1049 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (3)].declarator); (yyvsp[(1) - (3)].declarator)->var->eval = (yyvsp[(3) - (3)].expr); ;} break; case 327: /* Line 1455 of yacc.c */ #line 1053 "parser.y" - { (yyval.num) = RPC_FC_UP; ;} + { (yyval.num) = RPC_FC_RP; ;} break; case 328: /* Line 1455 of yacc.c */ #line 1054 "parser.y" - { (yyval.num) = RPC_FC_FP; ;} + { (yyval.num) = RPC_FC_UP; ;} break; case 329: /* Line 1455 of yacc.c */ -#line 1057 "parser.y" - { (yyval.type) = type_new_struct((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} +#line 1055 "parser.y" + { (yyval.num) = RPC_FC_FP; ;} break; case 330: /* Line 1455 of yacc.c */ -#line 1060 "parser.y" - { (yyval.type) = type_new_void(); ;} +#line 1058 "parser.y" + { (yyval.type) = type_new_struct((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} break; case 331: /* Line 1455 of yacc.c */ #line 1061 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + { (yyval.type) = type_new_void(); ;} break; case 332: /* Line 1455 of yacc.c */ #line 1062 "parser.y" - { (yyval.type) = (yyvsp[(1) - (1)].type); ;} + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} break; case 333: @@ -4961,85 +4952,92 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1064 "parser.y" - { (yyval.type) = type_new_enum((yyvsp[(2) - (2)].str), FALSE, NULL); ;} + { (yyval.type) = (yyvsp[(1) - (1)].type); ;} break; case 335: /* Line 1455 of yacc.c */ #line 1065 "parser.y" - { (yyval.type) = (yyvsp[(1) - (1)].type); ;} + { (yyval.type) = type_new_enum((yyvsp[(2) - (2)].str), FALSE, NULL); ;} break; case 336: /* Line 1455 of yacc.c */ #line 1066 "parser.y" - { (yyval.type) = type_new_struct((yyvsp[(2) - (2)].str), FALSE, NULL); ;} + { (yyval.type) = (yyvsp[(1) - (1)].type); ;} break; case 337: /* Line 1455 of yacc.c */ #line 1067 "parser.y" - { (yyval.type) = (yyvsp[(1) - (1)].type); ;} + { (yyval.type) = type_new_struct((yyvsp[(2) - (2)].str), FALSE, NULL); ;} break; case 338: /* Line 1455 of yacc.c */ #line 1068 "parser.y" - { (yyval.type) = type_new_nonencapsulated_union((yyvsp[(2) - (2)].str), FALSE, NULL); ;} + { (yyval.type) = (yyvsp[(1) - (1)].type); ;} break; case 339: /* Line 1455 of yacc.c */ #line 1069 "parser.y" - { (yyval.type) = make_safearray((yyvsp[(3) - (4)].type)); ;} + { (yyval.type) = type_new_nonencapsulated_union((yyvsp[(2) - (2)].str), FALSE, NULL); ;} break; case 340: /* Line 1455 of yacc.c */ -#line 1073 "parser.y" - { reg_typedefs((yyvsp[(3) - (4)].declspec), (yyvsp[(4) - (4)].declarator_list), check_typedef_attrs((yyvsp[(2) - (4)].attr_list))); - (yyval.statement) = make_statement_typedef((yyvsp[(4) - (4)].declarator_list)); - ;} +#line 1070 "parser.y" + { (yyval.type) = make_safearray((yyvsp[(3) - (4)].type)); ;} break; case 341: /* Line 1455 of yacc.c */ -#line 1079 "parser.y" - { (yyval.type) = type_new_nonencapsulated_union((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} +#line 1074 "parser.y" + { reg_typedefs((yyvsp[(3) - (4)].declspec), (yyvsp[(4) - (4)].declarator_list), check_typedef_attrs((yyvsp[(2) - (4)].attr_list))); + (yyval.statement) = make_statement_typedef((yyvsp[(4) - (4)].declarator_list)); + ;} break; case 342: /* Line 1455 of yacc.c */ -#line 1082 "parser.y" - { (yyval.type) = type_new_encapsulated_union((yyvsp[(2) - (10)].str), (yyvsp[(5) - (10)].var), (yyvsp[(7) - (10)].var), (yyvsp[(9) - (10)].var_list)); ;} +#line 1080 "parser.y" + { (yyval.type) = type_new_nonencapsulated_union((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} break; case 343: /* Line 1455 of yacc.c */ -#line 1086 "parser.y" - { (yyval.num) = MAKEVERSION((yyvsp[(1) - (1)].num), 0); ;} +#line 1083 "parser.y" + { (yyval.type) = type_new_encapsulated_union((yyvsp[(2) - (10)].str), (yyvsp[(5) - (10)].var), (yyvsp[(7) - (10)].var), (yyvsp[(9) - (10)].var_list)); ;} break; case 344: /* Line 1455 of yacc.c */ #line 1087 "parser.y" + { (yyval.num) = MAKEVERSION((yyvsp[(1) - (1)].num), 0); ;} + break; + + case 345: + +/* Line 1455 of yacc.c */ +#line 1088 "parser.y" { (yyval.num) = MAKEVERSION((yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num)); ;} break; /* Line 1455 of yacc.c */ -#line 5043 "parser.tab.c" +#line 5041 "parser.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -5251,7 +5249,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 1090 "parser.y" +#line 1091 "parser.y" static void decl_builtin_basic(const char *name, enum type_basic_type type) diff --git a/reactos/tools/widl/parser.tab.h b/reactos/tools/widl/parser.tab.h index 73f6993dbcc..1266e128b4a 100644 --- a/reactos/tools/widl/parser.tab.h +++ b/reactos/tools/widl/parser.tab.h @@ -46,150 +46,151 @@ aDOUBLE = 262, aSTRING = 263, aWSTRING = 264, - aUUID = 265, - aEOF = 266, - SHL = 267, - SHR = 268, - MEMBERPTR = 269, - EQUALITY = 270, - INEQUALITY = 271, - GREATEREQUAL = 272, - LESSEQUAL = 273, - LOGICALOR = 274, - LOGICALAND = 275, - ELLIPSIS = 276, - tAGGREGATABLE = 277, - tALLOCATE = 278, - tANNOTATION = 279, - tAPPOBJECT = 280, - tASYNC = 281, - tASYNCUUID = 282, - tAUTOHANDLE = 283, - tBINDABLE = 284, - tBOOLEAN = 285, - tBROADCAST = 286, - tBYTE = 287, - tBYTECOUNT = 288, - tCALLAS = 289, - tCALLBACK = 290, - tCASE = 291, - tCDECL = 292, - tCHAR = 293, - tCOCLASS = 294, - tCODE = 295, - tCOMMSTATUS = 296, - tCONST = 297, - tCONTEXTHANDLE = 298, - tCONTEXTHANDLENOSERIALIZE = 299, - tCONTEXTHANDLESERIALIZE = 300, - tCONTROL = 301, - tCPPQUOTE = 302, - tDEFAULT = 303, - tDEFAULTCOLLELEM = 304, - tDEFAULTVALUE = 305, - tDEFAULTVTABLE = 306, - tDISPLAYBIND = 307, - tDISPINTERFACE = 308, - tDLLNAME = 309, - tDOUBLE = 310, - tDUAL = 311, - tENDPOINT = 312, - tENTRY = 313, - tENUM = 314, - tERRORSTATUST = 315, - tEXPLICITHANDLE = 316, - tEXTERN = 317, - tFALSE = 318, - tFASTCALL = 319, - tFLOAT = 320, - tHANDLE = 321, - tHANDLET = 322, - tHELPCONTEXT = 323, - tHELPFILE = 324, - tHELPSTRING = 325, - tHELPSTRINGCONTEXT = 326, - tHELPSTRINGDLL = 327, - tHIDDEN = 328, - tHYPER = 329, - tID = 330, - tIDEMPOTENT = 331, - tIIDIS = 332, - tIMMEDIATEBIND = 333, - tIMPLICITHANDLE = 334, - tIMPORT = 335, - tIMPORTLIB = 336, - tIN = 337, - tIN_LINE = 338, - tINLINE = 339, - tINPUTSYNC = 340, - tINT = 341, - tINT3264 = 342, - tINT64 = 343, - tINTERFACE = 344, - tLCID = 345, - tLENGTHIS = 346, - tLIBRARY = 347, - tLOCAL = 348, - tLONG = 349, - tMETHODS = 350, - tMODULE = 351, - tNONBROWSABLE = 352, - tNONCREATABLE = 353, - tNONEXTENSIBLE = 354, - tNULL = 355, - tOBJECT = 356, - tODL = 357, - tOLEAUTOMATION = 358, - tOPTIONAL = 359, - tOUT = 360, - tPASCAL = 361, - tPOINTERDEFAULT = 362, - tPROPERTIES = 363, - tPROPGET = 364, - tPROPPUT = 365, - tPROPPUTREF = 366, - tPTR = 367, - tPUBLIC = 368, - tRANGE = 369, - tREADONLY = 370, - tREF = 371, - tREGISTER = 372, - tREQUESTEDIT = 373, - tRESTRICTED = 374, - tRETVAL = 375, - tSAFEARRAY = 376, - tSHORT = 377, - tSIGNED = 378, - tSIZEIS = 379, - tSIZEOF = 380, - tSMALL = 381, - tSOURCE = 382, - tSTATIC = 383, - tSTDCALL = 384, - tSTRICTCONTEXTHANDLE = 385, - tSTRING = 386, - tSTRUCT = 387, - tSWITCH = 388, - tSWITCHIS = 389, - tSWITCHTYPE = 390, - tTRANSMITAS = 391, - tTRUE = 392, - tTYPEDEF = 393, - tUNION = 394, - tUNIQUE = 395, - tUNSIGNED = 396, - tUUID = 397, - tV1ENUM = 398, - tVARARG = 399, - tVERSION = 400, - tVOID = 401, - tWCHAR = 402, - tWIREMARSHAL = 403, - ADDRESSOF = 404, - NEG = 405, - POS = 406, - PPTR = 407, - CAST = 408 + aSQSTRING = 265, + aUUID = 266, + aEOF = 267, + SHL = 268, + SHR = 269, + MEMBERPTR = 270, + EQUALITY = 271, + INEQUALITY = 272, + GREATEREQUAL = 273, + LESSEQUAL = 274, + LOGICALOR = 275, + LOGICALAND = 276, + ELLIPSIS = 277, + tAGGREGATABLE = 278, + tALLOCATE = 279, + tANNOTATION = 280, + tAPPOBJECT = 281, + tASYNC = 282, + tASYNCUUID = 283, + tAUTOHANDLE = 284, + tBINDABLE = 285, + tBOOLEAN = 286, + tBROADCAST = 287, + tBYTE = 288, + tBYTECOUNT = 289, + tCALLAS = 290, + tCALLBACK = 291, + tCASE = 292, + tCDECL = 293, + tCHAR = 294, + tCOCLASS = 295, + tCODE = 296, + tCOMMSTATUS = 297, + tCONST = 298, + tCONTEXTHANDLE = 299, + tCONTEXTHANDLENOSERIALIZE = 300, + tCONTEXTHANDLESERIALIZE = 301, + tCONTROL = 302, + tCPPQUOTE = 303, + tDEFAULT = 304, + tDEFAULTCOLLELEM = 305, + tDEFAULTVALUE = 306, + tDEFAULTVTABLE = 307, + tDISPLAYBIND = 308, + tDISPINTERFACE = 309, + tDLLNAME = 310, + tDOUBLE = 311, + tDUAL = 312, + tENDPOINT = 313, + tENTRY = 314, + tENUM = 315, + tERRORSTATUST = 316, + tEXPLICITHANDLE = 317, + tEXTERN = 318, + tFALSE = 319, + tFASTCALL = 320, + tFLOAT = 321, + tHANDLE = 322, + tHANDLET = 323, + tHELPCONTEXT = 324, + tHELPFILE = 325, + tHELPSTRING = 326, + tHELPSTRINGCONTEXT = 327, + tHELPSTRINGDLL = 328, + tHIDDEN = 329, + tHYPER = 330, + tID = 331, + tIDEMPOTENT = 332, + tIIDIS = 333, + tIMMEDIATEBIND = 334, + tIMPLICITHANDLE = 335, + tIMPORT = 336, + tIMPORTLIB = 337, + tIN = 338, + tIN_LINE = 339, + tINLINE = 340, + tINPUTSYNC = 341, + tINT = 342, + tINT3264 = 343, + tINT64 = 344, + tINTERFACE = 345, + tLCID = 346, + tLENGTHIS = 347, + tLIBRARY = 348, + tLOCAL = 349, + tLONG = 350, + tMETHODS = 351, + tMODULE = 352, + tNONBROWSABLE = 353, + tNONCREATABLE = 354, + tNONEXTENSIBLE = 355, + tNULL = 356, + tOBJECT = 357, + tODL = 358, + tOLEAUTOMATION = 359, + tOPTIONAL = 360, + tOUT = 361, + tPASCAL = 362, + tPOINTERDEFAULT = 363, + tPROPERTIES = 364, + tPROPGET = 365, + tPROPPUT = 366, + tPROPPUTREF = 367, + tPTR = 368, + tPUBLIC = 369, + tRANGE = 370, + tREADONLY = 371, + tREF = 372, + tREGISTER = 373, + tREQUESTEDIT = 374, + tRESTRICTED = 375, + tRETVAL = 376, + tSAFEARRAY = 377, + tSHORT = 378, + tSIGNED = 379, + tSIZEIS = 380, + tSIZEOF = 381, + tSMALL = 382, + tSOURCE = 383, + tSTATIC = 384, + tSTDCALL = 385, + tSTRICTCONTEXTHANDLE = 386, + tSTRING = 387, + tSTRUCT = 388, + tSWITCH = 389, + tSWITCHIS = 390, + tSWITCHTYPE = 391, + tTRANSMITAS = 392, + tTRUE = 393, + tTYPEDEF = 394, + tUNION = 395, + tUNIQUE = 396, + tUNSIGNED = 397, + tUUID = 398, + tV1ENUM = 399, + tVARARG = 400, + tVERSION = 401, + tVOID = 402, + tWCHAR = 403, + tWIREMARSHAL = 404, + ADDRESSOF = 405, + NEG = 406, + POS = 407, + PPTR = 408, + CAST = 409 }; #endif @@ -232,7 +233,7 @@ typedef union YYSTYPE /* Line 1676 of yacc.c */ -#line 236 "parser.tab.h" +#line 237 "parser.tab.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/reactos/tools/widl/parser.y b/reactos/tools/widl/parser.y index de44ab5626f..2af7742d172 100644 --- a/reactos/tools/widl/parser.y +++ b/reactos/tools/widl/parser.y @@ -186,7 +186,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s %token aKNOWNTYPE %token aNUM aHEXNUM %token aDOUBLE -%token aSTRING aWSTRING +%token aSTRING aWSTRING aSQSTRING %token aUUID %token aEOF %token SHL SHR @@ -632,6 +632,7 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); } | tTRUE { $$ = make_exprl(EXPR_TRUEFALSE, 1); } | aSTRING { $$ = make_exprs(EXPR_STRLIT, $1); } | aWSTRING { $$ = make_exprs(EXPR_WSTRLIT, $1); } + | aSQSTRING { $$ = make_exprs(EXPR_CHARCONST, $1); } | aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); } | expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); } | expr LOGICALOR expr { $$ = make_expr2(EXPR_LOGOR, $1, $3); } @@ -841,7 +842,7 @@ dispinterfacedef: dispinterfacehdr '{' ; inherit: { $$ = NULL; } - | ':' aKNOWNTYPE { $$ = find_type_or_error2($2, 0); } + | ':' aKNOWNTYPE { $$ = find_type_or_error2($2, 0); is_object_interface = 1; } ; interface: tINTERFACE aIDENTIFIER { $$ = get_type(TYPE_INTERFACE, $2, 0); } @@ -852,9 +853,9 @@ interfacehdr: attributes interface { $$.interface = $2; $$.old_pointer_default = pointer_default; if (is_attr($1, ATTR_POINTERDEFAULT)) pointer_default = get_attrv($1, ATTR_POINTERDEFAULT); - is_object_interface = is_object($1); check_def($2); $2->attrs = check_iface_attrs($2->name, $1); + is_object_interface = is_object($2); $2->defined = TRUE; } ; @@ -1033,7 +1034,7 @@ m_bitfield: { $$ = NULL; } struct_declarator: any_declarator m_bitfield { $$ = $1; $$->bits = $2; if (!$$->bits && !$$->var->name) - error_loc("unnamed fields are not allowed"); + error_loc("unnamed fields are not allowed\n"); } ; diff --git a/reactos/tools/widl/parser.yy.c b/reactos/tools/widl/parser.yy.c index 9cb425c8573..2bf33f614bc 100644 --- a/reactos/tools/widl/parser.yy.c +++ b/reactos/tools/widl/parser.yy.c @@ -301,26 +301,26 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 33 -#define YY_END_OF_BUFFER 34 -static yyconst short int yy_accept[142] = +#define YY_NUM_RULES 36 +#define YY_END_OF_BUFFER 37 +static yyconst short int yy_accept[148] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, - 34, 32, 21, 20, 32, 3, 32, 32, 32, 16, - 16, 32, 32, 32, 19, 19, 19, 11, 32, 21, - 1, 10, 33, 4, 10, 6, 16, 16, 13, 13, - 13, 12, 2, 26, 30, 24, 0, 0, 16, 16, - 16, 0, 22, 28, 25, 27, 23, 19, 5, 19, - 29, 0, 1, 1, 9, 8, 7, 16, 0, 13, - 13, 2, 31, 17, 16, 16, 15, 19, 16, 0, - 13, 0, 15, 15, 19, 16, 0, 13, 0, 17, - 15, 15, 19, 16, 0, 13, 19, 16, 0, 13, + 0, 0, 37, 35, 24, 23, 35, 3, 35, 7, + 35, 35, 19, 19, 35, 35, 35, 22, 22, 22, + 14, 35, 24, 1, 13, 36, 4, 13, 6, 19, + 19, 16, 16, 16, 15, 2, 8, 13, 29, 33, + 27, 0, 0, 19, 19, 19, 0, 25, 31, 28, + 30, 26, 22, 5, 22, 32, 0, 1, 1, 12, + 10, 9, 19, 0, 16, 16, 2, 11, 34, 20, + 19, 19, 18, 22, 19, 0, 16, 0, 18, 18, + 22, 19, 0, 16, 0, 20, 18, 18, 22, 19, - 19, 16, 0, 13, 19, 16, 0, 13, 19, 0, - 16, 0, 18, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 22, 19, 0, 16, 22, 19, 0, 16, + 22, 19, 0, 16, 22, 0, 19, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, - 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0 } ; static yyconst int yy_ec[256] = @@ -328,17 +328,17 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 1, 7, 1, 8, - 1, 1, 9, 1, 10, 11, 1, 12, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 1, 1, 14, - 15, 16, 1, 1, 17, 18, 18, 18, 19, 20, - 21, 21, 21, 21, 21, 22, 21, 21, 21, 21, - 21, 23, 24, 21, 25, 21, 21, 26, 27, 21, - 28, 29, 30, 1, 21, 1, 18, 18, 18, 18, + 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, + 1, 1, 10, 1, 11, 12, 1, 13, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 1, 1, 15, + 16, 17, 1, 1, 18, 19, 19, 19, 20, 21, + 22, 22, 22, 22, 22, 23, 22, 22, 22, 22, + 22, 24, 25, 22, 26, 22, 22, 27, 28, 22, + 29, 30, 31, 1, 22, 1, 19, 19, 19, 19, - 31, 18, 21, 21, 21, 21, 21, 32, 21, 21, - 21, 21, 21, 21, 21, 21, 33, 21, 21, 34, - 21, 21, 1, 35, 1, 1, 1, 1, 1, 1, + 32, 19, 22, 22, 22, 22, 22, 33, 22, 22, + 22, 22, 22, 22, 22, 22, 34, 22, 22, 35, + 22, 22, 1, 36, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -355,182 +355,182 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst int yy_meta[36] = +static yyconst int yy_meta[37] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 3, 1, 1, 1, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, - 3, 4, 4, 4, 1 + 1, 1, 3, 3, 1, 1, 1, 3, 3, 3, + 3, 4, 4, 4, 4, 4, 4, 4, 1, 1, + 1, 3, 4, 4, 4, 1 } ; -static yyconst short int yy_base[178] = +static yyconst short int yy_base[184] = { 0, - 0, 34, 34, 38, 39, 42, 71, 44, 270, 269, - 271, 491, 491, 491, 255, 491, 258, 248, 252, 96, - 22, 37, 242, 38, 0, 251, 238, 491, 219, 53, - 251, 491, 491, 491, 33, 491, 119, 23, 142, 165, - 246, 491, 0, 491, 491, 491, 239, 48, 0, 33, - 88, 0, 491, 491, 491, 491, 491, 0, 491, 228, - 491, 63, 241, 240, 491, 491, 491, 185, 0, 207, - 0, 0, 491, 104, 491, 491, 124, 222, 227, 0, - 249, 102, 94, 102, 220, 269, 0, 291, 113, 168, - 491, 491, 213, 311, 0, 333, 212, 353, 0, 375, + 0, 35, 35, 39, 40, 43, 61, 45, 262, 261, + 46, 47, 263, 481, 481, 481, 246, 481, 254, 481, + 243, 243, 85, 25, 41, 238, 42, 0, 248, 229, + 481, 210, 60, 243, 481, 481, 481, 34, 481, 108, + 26, 131, 154, 239, 481, 0, 481, 60, 481, 481, + 481, 231, 58, 0, 75, 77, 0, 481, 481, 481, + 481, 481, 0, 481, 220, 481, 61, 238, 236, 481, + 481, 481, 174, 0, 196, 0, 0, 481, 481, 93, + 481, 481, 113, 213, 216, 0, 238, 166, 89, 81, + 214, 258, 0, 280, 89, 169, 481, 481, 207, 300, - 217, 395, 0, 417, 206, 439, 222, 221, 62, 0, - 220, 140, 491, 0, 0, 0, 219, 0, 0, 0, - 0, 218, 0, 0, 0, 0, 213, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 491, - 491, 472, 476, 478, 482, 486, 219, 218, 212, 211, - 210, 209, 208, 206, 205, 203, 198, 197, 192, 191, - 190, 189, 188, 187, 186, 185, 183, 176, 169, 168, - 167, 155, 144, 140, 137, 130, 110 + 0, 322, 203, 342, 0, 364, 208, 384, 0, 406, + 197, 428, 213, 212, 115, 0, 211, 128, 481, 0, + 0, 0, 210, 0, 0, 0, 0, 209, 0, 0, + 0, 0, 208, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 481, 481, 462, 466, 468, + 472, 476, 215, 210, 209, 208, 202, 201, 200, 199, + 196, 195, 193, 188, 187, 182, 181, 178, 175, 168, + 167, 166, 159, 158, 157, 145, 135, 130, 129, 113, + 102, 88, 75 } ; -static yyconst short int yy_def[178] = +static yyconst short int yy_def[184] = { 0, - 141, 1, 142, 142, 142, 142, 141, 7, 143, 143, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 20, 141, 141, 141, 144, 144, 144, 141, 141, 141, - 141, 141, 141, 141, 145, 141, 141, 37, 141, 39, - 40, 141, 146, 141, 141, 141, 141, 141, 21, 141, - 141, 147, 141, 141, 141, 141, 141, 144, 141, 144, - 141, 141, 141, 141, 141, 141, 141, 141, 148, 40, - 40, 146, 141, 141, 141, 141, 147, 144, 141, 149, - 40, 141, 141, 141, 144, 141, 150, 40, 141, 141, - 141, 141, 144, 141, 151, 40, 144, 141, 152, 40, + 147, 1, 148, 148, 148, 148, 1, 7, 149, 149, + 148, 148, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 23, 147, 147, 147, 150, 150, 150, + 147, 147, 147, 147, 147, 147, 147, 151, 147, 147, + 40, 147, 42, 43, 147, 152, 147, 151, 147, 147, + 147, 147, 147, 24, 147, 147, 153, 147, 147, 147, + 147, 147, 150, 147, 150, 147, 147, 147, 147, 147, + 147, 147, 147, 154, 43, 43, 152, 147, 147, 147, + 147, 147, 153, 150, 147, 155, 43, 147, 147, 147, + 150, 147, 156, 43, 147, 147, 147, 147, 150, 147, - 144, 141, 153, 40, 144, 141, 141, 40, 144, 154, - 106, 141, 141, 155, 156, 157, 141, 158, 159, 160, - 161, 141, 162, 163, 164, 165, 141, 166, 167, 168, - 169, 170, 171, 172, 173, 174, 175, 176, 177, 141, - 0, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141 + 157, 43, 150, 147, 158, 43, 150, 147, 159, 43, + 150, 147, 147, 43, 150, 160, 112, 147, 147, 161, + 162, 163, 147, 164, 165, 166, 167, 147, 168, 169, + 170, 171, 147, 172, 173, 174, 175, 176, 177, 178, + 179, 180, 181, 182, 183, 147, 0, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147 } ; -static yyconst short int yy_nxt[527] = +static yyconst short int yy_nxt[518] = { 0, - 12, 13, 14, 15, 16, 12, 17, 12, 12, 18, - 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, - 25, 26, 25, 27, 25, 25, 25, 28, 12, 12, - 25, 25, 25, 25, 29, 30, 33, 66, 34, 31, - 33, 33, 34, 36, 33, 30, 36, 141, 141, 31, - 53, 54, 56, 57, 62, 141, 141, 75, 63, 74, - 74, 67, 35, 112, 62, 75, 35, 35, 63, 113, - 35, 12, 13, 14, 15, 16, 12, 17, 12, 12, - 18, 19, 37, 38, 22, 23, 24, 39, 39, 39, - 39, 40, 41, 40, 40, 40, 40, 40, 28, 12, + 14, 15, 16, 17, 18, 14, 19, 20, 14, 14, + 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, + 28, 28, 29, 28, 30, 28, 28, 28, 31, 14, + 14, 28, 28, 28, 28, 32, 33, 36, 71, 37, + 34, 36, 36, 37, 39, 36, 33, 39, 36, 36, + 34, 147, 147, 47, 47, 58, 59, 61, 62, 147, + 147, 67, 67, 72, 38, 68, 68, 78, 38, 38, + 80, 80, 38, 40, 41, 48, 48, 146, 42, 42, + 42, 42, 43, 44, 43, 43, 43, 43, 43, 72, + 145, 45, 42, 43, 43, 43, 53, 54, 54, 82, - 42, 39, 40, 40, 40, 29, 48, 49, 49, 76, - 89, 89, 140, 90, 90, 74, 74, 50, 91, 76, - 51, 52, 82, 92, 90, 90, 91, 50, 51, 52, - 68, 68, 139, 92, 82, 69, 69, 69, 69, 138, - 50, 112, 137, 51, 52, 83, 136, 113, 84, 69, - 50, 51, 52, 70, 70, 83, 84, 135, 70, 70, - 70, 70, 71, 71, 71, 71, 71, 71, 71, 134, - 133, 132, 70, 71, 71, 71, 71, 71, 131, 90, - 90, 71, 71, 71, 71, 130, 82, 129, 127, 126, - 125, 124, 122, 121, 120, 71, 79, 79, 82, 119, + 81, 96, 96, 98, 144, 80, 80, 55, 81, 82, + 56, 57, 88, 98, 97, 143, 118, 55, 56, 57, + 73, 73, 97, 119, 88, 74, 74, 74, 74, 118, + 55, 142, 141, 56, 57, 89, 119, 140, 90, 74, + 55, 56, 57, 75, 75, 89, 90, 139, 75, 75, + 75, 75, 76, 76, 76, 76, 76, 76, 76, 138, + 137, 136, 75, 76, 76, 76, 76, 76, 135, 133, + 132, 76, 76, 76, 76, 95, 95, 131, 96, 96, + 130, 96, 96, 128, 127, 76, 85, 85, 88, 126, + 125, 86, 86, 86, 86, 123, 55, 122, 121, 56, - 117, 80, 80, 80, 80, 116, 50, 115, 114, 51, - 107, 103, 99, 95, 87, 80, 50, 51, 81, 81, - 80, 77, 128, 81, 81, 81, 81, 123, 118, 141, - 110, 110, 109, 105, 101, 97, 93, 81, 86, 86, - 85, 64, 64, 87, 87, 87, 87, 78, 50, 73, - 59, 51, 64, 61, 60, 59, 55, 87, 50, 51, - 88, 88, 47, 46, 45, 88, 88, 88, 88, 44, - 141, 33, 33, 141, 141, 141, 141, 141, 141, 88, - 94, 94, 141, 141, 141, 95, 95, 95, 95, 141, - 50, 141, 141, 51, 141, 141, 141, 141, 141, 95, + 88, 120, 113, 109, 105, 86, 55, 56, 87, 87, + 101, 93, 86, 87, 87, 87, 87, 83, 134, 129, + 124, 147, 116, 116, 115, 111, 107, 87, 92, 92, + 103, 99, 91, 93, 93, 93, 93, 69, 55, 69, + 84, 56, 79, 64, 69, 66, 65, 93, 55, 56, + 94, 94, 64, 60, 52, 94, 94, 94, 94, 51, + 50, 49, 147, 36, 36, 147, 147, 147, 147, 94, + 100, 100, 147, 147, 147, 101, 101, 101, 101, 147, + 55, 147, 147, 56, 147, 147, 147, 147, 147, 101, + 55, 56, 102, 102, 147, 147, 147, 102, 102, 102, - 50, 51, 96, 96, 141, 141, 141, 96, 96, 96, - 96, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 96, 98, 98, 141, 141, 141, 99, 99, 99, - 99, 141, 50, 141, 141, 51, 141, 141, 141, 141, - 141, 99, 50, 51, 100, 100, 141, 141, 141, 100, - 100, 100, 100, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 100, 102, 102, 141, 141, 141, 103, - 103, 103, 103, 141, 50, 141, 141, 51, 141, 141, - 141, 141, 141, 103, 50, 51, 104, 104, 141, 141, - 141, 104, 104, 104, 104, 141, 141, 141, 141, 141, + 102, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 102, 104, 104, 147, 147, 147, 105, 105, 105, + 105, 147, 55, 147, 147, 56, 147, 147, 147, 147, + 147, 105, 55, 56, 106, 106, 147, 147, 147, 106, + 106, 106, 106, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 106, 108, 108, 147, 147, 147, 109, + 109, 109, 109, 147, 55, 147, 147, 56, 147, 147, + 147, 147, 147, 109, 55, 56, 110, 110, 147, 147, + 147, 110, 110, 110, 110, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 110, 112, 112, 147, 147, - 141, 141, 141, 141, 141, 104, 106, 106, 141, 141, - 141, 107, 107, 107, 107, 141, 50, 141, 141, 51, - 141, 141, 141, 141, 141, 107, 50, 51, 108, 108, - 141, 141, 141, 108, 108, 108, 108, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 108, 110, 141, - 111, 111, 141, 141, 141, 141, 141, 141, 141, 141, - 50, 141, 141, 51, 141, 141, 141, 141, 141, 141, - 50, 51, 32, 32, 32, 32, 43, 43, 43, 43, - 58, 58, 65, 141, 65, 65, 72, 141, 72, 72, - 11, 141, 141, 141, 141, 141, 141, 141, 141, 141, + 147, 113, 113, 113, 113, 147, 55, 147, 147, 56, + 147, 147, 147, 147, 147, 113, 55, 56, 114, 114, + 147, 147, 147, 114, 114, 114, 114, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 114, 116, 147, + 117, 117, 147, 147, 147, 147, 147, 147, 147, 147, + 55, 147, 147, 56, 147, 147, 147, 147, 147, 147, + 55, 56, 35, 35, 35, 35, 46, 46, 46, 46, + 63, 63, 70, 147, 70, 70, 77, 147, 77, 77, + 13, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141 + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147 } ; -static yyconst short int yy_chk[527] = +static yyconst short int yy_chk[518] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 3, 35, 3, 2, - 4, 5, 4, 5, 6, 8, 6, 21, 38, 8, - 22, 22, 24, 24, 30, 21, 38, 50, 30, 48, - 48, 35, 3, 109, 62, 50, 4, 5, 62, 109, - 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 1, 1, 1, 1, 1, 1, 2, 3, 38, 3, + 2, 4, 5, 4, 5, 6, 8, 6, 11, 12, + 8, 24, 41, 11, 12, 25, 25, 27, 27, 24, + 41, 33, 67, 38, 3, 33, 67, 48, 4, 5, + 53, 53, 6, 7, 7, 11, 12, 183, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 48, + 182, 7, 7, 7, 7, 7, 23, 23, 23, 56, - 7, 7, 7, 7, 7, 7, 20, 20, 20, 51, - 82, 82, 177, 82, 82, 74, 74, 20, 83, 51, - 20, 20, 74, 84, 89, 89, 83, 20, 20, 20, - 37, 37, 176, 84, 74, 37, 37, 37, 37, 175, - 37, 112, 174, 37, 37, 77, 173, 112, 77, 37, - 37, 37, 37, 39, 39, 77, 77, 172, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 171, - 170, 169, 39, 39, 39, 39, 40, 40, 168, 90, - 90, 40, 40, 40, 40, 167, 90, 166, 165, 164, - 163, 162, 161, 160, 159, 40, 68, 68, 90, 158, + 55, 95, 95, 90, 181, 80, 80, 23, 55, 56, + 23, 23, 80, 90, 89, 180, 115, 23, 23, 23, + 40, 40, 89, 115, 80, 40, 40, 40, 40, 118, + 40, 179, 178, 40, 40, 83, 118, 177, 83, 40, + 40, 40, 40, 42, 42, 83, 83, 176, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 175, + 174, 173, 42, 42, 42, 42, 43, 43, 172, 171, + 170, 43, 43, 43, 43, 88, 88, 169, 88, 88, + 168, 96, 96, 167, 166, 43, 73, 73, 96, 165, + 164, 73, 73, 73, 73, 163, 73, 162, 161, 73, - 157, 68, 68, 68, 68, 156, 68, 155, 154, 68, - 153, 152, 151, 150, 149, 68, 68, 68, 70, 70, - 148, 147, 127, 70, 70, 70, 70, 122, 117, 111, - 108, 107, 105, 101, 97, 93, 85, 70, 79, 79, - 78, 64, 63, 79, 79, 79, 79, 60, 79, 47, - 41, 79, 31, 29, 27, 26, 23, 79, 79, 79, - 81, 81, 19, 18, 17, 81, 81, 81, 81, 15, - 11, 10, 9, 0, 0, 0, 0, 0, 0, 81, - 86, 86, 0, 0, 0, 86, 86, 86, 86, 0, - 86, 0, 0, 86, 0, 0, 0, 0, 0, 86, + 96, 160, 159, 158, 157, 73, 73, 73, 75, 75, + 156, 155, 154, 75, 75, 75, 75, 153, 133, 128, + 123, 117, 114, 113, 111, 107, 103, 75, 85, 85, + 99, 91, 84, 85, 85, 85, 85, 69, 85, 68, + 65, 85, 52, 44, 34, 32, 30, 85, 85, 85, + 87, 87, 29, 26, 22, 87, 87, 87, 87, 21, + 19, 17, 13, 10, 9, 0, 0, 0, 0, 87, + 92, 92, 0, 0, 0, 92, 92, 92, 92, 0, + 92, 0, 0, 92, 0, 0, 0, 0, 0, 92, + 92, 92, 94, 94, 0, 0, 0, 94, 94, 94, - 86, 86, 88, 88, 0, 0, 0, 88, 88, 88, - 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 88, 94, 94, 0, 0, 0, 94, 94, 94, - 94, 0, 94, 0, 0, 94, 0, 0, 0, 0, - 0, 94, 94, 94, 96, 96, 0, 0, 0, 96, - 96, 96, 96, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 96, 98, 98, 0, 0, 0, 98, - 98, 98, 98, 0, 98, 0, 0, 98, 0, 0, - 0, 0, 0, 98, 98, 98, 100, 100, 0, 0, - 0, 100, 100, 100, 100, 0, 0, 0, 0, 0, + 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 94, 100, 100, 0, 0, 0, 100, 100, 100, + 100, 0, 100, 0, 0, 100, 0, 0, 0, 0, + 0, 100, 100, 100, 102, 102, 0, 0, 0, 102, + 102, 102, 102, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 102, 104, 104, 0, 0, 0, 104, + 104, 104, 104, 0, 104, 0, 0, 104, 0, 0, + 0, 0, 0, 104, 104, 104, 106, 106, 0, 0, + 0, 106, 106, 106, 106, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 106, 108, 108, 0, 0, - 0, 0, 0, 0, 0, 100, 102, 102, 0, 0, - 0, 102, 102, 102, 102, 0, 102, 0, 0, 102, - 0, 0, 0, 0, 0, 102, 102, 102, 104, 104, - 0, 0, 0, 104, 104, 104, 104, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 104, 106, 0, - 106, 106, 0, 0, 0, 0, 0, 0, 0, 0, - 106, 0, 0, 106, 0, 0, 0, 0, 0, 0, - 106, 106, 142, 142, 142, 142, 143, 143, 143, 143, - 144, 144, 145, 0, 145, 145, 146, 0, 146, 146, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, + 0, 108, 108, 108, 108, 0, 108, 0, 0, 108, + 0, 0, 0, 0, 0, 108, 108, 108, 110, 110, + 0, 0, 0, 110, 110, 110, 110, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 110, 112, 0, + 112, 112, 0, 0, 0, 0, 0, 0, 0, 0, + 112, 0, 0, 112, 0, 0, 0, 0, 0, 0, + 112, 112, 148, 148, 148, 148, 149, 149, 149, 149, + 150, 150, 151, 0, 151, 151, 152, 0, 152, 152, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141 + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147 } ; static yy_state_type yy_last_accepting_state; @@ -578,7 +578,9 @@ char *yytext; #define PP_LINE 4 -#line 42 "parser.l" +#define SQUOTE 5 + +#line 43 "parser.l" #include "config.h" @@ -603,8 +605,6 @@ char *yytext; #include "parser.tab.h" -extern char *temp_name; - static void addcchar(char c); static char *get_buffered_cstring(void); @@ -816,7 +816,7 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 127 "parser.l" +#line 126 "parser.l" #line 822 "parser.yy.c" @@ -870,13 +870,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 142 ) + if ( yy_current_state >= 148 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 491 ); + while ( yy_base[yy_current_state] != 481 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -904,12 +904,12 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 128 "parser.l" +#line 127 "parser.l" yy_push_state(PP_LINE); YY_BREAK case 2: YY_RULE_SETUP -#line 129 "parser.l" +#line 128 "parser.l" { int lineno; char *cptr, *fname; @@ -932,12 +932,12 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 148 "parser.l" +#line 147 "parser.l" yy_push_state(QUOTE); cbufidx = 0; YY_BREAK case 4: YY_RULE_SETUP -#line 149 "parser.l" +#line 148 "parser.l" { yy_pop_state(); parser_lval.str = get_buffered_cstring(); @@ -946,12 +946,12 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 154 "parser.l" +#line 153 "parser.l" yy_push_state(WSTRQUOTE); YY_BREAK case 6: YY_RULE_SETUP -#line 155 "parser.l" +#line 154 "parser.l" { yy_pop_state(); parser_lval.str = get_buffered_cstring(); @@ -959,145 +959,164 @@ YY_RULE_SETUP } YY_BREAK case 7: -#line 161 "parser.l" +YY_RULE_SETUP +#line 159 "parser.l" +yy_push_state(SQUOTE); cbufidx = 0; + YY_BREAK case 8: YY_RULE_SETUP -#line 161 "parser.l" -addcchar(yytext[1]); +#line 160 "parser.l" +{ + yy_pop_state(); + parser_lval.str = get_buffered_cstring(); + return aSQSTRING; + } YY_BREAK case 9: -YY_RULE_SETUP -#line 162 "parser.l" -addcchar('\\'); addcchar(yytext[1]); - YY_BREAK +#line 166 "parser.l" case 10: YY_RULE_SETUP -#line 163 "parser.l" -addcchar(yytext[0]); +#line 166 "parser.l" +addcchar(yytext[1]); YY_BREAK case 11: YY_RULE_SETUP -#line 164 "parser.l" -yy_push_state(ATTR); return '['; +#line 167 "parser.l" +addcchar(yytext[1]); YY_BREAK case 12: YY_RULE_SETUP -#line 165 "parser.l" -yy_pop_state(); return ']'; +#line 168 "parser.l" +addcchar('\\'); addcchar(yytext[1]); YY_BREAK case 13: YY_RULE_SETUP -#line 166 "parser.l" -return attr_token(yytext); +#line 169 "parser.l" +addcchar(yytext[0]); YY_BREAK case 14: YY_RULE_SETUP -#line 167 "parser.l" +#line 170 "parser.l" +yy_push_state(ATTR); return '['; + YY_BREAK +case 15: +YY_RULE_SETUP +#line 171 "parser.l" +yy_pop_state(); return ']'; + YY_BREAK +case 16: +YY_RULE_SETUP +#line 172 "parser.l" +return attr_token(yytext); + YY_BREAK +case 17: +YY_RULE_SETUP +#line 173 "parser.l" { parser_lval.uuid = parse_uuid(yytext); return aUUID; } YY_BREAK -case 15: +case 18: YY_RULE_SETUP -#line 171 "parser.l" +#line 177 "parser.l" { parser_lval.num = xstrtoul(yytext, NULL, 0); return aHEXNUM; } YY_BREAK -case 16: +case 19: YY_RULE_SETUP -#line 175 "parser.l" +#line 181 "parser.l" { parser_lval.num = xstrtoul(yytext, NULL, 0); return aNUM; } YY_BREAK -case 17: +case 20: YY_RULE_SETUP -#line 179 "parser.l" +#line 185 "parser.l" { parser_lval.dbl = strtod(yytext, NULL); return aDOUBLE; } YY_BREAK -case 18: +case 21: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 183 "parser.l" +#line 189 "parser.l" return tSAFEARRAY; - YY_BREAK -case 19: -YY_RULE_SETUP -#line 184 "parser.l" -return kw_token(yytext); - YY_BREAK -case 20: -YY_RULE_SETUP -#line 185 "parser.l" -line_number++; - YY_BREAK -case 21: -YY_RULE_SETUP -#line 186 "parser.l" - YY_BREAK case 22: YY_RULE_SETUP -#line 187 "parser.l" -return SHL; +#line 190 "parser.l" +return kw_token(yytext); YY_BREAK case 23: YY_RULE_SETUP -#line 188 "parser.l" -return SHR; +#line 191 "parser.l" +line_number++; YY_BREAK case 24: YY_RULE_SETUP -#line 189 "parser.l" -return MEMBERPTR; +#line 192 "parser.l" + YY_BREAK case 25: YY_RULE_SETUP -#line 190 "parser.l" -return EQUALITY; +#line 193 "parser.l" +return SHL; YY_BREAK case 26: YY_RULE_SETUP -#line 191 "parser.l" -return INEQUALITY; +#line 194 "parser.l" +return SHR; YY_BREAK case 27: YY_RULE_SETUP -#line 192 "parser.l" -return GREATEREQUAL; +#line 195 "parser.l" +return MEMBERPTR; YY_BREAK case 28: YY_RULE_SETUP -#line 193 "parser.l" -return LESSEQUAL; +#line 196 "parser.l" +return EQUALITY; YY_BREAK case 29: YY_RULE_SETUP -#line 194 "parser.l" -return LOGICALOR; +#line 197 "parser.l" +return INEQUALITY; YY_BREAK case 30: YY_RULE_SETUP -#line 195 "parser.l" -return LOGICALAND; +#line 198 "parser.l" +return GREATEREQUAL; YY_BREAK case 31: YY_RULE_SETUP -#line 196 "parser.l" -return ELLIPSIS; +#line 199 "parser.l" +return LESSEQUAL; YY_BREAK case 32: YY_RULE_SETUP -#line 197 "parser.l" +#line 200 "parser.l" +return LOGICALOR; + YY_BREAK +case 33: +YY_RULE_SETUP +#line 201 "parser.l" +return LOGICALAND; + YY_BREAK +case 34: +YY_RULE_SETUP +#line 202 "parser.l" +return ELLIPSIS; + YY_BREAK +case 35: +YY_RULE_SETUP +#line 203 "parser.l" return yytext[0]; YY_BREAK case YY_STATE_EOF(INITIAL): @@ -1105,19 +1124,20 @@ case YY_STATE_EOF(QUOTE): case YY_STATE_EOF(WSTRQUOTE): case YY_STATE_EOF(ATTR): case YY_STATE_EOF(PP_LINE): -#line 198 "parser.l" +case YY_STATE_EOF(SQUOTE): +#line 204 "parser.l" { if (import_stack_ptr) return aEOF; else yyterminate(); } YY_BREAK -case 33: +case 36: YY_RULE_SETUP -#line 203 "parser.l" +#line 209 "parser.l" ECHO; YY_BREAK -#line 1121 "parser.yy.c" +#line 1141 "parser.yy.c" case YY_END_OF_BUFFER: { @@ -1408,7 +1428,7 @@ static yy_state_type yy_get_previous_state() while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 142 ) + if ( yy_current_state >= 148 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1443,11 +1463,11 @@ yy_state_type yy_current_state; while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 142 ) + if ( yy_current_state >= 148 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 141); + yy_is_jam = (yy_current_state == 147); return yy_is_jam ? 0 : yy_current_state; } @@ -2003,7 +2023,7 @@ int main() return 0; } #endif -#line 203 "parser.l" +#line 209 "parser.l" #ifndef parser_wrap diff --git a/reactos/tools/widl/proxy.c b/reactos/tools/widl/proxy.c index cc753bbfcf2..30feca8dbe5 100644 --- a/reactos/tools/widl/proxy.c +++ b/reactos/tools/widl/proxy.c @@ -698,12 +698,12 @@ static int does_any_iface(const statement_list_t *stmts, type_pred_t pred) int need_proxy(const type_t *iface) { - return is_object(iface->attrs) && !is_local(iface->attrs); + return is_object(iface) && !is_local(iface->attrs); } int need_stub(const type_t *iface) { - return !is_object(iface->attrs) && !is_local(iface->attrs); + return !is_object(iface) && !is_local(iface->attrs); } int need_proxy_file(const statement_list_t *stmts) @@ -754,7 +754,7 @@ static void build_iface_list( const statement_list_t *stmts, type_t **ifaces[], type_t *iface = stmt->u.type; if (type_iface_get_inherit(iface) && need_proxy(iface)) { - *ifaces = xrealloc( *ifaces, (*count + 1) * sizeof(*ifaces) ); + *ifaces = xrealloc( *ifaces, (*count + 1) * sizeof(**ifaces) ); (*ifaces)[(*count)++] = iface; } } diff --git a/reactos/tools/widl/typegen.c b/reactos/tools/widl/typegen.c index fdb2379a070..c35020c90ad 100644 --- a/reactos/tools/widl/typegen.c +++ b/reactos/tools/widl/typegen.c @@ -69,7 +69,7 @@ static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs, type_t *type, int toplevel_param, const char *name, unsigned int *typestring_offset); -const char *string_of_type(unsigned char type) +static const char *string_of_type(unsigned char type) { switch (type) { @@ -133,7 +133,7 @@ static void *get_aliaschain_attrp(const type_t *type, enum attr_type attr) return get_attrp(t->attrs, attr); else if (type_is_alias(t)) t = type_alias_get_aliasee(t); - else return 0; + else return NULL; } } @@ -391,7 +391,7 @@ unsigned char get_struct_fc(const type_t *type) return RPC_FC_STRUCT; } -unsigned char get_array_fc(const type_t *type) +static unsigned char get_array_fc(const type_t *type) { unsigned char fc; const expr_t *size_is; @@ -641,7 +641,7 @@ static type_t *get_user_type(const type_t *t, const char **pname) if (type_is_alias(t)) t = type_alias_get_aliasee(t); else - return 0; + return NULL; } } @@ -3298,7 +3298,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, size = 0; } - if (phase == PHASE_MARSHAL) + if (phase == PHASE_MARSHAL && alignment > 1) print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1); print_file(file, indent, "__frame->_StubMsg.Buffer = (unsigned char *)(((ULONG_PTR)__frame->_StubMsg.Buffer + %u) & ~0x%x);\n", alignment - 1, alignment - 1); diff --git a/reactos/tools/widl/widl.c b/reactos/tools/widl/widl.c index c1c3832df2c..8c76c24e08e 100644 --- a/reactos/tools/widl/widl.c +++ b/reactos/tools/widl/widl.c @@ -100,7 +100,7 @@ int parser_debug, yy_flex_debug; int pedantic = 0; int do_everything = 1; -int preprocess_only = 0; +static int preprocess_only = 0; int do_header = 0; int do_typelib = 0; int do_proxies = 0; @@ -108,7 +108,7 @@ int do_client = 0; int do_server = 0; int do_idfile = 0; int do_dlldata = 0; -int no_preprocess = 0; +static int no_preprocess = 0; int old_names = 0; int do_win32 = 1; int do_win64 = 1; @@ -127,16 +127,15 @@ char *client_name; char *client_token; char *server_name; char *server_token; -char *idfile_name; -char *idfile_token; +static char *idfile_name; +static char *idfile_token; char *temp_name; const char *prefix_client = ""; const char *prefix_server = ""; int line_number = 1; -FILE *header; -FILE *idfile; +static FILE *idfile; size_t pointer_size = 0; syskind_t typelib_kind = sizeof(void*) == 8 ? SYS_WIN64 : SYS_WIN32; @@ -160,18 +159,18 @@ enum { static const char short_options[] = "b:cC:d:D:EhH:I:m:NpP:sS:tT:uU:VW"; static const struct option long_options[] = { - { "dlldata", 1, 0, DLLDATA_OPTION }, - { "dlldata-only", 0, 0, DLLDATA_ONLY_OPTION }, - { "local-stubs", 1, 0, LOCAL_STUBS_OPTION }, - { "oldnames", 0, 0, OLDNAMES_OPTION }, - { "prefix-all", 1, 0, PREFIX_ALL_OPTION }, - { "prefix-client", 1, 0, PREFIX_CLIENT_OPTION }, - { "prefix-server", 1, 0, PREFIX_SERVER_OPTION }, - { "win32", 0, 0, WIN32_OPTION }, - { "win64", 0, 0, WIN64_OPTION }, - { "win32-align", 1, 0, WIN32_ALIGN_OPTION }, - { "win64-align", 1, 0, WIN64_ALIGN_OPTION }, - { 0, 0, 0, 0 } + { "dlldata", 1, NULL, DLLDATA_OPTION }, + { "dlldata-only", 0, NULL, DLLDATA_ONLY_OPTION }, + { "local-stubs", 1, NULL, LOCAL_STUBS_OPTION }, + { "oldnames", 0, NULL, OLDNAMES_OPTION }, + { "prefix-all", 1, NULL, PREFIX_ALL_OPTION }, + { "prefix-client", 1, NULL, PREFIX_CLIENT_OPTION }, + { "prefix-server", 1, NULL, PREFIX_SERVER_OPTION }, + { "win32", 0, NULL, WIN32_OPTION }, + { "win64", 0, NULL, WIN64_OPTION }, + { "win32-align", 1, NULL, WIN32_ALIGN_OPTION }, + { "win64-align", 1, NULL, WIN64_ALIGN_OPTION }, + { NULL, 0, NULL, 0 } }; static void rm_tempfile(void); @@ -431,7 +430,7 @@ static void write_id_data_stmts(const statement_list_t *stmts) if (type_get_type(type) == TYPE_INTERFACE) { const UUID *uuid; - if (!is_object(type->attrs) && !is_attr(type->attrs, ATTR_DISPINTERFACE)) + if (!is_object(type) && !is_attr(type->attrs, ATTR_DISPINTERFACE)) continue; uuid = get_attrp(type->attrs, ATTR_UUID); write_guid(idfile, is_attr(type->attrs, ATTR_DISPINTERFACE) ? "DIID" : "IID", @@ -648,8 +647,8 @@ int main(int argc,char *argv[]) if(debuglevel) { - setbuf(stdout,0); - setbuf(stderr,0); + setbuf(stdout, NULL); + setbuf(stderr, NULL); } parser_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0; diff --git a/reactos/tools/widl/widltypes.h b/reactos/tools/widl/widltypes.h index f0afce4e6a5..9ee3b45882e 100644 --- a/reactos/tools/widl/widltypes.h +++ b/reactos/tools/widl/widltypes.h @@ -195,6 +195,7 @@ enum expr_type EXPR_POS, EXPR_STRLIT, EXPR_WSTRLIT, + EXPR_CHARCONST, }; enum type_kind From 266a9a6369dc2d90bb578a8aa416d7b08d54b14d Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 15:24:17 +0000 Subject: [PATCH 083/211] [URLMON] sync urlmon to wine 1.1.39 svn path=/trunk/; revision=45834 --- reactos/dll/win32/urlmon/binding.c | 9 + reactos/dll/win32/urlmon/bindprot.c | 3 +- reactos/dll/win32/urlmon/download.c | 4 +- reactos/dll/win32/urlmon/http.c | 27 +- reactos/dll/win32/urlmon/internet.c | 104 ++++++- reactos/dll/win32/urlmon/protocol.c | 5 + reactos/dll/win32/urlmon/regsvr.c | 30 +- reactos/dll/win32/urlmon/sec_mgr.c | 95 ++++++- reactos/dll/win32/urlmon/uri.c | 302 +++++++++++++++++++++ reactos/dll/win32/urlmon/urlmon.inf | 1 - reactos/dll/win32/urlmon/urlmon.rbuild | 15 +- reactos/dll/win32/urlmon/urlmon.spec | 3 +- reactos/dll/win32/urlmon/urlmon_local.idl | 2 - reactos/dll/win32/urlmon/urlmon_main.c | 5 + reactos/dll/win32/urlmon/urlmon_main.h | 6 + reactos/dll/win32/urlmon/urlmon_urlmon.idl | 19 ++ reactos/dll/win32/urlmon/usrmarshal.c | 162 +++++++++++ reactos/include/psdk/urlmon.idl | 59 ++++ 18 files changed, 813 insertions(+), 38 deletions(-) create mode 100644 reactos/dll/win32/urlmon/uri.c delete mode 100644 reactos/dll/win32/urlmon/urlmon_local.idl create mode 100644 reactos/dll/win32/urlmon/urlmon_urlmon.idl create mode 100644 reactos/dll/win32/urlmon/usrmarshal.c diff --git a/reactos/dll/win32/urlmon/binding.c b/reactos/dll/win32/urlmon/binding.c index 210e8e2ed43..dcf0207278c 100644 --- a/reactos/dll/win32/urlmon/binding.c +++ b/reactos/dll/win32/urlmon/binding.c @@ -98,6 +98,7 @@ struct Binding { LPWSTR mime; UINT clipboard_format; LPWSTR url; + LPWSTR redirect_url; IID iid; BOOL report_mime; DWORD state; @@ -829,6 +830,7 @@ static ULONG WINAPI Binding_Release(IBinding *iface) This->section.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->section); heap_free(This->mime); + heap_free(This->redirect_url); heap_free(This->url); heap_free(This); @@ -967,6 +969,11 @@ static HRESULT WINAPI InternetProtocolSink_ReportProgress(IInternetProtocolSink case BINDSTATUS_CONNECTING: on_progress(This, 0, 0, BINDSTATUS_CONNECTING, szStatusText); break; + case BINDSTATUS_REDIRECTING: + heap_free(This->redirect_url); + This->redirect_url = heap_strdupW(szStatusText); + on_progress(This, 0, 0, BINDSTATUS_REDIRECTING, szStatusText); + break; case BINDSTATUS_BEGINDOWNLOADDATA: fill_stgmed_buffer(This->stgmed_buf); break; @@ -1474,6 +1481,8 @@ static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, I if(binding_ctx) { set_binding_sink(binding->protocol, PROTSINK(binding)); + if(binding_ctx->redirect_url) + IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_REDIRECTING, binding_ctx->redirect_url); report_data(binding, 0, 0, 0); }else { hres = IInternetProtocol_Start(binding->protocol, url, PROTSINK(binding), diff --git a/reactos/dll/win32/urlmon/bindprot.c b/reactos/dll/win32/urlmon/bindprot.c index e4f203d28f5..07d6fc2f525 100644 --- a/reactos/dll/win32/urlmon/bindprot.c +++ b/reactos/dll/win32/urlmon/bindprot.c @@ -205,7 +205,7 @@ static void push_task(BindProtocol *This, task_header_t *task, task_proc_t proc) This->task_queue_tail = task; }else { This->task_queue_tail = This->task_queue_head = task; - do_post = TRUE; + do_post = !This->continue_call; } LeaveCriticalSection(&This->section); @@ -960,6 +960,7 @@ static void report_progress(BindProtocol *This, ULONG status_code, LPCWSTR statu switch(status_code) { case BINDSTATUS_FINDINGRESOURCE: case BINDSTATUS_CONNECTING: + case BINDSTATUS_REDIRECTING: case BINDSTATUS_BEGINDOWNLOADDATA: case BINDSTATUS_SENDINGREQUEST: case BINDSTATUS_CACHEFILENAMEAVAILABLE: diff --git a/reactos/dll/win32/urlmon/download.c b/reactos/dll/win32/urlmon/download.c index d81dffaedc4..ebcb9c932c7 100644 --- a/reactos/dll/win32/urlmon/download.c +++ b/reactos/dll/win32/urlmon/download.c @@ -140,6 +140,7 @@ static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG u debugstr_w(szStatusText)); switch(ulStatusCode) { + case BINDSTATUS_CONNECTING: case BINDSTATUS_BEGINDOWNLOADDATA: case BINDSTATUS_DOWNLOADINGDATA: case BINDSTATUS_ENDDOWNLOADDATA: @@ -153,8 +154,7 @@ static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG u This->cache_file = heap_strdupW(szStatusText); break; - case BINDSTATUS_FINDINGRESOURCE: - case BINDSTATUS_CONNECTING: + case BINDSTATUS_FINDINGRESOURCE: /* FIXME */ break; default: diff --git a/reactos/dll/win32/urlmon/http.c b/reactos/dll/win32/urlmon/http.c index bb81ec820b6..fc0b8c4ecfe 100644 --- a/reactos/dll/win32/urlmon/http.c +++ b/reactos/dll/win32/urlmon/http.c @@ -17,11 +17,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -/* - * TODO: - * - Handle redirects as native. - */ - #include "urlmon_main.h" #include "wininet.h" @@ -84,7 +79,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ URL_COMPONENTSW url_comp; BYTE security_id[512]; DWORD len = 0; - ULONG num = 0; + ULONG num; BOOL res, b; HRESULT hres; @@ -95,7 +90,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ memset(&url_comp, 0, sizeof(url_comp)); url_comp.dwStructSize = sizeof(url_comp); - url_comp.dwSchemeLength = url_comp.dwHostNameLength = url_comp.dwUrlPathLength = + url_comp.dwSchemeLength = url_comp.dwHostNameLength = url_comp.dwUrlPathLength = url_comp.dwExtraInfoLength = url_comp.dwUserNameLength = url_comp.dwPasswordLength = 1; if (!InternetCrackUrlW(url, 0, 0, &url_comp)) return MK_E_SYNTAX; @@ -124,7 +119,12 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ } accept_mimes[num] = 0; - path = heap_strndupW(url_comp.lpszUrlPath, url_comp.dwUrlPathLength); + path = heap_alloc((url_comp.dwUrlPathLength+url_comp.dwExtraInfoLength+1)*sizeof(WCHAR)); + if(url_comp.dwUrlPathLength) + memcpy(path, url_comp.lpszUrlPath, url_comp.dwUrlPathLength*sizeof(WCHAR)); + if(url_comp.dwExtraInfoLength) + memcpy(path+url_comp.dwUrlPathLength, url_comp.lpszExtraInfo, url_comp.dwExtraInfoLength*sizeof(WCHAR)); + path[url_comp.dwUrlPathLength+url_comp.dwExtraInfoLength] = 0; if(This->https) request_flags |= INTERNET_FLAG_SECURE; This->base.request = HttpOpenRequestW(This->base.connection, @@ -132,8 +132,8 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ ? wszBindVerb[This->base.bind_info.dwBindVerb] : This->base.bind_info.szCustomVerb, path, NULL, NULL, (LPCWSTR *)accept_mimes, request_flags, (DWORD_PTR)&This->base); heap_free(path); - while (numbase.request) { WARN("HttpOpenRequest failed: %d\n", GetLastError()); return INET_E_RESOURCE_NOT_FOUND; @@ -227,7 +227,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ static HRESULT HttpProtocol_start_downloading(Protocol *prot) { HttpProtocol *This = ASYNCPROTOCOL_THIS(prot); - LPWSTR content_type = 0, content_length = 0; + LPWSTR content_type, content_length, ranges; DWORD len = sizeof(DWORD); DWORD status_code; BOOL res; @@ -258,8 +258,11 @@ static HRESULT HttpProtocol_start_downloading(Protocol *prot) WARN("HttpQueryInfo failed: %d\n", GetLastError()); } - if(This->https) + ranges = query_http_info(This, HTTP_QUERY_ACCEPT_RANGES); + if(ranges) { IInternetProtocolSink_ReportProgress(This->base.protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL); + heap_free(ranges); + } content_type = query_http_info(This, HTTP_QUERY_CONTENT_TYPE); if(content_type) { diff --git a/reactos/dll/win32/urlmon/internet.c b/reactos/dll/win32/urlmon/internet.c index 8bde7b4790f..6a79e48b526 100644 --- a/reactos/dll/win32/urlmon/internet.c +++ b/reactos/dll/win32/urlmon/internet.c @@ -38,6 +38,9 @@ static HRESULT parse_schema(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, if(ptr) len = ptr-url; + if(rsize) + *rsize = len; + if(len >= size) return E_POINTER; @@ -45,9 +48,6 @@ static HRESULT parse_schema(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, memcpy(result, url, len*sizeof(WCHAR)); result[len] = 0; - if(rsize) - *rsize = len; - return S_OK; } @@ -170,6 +170,100 @@ static HRESULT parse_security_domain(LPCWSTR url, DWORD flags, LPWSTR result, return E_FAIL; } +static HRESULT parse_domain(LPCWSTR url, DWORD flags, LPWSTR result, + DWORD size, DWORD *rsize) +{ + IInternetProtocolInfo *protocol_info; + HRESULT hres; + + TRACE("(%s %08x %p %d %p)\n", debugstr_w(url), flags, result, size, rsize); + + protocol_info = get_protocol_info(url); + + if(protocol_info) { + hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_DOMAIN, + flags, result, size, rsize, 0); + IInternetProtocolInfo_Release(protocol_info); + if(SUCCEEDED(hres)) + return hres; + } + + hres = UrlGetPartW(url, result, &size, URL_PART_HOSTNAME, flags); + if(rsize) + *rsize = size; + + if(hres == E_POINTER) + return S_FALSE; + + if(FAILED(hres)) + return E_FAIL; + return S_OK; +} + +static HRESULT parse_rootdocument(LPCWSTR url, DWORD flags, LPWSTR result, + DWORD size, DWORD *rsize) +{ + IInternetProtocolInfo *protocol_info; + PARSEDURLW url_info; + HRESULT hres; + + TRACE("(%s %08x %p %d %p)\n", debugstr_w(url), flags, result, size, rsize); + + protocol_info = get_protocol_info(url); + + if(protocol_info) { + hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_ROOTDOCUMENT, + flags, result, size, rsize, 0); + IInternetProtocolInfo_Release(protocol_info); + if(SUCCEEDED(hres)) + return hres; + } + + url_info.cbSize = sizeof(url_info); + if(FAILED(ParseURLW(url, &url_info))) + return E_FAIL; + + switch(url_info.nScheme) { + case URL_SCHEME_FTP: + case URL_SCHEME_HTTP: + case URL_SCHEME_HTTPS: + if(url_info.cchSuffix<3 || *(url_info.pszSuffix)!='/' + || *(url_info.pszSuffix+1)!='/') + return E_FAIL; + + if(size < url_info.cchProtocol+3) { + size = 0; + hres = UrlGetPartW(url, result, &size, URL_PART_HOSTNAME, flags); + + if(rsize) + *rsize = size+url_info.cchProtocol+3; + + if(hres == E_POINTER) + return S_FALSE; + + return hres; + } + + size -= url_info.cchProtocol+3; + hres = UrlGetPartW(url, result+url_info.cchProtocol+3, + &size, URL_PART_HOSTNAME, flags); + + if(hres == E_POINTER) + return S_FALSE; + + if(FAILED(hres)) + return E_FAIL; + + if(rsize) + *rsize = size+url_info.cchProtocol+3; + + memcpy(result, url, (url_info.cchProtocol+3)*sizeof(WCHAR)); + return hres; + default: + return E_FAIL; + } +} + /************************************************************************** * CoInternetParseUrl (URLMON.@) */ @@ -192,6 +286,10 @@ HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD return parse_schema(pwzUrl, dwFlags, pszResult, cchResult, pcchResult); case PARSE_SECURITY_DOMAIN: return parse_security_domain(pwzUrl, dwFlags, pszResult, cchResult, pcchResult); + case PARSE_DOMAIN: + return parse_domain(pwzUrl, dwFlags, pszResult, cchResult, pcchResult); + case PARSE_ROOTDOCUMENT: + return parse_rootdocument(pwzUrl, dwFlags, pszResult, cchResult, pcchResult); default: FIXME("not supported action %d\n", ParseAction); } diff --git a/reactos/dll/win32/urlmon/protocol.c b/reactos/dll/win32/urlmon/protocol.c index 9b25cbf4307..3f3cbe505bc 100644 --- a/reactos/dll/win32/urlmon/protocol.c +++ b/reactos/dll/win32/urlmon/protocol.c @@ -151,6 +151,11 @@ static void WINAPI internet_status_callback(HINTERNET internet, DWORD_PTR contex report_progress(protocol, BINDSTATUS_SENDINGREQUEST, (LPWSTR)status_info); break; + case INTERNET_STATUS_REDIRECT: + TRACE("%p INTERNET_STATUS_REDIRECT\n", protocol); + report_progress(protocol, BINDSTATUS_REDIRECTING, (LPWSTR)status_info); + break; + case INTERNET_STATUS_REQUEST_COMPLETE: request_complete(protocol, status_info); break; diff --git a/reactos/dll/win32/urlmon/regsvr.c b/reactos/dll/win32/urlmon/regsvr.c index 9561a23feaf..9e278259e37 100644 --- a/reactos/dll/win32/urlmon/regsvr.c +++ b/reactos/dll/win32/urlmon/regsvr.c @@ -495,6 +495,12 @@ static struct regsvr_coclass const coclass_list[] = { "urlmon.dll", "Both" }, + { &CLSID_PSFactoryBuffer, + "URLMoniker ProxyStub Factory", + NULL, + "urlmon.dll", + "Apartment" + }, { NULL } /* list terminator */ }; @@ -573,12 +579,14 @@ HRESULT WINAPI DllRegisterServer(void) TRACE("\n"); - hr = register_coclasses(coclass_list); - if (SUCCEEDED(hr)) + hr = URLMON_DllRegisterServer(); + if(SUCCEEDED(hr)) + hr = register_coclasses(coclass_list); + if(SUCCEEDED(hr)) hr = register_interfaces(interface_list); - if(FAILED(hr)) - return hr; - return register_inf(TRUE); + if(SUCCEEDED(hr)) + hr = register_inf(TRUE); + return hr; } /*********************************************************************** @@ -590,10 +598,12 @@ HRESULT WINAPI DllUnregisterServer(void) TRACE("\n"); - hr = unregister_coclasses(coclass_list); - if (SUCCEEDED(hr)) + hr = URLMON_DllUnregisterServer(); + if(SUCCEEDED(hr)) + hr = unregister_coclasses(coclass_list); + if(SUCCEEDED(hr)) hr = unregister_interfaces(interface_list); - if(FAILED(hr)) - return hr; - return register_inf(FALSE); + if(SUCCEEDED(hr)) + hr = register_inf(FALSE); + return hr; } diff --git a/reactos/dll/win32/urlmon/sec_mgr.c b/reactos/dll/win32/urlmon/sec_mgr.c index 7a1255a49ad..81f2f507d0d 100644 --- a/reactos/dll/win32/urlmon/sec_mgr.c +++ b/reactos/dll/win32/urlmon/sec_mgr.c @@ -147,12 +147,18 @@ static HRESULT map_url_to_zone(LPCWSTR url, DWORD *zone, LPWSTR *ret_url) DWORD size=0; HRESULT hres; - secur_url = heap_alloc(INTERNET_MAX_URL_LENGTH*sizeof(WCHAR)); *zone = -1; - hres = CoInternetParseUrl(url, PARSE_SECURITY_URL, 0, secur_url, INTERNET_MAX_URL_LENGTH, &size, 0); - if(hres != S_OK) - strcpyW(secur_url, url); + hres = CoInternetGetSecurityUrl(url, &secur_url, PSU_SECURITY_URL_ONLY, 0); + if(hres != S_OK) { + size = strlenW(url)*sizeof(WCHAR); + + secur_url = heap_alloc(size); + if(!secur_url) + return E_OUTOFMEMORY; + + memcpy(secur_url, url, size); + } hres = CoInternetParseUrl(secur_url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(WCHAR), &size, 0); if(FAILED(hres) || !*schema) { @@ -1228,3 +1234,84 @@ HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider* pSP, IInternetZoneM TRACE("(%p %p %x)\n", pSP, ppZM, dwReserved); return ZoneMgrImpl_Construct(NULL, (void**)ppZM); } + +/******************************************************************** + * CoInternetGetSecurityUrl (URLMON.@) + */ +HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR pwzUrl, LPWSTR *ppwzSecUrl, PSUACTION psuAction, DWORD dwReserved) +{ + WCHAR buf1[INTERNET_MAX_URL_LENGTH], buf2[INTERNET_MAX_URL_LENGTH]; + LPWSTR url, domain; + DWORD len; + HRESULT hres; + + TRACE("(%p,%p,%u,%u)\n", pwzUrl, ppwzSecUrl, psuAction, dwReserved); + + url = buf1; + domain = buf2; + strcpyW(url, pwzUrl); + + while(1) { + hres = CoInternetParseUrl(url, PARSE_SECURITY_URL, 0, domain, INTERNET_MAX_URL_LENGTH, &len, 0); + if(hres!=S_OK || !strcmpW(url, domain)) + break; + + if(url == buf1) { + url = buf2; + domain = buf1; + } else { + url = buf1; + domain = buf2; + } + } + + if(psuAction==PSU_SECURITY_URL_ONLY) { + len = lstrlenW(url)+1; + *ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ppwzSecUrl) + return E_OUTOFMEMORY; + + memcpy(*ppwzSecUrl, url, len*sizeof(WCHAR)); + return S_OK; + } + + hres = CoInternetParseUrl(url, PARSE_SECURITY_DOMAIN, 0, domain, + INTERNET_MAX_URL_LENGTH, &len, 0); + if(SUCCEEDED(hres)) { + len++; + *ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ppwzSecUrl) + return E_OUTOFMEMORY; + + memcpy(*ppwzSecUrl, domain, len*sizeof(WCHAR)); + return S_OK; + } + + hres = CoInternetParseUrl(url, PARSE_ROOTDOCUMENT, 0, domain, 0, &len, 0); + if(hres == S_FALSE) { + hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, domain, + INTERNET_MAX_URL_LENGTH, &len, 0); + if(hres == S_OK) { + domain[len] = ':'; + hres = CoInternetParseUrl(url, PARSE_DOMAIN, 0, domain+len+1, + INTERNET_MAX_URL_LENGTH-len-1, &len, 0); + if(hres == S_OK) { + len = lstrlenW(domain)+1; + *ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ppwzSecUrl) + return E_OUTOFMEMORY; + + memcpy(*ppwzSecUrl, domain, len*sizeof(WCHAR)); + return S_OK; + } + } + } + + len = lstrlenW(url)+1; + *ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ppwzSecUrl) + return E_OUTOFMEMORY; + + memcpy(*ppwzSecUrl, url, len*sizeof(WCHAR)); + return S_OK; +} diff --git a/reactos/dll/win32/urlmon/uri.c b/reactos/dll/win32/urlmon/uri.c new file mode 100644 index 00000000000..d4d6b47e5ab --- /dev/null +++ b/reactos/dll/win32/urlmon/uri.c @@ -0,0 +1,302 @@ +/* + * Copyright 2010 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "urlmon_main.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(urlmon); + +typedef struct { + const IUriVtbl *lpIUriVtbl; + LONG ref; +} Uri; + +#define URI(x) ((IUri*) &(x)->lpIUriVtbl) + +#define URI_THIS(iface) DEFINE_THIS(Uri, IUri, iface) + +static HRESULT WINAPI Uri_QueryInterface(IUri *iface, REFIID riid, void **ppv) +{ + Uri *This = URI_THIS(iface); + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = URI(This); + }else if(IsEqualGUID(&IID_IUri, riid)) { + TRACE("(%p)->(IID_IUri %p)\n", This, ppv); + *ppv = URI(This); + }else { + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI Uri_AddRef(IUri *iface) +{ + Uri *This = URI_THIS(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI Uri_Release(IUri *iface) +{ + Uri *This = URI_THIS(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) + heap_free(This); + + return ref; +} + +static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BSTR *pbstrProperty, DWORD dwFlags) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_HasProperty(IUri *iface, Uri_PROPERTY uriProp, BOOL *pfHasProperty) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->()\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetAbsoluteUri(IUri *iface, BSTR *pstrAbsoluteUri) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrAbsoluteUri); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetAuthority(IUri *iface, BSTR *pstrAuthority) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrAuthority); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetDisplayUri(IUri *iface, BSTR *pstrDisplayUri) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrDisplayUri); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetDomain(IUri *iface, BSTR *pstrDomain) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrDomain); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetExtension(IUri *iface, BSTR *pstrExtension) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrExtension); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetFragment(IUri *iface, BSTR *pstrFragment) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrFragment); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetHost(IUri *iface, BSTR *pstrHost) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrHost); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPassword(IUri *iface, BSTR *pstrPassword) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrPassword); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPath(IUri *iface, BSTR *pstrPath) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrPath); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPathAndQuery(IUri *iface, BSTR *pstrPathAndQuery) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrPathAndQuery); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetQuery(IUri *iface, BSTR *pstrQuery) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrQuery); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetRawUri(IUri *iface, BSTR *pstrRawUri) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrRawUri); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetSchemeName(IUri *iface, BSTR *pstrSchemeName) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrSchemeName); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetUserInfo(IUri *iface, BSTR *pstrUserInfo) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrUserInfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetUserName(IUri *iface, BSTR *pstrUserName) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrUserName); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetHostType(IUri *iface, DWORD *pdwHostType) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwHostType); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPort(IUri *iface, DWORD *pdwPort) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwPort); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetScheme(IUri *iface, DWORD *pdwScheme) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwScheme); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetZone(IUri *iface, DWORD *pdwZone) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwZone); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetProperties(IUri *iface, DWORD *pdwProperties) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwProperties); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_IsEqual(IUri *iface, IUri *pUri, BOOL *pfEqual) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p %p)\n", This, pUri, pfEqual); + return E_NOTIMPL; +} + +#undef URI_THIS + +static const IUriVtbl UriVtbl = { + Uri_QueryInterface, + Uri_AddRef, + Uri_Release, + Uri_GetPropertyBSTR, + Uri_GetPropertyLength, + Uri_GetPropertyDWORD, + Uri_HasProperty, + Uri_GetAbsoluteUri, + Uri_GetAuthority, + Uri_GetDisplayUri, + Uri_GetDomain, + Uri_GetExtension, + Uri_GetFragment, + Uri_GetHost, + Uri_GetPassword, + Uri_GetPath, + Uri_GetPathAndQuery, + Uri_GetQuery, + Uri_GetRawUri, + Uri_GetSchemeName, + Uri_GetUserInfo, + Uri_GetUserName, + Uri_GetHostType, + Uri_GetPort, + Uri_GetScheme, + Uri_GetZone, + Uri_GetProperties, + Uri_IsEqual +}; + +/*********************************************************************** + * CreateUri (urlmon.@) + */ +HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI) +{ + Uri *ret; + + TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI), dwFlags, (DWORD)dwReserved, ppURI); + + ret = heap_alloc(sizeof(Uri)); + if(!ret) + return E_OUTOFMEMORY; + + ret->lpIUriVtbl = &UriVtbl; + ret->ref = 1; + + *ppURI = URI(ret); + return S_OK; +} diff --git a/reactos/dll/win32/urlmon/urlmon.inf b/reactos/dll/win32/urlmon/urlmon.inf index 4d781c73bd0..c9debb43a80 100644 --- a/reactos/dll/win32/urlmon/urlmon.inf +++ b/reactos/dll/win32/urlmon/urlmon.inf @@ -43,7 +43,6 @@ HKCR,"PROTOCOLS\Filter\lzdhtml","CLSID",,"%CLSID_DeCompMimeFilter%" [ZoneMap.Reg] -HKCU,"Software\Microsoft\Windows\CurrentVersion\Internet Settings",,, HKCU,"%PATH_ZONEMAP%",,, HKLM,"%PATH_ZONEMAP%",,, HKCU,"%PATH_ZONEMAP%","ProxyByPass", 0x10001,0x1 diff --git a/reactos/dll/win32/urlmon/urlmon.rbuild b/reactos/dll/win32/urlmon/urlmon.rbuild index 48034c5b4bb..c8c75863db4 100644 --- a/reactos/dll/win32/urlmon/urlmon.rbuild +++ b/reactos/dll/win32/urlmon/urlmon.rbuild @@ -27,18 +27,29 @@ session.c umon.c umstream.c + uri.c urlmon_main.c + usrmarshal.c rsrc.rc wine uuid + rpcrt4 ole32 shlwapi wininet user32 advapi32 + pseh + urlmon_proxy ntdll - - urlmon_local.idl + + + URLMON_ + + + + {0x79EAC9F1,0xBAF9,0x11CE,{0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B}} + urlmon_urlmon.idl diff --git a/reactos/dll/win32/urlmon/urlmon.spec b/reactos/dll/win32/urlmon/urlmon.spec index 2ed99886d21..dbb8fa974c6 100644 --- a/reactos/dll/win32/urlmon/urlmon.spec +++ b/reactos/dll/win32/urlmon/urlmon.spec @@ -15,7 +15,7 @@ @ stdcall CoInternetCreateSecurityManager(ptr ptr long) @ stdcall CoInternetCreateZoneManager(ptr ptr long) @ stub CoInternetGetProtocolFlags -@ stub CoInternetGetSecurityUrl +@ stdcall CoInternetGetSecurityUrl(ptr ptr long long) @ stdcall CoInternetGetSession(long ptr long) @ stdcall CoInternetParseUrl(wstr long long wstr long ptr long) @ stdcall CoInternetQueryInfo(ptr long long ptr long ptr long) @@ -26,6 +26,7 @@ @ stdcall CreateAsyncBindCtx(long ptr ptr ptr) @ stdcall CreateAsyncBindCtxEx(ptr long ptr ptr ptr long) @ stdcall CreateFormatEnumerator(long ptr ptr) +@ stdcall CreateUri(wstr long long ptr) @ stdcall CreateURLMoniker(ptr wstr ptr) @ stdcall CreateURLMonikerEx(ptr wstr ptr long) @ stdcall -private DllCanUnloadNow() diff --git a/reactos/dll/win32/urlmon/urlmon_local.idl b/reactos/dll/win32/urlmon/urlmon_local.idl deleted file mode 100644 index 1a1403ea73e..00000000000 --- a/reactos/dll/win32/urlmon/urlmon_local.idl +++ /dev/null @@ -1,2 +0,0 @@ - -#include "urlmon.idl" diff --git a/reactos/dll/win32/urlmon/urlmon_main.c b/reactos/dll/win32/urlmon/urlmon_main.c index a420308453d..272884eb2a6 100644 --- a/reactos/dll/win32/urlmon/urlmon_main.c +++ b/reactos/dll/win32/urlmon/urlmon_main.c @@ -348,6 +348,7 @@ static void init_session(BOOL init) HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { unsigned int i; + HRESULT hr; TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); @@ -357,6 +358,10 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) return IClassFactory_QueryInterface(object_creation[i].cf, riid, ppv); } + hr = URLMON_DllGetClassObject(rclsid, riid, ppv); + if(SUCCEEDED(hr)) + return hr; + FIXME("%s: no class found.\n", debugstr_guid(rclsid)); return CLASS_E_CLASSNOTAVAILABLE; } diff --git a/reactos/dll/win32/urlmon/urlmon_main.h b/reactos/dll/win32/urlmon/urlmon_main.h index 21b93430a60..8db786b7d80 100644 --- a/reactos/dll/win32/urlmon/urlmon_main.h +++ b/reactos/dll/win32/urlmon/urlmon_main.h @@ -48,6 +48,12 @@ extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); +extern HRESULT WINAPI URLMON_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) DECLSPEC_HIDDEN; +extern HRESULT WINAPI URLMON_DllRegisterServer(void) DECLSPEC_HIDDEN; +extern HRESULT WINAPI URLMON_DllUnregisterServer(void) DECLSPEC_HIDDEN; + +extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN; + /********************************************************************** * Dll lifetime tracking declaration for urlmon.dll */ diff --git a/reactos/dll/win32/urlmon/urlmon_urlmon.idl b/reactos/dll/win32/urlmon/urlmon_urlmon.idl new file mode 100644 index 00000000000..71a0719d7d9 --- /dev/null +++ b/reactos/dll/win32/urlmon/urlmon_urlmon.idl @@ -0,0 +1,19 @@ +/* + * Copyright 2009 Piotr Caban for Codeweavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "urlmon.idl" diff --git a/reactos/dll/win32/urlmon/usrmarshal.c b/reactos/dll/win32/urlmon/usrmarshal.c new file mode 100644 index 00000000000..b94556362be --- /dev/null +++ b/reactos/dll/win32/urlmon/usrmarshal.c @@ -0,0 +1,162 @@ +/* + * Copyright 2009 Piotr Caban for Codeweavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "urlmon_main.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(urlmon); + +HRESULT CALLBACK IWinInetHttpInfo_QueryInfo_Proxy(IWinInetHttpInfo* This, + DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf, DWORD *pdwFlags, + DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IWinInetHttpInfo_QueryInfo_Stub(IWinInetHttpInfo* This, + DWORD dwOption, BYTE *pBuffer, DWORD *pcbBuf, DWORD *pdwFlags, + DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IWinInetInfo_QueryOption_Proxy(IWinInetInfo* This, + DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IWinInetInfo_QueryOption_Stub(IWinInetInfo* This, + DWORD dwOption, BYTE *pBuffer, DWORD *pcbBuf) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindHost_MonikerBindToStorage_Proxy(IBindHost* This, + IMoniker *pMk, IBindCtx *pBC, IBindStatusCallback *pBSC, + REFIID riid, void **ppvObj) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindHost_MonikerBindToStorage_Stub(IBindHost* This, + IMoniker *pMk, IBindCtx *pBC, IBindStatusCallback *pBSC, + REFIID riid, IUnknown **ppvObj) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindHost_MonikerBindToObject_Proxy(IBindHost* This, + IMoniker *pMk, IBindCtx *pBC, IBindStatusCallback *pBSC, + REFIID riid, void **ppvObj) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindHost_MonikerBindToObject_Stub(IBindHost* This, + IMoniker *pMk, IBindCtx *pBC, IBindStatusCallback *pBSC, + REFIID riid, IUnknown **ppvObj) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindStatusCallbackEx_GetBindInfoEx_Proxy( + IBindStatusCallbackEx* This, DWORD *grfBINDF, BINDINFO *pbindinfo, + DWORD *grfBINDF2, DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindStatusCallbackEx_GetBindInfoEx_Stub( + IBindStatusCallbackEx* This, DWORD *grfBINDF, RemBINDINFO *pbindinfo, + RemSTGMEDIUM *pstgmed, DWORD *grfBINDF2, DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindStatusCallback_GetBindInfo_Proxy( + IBindStatusCallback* This, DWORD *grfBINDF, BINDINFO *pbindinfo) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindStatusCallback_GetBindInfo_Stub( + IBindStatusCallback* This, DWORD *grfBINDF, + RemBINDINFO *pbindinfo, RemSTGMEDIUM *pstgmed) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindStatusCallback_OnDataAvailable_Proxy( + IBindStatusCallback* This, DWORD grfBSCF, DWORD dwSize, + FORMATETC *pformatetc, STGMEDIUM *pstgmed) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindStatusCallback_OnDataAvailable_Stub( + IBindStatusCallback* This, DWORD grfBSCF, DWORD dwSize, + RemFORMATETC *pformatetc, RemSTGMEDIUM *pstgmed) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBinding_GetBindResult_Proxy(IBinding* This, + CLSID *pclsidProtocol, DWORD *pdwResult, + LPOLESTR *pszResult, DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBinding_GetBindResult_Stub(IBinding* This, + CLSID *pclsidProtocol, DWORD *pdwResult, + LPOLESTR *pszResult, DWORD dwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE IWindowForBindingUI_GetWindow_Proxy( + IWindowForBindingUI* This, REFGUID rguidReason, HWND *phwnd) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +void __RPC_STUB IWindowForBindingUI_GetWindow_Stub(IRpcStubBuffer* This, + IRpcChannelBuffer* pRpcChannelBuffer, PRPC_MESSAGE pRpcMessage, + DWORD* pdwStubPhase) +{ + FIXME("stub\n"); +} diff --git a/reactos/include/psdk/urlmon.idl b/reactos/include/psdk/urlmon.idl index 78afd1691c9..d16a3b5d7ec 100644 --- a/reactos/include/psdk/urlmon.idl +++ b/reactos/include/psdk/urlmon.idl @@ -1646,6 +1646,62 @@ interface IUri : IUnknown [out] BOOL *pfEqual); } +cpp_quote("HRESULT WINAPI CreateUri(LPCWSTR,DWORD,DWORD_PTR,IUri**);") +cpp_quote("HRESULT WINAPI CreateUriWithFragment(LPCWSTR,LPCWSTR,DWORD,DWORD_PTR,IUri**);") +cpp_quote("HRESULT WINAPI CreateUriFromMultiByteString(LPCSTR,DWORD,DWORD,DWORD,DWORD_PTR,IUri**);") + +cpp_quote("#define Uri_HAS_ABSOLUTE_URI (1 << Uri_PROPERTY_ABSOLUTE_URI)") +cpp_quote("#define Uri_HAS_AUTHORITY (1 << Uri_PROPERTY_AUTHORITY)") +cpp_quote("#define Uri_HAS_DISPLAY_URI (1 << Uri_PROPERTY_DISPLAY_URI)") +cpp_quote("#define Uri_HAS_DOMAIN (1 << Uri_PROPERTY_DOMAIN)") +cpp_quote("#define Uri_HAS_EXTENSION (1 << Uri_PROPERTY_EXTENSION)") +cpp_quote("#define Uri_HAS_FRAGMENT (1 << Uri_PROPERTY_FRAGMENT)") +cpp_quote("#define Uri_HAS_HOST (1 << Uri_PROPERTY_HOST)") +cpp_quote("#define Uri_HAS_PASSWORD (1 << Uri_PROPERTY_PASSWORD)") +cpp_quote("#define Uri_HAS_PATH (1 << Uri_PROPERTY_PATH)") +cpp_quote("#define Uri_HAS_QUERY (1 << Uri_PROPERTY_QUERY)") +cpp_quote("#define Uri_HAS_RAW_URI (1 << Uri_PROPERTY_RAW_URI)") +cpp_quote("#define Uri_HAS_SCHEME_NAME (1 << Uri_PROPERTY_SCHEME_NAME)") +cpp_quote("#define Uri_HAS_USER_NAME (1 << Uri_PROPERTY_USER_NAME)") +cpp_quote("#define Uri_HAS_PATH_AND_QUERY (1 << Uri_PROPERTY_PATH_AND_QUERY)") +cpp_quote("#define Uri_HAS_USER_INFO (1 << Uri_PROPERTY_USER_INFO)") +cpp_quote("#define Uri_HAS_HOST_TYPE (1 << Uri_PROPERTY_HOST_TYPE)") +cpp_quote("#define Uri_HAS_PORT (1 << Uri_PROPERTY_PORT)") +cpp_quote("#define Uri_HAS_SCHEME (1 << Uri_PROPERTY_SCHEME)") +cpp_quote("#define Uri_HAS_ZONE (1 << Uri_PROPERTY_ZONE)") + +cpp_quote("#define Uri_CREATE_ALLOW_RELATIVE 0x0001") +cpp_quote("#define Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME 0x0002") +cpp_quote("#define Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME 0x0004") +cpp_quote("#define Uri_CREATE_NOFRAG 0x0008") +cpp_quote("#define Uri_CREATE_NO_CANONICALIZE 0x0010") +cpp_quote("#define Uri_CREATE_CANONICALIZE 0x0100") +cpp_quote("#define Uri_CREATE_FILE_USE_DOS_PATH 0x0020") +cpp_quote("#define Uri_CREATE_DECODE_EXTRA_INFO 0x0040") +cpp_quote("#define Uri_CREATE_NO_DECODE_EXTRA_INFO 0x0080") +cpp_quote("#define Uri_CREATE_CRACK_UNKNOWN_SCHEMES 0x0200") +cpp_quote("#define Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES 0x0400") +cpp_quote("#define Uri_CREATE_PRE_PROCESS_HTML_URI 0x0800") +cpp_quote("#define Uri_CREATE_NO_PRE_PROCESS_HTML_URI 0x1000") +cpp_quote("#define Uri_CREATE_IE_SETTINGS 0x2000") +cpp_quote("#define Uri_CREATE_NO_IE_SETTINGS 0x4000") +cpp_quote("#define Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS 0x8000") + +cpp_quote("#define Uri_DISPLAY_NO_FRAGMENT 0x00000001") +cpp_quote("#define Uri_PUNYCODE_IDN_HOST 0x00000002") +cpp_quote("#define Uri_DISPLAY_IDN_HOST 0x00000004") + +cpp_quote("#define Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8 0x00000001") +cpp_quote("#define Uri_ENCODING_USER_INFO_AND_PATH_IS_CP 0x00000002") +cpp_quote("#define Uri_ENCODING_HOST_IS_IDN 0x00000004") +cpp_quote("#define Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8 0x00000008") +cpp_quote("#define Uri_ENCODING_HOST_IS_PERCENT_ENCODED_CP 0x00000010") +cpp_quote("#define Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8 0x00000020") +cpp_quote("#define Uri_ENCODING_QUERY_AND_FRAGMENT_IS_CP 0x00000040") +cpp_quote("#define Uri_ENCODING_RFC (Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8|Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8|Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8)") + +cpp_quote("#define UriBuilder_USE_ORIGINAL_FLAGS 0x00000001") + /***************************************************************************** * IUriContainer interface */ @@ -1740,6 +1796,8 @@ cpp_quote("#define INET_E_DEFAULT_ACTION INET_E_USE_DEFAULT_PROTOCOLH cpp_quote("HRESULT WINAPI CoGetClassObjectFromURL(REFCLSID, LPCWSTR, DWORD, DWORD, LPCWSTR, LPBINDCTX, DWORD, LPVOID, REFIID, LPVOID*);") cpp_quote("HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk);") +cpp_quote("HRESULT WINAPI CreateURLMonikerEx(IMoniker*,LPCWSTR,IMoniker**,DWORD);") +cpp_quote("HRESULT WINAPI CreateURLMonikerEx2(IMoniker*,IUri*,IMoniker**,DWORD);") cpp_quote("HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc, IBindStatusCallback **ppbsc, DWORD dwReserved);") cpp_quote("HRESULT WINAPI CompareSecurityIds(BYTE*,DWORD,BYTE*,DWORD,DWORD);") cpp_quote("HRESULT WINAPI URLDownloadToFileA(LPUNKNOWN,LPCSTR,LPCSTR,DWORD,LPBINDSTATUSCALLBACK);") @@ -1758,6 +1816,7 @@ cpp_quote("HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider*, IIntern cpp_quote("HRESULT WINAPI CoInternetParseUrl(LPCWSTR,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD);") cpp_quote("HRESULT WINAPI CoInternetQueryInfo(LPCWSTR,QUERYOPTION,DWORD,LPVOID,DWORD,DWORD*,DWORD);") cpp_quote("HRESULT WINAPI CoInternetSetFeatureEnabled(INTERNETFEATURELIST,DWORD,BOOL);") +cpp_quote("HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR,LPWSTR*,PSUACTION,DWORD);") cpp_quote("HRESULT WINAPI CreateFormatEnumerator(UINT,FORMATETC*,IEnumFORMATETC**);") cpp_quote("HRESULT WINAPI GetSoftwareUpdateInfo( LPCWSTR szDistUnit, LPSOFTDISTINFO psdi);") cpp_quote("HRESULT WINAPI FaultInIEFeature(HWND,uCLSSPEC*,QUERYCONTEXT*,DWORD);") From eb4f41f03bff31aebcb9eff46116640c2eecc4cf Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 15:28:42 +0000 Subject: [PATCH 084/211] [ATL] sync atl to wine 1.1.39 svn path=/trunk/; revision=45835 --- reactos/dll/win32/atl/atl_ax.c | 2 +- reactos/dll/win32/atl/atl_main.c | 32 +++++++++++++++++++++----------- reactos/dll/win32/atl/atlbase.h | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/atl/atl_ax.c b/reactos/dll/win32/atl/atl_ax.c index da595a4e24b..2afc7460328 100644 --- a/reactos/dll/win32/atl/atl_ax.c +++ b/reactos/dll/win32/atl/atl_ax.c @@ -1208,7 +1208,7 @@ HWND WINAPI AtlAxCreateDialogA(HINSTANCE hInst, LPCSTR name, HWND owner, DLGPROC int length; WCHAR *nameW; - if ( HIWORD(name) == 0 ) + if (IS_INTRESOURCE(name)) return AtlAxCreateDialogW( hInst, (LPCWSTR) name, owner, dlgProc, param ); length = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 ); diff --git a/reactos/dll/win32/atl/atl_main.c b/reactos/dll/win32/atl/atl_main.c index 374b0d26f24..75f9a11116c 100644 --- a/reactos/dll/win32/atl/atl_main.c +++ b/reactos/dll/win32/atl/atl_main.c @@ -97,6 +97,19 @@ HRESULT WINAPI AtlModuleInit(_ATL_MODULEW* pM, _ATL_OBJMAP_ENTRYW* p, HINSTANCE return S_OK; } +static _ATL_OBJMAP_ENTRYW_V1 *get_objmap_entry( _ATL_MODULEW *mod, unsigned int index ) +{ + _ATL_OBJMAP_ENTRYW_V1 *ret; + + if (mod->cbSize == ATLVer1Size) + ret = (_ATL_OBJMAP_ENTRYW_V1 *)mod->m_pObjMap + index; + else + ret = (_ATL_OBJMAP_ENTRYW_V1 *)(mod->m_pObjMap + index); + + if (!ret->pclsid) ret = NULL; + return ret; +} + HRESULT WINAPI AtlModuleLoadTypeLib(_ATL_MODULEW *pM, LPCOLESTR lpszIndex, BSTR *pbstrPath, ITypeLib **ppTypeLib) { @@ -158,6 +171,7 @@ HRESULT WINAPI AtlModuleAddTermFunc(_ATL_MODULEW *pM, _ATL_TERMFUNC *pFunc, DWOR HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContext, DWORD dwFlags) { + _ATL_OBJMAP_ENTRYW_V1 *obj; HRESULT hRes = S_OK; int i=0; @@ -166,10 +180,9 @@ HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContex if (pM == NULL) return E_INVALIDARG; - while(pM->m_pObjMap[i].pclsid != NULL) + while ((obj = get_objmap_entry( pM, i++ ))) { IUnknown* pUnknown; - _ATL_OBJMAP_ENTRYW *obj = &(pM->m_pObjMap[i]); HRESULT rc; TRACE("Registering object %i\n",i); @@ -185,7 +198,6 @@ HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContex IUnknown_Release(pUnknown); } } - i++; } return hRes; @@ -269,6 +281,7 @@ HRESULT WINAPI AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY* pE */ HRESULT WINAPI AtlModuleRegisterServer(_ATL_MODULEW* pM, BOOL bRegTypeLib, const CLSID* clsid) { + const _ATL_OBJMAP_ENTRYW_V1 *obj; int i; HRESULT hRes; @@ -277,12 +290,10 @@ HRESULT WINAPI AtlModuleRegisterServer(_ATL_MODULEW* pM, BOOL bRegTypeLib, const if (pM == NULL) return E_INVALIDARG; - for (i = 0; pM->m_pObjMap[i].pclsid != NULL; i++) /* register CLSIDs */ + for (i = 0; (obj = get_objmap_entry( pM, i )) != NULL; i++) /* register CLSIDs */ { - if (!clsid || IsEqualCLSID(pM->m_pObjMap[i].pclsid, clsid)) + if (!clsid || IsEqualCLSID(obj->pclsid, clsid)) { - const _ATL_OBJMAP_ENTRYW *obj = &pM->m_pObjMap[i]; - TRACE("Registering clsid %s\n", debugstr_guid(obj->pclsid)); hRes = obj->pfnUpdateRegistry(TRUE); /* register */ if (FAILED(hRes)) @@ -351,6 +362,7 @@ HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk) HRESULT WINAPI AtlModuleGetClassObject(_ATL_MODULEW *pm, REFCLSID rclsid, REFIID riid, LPVOID *ppv) { + _ATL_OBJMAP_ENTRYW_V1 *obj; int i; HRESULT hres = CLASS_E_CLASSNOTAVAILABLE; @@ -359,12 +371,10 @@ HRESULT WINAPI AtlModuleGetClassObject(_ATL_MODULEW *pm, REFCLSID rclsid, if (pm == NULL) return E_INVALIDARG; - for (i = 0; pm->m_pObjMap[i].pclsid != NULL; i++) + for (i = 0; (obj = get_objmap_entry( pm, i )) != NULL; i++) { - if (IsEqualCLSID(pm->m_pObjMap[i].pclsid, rclsid)) + if (IsEqualCLSID(obj->pclsid, rclsid)) { - _ATL_OBJMAP_ENTRYW *obj = &pm->m_pObjMap[i]; - TRACE("found object %i\n", i); if (obj->pfnGetClassObject) { diff --git a/reactos/dll/win32/atl/atlbase.h b/reactos/dll/win32/atl/atlbase.h index 49c13e439a3..59cdddf1b77 100644 --- a/reactos/dll/win32/atl/atlbase.h +++ b/reactos/dll/win32/atl/atlbase.h @@ -33,6 +33,28 @@ typedef LPCWSTR (WINAPI _ATL_DESCRIPTIONFUNCW)(void); typedef const struct _ATL_CATMAP_ENTRY* (_ATL_CATMAPFUNC)(void); typedef void (WINAPI _ATL_TERMFUNC)(DWORD dw); +typedef struct _ATL_OBJMAP_ENTRYA_V1_TAG +{ + const CLSID* pclsid; + HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister); + _ATL_CREATORFUNC* pfnGetClassObject; + _ATL_CREATORFUNC* pfnCreateInstance; + IUnknown* pCF; + DWORD dwRegister; + _ATL_DESCRIPTIONFUNCA* pfnGetObjectDescription; +}_ATL_OBJMAP_ENTRYA_V1; + +typedef struct _ATL_OBJMAP_ENTRYW_V1_TAG +{ + const CLSID* pclsid; + HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister); + _ATL_CREATORFUNC* pfnGetClassObject; + _ATL_CREATORFUNC* pfnCreateInstance; + IUnknown* pCF; + DWORD dwRegister; + _ATL_DESCRIPTIONFUNCW* pfnGetObjectDescription; +} _ATL_OBJMAP_ENTRYW_V1; + typedef struct _ATL_OBJMAP_ENTRYA_TAG { const CLSID* pclsid; From 57103f1233df4e2f93fade11d09c969a9d195e6b Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 4 Mar 2010 17:34:22 +0000 Subject: [PATCH 085/211] [KSPROXY] - Silence traces in IEnumPins interface - Partly implement IKsObject interface for COutputPin - Retrieve pin communication and pass it to constructor of CInputPin - Implement IKsPinEx and IMemInputPin interface for CInputPin - The DVBT network provider can now connect to the BDA Source Filter svn path=/trunk/; revision=45836 --- reactos/dll/directx/ksproxy/enumpins.cpp | 20 - reactos/dll/directx/ksproxy/input_pin.cpp | 582 ++++++++++++++++++--- reactos/dll/directx/ksproxy/ksproxy.rbuild | 1 + reactos/dll/directx/ksproxy/output_pin.cpp | 29 +- reactos/dll/directx/ksproxy/precomp.h | 1 + reactos/dll/directx/ksproxy/proxy.cpp | 28 +- 6 files changed, 576 insertions(+), 85 deletions(-) diff --git a/reactos/dll/directx/ksproxy/enumpins.cpp b/reactos/dll/directx/ksproxy/enumpins.cpp index 5d71d5355d2..5c0f0ecd7bd 100644 --- a/reactos/dll/directx/ksproxy/enumpins.cpp +++ b/reactos/dll/directx/ksproxy/enumpins.cpp @@ -64,13 +64,6 @@ CEnumPins::QueryInterface( return NOERROR; } - WCHAR Buffer[MAX_PATH]; - LPOLESTR lpstr; - StringFromCLSID(refiid, &lpstr); - swprintf(Buffer, L"CEnumPins::QueryInterface: NoInterface for %s\n", lpstr); - OutputDebugStringW(Buffer); - CoTaskMemFree(lpstr); - return E_NOINTERFACE; } @@ -89,10 +82,6 @@ CEnumPins::Next( if (cPins > 1 && !pcFetched) return E_INVALIDARG; - WCHAR Buffer[MAX_PATH]; - swprintf(Buffer, L"CEnumPins::Next: this %p m_Index %lx cPins %u\n", this, m_Index, cPins); - OutputDebugStringW(Buffer); - while(i < cPins) { if (m_Index + i >= m_Pins.size()) @@ -110,7 +99,6 @@ CEnumPins::Next( } m_Index += i; - OutputDebugStringW(L"CEnumPins::Next: done\n"); if (i < cPins) return S_FALSE; else @@ -157,14 +145,6 @@ CEnumPins_fnConstructor( { CEnumPins * handler = new CEnumPins(Pins); -#ifdef MSDVBNP_TRACE - WCHAR Buffer[MAX_PATH]; - LPOLESTR lpstr; - StringFromCLSID(riid, &lpstr); - swprintf(Buffer, L"CEnumPins_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); - OutputDebugStringW(Buffer); -#endif - if (!handler) return E_OUTOFMEMORY; diff --git a/reactos/dll/directx/ksproxy/input_pin.cpp b/reactos/dll/directx/ksproxy/input_pin.cpp index 896335b6512..2b08b16e89e 100644 --- a/reactos/dll/directx/ksproxy/input_pin.cpp +++ b/reactos/dll/directx/ksproxy/input_pin.cpp @@ -8,13 +8,32 @@ */ #include "precomp.h" +const GUID IID_IKsPinEx = {0x7bb38260L, 0xd19c, 0x11d2, {0xb3, 0x8a, 0x00, 0xa0, 0xc9, 0x5e, 0xc2, 0x2e}}; +const GUID KSPROPSETID_Connection = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; + +KSPIN_INTERFACE StandardPinInterface = +{ + {STATIC_KSINTERFACESETID_Standard}, + KSINTERFACE_STANDARD_STREAMING, + 0 +}; + +KSPIN_MEDIUM StandardPinMedium = +{ + {STATIC_KSMEDIUMSETID_Standard}, + KSMEDIUM_TYPE_ANYINSTANCE, + 0 +}; + + class CInputPin : public IPin, public IKsPropertySet, public IKsControl, - public IKsObject + public IKsObject, + public IKsPinEx, + public IMemInputPin /* public IQualityControl, - public IKsPinEx, public IKsPinPipe, public ISpecifyPropertyPages, public IStreamBuilder, @@ -71,8 +90,36 @@ public: HRESULT STDMETHODCALLTYPE KsMethod(PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData, ULONG DataLength, ULONG* BytesReturned); HRESULT STDMETHODCALLTYPE KsEvent(PKSEVENT Event, ULONG EventLength, LPVOID EventData, ULONG DataLength, ULONG* BytesReturned); + //IKsPin + HRESULT STDMETHODCALLTYPE KsQueryMediums(PKSMULTIPLE_ITEM* MediumList); + HRESULT STDMETHODCALLTYPE KsQueryInterfaces(PKSMULTIPLE_ITEM* InterfaceList); + HRESULT STDMETHODCALLTYPE KsCreateSinkPinHandle(KSPIN_INTERFACE& Interface, KSPIN_MEDIUM& Medium); + HRESULT STDMETHODCALLTYPE KsGetCurrentCommunication(KSPIN_COMMUNICATION *Communication, KSPIN_INTERFACE *Interface, KSPIN_MEDIUM *Medium); + HRESULT STDMETHODCALLTYPE KsPropagateAcquire(); + HRESULT STDMETHODCALLTYPE KsDeliver(IMediaSample* Sample, ULONG Flags); + HRESULT STDMETHODCALLTYPE KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment); + IMemAllocator * STDMETHODCALLTYPE KsPeekAllocator(KSPEEKOPERATION Operation); + HRESULT STDMETHODCALLTYPE KsReceiveAllocator(IMemAllocator *MemAllocator); + HRESULT STDMETHODCALLTYPE KsRenegotiateAllocator(); + LONG STDMETHODCALLTYPE KsIncrementPendingIoCount(); + LONG STDMETHODCALLTYPE KsDecrementPendingIoCount(); + HRESULT STDMETHODCALLTYPE KsQualityNotify(ULONG Proportion, REFERENCE_TIME TimeDelta); + // IKsPinEx + VOID STDMETHODCALLTYPE KsNotifyError(IMediaSample* Sample, HRESULT hr); + + //IMemInputPin + HRESULT STDMETHODCALLTYPE GetAllocator(IMemAllocator **ppAllocator); + HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly); + HRESULT STDMETHODCALLTYPE GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps); + HRESULT STDMETHODCALLTYPE Receive(IMediaSample *pSample); + HRESULT STDMETHODCALLTYPE ReceiveMultiple(IMediaSample **pSamples, long nSamples, long *nSamplesProcessed); + HRESULT STDMETHODCALLTYPE ReceiveCanBlock( void); + + //--------------------------------------------------------------- HRESULT STDMETHODCALLTYPE CheckFormat(const AM_MEDIA_TYPE *pmt); - CInputPin(IBaseFilter * ParentFilter, LPCWSTR PinName, HANDLE hFilter, ULONG PinId) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName), m_hFilter(hFilter), m_hPin(0), m_PinId(PinId){}; + HRESULT STDMETHODCALLTYPE CreatePin(); + HRESULT STDMETHODCALLTYPE CreatePinHandle(PKSPIN_MEDIUM Medium, PKSPIN_INTERFACE Interface, PKSDATAFORMAT DataFormat); + CInputPin(IBaseFilter * ParentFilter, LPCWSTR PinName, HANDLE hFilter, ULONG PinId, KSPIN_COMMUNICATION Communication) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName), m_hFilter(hFilter), m_hPin(0), m_PinId(PinId), m_MemAllocator(0), m_IoCount(0), m_Communication(Communication), m_Pin(0){}; virtual ~CInputPin(){}; protected: @@ -82,6 +129,12 @@ protected: HANDLE m_hFilter; HANDLE m_hPin; ULONG m_PinId; + IMemAllocator * m_MemAllocator; + LONG m_IoCount; + KSPIN_COMMUNICATION m_Communication; + KSPIN_INTERFACE m_Interface; + KSPIN_MEDIUM m_Medium; + IPin * m_Pin; }; HRESULT @@ -99,12 +152,19 @@ CInputPin::QueryInterface( reinterpret_cast(*Output)->AddRef(); return NOERROR; } + else if (IsEqualGUID(refiid, IID_IMemInputPin)) + { + *Output = (IMemInputPin*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } else if (IsEqualGUID(refiid, IID_IKsObject)) { if (!m_hPin) { - OutputDebugStringW(L"CInputPin::QueryInterface IID_IKsObject Create PIN!!!\n"); - DebugBreak(); + HRESULT hr = CreatePin(); + if (FAILED(hr)) + return hr; } *Output = (IKsObject*)(this); @@ -115,8 +175,9 @@ CInputPin::QueryInterface( { if (!m_hPin) { - OutputDebugStringW(L"CInputPin::QueryInterface IID_IKsPropertySet Create PIN!!!\n"); - DebugBreak(); + HRESULT hr = CreatePin(); + if (FAILED(hr)) + return hr; } *Output = (IKsPropertySet*)(this); @@ -127,14 +188,30 @@ CInputPin::QueryInterface( { if (!m_hPin) { - OutputDebugStringW(L"CInputPin::QueryInterface IID_IKsControl Create PIN!!!\n"); - DebugBreak(); + HRESULT hr = CreatePin(); + if (FAILED(hr)) + return hr; } *Output = (IKsControl*)(this); reinterpret_cast(*Output)->AddRef(); return NOERROR; } + else if (IsEqualGUID(refiid, IID_IKsPin) || + IsEqualGUID(refiid, IID_IKsPinEx)) + { + if (!m_hPin) + { + HRESULT hr = CreatePin(); + if (FAILED(hr)) + return hr; + } + + *Output = (IKsPinEx*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + WCHAR Buffer[MAX_PATH]; LPOLESTR lpstr; @@ -146,6 +223,248 @@ CInputPin::QueryInterface( return E_NOINTERFACE; } +//------------------------------------------------------------------- +// IMemInputPin +// + + // +HRESULT +STDMETHODCALLTYPE +CInputPin::GetAllocator(IMemAllocator **ppAllocator) +{ + OutputDebugStringW(L"CInputPin::GetAllocator\n"); + return VFW_E_NO_ALLOCATOR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly) +{ + if (pAllocator) + { + pAllocator->AddRef(); + } + + if (m_MemAllocator) + { + m_MemAllocator->Release(); + } + + m_MemAllocator = pAllocator; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps) +{ + KSALLOCATOR_FRAMING Framing; + KSPROPERTY Property; + HRESULT hr; + ULONG BytesReturned; + + Property.Set = KSPROPSETID_Connection; + Property.Id = KSPROPERTY_CONNECTION_ALLOCATORFRAMING; + Property.Flags = KSPROPERTY_TYPE_SET; + + hr = KsProperty(&Property, sizeof(KSPROPERTY), (PVOID)&Framing, sizeof(KSALLOCATOR_FRAMING), &BytesReturned); + if (SUCCEEDED(hr)) + { + pProps->cBuffers = Framing.Frames; + pProps->cbBuffer = Framing.FrameSize; + pProps->cbAlign = Framing.FileAlignment; + pProps->cbPrefix = 0; + return hr; + } + else + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::Receive(IMediaSample *pSample) +{ + OutputDebugStringW(L"CInputPin::Receive NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::ReceiveMultiple(IMediaSample **pSamples, long nSamples, long *nSamplesProcessed) +{ + OutputDebugStringW(L"CInputPin::ReceiveMultiple NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::ReceiveCanBlock( void) +{ + OutputDebugStringW(L"CInputPin::ReceiveCanBlock NotImplemented\n"); + return S_FALSE; +} + + +//------------------------------------------------------------------- +// IKsPin +// + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsQueryMediums( + PKSMULTIPLE_ITEM* MediumList) +{ + return KsGetMultiplePinFactoryItems(m_hFilter, m_PinId, KSPROPERTY_PIN_MEDIUMS, (PVOID*)MediumList); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsQueryInterfaces( + PKSMULTIPLE_ITEM* InterfaceList) +{ + return KsGetMultiplePinFactoryItems(m_hFilter, m_PinId, KSPROPERTY_PIN_INTERFACES, (PVOID*)InterfaceList); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsCreateSinkPinHandle( + KSPIN_INTERFACE& Interface, + KSPIN_MEDIUM& Medium) +{ + OutputDebugStringW(L"CInputPin::KsCreateSinkPinHandle NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsGetCurrentCommunication( + KSPIN_COMMUNICATION *Communication, + KSPIN_INTERFACE *Interface, + KSPIN_MEDIUM *Medium) +{ + if (Communication) + { + *Communication = m_Communication; + } + + if (Interface) + { + if (!m_hPin) + return VFW_E_NOT_CONNECTED; + + CopyMemory(Interface, &m_Interface, sizeof(KSPIN_INTERFACE)); + } + + if (Medium) + { + if (!m_hPin) + return VFW_E_NOT_CONNECTED; + + CopyMemory(Medium, &m_Medium, sizeof(KSPIN_MEDIUM)); + } + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsPropagateAcquire() +{ + OutputDebugStringW(L"CInputPin::KsPropagateAcquire NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsDeliver( + IMediaSample* Sample, + ULONG Flags) +{ + return E_FAIL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment) +{ + return NOERROR; +} + +IMemAllocator * +STDMETHODCALLTYPE +CInputPin::KsPeekAllocator(KSPEEKOPERATION Operation) +{ + if (Operation == KsPeekOperation_AddRef) + { + // add reference on allocator + m_MemAllocator->AddRef(); + } + + return m_MemAllocator; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsReceiveAllocator(IMemAllocator *MemAllocator) +{ + if (MemAllocator) + { + MemAllocator->AddRef(); + } + + if (m_MemAllocator) + { + m_MemAllocator->Release(); + } + + m_MemAllocator = MemAllocator; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsRenegotiateAllocator() +{ + return E_FAIL; +} + +LONG +STDMETHODCALLTYPE +CInputPin::KsIncrementPendingIoCount() +{ + return InterlockedIncrement((volatile LONG*)&m_IoCount); +} + +LONG +STDMETHODCALLTYPE +CInputPin::KsDecrementPendingIoCount() +{ + return InterlockedDecrement((volatile LONG*)&m_IoCount); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsQualityNotify( + ULONG Proportion, + REFERENCE_TIME TimeDelta) +{ + OutputDebugStringW(L"CInputPin::KsQualityNotify NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IKsPinEx +// + +VOID +STDMETHODCALLTYPE +CInputPin::KsNotifyError( + IMediaSample* Sample, + HRESULT hr) +{ + OutputDebugStringW(L"CInputPin::KsNotifyError NotImplemented\n"); +} + + //------------------------------------------------------------------- // IKsPropertySet // @@ -314,25 +633,36 @@ HRESULT STDMETHODCALLTYPE CInputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) { - //MajorFormat: KSDATAFORMAT_TYPE_BDA_ANTENNA - //SubType: MEDIASUBTYPE_None - //FormatType: FORMAT_None - //bFixedSizeSamples 1 bTemporalCompression 0 lSampleSize 1 pUnk 00000000 cbFormat 0 pbFormat 00000000 - - //KSPROPSETID_Connection KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT - //PriorityClass = KSPRIORITY_NORMAL PrioritySubClass = KSPRIORITY_NORMAL - - OutputDebugStringW(L"CInputPin::Connect NotImplemented\n"); - return E_NOTIMPL; + return NOERROR; } HRESULT STDMETHODCALLTYPE CInputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) { + HRESULT hr; + + if (m_Pin) + { + OutputDebugStringW(L"CInputPin::ReceiveConnection already connected\n"); + return VFW_E_ALREADY_CONNECTED; + } + + // first check format + hr = CheckFormat(pmt); + if (FAILED(hr)) + return hr; + + if (FAILED(CheckFormat(pmt))) + return hr; + + //FIXME create pin + m_Pin = pConnector; + m_Pin->AddRef(); + OutputDebugStringW(L"CInputPin::ReceiveConnection NotImplemented\n"); - return E_NOTIMPL; + return S_OK; } HRESULT STDMETHODCALLTYPE @@ -345,8 +675,18 @@ HRESULT STDMETHODCALLTYPE CInputPin::ConnectedTo(IPin **pPin) { + if (!pPin) + return E_POINTER; + + if (m_Pin) + { + // increment reference count + m_Pin->AddRef(); + *pPin = m_Pin; + return S_OK; + } + *pPin = NULL; - OutputDebugStringW(L"CInputPin::ConnectedTo NotImplemented\n"); return VFW_E_NOT_CONNECTED; } HRESULT @@ -391,6 +731,56 @@ CInputPin::QueryId(LPWSTR *Id) return S_OK; } +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryAccept( + const AM_MEDIA_TYPE *pmt) +{ + return CheckFormat(pmt); +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +{ + return CEnumMediaTypes_fnConstructor(0, NULL, IID_IEnumMediaTypes, (void**)ppEnum); +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) +{ + OutputDebugStringW(L"CInputPin::QueryInternalConnections NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EndOfStream( void) +{ + OutputDebugStringW(L"CInputPin::EndOfStream NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::BeginFlush( void) +{ + OutputDebugStringW(L"CInputPin::BeginFlush NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EndFlush( void) +{ + OutputDebugStringW(L"CInputPin::EndFlush NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) +{ + OutputDebugStringW(L"CInputPin::NewSegment NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE CInputPin::CheckFormat( @@ -452,51 +842,118 @@ CInputPin::CheckFormat( HRESULT STDMETHODCALLTYPE -CInputPin::QueryAccept( - const AM_MEDIA_TYPE *pmt) +CInputPin::CreatePin() { - return CheckFormat(pmt); + PKSMULTIPLE_ITEM MediumList; + PKSMULTIPLE_ITEM InterfaceList; + PKSMULTIPLE_ITEM DataFormatList = NULL; + PKSPIN_MEDIUM Medium; + PKSDATAFORMAT DataFormat; + PKSPIN_INTERFACE Interface; + HRESULT hr; + + // query for pin medium + hr = KsQueryMediums(&MediumList); + if (FAILED(hr)) + return hr; + + // query for pin interface + hr = KsQueryInterfaces(&InterfaceList); + if (FAILED(hr)) + { + // failed + CoTaskMemFree(MediumList); + return hr; + } + + // get data ranges + hr = KsGetMultiplePinFactoryItems(m_hFilter, m_PinId, KSPROPERTY_PIN_DATARANGES, (PVOID*)&DataFormatList); + if (FAILED(hr) || DataFormatList->Count == 0) + { + // failed + CoTaskMemFree(MediumList); + CoTaskMemFree(InterfaceList); + if (DataFormatList) + CoTaskMemFree(DataFormatList); + + return hr; + } + + if (MediumList->Count) + { + //use first available medium + Medium = (PKSPIN_MEDIUM)(MediumList + 1); + } + else + { + // default to standard medium + Medium = &StandardPinMedium; + } + + if (InterfaceList->Count) + { + //use first available interface + Interface = (PKSPIN_INTERFACE)(InterfaceList + 1); + } + else + { + // default to standard interface + Interface = &StandardPinInterface; + } + + //FIXME determine format + // use first available format + DataFormat = (PKSDATAFORMAT) (DataFormatList + 1); + + // now create pin + hr = CreatePinHandle(Medium, Interface, DataFormat); + + // free medium / interface / dataformat + CoTaskMemFree(DataFormatList); + CoTaskMemFree(MediumList); + CoTaskMemFree(InterfaceList); + + return hr; } + HRESULT STDMETHODCALLTYPE -CInputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +CInputPin::CreatePinHandle( + PKSPIN_MEDIUM Medium, + PKSPIN_INTERFACE Interface, + PKSDATAFORMAT DataFormat) { - return CEnumMediaTypes_fnConstructor(0, NULL, IID_IEnumMediaTypes, (void**)ppEnum); -} -HRESULT -STDMETHODCALLTYPE -CInputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) -{ - OutputDebugStringW(L"CInputPin::QueryInternalConnections NotImplemented\n"); - return E_NOTIMPL; -} -HRESULT -STDMETHODCALLTYPE -CInputPin::EndOfStream( void) -{ - OutputDebugStringW(L"CInputPin::EndOfStream NotImplemented\n"); - return E_NOTIMPL; -} -HRESULT -STDMETHODCALLTYPE -CInputPin::BeginFlush( void) -{ - OutputDebugStringW(L"CInputPin::BeginFlush NotImplemented\n"); - return E_NOTIMPL; -} -HRESULT -STDMETHODCALLTYPE -CInputPin::EndFlush( void) -{ - OutputDebugStringW(L"CInputPin::EndFlush NotImplemented\n"); - return E_NOTIMPL; -} -HRESULT -STDMETHODCALLTYPE -CInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) -{ - OutputDebugStringW(L"CInputPin::NewSegment NotImplemented\n"); - return E_NOTIMPL; + PKSPIN_CONNECT PinConnect; + ULONG Length; + HRESULT hr; + + // calc format size + Length = sizeof(KSPIN_CONNECT) + DataFormat->FormatSize; + + // allocate pin connect + PinConnect = (PKSPIN_CONNECT)CoTaskMemAlloc(Length); + if (!PinConnect) + { + // failed + return E_OUTOFMEMORY; + } + + // setup request + CopyMemory(&PinConnect->Interface, Interface, sizeof(KSPIN_INTERFACE)); + CopyMemory(&PinConnect->Medium, Medium, sizeof(KSPIN_MEDIUM)); + PinConnect->PinId = m_PinId; + PinConnect->PinToHandle = NULL; + PinConnect->Priority.PriorityClass = KSPRIORITY_NORMAL; + PinConnect->Priority.PrioritySubClass = KSPRIORITY_NORMAL; + CopyMemory((PinConnect + 1), DataFormat, DataFormat->FormatSize); + + // create pin + hr = KsCreatePin(m_hFilter, PinConnect, GENERIC_WRITE, &m_hPin); + + // free pin connect + CoTaskMemFree(PinConnect); + + return hr; } HRESULT @@ -506,10 +963,11 @@ CInputPin_Constructor( LPCWSTR PinName, HANDLE hFilter, ULONG PinId, + KSPIN_COMMUNICATION Communication, REFIID riid, LPVOID * ppv) { - CInputPin * handler = new CInputPin(ParentFilter, PinName, hFilter, PinId); + CInputPin * handler = new CInputPin(ParentFilter, PinName, hFilter, PinId, Communication); if (!handler) return E_OUTOFMEMORY; diff --git a/reactos/dll/directx/ksproxy/ksproxy.rbuild b/reactos/dll/directx/ksproxy/ksproxy.rbuild index 2fa2bd3ac26..440e279e86a 100644 --- a/reactos/dll/directx/ksproxy/ksproxy.rbuild +++ b/reactos/dll/directx/ksproxy/ksproxy.rbuild @@ -11,6 +11,7 @@ setupapi msvcrt strmiids + ksuser -fno-exceptions -fno-rtti diff --git a/reactos/dll/directx/ksproxy/output_pin.cpp b/reactos/dll/directx/ksproxy/output_pin.cpp index ba7b31bb131..b29d12ac4b2 100644 --- a/reactos/dll/directx/ksproxy/output_pin.cpp +++ b/reactos/dll/directx/ksproxy/output_pin.cpp @@ -8,10 +8,10 @@ */ #include "precomp.h" -class COutputPin : public IPin +class COutputPin : public IPin, + public IKsObject /* public IQualityControl, - public IKsObject, public IKsPinEx, public IKsPinPipe, public ISpecifyPropertyPages, @@ -61,6 +61,10 @@ public: HRESULT STDMETHODCALLTYPE EndFlush(); HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); + //IKsObject methods + HANDLE STDMETHODCALLTYPE KsGetObjectHandle(); + + COutputPin(IBaseFilter * ParentFilter, LPCWSTR PinName) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName){}; virtual ~COutputPin(){}; @@ -84,6 +88,12 @@ COutputPin::QueryInterface( reinterpret_cast(*Output)->AddRef(); return NOERROR; } + else if (IsEqualGUID(refiid, IID_IKsObject)) + { + *Output = (IKsObject*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } WCHAR Buffer[MAX_PATH]; LPOLESTR lpstr; @@ -95,6 +105,20 @@ COutputPin::QueryInterface( return E_NOINTERFACE; } +//------------------------------------------------------------------- +// IKsObject +// +HANDLE +STDMETHODCALLTYPE +COutputPin::KsGetObjectHandle() +{ + OutputDebugStringW(L"COutputPin::KsGetObjectHandle CALLED\n"); + + //FIXME + // return pin handle + return NULL; +} + //------------------------------------------------------------------- // IPin interface // @@ -124,6 +148,7 @@ HRESULT STDMETHODCALLTYPE COutputPin::ConnectedTo(IPin **pPin) { + *pPin = NULL; OutputDebugStringW(L"COutputPin::ConnectedTo called\n"); return VFW_E_NOT_CONNECTED; } diff --git a/reactos/dll/directx/ksproxy/precomp.h b/reactos/dll/directx/ksproxy/precomp.h index 19b846a83ef..32953e94cb5 100644 --- a/reactos/dll/directx/ksproxy/precomp.h +++ b/reactos/dll/directx/ksproxy/precomp.h @@ -107,6 +107,7 @@ CInputPin_Constructor( LPCWSTR PinName, HANDLE hFilter, ULONG PinId, + KSPIN_COMMUNICATION Communication, REFIID riid, LPVOID * ppv); diff --git a/reactos/dll/directx/ksproxy/proxy.cpp b/reactos/dll/directx/ksproxy/proxy.cpp index 5e939ebd465..0ff397c2062 100644 --- a/reactos/dll/directx/ksproxy/proxy.cpp +++ b/reactos/dll/directx/ksproxy/proxy.cpp @@ -95,6 +95,7 @@ public: HRESULT STDMETHODCALLTYPE GetPinInstanceCount(ULONG PinId, PKSPIN_CINSTANCES Instances); HRESULT STDMETHODCALLTYPE GetPinDataflow(ULONG PinId, KSPIN_DATAFLOW * DataFlow); HRESULT STDMETHODCALLTYPE GetPinName(ULONG PinId, KSPIN_DATAFLOW DataFlow, ULONG PinCount, LPWSTR * OutPinName); + HRESULT STDMETHODCALLTYPE GetPinCommunication(ULONG PinId, KSPIN_COMMUNICATION * Communication); HRESULT STDMETHODCALLTYPE CreatePins(); protected: LONG m_Ref; @@ -350,6 +351,25 @@ CKsProxy::GetPinInstanceCount( return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)Instances, sizeof(KSPIN_CINSTANCES), &BytesReturned); } +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetPinCommunication( + ULONG PinId, + KSPIN_COMMUNICATION * Communication) +{ + KSP_PIN Property; + ULONG BytesReturned; + + // setup request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_COMMUNICATION; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = PinId; + Property.Reserved = 0; + + return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)Communication, sizeof(KSPIN_COMMUNICATION), &BytesReturned); +} + HRESULT STDMETHODCALLTYPE CKsProxy::GetPinDataflow( @@ -446,6 +466,7 @@ CKsProxy::CreatePins() ULONG NumPins, Index; KSPIN_CINSTANCES Instances; KSPIN_DATAFLOW DataFlow; + KSPIN_COMMUNICATION Communication; HRESULT hr; WCHAR Buffer[100]; LPWSTR PinName; @@ -465,6 +486,11 @@ CKsProxy::CreatePins() if (FAILED(hr)) continue; + // query pin communication; + hr = GetPinCommunication(Index, &Communication); + if (FAILED(hr)) + continue; + if (Instances.CurrentCount == Instances.PossibleCount) { // already maximum reached for this pin @@ -487,7 +513,7 @@ CKsProxy::CreatePins() // construct the pins if (DataFlow == KSPIN_DATAFLOW_IN) { - hr = CInputPin_Constructor((IBaseFilter*)this, PinName, m_hDevice, Index, IID_IPin, (void**)&pPin); + hr = CInputPin_Constructor((IBaseFilter*)this, PinName, m_hDevice, Index, Communication, IID_IPin, (void**)&pPin); if (FAILED(hr)) { CoTaskMemFree(PinName); From f7539495dc67c93215749cc628e2afe47759b8e7 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Thu, 4 Mar 2010 18:50:24 +0000 Subject: [PATCH 086/211] [URLMON] Fix build. svn path=/trunk/; revision=45837 --- reactos/dll/win32/urlmon/urlmon.rbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/urlmon/urlmon.rbuild b/reactos/dll/win32/urlmon/urlmon.rbuild index c8c75863db4..c904c5726a0 100644 --- a/reactos/dll/win32/urlmon/urlmon.rbuild +++ b/reactos/dll/win32/urlmon/urlmon.rbuild @@ -49,7 +49,7 @@ - {0x79EAC9F1,0xBAF9,0x11CE,{0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B}} + "{0x79EAC9F1,0xBAF9,0x11CE,{0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B}}" urlmon_urlmon.idl From d8730713765b603c9ea811be66ec03e38881241d Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 20:39:41 +0000 Subject: [PATCH 087/211] [WINTRUST] sync wintrust to wine 1.1.39 svn path=/trunk/; revision=45838 --- reactos/dll/win32/wintrust/asn.c | 91 ++--- reactos/dll/win32/wintrust/crypt.c | 16 +- reactos/dll/win32/wintrust/softpub.c | 398 +++++++++++---------- reactos/dll/win32/wintrust/wintrust_main.c | 111 +++++- 4 files changed, 368 insertions(+), 248 deletions(-) diff --git a/reactos/dll/win32/wintrust/asn.c b/reactos/dll/win32/wintrust/asn.c index 002eab5374d..69c9dd3d604 100644 --- a/reactos/dll/win32/wintrust/asn.c +++ b/reactos/dll/win32/wintrust/asn.c @@ -1469,6 +1469,11 @@ struct AsnDecodeSequenceItem */ #define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1)) +#define FINALMEMBERSIZE(s, member) (sizeof(s) - offsetof(s, member)) +#define MEMBERSIZE(s, member, nextmember) \ + (offsetof(s, nextmember) - offsetof(s, member)) + + /* Decodes the items in a sequence, where the items are described in items, * the encoded data are in pbEncoded with length cbEncoded. Decodes into * pvStructInfo. nextData is a pointer to the memory location at which the @@ -1520,8 +1525,13 @@ static BOOL CRYPT_AsnDecodeSequenceItems(DWORD dwCertEncodingType, : NULL, &items[i].size); if (ret) { - /* Account for alignment padding */ - items[i].size = ALIGN_DWORD_PTR(items[i].size); + if (items[i].size < items[i].minSize) + items[i].size = items[i].minSize; + else if (items[i].size > items[i].minSize) + { + /* Account for alignment padding */ + items[i].size = ALIGN_DWORD_PTR(items[i].size); + } TRACE("item %d size: %d\n", i, items[i].size); if (nextData && items[i].hasPointer && items[i].size > items[i].minSize) @@ -2179,62 +2189,24 @@ BOOL WINAPI WVTAsn1SpcSpOpusInfoDecode(DWORD dwCertEncodingType, return ret; } -static BOOL CRYPT_AsnDecodeInteger(const BYTE *pbEncoded, - DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo) -{ - BOOL ret; - DWORD bytesNeeded, dataLen; - - if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) - { - BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); - - bytesNeeded = dataLen + sizeof(CRYPT_INTEGER_BLOB); - if (!pvStructInfo) - *pcbStructInfo = bytesNeeded; - else if (*pcbStructInfo < bytesNeeded) - { - *pcbStructInfo = bytesNeeded; - SetLastError(ERROR_MORE_DATA); - ret = FALSE; - } - else - { - CRYPT_INTEGER_BLOB *blob = pvStructInfo; - - *pcbStructInfo = bytesNeeded; - blob->cbData = dataLen; - assert(blob->pbData); - if (blob->cbData) - { - DWORD i; - - for (i = 0; i < blob->cbData; i++) - { - blob->pbData[i] = *(pbEncoded + 1 + lenBytes + - dataLen - i - 1); - } - } - } - } - return ret; -} - /* Ignores tag. Only allows integers 4 bytes or smaller in size. */ static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo) { BOOL ret; - BYTE buf[sizeof(CRYPT_INTEGER_BLOB) + sizeof(int)]; - CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; - DWORD size = sizeof(buf); + DWORD dataLen; - blob->pbData = buf + sizeof(CRYPT_INTEGER_BLOB); - ret = CRYPT_AsnDecodeInteger(pbEncoded, cbEncoded, 0, buf, &size); - if (ret) + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - if (!pvStructInfo) + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + if (dataLen > sizeof(int)) + { + SetLastError(CRYPT_E_ASN1_LARGE); + ret = FALSE; + } + else if (!pvStructInfo) *pcbStructInfo = sizeof(int); else if (*pcbStructInfo < sizeof(int)) { @@ -2248,23 +2220,21 @@ static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, DWORD i; *pcbStructInfo = sizeof(int); - if (blob->pbData[blob->cbData - 1] & 0x80) + if (dataLen && pbEncoded[1 + lenBytes] & 0x80) { /* initialize to a negative value to sign-extend */ val = -1; } else val = 0; - for (i = 0; i < blob->cbData; i++) + for (i = 0; i < dataLen; i++) { val <<= 8; - val |= blob->pbData[blob->cbData - i - 1]; + val |= pbEncoded[1 + lenBytes + i]; } memcpy(pvStructInfo, &val, sizeof(int)); } } - else if (GetLastError() == ERROR_MORE_DATA) - SetLastError(CRYPT_E_ASN1_LARGE); return ret; } @@ -2284,7 +2254,7 @@ BOOL WINAPI WVTAsn1CatMemberInfoDecode(DWORD dwCertEncodingType, CRYPT_AsnDecodeBMPString, sizeof(LPWSTR), FALSE, TRUE, offsetof(CAT_MEMBERINFO, pwszSubjGuid), 0 }, { ASN_INTEGER, offsetof(CAT_MEMBERINFO, dwCertVersion), - CRYPT_AsnDecodeInt, sizeof(DWORD), + CRYPT_AsnDecodeInt, FINALMEMBERSIZE(CAT_MEMBERINFO, dwCertVersion), FALSE, FALSE, 0, 0 }, }; @@ -2317,7 +2287,8 @@ BOOL WINAPI WVTAsn1CatNameValueDecode(DWORD dwCertEncodingType, CRYPT_AsnDecodeBMPString, sizeof(LPWSTR), FALSE, TRUE, offsetof(CAT_NAMEVALUE, pwszTag), 0 }, { ASN_INTEGER, offsetof(CAT_NAMEVALUE, fdwFlags), - CRYPT_AsnDecodeInt, sizeof(DWORD), FALSE, FALSE, 0, 0 }, + CRYPT_AsnDecodeInt, MEMBERSIZE(CAT_NAMEVALUE, fdwFlags, Value), + FALSE, FALSE, 0, 0 }, { ASN_OCTETSTRING, offsetof(CAT_NAMEVALUE, Value), CRYPT_AsnDecodeOctets, sizeof(CRYPT_DER_BLOB), FALSE, TRUE, offsetof(CAT_NAMEVALUE, Value.pbData), 0 }, @@ -2391,9 +2362,11 @@ BOOL WINAPI WVTAsn1SpcFinancialCriteriaInfoDecode(DWORD dwCertEncodingType, { struct AsnDecodeSequenceItem items[] = { { ASN_BOOL, offsetof(SPC_FINANCIAL_CRITERIA, fFinancialInfoAvailable), - CRYPT_AsnDecodeBool, sizeof(BOOL), FALSE, FALSE, 0, 0 }, + CRYPT_AsnDecodeBool, MEMBERSIZE(SPC_FINANCIAL_CRITERIA, + fFinancialInfoAvailable, fMeetsCriteria), FALSE, FALSE, 0, 0 }, { ASN_BOOL, offsetof(SPC_FINANCIAL_CRITERIA, fMeetsCriteria), - CRYPT_AsnDecodeBool, sizeof(BOOL), FALSE, FALSE, 0, 0 }, + CRYPT_AsnDecodeBool, FINALMEMBERSIZE(SPC_FINANCIAL_CRITERIA, + fMeetsCriteria), FALSE, FALSE, 0, 0 }, }; ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, diff --git a/reactos/dll/win32/wintrust/crypt.c b/reactos/dll/win32/wintrust/crypt.c index d9fa5633562..c41a56b1d1a 100644 --- a/reactos/dll/win32/wintrust/crypt.c +++ b/reactos/dll/win32/wintrust/crypt.c @@ -1028,7 +1028,18 @@ static BOOL WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO *pSubjectInfo, /* app hasn't passed buffer, just get the length */ ret = ImageGetCertificateHeader(pSubjectInfo->hFile, dwIndex, &cert); if (ret) - *pcbSignedDataMsg = cert.dwLength; + { + switch (cert.wCertificateType) + { + case WIN_CERT_TYPE_X509: + case WIN_CERT_TYPE_PKCS_SIGNED_DATA: + *pcbSignedDataMsg = cert.dwLength; + break; + default: + WARN("unknown certificate type %d\n", cert.wCertificateType); + ret = FALSE; + } + } } else { @@ -1065,9 +1076,10 @@ static BOOL WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO *pSubjectInfo, *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; break; default: - FIXME("don't know what to do for encoding type %d\n", + WARN("don't know what to do for encoding type %d\n", pCert->wCertificateType); *pdwEncodingType = 0; + ret = FALSE; } } } diff --git a/reactos/dll/win32/wintrust/softpub.c b/reactos/dll/win32/wintrust/softpub.c index 1db4b47107f..f753c9302e6 100644 --- a/reactos/dll/win32/wintrust/softpub.c +++ b/reactos/dll/win32/wintrust/softpub.c @@ -75,9 +75,9 @@ HRESULT WINAPI DriverFinalPolicy(CRYPT_PROVIDER_DATA *data) /* Assumes data->pWintrustData->u.pFile exists. Makes sure a file handle is * open for the file. */ -static BOOL SOFTPUB_OpenFile(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_OpenFile(CRYPT_PROVIDER_DATA *data) { - BOOL ret = TRUE; + DWORD err = ERROR_SUCCESS; /* PSDK implies that all values should be initialized to NULL, so callers * typically have hFile as NULL rather than INVALID_HANDLE_VALUE. Check @@ -92,65 +92,64 @@ static BOOL SOFTPUB_OpenFile(CRYPT_PROVIDER_DATA *data) if (data->pWintrustData->u.pFile->hFile != INVALID_HANDLE_VALUE) data->fOpenedFile = TRUE; else - ret = FALSE; + err = GetLastError(); } - if (ret) + if (!err) GetFileTime(data->pWintrustData->u.pFile->hFile, &data->sftSystemTime, NULL, NULL); - TRACE("returning %d\n", ret); - return ret; + TRACE("returning %d\n", err); + return err; } /* Assumes data->pWintrustData->u.pFile exists. Sets data->pPDSip->gSubject to * the file's subject GUID. */ -static BOOL SOFTPUB_GetFileSubject(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_GetFileSubject(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; if (!WVT_ISINSTRUCT(WINTRUST_FILE_INFO, data->pWintrustData->u.pFile->cbStruct, pgKnownSubject) || !data->pWintrustData->u.pFile->pgKnownSubject) { - ret = CryptSIPRetrieveSubjectGuid( + if (!CryptSIPRetrieveSubjectGuid( data->pWintrustData->u.pFile->pcwszFilePath, data->pWintrustData->u.pFile->hFile, - &data->u.pPDSip->gSubject); + &data->u.pPDSip->gSubject)) + err = GetLastError(); } else - { data->u.pPDSip->gSubject = *data->pWintrustData->u.pFile->pgKnownSubject; - ret = TRUE; - } - TRACE("returning %d\n", ret); - return ret; + TRACE("returning %d\n", err); + return err; } /* Assumes data->u.pPDSip exists, and its gSubject member set. * Allocates data->u.pPDSip->pSip and loads it, if possible. */ -static BOOL SOFTPUB_GetSIP(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_GetSIP(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; data->u.pPDSip->pSip = data->psPfns->pfnAlloc(sizeof(SIP_DISPATCH_INFO)); if (data->u.pPDSip->pSip) - ret = CryptSIPLoad(&data->u.pPDSip->gSubject, 0, data->u.pPDSip->pSip); - else { - SetLastError(ERROR_OUTOFMEMORY); - ret = FALSE; + if (!CryptSIPLoad(&data->u.pPDSip->gSubject, 0, data->u.pPDSip->pSip)) + err = GetLastError(); } - TRACE("returning %d\n", ret); - return ret; + else + err = ERROR_OUTOFMEMORY; + TRACE("returning %d\n", err); + return err; } /* Assumes data->u.pPDSip has been loaded, and data->u.pPDSip->pSip allocated. * Calls data->u.pPDSip->pSip->pfGet to construct data->hMsg. */ -static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, +static DWORD SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, LPCWSTR filePath) { + DWORD err = ERROR_SUCCESS; BOOL ret; LPBYTE buf = NULL; DWORD size = 0; @@ -158,10 +157,7 @@ static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, data->u.pPDSip->psSipSubjectInfo = data->psPfns->pfnAlloc(sizeof(SIP_SUBJECTINFO)); if (!data->u.pPDSip->psSipSubjectInfo) - { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } + return ERROR_OUTOFMEMORY; data->u.pPDSip->psSipSubjectInfo->cbSize = sizeof(SIP_SUBJECTINFO); data->u.pPDSip->psSipSubjectInfo->pgSubjectType = &data->u.pPDSip->gSubject; @@ -171,17 +167,11 @@ static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, ret = data->u.pPDSip->pSip->pfGet(data->u.pPDSip->psSipSubjectInfo, &data->dwEncoding, 0, &size, 0); if (!ret) - { - SetLastError(TRUST_E_NOSIGNATURE); - return FALSE; - } + return TRUST_E_NOSIGNATURE; buf = data->psPfns->pfnAlloc(size); if (!buf) - { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } + return ERROR_OUTOFMEMORY; ret = data->u.pPDSip->pSip->pfGet(data->u.pPDSip->psSipSubjectInfo, &data->dwEncoding, 0, &size, buf); @@ -190,88 +180,111 @@ static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, data->hMsg = CryptMsgOpenToDecode(data->dwEncoding, 0, 0, data->hProv, NULL, NULL); if (data->hMsg) + { ret = CryptMsgUpdate(data->hMsg, buf, size, TRUE); + if (!ret) + err = GetLastError(); + } } + else + err = GetLastError(); data->psPfns->pfnFree(buf); - TRACE("returning %d\n", ret); - return ret; + TRACE("returning %d\n", err); + return err; } -static BOOL SOFTPUB_CreateStoreFromMessage(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_CreateStoreFromMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret = FALSE; + DWORD err = ERROR_SUCCESS; HCERTSTORE store; store = CertOpenStore(CERT_STORE_PROV_MSG, data->dwEncoding, data->hProv, CERT_STORE_NO_CRYPT_RELEASE_FLAG, data->hMsg); if (store) { - ret = data->psPfns->pfnAddStore2Chain(data, store); + if (!data->psPfns->pfnAddStore2Chain(data, store)) + err = GetLastError(); CertCloseStore(store, 0); } - TRACE("returning %d\n", ret); - return ret; + else + err = GetLastError(); + TRACE("returning %d\n", err); + return err; } static DWORD SOFTPUB_DecodeInnerContent(CRYPT_PROVIDER_DATA *data) { BOOL ret; - DWORD size; + DWORD size, err = ERROR_SUCCESS; LPSTR oid = NULL; LPBYTE buf = NULL; ret = CryptMsgGetParam(data->hMsg, CMSG_INNER_CONTENT_TYPE_PARAM, 0, NULL, &size); if (!ret) + { + err = GetLastError(); goto error; + } oid = data->psPfns->pfnAlloc(size); if (!oid) { - SetLastError(ERROR_OUTOFMEMORY); - ret = FALSE; + err = ERROR_OUTOFMEMORY; goto error; } ret = CryptMsgGetParam(data->hMsg, CMSG_INNER_CONTENT_TYPE_PARAM, 0, oid, &size); if (!ret) + { + err = GetLastError(); goto error; + } ret = CryptMsgGetParam(data->hMsg, CMSG_CONTENT_PARAM, 0, NULL, &size); if (!ret) + { + err = GetLastError(); goto error; + } buf = data->psPfns->pfnAlloc(size); if (!buf) { - SetLastError(ERROR_OUTOFMEMORY); - ret = FALSE; + err = ERROR_OUTOFMEMORY; goto error; } ret = CryptMsgGetParam(data->hMsg, CMSG_CONTENT_PARAM, 0, buf, &size); if (!ret) + { + err = GetLastError(); goto error; + } ret = CryptDecodeObject(data->dwEncoding, oid, buf, size, 0, NULL, &size); if (!ret) + { + err = GetLastError(); goto error; + } data->u.pPDSip->psIndirectData = data->psPfns->pfnAlloc(size); if (!data->u.pPDSip->psIndirectData) { - SetLastError(ERROR_OUTOFMEMORY); - ret = FALSE; + err = ERROR_OUTOFMEMORY; goto error; } ret = CryptDecodeObject(data->dwEncoding, oid, buf, size, 0, data->u.pPDSip->psIndirectData, &size); + if (!ret) + err = GetLastError(); error: - TRACE("returning %d\n", ret); + TRACE("returning %d\n", err); data->psPfns->pfnFree(oid); data->psPfns->pfnFree(buf); - return ret; + return err; } -static BOOL SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; if (data->pWintrustData->u.pCert && WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(WINTRUST_CERT_INFO, @@ -281,6 +294,7 @@ static BOOL SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data) { CRYPT_PROVIDER_SGNR signer = { sizeof(signer), { 0 } }; DWORD i; + BOOL ret; /* Add a signer with nothing but the time to verify, so we can * add a cert to it @@ -308,55 +322,57 @@ static BOOL SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data) ret = data->psPfns->pfnAddStore2Chain(data, data->pWintrustData->u.pCert->pahStores[i]); } - } - else - { - /* Do nothing!? See the tests */ - ret = TRUE; + if (!ret) + err = GetLastError(); } } else - { - SetLastError(ERROR_INVALID_PARAMETER); - ret = FALSE; - } - return ret; + err = ERROR_INVALID_PARAMETER; + return err; } -static BOOL SOFTPUB_LoadFileMessage(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_LoadFileMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; if (!data->pWintrustData->u.pFile) { - SetLastError(ERROR_INVALID_PARAMETER); - ret = FALSE; + err = ERROR_INVALID_PARAMETER; goto error; } - ret = SOFTPUB_OpenFile(data); - if (!ret) + err = SOFTPUB_OpenFile(data); + if (err) goto error; - ret = SOFTPUB_GetFileSubject(data); - if (!ret) + err = SOFTPUB_GetFileSubject(data); + if (err) goto error; - ret = SOFTPUB_GetSIP(data); - if (!ret) + err = SOFTPUB_GetSIP(data); + if (err) goto error; - ret = SOFTPUB_GetMessageFromFile(data, data->pWintrustData->u.pFile->hFile, + err = SOFTPUB_GetMessageFromFile(data, data->pWintrustData->u.pFile->hFile, data->pWintrustData->u.pFile->pcwszFilePath); - if (!ret) + if (err) goto error; - ret = SOFTPUB_CreateStoreFromMessage(data); - if (!ret) + err = SOFTPUB_CreateStoreFromMessage(data); + if (err) goto error; - ret = SOFTPUB_DecodeInnerContent(data); + err = SOFTPUB_DecodeInnerContent(data); + error: - return ret; + if (err && data->fOpenedFile && data->pWintrustData->u.pFile) + { + /* The caller won't expect the file to be open on failure, so close it. + */ + CloseHandle(data->pWintrustData->u.pFile->hFile); + data->pWintrustData->u.pFile->hFile = INVALID_HANDLE_VALUE; + data->fOpenedFile = FALSE; + } + return err; } -static BOOL SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err; HANDLE catalog = INVALID_HANDLE_VALUE; if (!data->pWintrustData->u.pCatalog) @@ -368,32 +384,34 @@ static BOOL SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data) GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (catalog == INVALID_HANDLE_VALUE) - return FALSE; - ret = CryptSIPRetrieveSubjectGuid( + return GetLastError(); + if (!CryptSIPRetrieveSubjectGuid( data->pWintrustData->u.pCatalog->pcwszCatalogFilePath, catalog, - &data->u.pPDSip->gSubject); - if (!ret) + &data->u.pPDSip->gSubject)) + { + err = GetLastError(); goto error; - ret = SOFTPUB_GetSIP(data); - if (!ret) + } + err = SOFTPUB_GetSIP(data); + if (err) goto error; - ret = SOFTPUB_GetMessageFromFile(data, catalog, + err = SOFTPUB_GetMessageFromFile(data, catalog, data->pWintrustData->u.pCatalog->pcwszCatalogFilePath); - if (!ret) + if (err) goto error; - ret = SOFTPUB_CreateStoreFromMessage(data); - if (!ret) + err = SOFTPUB_CreateStoreFromMessage(data); + if (err) goto error; - ret = SOFTPUB_DecodeInnerContent(data); + err = SOFTPUB_DecodeInnerContent(data); /* FIXME: this loads the catalog file, but doesn't validate the member. */ error: CloseHandle(catalog); - return ret; + return err; } HRESULT WINAPI SoftpubLoadMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; TRACE("(%p)\n", data); @@ -403,26 +421,24 @@ HRESULT WINAPI SoftpubLoadMessage(CRYPT_PROVIDER_DATA *data) switch (data->pWintrustData->dwUnionChoice) { case WTD_CHOICE_CERT: - ret = SOFTPUB_LoadCertMessage(data); + err = SOFTPUB_LoadCertMessage(data); break; case WTD_CHOICE_FILE: - ret = SOFTPUB_LoadFileMessage(data); + err = SOFTPUB_LoadFileMessage(data); break; case WTD_CHOICE_CATALOG: - ret = SOFTPUB_LoadCatalogMessage(data); + err = SOFTPUB_LoadCatalogMessage(data); break; default: FIXME("unimplemented for %d\n", data->pWintrustData->dwUnionChoice); - SetLastError(ERROR_INVALID_PARAMETER); - ret = FALSE; + err = ERROR_INVALID_PARAMETER; } - if (!ret) - data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] = - GetLastError(); - TRACE("returning %d (%08x)\n", ret ? S_OK : S_FALSE, + if (err) + data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] = err; + TRACE("returning %d (%08x)\n", !err ? S_OK : S_FALSE, data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]); - return ret ? S_OK : S_FALSE; + return !err ? S_OK : S_FALSE; } static CMSG_SIGNER_INFO *WINTRUST_GetSigner(CRYPT_PROVIDER_DATA *data, @@ -453,9 +469,9 @@ static CMSG_SIGNER_INFO *WINTRUST_GetSigner(CRYPT_PROVIDER_DATA *data, return signerInfo; } -static BOOL WINTRUST_SaveSigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) +static DWORD WINTRUST_SaveSigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) { - BOOL ret; + DWORD err; CMSG_SIGNER_INFO *signerInfo = WINTRUST_GetSigner(data, signerIdx); if (signerInfo) @@ -464,11 +480,14 @@ static BOOL WINTRUST_SaveSigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) sgnr.psSigner = signerInfo; sgnr.sftVerifyAsOf = data->sftSystemTime; - ret = data->psPfns->pfnAddSgnr2Chain(data, FALSE, signerIdx, &sgnr); + if (!data->psPfns->pfnAddSgnr2Chain(data, FALSE, signerIdx, &sgnr)) + err = GetLastError(); + else + err = ERROR_SUCCESS; } else - ret = FALSE; - return ret; + err = GetLastError(); + return err; } static CERT_INFO *WINTRUST_GetSignerCertInfo(CRYPT_PROVIDER_DATA *data, @@ -499,9 +518,9 @@ static CERT_INFO *WINTRUST_GetSignerCertInfo(CRYPT_PROVIDER_DATA *data, return certInfo; } -static BOOL WINTRUST_VerifySigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) +static DWORD WINTRUST_VerifySigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) { - BOOL ret; + DWORD err; CERT_INFO *certInfo = WINTRUST_GetSignerCertInfo(data, signerIdx); if (certInfo) @@ -514,30 +533,29 @@ static BOOL WINTRUST_VerifySigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA para = { sizeof(para), 0, signerIdx, CMSG_VERIFY_SIGNER_CERT, (LPVOID)subject }; - ret = CryptMsgControl(data->hMsg, 0, CMSG_CTRL_VERIFY_SIGNATURE_EX, - ¶); - if (!ret) - SetLastError(TRUST_E_CERT_SIGNATURE); + if (!CryptMsgControl(data->hMsg, 0, CMSG_CTRL_VERIFY_SIGNATURE_EX, + ¶)) + err = TRUST_E_CERT_SIGNATURE; else + { data->psPfns->pfnAddCert2Chain(data, signerIdx, FALSE, 0, subject); + err = ERROR_SUCCESS; + } CertFreeCertificateContext(subject); } else - { - SetLastError(TRUST_E_NO_SIGNER_CERT); - ret = FALSE; - } + err = TRUST_E_NO_SIGNER_CERT; data->psPfns->pfnFree(certInfo); } else - ret = FALSE; - return ret; + err = GetLastError(); + return err; } HRESULT WINAPI SoftpubLoadSignature(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err; TRACE("(%p)\n", data); @@ -549,27 +567,26 @@ HRESULT WINAPI SoftpubLoadSignature(CRYPT_PROVIDER_DATA *data) DWORD signerCount, size; size = sizeof(signerCount); - ret = CryptMsgGetParam(data->hMsg, CMSG_SIGNER_COUNT_PARAM, 0, - &signerCount, &size); - if (ret) + if (CryptMsgGetParam(data->hMsg, CMSG_SIGNER_COUNT_PARAM, 0, + &signerCount, &size)) { DWORD i; - for (i = 0; ret && i < signerCount; i++) + err = ERROR_SUCCESS; + for (i = 0; !err && i < signerCount; i++) { - if ((ret = WINTRUST_SaveSigner(data, i))) - ret = WINTRUST_VerifySigner(data, i); + if (!(err = WINTRUST_SaveSigner(data, i))) + err = WINTRUST_VerifySigner(data, i); } } else - SetLastError(TRUST_E_NOSIGNATURE); + err = TRUST_E_NOSIGNATURE; } else - ret = TRUE; - if (!ret) - data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_SIGPROV] = - GetLastError(); - return ret ? S_OK : S_FALSE; + err = ERROR_SUCCESS; + if (err) + data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_SIGPROV] = err; + return !err ? S_OK : S_FALSE; } static DWORD WINTRUST_TrustStatusToConfidence(DWORD errorStatus) @@ -672,24 +689,22 @@ static DWORD WINTRUST_TrustStatusToError(DWORD errorStatus) return error; } -static BOOL WINTRUST_CopyChain(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) +static DWORD WINTRUST_CopyChain(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) { - BOOL ret; + DWORD err, i; PCERT_SIMPLE_CHAIN simpleChain = data->pasSigners[signerIdx].pChainContext->rgpChain[0]; - DWORD i; data->pasSigners[signerIdx].pasCertChain[0].dwConfidence = WINTRUST_TrustStatusToConfidence( simpleChain->rgpElement[0]->TrustStatus.dwErrorStatus); data->pasSigners[signerIdx].pasCertChain[0].pChainElement = simpleChain->rgpElement[0]; - ret = TRUE; - for (i = 1; ret && i < simpleChain->cElement; i++) + err = ERROR_SUCCESS; + for (i = 1; !err && i < simpleChain->cElement; i++) { - ret = data->psPfns->pfnAddCert2Chain(data, signerIdx, FALSE, 0, - simpleChain->rgpElement[i]->pCertContext); - if (ret) + if (data->psPfns->pfnAddCert2Chain(data, signerIdx, FALSE, 0, + simpleChain->rgpElement[i]->pCertContext)) { data->pasSigners[signerIdx].pasCertChain[i].pChainElement = simpleChain->rgpElement[i]; @@ -697,12 +712,14 @@ static BOOL WINTRUST_CopyChain(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) WINTRUST_TrustStatusToConfidence( simpleChain->rgpElement[i]->TrustStatus.dwErrorStatus); } + else + err = GetLastError(); } data->pasSigners[signerIdx].pasCertChain[simpleChain->cElement - 1].dwError = WINTRUST_TrustStatusToError( simpleChain->rgpElement[simpleChain->cElement - 1]-> TrustStatus.dwErrorStatus); - return ret; + return err; } static void WINTRUST_CreateChainPolicyCreateInfo( @@ -731,11 +748,11 @@ static void WINTRUST_CreateChainPolicyCreateInfo( info->pvReserved = NULL; } -static BOOL WINTRUST_CreateChainForSigner(CRYPT_PROVIDER_DATA *data, +static DWORD WINTRUST_CreateChainForSigner(CRYPT_PROVIDER_DATA *data, DWORD signer, PWTD_GENERIC_CHAIN_POLICY_CREATE_INFO createInfo, PCERT_CHAIN_PARA chainPara) { - BOOL ret = TRUE; + DWORD err = ERROR_SUCCESS; HCERTSTORE store = NULL; if (data->chStores) @@ -749,53 +766,64 @@ static BOOL WINTRUST_CreateChainForSigner(CRYPT_PROVIDER_DATA *data, for (i = 0; i < data->chStores; i++) CertAddStoreToCollection(store, data->pahStores[i], 0, 0); } + else + err = GetLastError(); } - /* Expect the end certificate for each signer to be the only cert in the - * chain: - */ - if (data->pasSigners[signer].csCertChain) + if (!err) { - /* Create a certificate chain for each signer */ - ret = CertGetCertificateChain(createInfo->hChainEngine, - data->pasSigners[signer].pasCertChain[0].pCert, - &data->pasSigners[signer].sftVerifyAsOf, store, - chainPara, createInfo->dwFlags, createInfo->pvReserved, - &data->pasSigners[signer].pChainContext); - if (ret) + /* Expect the end certificate for each signer to be the only cert in + * the chain: + */ + if (data->pasSigners[signer].csCertChain) { - if (data->pasSigners[signer].pChainContext->cChain != 1) + BOOL ret; + + /* Create a certificate chain for each signer */ + ret = CertGetCertificateChain(createInfo->hChainEngine, + data->pasSigners[signer].pasCertChain[0].pCert, + &data->pasSigners[signer].sftVerifyAsOf, store, + chainPara, createInfo->dwFlags, createInfo->pvReserved, + &data->pasSigners[signer].pChainContext); + if (ret) { - FIXME("unimplemented for more than 1 simple chain\n"); - ret = FALSE; - } - else - { - if ((ret = WINTRUST_CopyChain(data, signer))) + if (data->pasSigners[signer].pChainContext->cChain != 1) { - if (data->psPfns->pfnCertCheckPolicy) - ret = data->psPfns->pfnCertCheckPolicy(data, signer, - FALSE, 0); - else - TRACE("no cert check policy, skipping policy check\n"); + FIXME("unimplemented for more than 1 simple chain\n"); + err = E_NOTIMPL; + } + else + { + if (!(err = WINTRUST_CopyChain(data, signer))) + { + if (data->psPfns->pfnCertCheckPolicy) + { + ret = data->psPfns->pfnCertCheckPolicy(data, signer, + FALSE, 0); + if (!ret) + err = GetLastError(); + } + else + TRACE( + "no cert check policy, skipping policy check\n"); + } } } + else + err = GetLastError(); } + CertCloseStore(store, 0); } - CertCloseStore(store, 0); - return ret; + return err; } HRESULT WINAPI WintrustCertificateTrust(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err; TRACE("(%p)\n", data); if (!data->csSigners) - { - ret = FALSE; - SetLastError(TRUST_E_NOSIGNATURE); - } + err = TRUST_E_NOSIGNATURE; else { DWORD i; @@ -803,17 +831,16 @@ HRESULT WINAPI WintrustCertificateTrust(CRYPT_PROVIDER_DATA *data) CERT_CHAIN_PARA chainPara; WINTRUST_CreateChainPolicyCreateInfo(data, &createInfo, &chainPara); - ret = TRUE; - for (i = 0; i < data->csSigners; i++) - ret = WINTRUST_CreateChainForSigner(data, i, &createInfo, + err = ERROR_SUCCESS; + for (i = 0; !err && i < data->csSigners; i++) + err = WINTRUST_CreateChainForSigner(data, i, &createInfo, &chainPara); } - if (!ret) - data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] = - GetLastError(); - TRACE("returning %d (%08x)\n", ret ? S_OK : S_FALSE, + if (err) + data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] = err; + TRACE("returning %d (%08x)\n", !err ? S_OK : S_FALSE, data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV]); - return ret ? S_OK : S_FALSE; + return !err ? S_OK : S_FALSE; } HRESULT WINAPI GenericChainCertificateTrust(CRYPT_PROVIDER_DATA *data) @@ -1078,7 +1105,8 @@ HRESULT WINAPI SoftpubCleanup(CRYPT_PROVIDER_DATA *data) CryptMsgClose(data->hMsg); - if (data->fOpenedFile) + if (data->fOpenedFile && + data->pWintrustData->dwUnionChoice == WTD_CHOICE_FILE) CloseHandle(data->pWintrustData->u.pFile->hFile); return S_OK; diff --git a/reactos/dll/win32/wintrust/wintrust_main.c b/reactos/dll/win32/wintrust/wintrust_main.c index c61f6e0f2d6..1c87b6ee07f 100644 --- a/reactos/dll/win32/wintrust/wintrust_main.c +++ b/reactos/dll/win32/wintrust/wintrust_main.c @@ -77,11 +77,118 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) */ BOOL WINAPI TrustIsCertificateSelfSigned( PCCERT_CONTEXT cert ) { + PCERT_EXTENSION ext; + DWORD size; BOOL ret; TRACE("%p\n", cert); - ret = CertCompareCertificateName(cert->dwCertEncodingType, - &cert->pCertInfo->Subject, &cert->pCertInfo->Issuer); + if ((ext = CertFindExtension(szOID_AUTHORITY_KEY_IDENTIFIER2, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + { + CERT_AUTHORITY_KEY_ID2_INFO *info; + + ret = CryptDecodeObjectEx(cert->dwCertEncodingType, + X509_AUTHORITY_KEY_ID2, ext->Value.pbData, ext->Value.cbData, + CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL, + &info, &size); + if (ret) + { + if (info->AuthorityCertIssuer.cAltEntry && + info->AuthorityCertSerialNumber.cbData) + { + PCERT_ALT_NAME_ENTRY directoryName = NULL; + DWORD i; + + for (i = 0; !directoryName && + i < info->AuthorityCertIssuer.cAltEntry; i++) + if (info->AuthorityCertIssuer.rgAltEntry[i].dwAltNameChoice + == CERT_ALT_NAME_DIRECTORY_NAME) + directoryName = + &info->AuthorityCertIssuer.rgAltEntry[i]; + if (directoryName) + { + ret = CertCompareCertificateName(cert->dwCertEncodingType, + &directoryName->u.DirectoryName, &cert->pCertInfo->Issuer) + && CertCompareIntegerBlob(&info->AuthorityCertSerialNumber, + &cert->pCertInfo->SerialNumber); + } + else + { + FIXME("no supported name type in authority key id2\n"); + ret = FALSE; + } + } + else if (info->KeyId.cbData) + { + ret = CertGetCertificateContextProperty(cert, + CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size); + if (ret && size == info->KeyId.cbData) + { + LPBYTE buf = CryptMemAlloc(size); + + if (buf) + { + CertGetCertificateContextProperty(cert, + CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); + ret = !memcmp(buf, info->KeyId.pbData, size); + CryptMemFree(buf); + } + else + ret = FALSE; + } + else + ret = FALSE; + } + LocalFree(info); + } + } + else if ((ext = CertFindExtension(szOID_AUTHORITY_KEY_IDENTIFIER, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + { + CERT_AUTHORITY_KEY_ID_INFO *info; + + ret = CryptDecodeObjectEx(cert->dwCertEncodingType, + X509_AUTHORITY_KEY_ID, ext->Value.pbData, ext->Value.cbData, + CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL, + &info, &size); + if (ret) + { + if (info->CertIssuer.cbData && info->CertSerialNumber.cbData) + { + ret = CertCompareCertificateName(cert->dwCertEncodingType, + &info->CertIssuer, &cert->pCertInfo->Issuer) && + CertCompareIntegerBlob(&info->CertSerialNumber, + &cert->pCertInfo->SerialNumber); + } + else if (info->KeyId.cbData) + { + ret = CertGetCertificateContextProperty(cert, + CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size); + if (ret && size == info->KeyId.cbData) + { + LPBYTE buf = CryptMemAlloc(size); + + if (buf) + { + CertGetCertificateContextProperty(cert, + CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); + ret = !memcmp(buf, info->KeyId.pbData, size); + CryptMemFree(buf); + } + else + ret = FALSE; + } + else + ret = FALSE; + } + else + ret = FALSE; + LocalFree(info); + } + } + else + ret = CertCompareCertificateName(cert->dwCertEncodingType, + &cert->pCertInfo->Subject, &cert->pCertInfo->Issuer); return ret; } From 789a1e0a2bcfbd249bfc1a79781a003540a912ac Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 20:42:21 +0000 Subject: [PATCH 088/211] [WINDOWSCODECS] sync windowscodecs to wine 1.1.39 svn path=/trunk/; revision=45839 --- reactos/dll/win32/windowscodecs/pngformat.c | 44 +++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/reactos/dll/win32/windowscodecs/pngformat.c b/reactos/dll/win32/windowscodecs/pngformat.c index f3613637e49..482ea90089d 100644 --- a/reactos/dll/win32/windowscodecs/pngformat.c +++ b/reactos/dll/win32/windowscodecs/pngformat.c @@ -51,6 +51,7 @@ MAKE_FUNCPTR(png_destroy_write_struct); MAKE_FUNCPTR(png_error); MAKE_FUNCPTR(png_get_bit_depth); MAKE_FUNCPTR(png_get_color_type); +MAKE_FUNCPTR(png_get_error_ptr); MAKE_FUNCPTR(png_get_image_height); MAKE_FUNCPTR(png_get_image_width); MAKE_FUNCPTR(png_get_io_ptr); @@ -58,8 +59,9 @@ MAKE_FUNCPTR(png_get_pHYs); MAKE_FUNCPTR(png_get_PLTE); MAKE_FUNCPTR(png_get_tRNS); MAKE_FUNCPTR(png_set_bgr); +MAKE_FUNCPTR(png_set_error_fn); +MAKE_FUNCPTR(png_set_expand_gray_1_2_4_to_8); MAKE_FUNCPTR(png_set_filler); -MAKE_FUNCPTR(png_set_gray_1_2_4_to_8); MAKE_FUNCPTR(png_set_gray_to_rgb); MAKE_FUNCPTR(png_set_IHDR); MAKE_FUNCPTR(png_set_pHYs); @@ -92,6 +94,7 @@ static void *load_libpng(void) LOAD_FUNCPTR(png_error); LOAD_FUNCPTR(png_get_bit_depth); LOAD_FUNCPTR(png_get_color_type); + LOAD_FUNCPTR(png_get_error_ptr); LOAD_FUNCPTR(png_get_image_height); LOAD_FUNCPTR(png_get_image_width); LOAD_FUNCPTR(png_get_io_ptr); @@ -99,8 +102,9 @@ static void *load_libpng(void) LOAD_FUNCPTR(png_get_PLTE); LOAD_FUNCPTR(png_get_tRNS); LOAD_FUNCPTR(png_set_bgr); + LOAD_FUNCPTR(png_set_error_fn); + LOAD_FUNCPTR(png_set_expand_gray_1_2_4_to_8); LOAD_FUNCPTR(png_set_filler); - LOAD_FUNCPTR(png_set_gray_1_2_4_to_8); LOAD_FUNCPTR(png_set_gray_to_rgb); LOAD_FUNCPTR(png_set_IHDR); LOAD_FUNCPTR(png_set_pHYs); @@ -120,6 +124,23 @@ static void *load_libpng(void) return libpng_handle; } +static void user_error_fn(png_structp png_ptr, png_const_charp error_message) +{ + jmp_buf *pjmpbuf; + + /* This uses setjmp/longjmp just like the default. We can't use the + * default because there's no way to access the jmp buffer in the png_struct + * that works in 1.2 and 1.4 and allows us to dynamically load libpng. */ + WARN("PNG error: %s\n", debugstr_a(error_message)); + pjmpbuf = ppng_get_error_ptr(png_ptr); + longjmp(*pjmpbuf, 1); +} + +static void user_warning_fn(png_structp png_ptr, png_const_charp warning_message) +{ + WARN("PNG warning: %s\n", debugstr_a(warning_message)); +} + typedef struct { const IWICBitmapDecoderVtbl *lpVtbl; const IWICBitmapFrameDecodeVtbl *lpFrameVtbl; @@ -226,6 +247,8 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p int num_trans; png_uint_32 transparency; png_color_16p trans_values; + jmp_buf jmpbuf; + TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions); /* initialize libpng */ @@ -249,13 +272,14 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p } /* set up setjmp/longjmp error handling */ - if (setjmp(png_jmpbuf(This->png_ptr))) + if (setjmp(jmpbuf)) { ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, &This->end_info); HeapFree(GetProcessHeap(), 0, row_pointers); This->png_ptr = NULL; return E_FAIL; } + ppng_set_error_fn(This->png_ptr, &jmpbuf, user_error_fn, user_warning_fn); /* seek to the start of the stream */ seek.QuadPart = 0; @@ -282,7 +306,7 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p { if (bit_depth < 8) { - ppng_set_gray_1_2_4_to_8(This->png_ptr); + ppng_set_expand_gray_1_2_4_to_8(This->png_ptr); bit_depth = 8; } ppng_set_gray_to_rgb(This->png_ptr); @@ -849,6 +873,7 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, PngEncoder *This = encoder_from_frame(iface); png_byte **row_pointers=NULL; UINT i; + jmp_buf jmpbuf; TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels); if (!This->frame_initialized || !This->width || !This->height || !This->format) @@ -858,11 +883,12 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, return E_INVALIDARG; /* set up setjmp/longjmp error handling */ - if (setjmp(png_jmpbuf(This->png_ptr))) + if (setjmp(jmpbuf)) { HeapFree(GetProcessHeap(), 0, row_pointers); return E_FAIL; } + ppng_set_error_fn(This->png_ptr, &jmpbuf, user_error_fn, user_warning_fn); if (!This->info_written) { @@ -978,16 +1004,18 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, static HRESULT WINAPI PngFrameEncode_Commit(IWICBitmapFrameEncode *iface) { PngEncoder *This = encoder_from_frame(iface); + jmp_buf jmpbuf; TRACE("(%p)\n", iface); if (!This->info_written || This->lines_written != This->height || This->frame_committed) return WINCODEC_ERR_WRONGSTATE; /* set up setjmp/longjmp error handling */ - if (setjmp(png_jmpbuf(This->png_ptr))) + if (setjmp(jmpbuf)) { return E_FAIL; } + ppng_set_error_fn(This->png_ptr, &jmpbuf, user_error_fn, user_warning_fn); ppng_write_end(This->png_ptr, This->info_ptr); @@ -1093,6 +1121,7 @@ static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface, IStream *pIStream, WICBitmapEncoderCacheOption cacheOption) { PngEncoder *This = (PngEncoder*)iface; + jmp_buf jmpbuf; TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption); @@ -1116,7 +1145,7 @@ static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface, This->stream = pIStream; /* set up setjmp/longjmp error handling */ - if (setjmp(png_jmpbuf(This->png_ptr))) + if (setjmp(jmpbuf)) { ppng_destroy_write_struct(&This->png_ptr, &This->info_ptr); This->png_ptr = NULL; @@ -1124,6 +1153,7 @@ static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface, This->stream = NULL; return E_FAIL; } + ppng_set_error_fn(This->png_ptr, &jmpbuf, user_error_fn, user_warning_fn); /* set up custom i/o handling */ ppng_set_write_fn(This->png_ptr, This, user_write_data, user_flush); From a327cb39e8da85daab98132da49eaf37ac397be0 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 20:46:06 +0000 Subject: [PATCH 089/211] [WINTRUST_WINETEST] sync wintrust_winetest to wine 1.1.39 svn path=/trunk/; revision=45840 --- rostests/winetests/wintrust/crypt.c | 2 ++ rostests/winetests/wintrust/softpub.c | 33 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/rostests/winetests/wintrust/crypt.c b/rostests/winetests/wintrust/crypt.c index 3e77814079f..a2e096a3ecc 100644 --- a/rostests/winetests/wintrust/crypt.c +++ b/rostests/winetests/wintrust/crypt.c @@ -515,6 +515,8 @@ static void test_CryptCATAdminAddRemoveCatalog(void) ok(hcatinfo == NULL, "CryptCATAdminAddCatalog succeeded\n"); ok(error == ERROR_BAD_FORMAT, "got %u expected ERROR_BAD_FORMAT\n", GetLastError()); } + if (hcatinfo != NULL) + pCryptCATAdminReleaseCatalogContext(hcatadmin, hcatinfo, 0); SetLastError(0xdeadbeef); hcatinfo = pCryptCATAdminAddCatalog(hcatadmin, tmpfileW, basenameW, 1); diff --git a/rostests/winetests/wintrust/softpub.c b/rostests/winetests/wintrust/softpub.c index 3e4347d80d3..e01a26ca288 100644 --- a/rostests/winetests/wintrust/softpub.c +++ b/rostests/winetests/wintrust/softpub.c @@ -179,8 +179,12 @@ static void test_utils(SAFE_PROVIDER_FUNCTIONS *funcs) ok(data.pasSigners[0].pasCertChain != NULL, "Expected pasCertChain to be allocated\n"); if (data.pasSigners[0].pasCertChain) + { ok(data.pasSigners[0].pasCertChain[0].pCert == cert, "Unexpected cert\n"); + CertFreeCertificateContext( + data.pasSigners[0].pasCertChain[0].pCert); + } CertFreeCertificateContext(cert); } else @@ -266,6 +270,8 @@ static void testObjTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID) PROVDATA_SIP provDataSIP = { 0 }; static const GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47, 0x00,0xC0,0x4F,0xC2,0x95,0xEE } }; + static GUID bogusGuid = { 0xdeadbeef, 0xbaad, 0xf00d, { 0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00 } }; ret = funcs->pfnObjectTrust(&data); ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret); @@ -317,6 +323,30 @@ static void testObjTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID) ok(provDataSIP.psSipSubjectInfo != NULL, "Expected a subject info\n"); } + /* Specifying the GUID results in that GUID being the subject GUID */ + fileInfo.pgKnownSubject = &bogusGuid; + ret = funcs->pfnObjectTrust(&data); + ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret); + ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] == + TRUST_E_NOSIGNATURE || + data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] == + TRUST_E_SUBJECT_FORM_UNKNOWN || + data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] == + TRUST_E_PROVIDER_UNKNOWN, + "Expected TRUST_E_NOSIGNATURE or TRUST_E_SUBJECT_FORM_UNKNOWN or TRUST_E_PROVIDER_UNKNOWN, got %08x\n", + data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]); + if (data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] == + TRUST_E_NOSIGNATURE) + { + ok(!memcmp(&provDataSIP.gSubject, &bogusGuid, sizeof(bogusGuid)), + "unexpected subject GUID\n"); + } + /* Specifying a bogus GUID pointer crashes */ + if (0) + { + fileInfo.pgKnownSubject = (GUID *)0xdeadbeef; + ret = funcs->pfnObjectTrust(&data); + } funcs->pfnFree(data.padwTrustStepErrors); } } @@ -407,6 +437,9 @@ static void testCertTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID) (CERT_CONFIDENCE_SIG | CERT_CONFIDENCE_TIMENEST), "Expected CERT_CONFIDENCE_SIG | CERT_CONFIDENCE_TIMENEST, got %08x\n", data.pasSigners[0].pasCertChain[0].dwConfidence); + CertFreeCertificateContext( + data.pasSigners[0].pasCertChain[0].pCert); + CertFreeCertificateChain(data.pasSigners[0].pChainContext); CertFreeCertificateContext(cert); } } From f793b1390f1e39a77c867c1110aeb6f5cb669409 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 20:55:41 +0000 Subject: [PATCH 090/211] [IPHLPAPI_WINETEST] sync iphlpapi_winetest to wine 1.1.39 svn path=/trunk/; revision=45841 --- rostests/winetests/iphlpapi/iphlpapi.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/rostests/winetests/iphlpapi/iphlpapi.c b/rostests/winetests/iphlpapi/iphlpapi.c index cd2e45200a3..c03c56d2dee 100644 --- a/rostests/winetests/iphlpapi/iphlpapi.c +++ b/rostests/winetests/iphlpapi/iphlpapi.c @@ -775,11 +775,12 @@ GetBestRoute IpReleaseAddress IpRenewAddress */ -static void testWin98Functions(void) +static DWORD CALLBACK testWin98Functions(void *p) { testGetInterfaceInfo(); testGetAdaptersInfo(); testGetNetworkParams(); + return 0; } static void testGetPerAdapterInfo(void) @@ -839,6 +840,7 @@ static void test_GetAdaptersAddresses(void) ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL); ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", ret); + size = 0; ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size); ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret); if (ret != ERROR_BUFFER_OVERFLOW) return; @@ -849,16 +851,16 @@ static void test_GetAdaptersAddresses(void) while (!ret && winetest_debug > 1 && aa) { - trace("Length: %u\n", aa->Length); - trace("IfIndex: %u\n", aa->IfIndex); + trace("Length: %u\n", S(U(*aa)).Length); + trace("IfIndex: %u\n", S(U(*aa)).IfIndex); trace("Next: %p\n", aa->Next); trace("AdapterName: %s\n", aa->AdapterName); trace("FirstUnicastAddress: %p\n", aa->FirstUnicastAddress); ua = aa->FirstUnicastAddress; while (ua) { - trace("\tLength: %u\n", ua->Length); - trace("\tFlags: 0x%08x\n", ua->Flags); + trace("\tLength: %u\n", S(U(*ua)).Length); + trace("\tFlags: 0x%08x\n", S(U(*ua)).Flags); trace("\tNext: %p\n", ua->Next); trace("\tAddress.lpSockaddr: %p\n", ua->Address.lpSockaddr); trace("\tAddress.iSockaddrLength: %d\n", ua->Address.iSockaddrLength); @@ -894,9 +896,16 @@ START_TEST(iphlpapi) loadIPHlpApi(); if (hLibrary) { + HANDLE thread; + testWin98OnlyFunctions(); testWinNT4Functions(); - testWin98Functions(); + + /* run testGetXXXX in two threads at once to make sure we don't crash in that case */ + thread = CreateThread(NULL, 0, testWin98Functions, NULL, 0, NULL); + testWin98Functions(NULL); + WaitForSingleObject(thread, INFINITE); + testWin2KFunctions(); test_GetAdaptersAddresses(); freeIPHlpApi(); From 56ea0194bb1975e5418930e0d248d2f9e5314695 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 4 Mar 2010 20:55:58 +0000 Subject: [PATCH 091/211] [SHELL32_WINETEST] sync shell32_winetest to wine 1.1.39 svn path=/trunk/; revision=45842 --- rostests/winetests/shell32/autocomplete.c | 33 +++-- rostests/winetests/shell32/progman_dde.c | 30 ++++- rostests/winetests/shell32/shelllink.c | 12 +- rostests/winetests/shell32/shellpath.c | 10 +- rostests/winetests/shell32/shlfileop.c | 152 +++++++++++++++++++--- 5 files changed, 202 insertions(+), 35 deletions(-) diff --git a/rostests/winetests/shell32/autocomplete.c b/rostests/winetests/shell32/autocomplete.c index 20315c749ea..042e238c2de 100644 --- a/rostests/winetests/shell32/autocomplete.c +++ b/rostests/winetests/shell32/autocomplete.c @@ -33,7 +33,8 @@ static HWND hMainWnd, hEdit; static HINSTANCE hinst; static int killfocus_count; -static BOOL test_init(void) { +static IAutoComplete *test_init(void) +{ HRESULT r; IAutoComplete* ac; IUnknown *acSource; @@ -44,7 +45,7 @@ static BOOL test_init(void) { if (r == REGDB_E_CLASSNOTREG) { win_skip("CLSID_AutoComplete is not registered\n"); - return FALSE; + return NULL; } ok(SUCCEEDED(r), "no IID_IAutoComplete (0x%08x)\n", r); @@ -54,7 +55,7 @@ static BOOL test_init(void) { if (r == REGDB_E_CLASSNOTREG) { win_skip("CLSID_ACLMulti is not registered\n"); - return FALSE; + return NULL; } ok(SUCCEEDED(r), "no IID_IACList (0x%08x)\n", r); @@ -62,9 +63,13 @@ static BOOL test_init(void) { r = IAutoComplete_Init(ac, hEdit, acSource, NULL, NULL); ok(SUCCEEDED(r), "Init failed (0x%08x)\n", r); - return TRUE; + IUnknown_Release(acSource); + + return ac; } -static void test_killfocus(void) { + +static void test_killfocus(void) +{ /* Test if WM_KILLFOCUS messages are handled properly by checking if * the parent receives an EN_KILLFOCUS message. */ SetFocus(hEdit); @@ -72,7 +77,9 @@ static void test_killfocus(void) { SetFocus(0); ok(killfocus_count == 1, "Expected one EN_KILLFOCUS message, got: %d\n", killfocus_count); } -static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { + +static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ switch(msg) { case WM_CREATE: /* create edit control */ @@ -87,7 +94,9 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa } return DefWindowProcA(hWnd, msg, wParam, lParam); } -static void createMainWnd(void) { + +static void createMainWnd(void) +{ WNDCLASSA wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbClsExtra = 0; @@ -104,9 +113,12 @@ static void createMainWnd(void) { hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 130, 105, NULL, NULL, GetModuleHandleA(NULL), 0); } -START_TEST(autocomplete) { + +START_TEST(autocomplete) +{ HRESULT r; MSG msg; + IAutoComplete* ac; r = CoInitialize(NULL); ok(SUCCEEDED(r), "CoInitialize failed (0x%08x). Tests aborted.\n", r); @@ -118,7 +130,8 @@ START_TEST(autocomplete) { if(!ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n")) return; - if (!test_init()) + ac = test_init(); + if (!ac) goto cleanup; test_killfocus(); @@ -128,6 +141,8 @@ START_TEST(autocomplete) { DispatchMessageA(&msg); } + IAutoComplete_Release(ac); + cleanup: DestroyWindow(hEdit); DestroyWindow(hMainWnd); diff --git a/rostests/winetests/shell32/progman_dde.c b/rostests/winetests/shell32/progman_dde.c index 0a7fdaa2102..333e1f1e16b 100644 --- a/rostests/winetests/shell32/progman_dde.c +++ b/rostests/winetests/shell32/progman_dde.c @@ -102,6 +102,30 @@ static BOOL use_common(void) return TRUE; } +static BOOL full_title(void) +{ + CABINETSTATE cs; + + memset(&cs, 0, sizeof(cs)); + if (pReadCabinetState) + { + pReadCabinetState(&cs, sizeof(cs)); + } + else + { + HKEY key; + DWORD size; + + win_skip("ReadCabinetState is not available, reading registry directly\n"); + RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState", &key); + size = sizeof(cs); + RegQueryValueExA(key, "Settings", NULL, NULL, (LPBYTE)&cs, &size); + RegCloseKey(key); + } + + return (cs.fFullPathTitle == -1); +} + static char ProgramsDir[MAX_PATH]; static char Group1Title[MAX_PATH] = "Group1"; @@ -115,8 +139,6 @@ static void init_strings(void) char commonprograms[MAX_PATH]; char programs[MAX_PATH]; - CABINETSTATE cs; - if (pSHGetSpecialFolderPathA) { pSHGetSpecialFolderPathA(NULL, programs, CSIDL_PROGRAMS, FALSE); @@ -153,9 +175,7 @@ static void init_strings(void) else lstrcpyA(ProgramsDir, programs); - memset(&cs, 0, sizeof(cs)); - pReadCabinetState(&cs, sizeof(cs)); - if (cs.fFullPathTitle == -1) + if (full_title()) { lstrcpyA(Group1Title, ProgramsDir); lstrcatA(Group1Title, "\\Group1"); diff --git a/rostests/winetests/shell32/shelllink.c b/rostests/winetests/shell32/shelllink.c index 25354718601..bb2d5b366db 100755 --- a/rostests/winetests/shell32/shelllink.c +++ b/rostests/winetests/shell32/shelllink.c @@ -207,6 +207,7 @@ static void test_get_set(void) } if (ret) ok(lstrcmpi(buffer,str)==0, "GetIDList returned '%s'\n", buffer); + pILFree(tmp_pidl); } pidl=path_to_pidl(mypath); @@ -214,6 +215,8 @@ static void test_get_set(void) if (pidl) { + LPITEMIDLIST second_pidl; + r = IShellLinkA_SetIDList(sl, pidl); ok(SUCCEEDED(r), "SetIDList failed (0x%08x)\n", r); @@ -223,7 +226,14 @@ static void test_get_set(void) ok(tmp_pidl && pILIsEqual(pidl, tmp_pidl), "GetIDList returned an incorrect pidl\n"); - /* tmp_pidl is owned by IShellLink so we don't free it */ + r = IShellLinkA_GetIDList(sl, &second_pidl); + ok(SUCCEEDED(r), "GetIDList failed (0x%08x)\n", r); + ok(second_pidl && pILIsEqual(pidl, second_pidl), + "GetIDList returned an incorrect pidl\n"); + ok(second_pidl != tmp_pidl, "pidls are the same\n"); + + pILFree(second_pidl); + pILFree(tmp_pidl); pILFree(pidl); strcpy(buffer,"garbage"); diff --git a/rostests/winetests/shell32/shellpath.c b/rostests/winetests/shell32/shellpath.c index f9f59e16dde..c035aaf1780 100644 --- a/rostests/winetests/shell32/shellpath.c +++ b/rostests/winetests/shell32/shellpath.c @@ -675,7 +675,7 @@ static void testWinDir(void) */ static void testSystemDir(void) { - char systemShellPath[MAX_PATH], systemDir[MAX_PATH] = { 0 }; + char systemShellPath[MAX_PATH], systemDir[MAX_PATH], systemDirx86[MAX_PATH]; if (!pSHGetSpecialFolderPathA) return; @@ -689,13 +689,13 @@ static void testSystemDir(void) systemDir, systemShellPath); } - if (!pGetSystemWow64DirectoryA || !pGetSystemWow64DirectoryA(systemDir, sizeof(systemDir))) - GetSystemDirectoryA(systemDir, sizeof(systemDir)); - myPathRemoveBackslashA(systemDir); + if (!pGetSystemWow64DirectoryA || !pGetSystemWow64DirectoryA(systemDirx86, sizeof(systemDirx86))) + GetSystemDirectoryA(systemDirx86, sizeof(systemDirx86)); + myPathRemoveBackslashA(systemDirx86); if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEMX86, FALSE)) { myPathRemoveBackslashA(systemShellPath); - ok(!lstrcmpiA(systemDir, systemShellPath), + ok(!lstrcmpiA(systemDirx86, systemShellPath) || broken(!lstrcmpiA(systemDir, systemShellPath)), "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n", systemDir, systemShellPath); } diff --git a/rostests/winetests/shell32/shlfileop.c b/rostests/winetests/shell32/shlfileop.c index 0a5cdcab4fd..777801e7786 100644 --- a/rostests/winetests/shell32/shlfileop.c +++ b/rostests/winetests/shell32/shlfileop.c @@ -47,6 +47,8 @@ broken(retval == ret_prewin32),\ "Expected %d, got %d\n", ret, retval) +static BOOL old_shell32 = FALSE; + static CHAR CURR_DIR[MAX_PATH]; static const WCHAR UNICODE_PATH[] = {'c',':','\\',0x00ae,'\0','\0'}; /* "c:\®" can be used in all codepages */ @@ -764,6 +766,8 @@ static void test_rename(void) /* pTo already exist */ shfo.pFrom = "test1.txt\0"; shfo.pTo = "test2.txt\0"; + if (old_shell32) + shfo.fFlags |= FOF_NOCONFIRMMKDIR; retval = SHFileOperationA(&shfo); if (retval == ERROR_SUCCESS) { @@ -817,6 +821,12 @@ static void test_copy(void) LPSTR ptr; BOOL on_nt4 = FALSE; + if (old_shell32) + { + win_skip("Too many differences for old shell32\n"); + return; + } + shfo.hwnd = NULL; shfo.wFunc = FO_COPY; shfo.pFrom = from; @@ -1710,6 +1720,21 @@ static void test_copy(void) ok(DeleteFileA("ab.txt"), "Expected file to exist\n"); ok(RemoveDirectoryA("one"), "Expected dir to exist\n"); ok(RemoveDirectoryA("two"), "Expected dir to exist\n"); + + /* pTo is an empty string */ + CreateDirectoryA("dir", NULL); + createTestFile("dir\\abcdefgh.abc"); + shfo.pFrom = "dir\\abcdefgh.abc\0"; + shfo.pTo = "\0"; + shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; + retval = SHFileOperation(&shfo); + ok(retval == ERROR_SUCCESS || + broken(retval == DE_OPCANCELLED), /* NT4 */ + "Expected ERROR_SUCCESS, got %d\n", retval); + if (retval == ERROR_SUCCESS) + ok(DeleteFileA("abcdefgh.abc"), "Expected file to exist\n"); + ok(DeleteFileA("dir\\abcdefgh.abc"), "Expected file to exist\n"); + ok(RemoveDirectoryA("dir"), "Expected dir to exist\n"); } /* tests the FO_MOVE action */ @@ -1751,6 +1776,8 @@ static void test_move(void) set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); + if (old_shell32) + shfo2.fFlags |= FOF_NOCONFIRMMKDIR; ok(!SHFileOperationA(&shfo2), "Move many files\n"); ok(DeleteFileA("test6.txt"), "The file is not moved - many files are " "specified as a target\n"); @@ -1765,12 +1792,23 @@ static void test_move(void) retval = SHFileOperationA(&shfo2); if (dir_exists("test6.txt")) { - /* Vista and W2K8 (broken or new behavior ?) */ - ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %d\n", retval); - ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved\n"); - RemoveDirectoryA("test6.txt"); - ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not moved\n"); - RemoveDirectoryA("test7.txt"); + if (retval == ERROR_SUCCESS) + { + /* Old shell32 */ + DeleteFileA("test6.txt\\test1.txt"); + DeleteFileA("test6.txt\\test2.txt"); + RemoveDirectoryA("test6.txt\\test4.txt"); + RemoveDirectoryA("test6.txt"); + } + else + { + /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %d\n", retval); + ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved\n"); + RemoveDirectoryA("test6.txt"); + ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not moved\n"); + RemoveDirectoryA("test7.txt"); + } } else { @@ -1788,9 +1826,12 @@ static void test_move(void) set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); + if (old_shell32) + shfo.fFlags |= FOF_NOCONFIRMMKDIR; retval = SHFileOperationA(&shfo); if (dir_exists("test6.txt")) { + /* Old shell32 */ /* Vista and W2K8 (broken or new behavior ?) */ ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved. Many files are specified\n"); @@ -1839,8 +1880,14 @@ static void test_move(void) else { ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + if (old_shell32) + { + DeleteFile("a.txt\\a.txt"); + RemoveDirectoryA("a.txt"); + } + else + ok(DeleteFile("a.txt"), "Expected a.txt to exist\n"); ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n"); - ok(DeleteFile("a.txt"), "Expected a.txt to exist\n"); } ok(!file_exists("b.txt"), "Expected b.txt to not exist\n"); @@ -1850,6 +1897,7 @@ static void test_move(void) retval = SHFileOperationA(&shfo); if (dir_exists("test1.txt")) { + /* Old shell32 */ /* Vista and W2K8 (broken or new behavior ?) */ ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFileA("test1.txt\\test2.txt"), "Expected test1.txt\\test2.txt to exist\n"); @@ -1882,6 +1930,7 @@ static void test_move(void) retval = SHFileOperationA(&shfo); if (dir_exists("d.txt")) { + /* Old shell32 */ /* Vista and W2K8 (broken or new behavior ?) */ ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n"); @@ -1903,13 +1952,23 @@ static void test_move(void) retval = SHFileOperationA(&shfo); if (dir_exists("d.txt")) { - /* Vista and W2K8 (broken or new behavior ?) */ - ok(retval == DE_SAMEFILE, - "Expected DE_SAMEFILE, got %d\n", retval); - ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n"); - ok(!file_exists("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to not exist\n"); - RemoveDirectoryA("d.txt"); - createTestFile("test2.txt"); + if (old_shell32) + { + DeleteFileA("d.txt\\test2.txt"); + DeleteFileA("d.txt\\test3.txt"); + RemoveDirectoryA("d.txt"); + createTestFile("test2.txt"); + } + else + { + /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == DE_SAMEFILE, + "Expected DE_SAMEFILE, got %d\n", retval); + ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n"); + ok(!file_exists("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to not exist\n"); + RemoveDirectoryA("d.txt"); + createTestFile("test2.txt"); + } } else { @@ -1947,7 +2006,13 @@ static void test_move(void) { ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n"); - ok(file_exists("test3.txt"), "Expected test3.txt to exist\n"); + if (old_shell32) + { + DeleteFileA("test3.txt\\test3.txt"); + RemoveDirectoryA("test3.txt"); + } + else + ok(file_exists("test3.txt"), "Expected test3.txt to exist\n"); } } @@ -2224,12 +2289,67 @@ static void test_unicode(void) ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n"); } +extern HRESULT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags); + +static void +test_shlmenu(void) { + HRESULT hres; + hres = Shell_MergeMenus (0, 0, 0x42, 0x4242, 0x424242, 0); + ok (hres == 0x4242, "expected 0x4242 but got %x\n", hres); + hres = Shell_MergeMenus ((HMENU)42, 0, 0x42, 0x4242, 0x424242, 0); + ok (hres == 0x4242, "expected 0x4242 but got %x\n", hres); +} + +/* Check for old shell32 (4.0.x) */ +static BOOL is_old_shell32(void) +{ + SHFILEOPSTRUCTA shfo; + CHAR from[5*MAX_PATH]; + CHAR to[5*MAX_PATH]; + DWORD retval; + + shfo.hwnd = NULL; + shfo.wFunc = FO_COPY; + shfo.pFrom = from; + shfo.pTo = to; + /* FOF_NOCONFIRMMKDIR is needed for old shell32 */ + shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_MULTIDESTFILES | FOF_NOCONFIRMMKDIR; + shfo.hNameMappings = NULL; + shfo.lpszProgressTitle = NULL; + + set_curr_dir_path(from, "test1.txt\0test2.txt\0test3.txt\0"); + set_curr_dir_path(to, "test6.txt\0test7.txt\0"); + retval = SHFileOperationA(&shfo); + + /* Delete extra files on old shell32 and Vista+*/ + DeleteFileA("test6.txt\\test1.txt"); + /* Delete extra files on old shell32 */ + DeleteFileA("test6.txt\\test2.txt"); + DeleteFileA("test6.txt\\test3.txt"); + /* Delete extra directory on old shell32 and Vista+ */ + RemoveDirectoryA("test6.txt"); + /* Delete extra files/directories on Vista+*/ + DeleteFileA("test7.txt\\test2.txt"); + RemoveDirectoryA("test7.txt"); + + if (retval == ERROR_SUCCESS) + return TRUE; + + return FALSE; +} + START_TEST(shlfileop) { InitFunctionPointers(); clean_after_shfo_tests(); + init_shfo_tests(); + old_shell32 = is_old_shell32(); + if (old_shell32) + win_skip("Need to cater for old shell32 (4.0.x) on Win95\n"); + clean_after_shfo_tests(); + init_shfo_tests(); test_get_file_info(); test_get_file_info_iconlist(); @@ -2263,4 +2383,6 @@ START_TEST(shlfileop) clean_after_shfo_tests(); test_unicode(); + + test_shlmenu(); } From 78dce7419ff026cf11aa94d9fd082a533b37a0bd Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 4 Mar 2010 21:16:09 +0000 Subject: [PATCH 092/211] [PSDK] - Update RPC includes to Wine-1.1.39. svn path=/trunk/; revision=45843 --- reactos/dll/win32/rpcrt4/rpc_transport.c | 2 +- reactos/include/psdk/rpcdce.h | 33 ++++++++++++++++++++-- reactos/include/psdk/rpcndr.h | 36 +++++++++++++----------- reactos/include/reactos/wine/rpcfc.h | 1 + 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/reactos/dll/win32/rpcrt4/rpc_transport.c b/reactos/dll/win32/rpcrt4/rpc_transport.c index 735a19df648..b9077a3dc1a 100644 --- a/reactos/dll/win32/rpcrt4/rpc_transport.c +++ b/reactos/dll/win32/rpcrt4/rpc_transport.c @@ -207,7 +207,7 @@ static RPC_STATUS rpcrt4_conn_open_pipe(RpcConnection *Connection, LPCSTR pname, dwFlags |= SECURITY_DELEGATION; break; } - if (Connection->QOS->qos->IdentityTracking == RPC_C_QOS_IDENTIFY_DYNAMIC) + if (Connection->QOS->qos->IdentityTracking == RPC_C_QOS_IDENTITY_DYNAMIC) dwFlags |= SECURITY_CONTEXT_TRACKING; } pipe = CreateFileA(pname, GENERIC_READ|GENERIC_WRITE, 0, NULL, diff --git a/reactos/include/psdk/rpcdce.h b/reactos/include/psdk/rpcdce.h index 9486a35f1f5..439f16483aa 100644 --- a/reactos/include/psdk/rpcdce.h +++ b/reactos/include/psdk/rpcdce.h @@ -108,6 +108,11 @@ typedef I_RPC_HANDLE *RPC_EP_INQ_HANDLE; #define RPC_C_LISTEN_MAX_CALLS_DEFAULT 1234 #define RPC_C_PROTSEQ_MAX_REQS_DEFAULT 10 +#define RPC_PROTSEQ_TCP 0x1 +#define RPC_PROTSEQ_NMP 0x2 +#define RPC_PROTSEQ_LRPC 0x3 +#define RPC_PROTSEQ_HTTP 0x4 + /* RPC_POLICY EndpointFlags */ #define RPC_C_BIND_TO_ALL_NICS 0x1 #define RPC_C_USE_INTERNET_PORT 0x1 @@ -158,8 +163,8 @@ typedef I_RPC_HANDLE *RPC_EP_INQ_HANDLE; #define RPC_C_IMP_LEVEL_DELEGATE 4 /* values for RPC_SECURITY_QOS*::IdentityTracking */ -#define RPC_C_QOS_IDENTIFY_STATIC 0 -#define RPC_C_QOS_IDENTIFY_DYNAMIC 1 +#define RPC_C_QOS_IDENTITY_STATIC 0 +#define RPC_C_QOS_IDENTITY_DYNAMIC 1 /* flags for RPC_SECURITY_QOS*::Capabilities */ #define RPC_C_QOS_CAPABILITIES_DEFAULT 0x0 @@ -190,7 +195,7 @@ typedef I_RPC_HANDLE *RPC_EP_INQ_HANDLE; #define RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE 0x10 typedef RPC_STATUS RPC_ENTRY RPC_IF_CALLBACK_FN( RPC_IF_HANDLE InterfaceUuid, void *Context ); -typedef void (__RPC_USER *RPC_AUTH_KEY_RETRIEVAL_FN)( void *Arg, unsigned char *ServerPrincName, unsigned long KeyVer, void **Key, RPC_STATUS *Status ); +typedef void (__RPC_USER *RPC_AUTH_KEY_RETRIEVAL_FN)(void *, RPC_WSTR, ULONG, void **, RPC_STATUS *); typedef struct _RPC_POLICY { @@ -504,6 +509,28 @@ RPCRTAPI RPC_STATUS RPC_ENTRY ULONG *AuthnSvc, RPC_AUTH_IDENTITY_HANDLE *AuthIdentity, ULONG *AuthzSvc ); #define RpcBindingInqAuthInfo WINELIB_NAME_AW(RpcBindingInqAuthInfo) +RPCRTAPI RPC_STATUS RPC_ENTRY + RpcBindingInqAuthClientA( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *Privs, + RPC_CSTR *ServerPrincName, ULONG *AuthnLevel, ULONG *AuthnSvc, + ULONG *AuthzSvc ); + +RPCRTAPI RPC_STATUS RPC_ENTRY + RpcBindingInqAuthClientW( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *Privs, + RPC_WSTR *ServerPrincName, ULONG *AuthnLevel, ULONG *AuthnSvc, + ULONG *AuthzSvc ); +#define RpcBindingInqAuthClient WINELIB_NAME_AW(RpcBindingInqAuthClient) + +RPCRTAPI RPC_STATUS RPC_ENTRY + RpcBindingInqAuthClientExA( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *Privs, + RPC_CSTR *ServerPrincName, ULONG *AuthnLevel, ULONG *AuthnSvc, + ULONG *AuthzSvc, ULONG Flags ); + +RPCRTAPI RPC_STATUS RPC_ENTRY + RpcBindingInqAuthClientExW( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *Privs, + RPC_WSTR *ServerPrincName, ULONG *AuthnLevel, ULONG *AuthnSvc, + ULONG *AuthzSvc, ULONG Flags ); +#define RpcBindingInqAuthClientEx WINELIB_NAME_AW(RpcBindingInqAuthClientEx) + RPCRTAPI RPC_STATUS RPC_ENTRY RpcCancelThread(void*); RPCRTAPI RPC_STATUS RPC_ENTRY RpcCancelThreadEx(void*,LONG); diff --git a/reactos/include/psdk/rpcndr.h b/reactos/include/psdk/rpcndr.h index 9d0df1ae2aa..9691dba9ecd 100644 --- a/reactos/include/psdk/rpcndr.h +++ b/reactos/include/psdk/rpcndr.h @@ -104,8 +104,8 @@ extern "C" { #define small char typedef unsigned char byte; -#define hyper __int64 -#define MIDL_uhyper unsigned __int64 +typedef INT64 hyper; +typedef UINT64 MIDL_uhyper; typedef unsigned char boolean; #define __RPC_CALLEE WINAPI @@ -128,7 +128,7 @@ typedef unsigned char boolean; (RpcExceptionCode() == RPC_X_BAD_STUB_DATA) || \ (RpcExceptionCode() == RPC_S_INVALID_BOUND)) -typedef struct _NDR_SCONTEXT +typedef struct { void *pad[2]; void *userContext; @@ -211,19 +211,19 @@ typedef struct _MIDL_STUB_MESSAGE struct _FULL_PTR_XLAT_TABLES *FullPtrXlatTables; ULONG FullPtrRefId; ULONG PointerLength; - int fInDontFree:1; - int fDontCallFreeInst:1; - int fInOnlyParam:1; - int fHasReturn:1; - int fHasExtensions:1; - int fHasNewCorrDesc:1; - int fIsIn:1; - int fIsOut:1; - int fIsOicf:1; - int fBufferValid:1; - int fHasMemoryValidateCallback:1; - int fInFree:1; - int fNeedMCCP:1; + unsigned int fInDontFree:1; + unsigned int fDontCallFreeInst:1; + unsigned int fInOnlyParam:1; + unsigned int fHasReturn:1; + unsigned int fHasExtensions:1; + unsigned int fHasNewCorrDesc:1; + unsigned int fIsIn:1; + unsigned int fIsOut:1; + unsigned int fIsOicf:1; + unsigned int fBufferValid:1; + unsigned int fHasMemoryValidateCallback:1; + unsigned int fInFree:1; + unsigned int fNeedMCCP:1; int fUnused:3; int fUnused2:16; DWORD dwDestContext; @@ -390,7 +390,11 @@ typedef struct _MIDL_SYNTAX_INFO typedef void (__RPC_API *STUB_THUNK)( PMIDL_STUB_MESSAGE ); +#ifdef WINE_STRICT_PROTOTYPES +typedef LONG (__RPC_API *SERVER_ROUTINE)(void); +#else typedef LONG (__RPC_API *SERVER_ROUTINE)(); +#endif typedef struct _MIDL_SERVER_INFO_ { diff --git a/reactos/include/reactos/wine/rpcfc.h b/reactos/include/reactos/wine/rpcfc.h index ee7ba7fb1ff..53dd1633087 100644 --- a/reactos/include/reactos/wine/rpcfc.h +++ b/reactos/include/reactos/wine/rpcfc.h @@ -167,6 +167,7 @@ #define RPC_FC_PROC_OIF_OBJECT 0x04 #define RPC_FC_PROC_OIF_RPCFLAGS 0x08 #define RPC_FC_PROC_OIF_OBJ_V2 0x20 +#define RPC_FC_PROC_OIF_HAS_COMM_OR_FAULT 0x20 #define RPC_FC_PROC_OIF_NEWINIT 0x40 #define RPC_FC_PROC_PF_MUSTSIZE 0x0001 From 3a4617cfcb14be68a44b37b17227fbbb72e568e2 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 4 Mar 2010 21:53:12 +0000 Subject: [PATCH 093/211] - Implement VideoPortIsNoVesa svn path=/trunk/; revision=45844 --- reactos/drivers/video/videoprt/videoprt.c | 96 ++++++++++++++++++++ reactos/drivers/video/videoprt/videoprt.spec | 1 + 2 files changed, 97 insertions(+) diff --git a/reactos/drivers/video/videoprt/videoprt.c b/reactos/drivers/video/videoprt/videoprt.c index 6d106f62015..0d85bb559e7 100644 --- a/reactos/drivers/video/videoprt/videoprt.c +++ b/reactos/drivers/video/videoprt/videoprt.c @@ -1417,3 +1417,99 @@ VideoPortAllocateContiguousMemory( return MmAllocateContiguousMemory(NumberOfBytes, HighestAcceptableAddress); } + +/* + * @implemented + */ +BOOLEAN NTAPI +VideoPortIsNoVesa(VOID) +{ + NTSTATUS Status; + HANDLE KeyHandle; + UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control"); + UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions"); + OBJECT_ATTRIBUTES ObjectAttributes; + PKEY_VALUE_PARTIAL_INFORMATION KeyInfo; + ULONG Length, NewLength; + + /* Initialize object attributes with the path we want */ + InitializeObjectAttributes(&ObjectAttributes, + &Path, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* Open the key */ + Status = ZwOpenKey(&KeyHandle, + KEY_QUERY_VALUE, + &ObjectAttributes); + + if (!NT_SUCCESS(Status)) + { + VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status); + return FALSE; + } + + /* Find out how large our buffer should be */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + NULL, + 0, + &Length); + if (Status != STATUS_BUFFER_OVERFLOW && Status != STATUS_BUFFER_TOO_SMALL) + { + VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); + ZwClose(KeyHandle); + return FALSE; + } + + /* Allocate it */ + KeyInfo = ExAllocatePool(PagedPool, Length); + if (!KeyInfo) + { + VideoPortDebugPrint(Error, "Out of memory\n"); + ZwClose(KeyHandle); + return FALSE; + } + + /* Now for real this time */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + KeyInfo, + Length, + &NewLength); + + ZwClose(KeyHandle); + + if (!NT_SUCCESS(Status)) + { + VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); + ExFreePool(KeyInfo); + return FALSE; + } + + /* Sanity check */ + if (KeyInfo->Type != REG_SZ) + { + VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n"); + ExFreePool(KeyInfo); + return FALSE; + } + + /* Check if NOVESA is present in the start options */ + if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA")) + { + VideoPortDebugPrint(Info, "VESA mode disabled\n"); + ExFreePool(KeyInfo); + return TRUE; + } + + ExFreePool(KeyInfo); + + VideoPortDebugPrint(Info, "VESA mode enabled\n"); + + return FALSE; +} + diff --git a/reactos/drivers/video/videoprt/videoprt.spec b/reactos/drivers/video/videoprt/videoprt.spec index e07ce343e63..9d5147636fe 100644 --- a/reactos/drivers/video/videoprt/videoprt.spec +++ b/reactos/drivers/video/videoprt/videoprt.spec @@ -47,6 +47,7 @@ @ fastcall VideoPortInterlockedDecrement(ptr) NTOSKRNL.InterlockedDecrement @ fastcall VideoPortInterlockedExchange(ptr long) NTOSKRNL.InterlockedExchange @ fastcall VideoPortInterlockedIncrement(ptr) NTOSKRNL.InterlockedIncrement +@ stdcall VideoPortIsNoVesa() @ stdcall VideoPortLockBuffer(ptr ptr long long) @ stdcall VideoPortLockPages(ptr ptr ptr ptr long) @ stdcall VideoPortLogError(ptr ptr long long) From 69f20a953b5304fa54823d4d6807ee73ecea43aa Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 4 Mar 2010 22:05:34 +0000 Subject: [PATCH 094/211] [RTL] - Fix Samuel's mistake of assuming that xmlstrs are zero-terminated by adding a xmlstr2unicode function, which returns a UNICODE_STRING representation of xmlstr suitable for printing. No debug log garbage now (disadvantage: more code changes compared to the original code). svn path=/trunk/; revision=45845 --- reactos/lib/rtl/actctx.c | 132 +++++++++++++++++++++++++++++---------- 1 file changed, 98 insertions(+), 34 deletions(-) diff --git a/reactos/lib/rtl/actctx.c b/reactos/lib/rtl/actctx.c index 38cbbbf64c7..896d1fbf069 100644 --- a/reactos/lib/rtl/actctx.c +++ b/reactos/lib/rtl/actctx.c @@ -234,6 +234,16 @@ static WCHAR *xmlstrdupW(const xmlstr_t* str) return strW; } +static UNICODE_STRING xmlstr2unicode(const xmlstr_t *xmlstr) +{ + UNICODE_STRING res; + + res.Buffer = (PWSTR)xmlstr->ptr; + res.Length = res.MaximumLength = xmlstr->len; + + return res; +} + static inline BOOL xmlstr_cmp(const xmlstr_t* xmlstr, const WCHAR *str) { return !strncmpW(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len]; @@ -732,6 +742,7 @@ static BOOL parse_version(const xmlstr_t *str, struct assembly_version *version) unsigned int ver[4]; unsigned int pos; const WCHAR *curr; + UNICODE_STRING strU; /* major.minor.build.revision */ ver[0] = ver[1] = ver[2] = ver[3] = pos = 0; @@ -755,28 +766,34 @@ static BOOL parse_version(const xmlstr_t *str, struct assembly_version *version) return TRUE; error: - DPRINT1( "Wrong version definition in manifest file (%S)\n", str->ptr ); + strU = xmlstr2unicode(str); + DPRINT1( "Wrong version definition in manifest file (%wZ)\n", &strU ); return FALSE; } static BOOL parse_expect_elem(xmlbuf_t* xmlbuf, const WCHAR* name) { xmlstr_t elem; + UNICODE_STRING elemU; if (!next_xml_elem(xmlbuf, &elem)) return FALSE; if (xmlstr_cmp(&elem, name)) return TRUE; - DPRINT1( "unexpected element %S\n", elem.ptr ); + elemU = xmlstr2unicode(&elem); + DPRINT1( "unexpected element %wZ\n", &elemU ); return FALSE; } static BOOL parse_expect_no_attr(xmlbuf_t* xmlbuf, BOOL* end) { xmlstr_t attr_name, attr_value; + UNICODE_STRING attr_nameU, attr_valueU; BOOL error; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, end)) { - DPRINT1( "unexpected attr %S=%S\n", attr_name.ptr, - attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_name); + DPRINT1( "unexpected attr %S=%S\n", &attr_nameU, + &attr_valueU); } return !error; } @@ -790,10 +807,12 @@ static BOOL parse_end_element(xmlbuf_t *xmlbuf) static BOOL parse_expect_end_elem(xmlbuf_t *xmlbuf, const WCHAR *name) { xmlstr_t elem; + UNICODE_STRING elemU; if (!next_xml_elem(xmlbuf, &elem)) return FALSE; if (!xmlstr_cmp_end(&elem, name)) { - DPRINT1( "unexpected element %S\n", elem.ptr ); + elemU = xmlstr2unicode(&elem); + DPRINT1( "unexpected element %wZ\n", &elemU ); return FALSE; } return parse_end_element(xmlbuf); @@ -824,6 +843,7 @@ static BOOL parse_assembly_identity_elem(xmlbuf_t* xmlbuf, ACTIVATION_CONTEXT* a { xmlstr_t attr_name, attr_value; BOOL end = FALSE, error; + UNICODE_STRING attr_valueU, attr_nameU; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { @@ -849,14 +869,15 @@ static BOOL parse_assembly_identity_elem(xmlbuf_t* xmlbuf, ACTIVATION_CONTEXT* a } else if (xmlstr_cmp(&attr_name, languageW)) { - DPRINT1("Unsupported yet language attribute (%S)\n", - attr_value.ptr); if (!(ai->language = xmlstrdupW(&attr_value))) return FALSE; + DPRINT1("Unsupported yet language attribute (%S)\n", + ai->language); } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, - attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -869,6 +890,7 @@ static BOOL parse_com_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) xmlstr_t elem, attr_name, attr_value; BOOL ret, end = FALSE, error; struct entity* entity; + UNICODE_STRING attr_valueU, attr_nameU; if (!(entity = add_entity(&dll->entities, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION))) return FALSE; @@ -881,7 +903,9 @@ static BOOL parse_com_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -896,7 +920,8 @@ static BOOL parse_com_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown elem %S\n", elem.ptr); + attr_nameU = xmlstr2unicode(&elem); + DPRINT1("unknown elem %wZ\n", &attr_nameU); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -908,6 +933,7 @@ static BOOL parse_cominterface_proxy_stub_elem(xmlbuf_t* xmlbuf, struct dll_redi xmlstr_t attr_name, attr_value; BOOL end = FALSE, error; struct entity* entity; + UNICODE_STRING attr_valueU, attr_nameU; if (!(entity = add_entity(&dll->entities, ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION))) return FALSE; @@ -924,7 +950,9 @@ static BOOL parse_cominterface_proxy_stub_elem(xmlbuf_t* xmlbuf, struct dll_redi } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -937,6 +965,7 @@ static BOOL parse_typelib_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) xmlstr_t attr_name, attr_value; BOOL end = FALSE, error; struct entity* entity; + UNICODE_STRING attr_valueU, attr_nameU; if (!(entity = add_entity(&dll->entities, ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION))) return FALSE; @@ -957,7 +986,9 @@ static BOOL parse_typelib_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr , attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -970,6 +1001,7 @@ static BOOL parse_window_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) xmlstr_t elem, content; BOOL end = FALSE, ret = TRUE; struct entity* entity; + UNICODE_STRING elemU; if (!(entity = add_entity(&dll->entities, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION))) return FALSE; @@ -990,7 +1022,8 @@ static BOOL parse_window_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown elem %S\n", elem.ptr); + elemU = xmlstr2unicode(&elem); + DPRINT1("unknown elem %wZ\n", &elemU); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1001,21 +1034,25 @@ static BOOL parse_window_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) static BOOL parse_binding_redirect_elem(xmlbuf_t* xmlbuf) { xmlstr_t attr_name, attr_value; + UNICODE_STRING attr_valueU, attr_nameU; BOOL end = FALSE, error; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + if (xmlstr_cmp(&attr_name, oldVersionW)) { - DPRINT1("Not stored yet oldVersion=%S\n", attr_value.ptr); + DPRINT1("Not stored yet oldVersion=%wZ\n", &attr_valueU); } else if (xmlstr_cmp(&attr_name, newVersionW)) { - DPRINT1("Not stored yet newVersion=%S\n", attr_value.ptr); + DPRINT1("Not stored yet newVersion=%wZ\n", &attr_valueU); } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1026,13 +1063,15 @@ static BOOL parse_binding_redirect_elem(xmlbuf_t* xmlbuf) static BOOL parse_description_elem(xmlbuf_t* xmlbuf) { xmlstr_t elem, content; + UNICODE_STRING elemU; BOOL end = FALSE, ret = TRUE; if (!parse_expect_no_attr(xmlbuf, &end) || end || !parse_text_content(xmlbuf, &content)) return FALSE; - DPRINT("Got description %S\n", content.ptr); + elemU = xmlstr2unicode(&content); + DPRINT("Got description %wZ\n", &elemU); while (ret && (ret = next_xml_elem(xmlbuf, &elem))) { @@ -1043,7 +1082,8 @@ static BOOL parse_description_elem(xmlbuf_t* xmlbuf) } else { - DPRINT1("unknown elem %S\n", elem.ptr); + elemU = xmlstr2unicode(&elem); + DPRINT1("unknown elem %wZ\n", &elemU); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1084,6 +1124,7 @@ static BOOL parse_com_interface_external_proxy_stub_elem(xmlbuf_t* xmlbuf, static BOOL parse_clr_class_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { xmlstr_t attr_name, attr_value; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, error; struct entity* entity; @@ -1102,7 +1143,9 @@ static BOOL parse_clr_class_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1113,6 +1156,7 @@ static BOOL parse_clr_class_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) static BOOL parse_clr_surrogate_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { xmlstr_t attr_name, attr_value; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, error; struct entity* entity; @@ -1131,7 +1175,9 @@ static BOOL parse_clr_surrogate_elem(xmlbuf_t* xmlbuf, struct assembly* assembly } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1181,19 +1227,23 @@ static BOOL parse_dependent_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader static BOOL parse_dependency_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl) { xmlstr_t attr_name, attr_value, elem; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, ret = TRUE, error, optional = FALSE; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + if (xmlstr_cmp(&attr_name, optionalW)) { static const WCHAR yesW[] = {'y','e','s',0}; optional = xmlstr_cmpi( &attr_value, yesW ); - DPRINT1("optional=%S\n", attr_value.ptr); + DPRINT1("optional=%wZ\n", &attr_valueU); } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1210,7 +1260,8 @@ static BOOL parse_dependency_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl) } else { - DPRINT1("unknown element %S\n", elem.ptr); + attr_nameU = xmlstr2unicode(&elem); + DPRINT1("unknown element %wZ\n", &attr_nameU); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1237,6 +1288,7 @@ static BOOL parse_noinheritable_elem(xmlbuf_t* xmlbuf) static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { xmlstr_t attr_name, attr_value, elem; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, error, ret = TRUE; struct dll_redirect* dll; @@ -1244,10 +1296,13 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + if (xmlstr_cmp(&attr_name, nameW)) { if (!(dll->name = xmlstrdupW(&attr_value))) return FALSE; - DPRINT("name=%S\n", attr_value.ptr); + DPRINT("name=%wZ\n", &attr_valueU); } else if (xmlstr_cmp(&attr_name, hashW)) { @@ -1257,11 +1312,11 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { static const WCHAR sha1W[] = {'S','H','A','1',0}; if (!xmlstr_cmpi(&attr_value, sha1W)) - DPRINT1("hashalg should be SHA1, got %S\n", attr_value.ptr); + DPRINT1("hashalg should be SHA1, got %wZ\n", &attr_valueU); } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1298,7 +1353,8 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) } else { - DPRINT1("unknown elem %S\n", elem.ptr); + attr_nameU = xmlstr2unicode(&elem); + DPRINT1("unknown elem %wZ\n", &attr_nameU); ret = parse_unknown_elem( xmlbuf, &elem ); } } @@ -1311,16 +1367,20 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, struct assembly_identity* expected_ai) { xmlstr_t attr_name, attr_value, elem; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, error, version = FALSE, xmlns = FALSE, ret = TRUE; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + if (xmlstr_cmp(&attr_name, manifestVersionW)) { static const WCHAR v10W[] = {'1','.','0',0}; if (!xmlstr_cmp(&attr_value, v10W)) { - DPRINT1("wrong version %S\n", attr_value.ptr); + DPRINT1("wrong version %wZ\n", &attr_valueU); return FALSE; } version = TRUE; @@ -1329,14 +1389,14 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, { if (!xmlstr_cmp(&attr_value, manifestv1W) && !xmlstr_cmp(&attr_value, manifestv3W)) { - DPRINT1("wrong namespace %S\n", attr_value.ptr); + DPRINT1("wrong namespace %wZ\n", &attr_valueU); return FALSE; } xmlns = TRUE; } else { - DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1421,7 +1481,8 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, } else { - DPRINT1("unknown element %S\n", elem.ptr); + attr_nameU = xmlstr2unicode(&elem); + DPRINT1("unknown element %wZ\n", &attr_nameU); ret = parse_unknown_elem(xmlbuf, &elem); } if (ret) ret = next_xml_elem(xmlbuf, &elem); @@ -1434,6 +1495,7 @@ static NTSTATUS parse_manifest_buffer( struct actctx_loader* acl, struct assembl struct assembly_identity* ai, xmlbuf_t *xmlbuf ) { xmlstr_t elem; + UNICODE_STRING elemU; if (!next_xml_elem(xmlbuf, &elem)) return STATUS_SXS_CANT_GEN_ACTCTX; @@ -1443,7 +1505,8 @@ static NTSTATUS parse_manifest_buffer( struct actctx_loader* acl, struct assembl if (!xmlstr_cmp(&elem, assemblyW)) { - DPRINT1("root element is %S, not \n", elem.ptr); + elemU = xmlstr2unicode(&elem); + DPRINT1("root element is %wZ, not \n", &elemU); return STATUS_SXS_CANT_GEN_ACTCTX; } @@ -1455,7 +1518,8 @@ static NTSTATUS parse_manifest_buffer( struct actctx_loader* acl, struct assembl if (next_xml_elem(xmlbuf, &elem)) { - DPRINT1("unexpected element %S\n", elem.ptr); + elemU = xmlstr2unicode(&elem); + DPRINT1("unexpected element %wZ\n", &elemU); return STATUS_SXS_CANT_GEN_ACTCTX; } From ea385f2fe4c0c2cd4876c6e7c22a811692058a37 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 4 Mar 2010 23:25:30 +0000 Subject: [PATCH 095/211] - [User32] Sync controls to wine 1.1.39. svn path=/trunk/; revision=45847 --- reactos/dll/win32/user32/controls/button.c | 42 ++- reactos/dll/win32/user32/controls/combo.c | 3 - reactos/dll/win32/user32/controls/icontitle.c | 2 - reactos/dll/win32/user32/controls/listbox.c | 268 +----------------- reactos/dll/win32/user32/controls/scrollbar.c | 47 +-- reactos/dll/win32/user32/controls/static.c | 109 +++---- reactos/include/psdk/winuser.h | 7 +- reactos/media/doc/README.WINE | 12 +- 8 files changed, 117 insertions(+), 373 deletions(-) diff --git a/reactos/dll/win32/user32/controls/button.c b/reactos/dll/win32/user32/controls/button.c index 4eb8bc66547..1f448bd1885 100644 --- a/reactos/dll/win32/user32/controls/button.c +++ b/reactos/dll/win32/user32/controls/button.c @@ -102,8 +102,6 @@ static void GB_Paint( HWND hwnd, HDC hDC, UINT action ); static void UB_Paint( HWND hwnd, HDC hDC, UINT action ); static void OB_Paint( HWND hwnd, HDC hDC, UINT action ); static void BUTTON_CheckAutoRadioButton( HWND hwnd ); -//static LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); -//static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); #define MAX_BTN_TYPE 12 @@ -291,6 +289,13 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, } if (btn_type >= MAX_BTN_TYPE) return -1; /* abort */ + + /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */ + if (btn_type == BS_USERBUTTON ) + { + style = (style & ~0x0f) | BS_PUSHBUTTON; + SetWindowLongPtrW( hWnd, GWL_STYLE, style ); + } set_button_state( hWnd, BUTTON_UNCHECKED ); button_update_uistate( hWnd, unicode ); return 0; @@ -474,9 +479,6 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, InvalidateRect( hWnd, NULL, FALSE ); break; -#ifndef __REACTOS__ - case BM_SETSTYLE16: -#endif case BM_SETSTYLE: if ((wParam & 0x0f) >= MAX_BTN_TYPE) break; btn_type = wParam & 0x0f; @@ -485,7 +487,7 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, /* Only redraw if lParam flag is set.*/ if (lParam) - paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); + InvalidateRect( hWnd, NULL, TRUE ); break; @@ -514,15 +516,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, case BM_GETIMAGE: return GetWindowLongPtrW( hWnd, HIMAGE_GWL_OFFSET ); -#ifndef __REACTOS__ - case BM_GETCHECK16: -#endif case BM_GETCHECK: return get_button_state( hWnd ) & 3; -#ifndef __REACTOS__ - case BM_SETCHECK16: -#endif case BM_SETCHECK: if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type]; state = get_button_state( hWnd ); @@ -541,15 +537,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, BUTTON_CheckAutoRadioButton( hWnd ); break; -#ifndef __REACTOS__ - case BM_GETSTATE16: -#endif case BM_GETSTATE: return get_button_state( hWnd ); -#ifndef __REACTOS__ - case BM_SETSTATE16: -#endif case BM_SETSTATE: state = get_button_state( hWnd ); if (wParam) @@ -871,9 +861,15 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) if (get_button_type(style) == BS_DEFPUSHBUTTON) { - Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); + if (action != ODA_FOCUS) + Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); InflateRect( &rc, -1, -1 ); } + + focus_rect = rc; + + /* completely skip the drawing if only focus has changed */ + if (action == ODA_FOCUS) goto draw_focus; uState = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT; @@ -892,8 +888,6 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) DrawFrameControl( hDC, &rc, DFC_BUTTON, uState ); - focus_rect = rc; - /* draw button label */ r = rc; dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r); @@ -912,7 +906,9 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) SetTextColor( hDC, oldTxtColor ); - if (state & BUTTON_HASFOCUS) +draw_focus: + if ((action == ODA_FOCUS) || + ((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS))) { if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) { @@ -1165,6 +1161,8 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action ) if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) DrawFocusRect( hDC, &rc ); } + + BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT ); } diff --git a/reactos/dll/win32/user32/controls/combo.c b/reactos/dll/win32/user32/controls/combo.c index 99193b17a07..2a7ab1822b9 100644 --- a/reactos/dll/win32/user32/controls/combo.c +++ b/reactos/dll/win32/user32/controls/combo.c @@ -74,9 +74,6 @@ static UINT CBitHeight, CBitWidth; #define COMBO_EDITBUTTONSPACE() 0 #define EDIT_CONTROL_PADDING() 1 -//static LRESULT WINAPI ComboWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); -//static LRESULT WINAPI ComboWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); - /********************************************************************* * combo class descriptor */ diff --git a/reactos/dll/win32/user32/controls/icontitle.c b/reactos/dll/win32/user32/controls/icontitle.c index 01231cdd03c..465a1a40ca4 100644 --- a/reactos/dll/win32/user32/controls/icontitle.c +++ b/reactos/dll/win32/user32/controls/icontitle.c @@ -30,8 +30,6 @@ static BOOL bMultiLineTitle; static HFONT hIconTitleFont; -//static LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); - /********************************************************************* * icon title class descriptor */ diff --git a/reactos/dll/win32/user32/controls/listbox.c b/reactos/dll/win32/user32/controls/listbox.c index d46c1bb81ba..0f66305a285 100644 --- a/reactos/dll/win32/user32/controls/listbox.c +++ b/reactos/dll/win32/user32/controls/listbox.c @@ -40,13 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(listbox); /* Start of hack section -------------------------------- */ -typedef short *LPINT16; - -BOOL is_old_app(HWND hwnd) -{ - return FALSE; -} - #define WM_LBTRACKPOINT 0x0131 #define WS_EX_DRAGDETECT 0x00000002L #define WM_BEGINDRAG 0x022C @@ -105,7 +98,7 @@ typedef struct HFONT font; /* Current font */ LCID locale; /* Current locale for string comparisons */ LPHEADCOMBO lphc; /* ComboLBox */ - LONG UIState; + LONG UIState; // REACTOS } LB_DESCR; @@ -138,9 +131,6 @@ typedef enum static TIMER_DIRECTION LISTBOX_Timer = LB_TIMER_NONE; -//static LRESULT WINAPI ListBoxWndProcA( HWND hwnd, UINT msg, WPARAM wParam,LPARAM lParam ); -//static LRESULT WINAPI ListBoxWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); - static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT *rect ); /********************************************************************* @@ -174,14 +164,6 @@ const struct builtin_class_descr COMBOLBOX_builtin_class = 0 /* brush */ }; -#ifndef __REACTOS__ -/* check whether app is a Win 3.1 app */ -static inline BOOL is_old_app( LB_DESCR *descr ) -{ - return (GetExpWinVer16( GetWindowLongPtrW(descr->self, GWLP_HINSTANCE) ) & 0xFF00 ) == 0x0300; -} -#endif - /*********************************************************************** * LISTBOX_GetCurrentPageSize @@ -409,16 +391,6 @@ static void LISTBOX_UpdateSize( LB_DESCR *descr ) remaining = 0; if ((descr->height > descr->item_height) && remaining) { -#ifndef __REACTOS__ - if (is_old_app(descr)) - { /* give a margin for error to 16 bits programs - if we need - less than the height of the nonclient area, round to the - *next* number of items */ - int ncheight = rect.bottom - rect.top - descr->height; - if ((descr->item_height - remaining) <= ncheight) - remaining = remaining - descr->item_height; - } -#endif TRACE("[%p]: changing height %d -> %d\n", descr->self, descr->height, descr->height - remaining ); SetWindowPos( descr->self, 0, 0, 0, rect.right - rect.left, @@ -565,10 +537,10 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, if (!item) { if (action == ODA_FOCUS) - { - if (!(descr->UIState & UISF_HIDEFOCUS)) - DrawFocusRect( hdc, rect ); - } + { // REACTOS + if (!(descr->UIState & UISF_HIDEFOCUS)) + DrawFocusRect( hdc, rect ); + } // else ERR("called with an out of bounds index %d(%d) in owner draw, Not good.\n",index,descr->nb_items); return; @@ -608,7 +580,7 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, if (action == ODA_FOCUS) { - if (!(descr->UIState & UISF_HIDEFOCUS)) + if (!(descr->UIState & UISF_HIDEFOCUS)) // REACTOS DrawFocusRect( hdc, rect ); return; } @@ -771,7 +743,7 @@ static LRESULT LISTBOX_InitStorage( LB_DESCR *descr, INT nb_items ) /*********************************************************************** * LISTBOX_SetTabStops */ -static BOOL LISTBOX_SetTabStops( LB_DESCR *descr, INT count, LPINT tabs, BOOL short_ints ) +static BOOL LISTBOX_SetTabStops( LB_DESCR *descr, INT count, LPINT tabs ) { INT i; @@ -790,23 +762,7 @@ static BOOL LISTBOX_SetTabStops( LB_DESCR *descr, INT count, LPINT tabs, BOOL sh if (!(descr->tabs = HeapAlloc( GetProcessHeap(), 0, descr->nb_tabs * sizeof(INT) ))) return FALSE; -#ifndef __REACTOS__ - if (short_ints) - { - INT i; - LPINT16 p = (LPINT16)tabs; - - TRACE("[%p]: settabstops ", descr->self ); - for (i = 0; i < descr->nb_tabs; i++) { - descr->tabs[i] = *p++<<1; /* FIXME */ - TRACE("%hd ", descr->tabs[i]); - } - TRACE("\n"); - } - else memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) ); -#else - memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) ); -#endif + memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) ); /* convert into "dialog units"*/ for (i = 0; i < descr->nb_tabs; i++) @@ -1049,23 +1005,6 @@ static LRESULT LISTBOX_GetSelCount( const LB_DESCR *descr ) } -#ifndef __REACTOS__ -/*********************************************************************** - * LISTBOX_GetSelItems16 - */ -static LRESULT LISTBOX_GetSelItems16( const LB_DESCR *descr, INT16 max, LPINT16 array ) -{ - INT i, count; - const LB_ITEMDATA *item = descr->items; - - if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR; - for (i = count = 0; (i < descr->nb_items) && (count < max); i++, item++) - if (item->selected) array[count++] = (INT16)i; - return count; -} -#endif - - /*********************************************************************** * LISTBOX_GetSelItems */ @@ -1595,15 +1534,8 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index, /* We need to grow the array */ max_items += LB_ARRAY_GRANULARITY; if (descr->items) - { item = HeapReAlloc( GetProcessHeap(), 0, descr->items, max_items * sizeof(LB_ITEMDATA) ); - if (!item) - { - SEND_NOTIFICATION( descr, LBN_ERRSPACE ); - return LB_ERRSPACE; - } - } else item = HeapAlloc( GetProcessHeap(), 0, max_items * sizeof(LB_ITEMDATA) ); @@ -2166,7 +2098,7 @@ static LRESULT LISTBOX_HandleLButtonDown( LB_DESCR *descr, DWORD keys, INT x, IN } if (!descr->lphc) - { + { // See rev 40864 use Ptr for 64 bit. if (GetWindowLongPtrW( descr->self, GWL_EXSTYLE ) & WS_EX_DRAGDETECT) { POINT pt; @@ -2539,7 +2471,7 @@ static LRESULT LISTBOX_HandleChar( LB_DESCR *descr, WCHAR charW ) return 0; } -/* Retrieve the UI state for the control */ +/* ReactOS Retrieve the UI state for the control */ static BOOL LISTBOX_update_uistate(LB_DESCR *descr) { LONG prev_flags; @@ -2589,18 +2521,6 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) descr->locale = GetUserDefaultLCID(); descr->lphc = lphc; -#ifndef __REACTOS__ - if (is_old_app(descr) && ( descr->style & ( WS_VSCROLL | WS_HSCROLL ) ) ) - { - /* Win95 document "List Box Differences" from MSDN: - If a list box in a version 3.x application has either the - WS_HSCROLL or WS_VSCROLL style, the list box receives both - horizontal and vertical scroll bars. - */ - descr->style |= WS_VSCROLL | WS_HSCROLL; - } -#endif - if( lphc ) { TRACE("[%p]: resetting owner %p -> %p\n", descr->self, descr->owner, lphc->self ); @@ -2609,7 +2529,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) SetWindowLongPtrW( descr->self, 0, (LONG_PTR)descr ); - LISTBOX_update_uistate(descr); + LISTBOX_update_uistate(descr); // ReactOS /* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY; */ @@ -2689,20 +2609,12 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, switch(msg) { -#ifndef __REACTOS__ - case LB_RESETCONTENT16: -#endif case LB_RESETCONTENT: LISTBOX_ResetContent( descr ); LISTBOX_UpdateScroll( descr ); InvalidateRect( descr->self, NULL, TRUE ); return 0; -#ifndef __REACTOS__ - case LB_ADDSTRING16: - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_ADDSTRING: case LB_ADDSTRING_LOWER: case LB_ADDSTRING_UPPER: @@ -2733,12 +2645,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_INSERTSTRING16: - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - wParam = (INT)(INT16)wParam; - /* fall through */ -#endif case LB_INSERTSTRING: case LB_INSERTSTRING_UPPER: case LB_INSERTSTRING_LOWER: @@ -2768,11 +2674,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_ADDFILE16: - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_ADDFILE: { INT ret; @@ -2795,9 +2696,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_DELETESTRING16: -#endif case LB_DELETESTRING: if (LISTBOX_RemoveItem( descr, wParam) != LB_ERR) return descr->nb_items; @@ -2807,9 +2705,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return LB_ERR; } -#ifndef __REACTOS__ - case LB_GETITEMDATA16: -#endif case LB_GETITEMDATA: if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) { @@ -2818,9 +2713,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, } return descr->items[wParam].data; -#ifndef __REACTOS__ - case LB_SETITEMDATA16: -#endif case LB_SETITEMDATA: if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) { @@ -2831,24 +2723,12 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, /* undocumented: returns TRUE, not LB_OKAY (0) */ return TRUE; -#ifndef __REACTOS__ - case LB_GETCOUNT16: -#endif case LB_GETCOUNT: return descr->nb_items; -#ifndef __REACTOS__ - case LB_GETTEXT16: - lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_GETTEXT: return LISTBOX_GetText( descr, wParam, (LPWSTR)lParam, unicode ); -#ifndef __REACTOS__ - case LB_GETTEXTLEN16: - /* fall through */ -#endif case LB_GETTEXTLEN: if ((INT)wParam >= descr->nb_items || (INT)wParam < 0) { @@ -2860,9 +2740,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return WideCharToMultiByte( CP_ACP, 0, descr->items[wParam].str, strlenW(descr->items[wParam].str), NULL, 0, NULL, NULL ); -#ifndef __REACTOS__ - case LB_GETCURSEL16: -#endif case LB_GETCURSEL: if (descr->nb_items == 0) return LB_ERR; @@ -2873,23 +2750,12 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return descr->focus_item; /* otherwise, if the user tries to move the selection with the */ /* arrow keys, we will give the application something to choke on */ -#ifndef __REACTOS__ - case LB_GETTOPINDEX16: -#endif case LB_GETTOPINDEX: return descr->top_item; -#ifndef __REACTOS__ - case LB_GETITEMHEIGHT16: -#endif case LB_GETITEMHEIGHT: return LISTBOX_GetItemHeight( descr, wParam ); -#ifndef __REACTOS__ - case LB_SETITEMHEIGHT16: - lParam = LOWORD(lParam); - /* fall through */ -#endif case LB_SETITEMHEIGHT: return LISTBOX_SetItemHeight( descr, wParam, lParam, TRUE ); @@ -2931,9 +2797,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return MAKELONG(index, hit ? 0 : 1); } -#ifndef __REACTOS__ - case LB_SETCARETINDEX16: -#endif case LB_SETCARETINDEX: if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR; if (LISTBOX_SetCaretIndex( descr, wParam, !lParam ) == LB_ERR) @@ -2943,47 +2806,18 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, else return LB_OKAY; -#ifndef __REACTOS__ - case LB_GETCARETINDEX16: -#endif case LB_GETCARETINDEX: return descr->focus_item; -#ifndef __REACTOS__ - case LB_SETTOPINDEX16: -#endif case LB_SETTOPINDEX: return LISTBOX_SetTopItem( descr, wParam, TRUE ); -#ifndef __REACTOS__ - case LB_SETCOLUMNWIDTH16: -#endif case LB_SETCOLUMNWIDTH: return LISTBOX_SetColumnWidth( descr, wParam ); -#ifndef __REACTOS__ - case LB_GETITEMRECT16: - { - RECT rect; - RECT16 *r16 = MapSL(lParam); - ret = LISTBOX_GetItemRect( descr, (INT16)wParam, &rect ); - r16->left = rect.left; - r16->top = rect.top; - r16->right = rect.right; - r16->bottom = rect.bottom; - } - return ret; -#endif - case LB_GETITEMRECT: return LISTBOX_GetItemRect( descr, wParam, (RECT *)lParam ); -#ifndef __REACTOS__ - case LB_FINDSTRING16: - wParam = (INT)(INT16)wParam; - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_FINDSTRING: { INT ret; @@ -3003,12 +2837,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_FINDSTRINGEXACT16: - wParam = (INT)(INT16)wParam; - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_FINDSTRINGEXACT: { INT ret; @@ -3028,12 +2856,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_SELECTSTRING16: - wParam = (INT)(INT16)wParam; - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_SELECTSTRING: { INT index; @@ -3062,29 +2884,14 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return index; } -#ifndef __REACTOS__ - case LB_GETSEL16: - wParam = (INT)(INT16)wParam; - /* fall through */ -#endif case LB_GETSEL: if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) return LB_ERR; return descr->items[wParam].selected; -#ifndef __REACTOS__ - case LB_SETSEL16: - lParam = (INT)(INT16)lParam; - /* fall through */ -#endif case LB_SETSEL: return LISTBOX_SetSelection( descr, lParam, wParam, FALSE ); -#ifndef __REACTOS__ - case LB_SETCURSEL16: - wParam = (INT)(INT16)wParam; - /* fall through */ -#endif case LB_SETCURSEL: if (IS_MULTISELECT(descr)) return LB_ERR; LISTBOX_SetCaretIndex( descr, wParam, FALSE ); @@ -3092,23 +2899,12 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, if (ret != LB_ERR) ret = descr->selected_item; return ret; -#ifndef __REACTOS__ - case LB_GETSELCOUNT16: -#endif case LB_GETSELCOUNT: return LISTBOX_GetSelCount( descr ); -#ifndef __REACTOS__ - case LB_GETSELITEMS16: - return LISTBOX_GetSelItems16( descr, wParam, (LPINT16)MapSL(lParam) ); -#endif - case LB_GETSELITEMS: return LISTBOX_GetSelItems( descr, wParam, (LPINT)lParam ); -#ifndef __REACTOS__ - case LB_SELITEMRANGE16: -#endif case LB_SELITEMRANGE: if (LOWORD(lParam) <= HIWORD(lParam)) return LISTBOX_SelectItemRange( descr, LOWORD(lParam), @@ -3117,38 +2913,21 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return LISTBOX_SelectItemRange( descr, HIWORD(lParam), LOWORD(lParam), wParam ); -#ifndef __REACTOS__ - case LB_SELITEMRANGEEX16: -#endif case LB_SELITEMRANGEEX: if ((INT)lParam >= (INT)wParam) return LISTBOX_SelectItemRange( descr, wParam, lParam, TRUE ); else return LISTBOX_SelectItemRange( descr, lParam, wParam, FALSE); -#ifndef __REACTOS__ - case LB_GETHORIZONTALEXTENT16: -#endif case LB_GETHORIZONTALEXTENT: return descr->horz_extent; -#ifndef __REACTOS__ - case LB_SETHORIZONTALEXTENT16: -#endif case LB_SETHORIZONTALEXTENT: return LISTBOX_SetHorizontalExtent( descr, wParam ); -#ifndef __REACTOS__ - case LB_GETANCHORINDEX16: -#endif case LB_GETANCHORINDEX: return descr->anchor_item; -#ifndef __REACTOS__ - case LB_SETANCHORINDEX16: - wParam = (INT)(INT16)wParam; - /* fall through */ -#endif case LB_SETANCHORINDEX: if (((INT)wParam < -1) || ((INT)wParam >= descr->nb_items)) { @@ -3158,14 +2937,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, descr->anchor_item = (INT)wParam; return LB_OKAY; -#ifndef __REACTOS__ - case LB_DIR16: - /* according to Win16 docs, DDL_DRIVES should make DDL_EXCLUSIVE - * be set automatically (this is different in Win32) */ - if (wParam & DDL_DRIVES) wParam |= DDL_EXCLUSIVE; - lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_DIR: { INT ret; @@ -3204,17 +2975,9 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, case LB_SETCOUNT: return LISTBOX_SetCount( descr, (INT)wParam ); -#ifndef __REACTOS__ - case LB_SETTABSTOPS16: - return LISTBOX_SetTabStops( descr, (INT)(INT16)wParam, MapSL(lParam), TRUE ); -#endif - case LB_SETTABSTOPS: - return LISTBOX_SetTabStops( descr, wParam, (LPINT)lParam, FALSE ); + return LISTBOX_SetTabStops( descr, wParam, (LPINT)lParam ); -#ifndef __REACTOS__ - case LB_CARETON16: -#endif case LB_CARETON: if (descr->caret_on) return LB_OKAY; @@ -3223,9 +2986,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS ); return LB_OKAY; -#ifndef __REACTOS__ - case LB_CARETOFF16: -#endif case LB_CARETOFF: if (!descr->caret_on) return LB_OKAY; @@ -3418,7 +3178,7 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, case WM_NCACTIVATE: if (lphc) return 0; break; - +// ReactOS case WM_UPDATEUISTATE: if (unicode) DefWindowProcW(descr->self, msg, wParam, lParam); @@ -3432,7 +3192,7 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, LISTBOX_DrawFocusRect( descr, descr->in_focus ); } break; - +// default: if ((msg >= WM_USER) && (msg < 0xc000)) WARN("[%p]: unknown msg %04x wp %08lx lp %08lx\n", diff --git a/reactos/dll/win32/user32/controls/scrollbar.c b/reactos/dll/win32/user32/controls/scrollbar.c index e55baadffb9..460fd6a3ea1 100644 --- a/reactos/dll/win32/user32/controls/scrollbar.c +++ b/reactos/dll/win32/user32/controls/scrollbar.c @@ -68,9 +68,6 @@ static BOOL ScrollTrackVertical; HBRUSH DefWndControlColor(HDC hDC, UINT ctlType); -//static LRESULT WINAPI ScrollBarWndProcW( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); -//static LRESULT WINAPI ScrollBarWndProcA( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); - UINT WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC); BOOL WINAPI KillSystemTimer(HWND,UINT_PTR); @@ -712,6 +709,22 @@ IntScrollDrawSizeGrip(HWND Wnd, HDC Dc) DrawFrameControl(Dc, &Rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); } +/*********************************************************************** + * SCROLL_RefreshScrollBar + * + * Repaint the scroll bar interior after a SetScrollRange() or + * SetScrollPos() call. + */ +static void SCROLL_RefreshScrollBar( HWND hwnd, INT nBar, + BOOL arrows, BOOL interior ) +{ + HDC hdc = GetDCEx( hwnd, 0, + DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW) ); + if (!hdc) return; + + IntDrawScrollBar( hwnd, hdc, nBar);//, arrows, interior ); + ReleaseDC( hwnd, hdc ); +} /*********************************************************************** @@ -1399,14 +1412,14 @@ ScrollBarWndProc(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARA case SBM_GETPOS: return IntScrollGetScrollPos(Wnd, SB_CTL); + case SBM_SETRANGEREDRAW: case SBM_SETRANGE: { INT OldPos = IntScrollGetScrollPos(Wnd, SB_CTL); SetScrollRange(Wnd, SB_CTL, wParam, lParam, FALSE); - if (OldPos != IntScrollGetScrollPos(Wnd, SB_CTL)) - { - return OldPos; - } + if (Msg == SBM_SETRANGEREDRAW) + SCROLL_RefreshScrollBar( Wnd, SB_CTL, TRUE, TRUE ); + if (OldPos != IntScrollGetScrollPos(Wnd, SB_CTL)) return OldPos; } return 0; @@ -1416,27 +1429,19 @@ ScrollBarWndProc(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARA case SBM_ENABLE_ARROWS: return EnableScrollBar(Wnd, SB_CTL, wParam); - case SBM_SETRANGEREDRAW: - { - INT OldPos = IntScrollGetScrollPos(Wnd, SB_CTL); - SetScrollRange(Wnd, SB_CTL, wParam, lParam, TRUE); - if (OldPos != IntScrollGetScrollPos(Wnd, SB_CTL)) - { - return OldPos; - } - } - return 0; - case SBM_SETSCROLLINFO: return NtUserSetScrollInfo(Wnd, SB_CTL, (SCROLLINFO *) lParam, wParam); case SBM_GETSCROLLINFO: return NtUserSBGetParms(Wnd, SB_CTL, NULL, (SCROLLINFO *) lParam); + case SBM_GETSCROLLBARINFO: + ((PSCROLLBARINFO)lParam)->cbSize = sizeof(SCROLLBARINFO); + return NtUserGetScrollBarInfo(Wnd, OBJID_CLIENT, (PSCROLLBARINFO)lParam); + case 0x00e5: case 0x00e7: case 0x00e8: - case 0x00eb: case 0x00ec: case 0x00ed: case 0x00ee: @@ -1505,8 +1510,8 @@ RealGetScrollInfo(HWND Wnd, INT SBType, LPSCROLLINFO Info) PWND pWnd; PSBDATA pSBData = NULL; - if (SB_CTL == SBType) - { + if (SB_CTL == SBType) + { return SendMessageW(Wnd, SBM_GETSCROLLINFO, 0, (LPARAM) Info); } diff --git a/reactos/dll/win32/user32/controls/static.c b/reactos/dll/win32/user32/controls/static.c index df8b7bf3ef5..db0f4408980 100644 --- a/reactos/dll/win32/user32/controls/static.c +++ b/reactos/dll/win32/user32/controls/static.c @@ -296,23 +296,25 @@ static HANDLE STATIC_GetImage( HWND hwnd, WPARAM wParam, DWORD style ) * * Load the icon for an SS_ICON control. */ -static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style ) +static HICON STATIC_LoadIconA( HINSTANCE hInstance, LPCSTR name, DWORD style ) { - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); - if ((style & SS_REALSIZEIMAGE) != 0) + HICON hicon = 0; + + if (hInstance && ((ULONG_PTR)hInstance >> 16)) { - return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED); - } - else - { - HICON hicon = LoadIconA( hInstance, name ); - if (!hicon) hicon = LoadCursorA( hInstance, name ); - if (!hicon) hicon = LoadIconA( 0, name ); - /* Windows doesn't try to load a standard cursor, - probably because most IDs for standard cursors conflict - with the IDs for standard icons anyway */ - return hicon; + if ((style & SS_REALSIZEIMAGE) != 0) + hicon = LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED); + else + { + hicon = LoadIconA( hInstance, name ); + if (!hicon) hicon = LoadCursorA( hInstance, name ); + } } + if (!hicon) hicon = LoadIconA( 0, name ); + /* Windows doesn't try to load a standard cursor, + probably because most IDs for standard cursors conflict + with the IDs for standard icons anyway */ + return hicon; } /*********************************************************************** @@ -320,48 +322,27 @@ static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style ) * * Load the icon for an SS_ICON control. */ -static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style ) +static HICON STATIC_LoadIconW( HINSTANCE hInstance, LPCWSTR name, DWORD style ) { - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); - if ((style & SS_REALSIZEIMAGE) != 0) + HICON hicon = 0; + + if (hInstance && ((ULONG_PTR)hInstance >> 16)) { - return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED); - } - else - { - HICON hicon = LoadIconW( hInstance, name ); - if (!hicon) hicon = LoadCursorW( hInstance, name ); - if (!hicon) hicon = LoadIconW( 0, name ); - /* Windows doesn't try to load a standard cursor, - probably because most IDs for standard cursors conflict - with the IDs for standard icons anyway */ - return hicon; + if ((style & SS_REALSIZEIMAGE) != 0) + hicon = LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED); + else + { + hicon = LoadIconW( hInstance, name ); + if (!hicon) hicon = LoadCursorW( hInstance, name ); + } } + if (!hicon) hicon = LoadIconW( 0, name ); + /* Windows doesn't try to load a standard cursor, + probably because most IDs for standard cursors conflict + with the IDs for standard icons anyway */ + return hicon; } -/*********************************************************************** - * STATIC_LoadBitmapA - * - * Load the bitmap for an SS_BITMAP control. - */ -static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name ) -{ - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); - /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */ - return LoadBitmapA( hInstance, name ); -} - -/*********************************************************************** - * STATIC_LoadBitmapW - * - * Load the bitmap for an SS_BITMAP control. - */ -static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name ) -{ - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); - /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */ - return LoadBitmapW( hInstance, name ); -} /*********************************************************************** * STATIC_TryPaintFcn @@ -513,6 +494,7 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, { LPCSTR textA; LPCWSTR textW; + HINSTANCE hInstance; if (full_style & SS_SUNKEN) SetWindowLongPtrW( hwnd, GWL_EXSTYLE, @@ -527,26 +509,30 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, { textA = ((LPCREATESTRUCTA)lParam)->lpszName; textW = NULL; + } + hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); + switch (style) { case SS_ICON: { HICON hIcon; - if(unicode) - hIcon = STATIC_LoadIconW(hwnd, textW, full_style); + if(unicode ) + hIcon = STATIC_LoadIconW(hInstance, textW, full_style); else - hIcon = STATIC_LoadIconA(hwnd, textA, full_style); + hIcon = STATIC_LoadIconA(hInstance, textA, full_style); STATIC_SetIcon(hwnd, hIcon, full_style); } break; case SS_BITMAP: + if ((ULONG_PTR)hInstance >> 16) { HBITMAP hBitmap; if(unicode) - hBitmap = STATIC_LoadBitmapW(hwnd, textW); + hBitmap = LoadBitmapW(hInstance, textW); else - hBitmap = STATIC_LoadBitmapA(hwnd, textA); + hBitmap = LoadBitmapA(hInstance, textA); STATIC_SetBitmap(hwnd, hBitmap, full_style); } break; @@ -575,8 +561,8 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, if (hasTextStyle( full_style )) { SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam ); - if (LOWORD(lParam)) - RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN ); + if (LOWORD(lParam)) + RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN ); } break; @@ -608,9 +594,7 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, case STM_GETIMAGE: return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style ); -#ifndef __REACTOS__ - case STM_GETICON16: -#endif + case STM_GETICON: return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style ); @@ -636,9 +620,6 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, STATIC_TryPaintFcn( hwnd, full_style ); break; -#ifndef __REACTOS__ - case STM_SETICON16: -#endif case STM_SETICON: lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style ); STATIC_TryPaintFcn( hwnd, full_style ); diff --git a/reactos/include/psdk/winuser.h b/reactos/include/psdk/winuser.h index 56ddef53230..8700be78f5d 100644 --- a/reactos/include/psdk/winuser.h +++ b/reactos/include/psdk/winuser.h @@ -1993,11 +1993,16 @@ extern "C" { #define SBM_ENABLE_ARROWS 228 #define SBM_GETPOS 225 #define SBM_GETRANGE 227 -#define SBM_GETSCROLLINFO 234 #define SBM_SETPOS 224 #define SBM_SETRANGE 226 #define SBM_SETRANGEREDRAW 230 +#if (_WIN32_WINNT >= 0x0400) +#define SBM_GETSCROLLINFO 234 #define SBM_SETSCROLLINFO 233 +#endif +#if (_WIN32_WINNT >= 0x0501) +#define SBM_GETSCROLLBARINFO 235 +#endif #define STM_GETICON 369 #define STM_GETIMAGE 371 #define STM_SETICON 368 diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 729128b4389..a69885a153d 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -230,13 +230,13 @@ snmpapi - reactos/dll/win32/snmpapi/main.c # Synced at 20090222 User32 - - reactos/dll/win32/user32/controls/button.c # Synced to Wine-1_1_22 - reactos/dll/win32/user32/controls/combo.c # Synced to Wine-1_1_22 - reactos/dll/win32/user32/controls/edit.c # Synced to Wine-1_1_29 - reactos/dll/win32/user32/controls/icontitle.c # Synced to Wine-1_1_13 - reactos/dll/win32/user32/controls/listbox.c # Synced to Wine-1_1_22 + reactos/dll/win32/user32/controls/button.c # Synced to Wine-1_1_39 + reactos/dll/win32/user32/controls/combo.c # Synced to Wine-1_1_39 + reactos/dll/win32/user32/controls/edit.c # Synced to Wine-1_1_39 + reactos/dll/win32/user32/controls/icontitle.c # Synced to Wine-1_1_39 + reactos/dll/win32/user32/controls/listbox.c # Synced to Wine-1_1_39 reactos/dll/win32/user32/controls/scrollbar.c # Forked - reactos/dll/win32/user32/controls/static.c # Synced to Wine-1_1_22 + reactos/dll/win32/user32/controls/static.c # Synced to Wine-1_1_39 reactos/dll/win32/user32/include/dde_private.h # Synced to wine 1.1.24 From 858705878a7e6e21468d429f586b0cc15f0fbee5 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 5 Mar 2010 01:09:24 +0000 Subject: [PATCH 096/211] - Fail HwFindAdapter if VESA is disabled - This should allow VGA to take over but it doesn't work due to a bug in videoprt svn path=/trunk/; revision=45855 --- reactos/drivers/video/miniport/vbe/vbemp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/drivers/video/miniport/vbe/vbemp.c b/reactos/drivers/video/miniport/vbe/vbemp.c index 55b2bcb980c..2107e5ff70e 100644 --- a/reactos/drivers/video/miniport/vbe/vbemp.c +++ b/reactos/drivers/video/miniport/vbe/vbemp.c @@ -71,6 +71,9 @@ VBEFindAdapter( IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again) { + if (VideoPortIsNoVesa()) + return ERROR_DEV_NOT_EXIST; + return NO_ERROR; } From ea5024f932f455509fbfa70ab1e0ba773e0f0c9f Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Fri, 5 Mar 2010 01:27:43 +0000 Subject: [PATCH 097/211] [DDK]: Add missing video IOCTLs. svn path=/trunk/; revision=45857 --- reactos/include/ddk/ntddvdeo.h | 38 +++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/reactos/include/ddk/ntddvdeo.h b/reactos/include/ddk/ntddvdeo.h index c4522343e34..f2fdc5bcae7 100644 --- a/reactos/include/ddk/ntddvdeo.h +++ b/reactos/include/ddk/ntddvdeo.h @@ -35,6 +35,41 @@ extern "C" { DEFINE_GUID(GUID_DEVINTERFACE_DISPLAY_ADAPTER, \ 0x5b45201d, 0xf2f2, 0x4f3b, 0x85, 0xbb, 0x30, 0xff, 0x1f, 0x95, 0x35, 0x99); +#define IOCTL_VIDEO_ENABLE_VDM \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x00, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_DISABLE_VDM \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_REGISTER_VDM \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x02, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x03, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x04, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_MONITOR_DEVICE \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x05, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_ENUM_MONITOR_PDO \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x06, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x07, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_IS_VGA_DEVICE \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x09, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x0a, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x0b, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_VIDEO_DISABLE_CURSOR \ CTL_CODE (FILE_DEVICE_VIDEO, 0x109, METHOD_BUFFERED, FILE_ANY_ACCESS) @@ -60,9 +95,6 @@ DEFINE_GUID(GUID_DEVINTERFACE_DISPLAY_ADAPTER, \ #define IOCTL_VIDEO_GET_POWER_MANAGEMENT \ CTL_CODE(FILE_DEVICE_VIDEO, 0x11c, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS \ - CTL_CODE(FILE_DEVICE_VIDEO, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS) - #define IOCTL_VIDEO_LOAD_AND_SET_FONT \ CTL_CODE(FILE_DEVICE_VIDEO, 0x105, METHOD_BUFFERED, FILE_ANY_ACCESS) From e3fb834a19909cef6d72be6dda17deeb123b4751 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 5 Mar 2010 09:09:14 +0000 Subject: [PATCH 098/211] [PORTCLS] - Remove dead code - Disable last mapping failed status when a new mapping is inserted - Notify IMiniportWavePciStream::MappingAvailable when a new mapping has arrived and the last one has failed - Return STATUS_NOT_FOUND in IPortWavePciStream::GetMapping when no mapping is available - Don't stop stream when no mapping is currently available svn path=/trunk/; revision=45859 --- .../wdm/audio/backpln/portcls/interfaces.hpp | 27 +- .../wdm/audio/backpln/portcls/irpstream.cpp | 66 +--- .../wdm/audio/backpln/portcls/pin_dmus.cpp | 240 +++------------ .../audio/backpln/portcls/pin_wavecyclic.cpp | 3 - .../wdm/audio/backpln/portcls/pin_wavepci.cpp | 286 ++---------------- .../wdm/audio/backpln/portcls/pin_wavert.cpp | 86 ------ 6 files changed, 78 insertions(+), 630 deletions(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp b/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp index 7aefc882ee4..0fb9cd64a10 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp @@ -337,17 +337,10 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHOD_(VOID, UpdateMapping)(THIS_ IN ULONG BytesWritten) PURE; - STDMETHOD_(ULONG, NumMappings)(THIS) PURE; - STDMETHOD_(ULONG, NumData)(THIS) PURE; - STDMETHOD_(BOOL, MinimumDataAvailable)(THIS) PURE; - STDMETHOD_(BOOL, CancelBuffers)(THIS) PURE; - STDMETHOD_(VOID, UpdateFormat)(THIS_ - IN PKSDATAFORMAT DataFormat) PURE; - STDMETHOD_(NTSTATUS, GetMappingWithTag)(THIS_ IN PVOID Tag, OUT PPHYSICAL_ADDRESS PhysicalAddress, @@ -358,11 +351,8 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHOD_(NTSTATUS, ReleaseMappingWithTag)(THIS_ IN PVOID Tag) PURE; - STDMETHOD_(BOOL, HasLastMappingFailed)(THIS) PURE; + STDMETHOD_(BOOLEAN, HasLastMappingFailed)(THIS) PURE; STDMETHOD_(ULONG, GetCurrentIrpOffset)(THIS) PURE; - STDMETHOD_(VOID, SetMinimumDataThreshold)(THIS_ - IN ULONG MinimumDataThreshold) PURE; - STDMETHOD_(ULONG, GetMinimumDataThreshold)(THIS) PURE; }; @@ -386,17 +376,10 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHODIMP_(VOID) UpdateMapping(THIS_ \ IN ULONG BytesWritten); \ \ - STDMETHODIMP_(ULONG) NumMappings(THIS); \ - \ STDMETHODIMP_(ULONG) NumData(THIS); \ \ - STDMETHODIMP_(BOOL) MinimumDataAvailable(THIS); \ - \ STDMETHODIMP_(BOOL) CancelBuffers(THIS); \ \ - STDMETHODIMP_(VOID) UpdateFormat(THIS_ \ - IN PKSDATAFORMAT DataFormat); \ - \ STDMETHODIMP_(NTSTATUS) GetMappingWithTag(THIS_ \ IN PVOID Tag, \ OUT PPHYSICAL_ADDRESS PhysicalAddress, \ @@ -407,11 +390,9 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHODIMP_(NTSTATUS) ReleaseMappingWithTag( \ IN PVOID Tag); \ \ - STDMETHODIMP_(BOOL) HasLastMappingFailed(THIS); \ - STDMETHODIMP_(ULONG) GetCurrentIrpOffset(THIS); \ - STDMETHODIMP_(VOID) SetMinimumDataThreshold( \ - IN ULONG MinimumDataThreshold); \ - STDMETHODIMP_(ULONG) GetMinimumDataThreshold(VOID) + STDMETHODIMP_(BOOLEAN) HasLastMappingFailed(THIS); \ + STDMETHODIMP_(ULONG) GetCurrentIrpOffset(THIS); + /***************************************************************************** * IKsWorkSink diff --git a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp index b3ce1d4d03b..32f4866dca2 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp @@ -225,6 +225,9 @@ CIrpQueue::AddMapping( // add irp to cancelable queue KsAddIrpToCancelableQueue(&m_IrpList, &m_IrpListLock, Irp, KsListEntryTail, NULL); + // disable mapping failed status + m_OutOfMapping = FALSE; + // done return Status; } @@ -410,15 +413,6 @@ CIrpQueue::UpdateMapping( } } -ULONG -NTAPI -CIrpQueue::NumMappings() -{ - - // returns the amount of mappings available - return m_NumMappings; -} - ULONG NTAPI CIrpQueue::NumData() @@ -427,28 +421,6 @@ CIrpQueue::NumData() return m_NumDataAvailable; } - -BOOL -NTAPI -CIrpQueue::MinimumDataAvailable() -{ - BOOL Result; - - if (m_StartStream) - return TRUE; - - if (m_MinimumDataThreshold < m_NumDataAvailable) - { - m_StartStream = TRUE; - Result = TRUE; - } - else - { - Result = FALSE; - } - return Result; -} - BOOL NTAPI CIrpQueue::CancelBuffers() @@ -475,17 +447,6 @@ CIrpQueue::CancelBuffers() return TRUE; } -VOID -NTAPI -CIrpQueue::UpdateFormat( - PKSDATAFORMAT DataFormat) -{ - m_DataFormat = (PKSDATAFORMAT_WAVEFORMATEX)DataFormat; - m_MinimumDataThreshold = m_DataFormat->WaveFormatEx.nAvgBytesPerSec / 3; - m_StartStream = FALSE; - m_NumDataAvailable = 0; -} - NTSTATUS NTAPI CIrpQueue::GetMappingWithTag( @@ -510,7 +471,7 @@ CIrpQueue::GetMappingWithTag( // no irp available m_OutOfMapping = TRUE; m_StartStream = FALSE; - return STATUS_UNSUCCESSFUL; + return STATUS_NOT_FOUND; } //FIXME support more than one stream header @@ -578,7 +539,7 @@ CIrpQueue::ReleaseMappingWithTag( return STATUS_SUCCESS; } -BOOL +BOOLEAN NTAPI CIrpQueue::HasLastMappingFailed() { @@ -593,23 +554,6 @@ CIrpQueue::GetCurrentIrpOffset() return m_CurrentOffset; } -VOID -NTAPI -CIrpQueue::SetMinimumDataThreshold( - ULONG MinimumDataThreshold) -{ - - m_MinimumDataThreshold = MinimumDataThreshold; -} - -ULONG -NTAPI -CIrpQueue::GetMinimumDataThreshold() -{ - return m_MinimumDataThreshold; -} - - NTSTATUS NTAPI NewIrpQueue( diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp index 07395aedc27..cea693b1b35 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp @@ -41,9 +41,6 @@ protected: VOID TransferMidiDataToDMus(); VOID TransferMidiData(); - VOID NTAPI SetStreamState(IN KSSTATE State); - - IPortDMus * m_Port; IPortFilterDMus * m_Filter; KSPIN_DESCRIPTOR * m_KsPinDescriptor; @@ -75,10 +72,6 @@ protected: ULONG m_LastTag; LONG m_Ref; - - friend VOID NTAPI SetStreamWorkerRoutineDMus(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context); - friend VOID NTAPI CloseStreamRoutineDMus(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context); - }; typedef struct @@ -198,92 +191,6 @@ CPortPinDMus::DisconnectOutput( //================================================================================================================================== -VOID -NTAPI -SetStreamWorkerRoutineDMus( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - CPortPinDMus* This; - KSSTATE State; - NTSTATUS Status; - PSETSTREAM_CONTEXT Ctx = (PSETSTREAM_CONTEXT)Context; - - This = Ctx->Pin; - State = Ctx->State; - - IoFreeWorkItem(Ctx->WorkItem); - FreeItem(Ctx, TAG_PORTCLASS); - - // Has the audio stream resumed? - if (This->m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Set the state - if (This->m_MidiStream) - { - Status = This->m_MidiStream->SetState(State); - } - else - { - Status = This->m_Mxf->SetState(State); - } - - if (NT_SUCCESS(Status)) - { - // Set internal state to requested state - This->m_State = State; - - if (This->m_State == KSSTATE_STOP) - { - // reset start stream - This->m_IrpQueue->CancelBuffers(); //FIX function name - DPRINT("Stopping PreCompleted %u PostCompleted %u\n", This->m_PreCompleted, This->m_PostCompleted); - } - } -} - -VOID -NTAPI -CPortPinDMus::SetStreamState( - IN KSSTATE State) -{ - PIO_WORKITEM WorkItem; - PSETSTREAM_CONTEXT Context; - - PC_ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); - - // Has the audio stream resumed? - if (m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Has the audio state already been set? - if (m_State == State) - return; - - // allocate set state context - Context = (PSETSTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(SETSTREAM_CONTEXT), TAG_PORTCLASS); - - if (!Context) - return; - - // allocate work item - WorkItem = IoAllocateWorkItem(m_DeviceObject); - - if (!WorkItem) - { - ExFreePool(Context); - return; - } - - Context->Pin = this; - Context->WorkItem = WorkItem; - Context->State = State; - - // queue the work item - IoQueueWorkItem(WorkItem, SetStreamWorkerRoutineDMus, DelayedWorkQueue, (PVOID)Context); -} - VOID CPortPinDMus::TransferMidiData() { @@ -297,7 +204,6 @@ CPortPinDMus::TransferMidiData() Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize); if (!NT_SUCCESS(Status)) { - SetStreamState(KSSTATE_STOP); return; } @@ -375,7 +281,6 @@ CPortPinDMus::TransferMidiDataToDMus() if (!Root) { - SetStreamState(KSSTATE_STOP); return; } @@ -482,128 +387,59 @@ CPortPinDMus::Flush( return KsDispatchInvalidDeviceRequest(DeviceObject, Irp); } - -VOID -NTAPI -CloseStreamRoutineDMus( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - PMINIPORTMIDISTREAM Stream = NULL; - NTSTATUS Status; - ISubdevice *ISubDevice; - PSUBDEVICE_DESCRIPTOR Descriptor; - CPortPinDMus * This; - PCLOSESTREAM_CONTEXT Ctx = (PCLOSESTREAM_CONTEXT)Context; - - This = (CPortPinDMus*)Ctx->Pin; - - if (This->m_MidiStream) - { - if (This->m_State != KSSTATE_STOP) - { - This->m_MidiStream->SetState(KSSTATE_STOP); - } - Stream = This->m_MidiStream; - This->m_MidiStream = NULL; - } - - if (This->m_ServiceGroup) - { - This->m_ServiceGroup->RemoveMember(PSERVICESINK(This)); - } - - Status = This->m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice); - if (NT_SUCCESS(Status)) - { - Status = ISubDevice->GetDescriptor(&Descriptor); - if (NT_SUCCESS(Status)) - { - Descriptor->Factory.Instances[This->m_ConnectDetails->PinId].CurrentPinInstanceCount--; - ISubDevice->Release(); - } - } - - if (This->m_Format) - { - ExFreePool(This->m_Format); - This->m_Format = NULL; - } - - // complete the irp - Ctx->Irp->IoStatus.Information = 0; - Ctx->Irp->IoStatus.Status = STATUS_SUCCESS; - IoCompleteRequest(Ctx->Irp, IO_NO_INCREMENT); - - // free the work item - IoFreeWorkItem(Ctx->WorkItem); - - // free work item ctx - FreeItem(Ctx, TAG_PORTCLASS); - - // destroy DMus pin - This->m_Filter->FreePin(PPORTPINDMUS(This)); - - if (Stream) - { - DPRINT("Closing stream at Irql %u\n", KeGetCurrentIrql()); - Stream->Release(); - } -} - NTSTATUS NTAPI CPortPinDMus::Close( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - PCLOSESTREAM_CONTEXT Ctx; + NTSTATUS Status; + ISubdevice * SubDevice; + PSUBDEVICE_DESCRIPTOR Descriptor; - if (m_MidiStream || m_Mxf) + if (m_ServiceGroup) { - Ctx = (PCLOSESTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(CLOSESTREAM_CONTEXT), TAG_PORTCLASS); - if (!Ctx) - { - DPRINT("Failed to allocate stream context\n"); - goto cleanup; - } - - Ctx->WorkItem = IoAllocateWorkItem(DeviceObject); - if (!Ctx->WorkItem) - { - DPRINT("Failed to allocate work item\n"); - goto cleanup; - } - - Ctx->Irp = Irp; - Ctx->Pin = this; - - IoMarkIrpPending(Irp); - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_PENDING; - - // defer work item - IoQueueWorkItem(Ctx->WorkItem, CloseStreamRoutineDMus, DelayedWorkQueue, (PVOID)Ctx); - // Return result - return STATUS_PENDING; + m_ServiceGroup->RemoveMember(PSERVICESINK(this)); } + if (m_MidiStream) + { + if (m_State != KSSTATE_STOP) + { + m_MidiStream->SetState(KSSTATE_STOP); + m_State = KSSTATE_STOP; + } + DPRINT("Closing stream at Irql %u\n", KeGetCurrentIrql()); + m_MidiStream->Release(); + } + + Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&SubDevice); + if (NT_SUCCESS(Status)) + { + Status = SubDevice->GetDescriptor(&Descriptor); + if (NT_SUCCESS(Status)) + { + // release reference count + Descriptor->Factory.Instances[m_ConnectDetails->PinId].CurrentPinInstanceCount--; + } + SubDevice->Release(); + } + + if (m_Format) + { + ExFreePool(m_Format); + m_Format = NULL; + } + + // complete the irp Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); + // destroy DMus pin + m_Filter->FreePin(PPORTPINDMUS(this)); + return STATUS_SUCCESS; - -cleanup: - - if (Ctx) - FreeItem(Ctx, TAG_PORTCLASS); - - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_UNSUCCESSFUL; - } NTSTATUS diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp index e36e9b97a0e..acf5eb45be7 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp @@ -543,9 +543,6 @@ PinWaveCyclicDataFormat( // free old format FreeItem(Pin->m_Format, TAG_PORTCLASS); - // update irp queue with new format - Pin->m_IrpQueue->UpdateFormat((PKSDATAFORMAT)NewDataFormat); - // store new format Pin->m_Format = NewDataFormat; Irp->IoStatus.Information = NewDataFormat->FormatSize; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp index 273bfae6539..d13f52e0baa 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp @@ -36,9 +36,6 @@ public: IMP_IPortWavePciStream; CPortPinWavePci(IUnknown *OuterUnknown) {} virtual ~CPortPinWavePci(){} - - VOID NTAPI SetState( IN KSSTATE State); - VOID NTAPI CloseStream(); protected: friend NTSTATUS NTAPI PinWavePciState(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data); @@ -77,9 +74,6 @@ protected: NTSTATUS NTAPI HandleKsProperty(IN PIRP Irp); NTSTATUS NTAPI HandleKsStream(IN PIRP Irp); - - - VOID NTAPI SetStreamState( IN KSSTATE State); }; typedef struct @@ -311,9 +305,6 @@ PinWavePciDataFormat( // free old format FreeItem(Pin->m_Format, TAG_PORTCLASS); - // update irp queue with new format - Pin->m_IrpQueue->UpdateFormat((PKSDATAFORMAT)NewDataFormat); - // store new format Pin->m_Format = NewDataFormat; Irp->IoStatus.Information = NewDataFormat->FormatSize; @@ -373,7 +364,7 @@ CPortPinWavePci::QueryInterface( IN REFIID refiid, OUT PVOID* Output) { - DPRINT("CPortPinWavePci::QueryInterface entered\n"); + //DPRINT("CPortPinWavePci::QueryInterface entered\n"); if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) || IsEqualGUIDAligned(refiid, IID_IUnknown)) @@ -435,134 +426,12 @@ CPortPinWavePci::TerminatePacket() } -VOID -CPortPinWavePci::SetState(KSSTATE State) -{ - ULONG MinimumDataThreshold; - ULONG MaximumDataThreshold; - - // Has the audio stream resumed? - if (m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Set the state - if (NT_SUCCESS(m_Stream->SetState(State))) - { - // Save new internal state - m_State = State; - - if (m_State == KSSTATE_STOP) - { - // reset start stream - m_IrpQueue->CancelBuffers(); //FIX function name - //This->ServiceGroup->lpVtbl->CancelDelayedService(This->ServiceGroup); - // increase stop counter - m_StopCount++; - // get current data threshold - MinimumDataThreshold = m_IrpQueue->GetMinimumDataThreshold(); - // get maximum data threshold - MaximumDataThreshold = ((PKSDATAFORMAT_WAVEFORMATEX)m_Format)->WaveFormatEx.nAvgBytesPerSec; - // increase minimum data threshold by 10 frames - MinimumDataThreshold += m_AllocatorFraming.FrameSize * 10; - - // assure it has not exceeded - MinimumDataThreshold = min(MinimumDataThreshold, MaximumDataThreshold); - // store minimum data threshold - m_IrpQueue->SetMinimumDataThreshold(MinimumDataThreshold); - - DPRINT("Stopping TotalCompleted %u StopCount %u MinimumDataThreshold %u\n", m_TotalPackets, m_StopCount, MinimumDataThreshold); - } - if (m_State == KSSTATE_RUN) - { - // start the notification timer - //m_ServiceGroup->RequestDelayedService(m_ServiceGroup, m_Delay); - } - } - - -} - -VOID -NTAPI -PinWavePciSetStreamWorkerRoutine( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - CPortPinWavePci * This; - PSETSTREAM_CONTEXT Ctx = (PSETSTREAM_CONTEXT)Context; - KSSTATE State; - - This = Ctx->Pin; - State = Ctx->State; - - IoFreeWorkItem(Ctx->WorkItem); - FreeItem(Ctx, TAG_PORTCLASS); - - This->SetState(State); -} - -VOID -NTAPI -CPortPinWavePci::SetStreamState( - IN KSSTATE State) -{ - PDEVICE_OBJECT DeviceObject; - PIO_WORKITEM WorkItem; - PSETSTREAM_CONTEXT Context; - - PC_ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); - - // Has the audio stream resumed? - if (m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Has the audio state already been set? - if (m_State == State) - return; - - // Get device object - DeviceObject = GetDeviceObjectFromPortWavePci(m_Port); - - // allocate set state context - Context = (PSETSTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(SETSTREAM_CONTEXT), TAG_PORTCLASS); - - if (!Context) - return; - - // allocate work item - WorkItem = IoAllocateWorkItem(DeviceObject); - - if (!WorkItem) - { - ExFreePool(Context); - return; - } - - Context->Pin = this; - Context->WorkItem = WorkItem; - Context->State = State; - - // queue the work item - IoQueueWorkItem(WorkItem, PinWavePciSetStreamWorkerRoutine, DelayedWorkQueue, (PVOID)Context); -} - - VOID NTAPI CPortPinWavePci::RequestService() { PC_ASSERT_IRQL(DISPATCH_LEVEL); - if (m_IrpQueue->HasLastMappingFailed()) - { - if (m_IrpQueue->NumMappings() == 0) - { - DPRINT("Stopping stream...\n"); - SetStreamState(KSSTATE_STOP); - return; - } - } - m_Stream->Service(); //TODO //generate events @@ -597,18 +466,18 @@ CPortPinWavePci::HandleKsProperty( { PKSPROPERTY Property; NTSTATUS Status; - UNICODE_STRING GuidString; + //UNICODE_STRING GuidString; PIO_STACK_LOCATION IoStack; IoStack = IoGetCurrentIrpStackLocation(Irp); - DPRINT("IPortPinWave_HandleKsProperty entered\n"); + //DPRINT("IPortPinWave_HandleKsProperty entered\n"); IoStack = IoGetCurrentIrpStackLocation(Irp); if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY) { - DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength); + //DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength); Irp->IoStatus.Status = STATUS_SUCCESS; @@ -621,10 +490,11 @@ CPortPinWavePci::HandleKsProperty( if (Status == STATUS_NOT_FOUND) { Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer; - +#if 0 RtlStringFromGUID(Property->Set, &GuidString); - DPRINT("Unhandeled property Set |%S| Id %u Flags %x\n", GuidString.Buffer, Property->Id, Property->Flags); + //DPRINT("Unhandeled property Set |%S| Id %u Flags %x\n", GuidString.Buffer, Property->Id, Property->Flags); RtlFreeUnicodeString(&GuidString); +#endif } if (Status != STATUS_PENDING) @@ -636,29 +506,6 @@ CPortPinWavePci::HandleKsProperty( return Status; } -#if 0 - else if (Property->Id == KSPROPERTY_CONNECTION_ALLOCATORFRAMING) - { - PKSALLOCATOR_FRAMING Framing = (PKSALLOCATOR_FRAMING)OutputBuffer; - - PC_ASSERT_IRQL(DISPATCH_LEVEL); - // Validate input buffer - if (OutputBufferLength < sizeof(KSALLOCATOR_FRAMING)) - { - IoStatusBlock->Information = sizeof(KSALLOCATOR_FRAMING); - IoStatusBlock->Status = STATUS_BUFFER_TOO_SMALL; - return STATUS_BUFFER_TOO_SMALL; - } - // copy frame allocator struct - RtlMoveMemory(Framing, &m_AllocatorFraming, sizeof(KSALLOCATOR_FRAMING)); - - IoStatusBlock->Information = sizeof(KSALLOCATOR_FRAMING); - IoStatusBlock->Status = STATUS_SUCCESS; - return STATUS_SUCCESS; - } - } -#endif - NTSTATUS NTAPI CPortPinWavePci::HandleKsStream( @@ -666,10 +513,13 @@ CPortPinWavePci::HandleKsStream( { NTSTATUS Status; ULONG Data = 0; + BOOLEAN bFailed; InterlockedIncrement((PLONG)&m_TotalPackets); DPRINT("IPortPinWaveCyclic_HandleKsStream entered Total %u State %x MinData %u\n", m_TotalPackets, m_State, m_IrpQueue->NumData()); + bFailed = m_IrpQueue->HasLastMappingFailed(); + Status = m_IrpQueue->AddMapping(Irp, &Data); if (NT_SUCCESS(Status)) @@ -679,6 +529,12 @@ CPortPinWavePci::HandleKsStream( else m_Position.WriteOffset += Data; + if (bFailed) + { + // notify stream of new mapping + m_Stream->MappingAvailable(); + } + return STATUS_PENDING; } @@ -741,37 +597,39 @@ CPortPinWavePci::Flush( return KsDispatchInvalidDeviceRequest(DeviceObject, Irp); } -VOID +NTSTATUS NTAPI -CPortPinWavePci::CloseStream() +CPortPinWavePci::Close( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) { - PMINIPORTWAVEPCISTREAM Stream; - ISubdevice *ISubDevice; + ISubdevice *SubDevice; NTSTATUS Status; PSUBDEVICE_DESCRIPTOR Descriptor; + if (m_ServiceGroup) + { + m_ServiceGroup->RemoveMember(PSERVICESINK(this)); + } + if (m_Stream) { if (m_State != KSSTATE_STOP) { m_Stream->SetState(KSSTATE_STOP); } + m_Stream->Release(); } - if (m_ServiceGroup) - { - m_ServiceGroup->RemoveMember(PSERVICESINK(this)); - } - - Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice); + Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&SubDevice); if (NT_SUCCESS(Status)) { - Status = ISubDevice->GetDescriptor(&Descriptor); + Status = SubDevice->GetDescriptor(&Descriptor); if (NT_SUCCESS(Status)) { Descriptor->Factory.Instances[m_ConnectDetails->PinId].CurrentPinInstanceCount--; } - ISubDevice->Release(); + SubDevice->Release(); } if (m_Format) @@ -780,93 +638,11 @@ CPortPinWavePci::CloseStream() m_Format = NULL; } - if (m_Stream) - { - Stream = m_Stream; - m_Stream = 0; - DPRINT("Closing stream at Irql %u\n", KeGetCurrentIrql()); - Stream->Release(); - } -} - -VOID -NTAPI -PinWavePciCloseStreamRoutine( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - CPortPinWavePci * This; - PCLOSESTREAM_CONTEXT Ctx = (PCLOSESTREAM_CONTEXT)Context; - - This = (CPortPinWavePci*)Ctx->Pin; - - This->CloseStream(); - - // complete the irp - Ctx->Irp->IoStatus.Information = 0; - Ctx->Irp->IoStatus.Status = STATUS_SUCCESS; - IoCompleteRequest(Ctx->Irp, IO_NO_INCREMENT); - - // free the work item - IoFreeWorkItem(Ctx->WorkItem); - - // free work item ctx - FreeItem(Ctx, TAG_PORTCLASS); -} - -NTSTATUS -NTAPI -CPortPinWavePci::Close( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) -{ - PCLOSESTREAM_CONTEXT Ctx; - - if (m_Stream) - { - Ctx = (PCLOSESTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(CLOSESTREAM_CONTEXT), TAG_PORTCLASS); - if (!Ctx) - { - DPRINT("Failed to allocate stream context\n"); - goto cleanup; - } - - Ctx->WorkItem = IoAllocateWorkItem(DeviceObject); - if (!Ctx->WorkItem) - { - DPRINT("Failed to allocate work item\n"); - goto cleanup; - } - - Ctx->Irp = Irp; - Ctx->Pin = (PVOID)this; - - IoMarkIrpPending(Irp); - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_PENDING; - - // defer work item - IoQueueWorkItem(Ctx->WorkItem, PinWavePciCloseStreamRoutine, DelayedWorkQueue, (PVOID)Ctx); - // Return result - return STATUS_PENDING; - } - - Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_SUCCESS; - -cleanup: - - if (Ctx) - FreeItem(Ctx, TAG_PORTCLASS); - - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_UNSUCCESSFUL; - } NTSTATUS diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp index e325e49fe61..439f8aba75e 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp @@ -100,91 +100,6 @@ CPortPinWaveRT::QueryInterface( return STATUS_UNSUCCESSFUL; } -VOID -NTAPI -SetStreamWorkerRoutine( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - CPortPinWaveRT * This; - PSETSTREAM_CONTEXT Ctx = (PSETSTREAM_CONTEXT)Context; - KSSTATE State; - - This = Ctx->Pin; - State = Ctx->State; - - IoFreeWorkItem(Ctx->WorkItem); - FreeItem(Ctx, TAG_PORTCLASS); - - // Has the audio stream resumed? - if (This->m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Set the state - if (NT_SUCCESS(This->m_Stream->SetState(State))) - { - // Set internal state to stop - This->m_State = State; - - if (This->m_State == KSSTATE_STOP) - { - // reset start stream - This->m_IrpQueue->CancelBuffers(); //FIX function name - DPRINT("Stopping PreCompleted %u PostCompleted %u\n", This->m_PreCompleted, This->m_PostCompleted); - } - - if (This->m_State == KSSTATE_RUN) - { - // start the notification timer - } - } -} - -VOID -NTAPI -CPortPinWaveRT::SetStreamState( - IN KSSTATE State) -{ - PDEVICE_OBJECT DeviceObject; - PIO_WORKITEM WorkItem; - PSETSTREAM_CONTEXT Context; - - PC_ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); - - // Has the audio stream resumed? - if (m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Has the audio state already been set? - if (m_State == State) - return; - - // Get device object - DeviceObject = GetDeviceObjectFromPortWaveRT(m_Port); - - // allocate set state context - Context = (PSETSTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(SETSTREAM_CONTEXT), TAG_PORTCLASS); - - if (!Context) - return; - - // allocate work item - WorkItem = IoAllocateWorkItem(DeviceObject); - - if (!WorkItem) - { - ExFreePool(Context); - return; - } - - Context->Pin = this; - Context->WorkItem = WorkItem; - Context->State = State; - - // queue the work item - IoQueueWorkItem(WorkItem, SetStreamWorkerRoutine, DelayedWorkQueue, (PVOID)Context); -} - //================================================================================================================================== NTSTATUS @@ -313,7 +228,6 @@ CPortPinWaveRT::HandleKsProperty( if (m_Format) ExFreePoolWithTag(m_Format, TAG_PORTCLASS); - m_IrpQueue->UpdateFormat((PKSDATAFORMAT)NewDataFormat); m_Format = NewDataFormat; Irp->IoStatus.Information = DataFormat->FormatSize; Irp->IoStatus.Status = STATUS_SUCCESS; From 95f5adb673b9c5b21eac5791fcbe7e0b22b3f2fb Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 5 Mar 2010 09:43:42 +0000 Subject: [PATCH 099/211] [PORTCLS] - More cleanup - Only copy audio bytes to common buffer when the audio pin is in the running state - Only notify miniport when the audio pin is in the running state svn path=/trunk/; revision=45860 --- .../wdm/audio/backpln/portcls/interfaces.hpp | 4 -- .../wdm/audio/backpln/portcls/irpstream.cpp | 15 ------ .../wdm/audio/backpln/portcls/pin_dmus.cpp | 2 +- .../audio/backpln/portcls/pin_wavecyclic.cpp | 47 ++++++++++--------- .../wdm/audio/backpln/portcls/pin_wavepci.cpp | 11 +++-- .../wdm/audio/backpln/portcls/pin_wavert.cpp | 2 +- 6 files changed, 34 insertions(+), 47 deletions(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp b/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp index 0fb9cd64a10..50e50d33a4d 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp @@ -320,8 +320,6 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHOD_(NTSTATUS, Init)(THIS_ IN KSPIN_CONNECT *ConnectDetails, - IN PKSDATAFORMAT DataFormat, - IN PDEVICE_OBJECT DeviceObject, IN ULONG FrameSize, IN ULONG Alignment, IN PVOID SilenceBuffer) PURE; @@ -359,8 +357,6 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) #define IMP_IIrpQueue \ STDMETHODIMP_(NTSTATUS) Init(THIS_ \ IN KSPIN_CONNECT *ConnectDetails, \ - IN PKSDATAFORMAT DataFormat, \ - IN PDEVICE_OBJECT DeviceObject, \ IN ULONG FrameSize, \ IN ULONG Alignment, \ IN PVOID SilenceBuffer); \ diff --git a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp index 32f4866dca2..25e1683216a 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp @@ -38,10 +38,7 @@ protected: volatile ULONG m_CurrentOffset; LONG m_NumMappings; ULONG m_NumDataAvailable; - BOOL m_StartStream; PKSPIN_CONNECT m_ConnectDetails; - PKSDATAFORMAT_WAVEFORMATEX m_DataFormat; - KSPIN_LOCK m_IrpListLock; LIST_ENTRY m_IrpList; LIST_ENTRY m_FreeIrpList; @@ -51,7 +48,6 @@ protected: ULONG m_OutOfMapping; ULONG m_MaxFrameSize; ULONG m_Alignment; - ULONG m_MinimumDataThreshold; LONG m_Ref; @@ -87,18 +83,14 @@ NTSTATUS NTAPI CIrpQueue::Init( IN KSPIN_CONNECT *ConnectDetails, - IN PKSDATAFORMAT DataFormat, - IN PDEVICE_OBJECT DeviceObject, IN ULONG FrameSize, IN ULONG Alignment, IN PVOID SilenceBuffer) { m_ConnectDetails = ConnectDetails; - m_DataFormat = (PKSDATAFORMAT_WAVEFORMATEX)DataFormat; m_MaxFrameSize = FrameSize; m_SilenceBuffer = SilenceBuffer; m_Alignment = Alignment; - m_MinimumDataThreshold = ((PKSDATAFORMAT_WAVEFORMATEX)DataFormat)->WaveFormatEx.nAvgBytesPerSec / 3; InitializeListHead(&m_IrpList); InitializeListHead(&m_FreeIrpList); @@ -273,10 +265,6 @@ CIrpQueue::GetMapping( // no irp available, use silence buffer *Buffer = (PUCHAR)m_SilenceBuffer; *BufferSize = m_MaxFrameSize; - // flag for port wave pci driver - m_OutOfMapping = TRUE; - // indicate flag to restart fast buffering - m_StartStream = FALSE; return STATUS_SUCCESS; } @@ -436,8 +424,6 @@ CIrpQueue::CancelBuffers() // cancel all irps KsCancelIo(&m_IrpList, &m_IrpListLock); - // reset stream start flag - m_StartStream = FALSE; // reset number of mappings m_NumMappings = 0; // reset number of data available @@ -470,7 +456,6 @@ CIrpQueue::GetMappingWithTag( { // no irp available m_OutOfMapping = TRUE; - m_StartStream = FALSE; return STATUS_NOT_FOUND; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp index cea693b1b35..da6e98d9d51 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp @@ -605,7 +605,7 @@ CPortPinDMus::Init( m_ServiceGroup->SupportDelayedService(); } - Status = m_IrpQueue->Init(ConnectDetails, m_Format, DeviceObject, 0, 0, NULL); + Status = m_IrpQueue->Init(ConnectDetails, 0, 0, NULL); if (!NT_SUCCESS(Status)) { DPRINT("IrpQueue_Init failed with %x\n", Status); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp index acf5eb45be7..f74ea0919c6 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp @@ -780,29 +780,32 @@ CPortPinWaveCyclic::RequestService() PC_ASSERT_IRQL(DISPATCH_LEVEL); - Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize); - if (!NT_SUCCESS(Status)) + if (m_State == KSSTATE_RUN) { - return; + Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize); + if (!NT_SUCCESS(Status)) + { + return; + } + + Status = m_Stream->GetPosition(&Position); + DPRINT("Position %u Buffer %p BufferSize %u ActiveIrpOffset %u Capture %u\n", Position, Buffer, m_CommonBufferSize, BufferSize, m_Capture); + + OldOffset = m_Position.PlayOffset; + + if (Position < m_CommonBufferOffset) + { + UpdateCommonBufferOverlap(Position, m_FrameSize); + } + else if (Position >= m_CommonBufferOffset) + { + UpdateCommonBuffer(Position, m_FrameSize); + } + + NewOffset = m_Position.PlayOffset; + + GeneratePositionEvents(OldOffset, NewOffset); } - - Status = m_Stream->GetPosition(&Position); - DPRINT("Position %u Buffer %p BufferSize %u ActiveIrpOffset %u Capture %u\n", Position, Buffer, m_CommonBufferSize, BufferSize, m_Capture); - - OldOffset = m_Position.PlayOffset; - - if (Position < m_CommonBufferOffset) - { - UpdateCommonBufferOverlap(Position, m_FrameSize); - } - else if (Position >= m_CommonBufferOffset) - { - UpdateCommonBuffer(Position, m_FrameSize); - } - - NewOffset = m_Position.PlayOffset; - - GeneratePositionEvents(OldOffset, NewOffset); } NTSTATUS @@ -1239,7 +1242,7 @@ CPortPinWaveCyclic::Init( m_Stream->Silence(SilenceBuffer, m_FrameSize); m_Stream->Silence(m_CommonBuffer, m_CommonBufferSize); - Status = m_IrpQueue->Init(ConnectDetails, DataFormat, DeviceObject, m_FrameSize, 0, SilenceBuffer); + Status = m_IrpQueue->Init(ConnectDetails, m_FrameSize, 0, SilenceBuffer); if (!NT_SUCCESS(Status)) { m_IrpQueue->Release(); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp index d13f52e0baa..bfda8c93c78 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp @@ -432,9 +432,12 @@ CPortPinWavePci::RequestService() { PC_ASSERT_IRQL(DISPATCH_LEVEL); - m_Stream->Service(); - //TODO - //generate events + if (m_State == KSSTATE_RUN) + { + m_Stream->Service(); + //TODO + //generate events + } } //================================================================================================================================== @@ -829,7 +832,7 @@ CPortPinWavePci::Init( if (!NT_SUCCESS(Status)) return Status; - Status = m_IrpQueue->Init(ConnectDetails, m_Format, DeviceObject, m_AllocatorFraming.FrameSize, m_AllocatorFraming.FileAlignment, NULL); + Status = m_IrpQueue->Init(ConnectDetails, m_AllocatorFraming.FrameSize, m_AllocatorFraming.FileAlignment, NULL); if (!NT_SUCCESS(Status)) { DPRINT("IrpQueue_Init failed with %x\n", Status); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp index 439f8aba75e..0aa281d0032 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp @@ -587,7 +587,7 @@ CPortPinWaveRT::Init( goto cleanup; } - Status = m_IrpQueue->Init(ConnectDetails, DataFormat, DeviceObject, 0, 0, NULL); + Status = m_IrpQueue->Init(ConnectDetails, 0, 0, NULL); if (!NT_SUCCESS(Status)) { goto cleanup; From 309fb1c02ad3bb0879da6b0b42ed0563746b8843 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 5 Mar 2010 10:11:54 +0000 Subject: [PATCH 100/211] [PORTCLS] - Implement a function to retrieve the current acquired mapping tag range of the miniport driver - Call RevokeMappings when audio pin is stopped svn path=/trunk/; revision=45862 --- .../wdm/audio/backpln/portcls/interfaces.hpp | 11 ++++- .../wdm/audio/backpln/portcls/irpstream.cpp | 47 +++++++++++++++++++ .../audio/backpln/portcls/pin_wavecyclic.cpp | 1 - .../wdm/audio/backpln/portcls/pin_wavepci.cpp | 31 ++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp b/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp index 50e50d33a4d..730b6a3adfb 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp @@ -351,6 +351,11 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHOD_(BOOLEAN, HasLastMappingFailed)(THIS) PURE; STDMETHOD_(ULONG, GetCurrentIrpOffset)(THIS) PURE; + + STDMETHOD_(BOOLEAN, GetAcquiredTagRange)(THIS_ + IN PVOID * FirstTag, + IN PVOID * LastTag); + }; @@ -387,7 +392,11 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) IN PVOID Tag); \ \ STDMETHODIMP_(BOOLEAN) HasLastMappingFailed(THIS); \ - STDMETHODIMP_(ULONG) GetCurrentIrpOffset(THIS); + STDMETHODIMP_(ULONG) GetCurrentIrpOffset(THIS); \ + STDMETHODIMP_(BOOLEAN) GetAcquiredTagRange(THIS_ \ + IN PVOID * FirstTag, \ + IN PVOID * LastTag); + /***************************************************************************** diff --git a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp index 25e1683216a..50d55fb4901 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp @@ -539,6 +539,53 @@ CIrpQueue::GetCurrentIrpOffset() return m_CurrentOffset; } +BOOLEAN +NTAPI +CIrpQueue::GetAcquiredTagRange( + IN PVOID * FirstTag, + IN PVOID * LastTag) +{ + KIRQL OldLevel; + BOOLEAN Ret = FALSE; + PIRP Irp; + PLIST_ENTRY CurEntry; + + KeAcquireSpinLock(&m_IrpListLock, &OldLevel); + + if (!IsListEmpty(&m_FreeIrpList)) + { + // get first entry + CurEntry = RemoveHeadList(&m_FreeIrpList); + // get irp from list entry + Irp = (PIRP)CONTAINING_RECORD(CurEntry, IRP, Tail.Overlay.ListEntry); + + // get tag of first acquired buffer + *FirstTag = Irp->Tail.Overlay.DriverContext[3]; + + // put back irp + InsertHeadList(&m_FreeIrpList, &Irp->Tail.Overlay.ListEntry); + + // get last entry + CurEntry = RemoveTailList(&m_FreeIrpList); + // get irp from list entry + Irp = (PIRP)CONTAINING_RECORD(CurEntry, IRP, Tail.Overlay.ListEntry); + + // get tag of first acquired buffer + *LastTag = Irp->Tail.Overlay.DriverContext[3]; + + // put back irp + InsertTailList(&m_FreeIrpList, &Irp->Tail.Overlay.ListEntry); + + // indicate success + Ret = TRUE; + } + + // release lock + KeReleaseSpinLock(&m_IrpListLock, OldLevel); + // done + return Ret; +} + NTSTATUS NTAPI NewIrpQueue( diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp index f74ea0919c6..ff02905e386 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp @@ -347,7 +347,6 @@ PinWaveCyclicAudioPosition( DPRINT("Play %lu Write %lu\n", Position->PlayOffset, Position->WriteOffset); } - Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION); return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp index bfda8c93c78..935ece83ec7 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp @@ -195,6 +195,8 @@ PinWavePciState( NTSTATUS Status = STATUS_UNSUCCESSFUL; CPortPinWavePci *Pin; PSUBDEVICE_DESCRIPTOR Descriptor; + PVOID FirstTag, LastTag; + ULONG MappingsRevoked; PKSSTATE State = (PKSSTATE)Data; // get sub device descriptor @@ -221,6 +223,35 @@ PinWavePciState( { // store new state Pin->m_State = *State; + if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && Pin->m_State == KSSTATE_STOP) + { + // FIXME + // complete with successful state + Pin->m_IrpQueue->CancelBuffers(); + while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag)) + { + Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked); + DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked); + KeStallExecutionProcessor(10); + } + Pin->m_Position.PlayOffset = 0; + Pin->m_Position.WriteOffset = 0; + } + else if (Pin->m_State == KSSTATE_STOP) + { + Pin->m_IrpQueue->CancelBuffers(); + while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag)) + { + Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked); + DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked); + KeStallExecutionProcessor(10); + } + Pin->m_Position.PlayOffset = 0; + Pin->m_Position.WriteOffset = 0; + } + // store result + Irp->IoStatus.Information = sizeof(KSSTATE); + } // store result Irp->IoStatus.Information = sizeof(KSSTATE); From ebfc1156945492cf70132bee64ed16400ba62c1c Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 5 Mar 2010 13:16:52 +0000 Subject: [PATCH 101/211] [UNIATA] - Reduce pause between SelectDrive and ATAPI_RESET from 10000 to 500 (as it is in the old ATAPI driver). svn path=/trunk/; revision=45868 --- reactos/drivers/storage/ide/uniata/id_ata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/storage/ide/uniata/id_ata.cpp b/reactos/drivers/storage/ide/uniata/id_ata.cpp index 70976684235..5bb5cf74009 100644 --- a/reactos/drivers/storage/ide/uniata/id_ata.cpp +++ b/reactos/drivers/storage/ide/uniata/id_ata.cpp @@ -687,7 +687,7 @@ AtapiSoftReset( GetBaseStatus(chan, statusByte2); KdPrint2((PRINT_PREFIX " statusByte2 %x:\n", statusByte2)); SelectDrive(chan, DeviceNumber); - AtapiStallExecution(10000); + AtapiStallExecution(500); AtapiWritePort1(chan, IDX_IO1_o_Command, IDE_COMMAND_ATAPI_RESET); // ReactOS modification: Already stop looping when we know that the drive has finished resetting. From eb6bae0c08f2a8fce1a8ee670ef5ffced3047b43 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 5 Mar 2010 13:23:43 +0000 Subject: [PATCH 102/211] [UNIATA] - Really perform a controller hard-reset if it can't recover from a soft reset. Fixes VirtualBox one IDE controller configuration (master - IDE, slave - ATAPI). See issue #5145 for more details. svn path=/trunk/; revision=45869 --- reactos/drivers/storage/ide/uniata/id_probe.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/reactos/drivers/storage/ide/uniata/id_probe.cpp b/reactos/drivers/storage/ide/uniata/id_probe.cpp index 752c88c826e..725f5ffe790 100644 --- a/reactos/drivers/storage/ide/uniata/id_probe.cpp +++ b/reactos/drivers/storage/ide/uniata/id_probe.cpp @@ -2723,6 +2723,7 @@ CheckDevice( signatureHigh; UCHAR statusByte; ULONG RetVal=0; + ULONG waitCount = 10000; KdPrint2((PRINT_PREFIX "CheckDevice: Device %#x\n", deviceNumber)); @@ -2745,7 +2746,22 @@ CheckDevice( // Perform hard-reset. KdPrint2((PRINT_PREFIX "CheckDevice: BUSY\n")); + + AtapiWritePort1(chan, IDX_IO2_o_Control, IDE_DC_RESET_CONTROLLER ); + AtapiStallExecution(500 * 1000); + AtapiWritePort1(chan, IDX_IO2_o_Control, IDE_DC_REENABLE_CONTROLLER); + SelectDrive(chan, deviceNumber & 0x01); + + do { + // Wait for Busy to drop. + AtapiStallExecution(100); + GetStatus(chan, statusByte); + + } while ((statusByte & IDE_STATUS_BUSY) && waitCount--); + GetBaseStatus(chan, statusByte); + KdPrint2((PRINT_PREFIX + "CheckDevice: status after hard reset %x\n", statusByte)); } if((statusByte | IDE_STATUS_BUSY) == 0xff) { From 4834e2c3d5203302bf10bdda3b6b1a92e1c9a355 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 5 Mar 2010 16:40:40 +0000 Subject: [PATCH 103/211] - Detach the device object from the stack before deleting it - Add a hack that selects the correct display number to use which allows other drivers to take over if one driver's HwFindAdapter fails - This allows ROS to work on non-VESA 2.0 compliant video cards if /NOVESA is specified - NOTE: VGA seems to have regressed quite a bit. The mouse doesn't show up but still works. svn path=/trunk/; revision=45872 --- reactos/drivers/video/videoprt/videoprt.c | 37 +++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/reactos/drivers/video/videoprt/videoprt.c b/reactos/drivers/video/videoprt/videoprt.c index 0d85bb559e7..19a64f7b53c 100644 --- a/reactos/drivers/video/videoprt/videoprt.c +++ b/reactos/drivers/video/videoprt/videoprt.c @@ -322,7 +322,6 @@ IntVideoPortCreateAdapterDeviceObject( } -/* FIXME: we have to detach the device object in IntVideoPortFindAdapter if it fails */ NTSTATUS NTAPI IntVideoPortFindAdapter( IN PDRIVER_OBJECT DriverObject, @@ -341,7 +340,7 @@ IntVideoPortFindAdapter( WCHAR SymlinkBuffer[20]; UNICODE_STRING SymlinkName; BOOL LegacyDetection = FALSE; - ULONG DeviceNumber; + ULONG DeviceNumber, DisplayNumber; DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension; DeviceNumber = DeviceExtension->DeviceNumber; @@ -423,6 +422,8 @@ IntVideoPortFindAdapter( { WARN_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status); RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); IoDeleteDevice(DeviceObject); return Status; @@ -444,6 +445,8 @@ IntVideoPortFindAdapter( { WARN_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status); RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); IoDeleteDevice(DeviceObject); return Status; } @@ -458,12 +461,30 @@ IntVideoPortFindAdapter( RtlInitUnicodeString(&DeviceName, DeviceBuffer); /* Create symbolic link "\??\DISPLAYx" */ - swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1); - RtlInitUnicodeString(&SymlinkName, SymlinkBuffer); - IoCreateSymbolicLink(&SymlinkName, &DeviceName); + + /* HACK: We need this to find the first available display to + * use. We can't use the device number because then we could + * end up with \Device\Video0 being non-functional because + * HwFindAdapter returned an error. \Device\Video1 would be + * the correct primary display but it would be set to DISPLAY2 + * so it would never be used and ROS would bugcheck on boot. + * By doing it this way, we ensure that DISPLAY1 is always + * functional. Another idea would be letting the IO manager + * give our video devices names then getting those names + * somehow and creating symbolic links to \Device\VideoX + * and \??\DISPLAYX once we know that HwFindAdapter has succeeded. + */ + DisplayNumber = 0; + do + { + DisplayNumber++; + swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DisplayNumber); + RtlInitUnicodeString(&SymlinkName, SymlinkBuffer); + } + while (IoCreateSymbolicLink(&SymlinkName, &DeviceName) != STATUS_SUCCESS); /* Add entry to DEVICEMAP\VIDEO key in registry. */ - swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DeviceNumber); + swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DisplayNumber - 1); RtlWriteRegistryValue( RTL_REGISTRY_DEVICEMAP, L"VIDEO", @@ -489,6 +510,8 @@ IntVideoPortFindAdapter( if (!IntVideoPortSetupInterrupt(DeviceObject, DriverExtension, &ConfigInfo)) { RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); IoDeleteDevice(DeviceObject); return STATUS_INSUFFICIENT_RESOURCES; } @@ -501,6 +524,8 @@ IntVideoPortFindAdapter( { if (DeviceExtension->InterruptObject != NULL) IoDisconnectInterrupt(DeviceExtension->InterruptObject); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); RtlFreeUnicodeString(&DeviceExtension->RegistryPath); IoDeleteDevice(DeviceObject); WARN_(VIDEOPRT, "STATUS_INSUFFICIENT_RESOURCES\n"); From 5ba4b4bbebd8a4392982d5268e8acaa5f905bef5 Mon Sep 17 00:00:00 2001 From: evb Date: Fri, 5 Mar 2010 17:22:18 +0000 Subject: [PATCH 104/211] - Add new unified VGA/VBE miniport driver. Based on NT4 DDK Cirrus Miniport Driver Sample with my modifications (marked with // eVb) to change Cirrus parts to VGA parts if needed. Also add VBE suppor which is not in Cirrus driver, but exists in Windows VGA miniport. - Work-in-progress, can boot to GUI with VMWare, but banked modes not yet supported, no VDM, no Mode-X, etc... - Thanks to sir_richard for help with headers, comments and other English stuff. - Driver is only built, not yet used. - NOTE: Some parts of BootVid seem to use functions copied from this sample (VgaInterpretCmdStream) but under "GPL", and also buggy (Chain4 Mode test will not work on most cards and VgaIsPresent == FALSE). Someone should fix. svn path=/trunk/; revision=45873 --- .../drivers/video/miniport/directory.rbuild | 7 +- .../drivers/video/miniport/vga_new/cmdcnst.h | 92 ++ .../drivers/video/miniport/vga_new/modeset.c | 747 +++++++++ reactos/drivers/video/miniport/vga_new/vbe.c | 196 +++ reactos/drivers/video/miniport/vga_new/vbe.h | 217 +++ .../drivers/video/miniport/vga_new/vbemodes.c | 449 ++++++ reactos/drivers/video/miniport/vga_new/vga.c | 1401 +++++++++++++++++ reactos/drivers/video/miniport/vga_new/vga.h | 446 ++++++ .../drivers/video/miniport/vga_new/vga.rbuild | 18 + reactos/drivers/video/miniport/vga_new/vga.rc | 5 + .../drivers/video/miniport/vga_new/vgadata.c | 490 ++++++ 11 files changed, 4063 insertions(+), 5 deletions(-) create mode 100644 reactos/drivers/video/miniport/vga_new/cmdcnst.h create mode 100644 reactos/drivers/video/miniport/vga_new/modeset.c create mode 100644 reactos/drivers/video/miniport/vga_new/vbe.c create mode 100644 reactos/drivers/video/miniport/vga_new/vbe.h create mode 100644 reactos/drivers/video/miniport/vga_new/vbemodes.c create mode 100644 reactos/drivers/video/miniport/vga_new/vga.c create mode 100644 reactos/drivers/video/miniport/vga_new/vga.h create mode 100644 reactos/drivers/video/miniport/vga_new/vga.rbuild create mode 100644 reactos/drivers/video/miniport/vga_new/vga.rc create mode 100644 reactos/drivers/video/miniport/vga_new/vgadata.c diff --git a/reactos/drivers/video/miniport/directory.rbuild b/reactos/drivers/video/miniport/directory.rbuild index 2575e1a7677..b61f80c1fda 100644 --- a/reactos/drivers/video/miniport/directory.rbuild +++ b/reactos/drivers/video/miniport/directory.rbuild @@ -1,11 +1,8 @@ - - - - - + + diff --git a/reactos/drivers/video/miniport/vga_new/cmdcnst.h b/reactos/drivers/video/miniport/vga_new/cmdcnst.h new file mode 100644 index 00000000000..c818b49d494 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/cmdcnst.h @@ -0,0 +1,92 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/cmdcnst.h + * PURPOSE: Command Code Definitions for VGA Command Streams + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + */ + + +//-------------------------------------------------------------------------- +// Definition of the set/clear mode command language. +// +// Each command is composed of a major portion and a minor portion. +// The major portion of a command can be found in the most significant +// nibble of a command byte, while the minor portion is in the least +// significant portion of a command byte. +// +// maj minor Description +// ---- ----- -------------------------------------------- +// 00 End of data +// +// 10 in and out type commands as described by flags +// flags: +// +// xxxx +// |||| +// |||+-------- unused +// ||+--------- 0/1 single/multiple values to output (in's are always +// |+---------- 0/1 8/16 bit operation single) +// +----------- 0/1 out/in instruction +// +// Outs +// ---------------------------------------------- +// 0 reg:W val:B +// 2 reg:W cnt:W val1:B val2:B...valN:B +// 4 reg:W val:W +// 6 reg:W cnt:W val1:W val2:W...valN:W +// +// Ins +// ---------------------------------------------- +// 8 reg:W +// a reg:W cnt:W +// c reg:W +// e reg:W cnt:W +// +// 20 Special purpose outs +// 00 do indexed outs for seq, crtc, and gdc +// indexreg:W cnt:B startindex:B val1:B val2:B...valN:B +// 01 do indexed outs for atc +// index-data_reg:W cnt:B startindex:B val1:B val2:B...valN:B +// 02 do masked outs +// indexreg:W andmask:B xormask:B +// +// F0 Nop +// +//--------------------------------------------------------------------------- + +// some useful equates - major commands + +#define EOD 0x000 // end of data +#define INOUT 0x010 // do ins or outs +#define METAOUT 0x020 // do special types of outs +#define NCMD 0x0f0 // Nop command + + +// flags for INOUT major command + +//#define UNUSED 0x01 // reserved +#define MULTI 0x02 // multiple or single outs +#define BW 0x04 // byte/word size of operation +#define IO 0x08 // out/in instruction + +// minor commands for metout + +#define INDXOUT 0x00 // do indexed outs +#define ATCOUT 0x01 // do indexed outs for atc +#define MASKOUT 0x02 // do masked outs using and-xor masks + + +// composite inout type commands + +#define OB (INOUT) // output 8 bit value +#define OBM (INOUT+MULTI) // output multiple bytes +#define OW (INOUT+BW) // output single word value +#define OWM (INOUT+BW+MULTI) // output multiple words + +#define IB (INOUT+IO) // input byte +#define IBM (INOUT+IO+MULTI) // input multiple bytes +#define IW (INOUT+IO+BW) // input word +#define IWM (INOUT+IO+BW+MULTI) // input multiple words + +/* EOF */ diff --git a/reactos/drivers/video/miniport/vga_new/modeset.c b/reactos/drivers/video/miniport/vga_new/modeset.c new file mode 100644 index 00000000000..83c00011a88 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/modeset.c @@ -0,0 +1,747 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/modeset.c + * PURPOSE: Handles switching to Standard VGA Modes for compatible cards + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "vga.h" + +VP_STATUS +VgaInterpretCmdStream( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PUSHORT pusCmdStream + ); + +VP_STATUS +VgaSetMode( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE Mode, + ULONG ModeSize, +// eVb: 2.1 [SET MODE] - Add new output parameter for framebuffer update functionality + PULONG PhysPtrChange +// eVb: 2.1 [END] + ); + +VP_STATUS +VgaQueryAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE_INFORMATION ModeInformation, + ULONG ModeInformationSize, + PULONG OutputSize + ); + +VP_STATUS +VgaQueryNumberOfAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_NUM_MODES NumModes, + ULONG NumModesSize, + PULONG OutputSize + ); + +VOID +VgaZeroVideoMemory( + PHW_DEVICE_EXTENSION HwDeviceExtension + ); + +#if defined(ALLOC_PRAGMA) +#pragma alloc_text(PAGE,VgaInterpretCmdStream) +#pragma alloc_text(PAGE,VgaSetMode) +#pragma alloc_text(PAGE,VgaQueryAvailableModes) +#pragma alloc_text(PAGE,VgaQueryNumberOfAvailableModes) +#pragma alloc_text(PAGE,VgaZeroVideoMemory) +#endif + +//--------------------------------------------------------------------------- +VP_STATUS +VgaInterpretCmdStream( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PUSHORT pusCmdStream + ) + +/*++ + +Routine Description: + + Interprets the appropriate command array to set up VGA registers for the + requested mode. Typically used to set the VGA into a particular mode by + programming all of the registers + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + pusCmdStream - array of commands to be interpreted. + +Return Value: + + The status of the operation (can only fail on a bad command); TRUE for + success, FALSE for failure. + +--*/ + +{ + ULONG ulCmd; + ULONG ulPort; + UCHAR jValue; + USHORT usValue; + ULONG culCount; + ULONG ulIndex; + ULONG ulBase; + + if (pusCmdStream == NULL) { + + VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n")); + return TRUE; + } + + ulBase = (ULONG)HwDeviceExtension->IOAddress; + + // + // Now set the adapter to the desired mode. + // + + while ((ulCmd = *pusCmdStream++) != EOD) { + + // + // Determine major command type + // + + switch (ulCmd & 0xF0) { + + // + // Basic input/output command + // + + case INOUT: + + // + // Determine type of inout instruction + // + + if (!(ulCmd & IO)) { + + // + // Out instruction. Single or multiple outs? + // + + if (!(ulCmd & MULTI)) { + + // + // Single out. Byte or word out? + // + + if (!(ulCmd & BW)) { + + // + // Single byte out + // + + ulPort = *pusCmdStream++; + jValue = (UCHAR) *pusCmdStream++; + VideoPortWritePortUchar((PUCHAR)(ulBase+ulPort), + jValue); + + } else { + + // + // Single word out + // + + ulPort = *pusCmdStream++; + usValue = *pusCmdStream++; + VideoPortWritePortUshort((PUSHORT)(ulBase+ulPort), + usValue); + + } + + } else { + + // + // Output a string of values + // Byte or word outs? + // + + if (!(ulCmd & BW)) { + + // + // String byte outs. Do in a loop; can't use + // VideoPortWritePortBufferUchar because the data + // is in USHORT form + // + + ulPort = ulBase + *pusCmdStream++; + culCount = *pusCmdStream++; + + while (culCount--) { + jValue = (UCHAR) *pusCmdStream++; + VideoPortWritePortUchar((PUCHAR)ulPort, + jValue); + + } + + } else { + + // + // String word outs + // + + ulPort = *pusCmdStream++; + culCount = *pusCmdStream++; + VideoPortWritePortBufferUshort((PUSHORT) + (ulBase + ulPort), pusCmdStream, culCount); + pusCmdStream += culCount; + + } + } + + } else { + + // In instruction + // + // Currently, string in instructions aren't supported; all + // in instructions are handled as single-byte ins + // + // Byte or word in? + // + + if (!(ulCmd & BW)) { + // + // Single byte in + // + + ulPort = *pusCmdStream++; + jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort); + + } else { + + // + // Single word in + // + + ulPort = *pusCmdStream++; + usValue = VideoPortReadPortUshort((PUSHORT) + (ulBase+ulPort)); + + } + + } + + break; + + // + // Higher-level input/output commands + // + + case METAOUT: + + // + // Determine type of metaout command, based on minor + // command field + // + switch (ulCmd & 0x0F) { + + // + // Indexed outs + // + + case INDXOUT: + + ulPort = ulBase + *pusCmdStream++; + culCount = *pusCmdStream++; + ulIndex = *pusCmdStream++; + + while (culCount--) { + + usValue = (USHORT) (ulIndex + + (((ULONG)(*pusCmdStream++)) << 8)); + VideoPortWritePortUshort((PUSHORT)ulPort, usValue); + + ulIndex++; + + } + + break; + + // + // Masked out (read, AND, XOR, write) + // + + case MASKOUT: + + ulPort = *pusCmdStream++; + jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort); + jValue &= *pusCmdStream++; + jValue ^= *pusCmdStream++; + VideoPortWritePortUchar((PUCHAR)ulBase + ulPort, + jValue); + break; + + // + // Attribute Controller out + // + + case ATCOUT: + + ulPort = ulBase + *pusCmdStream++; + culCount = *pusCmdStream++; + ulIndex = *pusCmdStream++; + + while (culCount--) { + + // Write Attribute Controller index + VideoPortWritePortUchar((PUCHAR)ulPort, + (UCHAR)ulIndex); + + // Write Attribute Controller data + jValue = (UCHAR) *pusCmdStream++; + VideoPortWritePortUchar((PUCHAR)ulPort, jValue); + + ulIndex++; + + } + + break; + + // + // None of the above; error + // + default: + + return FALSE; + + } + + + break; + + // + // NOP + // + + case NCMD: + + break; + + // + // Unknown command; error + // + + default: + + return FALSE; + + } + + } + + return TRUE; + +} // end VgaInterpretCmdStream() + + +VP_STATUS +VgaSetMode( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE Mode, + ULONG ModeSize, +// eVb: 2.2 [SET MODE] - Add new output parameter for framebuffer update functionality + PULONG PhysPtrChange +// eVb: 2.2 [END] + ) + +/*++ + +Routine Description: + + This routine sets the vga into the requested mode. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + Mode - Pointer to the structure containing the information about the + font to be set. + + ModeSize - Length of the input buffer supplied by the user. + +Return Value: + + ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough + for the input data. + + ERROR_INVALID_PARAMETER if the mode number is invalid. + + NO_ERROR if the operation completed successfully. + +--*/ + +{ + PVIDEOMODE pRequestedMode; + VP_STATUS status; + ULONG RequestedModeNum; +// eVb: 2.3 [SET MODE] - Add new output parameter for framebuffer update functionality + *PhysPtrChange = FALSE; +// eVb: 2.3 [END] + // + // Check if the size of the data in the input buffer is large enough. + // + + if (ModeSize < sizeof(VIDEO_MODE)) + { + return ERROR_INSUFFICIENT_BUFFER; + } + + // + // Extract the clear memory, and map linear bits. + // + + RequestedModeNum = Mode->RequestedMode & + ~(VIDEO_MODE_NO_ZERO_MEMORY | VIDEO_MODE_MAP_MEM_LINEAR); + + + if (!(Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY)) + { +#if defined(_X86_) + VgaZeroVideoMemory(HwDeviceExtension); +#endif + } + + // + // Check to see if we are requesting a valid mode + // +// eVb: 2.4 [CIRRUS] - Remove Cirrus-specific check for valid mode + if ( (RequestedModeNum >= NumVideoModes) ) +// eVb: 2.4 [END] + { + VideoDebugPrint((0, "Invalide Mode Number = %d!\n", RequestedModeNum)); + + return ERROR_INVALID_PARAMETER; + } + + VideoDebugPrint((2, "Attempting to set mode %d\n", + RequestedModeNum)); +// eVb: 2.5 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list + pRequestedMode = &VgaModeList[RequestedModeNum]; +// eVb: 2.5 [END] + VideoDebugPrint((2, "Info on Requested Mode:\n" + "\tResolution: %dx%d\n", + pRequestedMode->hres, + pRequestedMode->vres )); + + // + // VESA BIOS mode switch + // +// eVb: 2.6 [VBE] - VBE Mode Switch Support + status = VbeSetMode(HwDeviceExtension, pRequestedMode, PhysPtrChange); + if (status == ERROR_INVALID_FUNCTION) + { + // + // VGA mode switch + // + + if (!pRequestedMode->CmdStream) return ERROR_INVALID_FUNCTION; + if (!VgaInterpretCmdStream(HwDeviceExtension, pRequestedMode->CmdStream)) return ERROR_INVALID_FUNCTION; + goto Cleanup; + } + else if (status != NO_ERROR) return status; +// eVb: 2.6 [END] +// eVb: 2.7 [MODE-X] - Windows VGA Miniport Supports Mode-X, we should too + // + // ModeX check + // + + if (pRequestedMode->hres == 320) + { + VideoPortDebugPrint(0, "ModeX not support!!!\n"); + return ERROR_INVALID_PARAMETER; + } +// eVb: 2.7 [END] + // + // Text mode check + // + + if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS)) + { +// eVb: 2.8 [TODO] - This code path is not implemented yet + VideoPortDebugPrint(0, "Text-mode not support!!!\n"); + return ERROR_INVALID_PARAMETER; +// eVb: 2.8 [END] + } + +Cleanup: + // + // Update the location of the physical frame buffer within video memory. + // +// eVb: 2.9 [VBE] - Linear and banked support is unified in VGA, unlike Cirrus + HwDeviceExtension->PhysicalVideoMemoryBase.LowPart = pRequestedMode->PhysBase; + HwDeviceExtension->PhysicalVideoMemoryLength = pRequestedMode->PhysSize; + + HwDeviceExtension->PhysicalFrameLength = + pRequestedMode->FrameBufferSize; + + HwDeviceExtension->PhysicalFrameOffset.LowPart = + pRequestedMode->FrameBufferBase; +// eVb: 2.9 [END] + + // + // Store the new mode value. + // + + HwDeviceExtension->CurrentMode = pRequestedMode; + HwDeviceExtension->ModeIndex = Mode->RequestedMode; + + return NO_ERROR; + +} //end VgaSetMode() + +VP_STATUS +VgaQueryAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE_INFORMATION ModeInformation, + ULONG ModeInformationSize, + PULONG OutputSize + ) + +/*++ + +Routine Description: + + This routine returns the list of all available available modes on the + card. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + ModeInformation - Pointer to the output buffer supplied by the user. + This is where the list of all valid modes is stored. + + ModeInformationSize - Length of the output buffer supplied by the user. + + OutputSize - Pointer to a buffer in which to return the actual size of + the data in the buffer. If the buffer was not large enough, this + contains the minimum required buffer size. + +Return Value: + + ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough + for the data being returned. + + NO_ERROR if the operation completed successfully. + +--*/ + +{ + PVIDEO_MODE_INFORMATION videoModes = ModeInformation; + ULONG i; + + // + // Find out the size of the data to be put in the buffer and return + // that in the status information (whether or not the information is + // there). If the buffer passed in is not large enough return an + // appropriate error code. + // + + if (ModeInformationSize < (*OutputSize = +// eVb: 2.10 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus + NumVideoModes * +// eVb: 2.10 [END] + sizeof(VIDEO_MODE_INFORMATION)) ) { + + return ERROR_INSUFFICIENT_BUFFER; + + } + + // + // For each mode supported by the card, store the mode characteristics + // in the output buffer. + // + + for (i = 0; i < NumVideoModes; i++) + { + videoModes->Length = sizeof(VIDEO_MODE_INFORMATION); + videoModes->ModeIndex = i; +// eVb: 2.11 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list + videoModes->VisScreenWidth = VgaModeList[i].hres; + videoModes->ScreenStride = VgaModeList[i].wbytes; + videoModes->VisScreenHeight = VgaModeList[i].vres; + videoModes->NumberOfPlanes = VgaModeList[i].numPlanes; + videoModes->BitsPerPlane = VgaModeList[i].bitsPerPlane; + videoModes->Frequency = VgaModeList[i].Frequency; + videoModes->XMillimeter = 320; // temporary hardcoded constant + videoModes->YMillimeter = 240; // temporary hardcoded constant + videoModes->AttributeFlags = VgaModeList[i].fbType; +// eVb: 2.11 [END] + + if ((VgaModeList[i].bitsPerPlane == 32) || + (VgaModeList[i].bitsPerPlane == 24)) + { + + videoModes->NumberRedBits = 8; + videoModes->NumberGreenBits = 8; + videoModes->NumberBlueBits = 8; + videoModes->RedMask = 0xff0000; + videoModes->GreenMask = 0x00ff00; + videoModes->BlueMask = 0x0000ff; + + } + else if (VgaModeList[i].bitsPerPlane == 16) + { + + videoModes->NumberRedBits = 6; + videoModes->NumberGreenBits = 6; + videoModes->NumberBlueBits = 6; + videoModes->RedMask = 0x1F << 11; + videoModes->GreenMask = 0x3F << 5; + videoModes->BlueMask = 0x1F; + + } +// eVb: 2.12 [VGA] - Add support for 15bpp modes, which Cirrus doesn't support + else if (VgaModeList[i].bitsPerPlane == 15) + { + + videoModes->NumberRedBits = 6; + videoModes->NumberGreenBits = 6; + videoModes->NumberBlueBits = 6; + videoModes->RedMask = 0x3E << 9; + videoModes->GreenMask = 0x1F << 5; + videoModes->BlueMask = 0x1F; + } +// eVb: 2.12 [END] + else + { + + videoModes->NumberRedBits = 6; + videoModes->NumberGreenBits = 6; + videoModes->NumberBlueBits = 6; + videoModes->RedMask = 0; + videoModes->GreenMask = 0; + videoModes->BlueMask = 0; + } + +// eVb: 2.13 [VGA] - All modes are palette managed/driven, unlike Cirrus + videoModes->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN | + VIDEO_MODE_MANAGED_PALETTE; +// eVb: 2.13 [END] + videoModes++; + + } + + return NO_ERROR; + +} // end VgaGetAvailableModes() + +VP_STATUS +VgaQueryNumberOfAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_NUM_MODES NumModes, + ULONG NumModesSize, + PULONG OutputSize + ) + +/*++ + +Routine Description: + + This routine returns the number of available modes for this particular + video card. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + NumModes - Pointer to the output buffer supplied by the user. This is + where the number of modes is stored. + + NumModesSize - Length of the output buffer supplied by the user. + + OutputSize - Pointer to a buffer in which to return the actual size of + the data in the buffer. + +Return Value: + + ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough + for the data being returned. + + NO_ERROR if the operation completed successfully. + +--*/ + +{ + // + // Find out the size of the data to be put in the the buffer and return + // that in the status information (whether or not the information is + // there). If the buffer passed in is not large enough return an + // appropriate error code. + // + + if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) { + + return ERROR_INSUFFICIENT_BUFFER; + + } + + // + // Store the number of modes into the buffer. + // + +// eVb: 2.14 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus + NumModes->NumModes = NumVideoModes; +// eVb: 2.14 [END] + NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION); + + return NO_ERROR; + +} // end VgaGetNumberOfAvailableModes() + +VOID +VgaZeroVideoMemory( + PHW_DEVICE_EXTENSION HwDeviceExtension + ) + +/*++ + +Routine Description: + + This routine zeros the first 256K on the VGA. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + +Return Value: + + None. + +--*/ +{ + UCHAR temp; + + // + // Map font buffer at A0000 + // + + VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data); + + // + // Enable all planes. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_ADDRESS_PORT, + IND_MAP_MASK); + + temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT) | (UCHAR)0x0F; + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT, + temp); + + VideoPortZeroDeviceMemory(HwDeviceExtension->VideoMemoryAddress, 0xFFFF); + + VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color); + +} diff --git a/reactos/drivers/video/miniport/vga_new/vbe.c b/reactos/drivers/video/miniport/vga_new/vbe.c new file mode 100644 index 00000000000..a2c593da460 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/vbe.c @@ -0,0 +1,196 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/video/miniport/vga/vbe.c + * PURPOSE: Main VESA VBE 1.02+ SVGA Miniport Handling Code + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include "vga.h" + +/* GLOBALS ********************************************************************/ + +static const PCHAR Nv11Board = "NV11 (GeForce2) Board"; +static const PCHAR Nv11Chip = "Chip Rev B2"; +static const PCHAR Nv11Vendor = "NVidia Corporation"; +static const PCHAR IntelBrookdale = "Brookdale-G Graphics Controller"; +static const PCHAR BrokenVesaBiosList[] = +{ + "SiS 5597", + "MGA-G100", + "3Dfx Banshee", + "Voodoo3 2000 LC ", + "Voodoo3 3000 LC ", + "Voodoo4 4500 ", + "ArtX I", + "ATI S1-370TL" +}; + +BOOLEAN g_bIntelBrookdaleBIOS; + +/* FUNCTIONS ******************************************************************/ + +BOOLEAN +NTAPI +IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, + IN ULONG OemRevision, + IN PCHAR Vendor, + IN PCHAR Product, + IN PCHAR Revision) +{ + ULONG i; + CHAR Version[21]; + + /* If the broken VESA bios found, turn VESA off */ + VideoPortDebugPrint(0, "Vendor: %s Product: %s Revision: %s (%lx)\n", Vendor, Product, Revision, OemRevision); + for (i = 0; i < (sizeof(BrokenVesaBiosList) / sizeof(PCHAR)); i++) + { + if (!strncmp(Product, BrokenVesaBiosList[i], sizeof(BrokenVesaBiosList[i]))) return FALSE; + } + + /* For Brookdale-G (Intel), special hack used */ + g_bIntelBrookdaleBIOS = !strncmp(Product, IntelBrookdale, sizeof(IntelBrookdale)); + + /* For NVIDIA make sure */ + if (!(strncmp(Vendor, Nv11Vendor, sizeof(Nv11Vendor))) && + !(strncmp(Product, Nv11Board, sizeof(Nv11Board))) && + !(strncmp(Revision, Nv11Chip, sizeof(Nv11Chip))) && + (OemRevision == 0x311)) + { + /* Read version */ + if (Interface->Int10ReadMemory(Interface->Context, + 0xC000, + 345, + Version, + sizeof(Version))) return FALSE; + if (!strncmp(Version, "Version 3.11.01.24N16", sizeof(Version))) return FALSE; + } + + /* VESA ok */ + //VideoPortDebugPrint(0, "Vesa ok\n"); + return TRUE; +} + +BOOLEAN +NTAPI +ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVBE_INFO VbeInfo) +{ + BOOLEAN VesaBiosOk; + PVOID Context; + CHAR ProductRevision[80]; + CHAR OemString[80]; + CHAR ProductName[80]; + CHAR VendorName[80]; + VP_STATUS Status; + + /* Set default */ + VesaBiosOk = FALSE; + Context = VgaExtension->Int10Interface.Context; + + /* Check magic and version */ + if (strncmp(VbeInfo->Info.Signature, "VESA", 4)) return VesaBiosOk; + if (VbeInfo->Info.Version < 0x102) return VesaBiosOk; + + /* Read strings */ + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.OemStringPtr), + LOWORD(VbeInfo->Info.OemStringPtr), + OemString, + sizeof(OemString)); + if (Status != NO_ERROR) return VesaBiosOk; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.OemVendorNamePtr), + LOWORD(VbeInfo->Info.OemVendorNamePtr), + VendorName, + sizeof(VendorName)); + if (Status != NO_ERROR) return VesaBiosOk; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.OemProductNamePtr), + LOWORD(VbeInfo->Info.OemProductNamePtr), + ProductName, + sizeof(ProductName)); + if (Status != NO_ERROR) return VesaBiosOk; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.OemProductRevPtr), + LOWORD(VbeInfo->Info.OemProductRevPtr), + ProductRevision, + sizeof(ProductRevision)); + if (Status != NO_ERROR) return VesaBiosOk; + + /* Null-terminate strings */ + VendorName[sizeof(OemString) - 1] = ANSI_NULL; + ProductName[sizeof(OemString) - 1] = ANSI_NULL; + ProductRevision[sizeof(OemString) - 1] = ANSI_NULL; + OemString[sizeof(OemString) - 1] = ANSI_NULL; + + /* Check for known bad BIOS */ + VesaBiosOk = IsVesaBiosOk(&VgaExtension->Int10Interface, + VbeInfo->Info.OemSoftwareRevision, + VendorName, + ProductName, + ProductRevision); + VgaExtension->VesaBiosOk = VesaBiosOk; + return VesaBiosOk; +} + +VP_STATUS +NTAPI +VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVIDEO_CLUT ClutBuffer) +{ + PVBE_COLOR_REGISTER VesaClut; + INT10_BIOS_ARGUMENTS BiosArguments; + PVOID Context; + ULONG Entries; + ULONG BufferSize = 4 * 1024; + USHORT TrampolineMemorySegment, TrampolineMemoryOffset; + VP_STATUS Status; + USHORT i; + + Entries = ClutBuffer->NumEntries; + + /* Allocate INT10 context/buffer */ + VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, 0x20616756u); + if (!VesaClut) return ERROR_INVALID_PARAMETER; + if (!VgaExtension->Int10Interface.Size) return ERROR_INVALID_PARAMETER; + Context = VgaExtension->Int10Interface.Context; + Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context, + &TrampolineMemorySegment, + &TrampolineMemoryOffset, + &BufferSize); + if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; + + /* VESA has color registers backward! */ + for (i = 0; i < Entries; i++) + { + VesaClut[i].Blue = ClutBuffer->LookupTable[i].RgbArray.Blue; + VesaClut[i].Green = ClutBuffer->LookupTable[i].RgbArray.Green; + VesaClut[i].Red = ClutBuffer->LookupTable[i].RgbArray.Red; + VesaClut[i].Pad = 0; + } + Status = VgaExtension->Int10Interface.Int10WriteMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VesaClut, + Entries * sizeof(ULONG)); + if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; + + /* Write new palette */ + BiosArguments.Ebx = 0; + BiosArguments.Ecx = Entries; + BiosArguments.Edx = ClutBuffer->FirstEntry; + BiosArguments.Edi = TrampolineMemoryOffset; + BiosArguments.SegEs = TrampolineMemorySegment; + BiosArguments.Eax = VBE_SET_GET_PALETTE_DATA; + Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); + if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; + VideoPortFreePool(VgaExtension, VesaClut); + VideoPortDebugPrint(Error, "VBE Status: %lx\n", BiosArguments.Eax); + if (BiosArguments.Eax == VBE_SUCCESS) return NO_ERROR; + return ERROR_INVALID_PARAMETER; +} + +/* EOF */ diff --git a/reactos/drivers/video/miniport/vga_new/vbe.h b/reactos/drivers/video/miniport/vga_new/vbe.h new file mode 100644 index 00000000000..8802a5ead16 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/vbe.h @@ -0,0 +1,217 @@ +/* + * PROJECT: VGA Miniport Driver + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/video/miniport/vga/vbe.h + * PURPOSE: VESA VBE Registers and Structures + * PROGRAMMERS: ReactOS Portable Systems Group + */ + + +#define LOWORD(l) ((USHORT)((ULONG_PTR)(l))) +#define HIWORD(l) ((USHORT)(((ULONG_PTR)(l)>>16)&0xFFFF)) + + +/* + * VBE Command Definitions + */ + +#define VBE_GET_CONTROLLER_INFORMATION 0x4F00 +#define VBE_GET_MODE_INFORMATION 0x4F01 +#define VBE_SET_VBE_MODE 0x4F02 +#define VBE_GET_CURRENT_VBE_MODE 0x4F03 +#define VBE_SAVE_RESTORE_STATE 0x4F04 +#define VBE_DISPLAY_WINDOW_CONTROL 0x4F05 +#define VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH 0x4F06 +#define VBE_SET_GET_DISPLAY_START 0x4F07 +#define VBE_SET_GET_DAC_PALETTE_FORMAT 0x4F08 +#define VBE_SET_GET_PALETTE_DATA 0x4F09 + +/* VBE 2.0+ */ +#define VBE_RETURN_PROTECTED_MODE_INTERFACE 0x4F0A +#define VBE_GET_SET_PIXEL_CLOCK 0x4F0B + +/* Extensions */ +#define VBE_POWER_MANAGEMENT_EXTENSIONS 0x4F10 +#define VBE_FLAT_PANEL_INTERFACE_EXTENSIONS 0x4F11 +#define VBE_AUDIO_INTERFACE_EXTENSIONS 0x4F12 +#define VBE_OEM_EXTENSIONS 0x4F13 +#define VBE_DISPLAY_DATA_CHANNEL 0x4F14 +#define VBE_DDC 0x4F15 + +/* + * VBE DDC Sub-Functions + */ + +#define VBE_DDC_READ_EDID 0x01 +#define VBE_DDC_REPORT_CAPABILITIES 0x10 +#define VBE_DDC_BEGIN_SCL_SDA_CONTROL 0x11 +#define VBE_DDC_END_SCL_SDA_CONTROL 0x12 +#define VBE_DDC_WRITE_SCL_CLOCK_LINE 0x13 +#define VBE_DDC_WRITE_SDA_DATA_LINE 0x14 +#define VBE_DDC_READ_SCL_CLOCK_LINE 0x15 +#define VBE_DDC_READ_SDA_DATA_LINE 0x16 + +/* + * VBE Video Mode Information Definitions + */ +#define VBE_MODEATTR_VALID 0x01 +#define VBE_MODEATTR_COLOR 0x08 +#define VBE_MODEATTR_GRAPHICS 0x10 +#define VBE_MODEATTR_NON_VGA 0x20 +#define VBE_MODEATTR_NO_BANK_SWITCH 0x40 +#define VBE_MODEATTR_LINEAR 0x80 + +#define VBE_MODE_BITS 8 +#define VBE_MODE_RESERVED_1 0x200 +#define VBE_MODE_RESERVED_2 0x400 +#define VBE_MODE_REFRESH_CONTROL 0x800 +#define VBE_MODE_ACCELERATED_1 0x1000 +#define VBE_MODE_ACCELERATED_2 0x2000 +#define VBE_MODE_LINEAR_FRAMEBUFFER 0x4000 +#define VBE_MODE_PRESERVE_DISPLAY 0x8000 +#define VBE_MODE_MASK ((1 << (VBE_MODE_BITS + 1)) - 1) + +#define VBE_MEMORYMODEL_PACKEDPIXEL 0x04 +#define VBE_MEMORYMODEL_DIRECTCOLOR 0x06 + +/* + * VBE Return Codes + */ + +#define VBE_SUCCESS 0x4F +#define VBE_UNSUCCESSFUL 0x14F +#define VBE_NOT_SUPPORTED 0x24F +#define VBE_FUNCTION_INVALID 0x34F + +#define VBE_GETRETURNCODE(x) (x & 0xFFFF) + +#include + +/* + * VBE specification defined structure for general adapter info + * returned by function VBE_GET_CONTROLLER_INFORMATION command. + */ + +typedef struct _VBE_CONTROLLER_INFO +{ + CHAR Signature[4]; + USHORT Version; + ULONG OemStringPtr; + LONG Capabilities; + ULONG VideoModePtr; + USHORT TotalMemory; + USHORT OemSoftwareRevision; + ULONG OemVendorNamePtr; + ULONG OemProductNamePtr; + ULONG OemProductRevPtr; + CHAR Reserved[222]; + CHAR OemData[256]; +} VBE_CONTROLLER_INFO, *PVBE_CONTROLLER_INFO; + +/* + * VBE specification defined structure for specific video mode + * info returned by function VBE_GET_MODE_INFORMATION command. + */ + +typedef struct _VBE_MODE_INFO +{ + /* Mandatory information for all VBE revisions */ + USHORT ModeAttributes; + UCHAR WinAAttributes; + UCHAR WinBAttributes; + USHORT WinGranularity; + USHORT WinSize; + USHORT WinASegment; + USHORT WinBSegment; + ULONG WinFuncPtr; + USHORT BytesPerScanLine; + + /* Mandatory information for VBE 1.2 and above */ + USHORT XResolution; + USHORT YResolution; + UCHAR XCharSize; + UCHAR YCharSize; + UCHAR NumberOfPlanes; + UCHAR BitsPerPixel; + UCHAR NumberOfBanks; + UCHAR MemoryModel; + UCHAR BankSize; + UCHAR NumberOfImagePages; + UCHAR Reserved1; + + /* Direct Color fields (required for Direct/6 and YUV/7 memory models) */ + UCHAR RedMaskSize; + UCHAR RedFieldPosition; + UCHAR GreenMaskSize; + UCHAR GreenFieldPosition; + UCHAR BlueMaskSize; + UCHAR BlueFieldPosition; + UCHAR ReservedMaskSize; + UCHAR ReservedFieldPosition; + UCHAR DirectColorModeInfo; + + /* Mandatory information for VBE 2.0 and above */ + ULONG PhysBasePtr; + ULONG Reserved2; + USHORT Reserved3; + + /* Mandatory information for VBE 3.0 and above */ + USHORT LinBytesPerScanLine; + UCHAR BnkNumberOfImagePages; + UCHAR LinNumberOfImagePages; + UCHAR LinRedMaskSize; + UCHAR LinRedFieldPosition; + UCHAR LinGreenMaskSize; + UCHAR LinGreenFieldPosition; + UCHAR LinBlueMaskSize; + UCHAR LinBlueFieldPosition; + UCHAR LinReservedMaskSize; + UCHAR LinReservedFieldPosition; + ULONG MaxPixelClock; + + CHAR Reserved4[190]; +} VBE_MODE_INFO, *PVBE_MODE_INFO; + +#include + +typedef struct _VBE_INFO +{ + VBE_CONTROLLER_INFO Info; + VBE_MODE_INFO Modes; + USHORT ModeArray[129]; +} VBE_INFO, *PVBE_INFO; + +C_ASSERT(sizeof(VBE_CONTROLLER_INFO) == 0x200); +C_ASSERT(sizeof(VBE_MODE_INFO) == 0x100); + +typedef struct _VBE_COLOR_REGISTER +{ + UCHAR Blue; + UCHAR Green; + UCHAR Red; + UCHAR Pad; +} VBE_COLOR_REGISTER, *PVBE_COLOR_REGISTER; + +VOID +NTAPI +InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension); + +VP_STATUS +NTAPI +VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, + IN PVIDEOMODE VgaMode, + OUT PULONG PhysPtrChange); + +VP_STATUS +NTAPI +VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVIDEO_CLUT ClutBuffer); + +BOOLEAN +NTAPI +ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVBE_INFO VbeInfo); + +extern BOOLEAN g_bIntelBrookdaleBIOS; + +/* EOF */ diff --git a/reactos/drivers/video/miniport/vga_new/vbemodes.c b/reactos/drivers/video/miniport/vga_new/vbemodes.c new file mode 100644 index 00000000000..39537c64563 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/vbemodes.c @@ -0,0 +1,449 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/video/miniport/vga/vbemodes.c + * PURPOSE: Mode Initialization and Mode Set for VBE-compatible cards + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include "vga.h" + +/* FUNCTIONS ******************************************************************/ + +ULONG +NTAPI +RaiseToPower2Ulong(IN ULONG Value) +{ + ULONG SquaredResult = Value; + if ((Value - 1) & Value) for (SquaredResult = 1; (SquaredResult < Value) && (SquaredResult); SquaredResult *= 2); + return SquaredResult; +} + +ULONG +NTAPI +RaiseToPower2(IN USHORT Value) +{ + ULONG SquaredResult = Value; + if ((Value - 1) & Value) for (SquaredResult = 1; (SquaredResult < Value) && (SquaredResult); SquaredResult *= 2); + return SquaredResult; +} + +ULONG +NTAPI +VbeGetVideoMemoryBaseAddress(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVIDEOMODE VgaMode) +{ + ULONG Length = 4 * 1024; + USHORT TrampolineMemorySegment, TrampolineMemoryOffset; + PVOID Context; + INT10_BIOS_ARGUMENTS BiosArguments; + PVBE_MODE_INFO VbeModeInfo; + ULONG BaseAddress; + VP_STATUS Status; + + /* Need linear and INT10 interface */ + if (!(VgaMode->fbType & VIDEO_MODE_BANKED)) return 0; + if (VgaExtension->Int10Interface.Size) return 0; + + /* Allocate scratch area and context */ + VbeModeInfo = VideoPortAllocatePool(VgaExtension, 1, sizeof(VBE_MODE_INFO), ' agV'); + if (!VbeModeInfo) return 0; + Context = VgaExtension->Int10Interface.Context; + Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context, + &TrampolineMemorySegment, + &TrampolineMemoryOffset, + &Length); + if (Status != NO_ERROR) return 0; + + /* Ask VBE BIOS for mode info */ + BiosArguments.Ecx = HIWORD(VgaMode->Mode); + BiosArguments.Edi = TrampolineMemorySegment; + BiosArguments.SegEs = TrampolineMemoryOffset; + BiosArguments.Eax = VBE_GET_MODE_INFORMATION; + Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); + if (Status != NO_ERROR) return 0; + if (BiosArguments.Eax != VBE_SUCCESS) return 0; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VbeModeInfo, + sizeof(VBE_MODE_INFO)); + if (Status != NO_ERROR) return 0; + + /* Return phys address and cleanup */ + BaseAddress = VbeModeInfo->PhysBasePtr; + VgaExtension->Int10Interface.Int10FreeBuffer(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset); + VideoPortFreePool(VgaExtension, VbeModeInfo); + return BaseAddress; +} + +VP_STATUS +NTAPI +VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, + IN PVIDEOMODE VgaMode, + OUT PULONG PhysPtrChange) +{ + VP_STATUS Status; + VIDEO_X86_BIOS_ARGUMENTS BiosArguments; + ULONG ModeIndex; + ULONG BaseAddress; + + VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments)); + ModeIndex = VgaMode->Mode; + BiosArguments.Eax = ModeIndex & 0x0000FFFF; + BiosArguments.Ebx = ModeIndex >> 16; + VideoPortDebugPrint(0, "Switching to %lx %lx\n", BiosArguments.Eax, BiosArguments.Ebx); + Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); + if (Status != NO_ERROR) return Status; + + /* Check for VESA mode */ + if (ModeIndex >> 16) + { + /* Mode set fail */ + if (BiosArguments.Eax != VBE_SUCCESS) return ERROR_INVALID_PARAMETER; + + /* Check current mode is desired mode */ + BiosArguments.Eax = VBE_GET_CURRENT_VBE_MODE; + Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); + if ((Status == NO_ERROR) && + (BiosArguments.Eax == VBE_SUCCESS) && + ((BiosArguments.Ebx ^ (ModeIndex >> 16)) & VBE_MODE_BITS)) + { + return ERROR_INVALID_PARAMETER; + } + + /* Set logical scanline width if different from physical */ + if (VgaMode->LogicalWidth != VgaMode->hres) + { + /* Check setting works after being set */ + BiosArguments.Eax = VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH; + BiosArguments.Ecx = VgaMode->LogicalWidth; + BiosArguments.Ebx = 0; + Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); + if ((Status != NO_ERROR) || + (BiosArguments.Eax != VBE_SUCCESS) || + (BiosArguments.Ecx != VgaMode->LogicalWidth)) + { + return ERROR_INVALID_PARAMETER; + } + } + } + + /* Get VRAM address to update changes */ + BaseAddress = VbeGetVideoMemoryBaseAddress(VgaDeviceExtension, VgaMode); + if ((BaseAddress) && (VgaMode->PhysBase != BaseAddress)) + { + *PhysPtrChange = TRUE; + VgaMode->PhysBase = BaseAddress; + } + + return NO_ERROR; +} + +VOID +NTAPI +InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) +{ + ULONG ModeCount = 0; + ULONG Length = 4 * 1024; + ULONG TotalMemory; + VP_STATUS Status; + INT10_BIOS_ARGUMENTS BiosArguments; + PVBE_INFO VbeInfo; + PVBE_MODE_INFO VbeModeInfo; + PVOID Context; + USHORT TrampolineMemorySegment; + USHORT TrampolineMemoryOffset; + ULONG VbeVersion; + ULONG NewModes = 0; + BOOLEAN FourBppModeFound = FALSE; + USHORT ModeResult; + USHORT Mode; + PUSHORT ThisMode; + BOOLEAN LinearAddressing; + ULONG Size, ScreenSize; + PVIDEOMODE VgaMode; + PVOID BaseAddress; + ULONG ScreenStride = 0; + PHYSICAL_ADDRESS PhysicalAddress; + + /* Enable only default vga modes if no vesa */ + VgaModeList = ModesVGA; + if (VideoPortIsNoVesa()) + { + VgaExtension->Int10Interface.Size = 0; + VgaExtension->Int10Interface.Version = 0; + return; + } + + /* Query INT10 interface */ + VgaExtension->Int10Interface.Version = VIDEO_PORT_INT10_INTERFACE_VERSION_1; + VgaExtension->Int10Interface.Size = sizeof(VIDEO_PORT_INT10_INTERFACE); + if (VideoPortQueryServices(VgaExtension, + VideoPortServicesInt10, + (PINTERFACE)&VgaExtension->Int10Interface)) + { + VgaExtension->Int10Interface.Size = 0; + VgaExtension->Int10Interface.Version = 0; + } + + /* Add ref */ + //VideoPortDebugPrint(0, "have int10 iface\n"); + VgaExtension->Int10Interface.InterfaceReference(VgaExtension->Int10Interface.Context); + Context = VgaExtension->Int10Interface.Context; + + /* Allocate scratch area and context */ + Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context, + &TrampolineMemorySegment, + &TrampolineMemoryOffset, + &Length); + if (Status != NO_ERROR) return; + VbeInfo = VideoPortAllocatePool(VgaExtension, 1, sizeof(VBE_INFO), ' agV'); + VbeModeInfo = &VbeInfo->Modes; + if (!VbeInfo) return; + + /* Init VBE data and write to card buffer */ + //VideoPortDebugPrint(0, "have int10 data\n"); + VbeInfo->ModeArray[128] = 0xFFFF; + strcpy(VbeInfo->Info.Signature, "VBE2"); + Status = VgaExtension->Int10Interface.Int10WriteMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VbeInfo, + 512); + if (Status != NO_ERROR) return; + + /* Get controller info */ + BiosArguments.Edi = TrampolineMemoryOffset; + BiosArguments.SegEs = TrampolineMemorySegment; + BiosArguments.Eax = VBE_GET_CONTROLLER_INFORMATION; + Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); + if (Status != NO_ERROR) return; + if (BiosArguments.Eax != VBE_SUCCESS) return; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VbeInfo, + 512); + if (Status != NO_ERROR) return; + + /* Check correct VBE BIOS */ + //VideoPortDebugPrint(0, "have vbe data\n"); + TotalMemory = VbeInfo->Info.TotalMemory << 16; + VbeVersion = VbeInfo->Info.Version; + VideoPortDebugPrint(0, "vbe version %lx memory %lx\n", VbeVersion, TotalMemory); + if (!ValidateVbeInfo(VgaExtension, VbeInfo)) return; + + /* Read modes */ + //VideoPortDebugPrint(0, "read modes from %p\n", VbeInfo->Info.VideoModePtr); + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.VideoModePtr), + LOWORD(VbeInfo->Info.VideoModePtr), + VbeInfo->ModeArray, + 128 * sizeof(USHORT)); + if (Status != NO_ERROR) return; + //VideoPortDebugPrint(0, "Read modes at: %p\n", VbeInfo->ModeArray); + + /* Count modes, check for new 4bpp SVGA modes */ + ThisMode = VbeInfo->ModeArray; + ModeResult = VbeInfo->ModeArray[0]; + while (ModeResult != 0xFFFF) + { + Mode = ModeResult & 0x1FF; + //VideoPortDebugPrint(0, "Mode found: %lx\n", Mode); + if ((Mode == 0x102) || (Mode == 0x6A)) FourBppModeFound = TRUE; + ModeResult = *++ThisMode; + NewModes++; + } + + /* Remove the built-in mode if not supported by card and check max modes */ + if (!FourBppModeFound) --NumVideoModes; + if ((NewModes >= 128) && (NumVideoModes > 8)) goto Cleanup; + + /* Switch to new SVGA mode list, copy VGA modes */ + VgaModeList = VideoPortAllocatePool(VgaExtension, 1, (NewModes + NumVideoModes) * sizeof(VIDEOMODE), ' agV'); + if (!VgaModeList) goto Cleanup; + VideoPortMoveMemory(VgaModeList, ModesVGA, NumVideoModes * sizeof(VIDEOMODE)); + + /* Apply fixup for Intel Brookdale */ + if (g_bIntelBrookdaleBIOS) + { + VideoPortDebugPrint(0, "Intel Brookdale-G Video BIOS Not Support!\n"); + while (TRUE); + } + + /* Scan SVGA modes */ +// VideoPortDebugPrint(0, "Static modes: %d\n", NumVideoModes); + VgaMode = &VgaModeList[NumVideoModes]; + ThisMode = VbeInfo->ModeArray; + //VideoPortDebugPrint(0, "new modes: %d\n", NewModes); + while (NewModes--) + { + /* Get info on mode */ + BiosArguments.Eax = VBE_GET_MODE_INFORMATION; + BiosArguments.Ecx = *ThisMode; + BiosArguments.Edi = TrampolineMemoryOffset; + BiosArguments.SegEs = TrampolineMemorySegment; + Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); + if (Status != NO_ERROR) goto Next; + if (BiosArguments.Eax != VBE_SUCCESS) goto Next; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VbeModeInfo, + 256); + if (Status != NO_ERROR) goto Next; + + /* Parse graphics modes only if linear framebuffer support */ + //VideoPortDebugPrint(0, "attr: %lx\n", VbeModeInfo->ModeAttributes); + if (!(VbeModeInfo->ModeAttributes & (VBE_MODEATTR_VALID | + VBE_MODEATTR_GRAPHICS))) goto Next; + LinearAddressing = ((VbeVersion >= 0x200) && + (VbeModeInfo->PhysBasePtr) && + (VbeModeInfo->ModeAttributes & VBE_MODEATTR_LINEAR)) ? + TRUE : FALSE; + + /* Check SVGA modes if 8bpp or higher */ + //VideoPortDebugPrint(0, "PhysBase: %lx\n", VbeModeInfo->PhysBasePtr); + if ((VbeModeInfo->XResolution >= 640) && + (VbeModeInfo->YResolution >= 480) && + (VbeModeInfo->NumberOfPlanes >= 1) && + (VbeModeInfo->BitsPerPixel >= 8)) + { + /* Copy VGA mode info */ + VideoPortZeroMemory(VgaMode, sizeof(VIDEOMODE)); + VgaMode->numPlanes = VbeModeInfo->NumberOfPlanes; + VgaMode->hres = VbeModeInfo->XResolution; + VgaMode->vres = VbeModeInfo->YResolution; + VgaMode->Frequency = 1; + VgaMode->Mode = (*ThisMode << 16) | VBE_SET_VBE_MODE; + VgaMode->Granularity = VbeModeInfo->WinGranularity << 10; + //VideoPortDebugPrint(0, "Mode %lx (Granularity %d)\n", VgaMode->Mode, VgaMode->Granularity); + + /* Set flags */ + if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_COLOR) VgaMode->fbType |= VIDEO_MODE_COLOR; + if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_GRAPHICS) VgaMode->fbType |= VIDEO_MODE_GRAPHICS; + if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_NON_VGA) VgaMode->NonVgaMode = TRUE; + + /* If no char data, say 80x25 */ + VgaMode->col = VbeModeInfo->XCharSize ? VbeModeInfo->XResolution / VbeModeInfo->XCharSize : 80; + VgaMode->row = VbeModeInfo->YCharSize ? VbeModeInfo->YResolution / VbeModeInfo->YCharSize : 25; + //VideoPortDebugPrint(0, "%d by %d rows\n", VgaMode->Columns, VgaMode->Rows); + + /* Check RGB555 (15bpp only) */ + VgaMode->bitsPerPlane = VbeModeInfo->BitsPerPixel / VbeModeInfo->NumberOfPlanes; + if ((VgaMode->bitsPerPlane == 16) && (VbeModeInfo->GreenMaskSize == 5)) VgaMode->bitsPerPlane = 15; + //VideoPortDebugPrint(0, "BPP: %d\n", VgaMode->BitsPerPlane); + + /* Do linear or banked frame buffers */ + VgaMode->FrameBufferBase = 0; + if (!LinearAddressing) + { + /* Read the screen stride (scanline size) */ + ScreenStride = RaiseToPower2(VbeModeInfo->BytesPerScanLine); + VgaMode->wbytes = ScreenStride; + //VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->Stride); + + /* Size of frame buffer is Height X ScanLine, align to bank/page size */ + ScreenSize = VgaMode->hres * ScreenStride; + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + Size = (ScreenSize + ((64 * 1024) - 1)) & ((64 * 1024) - 1); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + + /* Banked VGA at 0xA0000 (64K) */ + //VideoPortDebugPrint(0, "Final size: %lx\n", Size); + VgaMode->fbType |= VIDEO_MODE_BANKED; + VgaMode->sbytes = Size; + VgaMode->PhysSize = 64 * 1024; + VgaMode->FrameBufferSize = 64 * 1024; + VgaMode->NoBankSwitch = TRUE; + VgaMode->PhysBase = 0xA0000; + VgaMode->LogicalWidth = RaiseToPower2(VgaMode->hres); + } + else + { + /* VBE 3.00+ has specific field, read legacy field if not */ + //VideoPortDebugPrint(0, "LINEAR MODE!!!\n"); + ScreenStride = (VbeVersion >= 0x300) ? VbeModeInfo->LinBytesPerScanLine : 0; + if (!ScreenStride) ScreenStride = VbeModeInfo->BytesPerScanLine; + VgaMode->wbytes = ScreenStride; + //VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->Stride); + + /* Size of frame buffer is Height X ScanLine, align to page size */ + ScreenSize = VgaMode->hres * LOWORD(VgaMode->wbytes); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + Size = RaiseToPower2Ulong(ScreenSize); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + + /* Linear VGA must read settings from VBE */ + VgaMode->fbType |= VIDEO_MODE_LINEAR; + VgaMode->sbytes = Size; + VgaMode->PhysSize = Size; + VgaMode->FrameBufferSize = Size; + VgaMode->NoBankSwitch = FALSE; + VgaMode->PhysBase = VbeModeInfo->PhysBasePtr; + VgaMode->LogicalWidth = VgaMode->hres; + + /* Make VBE_SET_VBE_MODE command use Linear Framebuffer Select */ + VgaMode->Mode |= (VBE_MODE_LINEAR_FRAMEBUFFER << 16); + } + + /* Override bank switch if not support by card */ + if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_NO_BANK_SWITCH) VgaMode->NoBankSwitch = TRUE; + + /* Next */ + if (ScreenSize <= TotalMemory) + { + VgaMode++; + ModeCount++; + } + } +Next: + /* Next */ + ThisMode++; + } + + /* Check if last mode was color to do test */ + VideoPortDebugPrint(0, "mode scan complete. Total modes: %d\n", ModeCount); + if (--VgaMode->fbType & VIDEO_MODE_COLOR) + { + /* Try map physical buffer and free if worked */ + PhysicalAddress.QuadPart = VgaMode->PhysBase; + BaseAddress = VideoPortGetDeviceBase(VgaExtension, PhysicalAddress, 4 * 1024, FALSE); + if (BaseAddress) + { + VideoPortFreeDeviceBase(VgaExtension, BaseAddress); + } + else + { + /* Not work, so throw out VBE data */ + ModeCount = 0; + } + } + + /* Cleanup sucess path */ + VideoPortFreePool(VgaExtension, VbeInfo); + VgaExtension->Int10Interface.Int10FreeBuffer(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset); + NumVideoModes += ModeCount; + return; + +Cleanup: + /* Cleanup failure path, reset standard VGA and free memory */ + VgaModeList = ModesVGA; + VideoPortFreePool(VgaExtension, VbeInfo); + VgaExtension->Int10Interface.Int10FreeBuffer(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset); +} + +/* EOF */ diff --git a/reactos/drivers/video/miniport/vga_new/vga.c b/reactos/drivers/video/miniport/vga_new/vga.c new file mode 100644 index 00000000000..5b59b53624a --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/vga.c @@ -0,0 +1,1401 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/vga.c + * PURPOSE: Main Standard VGA-compatible Minport Handling Code + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +//--------------------------------------------------------------------------- + +#include "vga.h" + +//--------------------------------------------------------------------------- +// +// Function declarations +// +// Functions that start with 'VGA' are entry points for the OS port driver. +// + +VP_STATUS +VgaFindAdapter( + PVOID HwDeviceExtension, + PVOID HwContext, + PWSTR ArgumentString, + PVIDEO_PORT_CONFIG_INFO ConfigInfo, + PUCHAR Again + ); + +BOOLEAN +VgaInitialize( + PVOID HwDeviceExtension + ); + +BOOLEAN +VgaStartIO( + PVOID HwDeviceExtension, + PVIDEO_REQUEST_PACKET RequestPacket + ); + +// +// Private function prototypes. +// + +VP_STATUS +VgaQueryAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE_INFORMATION ModeInformation, + ULONG ModeInformationSize, + PULONG OutputSize + ); + +VP_STATUS +VgaQueryNumberOfAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_NUM_MODES NumModes, + ULONG NumModesSize, + PULONG OutputSize + ); + +VP_STATUS +VgaSetMode( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE Mode, + ULONG ModeSize, +// eVb: 1.1 [SET MODE] - Add new output parameter for framebuffer update functionality + PULONG PhysPtrChange +// eVb: 1.1 [END] + ); + +BOOLEAN +VgaIsPresent( + PHW_DEVICE_EXTENSION HwDeviceExtension + ); + +VOID +VgaInterpretCmdStream( + PVOID HwDeviceExtension, + PUSHORT pusCmdStream + ); + +VP_STATUS +VgaSetColorLookup( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_CLUT ClutBuffer, + ULONG ClutBufferSize + ); + +VP_STATUS +GetDeviceDataCallback( + PVOID HwDeviceExtension, + PVOID Context, + VIDEO_DEVICE_DATA_TYPE DeviceDataType, + PVOID Identifier, + ULONG IdentifierLength, + PVOID ConfigurationData, + ULONG ConfigurationDataLength, + PVOID ComponentInformation, + ULONG ComponentInformationLength + ); + +// eVb: 1.2 [RESOURCE] - Add new function for acquiring VGA resources (I/O, memory) +VP_STATUS +VgaAcquireResources( + PHW_DEVICE_EXTENSION DeviceExtension + ); +// eVb: 1.2 [END] + +#if defined(ALLOC_PRAGMA) +#pragma alloc_text(PAGE,DriverEntry) +#pragma alloc_text(PAGE,VgaFindAdapter) +#pragma alloc_text(PAGE,VgaInitialize) +#pragma alloc_text(PAGE,VgaStartIO) +#pragma alloc_text(PAGE,VgaIsPresent) +#pragma alloc_text(PAGE,VgaSetColorLookup) +#endif + + +//--------------------------------------------------------------------------- +ULONG +// eVb: 1.3 [GCC] - Add NTAPI for GCC support +NTAPI +// eVb: 1.3 [END] +DriverEntry( + PVOID Context1, + PVOID Context2 + ) + +/*++ + +Routine Description: + + Installable driver initialization entry point. + This entry point is called directly by the I/O system. + +Arguments: + + Context1 - First context value passed by the operating system. This is + the value with which the miniport driver calls VideoPortInitialize(). + + Context2 - Second context value passed by the operating system. This is + the value with which the miniport driver calls 3VideoPortInitialize(). + +Return Value: + + Status from VideoPortInitialize() + +--*/ + +{ + + VIDEO_HW_INITIALIZATION_DATA hwInitData; + ULONG status; + ULONG initializationStatus = (ULONG) -1; + + // + // Zero out structure. + // + + VideoPortZeroMemory(&hwInitData, sizeof(VIDEO_HW_INITIALIZATION_DATA)); + + // + // Specify sizes of structure and extension. + // + + hwInitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA); + + // + // Set entry points. + // + + hwInitData.HwFindAdapter = VgaFindAdapter; + hwInitData.HwInitialize = VgaInitialize; + hwInitData.HwInterrupt = NULL; + hwInitData.HwStartIO = VgaStartIO; + + // + // Determine the size we require for the device extension. + // + + hwInitData.HwDeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION); + + // + // Always start with parameters for device0 in this case. + // We can leave it like this since we know we will only ever find one + // VGA type adapter in a machine. + // + + // hwInitData.StartingDeviceNumber = 0; + + // + // Once all the relevant information has been stored, call the video + // port driver to do the initialization. + // For this device we will repeat this call three times, for ISA, EISA + // and PCI. + // We will return the minimum of all return values. + // + + // + // We will try the PCI bus first so that our ISA detection does'nt claim + // PCI cards (since it is impossible to differentiate between the two + // by looking at the registers). + // + + // + // NOTE: since this driver only supports one adapter, we will return + // as soon as we find a device, without going on to the following buses. + // Normally one would call for each bus type and return the smallest + // value. + // + +#if !defined(_ALPHA_) + + // + // Before we can enable this on ALPHA we need to find a way to map a + // sparse view of a 4MB region successfully. + // + + hwInitData.AdapterInterfaceType = PCIBus; + + initializationStatus = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + if (initializationStatus == NO_ERROR) + { + return initializationStatus; + } + +#endif + + hwInitData.AdapterInterfaceType = MicroChannel; + + initializationStatus = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + // + // Return immediately instead of checkin for smallest return code. + // + + if (initializationStatus == NO_ERROR) + { + return initializationStatus; + } + + + hwInitData.AdapterInterfaceType = Internal; + + initializationStatus = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + if (initializationStatus == NO_ERROR) + { + return initializationStatus; + } + + + hwInitData.AdapterInterfaceType = Isa; + + initializationStatus = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + if (initializationStatus == NO_ERROR) + { + return initializationStatus; + } + + + + hwInitData.AdapterInterfaceType = Eisa; + + status = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + if (initializationStatus > status) { + initializationStatus = status; + } + + return initializationStatus; + +} // end DriverEntry() + +//--------------------------------------------------------------------------- +VP_STATUS +VgaFindAdapter( + PVOID HwDeviceExtension, + PVOID HwContext, + PWSTR ArgumentString, + PVIDEO_PORT_CONFIG_INFO ConfigInfo, + PUCHAR Again + ) + +/*++ + +Routine Description: + + This routine is called to determine if the adapter for this driver + is present in the system. + If it is present, the function fills out some information describing + the adapter. + +Arguments: + + HwDeviceExtension - Supplies the miniport driver's adapter storage. This + storage is initialized to zero before this call. + + HwContext - Supplies the context value which was passed to + VideoPortInitialize(). + + ArgumentString - Supplies a NULL terminated ASCII string. This string + originates from the user. + + ConfigInfo - Returns the configuration information structure which is + filled by the miniport driver. This structure is initialized with + any known configuration information (such as SystemIoBusNumber) by + the port driver. Where possible, drivers should have one set of + defaults which do not require any supplied configuration information. + + Again - Indicates if the miniport driver wants the port driver to call + its VIDEO_HW_FIND_ADAPTER function again with a new device extension + and the same config info. This is used by the miniport drivers which + can search for several adapters on a bus. + +Return Value: + + This routine must return: + + NO_ERROR - Indicates a host adapter was found and the + configuration information was successfully determined. + + ERROR_INVALID_PARAMETER - Indicates an adapter was found but there was an + error obtaining the configuration information. If possible an error + should be logged. + + ERROR_DEV_NOT_EXIST - Indicates no host adapter was found for the + supplied configuration information. + +--*/ + +{ + + PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension; + + // + // Make sure the size of the structure is at least as large as what we + // are expecting (check version of the config info structure). + // + + if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO)) { + + return ERROR_INVALID_PARAMETER; + + } +// eVb: 1.4 [CIRRUS] - Remove CIRRUS-specific support + // + // Check internal VGA (MIPS and ARM systems) + // + + if ((ConfigInfo->AdapterInterfaceType == Internal) && + (VideoPortGetDeviceData(HwDeviceExtension, + VpControllerData, + &GetDeviceDataCallback, + VgaAccessRange) != NO_ERROR)) + { + return ERROR_INVALID_PARAMETER; + } +// eVb: 1.4 [END] + // + // No interrupt information is necessary. + // + + // + // Check to see if there is a hardware resource conflict. + // +// eVb: 1.5 [RESOURCE] - Use new function for acquiring VGA resources (I/O, memory) + if (VgaAcquireResources(hwDeviceExtension) != NO_ERROR) return ERROR_INVALID_PARAMETER; +// eVb: 1.5 [END] + // + // Get logical IO port addresses. + // + + if ((hwDeviceExtension->IOAddress = + VideoPortGetDeviceBase(hwDeviceExtension, + VgaAccessRange->RangeStart, + VGA_MAX_IO_PORT - VGA_BASE_IO_PORT + 1, + VgaAccessRange->RangeInIoSpace)) == NULL) + { + VideoDebugPrint((2, "VgaFindAdapter - Fail to get io address\n")); + + return ERROR_INVALID_PARAMETER; + } + + // + // Determine whether a VGA is present. + // + + if (!VgaIsPresent(hwDeviceExtension)) { + + VideoDebugPrint((0, "VgaFindAdapter - VGA Failed\n")); + return ERROR_DEV_NOT_EXIST; + } + + // + // Minimum size of the buffer required to store the hardware state + // information returned by IOCTL_VIDEO_SAVE_HARDWARE_STATE. + // + + ConfigInfo->HardwareStateSize = VGA_TOTAL_STATE_SIZE; + + // + // Pass a pointer to the emulator range we are using. + // +// eVb: 1.6 [VDM] - Disable VDM for now + ConfigInfo->NumEmulatorAccessEntries = 0; + ConfigInfo->EmulatorAccessEntries = NULL; + ConfigInfo->EmulatorAccessEntriesContext = 0; +// eVb: 1.6 [END] + // + // BUGBUG + // + // There is really no reason to have the frame buffer mapped. On an + // x86 we use if for save/restore (supposedly) but even then we + // would only need to map a 64K window, not all 16 Meg! + // + +#ifdef _X86_ + + // + // Map the video memory into the system virtual address space so we can + // clear it out and use it for save and restore. + // + + if ( (hwDeviceExtension->VideoMemoryAddress = + VideoPortGetDeviceBase(hwDeviceExtension, + VgaAccessRange[2].RangeStart, + VgaAccessRange[2].RangeLength, + FALSE)) == NULL) + { + VideoDebugPrint((1, "VgaFindAdapter - Fail to get memory address\n")); + + return ERROR_INVALID_PARAMETER; + } + + VideoPortDebugPrint(0, "vga mapped at %x\n", hwDeviceExtension->VideoMemoryAddress); +#endif +// eVb: 1.7 [VDM] - Disable VDM for now + ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0; + ConfigInfo->VdmPhysicalVideoMemoryLength = 0; +// eVb: 1.7 [END] + // + // Indicate we do not wish to be called again for another initialization. + // + + *Again = 0; + + // + // Indicate a successful completion status. + // + + return NO_ERROR; + + +} // VgaFindAdapter() + +//--------------------------------------------------------------------------- +BOOLEAN +VgaInitialize( + PVOID HwDeviceExtension + ) + +/*++ + +Routine Description: + + This routine does one time initialization of the device. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's adapter information. + +Return Value: + + None. + +--*/ + +{ + PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension; + + // + // set up the default cursor position and type. + // + + hwDeviceExtension->CursorPosition.Column = 0; + hwDeviceExtension->CursorPosition.Row = 0; + hwDeviceExtension->CursorTopScanLine = 0; + hwDeviceExtension->CursorBottomScanLine = 31; + hwDeviceExtension->CursorEnable = TRUE; + +// eVb: 1.8 [VBE] - Initialize VBE modes + InitializeModeTable(hwDeviceExtension); +// eVb: 1.8 [END] + return TRUE; + +} // VgaInitialize() + +//--------------------------------------------------------------------------- +BOOLEAN +VgaStartIO( + PVOID HwDeviceExtension, + PVIDEO_REQUEST_PACKET RequestPacket + ) + +/*++ + +Routine Description: + + This routine is the main execution routine for the miniport driver. It + accepts a Video Request Packet, performs the request, and then returns + with the appropriate status. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's adapter information. + + RequestPacket - Pointer to the video request packet. This structure + contains all the parameters passed to the VideoIoControl function. + +Return Value: + + This routine will return error codes from the various support routines + and will also return ERROR_INSUFFICIENT_BUFFER for incorrectly sized + buffers and ERROR_INVALID_FUNCTION for unsupported functions. + +--*/ + +{ + PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension; + VP_STATUS status; + VIDEO_MODE videoMode; + PVIDEO_MEMORY_INFORMATION memoryInformation; + ULONG inIoSpace; + ULONG Result; + + // + // Switch on the IoContolCode in the RequestPacket. It indicates which + // function must be performed by the driver. + // +// eVb: 1.9 [IOCTL] - Remove IOCTLs not needed yet + switch (RequestPacket->IoControlCode) + { + case IOCTL_VIDEO_SHARE_VIDEO_MEMORY: + + VideoDebugPrint((2, "VgaStartIO - ShareVideoMemory\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + case IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY: + + VideoDebugPrint((2, "VgaStartIO - UnshareVideoMemory\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_MAP_VIDEO_MEMORY: + + VideoDebugPrint((2, "VgaStartIO - MapVideoMemory\n")); + + if ( (RequestPacket->OutputBufferLength < + (RequestPacket->StatusBlock->Information = + sizeof(VIDEO_MEMORY_INFORMATION))) || + (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY)) ) + { + status = ERROR_INSUFFICIENT_BUFFER; + } + + memoryInformation = RequestPacket->OutputBuffer; + + memoryInformation->VideoRamBase = ((PVIDEO_MEMORY) + (RequestPacket->InputBuffer))->RequestedVirtualAddress; + + // + // We reserved 16 meg for the frame buffer, however, it makes + // no sense to map more memory than there is on the card. So + // only map the amount of memory we have on the card. + // +// eVb: 1.10 [CIRRUS] - On VGA, we have VRAM size since boot, use it + memoryInformation->VideoRamLength = + hwDeviceExtension->PhysicalVideoMemoryLength; +// eVb: 1.10 [END] + // + // If you change to using a dense space frame buffer, make this + // value a 4 for the ALPHA. + // + + inIoSpace = 0; + + status = VideoPortMapMemory(hwDeviceExtension, + hwDeviceExtension->PhysicalVideoMemoryBase, +// eVb: 1.11 [CIRRUS] - On VGA, we have VRAM size since boot, use it + &memoryInformation->VideoRamLength, +// eVb: 1.11 [END] + &inIoSpace, + &(memoryInformation->VideoRamBase)); + + if (status != NO_ERROR) { + VideoDebugPrint((0, "VgaStartIO - IOCTL_VIDEO_MAP_VIDEO_MEMORY failed VideoPortMapMemory (%x)\n", status)); + } + + memoryInformation->FrameBufferBase = + ((PUCHAR) (memoryInformation->VideoRamBase)) + + hwDeviceExtension->PhysicalFrameOffset.LowPart; + + memoryInformation->FrameBufferLength = + hwDeviceExtension->PhysicalFrameLength ? + hwDeviceExtension->PhysicalFrameLength : + memoryInformation->VideoRamLength; + + + VideoDebugPrint((2, "physical VideoMemoryBase %08lx\n", hwDeviceExtension->PhysicalVideoMemoryBase)); + VideoDebugPrint((2, "physical VideoMemoryLength %08lx\n", hwDeviceExtension->PhysicalVideoMemoryLength)); + VideoDebugPrint((2, "VideoMemoryBase %08lx\n", memoryInformation->VideoRamBase)); + VideoDebugPrint((2, "VideoMemoryLength %08lx\n", memoryInformation->VideoRamLength)); + + VideoDebugPrint((2, "physical framebuf offset %08lx\n", hwDeviceExtension->PhysicalFrameOffset.LowPart)); + VideoDebugPrint((2, "framebuf base %08lx\n", memoryInformation->FrameBufferBase)); + VideoDebugPrint((2, "physical framebuf len %08lx\n", hwDeviceExtension->PhysicalFrameLength)); + VideoDebugPrint((2, "framebuf length %08lx\n", memoryInformation->FrameBufferLength)); + + break; + + case IOCTL_VIDEO_UNMAP_VIDEO_MEMORY: + + VideoDebugPrint((2, "VgaStartIO - UnMapVideoMemory\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_QUERY_AVAIL_MODES: + + VideoDebugPrint((2, "VgaStartIO - QueryAvailableModes\n")); + + status = VgaQueryAvailableModes(HwDeviceExtension, + (PVIDEO_MODE_INFORMATION) + RequestPacket->OutputBuffer, + RequestPacket->OutputBufferLength, + &RequestPacket->StatusBlock->Information); + + break; + + + case IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES: + + VideoDebugPrint((2, "VgaStartIO - QueryNumAvailableModes\n")); + + status = VgaQueryNumberOfAvailableModes(HwDeviceExtension, + (PVIDEO_NUM_MODES) + RequestPacket->OutputBuffer, + RequestPacket->OutputBufferLength, + &RequestPacket->StatusBlock->Information); + + break; + + + case IOCTL_VIDEO_QUERY_CURRENT_MODE: + + VideoDebugPrint((2, "VgaStartIO - QueryCurrentMode\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_CURRENT_MODE: + + VideoDebugPrint((2, "VgaStartIO - SetCurrentModes\n")); + + status = VgaSetMode(HwDeviceExtension, + (PVIDEO_MODE) RequestPacket->InputBuffer, + RequestPacket->InputBufferLength, +// eVb: 1.12 [SET MODE] - Use new output parameter for framebuffer update functionality + &Result); +// eVb: 1.12 [END] + + break; + + + case IOCTL_VIDEO_RESET_DEVICE: + + VideoDebugPrint((2, "VgaStartIO - Reset Device\n")); + + videoMode.RequestedMode = 0; + + VgaSetMode(HwDeviceExtension, + (PVIDEO_MODE) &videoMode, + sizeof(videoMode), +// eVb: 1.13 [SET MODE] - Use new output parameter for framebuffer update functionality + &Result); +// eVb: 1.13 [END] + + // + // Always return succcess since settings the text mode will fail on + // non-x86. + // + // Also, failiure to set the text mode is not fatal in any way, since + // this operation must be followed by another set mode operation. + // + + status = NO_ERROR; + + break; + + + case IOCTL_VIDEO_LOAD_AND_SET_FONT: + + VideoDebugPrint((2, "VgaStartIO - LoadAndSetFont\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_QUERY_CURSOR_POSITION: + + VideoDebugPrint((2, "VgaStartIO - QueryCursorPosition\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_CURSOR_POSITION: + + VideoDebugPrint((2, "VgaStartIO - SetCursorPosition\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_QUERY_CURSOR_ATTR: + + VideoDebugPrint((2, "VgaStartIO - QueryCursorAttributes\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_CURSOR_ATTR: + + VideoDebugPrint((2, "VgaStartIO - SetCursorAttributes\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_PALETTE_REGISTERS: + + VideoDebugPrint((2, "VgaStartIO - SetPaletteRegs\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_COLOR_REGISTERS: + + VideoDebugPrint((2, "VgaStartIO - SetColorRegs\n")); + + status = VgaSetColorLookup(HwDeviceExtension, + (PVIDEO_CLUT) RequestPacket->InputBuffer, + RequestPacket->InputBufferLength); + + break; + + + case IOCTL_VIDEO_ENABLE_VDM: + + VideoDebugPrint((2, "VgaStartIO - EnableVDM\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_RESTORE_HARDWARE_STATE: + + VideoDebugPrint((2, "VgaStartIO - RestoreHardwareState\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SAVE_HARDWARE_STATE: + + VideoDebugPrint((2, "VgaStartIO - SaveHardwareState\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + case IOCTL_VIDEO_GET_BANK_SELECT_CODE: + + VideoDebugPrint((2, "VgaStartIO - GetBankSelectCode\n")); + + status = ERROR_INVALID_FUNCTION; + break; + + case IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES: + case IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES: + + // + // if we get here, an invalid IoControlCode was specified. + // + + default: + + VideoDebugPrint((0, "Fell through vga startIO routine - invalid command\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + } +// eVb: 1.9 [END] + RequestPacket->StatusBlock->Status = status; + + return TRUE; + +} // VgaStartIO() + + +//--------------------------------------------------------------------------- +// +// private routines +// + + +//--------------------------------------------------------------------------- +BOOLEAN +VgaIsPresent( + PHW_DEVICE_EXTENSION HwDeviceExtension + ) + +/*++ + +Routine Description: + + This routine returns TRUE if a VGA is present. Determining whether a VGA + is present is a two-step process. First, this routine walks bits through + the Bit Mask register, to establish that there are readable indexed + registers (EGAs normally don't have readable registers, and other adapters + are unlikely to have indexed registers). This test is done first because + it's a non-destructive EGA rejection test (correctly rejects EGAs, but + doesn't potentially mess up the screen or the accessibility of display + memory). Normally, this would be an adequate test, but some EGAs have + readable registers, so next, we check for the existence of the Chain4 bit + in the Memory Mode register; this bit doesn't exist in EGAs. It's + conceivable that there are EGAs with readable registers and a register bit + where Chain4 is stored, although I don't know of any; if a better test yet + is needed, memory could be written to in Chain4 mode, and then examined + plane by plane in non-Chain4 mode to make sure the Chain4 bit did what it's + supposed to do. However, the current test should be adequate to eliminate + just about all EGAs, and 100% of everything else. + + If this function fails to find a VGA, it attempts to undo any damage it + may have inadvertently done while testing. The underlying assumption for + the damage control is that if there's any non-VGA adapter at the tested + ports, it's an EGA or an enhanced EGA, because: a) I don't know of any + other adapters that use 3C4/5 or 3CE/F, and b), if there are other + adapters, I certainly don't know how to restore their original states. So + all error recovery is oriented toward putting an EGA back in a writable + state, so that error messages are visible. The EGA's state on entry is + assumed to be text mode, so the Memory Mode register is restored to the + default state for text mode. + + If a VGA is found, the VGA is returned to its original state after + testing is finished. + +Arguments: + + None. + +Return Value: + + TRUE if a VGA is present, FALSE if not. + +--*/ + +{ + UCHAR originalGCAddr; + UCHAR originalSCAddr; + UCHAR originalBitMask; + UCHAR originalReadMap; + UCHAR originalMemoryMode; + UCHAR testMask; + BOOLEAN returnStatus; + + // + // Remember the original state of the Graphics Controller Address register. + // + + originalGCAddr = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT); + + // + // Write the Read Map register with a known state so we can verify + // that it isn't changed after we fool with the Bit Mask. This ensures + // that we're dealing with indexed registers, since both the Read Map and + // the Bit Mask are addressed at GRAPH_DATA_PORT. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_READ_MAP); + + // + // If we can't read back the Graphics Address register setting we just + // performed, it's not readable and this isn't a VGA. + // + + if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT) & GRAPH_ADDR_MASK) != IND_READ_MAP) { + + return FALSE; + } + + // + // Set the Read Map register to a known state. + // + + originalReadMap = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_TEST_SETTING); + + if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT) != READ_MAP_TEST_SETTING) { + + // + // The Read Map setting we just performed can't be read back; not a + // VGA. Restore the default Read Map state. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_DEFAULT); + + return FALSE; + } + + // + // Remember the original setting of the Bit Mask register. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_BIT_MASK); + if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT) & GRAPH_ADDR_MASK) != IND_BIT_MASK) { + + // + // The Graphics Address register setting we just made can't be read + // back; not a VGA. Restore the default Read Map state. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_READ_MAP); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_DEFAULT); + + return FALSE; + } + + originalBitMask = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT); + + // + // Set up the initial test mask we'll write to and read from the Bit Mask. + // + + testMask = 0xBB; + + do { + + // + // Write the test mask to the Bit Mask. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, testMask); + + // + // Make sure the Bit Mask remembered the value. + // + + if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT) != testMask) { + + // + // The Bit Mask is not properly writable and readable; not a VGA. + // Restore the Bit Mask and Read Map to their default states. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, BIT_MASK_DEFAULT); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_READ_MAP); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_DEFAULT); + + return FALSE; + } + + // + // Cycle the mask for next time. + // + + testMask >>= 1; + + } while (testMask != 0); + + // + // There's something readable at GRAPH_DATA_PORT; now switch back and + // make sure that the Read Map register hasn't changed, to verify that + // we're dealing with indexed registers. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_READ_MAP); + if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT) != READ_MAP_TEST_SETTING) { + + // + // The Read Map is not properly writable and readable; not a VGA. + // Restore the Bit Mask and Read Map to their default states, in case + // this is an EGA, so subsequent writes to the screen aren't garbled. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_DEFAULT); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_BIT_MASK); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, BIT_MASK_DEFAULT); + + return FALSE; + } + + // + // We've pretty surely verified the existence of the Bit Mask register. + // Put the Graphics Controller back to the original state. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, originalReadMap); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_BIT_MASK); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, originalBitMask); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, originalGCAddr); + + // + // Now, check for the existence of the Chain4 bit. + // + + // + // Remember the original states of the Sequencer Address and Memory Mode + // registers. + // + + originalSCAddr = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT, IND_MEMORY_MODE); + if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT) & SEQ_ADDR_MASK) != IND_MEMORY_MODE) { + + // + // Couldn't read back the Sequencer Address register setting we just + // performed. + // + + return FALSE; + } + originalMemoryMode = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT); + + // + // Toggle the Chain4 bit and read back the result. This must be done during + // sync reset, since we're changing the chaining state. + // + + // + // Begin sync reset. + // + + VideoPortWritePortUshort((PUSHORT)(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT), + (IND_SYNC_RESET + (START_SYNC_RESET_VALUE << 8))); + + // + // Toggle the Chain4 bit. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT, IND_MEMORY_MODE); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT, (UCHAR)(originalMemoryMode ^ CHAIN4_MASK)); + + if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT) != (UCHAR) (originalMemoryMode ^ CHAIN4_MASK)) { + + // + // Chain4 bit not there; not a VGA. + // Set text mode default for Memory Mode register. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT, MEMORY_MODE_TEXT_DEFAULT); + // + // End sync reset. + // + + VideoPortWritePortUshort((PUSHORT) (HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT), + (IND_SYNC_RESET + (END_SYNC_RESET_VALUE << 8))); + + returnStatus = FALSE; + + } else { + + // + // It's a VGA. + // + + // + // Restore the original Memory Mode setting. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT, originalMemoryMode); + + // + // End sync reset. + // + + VideoPortWritePortUshort((PUSHORT)(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT), + (USHORT)(IND_SYNC_RESET + (END_SYNC_RESET_VALUE << 8))); + + // + // Restore the original Sequencer Address setting. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT, originalSCAddr); + + returnStatus = TRUE; + } + + return returnStatus; + +} // VgaIsPresent() + + +//--------------------------------------------------------------------------- +VP_STATUS +VgaSetColorLookup( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_CLUT ClutBuffer, + ULONG ClutBufferSize + ) + +/*++ + +Routine Description: + + This routine sets a specified portion of the DAC color lookup table + settings. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + ClutBufferSize - Length of the input buffer supplied by the user. + + ClutBuffer - Pointer to the structure containing the color lookup table. + +Return Value: + + NO_ERROR - information returned successfully + + ERROR_INSUFFICIENT_BUFFER - input buffer not large enough for input data. + + ERROR_INVALID_PARAMETER - invalid clut size. + +--*/ + +{ + PVIDEOMODE CurrentMode = HwDeviceExtension->CurrentMode; + USHORT i; + + // + // Check if the size of the data in the input buffer is large enough. + // + + if ( (ClutBufferSize < sizeof(VIDEO_CLUT) - sizeof(ULONG)) || + (ClutBufferSize < sizeof(VIDEO_CLUT) + + (sizeof(ULONG) * (ClutBuffer->NumEntries - 1)) ) ) { + + return ERROR_INSUFFICIENT_BUFFER; + + } + + // + // Check to see if the parameters are valid. + // + + if ( (ClutBuffer->NumEntries == 0) || + (ClutBuffer->FirstEntry > VIDEO_MAX_COLOR_REGISTER) || + (ClutBuffer->FirstEntry + ClutBuffer->NumEntries > + VIDEO_MAX_COLOR_REGISTER + 1) ) { + + return ERROR_INVALID_PARAMETER; + + } +// eVb: 1.14 [VBE] - Add VBE color support + // + // Check SVGA mode + // + + if (CurrentMode->bitsPerPlane >= 8) return VbeSetColorLookup(HwDeviceExtension, ClutBuffer); +// eVb: 1.14 [END] + // + // Path for VGA mode + // +// eVb: 1.15 [VBE] - Add VBE support for non-VGA-compatible detected modes + if (!CurrentMode->NonVgaMode) + { +// eVb: 1.15 [END] + // + // Set CLUT registers directly on the hardware + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_ADDRESS_WRITE_PORT, (UCHAR) ClutBuffer->FirstEntry); + + for (i = 0; i < ClutBuffer->NumEntries; i++) { + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_ADDRESS_WRITE_PORT, + (UCHAR)(i + ClutBuffer->FirstEntry)); + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_DATA_REG_PORT, + ClutBuffer->LookupTable[i].RgbArray.Red); + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_DATA_REG_PORT, + ClutBuffer->LookupTable[i].RgbArray.Green); + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_DATA_REG_PORT, + ClutBuffer->LookupTable[i].RgbArray.Blue); + } + return NO_ERROR; + } + + return ERROR_INVALID_PARAMETER; + +} // end VgaSetColorLookup() + +VP_STATUS +GetDeviceDataCallback( + PVOID HwDeviceExtension, + PVOID Context, + VIDEO_DEVICE_DATA_TYPE DeviceDataType, + PVOID Identifier, + ULONG IdentifierLength, + PVOID ConfigurationData, + ULONG ConfigurationDataLength, + PVOID ComponentInformation, + ULONG ComponentInformationLength + ) + +/*++ + +Routine Description: + + Callback routine for the VideoPortGetDeviceData function. + +Arguments: + + HwDeviceExtension - Pointer to the miniport drivers device extension. + + Context - Context value passed to the VideoPortGetDeviceData function. + + DeviceDataType - The type of data that was requested in + VideoPortGetDeviceData. + + Identifier - Pointer to a string that contains the name of the device, + as setup by the ROM or ntdetect. + + IdentifierLength - Length of the Identifier string. + + ConfigurationData - Pointer to the configuration data for the device or + BUS. + + ConfigurationDataLength - Length of the data in the configurationData + field. + + ComponentInformation - Undefined. + + ComponentInformationLength - Undefined. + +Return Value: + + Returns NO_ERROR if the function completed properly. + Returns ERROR_DEV_NOT_EXIST if we did not find the device. + Returns ERROR_INVALID_PARAMETER otherwise. + +--*/ + +{ + VideoPortDebugPrint(Error, "Detected internal VGA chip on embedded board, todo\n"); + while (TRUE); + return NO_ERROR; + +} //end GetDeviceDataCallback() + +// eVb: 1.16 [RESOURCE] - Add new function for acquiring VGA resources (I/O, memory) +VP_STATUS +VgaAcquireResources( + PHW_DEVICE_EXTENSION DeviceExtension + ) +{ + VP_STATUS Status = NO_ERROR; + ULONG Ranges, i; + + // + // Try exclusive ranges (vga + ati) + // + + Ranges = NUM_VGA_ACCESS_RANGES; + for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = FALSE; + if (VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange) != NO_ERROR) + { + // + // Not worked, try vga only + // + + Ranges = 3; + if (VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange) != NO_ERROR) + { + // + // Still not, try shared ranges + // + + for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = TRUE; + Status = VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange); + if (Status == NO_ERROR) + { + // + // It did work + // + + VideoPortVerifyAccessRanges(DeviceExtension, 0, 0); + Status = NO_ERROR; + } + } + } + + if (Status == NO_ERROR) + { + // + // Worked with exclusive, also try shared + // + + for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = TRUE; + Status = VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange); + } + + return Status; +} +// eVb: 1.16 [END] diff --git a/reactos/drivers/video/miniport/vga_new/vga.h b/reactos/drivers/video/miniport/vga_new/vga.h new file mode 100644 index 00000000000..21e411584f8 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/vga.h @@ -0,0 +1,446 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/vga.h + * PURPOSE: Main Header File + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "ntdef.h" +#include "dderror.h" +#include "devioctl.h" +#include "miniport.h" +#include "ntddvdeo.h" +#include "video.h" +#include "cmdcnst.h" + +// +// Base address of VGA memory range. Also used as base address of VGA +// memory when loading a font, which is done with the VGA mapped at A0000. +// + +#define MEM_VGA 0xA0000 +#define MEM_VGA_SIZE 0x20000 + +// +// For memory mapped IO +// + +#define MEMORY_MAPPED_IO_OFFSET (0xB8000 - 0xA0000) + +// +// Port definitions for filling the ACCESS_RANGES structure in the miniport +// information, defines the range of I/O ports the VGA spans. +// There is a break in the IO ports - a few ports are used for the parallel +// port. Those cannot be defined in the ACCESS_RANGE, but are still mapped +// so all VGA ports are in one address range. +// + +#define VGA_BASE_IO_PORT 0x000003B0 +#define VGA_START_BREAK_PORT 0x000003BB +#define VGA_END_BREAK_PORT 0x000003C0 +#define VGA_MAX_IO_PORT 0x000003DF + +// +// VGA register definitions +// +// eVb: 3.1 [VGA] - Use offsets from the VGA Port Address instead of absolute +#define CRTC_ADDRESS_PORT_MONO 0x0004 // CRT Controller Address and +#define CRTC_DATA_PORT_MONO 0x0005 // Data registers in mono mode +#define FEAT_CTRL_WRITE_PORT_MONO 0x000A // Feature Control write port + // in mono mode +#define INPUT_STATUS_1_MONO 0x000A // Input Status 1 register read + // port in mono mode +#define ATT_INITIALIZE_PORT_MONO INPUT_STATUS_1_MONO + // Register to read to reset + // Attribute Controller index/data + +#define ATT_ADDRESS_PORT 0x0010 // Attribute Controller Address and +#define ATT_DATA_WRITE_PORT 0x0010 // Data registers share one port + // for writes, but only Address is + // readable at 0x3C0 +#define ATT_DATA_READ_PORT 0x0011 // Attribute Controller Data reg is + // readable here +#define MISC_OUTPUT_REG_WRITE_PORT 0x0012 // Miscellaneous Output reg write + // port +#define INPUT_STATUS_0_PORT 0x0012 // Input Status 0 register read + // port +#define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013 // Bit 0 enables/disables the + // entire VGA subsystem +#define SEQ_ADDRESS_PORT 0x0014 // Sequence Controller Address and +#define SEQ_DATA_PORT 0x0015 // Data registers +#define DAC_PIXEL_MASK_PORT 0x0016 // DAC pixel mask reg +#define DAC_ADDRESS_READ_PORT 0x0017 // DAC register read index reg, + // write-only +#define DAC_STATE_PORT 0x0017 // DAC state (read/write), + // read-only +#define DAC_ADDRESS_WRITE_PORT 0x0018 // DAC register write index reg +#define DAC_DATA_REG_PORT 0x0019 // DAC data transfer reg +#define FEAT_CTRL_READ_PORT 0x001A // Feature Control read port +#define MISC_OUTPUT_REG_READ_PORT 0x001C // Miscellaneous Output reg read + // port +#define GRAPH_ADDRESS_PORT 0x001E // Graphics Controller Address +#define GRAPH_DATA_PORT 0x001F // and Data registers + +#define CRTC_ADDRESS_PORT_COLOR 0x0024 // CRT Controller Address and +#define CRTC_DATA_PORT_COLOR 0x0025 // Data registers in color mode +#define FEAT_CTRL_WRITE_PORT_COLOR 0x002A // Feature Control write port +#define INPUT_STATUS_1_COLOR 0x002A // Input Status 1 register read + // port in color mode +// eVb: 3.2 [END] +#define ATT_INITIALIZE_PORT_COLOR INPUT_STATUS_1_COLOR + // Register to read to reset + // Attribute Controller index/data + // toggle in color mode + +// +// Offsets in HardwareStateHeader->PortValue[] of save areas for non-indexed +// VGA registers. +// + +#define CRTC_ADDRESS_MONO_OFFSET 0x04 +#define FEAT_CTRL_WRITE_MONO_OFFSET 0x0A +#define ATT_ADDRESS_OFFSET 0x10 +#define MISC_OUTPUT_REG_WRITE_OFFSET 0x12 +#define VIDEO_SUBSYSTEM_ENABLE_OFFSET 0x13 +#define SEQ_ADDRESS_OFFSET 0x14 +#define DAC_PIXEL_MASK_OFFSET 0x16 +#define DAC_STATE_OFFSET 0x17 +#define DAC_ADDRESS_WRITE_OFFSET 0x18 +#define GRAPH_ADDRESS_OFFSET 0x1E +#define CRTC_ADDRESS_COLOR_OFFSET 0x24 +#define FEAT_CTRL_WRITE_COLOR_OFFSET 0x2A + + // toggle in color mode +// +// VGA indexed register indexes. +// + +// CL-GD542x specific registers: +// +#define IND_CL_EXTS_ENB 0x06 // index in Sequencer to enable exts +#define IND_NORD_SCRATCH_PAD 0x09 // index in Seq of Nordic scratch pad +#define IND_CL_SCRATCH_PAD 0x0A // index in Seq of 542x scratch pad +#define IND_ALP_SCRATCH_PAD 0x15 // index in Seq of Alpine scratch pad +#define IND_CL_REV_REG 0x25 // index in CRTC of ID Register +#define IND_CL_ID_REG 0x27 // index in CRTC of ID Register +// +#define IND_CURSOR_START 0x0A // index in CRTC of the Cursor Start +#define IND_CURSOR_END 0x0B // and End registers +#define IND_CURSOR_HIGH_LOC 0x0E // index in CRTC of the Cursor Location +#define IND_CURSOR_LOW_LOC 0x0F // High and Low Registers +#define IND_VSYNC_END 0x11 // index in CRTC of the Vertical Sync + // End register, which has the bit + // that protects/unprotects CRTC + // index registers 0-7 +#define IND_CR2C 0x2C // Nordic LCD Interface Register +#define IND_CR2D 0x2D // Nordic LCD Display Control +#define IND_SET_RESET_ENABLE 0x01 // index of Set/Reset Enable reg in GC +#define IND_DATA_ROTATE 0x03 // index of Data Rotate reg in GC +#define IND_READ_MAP 0x04 // index of Read Map reg in Graph Ctlr +#define IND_GRAPH_MODE 0x05 // index of Mode reg in Graph Ctlr +#define IND_GRAPH_MISC 0x06 // index of Misc reg in Graph Ctlr +#define IND_BIT_MASK 0x08 // index of Bit Mask reg in Graph Ctlr +#define IND_SYNC_RESET 0x00 // index of Sync Reset reg in Seq +#define IND_MAP_MASK 0x02 // index of Map Mask in Sequencer +#define IND_MEMORY_MODE 0x04 // index of Memory Mode reg in Seq +#define IND_CRTC_PROTECT 0x11 // index of reg containing regs 0-7 in + // CRTC +#define IND_CRTC_COMPAT 0x34 // index of CRTC Compatibility reg + // in CRTC +#define IND_PERF_TUNING 0x16 // index of performance tuning in Seq +#define START_SYNC_RESET_VALUE 0x01 // value for Sync Reset reg to start + // synchronous reset +#define END_SYNC_RESET_VALUE 0x03 // value for Sync Reset reg to end + // synchronous reset + +// +// Value to write to Extensions Control register values extensions. +// + +#define CL64xx_EXTENSION_ENABLE_INDEX 0x0A // GR0A to be exact! +#define CL64xx_EXTENSION_ENABLE_VALUE 0xEC +#define CL64xx_EXTENSION_DISABLE_VALUE 0xCE +#define CL64xx_TRISTATE_CONTROL_REG 0xA1 + +#define CL6340_ENABLE_READBACK_REGISTER 0xE0 +#define CL6340_ENABLE_READBACK_ALLSEL_VALUE 0xF0 +#define CL6340_ENABLE_READBACK_OFF_VALUE 0x00 +#define CL6340_IDENTIFICATION_REGISTER 0xE9 +// +// Values for Attribute Controller Index register to turn video off +// and on, by setting bit 5 to 0 (off) or 1 (on). +// + +#define VIDEO_DISABLE 0 +#define VIDEO_ENABLE 0x20 + +#define INDEX_ENABLE_AUTO_START 0x31 + +// Masks to keep only the significant bits of the Graphics Controller and +// Sequencer Address registers. Masking is necessary because some VGAs, such +// as S3-based ones, don't return unused bits set to 0, and some SVGAs use +// these bits if extensions are enabled. +// + +#define GRAPH_ADDR_MASK 0x0F +#define SEQ_ADDR_MASK 0x07 + +// +// Mask used to toggle Chain4 bit in the Sequencer's Memory Mode register. +// + +#define CHAIN4_MASK 0x08 + +// +// Value written to the Read Map register when identifying the existence of +// a VGA in VgaInitialize. This value must be different from the final test +// value written to the Bit Mask in that routine. +// + +#define READ_MAP_TEST_SETTING 0x03 + +// +// Default text mode setting for various registers, used to restore their +// states if VGA detection fails after they've been modified. +// + +#define MEMORY_MODE_TEXT_DEFAULT 0x02 +#define BIT_MASK_DEFAULT 0xFF +#define READ_MAP_DEFAULT 0x00 + + +// +// Palette-related info. +// + +// +// Highest valid DAC color register index. +// + +#define VIDEO_MAX_COLOR_REGISTER 0xFF + +// +// Highest valid palette register index +// + +#define VIDEO_MAX_PALETTE_REGISTER 0x0F + +// +// Driver Specific Attribute Flags +// + +#define CAPS_NO_HOST_XFER 0x00000002 // Do not use host xfers to + // the blt engine. +#define CAPS_SW_POINTER 0x00000004 // Use software pointer. +#define CAPS_TRUE_COLOR 0x00000008 // Set upper color registers. +#define CAPS_MM_IO 0x00000010 // Use memory mapped IO. +#define CAPS_BLT_SUPPORT 0x00000020 // BLTs are supported +#define CAPS_IS_542x 0x00000040 // This is a 542x +#define CAPS_IS_5436 0x00000080 // This is a 5436 +#define CAPS_CURSOR_VERT_EXP 0x00000100 // Flag set if 8x6 panel, + // but 6x4 resolution + +// +// Structure used to describe each video mode in ModesVGA[]. +// + +typedef struct { + USHORT fbType; // color or monochrome, text or graphics, via + // VIDEO_MODE_COLOR and VIDEO_MODE_GRAPHICS + USHORT numPlanes; // # of video memory planes + USHORT bitsPerPlane; // # of bits of color in each plane + SHORT col; // # of text columns across screen with default font + SHORT row; // # of text rows down screen with default font + USHORT hres; // # of pixels across screen + USHORT vres; // # of scan lines down screen +// eVb: 3.2 [VGA] - Store frequency next to resolution data + ULONG Frequency; // Vertical Frequency +// eVb: 3.2 [END] + USHORT wbytes; // # of bytes from start of one scan line to start of next + ULONG sbytes; // total size of addressable display memory in bytes +// eVb: 3.3 [VBE] - Add VBE mode and bank flag + ULONG NoBankSwitch; + ULONG Mode; +// eVb: 3.3 [VBE] + PUSHORT CmdStream; // pointer to array of register-setting commands to + // set up mode +// eVb: 3.4 [VBE] - Add fields to track linear addresses/sizes and flags + ULONG PhysBase; + ULONG FrameBufferBase; + ULONG FrameBufferSize; + ULONG PhysSize; + ULONG LogicalWidth; + ULONG NonVgaMode; + ULONG Granularity; +// eVb: 3.4 [END] +} VIDEOMODE, *PVIDEOMODE; + +// +// Mode into which to put the VGA before starting a VDM, so it's a plain +// vanilla VGA. (This is the mode's index in ModesVGA[], currently standard +// 80x25 text mode.) +// + +#define DEFAULT_MODE 0 + + +// +// Info used by the Validator functions and save/restore code. +// Structure used to trap register accesses that must be done atomically. +// + +#define VGA_MAX_VALIDATOR_DATA 100 + +#define VGA_VALIDATOR_UCHAR_ACCESS 1 +#define VGA_VALIDATOR_USHORT_ACCESS 2 +#define VGA_VALIDATOR_ULONG_ACCESS 3 + +typedef struct _VGA_VALIDATOR_DATA { + ULONG Port; + UCHAR AccessType; + ULONG Data; +} VGA_VALIDATOR_DATA, *PVGA_VALIDATOR_DATA; + +// +// Number of bytes to save in each plane. +// + +#define VGA_PLANE_SIZE 0x10000 + +// +// Number of each type of indexed register in a standard VGA, used by +// validator and state save/restore functions. +// +// Note: VDMs currently only support basic VGAs only. +// + +#define VGA_NUM_SEQUENCER_PORTS 5 +#define VGA_NUM_CRTC_PORTS 25 +#define VGA_NUM_GRAPH_CONT_PORTS 9 +#define VGA_NUM_ATTRIB_CONT_PORTS 21 +#define VGA_NUM_DAC_ENTRIES 256 + +#define EXT_NUM_GRAPH_CONT_PORTS 0 +#define EXT_NUM_SEQUENCER_PORTS 0 +#define EXT_NUM_CRTC_PORTS 0 +#define EXT_NUM_ATTRIB_CONT_PORTS 0 +#define EXT_NUM_DAC_ENTRIES 0 + +// +// These constants determine the offsets within the +// VIDEO_HARDWARE_STATE_HEADER structure that are used to save and +// restore the VGA's state. +// + +#define VGA_HARDWARE_STATE_SIZE sizeof(VIDEO_HARDWARE_STATE_HEADER) + +#define VGA_BASIC_SEQUENCER_OFFSET (VGA_HARDWARE_STATE_SIZE + 0) +#define VGA_BASIC_CRTC_OFFSET (VGA_BASIC_SEQUENCER_OFFSET + \ + VGA_NUM_SEQUENCER_PORTS) +#define VGA_BASIC_GRAPH_CONT_OFFSET (VGA_BASIC_CRTC_OFFSET + \ + VGA_NUM_CRTC_PORTS) +#define VGA_BASIC_ATTRIB_CONT_OFFSET (VGA_BASIC_GRAPH_CONT_OFFSET + \ + VGA_NUM_GRAPH_CONT_PORTS) +#define VGA_BASIC_DAC_OFFSET (VGA_BASIC_ATTRIB_CONT_OFFSET + \ + VGA_NUM_ATTRIB_CONT_PORTS) +#define VGA_BASIC_LATCHES_OFFSET (VGA_BASIC_DAC_OFFSET + \ + (3 * VGA_NUM_DAC_ENTRIES)) + +#define VGA_EXT_SEQUENCER_OFFSET (VGA_BASIC_LATCHES_OFFSET + 4) +#define VGA_EXT_CRTC_OFFSET (VGA_EXT_SEQUENCER_OFFSET + \ + EXT_NUM_SEQUENCER_PORTS) +#define VGA_EXT_GRAPH_CONT_OFFSET (VGA_EXT_CRTC_OFFSET + \ + EXT_NUM_CRTC_PORTS) +#define VGA_EXT_ATTRIB_CONT_OFFSET (VGA_EXT_GRAPH_CONT_OFFSET +\ + EXT_NUM_GRAPH_CONT_PORTS) +#define VGA_EXT_DAC_OFFSET (VGA_EXT_ATTRIB_CONT_OFFSET + \ + EXT_NUM_ATTRIB_CONT_PORTS) + +#define VGA_VALIDATOR_OFFSET (VGA_EXT_DAC_OFFSET + 4 * EXT_NUM_DAC_ENTRIES) + +#define VGA_VALIDATOR_AREA_SIZE sizeof (ULONG) + (VGA_MAX_VALIDATOR_DATA * \ + sizeof (VGA_VALIDATOR_DATA)) + \ + sizeof (ULONG) + \ + sizeof (ULONG) + \ + sizeof (PVIDEO_ACCESS_RANGE) + +#define VGA_MISC_DATA_AREA_OFFSET VGA_VALIDATOR_OFFSET + VGA_VALIDATOR_AREA_SIZE + +#define VGA_MISC_DATA_AREA_SIZE 0 + +#define VGA_PLANE_0_OFFSET VGA_MISC_DATA_AREA_OFFSET + VGA_MISC_DATA_AREA_SIZE + +#define VGA_PLANE_1_OFFSET VGA_PLANE_0_OFFSET + VGA_PLANE_SIZE +#define VGA_PLANE_2_OFFSET VGA_PLANE_1_OFFSET + VGA_PLANE_SIZE +#define VGA_PLANE_3_OFFSET VGA_PLANE_2_OFFSET + VGA_PLANE_SIZE + +// +// Space needed to store all state data. +// + +#define VGA_TOTAL_STATE_SIZE VGA_PLANE_3_OFFSET + VGA_PLANE_SIZE + + +// +// Device extension for the driver object. This data is only used +// locally, so this structure can be added to as needed. +// + +typedef struct _HW_DEVICE_EXTENSION { + + PHYSICAL_ADDRESS PhysicalVideoMemoryBase; // physical memory address and + PHYSICAL_ADDRESS PhysicalFrameOffset; // physical memory address and + ULONG PhysicalVideoMemoryLength; // length of display memory + ULONG PhysicalFrameLength; // length of display memory for + // the current mode. + + PUCHAR IOAddress; // base I/O address of VGA ports + PUCHAR VideoMemoryAddress; // base virtual memory address of VGA memory + ULONG ModeIndex; // index of current mode in ModesVGA[] + PVIDEOMODE CurrentMode; // pointer to VIDEOMODE structure for + // current mode + + VIDEO_CURSOR_POSITION CursorPosition; // current cursor position + + UCHAR CursorEnable; // whether cursor is enabled or not + UCHAR CursorTopScanLine; // Cursor Start register setting (top scan) + UCHAR CursorBottomScanLine; // Cursor End register setting (bottom scan) +// eVb: 3.5 [VBE] - Add fields for VBE support and XP+ INT10 interface + VIDEO_PORT_INT10_INTERFACE Int10Interface; + BOOLEAN VesaBiosOk; +// eVb: 3.5 [END] +} HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION; + + +// +// Function prototypes. +// + +// +// Entry points for the VGA validator. Used in VgaEmulatorAccessEntries[]. +// + + +// +// Vga init scripts for font loading +// + +extern USHORT EnableA000Data[]; +extern USHORT DisableA000Color[]; + +// +// Mode Information +// + +extern ULONG NumVideoModes; +extern VIDEOMODE ModesVGA[]; +extern PVIDEOMODE VgaModeList; + +// eVb: 3.5 [VGA] - Add ATI/Mach64 Access Range +#define NUM_VGA_ACCESS_RANGES 5 +// eVb: 3.5 [END] +extern VIDEO_ACCESS_RANGE VgaAccessRange[]; + +#include "vbe.h" diff --git a/reactos/drivers/video/miniport/vga_new/vga.rbuild b/reactos/drivers/video/miniport/vga_new/vga.rbuild new file mode 100644 index 00000000000..622440d4423 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/vga.rbuild @@ -0,0 +1,18 @@ + + + + . + videoprt + libcntpr + modeset.c + vgadata.c + vga.c + vbemodes.c + vbe.c + vga.rc + vga.h + + -mrtd + -fno-builtin + + diff --git a/reactos/drivers/video/miniport/vga_new/vga.rc b/reactos/drivers/video/miniport/vga_new/vga.rc new file mode 100644 index 00000000000..4aac6fdcae3 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/vga.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "VGA Miniport Device Driver\0" +#define REACTOS_STR_INTERNAL_NAME "vga\0" +#define REACTOS_STR_ORIGINAL_FILENAME "vga.sys\0" +#include diff --git a/reactos/drivers/video/miniport/vga_new/vgadata.c b/reactos/drivers/video/miniport/vga_new/vgadata.c new file mode 100644 index 00000000000..6f9ea0f1c61 --- /dev/null +++ b/reactos/drivers/video/miniport/vga_new/vgadata.c @@ -0,0 +1,490 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/vgadata.c + * PURPOSE: Handles switching to VGA Modes and holds VGA Built-in Modes + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "vga.h" + +// +// This structure describes to which ports access is required. +// + +VIDEO_ACCESS_RANGE VgaAccessRange[] = { +{ + {{VGA_BASE_IO_PORT, 0x00000000}}, // 64-bit linear base address + // of range + VGA_START_BREAK_PORT - VGA_BASE_IO_PORT + 1, // # of ports + 1, // range is in I/O space + 1, // range should be visible + 0 // range should be shareable +}, +{ + {{VGA_END_BREAK_PORT, 0x00000000}}, + VGA_MAX_IO_PORT - VGA_END_BREAK_PORT + 1, + 1, + 1, + 0 +}, + +// +// This next region also includes Memory mapped IO. In MMIO, the ports are +// repeated every 256 bytes from b8000 to bff00. +// + +{ + {{MEM_VGA, 0x00000000}}, + MEM_VGA_SIZE, + 0, + 1, + 0 +}, +// eVb: 4.1 [VGA] - Add ATI/Mach64 VGA registers +// +// ATI Registers +// + +{ + {{0x1CE, 0x00000000}}, + 2, + 1, + 1, + 0 +}, +{ + {{0x2E8, 0x00000000}}, + 8, + 1, + 1, + 0 +} +// eVb: 4.1 [END] +}; + +// +// 640x480 256-color 60Hz mode (BIOS mode 12) set command string for +// VGA. +// +// eVb: 4.2 [VGA] - Add VGA command streams instead of Cirrus +USHORT VGA_640x480[] = { + OWM, // begin setmode + SEQ_ADDRESS_PORT, + 5, // count + 0x100, // start sync reset + 0x0101,0x0F02,0x0003,0x0604, // program up sequencer + + OB, // misc. register + MISC_OUTPUT_REG_WRITE_PORT, + 0xE3, + + OW, // text/graphics bit + GRAPH_ADDRESS_PORT, + 0x506, + + OW, // end sync reset + SEQ_ADDRESS_PORT, + IND_SYNC_RESET, + + OB, + SEQ_DATA_PORT, + END_SYNC_RESET_VALUE, + + OW, // unprotect crtc 0-7 + CRTC_ADDRESS_PORT_COLOR, + 0x511, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_CRTC_PORTS,0, // count, startindex + 0x5F,0x4F,0x50,0x82,0x54,0x80,0x0B,0x3E,0x00,0x40,0x0,0x0,0x0,0x0,0x0,0x0, + 0xEA,0x8C,0xDF,0x28,0x0,0xE7,0x4,0xE3,0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + METAOUT+ATCOUT, // program atc registers + ATT_ADDRESS_PORT, + VGA_NUM_ATTRIB_CONT_PORTS,0, // count, startindex + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x3F, 0x01, 0x00, + 0x0F, 0x00, 0x00, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_GRAPH_CONT_PORTS,0, // count, startindex + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x05, 0x0F, 0xFF, + + OB, + DAC_PIXEL_MASK_PORT, + 0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + OB, // turn video on. + ATT_ADDRESS_PORT, + VIDEO_ENABLE, + + EOD +}; + +// +// 720x400 color text mode (BIOS mode 3) set command string for +// VGA. +// + +USHORT VGA_TEXT_0[] = { + OWM, // begin setmode + SEQ_ADDRESS_PORT, + 5, // count + 0x100, // start sync reset + 0x0101,0x0302,0x0003,0x0204, // program up sequencer + + OB, // misc. register + MISC_OUTPUT_REG_WRITE_PORT, + 0x67, + + OW, // text/graphics bit + GRAPH_ADDRESS_PORT, + 0x0e06, + + OW, // end sync reset + SEQ_ADDRESS_PORT, + IND_SYNC_RESET, + + OB, + SEQ_DATA_PORT, + END_SYNC_RESET_VALUE, + + OW, // unprotect crtc 0-7 + CRTC_ADDRESS_PORT_COLOR, + 0xE11, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_CRTC_PORTS,0, // count, startindex + 0x5F,0x4F,0x50,0x82,0x55,0x81,0xBF,0x1F,0x00,0x4F,0xD,0xE,0x0,0x0,0x0,0x0, + 0x9c,0x8E,0x8F,0x28,0x1F,0x96,0xB9,0xA3,0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + METAOUT+ATCOUT, // program atc registers + ATT_ADDRESS_PORT, + VGA_NUM_ATTRIB_CONT_PORTS,0, // count, startindex + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x3F, 0x04, 0x00, + 0x0F, 0x08, 0x00, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_GRAPH_CONT_PORTS,0, // count, startindex + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x0E, 0x00, 0xFF, + + OB, + DAC_PIXEL_MASK_PORT, + 0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + OB, // turn video on. + ATT_ADDRESS_PORT, + VIDEO_ENABLE, + + EOD +}; + +// +// 640x400 color text mode (BIOS mode 3) set command string for +// VGA. +// + +USHORT VGA_TEXT_1[] = { + OWM, // begin setmode + SEQ_ADDRESS_PORT, + 5, // count + 0x100, // start sync reset + 0x0101,0x0302,0x0003,0x0204, // program up sequencer + + OB, // misc. register + MISC_OUTPUT_REG_WRITE_PORT, + 0xA3, + + OW, // text/graphics bit + GRAPH_ADDRESS_PORT, + 0x0e06, + + OW, // end sync reset + SEQ_ADDRESS_PORT, + IND_SYNC_RESET, + + OB, + SEQ_DATA_PORT, + END_SYNC_RESET_VALUE, + + OW, // unprotect crtc 0-7 + CRTC_ADDRESS_PORT_COLOR, + 0x511, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_CRTC_PORTS,0, // count, startindex + 0x5F,0x4F,0x50,0x82,0x55,0x81,0xBF,0x1F,0x00,0x4D,0xB,0xC,0x0,0x0,0x0,0x0, + 0x83,0x85,0x5D,0x28,0x1F,0x63,0xBA,0xA3,0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + METAOUT+ATCOUT, // program atc registers + ATT_ADDRESS_PORT, + VGA_NUM_ATTRIB_CONT_PORTS,0, // count, startindex + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x3F, 0x04, 0x00, + 0x0F, 0x00, 0x00, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_GRAPH_CONT_PORTS,0, // count, startindex + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x0E, 0x00, 0xFF, + + OB, + DAC_PIXEL_MASK_PORT, + 0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + OB, // turn video on. + ATT_ADDRESS_PORT, + VIDEO_ENABLE, + + EOD +}; +// eVb: 4.2 [END] +// +// Video mode table - contains information and commands for initializing each +// mode. These entries must correspond with those in VIDEO_MODE_VGA. The first +// entry is commented; the rest follow the same format, but are not so +// heavily commented. +// +// eVb: 4.3 [VGA] - Add VGA, ModeX and SVGA mode instead of Cirrus Modes +VIDEOMODE ModesVGA[] = +{ + // Color text mode 3, 720x400, 9x16 char cell (VGA). + // + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR, // flags that this mode is a color mode, but not graphics + 4, // four planes + 1, // one bit of colour per plane + 80, 25, // 80x25 text resolution + 720, 400, // 720x400 pixels on screen + 1, // only support one frequency, non-interlaced + 160, 0x10000, // 160 bytes per scan line, 64K of CPU-addressable bitmap + FALSE, + 0x3, VGA_TEXT_0, // Mode 3, I/O initialization stream + 0xA0000, // Physical address at 0xA0000 + 0x18000, 0x8000, + 0x20000, // 2 banks of 64K, 128KB total memory + 720, // 720 pixels per scan line + FALSE, + 0 + }, + + // + // Color text mode 3, 640x350, 8x14 char cell (EGA). + // + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR, + 4, 1, + 80, 25, + 640, 350, + 1, + 160, 0x10000, + FALSE, + 0x3, VGA_TEXT_1, + 0xA0000, + 0x18000, 0x8000, + 0x20000, + 640, + FALSE, + 0 + }, + + // + // + // Standard VGA Color graphics mode 0x12, 640x480 16 colors. + // + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 4, 1, + 80, 30, + 640, 480, + 1, + 80, 0x10000, + FALSE, + 0x12, VGA_640x480, + 0xA0000, + 0, 0x20000, + 0x20000, + 640, + FALSE, + 0 + }, + + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 8, 1, + 0, 0, + 320, 200, + 70, + 80, 0x10000, + FALSE, + 0x3, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 320, + FALSE, + 0 + }, + + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 8, 1, + 0, 0, + 320, 240, + 60, + 80, 0x10000, + FALSE, + 0x3, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 320, + FALSE, + 0 + }, + + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 8, 1, + 0, 0, + 320, 400, + 70, + 80, 0x10000, + FALSE, + 0x3, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 320, + FALSE, + 0 + }, + + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 8, 1, + 0, 0, + 320, 480, + 60, + 80, 0x10000, + FALSE, + 0x3, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 320, + FALSE, + 0 + }, + + // + // 800x600 16 colors. + // + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 4, 1, + 100, 37, + 800, 600, + 1, + 100, 0x10000, + FALSE, + (0x102 << 16) | VBE_SET_VBE_MODE, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 800, + FALSE, + 0 + }, +}; + +ULONG NumVideoModes = sizeof(ModesVGA) / sizeof(VIDEOMODE); +PVIDEOMODE VgaModeList; +// eVb: 4.3 [END] + +// +// +// Data used to set the Graphics and Sequence Controllers to put the +// VGA into a planar state at A0000 for 64K, with plane 2 enabled for +// reads and writes, so that a font can be loaded, and to disable that mode. +// + +// Settings to enable planar mode with plane 2 enabled. +// + +USHORT EnableA000Data[] = { + OWM, + SEQ_ADDRESS_PORT, + 1, + 0x0100, + + OWM, + GRAPH_ADDRESS_PORT, + 3, + 0x0204, // Read Map = plane 2 + 0x0005, // Graphics Mode = read mode 0, write mode 0 + 0x0406, // Graphics Miscellaneous register = A0000 for 64K, not odd/even, + // graphics mode + OWM, + SEQ_ADDRESS_PORT, + 3, + 0x0402, // Map Mask = write to plane 2 only + 0x0404, // Memory Mode = not odd/even, not full memory, graphics mode + 0x0300, // end sync reset + EOD +}; + +// +// Settings to disable the font-loading planar mode. +// + +USHORT DisableA000Color[] = { + OWM, + SEQ_ADDRESS_PORT, + 1, + 0x0100, + + OWM, + GRAPH_ADDRESS_PORT, + 3, + 0x0004, 0x1005, 0x0E06, + + OWM, + SEQ_ADDRESS_PORT, + 3, + 0x0302, 0x0204, 0x0300, // end sync reset + EOD + +}; From d1efdcf9df055a197aa98b4f6d6c5a524d8f0fc2 Mon Sep 17 00:00:00 2001 From: evb Date: Fri, 5 Mar 2010 17:29:51 +0000 Subject: [PATCH 105/211] - New Framebuffer (Linear) Display Driver to support new unified VGA/VBE miniport. Based on NT4 DDK Sample, with modifications by me (marked with // eVb) to support new functionality needed for 2003-era driver. - Also used Virtual Box Display Driver as sample, which is based on "GPL" Windows 2003 DDK sample driver. Could not use 2003 DDK sample directly because of licensing issues, and feel unsafe about VirtualBox "GPL" driver that says "PATENTED AND ONLY FOR USE IN MICROSOFT PRODUCTS". - Note that old driver was based off DDK sample too, but with variables renamed (some comments identical!) and code reformatted, then marked as "GPL". This is not very good way to share/use code... one day someone can teach you lesson. svn path=/trunk/; revision=45874 --- .../drivers/video/displays/directory.rbuild | 7 +- .../video/displays/framebuf_new/debug.c | 59 ++ .../video/displays/framebuf_new/debug.h | 26 + .../video/displays/framebuf_new/driver.h | 75 +++ .../video/displays/framebuf_new/enable.c | 476 ++++++++++++++ .../displays/framebuf_new/framebuf_new.rbuild | 18 + .../displays/framebuf_new/framebuf_new.rc | 5 + .../displays/framebuf_new/framebuf_new.spec | 1 + .../video/displays/framebuf_new/palette.c | 332 ++++++++++ .../video/displays/framebuf_new/pointer.c | 455 +++++++++++++ .../video/displays/framebuf_new/screen.c | 601 ++++++++++++++++++ 11 files changed, 2050 insertions(+), 5 deletions(-) create mode 100755 reactos/drivers/video/displays/framebuf_new/debug.c create mode 100755 reactos/drivers/video/displays/framebuf_new/debug.h create mode 100755 reactos/drivers/video/displays/framebuf_new/driver.h create mode 100644 reactos/drivers/video/displays/framebuf_new/enable.c create mode 100644 reactos/drivers/video/displays/framebuf_new/framebuf_new.rbuild create mode 100644 reactos/drivers/video/displays/framebuf_new/framebuf_new.rc create mode 100644 reactos/drivers/video/displays/framebuf_new/framebuf_new.spec create mode 100755 reactos/drivers/video/displays/framebuf_new/palette.c create mode 100755 reactos/drivers/video/displays/framebuf_new/pointer.c create mode 100755 reactos/drivers/video/displays/framebuf_new/screen.c diff --git a/reactos/drivers/video/displays/directory.rbuild b/reactos/drivers/video/displays/directory.rbuild index eb650854819..16801792653 100644 --- a/reactos/drivers/video/displays/directory.rbuild +++ b/reactos/drivers/video/displays/directory.rbuild @@ -1,10 +1,7 @@ - - - - - + + diff --git a/reactos/drivers/video/displays/framebuf_new/debug.c b/reactos/drivers/video/displays/framebuf_new/debug.c new file mode 100755 index 00000000000..ada125df7ec --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/debug.c @@ -0,0 +1,59 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/debug.c + * PURPOSE: Debug Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +#if DBG + +ULONG DebugLevel = 0xFFFFFFFF; + +/***************************************************************************** + * + * Routine Description: + * + * This function is variable-argument, level-sensitive debug print + * routine. + * If the specified debug level for the print statement is lower or equal + * to the current debug level, the message will be printed. + * + * Arguments: + * + * DebugPrintLevel - Specifies at which debugging level the string should + * be printed + * + * DebugMessage - Variable argument ascii c string + * + * Return Value: + * + * None. + * + ***************************************************************************/ + +VOID +DebugPrint( + ULONG DebugPrintLevel, + PCHAR DebugMessage, + ... + ) + +{ + + va_list ap; + + va_start(ap, DebugMessage); + + if (DebugPrintLevel <= DebugLevel) + { + EngDebugPrint(STANDARD_DEBUG_PREFIX, DebugMessage, ap); + } + + va_end(ap); + +} + +#endif diff --git a/reactos/drivers/video/displays/framebuf_new/debug.h b/reactos/drivers/video/displays/framebuf_new/debug.h new file mode 100755 index 00000000000..d73a223baaf --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/debug.h @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/debug.h + * PURPOSE: Debug Support Header + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#if DBG + +VOID +DebugPrint( + ULONG DebugPrintLevel, + PCHAR DebugMessage, + ... + ); + +#define DISPDBG(arg) DebugPrint arg +#define RIP(x) { DebugPrint(0, x); EngDebugBreak();} + +#else + +#define DISPDBG(arg) +#define RIP(x) + +#endif diff --git a/reactos/drivers/video/displays/framebuf_new/driver.h b/reactos/drivers/video/displays/framebuf_new/driver.h new file mode 100755 index 00000000000..77306ca5ba6 --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/driver.h @@ -0,0 +1,75 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/driver.h + * PURPOSE: Main Driver Header File + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#define DBG 1 +#include "stddef.h" +#include +#include "windef.h" +#include "wingdi.h" +#include "winddi.h" +#include "devioctl.h" +#include "ntddvdeo.h" +#include "debug.h" + +typedef struct _PDEV +{ + HANDLE hDriver; // Handle to \Device\Screen + HDEV hdevEng; // Engine's handle to PDEV + HSURF hsurfEng; // Engine's handle to surface + HPALETTE hpalDefault; // Handle to the default palette for device. + PBYTE pjScreen; // This is pointer to base screen address + ULONG cxScreen; // Visible screen width + ULONG cyScreen; // Visible screen height + ULONG ulMode; // Mode the mini-port driver is in. + LONG lDeltaScreen; // Distance from one scan to the next. + ULONG cScreenSize; // size of video memory, including + // offscreen memory. + PVOID pOffscreenList; // linked list of DCI offscreen surfaces. + FLONG flRed; // For bitfields device, Red Mask + FLONG flGreen; // For bitfields device, Green Mask + FLONG flBlue; // For bitfields device, Blue Mask + ULONG cPaletteShift; // number of bits the 8-8-8 palette must + // be shifted by to fit in the hardware + // palette. + ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported. + POINTL ptlHotSpot; // adjustment for pointer hot spot + VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes + DWORD cjPointerAttributes; // Size of buffer allocated + BOOL fHwCursorActive; // Are we currently using the hw cursor + PALETTEENTRY *pPal; // If this is pal managed, this is the pal + BOOL bSupportDCI; // Does the miniport support DCI? +// eVb: 3.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + LONG flHooks; +// eVb: 3.1 [END] +} PDEV, *PPDEV; + +DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *); +BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *); +BOOL bInitSURF(PPDEV, BOOL); +BOOL bInitPaletteInfo(PPDEV, DEVINFO *); +BOOL bInitPointer(PPDEV, DEVINFO *); +BOOL bInit256ColorPalette(PPDEV); +VOID vDisablePalette(PPDEV); +VOID vDisableSURF(PPDEV); + +#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256)) + +// +// Determines the size of the DriverExtra information in the DEVMODE +// structure passed to and from the display driver. +// + +#define DRIVER_EXTRA_SIZE 0 + +#define DLL_NAME L"framebuf" // Name of the DLL in UNICODE +#define STANDARD_DEBUG_PREFIX "FRAMEBUF: " // All debug output is prefixed +#define ALLOC_TAG 'bfDD' // Four byte tag (characters in + // reverse order) used for memory + // allocations diff --git a/reactos/drivers/video/displays/framebuf_new/enable.c b/reactos/drivers/video/displays/framebuf_new/enable.c new file mode 100644 index 00000000000..8031da8a173 --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/enable.c @@ -0,0 +1,476 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/enable.c + * PURPOSE: Main Driver Initialization and PDEV Enabling + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "driver.h" + +// The driver function table with all function index/address pairs + +static DRVFN gadrvfn[] = +{ + { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV }, + { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV }, + { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV }, + { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, + { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, + { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, + { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, + { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, + { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, + { INDEX_DrvGetModes, (PFN) DrvGetModes } +}; + +// Define the functions you want to hook for 8/16/24/32 pel formats + +#define HOOKS_BMF8BPP 0 + +#define HOOKS_BMF16BPP 0 + +#define HOOKS_BMF24BPP 0 + +#define HOOKS_BMF32BPP 0 + +/******************************Public*Routine******************************\ +* DrvEnableDriver +* +* Enables the driver by retrieving the drivers function table and version. +* +\**************************************************************************/ + +BOOL DrvEnableDriver( +ULONG iEngineVersion, +ULONG cj, +PDRVENABLEDATA pded) +{ +// Engine Version is passed down so future drivers can support previous +// engine versions. A next generation driver can support both the old +// and new engine conventions if told what version of engine it is +// working with. For the first version the driver does nothing with it. +// eVb: 1.1 [DDK Change] - Remove bogus statement + //iEngineVersion; +// eVb: 1.1 [END] +// Fill in as much as we can. + + if (cj >= sizeof(DRVENABLEDATA)) + pded->pdrvfn = gadrvfn; + + if (cj >= (sizeof(ULONG) * 2)) + pded->c = sizeof(gadrvfn) / sizeof(DRVFN); + +// DDI version this driver was targeted for is passed back to engine. +// Future graphic's engine may break calls down to old driver format. + + if (cj >= sizeof(ULONG)) +// eVb: 1.2 [DDK Change] - Use DDI_DRIVER_VERSION_NT4 instead of DDI_DRIVER_VERSION + pded->iDriverVersion = DDI_DRIVER_VERSION_NT4; +// eVb: 1.2 [END] + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* DrvEnablePDEV +* +* DDI function, Enables the Physical Device. +* +* Return Value: device handle to pdev. +* +\**************************************************************************/ + +DHPDEV DrvEnablePDEV( +DEVMODEW *pDevmode, // Pointer to DEVMODE +PWSTR pwszLogAddress, // Logical address +ULONG cPatterns, // number of patterns +HSURF *ahsurfPatterns, // return standard patterns +ULONG cjGdiInfo, // Length of memory pointed to by pGdiInfo +ULONG *pGdiInfo, // Pointer to GdiInfo structure +ULONG cjDevInfo, // Length of following PDEVINFO structure +DEVINFO *pDevInfo, // physical device information structure +HDEV hdev, // HDEV, used for callbacks +PWSTR pwszDeviceName, // DeviceName - not used +HANDLE hDriver) // Handle to base driver +{ + GDIINFO GdiInfo; + DEVINFO DevInfo; + PPDEV ppdev = (PPDEV) NULL; + + UNREFERENCED_PARAMETER(pwszLogAddress); + UNREFERENCED_PARAMETER(pwszDeviceName); + + // Allocate a physical device structure. + + ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG); + + if (ppdev == (PPDEV) NULL) + { + RIP("DISP DrvEnablePDEV failed EngAllocMem\n"); + return((DHPDEV) 0); + } + + memset(ppdev, 0, sizeof(PDEV)); + + // Save the screen handle in the PDEV. + + ppdev->hDriver = hDriver; + + // Get the current screen mode information. Set up device caps and devinfo. + + if (!bInitPDEV(ppdev, pDevmode, &GdiInfo, &DevInfo)) + { + DISPDBG((0,"DISP DrvEnablePDEV failed\n")); + goto error_free; + } + + // Initialize the cursor information. + + if (!bInitPointer(ppdev, &DevInfo)) + { + // Not a fatal error... + DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n")); + } + + // Initialize palette information. + + if (!bInitPaletteInfo(ppdev, &DevInfo)) + { + RIP("DrvEnablePDEV failed bInitPalette\n"); + goto error_free; + } + + // Copy the devinfo into the engine buffer. + + memcpy(pDevInfo, &DevInfo, min(sizeof(DEVINFO), cjDevInfo)); + + // Set the pdevCaps with GdiInfo we have prepared to the list of caps for this + // pdev. + + memcpy(pGdiInfo, &GdiInfo, min(cjGdiInfo, sizeof(GDIINFO))); + + return((DHPDEV) ppdev); + + // Error case for failure. +error_free: + EngFreeMem(ppdev); + return((DHPDEV) 0); +} + +/******************************Public*Routine******************************\ +* DrvCompletePDEV +* +* Store the HPDEV, the engines handle for this PDEV, in the DHPDEV. +* +\**************************************************************************/ + +VOID DrvCompletePDEV( +DHPDEV dhpdev, +HDEV hdev) +{ + ((PPDEV) dhpdev)->hdevEng = hdev; +} + +/******************************Public*Routine******************************\ +* DrvDisablePDEV +* +* Release the resources allocated in DrvEnablePDEV. If a surface has been +* enabled DrvDisableSurface will have already been called. +* +\**************************************************************************/ + +VOID DrvDisablePDEV( +DHPDEV dhpdev) +{ + vDisablePalette((PPDEV) dhpdev); + EngFreeMem(dhpdev); +} + +/******************************Public*Routine******************************\ +* DrvEnableSurface +* +* Enable the surface for the device. Hook the calls this driver supports. +* +* Return: Handle to the surface if successful, 0 for failure. +* +\**************************************************************************/ + +HSURF DrvEnableSurface( +DHPDEV dhpdev) +{ + PPDEV ppdev; + HSURF hsurf; + SIZEL sizl; + ULONG ulBitmapType; + FLONG flHooks; + + // Create engine bitmap around frame buffer. + + ppdev = (PPDEV) dhpdev; + + if (!bInitSURF(ppdev, TRUE)) + { + RIP("DISP DrvEnableSurface failed bInitSURF\n"); + return(FALSE); + } + + sizl.cx = ppdev->cxScreen; + sizl.cy = ppdev->cyScreen; + + if (ppdev->ulBitCount == 8) + { + if (!bInit256ColorPalette(ppdev)) { + RIP("DISP DrvEnableSurface failed to init the 8bpp palette\n"); + return(FALSE); + } + ulBitmapType = BMF_8BPP; + flHooks = HOOKS_BMF8BPP; + } + else if (ppdev->ulBitCount == 16) + { + ulBitmapType = BMF_16BPP; + flHooks = HOOKS_BMF16BPP; + } + else if (ppdev->ulBitCount == 24) + { + ulBitmapType = BMF_24BPP; + flHooks = HOOKS_BMF24BPP; + } + else + { + ulBitmapType = BMF_32BPP; + flHooks = HOOKS_BMF32BPP; + } +// eVb: 1.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + ppdev->flHooks = flHooks; +// eVb: 1.3 [END] +// eVb: 1.4 [DDK Change] - Use EngCreateDeviceSurface instead of EngCreateBitmap + hsurf = (HSURF)EngCreateDeviceSurface((DHSURF)ppdev, + sizl, + ulBitmapType); + + if (hsurf == (HSURF) 0) + { + RIP("DISP DrvEnableSurface failed EngCreateDeviceSurface\n"); + return(FALSE); + } +// eVb: 1.4 [END] + +// eVb: 1.5 [DDK Change] - Use EngModifySurface instead of EngAssociateSurface + if ( !EngModifySurface(hsurf, + ppdev->hdevEng, + ppdev->flHooks | HOOK_SYNCHRONIZE, + MS_NOTSYSTEMMEMORY, + (DHSURF)ppdev, + ppdev->pjScreen, + ppdev->lDeltaScreen, + NULL)) + { + RIP("DISP DrvEnableSurface failed EngModifySurface\n"); + return(FALSE); + } +// eVb: 1.5 [END] + ppdev->hsurfEng = hsurf; + + return(hsurf); +} + +/******************************Public*Routine******************************\ +* DrvDisableSurface +* +* Free resources allocated by DrvEnableSurface. Release the surface. +* +\**************************************************************************/ + +VOID DrvDisableSurface( +DHPDEV dhpdev) +{ + EngDeleteSurface(((PPDEV) dhpdev)->hsurfEng); + vDisableSURF((PPDEV) dhpdev); + ((PPDEV) dhpdev)->hsurfEng = (HSURF) 0; +} + +/******************************Public*Routine******************************\ +* DrvAssertMode +* +* This asks the device to reset itself to the mode of the pdev passed in. +* +\**************************************************************************/ + +BOOL DrvAssertMode( +DHPDEV dhpdev, +BOOL bEnable) +{ + PPDEV ppdev = (PPDEV) dhpdev; + ULONG ulReturn; + PBYTE pjScreen; + + if (bEnable) + { + // + // The screen must be reenabled, reinitialize the device to clean state. + // +// eVb: 1.6 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + pjScreen = ppdev->pjScreen; + + if (!bInitSURF(ppdev, FALSE)) + { + DISPDBG((0, "DISP DrvAssertMode failed bInitSURF\n")); + return (FALSE); + } + + if (pjScreen != ppdev->pjScreen) { + + if ( !EngModifySurface(ppdev->hsurfEng, + ppdev->hdevEng, + ppdev->flHooks | HOOK_SYNCHRONIZE, + MS_NOTSYSTEMMEMORY, + (DHSURF)ppdev, + ppdev->pjScreen, + ppdev->lDeltaScreen, + NULL)) + { + DISPDBG((0, "DISP DrvAssertMode failed EngModifySurface\n")); + return (FALSE); + } + } +// eVb: 1.6 [END] + return (TRUE); + } + else + { + // + // We must give up the display. + // Call the kernel driver to reset the device to a known state. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_RESET_DEVICE, + NULL, + 0, + NULL, + 0, + &ulReturn)) + { + RIP("DISP DrvAssertMode failed IOCTL"); + return FALSE; + } + else + { + return TRUE; + } + } +} + +/******************************Public*Routine******************************\ +* DrvGetModes +* +* Returns the list of available modes for the device. +* +\**************************************************************************/ + +ULONG DrvGetModes( +HANDLE hDriver, +ULONG cjSize, +DEVMODEW *pdm) + +{ + + DWORD cModes; + DWORD cbOutputSize; + PVIDEO_MODE_INFORMATION pVideoModeInformation, pVideoTemp; + DWORD cOutputModes = cjSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + DWORD cbModeSize; + + DISPDBG((3, "DrvGetModes\n")); + + cModes = getAvailableModes(hDriver, + (PVIDEO_MODE_INFORMATION *) &pVideoModeInformation, + &cbModeSize); + + if (cModes == 0) + { + DISPDBG((0, "DrvGetModes failed to get mode information")); + return 0; + } + + if (pdm == NULL) + { + cbOutputSize = cModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + } + else + { + // + // Now copy the information for the supported modes back into the output + // buffer + // + + cbOutputSize = 0; + + pVideoTemp = pVideoModeInformation; + + do + { + if (pVideoTemp->Length != 0) + { + if (cOutputModes == 0) + { + break; + } + + // + // Zero the entire structure to start off with. + // + + memset(pdm, 0, sizeof(DEVMODEW)); + + // + // Set the name of the device to the name of the DLL. + // + + memcpy(pdm->dmDeviceName, DLL_NAME, sizeof(DLL_NAME)); + + pdm->dmSpecVersion = DM_SPECVERSION; + pdm->dmDriverVersion = DM_SPECVERSION; + pdm->dmSize = sizeof(DEVMODEW); + pdm->dmDriverExtra = DRIVER_EXTRA_SIZE; + + pdm->dmBitsPerPel = pVideoTemp->NumberOfPlanes * + pVideoTemp->BitsPerPlane; + pdm->dmPelsWidth = pVideoTemp->VisScreenWidth; + pdm->dmPelsHeight = pVideoTemp->VisScreenHeight; + pdm->dmDisplayFrequency = pVideoTemp->Frequency; + pdm->dmDisplayFlags = 0; + + pdm->dmFields = DM_BITSPERPEL | + DM_PELSWIDTH | + DM_PELSHEIGHT | + DM_DISPLAYFREQUENCY | + DM_DISPLAYFLAGS ; + + // + // Go to the next DEVMODE entry in the buffer. + // + + cOutputModes--; + + pdm = (LPDEVMODEW) ( ((ULONG)pdm) + sizeof(DEVMODEW) + + DRIVER_EXTRA_SIZE); + + cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + cbModeSize); + + } while (--cModes); + } + + EngFreeMem(pVideoModeInformation); + + return cbOutputSize; + +} diff --git a/reactos/drivers/video/displays/framebuf_new/framebuf_new.rbuild b/reactos/drivers/video/displays/framebuf_new/framebuf_new.rbuild new file mode 100644 index 00000000000..c334ac9ac4a --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/framebuf_new.rbuild @@ -0,0 +1,18 @@ + + + + + . + win32k + debug.c + enable.c + palette.c + pointer.c + screen.c + framebuf_new.rc + + -mrtd + -fno-builtin + -Wno-unused-variable + + diff --git a/reactos/drivers/video/displays/framebuf_new/framebuf_new.rc b/reactos/drivers/video/displays/framebuf_new/framebuf_new.rc new file mode 100644 index 00000000000..98ba2627f11 --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/framebuf_new.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Framebuffer Display Driver\0" +#define REACTOS_STR_INTERNAL_NAME "framebuf\0" +#define REACTOS_STR_ORIGINAL_FILENAME "framebuf.dll\0" +#include diff --git a/reactos/drivers/video/displays/framebuf_new/framebuf_new.spec b/reactos/drivers/video/displays/framebuf_new/framebuf_new.spec new file mode 100644 index 00000000000..aec115e4ef7 --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/framebuf_new.spec @@ -0,0 +1 @@ +@ stdcall DrvEnableDriver(long long ptr) diff --git a/reactos/drivers/video/displays/framebuf_new/palette.c b/reactos/drivers/video/displays/framebuf_new/palette.c new file mode 100755 index 00000000000..c8cff990e2b --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/palette.c @@ -0,0 +1,332 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/palette.c + * PURPOSE: Palette Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +// Global Table defining the 20 Window Default Colors. For 256 color +// palettes the first 10 must be put at the beginning of the palette +// and the last 10 at the end of the palette. + +const PALETTEENTRY BASEPALETTE[20] = +{ + { 0, 0, 0, 0 }, // 0 + { 0x80,0, 0, 0 }, // 1 + { 0, 0x80,0, 0 }, // 2 + { 0x80,0x80,0, 0 }, // 3 + { 0, 0, 0x80,0 }, // 4 + { 0x80,0, 0x80,0 }, // 5 + { 0, 0x80,0x80,0 }, // 6 + { 0xC0,0xC0,0xC0,0 }, // 7 + { 192, 220, 192, 0 }, // 8 + { 166, 202, 240, 0 }, // 9 + { 255, 251, 240, 0 }, // 10 + { 160, 160, 164, 0 }, // 11 + { 0x80,0x80,0x80,0 }, // 12 + { 0xFF,0, 0 ,0 }, // 13 + { 0, 0xFF,0 ,0 }, // 14 + { 0xFF,0xFF,0 ,0 }, // 15 + { 0 ,0, 0xFF,0 }, // 16 + { 0xFF,0, 0xFF,0 }, // 17 + { 0, 0xFF,0xFF,0 }, // 18 + { 0xFF,0xFF,0xFF,0 }, // 19 +}; + +BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo); + +/******************************Public*Routine******************************\ +* bInitPaletteInfo +* +* Initializes the palette information for this PDEV. +* +* Called by DrvEnablePDEV. +* +\**************************************************************************/ + +BOOL bInitPaletteInfo(PPDEV ppdev, DEVINFO *pDevInfo) +{ + if (!bInitDefaultPalette(ppdev, pDevInfo)) + return(FALSE); + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* vDisablePalette +* +* Frees resources allocated by bInitPaletteInfo. +* +\**************************************************************************/ + +VOID vDisablePalette(PPDEV ppdev) +{ +// Delete the default palette if we created one. + + if (ppdev->hpalDefault) + { + EngDeletePalette(ppdev->hpalDefault); + ppdev->hpalDefault = (HPALETTE) 0; + } + + if (ppdev->pPal != (PPALETTEENTRY)NULL) + EngFreeMem((PVOID)ppdev->pPal); +} + +/******************************Public*Routine******************************\ +* bInitDefaultPalette +* +* Initializes default palette for PDEV. +* +\**************************************************************************/ + +BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo) +{ + if (ppdev->ulBitCount == 8) + { + ULONG ulLoop; + BYTE jRed,jGre,jBlu; + + // + // Allocate our palette + // + + ppdev->pPal = (PPALETTEENTRY)EngAllocMem(0, sizeof(PALETTEENTRY) * 256, + ALLOC_TAG); + + if ((ppdev->pPal) == NULL) { + RIP("DISP bInitDefaultPalette() failed EngAllocMem\n"); + return(FALSE); + } + + // + // Generate 256 (8*4*4) RGB combinations to fill the palette + // + + jRed = jGre = jBlu = 0; + + for (ulLoop = 0; ulLoop < 256; ulLoop++) + { + ppdev->pPal[ulLoop].peRed = jRed; + ppdev->pPal[ulLoop].peGreen = jGre; + ppdev->pPal[ulLoop].peBlue = jBlu; + ppdev->pPal[ulLoop].peFlags = (BYTE)0; + + if (!(jRed += 32)) + if (!(jGre += 32)) + jBlu += 64; + } + + // + // Fill in Windows Reserved Colors from the WIN 3.0 DDK + // The Window Manager reserved the first and last 10 colors for + // painting windows borders and for non-palette managed applications. + // + + for (ulLoop = 0; ulLoop < 10; ulLoop++) + { + // + // First 10 + // + + ppdev->pPal[ulLoop] = BASEPALETTE[ulLoop]; + + // + // Last 10 + // + + ppdev->pPal[246 + ulLoop] = BASEPALETTE[ulLoop+10]; + } + + // + // Create handle for palette. + // + + ppdev->hpalDefault = + pDevInfo->hpalDefault = EngCreatePalette(PAL_INDEXED, + 256, + (PULONG) ppdev->pPal, + 0,0,0); + + if (ppdev->hpalDefault == (HPALETTE) 0) + { + RIP("DISP bInitDefaultPalette failed EngCreatePalette\n"); + EngFreeMem(ppdev->pPal); + return(FALSE); + } + + // + // Initialize the hardware with the initial palette. + // + + return(TRUE); + + } else { + + ppdev->hpalDefault = + pDevInfo->hpalDefault = EngCreatePalette(PAL_BITFIELDS, + 0,(PULONG) NULL, + ppdev->flRed, + ppdev->flGreen, + ppdev->flBlue); + + if (ppdev->hpalDefault == (HPALETTE) 0) + { + RIP("DISP bInitDefaultPalette failed EngCreatePalette\n"); + return(FALSE); + } + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bInit256ColorPalette +* +* Initialize the hardware's palette registers. +* +\**************************************************************************/ + +BOOL bInit256ColorPalette(PPDEV ppdev) +{ + BYTE ajClutSpace[MAX_CLUT_SIZE]; + PVIDEO_CLUT pScreenClut; + ULONG ulReturnedDataLength; + ULONG cColors; + PVIDEO_CLUTDATA pScreenClutData; + + if (ppdev->ulBitCount == 8) + { + // + // Fill in pScreenClut header info: + // + + pScreenClut = (PVIDEO_CLUT) ajClutSpace; + pScreenClut->NumEntries = 256; + pScreenClut->FirstEntry = 0; + + // + // Copy colours in: + // + + cColors = 256; + pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0])); + + while(cColors--) + { + pScreenClutData[cColors].Red = ppdev->pPal[cColors].peRed >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Green = ppdev->pPal[cColors].peGreen >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Blue = ppdev->pPal[cColors].peBlue >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Unused = 0; + } + + // + // Set palette registers: + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_COLOR_REGISTERS, + pScreenClut, + MAX_CLUT_SIZE, + NULL, + 0, + &ulReturnedDataLength)) + { + DISPDBG((0, "Failed bEnablePalette")); + return(FALSE); + } + } + + DISPDBG((5, "Passed bEnablePalette")); + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* DrvSetPalette +* +* DDI entry point for manipulating the palette. +* +\**************************************************************************/ + +BOOL DrvSetPalette( +DHPDEV dhpdev, +PALOBJ* ppalo, +FLONG fl, +ULONG iStart, +ULONG cColors) +{ + BYTE ajClutSpace[MAX_CLUT_SIZE]; + PVIDEO_CLUT pScreenClut; + PVIDEO_CLUTDATA pScreenClutData; + PDEV* ppdev; + + UNREFERENCED_PARAMETER(fl); + + ppdev = (PDEV*) dhpdev; + + // + // Fill in pScreenClut header info: + // + + pScreenClut = (PVIDEO_CLUT) ajClutSpace; + pScreenClut->NumEntries = (USHORT) cColors; + pScreenClut->FirstEntry = (USHORT) iStart; + + pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0])); + + if (cColors != PALOBJ_cGetColors(ppalo, iStart, cColors, + (ULONG*) pScreenClutData)) + { + DISPDBG((0, "DrvSetPalette failed PALOBJ_cGetColors\n")); + return (FALSE); + } + + // + // Set the high reserved byte in each palette entry to 0. + // Do the appropriate palette shifting to fit in the DAC. + // + + if (ppdev->cPaletteShift) + { + while(cColors--) + { + pScreenClutData[cColors].Red >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Green >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Blue >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Unused = 0; + } + } + else + { + while(cColors--) + { + pScreenClutData[cColors].Unused = 0; + } + } + + // + // Set palette registers + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_COLOR_REGISTERS, + pScreenClut, + MAX_CLUT_SIZE, + NULL, + 0, + &cColors)) + { + DISPDBG((0, "DrvSetPalette failed EngDeviceIoControl\n")); + return (FALSE); + } + + return(TRUE); + +} diff --git a/reactos/drivers/video/displays/framebuf_new/pointer.c b/reactos/drivers/video/displays/framebuf_new/pointer.c new file mode 100755 index 00000000000..d3752a2763c --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/pointer.c @@ -0,0 +1,455 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/pointer.c + * PURPOSE: Hardware Pointer Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +BOOL bCopyColorPointer( +PPDEV ppdev, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo); + +BOOL bCopyMonoPointer( +PPDEV ppdev, +SURFOBJ *psoMask); + +BOOL bSetHardwarePointerShape( +SURFOBJ *pso, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo, +LONG x, +LONG y, +FLONG fl); + +/******************************Public*Routine******************************\ +* DrvMovePointer +* +* Moves the hardware pointer to a new position. +* +\**************************************************************************/ + +VOID DrvMovePointer +( + SURFOBJ *pso, + LONG x, + LONG y, + RECTL *prcl +) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + DWORD returnedDataLength; + VIDEO_POINTER_POSITION NewPointerPosition; + + // We don't use the exclusion rectangle because we only support + // hardware Pointers. If we were doing our own Pointer simulations + // we would want to update prcl so that the engine would call us + // to exclude out pointer before drawing to the pixels in prcl. + + UNREFERENCED_PARAMETER(prcl); + + if (x == -1) + { + // + // A new position of (-1,-1) means hide the pointer. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) + { + // + // Not the end of the world, print warning in checked build. + // + + DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + } + else + { + NewPointerPosition.Column = (SHORT) x - (SHORT) (ppdev->ptlHotSpot.x); + NewPointerPosition.Row = (SHORT) y - (SHORT) (ppdev->ptlHotSpot.y); + + // + // Call miniport driver to move Pointer. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_POINTER_POSITION, + &NewPointerPosition, + sizeof(VIDEO_POINTER_POSITION), + NULL, + 0, + &returnedDataLength)) + { + // + // Not the end of the world, print warning in checked build. + // + + DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_SET_POINTER_POSITION\n")); + } + } +} + +/******************************Public*Routine******************************\ +* DrvSetPointerShape +* +* Sets the new pointer shape. +* +\**************************************************************************/ + +ULONG DrvSetPointerShape +( + SURFOBJ *pso, + SURFOBJ *psoMask, + SURFOBJ *psoColor, + XLATEOBJ *pxlo, + LONG xHot, + LONG yHot, + LONG x, + LONG y, + RECTL *prcl, + FLONG fl +) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + DWORD returnedDataLength; + + // We don't use the exclusion rectangle because we only support + // hardware Pointers. If we were doing our own Pointer simulations + // we would want to update prcl so that the engine would call us + // to exclude out pointer before drawing to the pixels in prcl. + UNREFERENCED_PARAMETER(prcl); + + if (ppdev->pPointerAttributes == (PVIDEO_POINTER_ATTRIBUTES) NULL) + { + // Mini-port has no hardware Pointer support. + return(SPS_ERROR); + } + + // See if we are being asked to hide the pointer + + if (psoMask == (SURFOBJ *) NULL) + { + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) + { + // + // It should never be possible to fail. + // Message supplied for debugging. + // + + DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + + return(TRUE); + } + + ppdev->ptlHotSpot.x = xHot; + ppdev->ptlHotSpot.y = yHot; + + if (!bSetHardwarePointerShape(pso,psoMask,psoColor,pxlo,x,y,fl)) + { + if (ppdev->fHwCursorActive) { + ppdev->fHwCursorActive = FALSE; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) { + + DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + } + + // + // Mini-port declines to realize this Pointer + // + + return(SPS_DECLINE); + } + else + { + ppdev->fHwCursorActive = TRUE; + } + + return(SPS_ACCEPT_NOEXCLUDE); +} + +/******************************Public*Routine******************************\ +* bSetHardwarePointerShape +* +* Changes the shape of the Hardware Pointer. +* +* Returns: True if successful, False if Pointer shape can't be hardware. +* +\**************************************************************************/ + +BOOL bSetHardwarePointerShape( +SURFOBJ *pso, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo, +LONG x, +LONG y, +FLONG fl) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; + DWORD returnedDataLength; + + if (psoColor != (SURFOBJ *) NULL) + { + if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER) && + bCopyColorPointer(ppdev, psoMask, psoColor, pxlo)) + { + pPointerAttributes->Flags |= VIDEO_MODE_COLOR_POINTER; + } else { + return(FALSE); + } + + } else { + + if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER) && + bCopyMonoPointer(ppdev, psoMask)) + { + pPointerAttributes->Flags |= VIDEO_MODE_MONO_POINTER; + } else { + return(FALSE); + } + } + + // + // Initialize Pointer attributes and position + // + + pPointerAttributes->Enable = 1; + + // + // if x,y = -1,-1 then pass them directly to the miniport so that + // the cursor will be disabled + + pPointerAttributes->Column = (SHORT)(x); + pPointerAttributes->Row = (SHORT)(y); + + if ((x != -1) || (y != -1)) { + pPointerAttributes->Column -= (SHORT)(ppdev->ptlHotSpot.x); + pPointerAttributes->Row -= (SHORT)(ppdev->ptlHotSpot.y); + } + + // + // set animate flags + // + + if (fl & SPS_ANIMATESTART) { + pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_START; + } else if (fl & SPS_ANIMATEUPDATE) { + pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_UPDATE; + } + + // + // Set the new Pointer shape. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_POINTER_ATTR, + pPointerAttributes, + ppdev->cjPointerAttributes, + NULL, + 0, + &returnedDataLength)) { + + DISPDBG((1, "DISP:Failed IOCTL_VIDEO_SET_POINTER_ATTR call\n")); + return(FALSE); + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bCopyMonoPointer +* +* Copies two monochrome masks into a buffer of the maximum size handled by the +* miniport, with any extra bits set to 0. The masks are converted to topdown +* form if they aren't already. Returns TRUE if we can handle this pointer in +* hardware, FALSE if not. +* +\**************************************************************************/ + +BOOL bCopyMonoPointer( + PPDEV ppdev, + SURFOBJ *pso) +{ + ULONG cy; + PBYTE pjSrcAnd, pjSrcXor; + LONG lDeltaSrc, lDeltaDst; + LONG lSrcWidthInBytes; + ULONG cxSrc = pso->sizlBitmap.cx; + ULONG cySrc = pso->sizlBitmap.cy; + ULONG cxSrcBytes; + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; + PBYTE pjDstAnd = pPointerAttributes->Pixels; + PBYTE pjDstXor = pPointerAttributes->Pixels; + + // Make sure the new pointer isn't too big to handle + // (*2 because both masks are in there) + if ((cxSrc > ppdev->PointerCapabilities.MaxWidth) || + (cySrc > (ppdev->PointerCapabilities.MaxHeight * 2))) + { + return(FALSE); + } + + pjDstXor += ((ppdev->PointerCapabilities.MaxWidth + 7) / 8) * + ppdev->pPointerAttributes->Height; + + // set the desk and mask to 0xff + RtlFillMemory(pjDstAnd, ppdev->pPointerAttributes->WidthInBytes * + ppdev->pPointerAttributes->Height, 0xFF); + + // Zero the dest XOR mask + RtlZeroMemory(pjDstXor, ppdev->pPointerAttributes->WidthInBytes * + ppdev->pPointerAttributes->Height); + + cxSrcBytes = (cxSrc + 7) / 8; + + if ((lDeltaSrc = pso->lDelta) < 0) + { + lSrcWidthInBytes = -lDeltaSrc; + } else { + lSrcWidthInBytes = lDeltaSrc; + } + + pjSrcAnd = (PBYTE) pso->pvBits; + + // If the incoming pointer bitmap is bottomup, we'll flip it to topdown to + // save the miniport some work + if (!(pso->fjBitmap & BMF_TOPDOWN)) + { + // Copy from the bottom + pjSrcAnd += lSrcWidthInBytes * (cySrc - 1); + } + + // Height of just AND mask + cySrc = cySrc / 2; + + // Point to XOR mask + pjSrcXor = pjSrcAnd + (cySrc * lDeltaSrc); + + // Offset from end of one dest scan to start of next + lDeltaDst = ppdev->pPointerAttributes->WidthInBytes; + + for (cy = 0; cy < cySrc; ++cy) + { + RtlCopyMemory(pjDstAnd, pjSrcAnd, cxSrcBytes); + RtlCopyMemory(pjDstXor, pjSrcXor, cxSrcBytes); + + // Point to next source and dest scans + pjSrcAnd += lDeltaSrc; + pjSrcXor += lDeltaSrc; + pjDstAnd += lDeltaDst; + pjDstXor += lDeltaDst; + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bCopyColorPointer +* +* Copies the mono and color masks into the buffer of maximum size +* handled by the miniport with any extra bits set to 0. Color translation +* is handled at this time. The masks are converted to topdown form if they +* aren't already. Returns TRUE if we can handle this pointer in hardware, +* FALSE if not. +* +\**************************************************************************/ +BOOL bCopyColorPointer( +PPDEV ppdev, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo) +{ + return(FALSE); +} + + +/******************************Public*Routine******************************\ +* bInitPointer +* +* Initialize the Pointer attributes. +* +\**************************************************************************/ + +BOOL bInitPointer(PPDEV ppdev, DEVINFO *pdevinfo) +{ + DWORD returnedDataLength; + + ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) NULL; + ppdev->cjPointerAttributes = 0; // initialized in screen.c + + // + // Ask the miniport whether it provides pointer support. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES, + &ppdev->ulMode, + sizeof(PVIDEO_MODE), + &ppdev->PointerCapabilities, + sizeof(ppdev->PointerCapabilities), + &returnedDataLength)) + { + return(FALSE); + } + + // + // If neither mono nor color hardware pointer is supported, there's no + // hardware pointer support and we're done. + // + + if ((!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER)) && + (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))) + { + return(TRUE); + } + + // + // Note: The buffer itself is allocated after we set the + // mode. At that time we know the pixel depth and we can + // allocate the correct size for the color pointer if supported. + // + + // + // Set the asynchronous support status (async means miniport is capable of + // drawing the Pointer at any time, with no interference with any ongoing + // drawing operation) + // + + if (ppdev->PointerCapabilities.Flags & VIDEO_MODE_ASYNC_POINTER) + { + pdevinfo->flGraphicsCaps |= GCAPS_ASYNCMOVE; + } + else + { + pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE; + } + + return(TRUE); +} diff --git a/reactos/drivers/video/displays/framebuf_new/screen.c b/reactos/drivers/video/displays/framebuf_new/screen.c new file mode 100755 index 00000000000..1973c580866 --- /dev/null +++ b/reactos/drivers/video/displays/framebuf_new/screen.c @@ -0,0 +1,601 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/screen.c + * PURPOSE: Surface, Screen and PDEV support/initialization + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ +#include "driver.h" + +#define SYSTM_LOGFONT {16,7,0,0,700,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"System"} +#define HELVE_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"MS Sans Serif"} +#define COURI_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,FIXED_PITCH | FF_DONTCARE, L"Courier"} + +// This is the basic devinfo for a default driver. This is used as a base and customized based +// on information passed back from the miniport driver. + +const DEVINFO gDevInfoFrameBuffer = { + ( GCAPS_OPAQUERECT + | GCAPS_MONO_DITHER + ), /* Graphics capabilities */ + SYSTM_LOGFONT, /* Default font description */ + HELVE_LOGFONT, /* ANSI variable font description */ + COURI_LOGFONT, /* ANSI fixed font description */ + 0, /* Count of device fonts */ + 0, /* Preferred DIB format */ + 8, /* Width of color dither */ + 8, /* Height of color dither */ + 0 /* Default palette to use for this device */ +}; + +/******************************Public*Routine******************************\ +* bInitSURF +* +* Enables the surface. Maps the frame buffer into memory. +* +\**************************************************************************/ + +BOOL bInitSURF(PPDEV ppdev, BOOL bFirst) +{ + DWORD returnedDataLength; + DWORD MaxWidth, MaxHeight; + VIDEO_MEMORY videoMemory; + VIDEO_MEMORY_INFORMATION videoMemoryInformation; +// eVb: 2.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + ULONG RemappingNeeded = 0; +// eVb: 2.1 [END] + // + // Set the current mode into the hardware. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_CURRENT_MODE, + &(ppdev->ulMode), + sizeof(ULONG), +// eVb: 2.2 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + &RemappingNeeded, + sizeof(ULONG), +// eVb: 2.2 [END] + &returnedDataLength)) + { + RIP("DISP bInitSURF failed IOCTL_SET_MODE\n"); + return(FALSE); + } + + // + // If this is the first time we enable the surface we need to map in the + // memory also. + // +// eVb: 2.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + if (bFirst || RemappingNeeded) + { +// eVb: 2.3 [END] + videoMemory.RequestedVirtualAddress = NULL; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_MAP_VIDEO_MEMORY, + &videoMemory, + sizeof(VIDEO_MEMORY), + &videoMemoryInformation, + sizeof(VIDEO_MEMORY_INFORMATION), + &returnedDataLength)) + { + RIP("DISP bInitSURF failed IOCTL_VIDEO_MAP\n"); + return(FALSE); + } + + ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase); + + if (videoMemoryInformation.FrameBufferBase != + videoMemoryInformation.VideoRamBase) + { + RIP("VideoRamBase does not correspond to FrameBufferBase\n"); + } +// eVb: 2.4 [DDK Change] - Make sure frame buffer mapping worked + // + // Make sure we can access this video memory + // + + *(PULONG)(ppdev->pjScreen) = 0xaa55aa55; + + if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) { + + DISPDBG((1, "Frame buffer memory is not accessible.\n")); + return(FALSE); + } +// eVb: 2.4 [END] + ppdev->cScreenSize = videoMemoryInformation.VideoRamLength; + + // + // Initialize the head of the offscreen list to NULL. + // + + ppdev->pOffscreenList = NULL; + + // It's a hardware pointer; set up pointer attributes. + + MaxHeight = ppdev->PointerCapabilities.MaxHeight; + + // Allocate space for two DIBs (data/mask) for the pointer. If this + // device supports a color Pointer, we will allocate a larger bitmap. + // If this is a color bitmap we allocate for the largest possible + // bitmap because we have no idea of what the pixel depth might be. + + // Width rounded up to nearest byte multiple + + if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER)) + { + MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8; + } + else + { + MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD); + } + + ppdev->cjPointerAttributes = + sizeof(VIDEO_POINTER_ATTRIBUTES) + + ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2); + + ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) + EngAllocMem(0, ppdev->cjPointerAttributes, ALLOC_TAG); + + if (ppdev->pPointerAttributes == NULL) { + + DISPDBG((0, "bInitPointer EngAllocMem failed\n")); + return(FALSE); + } + + ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags; + ppdev->pPointerAttributes->WidthInBytes = MaxWidth; + ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth; + ppdev->pPointerAttributes->Height = MaxHeight; + ppdev->pPointerAttributes->Column = 0; + ppdev->pPointerAttributes->Row = 0; + ppdev->pPointerAttributes->Enable = 0; + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* vDisableSURF +* +* Disable the surface. Un-Maps the frame in memory. +* +\**************************************************************************/ + +VOID vDisableSURF(PPDEV ppdev) +{ + DWORD returnedDataLength; + VIDEO_MEMORY videoMemory; + + videoMemory.RequestedVirtualAddress = (PVOID) ppdev->pjScreen; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_UNMAP_VIDEO_MEMORY, + &videoMemory, + sizeof(VIDEO_MEMORY), + NULL, + 0, + &returnedDataLength)) + { + RIP("DISP vDisableSURF failed IOCTL_VIDEO_UNMAP\n"); + } +} + + +/******************************Public*Routine******************************\ +* bInitPDEV +* +* Determine the mode we should be in based on the DEVMODE passed in. +* Query mini-port to get information needed to fill in the DevInfo and the +* GdiInfo . +* +\**************************************************************************/ + +BOOL bInitPDEV( +PPDEV ppdev, +DEVMODEW *pDevMode, +GDIINFO *pGdiInfo, +DEVINFO *pDevInfo) +{ + ULONG cModes; + PVIDEO_MODE_INFORMATION pVideoBuffer, pVideoModeSelected, pVideoTemp; + VIDEO_COLOR_CAPABILITIES colorCapabilities; + ULONG ulTemp; + BOOL bSelectDefault; + ULONG cbModeSize; + + // + // calls the miniport to get mode information. + // + + cModes = getAvailableModes(ppdev->hDriver, &pVideoBuffer, &cbModeSize); + + if (cModes == 0) + { + return(FALSE); + } + + // + // Now see if the requested mode has a match in that table. + // + + pVideoModeSelected = NULL; + pVideoTemp = pVideoBuffer; + + if ((pDevMode->dmPelsWidth == 0) && + (pDevMode->dmPelsHeight == 0) && + (pDevMode->dmBitsPerPel == 0) && + (pDevMode->dmDisplayFrequency == 0)) + { + DISPDBG((2, "Default mode requested")); + bSelectDefault = TRUE; + } + else + { +// eVb: 2.5 [DDK Change] - Add missing newlines to debug output + DISPDBG((2, "Requested mode...\n")); + DISPDBG((2, " Screen width -- %li\n", pDevMode->dmPelsWidth)); + DISPDBG((2, " Screen height -- %li\n", pDevMode->dmPelsHeight)); + DISPDBG((2, " Bits per pel -- %li\n", pDevMode->dmBitsPerPel)); + DISPDBG((2, " Frequency -- %li\n", pDevMode->dmDisplayFrequency)); +// eVb: 2.5 [END] + bSelectDefault = FALSE; + } + + while (cModes--) + { + if (pVideoTemp->Length != 0) + { + if (bSelectDefault || + ((pVideoTemp->VisScreenWidth == pDevMode->dmPelsWidth) && + (pVideoTemp->VisScreenHeight == pDevMode->dmPelsHeight) && + (pVideoTemp->BitsPerPlane * + pVideoTemp->NumberOfPlanes == pDevMode->dmBitsPerPel) && + (pVideoTemp->Frequency == pDevMode->dmDisplayFrequency))) + { + pVideoModeSelected = pVideoTemp; + DISPDBG((3, "Found a match\n")) ; + break; + } + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + cbModeSize); + } + + // + // If no mode has been found, return an error + // + + if (pVideoModeSelected == NULL) + { + EngFreeMem(pVideoBuffer); + DISPDBG((0,"DISP bInitPDEV failed - no valid modes\n")); + return(FALSE); + } + + // + // Fill in the GDIINFO data structure with the information returned from + // the kernel driver. + // + + ppdev->ulMode = pVideoModeSelected->ModeIndex; + ppdev->cxScreen = pVideoModeSelected->VisScreenWidth; + ppdev->cyScreen = pVideoModeSelected->VisScreenHeight; + ppdev->ulBitCount = pVideoModeSelected->BitsPerPlane * + pVideoModeSelected->NumberOfPlanes; + ppdev->lDeltaScreen = pVideoModeSelected->ScreenStride; + + ppdev->flRed = pVideoModeSelected->RedMask; + ppdev->flGreen = pVideoModeSelected->GreenMask; + ppdev->flBlue = pVideoModeSelected->BlueMask; + + + pGdiInfo->ulVersion = GDI_DRIVER_VERSION; + pGdiInfo->ulTechnology = DT_RASDISPLAY; + pGdiInfo->ulHorzSize = pVideoModeSelected->XMillimeter; + pGdiInfo->ulVertSize = pVideoModeSelected->YMillimeter; + + pGdiInfo->ulHorzRes = ppdev->cxScreen; + pGdiInfo->ulVertRes = ppdev->cyScreen; + pGdiInfo->ulPanningHorzRes = ppdev->cxScreen; + pGdiInfo->ulPanningVertRes = ppdev->cyScreen; + pGdiInfo->cBitsPixel = pVideoModeSelected->BitsPerPlane; + pGdiInfo->cPlanes = pVideoModeSelected->NumberOfPlanes; + pGdiInfo->ulVRefresh = pVideoModeSelected->Frequency; + pGdiInfo->ulBltAlignment = 1; // We don't have accelerated screen- + // to-screen blts, and any + // window alignment is okay + + pGdiInfo->ulLogPixelsX = pDevMode->dmLogPixels; + pGdiInfo->ulLogPixelsY = pDevMode->dmLogPixels; + +#ifdef MIPS + if (ppdev->ulBitCount == 8) + pGdiInfo->flTextCaps = (TC_RA_ABLE | TC_SCROLLBLT); + else +#endif + pGdiInfo->flTextCaps = TC_RA_ABLE; + + pGdiInfo->flRaster = 0; // flRaster is reserved by DDI + + pGdiInfo->ulDACRed = pVideoModeSelected->NumberRedBits; + pGdiInfo->ulDACGreen = pVideoModeSelected->NumberGreenBits; + pGdiInfo->ulDACBlue = pVideoModeSelected->NumberBlueBits; + + pGdiInfo->ulAspectX = 0x24; // One-to-one aspect ratio + pGdiInfo->ulAspectY = 0x24; + pGdiInfo->ulAspectXY = 0x33; + + pGdiInfo->xStyleStep = 1; // A style unit is 3 pels + pGdiInfo->yStyleStep = 1; + pGdiInfo->denStyleStep = 3; + + pGdiInfo->ptlPhysOffset.x = 0; + pGdiInfo->ptlPhysOffset.y = 0; + pGdiInfo->szlPhysSize.cx = 0; + pGdiInfo->szlPhysSize.cy = 0; + + // RGB and CMY color info. + + // + // try to get it from the miniport. + // if the miniport doesn ot support this feature, use defaults. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES, + NULL, + 0, + &colorCapabilities, + sizeof(VIDEO_COLOR_CAPABILITIES), + &ulTemp)) + { + + DISPDBG((2, "getcolorCapabilities failed \n")); + + pGdiInfo->ciDevice.Red.x = 6700; + pGdiInfo->ciDevice.Red.y = 3300; + pGdiInfo->ciDevice.Red.Y = 0; + pGdiInfo->ciDevice.Green.x = 2100; + pGdiInfo->ciDevice.Green.y = 7100; + pGdiInfo->ciDevice.Green.Y = 0; + pGdiInfo->ciDevice.Blue.x = 1400; + pGdiInfo->ciDevice.Blue.y = 800; + pGdiInfo->ciDevice.Blue.Y = 0; + pGdiInfo->ciDevice.AlignmentWhite.x = 3127; + pGdiInfo->ciDevice.AlignmentWhite.y = 3290; + pGdiInfo->ciDevice.AlignmentWhite.Y = 0; + + pGdiInfo->ciDevice.RedGamma = 20000; + pGdiInfo->ciDevice.GreenGamma = 20000; + pGdiInfo->ciDevice.BlueGamma = 20000; + + } + else + { + pGdiInfo->ciDevice.Red.x = colorCapabilities.RedChromaticity_x; + pGdiInfo->ciDevice.Red.y = colorCapabilities.RedChromaticity_y; + pGdiInfo->ciDevice.Red.Y = 0; + pGdiInfo->ciDevice.Green.x = colorCapabilities.GreenChromaticity_x; + pGdiInfo->ciDevice.Green.y = colorCapabilities.GreenChromaticity_y; + pGdiInfo->ciDevice.Green.Y = 0; + pGdiInfo->ciDevice.Blue.x = colorCapabilities.BlueChromaticity_x; + pGdiInfo->ciDevice.Blue.y = colorCapabilities.BlueChromaticity_y; + pGdiInfo->ciDevice.Blue.Y = 0; + pGdiInfo->ciDevice.AlignmentWhite.x = colorCapabilities.WhiteChromaticity_x; + pGdiInfo->ciDevice.AlignmentWhite.y = colorCapabilities.WhiteChromaticity_y; + pGdiInfo->ciDevice.AlignmentWhite.Y = colorCapabilities.WhiteChromaticity_Y; + + // if we have a color device store the three color gamma values, + // otherwise store the unique gamma value in all three. + + if (colorCapabilities.AttributeFlags & VIDEO_DEVICE_COLOR) + { + pGdiInfo->ciDevice.RedGamma = colorCapabilities.RedGamma; + pGdiInfo->ciDevice.GreenGamma = colorCapabilities.GreenGamma; + pGdiInfo->ciDevice.BlueGamma = colorCapabilities.BlueGamma; + } + else + { + pGdiInfo->ciDevice.RedGamma = colorCapabilities.WhiteGamma; + pGdiInfo->ciDevice.GreenGamma = colorCapabilities.WhiteGamma; + pGdiInfo->ciDevice.BlueGamma = colorCapabilities.WhiteGamma; + } + + }; + + pGdiInfo->ciDevice.Cyan.x = 0; + pGdiInfo->ciDevice.Cyan.y = 0; + pGdiInfo->ciDevice.Cyan.Y = 0; + pGdiInfo->ciDevice.Magenta.x = 0; + pGdiInfo->ciDevice.Magenta.y = 0; + pGdiInfo->ciDevice.Magenta.Y = 0; + pGdiInfo->ciDevice.Yellow.x = 0; + pGdiInfo->ciDevice.Yellow.y = 0; + pGdiInfo->ciDevice.Yellow.Y = 0; + + // No dye correction for raster displays. + + pGdiInfo->ciDevice.MagentaInCyanDye = 0; + pGdiInfo->ciDevice.YellowInCyanDye = 0; + pGdiInfo->ciDevice.CyanInMagentaDye = 0; + pGdiInfo->ciDevice.YellowInMagentaDye = 0; + pGdiInfo->ciDevice.CyanInYellowDye = 0; + pGdiInfo->ciDevice.MagentaInYellowDye = 0; + + pGdiInfo->ulDevicePelsDPI = 0; // For printers only + pGdiInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA; + + // BUGBUG this should be modified to take into account the size + // of the display and the resolution. + + pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M; + + pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS; + + // Fill in the basic devinfo structure + + *pDevInfo = gDevInfoFrameBuffer; + + // Fill in the rest of the devinfo and GdiInfo structures. + + if (ppdev->ulBitCount == 8) + { + // It is Palette Managed. + + pGdiInfo->ulNumColors = 20; + pGdiInfo->ulNumPalReg = 1 << ppdev->ulBitCount; + + pDevInfo->flGraphicsCaps |= (GCAPS_PALMANAGED | GCAPS_COLOR_DITHER); + + pGdiInfo->ulHTOutputFormat = HT_FORMAT_8BPP; + pDevInfo->iDitherFormat = BMF_8BPP; + + // Assuming palette is orthogonal - all colors are same size. + + ppdev->cPaletteShift = 8 - pGdiInfo->ulDACRed; + } + else + { + pGdiInfo->ulNumColors = (ULONG) (-1); + pGdiInfo->ulNumPalReg = 0; + + if (ppdev->ulBitCount == 16) + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_16BPP; + pDevInfo->iDitherFormat = BMF_16BPP; + } + else if (ppdev->ulBitCount == 24) + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_24BPP; + pDevInfo->iDitherFormat = BMF_24BPP; + } + else + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_32BPP; + pDevInfo->iDitherFormat = BMF_32BPP; + } + } + + EngFreeMem(pVideoBuffer); + + return(TRUE); +} + + +/******************************Public*Routine******************************\ +* getAvailableModes +* +* Calls the miniport to get the list of modes supported by the kernel driver, +* and returns the list of modes supported by the diplay driver among those +* +* returns the number of entries in the videomode buffer. +* 0 means no modes are supported by the miniport or that an error occured. +* +* NOTE: the buffer must be freed up by the caller. +* +\**************************************************************************/ + +DWORD getAvailableModes( +HANDLE hDriver, +PVIDEO_MODE_INFORMATION *modeInformation, +DWORD *cbModeSize) +{ + ULONG ulTemp; + VIDEO_NUM_MODES modes; + PVIDEO_MODE_INFORMATION pVideoTemp; + + // + // Get the number of modes supported by the mini-port + // + + if (EngDeviceIoControl(hDriver, + IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES, + NULL, + 0, + &modes, + sizeof(VIDEO_NUM_MODES), + &ulTemp)) + { + DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_NUM_AVAIL_MODES\n")); + return(0); + } + + *cbModeSize = modes.ModeInformationLength; + + // + // Allocate the buffer for the mini-port to write the modes in. + // + + *modeInformation = (PVIDEO_MODE_INFORMATION) + EngAllocMem(0, modes.NumModes * + modes.ModeInformationLength, ALLOC_TAG); + + if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL) + { + DISPDBG((0, "getAvailableModes failed EngAllocMem\n")); + + return 0; + } + + // + // Ask the mini-port to fill in the available modes. + // + + if (EngDeviceIoControl(hDriver, + IOCTL_VIDEO_QUERY_AVAIL_MODES, + NULL, + 0, + *modeInformation, + modes.NumModes * modes.ModeInformationLength, + &ulTemp)) + { + + DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_AVAIL_MODES\n")); + + EngFreeMem(*modeInformation); + *modeInformation = (PVIDEO_MODE_INFORMATION) NULL; + + return(0); + } + + // + // Now see which of these modes are supported by the display driver. + // As an internal mechanism, set the length to 0 for the modes we + // DO NOT support. + // + + ulTemp = modes.NumModes; + pVideoTemp = *modeInformation; + + // + // Mode is rejected if it is not one plane, or not graphics, or is not + // one of 8, 16 or 32 bits per pel. + // + + while (ulTemp--) + { + if ((pVideoTemp->NumberOfPlanes != 1 ) || + !(pVideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) || +// eVb: 2.6 [DDK CHANGE] - Do not process banked video modes + (pVideoTemp->AttributeFlags & VIDEO_MODE_BANKED) || +// eVb: 2.6 [END] + ((pVideoTemp->BitsPerPlane != 8) && + (pVideoTemp->BitsPerPlane != 16) && + (pVideoTemp->BitsPerPlane != 24) && + (pVideoTemp->BitsPerPlane != 32))) + { + pVideoTemp->Length = 0; + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + modes.ModeInformationLength); + } + + return modes.NumModes; + +} From a5b69953911c34455d1637748c2fbb00605a1494 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:30:07 +0000 Subject: [PATCH 106/211] [FUSION] sync fusion to wine 1.1.39 svn path=/trunk/; revision=45878 --- reactos/dll/win32/fusion/asmname.c | 5 +++++ reactos/dll/win32/fusion/fusion_main.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/reactos/dll/win32/fusion/asmname.c b/reactos/dll/win32/fusion/asmname.c index 913674aa80e..3c014ea3244 100644 --- a/reactos/dll/win32/fusion/asmname.c +++ b/reactos/dll/win32/fusion/asmname.c @@ -471,6 +471,11 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam done: HeapFree(GetProcessHeap(), 0, save); + if (FAILED(hr)) + { + HeapFree(GetProcessHeap(), 0, name->displayname); + HeapFree(GetProcessHeap(), 0, name->name); + } return hr; } diff --git a/reactos/dll/win32/fusion/fusion_main.c b/reactos/dll/win32/fusion/fusion_main.c index 8bc4b1e3349..5c9d77646e0 100644 --- a/reactos/dll/win32/fusion/fusion_main.c +++ b/reactos/dll/win32/fusion/fusion_main.c @@ -34,6 +34,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) switch (fdwReason) { + case DLL_WINE_PREATTACH: + return FALSE; /* prefer native version */ case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls(hinstDLL); break; From ddc822b8bb969f3aba7ffc4b6b6bf00c147eeba5 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:32:19 +0000 Subject: [PATCH 107/211] [INETCOMM] sync inetcomm to wine 1.1.39 svn path=/trunk/; revision=45879 --- reactos/dll/win32/inetcomm/inetcomm_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/reactos/dll/win32/inetcomm/inetcomm_main.c b/reactos/dll/win32/inetcomm/inetcomm_main.c index 22f19197488..dac1a5c069d 100644 --- a/reactos/dll/win32/inetcomm/inetcomm_main.c +++ b/reactos/dll/win32/inetcomm/inetcomm_main.c @@ -197,6 +197,5 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) */ HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("\n"); return S_FALSE; } From 1a12523fbea5b9a65e7caabf76b29265406395c4 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:34:19 +0000 Subject: [PATCH 108/211] [INETMIB1] sync inetmib1 to wine 1.1.39 svn path=/trunk/; revision=45880 --- reactos/dll/win32/inetmib1/main.c | 73 +++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/reactos/dll/win32/inetmib1/main.c b/reactos/dll/win32/inetmib1/main.c index b0ff812dd7c..9aef4d5c5dc 100644 --- a/reactos/dll/win32/inetmib1/main.c +++ b/reactos/dll/win32/inetmib1/main.c @@ -32,10 +32,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(inetmib1); /** * Utility functions */ -static void copyInt(AsnAny *value, void *src) +static DWORD copyInt(AsnAny *value, void *src) { value->asnType = ASN_INTEGER; value->asnValue.number = *(DWORD *)src; + return SNMP_ERRORSTATUS_NOERROR; } static void setStringValue(AsnAny *value, BYTE type, DWORD len, BYTE *str) @@ -45,18 +46,11 @@ static void setStringValue(AsnAny *value, BYTE type, DWORD len, BYTE *str) strValue.asnType = type; strValue.asnValue.string.stream = str; strValue.asnValue.string.length = len; - strValue.asnValue.string.dynamic = TRUE; + strValue.asnValue.string.dynamic = FALSE; SnmpUtilAsnAnyCpy(value, &strValue); } -static void copyLengthPrecededString(AsnAny *value, void *src) -{ - DWORD len = *(DWORD *)src; - - setStringValue(value, ASN_OCTETSTRING, len, (BYTE *)src + sizeof(DWORD)); -} - -typedef void (*copyValueFunc)(AsnAny *value, void *src); +typedef DWORD (*copyValueFunc)(AsnAny *value, void *src); struct structToAsnValue { @@ -75,13 +69,13 @@ static AsnInteger32 mapStructEntryToValue(struct structToAsnValue *map, return SNMP_ERRORSTATUS_NOSUCHNAME; if (!map[id].copy) return SNMP_ERRORSTATUS_NOSUCHNAME; - map[id].copy(&pVarBind->value, (BYTE *)record + map[id].offset); - return SNMP_ERRORSTATUS_NOERROR; + return map[id].copy(&pVarBind->value, (BYTE *)record + map[id].offset); } -static void copyIpAddr(AsnAny *value, void *src) +static DWORD copyIpAddr(AsnAny *value, void *src) { setStringValue(value, ASN_IPADDRESS, sizeof(DWORD), src); + return SNMP_ERRORSTATUS_NOERROR; } static UINT mib2[] = { 1,3,6,1,2,1 }; @@ -168,7 +162,7 @@ static BOOL mib2IfNumberQuery(BYTE bPduType, SnmpVarBind *pVarBind, return ret; } -static void copyOperStatus(AsnAny *value, void *src) +static DWORD copyOperStatus(AsnAny *value, void *src) { value->asnType = ASN_INTEGER; /* The IPHlpApi definition of operational status differs from the MIB2 one, @@ -186,6 +180,7 @@ static void copyOperStatus(AsnAny *value, void *src) default: value->asnValue.number = MIB_IF_ADMIN_STATUS_DOWN; }; + return SNMP_ERRORSTATUS_NOERROR; } /* Given an OID and a base OID that it must begin with, finds the item and @@ -393,7 +388,7 @@ static UINT findNextOidInTable(AsnObjectIdentifier *oid, * an infinite loop. */ for (++index; index <= table->numEntries && compare(key, - &table->entries[tableEntrySize * index]) == 0; ++index) + &table->entries[tableEntrySize * (index - 1)]) == 0; ++index) ; } HeapFree(GetProcessHeap(), 0, key); @@ -550,13 +545,46 @@ static INT setOidWithItemAndInteger(AsnObjectIdentifier *dst, return ret; } +static DWORD copyIfRowDescr(AsnAny *value, void *src) +{ + PMIB_IFROW row = (PMIB_IFROW)((BYTE *)src - + FIELD_OFFSET(MIB_IFROW, dwDescrLen)); + DWORD ret; + + if (row->dwDescrLen) + { + setStringValue(value, ASN_OCTETSTRING, row->dwDescrLen, row->bDescr); + ret = SNMP_ERRORSTATUS_NOERROR; + } + else + ret = SNMP_ERRORSTATUS_NOSUCHNAME; + return ret; +} + +static DWORD copyIfRowPhysAddr(AsnAny *value, void *src) +{ + PMIB_IFROW row = (PMIB_IFROW)((BYTE *)src - + FIELD_OFFSET(MIB_IFROW, dwPhysAddrLen)); + DWORD ret; + + if (row->dwPhysAddrLen) + { + setStringValue(value, ASN_OCTETSTRING, row->dwPhysAddrLen, + row->bPhysAddr); + ret = SNMP_ERRORSTATUS_NOERROR; + } + else + ret = SNMP_ERRORSTATUS_NOSUCHNAME; + return ret; +} + static struct structToAsnValue mib2IfEntryMap[] = { { FIELD_OFFSET(MIB_IFROW, dwIndex), copyInt }, - { FIELD_OFFSET(MIB_IFROW, dwDescrLen), copyLengthPrecededString }, + { FIELD_OFFSET(MIB_IFROW, dwDescrLen), copyIfRowDescr }, { FIELD_OFFSET(MIB_IFROW, dwType), copyInt }, { FIELD_OFFSET(MIB_IFROW, dwMtu), copyInt }, { FIELD_OFFSET(MIB_IFROW, dwSpeed), copyInt }, - { FIELD_OFFSET(MIB_IFROW, dwPhysAddrLen), copyLengthPrecededString }, + { FIELD_OFFSET(MIB_IFROW, dwPhysAddrLen), copyIfRowPhysAddr }, { FIELD_OFFSET(MIB_IFROW, dwAdminStatus), copyInt }, { FIELD_OFFSET(MIB_IFROW, dwOperStatus), copyOperStatus }, { FIELD_OFFSET(MIB_IFROW, dwLastChange), copyInt }, @@ -883,9 +911,18 @@ static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind, static UINT mib2IpNet[] = { 1,3,6,1,2,1,4,22,1 }; static PMIB_IPNETTABLE ipNetTable; +static DWORD copyIpNetPhysAddr(AsnAny *value, void *src) +{ + PMIB_IPNETROW row = (PMIB_IPNETROW)((BYTE *)src - FIELD_OFFSET(MIB_IPNETROW, + dwPhysAddrLen)); + + setStringValue(value, ASN_OCTETSTRING, row->dwPhysAddrLen, row->bPhysAddr); + return SNMP_ERRORSTATUS_NOERROR; +} + static struct structToAsnValue mib2IpNetMap[] = { { FIELD_OFFSET(MIB_IPNETROW, dwIndex), copyInt }, - { FIELD_OFFSET(MIB_IPNETROW, dwPhysAddrLen), copyLengthPrecededString }, + { FIELD_OFFSET(MIB_IPNETROW, dwPhysAddrLen), copyIpNetPhysAddr }, { FIELD_OFFSET(MIB_IPNETROW, dwAddr), copyIpAddr }, { FIELD_OFFSET(MIB_IPNETROW, dwType), copyInt }, }; From 7249fc91c006e1544f2471dbacda8b7fce24cb8c Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:40:20 +0000 Subject: [PATCH 109/211] [MAPI32] sync mapi32 to wine 1.1.39 svn path=/trunk/; revision=45881 --- reactos/dll/win32/mapi32/De.rc | 30 +++++ reactos/dll/win32/mapi32/En.rc | 30 +++++ reactos/dll/win32/mapi32/Es.rc | 33 ++++++ reactos/dll/win32/mapi32/Fr.rc | 33 ++++++ reactos/dll/win32/mapi32/Lt.rc | 33 ++++++ reactos/dll/win32/mapi32/Ru.rc | 33 ++++++ reactos/dll/win32/mapi32/mapi32.rbuild | 1 + reactos/dll/win32/mapi32/mapi32.spec | 20 ++-- reactos/dll/win32/mapi32/mapi32_main.c | 2 + reactos/dll/win32/mapi32/prop.c | 2 +- reactos/dll/win32/mapi32/res.h | 26 +++++ reactos/dll/win32/mapi32/sendmail.c | 150 ++----------------------- reactos/dll/win32/mapi32/util.c | 2 +- reactos/dll/win32/mapi32/util.h | 1 + reactos/dll/win32/mapi32/version.rc | 7 ++ reactos/include/psdk/mapi.h | 2 +- 16 files changed, 250 insertions(+), 155 deletions(-) create mode 100644 reactos/dll/win32/mapi32/De.rc create mode 100644 reactos/dll/win32/mapi32/En.rc create mode 100644 reactos/dll/win32/mapi32/Es.rc create mode 100644 reactos/dll/win32/mapi32/Fr.rc create mode 100644 reactos/dll/win32/mapi32/Lt.rc create mode 100644 reactos/dll/win32/mapi32/Ru.rc create mode 100644 reactos/dll/win32/mapi32/res.h diff --git a/reactos/dll/win32/mapi32/De.rc b/reactos/dll/win32/mapi32/De.rc new file mode 100644 index 00000000000..2c811d15a0c --- /dev/null +++ b/reactos/dll/win32/mapi32/De.rc @@ -0,0 +1,30 @@ +/* +* MAPI32 German resources +* +* Copyright 2009 André Hentschel +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "Das senden der E-Mails scheiterte, da Sie keinen MAPI E-Mail Programm installiert haben." + IDS_SEND_MAIL, "E-Mail senden" +} diff --git a/reactos/dll/win32/mapi32/En.rc b/reactos/dll/win32/mapi32/En.rc new file mode 100644 index 00000000000..9a6bf77998f --- /dev/null +++ b/reactos/dll/win32/mapi32/En.rc @@ -0,0 +1,30 @@ +/* +* MAPI32 English resources +* +* Copyright 2009 Owen Rudge for CodeWeavers +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "Mail sending failed as you do not have a MAPI mail client installed." + IDS_SEND_MAIL, "Send Mail" +} diff --git a/reactos/dll/win32/mapi32/Es.rc b/reactos/dll/win32/mapi32/Es.rc new file mode 100644 index 00000000000..534f4d4dbc9 --- /dev/null +++ b/reactos/dll/win32/mapi32/Es.rc @@ -0,0 +1,33 @@ +/* +* MAPI32 Spanish resources +* +* Copyright 2010 José Manuel Ferrer Ortiz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "El envío de correo ha fallado debido a que no tiene instalado un cliente de correo MAPI." + IDS_SEND_MAIL, "Enviar correo" +} diff --git a/reactos/dll/win32/mapi32/Fr.rc b/reactos/dll/win32/mapi32/Fr.rc new file mode 100644 index 00000000000..ab14e4ad377 --- /dev/null +++ b/reactos/dll/win32/mapi32/Fr.rc @@ -0,0 +1,33 @@ +/* +* MAPI32 French resources +* +* Copyright 2009 Frédéric Delanoy +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "L'envoi de courriel a échoué car aucun client mail MAPI n'est installé." + IDS_SEND_MAIL, "Envoyer un courriel" +} diff --git a/reactos/dll/win32/mapi32/Lt.rc b/reactos/dll/win32/mapi32/Lt.rc new file mode 100644 index 00000000000..b66bf3da010 --- /dev/null +++ b/reactos/dll/win32/mapi32/Lt.rc @@ -0,0 +1,33 @@ +/* +* MAPI32 Lithuanian resources +* + * Copyright 2009 Aurimas FiÅ¡eras +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "Nepavyko iÅ¡siųsti laiÅ¡kų, nes neturite įdiegto MAPI paÅ¡to kliento." + IDS_SEND_MAIL, "LaiÅ¡kų siuntimas" +} diff --git a/reactos/dll/win32/mapi32/Ru.rc b/reactos/dll/win32/mapi32/Ru.rc new file mode 100644 index 00000000000..66626da23a2 --- /dev/null +++ b/reactos/dll/win32/mapi32/Ru.rc @@ -0,0 +1,33 @@ +/* +* MAPI32 Russian resources +* +* Copyright 2009 Vladimir Pankratov +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "Ðевозможно отправить почту: не уÑтановлен почтовый клиент MAPI." + IDS_SEND_MAIL, "Отправка почты" +} diff --git a/reactos/dll/win32/mapi32/mapi32.rbuild b/reactos/dll/win32/mapi32/mapi32.rbuild index 93a8d539875..4832457070b 100644 --- a/reactos/dll/win32/mapi32/mapi32.rbuild +++ b/reactos/dll/win32/mapi32/mapi32.rbuild @@ -15,6 +15,7 @@ wine shlwapi shell32 + user32 advapi32 uuid ntdll diff --git a/reactos/dll/win32/mapi32/mapi32.spec b/reactos/dll/win32/mapi32/mapi32.spec index 04be363d2bc..8037c9b54d8 100644 --- a/reactos/dll/win32/mapi32/mapi32.spec +++ b/reactos/dll/win32/mapi32/mapi32.spec @@ -145,17 +145,17 @@ 205 stub FDecodeID@12 206 stub CchOfEncoding@4 207 stdcall CbOfEncoded@4(ptr) CbOfEncoded -208 stdcall MAPISendDocuments(ptr ptr ptr ptr long) -209 stdcall MAPILogon(long ptr ptr long long ptr) -210 stdcall MAPILogoff(long long long long) -211 stdcall MAPISendMail(long long ptr long long) -212 stdcall MAPISaveMail(ptr ptr ptr long long ptr) -213 stdcall MAPIReadMail(ptr ptr ptr long long ptr) -214 stdcall MAPIFindNext(ptr ptr ptr ptr long long ptr) -215 stdcall MAPIDeleteMail(ptr ptr ptr long long) -217 stdcall MAPIAddress(ptr ptr ptr long ptr long long ptr long ptr ptr) +208 stdcall MAPISendDocuments(ptr str str str long) +209 stdcall MAPILogon(ptr str str long long ptr) +210 stdcall MAPILogoff(ptr ptr long long) +211 stdcall MAPISendMail(ptr ptr ptr long long) +212 stdcall MAPISaveMail(ptr ptr ptr long long str) +213 stdcall MAPIReadMail(ptr ptr str long long ptr) +214 stdcall MAPIFindNext(ptr ptr str str long long ptr) +215 stdcall MAPIDeleteMail(ptr ptr str long long) +217 stdcall MAPIAddress(ptr ptr str long str long ptr long long ptr ptr) 218 stdcall MAPIDetails(ptr ptr ptr long long) -219 stdcall MAPIResolveName(ptr ptr ptr long long ptr) +219 stdcall MAPIResolveName(ptr ptr str long long ptr) 220 stub BMAPISendMail 221 stub BMAPISaveMail 222 stub BMAPIReadMail diff --git a/reactos/dll/win32/mapi32/mapi32_main.c b/reactos/dll/win32/mapi32/mapi32_main.c index 906c22e2c9f..6c35563a448 100644 --- a/reactos/dll/win32/mapi32/mapi32_main.c +++ b/reactos/dll/win32/mapi32/mapi32_main.c @@ -34,6 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mapi); LONG MAPI_ObjectCount = 0; +HINSTANCE hInstMAPI32; /*********************************************************************** * DllMain (MAPI32.init) @@ -45,6 +46,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) switch (fdwReason) { case DLL_PROCESS_ATTACH: + hInstMAPI32 = hinstDLL; DisableThreadLibraryCalls(hinstDLL); load_mapi_providers(); break; diff --git a/reactos/dll/win32/mapi32/prop.c b/reactos/dll/win32/mapi32/prop.c index 1a157da352f..5a7e8db0565 100644 --- a/reactos/dll/win32/mapi32/prop.c +++ b/reactos/dll/win32/mapi32/prop.c @@ -1835,7 +1835,7 @@ IMAPIProp_fnSetProps(LPMAPIPROP iface, ULONG ulValues, else { /* Add new value */ - if (!(item = IMAPIPROP_AddValue(This, &lpProps[i]))) + if (!IMAPIPROP_AddValue(This, &lpProps[i])) hRet = MAPI_E_NOT_ENOUGH_MEMORY; } } diff --git a/reactos/dll/win32/mapi32/res.h b/reactos/dll/win32/mapi32/res.h new file mode 100644 index 00000000000..658f8f609b0 --- /dev/null +++ b/reactos/dll/win32/mapi32/res.h @@ -0,0 +1,26 @@ +/* +* MAPI32 resources +* +* Copyright 2009 Owen Rudge for CodeWeavers +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include + +/* Strings */ +#define IDS_NO_MAPI_CLIENT 1 +#define IDS_SEND_MAIL 2 diff --git a/reactos/dll/win32/mapi32/sendmail.c b/reactos/dll/win32/mapi32/sendmail.c index cbbff9847e9..e1156498cd1 100644 --- a/reactos/dll/win32/mapi32/sendmail.c +++ b/reactos/dll/win32/mapi32/sendmail.c @@ -30,6 +30,7 @@ #include "windef.h" #include "winbase.h" #include "winerror.h" +#include "winuser.h" #include "objbase.h" #include "objidl.h" #include "mapi.h" @@ -41,6 +42,7 @@ #include "shlwapi.h" #include "wine/debug.h" #include "util.h" +#include "res.h" WINE_DEFAULT_DEBUG_CHANNEL(mapi); @@ -383,27 +385,11 @@ cleanup: ; * Success: SUCCESS_SUCCESS * Failure: MAPI_E_FAILURE * - * NOTES - * The fallback procedure is a temporary hack. */ ULONG WINAPI MAPISendMail( LHANDLE session, ULONG_PTR uiparam, lpMapiMessage message, FLAGS flags, ULONG reserved ) { - ULONG ret = MAPI_E_FAILURE; - unsigned int i, to_count = 0, cc_count = 0, bcc_count = 0; - unsigned int to_size = 0, cc_size = 0, bcc_size = 0, subj_size, body_size; - - char *to = NULL, *cc = NULL, *bcc = NULL; - const char *address, *subject, *body; - static const char format[] = - "mailto:\"%s\"?subject=\"%s\"&cc=\"%s\"&bcc=\"%s\"&body=\"%s\""; - char *mailto = NULL, *escape = NULL; - char empty_string[] = ""; - HRESULT res; - DWORD size; - - TRACE( "(0x%08x 0x%08lx %p 0x%08x 0x%08x)\n", session, uiparam, - message, flags, reserved ); + WCHAR msg_title[READ_BUF_SIZE], error_msg[READ_BUF_SIZE]; /* Check to see if we have a Simple MAPI provider loaded */ if (mapiFunctions.MAPISendMail) @@ -413,133 +399,13 @@ ULONG WINAPI MAPISendMail( LHANDLE session, ULONG_PTR uiparam, if (MAPIInitialize(NULL) == S_OK) return sendmail_extended_mapi(session, uiparam, message, flags, reserved); - /* Fall back on our own implementation */ - if (!message) return MAPI_E_FAILURE; + /* Display an error message since we apparently have no mail clients */ + LoadStringW(hInstMAPI32, IDS_NO_MAPI_CLIENT, error_msg, sizeof(error_msg) / sizeof(WCHAR)); + LoadStringW(hInstMAPI32, IDS_SEND_MAIL, msg_title, sizeof(msg_title) / sizeof(WCHAR)); - for (i = 0; i < message->nRecipCount; i++) - { - if (!message->lpRecips) - { - WARN("No recipients found\n"); - return MAPI_E_FAILURE; - } + MessageBoxW((HWND) uiparam, error_msg, msg_title, MB_ICONEXCLAMATION); - address = message->lpRecips[i].lpszAddress; - if (address) - { - switch (message->lpRecips[i].ulRecipClass) - { - case MAPI_ORIG: - TRACE( "From: %s\n", debugstr_a(address) ); - break; - case MAPI_TO: - TRACE( "To: %s\n", debugstr_a(address) ); - to_size += lstrlenA( address ) + 1; - break; - case MAPI_CC: - TRACE( "Cc: %s\n", debugstr_a(address) ); - cc_size += lstrlenA( address ) + 1; - break; - case MAPI_BCC: - TRACE( "Bcc: %s\n", debugstr_a(address) ); - bcc_size += lstrlenA( address ) + 1; - break; - default: - TRACE( "Unknown recipient class: %d\n", - message->lpRecips[i].ulRecipClass ); - } - } - else - FIXME("Name resolution and entry identifiers not supported\n"); - } - if (message->nFileCount) FIXME("Ignoring attachments\n"); - - subject = message->lpszSubject ? message->lpszSubject : ""; - body = message->lpszNoteText ? message->lpszNoteText : ""; - - TRACE( "Subject: %s\n", debugstr_a(subject) ); - TRACE( "Body: %s\n", debugstr_a(body) ); - - subj_size = lstrlenA( subject ); - body_size = lstrlenA( body ); - - ret = MAPI_E_INSUFFICIENT_MEMORY; - if (to_size) - { - to = HeapAlloc( GetProcessHeap(), 0, to_size ); - if (!to) goto exit; - to[0] = 0; - } - if (cc_size) - { - cc = HeapAlloc( GetProcessHeap(), 0, cc_size ); - if (!cc) goto exit; - cc[0] = 0; - } - if (bcc_size) - { - bcc = HeapAlloc( GetProcessHeap(), 0, bcc_size ); - if (!bcc) goto exit; - bcc[0] = 0; - } - - if (message->lpOriginator) - TRACE( "From: %s\n", debugstr_a(message->lpOriginator->lpszAddress) ); - - for (i = 0; i < message->nRecipCount; i++) - { - address = message->lpRecips[i].lpszAddress; - if (address) - { - switch (message->lpRecips[i].ulRecipClass) - { - case MAPI_TO: - if (to_count) lstrcatA( to, "," ); - lstrcatA( to, address ); - to_count++; - break; - case MAPI_CC: - if (cc_count) lstrcatA( cc, "," ); - lstrcatA( cc, address ); - cc_count++; - break; - case MAPI_BCC: - if (bcc_count) lstrcatA( bcc, "," ); - lstrcatA( bcc, address ); - bcc_count++; - break; - } - } - } - ret = MAPI_E_FAILURE; - size = sizeof(format) + to_size + cc_size + bcc_size + subj_size + body_size; - - mailto = HeapAlloc( GetProcessHeap(), 0, size ); - if (!mailto) goto exit; - - sprintf( mailto, format, to ? to : "", subject, cc ? cc : "", bcc ? bcc : "", body ); - - size = 1; - res = UrlEscapeA( mailto, empty_string, &size, URL_ESCAPE_SPACES_ONLY ); - if (res != E_POINTER) goto exit; - - escape = HeapAlloc( GetProcessHeap(), 0, size ); - if (!escape) goto exit; - - res = UrlEscapeA( mailto, escape, &size, URL_ESCAPE_SPACES_ONLY ); - if (res != S_OK) goto exit; - - if ((UINT_PTR)ShellExecuteA( NULL, "open", escape, NULL, NULL, 0 ) > 32) - ret = SUCCESS_SUCCESS; - -exit: - HeapFree( GetProcessHeap(), 0, to ); - HeapFree( GetProcessHeap(), 0, cc ); - HeapFree( GetProcessHeap(), 0, bcc ); - HeapFree( GetProcessHeap(), 0, mailto ); - HeapFree( GetProcessHeap(), 0, escape ); - - return ret; + return MAPI_E_NOT_SUPPORTED; } ULONG WINAPI MAPISendDocuments(ULONG_PTR uiparam, LPSTR delim, LPSTR paths, diff --git a/reactos/dll/win32/mapi32/util.c b/reactos/dll/win32/mapi32/util.c index 71a5e1aec59..90cfa6ecd67 100644 --- a/reactos/dll/win32/mapi32/util.c +++ b/reactos/dll/win32/mapi32/util.c @@ -1037,7 +1037,7 @@ void load_mapi_providers(void) TRACE("appName: %s\n", debugstr_w(appName)); appKey = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (lstrlenW(regkey_mail) + - lstrlenW(regkey_backslash) + lstrlenW(appName))); + lstrlenW(regkey_backslash) + lstrlenW(appName) + 1)); if (!appKey) goto cleanUp; diff --git a/reactos/dll/win32/mapi32/util.h b/reactos/dll/win32/mapi32/util.h index fd813ca5892..df03d6e5f9a 100644 --- a/reactos/dll/win32/mapi32/util.h +++ b/reactos/dll/win32/mapi32/util.h @@ -61,5 +61,6 @@ typedef struct MAPI_FUNCTIONS { } MAPI_FUNCTIONS; extern MAPI_FUNCTIONS mapiFunctions; +extern HINSTANCE hInstMAPI32; #endif diff --git a/reactos/dll/win32/mapi32/version.rc b/reactos/dll/win32/mapi32/version.rc index d3a620bd8fb..e7c3d5926fb 100644 --- a/reactos/dll/win32/mapi32/version.rc +++ b/reactos/dll/win32/mapi32/version.rc @@ -24,3 +24,10 @@ #define WINE_PRODUCTVERSION_STR "1.0.0.0" #include "wine/wine_common_ver.rc" + +#include "De.rc" +#include "En.rc" +#include "Es.rc" +#include "Fr.rc" +#include "Lt.rc" +#include "Ru.rc" diff --git a/reactos/include/psdk/mapi.h b/reactos/include/psdk/mapi.h index 2d335ea588a..7d19734c599 100644 --- a/reactos/include/psdk/mapi.h +++ b/reactos/include/psdk/mapi.h @@ -27,7 +27,7 @@ extern "C" { #ifndef __LHANDLE #define __LHANDLE -typedef ULONG LHANDLE, *LPLHANDLE; +typedef ULONG_PTR LHANDLE, *LPLHANDLE; #endif #define lhSessionNull ((LHANDLE)0) From 257289fd89d5a92d137b0472fabfee35d8ade276 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:41:30 +0000 Subject: [PATCH 110/211] [MAPI32_WINETEST] sync mapi32_winetest to wine 1.1.39 svn path=/trunk/; revision=45882 --- rostests/winetests/mapi32/imalloc.c | 7 ++ rostests/winetests/mapi32/prop.c | 144 ++++++++++++++++++++-------- rostests/winetests/mapi32/util.c | 71 +++++++++++--- 3 files changed, 170 insertions(+), 52 deletions(-) diff --git a/rostests/winetests/mapi32/imalloc.c b/rostests/winetests/mapi32/imalloc.c index 485180c0e45..341155cf9d6 100644 --- a/rostests/winetests/mapi32/imalloc.c +++ b/rostests/winetests/mapi32/imalloc.c @@ -45,11 +45,18 @@ static void test_IMalloc(void) pMAPIGetDefaultMalloc = (void*)GetProcAddress(hMapi32, "MAPIGetDefaultMalloc@0"); if (!pMAPIGetDefaultMalloc) + { + win_skip("MAPIGetDefaultMalloc is not available\n"); return; + } lpMalloc = pMAPIGetDefaultMalloc(); + ok(lpMalloc != NULL, "Expected MAPIGetDefaultMalloc to return non-NULL\n"); if (!lpMalloc) + { + skip("MAPIGetDefaultMalloc failed\n"); return; + } lpVoid = NULL; hRet = IMalloc_QueryInterface(lpMalloc, &IID_IUnknown, &lpVoid); diff --git a/rostests/winetests/mapi32/prop.c b/rostests/winetests/mapi32/prop.c index 237134b07c5..15d6d98e4b5 100644 --- a/rostests/winetests/mapi32/prop.c +++ b/rostests/winetests/mapi32/prop.c @@ -32,6 +32,7 @@ static HMODULE hMapi32 = 0; static SCODE (WINAPI *pScInitMapiUtil)(ULONG); +static void (WINAPI *pDeinitMapiUtil)(void); static SCODE (WINAPI *pPropCopyMore)(LPSPropValue,LPSPropValue,ALLOCATEMORE*,LPVOID); static ULONG (WINAPI *pUlPropSize)(LPSPropValue); static BOOL (WINAPI *pFPropContainsProp)(LPSPropValue,LPSPropValue,ULONG); @@ -53,26 +54,49 @@ static SCODE (WINAPI *pCreateIProp)(LPCIID,ALLOCATEBUFFER*,ALLOCATEMORE*, FREEBUFFER*,LPVOID,LPPROPDATA*); static SCODE (WINAPI *pMAPIAllocateBuffer)(ULONG, LPVOID); static SCODE (WINAPI *pMAPIAllocateMore)(ULONG, LPVOID, LPVOID); +static SCODE (WINAPI *pMAPIInitialize)(LPVOID); static SCODE (WINAPI *pMAPIFreeBuffer)(LPVOID); +static void (WINAPI *pMAPIUninitialize)(void); static BOOL InitFuncPtrs(void) { hMapi32 = LoadLibraryA("mapi32.dll"); + pPropCopyMore = (void*)GetProcAddress(hMapi32, "PropCopyMore@16"); + pUlPropSize = (void*)GetProcAddress(hMapi32, "UlPropSize@4"); + pFPropContainsProp = (void*)GetProcAddress(hMapi32, "FPropContainsProp@12"); + pFPropCompareProp = (void*)GetProcAddress(hMapi32, "FPropCompareProp@12"); + pLPropCompareProp = (void*)GetProcAddress(hMapi32, "LPropCompareProp@8"); + pPpropFindProp = (void*)GetProcAddress(hMapi32, "PpropFindProp@12"); + pScCountProps = (void*)GetProcAddress(hMapi32, "ScCountProps@12"); + pScCopyProps = (void*)GetProcAddress(hMapi32, "ScCopyProps@16"); + pScRelocProps = (void*)GetProcAddress(hMapi32, "ScRelocProps@20"); + pLpValFindProp = (void*)GetProcAddress(hMapi32, "LpValFindProp@12"); + pFBadRglpszA = (void*)GetProcAddress(hMapi32, "FBadRglpszA@8"); + pFBadRglpszW = (void*)GetProcAddress(hMapi32, "FBadRglpszW@8"); + pFBadRowSet = (void*)GetProcAddress(hMapi32, "FBadRowSet@4"); + pFBadPropTag = (void*)GetProcAddress(hMapi32, "FBadPropTag@4"); + pFBadRow = (void*)GetProcAddress(hMapi32, "FBadRow@4"); + pFBadProp = (void*)GetProcAddress(hMapi32, "FBadProp@4"); + pFBadColumnSet = (void*)GetProcAddress(hMapi32, "FBadColumnSet@4"); + pCreateIProp = (void*)GetProcAddress(hMapi32, "CreateIProp@24"); + pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4"); + pDeinitMapiUtil = (void*)GetProcAddress(hMapi32, "DeinitMapiUtil@0"); pMAPIAllocateBuffer = (void*)GetProcAddress(hMapi32, "MAPIAllocateBuffer"); pMAPIAllocateMore = (void*)GetProcAddress(hMapi32, "MAPIAllocateMore"); pMAPIFreeBuffer = (void*)GetProcAddress(hMapi32, "MAPIFreeBuffer"); - if(pScInitMapiUtil && pMAPIAllocateBuffer && pMAPIAllocateMore && pMAPIFreeBuffer) - return TRUE; - else - return FALSE; + pMAPIInitialize = (void*)GetProcAddress(hMapi32, "MAPIInitialize"); + pMAPIUninitialize = (void*)GetProcAddress(hMapi32, "MAPIUninitialize"); + + return pMAPIAllocateBuffer && pMAPIAllocateMore && pMAPIFreeBuffer && + pScInitMapiUtil && pDeinitMapiUtil; } +/* FIXME: Test PT_I2, PT_I4, PT_R4, PT_R8, PT_CURRENCY, PT_APPTIME, PT_SYSTIME, + * PT_ERROR, PT_BOOLEAN, PT_I8, and PT_CLSID. */ static ULONG ptTypes[] = { - PT_I2, PT_I4, PT_R4, PT_R8, PT_CURRENCY, PT_APPTIME, PT_SYSTIME, - PT_ERROR, PT_BOOLEAN, PT_I8, PT_CLSID, PT_STRING8, PT_BINARY, - PT_UNICODE + PT_STRING8, PT_BINARY, PT_UNICODE }; static inline int strcmpW(const WCHAR *str1, const WCHAR *str2) @@ -89,18 +113,27 @@ static void test_PropCopyMore(void) ULONG i; SCODE scode; - pPropCopyMore = (void*)GetProcAddress(hMapi32, "PropCopyMore@16"); - if (!pPropCopyMore) + { + win_skip("PropCopyMore is not available\n"); return; + } - scode = pMAPIAllocateBuffer(sizeof(LPSPropValue), lpDest); + scode = pMAPIAllocateBuffer(sizeof(SPropValue), &lpDest); + ok(scode == S_OK, "Expected MAPIAllocateBuffer to return S_OK, got 0x%x\n", scode); if (FAILED(scode)) + { + skip("MAPIAllocateBuffer failed\n"); return; + } - scode = pMAPIAllocateMore(sizeof(LPSPropValue), lpDest, lpSrc); + scode = pMAPIAllocateMore(sizeof(SPropValue), lpDest, &lpSrc); + ok(scode == S_OK, "Expected MAPIAllocateMore to return S_OK, got 0x%x\n", scode); if (FAILED(scode)) + { + skip("MAPIAllocateMore failed\n"); return; + } for (i = 0; i < sizeof(ptTypes)/sizeof(ptTypes[0]); i++) { @@ -148,7 +181,8 @@ static void test_PropCopyMore(void) } /* Since all allocations are linked, freeing lpDest frees everything */ - pMAPIFreeBuffer(lpDest); + scode = pMAPIFreeBuffer(lpDest); + ok(scode == S_OK, "Expected MAPIFreeBuffer to return S_OK, got 0x%x\n", scode); } static void test_UlPropSize(void) @@ -160,10 +194,11 @@ static void test_UlPropSize(void) SBinary buffbin[2]; ULONG pt, exp, res; - pUlPropSize = (void*)GetProcAddress(hMapi32, "UlPropSize@4"); - if (!pUlPropSize) + { + win_skip("UlPropSize is not available\n"); return; + } for (pt = 0; pt < PROP_ID_INVALID; pt++) { @@ -257,10 +292,11 @@ static void test_FPropContainsProp(void) ULONG pt; BOOL bRet; - pFPropContainsProp = (void*)GetProcAddress(hMapi32, "FPropContainsProp@12"); - if (!pFPropContainsProp) + { + win_skip("FPropContainsProp is not available\n"); return; + } /* Ensure that only PT_STRING8 and PT_BINARY are handled */ for (pt = 0; pt < PROP_ID_INVALID; pt++) @@ -406,10 +442,11 @@ static void test_FPropCompareProp(void) ULONG i, j; BOOL bRet, bExp; - pFPropCompareProp = (void*)GetProcAddress(hMapi32, "FPropCompareProp@12"); - if (!pFPropCompareProp) + { + win_skip("FPropCompareProp is not available\n"); return; + } lbuffa[1] = '\0'; rbuffa[1] = '\0'; @@ -535,10 +572,11 @@ static void test_LPropCompareProp(void) ULONG i, j; INT iRet, iExp; - pLPropCompareProp = (void*)GetProcAddress(hMapi32, "LPropCompareProp@8"); - if (!pLPropCompareProp) + { + win_skip("LPropCompareProp is not available\n"); return; + } lbuffa[1] = '\0'; rbuffa[1] = '\0'; @@ -640,10 +678,11 @@ static void test_PpropFindProp(void) SPropValue pvProp, *pRet; ULONG i; - pPpropFindProp = (void*)GetProcAddress(hMapi32, "PpropFindProp@12"); - if (!pPpropFindProp) + { + win_skip("PpropFindProp is not available\n"); return; + } for (i = 0; i < sizeof(ptTypes)/sizeof(ptTypes[0]); i++) { @@ -679,10 +718,11 @@ static void test_ScCountProps(void) ULONG pt, exp, ulRet; int success = 1; - pScCountProps = (void*)GetProcAddress(hMapi32, "ScCountProps@12"); - if (!pScCountProps) + { + win_skip("ScCountProps is not available\n"); return; + } for (pt = 0; pt < PROP_ID_INVALID && success; pt++) { @@ -814,11 +854,11 @@ static void test_ScCopyRelocProps(void) ULONG ulCount; SCODE sc; - pScCopyProps = (void*)GetProcAddress(hMapi32, "ScCopyProps@16"); - pScRelocProps = (void*)GetProcAddress(hMapi32, "ScRelocProps@20"); - if (!pScCopyProps || !pScRelocProps) + { + win_skip("SPropValue copy functions are not available\n"); return; + } pvProp.ulPropTag = PROP_TAG(PT_MV_STRING8, 1u); @@ -877,10 +917,11 @@ static void test_LpValFindProp(void) SPropValue pvProp, *pRet; ULONG i; - pLpValFindProp = (void*)GetProcAddress(hMapi32, "LpValFindProp@12"); - if (!pLpValFindProp) + { + win_skip("LpValFindProp is not available\n"); return; + } for (i = 0; i < sizeof(ptTypes)/sizeof(ptTypes[0]); i++) { @@ -912,9 +953,11 @@ static void test_FBadRglpszA(void) static CHAR szString[] = "A String"; BOOL bRet; - pFBadRglpszA = (void*)GetProcAddress(hMapi32, "FBadRglpszA@8"); if (!pFBadRglpszA) + { + win_skip("FBadRglpszA is not available\n"); return; + } bRet = pFBadRglpszA(NULL, 10); ok(bRet == TRUE, "FBadRglpszA(Null): expected TRUE, got FALSE\n"); @@ -937,9 +980,11 @@ static void test_FBadRglpszW(void) static WCHAR szString[] = { 'A',' ','S','t','r','i','n','g','\0' }; BOOL bRet; - pFBadRglpszW = (void*)GetProcAddress(hMapi32, "FBadRglpszW@8"); if (!pFBadRglpszW) + { + win_skip("FBadRglpszW is not available\n"); return; + } bRet = pFBadRglpszW(NULL, 10); ok(bRet == TRUE, "FBadRglpszW(Null): expected TRUE, got FALSE\n"); @@ -960,9 +1005,11 @@ static void test_FBadRowSet(void) { ULONG ulRet; - pFBadRowSet = (void*)GetProcAddress(hMapi32, "FBadRowSet@4"); if (!pFBadRowSet) + { + win_skip("FBadRowSet is not available\n"); return; + } ulRet = pFBadRowSet(NULL); ok(ulRet != 0, "FBadRow(null): Expected non-zero, got 0\n"); @@ -974,9 +1021,11 @@ static void test_FBadPropTag(void) { ULONG pt, res; - pFBadPropTag = (void*)GetProcAddress(hMapi32, "FBadPropTag@4"); if (!pFBadPropTag) + { + win_skip("FBadPropTag is not available\n"); return; + } for (pt = 0; pt < PROP_ID_INVALID; pt++) { @@ -1006,9 +1055,11 @@ static void test_FBadRow(void) { ULONG ulRet; - pFBadRow = (void*)GetProcAddress(hMapi32, "FBadRow@4"); if (!pFBadRow) + { + win_skip("FBadRow is not available\n"); return; + } ulRet = pFBadRow(NULL); ok(ulRet != 0, "FBadRow(null): Expected non-zero, got 0\n"); @@ -1023,9 +1074,11 @@ static void test_FBadProp(void) ULONG pt, res; SPropValue pv; - pFBadProp = (void*)GetProcAddress(hMapi32, "FBadProp@4"); if (!pFBadProp) + { + win_skip("FBadProp is not available\n"); return; + } for (pt = 0; pt < PROP_ID_INVALID; pt++) { @@ -1097,9 +1150,11 @@ static void test_FBadColumnSet(void) SPropTagArray pta; ULONG pt, res; - pFBadColumnSet = (void*)GetProcAddress(hMapi32, "FBadColumnSet@4"); if (!pFBadColumnSet) + { + win_skip("FBadColumnSet is not available\n"); return; + } res = pFBadColumnSet(NULL); ok(res != 0, "(null): Expected non-zero, got 0\n"); @@ -1157,10 +1212,11 @@ static void test_IProp(void) ULONG access[2], count; SCODE sc; - pCreateIProp = (void*)GetProcAddress(hMapi32, "CreateIProp@24"); - if (!pCreateIProp) + { + win_skip("CreateIProp is not available\n"); return; + } memset(&tags, 0 , sizeof(tags)); @@ -1390,7 +1446,17 @@ START_TEST(prop) test_PropCopyMore(); test_UlPropSize(); + + /* We call MAPIInitialize here for the benefit of native extended MAPI + * providers which crash in the FPropContainsProp tests when MAPIInitialize + * has not been called. Since MAPIInitialize is irrelevant for FPropContainsProp + * on Wine, we do not care whether MAPIInitialize succeeds. */ + if (pMAPIInitialize) + ret = pMAPIInitialize(NULL); test_FPropContainsProp(); + if (pMAPIUninitialize && ret == S_OK) + pMAPIUninitialize(); + test_FPropCompareProp(); test_LPropCompareProp(); test_PpropFindProp(); @@ -1406,5 +1472,7 @@ START_TEST(prop) test_FBadColumnSet(); test_IProp(); + + pDeinitMapiUtil(); FreeLibrary(hMapi32); } diff --git a/rostests/winetests/mapi32/util.c b/rostests/winetests/mapi32/util.c index feb2c6daa0b..0edac07aee6 100644 --- a/rostests/winetests/mapi32/util.c +++ b/rostests/winetests/mapi32/util.c @@ -31,22 +31,45 @@ static HMODULE hMapi32 = 0; static SCODE (WINAPI *pScInitMapiUtil)(ULONG); +static void (WINAPI *pDeinitMapiUtil)(void); static void (WINAPI *pSwapPword)(PUSHORT,ULONG); static void (WINAPI *pSwapPlong)(PULONG,ULONG); static void (WINAPI *pHexFromBin)(LPBYTE,int,LPWSTR); -static void (WINAPI *pFBinFromHex)(LPWSTR,LPBYTE); +static BOOL (WINAPI *pFBinFromHex)(LPWSTR,LPBYTE); static UINT (WINAPI *pUFromSz)(LPCSTR); static ULONG (WINAPI *pUlFromSzHex)(LPCSTR); static ULONG (WINAPI *pCbOfEncoded)(LPCSTR); static BOOL (WINAPI *pIsBadBoundedStringPtr)(LPCSTR,ULONG); +static SCODE (WINAPI *pMAPIInitialize)(LPVOID); +static void (WINAPI *pMAPIUninitialize)(void); + +static void init_function_pointers(void) +{ + hMapi32 = LoadLibraryA("mapi32.dll"); + + pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4"); + pDeinitMapiUtil = (void*)GetProcAddress(hMapi32, "DeinitMapiUtil@0"); + pSwapPword = (void*)GetProcAddress(hMapi32, "SwapPword@8"); + pSwapPlong = (void*)GetProcAddress(hMapi32, "SwapPlong@8"); + pHexFromBin = (void*)GetProcAddress(hMapi32, "HexFromBin@12"); + pFBinFromHex = (void*)GetProcAddress(hMapi32, "FBinFromHex@8"); + pUFromSz = (void*)GetProcAddress(hMapi32, "UFromSz@4"); + pUlFromSzHex = (void*)GetProcAddress(hMapi32, "UlFromSzHex@4"); + pCbOfEncoded = (void*)GetProcAddress(hMapi32, "CbOfEncoded@4"); + pIsBadBoundedStringPtr = (void*)GetProcAddress(hMapi32, "IsBadBoundedStringPtr@8"); + pMAPIInitialize = (void*)GetProcAddress(hMapi32, "MAPIInitialize"); + pMAPIUninitialize = (void*)GetProcAddress(hMapi32, "MAPIUninitialize"); +} static void test_SwapPword(void) { USHORT shorts[3]; - pSwapPword = (void*)GetProcAddress(hMapi32, "SwapPword@8"); if (!pSwapPword) + { + win_skip("SwapPword is not available\n"); return; + } shorts[0] = 0xff01; shorts[1] = 0x10ff; @@ -61,9 +84,11 @@ static void test_SwapPlong(void) { ULONG longs[3]; - pSwapPlong = (void*)GetProcAddress(hMapi32, "SwapPlong@8"); if (!pSwapPlong) + { + win_skip("SwapPlong is not available\n"); return; + } longs[0] = 0xffff0001; longs[1] = 0x1000ffff; @@ -89,10 +114,11 @@ static void test_HexFromBin(void) BOOL bOk; int i; - pHexFromBin = (void*)GetProcAddress(hMapi32, "HexFromBin@12"); - pFBinFromHex = (void*)GetProcAddress(hMapi32, "FBinFromHex@8"); if (!pHexFromBin || !pFBinFromHex) + { + win_skip("Hexadecimal conversion functions are not available\n"); return; + } for (i = 0; i < 255; i++) data[i] = i; @@ -112,9 +138,11 @@ static void test_HexFromBin(void) static void test_UFromSz(void) { - pUFromSz = (void*)GetProcAddress(hMapi32, "UFromSz@4"); if (!pUFromSz) + { + win_skip("UFromSz is not available\n"); return; + } ok(pUFromSz("105679") == 105679u, "UFromSz: expected 105679, got %d\n", pUFromSz("105679")); @@ -125,9 +153,11 @@ static void test_UFromSz(void) static void test_UlFromSzHex(void) { - pUlFromSzHex = (void*)GetProcAddress(hMapi32, "UlFromSzHex@4"); if (!pUlFromSzHex) + { + win_skip("UlFromSzHex is not available\n"); return; + } ok(pUlFromSzHex("fF") == 0xffu, "UlFromSzHex: expected 0xff, got 0x%x\n", pUlFromSzHex("fF")); @@ -141,9 +171,11 @@ static void test_CbOfEncoded(void) char buff[129]; unsigned int i; - pCbOfEncoded = (void*)GetProcAddress(hMapi32, "CbOfEncoded@4"); if (!pCbOfEncoded) + { + win_skip("CbOfEncoded is not available\n"); return; + } for (i = 0; i < sizeof(buff) - 1; i++) { @@ -160,9 +192,11 @@ static void test_CbOfEncoded(void) static void test_IsBadBoundedStringPtr(void) { - pIsBadBoundedStringPtr = (void*)GetProcAddress(hMapi32, "IsBadBoundedStringPtr@8"); if (!pIsBadBoundedStringPtr) + { + win_skip("IsBadBoundedStringPtr is not available\n"); return; + } ok(pIsBadBoundedStringPtr(NULL, 0) == TRUE, "IsBadBoundedStringPtr: expected TRUE\n"); ok(pIsBadBoundedStringPtr("TEST", 4) == TRUE, "IsBadBoundedStringPtr: expected TRUE\n"); @@ -179,13 +213,11 @@ START_TEST(util) return; } - hMapi32 = LoadLibraryA("mapi32.dll"); + init_function_pointers(); - pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4"); - - if (!pScInitMapiUtil) + if (!pScInitMapiUtil || !pDeinitMapiUtil) { - win_skip("ScInitMapiUtil is not available\n"); + win_skip("MAPI utility initialization functions are not available\n"); FreeLibrary(hMapi32); return; } @@ -207,11 +239,22 @@ START_TEST(util) test_SwapPword(); test_SwapPlong(); + + /* We call MAPIInitialize here for the benefit of native extended MAPI + * providers which crash in the HexFromBin tests when MAPIInitialize has + * not been called. Since MAPIInitialize is irrelevant for HexFromBin on + * Wine, we do not care whether MAPIInitialize succeeds. */ + if (pMAPIInitialize) + ret = pMAPIInitialize(NULL); test_HexFromBin(); + if (pMAPIUninitialize && ret == S_OK) + pMAPIUninitialize(); + test_UFromSz(); test_UlFromSzHex(); test_CbOfEncoded(); test_IsBadBoundedStringPtr(); + pDeinitMapiUtil(); FreeLibrary(hMapi32); } From 71ca03ec6a9b36ab150e17bb4b1bac2072e2c749 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:44:59 +0000 Subject: [PATCH 111/211] [DSOUND_WINETEST] sync dsound_winetest to wine 1.1.39 svn path=/trunk/; revision=45883 --- rostests/winetests/dsound/ds3d.c | 23 +++++++++++++++++++++-- rostests/winetests/dsound/dsound.c | 13 ++++++++++--- rostests/winetests/dsound/dsound8.c | 13 ++++++++++--- rostests/winetests/dsound/propset.c | 1 + 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/rostests/winetests/dsound/ds3d.c b/rostests/winetests/dsound/ds3d.c index 71ff2ab3908..ad380d863a2 100644 --- a/rostests/winetests/dsound/ds3d.c +++ b/rostests/winetests/dsound/ds3d.c @@ -1158,13 +1158,12 @@ static HRESULT test_primary_3d_with_listener(LPGUID lpGuid) "to create a 3D primary buffer: %08x\n",rc); if (rc==DS_OK && primary!=NULL) { LPDIRECTSOUND3DLISTENER listener=NULL; + LPDIRECTSOUNDBUFFER temp_buffer=NULL; rc=IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSound3DListener,(void **)&listener); ok(rc==DS_OK && listener!=NULL,"IDirectSoundBuffer_QueryInterface() " "failed to get a 3D listener: %08x\n",rc); if (rc==DS_OK && listener!=NULL) { - LPDIRECTSOUNDBUFFER temp_buffer=NULL; - /* Checking the COM interface */ rc=IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer); @@ -1195,6 +1194,16 @@ static HRESULT test_primary_3d_with_listener(LPGUID lpGuid) winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0, listener,0,0,FALSE,0); + + todo_wine { + temp_buffer = NULL; + rc=IDirectSound3DListener_QueryInterface(listener, + &IID_IKsPropertySet,(LPVOID *)&temp_buffer); + ok(rc==DS_OK && temp_buffer!=NULL, + "IDirectSound3DListener_QueryInterface didn't handle IKsPropertySet: ret = %08x\n", rc); + if(temp_buffer) + IKsPropertySet_Release(temp_buffer); + } } /* Testing the reference counting */ @@ -1203,6 +1212,16 @@ static HRESULT test_primary_3d_with_listener(LPGUID lpGuid) "references, should have 0\n",ref); } + todo_wine { + temp_buffer = NULL; + rc=IDirectSoundBuffer_QueryInterface(primary, + &IID_IKsPropertySet,(LPVOID *)&temp_buffer); + ok(rc==DS_OK && temp_buffer!=NULL, + "IDirectSoundBuffer_QueryInterface didn't handle IKsPropertySet on primary buffer: ret = %08x\n", rc); + if(temp_buffer) + IKsPropertySet_Release(temp_buffer); + } + /* Testing the reference counting */ ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " diff --git a/rostests/winetests/dsound/dsound.c b/rostests/winetests/dsound/dsound.c index 114dbb6ced2..f059c20e62f 100644 --- a/rostests/winetests/dsound/dsound.c +++ b/rostests/winetests/dsound/dsound.c @@ -55,7 +55,7 @@ static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized, IUnknown * unknown; IDirectSound * ds; IDirectSound8 * ds8; - DWORD speaker_config, new_speaker_config; + DWORD speaker_config, new_speaker_config, ref_speaker_config; /* Try to Query for objects */ rc=IDirectSound_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown); @@ -144,11 +144,17 @@ static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized, rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config); ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %08x\n", rc); + ref_speaker_config = speaker_config; speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE); - rc=IDirectSound_SetSpeakerConfig(dso,speaker_config); - ok(rc==DS_OK,"IDirectSound_SetSpeakerConfig() failed: %08x\n", rc); + if (speaker_config == ref_speaker_config) + speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, + DSSPEAKER_GEOMETRY_NARROW); + if(rc==DS_OK) { + rc=IDirectSound_SetSpeakerConfig(dso,speaker_config); + ok(rc==DS_OK,"IDirectSound_SetSpeakerConfig() failed: %08x\n", rc); + } if (rc==DS_OK) { rc=IDirectSound_GetSpeakerConfig(dso,&new_speaker_config); ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %08x\n", rc); @@ -156,6 +162,7 @@ static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized, trace("IDirectSound_GetSpeakerConfig() failed to set speaker " "config: expected 0x%08x, got 0x%08x\n", speaker_config,new_speaker_config); + IDirectSound_SetSpeakerConfig(dso,ref_speaker_config); } EXIT: diff --git a/rostests/winetests/dsound/dsound8.c b/rostests/winetests/dsound/dsound8.c index a2b16d85bbb..5eb7c059d35 100644 --- a/rostests/winetests/dsound/dsound8.c +++ b/rostests/winetests/dsound/dsound8.c @@ -54,7 +54,7 @@ static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized, IUnknown * unknown; IDirectSound * ds; IDirectSound8 * ds8; - DWORD speaker_config, new_speaker_config; + DWORD speaker_config, new_speaker_config, ref_speaker_config; DWORD certified; /* Try to Query for objects */ @@ -148,11 +148,17 @@ static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized, rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config); ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %08x\n", rc); + ref_speaker_config = speaker_config; speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE); - rc=IDirectSound8_SetSpeakerConfig(dso,speaker_config); - ok(rc==DS_OK,"IDirectSound8_SetSpeakerConfig() failed: %08x\n", rc); + if (speaker_config == ref_speaker_config) + speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, + DSSPEAKER_GEOMETRY_NARROW); + if(rc==DS_OK) { + rc=IDirectSound8_SetSpeakerConfig(dso,speaker_config); + ok(rc==DS_OK,"IDirectSound8_SetSpeakerConfig() failed: %08x\n", rc); + } if (rc==DS_OK) { rc=IDirectSound8_GetSpeakerConfig(dso,&new_speaker_config); ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %08x\n", rc); @@ -160,6 +166,7 @@ static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized, trace("IDirectSound8_GetSpeakerConfig() failed to set speaker " "config: expected 0x%08x, got 0x%08x\n", speaker_config,new_speaker_config); + IDirectSound8_SetSpeakerConfig(dso,ref_speaker_config); } rc=IDirectSound8_VerifyCertification(dso, &certified); diff --git a/rostests/winetests/dsound/propset.c b/rostests/winetests/dsound/propset.c index 70a8e0d9f24..5007fccb3ca 100644 --- a/rostests/winetests/dsound/propset.c +++ b/rostests/winetests/dsound/propset.c @@ -550,6 +550,7 @@ static void propset_private_tests(void) NULL, 0, &data, sizeof(data), &bytes); ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc); } + IKsPropertySet_Release(pps); } static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, From 5df3fe3f82da4844f81db1fcede504486843d706 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:45:24 +0000 Subject: [PATCH 112/211] add dsound_winetest to build svn path=/trunk/; revision=45884 --- rostests/winetests/directory.rbuild | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rostests/winetests/directory.rbuild b/rostests/winetests/directory.rbuild index f774eb8b6e6..e4df81b16f1 100644 --- a/rostests/winetests/directory.rbuild +++ b/rostests/winetests/directory.rbuild @@ -37,6 +37,9 @@ + + + From 38a74f7e1ebf1fc2756dcd8ac7cf641e444cb12a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:47:06 +0000 Subject: [PATCH 113/211] [URLMON_WINETEST] sync urlmon_winetest to wine 1.1.39 svn path=/trunk/; revision=45885 --- rostests/winetests/urlmon/misc.c | 82 +++++++++++-- rostests/winetests/urlmon/protocol.c | 37 ++++-- rostests/winetests/urlmon/sec_mgr.c | 68 +++++++++++ rostests/winetests/urlmon/stream.c | 7 +- rostests/winetests/urlmon/url.c | 171 ++++++++++++++------------- 5 files changed, 267 insertions(+), 98 deletions(-) diff --git a/rostests/winetests/urlmon/misc.c b/rostests/winetests/urlmon/misc.c index 5b59626398f..2e77c1bc237 100644 --- a/rostests/winetests/urlmon/misc.c +++ b/rostests/winetests/urlmon/misc.c @@ -270,6 +270,10 @@ static const WCHAR wszHttp[] = {'h','t','t','p',0}; static const WCHAR wszAbout[] = {'a','b','o','u','t',0}; static const WCHAR wszEmpty[] = {0}; +static const WCHAR wszWineHQ[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}; +static const WCHAR wszHttpWineHQ[] = {'h','t','t','p',':','/','/','w','w','w','.', + 'w','i','n','e','h','q','.','o','r','g',0}; + struct parse_test { LPCWSTR url; HRESULT secur_hres; @@ -277,15 +281,19 @@ struct parse_test { HRESULT path_hres; LPCWSTR path; LPCWSTR schema; + LPCWSTR domain; + HRESULT domain_hres; + LPCWSTR rootdocument; + HRESULT rootdocument_hres; }; static const struct parse_test parse_tests[] = { - {url1, S_OK, url1, E_INVALIDARG, NULL, wszRes}, - {url2, E_FAIL, url2, E_INVALIDARG, NULL, wszEmpty}, - {url3, E_FAIL, url3, S_OK, path3, wszFile}, - {url4, E_FAIL, url4e, S_OK, path4, wszFile}, - {url5, E_FAIL, url5, E_INVALIDARG, NULL, wszHttp}, - {url6, S_OK, url6, E_INVALIDARG, NULL, wszAbout} + {url1, S_OK, url1, E_INVALIDARG, NULL, wszRes, NULL, E_FAIL, NULL, E_FAIL}, + {url2, E_FAIL, url2, E_INVALIDARG, NULL, wszEmpty, NULL, E_FAIL, NULL, E_FAIL}, + {url3, E_FAIL, url3, S_OK, path3, wszFile, wszEmpty, S_OK, NULL, E_FAIL}, + {url4, E_FAIL, url4e, S_OK, path4, wszFile, wszEmpty, S_OK, NULL, E_FAIL}, + {url5, E_FAIL, url5, E_INVALIDARG, NULL, wszHttp, wszWineHQ, S_OK, wszHttpWineHQ, S_OK}, + {url6, S_OK, url6, E_INVALIDARG, NULL, wszAbout, NULL, E_FAIL, NULL, E_FAIL}, }; static void test_CoInternetParseUrl(void) @@ -331,6 +339,23 @@ static void test_CoInternetParseUrl(void) ok(hres == S_OK, "[%d] schema failed: %08x\n", i, hres); ok(size == lstrlenW(parse_tests[i].schema), "[%d] wrong size\n", i); ok(!lstrcmpW(parse_tests[i].schema, buf), "[%d] wrong schema\n", i); + + if(memcmp(parse_tests[i].url, wszRes, 3*sizeof(WCHAR)) + && memcmp(parse_tests[i].url, wszAbout, 5*sizeof(WCHAR))) { + memset(buf, 0xf0, sizeof(buf)); + hres = CoInternetParseUrl(parse_tests[i].url, PARSE_DOMAIN, 0, buf, + sizeof(buf)/sizeof(WCHAR), &size, 0); + ok(hres == parse_tests[i].domain_hres, "[%d] domain failed: %08x\n", i, hres); + if(parse_tests[i].domain) + ok(!lstrcmpW(parse_tests[i].domain, buf), "[%d] wrong domain, received %s\n", i, wine_dbgstr_w(buf)); + } + + memset(buf, 0xf0, sizeof(buf)); + hres = CoInternetParseUrl(parse_tests[i].url, PARSE_ROOTDOCUMENT, 0, buf, + sizeof(buf)/sizeof(WCHAR), &size, 0); + ok(hres == parse_tests[i].rootdocument_hres, "[%d] rootdocument failed: %08x\n", i, hres); + if(parse_tests[i].rootdocument) + ok(!lstrcmpW(parse_tests[i].rootdocument, buf), "[%d] wrong rootdocument, received %s\n", i, wine_dbgstr_w(buf)); } } @@ -755,7 +780,19 @@ static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved) { - CHECK_EXPECT(ParseUrl); + CHECK_EXPECT2(ParseUrl); + + if(ParseAction == PARSE_SECURITY_URL) { + if(pcchResult) + *pcchResult = sizeof(url1)/sizeof(WCHAR); + + if(cchResultsizeof(wszFile)/sizeof(WCHAR) && + !memcmp(sec_url, wszFile, sizeof(wszFile)-sizeof(WCHAR)), + "Encoded url = %s\n", wine_dbgstr_w(sec_url)); + CoTaskMemFree(sec_url); + } + + CHECK_CALLED(QI_IInternetProtocolInfo); + CHECK_CALLED(ParseUrl); + hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest); ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres); diff --git a/rostests/winetests/urlmon/protocol.c b/rostests/winetests/urlmon/protocol.c index 5f48cfe3ca4..d54d00d9d42 100644 --- a/rostests/winetests/urlmon/protocol.c +++ b/rostests/winetests/urlmon/protocol.c @@ -131,7 +131,7 @@ static const WCHAR gzipW[] = {'g','z','i','p',0}; static HRESULT expect_hrResult; static LPCWSTR file_name, http_url, expect_wsz; static IInternetProtocol *async_protocol = NULL; -static BOOL first_data_notif, http_is_first, http_post_test; +static BOOL first_data_notif, http_is_first, http_post_test, test_redirect; static int state = 0, prot_state, read_report_data; static DWORD bindf, ex_priority , pi; static IInternetProtocol *binding_protocol, *filtered_protocol; @@ -442,19 +442,23 @@ static void call_continue(PROTOCOLDATA *protocol_data) CLEAR_CALLED(ReportProgress_FINDINGRESOURCE); CLEAR_CALLED(ReportProgress_CONNECTING); CLEAR_CALLED(ReportProgress_PROXYDETECTING); - } else todo_wine { - CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE); - /* IE7 does call this */ - CLEAR_CALLED(ReportProgress_CONNECTING); - } + }else if(test_redirect) { + CHECK_CALLED(ReportProgress_FINDINGRESOURCE); + }else todo_wine { + CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE); + /* IE7 does call this */ + CLEAR_CALLED(ReportProgress_CONNECTING); + } } if(tested_protocol == FTP_TEST) todo_wine CHECK_CALLED(ReportProgress_SENDINGREQUEST); else if (tested_protocol != HTTPS_TEST) CHECK_CALLED(ReportProgress_SENDINGREQUEST); + if(test_redirect) + CHECK_CALLED(ReportProgress_REDIRECTING); if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) { SET_EXPECT(OnResponse); - if(tested_protocol == HTTPS_TEST) + if(tested_protocol == HTTPS_TEST || test_redirect) SET_EXPECT(ReportProgress_ACCEPTRANGES); SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); if(bindf & BINDF_NEEDFILE) @@ -478,6 +482,8 @@ static void call_continue(PROTOCOLDATA *protocol_data) CHECK_CALLED(OnResponse); if(tested_protocol == HTTPS_TEST) CHECK_CALLED(ReportProgress_ACCEPTRANGES); + else if(test_redirect) + CLEAR_CALLED(ReportProgress_ACCEPTRANGES); CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); if(bindf & BINDF_NEEDFILE) CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE); @@ -616,7 +622,10 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, break; case BINDSTATUS_REDIRECTING: CHECK_EXPECT(ReportProgress_REDIRECTING); - ok(szStatusText == NULL, "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); + if(test_redirect) + ok(!strcmp_wa(szStatusText, "http://test.winehq.org/hello.html"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); + else + ok(szStatusText == NULL, "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); break; case BINDSTATUS_ENCODING: CHECK_EXPECT(ReportProgress_ENCODING); @@ -1346,6 +1355,7 @@ static HRESULT WINAPI ProtocolEmul_Start(IInternetProtocol *iface, LPCWSTR szUrl "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres); ok(fetched == 1, "fetched = %d, expected 1\n", fetched); ok(!strcmp_ww(acc_mimeW, accept_mimes[0]), "unexpected mimes %s\n", wine_dbgstr_w(accept_mimes[0])); + CoTaskMemFree(accept_mimes[0]); hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider, (void**)&service_provider); @@ -1952,6 +1962,7 @@ static IClassFactory mimefilter_cf = { &MimeFilterCFVtbl }; #define TEST_POST 0x10 #define TEST_EMULATEPROT 0x20 #define TEST_SHORT_READ 0x40 +#define TEST_REDIRECT 0x80 static void init_test(int prot, DWORD flags) { @@ -1977,6 +1988,7 @@ static void init_test(int prot, DWORD flags) emulate_prot = (flags & TEST_EMULATEPROT) != 0; wait_for_switch = TRUE; short_read = (flags & TEST_SHORT_READ) != 0; + test_redirect = (flags & TEST_REDIRECT) != 0; } static void test_priority(IInternetProtocol *protocol) @@ -2429,6 +2441,8 @@ static void test_http_protocol_url(LPCWSTR url, int prot, DWORD flags) SET_EXPECT(ReportProgress_FINDINGRESOURCE); SET_EXPECT(ReportProgress_CONNECTING); SET_EXPECT(ReportProgress_SENDINGREQUEST); + if(test_redirect) + SET_EXPECT(ReportProgress_REDIRECTING); SET_EXPECT(ReportProgress_PROXYDETECTING); if(prot == HTTP_TEST) SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE); @@ -2516,6 +2530,9 @@ static void test_http_protocol(void) {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.', 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/', 'p','o','s','t','t','e','s','t','.','p','h','p',0}; + static const WCHAR redirect_url[] = + {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/', + 't','e','s','t','r','e','d','i','r','e','c','t',0}; trace("Testing http protocol (not from urlmon)...\n"); bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA; @@ -2538,6 +2555,10 @@ static void test_http_protocol(void) trace("Testing http protocol (direct read)...\n"); bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON; test_http_protocol_url(winehq_url, HTTP_TEST, TEST_DIRECT_READ); + + trace("Testing http protocol (redirected)...\n"); + bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON; + test_http_protocol_url(redirect_url, HTTP_TEST, TEST_REDIRECT); } static void test_https_protocol(void) diff --git a/rostests/winetests/urlmon/sec_mgr.c b/rostests/winetests/urlmon/sec_mgr.c index 62471cf8de5..e4416981dac 100644 --- a/rostests/winetests/urlmon/sec_mgr.c +++ b/rostests/winetests/urlmon/sec_mgr.c @@ -91,6 +91,15 @@ static struct secmgr_test { {url7, 3, S_OK, sizeof(secid7), secid7, S_OK} }; +static int strcmp_w(const WCHAR *str1, const WCHAR *str2) +{ + DWORD len1 = lstrlenW(str1); + DWORD len2 = lstrlenW(str2); + + if(len1!=len2) return 1; + return memcmp(str1, str2, len1*sizeof(WCHAR)); +} + static void test_SecurityManager(void) { int i; @@ -605,11 +614,69 @@ static void test_GetZoneAttributes(void) ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr); } +static void test_InternetSecurityMarshalling(void) +{ + IInternetSecurityManager *secmgr = NULL; + IUnknown *unk; + IStream *stream; + HRESULT hres; + + hres = CoInternetCreateSecurityManager(NULL, &secmgr, 0); + if(FAILED(hres)) + return; + + hres = IInternetSecurityManager_QueryInterface(secmgr, &IID_IUnknown, (void**)&unk); + ok(hres == S_OK, "QueryInterface returned: %08x\n", hres); + + hres = CreateStreamOnHGlobal(NULL, TRUE, &stream); + ok(hres == S_OK, "CreateStreamOnHGlobal returned: %08x\n", hres); + + hres = CoMarshalInterface(stream, &IID_IInternetSecurityManager, unk, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL); + ok(hres == S_OK, "CoMarshalInterface returned: %08x\n", hres); + + IStream_Release(stream); + IUnknown_Release(unk); + IInternetSecurityManager_Release(secmgr); +} + +static void test_InternetGetSecurityUrl(void) +{ + const WCHAR url5_out[] = {'h','t','t','p',':','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}; + const WCHAR url7_out[] = {'f','t','p',':','w','i','n','e','h','q','.','o','r','g',0}; + + const WCHAR *in[] = {url2, url3, url4, url5, url7, url8, url9, url10}; + const WCHAR *out_default[] = {url2, url3, url4, url5_out, url7_out, url8, url5_out, url10}; + const WCHAR *out_securl[] = {url2, url3, url4, url5, url7, url8, url9, url10}; + + WCHAR *sec; + DWORD i; + HRESULT hres; + + for(i=0; i Date: Fri, 5 Mar 2010 18:49:06 +0000 Subject: [PATCH 114/211] [RICHED20_WINETEST] sync riched20_winetest to wine 1.1.39 svn path=/trunk/; revision=45886 --- rostests/winetests/riched20/editor.c | 523 ++++++++++++++++++++++----- rostests/winetests/riched20/txtsrv.c | 27 ++ 2 files changed, 468 insertions(+), 82 deletions(-) diff --git a/rostests/winetests/riched20/editor.c b/rostests/winetests/riched20/editor.c index 0383d1487bf..8aa1c3930b2 100644 --- a/rostests/winetests/riched20/editor.c +++ b/rostests/winetests/riched20/editor.c @@ -33,6 +33,8 @@ #include #include +#define ID_RICHEDITTESTDBUTTON 0x123 + static CHAR string1[MAX_PATH], string2[MAX_PATH], string3[MAX_PATH]; #define ok_w3(format, szString1, szString2, szString3) \ @@ -291,8 +293,7 @@ static void test_EM_FINDTEXT(void) /* Setting a format on an arbitrary range should have no effect in search results. This tests correct offset reporting across runs. */ cf2.cbSize = sizeof(CHARFORMAT2); - SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT, - (LPARAM) &cf2); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2); cf2.dwMask = CFM_ITALIC | cf2.dwMask; cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects; SendMessage(hwndRichEdit, EM_SETSEL, 6, 20); @@ -743,7 +744,7 @@ static void test_EM_SETCHARFORMAT(void) (LPARAM) &cf2); ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); rc = SendMessage(hwndRichEdit, EM_CANUNDO, 0, 0); - todo_wine ok(rc == TRUE, "Should not be able to undo here.\n"); + ok(rc == TRUE, "Should not be able to undo here.\n"); SendMessage(hwndRichEdit, EM_EMPTYUNDOBUFFER, 0, 0); cf2.cbSize = sizeof(CHARFORMAT2); @@ -1238,31 +1239,30 @@ static void test_TM_PLAINTEXT(void) cr.cpMax = 20; SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr); cf2.cbSize = sizeof(CHARFORMAT2); - SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT, - (LPARAM) &cf2); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2); cf2.dwMask = CFM_BOLD | cf2.dwMask; cf2.dwEffects = CFE_BOLD ^ cf2.dwEffects; - rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM) &cf2); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok(rc == 0, "EM_SETCHARFORMAT returned %d instead of 0\n", rc); - rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_WORD | SCF_SELECTION, (LPARAM) &cf2); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_WORD | SCF_SELECTION, (LPARAM)&cf2); ok(rc == 0, "EM_SETCHARFORMAT returned %d instead of 0\n", rc); - rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM)&cf2); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); /*Get the formatting of those characters*/ - SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM) &cf2); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); /*Get the formatting of some other characters*/ cf2test.cbSize = sizeof(CHARFORMAT2); cr.cpMin = 21; cr.cpMax = 30; SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr); - SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM) &cf2test); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2test); /*Test that they are the same as plain text allows only one formatting*/ @@ -1284,14 +1284,14 @@ static void test_TM_PLAINTEXT(void) /*Swap back to rich text*/ SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) ""); - SendMessage(hwndRichEdit, EM_SETTEXTMODE, (WPARAM) TM_RICHTEXT, 0); + SendMessage(hwndRichEdit, EM_SETTEXTMODE, TM_RICHTEXT, 0); /*Set the default formatting to bold italics*/ - SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT, (LPARAM) &cf2); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2); cf2.dwMask |= CFM_ITALIC; cf2.dwEffects ^= CFE_ITALIC; - rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); /*Set the text in the control to "wine", which will be bold and italicized*/ @@ -1308,14 +1308,14 @@ static void test_TM_PLAINTEXT(void) cr.cpMin = 1; cr.cpMax = 3; SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr); - SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM) &cf2); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); /*Select the second "wine" string and retrieve its formatting*/ cr.cpMin = 5; cr.cpMax = 7; SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr); - SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM) &cf2test); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2test); /*Compare the two formattings. They should be the same.*/ @@ -3282,10 +3282,15 @@ static void test_WM_SETTEXT(void) const char * TestItem7 = "TestSomeText\r\n\r\r\n\rTestSomeText"; const char * TestItem7_after = "TestSomeText\r\n \r\nTestSomeText"; + const char rtftextA[] = "{\\rtf sometext}"; + const char urtftextA[] = "{\\urtf sometext}"; + const WCHAR rtftextW[] = {'{','\\','r','t','f',' ','s','o','m','e','t','e','x','t','}',0}; + const WCHAR urtftextW[] = {'{','\\','u','r','t','f',' ','s','o','m','e','t','e','x','t','}',0}; + const WCHAR sometextW[] = {'s','o','m','e','t','e','x','t',0}; + char buf[1024] = {0}; + WCHAR bufW[1024] = {0}; LRESULT result; - EDITSTREAM es; - char * p; /* This test attempts to show that WM_SETTEXT on a riched20 control causes any solitary \r to be converted to \r\n on return. Properly paired @@ -3302,7 +3307,7 @@ static void test_WM_SETTEXT(void) result, lstrlen(buf)); \ result = strcmp(b, buf); \ ok(result == 0, \ - "WM_SETTEXT round trip: strcmp = %ld\n", result); + "WM_SETTEXT round trip: strcmp = %ld, text=\"%s\"\n", result, buf); TEST_SETTEXT(TestItem1, TestItem1) TEST_SETTEXT(TestItem2, TestItem2_after) @@ -3313,20 +3318,39 @@ static void test_WM_SETTEXT(void) TEST_SETTEXT(TestItem6, TestItem6_after) TEST_SETTEXT(TestItem7, TestItem7_after) - /* The following test demonstrates that WM_SETTEXT supports RTF strings */ - SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) TestItem1); - p = buf; - es.dwCookie = (DWORD_PTR)&p; - es.dwError = 0; - es.pfnCallback = test_WM_SETTEXT_esCallback; - memset(buf, 0, sizeof(buf)); - SendMessage(hwndRichEdit, EM_STREAMOUT, - (WPARAM)(SF_RTF), (LPARAM)&es); - trace("EM_STREAMOUT produced:\n%s\n", buf); - TEST_SETTEXT(buf, TestItem1) - -#undef TEST_SETTEXT + /* The following tests demonstrate that WM_SETTEXT supports RTF strings */ + TEST_SETTEXT(rtftextA, "sometext") /* interpreted as ascii rtf */ + TEST_SETTEXT(urtftextA, "sometext") /* interpreted as ascii rtf */ + TEST_SETTEXT(rtftextW, "{") /* interpreted as ascii text */ + TEST_SETTEXT(urtftextW, "{") /* interpreted as ascii text */ DestroyWindow(hwndRichEdit); +#undef TEST_SETTEXT + +#define TEST_SETTEXTW(a, b) \ + result = SendMessageW(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) a); \ + ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result); \ + result = SendMessageW(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) bufW); \ + ok (result == lstrlenW(bufW), \ + "WM_GETTEXT returned %ld instead of expected %u\n", \ + result, lstrlenW(bufW)); \ + result = lstrcmpW(b, bufW); \ + ok(result == 0, "WM_SETTEXT round trip: strcmp = %ld\n", result); + + if (is_win9x) + { + skip("Cannot perform unicode tests\n"); + return; + } +hwndRichEdit = CreateWindowW(RICHEDIT_CLASS20W, NULL, + ES_MULTILINE|WS_POPUP|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE, + 0, 0, 200, 60, NULL, NULL, hmoduleRichEdit, NULL); + ok(hwndRichEdit != NULL, "class: RichEdit20W, error: %d\n", (int) GetLastError()); + TEST_SETTEXTW(rtftextA, sometextW) /* interpreted as ascii rtf */ + TEST_SETTEXTW(urtftextA, sometextW) /* interpreted as ascii rtf */ + TEST_SETTEXTW(rtftextW, rtftextW) /* interpreted as ascii text */ + TEST_SETTEXTW(urtftextW, urtftextW) /* interpreted as ascii text */ + DestroyWindow(hwndRichEdit); +#undef TEST_SETTEXTW } static void test_EM_STREAMOUT(void) @@ -3347,8 +3371,7 @@ static void test_EM_STREAMOUT(void) es.dwError = 0; es.pfnCallback = test_WM_SETTEXT_esCallback; memset(buf, 0, sizeof(buf)); - SendMessage(hwndRichEdit, EM_STREAMOUT, - (WPARAM)(SF_TEXT), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es); r = strlen(buf); ok(r == 12, "streamed text length is %d, expecting 12\n", r); ok(strcmp(buf, TestItem1) == 0, @@ -3360,8 +3383,7 @@ static void test_EM_STREAMOUT(void) es.dwError = 0; es.pfnCallback = test_WM_SETTEXT_esCallback; memset(buf, 0, sizeof(buf)); - SendMessage(hwndRichEdit, EM_STREAMOUT, - (WPARAM)(SF_TEXT), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es); r = strlen(buf); /* Here again, \r gets converted to \r\n, like WM_GETTEXT */ ok(r == 14, "streamed text length is %d, expecting 14\n", r); @@ -3373,8 +3395,7 @@ static void test_EM_STREAMOUT(void) es.dwError = 0; es.pfnCallback = test_WM_SETTEXT_esCallback; memset(buf, 0, sizeof(buf)); - SendMessage(hwndRichEdit, EM_STREAMOUT, - (WPARAM)(SF_TEXT), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es); r = strlen(buf); ok(r == 14, "streamed text length is %d, expecting 14\n", r); ok(strcmp(buf, TestItem3) == 0, @@ -3403,8 +3424,7 @@ static void test_EM_STREAMOUT_FONTTBL(void) es.dwError = 0; es.pfnCallback = test_WM_SETTEXT_esCallback; memset(buf, 0, sizeof(buf)); - SendMessage(hwndRichEdit, EM_STREAMOUT, - (WPARAM)(SF_RTF), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es); /* scans for \fonttbl, error if not found */ fontTbl = strstr(buf, "\\fonttbl"); @@ -4228,12 +4248,11 @@ static void test_EM_GETMODIFY(void) /* set char format */ SendMessage(hwndRichEdit, EM_SETMODIFY, FALSE, 0); cf2.cbSize = sizeof(CHARFORMAT2); - SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT, - (LPARAM) &cf2); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2); cf2.dwMask = CFM_ITALIC | cf2.dwMask; cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects; - SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2); - result = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2); + SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); + result = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); ok(result == 1, "EM_SETCHARFORMAT returned %ld instead of 1\n", result); result = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); ok (result != 0, @@ -4256,8 +4275,7 @@ static void test_EM_GETMODIFY(void) es.dwCookie = (DWORD_PTR)&streamText; es.dwError = 0; es.pfnCallback = test_EM_GETMODIFY_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_TEXT), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); result = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); ok (result != 0, "EM_GETMODIFY returned zero, instead of non-zero for EM_STREAM\n"); @@ -4996,8 +5014,7 @@ static void test_EM_STREAMIN(void) es.dwCookie = (DWORD_PTR)&streamText0; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_RTF), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 12, @@ -5011,8 +5028,7 @@ static void test_EM_STREAMIN(void) es.dwCookie = (DWORD_PTR)&streamText0a; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_RTF), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 12, @@ -5026,8 +5042,7 @@ static void test_EM_STREAMIN(void) es.dwCookie = (DWORD_PTR)&streamText0b; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_RTF), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 14, @@ -5040,8 +5055,7 @@ static void test_EM_STREAMIN(void) es.dwCookie = (DWORD_PTR)&streamText1; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_RTF), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 12, @@ -5053,8 +5067,7 @@ static void test_EM_STREAMIN(void) es.dwCookie = (DWORD_PTR)&streamText2; es.dwError = 0; - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_RTF), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 0, @@ -5065,8 +5078,7 @@ static void test_EM_STREAMIN(void) es.dwCookie = (DWORD_PTR)&streamText3; es.dwError = 0; - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_RTF), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 0, @@ -5078,8 +5090,7 @@ static void test_EM_STREAMIN(void) es.dwCookie = (DWORD_PTR)&cookieForStream4; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback2; - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_TEXT), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == length4, @@ -5117,7 +5128,7 @@ static void test_EM_StreamIn_Undo(void) SendMessage(hwndRichEdit,EM_EMPTYUNDOBUFFER, 0,0); SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) randomtext); SendMessage(hwndRichEdit, EM_SETSEL,0,0); - SendMessage(hwndRichEdit, EM_STREAMIN, (WPARAM)SF_TEXT, (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); result = strcmp (buffer,"test"); ok (result == 0, @@ -5132,8 +5143,7 @@ static void test_EM_StreamIn_Undo(void) SendMessage(hwndRichEdit,EM_EMPTYUNDOBUFFER, 0,0); SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) randomtext); SendMessage(hwndRichEdit, EM_SETSEL,0,0); - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_TEXT|SFF_SELECTION), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_TEXT|SFF_SELECTION, (LPARAM)&es); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); result = strcmp (buffer,"testSome text"); ok (result == 0, @@ -5149,8 +5159,7 @@ static void test_EM_StreamIn_Undo(void) SendMessage(hwndRichEdit,EM_EMPTYUNDOBUFFER, 0,0); SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) randomtext); SendMessage(hwndRichEdit, EM_SETSEL,4,5); - SendMessage(hwndRichEdit, EM_STREAMIN, - (WPARAM)(SF_TEXT|SFF_SELECTION), (LPARAM)&es); + SendMessage(hwndRichEdit, EM_STREAMIN, SF_TEXT|SFF_SELECTION, (LPARAM)&es); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); result = strcmp (buffer,"Sometesttext"); ok (result == 0, @@ -5258,13 +5267,13 @@ static void test_unicode_conversions(void) expect_empty(hwnd, WM_GETTEXT); expect_empty(hwnd, EM_GETTEXTEX); - ret = SendMessageA(hwnd, WM_CHAR, (WPARAM)textW[0], 0); + ret = SendMessageA(hwnd, WM_CHAR, textW[0], 0); ok(!ret, "SendMessageA(WM_CHAR) should return 0, got %d\n", ret); expect_textA(hwnd, WM_GETTEXT, "t"); expect_textA(hwnd, EM_GETTEXTEX, "t"); expect_textW(hwnd, EM_GETTEXTEX, tW); - ret = SendMessageA(hwnd, WM_CHAR, (WPARAM)textA[1], 0); + ret = SendMessageA(hwnd, WM_CHAR, textA[1], 0); ok(!ret, "SendMessageA(WM_CHAR) should return 0, got %d\n", ret); expect_textA(hwnd, WM_GETTEXT, "te"); expect_textA(hwnd, EM_GETTEXTEX, "te"); @@ -5564,7 +5573,7 @@ static void test_eventMask(void) ok(eventMaskEditHwnd != 0, "Failed to create edit window\n"); eventMask = ENM_CHANGE | ENM_UPDATE; - ret = SendMessage(eventMaskEditHwnd, EM_SETEVENTMASK, 0, (LPARAM) eventMask); + ret = SendMessage(eventMaskEditHwnd, EM_SETEVENTMASK, 0, eventMask); ok(ret == ENM_NONE, "wrong event mask\n"); ret = SendMessage(eventMaskEditHwnd, EM_GETEVENTMASK, 0, 0); ok(ret == eventMask, "failed to set event mask\n"); @@ -5615,6 +5624,7 @@ static void test_eventMask(void) static int received_WM_NOTIFY = 0; static int modify_at_WM_NOTIFY = 0; +static BOOL filter_on_WM_NOTIFY = FALSE; static HWND hwndRichedit_WM_NOTIFY; static LRESULT WINAPI WM_NOTIFY_ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -5623,6 +5633,7 @@ static LRESULT WINAPI WM_NOTIFY_ParentMsgCheckProcA(HWND hwnd, UINT message, WPA { received_WM_NOTIFY = 1; modify_at_WM_NOTIFY = SendMessage(hwndRichedit_WM_NOTIFY, EM_GETMODIFY, 0, 0); + if (filter_on_WM_NOTIFY) return TRUE; } return DefWindowProcA(hwnd, message, wParam, lParam); } @@ -5632,6 +5643,7 @@ static void test_WM_NOTIFY(void) HWND parent; WNDCLASSA cls; CHARFORMAT2 cf2; + int sel_start, sel_end; /* register class to capture WM_NOTIFY */ cls.style = 0; @@ -5660,8 +5672,7 @@ static void test_WM_NOTIFY(void) ME_CommitUndo, which should check whether message should be sent */ received_WM_NOTIFY = 0; cf2.cbSize = sizeof(CHARFORMAT2); - SendMessage(hwndRichedit_WM_NOTIFY, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT, - (LPARAM) &cf2); + SendMessage(hwndRichedit_WM_NOTIFY, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2); cf2.dwMask = CFM_ITALIC | cf2.dwMask; cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects; SendMessage(hwndRichedit_WM_NOTIFY, EM_SETCHARFORMAT, 0, (LPARAM) &cf2); @@ -5694,6 +5705,29 @@ static void test_WM_NOTIFY(void) ok(received_WM_NOTIFY == 1, "Expected WM_NOTIFY was NOT sent!\n"); SendMessage(hwndRichedit_WM_NOTIFY, WM_SETREDRAW, TRUE, 0); + /* Test filtering key events. */ + SendMessage(hwndRichedit_WM_NOTIFY, EM_SETSEL, 0, 0); + SendMessage(hwndRichedit_WM_NOTIFY, EM_SETEVENTMASK, 0, ENM_KEYEVENTS); + SendMessage(hwndRichedit_WM_NOTIFY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + received_WM_NOTIFY = 0; + SendMessage(hwndRichedit_WM_NOTIFY, WM_KEYDOWN, VK_RIGHT, 0); + SendMessage(hwndRichedit_WM_NOTIFY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == 1 && sel_end == 1, + "selections is incorrectly at (%d,%d)\n", sel_start, sel_end); + filter_on_WM_NOTIFY = TRUE; + received_WM_NOTIFY = 0; + SendMessage(hwndRichedit_WM_NOTIFY, WM_KEYDOWN, VK_RIGHT, 0); + SendMessage(hwndRichedit_WM_NOTIFY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == 1 && sel_end == 1, + "selections is incorrectly at (%d,%d)\n", sel_start, sel_end); + + /* test with owner set to NULL */ + SetWindowLongPtr(hwndRichedit_WM_NOTIFY, GWLP_HWNDPARENT, 0); + SendMessage(hwndRichedit_WM_NOTIFY, WM_KEYDOWN, VK_RIGHT, 0); + SendMessage(hwndRichedit_WM_NOTIFY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == 1 && sel_end == 1, + "selections is incorrectly at (%d,%d)\n", sel_start, sel_end); + DestroyWindow(hwndRichedit_WM_NOTIFY); DestroyWindow(parent); } @@ -5781,7 +5815,7 @@ static void test_undo_coalescing(void) SendMessage(hwnd, EM_EMPTYUNDOBUFFER, 0, 0); result = SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"abcd"); ok(result == TRUE, "Failed to set the text.\n"); - SendMessage(hwnd, EM_SETSEL, (WPARAM)1, (LPARAM)1); + SendMessage(hwnd, EM_SETSEL, 1, 1); SendMessage(hwnd, WM_KEYDOWN, VK_DELETE, 1); SendMessage(hwnd, WM_KEYUP, VK_DELETE, 1); SendMessage(hwnd, WM_KEYDOWN, VK_DELETE, 1); @@ -6540,7 +6574,7 @@ static void test_zoom(void) ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret); /* Test how much the mouse wheel can zoom in and out. */ - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)490, (LPARAM)100); + ret = SendMessage(hwnd, EM_SETZOOM, 490, 100); ok(ret == TRUE, "EM_SETZOOM failed (%d).\n", ret); hold_key(VK_CONTROL); @@ -6554,7 +6588,7 @@ static void test_zoom(void) ok(denominator == 100, "incorrect denominator is %d\n", denominator); ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret); - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)491, (LPARAM)100); + ret = SendMessage(hwnd, EM_SETZOOM, 491, 100); ok(ret == TRUE, "EM_SETZOOM failed (%d).\n", ret); hold_key(VK_CONTROL); @@ -6568,7 +6602,7 @@ static void test_zoom(void) ok(denominator == 100, "incorrect denominator is %d\n", denominator); ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret); - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)20, (LPARAM)100); + ret = SendMessage(hwnd, EM_SETZOOM, 20, 100); ok(ret == TRUE, "EM_SETZOOM failed (%d).\n", ret); hold_key(VK_CONTROL); @@ -6582,7 +6616,7 @@ static void test_zoom(void) ok(denominator == 100, "incorrect denominator is %d\n", denominator); ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret); - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)19, (LPARAM)100); + ret = SendMessage(hwnd, EM_SETZOOM, 19, 100); ok(ret == TRUE, "EM_SETZOOM failed (%d).\n", ret); hold_key(VK_CONTROL); @@ -6597,7 +6631,7 @@ static void test_zoom(void) ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret); /* Test how WM_SCROLLWHEEL treats our custom denominator. */ - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)50, (LPARAM)13); + ret = SendMessage(hwnd, EM_SETZOOM, 50, 13); ok(ret == TRUE, "EM_SETZOOM failed (%d).\n", ret); hold_key(VK_CONTROL); @@ -6612,13 +6646,13 @@ static void test_zoom(void) ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret); /* Test bounds checking on EM_SETZOOM */ - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)2, (LPARAM)127); + ret = SendMessage(hwnd, EM_SETZOOM, 2, 127); ok(ret == TRUE, "EM_SETZOOM rejected valid values (%d).\n", ret); - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)127, (LPARAM)2); + ret = SendMessage(hwnd, EM_SETZOOM, 127, 2); ok(ret == TRUE, "EM_SETZOOM rejected valid values (%d).\n", ret); - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)2, (LPARAM)128); + ret = SendMessage(hwnd, EM_SETZOOM, 2, 128); ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret); ret = SendMessage(hwnd, EM_GETZOOM, (WPARAM)&numerator, (LPARAM)&denominator); @@ -6626,15 +6660,15 @@ static void test_zoom(void) ok(denominator == 2, "incorrect denominator is %d\n", denominator); ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret); - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)128, (LPARAM)2); + ret = SendMessage(hwnd, EM_SETZOOM, 128, 2); ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret); /* See if negative numbers are accepted. */ - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)-100, (LPARAM)-100); + ret = SendMessage(hwnd, EM_SETZOOM, -100, -100); ok(ret == FALSE, "EM_SETZOOM accepted invalid values (%d).\n", ret); /* See if negative numbers are accepted. */ - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)0, (LPARAM)100); + ret = SendMessage(hwnd, EM_SETZOOM, 0, 100); ok(ret == FALSE, "EM_SETZOOM failed (%d).\n", ret); ret = SendMessage(hwnd, EM_GETZOOM, (WPARAM)&numerator, (LPARAM)&denominator); @@ -6643,12 +6677,336 @@ static void test_zoom(void) ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret); /* Reset the zoom value */ - ret = SendMessage(hwnd, EM_SETZOOM, (WPARAM)0, (LPARAM)0); + ret = SendMessage(hwnd, EM_SETZOOM, 0, 0); ok(ret == TRUE, "EM_SETZOOM failed (%d).\n", ret); DestroyWindow(hwnd); } +struct dialog_mode_messages +{ + int wm_getdefid, wm_close, wm_nextdlgctl; +}; + +static struct dialog_mode_messages dm_messages; + +#define test_dm_messages(wmclose, wmgetdefid, wmnextdlgctl) \ + ok(dm_messages.wm_close == wmclose, "expected %d WM_CLOSE message, " \ + "got %d\n", wmclose, dm_messages.wm_close); \ + ok(dm_messages.wm_getdefid == wmgetdefid, "expected %d WM_GETDIFID message, " \ + "got %d\n", wmgetdefid, dm_messages.wm_getdefid);\ + ok(dm_messages.wm_nextdlgctl == wmnextdlgctl, "expected %d WM_NEXTDLGCTL message, " \ + "got %d\n", wmnextdlgctl, dm_messages.wm_nextdlgctl) + +static LRESULT CALLBACK dialog_mode_wnd_proc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) +{ + switch (iMsg) + { + case DM_GETDEFID: + dm_messages.wm_getdefid++; + return MAKELONG(ID_RICHEDITTESTDBUTTON, DC_HASDEFID); + case WM_NEXTDLGCTL: + dm_messages.wm_nextdlgctl++; + break; + case WM_CLOSE: + dm_messages.wm_close++; + break; + } + + return DefWindowProc(hwnd, iMsg, wParam, lParam); +} + +static void test_dialogmode(void) +{ + HWND hwRichEdit, hwParent, hwButton; + MSG msg= {0}; + int lcount, r; + WNDCLASSA cls; + + cls.style = 0; + cls.lpfnWndProc = dialog_mode_wnd_proc; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleA(0); + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = "DialogModeParentClass"; + if(!RegisterClassA(&cls)) assert(0); + + hwParent = CreateWindow("DialogModeParentClass", NULL, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, 200, 120, NULL, NULL, GetModuleHandleA(0), NULL); + + /* Test richedit(ES_MULTILINE) */ + + hwRichEdit = new_window(RICHEDIT_CLASS, ES_MULTILINE, hwParent); + + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(2 == lcount, "expected 2, got %d\n", lcount); + + r = SendMessage(hwRichEdit, WM_GETDLGCODE, 0, 0); + ok(0x8f == r, "expected 0x8f, got 0x%x\n", r); + + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(3 == lcount, "expected 3, got %d\n", lcount); + + r = SendMessage(hwRichEdit, WM_GETDLGCODE, 0, (LPARAM)&msg); + ok(0x8f == r, "expected 0x8f, got 0x%x\n", r); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(3 == lcount, "expected 3, got %d\n", lcount); + + DestroyWindow(hwRichEdit); + + /* Test standalone richedit(ES_MULTILINE) */ + + hwRichEdit = new_window(RICHEDIT_CLASS, ES_MULTILINE, NULL); + + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(2 == lcount, "expected 2, got %d\n", lcount); + + r = SendMessage(hwRichEdit, WM_GETDLGCODE, 0, (LPARAM)&msg); + ok(0x8f == r, "expected 0x8f, got 0x%x\n", r); + + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(2 == lcount, "expected 2, got %d\n", lcount); + + DestroyWindow(hwRichEdit); + + /* Check a destination for messages */ + + hwRichEdit = new_window(RICHEDIT_CLASS, ES_MULTILINE, hwParent); + + SetWindowLong(hwRichEdit, GWL_STYLE, GetWindowLong(hwRichEdit, GWL_STYLE)& ~WS_POPUP); + SetParent( hwRichEdit, NULL); + + r = SendMessage(hwRichEdit, WM_GETDLGCODE, 0, (LPARAM)&msg); + ok(0x8f == r, "expected 0x8f, got 0x%x\n", r); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 1, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_TAB, 0xf0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 1); + + DestroyWindow(hwRichEdit); + + /* Check messages from richedit(ES_MULTILINE) */ + + hwRichEdit = new_window(RICHEDIT_CLASS, ES_MULTILINE, hwParent); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(2 == lcount, "expected 2, got %d\n", lcount); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_ESCAPE, 0x10001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_TAB, 0xf0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_GETDLGCODE, 0, (LPARAM)&msg); + ok(0x8f == r, "expected 0x8f, got 0x%x\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 1, 0); + + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(2 == lcount, "expected 2, got %d\n", lcount); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_ESCAPE, 0x10001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_TAB, 0xf0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 1); + + hwButton = CreateWindow("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, + 100, 100, 50, 20, hwParent, (HMENU)ID_RICHEDITTESTDBUTTON, GetModuleHandleA(0), NULL); + ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError()); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 1, 1); + + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(2 == lcount, "expected 2, got %d\n", lcount); + + DestroyWindow(hwButton); + DestroyWindow(hwRichEdit); + + /* Check messages from richedit(ES_MULTILINE|ES_WANTRETURN) */ + + hwRichEdit = new_window(RICHEDIT_CLASS, ES_MULTILINE|ES_WANTRETURN, hwParent); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(2 == lcount, "expected 2, got %d\n", lcount); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_ESCAPE, 0x10001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_TAB, 0xf0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_GETDLGCODE, 0, (LPARAM)&msg); + ok(0x8f == r, "expected 0x8f, got 0x%x\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(3 == lcount, "expected 3, got %d\n", lcount); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_ESCAPE, 0x10001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_TAB, 0xf0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 1); + + hwButton = CreateWindow("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, + 100, 100, 50, 20, hwParent, (HMENU)ID_RICHEDITTESTDBUTTON, GetModuleHandleA(0), NULL); + ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError()); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + lcount = SendMessage(hwRichEdit, EM_GETLINECOUNT, 0, 0); + ok(4 == lcount, "expected 4, got %d\n", lcount); + + DestroyWindow(hwButton); + DestroyWindow(hwRichEdit); + + /* Check messages from richedit(0) */ + + hwRichEdit = new_window(RICHEDIT_CLASS, 0, hwParent); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_ESCAPE, 0x10001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_TAB, 0xf0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_GETDLGCODE, 0, (LPARAM)&msg); + ok(0x8b == r, "expected 0x8b, got 0x%x\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 1, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_ESCAPE, 0x10001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_TAB, 0xf0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 1); + + hwButton = CreateWindow("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, + 100, 100, 50, 20, hwParent, (HMENU)ID_RICHEDITTESTDBUTTON, GetModuleHandleA(0), NULL); + ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError()); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 1, 1); + + DestroyWindow(hwRichEdit); + + /* Check messages from richedit(ES_WANTRETURN) */ + + hwRichEdit = new_window(RICHEDIT_CLASS, ES_WANTRETURN, hwParent); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_GETDLGCODE, 0, (LPARAM)&msg); + ok(0x8b == r, "expected 0x8b, got 0x%x\n", r); + test_dm_messages(0, 0, 0); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + hwButton = CreateWindow("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, + 100, 100, 50, 20, hwParent, (HMENU)ID_RICHEDITTESTDBUTTON, GetModuleHandleA(0), NULL); + ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError()); + + memset(&dm_messages, 0, sizeof(dm_messages)); + r = SendMessage(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); + ok(0 == r, "expected 0, got %d\n", r); + test_dm_messages(0, 0, 0); + + DestroyWindow(hwRichEdit); + DestroyWindow(hwParent); +} + START_TEST( editor ) { /* Must explicitly LoadLibrary(). The test has no references to functions in @@ -6705,6 +7063,7 @@ START_TEST( editor ) test_format_rect(); test_WM_GETDLGCODE(); test_zoom(); + test_dialogmode(); /* Set the environment variable WINETEST_RICHED20 to keep windows * responsive and open for 30 seconds. This is useful for debugging. diff --git a/rostests/winetests/riched20/txtsrv.c b/rostests/winetests/riched20/txtsrv.c index e4d6ae44822..8da111de2c7 100644 --- a/rostests/winetests/riched20/txtsrv.c +++ b/rostests/winetests/riched20/txtsrv.c @@ -667,6 +667,7 @@ static void test_TxSetText(void) ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0, "String returned differs\n"); + SysFreeString(rettext); IUnknown_Release(txtserv); CoTaskMemFree(dummyTextHost); } @@ -739,6 +740,31 @@ static void test_TxGetNaturalSize(void) { CoTaskMemFree(dummyTextHost); } +static void test_TxDraw(void) +{ + HDC tmphdc = GetDC(NULL); + DWORD dwAspect = DVASPECT_CONTENT; + HDC hicTargetDev = NULL; /* Means "default" device */ + DVTARGETDEVICE *ptd = NULL; + void *pvAspect = NULL; + HRESULT result; + RECTL client = {0,0,100,100}; + + if (!init_texthost()) + return; + + todo_wine { + result = ITextServices_TxDraw(txtserv, dwAspect, 0, pvAspect, ptd, + tmphdc, hicTargetDev, &client, NULL, + NULL, NULL, 0, 0); + ok(result == S_OK, "TxDraw failed\n"); + } + + IUnknown_Release(txtserv); + CoTaskMemFree(dummyTextHost); + +} + START_TEST( txtsrv ) { setup_thiscall_wrappers(); @@ -756,6 +782,7 @@ START_TEST( txtsrv ) test_TxGetText(); test_TxSetText(); test_TxGetNaturalSize(); + test_TxDraw(); } if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); } From 4731484299ca3e07dda68b3054f9bda4b4b2383a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 18:50:02 +0000 Subject: [PATCH 115/211] [RICHED32_WINETEST] sync riched32_winetest to wine 1.1.39 svn path=/trunk/; revision=45887 --- rostests/winetests/riched32/editor.c | 248 +++++++++++++++++---------- 1 file changed, 162 insertions(+), 86 deletions(-) diff --git a/rostests/winetests/riched32/editor.c b/rostests/winetests/riched32/editor.c index 6216001afd1..5cc269d855d 100644 --- a/rostests/winetests/riched32/editor.c +++ b/rostests/winetests/riched32/editor.c @@ -50,25 +50,30 @@ static HWND new_richedit(HWND parent) { static void test_WM_SETTEXT(void) { + static const struct { + const char *itemtext; + DWORD lines; + DWORD lines_broken; + } testitems[] = { + { "TestSomeText", 1}, + { "TestSomeText\r", 1}, + { "TestSomeText\rSomeMoreText\r", 2, 1}, /* NT4 and below */ + { "TestSomeText\n\nTestSomeText", 3}, + { "TestSomeText\r\r\nTestSomeText", 2}, + { "TestSomeText\r\r\n\rTestSomeText", 3, 2}, /* NT4 and below */ + { "TestSomeText\r\n\r\r\n\rTestSomeText", 4, 3}, /* NT4 and below */ + { "TestSomeText\r\n" ,2}, + { "TestSomeText\r\nSomeMoreText\r\n", 3}, + { "TestSomeText\r\n\r\nTestSomeText", 3}, + { "TestSomeText TestSomeText" ,1}, + { "TestSomeText \r\nTestSomeText", 2}, + { "TestSomeText\r\n \r\nTestSomeText", 3}, + { "TestSomeText\n", 2}, + { "TestSomeText\r\r\r", 3, 1}, /* NT4 and below */ + { "TestSomeText\r\r\rSomeMoreText", 4, 2} /* NT4 and below */ + }; HWND hwndRichEdit = new_richedit(NULL); - const char * TestItem1 = "TestSomeText"; - const char * TestItem2 = "TestSomeText\r"; - const char * TestItem3 = "TestSomeText\rSomeMoreText\r"; - const char * TestItem4 = "TestSomeText\n\nTestSomeText"; - const char * TestItem5 = "TestSomeText\r\r\nTestSomeText"; - const char * TestItem6 = "TestSomeText\r\r\n\rTestSomeText"; - const char * TestItem7 = "TestSomeText\r\n\r\r\n\rTestSomeText"; - const char * TestItem8 = "TestSomeText\r\n"; - const char * TestItem9 = "TestSomeText\r\nSomeMoreText\r\n"; - const char * TestItem10 = "TestSomeText\r\n\r\nTestSomeText"; - const char * TestItem11 = "TestSomeText TestSomeText"; - const char * TestItem12 = "TestSomeText \r\nTestSomeText"; - const char * TestItem13 = "TestSomeText\r\n \r\nTestSomeText"; - const char * TestItem14 = "TestSomeText\n"; - const char * TestItem15 = "TestSomeText\r\r\r"; - const char * TestItem16 = "TestSomeText\r\r\rSomeMoreText"; - char buf[1024] = {0}; - LRESULT result; + int i; /* This test attempts to show that WM_SETTEXT on a riched32 control does not * attempt to modify the text that is pasted into the control, and should @@ -85,37 +90,26 @@ static void test_WM_SETTEXT(void) * where \r at the end of the text is a proper line break. */ -#define TEST_SETTEXT(a, b, nlines) \ - result = SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) a); \ - ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result); \ - result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buf); \ - ok (result == lstrlen(buf), \ - "WM_GETTEXT returned %ld instead of expected %u\n", \ - result, lstrlen(buf)); \ - result = strcmp(b, buf); \ - ok(result == 0, \ - "WM_SETTEXT round trip: strcmp = %ld\n", result); \ - result = SendMessage(hwndRichEdit, EM_GETLINECOUNT, 0, 0); \ - ok(result == nlines, "EM_GETLINECOUNT returned %ld, expected %d\n", result, nlines); + for (i = 0; i < sizeof(testitems)/sizeof(testitems[0]); i++) { - TEST_SETTEXT(TestItem1, TestItem1, 1) - TEST_SETTEXT(TestItem2, TestItem2, 1) - TEST_SETTEXT(TestItem3, TestItem3, 2) - TEST_SETTEXT(TestItem4, TestItem4, 3) - TEST_SETTEXT(TestItem5, TestItem5, 2) - TEST_SETTEXT(TestItem6, TestItem6, 3) - TEST_SETTEXT(TestItem7, TestItem7, 4) - TEST_SETTEXT(TestItem8, TestItem8, 2) - TEST_SETTEXT(TestItem9, TestItem9, 3) - TEST_SETTEXT(TestItem10, TestItem10, 3) - TEST_SETTEXT(TestItem11, TestItem11, 1) - TEST_SETTEXT(TestItem12, TestItem12, 2) - TEST_SETTEXT(TestItem13, TestItem13, 3) - TEST_SETTEXT(TestItem14, TestItem14, 2) - TEST_SETTEXT(TestItem15, TestItem15, 3) - TEST_SETTEXT(TestItem16, TestItem16, 4) + char buf[1024] = {0}; + LRESULT result; + + result = SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) testitems[i].itemtext); + ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buf); + ok (result == lstrlen(buf), + "[%d] WM_GETTEXT returned %ld instead of expected %u\n", + i, result, lstrlen(buf)); + result = strcmp(testitems[i].itemtext, buf); + ok (result == 0, + "[%d] WM_SETTEXT round trip: strcmp = %ld\n", i, result); + result = SendMessage(hwndRichEdit, EM_GETLINECOUNT, 0, 0); + ok (result == testitems[i].lines || + broken(testitems[i].lines_broken && result == testitems[i].lines_broken), + "[%d] EM_GETLINECOUNT returned %ld, expected %d\n", i, result, testitems[i].lines); + } -#undef TEST_SETTEXT DestroyWindow(hwndRichEdit); } @@ -354,11 +348,12 @@ static const struct getline_s { int line; size_t buffer_len; const char *text; + const char *broken_text; } gl[] = { - {0, 10, "foo bar\r\n"}, - {1, 10, "\r"}, - {2, 10, "\r\r\n"}, - {3, 10, "bar\n"}, + {0, 10, "foo bar\r\n", "foo bar\r\n"}, + {1, 10, "\r", "\r\r\r\n"}, + {2, 10, "\r\r\n", "bar\n"}, + {3, 10, "bar\n", "\r\n"}, {4, 10, "\r\n"}, /* Buffer smaller than line length */ @@ -373,19 +368,40 @@ static void test_EM_GETLINE(void) HWND hwndRichEdit = new_richedit(NULL); static const int nBuf = 1024; char dest[1024], origdest[1024]; + LRESULT linecount; const char text[] = "foo bar\r\n" "\r" "\r\r\n" "bar\n"; + BOOL broken_os = FALSE; SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text); + linecount = SendMessage(hwndRichEdit, EM_GETLINECOUNT, 0, 0); + if (linecount == 4) + { + broken_os = TRUE; + win_skip("Win9x, WinME and NT4 handle '\\r only' differently\n"); + } memset(origdest, 0xBB, nBuf); for (i = 0; i < sizeof(gl)/sizeof(struct getline_s); i++) { - int nCopied; - int expected_nCopied = min(gl[i].buffer_len, strlen(gl[i].text)); - int expected_bytes_written = min(gl[i].buffer_len, strlen(gl[i].text) + 1); + int nCopied, expected_nCopied, expected_bytes_written; + char gl_text[1024]; + + if (gl[i].line >= linecount) + continue; /* Win9x, WinME and NT4 */ + + if (broken_os && gl[i].broken_text) + /* Win9x, WinME and NT4 */ + strcpy(gl_text, gl[i].broken_text); + else + strcpy(gl_text, gl[i].text); + + expected_nCopied = min(gl[i].buffer_len, strlen(gl_text)); + /* Cater for the fact that Win9x, WinME and NT4 don't append the '\0' */ + expected_bytes_written = min(gl[i].buffer_len, strlen(gl_text) + (broken_os ? 0 : 1)); + memset(dest, 0xBB, nBuf); *(WORD *) dest = gl[i].buffer_len; @@ -399,11 +415,11 @@ static void test_EM_GETLINE(void) ok(!dest[0] && !dest[1] && !strncmp(dest+2, origdest+2, nBuf-2), "buffer_len=0\n"); else if (gl[i].buffer_len == 1) - ok(dest[0] == gl[i].text[0] && !dest[1] && + ok(dest[0] == gl_text[0] && !dest[1] && !strncmp(dest+2, origdest+2, nBuf-2), "buffer_len=1\n"); else { - ok(!strncmp(dest, gl[i].text, expected_bytes_written), + ok(!strncmp(dest, gl_text, expected_bytes_written), "%d: expected_bytes_written=%d\n", i, expected_bytes_written); ok(!strncmp(dest + expected_bytes_written, origdest + expected_bytes_written, nBuf - expected_bytes_written), @@ -656,6 +672,7 @@ static void check_EM_FINDTEXTEX(HWND hwnd, const char *name, struct find_s *f, ft.chrg.cpMin = f->start; ft.chrg.cpMax = f->end; ft.lpstrText = f->needle; + ft.chrgText.cpMax = 0xdeadbeef; findloc = SendMessage(hwnd, EM_FINDTEXTEX, f->flags, (LPARAM) &ft); ok(findloc == f->expected_loc, "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %d\n", @@ -665,7 +682,8 @@ static void check_EM_FINDTEXTEX(HWND hwnd, const char *name, struct find_s *f, name, id, f->needle, f->start, f->end, f->flags, ft.chrgText.cpMin, f->expected_loc); expected_end_loc = ((f->expected_loc == -1) ? -1 : f->expected_loc + strlen(f->needle)); - ok(ft.chrgText.cpMax == expected_end_loc, + ok(ft.chrgText.cpMax == expected_end_loc || + broken(ft.chrgText.cpMin == -1 && ft.chrgText.cpMax == 0xdeadbeef), /* Win9x, WinME and NT4 */ "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, end at %d, expected %d\n", name, id, f->needle, f->start, f->end, f->flags, ft.chrgText.cpMax, expected_end_loc); } @@ -750,7 +768,9 @@ static void test_EM_POSFROMCHAR(void) if (i == 0) { ok(pl.y == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl.y); - ok(pl.x == 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x); + ok(pl.x == 1 || + broken(pl.x == 0), /* Win9x, WinME and NT4 */ + "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x); xpos = pl.x; } else if (i == 1) @@ -811,7 +831,9 @@ static void test_EM_POSFROMCHAR(void) result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 0); ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result); ok(pl.y == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl.y); - ok(pl.x == 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x); + ok(pl.x == 1 || + broken(pl.x == 0), /* Win9x, WinME and NT4 */ + "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x); xpos = pl.x; SendMessage(hwndRichEdit, WM_HSCROLL, SB_LINERIGHT, 0); @@ -820,7 +842,9 @@ static void test_EM_POSFROMCHAR(void) ok(pl.y == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl.y); todo_wine { /* Fails on builtin because horizontal scrollbar is not being shown */ - ok(pl.x < xpos, "EM_POSFROMCHAR reports x=%hd, expected value less than %d\n", pl.x, xpos); + ok(pl.x < xpos || + broken(pl.x == xpos), /* Win9x, WinME and NT4 */ + "EM_POSFROMCHAR reports x=%hd, expected value less than %d\n", pl.x, xpos); } DestroyWindow(hwndRichEdit); } @@ -831,7 +855,7 @@ static void test_word_wrap(void) POINTL point = {0, 60}; /* This point must be below the first line */ const char *text = "Must be long enough to test line wrapping"; DWORD dwCommonStyle = WS_VISIBLE|WS_POPUP|WS_VSCROLL|ES_MULTILINE; - int res, pos, lines; + int res, pos, lines, prevlines, reflines[3]; /* Test the effect of WS_HSCROLL and ES_AUTOHSCROLL styles on wrapping * when specified on window creation and set later. */ @@ -872,11 +896,19 @@ static void test_word_wrap(void) res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text); ok(res, "WM_SETTEXT failed.\n"); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); - ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos); + ok(!pos || + broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ + "pos=%d indicating word wrap when none is expected.\n", pos); + lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); - ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos); + ok(!pos || + broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ + "pos=%d indicating word wrap when none is expected.\n", pos); + lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); DestroyWindow(hwnd); hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, @@ -886,17 +918,29 @@ static void test_word_wrap(void) res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text); ok(res, "WM_SETTEXT failed.\n"); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); - ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos); + ok(!pos || + broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ + "pos=%d indicating word wrap when none is expected.\n", pos); + lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); - ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos); + ok(!pos || + broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ + "pos=%d indicating word wrap when none is expected.\n", pos); + lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); /* Test the effect of EM_SETTARGETDEVICE on word wrap. */ res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 1); ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); - ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos); + ok(!pos || + broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ + "pos=%d indicating word wrap when none is expected.\n", pos); + lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 0); ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res); @@ -904,29 +948,55 @@ static void test_word_wrap(void) ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos); DestroyWindow(hwnd); - /* Test to see if wrapping happens with redraw disabled. */ + /* First lets see if the text would wrap normally (needed for reference) */ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle, - 0, 0, 400, 80, NULL, NULL, hmoduleRichEdit, NULL); + 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "error: %d\n", (int) GetLastError()); ok(IsWindowVisible(hwnd), "Window should be visible.\n"); + res = SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) text); + ok(res, "EM_REPLACESEL failed.\n"); + /* Should have wrapped */ + reflines[0] = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(reflines[0] > 1, "Line was expected to wrap (%d lines).\n", reflines[0]); + /* Resize the window to fit the line */ + MoveWindow(hwnd, 0, 0, 600, 80, TRUE); + /* Text should not be wrapped */ + reflines[1] = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(reflines[1] == 1, "Line wasn't expected to wrap (%d lines).\n", reflines[1]); + /* Resize the window again to make sure the line wraps again */ + MoveWindow(hwnd, 0, 0, 10, 80, TRUE); + reflines[2] = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(reflines[2] > 1, "Line was expected to wrap (%d lines).\n", reflines[2]); + DestroyWindow(hwnd); + + /* Same test with redraw disabled */ + hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle, + 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL); + ok(hwnd != NULL, "error: %d\n", (int) GetLastError()); + ok(IsWindowVisible(hwnd), "Window should be visible.\n"); + /* Redraw is disabled by making the window invisible. */ SendMessage(hwnd, WM_SETREDRAW, FALSE, 0); - /* redraw is disabled by making the window invisible. */ ok(!IsWindowVisible(hwnd), "Window shouldn't be visible.\n"); res = SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) text); ok(res, "EM_REPLACESEL failed.\n"); - MoveWindow(hwnd, 0, 0, 100, 80, TRUE); - SendMessage(hwnd, WM_SETREDRAW, TRUE, 0); - /* Wrapping didn't happen while redraw was disabled. */ + /* Should have wrapped */ + prevlines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); + ok(prevlines == reflines[0], + "Line was expected to wrap (%d lines).\n", prevlines); + /* Resize the window to fit the line, no change to the number of lines */ + MoveWindow(hwnd, 0, 0, 600, 80, TRUE); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); - todo_wine ok(lines == 1, "Line wasn't expected to wrap (lines=%d).\n", lines); - /* There isn't even a rewrap from resizing the window. */ + todo_wine + ok(lines == prevlines || + broken(lines == reflines[1]), /* Win98, WinME and NT4 */ + "Expected no change in the number of lines\n"); + /* Resize the window again to make sure the line wraps again */ + MoveWindow(hwnd, 0, 0, 10, 80, TRUE); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); - todo_wine ok(lines == 1, "Line wasn't expected to wrap (lines=%d).\n", lines); - res = SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) text); - ok(res, "EM_REPLACESEL failed.\n"); - lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); - ok(lines > 1, "Line was expected to wrap (lines=%d).\n", lines); - + todo_wine + ok(lines == prevlines || + broken(lines == reflines[2]), /* Win98, WinME and NT4 */ + "Expected no change in the number of lines\n"); DestroyWindow(hwnd); } @@ -946,7 +1016,8 @@ static void test_EM_GETOPTIONS(void) WS_POPUP|WS_VSCROLL|WS_HSCROLL, 0, 0, 200, 60, NULL, NULL, hmoduleRichEdit, NULL); options = SendMessage(hwnd, EM_GETOPTIONS, 0, 0); - ok(options == ECO_AUTOVSCROLL, + ok(options == ECO_AUTOVSCROLL || + broken(options == 0), /* Win9x, WinME and NT4 */ "Incorrect initial options %x\n", options); DestroyWindow(hwnd); } @@ -961,19 +1032,24 @@ static void test_autoscroll(void) hwnd = CreateWindowEx(0, RICHEDIT_CLASS10A, NULL, WS_POPUP|ES_MULTILINE|WS_VSCROLL|WS_HSCROLL, 0, 0, 200, 60, NULL, NULL, hmoduleRichEdit, NULL); - ok(hwnd != NULL, "class: %s, error: %d\n", RICHEDIT_CLASS, (int) GetLastError()); + ok(hwnd != NULL, "class: %s, error: %d\n", RICHEDIT_CLASS10A, (int) GetLastError()); ret = SendMessage(hwnd, EM_GETOPTIONS, 0, 0); - ok(ret & ECO_AUTOVSCROLL, "ECO_AUTOVSCROLL isn't set.\n"); + ok(ret & ECO_AUTOVSCROLL || + broken(!(ret & ECO_AUTOVSCROLL)), /* Win9x, WinME and NT4 */ + "ECO_AUTOVSCROLL isn't set.\n"); ok(!(ret & ECO_AUTOHSCROLL), "ECO_AUTOHSCROLL is set.\n"); ret = GetWindowLong(hwnd, GWL_STYLE); - todo_wine ok(ret & ES_AUTOVSCROLL, "ES_AUTOVSCROLL isn't set.\n"); + todo_wine + ok(ret & ES_AUTOVSCROLL || + broken(!(ret & ES_AUTOVSCROLL)), /* Win9x, WinMe and NT4 */ + "ES_AUTOVSCROLL isn't set.\n"); ok(!(ret & ES_AUTOHSCROLL), "ES_AUTOHSCROLL is set.\n"); DestroyWindow(hwnd); - hwnd = CreateWindowEx(0, RICHEDIT_CLASS, NULL, + hwnd = CreateWindowEx(0, RICHEDIT_CLASS10A, NULL, WS_POPUP|ES_MULTILINE, 0, 0, 200, 60, NULL, NULL, hmoduleRichEdit, NULL); - ok(hwnd != NULL, "class: %s, error: %d\n", RICHEDIT_CLASS, (int) GetLastError()); + ok(hwnd != NULL, "class: %s, error: %d\n", RICHEDIT_CLASS10A, (int) GetLastError()); ret = SendMessage(hwnd, EM_GETOPTIONS, 0, 0); ok(!(ret & ECO_AUTOVSCROLL), "ECO_AUTOVSCROLL is set.\n"); ok(!(ret & ECO_AUTOHSCROLL), "ECO_AUTOHSCROLL is set.\n"); From 6063b53ab2560ced52e4dc376373296e360b6fc0 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 5 Mar 2010 19:01:21 +0000 Subject: [PATCH 116/211] [KERNEL32_WINETEST] sync kernel32_winetest to wine 1.1.39 svn path=/trunk/; revision=45889 --- rostests/winetests/kernel32/actctx.c | 348 ++-- rostests/winetests/kernel32/alloc.c | 12 +- rostests/winetests/kernel32/atom.c | 20 +- rostests/winetests/kernel32/console.c | 67 +- rostests/winetests/kernel32/debugger.c | 5 +- rostests/winetests/kernel32/fiber.c | 197 ++ rostests/winetests/kernel32/file.c | 61 +- rostests/winetests/kernel32/generated.c | 2080 +++++++++++++++++++ rostests/winetests/kernel32/heap.c | 339 ++- rostests/winetests/kernel32/kernel32.rbuild | 1 + rostests/winetests/kernel32/module.c | 18 + rostests/winetests/kernel32/path.c | 163 +- rostests/winetests/kernel32/process.c | 2 +- rostests/winetests/kernel32/resource.c | 2 +- rostests/winetests/kernel32/testlist.c | 2 + rostests/winetests/kernel32/thread.c | 181 +- rostests/winetests/kernel32/timer.c | 2 +- rostests/winetests/kernel32/virtual.c | 73 +- rostests/winetests/kernel32/volume.c | 2 +- 19 files changed, 3276 insertions(+), 299 deletions(-) create mode 100644 rostests/winetests/kernel32/fiber.c create mode 100644 rostests/winetests/kernel32/generated.c diff --git a/rostests/winetests/kernel32/actctx.c b/rostests/winetests/kernel32/actctx.c index 8f51dfb1d96..a158cf30cae 100644 --- a/rostests/winetests/kernel32/actctx.c +++ b/rostests/winetests/kernel32/actctx.c @@ -278,7 +278,7 @@ static const detailed_info_t detailed_info2 = { work_dir, }; -static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo) +static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo, int line) { ACTIVATION_CONTEXT_DETAILED_INFORMATION detailed_info_tmp, *detailed_info; SIZE_T size, exsize, retsize; @@ -293,9 +293,9 @@ static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo) b = pQueryActCtxW(0, handle, NULL, ActivationContextDetailedInformation, &detailed_info_tmp, sizeof(detailed_info_tmp), &size); - ok(!b, "QueryActCtx succeeded\n"); - ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); - ok(size == exsize, "size=%ld, expected %ld\n", size, exsize); + ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n"); + ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); + ok_(__FILE__, line)(size == exsize, "size=%ld, expected %ld\n", size, exsize); }else { size = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION); } @@ -305,53 +305,53 @@ static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo) b = pQueryActCtxW(0, handle, NULL, ActivationContextDetailedInformation, detailed_info, size, &retsize); - ok(b, "QueryActCtx failed: %u\n", GetLastError()); - ok(retsize == exsize, "size=%ld, expected %ld\n", retsize, exsize); + ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError()); + ok_(__FILE__, line)(retsize == exsize, "size=%ld, expected %ld\n", retsize, exsize); - ok(detailed_info->dwFlags == 0, "detailed_info->dwFlags=%x\n", detailed_info->dwFlags); - ok(detailed_info->ulFormatVersion == exinfo->format_version, + ok_(__FILE__, line)(detailed_info->dwFlags == 0, "detailed_info->dwFlags=%x\n", detailed_info->dwFlags); + ok_(__FILE__, line)(detailed_info->ulFormatVersion == exinfo->format_version, "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info->ulFormatVersion, exinfo->format_version); - ok(exinfo->assembly_cnt_min <= detailed_info->ulAssemblyCount && + ok_(__FILE__, line)(exinfo->assembly_cnt_min <= detailed_info->ulAssemblyCount && detailed_info->ulAssemblyCount <= exinfo->assembly_cnt_max, "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info->ulAssemblyCount, exinfo->assembly_cnt_min, exinfo->assembly_cnt_max); - ok(detailed_info->ulRootManifestPathType == exinfo->root_manifest_type, + ok_(__FILE__, line)(detailed_info->ulRootManifestPathType == exinfo->root_manifest_type, "detailed_info->ulRootManifestPathType=%u, expected %u\n", detailed_info->ulRootManifestPathType, exinfo->root_manifest_type); - ok(detailed_info->ulRootManifestPathChars == + ok_(__FILE__, line)(detailed_info->ulRootManifestPathChars == (exinfo->root_manifest_path ? lstrlenW(exinfo->root_manifest_path) : 0), "detailed_info->ulRootManifestPathChars=%u, expected %u\n", detailed_info->ulRootManifestPathChars, exinfo->root_manifest_path ?lstrlenW(exinfo->root_manifest_path) : 0); - ok(detailed_info->ulRootConfigurationPathType == exinfo->root_config_type, + ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathType == exinfo->root_config_type, "detailed_info->ulRootConfigurationPathType=%u, expected %u\n", detailed_info->ulRootConfigurationPathType, exinfo->root_config_type); - ok(detailed_info->ulRootConfigurationPathChars == 0, + ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathChars == 0, "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info->ulRootConfigurationPathChars); - ok(detailed_info->ulAppDirPathType == exinfo->app_dir_type, + ok_(__FILE__, line)(detailed_info->ulAppDirPathType == exinfo->app_dir_type, "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info->ulAppDirPathType, exinfo->app_dir_type); - ok(detailed_info->ulAppDirPathChars == (exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0), + ok_(__FILE__, line)(detailed_info->ulAppDirPathChars == (exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0), "detailed_info->ulAppDirPathChars=%u, expected %u\n", detailed_info->ulAppDirPathChars, exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0); if(exinfo->root_manifest_path) { - ok(detailed_info->lpRootManifestPath != NULL, "detailed_info->lpRootManifestPath == NULL\n"); + ok_(__FILE__, line)(detailed_info->lpRootManifestPath != NULL, "detailed_info->lpRootManifestPath == NULL\n"); if(detailed_info->lpRootManifestPath) - ok(!lstrcmpiW(detailed_info->lpRootManifestPath, exinfo->root_manifest_path), + ok_(__FILE__, line)(!lstrcmpiW(detailed_info->lpRootManifestPath, exinfo->root_manifest_path), "unexpected detailed_info->lpRootManifestPath\n"); }else { - ok(detailed_info->lpRootManifestPath == NULL, "detailed_info->lpRootManifestPath != NULL\n"); + ok_(__FILE__, line)(detailed_info->lpRootManifestPath == NULL, "detailed_info->lpRootManifestPath != NULL\n"); } - ok(detailed_info->lpRootConfigurationPath == NULL, + ok_(__FILE__, line)(detailed_info->lpRootConfigurationPath == NULL, "detailed_info->lpRootConfigurationPath=%p\n", detailed_info->lpRootConfigurationPath); if(exinfo->app_dir) { - ok(detailed_info->lpAppDirPath != NULL, "detailed_info->lpAppDirPath == NULL\n"); + ok_(__FILE__, line)(detailed_info->lpAppDirPath != NULL, "detailed_info->lpAppDirPath == NULL\n"); if(detailed_info->lpAppDirPath) - ok(!lstrcmpiW(exinfo->app_dir, detailed_info->lpAppDirPath), + ok_(__FILE__, line)(!lstrcmpiW(exinfo->app_dir, detailed_info->lpAppDirPath), "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info->lpAppDirPath)); }else { - ok(detailed_info->lpAppDirPath == NULL, "detailed_info->lpAppDirPath != NULL\n"); + ok_(__FILE__, line)(detailed_info->lpAppDirPath == NULL, "detailed_info->lpAppDirPath != NULL\n"); } HeapFree(GetProcessHeap(), 0, detailed_info); @@ -419,7 +419,7 @@ static const info_in_assembly manifest_comctrl_info = { 0, NULL, NULL, TRUE /* These values may differ between Windows installations */ }; -static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembly *exinfo) +static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembly *exinfo, int line) { ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info, info_tmp; SIZE_T size, exsize; @@ -434,10 +434,10 @@ static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembl b = pQueryActCtxW(0, handle, &id, AssemblyDetailedInformationInActivationContext, &info_tmp, sizeof(info_tmp), &size); - ok(!b, "QueryActCtx succeeded\n"); - ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); + ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n"); + ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); - ok(size >= exsize, "size=%lu, expected %lu\n", size, exsize); + ok_(__FILE__, line)(size >= exsize, "size=%lu, expected %lu\n", size, exsize); if (size == 0xdeadbeef) { @@ -451,88 +451,88 @@ static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembl size = 0xdeadbeef; b = pQueryActCtxW(0, handle, &id, AssemblyDetailedInformationInActivationContext, info, size, &size); - ok(b, "QueryActCtx failed: %u\n", GetLastError()); + ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError()); if (!exinfo->manifest_path) exsize += info->ulManifestPathLength + sizeof(WCHAR); if (!exinfo->encoded_assembly_id) exsize += info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR); if (exinfo->has_assembly_dir) exsize += info->ulAssemblyDirectoryNameLength + sizeof(WCHAR); - ok(size == exsize, "size=%lu, expected %lu\n", size, exsize); + ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize); if (0) /* FIXME: flags meaning unknown */ { - ok((info->ulFlags) == exinfo->flags, "info->ulFlags = %x, expected %x\n", + ok_(__FILE__, line)((info->ulFlags) == exinfo->flags, "info->ulFlags = %x, expected %x\n", info->ulFlags, exinfo->flags); } if(exinfo->encoded_assembly_id) { len = strlen_aw(exinfo->encoded_assembly_id)*sizeof(WCHAR); - ok(info->ulEncodedAssemblyIdentityLength == len, + ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength == len, "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n", info->ulEncodedAssemblyIdentityLength, len); } else { - ok(info->ulEncodedAssemblyIdentityLength != 0, + ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength != 0, "info->ulEncodedAssemblyIdentityLength == 0\n"); } - ok(info->ulManifestPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, + ok_(__FILE__, line)(info->ulManifestPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, "info->ulManifestPathType = %x\n", info->ulManifestPathType); if(exinfo->manifest_path) { len = lstrlenW(exinfo->manifest_path)*sizeof(WCHAR); - ok(info->ulManifestPathLength == len, "info->ulManifestPathLength = %u, expected %u\n", + ok_(__FILE__, line)(info->ulManifestPathLength == len, "info->ulManifestPathLength = %u, expected %u\n", info->ulManifestPathLength, len); } else { - ok(info->ulManifestPathLength != 0, "info->ulManifestPathLength == 0\n"); + ok_(__FILE__, line)(info->ulManifestPathLength != 0, "info->ulManifestPathLength == 0\n"); } - ok(info->ulPolicyPathType == ACTIVATION_CONTEXT_PATH_TYPE_NONE, + ok_(__FILE__, line)(info->ulPolicyPathType == ACTIVATION_CONTEXT_PATH_TYPE_NONE, "info->ulPolicyPathType = %x\n", info->ulPolicyPathType); - ok(info->ulPolicyPathLength == 0, + ok_(__FILE__, line)(info->ulPolicyPathLength == 0, "info->ulPolicyPathLength = %u, expected 0\n", info->ulPolicyPathLength); - ok(info->ulMetadataSatelliteRosterIndex == 0, "info->ulMetadataSatelliteRosterIndex = %x\n", + ok_(__FILE__, line)(info->ulMetadataSatelliteRosterIndex == 0, "info->ulMetadataSatelliteRosterIndex = %x\n", info->ulMetadataSatelliteRosterIndex); - ok(info->ulManifestVersionMajor == 1,"info->ulManifestVersionMajor = %x\n", + ok_(__FILE__, line)(info->ulManifestVersionMajor == 1,"info->ulManifestVersionMajor = %x\n", info->ulManifestVersionMajor); - ok(info->ulManifestVersionMinor == 0, "info->ulManifestVersionMinor = %x\n", + ok_(__FILE__, line)(info->ulManifestVersionMinor == 0, "info->ulManifestVersionMinor = %x\n", info->ulManifestVersionMinor); - ok(info->ulPolicyVersionMajor == 0, "info->ulPolicyVersionMajor = %x\n", + ok_(__FILE__, line)(info->ulPolicyVersionMajor == 0, "info->ulPolicyVersionMajor = %x\n", info->ulPolicyVersionMajor); - ok(info->ulPolicyVersionMinor == 0, "info->ulPolicyVersionMinor = %x\n", + ok_(__FILE__, line)(info->ulPolicyVersionMinor == 0, "info->ulPolicyVersionMinor = %x\n", info->ulPolicyVersionMinor); if(exinfo->has_assembly_dir) - ok(info->ulAssemblyDirectoryNameLength != 0, + ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength != 0, "info->ulAssemblyDirectoryNameLength == 0\n"); else - ok(info->ulAssemblyDirectoryNameLength == 0, + ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength == 0, "info->ulAssemblyDirectoryNameLength != 0\n"); - ok(info->lpAssemblyEncodedAssemblyIdentity != NULL, + ok_(__FILE__, line)(info->lpAssemblyEncodedAssemblyIdentity != NULL, "info->lpAssemblyEncodedAssemblyIdentity == NULL\n"); if(info->lpAssemblyEncodedAssemblyIdentity && exinfo->encoded_assembly_id) { - ok(!strcmp_aw(info->lpAssemblyEncodedAssemblyIdentity, exinfo->encoded_assembly_id), + ok_(__FILE__, line)(!strcmp_aw(info->lpAssemblyEncodedAssemblyIdentity, exinfo->encoded_assembly_id), "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n", strw(info->lpAssemblyEncodedAssemblyIdentity), exinfo->encoded_assembly_id); } if(exinfo->manifest_path) { - ok(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n"); + ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n"); if(info->lpAssemblyManifestPath) - ok(!lstrcmpiW(info->lpAssemblyManifestPath, exinfo->manifest_path), + ok_(__FILE__, line)(!lstrcmpiW(info->lpAssemblyManifestPath, exinfo->manifest_path), "unexpected info->lpAssemblyManifestPath\n"); }else { - ok(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n"); + ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n"); } - ok(info->lpAssemblyPolicyPath == NULL, "info->lpAssemblyPolicyPath != NULL\n"); + ok_(__FILE__, line)(info->lpAssemblyPolicyPath == NULL, "info->lpAssemblyPolicyPath != NULL\n"); if(info->lpAssemblyPolicyPath) - ok(*(WORD*)info->lpAssemblyPolicyPath == 0, "info->lpAssemblyPolicyPath is not empty\n"); + ok_(__FILE__, line)(*(WORD*)info->lpAssemblyPolicyPath == 0, "info->lpAssemblyPolicyPath is not empty\n"); if(exinfo->has_assembly_dir) - ok(info->lpAssemblyDirectoryName != NULL, "info->lpAssemblyDirectoryName == NULL\n"); + ok_(__FILE__, line)(info->lpAssemblyDirectoryName != NULL, "info->lpAssemblyDirectoryName == NULL\n"); else - ok(info->lpAssemblyDirectoryName == NULL, "info->lpAssemblyDirectoryName = %s\n", + ok_(__FILE__, line)(info->lpAssemblyDirectoryName == NULL, "info->lpAssemblyDirectoryName = %s\n", strw(info->lpAssemblyDirectoryName)); HeapFree(GetProcessHeap(), 0, info); } -static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR filename) +static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR filename, int line) { ASSEMBLY_FILE_DETAILED_INFORMATION *info, info_tmp; ACTIVATION_CONTEXT_QUERY_INDEX index = {assid, fileid}; @@ -546,9 +546,9 @@ static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR fil b = pQueryActCtxW(0, handle, &index, FileInformationInAssemblyOfAssemblyInActivationContext, &info_tmp, sizeof(info_tmp), &size); - ok(!b, "QueryActCtx succeeded\n"); - ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); - ok(size == exsize, "size=%lu, expected %lu\n", size, exsize); + ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n"); + ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError()); + ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize); if(size == 0xdeadbeef) { @@ -561,18 +561,18 @@ static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR fil b = pQueryActCtxW(0, handle, &index, FileInformationInAssemblyOfAssemblyInActivationContext, info, size, &size); - ok(b, "QueryActCtx failed: %u\n", GetLastError()); - ok(!size, "size=%lu, expected 0\n", size); + ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError()); + ok_(__FILE__, line)(!size, "size=%lu, expected 0\n", size); - ok(info->ulFlags == 2, "info->ulFlags=%x, expected 2\n", info->ulFlags); - ok(info->ulFilenameLength == lstrlenW(filename)*sizeof(WCHAR), + ok_(__FILE__, line)(info->ulFlags == 2, "info->ulFlags=%x, expected 2\n", info->ulFlags); + ok_(__FILE__, line)(info->ulFilenameLength == lstrlenW(filename)*sizeof(WCHAR), "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n", info->ulFilenameLength, lstrlenW(filename)); - ok(info->ulPathLength == 0, "info->ulPathLength=%u\n", info->ulPathLength); - ok(info->lpFileName != NULL, "info->lpFileName == NULL\n"); + ok_(__FILE__, line)(info->ulPathLength == 0, "info->ulPathLength=%u\n", info->ulPathLength); + ok_(__FILE__, line)(info->lpFileName != NULL, "info->lpFileName == NULL\n"); if(info->lpFileName) - ok(!lstrcmpiW(info->lpFileName, filename), "unexpected info->lpFileName\n"); - ok(info->lpFilePath == NULL, "info->lpFilePath != NULL\n"); + ok_(__FILE__, line)(!lstrcmpiW(info->lpFileName, filename), "unexpected info->lpFileName\n"); + ok_(__FILE__, line)(info->lpFilePath == NULL, "info->lpFilePath != NULL\n"); HeapFree(GetProcessHeap(), 0, info); } @@ -693,7 +693,7 @@ static void test_create_fail(void) test_create_and_fail(manifest2, wrong_depmanifest1, 0 ); } -static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid) +static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid, int line) { ACTCTX_SECTION_KEYED_DATA data; DWORD *p; @@ -705,32 +705,32 @@ static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, libname, &data); - ok(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); + ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); if(!ret) { skip("couldn't find %s\n",strw(libname)); return; } - ok(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); - ok(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); - ok(data.lpData != NULL, "data.lpData == NULL\n"); - ok(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength); + ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); + ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); + ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); + ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength); p = data.lpData; if(ret && p) todo_wine { - ok(p[0] == 20 && p[1] == 2 && p[2] == 0 && p[3] == 0 && p[4] == 0, + ok_(__FILE__, line)(p[0] == 20 && p[1] == 2 && p[2] == 0 && p[3] == 0 && p[4] == 0, "wrong data %u,%u,%u,%u,%u\n",p[0], p[1], p[2], p[3], p[4]); } - ok(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); - ok(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", + ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); + ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength); - ok(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); - /* ok(data.ulSectionTotalLength == ??, "data.ulSectionTotalLength=%u\n", + ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); + /* ok_(__FILE__, line)(data.ulSectionTotalLength == ??, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength); */ - ok(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); - ok(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", + ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); + ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", data.ulAssemblyRosterIndex, exid); memset(&data, 0xfe, sizeof(data)); @@ -739,31 +739,31 @@ static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, libname, &data); - ok(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); + ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); if(!ret) { skip("couldn't find\n"); return; } - ok(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); - ok(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); - ok(data.lpData != NULL, "data.lpData == NULL\n"); - ok(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength); - ok(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); - ok(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", + ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); + ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); + ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); + ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength); + ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); + ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength); - ok(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); - /* ok(data.ulSectionTotalLength == ?? , "data.ulSectionTotalLength=%u\n", + ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); + /* ok_(__FILE__, line)(data.ulSectionTotalLength == ?? , "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength); */ - ok(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx); - ok(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", + ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx); + ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", data.ulAssemblyRosterIndex, exid); pReleaseActCtx(handle); } -static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid) +static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, int line) { ACTCTX_SECTION_KEYED_DATA data; BOOL ret; @@ -774,25 +774,25 @@ static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid) ret = pFindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, clsname, &data); - ok(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); + ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); if(!ret) { skip("couldn't find\n"); return; } - ok(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); - ok(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); - ok(data.lpData != NULL, "data.lpData == NULL\n"); - /* ok(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); */ - ok(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); - ok(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", + ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); + ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); + ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); + /* ok_(__FILE__, line)(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); */ + ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); + ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength); - ok(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); - /* ok(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n", + ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); + /* ok_(__FILE__, line)(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength); FIXME */ - ok(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); - ok(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", + ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); + ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", data.ulAssemblyRosterIndex, exid); memset(&data, 0xfe, sizeof(data)); @@ -801,25 +801,25 @@ static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid) ret = pFindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, clsname, &data); - ok(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); + ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError()); if(!ret) { skip("couldn't find\n"); return; } - ok(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); - ok(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); - ok(data.lpData != NULL, "data.lpData == NULL\n"); - /* ok(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); FIXME */ - ok(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); - ok(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", + ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize); + ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion); + ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n"); + /* ok_(__FILE__, line)(data.ulLength == ??, "data.ulLength=%u\n", data.ulLength); FIXME */ + ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n"); + ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength); - ok(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); - /* ok(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n", + ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); + /* ok_(__FILE__, line)(data.ulSectionTotalLength == 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength); FIXME */ - ok(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx); - ok(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", + ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx); + ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n", data.ulAssemblyRosterIndex, exid); pReleaseActCtx(handle); @@ -863,7 +863,7 @@ static void test_find_string_fail(void) } -static void test_basic_info(HANDLE handle) +static void test_basic_info(HANDLE handle, int line) { ACTIVATION_CONTEXT_BASIC_INFORMATION basic; SIZE_T size; @@ -873,10 +873,10 @@ static void test_basic_info(HANDLE handle) ActivationContextBasicInformation, &basic, sizeof(basic), &size); - ok (b,"ActivationContextBasicInformation failed\n"); - ok (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n"); - ok (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); - ok (basic.hActCtx == handle, "unexpected handle\n"); + ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n"); + ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n"); + ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); + ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n"); b = pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX | QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL, @@ -884,18 +884,18 @@ static void test_basic_info(HANDLE handle) sizeof(basic), &size); if (handle) { - ok (!b,"ActivationContextBasicInformation succeeded\n"); - ok (size == 0,"size mismatch\n"); - ok (GetLastError() == ERROR_INVALID_PARAMETER, "Wrong last error\n"); - ok (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); - ok (basic.hActCtx == handle, "unexpected handle\n"); + ok_(__FILE__, line) (!b,"ActivationContextBasicInformation succeeded\n"); + ok_(__FILE__, line) (size == 0,"size mismatch\n"); + ok_(__FILE__, line) (GetLastError() == ERROR_INVALID_PARAMETER, "Wrong last error\n"); + ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); + ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n"); } else { - ok (b,"ActivationContextBasicInformation failed\n"); - ok (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n"); - ok (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); - ok (basic.hActCtx == handle, "unexpected handle\n"); + ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n"); + ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n"); + ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags); + ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n"); } } @@ -913,8 +913,8 @@ static void test_actctx(void) ok(handle == NULL, "handle = %p, expected NULL\n", handle); ok(b, "GetCurrentActCtx failed: %u\n", GetLastError()); if(b) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info0); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info0, __LINE__); pReleaseActCtx(handle); } @@ -928,9 +928,9 @@ static void test_actctx(void) handle = test_create("test1.manifest", manifest1); DeleteFileA("test1.manifest"); if(handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info1); - test_info_in_assembly(handle, 1, &manifest1_info); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info1, __LINE__); + test_info_in_assembly(handle, 1, &manifest1_info, __LINE__); if (pIsDebuggerPresent && !pIsDebuggerPresent()) { @@ -954,10 +954,10 @@ static void test_actctx(void) DeleteFileA("test2.manifest"); DeleteFileA("testdep.manifest"); if(handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info2); - test_info_in_assembly(handle, 1, &manifest2_info); - test_info_in_assembly(handle, 2, &depmanifest1_info); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info2, __LINE__); + test_info_in_assembly(handle, 1, &manifest2_info, __LINE__); + test_info_in_assembly(handle, 2, &depmanifest1_info, __LINE__); pReleaseActCtx(handle); } @@ -972,17 +972,17 @@ static void test_actctx(void) DeleteFileA("test2-2.manifest"); DeleteFileA("testdep.manifest"); if(handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info2); - test_info_in_assembly(handle, 1, &manifest2_info); - test_info_in_assembly(handle, 2, &depmanifest2_info); - test_file_info(handle, 1, 0, testlib_dll); - test_file_info(handle, 1, 1, testlib2_dll); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info2, __LINE__); + test_info_in_assembly(handle, 1, &manifest2_info, __LINE__); + test_info_in_assembly(handle, 2, &depmanifest2_info, __LINE__); + test_file_info(handle, 1, 0, testlib_dll, __LINE__); + test_file_info(handle, 1, 1, testlib2_dll, __LINE__); b = pActivateActCtx(handle, &cookie); ok(b, "ActivateActCtx failed: %u\n", GetLastError()); - test_find_dll_redirection(handle, testlib_dll, 2); - test_find_dll_redirection(handle, testlib2_dll, 2); + test_find_dll_redirection(handle, testlib_dll, 2, __LINE__); + test_find_dll_redirection(handle, testlib2_dll, 2, __LINE__); b = pDeactivateActCtx(0, cookie); ok(b, "DeactivateActCtx failed: %u\n", GetLastError()); @@ -1000,19 +1000,19 @@ static void test_actctx(void) DeleteFileA("test2-3.manifest"); DeleteFileA("testdep.manifest"); if(handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info2); - test_info_in_assembly(handle, 1, &manifest2_info); - test_info_in_assembly(handle, 2, &depmanifest3_info); - test_file_info(handle, 1, 0, testlib_dll); - test_file_info(handle, 1, 1, testlib2_dll); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info2, __LINE__); + test_info_in_assembly(handle, 1, &manifest2_info, __LINE__); + test_info_in_assembly(handle, 2, &depmanifest3_info, __LINE__); + test_file_info(handle, 1, 0, testlib_dll, __LINE__); + test_file_info(handle, 1, 1, testlib2_dll, __LINE__); b = pActivateActCtx(handle, &cookie); ok(b, "ActivateActCtx failed: %u\n", GetLastError()); - test_find_dll_redirection(handle, testlib_dll, 2); - test_find_dll_redirection(handle, testlib2_dll, 2); - test_find_window_class(handle, wndClassW, 2); - test_find_window_class(handle, wndClass2W, 2); + test_find_dll_redirection(handle, testlib_dll, 2, __LINE__); + test_find_dll_redirection(handle, testlib2_dll, 2, __LINE__); + test_find_window_class(handle, wndClassW, 2, __LINE__); + test_find_window_class(handle, wndClass2W, 2, __LINE__); b = pDeactivateActCtx(0, cookie); ok(b, "DeactivateActCtx failed: %u\n", GetLastError()); @@ -1029,15 +1029,15 @@ static void test_actctx(void) handle = test_create("test3.manifest", manifest3); DeleteFileA("test3.manifest"); if(handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info1); - test_info_in_assembly(handle, 1, &manifest3_info); - test_file_info(handle, 0, 0, testlib_dll); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info1, __LINE__); + test_info_in_assembly(handle, 1, &manifest3_info, __LINE__); + test_file_info(handle, 0, 0, testlib_dll, __LINE__); b = pActivateActCtx(handle, &cookie); ok(b, "ActivateActCtx failed: %u\n", GetLastError()); - test_find_dll_redirection(handle, testlib_dll, 1); - test_find_dll_redirection(handle, testlib_dll, 1); + test_find_dll_redirection(handle, testlib_dll, 1, __LINE__); + test_find_dll_redirection(handle, testlib_dll, 1, __LINE__); test_find_string_fail(); b = pDeactivateActCtx(0, cookie); ok(b, "DeactivateActCtx failed: %u\n", GetLastError()); @@ -1056,10 +1056,10 @@ static void test_actctx(void) DeleteFileA("test4.manifest"); DeleteFileA("testdep.manifest"); if(handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info2); - test_info_in_assembly(handle, 1, &manifest4_info); - test_info_in_assembly(handle, 2, &manifest_comctrl_info); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info2, __LINE__); + test_info_in_assembly(handle, 1, &manifest4_info, __LINE__); + test_info_in_assembly(handle, 2, &manifest_comctrl_info, __LINE__); pReleaseActCtx(handle); } @@ -1075,9 +1075,9 @@ static void test_actctx(void) handle = test_create("..\\test1.manifest", manifest1); DeleteFileA("..\\test1.manifest"); if(handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info1); - test_info_in_assembly(handle, 1, &manifest1_info); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info1, __LINE__); + test_info_in_assembly(handle, 1, &manifest1_info, __LINE__); pReleaseActCtx(handle); } SetCurrentDirectoryW(work_dir); @@ -1095,9 +1095,9 @@ static void test_actctx(void) handle = test_create("test1.manifest", manifest1); DeleteFileA("test1.manifest"); if (handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info1); - test_info_in_assembly(handle, 1, &manifest1_info); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info1, __LINE__); + test_info_in_assembly(handle, 1, &manifest1_info, __LINE__); pReleaseActCtx(handle); } @@ -1110,9 +1110,9 @@ static void test_actctx(void) handle = test_create("test1.manifest", manifest1); DeleteFileA("test1.manifest"); if (handle != INVALID_HANDLE_VALUE) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info1); - test_info_in_assembly(handle, 1, &manifest1_info); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info1, __LINE__); + test_info_in_assembly(handle, 1, &manifest1_info, __LINE__); pReleaseActCtx(handle); } @@ -1129,9 +1129,9 @@ static void test_app_manifest(void) ok(handle == NULL, "handle != NULL\n"); ok(b, "GetCurrentActCtx failed: %u\n", GetLastError()); if(b) { - test_basic_info(handle); - test_detailed_info(handle, &detailed_info1_child); - test_info_in_assembly(handle, 1, &manifest1_child_info); + test_basic_info(handle, __LINE__); + test_detailed_info(handle, &detailed_info1_child, __LINE__); + test_info_in_assembly(handle, 1, &manifest1_child_info, __LINE__); pReleaseActCtx(handle); } } diff --git a/rostests/winetests/kernel32/alloc.c b/rostests/winetests/kernel32/alloc.c index 8cb0915c5ea..c1b2afc734d 100755 --- a/rostests/winetests/kernel32/alloc.c +++ b/rostests/winetests/kernel32/alloc.c @@ -70,15 +70,9 @@ static void test_Heap(void) heap=HeapCreate(0,2*memchunk,5*memchunk); /* Check that HeapCreate allocated the right amount of ram */ - todo_wine { - /* Today HeapCreate seems to return a memory block larger than specified. - MSDN says the maximum heap size should be dwMaximumSize rounded up to the - nearest page boundary - */ - mem1=HeapAlloc(heap,0,5*memchunk+1); - ok(mem1==NULL,"HeapCreate allocated more Ram than it should have\n"); - HeapFree(heap,0,mem1); - } + mem1=HeapAlloc(heap,0,5*memchunk+1); + ok(mem1==NULL,"HeapCreate allocated more Ram than it should have\n"); + HeapFree(heap,0,mem1); /* Check that a normal alloc works */ mem1=HeapAlloc(heap,0,memchunk); diff --git a/rostests/winetests/kernel32/atom.c b/rostests/winetests/kernel32/atom.c index 84013b94af3..f85d27255af 100755 --- a/rostests/winetests/kernel32/atom.c +++ b/rostests/winetests/kernel32/atom.c @@ -32,6 +32,7 @@ static const WCHAR foobarW[] = {'f','o','o','b','a','r',0}; static const WCHAR FOOBARW[] = {'F','O','O','B','A','R',0}; static const WCHAR _foobarW[] = {'_','f','o','o','b','a','r',0}; +static const WCHAR integfmt[] = {'#','%','d',0}; static void do_initA(char* tmp, const char* pattern, int len) { @@ -57,21 +58,6 @@ static void do_initW(WCHAR* tmp, const char* pattern, int len) *tmp = '\0'; } -static void print_integral( WCHAR* buffer, int atom ) -{ - BOOL first = TRUE; - -#define X(v) { if (atom >= v) {*buffer++ = '0' + atom / v; first = FALSE; } else if (!first || v == 1) *buffer++ = '0'; atom %= v; } - *buffer++ = '#'; - X(10000); - X(1000); - X(100); - X(10); - X(1); - *buffer = '\0'; -#undef X -} - static BOOL unicode_OS; static void test_add_atom(void) @@ -281,7 +267,7 @@ static void test_get_atom_name(void) WCHAR res[20]; ok( (len > 1) && (len < 7), "bad length %d\n", len ); - print_integral( res, i ); + wsprintfW( res, integfmt, i ); memset( res + lstrlenW(res) + 1, 'a', 10 * sizeof(WCHAR)); ok( !memcmp( res, outW, 10 * sizeof(WCHAR) ), "bad buffer contents for %d\n", i ); if (len <= 1 || len >= 7) break; /* don't bother testing all of them */ @@ -552,7 +538,7 @@ static void test_local_get_atom_name(void) WCHAR res[20]; ok( (len > 1) && (len < 7), "bad length %d\n", len ); - print_integral( res, i ); + wsprintfW( res, integfmt, i ); memset( res + lstrlenW(res) + 1, 'a', 10 * sizeof(WCHAR)); ok( !memcmp( res, outW, 10 * sizeof(WCHAR) ), "bad buffer contents for %d\n", i ); } diff --git a/rostests/winetests/kernel32/console.c b/rostests/winetests/kernel32/console.c index 33eab268e9c..ace4744067d 100755 --- a/rostests/winetests/kernel32/console.c +++ b/rostests/winetests/kernel32/console.c @@ -24,6 +24,7 @@ #include static BOOL (WINAPI *pGetConsoleInputExeNameA)(DWORD, LPSTR); +static DWORD (WINAPI *pGetConsoleProcessList)(LPDWORD, DWORD); static BOOL (WINAPI *pSetConsoleInputExeNameA)(LPCSTR); /* DEFAULT_ATTRIB is used for all initial filling of the console. @@ -63,6 +64,7 @@ static void init_function_pointers(void) hKernel32 = GetModuleHandleA("kernel32.dll"); KERNEL32_GET_PROC(GetConsoleInputExeNameA); + KERNEL32_GET_PROC(GetConsoleProcessList); KERNEL32_GET_PROC(SetConsoleInputExeNameA); #undef KERNEL32_GET_PROC @@ -926,6 +928,66 @@ static void test_GetSetConsoleInputExeName(void) ok(!lstrcmpA(buffer, input_exe), "got %s expected %s\n", buffer, input_exe); } +static void test_GetConsoleProcessList(void) +{ + DWORD ret, *list = NULL; + + if (!pGetConsoleProcessList) + { + win_skip("GetConsoleProcessList is not available\n"); + return; + } + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(NULL, 0); + ok(ret == 0, "Expected failure\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", + GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(NULL, 1); + ok(ret == 0, "Expected failure\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", + GetLastError()); + + /* We should only have 1 process but only for these specific unit tests as + * we created our own console. An AttachConsole(ATTACH_PARENT_PROCESS) would + * give us two processes for example. + */ + list = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD)); + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(list, 0); + ok(ret == 0, "Expected failure\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", + GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(list, 1); + todo_wine + ok(ret == 1, "Expected 1, got %d\n", ret); + + HeapFree(GetProcessHeap(), 0, list); + + list = HeapAlloc(GetProcessHeap(), 0, ret * sizeof(DWORD)); + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(list, ret); + todo_wine + ok(ret == 1, "Expected 1, got %d\n", ret); + + if (ret == 1) + { + DWORD pid = GetCurrentProcessId(); + ok(list[0] == pid, "Expected %d, got %d\n", pid, list[0]); + } + + HeapFree(GetProcessHeap(), 0, list); +} + START_TEST(console) { HANDLE hConIn, hConOut; @@ -971,10 +1033,9 @@ START_TEST(console) /* still to be done: access rights & access on objects */ if (!pGetConsoleInputExeNameA || !pSetConsoleInputExeNameA) - { win_skip("GetConsoleInputExeNameA and/or SetConsoleInputExeNameA is not available\n"); - return; - } else test_GetSetConsoleInputExeName(); + + test_GetConsoleProcessList(); } diff --git a/rostests/winetests/kernel32/debugger.c b/rostests/winetests/kernel32/debugger.c index 4cf8c05b133..b0f3b40b4aa 100644 --- a/rostests/winetests/kernel32/debugger.c +++ b/rostests/winetests/kernel32/debugger.c @@ -411,7 +411,10 @@ static void test_ExitCode(void) crash_and_debug(hkey, test_exe, "dbg,none"); else skip("\"none\" debugger test needs user interaction\n"); - crash_and_debug(hkey, test_exe, "dbg,event,order"); + if (disposition == REG_CREATED_NEW_KEY) + win_skip("'dbg,event,order' test doesn't finish on Win9x/WinMe\n"); + else + crash_and_debug(hkey, test_exe, "dbg,event,order"); crash_and_debug(hkey, test_exe, "dbg,attach,event,code2"); if (pDebugSetProcessKillOnExit) crash_and_debug(hkey, test_exe, "dbg,attach,event,nokill"); diff --git a/rostests/winetests/kernel32/fiber.c b/rostests/winetests/kernel32/fiber.c new file mode 100644 index 00000000000..dac9d6a83a9 --- /dev/null +++ b/rostests/winetests/kernel32/fiber.c @@ -0,0 +1,197 @@ +/* + * Unit tests for fiber functions + * + * Copyright (c) 2010 André Hentschel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "wine/test.h" + +static LPVOID (WINAPI *pCreateFiber)(SIZE_T,LPFIBER_START_ROUTINE,LPVOID); +static LPVOID (WINAPI *pConvertThreadToFiber)(LPVOID); +static BOOL (WINAPI *pConvertFiberToThread)(void); +static void (WINAPI *pSwitchToFiber)(LPVOID); +static void (WINAPI *pDeleteFiber)(LPVOID); +static LPVOID (WINAPI *pConvertThreadToFiberEx)(LPVOID,DWORD); +static LPVOID (WINAPI *pCreateFiberEx)(SIZE_T,SIZE_T,DWORD,LPFIBER_START_ROUTINE,LPVOID); +static BOOL (WINAPI *pIsThreadAFiber)(void); +static DWORD (WINAPI *pFlsAlloc)(PFLS_CALLBACK_FUNCTION); +static BOOL (WINAPI *pFlsFree)(DWORD); +static PVOID (WINAPI *pFlsGetValue)(DWORD); +static BOOL (WINAPI *pFlsSetValue)(DWORD,PVOID); + +static LPVOID fibers[2]; +static BYTE testparam = 185; +static WORD cbCount; + +static VOID init_funcs(void) +{ + HMODULE hKernel32 = GetModuleHandle("kernel32"); + +#define X(f) p##f = (void*)GetProcAddress(hKernel32, #f); + X(CreateFiber); + X(ConvertThreadToFiber); + X(ConvertFiberToThread); + X(SwitchToFiber); + X(DeleteFiber); + X(ConvertThreadToFiberEx); + X(CreateFiberEx); + X(IsThreadAFiber); + X(FlsAlloc); + X(FlsFree); + X(FlsGetValue); + X(FlsSetValue); +#undef X +} + +static VOID WINAPI FiberLocalStorageProc(PVOID lpFlsData) +{ + cbCount++; + ok(lpFlsData == (PVOID) 1587, "FlsData expected not to be changed\n"); +} + +static VOID WINAPI FiberMainProc(LPVOID lpFiberParameter) +{ + BYTE *tparam = (BYTE *)lpFiberParameter; + cbCount++; + ok(*tparam == 185, "Parameterdata expected not to be changed\n"); + pSwitchToFiber(fibers[0]); +} + +static void test_ConvertThreadToFiber(void) +{ + if (pConvertThreadToFiber) + { + fibers[0] = pConvertThreadToFiber(&testparam); + ok(fibers[0] != 0, "ConvertThreadToFiber failed with error %d\n", GetLastError()); + } + else + { + win_skip( "ConvertThreadToFiber not present\n" ); + } +} + +static void test_ConvertThreadToFiberEx(void) +{ + if (pConvertThreadToFiberEx) + { + fibers[0] = pConvertThreadToFiberEx(&testparam, 0); + ok(fibers[0] != 0, "ConvertThreadToFiberEx failed with error %d\n", GetLastError()); + } + else + { + win_skip( "ConvertThreadToFiberEx not present\n" ); + } +} + +static void test_ConvertFiberToThread(void) +{ + if (pConvertFiberToThread) + { + ok(pConvertFiberToThread() , "ConvertFiberToThread failed with error %d\n", GetLastError()); + } + else + { + win_skip( "ConvertFiberToThread not present\n" ); + } +} + +static void test_FiberHandling(void) +{ + cbCount = 0; + fibers[0] = pCreateFiber(0,FiberMainProc,&testparam); + ok(fibers[0] != 0, "CreateFiber failed with error %d\n", GetLastError()); + pDeleteFiber(fibers[0]); + + test_ConvertThreadToFiber(); + test_ConvertFiberToThread(); + if (pConvertThreadToFiberEx) + test_ConvertThreadToFiberEx(); + else + test_ConvertThreadToFiber(); + + + fibers[1] = pCreateFiber(0,FiberMainProc,&testparam); + ok(fibers[1] != 0, "CreateFiber failed with error %d\n", GetLastError()); + + pSwitchToFiber(fibers[1]); + ok(cbCount == 1, "Wrong callback count: %d\n", cbCount); + pDeleteFiber(fibers[1]); + + if (!pCreateFiberEx) + { + win_skip( "CreateFiberEx not present\n" ); + return; + } + + fibers[1] = pCreateFiberEx(0,0,0,FiberMainProc,&testparam); + ok(fibers[1] != 0, "CreateFiberEx failed with error %d\n", GetLastError()); + + pSwitchToFiber(fibers[1]); + ok(cbCount == 2, "Wrong callback count: %d\n", cbCount); + pDeleteFiber(fibers[1]); + + if (!pIsThreadAFiber) + { + win_skip( "IsThreadAFiber not present\n" ); + return; + } + + ok(pIsThreadAFiber(), "IsThreadAFiber reported FALSE\n"); + test_ConvertFiberToThread(); + ok(!pIsThreadAFiber(), "IsThreadAFiber reported TRUE\n"); +} + +static void test_FiberLocalStorage(PFLS_CALLBACK_FUNCTION cbfunc) +{ + DWORD fls; + BOOL ret; + PVOID val = (PVOID) 1587; + + if (!pFlsAlloc) + { + win_skip( "Fiber Local Storage not supported\n" ); + return; + } + cbCount = 0; + + fls = pFlsAlloc(cbfunc); + ok(fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %d\n", GetLastError()); + + ret = pFlsSetValue(fls, val); + ok(ret, "FlsSetValue failed\n"); + ok(val == pFlsGetValue(fls), "FlsGetValue failed\n"); + + ret = pFlsFree(fls); + ok(ret, "FlsFree failed\n"); + if (cbfunc) + todo_wine ok(cbCount == 1, "Wrong callback count: %d\n", cbCount); +} + +START_TEST(fiber) +{ + init_funcs(); + + if (!pCreateFiber) + { + win_skip( "Fibers not supported by win95\n" ); + return; + } + + test_FiberHandling(); + test_FiberLocalStorage(NULL); + test_FiberLocalStorage(FiberLocalStorageProc); +} diff --git a/rostests/winetests/kernel32/file.c b/rostests/winetests/kernel32/file.c index 3cc9022b32a..3493ff34ac4 100755 --- a/rostests/winetests/kernel32/file.c +++ b/rostests/winetests/kernel32/file.c @@ -202,6 +202,8 @@ static void test__hwrite( void ) ret = DeleteFileA( filename ); ok( ret != 0, "DeleteFile failed (%d)\n", GetLastError( ) ); + + LocalFree( contents ); } @@ -251,7 +253,9 @@ static void test__lcreat( void ) ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" ); - ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file\n" ); + find = FindFirstFileA( filename, &search_results ); + ok( INVALID_HANDLE_VALUE != find, "should be able to find file\n" ); + FindClose( find ); ret = DeleteFileA(filename); ok( ret != 0, "DeleteFile failed (%d)\n", GetLastError()); @@ -263,7 +267,9 @@ static void test__lcreat( void ) ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" ); - ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file\n" ); + find = FindFirstFileA( filename, &search_results ); + ok( INVALID_HANDLE_VALUE != find, "should be able to find file\n" ); + FindClose( find ); ok( 0 == DeleteFileA( filename ), "shouldn't be able to delete a readonly file\n" ); @@ -282,7 +288,9 @@ static void test__lcreat( void ) ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" ); - ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should STILL be able to find file\n" ); + find = FindFirstFileA( filename, &search_results ); + ok( INVALID_HANDLE_VALUE != find, "should STILL be able to find file\n" ); + FindClose( find ); ret = DeleteFileA( filename ); ok( ret, "DeleteFile failed (%d)\n", GetLastError( ) ); @@ -298,7 +306,9 @@ static void test__lcreat( void ) ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" ); - ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should STILL be able to find file\n" ); + find = FindFirstFileA( filename, &search_results ); + ok( INVALID_HANDLE_VALUE != find, "should STILL be able to find file\n" ); + FindClose( find ); ret = DeleteFileA( filename ); ok( ret, "DeleteFile failed (%d)\n", GetLastError( ) ); @@ -555,6 +565,8 @@ static void test__lwrite( void ) ret = DeleteFileA( filename ); ok( ret, "DeleteFile failed (%d)\n", GetLastError( ) ); + + LocalFree( contents ); } static void test_CopyFileA(void) @@ -702,33 +714,22 @@ static void test_CopyFileW(void) /* * Debugging routine to dump a buffer in a hexdump-like fashion. */ -static void dumpmem(unsigned char* mem, int len) { - int x,y; - char buf[200]; - int ln=0; +static void dumpmem(unsigned char *mem, int len) +{ + int x = 0; + char hex[49], *p; + char txt[17], *c; - for (x=0; xlen) { - ln += sprintf(buf+ln, " "); - } else { - ln += sprintf(buf+ln, "%02hhx ",mem[x+y]); - } - } - ln += sprintf(buf+ln, "- "); - for (y=0; y<16; y++) { - if ((x+y)<=len) { - if (mem[x+y]<32 || mem[x+y]>127) { - ln += sprintf(buf+ln, "."); - } else { - ln += sprintf(buf+ln, "%c",mem[x+y]); - } - } - } - sprintf(buf+ln, "\n"); - trace(buf); - ln = 0; + while (x < len) + { + p = hex; + c = txt; + do { + p += sprintf(p, "%02hhx ", mem[x]); + *c++ = (mem[x] >= 32 && mem[x] <= 127) ? mem[x] : '.'; + } while (++x % 16 && x < len); + *c = '\0'; + trace("%04x: %-48s- %s\n", x, hex, txt); } } diff --git a/rostests/winetests/kernel32/generated.c b/rostests/winetests/kernel32/generated.c new file mode 100644 index 00000000000..be68a085936 --- /dev/null +++ b/rostests/winetests/kernel32/generated.c @@ -0,0 +1,2080 @@ +/* File generated automatically from tools/winapi/tests.dat; do not edit! */ +/* This file can be copied, modified and distributed without restriction. */ + +/* + * Unit tests for data structure packing + */ + +#define WINVER 0x0501 +#define _WIN32_IE 0x0501 +#define _WIN32_WINNT 0x0501 + +#define WINE_NOWINSOCK + +#include "windows.h" + +#include "wine/test.h" + +/*********************************************************************** + * Compatibility macros + */ + +#define DWORD_PTR UINT_PTR +#define LONG_PTR INT_PTR +#define ULONG_PTR UINT_PTR + +/*********************************************************************** + * Windows API extension + */ + +#if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus) +# define _TYPE_ALIGNMENT(type) __alignof(type) +#elif defined(__GNUC__) +# define _TYPE_ALIGNMENT(type) __alignof__(type) +#else +/* + * FIXME: May not be possible without a compiler extension + * (if type is not just a name that is, otherwise the normal + * TYPE_ALIGNMENT can be used) + */ +#endif + +#if defined(TYPE_ALIGNMENT) && defined(_MSC_VER) && _MSC_VER >= 800 && !defined(__cplusplus) +#pragma warning(disable:4116) +#endif + +#if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT) +# define TYPE_ALIGNMENT _TYPE_ALIGNMENT +#endif + +/*********************************************************************** + * Test helper macros + */ + +#ifdef _WIN64 + +# define TEST_TYPE_SIZE(type, size) +# define TEST_TYPE_ALIGN(type, align) +# define TEST_TARGET_ALIGN(type, align) +# define TEST_FIELD_ALIGN(type, field, align) +# define TEST_FIELD_OFFSET(type, field, offset) + +#else + +# define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size); + +# ifdef TYPE_ALIGNMENT +# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align); +# else +# define TEST_TYPE_ALIGN(type, align) +# endif + +# ifdef _TYPE_ALIGNMENT +# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align); +# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align); +# else +# define TEST_TARGET_ALIGN(type, align) +# define TEST_FIELD_ALIGN(type, field, align) +# endif + +# define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset); + +#endif + +#define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size) +#define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size) +#define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0); +#define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0); + + +static void test_pack_LPOSVERSIONINFOA(void) +{ + /* LPOSVERSIONINFOA */ + TEST_TYPE_SIZE (LPOSVERSIONINFOA, 4) + TEST_TYPE_ALIGN (LPOSVERSIONINFOA, 4) + TEST_TARGET_SIZE (LPOSVERSIONINFOA, 148) + TEST_TARGET_ALIGN(LPOSVERSIONINFOA, 4) +} + +static void test_pack_LPOSVERSIONINFOEXA(void) +{ + /* LPOSVERSIONINFOEXA */ + TEST_TYPE_SIZE (LPOSVERSIONINFOEXA, 4) + TEST_TYPE_ALIGN (LPOSVERSIONINFOEXA, 4) + TEST_TARGET_SIZE (LPOSVERSIONINFOEXA, 156) + TEST_TARGET_ALIGN(LPOSVERSIONINFOEXA, 4) +} + +static void test_pack_LPOSVERSIONINFOEXW(void) +{ + /* LPOSVERSIONINFOEXW */ + TEST_TYPE_SIZE (LPOSVERSIONINFOEXW, 4) + TEST_TYPE_ALIGN (LPOSVERSIONINFOEXW, 4) + TEST_TARGET_SIZE (LPOSVERSIONINFOEXW, 284) + TEST_TARGET_ALIGN(LPOSVERSIONINFOEXW, 4) +} + +static void test_pack_LPOSVERSIONINFOW(void) +{ + /* LPOSVERSIONINFOW */ + TEST_TYPE_SIZE (LPOSVERSIONINFOW, 4) + TEST_TYPE_ALIGN (LPOSVERSIONINFOW, 4) + TEST_TARGET_SIZE (LPOSVERSIONINFOW, 276) + TEST_TARGET_ALIGN(LPOSVERSIONINFOW, 4) +} + +static void test_pack_OSVERSIONINFOA(void) +{ + /* OSVERSIONINFOA (pack 4) */ + TEST_TYPE_SIZE (OSVERSIONINFOA, 148) + TEST_TYPE_ALIGN (OSVERSIONINFOA, 4) + TEST_FIELD_SIZE (OSVERSIONINFOA, dwOSVersionInfoSize, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOA, dwOSVersionInfoSize, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOA, dwOSVersionInfoSize, 0) + TEST_FIELD_SIZE (OSVERSIONINFOA, dwMajorVersion, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOA, dwMajorVersion, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOA, dwMajorVersion, 4) + TEST_FIELD_SIZE (OSVERSIONINFOA, dwMinorVersion, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOA, dwMinorVersion, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOA, dwMinorVersion, 8) + TEST_FIELD_SIZE (OSVERSIONINFOA, dwBuildNumber, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOA, dwBuildNumber, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOA, dwBuildNumber, 12) + TEST_FIELD_SIZE (OSVERSIONINFOA, dwPlatformId, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOA, dwPlatformId, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOA, dwPlatformId, 16) + TEST_FIELD_SIZE (OSVERSIONINFOA, szCSDVersion, 128) + TEST_FIELD_ALIGN (OSVERSIONINFOA, szCSDVersion, 1) + TEST_FIELD_OFFSET(OSVERSIONINFOA, szCSDVersion, 20) +} + +static void test_pack_OSVERSIONINFOEXA(void) +{ + /* OSVERSIONINFOEXA (pack 4) */ + TEST_TYPE_SIZE (OSVERSIONINFOEXA, 156) + TEST_TYPE_ALIGN (OSVERSIONINFOEXA, 4) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, dwOSVersionInfoSize, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, dwOSVersionInfoSize, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, dwOSVersionInfoSize, 0) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, dwMajorVersion, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, dwMajorVersion, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, dwMajorVersion, 4) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, dwMinorVersion, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, dwMinorVersion, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, dwMinorVersion, 8) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, dwBuildNumber, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, dwBuildNumber, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, dwBuildNumber, 12) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, dwPlatformId, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, dwPlatformId, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, dwPlatformId, 16) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, szCSDVersion, 128) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, szCSDVersion, 1) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, szCSDVersion, 20) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, wServicePackMajor, 2) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, wServicePackMajor, 2) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, wServicePackMajor, 148) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, wServicePackMinor, 2) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, wServicePackMinor, 2) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, wServicePackMinor, 150) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, wSuiteMask, 2) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, wSuiteMask, 2) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, wSuiteMask, 152) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, wProductType, 1) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, wProductType, 1) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, wProductType, 154) + TEST_FIELD_SIZE (OSVERSIONINFOEXA, wReserved, 1) + TEST_FIELD_ALIGN (OSVERSIONINFOEXA, wReserved, 1) + TEST_FIELD_OFFSET(OSVERSIONINFOEXA, wReserved, 155) +} + +static void test_pack_OSVERSIONINFOEXW(void) +{ + /* OSVERSIONINFOEXW (pack 4) */ + TEST_TYPE_SIZE (OSVERSIONINFOEXW, 284) + TEST_TYPE_ALIGN (OSVERSIONINFOEXW, 4) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, dwOSVersionInfoSize, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, dwOSVersionInfoSize, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, dwOSVersionInfoSize, 0) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, dwMajorVersion, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, dwMajorVersion, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, dwMajorVersion, 4) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, dwMinorVersion, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, dwMinorVersion, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, dwMinorVersion, 8) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, dwBuildNumber, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, dwBuildNumber, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, dwBuildNumber, 12) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, dwPlatformId, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, dwPlatformId, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, dwPlatformId, 16) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, szCSDVersion, 256) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, szCSDVersion, 2) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, szCSDVersion, 20) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, wServicePackMajor, 2) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, wServicePackMajor, 2) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, wServicePackMajor, 276) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, wServicePackMinor, 2) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, wServicePackMinor, 2) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, wServicePackMinor, 278) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, wSuiteMask, 2) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, wSuiteMask, 2) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, wSuiteMask, 280) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, wProductType, 1) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, wProductType, 1) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, wProductType, 282) + TEST_FIELD_SIZE (OSVERSIONINFOEXW, wReserved, 1) + TEST_FIELD_ALIGN (OSVERSIONINFOEXW, wReserved, 1) + TEST_FIELD_OFFSET(OSVERSIONINFOEXW, wReserved, 283) +} + +static void test_pack_OSVERSIONINFOW(void) +{ + /* OSVERSIONINFOW (pack 4) */ + TEST_TYPE_SIZE (OSVERSIONINFOW, 276) + TEST_TYPE_ALIGN (OSVERSIONINFOW, 4) + TEST_FIELD_SIZE (OSVERSIONINFOW, dwOSVersionInfoSize, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOW, dwOSVersionInfoSize, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOW, dwOSVersionInfoSize, 0) + TEST_FIELD_SIZE (OSVERSIONINFOW, dwMajorVersion, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOW, dwMajorVersion, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOW, dwMajorVersion, 4) + TEST_FIELD_SIZE (OSVERSIONINFOW, dwMinorVersion, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOW, dwMinorVersion, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOW, dwMinorVersion, 8) + TEST_FIELD_SIZE (OSVERSIONINFOW, dwBuildNumber, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOW, dwBuildNumber, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOW, dwBuildNumber, 12) + TEST_FIELD_SIZE (OSVERSIONINFOW, dwPlatformId, 4) + TEST_FIELD_ALIGN (OSVERSIONINFOW, dwPlatformId, 4) + TEST_FIELD_OFFSET(OSVERSIONINFOW, dwPlatformId, 16) + TEST_FIELD_SIZE (OSVERSIONINFOW, szCSDVersion, 256) + TEST_FIELD_ALIGN (OSVERSIONINFOW, szCSDVersion, 2) + TEST_FIELD_OFFSET(OSVERSIONINFOW, szCSDVersion, 20) +} + +static void test_pack_POSVERSIONINFOA(void) +{ + /* POSVERSIONINFOA */ + TEST_TYPE_SIZE (POSVERSIONINFOA, 4) + TEST_TYPE_ALIGN (POSVERSIONINFOA, 4) + TEST_TARGET_SIZE (POSVERSIONINFOA, 148) + TEST_TARGET_ALIGN(POSVERSIONINFOA, 4) +} + +static void test_pack_POSVERSIONINFOEXA(void) +{ + /* POSVERSIONINFOEXA */ + TEST_TYPE_SIZE (POSVERSIONINFOEXA, 4) + TEST_TYPE_ALIGN (POSVERSIONINFOEXA, 4) + TEST_TARGET_SIZE (POSVERSIONINFOEXA, 156) + TEST_TARGET_ALIGN(POSVERSIONINFOEXA, 4) +} + +static void test_pack_POSVERSIONINFOEXW(void) +{ + /* POSVERSIONINFOEXW */ + TEST_TYPE_SIZE (POSVERSIONINFOEXW, 4) + TEST_TYPE_ALIGN (POSVERSIONINFOEXW, 4) + TEST_TARGET_SIZE (POSVERSIONINFOEXW, 284) + TEST_TARGET_ALIGN(POSVERSIONINFOEXW, 4) +} + +static void test_pack_POSVERSIONINFOW(void) +{ + /* POSVERSIONINFOW */ + TEST_TYPE_SIZE (POSVERSIONINFOW, 4) + TEST_TYPE_ALIGN (POSVERSIONINFOW, 4) + TEST_TARGET_SIZE (POSVERSIONINFOW, 276) + TEST_TARGET_ALIGN(POSVERSIONINFOW, 4) +} + +static void test_pack_LPLONG(void) +{ + /* LPLONG */ + TEST_TYPE_SIZE (LPLONG, 4) + TEST_TYPE_ALIGN (LPLONG, 4) +} + +static void test_pack_LPVOID(void) +{ + /* LPVOID */ + TEST_TYPE_SIZE (LPVOID, 4) + TEST_TYPE_ALIGN (LPVOID, 4) +} + +static void test_pack_PHKEY(void) +{ + /* PHKEY */ + TEST_TYPE_SIZE (PHKEY, 4) + TEST_TYPE_ALIGN (PHKEY, 4) +} + +static void test_pack_ACTCTXA(void) +{ + /* ACTCTXA (pack 4) */ + TEST_TYPE_SIZE (ACTCTXA, 32) + TEST_TYPE_ALIGN (ACTCTXA, 4) + TEST_FIELD_SIZE (ACTCTXA, cbSize, 4) + TEST_FIELD_ALIGN (ACTCTXA, cbSize, 4) + TEST_FIELD_OFFSET(ACTCTXA, cbSize, 0) + TEST_FIELD_SIZE (ACTCTXA, dwFlags, 4) + TEST_FIELD_ALIGN (ACTCTXA, dwFlags, 4) + TEST_FIELD_OFFSET(ACTCTXA, dwFlags, 4) + TEST_FIELD_SIZE (ACTCTXA, lpSource, 4) + TEST_FIELD_ALIGN (ACTCTXA, lpSource, 4) + TEST_FIELD_OFFSET(ACTCTXA, lpSource, 8) + TEST_FIELD_SIZE (ACTCTXA, wProcessorArchitecture, 2) + TEST_FIELD_ALIGN (ACTCTXA, wProcessorArchitecture, 2) + TEST_FIELD_OFFSET(ACTCTXA, wProcessorArchitecture, 12) + TEST_FIELD_SIZE (ACTCTXA, wLangId, 2) + TEST_FIELD_ALIGN (ACTCTXA, wLangId, 2) + TEST_FIELD_OFFSET(ACTCTXA, wLangId, 14) + TEST_FIELD_SIZE (ACTCTXA, lpAssemblyDirectory, 4) + TEST_FIELD_ALIGN (ACTCTXA, lpAssemblyDirectory, 4) + TEST_FIELD_OFFSET(ACTCTXA, lpAssemblyDirectory, 16) + TEST_FIELD_SIZE (ACTCTXA, lpResourceName, 4) + TEST_FIELD_ALIGN (ACTCTXA, lpResourceName, 4) + TEST_FIELD_OFFSET(ACTCTXA, lpResourceName, 20) + TEST_FIELD_SIZE (ACTCTXA, lpApplicationName, 4) + TEST_FIELD_ALIGN (ACTCTXA, lpApplicationName, 4) + TEST_FIELD_OFFSET(ACTCTXA, lpApplicationName, 24) + TEST_FIELD_SIZE (ACTCTXA, hModule, 4) + TEST_FIELD_ALIGN (ACTCTXA, hModule, 4) + TEST_FIELD_OFFSET(ACTCTXA, hModule, 28) +} + +static void test_pack_ACTCTXW(void) +{ + /* ACTCTXW (pack 4) */ + TEST_TYPE_SIZE (ACTCTXW, 32) + TEST_TYPE_ALIGN (ACTCTXW, 4) + TEST_FIELD_SIZE (ACTCTXW, cbSize, 4) + TEST_FIELD_ALIGN (ACTCTXW, cbSize, 4) + TEST_FIELD_OFFSET(ACTCTXW, cbSize, 0) + TEST_FIELD_SIZE (ACTCTXW, dwFlags, 4) + TEST_FIELD_ALIGN (ACTCTXW, dwFlags, 4) + TEST_FIELD_OFFSET(ACTCTXW, dwFlags, 4) + TEST_FIELD_SIZE (ACTCTXW, lpSource, 4) + TEST_FIELD_ALIGN (ACTCTXW, lpSource, 4) + TEST_FIELD_OFFSET(ACTCTXW, lpSource, 8) + TEST_FIELD_SIZE (ACTCTXW, wProcessorArchitecture, 2) + TEST_FIELD_ALIGN (ACTCTXW, wProcessorArchitecture, 2) + TEST_FIELD_OFFSET(ACTCTXW, wProcessorArchitecture, 12) + TEST_FIELD_SIZE (ACTCTXW, wLangId, 2) + TEST_FIELD_ALIGN (ACTCTXW, wLangId, 2) + TEST_FIELD_OFFSET(ACTCTXW, wLangId, 14) + TEST_FIELD_SIZE (ACTCTXW, lpAssemblyDirectory, 4) + TEST_FIELD_ALIGN (ACTCTXW, lpAssemblyDirectory, 4) + TEST_FIELD_OFFSET(ACTCTXW, lpAssemblyDirectory, 16) + TEST_FIELD_SIZE (ACTCTXW, lpResourceName, 4) + TEST_FIELD_ALIGN (ACTCTXW, lpResourceName, 4) + TEST_FIELD_OFFSET(ACTCTXW, lpResourceName, 20) + TEST_FIELD_SIZE (ACTCTXW, lpApplicationName, 4) + TEST_FIELD_ALIGN (ACTCTXW, lpApplicationName, 4) + TEST_FIELD_OFFSET(ACTCTXW, lpApplicationName, 24) + TEST_FIELD_SIZE (ACTCTXW, hModule, 4) + TEST_FIELD_ALIGN (ACTCTXW, hModule, 4) + TEST_FIELD_OFFSET(ACTCTXW, hModule, 28) +} + +static void test_pack_ACTCTX_SECTION_KEYED_DATA(void) +{ + /* ACTCTX_SECTION_KEYED_DATA (pack 4) */ + TEST_TYPE_SIZE (ACTCTX_SECTION_KEYED_DATA, 64) + TEST_TYPE_ALIGN (ACTCTX_SECTION_KEYED_DATA, 4) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, cbSize, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, cbSize, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, cbSize, 0) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, ulDataFormatVersion, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, ulDataFormatVersion, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, ulDataFormatVersion, 4) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, lpData, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, lpData, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, lpData, 8) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, ulLength, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, ulLength, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, ulLength, 12) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, lpSectionGlobalData, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, lpSectionGlobalData, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, lpSectionGlobalData, 16) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, ulSectionGlobalDataLength, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, ulSectionGlobalDataLength, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, ulSectionGlobalDataLength, 20) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, lpSectionBase, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, lpSectionBase, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, lpSectionBase, 24) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, ulSectionTotalLength, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, ulSectionTotalLength, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, ulSectionTotalLength, 28) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, hActCtx, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, hActCtx, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, hActCtx, 32) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, ulAssemblyRosterIndex, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, ulAssemblyRosterIndex, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, ulAssemblyRosterIndex, 36) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, ulFlags, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, ulFlags, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, ulFlags, 40) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA, AssemblyMetadata, 20) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA, AssemblyMetadata, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA, AssemblyMetadata, 44) +} + +static void test_pack_ACTCTX_SECTION_KEYED_DATA_2600(void) +{ + /* ACTCTX_SECTION_KEYED_DATA_2600 (pack 4) */ + TEST_TYPE_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, 40) + TEST_TYPE_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, 4) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, cbSize, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, cbSize, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, cbSize, 0) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, ulDataFormatVersion, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, ulDataFormatVersion, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, ulDataFormatVersion, 4) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, lpData, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, lpData, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, lpData, 8) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, ulLength, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, ulLength, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, ulLength, 12) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, lpSectionGlobalData, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, lpSectionGlobalData, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, lpSectionGlobalData, 16) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, ulSectionGlobalDataLength, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, ulSectionGlobalDataLength, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, ulSectionGlobalDataLength, 20) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, lpSectionBase, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, lpSectionBase, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, lpSectionBase, 24) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, ulSectionTotalLength, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, ulSectionTotalLength, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, ulSectionTotalLength, 28) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, hActCtx, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, hActCtx, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, hActCtx, 32) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_2600, ulAssemblyRosterIndex, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_2600, ulAssemblyRosterIndex, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_2600, ulAssemblyRosterIndex, 36) +} + +static void test_pack_ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA(void) +{ + /* ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA (pack 4) */ + TEST_TYPE_SIZE (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 20) + TEST_TYPE_ALIGN (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 4) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpInformation, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpInformation, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpInformation, 0) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpSectionBase, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpSectionBase, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpSectionBase, 4) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, ulSectionLength, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, ulSectionLength, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, ulSectionLength, 8) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpSectionGlobalDataBase, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpSectionGlobalDataBase, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, lpSectionGlobalDataBase, 12) + TEST_FIELD_SIZE (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, ulSectionGlobalDataLength, 4) + TEST_FIELD_ALIGN (ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, ulSectionGlobalDataLength, 4) + TEST_FIELD_OFFSET(ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, ulSectionGlobalDataLength, 16) +} + +static void test_pack_ACTIVATION_CONTEXT_BASIC_INFORMATION(void) +{ + /* ACTIVATION_CONTEXT_BASIC_INFORMATION (pack 4) */ + TEST_TYPE_SIZE (ACTIVATION_CONTEXT_BASIC_INFORMATION, 8) + TEST_TYPE_ALIGN (ACTIVATION_CONTEXT_BASIC_INFORMATION, 4) + TEST_FIELD_SIZE (ACTIVATION_CONTEXT_BASIC_INFORMATION, hActCtx, 4) + TEST_FIELD_ALIGN (ACTIVATION_CONTEXT_BASIC_INFORMATION, hActCtx, 4) + TEST_FIELD_OFFSET(ACTIVATION_CONTEXT_BASIC_INFORMATION, hActCtx, 0) + TEST_FIELD_SIZE (ACTIVATION_CONTEXT_BASIC_INFORMATION, dwFlags, 4) + TEST_FIELD_ALIGN (ACTIVATION_CONTEXT_BASIC_INFORMATION, dwFlags, 4) + TEST_FIELD_OFFSET(ACTIVATION_CONTEXT_BASIC_INFORMATION, dwFlags, 4) +} + +static void test_pack_BY_HANDLE_FILE_INFORMATION(void) +{ + /* BY_HANDLE_FILE_INFORMATION (pack 4) */ + TEST_TYPE_SIZE (BY_HANDLE_FILE_INFORMATION, 52) + TEST_TYPE_ALIGN (BY_HANDLE_FILE_INFORMATION, 4) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, dwFileAttributes, 4) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, dwFileAttributes, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, dwFileAttributes, 0) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, ftCreationTime, 8) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, ftCreationTime, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, ftCreationTime, 4) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, ftLastAccessTime, 8) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, ftLastAccessTime, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, ftLastAccessTime, 12) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, ftLastWriteTime, 8) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, ftLastWriteTime, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, ftLastWriteTime, 20) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, dwVolumeSerialNumber, 4) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, dwVolumeSerialNumber, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, dwVolumeSerialNumber, 28) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, nFileSizeHigh, 4) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, nFileSizeHigh, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, nFileSizeHigh, 32) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, nFileSizeLow, 4) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, nFileSizeLow, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, nFileSizeLow, 36) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, nNumberOfLinks, 4) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, nNumberOfLinks, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, nNumberOfLinks, 40) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, nFileIndexHigh, 4) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, nFileIndexHigh, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, nFileIndexHigh, 44) + TEST_FIELD_SIZE (BY_HANDLE_FILE_INFORMATION, nFileIndexLow, 4) + TEST_FIELD_ALIGN (BY_HANDLE_FILE_INFORMATION, nFileIndexLow, 4) + TEST_FIELD_OFFSET(BY_HANDLE_FILE_INFORMATION, nFileIndexLow, 48) +} + +static void test_pack_COMMCONFIG(void) +{ + /* COMMCONFIG (pack 4) */ + TEST_TYPE_SIZE (COMMCONFIG, 52) + TEST_TYPE_ALIGN (COMMCONFIG, 4) + TEST_FIELD_SIZE (COMMCONFIG, dwSize, 4) + TEST_FIELD_ALIGN (COMMCONFIG, dwSize, 4) + TEST_FIELD_OFFSET(COMMCONFIG, dwSize, 0) + TEST_FIELD_SIZE (COMMCONFIG, wVersion, 2) + TEST_FIELD_ALIGN (COMMCONFIG, wVersion, 2) + TEST_FIELD_OFFSET(COMMCONFIG, wVersion, 4) + TEST_FIELD_SIZE (COMMCONFIG, wReserved, 2) + TEST_FIELD_ALIGN (COMMCONFIG, wReserved, 2) + TEST_FIELD_OFFSET(COMMCONFIG, wReserved, 6) + TEST_FIELD_SIZE (COMMCONFIG, dcb, 28) + TEST_FIELD_ALIGN (COMMCONFIG, dcb, 4) + TEST_FIELD_OFFSET(COMMCONFIG, dcb, 8) + TEST_FIELD_SIZE (COMMCONFIG, dwProviderSubType, 4) + TEST_FIELD_ALIGN (COMMCONFIG, dwProviderSubType, 4) + TEST_FIELD_OFFSET(COMMCONFIG, dwProviderSubType, 36) + TEST_FIELD_SIZE (COMMCONFIG, dwProviderOffset, 4) + TEST_FIELD_ALIGN (COMMCONFIG, dwProviderOffset, 4) + TEST_FIELD_OFFSET(COMMCONFIG, dwProviderOffset, 40) + TEST_FIELD_SIZE (COMMCONFIG, dwProviderSize, 4) + TEST_FIELD_ALIGN (COMMCONFIG, dwProviderSize, 4) + TEST_FIELD_OFFSET(COMMCONFIG, dwProviderSize, 44) + TEST_FIELD_SIZE (COMMCONFIG, wcProviderData, 4) + TEST_FIELD_ALIGN (COMMCONFIG, wcProviderData, 4) + TEST_FIELD_OFFSET(COMMCONFIG, wcProviderData, 48) +} + +static void test_pack_COMMPROP(void) +{ + /* COMMPROP (pack 4) */ + TEST_TYPE_SIZE (COMMPROP, 64) + TEST_TYPE_ALIGN (COMMPROP, 4) + TEST_FIELD_SIZE (COMMPROP, wPacketLength, 2) + TEST_FIELD_ALIGN (COMMPROP, wPacketLength, 2) + TEST_FIELD_OFFSET(COMMPROP, wPacketLength, 0) + TEST_FIELD_SIZE (COMMPROP, wPacketVersion, 2) + TEST_FIELD_ALIGN (COMMPROP, wPacketVersion, 2) + TEST_FIELD_OFFSET(COMMPROP, wPacketVersion, 2) + TEST_FIELD_SIZE (COMMPROP, dwServiceMask, 4) + TEST_FIELD_ALIGN (COMMPROP, dwServiceMask, 4) + TEST_FIELD_OFFSET(COMMPROP, dwServiceMask, 4) + TEST_FIELD_SIZE (COMMPROP, dwReserved1, 4) + TEST_FIELD_ALIGN (COMMPROP, dwReserved1, 4) + TEST_FIELD_OFFSET(COMMPROP, dwReserved1, 8) + TEST_FIELD_SIZE (COMMPROP, dwMaxTxQueue, 4) + TEST_FIELD_ALIGN (COMMPROP, dwMaxTxQueue, 4) + TEST_FIELD_OFFSET(COMMPROP, dwMaxTxQueue, 12) + TEST_FIELD_SIZE (COMMPROP, dwMaxRxQueue, 4) + TEST_FIELD_ALIGN (COMMPROP, dwMaxRxQueue, 4) + TEST_FIELD_OFFSET(COMMPROP, dwMaxRxQueue, 16) + TEST_FIELD_SIZE (COMMPROP, dwMaxBaud, 4) + TEST_FIELD_ALIGN (COMMPROP, dwMaxBaud, 4) + TEST_FIELD_OFFSET(COMMPROP, dwMaxBaud, 20) + TEST_FIELD_SIZE (COMMPROP, dwProvSubType, 4) + TEST_FIELD_ALIGN (COMMPROP, dwProvSubType, 4) + TEST_FIELD_OFFSET(COMMPROP, dwProvSubType, 24) + TEST_FIELD_SIZE (COMMPROP, dwProvCapabilities, 4) + TEST_FIELD_ALIGN (COMMPROP, dwProvCapabilities, 4) + TEST_FIELD_OFFSET(COMMPROP, dwProvCapabilities, 28) + TEST_FIELD_SIZE (COMMPROP, dwSettableParams, 4) + TEST_FIELD_ALIGN (COMMPROP, dwSettableParams, 4) + TEST_FIELD_OFFSET(COMMPROP, dwSettableParams, 32) + TEST_FIELD_SIZE (COMMPROP, dwSettableBaud, 4) + TEST_FIELD_ALIGN (COMMPROP, dwSettableBaud, 4) + TEST_FIELD_OFFSET(COMMPROP, dwSettableBaud, 36) + TEST_FIELD_SIZE (COMMPROP, wSettableData, 2) + TEST_FIELD_ALIGN (COMMPROP, wSettableData, 2) + TEST_FIELD_OFFSET(COMMPROP, wSettableData, 40) + TEST_FIELD_SIZE (COMMPROP, wSettableStopParity, 2) + TEST_FIELD_ALIGN (COMMPROP, wSettableStopParity, 2) + TEST_FIELD_OFFSET(COMMPROP, wSettableStopParity, 42) + TEST_FIELD_SIZE (COMMPROP, dwCurrentTxQueue, 4) + TEST_FIELD_ALIGN (COMMPROP, dwCurrentTxQueue, 4) + TEST_FIELD_OFFSET(COMMPROP, dwCurrentTxQueue, 44) + TEST_FIELD_SIZE (COMMPROP, dwCurrentRxQueue, 4) + TEST_FIELD_ALIGN (COMMPROP, dwCurrentRxQueue, 4) + TEST_FIELD_OFFSET(COMMPROP, dwCurrentRxQueue, 48) + TEST_FIELD_SIZE (COMMPROP, dwProvSpec1, 4) + TEST_FIELD_ALIGN (COMMPROP, dwProvSpec1, 4) + TEST_FIELD_OFFSET(COMMPROP, dwProvSpec1, 52) + TEST_FIELD_SIZE (COMMPROP, dwProvSpec2, 4) + TEST_FIELD_ALIGN (COMMPROP, dwProvSpec2, 4) + TEST_FIELD_OFFSET(COMMPROP, dwProvSpec2, 56) + TEST_FIELD_SIZE (COMMPROP, wcProvChar, 2) + TEST_FIELD_ALIGN (COMMPROP, wcProvChar, 2) + TEST_FIELD_OFFSET(COMMPROP, wcProvChar, 60) +} + +static void test_pack_COMMTIMEOUTS(void) +{ + /* COMMTIMEOUTS (pack 4) */ + TEST_TYPE_SIZE (COMMTIMEOUTS, 20) + TEST_TYPE_ALIGN (COMMTIMEOUTS, 4) + TEST_FIELD_SIZE (COMMTIMEOUTS, ReadIntervalTimeout, 4) + TEST_FIELD_ALIGN (COMMTIMEOUTS, ReadIntervalTimeout, 4) + TEST_FIELD_OFFSET(COMMTIMEOUTS, ReadIntervalTimeout, 0) + TEST_FIELD_SIZE (COMMTIMEOUTS, ReadTotalTimeoutMultiplier, 4) + TEST_FIELD_ALIGN (COMMTIMEOUTS, ReadTotalTimeoutMultiplier, 4) + TEST_FIELD_OFFSET(COMMTIMEOUTS, ReadTotalTimeoutMultiplier, 4) + TEST_FIELD_SIZE (COMMTIMEOUTS, ReadTotalTimeoutConstant, 4) + TEST_FIELD_ALIGN (COMMTIMEOUTS, ReadTotalTimeoutConstant, 4) + TEST_FIELD_OFFSET(COMMTIMEOUTS, ReadTotalTimeoutConstant, 8) + TEST_FIELD_SIZE (COMMTIMEOUTS, WriteTotalTimeoutMultiplier, 4) + TEST_FIELD_ALIGN (COMMTIMEOUTS, WriteTotalTimeoutMultiplier, 4) + TEST_FIELD_OFFSET(COMMTIMEOUTS, WriteTotalTimeoutMultiplier, 12) + TEST_FIELD_SIZE (COMMTIMEOUTS, WriteTotalTimeoutConstant, 4) + TEST_FIELD_ALIGN (COMMTIMEOUTS, WriteTotalTimeoutConstant, 4) + TEST_FIELD_OFFSET(COMMTIMEOUTS, WriteTotalTimeoutConstant, 16) +} + +static void test_pack_COMSTAT(void) +{ + /* COMSTAT (pack 4) */ + TEST_TYPE_SIZE (COMSTAT, 12) + TEST_TYPE_ALIGN (COMSTAT, 4) + TEST_FIELD_SIZE (COMSTAT, cbInQue, 4) + TEST_FIELD_ALIGN (COMSTAT, cbInQue, 4) + TEST_FIELD_OFFSET(COMSTAT, cbInQue, 4) + TEST_FIELD_SIZE (COMSTAT, cbOutQue, 4) + TEST_FIELD_ALIGN (COMSTAT, cbOutQue, 4) + TEST_FIELD_OFFSET(COMSTAT, cbOutQue, 8) +} + +static void test_pack_CREATE_PROCESS_DEBUG_INFO(void) +{ + /* CREATE_PROCESS_DEBUG_INFO (pack 4) */ + TEST_TYPE_SIZE (CREATE_PROCESS_DEBUG_INFO, 40) + TEST_TYPE_ALIGN (CREATE_PROCESS_DEBUG_INFO, 4) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, hFile, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, hFile, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, hFile, 0) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, hProcess, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, hProcess, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, hProcess, 4) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, hThread, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, hThread, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, hThread, 8) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, lpBaseOfImage, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, lpBaseOfImage, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, lpBaseOfImage, 12) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, dwDebugInfoFileOffset, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, dwDebugInfoFileOffset, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, dwDebugInfoFileOffset, 16) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, nDebugInfoSize, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, nDebugInfoSize, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, nDebugInfoSize, 20) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, lpThreadLocalBase, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, lpThreadLocalBase, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, lpThreadLocalBase, 24) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, lpStartAddress, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, lpStartAddress, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, lpStartAddress, 28) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, lpImageName, 4) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, lpImageName, 4) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, lpImageName, 32) + TEST_FIELD_SIZE (CREATE_PROCESS_DEBUG_INFO, fUnicode, 2) + TEST_FIELD_ALIGN (CREATE_PROCESS_DEBUG_INFO, fUnicode, 2) + TEST_FIELD_OFFSET(CREATE_PROCESS_DEBUG_INFO, fUnicode, 36) +} + +static void test_pack_CREATE_THREAD_DEBUG_INFO(void) +{ + /* CREATE_THREAD_DEBUG_INFO (pack 4) */ + TEST_TYPE_SIZE (CREATE_THREAD_DEBUG_INFO, 12) + TEST_TYPE_ALIGN (CREATE_THREAD_DEBUG_INFO, 4) + TEST_FIELD_SIZE (CREATE_THREAD_DEBUG_INFO, hThread, 4) + TEST_FIELD_ALIGN (CREATE_THREAD_DEBUG_INFO, hThread, 4) + TEST_FIELD_OFFSET(CREATE_THREAD_DEBUG_INFO, hThread, 0) + TEST_FIELD_SIZE (CREATE_THREAD_DEBUG_INFO, lpThreadLocalBase, 4) + TEST_FIELD_ALIGN (CREATE_THREAD_DEBUG_INFO, lpThreadLocalBase, 4) + TEST_FIELD_OFFSET(CREATE_THREAD_DEBUG_INFO, lpThreadLocalBase, 4) + TEST_FIELD_SIZE (CREATE_THREAD_DEBUG_INFO, lpStartAddress, 4) + TEST_FIELD_ALIGN (CREATE_THREAD_DEBUG_INFO, lpStartAddress, 4) + TEST_FIELD_OFFSET(CREATE_THREAD_DEBUG_INFO, lpStartAddress, 8) +} + +static void test_pack_CRITICAL_SECTION(void) +{ + /* CRITICAL_SECTION */ + TEST_TYPE_SIZE (CRITICAL_SECTION, 24) + TEST_TYPE_ALIGN (CRITICAL_SECTION, 4) +} + +static void test_pack_CRITICAL_SECTION_DEBUG(void) +{ + /* CRITICAL_SECTION_DEBUG */ +} + +static void test_pack_DCB(void) +{ + /* DCB (pack 4) */ + TEST_TYPE_SIZE (DCB, 28) + TEST_TYPE_ALIGN (DCB, 4) + TEST_FIELD_SIZE (DCB, DCBlength, 4) + TEST_FIELD_ALIGN (DCB, DCBlength, 4) + TEST_FIELD_OFFSET(DCB, DCBlength, 0) + TEST_FIELD_SIZE (DCB, BaudRate, 4) + TEST_FIELD_ALIGN (DCB, BaudRate, 4) + TEST_FIELD_OFFSET(DCB, BaudRate, 4) + TEST_FIELD_SIZE (DCB, wReserved, 2) + TEST_FIELD_ALIGN (DCB, wReserved, 2) + TEST_FIELD_OFFSET(DCB, wReserved, 12) + TEST_FIELD_SIZE (DCB, XonLim, 2) + TEST_FIELD_ALIGN (DCB, XonLim, 2) + TEST_FIELD_OFFSET(DCB, XonLim, 14) + TEST_FIELD_SIZE (DCB, XoffLim, 2) + TEST_FIELD_ALIGN (DCB, XoffLim, 2) + TEST_FIELD_OFFSET(DCB, XoffLim, 16) + TEST_FIELD_SIZE (DCB, ByteSize, 1) + TEST_FIELD_ALIGN (DCB, ByteSize, 1) + TEST_FIELD_OFFSET(DCB, ByteSize, 18) + TEST_FIELD_SIZE (DCB, Parity, 1) + TEST_FIELD_ALIGN (DCB, Parity, 1) + TEST_FIELD_OFFSET(DCB, Parity, 19) + TEST_FIELD_SIZE (DCB, StopBits, 1) + TEST_FIELD_ALIGN (DCB, StopBits, 1) + TEST_FIELD_OFFSET(DCB, StopBits, 20) + TEST_FIELD_SIZE (DCB, XonChar, 1) + TEST_FIELD_ALIGN (DCB, XonChar, 1) + TEST_FIELD_OFFSET(DCB, XonChar, 21) + TEST_FIELD_SIZE (DCB, XoffChar, 1) + TEST_FIELD_ALIGN (DCB, XoffChar, 1) + TEST_FIELD_OFFSET(DCB, XoffChar, 22) + TEST_FIELD_SIZE (DCB, ErrorChar, 1) + TEST_FIELD_ALIGN (DCB, ErrorChar, 1) + TEST_FIELD_OFFSET(DCB, ErrorChar, 23) + TEST_FIELD_SIZE (DCB, EofChar, 1) + TEST_FIELD_ALIGN (DCB, EofChar, 1) + TEST_FIELD_OFFSET(DCB, EofChar, 24) + TEST_FIELD_SIZE (DCB, EvtChar, 1) + TEST_FIELD_ALIGN (DCB, EvtChar, 1) + TEST_FIELD_OFFSET(DCB, EvtChar, 25) + TEST_FIELD_SIZE (DCB, wReserved1, 2) + TEST_FIELD_ALIGN (DCB, wReserved1, 2) + TEST_FIELD_OFFSET(DCB, wReserved1, 26) +} + +static void test_pack_DEBUG_EVENT(void) +{ + /* DEBUG_EVENT (pack 4) */ + TEST_FIELD_SIZE (DEBUG_EVENT, dwDebugEventCode, 4) + TEST_FIELD_ALIGN (DEBUG_EVENT, dwDebugEventCode, 4) + TEST_FIELD_OFFSET(DEBUG_EVENT, dwDebugEventCode, 0) + TEST_FIELD_SIZE (DEBUG_EVENT, dwProcessId, 4) + TEST_FIELD_ALIGN (DEBUG_EVENT, dwProcessId, 4) + TEST_FIELD_OFFSET(DEBUG_EVENT, dwProcessId, 4) + TEST_FIELD_SIZE (DEBUG_EVENT, dwThreadId, 4) + TEST_FIELD_ALIGN (DEBUG_EVENT, dwThreadId, 4) + TEST_FIELD_OFFSET(DEBUG_EVENT, dwThreadId, 8) +} + +static void test_pack_ENUMRESLANGPROCA(void) +{ + /* ENUMRESLANGPROCA */ + TEST_TYPE_SIZE (ENUMRESLANGPROCA, 4) + TEST_TYPE_ALIGN (ENUMRESLANGPROCA, 4) +} + +static void test_pack_ENUMRESLANGPROCW(void) +{ + /* ENUMRESLANGPROCW */ + TEST_TYPE_SIZE (ENUMRESLANGPROCW, 4) + TEST_TYPE_ALIGN (ENUMRESLANGPROCW, 4) +} + +static void test_pack_ENUMRESNAMEPROCA(void) +{ + /* ENUMRESNAMEPROCA */ + TEST_TYPE_SIZE (ENUMRESNAMEPROCA, 4) + TEST_TYPE_ALIGN (ENUMRESNAMEPROCA, 4) +} + +static void test_pack_ENUMRESNAMEPROCW(void) +{ + /* ENUMRESNAMEPROCW */ + TEST_TYPE_SIZE (ENUMRESNAMEPROCW, 4) + TEST_TYPE_ALIGN (ENUMRESNAMEPROCW, 4) +} + +static void test_pack_ENUMRESTYPEPROCA(void) +{ + /* ENUMRESTYPEPROCA */ + TEST_TYPE_SIZE (ENUMRESTYPEPROCA, 4) + TEST_TYPE_ALIGN (ENUMRESTYPEPROCA, 4) +} + +static void test_pack_ENUMRESTYPEPROCW(void) +{ + /* ENUMRESTYPEPROCW */ + TEST_TYPE_SIZE (ENUMRESTYPEPROCW, 4) + TEST_TYPE_ALIGN (ENUMRESTYPEPROCW, 4) +} + +static void test_pack_EXCEPTION_DEBUG_INFO(void) +{ + /* EXCEPTION_DEBUG_INFO (pack 4) */ + TEST_TYPE_SIZE (EXCEPTION_DEBUG_INFO, 84) + TEST_TYPE_ALIGN (EXCEPTION_DEBUG_INFO, 4) + TEST_FIELD_SIZE (EXCEPTION_DEBUG_INFO, ExceptionRecord, 80) + TEST_FIELD_ALIGN (EXCEPTION_DEBUG_INFO, ExceptionRecord, 4) + TEST_FIELD_OFFSET(EXCEPTION_DEBUG_INFO, ExceptionRecord, 0) + TEST_FIELD_SIZE (EXCEPTION_DEBUG_INFO, dwFirstChance, 4) + TEST_FIELD_ALIGN (EXCEPTION_DEBUG_INFO, dwFirstChance, 4) + TEST_FIELD_OFFSET(EXCEPTION_DEBUG_INFO, dwFirstChance, 80) +} + +static void test_pack_EXIT_PROCESS_DEBUG_INFO(void) +{ + /* EXIT_PROCESS_DEBUG_INFO (pack 4) */ + TEST_TYPE_SIZE (EXIT_PROCESS_DEBUG_INFO, 4) + TEST_TYPE_ALIGN (EXIT_PROCESS_DEBUG_INFO, 4) + TEST_FIELD_SIZE (EXIT_PROCESS_DEBUG_INFO, dwExitCode, 4) + TEST_FIELD_ALIGN (EXIT_PROCESS_DEBUG_INFO, dwExitCode, 4) + TEST_FIELD_OFFSET(EXIT_PROCESS_DEBUG_INFO, dwExitCode, 0) +} + +static void test_pack_EXIT_THREAD_DEBUG_INFO(void) +{ + /* EXIT_THREAD_DEBUG_INFO (pack 4) */ + TEST_TYPE_SIZE (EXIT_THREAD_DEBUG_INFO, 4) + TEST_TYPE_ALIGN (EXIT_THREAD_DEBUG_INFO, 4) + TEST_FIELD_SIZE (EXIT_THREAD_DEBUG_INFO, dwExitCode, 4) + TEST_FIELD_ALIGN (EXIT_THREAD_DEBUG_INFO, dwExitCode, 4) + TEST_FIELD_OFFSET(EXIT_THREAD_DEBUG_INFO, dwExitCode, 0) +} + +static void test_pack_HW_PROFILE_INFOA(void) +{ + /* HW_PROFILE_INFOA (pack 4) */ + TEST_TYPE_SIZE (HW_PROFILE_INFOA, 124) + TEST_TYPE_ALIGN (HW_PROFILE_INFOA, 4) + TEST_FIELD_SIZE (HW_PROFILE_INFOA, dwDockInfo, 4) + TEST_FIELD_ALIGN (HW_PROFILE_INFOA, dwDockInfo, 4) + TEST_FIELD_OFFSET(HW_PROFILE_INFOA, dwDockInfo, 0) + TEST_FIELD_SIZE (HW_PROFILE_INFOA, szHwProfileGuid, 39) + TEST_FIELD_ALIGN (HW_PROFILE_INFOA, szHwProfileGuid, 1) + TEST_FIELD_OFFSET(HW_PROFILE_INFOA, szHwProfileGuid, 4) + TEST_FIELD_SIZE (HW_PROFILE_INFOA, szHwProfileName, 80) + TEST_FIELD_ALIGN (HW_PROFILE_INFOA, szHwProfileName, 1) + TEST_FIELD_OFFSET(HW_PROFILE_INFOA, szHwProfileName, 43) +} + +static void test_pack_HW_PROFILE_INFOW(void) +{ + /* HW_PROFILE_INFOW (pack 4) */ + TEST_TYPE_SIZE (HW_PROFILE_INFOW, 244) + TEST_TYPE_ALIGN (HW_PROFILE_INFOW, 4) + TEST_FIELD_SIZE (HW_PROFILE_INFOW, dwDockInfo, 4) + TEST_FIELD_ALIGN (HW_PROFILE_INFOW, dwDockInfo, 4) + TEST_FIELD_OFFSET(HW_PROFILE_INFOW, dwDockInfo, 0) + TEST_FIELD_SIZE (HW_PROFILE_INFOW, szHwProfileGuid, 78) + TEST_FIELD_ALIGN (HW_PROFILE_INFOW, szHwProfileGuid, 2) + TEST_FIELD_OFFSET(HW_PROFILE_INFOW, szHwProfileGuid, 4) + TEST_FIELD_SIZE (HW_PROFILE_INFOW, szHwProfileName, 160) + TEST_FIELD_ALIGN (HW_PROFILE_INFOW, szHwProfileName, 2) + TEST_FIELD_OFFSET(HW_PROFILE_INFOW, szHwProfileName, 82) +} + +static void test_pack_LOAD_DLL_DEBUG_INFO(void) +{ + /* LOAD_DLL_DEBUG_INFO (pack 4) */ + TEST_TYPE_SIZE (LOAD_DLL_DEBUG_INFO, 24) + TEST_TYPE_ALIGN (LOAD_DLL_DEBUG_INFO, 4) + TEST_FIELD_SIZE (LOAD_DLL_DEBUG_INFO, hFile, 4) + TEST_FIELD_ALIGN (LOAD_DLL_DEBUG_INFO, hFile, 4) + TEST_FIELD_OFFSET(LOAD_DLL_DEBUG_INFO, hFile, 0) + TEST_FIELD_SIZE (LOAD_DLL_DEBUG_INFO, lpBaseOfDll, 4) + TEST_FIELD_ALIGN (LOAD_DLL_DEBUG_INFO, lpBaseOfDll, 4) + TEST_FIELD_OFFSET(LOAD_DLL_DEBUG_INFO, lpBaseOfDll, 4) + TEST_FIELD_SIZE (LOAD_DLL_DEBUG_INFO, dwDebugInfoFileOffset, 4) + TEST_FIELD_ALIGN (LOAD_DLL_DEBUG_INFO, dwDebugInfoFileOffset, 4) + TEST_FIELD_OFFSET(LOAD_DLL_DEBUG_INFO, dwDebugInfoFileOffset, 8) + TEST_FIELD_SIZE (LOAD_DLL_DEBUG_INFO, nDebugInfoSize, 4) + TEST_FIELD_ALIGN (LOAD_DLL_DEBUG_INFO, nDebugInfoSize, 4) + TEST_FIELD_OFFSET(LOAD_DLL_DEBUG_INFO, nDebugInfoSize, 12) + TEST_FIELD_SIZE (LOAD_DLL_DEBUG_INFO, lpImageName, 4) + TEST_FIELD_ALIGN (LOAD_DLL_DEBUG_INFO, lpImageName, 4) + TEST_FIELD_OFFSET(LOAD_DLL_DEBUG_INFO, lpImageName, 16) + TEST_FIELD_SIZE (LOAD_DLL_DEBUG_INFO, fUnicode, 2) + TEST_FIELD_ALIGN (LOAD_DLL_DEBUG_INFO, fUnicode, 2) + TEST_FIELD_OFFSET(LOAD_DLL_DEBUG_INFO, fUnicode, 20) +} + +static void test_pack_LPBY_HANDLE_FILE_INFORMATION(void) +{ + /* LPBY_HANDLE_FILE_INFORMATION */ + TEST_TYPE_SIZE (LPBY_HANDLE_FILE_INFORMATION, 4) + TEST_TYPE_ALIGN (LPBY_HANDLE_FILE_INFORMATION, 4) + TEST_TARGET_SIZE (LPBY_HANDLE_FILE_INFORMATION, 52) + TEST_TARGET_ALIGN(LPBY_HANDLE_FILE_INFORMATION, 4) +} + +static void test_pack_LPCOMMCONFIG(void) +{ + /* LPCOMMCONFIG */ + TEST_TYPE_SIZE (LPCOMMCONFIG, 4) + TEST_TYPE_ALIGN (LPCOMMCONFIG, 4) + TEST_TARGET_SIZE (LPCOMMCONFIG, 52) + TEST_TARGET_ALIGN(LPCOMMCONFIG, 4) +} + +static void test_pack_LPCOMMPROP(void) +{ + /* LPCOMMPROP */ + TEST_TYPE_SIZE (LPCOMMPROP, 4) + TEST_TYPE_ALIGN (LPCOMMPROP, 4) + TEST_TARGET_SIZE (LPCOMMPROP, 64) + TEST_TARGET_ALIGN(LPCOMMPROP, 4) +} + +static void test_pack_LPCOMMTIMEOUTS(void) +{ + /* LPCOMMTIMEOUTS */ + TEST_TYPE_SIZE (LPCOMMTIMEOUTS, 4) + TEST_TYPE_ALIGN (LPCOMMTIMEOUTS, 4) + TEST_TARGET_SIZE (LPCOMMTIMEOUTS, 20) + TEST_TARGET_ALIGN(LPCOMMTIMEOUTS, 4) +} + +static void test_pack_LPCOMSTAT(void) +{ + /* LPCOMSTAT */ + TEST_TYPE_SIZE (LPCOMSTAT, 4) + TEST_TYPE_ALIGN (LPCOMSTAT, 4) + TEST_TARGET_SIZE (LPCOMSTAT, 12) + TEST_TARGET_ALIGN(LPCOMSTAT, 4) +} + +static void test_pack_LPCRITICAL_SECTION(void) +{ + /* LPCRITICAL_SECTION */ + TEST_TYPE_SIZE (LPCRITICAL_SECTION, 4) + TEST_TYPE_ALIGN (LPCRITICAL_SECTION, 4) +} + +static void test_pack_LPCRITICAL_SECTION_DEBUG(void) +{ + /* LPCRITICAL_SECTION_DEBUG */ + TEST_TYPE_SIZE (LPCRITICAL_SECTION_DEBUG, 4) + TEST_TYPE_ALIGN (LPCRITICAL_SECTION_DEBUG, 4) +} + +static void test_pack_LPDCB(void) +{ + /* LPDCB */ + TEST_TYPE_SIZE (LPDCB, 4) + TEST_TYPE_ALIGN (LPDCB, 4) + TEST_TARGET_SIZE (LPDCB, 28) + TEST_TARGET_ALIGN(LPDCB, 4) +} + +static void test_pack_LPDEBUG_EVENT(void) +{ + /* LPDEBUG_EVENT */ + TEST_TYPE_SIZE (LPDEBUG_EVENT, 4) + TEST_TYPE_ALIGN (LPDEBUG_EVENT, 4) +} + +static void test_pack_LPEXCEPTION_POINTERS(void) +{ + /* LPEXCEPTION_POINTERS */ + TEST_TYPE_SIZE (LPEXCEPTION_POINTERS, 4) + TEST_TYPE_ALIGN (LPEXCEPTION_POINTERS, 4) +} + +static void test_pack_LPEXCEPTION_RECORD(void) +{ + /* LPEXCEPTION_RECORD */ + TEST_TYPE_SIZE (LPEXCEPTION_RECORD, 4) + TEST_TYPE_ALIGN (LPEXCEPTION_RECORD, 4) +} + +static void test_pack_LPFIBER_START_ROUTINE(void) +{ + /* LPFIBER_START_ROUTINE */ + TEST_TYPE_SIZE (LPFIBER_START_ROUTINE, 4) + TEST_TYPE_ALIGN (LPFIBER_START_ROUTINE, 4) +} + +static void test_pack_LPHW_PROFILE_INFOA(void) +{ + /* LPHW_PROFILE_INFOA */ + TEST_TYPE_SIZE (LPHW_PROFILE_INFOA, 4) + TEST_TYPE_ALIGN (LPHW_PROFILE_INFOA, 4) + TEST_TARGET_SIZE (LPHW_PROFILE_INFOA, 124) + TEST_TARGET_ALIGN(LPHW_PROFILE_INFOA, 4) +} + +static void test_pack_LPHW_PROFILE_INFOW(void) +{ + /* LPHW_PROFILE_INFOW */ + TEST_TYPE_SIZE (LPHW_PROFILE_INFOW, 4) + TEST_TYPE_ALIGN (LPHW_PROFILE_INFOW, 4) + TEST_TARGET_SIZE (LPHW_PROFILE_INFOW, 244) + TEST_TARGET_ALIGN(LPHW_PROFILE_INFOW, 4) +} + +static void test_pack_LPMEMORYSTATUS(void) +{ + /* LPMEMORYSTATUS */ + TEST_TYPE_SIZE (LPMEMORYSTATUS, 4) + TEST_TYPE_ALIGN (LPMEMORYSTATUS, 4) + TEST_TARGET_SIZE (LPMEMORYSTATUS, 32) + TEST_TARGET_ALIGN(LPMEMORYSTATUS, 4) +} + +static void test_pack_LPMEMORYSTATUSEX(void) +{ + /* LPMEMORYSTATUSEX */ + TEST_TYPE_SIZE (LPMEMORYSTATUSEX, 4) + TEST_TYPE_ALIGN (LPMEMORYSTATUSEX, 4) + TEST_TARGET_SIZE (LPMEMORYSTATUSEX, 64) + TEST_TARGET_ALIGN(LPMEMORYSTATUSEX, 8) +} + +static void test_pack_LPOFSTRUCT(void) +{ + /* LPOFSTRUCT */ + TEST_TYPE_SIZE (LPOFSTRUCT, 4) + TEST_TYPE_ALIGN (LPOFSTRUCT, 4) + TEST_TARGET_SIZE (LPOFSTRUCT, 136) + TEST_TARGET_ALIGN(LPOFSTRUCT, 2) +} + +static void test_pack_LPOVERLAPPED(void) +{ + /* LPOVERLAPPED */ + TEST_TYPE_SIZE (LPOVERLAPPED, 4) + TEST_TYPE_ALIGN (LPOVERLAPPED, 4) +} + +static void test_pack_LPOVERLAPPED_COMPLETION_ROUTINE(void) +{ + /* LPOVERLAPPED_COMPLETION_ROUTINE */ + TEST_TYPE_SIZE (LPOVERLAPPED_COMPLETION_ROUTINE, 4) + TEST_TYPE_ALIGN (LPOVERLAPPED_COMPLETION_ROUTINE, 4) +} + +static void test_pack_LPPROCESS_HEAP_ENTRY(void) +{ + /* LPPROCESS_HEAP_ENTRY */ + TEST_TYPE_SIZE (LPPROCESS_HEAP_ENTRY, 4) + TEST_TYPE_ALIGN (LPPROCESS_HEAP_ENTRY, 4) +} + +static void test_pack_LPPROCESS_INFORMATION(void) +{ + /* LPPROCESS_INFORMATION */ + TEST_TYPE_SIZE (LPPROCESS_INFORMATION, 4) + TEST_TYPE_ALIGN (LPPROCESS_INFORMATION, 4) + TEST_TARGET_SIZE (LPPROCESS_INFORMATION, 16) + TEST_TARGET_ALIGN(LPPROCESS_INFORMATION, 4) +} + +static void test_pack_LPPROGRESS_ROUTINE(void) +{ + /* LPPROGRESS_ROUTINE */ + TEST_TYPE_SIZE (LPPROGRESS_ROUTINE, 4) + TEST_TYPE_ALIGN (LPPROGRESS_ROUTINE, 4) +} + +static void test_pack_LPSECURITY_ATTRIBUTES(void) +{ + /* LPSECURITY_ATTRIBUTES */ + TEST_TYPE_SIZE (LPSECURITY_ATTRIBUTES, 4) + TEST_TYPE_ALIGN (LPSECURITY_ATTRIBUTES, 4) + TEST_TARGET_SIZE (LPSECURITY_ATTRIBUTES, 12) + TEST_TARGET_ALIGN(LPSECURITY_ATTRIBUTES, 4) +} + +static void test_pack_LPSTARTUPINFOA(void) +{ + /* LPSTARTUPINFOA */ + TEST_TYPE_SIZE (LPSTARTUPINFOA, 4) + TEST_TYPE_ALIGN (LPSTARTUPINFOA, 4) + TEST_TARGET_SIZE (LPSTARTUPINFOA, 68) + TEST_TARGET_ALIGN(LPSTARTUPINFOA, 4) +} + +static void test_pack_LPSTARTUPINFOW(void) +{ + /* LPSTARTUPINFOW */ + TEST_TYPE_SIZE (LPSTARTUPINFOW, 4) + TEST_TYPE_ALIGN (LPSTARTUPINFOW, 4) + TEST_TARGET_SIZE (LPSTARTUPINFOW, 68) + TEST_TARGET_ALIGN(LPSTARTUPINFOW, 4) +} + +static void test_pack_LPSYSTEMTIME(void) +{ + /* LPSYSTEMTIME */ + TEST_TYPE_SIZE (LPSYSTEMTIME, 4) + TEST_TYPE_ALIGN (LPSYSTEMTIME, 4) + TEST_TARGET_SIZE (LPSYSTEMTIME, 16) + TEST_TARGET_ALIGN(LPSYSTEMTIME, 2) +} + +static void test_pack_LPSYSTEM_INFO(void) +{ + /* LPSYSTEM_INFO */ + TEST_TYPE_SIZE (LPSYSTEM_INFO, 4) + TEST_TYPE_ALIGN (LPSYSTEM_INFO, 4) +} + +static void test_pack_LPSYSTEM_POWER_STATUS(void) +{ + /* LPSYSTEM_POWER_STATUS */ + TEST_TYPE_SIZE (LPSYSTEM_POWER_STATUS, 4) + TEST_TYPE_ALIGN (LPSYSTEM_POWER_STATUS, 4) + TEST_TARGET_SIZE (LPSYSTEM_POWER_STATUS, 12) + TEST_TARGET_ALIGN(LPSYSTEM_POWER_STATUS, 4) +} + +static void test_pack_LPTHREAD_START_ROUTINE(void) +{ + /* LPTHREAD_START_ROUTINE */ + TEST_TYPE_SIZE (LPTHREAD_START_ROUTINE, 4) + TEST_TYPE_ALIGN (LPTHREAD_START_ROUTINE, 4) +} + +static void test_pack_LPTIME_ZONE_INFORMATION(void) +{ + /* LPTIME_ZONE_INFORMATION */ + TEST_TYPE_SIZE (LPTIME_ZONE_INFORMATION, 4) + TEST_TYPE_ALIGN (LPTIME_ZONE_INFORMATION, 4) + TEST_TARGET_SIZE (LPTIME_ZONE_INFORMATION, 172) + TEST_TARGET_ALIGN(LPTIME_ZONE_INFORMATION, 4) +} + +static void test_pack_LPWIN32_FILE_ATTRIBUTE_DATA(void) +{ + /* LPWIN32_FILE_ATTRIBUTE_DATA */ + TEST_TYPE_SIZE (LPWIN32_FILE_ATTRIBUTE_DATA, 4) + TEST_TYPE_ALIGN (LPWIN32_FILE_ATTRIBUTE_DATA, 4) + TEST_TARGET_SIZE (LPWIN32_FILE_ATTRIBUTE_DATA, 36) + TEST_TARGET_ALIGN(LPWIN32_FILE_ATTRIBUTE_DATA, 4) +} + +static void test_pack_LPWIN32_FIND_DATAA(void) +{ + /* LPWIN32_FIND_DATAA */ + TEST_TYPE_SIZE (LPWIN32_FIND_DATAA, 4) + TEST_TYPE_ALIGN (LPWIN32_FIND_DATAA, 4) + TEST_TARGET_SIZE (LPWIN32_FIND_DATAA, 320) + TEST_TARGET_ALIGN(LPWIN32_FIND_DATAA, 4) +} + +static void test_pack_LPWIN32_FIND_DATAW(void) +{ + /* LPWIN32_FIND_DATAW */ + TEST_TYPE_SIZE (LPWIN32_FIND_DATAW, 4) + TEST_TYPE_ALIGN (LPWIN32_FIND_DATAW, 4) + TEST_TARGET_SIZE (LPWIN32_FIND_DATAW, 592) + TEST_TARGET_ALIGN(LPWIN32_FIND_DATAW, 4) +} + +static void test_pack_LPWIN32_STREAM_ID(void) +{ + /* LPWIN32_STREAM_ID */ + TEST_TYPE_SIZE (LPWIN32_STREAM_ID, 4) + TEST_TYPE_ALIGN (LPWIN32_STREAM_ID, 4) + TEST_TARGET_SIZE (LPWIN32_STREAM_ID, 24) + TEST_TARGET_ALIGN(LPWIN32_STREAM_ID, 8) +} + +static void test_pack_MEMORYSTATUS(void) +{ + /* MEMORYSTATUS (pack 4) */ + TEST_TYPE_SIZE (MEMORYSTATUS, 32) + TEST_TYPE_ALIGN (MEMORYSTATUS, 4) + TEST_FIELD_SIZE (MEMORYSTATUS, dwLength, 4) + TEST_FIELD_ALIGN (MEMORYSTATUS, dwLength, 4) + TEST_FIELD_OFFSET(MEMORYSTATUS, dwLength, 0) + TEST_FIELD_SIZE (MEMORYSTATUS, dwMemoryLoad, 4) + TEST_FIELD_ALIGN (MEMORYSTATUS, dwMemoryLoad, 4) + TEST_FIELD_OFFSET(MEMORYSTATUS, dwMemoryLoad, 4) + TEST_FIELD_SIZE (MEMORYSTATUS, dwTotalPhys, 4) + TEST_FIELD_ALIGN (MEMORYSTATUS, dwTotalPhys, 4) + TEST_FIELD_OFFSET(MEMORYSTATUS, dwTotalPhys, 8) + TEST_FIELD_SIZE (MEMORYSTATUS, dwAvailPhys, 4) + TEST_FIELD_ALIGN (MEMORYSTATUS, dwAvailPhys, 4) + TEST_FIELD_OFFSET(MEMORYSTATUS, dwAvailPhys, 12) + TEST_FIELD_SIZE (MEMORYSTATUS, dwTotalPageFile, 4) + TEST_FIELD_ALIGN (MEMORYSTATUS, dwTotalPageFile, 4) + TEST_FIELD_OFFSET(MEMORYSTATUS, dwTotalPageFile, 16) + TEST_FIELD_SIZE (MEMORYSTATUS, dwAvailPageFile, 4) + TEST_FIELD_ALIGN (MEMORYSTATUS, dwAvailPageFile, 4) + TEST_FIELD_OFFSET(MEMORYSTATUS, dwAvailPageFile, 20) + TEST_FIELD_SIZE (MEMORYSTATUS, dwTotalVirtual, 4) + TEST_FIELD_ALIGN (MEMORYSTATUS, dwTotalVirtual, 4) + TEST_FIELD_OFFSET(MEMORYSTATUS, dwTotalVirtual, 24) + TEST_FIELD_SIZE (MEMORYSTATUS, dwAvailVirtual, 4) + TEST_FIELD_ALIGN (MEMORYSTATUS, dwAvailVirtual, 4) + TEST_FIELD_OFFSET(MEMORYSTATUS, dwAvailVirtual, 28) +} + +static void test_pack_MEMORYSTATUSEX(void) +{ + /* MEMORYSTATUSEX (pack 8) */ + TEST_TYPE_SIZE (MEMORYSTATUSEX, 64) + TEST_TYPE_ALIGN (MEMORYSTATUSEX, 8) + TEST_FIELD_SIZE (MEMORYSTATUSEX, dwLength, 4) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, dwLength, 4) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, dwLength, 0) + TEST_FIELD_SIZE (MEMORYSTATUSEX, dwMemoryLoad, 4) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, dwMemoryLoad, 4) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, dwMemoryLoad, 4) + TEST_FIELD_SIZE (MEMORYSTATUSEX, ullTotalPhys, 8) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, ullTotalPhys, 8) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, ullTotalPhys, 8) + TEST_FIELD_SIZE (MEMORYSTATUSEX, ullAvailPhys, 8) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, ullAvailPhys, 8) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, ullAvailPhys, 16) + TEST_FIELD_SIZE (MEMORYSTATUSEX, ullTotalPageFile, 8) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, ullTotalPageFile, 8) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, ullTotalPageFile, 24) + TEST_FIELD_SIZE (MEMORYSTATUSEX, ullAvailPageFile, 8) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, ullAvailPageFile, 8) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, ullAvailPageFile, 32) + TEST_FIELD_SIZE (MEMORYSTATUSEX, ullTotalVirtual, 8) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, ullTotalVirtual, 8) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, ullTotalVirtual, 40) + TEST_FIELD_SIZE (MEMORYSTATUSEX, ullAvailVirtual, 8) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, ullAvailVirtual, 8) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, ullAvailVirtual, 48) + TEST_FIELD_SIZE (MEMORYSTATUSEX, ullAvailExtendedVirtual, 8) + TEST_FIELD_ALIGN (MEMORYSTATUSEX, ullAvailExtendedVirtual, 8) + TEST_FIELD_OFFSET(MEMORYSTATUSEX, ullAvailExtendedVirtual, 56) +} + +static void test_pack_OFSTRUCT(void) +{ + /* OFSTRUCT (pack 4) */ + TEST_TYPE_SIZE (OFSTRUCT, 136) + TEST_TYPE_ALIGN (OFSTRUCT, 2) + TEST_FIELD_SIZE (OFSTRUCT, cBytes, 1) + TEST_FIELD_ALIGN (OFSTRUCT, cBytes, 1) + TEST_FIELD_OFFSET(OFSTRUCT, cBytes, 0) + TEST_FIELD_SIZE (OFSTRUCT, fFixedDisk, 1) + TEST_FIELD_ALIGN (OFSTRUCT, fFixedDisk, 1) + TEST_FIELD_OFFSET(OFSTRUCT, fFixedDisk, 1) + TEST_FIELD_SIZE (OFSTRUCT, nErrCode, 2) + TEST_FIELD_ALIGN (OFSTRUCT, nErrCode, 2) + TEST_FIELD_OFFSET(OFSTRUCT, nErrCode, 2) + TEST_FIELD_SIZE (OFSTRUCT, Reserved1, 2) + TEST_FIELD_ALIGN (OFSTRUCT, Reserved1, 2) + TEST_FIELD_OFFSET(OFSTRUCT, Reserved1, 4) + TEST_FIELD_SIZE (OFSTRUCT, Reserved2, 2) + TEST_FIELD_ALIGN (OFSTRUCT, Reserved2, 2) + TEST_FIELD_OFFSET(OFSTRUCT, Reserved2, 6) + TEST_FIELD_SIZE (OFSTRUCT, szPathName, 128) + TEST_FIELD_ALIGN (OFSTRUCT, szPathName, 1) + TEST_FIELD_OFFSET(OFSTRUCT, szPathName, 8) +} + +static void test_pack_OUTPUT_DEBUG_STRING_INFO(void) +{ + /* OUTPUT_DEBUG_STRING_INFO (pack 4) */ + TEST_TYPE_SIZE (OUTPUT_DEBUG_STRING_INFO, 8) + TEST_TYPE_ALIGN (OUTPUT_DEBUG_STRING_INFO, 4) + TEST_FIELD_SIZE (OUTPUT_DEBUG_STRING_INFO, lpDebugStringData, 4) + TEST_FIELD_ALIGN (OUTPUT_DEBUG_STRING_INFO, lpDebugStringData, 4) + TEST_FIELD_OFFSET(OUTPUT_DEBUG_STRING_INFO, lpDebugStringData, 0) + TEST_FIELD_SIZE (OUTPUT_DEBUG_STRING_INFO, fUnicode, 2) + TEST_FIELD_ALIGN (OUTPUT_DEBUG_STRING_INFO, fUnicode, 2) + TEST_FIELD_OFFSET(OUTPUT_DEBUG_STRING_INFO, fUnicode, 4) + TEST_FIELD_SIZE (OUTPUT_DEBUG_STRING_INFO, nDebugStringLength, 2) + TEST_FIELD_ALIGN (OUTPUT_DEBUG_STRING_INFO, nDebugStringLength, 2) + TEST_FIELD_OFFSET(OUTPUT_DEBUG_STRING_INFO, nDebugStringLength, 6) +} + +static void test_pack_PACTCTXA(void) +{ + /* PACTCTXA */ + TEST_TYPE_SIZE (PACTCTXA, 4) + TEST_TYPE_ALIGN (PACTCTXA, 4) + TEST_TARGET_SIZE (PACTCTXA, 32) + TEST_TARGET_ALIGN(PACTCTXA, 4) +} + +static void test_pack_PACTCTXW(void) +{ + /* PACTCTXW */ + TEST_TYPE_SIZE (PACTCTXW, 4) + TEST_TYPE_ALIGN (PACTCTXW, 4) + TEST_TARGET_SIZE (PACTCTXW, 32) + TEST_TARGET_ALIGN(PACTCTXW, 4) +} + +static void test_pack_PACTCTX_SECTION_KEYED_DATA(void) +{ + /* PACTCTX_SECTION_KEYED_DATA */ + TEST_TYPE_SIZE (PACTCTX_SECTION_KEYED_DATA, 4) + TEST_TYPE_ALIGN (PACTCTX_SECTION_KEYED_DATA, 4) + TEST_TARGET_SIZE (PACTCTX_SECTION_KEYED_DATA, 64) + TEST_TARGET_ALIGN(PACTCTX_SECTION_KEYED_DATA, 4) +} + +static void test_pack_PACTCTX_SECTION_KEYED_DATA_2600(void) +{ + /* PACTCTX_SECTION_KEYED_DATA_2600 */ + TEST_TYPE_SIZE (PACTCTX_SECTION_KEYED_DATA_2600, 4) + TEST_TYPE_ALIGN (PACTCTX_SECTION_KEYED_DATA_2600, 4) + TEST_TARGET_SIZE (PACTCTX_SECTION_KEYED_DATA_2600, 40) + TEST_TARGET_ALIGN(PACTCTX_SECTION_KEYED_DATA_2600, 4) +} + +static void test_pack_PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA(void) +{ + /* PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA */ + TEST_TYPE_SIZE (PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 4) + TEST_TYPE_ALIGN (PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 4) + TEST_TARGET_SIZE (PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 20) + TEST_TARGET_ALIGN(PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 4) +} + +static void test_pack_PACTIVATION_CONTEXT_BASIC_INFORMATION(void) +{ + /* PACTIVATION_CONTEXT_BASIC_INFORMATION */ + TEST_TYPE_SIZE (PACTIVATION_CONTEXT_BASIC_INFORMATION, 4) + TEST_TYPE_ALIGN (PACTIVATION_CONTEXT_BASIC_INFORMATION, 4) + TEST_TARGET_SIZE (PACTIVATION_CONTEXT_BASIC_INFORMATION, 8) + TEST_TARGET_ALIGN(PACTIVATION_CONTEXT_BASIC_INFORMATION, 4) +} + +static void test_pack_PAPCFUNC(void) +{ + /* PAPCFUNC */ + TEST_TYPE_SIZE (PAPCFUNC, 4) + TEST_TYPE_ALIGN (PAPCFUNC, 4) +} + +static void test_pack_PBY_HANDLE_FILE_INFORMATION(void) +{ + /* PBY_HANDLE_FILE_INFORMATION */ + TEST_TYPE_SIZE (PBY_HANDLE_FILE_INFORMATION, 4) + TEST_TYPE_ALIGN (PBY_HANDLE_FILE_INFORMATION, 4) + TEST_TARGET_SIZE (PBY_HANDLE_FILE_INFORMATION, 52) + TEST_TARGET_ALIGN(PBY_HANDLE_FILE_INFORMATION, 4) +} + +static void test_pack_PCACTCTXA(void) +{ + /* PCACTCTXA */ + TEST_TYPE_SIZE (PCACTCTXA, 4) + TEST_TYPE_ALIGN (PCACTCTXA, 4) + TEST_TARGET_SIZE (PCACTCTXA, 32) + TEST_TARGET_ALIGN(PCACTCTXA, 4) +} + +static void test_pack_PCACTCTXW(void) +{ + /* PCACTCTXW */ + TEST_TYPE_SIZE (PCACTCTXW, 4) + TEST_TYPE_ALIGN (PCACTCTXW, 4) + TEST_TARGET_SIZE (PCACTCTXW, 32) + TEST_TARGET_ALIGN(PCACTCTXW, 4) +} + +static void test_pack_PCACTCTX_SECTION_KEYED_DATA(void) +{ + /* PCACTCTX_SECTION_KEYED_DATA */ + TEST_TYPE_SIZE (PCACTCTX_SECTION_KEYED_DATA, 4) + TEST_TYPE_ALIGN (PCACTCTX_SECTION_KEYED_DATA, 4) + TEST_TARGET_SIZE (PCACTCTX_SECTION_KEYED_DATA, 64) + TEST_TARGET_ALIGN(PCACTCTX_SECTION_KEYED_DATA, 4) +} + +static void test_pack_PCACTCTX_SECTION_KEYED_DATA_2600(void) +{ + /* PCACTCTX_SECTION_KEYED_DATA_2600 */ + TEST_TYPE_SIZE (PCACTCTX_SECTION_KEYED_DATA_2600, 4) + TEST_TYPE_ALIGN (PCACTCTX_SECTION_KEYED_DATA_2600, 4) + TEST_TARGET_SIZE (PCACTCTX_SECTION_KEYED_DATA_2600, 40) + TEST_TARGET_ALIGN(PCACTCTX_SECTION_KEYED_DATA_2600, 4) +} + +static void test_pack_PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA(void) +{ + /* PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA */ + TEST_TYPE_SIZE (PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 4) + TEST_TYPE_ALIGN (PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 4) + TEST_TARGET_SIZE (PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 20) + TEST_TARGET_ALIGN(PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, 4) +} + +static void test_pack_PCRITICAL_SECTION(void) +{ + /* PCRITICAL_SECTION */ + TEST_TYPE_SIZE (PCRITICAL_SECTION, 4) + TEST_TYPE_ALIGN (PCRITICAL_SECTION, 4) +} + +static void test_pack_PCRITICAL_SECTION_DEBUG(void) +{ + /* PCRITICAL_SECTION_DEBUG */ + TEST_TYPE_SIZE (PCRITICAL_SECTION_DEBUG, 4) + TEST_TYPE_ALIGN (PCRITICAL_SECTION_DEBUG, 4) +} + +static void test_pack_PFIBER_START_ROUTINE(void) +{ + /* PFIBER_START_ROUTINE */ + TEST_TYPE_SIZE (PFIBER_START_ROUTINE, 4) + TEST_TYPE_ALIGN (PFIBER_START_ROUTINE, 4) +} + +static void test_pack_POFSTRUCT(void) +{ + /* POFSTRUCT */ + TEST_TYPE_SIZE (POFSTRUCT, 4) + TEST_TYPE_ALIGN (POFSTRUCT, 4) + TEST_TARGET_SIZE (POFSTRUCT, 136) + TEST_TARGET_ALIGN(POFSTRUCT, 2) +} + +static void test_pack_PPROCESS_HEAP_ENTRY(void) +{ + /* PPROCESS_HEAP_ENTRY */ + TEST_TYPE_SIZE (PPROCESS_HEAP_ENTRY, 4) + TEST_TYPE_ALIGN (PPROCESS_HEAP_ENTRY, 4) +} + +static void test_pack_PPROCESS_INFORMATION(void) +{ + /* PPROCESS_INFORMATION */ + TEST_TYPE_SIZE (PPROCESS_INFORMATION, 4) + TEST_TYPE_ALIGN (PPROCESS_INFORMATION, 4) + TEST_TARGET_SIZE (PPROCESS_INFORMATION, 16) + TEST_TARGET_ALIGN(PPROCESS_INFORMATION, 4) +} + +static void test_pack_PQUERYACTCTXW_FUNC(void) +{ + /* PQUERYACTCTXW_FUNC */ + TEST_TYPE_SIZE (PQUERYACTCTXW_FUNC, 4) + TEST_TYPE_ALIGN (PQUERYACTCTXW_FUNC, 4) +} + +static void test_pack_PROCESS_HEAP_ENTRY(void) +{ + /* PROCESS_HEAP_ENTRY (pack 4) */ + TEST_FIELD_SIZE (PROCESS_HEAP_ENTRY, lpData, 4) + TEST_FIELD_ALIGN (PROCESS_HEAP_ENTRY, lpData, 4) + TEST_FIELD_OFFSET(PROCESS_HEAP_ENTRY, lpData, 0) + TEST_FIELD_SIZE (PROCESS_HEAP_ENTRY, cbData, 4) + TEST_FIELD_ALIGN (PROCESS_HEAP_ENTRY, cbData, 4) + TEST_FIELD_OFFSET(PROCESS_HEAP_ENTRY, cbData, 4) + TEST_FIELD_SIZE (PROCESS_HEAP_ENTRY, cbOverhead, 1) + TEST_FIELD_ALIGN (PROCESS_HEAP_ENTRY, cbOverhead, 1) + TEST_FIELD_OFFSET(PROCESS_HEAP_ENTRY, cbOverhead, 8) + TEST_FIELD_SIZE (PROCESS_HEAP_ENTRY, iRegionIndex, 1) + TEST_FIELD_ALIGN (PROCESS_HEAP_ENTRY, iRegionIndex, 1) + TEST_FIELD_OFFSET(PROCESS_HEAP_ENTRY, iRegionIndex, 9) + TEST_FIELD_SIZE (PROCESS_HEAP_ENTRY, wFlags, 2) + TEST_FIELD_ALIGN (PROCESS_HEAP_ENTRY, wFlags, 2) + TEST_FIELD_OFFSET(PROCESS_HEAP_ENTRY, wFlags, 10) +} + +static void test_pack_PROCESS_INFORMATION(void) +{ + /* PROCESS_INFORMATION (pack 4) */ + TEST_TYPE_SIZE (PROCESS_INFORMATION, 16) + TEST_TYPE_ALIGN (PROCESS_INFORMATION, 4) + TEST_FIELD_SIZE (PROCESS_INFORMATION, hProcess, 4) + TEST_FIELD_ALIGN (PROCESS_INFORMATION, hProcess, 4) + TEST_FIELD_OFFSET(PROCESS_INFORMATION, hProcess, 0) + TEST_FIELD_SIZE (PROCESS_INFORMATION, hThread, 4) + TEST_FIELD_ALIGN (PROCESS_INFORMATION, hThread, 4) + TEST_FIELD_OFFSET(PROCESS_INFORMATION, hThread, 4) + TEST_FIELD_SIZE (PROCESS_INFORMATION, dwProcessId, 4) + TEST_FIELD_ALIGN (PROCESS_INFORMATION, dwProcessId, 4) + TEST_FIELD_OFFSET(PROCESS_INFORMATION, dwProcessId, 8) + TEST_FIELD_SIZE (PROCESS_INFORMATION, dwThreadId, 4) + TEST_FIELD_ALIGN (PROCESS_INFORMATION, dwThreadId, 4) + TEST_FIELD_OFFSET(PROCESS_INFORMATION, dwThreadId, 12) +} + +static void test_pack_PSECURITY_ATTRIBUTES(void) +{ + /* PSECURITY_ATTRIBUTES */ + TEST_TYPE_SIZE (PSECURITY_ATTRIBUTES, 4) + TEST_TYPE_ALIGN (PSECURITY_ATTRIBUTES, 4) + TEST_TARGET_SIZE (PSECURITY_ATTRIBUTES, 12) + TEST_TARGET_ALIGN(PSECURITY_ATTRIBUTES, 4) +} + +static void test_pack_PSYSTEMTIME(void) +{ + /* PSYSTEMTIME */ + TEST_TYPE_SIZE (PSYSTEMTIME, 4) + TEST_TYPE_ALIGN (PSYSTEMTIME, 4) + TEST_TARGET_SIZE (PSYSTEMTIME, 16) + TEST_TARGET_ALIGN(PSYSTEMTIME, 2) +} + +static void test_pack_PTIMERAPCROUTINE(void) +{ + /* PTIMERAPCROUTINE */ + TEST_TYPE_SIZE (PTIMERAPCROUTINE, 4) + TEST_TYPE_ALIGN (PTIMERAPCROUTINE, 4) +} + +static void test_pack_PTIME_ZONE_INFORMATION(void) +{ + /* PTIME_ZONE_INFORMATION */ + TEST_TYPE_SIZE (PTIME_ZONE_INFORMATION, 4) + TEST_TYPE_ALIGN (PTIME_ZONE_INFORMATION, 4) + TEST_TARGET_SIZE (PTIME_ZONE_INFORMATION, 172) + TEST_TARGET_ALIGN(PTIME_ZONE_INFORMATION, 4) +} + +static void test_pack_PWIN32_FIND_DATAA(void) +{ + /* PWIN32_FIND_DATAA */ + TEST_TYPE_SIZE (PWIN32_FIND_DATAA, 4) + TEST_TYPE_ALIGN (PWIN32_FIND_DATAA, 4) + TEST_TARGET_SIZE (PWIN32_FIND_DATAA, 320) + TEST_TARGET_ALIGN(PWIN32_FIND_DATAA, 4) +} + +static void test_pack_PWIN32_FIND_DATAW(void) +{ + /* PWIN32_FIND_DATAW */ + TEST_TYPE_SIZE (PWIN32_FIND_DATAW, 4) + TEST_TYPE_ALIGN (PWIN32_FIND_DATAW, 4) + TEST_TARGET_SIZE (PWIN32_FIND_DATAW, 592) + TEST_TARGET_ALIGN(PWIN32_FIND_DATAW, 4) +} + +static void test_pack_RIP_INFO(void) +{ + /* RIP_INFO (pack 4) */ + TEST_TYPE_SIZE (RIP_INFO, 8) + TEST_TYPE_ALIGN (RIP_INFO, 4) + TEST_FIELD_SIZE (RIP_INFO, dwError, 4) + TEST_FIELD_ALIGN (RIP_INFO, dwError, 4) + TEST_FIELD_OFFSET(RIP_INFO, dwError, 0) + TEST_FIELD_SIZE (RIP_INFO, dwType, 4) + TEST_FIELD_ALIGN (RIP_INFO, dwType, 4) + TEST_FIELD_OFFSET(RIP_INFO, dwType, 4) +} + +static void test_pack_SECURITY_ATTRIBUTES(void) +{ + /* SECURITY_ATTRIBUTES (pack 4) */ + TEST_TYPE_SIZE (SECURITY_ATTRIBUTES, 12) + TEST_TYPE_ALIGN (SECURITY_ATTRIBUTES, 4) + TEST_FIELD_SIZE (SECURITY_ATTRIBUTES, nLength, 4) + TEST_FIELD_ALIGN (SECURITY_ATTRIBUTES, nLength, 4) + TEST_FIELD_OFFSET(SECURITY_ATTRIBUTES, nLength, 0) + TEST_FIELD_SIZE (SECURITY_ATTRIBUTES, lpSecurityDescriptor, 4) + TEST_FIELD_ALIGN (SECURITY_ATTRIBUTES, lpSecurityDescriptor, 4) + TEST_FIELD_OFFSET(SECURITY_ATTRIBUTES, lpSecurityDescriptor, 4) + TEST_FIELD_SIZE (SECURITY_ATTRIBUTES, bInheritHandle, 4) + TEST_FIELD_ALIGN (SECURITY_ATTRIBUTES, bInheritHandle, 4) + TEST_FIELD_OFFSET(SECURITY_ATTRIBUTES, bInheritHandle, 8) +} + +static void test_pack_STARTUPINFOA(void) +{ + /* STARTUPINFOA (pack 4) */ + TEST_TYPE_SIZE (STARTUPINFOA, 68) + TEST_TYPE_ALIGN (STARTUPINFOA, 4) + TEST_FIELD_SIZE (STARTUPINFOA, cb, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, cb, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, cb, 0) + TEST_FIELD_SIZE (STARTUPINFOA, lpReserved, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, lpReserved, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, lpReserved, 4) + TEST_FIELD_SIZE (STARTUPINFOA, lpDesktop, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, lpDesktop, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, lpDesktop, 8) + TEST_FIELD_SIZE (STARTUPINFOA, lpTitle, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, lpTitle, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, lpTitle, 12) + TEST_FIELD_SIZE (STARTUPINFOA, dwX, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, dwX, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, dwX, 16) + TEST_FIELD_SIZE (STARTUPINFOA, dwY, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, dwY, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, dwY, 20) + TEST_FIELD_SIZE (STARTUPINFOA, dwXSize, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, dwXSize, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, dwXSize, 24) + TEST_FIELD_SIZE (STARTUPINFOA, dwYSize, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, dwYSize, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, dwYSize, 28) + TEST_FIELD_SIZE (STARTUPINFOA, dwXCountChars, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, dwXCountChars, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, dwXCountChars, 32) + TEST_FIELD_SIZE (STARTUPINFOA, dwYCountChars, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, dwYCountChars, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, dwYCountChars, 36) + TEST_FIELD_SIZE (STARTUPINFOA, dwFillAttribute, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, dwFillAttribute, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, dwFillAttribute, 40) + TEST_FIELD_SIZE (STARTUPINFOA, dwFlags, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, dwFlags, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, dwFlags, 44) + TEST_FIELD_SIZE (STARTUPINFOA, wShowWindow, 2) + TEST_FIELD_ALIGN (STARTUPINFOA, wShowWindow, 2) + TEST_FIELD_OFFSET(STARTUPINFOA, wShowWindow, 48) + TEST_FIELD_SIZE (STARTUPINFOA, cbReserved2, 2) + TEST_FIELD_ALIGN (STARTUPINFOA, cbReserved2, 2) + TEST_FIELD_OFFSET(STARTUPINFOA, cbReserved2, 50) + TEST_FIELD_SIZE (STARTUPINFOA, lpReserved2, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, lpReserved2, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, lpReserved2, 52) + TEST_FIELD_SIZE (STARTUPINFOA, hStdInput, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, hStdInput, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, hStdInput, 56) + TEST_FIELD_SIZE (STARTUPINFOA, hStdOutput, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, hStdOutput, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, hStdOutput, 60) + TEST_FIELD_SIZE (STARTUPINFOA, hStdError, 4) + TEST_FIELD_ALIGN (STARTUPINFOA, hStdError, 4) + TEST_FIELD_OFFSET(STARTUPINFOA, hStdError, 64) +} + +static void test_pack_STARTUPINFOW(void) +{ + /* STARTUPINFOW (pack 4) */ + TEST_TYPE_SIZE (STARTUPINFOW, 68) + TEST_TYPE_ALIGN (STARTUPINFOW, 4) + TEST_FIELD_SIZE (STARTUPINFOW, cb, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, cb, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, cb, 0) + TEST_FIELD_SIZE (STARTUPINFOW, lpReserved, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, lpReserved, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, lpReserved, 4) + TEST_FIELD_SIZE (STARTUPINFOW, lpDesktop, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, lpDesktop, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, lpDesktop, 8) + TEST_FIELD_SIZE (STARTUPINFOW, lpTitle, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, lpTitle, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, lpTitle, 12) + TEST_FIELD_SIZE (STARTUPINFOW, dwX, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, dwX, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, dwX, 16) + TEST_FIELD_SIZE (STARTUPINFOW, dwY, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, dwY, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, dwY, 20) + TEST_FIELD_SIZE (STARTUPINFOW, dwXSize, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, dwXSize, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, dwXSize, 24) + TEST_FIELD_SIZE (STARTUPINFOW, dwYSize, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, dwYSize, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, dwYSize, 28) + TEST_FIELD_SIZE (STARTUPINFOW, dwXCountChars, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, dwXCountChars, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, dwXCountChars, 32) + TEST_FIELD_SIZE (STARTUPINFOW, dwYCountChars, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, dwYCountChars, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, dwYCountChars, 36) + TEST_FIELD_SIZE (STARTUPINFOW, dwFillAttribute, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, dwFillAttribute, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, dwFillAttribute, 40) + TEST_FIELD_SIZE (STARTUPINFOW, dwFlags, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, dwFlags, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, dwFlags, 44) + TEST_FIELD_SIZE (STARTUPINFOW, wShowWindow, 2) + TEST_FIELD_ALIGN (STARTUPINFOW, wShowWindow, 2) + TEST_FIELD_OFFSET(STARTUPINFOW, wShowWindow, 48) + TEST_FIELD_SIZE (STARTUPINFOW, cbReserved2, 2) + TEST_FIELD_ALIGN (STARTUPINFOW, cbReserved2, 2) + TEST_FIELD_OFFSET(STARTUPINFOW, cbReserved2, 50) + TEST_FIELD_SIZE (STARTUPINFOW, lpReserved2, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, lpReserved2, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, lpReserved2, 52) + TEST_FIELD_SIZE (STARTUPINFOW, hStdInput, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, hStdInput, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, hStdInput, 56) + TEST_FIELD_SIZE (STARTUPINFOW, hStdOutput, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, hStdOutput, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, hStdOutput, 60) + TEST_FIELD_SIZE (STARTUPINFOW, hStdError, 4) + TEST_FIELD_ALIGN (STARTUPINFOW, hStdError, 4) + TEST_FIELD_OFFSET(STARTUPINFOW, hStdError, 64) +} + +static void test_pack_SYSTEMTIME(void) +{ + /* SYSTEMTIME (pack 4) */ + TEST_TYPE_SIZE (SYSTEMTIME, 16) + TEST_TYPE_ALIGN (SYSTEMTIME, 2) + TEST_FIELD_SIZE (SYSTEMTIME, wYear, 2) + TEST_FIELD_ALIGN (SYSTEMTIME, wYear, 2) + TEST_FIELD_OFFSET(SYSTEMTIME, wYear, 0) + TEST_FIELD_SIZE (SYSTEMTIME, wMonth, 2) + TEST_FIELD_ALIGN (SYSTEMTIME, wMonth, 2) + TEST_FIELD_OFFSET(SYSTEMTIME, wMonth, 2) + TEST_FIELD_SIZE (SYSTEMTIME, wDayOfWeek, 2) + TEST_FIELD_ALIGN (SYSTEMTIME, wDayOfWeek, 2) + TEST_FIELD_OFFSET(SYSTEMTIME, wDayOfWeek, 4) + TEST_FIELD_SIZE (SYSTEMTIME, wDay, 2) + TEST_FIELD_ALIGN (SYSTEMTIME, wDay, 2) + TEST_FIELD_OFFSET(SYSTEMTIME, wDay, 6) + TEST_FIELD_SIZE (SYSTEMTIME, wHour, 2) + TEST_FIELD_ALIGN (SYSTEMTIME, wHour, 2) + TEST_FIELD_OFFSET(SYSTEMTIME, wHour, 8) + TEST_FIELD_SIZE (SYSTEMTIME, wMinute, 2) + TEST_FIELD_ALIGN (SYSTEMTIME, wMinute, 2) + TEST_FIELD_OFFSET(SYSTEMTIME, wMinute, 10) + TEST_FIELD_SIZE (SYSTEMTIME, wSecond, 2) + TEST_FIELD_ALIGN (SYSTEMTIME, wSecond, 2) + TEST_FIELD_OFFSET(SYSTEMTIME, wSecond, 12) + TEST_FIELD_SIZE (SYSTEMTIME, wMilliseconds, 2) + TEST_FIELD_ALIGN (SYSTEMTIME, wMilliseconds, 2) + TEST_FIELD_OFFSET(SYSTEMTIME, wMilliseconds, 14) +} + +static void test_pack_SYSTEM_INFO(void) +{ + /* SYSTEM_INFO (pack 4) */ +} + +static void test_pack_SYSTEM_POWER_STATUS(void) +{ + /* SYSTEM_POWER_STATUS (pack 4) */ + TEST_TYPE_SIZE (SYSTEM_POWER_STATUS, 12) + TEST_TYPE_ALIGN (SYSTEM_POWER_STATUS, 4) + TEST_FIELD_SIZE (SYSTEM_POWER_STATUS, ACLineStatus, 1) + TEST_FIELD_ALIGN (SYSTEM_POWER_STATUS, ACLineStatus, 1) + TEST_FIELD_OFFSET(SYSTEM_POWER_STATUS, ACLineStatus, 0) + TEST_FIELD_SIZE (SYSTEM_POWER_STATUS, BatteryFlag, 1) + TEST_FIELD_ALIGN (SYSTEM_POWER_STATUS, BatteryFlag, 1) + TEST_FIELD_OFFSET(SYSTEM_POWER_STATUS, BatteryFlag, 1) + TEST_FIELD_SIZE (SYSTEM_POWER_STATUS, BatteryLifePercent, 1) + TEST_FIELD_ALIGN (SYSTEM_POWER_STATUS, BatteryLifePercent, 1) + TEST_FIELD_OFFSET(SYSTEM_POWER_STATUS, BatteryLifePercent, 2) + TEST_FIELD_SIZE (SYSTEM_POWER_STATUS, Reserved1, 1) + TEST_FIELD_ALIGN (SYSTEM_POWER_STATUS, Reserved1, 1) + TEST_FIELD_OFFSET(SYSTEM_POWER_STATUS, Reserved1, 3) + TEST_FIELD_SIZE (SYSTEM_POWER_STATUS, BatteryLifeTime, 4) + TEST_FIELD_ALIGN (SYSTEM_POWER_STATUS, BatteryLifeTime, 4) + TEST_FIELD_OFFSET(SYSTEM_POWER_STATUS, BatteryLifeTime, 4) + TEST_FIELD_SIZE (SYSTEM_POWER_STATUS, BatteryFullLifeTime, 4) + TEST_FIELD_ALIGN (SYSTEM_POWER_STATUS, BatteryFullLifeTime, 4) + TEST_FIELD_OFFSET(SYSTEM_POWER_STATUS, BatteryFullLifeTime, 8) +} + +static void test_pack_TIME_ZONE_INFORMATION(void) +{ + /* TIME_ZONE_INFORMATION (pack 4) */ + TEST_TYPE_SIZE (TIME_ZONE_INFORMATION, 172) + TEST_TYPE_ALIGN (TIME_ZONE_INFORMATION, 4) + TEST_FIELD_SIZE (TIME_ZONE_INFORMATION, Bias, 4) + TEST_FIELD_ALIGN (TIME_ZONE_INFORMATION, Bias, 4) + TEST_FIELD_OFFSET(TIME_ZONE_INFORMATION, Bias, 0) + TEST_FIELD_SIZE (TIME_ZONE_INFORMATION, StandardName, 64) + TEST_FIELD_ALIGN (TIME_ZONE_INFORMATION, StandardName, 2) + TEST_FIELD_OFFSET(TIME_ZONE_INFORMATION, StandardName, 4) + TEST_FIELD_SIZE (TIME_ZONE_INFORMATION, StandardDate, 16) + TEST_FIELD_ALIGN (TIME_ZONE_INFORMATION, StandardDate, 2) + TEST_FIELD_OFFSET(TIME_ZONE_INFORMATION, StandardDate, 68) + TEST_FIELD_SIZE (TIME_ZONE_INFORMATION, StandardBias, 4) + TEST_FIELD_ALIGN (TIME_ZONE_INFORMATION, StandardBias, 4) + TEST_FIELD_OFFSET(TIME_ZONE_INFORMATION, StandardBias, 84) + TEST_FIELD_SIZE (TIME_ZONE_INFORMATION, DaylightName, 64) + TEST_FIELD_ALIGN (TIME_ZONE_INFORMATION, DaylightName, 2) + TEST_FIELD_OFFSET(TIME_ZONE_INFORMATION, DaylightName, 88) + TEST_FIELD_SIZE (TIME_ZONE_INFORMATION, DaylightDate, 16) + TEST_FIELD_ALIGN (TIME_ZONE_INFORMATION, DaylightDate, 2) + TEST_FIELD_OFFSET(TIME_ZONE_INFORMATION, DaylightDate, 152) + TEST_FIELD_SIZE (TIME_ZONE_INFORMATION, DaylightBias, 4) + TEST_FIELD_ALIGN (TIME_ZONE_INFORMATION, DaylightBias, 4) + TEST_FIELD_OFFSET(TIME_ZONE_INFORMATION, DaylightBias, 168) +} + +static void test_pack_UNLOAD_DLL_DEBUG_INFO(void) +{ + /* UNLOAD_DLL_DEBUG_INFO (pack 4) */ + TEST_TYPE_SIZE (UNLOAD_DLL_DEBUG_INFO, 4) + TEST_TYPE_ALIGN (UNLOAD_DLL_DEBUG_INFO, 4) + TEST_FIELD_SIZE (UNLOAD_DLL_DEBUG_INFO, lpBaseOfDll, 4) + TEST_FIELD_ALIGN (UNLOAD_DLL_DEBUG_INFO, lpBaseOfDll, 4) + TEST_FIELD_OFFSET(UNLOAD_DLL_DEBUG_INFO, lpBaseOfDll, 0) +} + +static void test_pack_WAITORTIMERCALLBACK(void) +{ + /* WAITORTIMERCALLBACK */ + TEST_TYPE_SIZE (WAITORTIMERCALLBACK, 4) + TEST_TYPE_ALIGN (WAITORTIMERCALLBACK, 4) +} + +static void test_pack_WIN32_FILE_ATTRIBUTE_DATA(void) +{ + /* WIN32_FILE_ATTRIBUTE_DATA (pack 4) */ + TEST_TYPE_SIZE (WIN32_FILE_ATTRIBUTE_DATA, 36) + TEST_TYPE_ALIGN (WIN32_FILE_ATTRIBUTE_DATA, 4) + TEST_FIELD_SIZE (WIN32_FILE_ATTRIBUTE_DATA, dwFileAttributes, 4) + TEST_FIELD_ALIGN (WIN32_FILE_ATTRIBUTE_DATA, dwFileAttributes, 4) + TEST_FIELD_OFFSET(WIN32_FILE_ATTRIBUTE_DATA, dwFileAttributes, 0) + TEST_FIELD_SIZE (WIN32_FILE_ATTRIBUTE_DATA, ftCreationTime, 8) + TEST_FIELD_ALIGN (WIN32_FILE_ATTRIBUTE_DATA, ftCreationTime, 4) + TEST_FIELD_OFFSET(WIN32_FILE_ATTRIBUTE_DATA, ftCreationTime, 4) + TEST_FIELD_SIZE (WIN32_FILE_ATTRIBUTE_DATA, ftLastAccessTime, 8) + TEST_FIELD_ALIGN (WIN32_FILE_ATTRIBUTE_DATA, ftLastAccessTime, 4) + TEST_FIELD_OFFSET(WIN32_FILE_ATTRIBUTE_DATA, ftLastAccessTime, 12) + TEST_FIELD_SIZE (WIN32_FILE_ATTRIBUTE_DATA, ftLastWriteTime, 8) + TEST_FIELD_ALIGN (WIN32_FILE_ATTRIBUTE_DATA, ftLastWriteTime, 4) + TEST_FIELD_OFFSET(WIN32_FILE_ATTRIBUTE_DATA, ftLastWriteTime, 20) + TEST_FIELD_SIZE (WIN32_FILE_ATTRIBUTE_DATA, nFileSizeHigh, 4) + TEST_FIELD_ALIGN (WIN32_FILE_ATTRIBUTE_DATA, nFileSizeHigh, 4) + TEST_FIELD_OFFSET(WIN32_FILE_ATTRIBUTE_DATA, nFileSizeHigh, 28) + TEST_FIELD_SIZE (WIN32_FILE_ATTRIBUTE_DATA, nFileSizeLow, 4) + TEST_FIELD_ALIGN (WIN32_FILE_ATTRIBUTE_DATA, nFileSizeLow, 4) + TEST_FIELD_OFFSET(WIN32_FILE_ATTRIBUTE_DATA, nFileSizeLow, 32) +} + +static void test_pack_WIN32_FIND_DATAA(void) +{ + /* WIN32_FIND_DATAA (pack 4) */ + TEST_TYPE_SIZE (WIN32_FIND_DATAA, 320) + TEST_TYPE_ALIGN (WIN32_FIND_DATAA, 4) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, dwFileAttributes, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, dwFileAttributes, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, dwFileAttributes, 0) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, ftCreationTime, 8) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, ftCreationTime, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, ftCreationTime, 4) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, ftLastAccessTime, 8) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, ftLastAccessTime, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, ftLastAccessTime, 12) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, ftLastWriteTime, 8) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, ftLastWriteTime, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, ftLastWriteTime, 20) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, nFileSizeHigh, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, nFileSizeHigh, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, nFileSizeHigh, 28) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, nFileSizeLow, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, nFileSizeLow, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, nFileSizeLow, 32) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, dwReserved0, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, dwReserved0, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, dwReserved0, 36) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, dwReserved1, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, dwReserved1, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, dwReserved1, 40) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, cFileName, 260) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, cFileName, 1) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, cFileName, 44) + TEST_FIELD_SIZE (WIN32_FIND_DATAA, cAlternateFileName, 14) + TEST_FIELD_ALIGN (WIN32_FIND_DATAA, cAlternateFileName, 1) + TEST_FIELD_OFFSET(WIN32_FIND_DATAA, cAlternateFileName, 304) +} + +static void test_pack_WIN32_FIND_DATAW(void) +{ + /* WIN32_FIND_DATAW (pack 4) */ + TEST_TYPE_SIZE (WIN32_FIND_DATAW, 592) + TEST_TYPE_ALIGN (WIN32_FIND_DATAW, 4) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, dwFileAttributes, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, dwFileAttributes, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, dwFileAttributes, 0) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, ftCreationTime, 8) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, ftCreationTime, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, ftCreationTime, 4) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, ftLastAccessTime, 8) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, ftLastAccessTime, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, ftLastAccessTime, 12) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, ftLastWriteTime, 8) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, ftLastWriteTime, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, ftLastWriteTime, 20) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, nFileSizeHigh, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, nFileSizeHigh, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, nFileSizeHigh, 28) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, nFileSizeLow, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, nFileSizeLow, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, nFileSizeLow, 32) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, dwReserved0, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, dwReserved0, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, dwReserved0, 36) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, dwReserved1, 4) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, dwReserved1, 4) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, dwReserved1, 40) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, cFileName, 520) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, cFileName, 2) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, cFileName, 44) + TEST_FIELD_SIZE (WIN32_FIND_DATAW, cAlternateFileName, 28) + TEST_FIELD_ALIGN (WIN32_FIND_DATAW, cAlternateFileName, 2) + TEST_FIELD_OFFSET(WIN32_FIND_DATAW, cAlternateFileName, 564) +} + +static void test_pack_WIN32_STREAM_ID(void) +{ + /* WIN32_STREAM_ID (pack 8) */ + TEST_TYPE_SIZE (WIN32_STREAM_ID, 24) + TEST_TYPE_ALIGN (WIN32_STREAM_ID, 8) + TEST_FIELD_SIZE (WIN32_STREAM_ID, dwStreamId, 4) + TEST_FIELD_ALIGN (WIN32_STREAM_ID, dwStreamId, 4) + TEST_FIELD_OFFSET(WIN32_STREAM_ID, dwStreamId, 0) + TEST_FIELD_SIZE (WIN32_STREAM_ID, dwStreamAttributes, 4) + TEST_FIELD_ALIGN (WIN32_STREAM_ID, dwStreamAttributes, 4) + TEST_FIELD_OFFSET(WIN32_STREAM_ID, dwStreamAttributes, 4) + TEST_FIELD_SIZE (WIN32_STREAM_ID, Size, 8) + TEST_FIELD_ALIGN (WIN32_STREAM_ID, Size, 8) + TEST_FIELD_OFFSET(WIN32_STREAM_ID, Size, 8) + TEST_FIELD_SIZE (WIN32_STREAM_ID, dwStreamNameSize, 4) + TEST_FIELD_ALIGN (WIN32_STREAM_ID, dwStreamNameSize, 4) + TEST_FIELD_OFFSET(WIN32_STREAM_ID, dwStreamNameSize, 16) + TEST_FIELD_SIZE (WIN32_STREAM_ID, cStreamName, 2) + TEST_FIELD_ALIGN (WIN32_STREAM_ID, cStreamName, 2) + TEST_FIELD_OFFSET(WIN32_STREAM_ID, cStreamName, 20) +} + +static void test_pack(void) +{ + test_pack_ACTCTXA(); + test_pack_ACTCTXW(); + test_pack_ACTCTX_SECTION_KEYED_DATA(); + test_pack_ACTCTX_SECTION_KEYED_DATA_2600(); + test_pack_ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA(); + test_pack_ACTIVATION_CONTEXT_BASIC_INFORMATION(); + test_pack_BY_HANDLE_FILE_INFORMATION(); + test_pack_COMMCONFIG(); + test_pack_COMMPROP(); + test_pack_COMMTIMEOUTS(); + test_pack_COMSTAT(); + test_pack_CREATE_PROCESS_DEBUG_INFO(); + test_pack_CREATE_THREAD_DEBUG_INFO(); + test_pack_CRITICAL_SECTION(); + test_pack_CRITICAL_SECTION_DEBUG(); + test_pack_DCB(); + test_pack_DEBUG_EVENT(); + test_pack_ENUMRESLANGPROCA(); + test_pack_ENUMRESLANGPROCW(); + test_pack_ENUMRESNAMEPROCA(); + test_pack_ENUMRESNAMEPROCW(); + test_pack_ENUMRESTYPEPROCA(); + test_pack_ENUMRESTYPEPROCW(); + test_pack_EXCEPTION_DEBUG_INFO(); + test_pack_EXIT_PROCESS_DEBUG_INFO(); + test_pack_EXIT_THREAD_DEBUG_INFO(); + test_pack_HW_PROFILE_INFOA(); + test_pack_HW_PROFILE_INFOW(); + test_pack_LOAD_DLL_DEBUG_INFO(); + test_pack_LPBY_HANDLE_FILE_INFORMATION(); + test_pack_LPCOMMCONFIG(); + test_pack_LPCOMMPROP(); + test_pack_LPCOMMTIMEOUTS(); + test_pack_LPCOMSTAT(); + test_pack_LPCRITICAL_SECTION(); + test_pack_LPCRITICAL_SECTION_DEBUG(); + test_pack_LPDCB(); + test_pack_LPDEBUG_EVENT(); + test_pack_LPEXCEPTION_POINTERS(); + test_pack_LPEXCEPTION_RECORD(); + test_pack_LPFIBER_START_ROUTINE(); + test_pack_LPHW_PROFILE_INFOA(); + test_pack_LPHW_PROFILE_INFOW(); + test_pack_LPLONG(); + test_pack_LPMEMORYSTATUS(); + test_pack_LPMEMORYSTATUSEX(); + test_pack_LPOFSTRUCT(); + test_pack_LPOSVERSIONINFOA(); + test_pack_LPOSVERSIONINFOEXA(); + test_pack_LPOSVERSIONINFOEXW(); + test_pack_LPOSVERSIONINFOW(); + test_pack_LPOVERLAPPED(); + test_pack_LPOVERLAPPED_COMPLETION_ROUTINE(); + test_pack_LPPROCESS_HEAP_ENTRY(); + test_pack_LPPROCESS_INFORMATION(); + test_pack_LPPROGRESS_ROUTINE(); + test_pack_LPSECURITY_ATTRIBUTES(); + test_pack_LPSTARTUPINFOA(); + test_pack_LPSTARTUPINFOW(); + test_pack_LPSYSTEMTIME(); + test_pack_LPSYSTEM_INFO(); + test_pack_LPSYSTEM_POWER_STATUS(); + test_pack_LPTHREAD_START_ROUTINE(); + test_pack_LPTIME_ZONE_INFORMATION(); + test_pack_LPVOID(); + test_pack_LPWIN32_FILE_ATTRIBUTE_DATA(); + test_pack_LPWIN32_FIND_DATAA(); + test_pack_LPWIN32_FIND_DATAW(); + test_pack_LPWIN32_STREAM_ID(); + test_pack_MEMORYSTATUS(); + test_pack_MEMORYSTATUSEX(); + test_pack_OFSTRUCT(); + test_pack_OSVERSIONINFOA(); + test_pack_OSVERSIONINFOEXA(); + test_pack_OSVERSIONINFOEXW(); + test_pack_OSVERSIONINFOW(); + test_pack_OUTPUT_DEBUG_STRING_INFO(); + test_pack_PACTCTXA(); + test_pack_PACTCTXW(); + test_pack_PACTCTX_SECTION_KEYED_DATA(); + test_pack_PACTCTX_SECTION_KEYED_DATA_2600(); + test_pack_PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA(); + test_pack_PACTIVATION_CONTEXT_BASIC_INFORMATION(); + test_pack_PAPCFUNC(); + test_pack_PBY_HANDLE_FILE_INFORMATION(); + test_pack_PCACTCTXA(); + test_pack_PCACTCTXW(); + test_pack_PCACTCTX_SECTION_KEYED_DATA(); + test_pack_PCACTCTX_SECTION_KEYED_DATA_2600(); + test_pack_PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA(); + test_pack_PCRITICAL_SECTION(); + test_pack_PCRITICAL_SECTION_DEBUG(); + test_pack_PFIBER_START_ROUTINE(); + test_pack_PHKEY(); + test_pack_POFSTRUCT(); + test_pack_POSVERSIONINFOA(); + test_pack_POSVERSIONINFOEXA(); + test_pack_POSVERSIONINFOEXW(); + test_pack_POSVERSIONINFOW(); + test_pack_PPROCESS_HEAP_ENTRY(); + test_pack_PPROCESS_INFORMATION(); + test_pack_PQUERYACTCTXW_FUNC(); + test_pack_PROCESS_HEAP_ENTRY(); + test_pack_PROCESS_INFORMATION(); + test_pack_PSECURITY_ATTRIBUTES(); + test_pack_PSYSTEMTIME(); + test_pack_PTIMERAPCROUTINE(); + test_pack_PTIME_ZONE_INFORMATION(); + test_pack_PWIN32_FIND_DATAA(); + test_pack_PWIN32_FIND_DATAW(); + test_pack_RIP_INFO(); + test_pack_SECURITY_ATTRIBUTES(); + test_pack_STARTUPINFOA(); + test_pack_STARTUPINFOW(); + test_pack_SYSTEMTIME(); + test_pack_SYSTEM_INFO(); + test_pack_SYSTEM_POWER_STATUS(); + test_pack_TIME_ZONE_INFORMATION(); + test_pack_UNLOAD_DLL_DEBUG_INFO(); + test_pack_WAITORTIMERCALLBACK(); + test_pack_WIN32_FILE_ATTRIBUTE_DATA(); + test_pack_WIN32_FIND_DATAA(); + test_pack_WIN32_FIND_DATAW(); + test_pack_WIN32_STREAM_ID(); +} + +START_TEST(generated) +{ +#ifdef _WIN64 + ok(0, "The type size / alignment tests don't support Win64 yet\n"); +#else + test_pack(); +#endif +} diff --git a/rostests/winetests/kernel32/heap.c b/rostests/winetests/kernel32/heap.c index 56f9744a4d2..7c755b9d509 100755 --- a/rostests/winetests/kernel32/heap.c +++ b/rostests/winetests/kernel32/heap.c @@ -21,14 +21,34 @@ #include #include +#include + +#define WIN32_NO_STATUS +#include +#define NTOS_MODE_USER +#include -#include "windef.h" -#include "winbase.h" #include "wine/test.h" + #define MAGIC_DEAD 0xdeadbeef +/* some undocumented flags (names are made up) */ +#define HEAP_PAGE_ALLOCS 0x01000000 +#define HEAP_VALIDATE 0x10000000 +#define HEAP_VALIDATE_ALL 0x20000000 +#define HEAP_VALIDATE_PARAMS 0x40000000 + static BOOL (WINAPI *pHeapQueryInformation)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T); +static ULONG (WINAPI *pRtlGetNtGlobalFlags)(void); + +struct heap_layout +{ + DWORD_PTR unknown[2]; + DWORD pattern; + DWORD flags; + DWORD force_flags; +}; static SIZE_T resize_9x(SIZE_T size) { @@ -467,8 +487,307 @@ static void test_HeapQueryInformation(void) ok(info == 0 || info == 1 || info == 2, "expected 0, 1 or 2, got %u\n", info); } +static void test_heap_checks( DWORD flags ) +{ + BYTE old, *p, *p2; + BOOL ret; + SIZE_T i, size, large_size = 3000 * 1024 + 37; + + if (flags & HEAP_PAGE_ALLOCS) return; /* no tests for that case yet */ + trace( "testing heap flags %08x\n", flags ); + + p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 17 ); + ok( p != NULL, "HeapAlloc failed\n" ); + + ret = HeapValidate( GetProcessHeap(), 0, p ); + ok( ret, "HeapValidate failed\n" ); + + size = HeapSize( GetProcessHeap(), 0, p ); + ok( size == 17, "Wrong size %lu\n", size ); + + ok( p[14] == 0, "wrong data %x\n", p[14] ); + ok( p[15] == 0, "wrong data %x\n", p[15] ); + ok( p[16] == 0, "wrong data %x\n", p[16] ); + + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + ok( p[17] == 0xab, "wrong padding %x\n", p[17] ); + ok( p[18] == 0xab, "wrong padding %x\n", p[18] ); + ok( p[19] == 0xab, "wrong padding %x\n", p[19] ); + } + + p2 = HeapReAlloc( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, p, 14 ); + if (p2 == p) + { + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + ok( p[14] == 0xab, "wrong padding %x\n", p[14] ); + ok( p[15] == 0xab, "wrong padding %x\n", p[15] ); + ok( p[16] == 0xab, "wrong padding %x\n", p[16] ); + } + else + { + ok( p[14] == 0, "wrong padding %x\n", p[14] ); + ok( p[15] == 0, "wrong padding %x\n", p[15] ); + } + } + else skip( "realloc in place failed\n "); + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( ret, "HeapFree failed\n" ); + + p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 17 ); + ok( p != NULL, "HeapAlloc failed\n" ); + old = p[17]; + p[17] = 0xcc; + + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + ret = HeapValidate( GetProcessHeap(), 0, p ); + ok( !ret, "HeapValidate succeeded\n" ); + + /* other calls only check when HEAP_VALIDATE is set */ + if (flags & HEAP_VALIDATE) + { + size = HeapSize( GetProcessHeap(), 0, p ); + ok( size == ~(SIZE_T)0 || broken(size == ~0u), "Wrong size %lu\n", size ); + + p2 = HeapReAlloc( GetProcessHeap(), 0, p, 14 ); + ok( p2 == NULL, "HeapReAlloc succeeded\n" ); + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( !ret || broken(sizeof(void*) == 8), /* not caught on xp64 */ + "HeapFree succeeded\n" ); + } + + p[17] = old; + size = HeapSize( GetProcessHeap(), 0, p ); + ok( size == 17, "Wrong size %lu\n", size ); + + p2 = HeapReAlloc( GetProcessHeap(), 0, p, 14 ); + ok( p2 != NULL, "HeapReAlloc failed\n" ); + p = p2; + } + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( ret, "HeapFree failed\n" ); + + p = HeapAlloc( GetProcessHeap(), 0, 37 ); + ok( p != NULL, "HeapAlloc failed\n" ); + memset( p, 0xcc, 37 ); + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( ret, "HeapFree failed\n" ); + + if (flags & HEAP_FREE_CHECKING_ENABLED) + { + ok( p[16] == 0xee, "wrong data %x\n", p[16] ); + ok( p[17] == 0xfe, "wrong data %x\n", p[17] ); + ok( p[18] == 0xee, "wrong data %x\n", p[18] ); + ok( p[19] == 0xfe, "wrong data %x\n", p[19] ); + + ret = HeapValidate( GetProcessHeap(), 0, NULL ); + ok( ret, "HeapValidate failed\n" ); + + old = p[16]; + p[16] = 0xcc; + ret = HeapValidate( GetProcessHeap(), 0, NULL ); + ok( !ret, "HeapValidate succeeded\n" ); + + p[16] = old; + ret = HeapValidate( GetProcessHeap(), 0, NULL ); + ok( ret, "HeapValidate failed\n" ); + } + + /* now test large blocks */ + + p = HeapAlloc( GetProcessHeap(), 0, large_size ); + ok( p != NULL, "HeapAlloc failed\n" ); + + ret = HeapValidate( GetProcessHeap(), 0, p ); + ok( ret, "HeapValidate failed\n" ); + + size = HeapSize( GetProcessHeap(), 0, p ); + ok( size == large_size, "Wrong size %lu\n", size ); + + ok( p[large_size - 2] == 0, "wrong data %x\n", p[large_size - 2] ); + ok( p[large_size - 1] == 0, "wrong data %x\n", p[large_size - 1] ); + + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + /* Windows doesn't do tail checking on large blocks */ + ok( p[large_size] == 0xab || broken(p[large_size] == 0), "wrong data %x\n", p[large_size] ); + ok( p[large_size+1] == 0xab || broken(p[large_size+1] == 0), "wrong data %x\n", p[large_size+1] ); + ok( p[large_size+2] == 0xab || broken(p[large_size+2] == 0), "wrong data %x\n", p[large_size+2] ); + if (p[large_size] == 0xab) + { + p[large_size] = 0xcc; + ret = HeapValidate( GetProcessHeap(), 0, p ); + ok( !ret, "HeapValidate succeeded\n" ); + + /* other calls only check when HEAP_VALIDATE is set */ + if (flags & HEAP_VALIDATE) + { + size = HeapSize( GetProcessHeap(), 0, p ); + ok( size == ~(SIZE_T)0, "Wrong size %lu\n", size ); + + p2 = HeapReAlloc( GetProcessHeap(), 0, p, large_size - 3 ); + ok( p2 == NULL, "HeapReAlloc succeeded\n" ); + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( !ret, "HeapFree succeeded\n" ); + } + p[large_size] = 0xab; + } + } + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( ret, "HeapFree failed\n" ); + + /* test block sizes when tail checking */ + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + for (size = 0; size < 64; size++) + { + p = HeapAlloc( GetProcessHeap(), 0, size ); + for (i = 0; i < 32; i++) if (p[size + i] != 0xab) break; + ok( i >= 8, "only %lu tail bytes for size %lu\n", i, size ); + HeapFree( GetProcessHeap(), 0, p ); + } + } +} + +static void test_debug_heap( const char *argv0, DWORD flags ) +{ + char keyname[MAX_PATH]; + char buffer[MAX_PATH]; + PROCESS_INFORMATION info; + STARTUPINFOA startup; + BOOL ret; + DWORD err; + HKEY hkey; + const char *basename; + + if ((basename = strrchr( argv0, '\\' ))) basename++; + else basename = argv0; + + sprintf( keyname, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\%s", + basename ); + if (!strcmp( keyname + strlen(keyname) - 3, ".so" )) keyname[strlen(keyname) - 3] = 0; + + err = RegCreateKeyA( HKEY_LOCAL_MACHINE, keyname, &hkey ); + ok( !err, "failed to create '%s' error %u\n", keyname, err ); + if (err) return; + + if (flags == 0xdeadbeef) /* magic value for unsetting it */ + RegDeleteValueA( hkey, "GlobalFlag" ); + else + RegSetValueExA( hkey, "GlobalFlag", 0, REG_DWORD, (BYTE *)&flags, sizeof(flags) ); + + memset( &startup, 0, sizeof(startup) ); + startup.cb = sizeof(startup); + + sprintf( buffer, "%s heap.c 0x%x", argv0, flags ); + ret = CreateProcessA( NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ); + ok( ret, "failed to create child process error %u\n", GetLastError() ); + if (ret) + { + winetest_wait_child_process( info.hProcess ); + CloseHandle( info.hThread ); + CloseHandle( info.hProcess ); + } + RegDeleteValueA( hkey, "GlobalFlag" ); + RegCloseKey( hkey ); + RegDeleteKeyA( HKEY_LOCAL_MACHINE, keyname ); +} + +static DWORD heap_flags_from_global_flag( DWORD flag ) +{ + DWORD ret = 0; + + if (flag & FLG_HEAP_ENABLE_TAIL_CHECK) + ret |= HEAP_TAIL_CHECKING_ENABLED; + if (flag & FLG_HEAP_ENABLE_FREE_CHECK) + ret |= HEAP_FREE_CHECKING_ENABLED; + if (flag & FLG_HEAP_VALIDATE_PARAMETERS) + ret |= HEAP_VALIDATE_PARAMS | HEAP_VALIDATE | HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED; + if (flag & FLG_HEAP_VALIDATE_ALL) + ret |= HEAP_VALIDATE_ALL | HEAP_VALIDATE | HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED; + if (flag & FLG_HEAP_DISABLE_COALESCING) + ret |= HEAP_DISABLE_COALESCE_ON_FREE; + if (flag & FLG_HEAP_PAGE_ALLOCS) + ret |= HEAP_PAGE_ALLOCS | HEAP_GROWABLE; + return ret; +} + +static void test_child_heap( const char *arg ) +{ + struct heap_layout *heap = GetProcessHeap(); + DWORD expected = strtoul( arg, 0, 16 ); + DWORD expect_heap; + + if (expected == 0xdeadbeef) /* expected value comes from Session Manager global flags */ + { + HKEY hkey; + expected = 0; + if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", &hkey )) + { + char buffer[32]; + DWORD type, size = sizeof(buffer); + + if (!RegQueryValueExA( hkey, "GlobalFlag", 0, &type, (BYTE *)buffer, &size )) + { + if (type == REG_DWORD) expected = *(DWORD *)buffer; + else if (type == REG_SZ) expected = strtoul( buffer, 0, 16 ); + } + RegCloseKey( hkey ); + } + } + if (expected && !pRtlGetNtGlobalFlags()) /* not working on NT4 */ + { + win_skip( "global flags not set\n" ); + return; + } + + ok( pRtlGetNtGlobalFlags() == expected, + "%s: got global flags %08x expected %08x\n", arg, pRtlGetNtGlobalFlags(), expected ); + + expect_heap = heap_flags_from_global_flag( expected ); + + if (!(heap->flags & HEAP_GROWABLE) || heap->pattern == 0xffeeffee) /* vista layout */ + { + ok( heap->flags == 0, "%s: got heap flags %08x expected 0\n", arg, heap->flags ); + } + else if (heap->pattern == 0xeeeeeeee && heap->flags == 0xeeeeeeee) + { + ok( expected & FLG_HEAP_PAGE_ALLOCS, "%s: got heap flags 0xeeeeeeee without page alloc\n", arg ); + } + else + { + ok( heap->flags == (expect_heap | HEAP_GROWABLE), + "%s: got heap flags %08x expected %08x\n", arg, heap->flags, expect_heap ); + ok( heap->force_flags == (expect_heap & ~0x18000080), + "%s: got heap force flags %08x expected %08x\n", arg, heap->force_flags, expect_heap ); + expect_heap = heap->flags; + } + + test_heap_checks( expect_heap ); +} + START_TEST(heap) { + int argc; + char **argv; + + pRtlGetNtGlobalFlags = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"), "RtlGetNtGlobalFlags" ); + + argc = winetest_get_mainargs( &argv ); + if (argc >= 3) + { + test_child_heap( argv[2] ); + return; + } + test_heap(); test_obsolete_flags(); @@ -480,4 +799,20 @@ START_TEST(heap) test_sized_HeapReAlloc((1 << 20), (2 << 20)); test_sized_HeapReAlloc((1 << 20), 1); test_HeapQueryInformation(); + + if (pRtlGetNtGlobalFlags) + { + test_debug_heap( argv[0], 0 ); + test_debug_heap( argv[0], FLG_HEAP_ENABLE_TAIL_CHECK ); + test_debug_heap( argv[0], FLG_HEAP_ENABLE_FREE_CHECK ); + test_debug_heap( argv[0], FLG_HEAP_VALIDATE_PARAMETERS ); + test_debug_heap( argv[0], FLG_HEAP_VALIDATE_ALL ); + test_debug_heap( argv[0], FLG_POOL_ENABLE_TAGGING ); + test_debug_heap( argv[0], FLG_HEAP_ENABLE_TAGGING ); + test_debug_heap( argv[0], FLG_HEAP_ENABLE_TAG_BY_DLL ); + test_debug_heap( argv[0], FLG_HEAP_DISABLE_COALESCING ); + test_debug_heap( argv[0], FLG_HEAP_PAGE_ALLOCS ); + test_debug_heap( argv[0], 0xdeadbeef ); + } + else win_skip( "RtlGetNtGlobalFlags not found, skipping heap debug tests\n" ); } diff --git a/rostests/winetests/kernel32/kernel32.rbuild b/rostests/winetests/kernel32/kernel32.rbuild index 0745bbc805d..71629bc3faa 100644 --- a/rostests/winetests/kernel32/kernel32.rbuild +++ b/rostests/winetests/kernel32/kernel32.rbuild @@ -17,6 +17,7 @@ directory.c drive.c environ.c + fiber.c file.c format_msg.c diff --git a/rostests/winetests/kernel32/module.c b/rostests/winetests/kernel32/module.c index 4cb30a8d89f..906646e6cca 100755 --- a/rostests/winetests/kernel32/module.c +++ b/rostests/winetests/kernel32/module.c @@ -359,6 +359,24 @@ static void testLoadLibraryEx(void) ok(GetLastError() == ERROR_FILE_NOT_FOUND || broken(GetLastError() == ERROR_INVALID_HANDLE), /* nt4 */ "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + + /* Free the loaded dll when its the first time this dll is loaded + in process - First time should pass, second fail */ + SetLastError(0xdeadbeef); + hmodule = LoadLibraryExA("comctl32.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); + ok(hmodule != 0, "Expected valid module handle\n"); + + SetLastError(0xdeadbeef); + ok(FreeLibrary(hmodule), + "Expected to be able to free the module, failed with %d\n", + GetLastError()); + SetLastError(0xdeadbeef); + ok(!FreeLibrary(hmodule), + "Unexpected ability to free the module, failed with %d\n", + GetLastError()); + + CloseHandle(hmodule); + } START_TEST(module) diff --git a/rostests/winetests/kernel32/path.c b/rostests/winetests/kernel32/path.c index 1c899c8caec..be019483d57 100755 --- a/rostests/winetests/kernel32/path.c +++ b/rostests/winetests/kernel32/path.c @@ -57,6 +57,9 @@ static DWORD (WINAPI *pGetLongPathNameW)(LPWSTR,LPWSTR,DWORD); static BOOL (WINAPI *pNeedCurrentDirectoryForExePathA)(LPCSTR); static BOOL (WINAPI *pNeedCurrentDirectoryForExePathW)(LPCWSTR); +static DWORD (WINAPI *pSearchPathA)(LPCSTR,LPCSTR,LPCSTR,DWORD,LPSTR,LPSTR*); +static DWORD (WINAPI *pSearchPathW)(LPCWSTR,LPCWSTR,LPCWSTR,DWORD,LPWSTR,LPWSTR*); + /* a structure to deal with wine todos somewhat cleanly */ typedef struct { DWORD shortlen; @@ -420,6 +423,7 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive) static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir) { CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH]; + char *buffer; DWORD len,len1; /* Save the original directory, so that we can return to it at the end of the test @@ -434,6 +438,45 @@ static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir) ok(len1==len+1, "GetCurrentDirectoryA returned %d instead of %d\n",len1,len+1); ok(lstrcmpiA(tmpstr,"aaaaaaa")==0, "GetCurrentDirectoryA should not have modified the buffer\n"); + + buffer = HeapAlloc( GetProcessHeap(), 0, 2 * 65536 ); + SetLastError( 0xdeadbeef ); + strcpy( buffer, "foo" ); + len = GetCurrentDirectoryA( 32767, buffer ); + ok( len != 0 && len < MAX_PATH, "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() ); + if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer ); + SetLastError( 0xdeadbeef ); + strcpy( buffer, "foo" ); + len = GetCurrentDirectoryA( 32768, buffer ); + ok( len != 0 && len < MAX_PATH, "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() ); + if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer ); + SetLastError( 0xdeadbeef ); + strcpy( buffer, "foo" ); + len = GetCurrentDirectoryA( 65535, buffer ); + ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4, win2k, xp */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() ); + if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer ); + SetLastError( 0xdeadbeef ); + strcpy( buffer, "foo" ); + len = GetCurrentDirectoryA( 65536, buffer ); + ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4 */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() ); + if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer ); + SetLastError( 0xdeadbeef ); + strcpy( buffer, "foo" ); + len = GetCurrentDirectoryA( 2 * 65536, buffer ); + ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4 */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() ); + if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer ); + HeapFree( GetProcessHeap(), 0, buffer ); + +/* Check for crash prevention on swapped args. Crashes all but Win9x. +*/ + if (0) + { + SetLastError( 0xdeadbeef ); + len = GetCurrentDirectoryA( 42, (LPSTR)(MAX_PATH + 42) ); + ok( len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, + "GetCurrentDirectoryA failed to fail %u err %u\n", len, GetLastError() ); + } + /* SetCurrentDirectoryA shouldn't care whether the string has a trailing '\\' or not */ @@ -1323,6 +1366,12 @@ static void test_GetWindowsDirectory(void) static void test_NeedCurrentDirectoryForExePathA(void) { + if (!pNeedCurrentDirectoryForExePathA) + { + win_skip("NeedCurrentDirectoryForExePathA is not available\n"); + return; + } + /* Crashes in Windows */ if (0) ok(pNeedCurrentDirectoryForExePathA(NULL), "returned FALSE for NULL\n"); @@ -1344,6 +1393,12 @@ static void test_NeedCurrentDirectoryForExePathW(void) const WCHAR fullpath[] = {'c', ':', '\\', 0}; const WCHAR cmdname[] = {'c', 'm', 'd', '.', 'e', 'x', 'e', 0}; + if (!pNeedCurrentDirectoryForExePathW) + { + win_skip("NeedCurrentDirectoryForExePathW is not available\n"); + return; + } + /* Crashes in Windows */ if (0) ok(pNeedCurrentDirectoryForExePathW(NULL), "returned FALSE for NULL\n"); @@ -1444,19 +1499,95 @@ static void test_drive_letter_case(void) #undef is_upper_case_letter } +static void test_SearchPathA(void) +{ + CHAR pathA[MAX_PATH], fileA[] = "", buffA[MAX_PATH]; + CHAR *ptrA = NULL; + DWORD ret; + + if (!pSearchPathA) + { + win_skip("SearchPathA isn't available\n"); + return; + } + + GetWindowsDirectoryA(pathA, sizeof(pathA)/sizeof(CHAR)); + + /* NULL filename */ + SetLastError(0xdeadbeef); + ret = pSearchPathA(pathA, NULL, NULL, sizeof(buffA)/sizeof(CHAR), buffA, &ptrA); + ok(ret == 0, "Expected failure, got %d\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); + + /* empty filename */ + SetLastError(0xdeadbeef); + ret = pSearchPathA(pathA, fileA, NULL, sizeof(buffA)/sizeof(CHAR), buffA, &ptrA); + ok(ret == 0, "Expected failure, got %d\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER || + broken(GetLastError() == ERROR_FILE_NOT_FOUND) /* win9x */, + "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); +} + +static void test_SearchPathW(void) +{ + WCHAR pathW[MAX_PATH], fileW[] = { 0 }, buffW[MAX_PATH]; + WCHAR *ptrW = NULL; + DWORD ret; + + if (!pSearchPathW) + { + win_skip("SearchPathW isn't available\n"); + return; + } + + /* SearchPathW is a stub on win9x and doesn't return sane error, + so quess if it's implemented indirectly */ + SetLastError(0xdeadbeef); + GetWindowsDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR)); + if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + win_skip("SearchPathW not implemented\n"); + return; + } + +if (0) +{ + /* NULL filename, crashes on nt4 */ + SetLastError(0xdeadbeef); + ret = pSearchPathW(pathW, NULL, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, &ptrW); + ok(ret == 0, "Expected failure, got %d\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); +} + + /* empty filename */ + SetLastError(0xdeadbeef); + ret = pSearchPathW(pathW, fileW, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, &ptrW); + ok(ret == 0, "Expected failure, got %d\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); +} + +static void init_pointers(void) +{ + HMODULE hKernel32 = GetModuleHandleA("kernel32.dll"); + +#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hKernel32, #f)) + MAKEFUNC(GetLongPathNameA); + MAKEFUNC(GetLongPathNameW); + MAKEFUNC(NeedCurrentDirectoryForExePathA); + MAKEFUNC(NeedCurrentDirectoryForExePathW); + MAKEFUNC(SearchPathA); + MAKEFUNC(SearchPathW); +#undef MAKEFUNC +} + START_TEST(path) { CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive; - pGetLongPathNameA = (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"), - "GetLongPathNameA" ); - pGetLongPathNameW = (void*)GetProcAddress(GetModuleHandleA("kernel32.dll") , - "GetLongPathNameW" ); - pNeedCurrentDirectoryForExePathA = - (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"), - "NeedCurrentDirectoryForExePathA" ); - pNeedCurrentDirectoryForExePathW = - (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"), - "NeedCurrentDirectoryForExePathW" ); + + init_pointers(); /* Report only once */ if (!pGetLongPathNameA) @@ -1474,13 +1605,9 @@ START_TEST(path) test_GetShortPathNameW(); test_GetSystemDirectory(); test_GetWindowsDirectory(); - if (pNeedCurrentDirectoryForExePathA) - { - test_NeedCurrentDirectoryForExePathA(); - } - if (pNeedCurrentDirectoryForExePathW) - { - test_NeedCurrentDirectoryForExePathW(); - } + test_NeedCurrentDirectoryForExePathA(); + test_NeedCurrentDirectoryForExePathW(); test_drive_letter_case(); + test_SearchPathA(); + test_SearchPathW(); } diff --git a/rostests/winetests/kernel32/process.c b/rostests/winetests/kernel32/process.c index 36c86e2bac5..7b5ac757dd2 100755 --- a/rostests/winetests/kernel32/process.c +++ b/rostests/winetests/kernel32/process.c @@ -1,5 +1,5 @@ /* - * Unit test suite for CreateProcess function. + * Unit test suite for process functions * * Copyright 2002 Eric Pouech * Copyright 2006 Dmitry Timoshkov diff --git a/rostests/winetests/kernel32/resource.c b/rostests/winetests/kernel32/resource.c index 7410675a15f..a2c02c81aeb 100644 --- a/rostests/winetests/kernel32/resource.c +++ b/rostests/winetests/kernel32/resource.c @@ -1,5 +1,5 @@ /* - * Unit test suite for environment functions. + * Unit test suite for resource functions. * * Copyright 2006 Mike McCormack * diff --git a/rostests/winetests/kernel32/testlist.c b/rostests/winetests/kernel32/testlist.c index 3dd54afe8d4..0102ea70159 100755 --- a/rostests/winetests/kernel32/testlist.c +++ b/rostests/winetests/kernel32/testlist.c @@ -20,6 +20,7 @@ extern void func_console(void); extern void func_directory(void); extern void func_drive(void); extern void func_environ(void); +extern void func_fiber(void); extern void func_file(void); extern void func_format_msg(void); extern void func_heap(void); @@ -55,6 +56,7 @@ const struct test winetest_testlist[] = { "directory", func_directory }, { "drive", func_drive }, { "environ", func_environ }, + { "fiber", func_fiber }, { "file", func_file }, { "format_msg", func_format_msg }, { "heap", func_heap }, diff --git a/rostests/winetests/kernel32/thread.c b/rostests/winetests/kernel32/thread.c index 275f6aa51af..69203fea050 100755 --- a/rostests/winetests/kernel32/thread.c +++ b/rostests/winetests/kernel32/thread.c @@ -1,5 +1,5 @@ /* - * Unit test suite for directory functions. + * Unit test suite for thread functions. * * Copyright 2002 Geoffrey Hausheer * @@ -54,26 +54,17 @@ # endif #endif -typedef BOOL (WINAPI *GetThreadPriorityBoost_t)(HANDLE,PBOOL); -static GetThreadPriorityBoost_t pGetThreadPriorityBoost=NULL; - -typedef HANDLE (WINAPI *OpenThread_t)(DWORD,BOOL,DWORD); -static OpenThread_t pOpenThread=NULL; - -typedef BOOL (WINAPI *QueueUserWorkItem_t)(LPTHREAD_START_ROUTINE,PVOID,ULONG); -static QueueUserWorkItem_t pQueueUserWorkItem=NULL; - -typedef DWORD (WINAPI *SetThreadIdealProcessor_t)(HANDLE,DWORD); -static SetThreadIdealProcessor_t pSetThreadIdealProcessor=NULL; - -typedef BOOL (WINAPI *SetThreadPriorityBoost_t)(HANDLE,BOOL); -static SetThreadPriorityBoost_t pSetThreadPriorityBoost=NULL; - -typedef BOOL (WINAPI *RegisterWaitForSingleObject_t)(PHANDLE,HANDLE,WAITORTIMERCALLBACK,PVOID,ULONG,ULONG); -static RegisterWaitForSingleObject_t pRegisterWaitForSingleObject=NULL; - -typedef BOOL (WINAPI *UnregisterWait_t)(HANDLE); -static UnregisterWait_t pUnregisterWait=NULL; +static BOOL (WINAPI *pGetThreadPriorityBoost)(HANDLE,PBOOL); +static HANDLE (WINAPI *pOpenThread)(DWORD,BOOL,DWORD); +static BOOL (WINAPI *pQueueUserWorkItem)(LPTHREAD_START_ROUTINE,PVOID,ULONG); +static DWORD (WINAPI *pSetThreadIdealProcessor)(HANDLE,DWORD); +static BOOL (WINAPI *pSetThreadPriorityBoost)(HANDLE,BOOL); +static BOOL (WINAPI *pRegisterWaitForSingleObject)(PHANDLE,HANDLE,WAITORTIMERCALLBACK,PVOID,ULONG,ULONG); +static BOOL (WINAPI *pUnregisterWait)(HANDLE); +static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL); +static BOOL (WINAPI *pSetThreadErrorMode)(DWORD,PDWORD); +static DWORD (WINAPI *pGetThreadErrorMode)(void); +static DWORD (WINAPI *pRtlGetThreadErrorMode)(void); static HANDLE create_target_process(const char *arg) { @@ -792,6 +783,9 @@ static VOID test_thread_processor(void) DWORD_PTR processMask,systemMask; SYSTEM_INFO sysInfo; int error=0; + BOOL is_wow64; + + if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE; sysInfo.dwNumberOfProcessors=0; GetSystemInfo(&sysInfo); @@ -820,12 +814,27 @@ static VOID test_thread_processor(void) } ok(error!=-1, "SetThreadIdealProcessor failed\n"); - SetLastError(0xdeadbeef); - error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS+1); - ok(error==-1, - "SetThreadIdealProcessor succeeded with an illegal processor #\n"); - ok(GetLastError()==ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + if (is_wow64) + { + SetLastError(0xdeadbeef); + error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS+1); + todo_wine + ok(error!=-1, "SetThreadIdealProcessor failed for %u on Wow64\n", MAXIMUM_PROCESSORS+1); + + SetLastError(0xdeadbeef); + error=pSetThreadIdealProcessor(curthread,65); + ok(error==-1, "SetThreadIdealProcessor succeeded with an illegal processor #\n"); + ok(GetLastError()==ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + } + else + { + SetLastError(0xdeadbeef); + error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS+1); + ok(error==-1, "SetThreadIdealProcessor succeeded with an illegal processor #\n"); + ok(GetLastError()==ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + } error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS); ok(error==0, "SetThreadIdealProcessor returned an incorrect value\n"); @@ -1203,9 +1212,103 @@ static void test_TLS(void) cleanup_thread_sync_helpers(); } +static void test_ThreadErrorMode(void) +{ + DWORD oldmode; + DWORD mode; + DWORD rtlmode; + BOOL ret; + + if (!pSetThreadErrorMode || !pGetThreadErrorMode) + { + win_skip("SetThreadErrorMode and/or GetThreadErrorMode unavailable (added in Windows 7)\n"); + return; + } + + if (!pRtlGetThreadErrorMode) { + win_skip("RtlGetThreadErrorMode not available\n"); + return; + } + + oldmode = pGetThreadErrorMode(); + + ret = pSetThreadErrorMode(0, &mode); + ok(ret, "SetThreadErrorMode failed\n"); + ok(mode == oldmode, + "SetThreadErrorMode returned old mode 0x%x, expected 0x%x\n", + mode, oldmode); + mode = pGetThreadErrorMode(); + ok(mode == 0, "GetThreadErrorMode returned mode 0x%x, expected 0\n", mode); + rtlmode = pRtlGetThreadErrorMode(); + ok(rtlmode == 0, + "RtlGetThreadErrorMode returned mode 0x%x, expected 0\n", mode); + + ret = pSetThreadErrorMode(SEM_FAILCRITICALERRORS, &mode); + ok(ret, "SetThreadErrorMode failed\n"); + ok(mode == 0, + "SetThreadErrorMode returned old mode 0x%x, expected 0\n", mode); + mode = pGetThreadErrorMode(); + ok(mode == SEM_FAILCRITICALERRORS, + "GetThreadErrorMode returned mode 0x%x, expected SEM_FAILCRITICALERRORS\n", + mode); + rtlmode = pRtlGetThreadErrorMode(); + ok(rtlmode == 0x10, + "RtlGetThreadErrorMode returned mode 0x%x, expected 0x10\n", mode); + + ret = pSetThreadErrorMode(SEM_NOGPFAULTERRORBOX, &mode); + ok(ret, "SetThreadErrorMode failed\n"); + ok(mode == SEM_FAILCRITICALERRORS, + "SetThreadErrorMode returned old mode 0x%x, expected SEM_FAILCRITICALERRORS\n", + mode); + mode = pGetThreadErrorMode(); + ok(mode == SEM_NOGPFAULTERRORBOX, + "GetThreadErrorMode returned mode 0x%x, expected SEM_NOGPFAULTERRORBOX\n", + mode); + rtlmode = pRtlGetThreadErrorMode(); + ok(rtlmode == 0x20, + "RtlGetThreadErrorMode returned mode 0x%x, expected 0x20\n", mode); + + ret = pSetThreadErrorMode(SEM_NOOPENFILEERRORBOX, NULL); + ok(ret, "SetThreadErrorMode failed\n"); + mode = pGetThreadErrorMode(); + ok(mode == SEM_NOOPENFILEERRORBOX, + "GetThreadErrorMode returned mode 0x%x, expected SEM_NOOPENFILEERRORBOX\n", + mode); + rtlmode = pRtlGetThreadErrorMode(); + ok(rtlmode == 0x40, + "RtlGetThreadErrorMode returned mode 0x%x, expected 0x40\n", rtlmode); + + for (mode = 1; mode; mode <<= 1) + { + ret = pSetThreadErrorMode(mode, NULL); + if (mode & (SEM_FAILCRITICALERRORS | + SEM_NOGPFAULTERRORBOX | + SEM_NOOPENFILEERRORBOX)) + { + ok(ret, + "SetThreadErrorMode(0x%x,NULL) failed with error %d\n", + mode, GetLastError()); + } + else + { + DWORD GLE = GetLastError(); + ok(!ret, + "SetThreadErrorMode(0x%x,NULL) succeeded, expected failure\n", + mode); + ok(GLE == ERROR_INVALID_PARAMETER, + "SetThreadErrorMode(0x%x,NULL) failed with %d, " + "expected ERROR_INVALID_PARAMETER\n", + mode, GLE); + } + } + + pSetThreadErrorMode(oldmode, NULL); +} + START_TEST(thread) { HINSTANCE lib; + HINSTANCE ntdll; int argc; char **argv; argc = winetest_get_mainargs( &argv ); @@ -1214,13 +1317,22 @@ START_TEST(thread) */ lib=GetModuleHandleA("kernel32.dll"); ok(lib!=NULL,"Couldn't get a handle for kernel32.dll\n"); - pGetThreadPriorityBoost=(GetThreadPriorityBoost_t)GetProcAddress(lib,"GetThreadPriorityBoost"); - pOpenThread=(OpenThread_t)GetProcAddress(lib,"OpenThread"); - pQueueUserWorkItem=(QueueUserWorkItem_t)GetProcAddress(lib,"QueueUserWorkItem"); - pSetThreadIdealProcessor=(SetThreadIdealProcessor_t)GetProcAddress(lib,"SetThreadIdealProcessor"); - pSetThreadPriorityBoost=(SetThreadPriorityBoost_t)GetProcAddress(lib,"SetThreadPriorityBoost"); - pRegisterWaitForSingleObject=(RegisterWaitForSingleObject_t)GetProcAddress(lib,"RegisterWaitForSingleObject"); - pUnregisterWait=(UnregisterWait_t)GetProcAddress(lib,"UnregisterWait"); + pGetThreadPriorityBoost=(void *)GetProcAddress(lib,"GetThreadPriorityBoost"); + pOpenThread=(void *)GetProcAddress(lib,"OpenThread"); + pQueueUserWorkItem=(void *)GetProcAddress(lib,"QueueUserWorkItem"); + pSetThreadIdealProcessor=(void *)GetProcAddress(lib,"SetThreadIdealProcessor"); + pSetThreadPriorityBoost=(void *)GetProcAddress(lib,"SetThreadPriorityBoost"); + pRegisterWaitForSingleObject=(void *)GetProcAddress(lib,"RegisterWaitForSingleObject"); + pUnregisterWait=(void *)GetProcAddress(lib,"UnregisterWait"); + pIsWow64Process=(void *)GetProcAddress(lib,"IsWow64Process"); + pSetThreadErrorMode=(void *)GetProcAddress(lib,"SetThreadErrorMode"); + pGetThreadErrorMode=(void *)GetProcAddress(lib,"GetThreadErrorMode"); + + ntdll=GetModuleHandleA("ntdll.dll"); + if (ntdll) + { + pRtlGetThreadErrorMode=(void *)GetProcAddress(ntdll,"RtlGetThreadErrorMode"); + } if (argc >= 3) { @@ -1264,4 +1376,5 @@ START_TEST(thread) test_QueueUserWorkItem(); test_RegisterWaitForSingleObject(); test_TLS(); + test_ThreadErrorMode(); } diff --git a/rostests/winetests/kernel32/timer.c b/rostests/winetests/kernel32/timer.c index 3c3fde76f11..8c233f0d449 100755 --- a/rostests/winetests/kernel32/timer.c +++ b/rostests/winetests/kernel32/timer.c @@ -1,5 +1,5 @@ /* - * Unit test suite for time functions + * Unit test suite for timer functions * * Copyright 2004 Mike McCormack * diff --git a/rostests/winetests/kernel32/virtual.c b/rostests/winetests/kernel32/virtual.c index 5187a97627a..f95fdd92e72 100755 --- a/rostests/winetests/kernel32/virtual.c +++ b/rostests/winetests/kernel32/virtual.c @@ -872,13 +872,70 @@ static void test_CreateFileMapping(void) CloseHandle( handle ); } -static void test_BadPtr(void) +static void test_IsBadReadPtr(void) { - void *ptr = (void*)1; - /* We assume address 1 is not mapped. */ - ok(IsBadReadPtr(ptr,1),"IsBadReadPtr(1) failed.\n"); - ok(IsBadWritePtr(ptr,1),"IsBadWritePtr(1) failed.\n"); - ok(IsBadCodePtr(ptr),"IsBadCodePtr(1) failed.\n"); + BOOL ret; + void *ptr = (void *)0xdeadbeef; + char stackvar; + + ret = IsBadReadPtr(NULL, 0); + ok(ret == FALSE, "Expected IsBadReadPtr to return FALSE, got %d\n", ret); + + ret = IsBadReadPtr(NULL, 1); + ok(ret == TRUE, "Expected IsBadReadPtr to return TRUE, got %d\n", ret); + + ret = IsBadReadPtr(ptr, 0); + ok(ret == FALSE, "Expected IsBadReadPtr to return FALSE, got %d\n", ret); + + ret = IsBadReadPtr(ptr, 1); + ok(ret == TRUE, "Expected IsBadReadPtr to return TRUE, got %d\n", ret); + + ret = IsBadReadPtr(&stackvar, 0); + ok(ret == FALSE, "Expected IsBadReadPtr to return FALSE, got %d\n", ret); + + ret = IsBadReadPtr(&stackvar, sizeof(char)); + ok(ret == FALSE, "Expected IsBadReadPtr to return FALSE, got %d\n", ret); +} + +static void test_IsBadWritePtr(void) +{ + BOOL ret; + void *ptr = (void *)0xdeadbeef; + char stackval; + + ret = IsBadWritePtr(NULL, 0); + ok(ret == FALSE, "Expected IsBadWritePtr to return FALSE, got %d\n", ret); + + ret = IsBadWritePtr(NULL, 1); + ok(ret == TRUE, "Expected IsBadWritePtr to return TRUE, got %d\n", ret); + + ret = IsBadWritePtr(ptr, 0); + ok(ret == FALSE, "Expected IsBadWritePtr to return FALSE, got %d\n", ret); + + ret = IsBadWritePtr(ptr, 1); + ok(ret == TRUE, "Expected IsBadWritePtr to return TRUE, got %d\n", ret); + + ret = IsBadWritePtr(&stackval, 0); + ok(ret == FALSE, "Expected IsBadWritePtr to return FALSE, got %d\n", ret); + + ret = IsBadWritePtr(&stackval, sizeof(char)); + ok(ret == FALSE, "Expected IsBadWritePtr to return FALSE, got %d\n", ret); +} + +static void test_IsBadCodePtr(void) +{ + BOOL ret; + void *ptr = (void *)0xdeadbeef; + char stackval; + + ret = IsBadCodePtr(NULL); + ok(ret == TRUE, "Expected IsBadCodePtr to return TRUE, got %d\n", ret); + + ret = IsBadCodePtr(ptr); + ok(ret == TRUE, "Expected IsBadCodePtr to return TRUE, got %d\n", ret); + + ret = IsBadCodePtr((void *)&stackval); + ok(ret == FALSE, "Expected IsBadCodePtr to return FALSE, got %d\n", ret); } static void test_write_watch(void) @@ -1220,6 +1277,8 @@ START_TEST(virtual) test_MapViewOfFile(); test_NtMapViewOfSection(); test_CreateFileMapping(); - test_BadPtr(); + test_IsBadReadPtr(); + test_IsBadWritePtr(); + test_IsBadCodePtr(); test_write_watch(); } diff --git a/rostests/winetests/kernel32/volume.c b/rostests/winetests/kernel32/volume.c index efd74d5abf2..f94d9cb29ed 100644 --- a/rostests/winetests/kernel32/volume.c +++ b/rostests/winetests/kernel32/volume.c @@ -1,5 +1,5 @@ /* - * Unit test suite + * Unit test suite for volume functions * * Copyright 2006 Stefan Leichter * From 0c0b65082efdcc3b82636903c8372a126f8f833d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 5 Mar 2010 19:57:53 +0000 Subject: [PATCH 117/211] Attempt to fix build of bootcd, by adding back vga and vbe miniport drivers. svn path=/trunk/; revision=45891 --- reactos/drivers/video/miniport/directory.rbuild | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reactos/drivers/video/miniport/directory.rbuild b/reactos/drivers/video/miniport/directory.rbuild index b61f80c1fda..363c9097fee 100644 --- a/reactos/drivers/video/miniport/directory.rbuild +++ b/reactos/drivers/video/miniport/directory.rbuild @@ -1,6 +1,12 @@ + + + + + + From de3f44602395f635861a02acfc4ca7bbf66de58b Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Fri, 5 Mar 2010 20:12:37 +0000 Subject: [PATCH 118/211] Add back vgaddi to the build. svn path=/trunk/; revision=45892 --- reactos/drivers/video/displays/directory.rbuild | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/drivers/video/displays/directory.rbuild b/reactos/drivers/video/displays/directory.rbuild index 16801792653..c4d780d0a0d 100644 --- a/reactos/drivers/video/displays/directory.rbuild +++ b/reactos/drivers/video/displays/directory.rbuild @@ -4,4 +4,7 @@ + + + From e9231d6824a4cd173574b18885b299aee3b1d084 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Fri, 5 Mar 2010 20:37:34 +0000 Subject: [PATCH 119/211] Obvious one, add back framebuff as well. svn path=/trunk/; revision=45893 --- reactos/drivers/video/displays/directory.rbuild | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/video/displays/directory.rbuild b/reactos/drivers/video/displays/directory.rbuild index c4d780d0a0d..514fd432fd2 100644 --- a/reactos/drivers/video/displays/directory.rbuild +++ b/reactos/drivers/video/displays/directory.rbuild @@ -1,10 +1,13 @@ - - + + + + + From 04f1825bfb076ad3650655f18b831b5e3c836ebc Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 5 Mar 2010 23:10:16 +0000 Subject: [PATCH 120/211] - [Win32k] Fix DrawMenuBar. svn path=/trunk/; revision=45901 --- .../win32/win32k/ntuser/simplecall.c | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index 3522cd15e95..f0dcc3a755b 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -490,28 +490,17 @@ NtUserCallHwndLock( case HWNDLOCK_ROUTINE_DRAWMENUBAR: { - PMENU_OBJECT Menu; DPRINT("HWNDLOCK_ROUTINE_DRAWMENUBAR\n"); - Ret = FALSE; - if (!((Wnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)) - break; - - if(!(Menu = UserGetMenuObject((HMENU)(DWORD_PTR) Wnd->IDMenu))) - break; - - Menu->MenuInfo.WndOwner = hWnd; - Menu->MenuInfo.Height = 0; - - co_WinPosSetWindowPos( Window, - HWND_DESKTOP, - 0,0,0,0, - SWP_NOSIZE| - SWP_NOMOVE| - SWP_NOZORDER| - SWP_NOACTIVATE| - SWP_FRAMECHANGED ); - Ret = TRUE; + if ((Wnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD) + co_WinPosSetWindowPos( Window, + HWND_DESKTOP, + 0,0,0,0, + SWP_NOSIZE| + SWP_NOMOVE| + SWP_NOZORDER| + SWP_NOACTIVATE| + SWP_FRAMECHANGED ); break; } From c628a16ac8dd3a1ec7cfb0cdaccd2c1a9492c689 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 6 Mar 2010 02:52:25 +0000 Subject: [PATCH 121/211] - [User32 Wine Test] Disable cancel mode test. svn path=/trunk/; revision=45906 --- rostests/winetests/user32/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rostests/winetests/user32/menu.c b/rostests/winetests/user32/menu.c index 761d70c7a2f..8c49c2d5fdc 100755 --- a/rostests/winetests/user32/menu.c +++ b/rostests/winetests/user32/menu.c @@ -3218,7 +3218,7 @@ START_TEST(menu) test_menu_hilitemenuitem(); test_menu_trackpopupmenu(); - test_menu_cancelmode(); +// test_menu_cancelmode(); test_menu_maxdepth(); test_menu_circref(); } From 5d4d3fd694e2fd0305bc0394441d4a7230248a1b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 6 Mar 2010 06:03:04 +0000 Subject: [PATCH 122/211] - Transition the physical device into D0 state when we receive IRP_MN_START_DEVICE - Actually do the power state transtion when a PDO receives IRP_MN_SET_POWER for DevicePowerState - Fill the DEVICE_CHARACTERISTICS struct based on values in the acpi_device struct - Lots of unhacking svn path=/trunk/; revision=45907 --- reactos/drivers/bus/acpi/buspdo.c | 198 +++++++++++++----------------- reactos/drivers/bus/acpi/power.c | 45 ++++++- 2 files changed, 128 insertions(+), 115 deletions(-) diff --git a/reactos/drivers/bus/acpi/buspdo.c b/reactos/drivers/bus/acpi/buspdo.c index 556f5cad966..87656388976 100644 --- a/reactos/drivers/bus/acpi/buspdo.c +++ b/reactos/drivers/bus/acpi/buspdo.c @@ -32,9 +32,14 @@ Bus_PDO_PnP ( ) { NTSTATUS status; + struct acpi_device *device = NULL; + POWER_STATE state; PAGED_CODE (); + if (DeviceData->AcpiHandle) + acpi_bus_get_device(DeviceData->AcpiHandle, &device); + // // NB: Because we are a bus enumerator, we have no one to whom we could @@ -51,6 +56,15 @@ Bus_PDO_PnP ( // required to allow others to access this device. // Power up the device. // + if (device && !ACPI_SUCCESS(acpi_power_transition(device, ACPI_STATE_D0))) + { + DPRINT1("Device %x failed to start!\n", device); + status = STATUS_UNSUCCESSFUL; + break; + } + + state.DeviceState = PowerDeviceD0; + PoSetPowerState(DeviceData->Common.Self, DevicePowerState, state); DeviceData->Common.DevicePowerState = PowerDeviceD0; SET_NEW_PNP_STATE(DeviceData->Common, Started); status = STATUS_SUCCESS; @@ -62,7 +76,16 @@ Bus_PDO_PnP ( // Here we shut down the device and give up and unmap any resources // we acquired for the device. // + if (device && !ACPI_SUCCESS(acpi_power_transition(device, ACPI_STATE_D3))) + { + DPRINT1("Device %x failed to stop!\n", device); + status = STATUS_UNSUCCESSFUL; + break; + } + state.DeviceState = PowerDeviceD3; + PoSetPowerState(DeviceData->Common.Self, DevicePowerState, state); + DeviceData->Common.DevicePowerState = PowerDeviceD3; SET_NEW_PNP_STATE(DeviceData->Common, Stopped); status = STATUS_SUCCESS; break; @@ -102,6 +125,8 @@ Bus_PDO_PnP ( // We did receive a query-stop, so restore. // RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); + if (device) + acpi_power_transition(device, ACPI_STATE_D0); } status = STATUS_SUCCESS;// We must not fail this IRP. break; @@ -212,9 +237,6 @@ Bus_PDO_PnP ( return status; } -// -// FIX ME FIX ME FIX ME !!! -// NTSTATUS Bus_PDO_QueryDeviceCaps( PPDO_DEVICE_DATA DeviceData, @@ -223,11 +245,14 @@ Bus_PDO_QueryDeviceCaps( PIO_STACK_LOCATION stack; PDEVICE_CAPABILITIES deviceCapabilities; - DEVICE_CAPABILITIES parentCapabilities; - NTSTATUS status; + struct acpi_device *device = NULL; + ULONG i; PAGED_CODE (); + if (DeviceData->AcpiHandle) + acpi_bus_get_device(DeviceData->AcpiHandle, &device); + stack = IoGetCurrentIrpStackLocation (Irp); // @@ -245,131 +270,80 @@ Bus_PDO_QueryDeviceCaps( return STATUS_UNSUCCESSFUL; } - // - // Get the device capabilities of the parent - // - status = Bus_GetDeviceCapabilities( - FDO_FROM_PDO(DeviceData)->NextLowerDriver, &parentCapabilities); - if (!NT_SUCCESS(status)) { - - DPRINT("\tQueryDeviceCaps failed\n"); - return status; - - } - - // - // The entries in the DeviceState array are based on the capabilities - // of the parent devnode. These entries signify the highest-powered - // state that the device can support for the corresponding system - // state. A driver can specify a lower (less-powered) state than the - // bus driver. For eg: Suppose the acpi bus controller supports - // D0, D2, and D3; and the acpi Device supports D0, D1, D2, and D3. - // Following the above rule, the device cannot specify D1 as one of - // it's power state. A driver can make the rules more restrictive - // but cannot loosen them. - // First copy the parent's S to D state mapping - // - - RtlCopyMemory( - deviceCapabilities->DeviceState, - parentCapabilities.DeviceState, - (PowerSystemShutdown + 1) * sizeof(DEVICE_POWER_STATE) - ); - - // - // Adjust the caps to what your device supports. - // Our device just supports D0 and D3. - // + deviceCapabilities->D1Latency = 0; + deviceCapabilities->D2Latency = 0; + deviceCapabilities->D3Latency = 0; deviceCapabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0; + deviceCapabilities->DeviceState[PowerSystemSleeping1] = PowerDeviceD3; + deviceCapabilities->DeviceState[PowerSystemSleeping2] = PowerDeviceD3; + deviceCapabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; - if (deviceCapabilities->DeviceState[PowerSystemSleeping1] != PowerDeviceD0) - deviceCapabilities->DeviceState[PowerSystemSleeping1] = PowerDeviceD1; + for (i = 0; i < ACPI_D_STATE_COUNT && device; i++) + { + if (!device->power.states[i].flags.valid) + continue; - if (deviceCapabilities->DeviceState[PowerSystemSleeping2] != PowerDeviceD0) - deviceCapabilities->DeviceState[PowerSystemSleeping2] = PowerDeviceD3; + switch (i) + { + case ACPI_STATE_D0: + deviceCapabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0; + break; - if (deviceCapabilities->DeviceState[PowerSystemSleeping3] != PowerDeviceD0) - deviceCapabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; + case ACPI_STATE_D1: + deviceCapabilities->DeviceState[PowerSystemSleeping1] = PowerDeviceD1; + deviceCapabilities->D1Latency = device->power.states[i].latency; + break; + + case ACPI_STATE_D2: + deviceCapabilities->DeviceState[PowerSystemSleeping2] = PowerDeviceD2; + deviceCapabilities->D2Latency = device->power.states[i].latency; + break; + + case ACPI_STATE_D3: + deviceCapabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; + deviceCapabilities->D3Latency = device->power.states[i].latency; + break; + } + } // We can wake the system from D1 deviceCapabilities->DeviceWake = PowerDeviceD1; - // - // Specifies whether the device hardware supports the D1 and D2 - // power state. Set these bits explicitly. - // - deviceCapabilities->DeviceD1 = TRUE; // Yes we can - deviceCapabilities->DeviceD2 = FALSE; - - // - // Specifies whether the device can respond to an external wake - // signal while in the D0, D1, D2, and D3 state. - // Set these bits explicitly. - // + deviceCapabilities->DeviceD1 = + (deviceCapabilities->DeviceState[PowerSystemSleeping1] == PowerDeviceD1) ? TRUE : FALSE; + deviceCapabilities->DeviceD2 = + (deviceCapabilities->DeviceState[PowerSystemSleeping2] == PowerDeviceD2) ? TRUE : FALSE; deviceCapabilities->WakeFromD0 = FALSE; deviceCapabilities->WakeFromD1 = TRUE; //Yes we can deviceCapabilities->WakeFromD2 = FALSE; deviceCapabilities->WakeFromD3 = FALSE; - - // We have no latencies - - deviceCapabilities->D1Latency = 0; - deviceCapabilities->D2Latency = 0; - deviceCapabilities->D3Latency = 0; - - // Ejection supported - - deviceCapabilities->EjectSupported = TRUE; - - // - // This flag specifies whether the device's hardware is disabled. - // The PnP Manager only checks this bit right after the device is - // enumerated. Once the device is started, this bit is ignored. - // - deviceCapabilities->HardwareDisabled = FALSE; - - // - // Out simulated device can be physically removed. - // - deviceCapabilities->Removable = TRUE; - // - // Setting it to TURE prevents the warning dialog from appearing - // whenever the device is surprise removed. - // - deviceCapabilities->SurpriseRemovalOK = TRUE; - - // We don't support system-wide unique IDs. - - deviceCapabilities->UniqueID = FALSE; - - // - // Specify whether the Device Manager should suppress all - // installation pop-ups except required pop-ups such as - // "no compatible drivers found." - // + if (device) + { + deviceCapabilities->EjectSupported = device->flags.ejectable; + deviceCapabilities->HardwareDisabled = !device->status.enabled; + deviceCapabilities->Removable = device->flags.removable; + deviceCapabilities->SurpriseRemovalOK = device->flags.suprise_removal_ok; + deviceCapabilities->UniqueID = device->flags.unique_id; + deviceCapabilities->NoDisplayInUI = !device->status.show_in_ui; + deviceCapabilities->Address = device->pnp.bus_address; + } + else + { + deviceCapabilities->EjectSupported = FALSE; + deviceCapabilities->HardwareDisabled = FALSE; + deviceCapabilities->Removable = FALSE; + deviceCapabilities->SurpriseRemovalOK = FALSE; + deviceCapabilities->UniqueID = FALSE; + deviceCapabilities->NoDisplayInUI = FALSE; + deviceCapabilities->Address = 0; + } deviceCapabilities->SilentInstall = FALSE; - - // - // Specifies an address indicating where the device is located - // on its underlying bus. The interpretation of this number is - // bus-specific. If the address is unknown or the bus driver - // does not support an address, the bus driver leaves this - // member at its default value of 0xFFFFFFFF. In this example - // the location address is same as instance id. - // - - //deviceCapabilities->Address = DeviceData->SerialNo; - - // - // UINumber specifies a number associated with the device that can - // be displayed in the user interface. - // - //deviceCapabilities->UINumber = DeviceData->SerialNo; + deviceCapabilities->UINumber = (ULONG)-1; return STATUS_SUCCESS; diff --git a/reactos/drivers/bus/acpi/power.c b/reactos/drivers/bus/acpi/power.c index 720207db8d2..eda6cb62197 100644 --- a/reactos/drivers/bus/acpi/power.c +++ b/reactos/drivers/bus/acpi/power.c @@ -123,11 +123,16 @@ Bus_PDO_Power ( PIO_STACK_LOCATION stack; POWER_STATE powerState; POWER_STATE_TYPE powerType; + ULONG error; + struct acpi_device *device; stack = IoGetCurrentIrpStackLocation (Irp); powerType = stack->Parameters.Power.Type; powerState = stack->Parameters.Power.State; + if (PdoData->AcpiHandle) + acpi_bus_get_device(PdoData->AcpiHandle, &device); + switch (stack->MinorFunction) { case IRP_MN_SET_POWER: @@ -139,9 +144,43 @@ Bus_PDO_Power ( switch (powerType) { case DevicePowerState: - PoSetPowerState (PdoData->Common.Self, powerType, powerState); - PdoData->Common.DevicePowerState = powerState.DeviceState; - status = STATUS_SUCCESS; + if (!device) + { + PdoData->Common.DevicePowerState = powerState.DeviceState; + status = STATUS_SUCCESS; + break; + } + + switch (powerState.DeviceState) + { + case PowerDeviceD0: + error = acpi_power_transition(device, ACPI_STATE_D0); + break; + + case PowerDeviceD1: + error = acpi_power_transition(device, ACPI_STATE_D1); + break; + + case PowerDeviceD2: + error = acpi_power_transition(device, ACPI_STATE_D2); + break; + + case PowerDeviceD3: + error = acpi_power_transition(device, ACPI_STATE_D3); + break; + + default: + error = 0; + break; + } + + if (ACPI_SUCCESS(error)) + { + PdoData->Common.DevicePowerState = powerState.DeviceState; + status = STATUS_SUCCESS; + } + else + status = STATUS_UNSUCCESSFUL; break; case SystemPowerState: From 812fcd6a3ef27c95352e65726e9411f208198f1f Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 08:56:21 +0000 Subject: [PATCH 123/211] [MSXML3] sync msxml3 to wine 1.1.40 svn path=/trunk/; revision=45908 --- reactos/dll/win32/msxml3/domdoc.c | 5 ++++- reactos/dll/win32/msxml3/element.c | 28 ++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/reactos/dll/win32/msxml3/domdoc.c b/reactos/dll/win32/msxml3/domdoc.c index 41c1f417642..a29e9b2fb3e 100644 --- a/reactos/dll/win32/msxml3/domdoc.c +++ b/reactos/dll/win32/msxml3/domdoc.c @@ -2214,7 +2214,7 @@ static ULONG WINAPI xmldoc_Safety_Release(IObjectSafety *iface) return IXMLDocument_Release((IXMLDocument *)This); } -#define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA) +#define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER) static HRESULT WINAPI xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions) @@ -2238,6 +2238,9 @@ static HRESULT WINAPI xmldoc_Safety_SetInterfaceSafetyOptions(IObjectSafety *ifa domdoc *This = impl_from_IObjectSafety(iface); TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions); + if ((dwOptionSetMask & ~SAFETY_SUPPORTED_OPTIONS) != 0) + return E_FAIL; + This->safeopt = dwEnabledOptions & dwOptionSetMask & SAFETY_SUPPORTED_OPTIONS; return S_OK; } diff --git a/reactos/dll/win32/msxml3/element.c b/reactos/dll/win32/msxml3/element.c index 01547709b7b..b6caf73df15 100644 --- a/reactos/dll/win32/msxml3/element.c +++ b/reactos/dll/win32/msxml3/element.c @@ -489,32 +489,24 @@ static HRESULT WINAPI domelem_get_tagName( { domelem *This = impl_from_IXMLDOMElement( iface ); xmlNodePtr element; - DWORD len; - DWORD offset = 0; - LPWSTR str; + const xmlChar *prefix; + xmlChar *qname; TRACE("(%p)->(%p)\n", This, p ); + if (!p) return E_INVALIDARG; + element = get_element( This ); if ( !element ) return E_FAIL; - len = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, NULL, 0 ); - if (element->ns) - len += MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, NULL, 0 ); - str = heap_alloc( len * sizeof (WCHAR) ); - if ( !str ) - return E_OUTOFMEMORY; - if (element->ns) - { - offset = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, str, len ); - str[offset - 1] = ':'; - } - MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, str + offset, len - offset ); - *p = SysAllocString( str ); - heap_free( str ); + prefix = element->ns ? element->ns->prefix : NULL; + qname = xmlBuildQName(element->name, prefix, NULL, 0); - return S_OK; + *p = bstr_from_xmlChar(qname); + if (qname != element->name) xmlFree(qname); + + return *p ? S_OK : E_OUTOFMEMORY; } static HRESULT WINAPI domelem_getAttribute( From 67aebd5a4feb9653119dc3656ca4de748e4f7484 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 09:05:09 +0000 Subject: [PATCH 124/211] [MSI] sync msi to wine 1.1.40 svn path=/trunk/; revision=45909 --- reactos/dll/win32/msi/action.c | 1350 +++++++++++++++++------------ reactos/dll/win32/msi/appsearch.c | 16 +- reactos/dll/win32/msi/custom.c | 40 +- reactos/dll/win32/msi/dialog.c | 61 +- reactos/dll/win32/msi/files.c | 609 +++++++++++-- reactos/dll/win32/msi/helpers.c | 21 +- reactos/dll/win32/msi/msi.rc | 17 +- reactos/dll/win32/msi/msipriv.h | 11 +- reactos/dll/win32/msi/package.c | 19 + reactos/dll/win32/msi/streams.c | 4 +- reactos/dll/win32/msi/upgrade.c | 13 +- reactos/include/psdk/msidefs.h | 9 + 12 files changed, 1476 insertions(+), 694 deletions(-) diff --git a/reactos/dll/win32/msi/action.c b/reactos/dll/win32/msi/action.c index ca8588f4529..81dcba43ae9 100644 --- a/reactos/dll/win32/msi/action.c +++ b/reactos/dll/win32/msi/action.c @@ -92,8 +92,6 @@ static const WCHAR szForceReboot[] = {'F','o','r','c','e','R','e','b','o','o','t',0}; static const WCHAR szResolveSource[] = {'R','e','s','o','l','v','e','S','o','u','r','c','e',0}; -static const WCHAR szAppSearch[] = - {'A','p','p','S','e','a','r','c','h',0}; static const WCHAR szAllocateRegistrySpace[] = {'A','l','l','o','c','a','t','e','R','e','g','i','s','t','r','y','S','p','a','c','e',0}; static const WCHAR szBindImage[] = @@ -114,8 +112,6 @@ static const WCHAR szIsolateComponents[] = {'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t','s',0}; static const WCHAR szMigrateFeatureStates[] = {'M','i','g','r','a','t','e','F','e','a','t','u','r','e','S','t','a','t','e','s',0}; -static const WCHAR szMoveFiles[] = - {'M','o','v','e','F','i','l','e','s',0}; static const WCHAR szMsiPublishAssemblies[] = {'M','s','i','P','u','b','l','i','s','h','A','s','s','e','m','b','l','i','e','s',0}; static const WCHAR szMsiUnpublishAssemblies[] = @@ -134,8 +130,6 @@ static const WCHAR szRegisterFonts[] = {'R','e','g','i','s','t','e','r','F','o','n','t','s',0}; static const WCHAR szRegisterUser[] = {'R','e','g','i','s','t','e','r','U','s','e','r',0}; -static const WCHAR szRemoveDuplicateFiles[] = - {'R','e','m','o','v','e','D','u','p','l','i','c','a','t','e','F','i','l','e','s',0}; static const WCHAR szRemoveEnvironmentStrings[] = {'R','e','m','o','v','e','E','n','v','i','r','o','n','m','e','n','t','S','t','r','i','n','g','s',0}; static const WCHAR szRemoveExistingProducts[] = @@ -912,6 +906,11 @@ static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) return ERROR_SUCCESS; } + uirow = MSI_CreateRecord(1); + MSI_RecordSetStringW(uirow, 1, dir); + ui_actiondata(package, szCreateFolders, uirow); + msiobj_release(&uirow->hdr); + full_path = resolve_folder(package,dir,FALSE,FALSE,TRUE,&folder); if (!full_path) { @@ -921,12 +920,6 @@ static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) TRACE("Folder is %s\n",debugstr_w(full_path)); - /* UI stuff */ - uirow = MSI_CreateRecord(1); - MSI_RecordSetStringW(uirow,1,full_path); - ui_actiondata(package,szCreateFolders,uirow); - msiobj_release( &uirow->hdr ); - if (folder->State == 0) create_full_pathW(full_path); @@ -2220,21 +2213,51 @@ static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type, return data; } +static const WCHAR *get_root_key( MSIPACKAGE *package, INT root, HKEY *root_key ) +{ + const WCHAR *ret; + + switch (root) + { + case -1: + if (msi_get_property_int( package, szAllUsers, 0 )) + { + *root_key = HKEY_LOCAL_MACHINE; + ret = szHLM; + } + else + { + *root_key = HKEY_CURRENT_USER; + ret = szHCU; + } + break; + case 0: + *root_key = HKEY_CLASSES_ROOT; + ret = szHCR; + break; + case 1: + *root_key = HKEY_CURRENT_USER; + ret = szHCU; + break; + case 2: + *root_key = HKEY_LOCAL_MACHINE; + ret = szHLM; + break; + case 3: + *root_key = HKEY_USERS; + ret = szHU; + break; + default: + ERR("Unknown root %i\n", root); + return NULL; + } + + return ret; +} + static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - static const WCHAR szHCR[] = - {'H','K','E','Y','_','C','L','A','S','S','E','S','_', - 'R','O','O','T','\\',0}; - static const WCHAR szHCU[] = - {'H','K','E','Y','_','C','U','R','R','E','N','T','_', - 'U','S','E','R','\\',0}; - static const WCHAR szHLM[] = - {'H','K','E','Y','_','L','O','C','A','L','_', - 'M','A','C','H','I','N','E','\\',0}; - static const WCHAR szHU[] = - {'H','K','E','Y','_','U','S','E','R','S','\\',0}; - LPSTR value_data = NULL; HKEY root_key, hkey; DWORD type,size; @@ -2282,44 +2305,8 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) root = MSI_RecordGetInteger(row,2); key = MSI_RecordGetString(row, 3); - /* get the root key */ - switch (root) - { - case -1: - { - LPWSTR all_users = msi_dup_property( package, szAllUsers ); - if (all_users && all_users[0] == '1') - { - root_key = HKEY_LOCAL_MACHINE; - szRoot = szHLM; - } - else - { - root_key = HKEY_CURRENT_USER; - szRoot = szHCU; - } - msi_free(all_users); - } - break; - case 0: root_key = HKEY_CLASSES_ROOT; - szRoot = szHCR; - break; - case 1: root_key = HKEY_CURRENT_USER; - szRoot = szHCU; - break; - case 2: root_key = HKEY_LOCAL_MACHINE; - szRoot = szHLM; - break; - case 3: root_key = HKEY_USERS; - szRoot = szHU; - break; - default: - ERR("Unknown root %i\n",root); - root_key=NULL; - szRoot = NULL; - break; - } - if (!root_key) + szRoot = get_root_key( package, root, &root_key ); + if (!szRoot) return ERROR_SUCCESS; deformat_string(package, key , &deformated); @@ -2414,6 +2401,212 @@ static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package) return rc; } +static void delete_reg_key_or_value( HKEY hkey_root, LPCWSTR key, LPCWSTR value, BOOL delete_key ) +{ + LONG res; + HKEY hkey; + DWORD num_subkeys, num_values; + + if (delete_key) + { + if ((res = RegDeleteTreeW( hkey_root, key ))) + { + WARN("Failed to delete key %s (%d)\n", debugstr_w(key), res); + } + return; + } + + if (!(res = RegOpenKeyW( hkey_root, key, &hkey ))) + { + if ((res = RegDeleteValueW( hkey, value ))) + { + WARN("Failed to delete value %s (%d)\n", debugstr_w(value), res); + } + res = RegQueryInfoKeyW( hkey, NULL, NULL, NULL, &num_subkeys, NULL, NULL, &num_values, + NULL, NULL, NULL, NULL ); + RegCloseKey( hkey ); + + if (!res && !num_subkeys && !num_values) + { + TRACE("Removing empty key %s\n", debugstr_w(key)); + RegDeleteKeyW( hkey_root, key ); + } + return; + } + WARN("Failed to open key %s (%d)\n", debugstr_w(key), res); +} + + +static UINT ITERATE_RemoveRegistryValuesOnUninstall( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, name, key_str, root_key_str; + LPWSTR deformated_key, deformated_name, ui_key_str; + MSICOMPONENT *comp; + MSIRECORD *uirow; + BOOL delete_key = FALSE; + HKEY hkey_root; + UINT size; + INT root; + + ui_progress( package, 2, 0, 0, 0 ); + + component = MSI_RecordGetString( row, 6 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + name = MSI_RecordGetString( row, 4 ); + if (MSI_RecordIsNull( row, 5 ) && name ) + { + if (name[0] == '+' && !name[1]) + return ERROR_SUCCESS; + else if ((name[0] == '-' && !name[1]) || (name[0] == '*' && !name[1])) + { + delete_key = TRUE; + name = NULL; + } + } + + root = MSI_RecordGetInteger( row, 2 ); + key_str = MSI_RecordGetString( row, 3 ); + + root_key_str = get_root_key( package, root, &hkey_root ); + if (!root_key_str) + return ERROR_SUCCESS; + + deformat_string( package, key_str, &deformated_key ); + size = strlenW( deformated_key ) + strlenW( root_key_str ) + 1; + ui_key_str = msi_alloc( size * sizeof(WCHAR) ); + strcpyW( ui_key_str, root_key_str ); + strcatW( ui_key_str, deformated_key ); + + deformat_string( package, name, &deformated_name ); + + delete_reg_key_or_value( hkey_root, deformated_key, deformated_name, delete_key ); + msi_free( deformated_key ); + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, ui_key_str ); + MSI_RecordSetStringW( uirow, 2, deformated_name ); + + ui_actiondata( package, szRemoveRegistryValues, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free( ui_key_str ); + msi_free( deformated_name ); + return ERROR_SUCCESS; +} + +static UINT ITERATE_RemoveRegistryValuesOnInstall( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, name, key_str, root_key_str; + LPWSTR deformated_key, deformated_name, ui_key_str; + MSICOMPONENT *comp; + MSIRECORD *uirow; + BOOL delete_key = FALSE; + HKEY hkey_root; + UINT size; + INT root; + + ui_progress( package, 2, 0, 0, 0 ); + + component = MSI_RecordGetString( row, 5 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; + + if ((name = MSI_RecordGetString( row, 4 ))) + { + if (name[0] == '-' && !name[1]) + { + delete_key = TRUE; + name = NULL; + } + } + + root = MSI_RecordGetInteger( row, 2 ); + key_str = MSI_RecordGetString( row, 3 ); + + root_key_str = get_root_key( package, root, &hkey_root ); + if (!root_key_str) + return ERROR_SUCCESS; + + deformat_string( package, key_str, &deformated_key ); + size = strlenW( deformated_key ) + strlenW( root_key_str ) + 1; + ui_key_str = msi_alloc( size * sizeof(WCHAR) ); + strcpyW( ui_key_str, root_key_str ); + strcatW( ui_key_str, deformated_key ); + + deformat_string( package, name, &deformated_name ); + + delete_reg_key_or_value( hkey_root, deformated_key, deformated_name, delete_key ); + msi_free( deformated_key ); + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, ui_key_str ); + MSI_RecordSetStringW( uirow, 2, deformated_name ); + + ui_actiondata( package, szRemoveRegistryValues, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free( ui_key_str ); + msi_free( deformated_name ); + return ERROR_SUCCESS; +} + +static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR registry_query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','R','e','g','i','s','t','r','y','`',0 }; + static const WCHAR remove_registry_query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','R','e','m','o','v','e','R','e','g','i','s','t','r','y','`',0 }; + + /* increment progress bar each time action data is sent */ + ui_progress( package, 1, REG_PROGRESS_VALUE, 1, 0 ); + + rc = MSI_DatabaseOpenViewW( package->db, registry_query, &view ); + if (rc == ERROR_SUCCESS) + { + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveRegistryValuesOnUninstall, package ); + msiobj_release( &view->hdr ); + if (rc != ERROR_SUCCESS) + return rc; + } + + rc = MSI_DatabaseOpenViewW( package->db, remove_registry_query, &view ); + if (rc == ERROR_SUCCESS) + { + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveRegistryValuesOnInstall, package ); + msiobj_release( &view->hdr ); + if (rc != ERROR_SUCCESS) + return rc; + } + + return ERROR_SUCCESS; +} + static UINT ACTION_InstallInitialize(MSIPACKAGE *package) { package->script->CurrentlyScripting = TRUE; @@ -3276,7 +3469,6 @@ static UINT ITERATE_PublishIcon(MSIRECORD *row, LPVOID param) CHAR buffer[1024]; DWORD sz; UINT rc; - MSIRECORD *uirow; FileName = MSI_RecordGetString(row,1); if (!FileName) @@ -3315,14 +3507,8 @@ static UINT ITERATE_PublishIcon(MSIRECORD *row, LPVOID param) } while (sz == 1024); msi_free(FilePath); - CloseHandle(the_file); - uirow = MSI_CreateRecord(1); - MSI_RecordSetStringW(uirow,1,FileName); - ui_actiondata(package,szPublishProduct,uirow); - msiobj_release( &uirow->hdr ); - return ERROR_SUCCESS; } @@ -3584,8 +3770,8 @@ done: static UINT ACTION_PublishProduct(MSIPACKAGE *package) { UINT rc; - HKEY hukey=0; - HKEY hudkey=0; + HKEY hukey = NULL, hudkey = NULL; + MSIRECORD *uirow; /* FIXME: also need to publish if the product is in advertise mode */ if (!msi_check_publish(package)) @@ -3623,24 +3809,60 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package) rc = msi_publish_icons(package); end: + uirow = MSI_CreateRecord( 1 ); + MSI_RecordSetStringW( uirow, 1, package->ProductCode ); + ui_actiondata( package, szPublishProduct, uirow ); + msiobj_release( &uirow->hdr ); + RegCloseKey(hukey); RegCloseKey(hudkey); return rc; } +static WCHAR *get_ini_file_name( MSIPACKAGE *package, MSIRECORD *row ) +{ + WCHAR *filename, *ptr, *folder, *ret; + const WCHAR *dirprop; + + filename = msi_dup_record_field( row, 2 ); + if (filename && (ptr = strchrW( filename, '|' ))) + ptr++; + else + ptr = filename; + + dirprop = MSI_RecordGetString( row, 3 ); + if (dirprop) + { + folder = resolve_folder( package, dirprop, FALSE, FALSE, TRUE, NULL ); + if (!folder) + folder = msi_dup_property( package, dirprop ); + } + else + folder = msi_dup_property( package, szWindowsFolder ); + + if (!folder) + { + ERR("Unable to resolve folder %s\n", debugstr_w(dirprop)); + msi_free( filename ); + return NULL; + } + + ret = build_directory_name( 2, folder, ptr ); + + msi_free( filename ); + msi_free( folder ); + return ret; +} + static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPCWSTR component, section, key, value, identifier, dirproperty; - LPWSTR deformated_section, deformated_key, deformated_value; - LPWSTR folder, filename, fullname = NULL; - LPCWSTR filenameptr; + LPCWSTR component, section, key, value, identifier; + LPWSTR deformated_section, deformated_key, deformated_value, fullname; MSIRECORD * uirow; INT action; MSICOMPONENT *comp; - static const WCHAR szWindowsFolder[] = - {'W','i','n','d','o','w','s','F','o','l','d','e','r',0}; component = MSI_RecordGetString(row, 8); comp = get_loaded_component(package,component); @@ -3656,7 +3878,6 @@ static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param) comp->Action = INSTALLSTATE_LOCAL; identifier = MSI_RecordGetString(row,1); - dirproperty = MSI_RecordGetString(row,3); section = MSI_RecordGetString(row,4); key = MSI_RecordGetString(row,5); value = MSI_RecordGetString(row,6); @@ -3666,28 +3887,7 @@ static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param) deformat_string(package,key,&deformated_key); deformat_string(package,value,&deformated_value); - filename = msi_dup_record_field(row, 2); - if (filename && (filenameptr = strchrW(filename, '|'))) - filenameptr++; - else - filenameptr = filename; - - if (dirproperty) - { - folder = resolve_folder(package, dirproperty, FALSE, FALSE, TRUE, NULL); - if (!folder) - folder = msi_dup_property( package, dirproperty ); - } - else - folder = msi_dup_property( package, szWindowsFolder ); - - if (!folder) - { - ERR("Unable to resolve folder! (%s)\n",debugstr_w(dirproperty)); - goto cleanup; - } - - fullname = build_directory_name(2, folder, filenameptr); + fullname = get_ini_file_name(package, row); if (action == 0) { @@ -3723,10 +3923,7 @@ static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param) ui_actiondata(package,szWriteIniValues,uirow); msiobj_release( &uirow->hdr ); -cleanup: - msi_free(filename); msi_free(fullname); - msi_free(folder); msi_free(deformated_key); msi_free(deformated_value); msi_free(deformated_section); @@ -3753,6 +3950,163 @@ static UINT ACTION_WriteIniValues(MSIPACKAGE *package) return rc; } +static UINT ITERATE_RemoveIniValuesOnUninstall( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, section, key, value, identifier; + LPWSTR deformated_section, deformated_key, deformated_value, filename; + MSICOMPONENT *comp; + MSIRECORD *uirow; + INT action; + + component = MSI_RecordGetString( row, 8 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + identifier = MSI_RecordGetString( row, 1 ); + section = MSI_RecordGetString( row, 4 ); + key = MSI_RecordGetString( row, 5 ); + value = MSI_RecordGetString( row, 6 ); + action = MSI_RecordGetInteger( row, 7 ); + + deformat_string( package, section, &deformated_section ); + deformat_string( package, key, &deformated_key ); + deformat_string( package, value, &deformated_value ); + + if (action == msidbIniFileActionAddLine || action == msidbIniFileActionCreateLine) + { + filename = get_ini_file_name( package, row ); + + TRACE("Removing key %s from section %s in %s\n", + debugstr_w(deformated_key), debugstr_w(deformated_section), debugstr_w(filename)); + + if (!WritePrivateProfileStringW( deformated_section, deformated_key, NULL, filename )) + { + WARN("Unable to remove key %u\n", GetLastError()); + } + msi_free( filename ); + } + else + FIXME("Unsupported action %d\n", action); + + + uirow = MSI_CreateRecord( 4 ); + MSI_RecordSetStringW( uirow, 1, identifier ); + MSI_RecordSetStringW( uirow, 2, deformated_section ); + MSI_RecordSetStringW( uirow, 3, deformated_key ); + MSI_RecordSetStringW( uirow, 4, deformated_value ); + ui_actiondata( package, szRemoveIniValues, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free( deformated_key ); + msi_free( deformated_value ); + msi_free( deformated_section ); + return ERROR_SUCCESS; +} + +static UINT ITERATE_RemoveIniValuesOnInstall( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, section, key, value, identifier; + LPWSTR deformated_section, deformated_key, deformated_value, filename; + MSICOMPONENT *comp; + MSIRECORD *uirow; + INT action; + + component = MSI_RecordGetString( row, 8 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; + + identifier = MSI_RecordGetString( row, 1 ); + section = MSI_RecordGetString( row, 4 ); + key = MSI_RecordGetString( row, 5 ); + value = MSI_RecordGetString( row, 6 ); + action = MSI_RecordGetInteger( row, 7 ); + + deformat_string( package, section, &deformated_section ); + deformat_string( package, key, &deformated_key ); + deformat_string( package, value, &deformated_value ); + + if (action == msidbIniFileActionRemoveLine) + { + filename = get_ini_file_name( package, row ); + + TRACE("Removing key %s from section %s in %s\n", + debugstr_w(deformated_key), debugstr_w(deformated_section), debugstr_w(filename)); + + if (!WritePrivateProfileStringW( deformated_section, deformated_key, NULL, filename )) + { + WARN("Unable to remove key %u\n", GetLastError()); + } + msi_free( filename ); + } + else + FIXME("Unsupported action %d\n", action); + + uirow = MSI_CreateRecord( 4 ); + MSI_RecordSetStringW( uirow, 1, identifier ); + MSI_RecordSetStringW( uirow, 2, deformated_section ); + MSI_RecordSetStringW( uirow, 3, deformated_key ); + MSI_RecordSetStringW( uirow, 4, deformated_value ); + ui_actiondata( package, szRemoveIniValues, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free( deformated_key ); + msi_free( deformated_value ); + msi_free( deformated_section ); + return ERROR_SUCCESS; +} + +static UINT ACTION_RemoveIniValues( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','I','n','i','F','i','l','e','`',0}; + static const WCHAR remove_query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','R','e','m','o','v','e','I','n','i','F','i','l','e','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc == ERROR_SUCCESS) + { + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveIniValuesOnUninstall, package ); + msiobj_release( &view->hdr ); + if (rc != ERROR_SUCCESS) + return rc; + } + + rc = MSI_DatabaseOpenViewW( package->db, remove_query, &view ); + if (rc == ERROR_SUCCESS) + { + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveIniValuesOnInstall, package ); + msiobj_release( &view->hdr ); + if (rc != ERROR_SUCCESS) + return rc; + } + + return ERROR_SUCCESS; +} + static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; @@ -3924,8 +4278,7 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package) { MSIFEATURE *feature; UINT rc; - HKEY hkey; - HKEY userdata = NULL; + HKEY hkey = NULL, userdata = NULL; if (!msi_check_publish(package)) return ERROR_SUCCESS; @@ -4178,6 +4531,7 @@ static UINT msi_publish_install_properties(MSIPACKAGE *package, HKEY hkey) static UINT ACTION_RegisterProduct(MSIPACKAGE *package) { WCHAR squashed_pc[SQUISH_GUID_SIZE]; + MSIRECORD *uirow; LPWSTR upgrade_code; HKEY hkey, props; HKEY upgrade; @@ -4222,8 +4576,12 @@ static UINT ACTION_RegisterProduct(MSIPACKAGE *package) } done: - RegCloseKey(hkey); + uirow = MSI_CreateRecord( 1 ); + MSI_RecordSetStringW( uirow, 1, package->ProductCode ); + ui_actiondata( package, szRegisterProduct, uirow ); + msiobj_release( &uirow->hdr ); + RegCloseKey(hkey); return ERROR_SUCCESS; } @@ -4424,10 +4782,10 @@ static UINT ACTION_ResolveSource(MSIPACKAGE* package) static UINT ACTION_RegisterUser(MSIPACKAGE *package) { - HKEY hkey=0; - LPWSTR buffer; - LPWSTR productid; - UINT rc,i; + HKEY hkey = 0; + LPWSTR buffer, productid = NULL; + UINT i, rc = ERROR_SUCCESS; + MSIRECORD *uirow; static const WCHAR szPropKeys[][80] = { @@ -4448,12 +4806,12 @@ static UINT ACTION_RegisterUser(MSIPACKAGE *package) if (msi_check_unpublish(package)) { MSIREG_DeleteUserDataProductKey(package->ProductCode); - return ERROR_SUCCESS; + goto end; } productid = msi_dup_property( package, INSTALLPROPERTY_PRODUCTIDW ); if (!productid) - return ERROR_SUCCESS; + goto end; rc = MSIREG_OpenInstallProps(package->ProductCode, package->Context, NULL, &hkey, TRUE); @@ -4468,11 +4826,13 @@ static UINT ACTION_RegisterUser(MSIPACKAGE *package) } end: + uirow = MSI_CreateRecord( 1 ); + MSI_RecordSetStringW( uirow, 1, productid ); + ui_actiondata( package, szRegisterUser, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(productid); RegCloseKey(hkey); - - /* FIXME: call ui_actiondata */ - return rc; } @@ -4492,7 +4852,7 @@ static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param) MSIPACKAGE *package = param; LPCWSTR compgroupid, component, feature, qualifier, text; LPWSTR advertise = NULL, output = NULL; - HKEY hkey; + HKEY hkey = NULL; UINT rc; MSICOMPONENT *comp; MSIFEATURE *feat; @@ -4803,15 +5163,24 @@ static UINT ITERATE_StartService(MSIRECORD *rec, LPVOID param) MSIPACKAGE *package = param; MSICOMPONENT *comp; SC_HANDLE scm = NULL, service = NULL; - LPCWSTR *vector = NULL; + LPCWSTR component, *vector = NULL; LPWSTR name, args; DWORD event, numargs; UINT r = ERROR_FUNCTION_FAILED; - comp = get_loaded_component(package, MSI_RecordGetString(rec, 6)); - if (!comp || comp->Action == INSTALLSTATE_UNKNOWN || comp->Action == INSTALLSTATE_ABSENT) + component = MSI_RecordGetString(rec, 6); + comp = get_loaded_component(package, component); + if (!comp) return ERROR_SUCCESS; + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; + deformat_string(package, MSI_RecordGetString(rec, 2), &name); deformat_string(package, MSI_RecordGetString(rec, 4), &args); event = MSI_RecordGetInteger(rec, 3); @@ -4966,6 +5335,7 @@ static UINT ITERATE_StopService( MSIRECORD *rec, LPVOID param ) { MSIPACKAGE *package = param; MSICOMPONENT *comp; + LPCWSTR component; LPWSTR name; DWORD event; @@ -4973,10 +5343,19 @@ static UINT ITERATE_StopService( MSIRECORD *rec, LPVOID param ) if (!(event & msidbServiceControlEventStop)) return ERROR_SUCCESS; - comp = get_loaded_component( package, MSI_RecordGetString( rec, 6 ) ); - if (!comp || comp->Action == INSTALLSTATE_UNKNOWN || comp->Action == INSTALLSTATE_ABSENT) + component = MSI_RecordGetString( rec, 6 ); + comp = get_loaded_component( package, component ); + if (!comp) return ERROR_SUCCESS; + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + deformat_string( package, MSI_RecordGetString( rec, 2 ), &name ); stop_service( name ); msi_free( name ); @@ -5007,18 +5386,29 @@ static UINT ITERATE_DeleteService( MSIRECORD *rec, LPVOID param ) { MSIPACKAGE *package = param; MSICOMPONENT *comp; - LPWSTR name = NULL; - DWORD event; + MSIRECORD *uirow; + LPCWSTR component; + LPWSTR name = NULL, display_name = NULL; + DWORD event, len; SC_HANDLE scm = NULL, service = NULL; event = MSI_RecordGetInteger( rec, 3 ); if (!(event & msidbServiceControlEventDelete)) return ERROR_SUCCESS; - comp = get_loaded_component( package, MSI_RecordGetString(rec, 6) ); - if (!comp || comp->Action == INSTALLSTATE_UNKNOWN || comp->Action == INSTALLSTATE_ABSENT) + component = MSI_RecordGetString(rec, 6); + comp = get_loaded_component(package, component); + if (!comp) return ERROR_SUCCESS; + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + deformat_string( package, MSI_RecordGetString(rec, 2), &name ); stop_service( name ); @@ -5029,6 +5419,14 @@ static UINT ITERATE_DeleteService( MSIRECORD *rec, LPVOID param ) goto done; } + len = 0; + if (!GetServiceDisplayNameW( scm, name, NULL, &len ) && + GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + if ((display_name = msi_alloc( ++len * sizeof(WCHAR )))) + GetServiceDisplayNameW( scm, name, display_name, &len ); + } + service = OpenServiceW( scm, name, DELETE ); if (!service) { @@ -5040,9 +5438,16 @@ static UINT ITERATE_DeleteService( MSIRECORD *rec, LPVOID param ) WARN("Failed to delete service (%s): %u\n", debugstr_w(name), GetLastError()); done: + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, display_name ); + MSI_RecordSetStringW( uirow, 2, name ); + ui_actiondata( package, szDeleteServices, uirow ); + msiobj_release( &uirow->hdr ); + CloseServiceHandle( service ); CloseServiceHandle( scm ); msi_free( name ); + msi_free( display_name ); return ERROR_SUCCESS; } @@ -5085,6 +5490,7 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) LPWSTR driver, driver_path, ptr; WCHAR outpath[MAX_PATH]; MSIFILE *driver_file, *setup_file; + MSIRECORD *uirow; LPCWSTR desc; DWORD len, usage; UINT r = ERROR_SUCCESS; @@ -5110,7 +5516,7 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) len = lstrlenW(desc) + lstrlenW(driver_fmt) + lstrlenW(driver_file->FileName); if (setup_file) len += lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName); - len += lstrlenW(usage_fmt) + 1; + len += lstrlenW(usage_fmt) + 2; /* \0\0 */ driver = msi_alloc(len * sizeof(WCHAR)); if (!driver) @@ -5120,13 +5526,13 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) lstrcpyW(ptr, desc); ptr += lstrlenW(ptr) + 1; - sprintfW(ptr, driver_fmt, driver_file->FileName); - ptr += lstrlenW(ptr) + 1; + len = sprintfW(ptr, driver_fmt, driver_file->FileName); + ptr += len + 1; if (setup_file) { - sprintfW(ptr, setup_fmt, setup_file->FileName); - ptr += lstrlenW(ptr) + 1; + len = sprintfW(ptr, setup_fmt, setup_file->FileName); + ptr += len + 1; } lstrcpyW(ptr, usage_fmt); @@ -5144,6 +5550,13 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) r = ERROR_FUNCTION_FAILED; } + uirow = MSI_CreateRecord( 5 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + MSI_RecordSetStringW( uirow, 3, driver_path ); + ui_actiondata( package, szInstallODBC, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(driver); msi_free(driver_path); @@ -5156,6 +5569,7 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) LPWSTR translator, translator_path, ptr; WCHAR outpath[MAX_PATH]; MSIFILE *translator_file, *setup_file; + MSIRECORD *uirow; LPCWSTR desc; DWORD len, usage; UINT r = ERROR_SUCCESS; @@ -5176,7 +5590,7 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) return ERROR_FUNCTION_FAILED; } - len = lstrlenW(desc) + lstrlenW(translator_fmt) + lstrlenW(translator_file->FileName) + 1; + len = lstrlenW(desc) + lstrlenW(translator_fmt) + lstrlenW(translator_file->FileName) + 2; /* \0\0 */ if (setup_file) len += lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName); @@ -5188,13 +5602,13 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) lstrcpyW(ptr, desc); ptr += lstrlenW(ptr) + 1; - sprintfW(ptr, translator_fmt, translator_file->FileName); - ptr += lstrlenW(ptr) + 1; + len = sprintfW(ptr, translator_fmt, translator_file->FileName); + ptr += len + 1; if (setup_file) { - sprintfW(ptr, setup_fmt, setup_file->FileName); - ptr += lstrlenW(ptr) + 1; + len = sprintfW(ptr, setup_fmt, setup_file->FileName); + ptr += len + 1; } *ptr = '\0'; @@ -5209,6 +5623,13 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) r = ERROR_FUNCTION_FAILED; } + uirow = MSI_CreateRecord( 5 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + MSI_RecordSetStringW( uirow, 3, translator_path ); + ui_actiondata( package, szInstallODBC, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(translator); msi_free(translator_path); @@ -5217,12 +5638,14 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param ) { + MSIPACKAGE *package = param; LPWSTR attrs; LPCWSTR desc, driver; WORD request = ODBC_ADD_SYS_DSN; INT registration; DWORD len; UINT r = ERROR_SUCCESS; + MSIRECORD *uirow; static const WCHAR attrs_fmt[] = { 'D','S','N','=','%','s',0 }; @@ -5234,7 +5657,7 @@ static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param ) if (registration == msidbODBCDataSourceRegistrationPerMachine) request = ODBC_ADD_SYS_DSN; else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_ADD_DSN; - len = lstrlenW(attrs_fmt) + lstrlenW(desc) + 1 + 1; + len = lstrlenW(attrs_fmt) + lstrlenW(desc) + 2; /* \0\0 */ attrs = msi_alloc(len * sizeof(WCHAR)); if (!attrs) return ERROR_OUTOFMEMORY; @@ -5248,6 +5671,13 @@ static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param ) r = ERROR_FUNCTION_FAILED; } + uirow = MSI_CreateRecord( 5 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + MSI_RecordSetInteger( uirow, 3, request ); + ui_actiondata( package, szInstallODBC, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(attrs); return r; @@ -5296,6 +5726,8 @@ static UINT ACTION_InstallODBC( MSIPACKAGE *package ) static UINT ITERATE_RemoveODBCDriver( MSIRECORD *rec, LPVOID param ) { + MSIPACKAGE *package = param; + MSIRECORD *uirow; DWORD usage; LPCWSTR desc; @@ -5309,11 +5741,19 @@ static UINT ITERATE_RemoveODBCDriver( MSIRECORD *rec, LPVOID param ) FIXME("Usage count reached 0\n"); } + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + ui_actiondata( package, szRemoveODBC, uirow ); + msiobj_release( &uirow->hdr ); + return ERROR_SUCCESS; } static UINT ITERATE_RemoveODBCTranslator( MSIRECORD *rec, LPVOID param ) { + MSIPACKAGE *package = param; + MSIRECORD *uirow; DWORD usage; LPCWSTR desc; @@ -5327,11 +5767,19 @@ static UINT ITERATE_RemoveODBCTranslator( MSIRECORD *rec, LPVOID param ) FIXME("Usage count reached 0\n"); } + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + ui_actiondata( package, szRemoveODBC, uirow ); + msiobj_release( &uirow->hdr ); + return ERROR_SUCCESS; } static UINT ITERATE_RemoveODBCDataSource( MSIRECORD *rec, LPVOID param ) { + MSIPACKAGE *package = param; + MSIRECORD *uirow; LPWSTR attrs; LPCWSTR desc, driver; WORD request = ODBC_REMOVE_SYS_DSN; @@ -5348,7 +5796,7 @@ static UINT ITERATE_RemoveODBCDataSource( MSIRECORD *rec, LPVOID param ) if (registration == msidbODBCDataSourceRegistrationPerMachine) request = ODBC_REMOVE_SYS_DSN; else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_REMOVE_DSN; - len = strlenW( attrs_fmt ) + strlenW( desc ) + 1 + 1; + len = strlenW( attrs_fmt ) + strlenW( desc ) + 2; /* \0\0 */ attrs = msi_alloc( len * sizeof(WCHAR) ); if (!attrs) return ERROR_OUTOFMEMORY; @@ -5364,6 +5812,13 @@ static UINT ITERATE_RemoveODBCDataSource( MSIRECORD *rec, LPVOID param ) } msi_free( attrs ); + uirow = MSI_CreateRecord( 3 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + MSI_RecordSetInteger( uirow, 3, request ); + ui_actiondata( package, szRemoveODBC, uirow ); + msiobj_release( &uirow->hdr ); + return ERROR_SUCCESS; } @@ -5420,7 +5875,7 @@ static UINT ACTION_RemoveODBC( MSIPACKAGE *package ) #define check_flag_combo(x, y) ((x) & ~(y)) == (y) -static LONG env_set_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags ) +static UINT env_parse_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags ) { LPCWSTR cptr = *name; @@ -5501,17 +5956,8 @@ static LONG env_set_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags ) return ERROR_SUCCESS; } -static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) +static UINT open_env_key( DWORD flags, HKEY *key ) { - MSIPACKAGE *package = param; - LPCWSTR name, value; - LPWSTR data = NULL, newval = NULL; - LPWSTR deformatted = NULL, ptr; - DWORD flags, type, size; - LONG res; - HKEY env = NULL, root; - LPCWSTR environment; - static const WCHAR user_env[] = {'E','n','v','i','r','o','n','m','e','n','t',0}; static const WCHAR machine_env[] = @@ -5520,13 +5966,62 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) 'C','o','n','t','r','o','l','\\', 'S','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\', 'E','n','v','i','r','o','n','m','e','n','t',0}; + const WCHAR *env; + HKEY root; + LONG res; + + if (flags & ENV_MOD_MACHINE) + { + env = machine_env; + root = HKEY_LOCAL_MACHINE; + } + else + { + env = user_env; + root = HKEY_CURRENT_USER; + } + + res = RegOpenKeyExW( root, env, 0, KEY_ALL_ACCESS, key ); + if (res != ERROR_SUCCESS) + { + WARN("Failed to open key %s (%d)\n", debugstr_w(env), res); + return ERROR_FUNCTION_FAILED; + } + + return ERROR_SUCCESS; +} + +static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR name, value, component; + LPWSTR data = NULL, newval = NULL, deformatted = NULL, ptr; + DWORD flags, type, size; + UINT res; + HKEY env = NULL; + MSICOMPONENT *comp; + MSIRECORD *uirow; + int action = 0; + + component = MSI_RecordGetString(rec, 4); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; name = MSI_RecordGetString(rec, 2); value = MSI_RecordGetString(rec, 3); TRACE("name %s value %s\n", debugstr_w(name), debugstr_w(value)); - res = env_set_flags(&name, &value, &flags); + res = env_parse_flags(&name, &value, &flags); if (res != ERROR_SUCCESS || !value) goto done; @@ -5538,24 +6033,12 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) value = deformatted; - if (flags & ENV_MOD_MACHINE) - { - environment = machine_env; - root = HKEY_LOCAL_MACHINE; - } - else - { - environment = user_env; - root = HKEY_CURRENT_USER; - } - - res = RegCreateKeyExW(root, environment, 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &env, NULL); + res = open_env_key( flags, &env ); if (res != ERROR_SUCCESS) goto done; - if (flags & ENV_ACT_REMOVE) - FIXME("Not removing environment variable on uninstall!\n"); + if (flags & ENV_MOD_MACHINE) + action |= 0x20000000; size = 0; type = REG_SZ; @@ -5566,6 +6049,8 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) if ((res == ERROR_FILE_NOT_FOUND || !(flags & ENV_MOD_MASK))) { + action = 0x2; + /* Nothing to do. */ if (!value) { @@ -5586,6 +6071,8 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) } else { + action = 0x1; + /* Contrary to MSDN, +-variable to [~];path works */ if (flags & ENV_ACT_SETABSENT && !(flags & ENV_MOD_MASK)) { @@ -5606,7 +6093,10 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) if (flags & ENV_ACT_REMOVEMATCH && (!value || !lstrcmpW(data, value))) { - res = RegDeleteKeyW(env, name); + action = 0x4; + res = RegDeleteValueW(env, name); + if (res != ERROR_SUCCESS) + WARN("Failed to remove value %s (%d)\n", debugstr_w(name), res); goto done; } @@ -5633,6 +6123,7 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) { lstrcpyW(newval, value); ptr = newval + lstrlenW(value); + action |= 0x80000000; } lstrcpyW(ptr, data); @@ -5640,12 +6131,24 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) if (flags & ENV_MOD_APPEND) { lstrcatW(newval, value); + action |= 0x40000000; } } TRACE("setting %s to %s\n", debugstr_w(name), debugstr_w(newval)); res = RegSetValueExW(env, name, 0, type, (LPVOID)newval, size); + if (res) + { + WARN("Failed to set %s to %s (%d)\n", debugstr_w(name), debugstr_w(newval), res); + } done: + uirow = MSI_CreateRecord( 3 ); + MSI_RecordSetStringW( uirow, 1, name ); + MSI_RecordSetStringW( uirow, 2, newval ); + MSI_RecordSetInteger( uirow, 3, action ); + ui_actiondata( package, szWriteEnvironmentStrings, uirow ); + msiobj_release( &uirow->hdr ); + if (env) RegCloseKey(env); msi_free(deformatted); msi_free(data); @@ -5670,333 +6173,98 @@ static UINT ACTION_WriteEnvironmentStrings( MSIPACKAGE *package ) return rc; } -#define is_dot_dir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0)))) - -typedef struct -{ - struct list entry; - LPWSTR sourcename; - LPWSTR destname; - LPWSTR source; - LPWSTR dest; -} FILE_LIST; - -static BOOL msi_move_file(LPCWSTR source, LPCWSTR dest, int options) -{ - BOOL ret; - - if (GetFileAttributesW(source) == FILE_ATTRIBUTE_DIRECTORY || - GetFileAttributesW(dest) == FILE_ATTRIBUTE_DIRECTORY) - { - WARN("Source or dest is directory, not moving\n"); - return FALSE; - } - - if (options == msidbMoveFileOptionsMove) - { - TRACE("moving %s -> %s\n", debugstr_w(source), debugstr_w(dest)); - ret = MoveFileExW(source, dest, MOVEFILE_REPLACE_EXISTING); - if (!ret) - { - WARN("MoveFile failed: %d\n", GetLastError()); - return FALSE; - } - } - else - { - TRACE("copying %s -> %s\n", debugstr_w(source), debugstr_w(dest)); - ret = CopyFileW(source, dest, FALSE); - if (!ret) - { - WARN("CopyFile failed: %d\n", GetLastError()); - return FALSE; - } - } - - return TRUE; -} - -static LPWSTR wildcard_to_file(LPWSTR wildcard, LPWSTR filename) -{ - LPWSTR path, ptr; - DWORD dirlen, pathlen; - - ptr = strrchrW(wildcard, '\\'); - dirlen = ptr - wildcard + 1; - - pathlen = dirlen + lstrlenW(filename) + 1; - path = msi_alloc(pathlen * sizeof(WCHAR)); - - lstrcpynW(path, wildcard, dirlen + 1); - lstrcatW(path, filename); - - return path; -} - -static void free_file_entry(FILE_LIST *file) -{ - msi_free(file->source); - msi_free(file->dest); - msi_free(file); -} - -static void free_list(FILE_LIST *list) -{ - while (!list_empty(&list->entry)) - { - FILE_LIST *file = LIST_ENTRY(list_head(&list->entry), FILE_LIST, entry); - - list_remove(&file->entry); - free_file_entry(file); - } -} - -static BOOL add_wildcard(FILE_LIST *files, LPWSTR source, LPWSTR dest) -{ - FILE_LIST *new, *file; - LPWSTR ptr, filename; - DWORD size; - - new = msi_alloc_zero(sizeof(FILE_LIST)); - if (!new) - return FALSE; - - new->source = strdupW(source); - ptr = strrchrW(dest, '\\') + 1; - filename = strrchrW(new->source, '\\') + 1; - - new->sourcename = filename; - - if (*ptr) - new->destname = ptr; - else - new->destname = new->sourcename; - - size = (ptr - dest) + lstrlenW(filename) + 1; - new->dest = msi_alloc(size * sizeof(WCHAR)); - if (!new->dest) - { - free_file_entry(new); - return FALSE; - } - - lstrcpynW(new->dest, dest, ptr - dest + 1); - lstrcatW(new->dest, filename); - - if (list_empty(&files->entry)) - { - list_add_head(&files->entry, &new->entry); - return TRUE; - } - - LIST_FOR_EACH_ENTRY(file, &files->entry, FILE_LIST, entry) - { - if (lstrcmpW(source, file->source) < 0) - { - list_add_before(&file->entry, &new->entry); - return TRUE; - } - } - - list_add_after(&file->entry, &new->entry); - return TRUE; -} - -static BOOL move_files_wildcard(LPWSTR source, LPWSTR dest, int options) -{ - WIN32_FIND_DATAW wfd; - HANDLE hfile; - LPWSTR path; - BOOL res; - FILE_LIST files, *file; - DWORD size; - - hfile = FindFirstFileW(source, &wfd); - if (hfile == INVALID_HANDLE_VALUE) return FALSE; - - list_init(&files.entry); - - for (res = TRUE; res; res = FindNextFileW(hfile, &wfd)) - { - if (is_dot_dir(wfd.cFileName)) continue; - - path = wildcard_to_file(source, wfd.cFileName); - if (!path) - { - res = FALSE; - goto done; - } - - add_wildcard(&files, path, dest); - msi_free(path); - } - - /* no files match the wildcard */ - if (list_empty(&files.entry)) - goto done; - - /* only the first wildcard match gets renamed to dest */ - file = LIST_ENTRY(list_head(&files.entry), FILE_LIST, entry); - size = (strrchrW(file->dest, '\\') - file->dest) + lstrlenW(file->destname) + 2; - file->dest = msi_realloc(file->dest, size * sizeof(WCHAR)); - if (!file->dest) - { - res = FALSE; - goto done; - } - - /* file->dest may be shorter after the reallocation, so add a NULL - * terminator. This is needed for the call to strrchrW, as there will no - * longer be a NULL terminator within the bounds of the allocation in this case. - */ - file->dest[size - 1] = '\0'; - lstrcpyW(strrchrW(file->dest, '\\') + 1, file->destname); - - while (!list_empty(&files.entry)) - { - file = LIST_ENTRY(list_head(&files.entry), FILE_LIST, entry); - - msi_move_file(file->source, file->dest, options); - - list_remove(&file->entry); - free_file_entry(file); - } - - res = TRUE; - -done: - free_list(&files); - FindClose(hfile); - return res; -} - -static UINT ITERATE_MoveFiles( MSIRECORD *rec, LPVOID param ) +static UINT ITERATE_RemoveEnvironmentString( MSIRECORD *rec, LPVOID param ) { MSIPACKAGE *package = param; + LPCWSTR name, value, component; + LPWSTR deformatted = NULL; + DWORD flags; + HKEY env; MSICOMPONENT *comp; - LPCWSTR sourcename; - LPWSTR destname = NULL; - LPWSTR sourcedir = NULL, destdir = NULL; - LPWSTR source = NULL, dest = NULL; - int options; - DWORD size; - BOOL ret, wildcards; + MSIRECORD *uirow; + int action = 0; + LONG res; + UINT r; - comp = get_loaded_component(package, MSI_RecordGetString(rec, 2)); - if (!comp || !comp->Enabled || - !(comp->Action & (INSTALLSTATE_LOCAL | INSTALLSTATE_SOURCE))) + component = MSI_RecordGetString( rec, 4 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) { - TRACE("Component not set for install, not moving file\n"); + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + name = MSI_RecordGetString( rec, 2 ); + value = MSI_RecordGetString( rec, 3 ); + + TRACE("name %s value %s\n", debugstr_w(name), debugstr_w(value)); + + r = env_parse_flags( &name, &value, &flags ); + if (r != ERROR_SUCCESS) + return r; + + if (!(flags & ENV_ACT_REMOVE)) + { + TRACE("Environment variable %s not marked for removal\n", debugstr_w(name)); return ERROR_SUCCESS; } - sourcename = MSI_RecordGetString(rec, 3); - options = MSI_RecordGetInteger(rec, 7); + if (value && !deformat_string( package, value, &deformatted )) + return ERROR_OUTOFMEMORY; - sourcedir = msi_dup_property(package, MSI_RecordGetString(rec, 5)); - if (!sourcedir) + value = deformatted; + + r = open_env_key( flags, &env ); + if (r != ERROR_SUCCESS) + { + r = ERROR_SUCCESS; goto done; - - destdir = msi_dup_property(package, MSI_RecordGetString(rec, 6)); - if (!destdir) - goto done; - - if (!sourcename) - { - if (GetFileAttributesW(sourcedir) == INVALID_FILE_ATTRIBUTES) - goto done; - - source = strdupW(sourcedir); - if (!source) - goto done; - } - else - { - size = lstrlenW(sourcedir) + lstrlenW(sourcename) + 2; - source = msi_alloc(size * sizeof(WCHAR)); - if (!source) - goto done; - - lstrcpyW(source, sourcedir); - if (source[lstrlenW(source) - 1] != '\\') - lstrcatW(source, szBackSlash); - lstrcatW(source, sourcename); } - wildcards = strchrW(source, '*') || strchrW(source, '?'); + if (flags & ENV_MOD_MACHINE) + action |= 0x20000000; - if (MSI_RecordIsNull(rec, 4)) + TRACE("Removing %s\n", debugstr_w(name)); + + res = RegDeleteValueW( env, name ); + if (res != ERROR_SUCCESS) { - if (!wildcards) - { - destname = strdupW(sourcename); - if (!destname) - goto done; - } + WARN("Failed to delete value %s (%d)\n", debugstr_w(name), res); + r = ERROR_SUCCESS; } - else - { - destname = strdupW(MSI_RecordGetString(rec, 4)); - if (destname) - reduce_to_longfilename(destname); - } - - size = 0; - if (destname) - size = lstrlenW(destname); - - size += lstrlenW(destdir) + 2; - dest = msi_alloc(size * sizeof(WCHAR)); - if (!dest) - goto done; - - lstrcpyW(dest, destdir); - if (dest[lstrlenW(dest) - 1] != '\\') - lstrcatW(dest, szBackSlash); - - if (destname) - lstrcatW(dest, destname); - - if (GetFileAttributesW(destdir) == INVALID_FILE_ATTRIBUTES) - { - ret = CreateDirectoryW(destdir, NULL); - if (!ret) - { - WARN("CreateDirectory failed: %d\n", GetLastError()); - return ERROR_SUCCESS; - } - } - - if (!wildcards) - msi_move_file(source, dest, options); - else - move_files_wildcard(source, dest, options); done: - msi_free(sourcedir); - msi_free(destdir); - msi_free(destname); - msi_free(source); - msi_free(dest); + uirow = MSI_CreateRecord( 3 ); + MSI_RecordSetStringW( uirow, 1, name ); + MSI_RecordSetStringW( uirow, 2, value ); + MSI_RecordSetInteger( uirow, 3, action ); + ui_actiondata( package, szRemoveEnvironmentStrings, uirow ); + msiobj_release( &uirow->hdr ); - return ERROR_SUCCESS; + if (env) RegCloseKey( env ); + msi_free( deformatted ); + return r; } -static UINT ACTION_MoveFiles( MSIPACKAGE *package ) +static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package ) { UINT rc; MSIQUERY *view; - - static const WCHAR ExecSeqQuery[] = + static const WCHAR query[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - '`','M','o','v','e','F','i','l','e','`',0}; + '`','E','n','v','i','r','o','n','m','e','n','t','`',0}; - rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); if (rc != ERROR_SUCCESS) return ERROR_SUCCESS; - rc = MSI_IterateRecords(view, NULL, ITERATE_MoveFiles, package); - msiobj_release(&view->hdr); + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveEnvironmentString, package ); + msiobj_release( &view->hdr ); return rc; } @@ -6009,6 +6277,7 @@ typedef struct tagMSIASSEMBLY MSIFILE *file; LPWSTR manifest; LPWSTR application; + LPWSTR display_name; DWORD attributes; BOOL installed; } MSIASSEMBLY; @@ -6059,11 +6328,17 @@ static UINT install_assembly(MSIPACKAGE *package, MSIASSEMBLY *assembly, LPWSTR path) { IAssemblyCache *cache; + MSIRECORD *uirow; HRESULT hr; UINT r = ERROR_FUNCTION_FAILED; TRACE("installing assembly: %s\n", debugstr_w(path)); + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 2, assembly->display_name ); + ui_actiondata( package, szMsiPublishAssemblies, uirow ); + msiobj_release( &uirow->hdr ); + if (assembly->feature) msi_feature_set_state(package, assembly->feature, INSTALLSTATE_LOCAL); @@ -6153,81 +6428,87 @@ static void append_str(LPWSTR *str, DWORD *size, LPCWSTR append) lstrcatW(*str, append); } -static BOOL check_assembly_installed(MSIDATABASE *db, IAssemblyCache *cache, - MSICOMPONENT *comp) +static WCHAR *get_assembly_display_name( MSIDATABASE *db, MSICOMPONENT *comp ) { - ASSEMBLY_INFO asminfo; - ASSEMBLY_NAME name; - MSIQUERY *view; - LPWSTR disp; - DWORD size; - BOOL found; - UINT r; - static const WCHAR separator[] = {',',' ',0}; static const WCHAR Version[] = {'V','e','r','s','i','o','n','=',0}; static const WCHAR Culture[] = {'C','u','l','t','u','r','e','=',0}; - static const WCHAR PublicKeyToken[] = { - 'P','u','b','l','i','c','K','e','y','T','o','k','e','n','=',0}; + static const WCHAR PublicKeyToken[] = {'P','u','b','l','i','c','K','e','y','T','o','k','e','n','=',0}; static const WCHAR query[] = { 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', '`','M','s','i','A','s','s','e','m','b','l','y','N','a','m','e','`',' ', 'W','H','E','R','E',' ','`','C','o','m','p','o','n','e','n','t','_','`', '=','\'','%','s','\'',0}; + ASSEMBLY_NAME name; + MSIQUERY *view; + LPWSTR display_name; + DWORD size; + UINT r; - disp = NULL; - found = FALSE; - ZeroMemory(&name, sizeof(ASSEMBLY_NAME)); - ZeroMemory(&asminfo, sizeof(ASSEMBLY_INFO)); + display_name = NULL; + memset( &name, 0, sizeof(ASSEMBLY_NAME) ); - r = MSI_OpenQuery(db, &view, query, comp->Component); + r = MSI_OpenQuery( db, &view, query, comp->Component ); if (r != ERROR_SUCCESS) - return ERROR_SUCCESS; + return NULL; - MSI_IterateRecords(view, NULL, parse_assembly_name, &name); - msiobj_release(&view->hdr); + MSI_IterateRecords( view, NULL, parse_assembly_name, &name ); + msiobj_release( &view->hdr ); if (!name.name) { ERR("No assembly name specified!\n"); - goto done; + return NULL; } - append_str(&disp, &size, name.name); + append_str( &display_name, &size, name.name ); if (name.version) { - append_str(&disp, &size, separator); - append_str(&disp, &size, Version); - append_str(&disp, &size, name.version); + append_str( &display_name, &size, separator ); + append_str( &display_name, &size, Version ); + append_str( &display_name, &size, name.version ); } - if (name.culture) { - append_str(&disp, &size, separator); - append_str(&disp, &size, Culture); - append_str(&disp, &size, name.culture); + append_str( &display_name, &size, separator ); + append_str( &display_name, &size, Culture ); + append_str( &display_name, &size, name.culture ); } - if (name.pubkeytoken) { - append_str(&disp, &size, separator); - append_str(&disp, &size, PublicKeyToken); - append_str(&disp, &size, name.pubkeytoken); + append_str( &display_name, &size, separator ); + append_str( &display_name, &size, PublicKeyToken ); + append_str( &display_name, &size, name.pubkeytoken ); } + msi_free( name.name ); + msi_free( name.version ); + msi_free( name.culture ); + msi_free( name.pubkeytoken ); + + return display_name; +} + +static BOOL check_assembly_installed( MSIDATABASE *db, IAssemblyCache *cache, MSICOMPONENT *comp ) +{ + ASSEMBLY_INFO asminfo; + LPWSTR disp; + BOOL found = FALSE; + HRESULT hr; + + disp = get_assembly_display_name( db, comp ); + if (!disp) + return FALSE; + + memset( &asminfo, 0, sizeof(ASSEMBLY_INFO) ); asminfo.cbAssemblyInfo = sizeof(ASSEMBLY_INFO); - IAssemblyCache_QueryAssemblyInfo(cache, QUERYASMINFO_FLAG_VALIDATE, - disp, &asminfo); - found = (asminfo.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED); -done: - msi_free(disp); - msi_free(name.name); - msi_free(name.version); - msi_free(name.culture); - msi_free(name.pubkeytoken); + hr = IAssemblyCache_QueryAssemblyInfo( cache, QUERYASMINFO_FLAG_VALIDATE, disp, &asminfo ); + if (SUCCEEDED(hr)) + found = (asminfo.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED); + msi_free( disp ); return found; } @@ -6235,20 +6516,25 @@ static UINT load_assembly(MSIRECORD *rec, LPVOID param) { ASSEMBLY_LIST *list = param; MSIASSEMBLY *assembly; + LPCWSTR component; assembly = msi_alloc_zero(sizeof(MSIASSEMBLY)); if (!assembly) return ERROR_OUTOFMEMORY; - assembly->component = get_loaded_component(list->package, MSI_RecordGetString(rec, 1)); + component = MSI_RecordGetString(rec, 1); + assembly->component = get_loaded_component(list->package, component); + if (!assembly->component) + return ERROR_SUCCESS; - if (!assembly->component || !assembly->component->Enabled || - !(assembly->component->Action & (INSTALLSTATE_LOCAL | INSTALLSTATE_SOURCE))) + if (assembly->component->ActionRequest != INSTALLSTATE_LOCAL && + assembly->component->ActionRequest != INSTALLSTATE_SOURCE) { - TRACE("Component not set for install, not publishing assembly\n"); - msi_free(assembly); + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + assembly->component->Action = assembly->component->Installed; return ERROR_SUCCESS; } + assembly->component->Action = assembly->component->ActionRequest; assembly->feature = find_feature_by_name(list->package, MSI_RecordGetString(rec, 2)); assembly->file = msi_find_file(list->package, assembly->component->KeyPath); @@ -6328,6 +6614,7 @@ static void free_assemblies(struct list *assemblies) list_remove(&assembly->entry); msi_free(assembly->application); msi_free(assembly->manifest); + msi_free(assembly->display_name); msi_free(assembly); } } @@ -6490,7 +6777,18 @@ static UINT ACTION_ScheduleReboot( MSIPACKAGE *package ) static UINT ACTION_AllocateRegistrySpace( MSIPACKAGE *package ) { - TRACE("%p\n", package); + static const WCHAR szAvailableFreeReg[] = + {'A','V','A','I','L','A','B','L','E','F','R','E','E','R','E','G',0}; + MSIRECORD *uirow; + int space = msi_get_property_int( package, szAvailableFreeReg, 0 ); + + TRACE("%p %d kilobytes\n", package, space); + + uirow = MSI_CreateRecord( 1 ); + MSI_RecordSetInteger( uirow, 1, space ); + ui_actiondata( package, szAllocateRegistrySpace, uirow ); + msiobj_release( &uirow->hdr ); + return ERROR_SUCCESS; } @@ -6530,13 +6828,6 @@ static UINT msi_unimplemented_action_stub( MSIPACKAGE *package, return ERROR_SUCCESS; } -static UINT ACTION_RemoveIniValues( MSIPACKAGE *package ) -{ - static const WCHAR table[] = - {'R','e','m','o','v','e','I','n','i','F','i','l','e',0 }; - return msi_unimplemented_action_stub( package, "RemoveIniValues", table ); -} - static UINT ACTION_PatchFiles( MSIPACKAGE *package ) { static const WCHAR table[] = { 'P','a','t','c','h',0 }; @@ -6552,7 +6843,7 @@ static UINT ACTION_BindImage( MSIPACKAGE *package ) static UINT ACTION_IsolateComponents( MSIPACKAGE *package ) { static const WCHAR table[] = { - 'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t',0 }; + 'I','s','o','l','a','t','e','d','C','o','m','p','o','n','e','n','t',0 }; return msi_unimplemented_action_stub( package, "IsolateComponents", table ); } @@ -6562,13 +6853,6 @@ static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "MigrateFeatureStates", table ); } -static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { - 'E','n','v','i','r','o','n','m','e','n','t',0 }; - return msi_unimplemented_action_stub( package, "RemoveEnvironmentStrings", table ); -} - static UINT ACTION_MsiUnpublishAssemblies( MSIPACKAGE *package ) { static const WCHAR table[] = { @@ -6600,24 +6884,12 @@ static UINT ACTION_InstallSFPCatalogFile( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "InstallSFPCatalogFile", table ); } -static UINT ACTION_RemoveDuplicateFiles( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'D','u','p','l','i','c','a','t','e','F','i','l','e',0 }; - return msi_unimplemented_action_stub( package, "RemoveDuplicateFiles", table ); -} - static UINT ACTION_RemoveExistingProducts( MSIPACKAGE *package ) { static const WCHAR table[] = { 'U','p','g','r','a','d','e',0 }; return msi_unimplemented_action_stub( package, "RemoveExistingProducts", table ); } -static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'R','e','m','o','v','e','R','e','g','i','s','t','r','y',0 }; - return msi_unimplemented_action_stub( package, "RemoveRegistryValues", table ); -} - static UINT ACTION_SetODBCFolders( MSIPACKAGE *package ) { static const WCHAR table[] = { 'D','i','r','e','c','t','o','r','y',0 }; diff --git a/reactos/dll/win32/msi/appsearch.c b/reactos/dll/win32/msi/appsearch.c index c4e4e588077..12c741178e3 100644 --- a/reactos/dll/win32/msi/appsearch.c +++ b/reactos/dll/win32/msi/appsearch.c @@ -1026,13 +1026,15 @@ static UINT ACTION_AppSearchSigName(MSIPACKAGE *package, LPCWSTR sigName, static UINT iterate_appsearch(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPWSTR propName, sigName, value = NULL; + LPCWSTR propName, sigName; + LPWSTR value = NULL; MSISIGNATURE sig; + MSIRECORD *uirow; UINT r; /* get property and signature */ - propName = msi_dup_record_field(row,1); - sigName = msi_dup_record_field(row,2); + propName = MSI_RecordGetString(row, 1); + sigName = MSI_RecordGetString(row, 2); TRACE("%s %s\n", debugstr_w(propName), debugstr_w(sigName)); @@ -1043,8 +1045,12 @@ static UINT iterate_appsearch(MSIRECORD *row, LPVOID param) msi_free(value); } ACTION_FreeSignature(&sig); - msi_free(propName); - msi_free(sigName); + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, propName ); + MSI_RecordSetStringW( uirow, 2, sigName ); + ui_actiondata( package, szAppSearch, uirow ); + msiobj_release( &uirow->hdr ); return r; } diff --git a/reactos/dll/win32/msi/custom.c b/reactos/dll/win32/msi/custom.c index 2b2a3e1373f..584c0507c53 100644 --- a/reactos/dll/win32/msi/custom.c +++ b/reactos/dll/win32/msi/custom.c @@ -1120,38 +1120,44 @@ static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source, static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source, LPCWSTR target, const INT type, LPCWSTR action) { - LPWSTR filename, deformated; + LPWSTR workingdir, filename; STARTUPINFOW si; PROCESS_INFORMATION info; BOOL rc; - memset(&si,0,sizeof(STARTUPINFOW)); + memset(&si, 0, sizeof(STARTUPINFOW)); - filename = resolve_folder(package, source, FALSE, FALSE, TRUE, NULL); + workingdir = resolve_folder(package, source, FALSE, FALSE, TRUE, NULL); + + if (!workingdir) + return ERROR_FUNCTION_FAILED; + + deformat_string(package, target, &filename); if (!filename) + { + msi_free(workingdir); return ERROR_FUNCTION_FAILED; + } - SetCurrentDirectoryW(filename); - msi_free(filename); + TRACE("executing exe %s with working directory %s\n", + debugstr_w(filename), debugstr_w(workingdir)); - deformat_string(package,target,&deformated); - - if (!deformated) - return ERROR_FUNCTION_FAILED; - - TRACE("executing exe %s\n", debugstr_w(deformated)); - - rc = CreateProcessW(NULL, deformated, NULL, NULL, FALSE, 0, NULL, - c_collen, &si, &info); + rc = CreateProcessW(NULL, filename, NULL, NULL, FALSE, 0, NULL, + workingdir, &si, &info); if ( !rc ) { - ERR("Unable to execute command %s\n", debugstr_w(deformated)); - msi_free(deformated); + ERR("Unable to execute command %s with working directory %s\n", + debugstr_w(filename), debugstr_w(workingdir)); + msi_free(filename); + msi_free(workingdir); return ERROR_SUCCESS; } - msi_free(deformated); + + msi_free(filename); + msi_free(workingdir); + CloseHandle( info.hThread ); return wait_process_handle(package, type, info.hProcess, action); diff --git a/reactos/dll/win32/msi/dialog.c b/reactos/dll/win32/msi/dialog.c index 5fd4bbd138b..ac2e95af91f 100644 --- a/reactos/dll/win32/msi/dialog.c +++ b/reactos/dll/win32/msi/dialog.c @@ -801,11 +801,31 @@ static UINT msi_dialog_text_control( msi_dialog *dialog, MSIRECORD *rec ) return ERROR_SUCCESS; } +/* strip any leading text style label from text field */ +static WCHAR *msi_get_binary_name( MSIPACKAGE *package, MSIRECORD *rec ) +{ + WCHAR *p, *text; + + text = msi_get_deformatted_field( package, rec, 10 ); + if (!text) + return NULL; + + p = text; + while (*p && *p != '{') p++; + if (!*p++) return text; + + while (*p && *p != '}') p++; + if (!*p++) return text; + + p = strdupW( p ); + msi_free( text ); + return p; +} + static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec ) { msi_control *control; UINT attributes, style; - LPWSTR text; TRACE("%p %p\n", dialog, rec); @@ -820,12 +840,19 @@ static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec ) control->handler = msi_dialog_button_handler; - /* set the icon */ - text = msi_get_deformatted_field( dialog->package, rec, 10 ); - control->hIcon = msi_load_icon( dialog->package->db, text, attributes ); - if( attributes & msidbControlAttributesIcon ) - SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon ); - msi_free( text ); + if (attributes & msidbControlAttributesIcon) + { + /* set the icon */ + LPWSTR name = msi_get_binary_name( dialog->package, rec ); + control->hIcon = msi_load_icon( dialog->package->db, name, attributes ); + if (control->hIcon) + { + SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon ); + } + else + ERR("Failed to load icon %s\n", debugstr_w(name)); + msi_free( name ); + } return ERROR_SUCCESS; } @@ -1142,7 +1169,7 @@ static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec ) { UINT cx, cy, flags, style, attributes; msi_control *control; - LPWSTR text; + LPWSTR name; flags = LR_LOADFROMFILE; style = SS_BITMAP | SS_LEFT | WS_GROUP; @@ -1160,15 +1187,15 @@ static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec ) cx = msi_dialog_scale_unit( dialog, cx ); cy = msi_dialog_scale_unit( dialog, cy ); - text = msi_get_deformatted_field( dialog->package, rec, 10 ); - control->hBitmap = msi_load_picture( dialog->package->db, text, cx, cy, flags ); + name = msi_get_binary_name( dialog->package, rec ); + control->hBitmap = msi_load_picture( dialog->package->db, name, cx, cy, flags ); if( control->hBitmap ) SendMessageW( control->hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) control->hBitmap ); else - ERR("Failed to load bitmap %s\n", debugstr_w(text)); + ERR("Failed to load bitmap %s\n", debugstr_w(name)); - msi_free( text ); + msi_free( name ); return ERROR_SUCCESS; } @@ -1177,7 +1204,7 @@ static UINT msi_dialog_icon_control( msi_dialog *dialog, MSIRECORD *rec ) { msi_control *control; DWORD attributes; - LPWSTR text; + LPWSTR name; TRACE("\n"); @@ -1185,13 +1212,13 @@ static UINT msi_dialog_icon_control( msi_dialog *dialog, MSIRECORD *rec ) SS_ICON | SS_CENTERIMAGE | WS_GROUP ); attributes = MSI_RecordGetInteger( rec, 8 ); - text = msi_get_deformatted_field( dialog->package, rec, 10 ); - control->hIcon = msi_load_icon( dialog->package->db, text, attributes ); + name = msi_get_binary_name( dialog->package, rec ); + control->hIcon = msi_load_icon( dialog->package->db, name, attributes ); if( control->hIcon ) SendMessageW( control->hwnd, STM_SETICON, (WPARAM) control->hIcon, 0 ); else - ERR("Failed to load bitmap %s\n", debugstr_w(text)); - msi_free( text ); + ERR("Failed to load bitmap %s\n", debugstr_w(name)); + msi_free( name ); return ERROR_SUCCESS; } diff --git a/reactos/dll/win32/msi/files.c b/reactos/dll/win32/msi/files.c index d64195020aa..40501636af2 100644 --- a/reactos/dll/win32/msi/files.c +++ b/reactos/dll/win32/msi/files.c @@ -24,10 +24,10 @@ * * InstallFiles * DuplicateFiles - * MoveFiles (TODO) + * MoveFiles * PatchFiles (TODO) - * RemoveDuplicateFiles(TODO) - * RemoveFiles(TODO) + * RemoveDuplicateFiles + * RemoveFiles */ #include @@ -85,23 +85,6 @@ static int msi_compare_file_version(MSIFILE *file) return lstrcmpW(version, file->Version); } -static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key, - MSIFILE** file) -{ - LIST_FOR_EACH_ENTRY( *file, &package->files, MSIFILE, entry ) - { - if (lstrcmpW( file_key, (*file)->File )==0) - { - if ((*file)->state >= msifs_overwrite) - return ERROR_SUCCESS; - else - return ERROR_FILE_NOT_FOUND; - } - } - - return ERROR_FUNCTION_FAILED; -} - static void schedule_install_files(MSIPACKAGE *package) { MSIFILE *file; @@ -345,15 +328,407 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package) return rc; } +#define is_dot_dir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0)))) + +typedef struct +{ + struct list entry; + LPWSTR sourcename; + LPWSTR destname; + LPWSTR source; + LPWSTR dest; +} FILE_LIST; + +static BOOL msi_move_file(LPCWSTR source, LPCWSTR dest, int options) +{ + BOOL ret; + + if (GetFileAttributesW(source) == FILE_ATTRIBUTE_DIRECTORY || + GetFileAttributesW(dest) == FILE_ATTRIBUTE_DIRECTORY) + { + WARN("Source or dest is directory, not moving\n"); + return FALSE; + } + + if (options == msidbMoveFileOptionsMove) + { + TRACE("moving %s -> %s\n", debugstr_w(source), debugstr_w(dest)); + ret = MoveFileExW(source, dest, MOVEFILE_REPLACE_EXISTING); + if (!ret) + { + WARN("MoveFile failed: %d\n", GetLastError()); + return FALSE; + } + } + else + { + TRACE("copying %s -> %s\n", debugstr_w(source), debugstr_w(dest)); + ret = CopyFileW(source, dest, FALSE); + if (!ret) + { + WARN("CopyFile failed: %d\n", GetLastError()); + return FALSE; + } + } + + return TRUE; +} + +static LPWSTR wildcard_to_file(LPWSTR wildcard, LPWSTR filename) +{ + LPWSTR path, ptr; + DWORD dirlen, pathlen; + + ptr = strrchrW(wildcard, '\\'); + dirlen = ptr - wildcard + 1; + + pathlen = dirlen + lstrlenW(filename) + 1; + path = msi_alloc(pathlen * sizeof(WCHAR)); + + lstrcpynW(path, wildcard, dirlen + 1); + lstrcatW(path, filename); + + return path; +} + +static void free_file_entry(FILE_LIST *file) +{ + msi_free(file->source); + msi_free(file->dest); + msi_free(file); +} + +static void free_list(FILE_LIST *list) +{ + while (!list_empty(&list->entry)) + { + FILE_LIST *file = LIST_ENTRY(list_head(&list->entry), FILE_LIST, entry); + + list_remove(&file->entry); + free_file_entry(file); + } +} + +static BOOL add_wildcard(FILE_LIST *files, LPWSTR source, LPWSTR dest) +{ + FILE_LIST *new, *file; + LPWSTR ptr, filename; + DWORD size; + + new = msi_alloc_zero(sizeof(FILE_LIST)); + if (!new) + return FALSE; + + new->source = strdupW(source); + ptr = strrchrW(dest, '\\') + 1; + filename = strrchrW(new->source, '\\') + 1; + + new->sourcename = filename; + + if (*ptr) + new->destname = ptr; + else + new->destname = new->sourcename; + + size = (ptr - dest) + lstrlenW(filename) + 1; + new->dest = msi_alloc(size * sizeof(WCHAR)); + if (!new->dest) + { + free_file_entry(new); + return FALSE; + } + + lstrcpynW(new->dest, dest, ptr - dest + 1); + lstrcatW(new->dest, filename); + + if (list_empty(&files->entry)) + { + list_add_head(&files->entry, &new->entry); + return TRUE; + } + + LIST_FOR_EACH_ENTRY(file, &files->entry, FILE_LIST, entry) + { + if (lstrcmpW(source, file->source) < 0) + { + list_add_before(&file->entry, &new->entry); + return TRUE; + } + } + + list_add_after(&file->entry, &new->entry); + return TRUE; +} + +static BOOL move_files_wildcard(LPWSTR source, LPWSTR dest, int options) +{ + WIN32_FIND_DATAW wfd; + HANDLE hfile; + LPWSTR path; + BOOL res; + FILE_LIST files, *file; + DWORD size; + + hfile = FindFirstFileW(source, &wfd); + if (hfile == INVALID_HANDLE_VALUE) return FALSE; + + list_init(&files.entry); + + for (res = TRUE; res; res = FindNextFileW(hfile, &wfd)) + { + if (is_dot_dir(wfd.cFileName)) continue; + + path = wildcard_to_file(source, wfd.cFileName); + if (!path) + { + res = FALSE; + goto done; + } + + add_wildcard(&files, path, dest); + msi_free(path); + } + + /* no files match the wildcard */ + if (list_empty(&files.entry)) + goto done; + + /* only the first wildcard match gets renamed to dest */ + file = LIST_ENTRY(list_head(&files.entry), FILE_LIST, entry); + size = (strrchrW(file->dest, '\\') - file->dest) + lstrlenW(file->destname) + 2; + file->dest = msi_realloc(file->dest, size * sizeof(WCHAR)); + if (!file->dest) + { + res = FALSE; + goto done; + } + + /* file->dest may be shorter after the reallocation, so add a NULL + * terminator. This is needed for the call to strrchrW, as there will no + * longer be a NULL terminator within the bounds of the allocation in this case. + */ + file->dest[size - 1] = '\0'; + lstrcpyW(strrchrW(file->dest, '\\') + 1, file->destname); + + while (!list_empty(&files.entry)) + { + file = LIST_ENTRY(list_head(&files.entry), FILE_LIST, entry); + + msi_move_file(file->source, file->dest, options); + + list_remove(&file->entry); + free_file_entry(file); + } + + res = TRUE; + +done: + free_list(&files); + FindClose(hfile); + return res; +} + +static UINT ITERATE_MoveFiles( MSIRECORD *rec, LPVOID param ) +{ + MSIPACKAGE *package = param; + MSIRECORD *uirow; + MSICOMPONENT *comp; + LPCWSTR sourcename, component; + LPWSTR sourcedir, destname = NULL, destdir = NULL, source = NULL, dest = NULL; + int options; + DWORD size; + BOOL ret, wildcards; + + component = MSI_RecordGetString(rec, 2); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL && comp->ActionRequest != INSTALLSTATE_SOURCE) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = comp->ActionRequest; + + sourcename = MSI_RecordGetString(rec, 3); + options = MSI_RecordGetInteger(rec, 7); + + sourcedir = msi_dup_property(package, MSI_RecordGetString(rec, 5)); + if (!sourcedir) + goto done; + + destdir = msi_dup_property(package, MSI_RecordGetString(rec, 6)); + if (!destdir) + goto done; + + if (!sourcename) + { + if (GetFileAttributesW(sourcedir) == INVALID_FILE_ATTRIBUTES) + goto done; + + source = strdupW(sourcedir); + if (!source) + goto done; + } + else + { + size = lstrlenW(sourcedir) + lstrlenW(sourcename) + 2; + source = msi_alloc(size * sizeof(WCHAR)); + if (!source) + goto done; + + lstrcpyW(source, sourcedir); + if (source[lstrlenW(source) - 1] != '\\') + lstrcatW(source, szBackSlash); + lstrcatW(source, sourcename); + } + + wildcards = strchrW(source, '*') || strchrW(source, '?'); + + if (MSI_RecordIsNull(rec, 4)) + { + if (!wildcards) + { + destname = strdupW(sourcename); + if (!destname) + goto done; + } + } + else + { + destname = strdupW(MSI_RecordGetString(rec, 4)); + if (destname) + reduce_to_longfilename(destname); + } + + size = 0; + if (destname) + size = lstrlenW(destname); + + size += lstrlenW(destdir) + 2; + dest = msi_alloc(size * sizeof(WCHAR)); + if (!dest) + goto done; + + lstrcpyW(dest, destdir); + if (dest[lstrlenW(dest) - 1] != '\\') + lstrcatW(dest, szBackSlash); + + if (destname) + lstrcatW(dest, destname); + + if (GetFileAttributesW(destdir) == INVALID_FILE_ATTRIBUTES) + { + ret = CreateDirectoryW(destdir, NULL); + if (!ret) + { + WARN("CreateDirectory failed: %d\n", GetLastError()); + goto done; + } + } + + if (!wildcards) + msi_move_file(source, dest, options); + else + move_files_wildcard(source, dest, options); + +done: + uirow = MSI_CreateRecord( 9 ); + MSI_RecordSetStringW( uirow, 1, MSI_RecordGetString(rec, 1) ); + MSI_RecordSetInteger( uirow, 6, 1 ); /* FIXME */ + MSI_RecordSetStringW( uirow, 9, destdir ); + ui_actiondata( package, szMoveFiles, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free(sourcedir); + msi_free(destdir); + msi_free(destname); + msi_free(source); + msi_free(dest); + + return ERROR_SUCCESS; +} + +UINT ACTION_MoveFiles( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + + static const WCHAR ExecSeqQuery[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','M','o','v','e','F','i','l','e','`',0}; + + rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords(view, NULL, ITERATE_MoveFiles, package); + msiobj_release(&view->hdr); + + return rc; +} + +static WCHAR *get_duplicate_filename( MSIPACKAGE *package, MSIRECORD *row, const WCHAR *file_key, const WCHAR *src ) +{ + DWORD len; + WCHAR *dst_name, *dst_path, *dst; + + if (MSI_RecordIsNull( row, 4 )) + { + len = strlenW( src ) + 1; + if (!(dst_name = msi_alloc( len * sizeof(WCHAR)))) return NULL; + strcpyW( dst_name, strrchrW( src, '\\' ) + 1 ); + } + else + { + MSI_RecordGetStringW( row, 4, NULL, &len ); + if (!(dst_name = msi_alloc( ++len * sizeof(WCHAR) ))) return NULL; + MSI_RecordGetStringW( row, 4, dst_name, &len ); + reduce_to_longfilename( dst_name ); + } + + if (MSI_RecordIsNull( row, 5 )) + { + WCHAR *p; + dst_path = strdupW( src ); + p = strrchrW( dst_path, '\\' ); + if (p) *p = 0; + } + else + { + const WCHAR *dst_key = MSI_RecordGetString( row, 5 ); + + dst_path = resolve_folder( package, dst_key, FALSE, FALSE, TRUE, NULL ); + if (!dst_path) + { + /* try a property */ + dst_path = msi_dup_property( package, dst_key ); + if (!dst_path) + { + FIXME("Unable to get destination folder, try AppSearch properties\n"); + msi_free( dst_name ); + return NULL; + } + } + } + + dst = build_directory_name( 2, dst_path, dst_name ); + create_full_pathW( dst_path ); + + msi_free( dst_name ); + msi_free( dst_path ); + return dst; +} + static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - WCHAR dest_name[0x100]; - LPWSTR dest_path, dest; + LPWSTR dest; LPCWSTR file_key, component; - DWORD sz; - DWORD rc; MSICOMPONENT *comp; + MSIRECORD *uirow; MSIFILE *file; component = MSI_RecordGetString(row,2); @@ -376,70 +751,38 @@ static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param) return ERROR_FUNCTION_FAILED; } - rc = get_file_target(package,file_key,&file); - - if (rc != ERROR_SUCCESS) + file = get_loaded_file( package, file_key ); + if (!file) { - ERR("Original file unknown %s\n",debugstr_w(file_key)); + ERR("Original file unknown %s\n", debugstr_w(file_key)); return ERROR_SUCCESS; } - if (MSI_RecordIsNull(row,4)) - strcpyW(dest_name,strrchrW(file->TargetPath,'\\')+1); - else + dest = get_duplicate_filename( package, row, file_key, file->TargetPath ); + if (!dest) { - sz=0x100; - MSI_RecordGetStringW(row,4,dest_name,&sz); - reduce_to_longfilename(dest_name); + WARN("Unable to get duplicate filename\n"); + return ERROR_SUCCESS; } - if (MSI_RecordIsNull(row,5)) + TRACE("Duplicating file %s to %s\n", debugstr_w(file->TargetPath), debugstr_w(dest)); + + if (!CopyFileW( file->TargetPath, dest, TRUE )) { - LPWSTR p; - dest_path = strdupW(file->TargetPath); - p = strrchrW(dest_path,'\\'); - if (p) - *p=0; + WARN("Failed to copy file %s -> %s (%u)\n", + debugstr_w(file->TargetPath), debugstr_w(dest), GetLastError()); } - else - { - LPCWSTR destkey; - destkey = MSI_RecordGetString(row,5); - dest_path = resolve_folder(package, destkey, FALSE, FALSE, TRUE, NULL); - if (!dest_path) - { - /* try a Property */ - dest_path = msi_dup_property( package, destkey ); - if (!dest_path) - { - FIXME("Unable to get destination folder, try AppSearch properties\n"); - return ERROR_SUCCESS; - } - } - } - - dest = build_directory_name(2, dest_path, dest_name); - create_full_pathW(dest_path); - - TRACE("Duplicating file %s to %s\n",debugstr_w(file->TargetPath), - debugstr_w(dest)); - - if (strcmpW(file->TargetPath,dest)) - rc = !CopyFileW(file->TargetPath,dest,TRUE); - else - rc = ERROR_SUCCESS; - - if (rc != ERROR_SUCCESS) - ERR("Failed to copy file %s -> %s, last error %d\n", - debugstr_w(file->TargetPath), debugstr_w(dest_path), GetLastError()); FIXME("We should track these duplicate files as well\n"); - msi_free(dest_path); + uirow = MSI_CreateRecord( 9 ); + MSI_RecordSetStringW( uirow, 1, MSI_RecordGetString( row, 1 ) ); + MSI_RecordSetInteger( uirow, 6, file->FileSize ); + MSI_RecordSetStringW( uirow, 9, MSI_RecordGetString( row, 5 ) ); + ui_actiondata( package, szDuplicateFiles, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(dest); - - msi_file_update_ui(package, file, szDuplicateFiles); - return ERROR_SUCCESS; } @@ -461,6 +804,84 @@ UINT ACTION_DuplicateFiles(MSIPACKAGE *package) return rc; } +static UINT ITERATE_RemoveDuplicateFiles( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPWSTR dest; + LPCWSTR file_key, component; + MSICOMPONENT *comp; + MSIRECORD *uirow; + MSIFILE *file; + + component = MSI_RecordGetString( row, 2 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + file_key = MSI_RecordGetString( row, 3 ); + if (!file_key) + { + ERR("Unable to get file key\n"); + return ERROR_FUNCTION_FAILED; + } + + file = get_loaded_file( package, file_key ); + if (!file) + { + ERR("Original file unknown %s\n", debugstr_w(file_key)); + return ERROR_SUCCESS; + } + + dest = get_duplicate_filename( package, row, file_key, file->TargetPath ); + if (!dest) + { + WARN("Unable to get duplicate filename\n"); + return ERROR_SUCCESS; + } + + TRACE("Removing duplicate %s of %s\n", debugstr_w(dest), debugstr_w(file->TargetPath)); + + if (!DeleteFileW( dest )) + { + WARN("Failed to delete duplicate file %s (%u)\n", debugstr_w(dest), GetLastError()); + } + + uirow = MSI_CreateRecord( 9 ); + MSI_RecordSetStringW( uirow, 1, MSI_RecordGetString( row, 1 ) ); + MSI_RecordSetStringW( uirow, 9, MSI_RecordGetString( row, 5 ) ); + ui_actiondata( package, szRemoveDuplicateFiles, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free(dest); + return ERROR_SUCCESS; +} + +UINT ACTION_RemoveDuplicateFiles( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveDuplicateFiles, package ); + msiobj_release( &view->hdr ); + + return rc; +} + static BOOL verify_comp_for_removal(MSICOMPONENT *comp, UINT install_mode) { INSTALLSTATE request = comp->ActionRequest; @@ -491,6 +912,7 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; MSICOMPONENT *comp; + MSIRECORD *uirow; LPCWSTR component, filename, dirprop; UINT install_mode; LPWSTR dir = NULL, path = NULL; @@ -529,11 +951,10 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param) goto done; } - lstrcpyW(path, dir); - PathAddBackslashW(path); - if (filename) { + lstrcpyW(path, dir); + PathAddBackslashW(path); lstrcatW(path, filename); TRACE("Deleting misc file: %s\n", debugstr_w(path)); @@ -541,11 +962,17 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param) } else { - TRACE("Removing misc directory: %s\n", debugstr_w(path)); - RemoveDirectoryW(path); + TRACE("Removing misc directory: %s\n", debugstr_w(dir)); + RemoveDirectoryW(dir); } done: + uirow = MSI_CreateRecord( 9 ); + MSI_RecordSetStringW( uirow, 1, MSI_RecordGetString(row, 1) ); + MSI_RecordSetStringW( uirow, 9, dir ); + ui_actiondata( package, szRemoveFiles, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(path); msi_free(dir); return ERROR_SUCCESS; @@ -560,6 +987,9 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package ) static const WCHAR query[] = { 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', '`','R','e','m','o','v','e','F','i','l','e','`',0}; + static const WCHAR folder_query[] = { + 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0}; r = MSI_DatabaseOpenViewW(package->db, query, &view); if (r == ERROR_SUCCESS) @@ -568,10 +998,14 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package ) msiobj_release(&view->hdr); } + r = MSI_DatabaseOpenViewW(package->db, folder_query, &view); + if (r == ERROR_SUCCESS) + msiobj_release(&view->hdr); + LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry ) { MSIRECORD *uirow; - LPWSTR uipath, p; + LPWSTR dir, uipath, p; if ( file->state == msifs_installed ) ERR("removing installed file %s\n", debugstr_w(file->TargetPath)); @@ -587,8 +1021,17 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package ) continue; TRACE("removing %s\n", debugstr_w(file->File) ); - if ( !DeleteFileW( file->TargetPath ) ) - TRACE("failed to delete %s\n", debugstr_w(file->TargetPath)); + if (!DeleteFileW( file->TargetPath )) + { + WARN("failed to delete %s\n", debugstr_w(file->TargetPath)); + } + /* FIXME: check persistence for each directory */ + else if (r && (dir = strdupW( file->TargetPath ))) + { + if ((p = strrchrW( dir, '\\' ))) *p = 0; + RemoveDirectoryW( dir ); + msi_free( dir ); + } file->state = msifs_missing; /* the UI chunk */ diff --git a/reactos/dll/win32/msi/helpers.c b/reactos/dll/win32/msi/helpers.c index e763a113073..c45ba236d50 100644 --- a/reactos/dll/win32/msi/helpers.c +++ b/reactos/dll/win32/msi/helpers.c @@ -156,25 +156,6 @@ MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir ) return NULL; } -void msi_reset_folders( MSIPACKAGE *package, BOOL source ) -{ - MSIFOLDER *folder; - - LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry ) - { - if ( source ) - { - msi_free( folder->ResolvedSource ); - folder->ResolvedSource = NULL; - } - else - { - msi_free( folder->ResolvedTarget ); - folder->ResolvedTarget = NULL; - } - } -} - static LPWSTR get_source_root( MSIPACKAGE *package ) { LPWSTR path, p; @@ -732,7 +713,7 @@ UINT register_unique_action(MSIPACKAGE *package, LPCWSTR action) if (!package->script) return FALSE; - TRACE("Registering Action %s as having fun\n",debugstr_w(action)); + TRACE("Registering %s as unique action\n", debugstr_w(action)); count = package->script->UniqueActionsCount; package->script->UniqueActionsCount++; diff --git a/reactos/dll/win32/msi/msi.rc b/reactos/dll/win32/msi/msi.rc index dfccd08a9a3..a12cd328670 100644 --- a/reactos/dll/win32/msi/msi.rc +++ b/reactos/dll/win32/msi/msi.rc @@ -29,28 +29,31 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include "msi_Bg.rc" #include "msi_Da.rc" -#include "msi_De.rc" #include "msi_En.rc" #include "msi_Eo.rc" #include "msi_Es.rc" #include "msi_Fi.rc" -#include "msi_Fr.rc" #include "msi_Hu.rc" -#include "msi_It.rc" #include "msi_Ko.rc" -#include "msi_Lt.rc" #include "msi_Nl.rc" #include "msi_No.rc" #include "msi_Pl.rc" #include "msi_Pt.rc" -#include "msi_Ro.rc" -#include "msi_Ru.rc" -#include "msi_Si.rc" #include "msi_Sv.rc" #include "msi_Tr.rc" #include "msi_Uk.rc" #include "msi_Zh.rc" +/* UTF-8 */ +#include "msi_De.rc" +#include "msi_Fr.rc" +#include "msi_It.rc" +#include "msi_Lt.rc" +#include "msi_Ro.rc" +#include "msi_Ru.rc" +#include "msi_Si.rc" + + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL /* @makedep: msiserver.tlb */ diff --git a/reactos/dll/win32/msi/msipriv.h b/reactos/dll/win32/msi/msipriv.h index 2278ff7c2c8..0516dd18da7 100644 --- a/reactos/dll/win32/msi/msipriv.h +++ b/reactos/dll/win32/msi/msipriv.h @@ -955,7 +955,9 @@ extern UINT ACTION_CCPSearch(MSIPACKAGE *package); extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package); extern UINT ACTION_InstallFiles(MSIPACKAGE *package); extern UINT ACTION_RemoveFiles(MSIPACKAGE *package); +extern UINT ACTION_MoveFiles(MSIPACKAGE *package); extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package); +extern UINT ACTION_RemoveDuplicateFiles(MSIPACKAGE *package); extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package); @@ -975,7 +977,6 @@ extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Componen extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature ); extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file ); extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir ); -extern void msi_reset_folders( MSIPACKAGE *package, BOOL source ); extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path); extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action); extern void msi_free_action_script(MSIPACKAGE *package, UINT script); @@ -1064,6 +1065,7 @@ static const WCHAR szRegisterProgIdInfo[] = {'R','e','g','i','s','t','e','r','P' static const WCHAR szRegisterExtensionInfo[] = {'R','e','g','i','s','t','e','r','E','x','t','e','n','s','i','o','n','I','n','f','o',0}; static const WCHAR szRegisterMIMEInfo[] = {'R','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0}; static const WCHAR szDuplicateFiles[] = {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0}; +static const WCHAR szRemoveDuplicateFiles[] = {'R','e','m','o','v','e','D','u','p','l','i','c','a','t','e','F','i','l','e','s',0}; static const WCHAR szInstallFiles[] = {'I','n','s','t','a','l','l','F','i','l','e','s',0}; static const WCHAR szRemoveFiles[] = {'R','e','m','o','v','e','F','i','l','e','s',0}; static const WCHAR szFindRelatedProducts[] = {'F','i','n','d','R','e','l','a','t','e','d','P','r','o','d','u','c','t','s',0}; @@ -1075,6 +1077,13 @@ static const WCHAR szPIDTemplate[] = {'P','I','D','T','e','m','p','l','a','t','e static const WCHAR szPIDKEY[] = {'P','I','D','K','E','Y',0}; static const WCHAR szTYPELIB[] = {'T','Y','P','E','L','I','B',0}; static const WCHAR szSumInfo[] = {5 ,'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0}; +static const WCHAR szHCR[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T','\\',0}; +static const WCHAR szHCU[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\',0}; +static const WCHAR szHLM[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E','\\',0}; +static const WCHAR szHU[] = {'H','K','E','Y','_','U','S','E','R','S','\\',0}; +static const WCHAR szWindowsFolder[] = {'W','i','n','d','o','w','s','F','o','l','d','e','r',0}; +static const WCHAR szAppSearch[] = {'A','p','p','S','e','a','r','c','h',0}; +static const WCHAR szMoveFiles[] = {'M','o','v','e','F','i','l','e','s',0}; /* memory allocation macro functions */ static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1); diff --git a/reactos/dll/win32/msi/package.c b/reactos/dll/win32/msi/package.c index ad6d4c65830..b1741ae87cf 100644 --- a/reactos/dll/win32/msi/package.c +++ b/reactos/dll/win32/msi/package.c @@ -1621,6 +1621,25 @@ end: return r; } +static void msi_reset_folders( MSIPACKAGE *package, BOOL source ) +{ + MSIFOLDER *folder; + + LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry ) + { + if ( source ) + { + msi_free( folder->ResolvedSource ); + folder->ResolvedSource = NULL; + } + else + { + msi_free( folder->ResolvedTarget ); + folder->ResolvedTarget = NULL; + } + } +} + UINT MSI_SetPropertyW( MSIPACKAGE *package, LPCWSTR szName, LPCWSTR szValue) { MSIQUERY *view; diff --git a/reactos/dll/win32/msi/streams.c b/reactos/dll/win32/msi/streams.c index 8ec2ad9accb..66bda767a00 100644 --- a/reactos/dll/win32/msi/streams.c +++ b/reactos/dll/win32/msi/streams.c @@ -527,9 +527,9 @@ static INT add_streams_to_table(MSISTREAMSVIEW *sv) break; } - if (!strcmpW(stat.pwcsName, szSumInfo)) + /* these streams appear to be unencoded */ + if (*stat.pwcsName == 0x0005) { - /* summary information stream is not encoded */ r = db_get_raw_stream(sv->db, stat.pwcsName, &stream->stream); } else diff --git a/reactos/dll/win32/msi/upgrade.c b/reactos/dll/win32/msi/upgrade.c index 6d5f4cf6e28..a440070a4d8 100644 --- a/reactos/dll/win32/msi/upgrade.c +++ b/reactos/dll/win32/msi/upgrade.c @@ -182,9 +182,10 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param) continue; } - action_property = MSI_RecordGetString(rec,7); - append_productcode(package,action_property,productid); - ui_actiondata(package,szFindRelatedProducts,uirow); + action_property = MSI_RecordGetString(rec, 7); + append_productcode(package, action_property, productid); + MSI_RecordSetStringW(uirow, 1, productid); + ui_actiondata(package, szFindRelatedProducts, uirow); } index ++; } @@ -202,6 +203,12 @@ UINT ACTION_FindRelatedProducts(MSIPACKAGE *package) UINT rc = ERROR_SUCCESS; MSIQUERY *view; + if (msi_get_property_int(package, szInstalled, 0)) + { + TRACE("Skipping FindRelatedProducts action: product already installed\n"); + return ERROR_SUCCESS; + } + if (check_unique_action(package,szFindRelatedProducts)) { TRACE("Skipping FindRelatedProducts action: already done on client side\n"); diff --git a/reactos/include/psdk/msidefs.h b/reactos/include/psdk/msidefs.h index d87569f61c6..a3b487c8573 100644 --- a/reactos/include/psdk/msidefs.h +++ b/reactos/include/psdk/msidefs.h @@ -222,6 +222,15 @@ enum msidbRemoveFileInstallMode msidbRemoveFileInstallModeOnBoth = 0x00000003, }; +enum +{ + msidbIniFileActionAddLine = 0x00000000, + msidbIniFileActionCreateLine = 0x00000001, + msidbIniFileActionRemoveLine = 0x00000002, + msidbIniFileActionAddTag = 0x00000003, + msidbIniFileActionRemoveTag = 0x00000004 +}; + /* * Windows SDK braindamage alert * From f4c2a120ef8e3b0cf5e10505a2ee9ec5ba89325d Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:06:56 +0000 Subject: [PATCH 125/211] [CRYPT32] sync crypt32 to wine 1.1.40 svn path=/trunk/; revision=45911 --- reactos/dll/win32/crypt32/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/crypt32/main.c b/reactos/dll/win32/crypt32/main.c index 1a5972fe843..5844b1841e5 100644 --- a/reactos/dll/win32/crypt32/main.c +++ b/reactos/dll/win32/crypt32/main.c @@ -161,8 +161,13 @@ BOOL WINAPI I_CryptSetTls(DWORD dwTlsIndex, LPVOID lpTlsValue) BOOL WINAPI I_CryptFreeTls(DWORD dwTlsIndex, DWORD unknown) { + BOOL ret; + TRACE("(%d, %d)\n", dwTlsIndex, unknown); - return TlsFree(dwTlsIndex); + + ret = TlsFree(dwTlsIndex); + if (!ret) SetLastError( E_INVALIDARG ); + return ret; } BOOL WINAPI I_CryptGetOssGlobal(DWORD x) From 03db5f23db53960e364bcb6ecca404599f16b338 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:08:56 +0000 Subject: [PATCH 126/211] [DWMAPI] sync dwmapi to wine 1.1.40 svn path=/trunk/; revision=45912 --- reactos/dll/win32/dwmapi/dwmapi_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/dwmapi/dwmapi_main.c b/reactos/dll/win32/dwmapi/dwmapi_main.c index 60420282966..ee866912a35 100644 --- a/reactos/dll/win32/dwmapi/dwmapi_main.c +++ b/reactos/dll/win32/dwmapi/dwmapi_main.c @@ -54,7 +54,14 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) */ HRESULT WINAPI DwmIsCompositionEnabled(BOOL *enabled) { - FIXME("%p\n", enabled); + static int once; + if (!once) + { + FIXME("%p\n", enabled); + once = 1; + } + else + TRACE("%p\n", enabled); *enabled = FALSE; return S_OK; From 4a6951f8705b2f2124f3f93e9737696ebe74bc3a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:10:27 +0000 Subject: [PATCH 127/211] [QEDIT] sync qedit to wine 1.1.40 svn path=/trunk/; revision=45913 --- reactos/dll/directx/qedit/samplegrabber.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reactos/dll/directx/qedit/samplegrabber.c b/reactos/dll/directx/qedit/samplegrabber.c index b4912eb63de..d09d5546b19 100644 --- a/reactos/dll/directx/qedit/samplegrabber.c +++ b/reactos/dll/directx/qedit/samplegrabber.c @@ -1014,6 +1014,10 @@ SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE } else type = &This->sg->mtype; + if (!IsEqualGUID(&type->formattype, &FORMAT_None) && + !IsEqualGUID(&type->formattype, &GUID_NULL) && + !type->pbFormat) + return VFW_E_TYPE_NOT_ACCEPTED; hr = IPin_ReceiveConnection(receiver,(IPin*)&This->lpVtbl,type); if (FAILED(hr)) return hr; @@ -1054,6 +1058,10 @@ SampleGrabber_In_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_M !IsEqualGUID(&This->sg->mtype.formattype,&FORMAT_None) && !IsEqualGUID(&This->sg->mtype.formattype,&type->formattype)) return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&type->formattype, &FORMAT_None) && + !IsEqualGUID(&type->formattype, &GUID_NULL) && + !type->pbFormat) + return VFW_E_TYPE_NOT_ACCEPTED; if (This->sg->mtype.pbFormat) CoTaskMemFree(This->sg->mtype.pbFormat); This->sg->mtype = *type; From 06ef1d70d80a5189b412d35179f88a15730310cd Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:12:11 +0000 Subject: [PATCH 128/211] [QUARTZ] sync quartz to wine 1.1.40 svn path=/trunk/; revision=45914 --- reactos/dll/directx/quartz/filesource.c | 3 ++- reactos/dll/directx/quartz/pin.c | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/reactos/dll/directx/quartz/filesource.c b/reactos/dll/directx/quartz/filesource.c index 5f6350fb99f..cb9282c8bb5 100644 --- a/reactos/dll/directx/quartz/filesource.c +++ b/reactos/dll/directx/quartz/filesource.c @@ -395,7 +395,8 @@ static HRESULT WINAPI AsyncReader_QueryInterface(IBaseFilter * iface, REFIID rii return S_OK; } - if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IMediaSeeking) && !IsEqualIID(riid, &IID_IVideoWindow)) + if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IMediaSeeking) && + !IsEqualIID(riid, &IID_IVideoWindow) && !IsEqualIID(riid, &IID_IBasicAudio)) FIXME("No interface for %s!\n", qzdebugstr_guid(riid)); return E_NOINTERFACE; diff --git a/reactos/dll/directx/quartz/pin.c b/reactos/dll/directx/quartz/pin.c index 2e24d520667..ca34d9331c5 100644 --- a/reactos/dll/directx/quartz/pin.c +++ b/reactos/dll/directx/quartz/pin.c @@ -765,9 +765,6 @@ HRESULT WINAPI OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDI { assert(pmtCandidate); dump_AM_MEDIA_TYPE(pmtCandidate); - if (!IsEqualGUID(&FORMAT_None, &pmtCandidate->formattype) - && !IsEqualGUID(&GUID_NULL, &pmtCandidate->formattype)) - assert(pmtCandidate->pbFormat); if (( !pmt || CompareMediaTypes(pmt, pmtCandidate, TRUE) ) && (This->pConnectSpecific(iface, pReceivePin, pmtCandidate) == S_OK)) { From 464cdf7f1c0de6b7b607934f6faaee90ed704b93 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:14:00 +0000 Subject: [PATCH 129/211] [ATL] sync atl to wine 1.1.40 svn path=/trunk/; revision=45915 --- reactos/dll/win32/atl/registrar.c | 35 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/reactos/dll/win32/atl/registrar.c b/reactos/dll/win32/atl/registrar.c index b2efda989ad..70c1384ca9b 100644 --- a/reactos/dll/win32/atl/registrar.c +++ b/reactos/dll/win32/atl/registrar.c @@ -758,39 +758,44 @@ static HRESULT do_register_dll_server(IRegistrar *pRegistrar, LPCOLESTR wszDll, LPCOLESTR wszId, BOOL do_register, const struct _ATL_REGMAP_ENTRY* pMapEntries) { - WCHAR buf[MAX_PATH]; + IRegistrar *registrar; HRESULT hres; const struct _ATL_REGMAP_ENTRY *pMapEntry; static const WCHAR wszModule[] = {'M','O','D','U','L','E',0}; static const WCHAR wszRegistry[] = {'R','E','G','I','S','T','R','Y',0}; - static const WCHAR wszCLSID_ATLRegistrar[] = - {'C','L','S','I','D','_','A','T','L','R','e','g','i','s','t','r','a','r',0}; - if (!pRegistrar) - Registrar_create(NULL, &IID_IRegistrar, (void**)&pRegistrar); + if (pRegistrar) + registrar = pRegistrar; + else + Registrar_create(NULL, &IID_IRegistrar, (void**)®istrar); - IRegistrar_AddReplacement(pRegistrar, wszModule, wszDll); + IRegistrar_AddReplacement(registrar, wszModule, wszDll); for (pMapEntry = pMapEntries; pMapEntry && pMapEntry->szKey; pMapEntry++) - IRegistrar_AddReplacement(pRegistrar, pMapEntry->szKey, pMapEntry->szData); - - StringFromGUID2(&CLSID_ATLRegistrar, buf, sizeof(buf)/sizeof(buf[0])); - IRegistrar_AddReplacement(pRegistrar, wszCLSID_ATLRegistrar, buf); + IRegistrar_AddReplacement(registrar, pMapEntry->szKey, pMapEntry->szData); if(do_register) - hres = IRegistrar_ResourceRegisterSz(pRegistrar, wszDll, wszId, wszRegistry); + hres = IRegistrar_ResourceRegisterSz(registrar, wszDll, wszId, wszRegistry); else - hres = IRegistrar_ResourceUnregisterSz(pRegistrar, wszDll, wszId, wszRegistry); + hres = IRegistrar_ResourceUnregisterSz(registrar, wszDll, wszId, wszRegistry); - IRegistrar_Release(pRegistrar); + if(registrar != pRegistrar) + IRegistrar_Release(registrar); return hres; } static HRESULT do_register_server(BOOL do_register) { - static const WCHAR wszDll[] = {'a','t','l','.','d','l','l',0}; - return do_register_dll_server(NULL, wszDll, MAKEINTRESOURCEW(101), do_register, NULL); + static const WCHAR CLSID_ATLRegistrarW[] = + {'C','L','S','I','D','_','A','T','L','R','e','g','i','s','t','r','a','r',0}; + static const WCHAR atl_dllW[] = {'a','t','l','.','d','l','l',0}; + + WCHAR clsid_str[40]; + const struct _ATL_REGMAP_ENTRY reg_map[] = {{CLSID_ATLRegistrarW, clsid_str}, {NULL,NULL}}; + + StringFromGUID2(&CLSID_ATLRegistrar, clsid_str, sizeof(clsid_str)/sizeof(WCHAR)); + return do_register_dll_server(NULL, atl_dllW, MAKEINTRESOURCEW(101), do_register, reg_map); } /*********************************************************************** From 435ed8ec60926457ddae2d47be0e8f9a9a820b7b Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:15:39 +0000 Subject: [PATCH 130/211] [OLEPRO32] sync olepro32 to wine 1.1.40 svn path=/trunk/; revision=45916 --- reactos/dll/win32/olepro32/olepro32stubs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/reactos/dll/win32/olepro32/olepro32stubs.c b/reactos/dll/win32/olepro32/olepro32stubs.c index 04b1868dfc0..a93c24cb320 100644 --- a/reactos/dll/win32/olepro32/olepro32stubs.c +++ b/reactos/dll/win32/olepro32/olepro32stubs.c @@ -53,7 +53,6 @@ HRESULT WINAPI DllRegisterServer(void) */ HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("stub\n"); return S_OK; } From 701bf7b07fe4149adb6f76d607c1b1069ad7795c Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:21:01 +0000 Subject: [PATCH 131/211] [OLEDLG] sync oledlg to wine 1.1.40 svn path=/trunk/; revision=45917 --- reactos/dll/win32/oledlg/insobjdlg.c | 8 ++++---- reactos/dll/win32/oledlg/oledlg_De.rc | 4 ++-- reactos/dll/win32/oledlg/rsrc.rc | 17 ++++++++++------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/reactos/dll/win32/oledlg/insobjdlg.c b/reactos/dll/win32/oledlg/insobjdlg.c index 5db79f61109..01d242e6322 100644 --- a/reactos/dll/win32/oledlg/insobjdlg.c +++ b/reactos/dll/win32/oledlg/insobjdlg.c @@ -380,7 +380,7 @@ static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo) *lpclsid = clsid; len = SendMessageW(pdlgInfo->hwndObjTypeLB, LB_ADDSTRING, 0, (LPARAM)keydesc); - SendMessageW(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, (WPARAM)len, (LPARAM)lpclsid); + SendMessageW(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, len, (LPARAM)lpclsid); } } @@ -426,7 +426,7 @@ static void UIINSERTOBJECTDLG_SelChange(InsertObjectDlgInfo* pdlgInfo) if (LoadStringW(OLEDLG_hInstance, IDS_RESULTOBJDESC, resstr, MAX_PATH) && ((index = SendMessageW(pdlgInfo->hwndObjTypeLB, LB_GETCURSEL, 0, 0)) >= 0) && - SendMessageW(pdlgInfo->hwndObjTypeLB, LB_GETTEXT, (WPARAM)index, (LPARAM)objname)) + SendMessageW(pdlgInfo->hwndObjTypeLB, LB_GETTEXT, index, (LPARAM)objname)) wsprintfW(objdesc, resstr, objname); else objdesc[0] = 0; @@ -452,7 +452,7 @@ static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo) if (index >= 0) { CLSID* clsid = (CLSID*) SendMessageA(pdlgInfo->hwndObjTypeLB, - LB_GETITEMDATA, (WPARAM)index, 0); + LB_GETITEMDATA, index, 0); pdlgInfo->lpOleUIInsertObject->clsid = *clsid; if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CREATENEWOBJECT) @@ -525,7 +525,7 @@ static void UIINSERTOBJECTDLG_BrowseFile(InsertObjectDlgInfo* pdlgInfo) fn.nMaxCustFilter = 0; fn.nFilterIndex = 0; - SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname); + SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, MAX_PATH, (LPARAM)fname); fn.lpstrFile = fname; fn.nMaxFile = MAX_PATH; diff --git a/reactos/dll/win32/oledlg/oledlg_De.rc b/reactos/dll/win32/oledlg/oledlg_De.rc index 6f892091705..498fa80196b 100644 --- a/reactos/dll/win32/oledlg/oledlg_De.rc +++ b/reactos/dll/win32/oledlg/oledlg_De.rc @@ -75,11 +75,11 @@ BEGIN CONTROL "OK", IDOK, "Button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP | WS_VISIBLE, 224, 6, 66, 14 CONTROL "Abbrechen", IDCANCEL, "Button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE, 224, 23, 66, 14 CONTROL "&Hilfe", IDC_OLEUIHELP, "Button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE, 224, 42, 66, 14 - CONTROL "Als Symbol &darstellen", IDC_PS_DISPLAYASICON, "Button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE, 224, 59, 66, 14 + CONTROL "Als Sym&bol", IDC_PS_DISPLAYASICON, "Button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE, 224, 59, 66, 14 CONTROL "", IDC_PS_ICONDISPLAY, "Static", SS_ICON | WS_VISIBLE, 224, 75, 66, 44 CONTROL "&Symbol ändern...", IDC_PS_CHANGEICON, "Button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE, 224, 123, 66, 14 CONTROL "", IDC_PS_RESULTIMAGE, "Static", SS_ICON | WS_VISIBLE, 8, 101, 42, 34 - CONTROL "<< result text goes here >>", IDC_PS_RESULTTEXT, "Static", SS_NOPREFIX | WS_VISIBLE, 54, 100, 159, 35 + CONTROL "<< Ergebnis Text hier her >>", IDC_PS_RESULTTEXT, "Static", SS_NOPREFIX | WS_VISIBLE, 54, 100, 159, 35 CONTROL "Ergebnis", -1, "Button", BS_GROUPBOX | WS_GROUP | WS_VISIBLE, 6, 90, 212, 48 CONTROL "", IDC_PS_SOURCETEXT, "Edit", ES_READONLY | ES_AUTOHSCROLL | WS_VISIBLE, 37, 9, 180, 8 END diff --git a/reactos/dll/win32/oledlg/rsrc.rc b/reactos/dll/win32/oledlg/rsrc.rc index ef8e0ff42de..5966190236d 100644 --- a/reactos/dll/win32/oledlg/rsrc.rc +++ b/reactos/dll/win32/oledlg/rsrc.rc @@ -35,22 +35,25 @@ */ #include "oledlg_Cs.rc" #include "oledlg_Da.rc" -#include "oledlg_De.rc" #include "oledlg_En.rc" #include "oledlg_Es.rc" -#include "oledlg_Fr.rc" #include "oledlg_Hu.rc" #include "oledlg_It.rc" -#include "oledlg_Ja.rc" #include "oledlg_Ko.rc" -#include "oledlg_Lt.rc" #include "oledlg_Nl.rc" #include "oledlg_No.rc" #include "oledlg_Pl.rc" -#include "oledlg_Pt.rc" -#include "oledlg_Ru.rc" -#include "oledlg_Si.rc" #include "oledlg_Sv.rc" #include "oledlg_Tr.rc" #include "oledlg_Uk.rc" + +/* UTF-8 */ +#include "oledlg_De.rc" +#include "oledlg_Fr.rc" +#include "oledlg_Ja.rc" +#include "oledlg_Lt.rc" +#include "oledlg_Pt.rc" +#include "oledlg_Ru.rc" +#include "oledlg_Si.rc" #include "oledlg_Zh.rc" + From d25edac691698efe9e6b51ffee089abd7c81f415 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:42:03 +0000 Subject: [PATCH 132/211] [MSHTML] sync mshtml to wine 1.1.40 svn path=/trunk/; revision=45918 --- reactos/dll/win32/mshtml/htmldoc.c | 3 + reactos/dll/win32/mshtml/htmlscript.c | 14 +- reactos/dll/win32/mshtml/htmlwindow.c | 166 ++++- reactos/dll/win32/mshtml/mshtml_private.h | 24 +- reactos/dll/win32/mshtml/navigate.c | 153 +++-- reactos/dll/win32/mshtml/nsembed.c | 48 +- reactos/dll/win32/mshtml/nsiface.idl | 29 - reactos/dll/win32/mshtml/nsio.c | 756 ++++++++++------------ reactos/dll/win32/mshtml/oleobj.c | 17 +- reactos/dll/win32/mshtml/persist.c | 154 ++--- reactos/dll/win32/mshtml/rsrc.rc | 17 +- reactos/include/psdk/mshtml.idl | 20 + 12 files changed, 770 insertions(+), 631 deletions(-) diff --git a/reactos/dll/win32/mshtml/htmldoc.c b/reactos/dll/win32/mshtml/htmldoc.c index 93aea065011..8adfdb14b43 100644 --- a/reactos/dll/win32/mshtml/htmldoc.c +++ b/reactos/dll/win32/mshtml/htmldoc.c @@ -1776,6 +1776,9 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv) }else if(IsEqualGUID(&IID_IExternalConnection, riid)) { TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv); *ppv = NULL; + }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) { + TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv); + *ppv = NULL; }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) { TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv); *ppv = OBJSITE(This); diff --git a/reactos/dll/win32/mshtml/htmlscript.c b/reactos/dll/win32/mshtml/htmlscript.c index 2427309bfba..f39e3061c5d 100644 --- a/reactos/dll/win32/mshtml/htmlscript.c +++ b/reactos/dll/win32/mshtml/htmlscript.c @@ -214,8 +214,18 @@ static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, V static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v) { HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString nstype_str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + nsAString_Init(&nstype_str, v); + nsres = nsIDOMHTMLScriptElement_SetType(This->nsscript, &nstype_str); + if (NS_FAILED(nsres)) + ERR("SetType failed: %08x\n", nsres); + nsAString_Finish (&nstype_str); + + return S_OK; } static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p) diff --git a/reactos/dll/win32/mshtml/htmlwindow.c b/reactos/dll/win32/mshtml/htmlwindow.c index 58d5f7b5789..491625ed241 100644 --- a/reactos/dll/win32/mshtml/htmlwindow.c +++ b/reactos/dll/win32/mshtml/htmlwindow.c @@ -1,5 +1,5 @@ /* - * Copyright 2006 Jacek Caban for CodeWeavers + * Copyright 2006-2010 Jacek Caban for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,9 +25,9 @@ #include "winuser.h" #include "ole2.h" #include "mshtmdid.h" +#include "shlguid.h" #include "wine/debug.h" -#include "wine/unicode.h" #include "mshtml_private.h" #include "htmlevent.h" @@ -35,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); +#define HTMLPRIVWINDOW(x) ((IHTMLPrivateWindow*) &(x)->lpIHTMLPrivateWindowVtbl) + static struct list window_list = LIST_INIT(window_list); static void window_set_docnode(HTMLWindow *window, HTMLDocumentNode *doc_node) @@ -166,6 +168,9 @@ static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID rii }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) { TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv); *ppv = HTMLWINDOW4(This); + }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) { + TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv); + *ppv = HTMLPRIVWINDOW(This); }else if(dispex_query_interface(&This->dispex, riid, ppv)) { return *ppv ? S_OK : E_NOINTERFACE; } @@ -1641,6 +1646,162 @@ static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = { HTMLWindow4_get_frameElement }; +#define HTMLPRIVWINDOW_THIS(iface) DEFINE_THIS(HTMLWindow, IHTMLPrivateWindow, iface) + +static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + + return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv); +} + +static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + + return IHTMLWindow2_AddRef(HTMLWINDOW2(This)); +} + +static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + + return IHTMLWindow2_Release(HTMLWINDOW2(This)); +} + +static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3, + BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + DWORD post_data_size = 0; + BYTE *post_data = NULL; + WCHAR *headers = NULL; + nsChannelBSC *bsc; + IMoniker *mon; + BSTR new_url; + HRESULT hres; + + TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4), + debugstr_variant(post_data_var), debugstr_variant(headers_var), flags); + + new_url = url; + if(This->doc_obj->hostui) { + OLECHAR *translated_url = NULL; + + hres = IDocHostUIHandler_TranslateUrl(This->doc_obj->hostui, 0, url, &translated_url); + if(hres == S_OK && translated_url) { + new_url = SysAllocString(translated_url); + CoTaskMemFree(translated_url); + } + } + + if(This->doc_obj->client) { + IOleCommandTarget *cmdtrg; + + hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget, (void**)&cmdtrg); + if(SUCCEEDED(hres)) { + VARIANT in, out; + + V_VT(&in) = VT_BSTR; + V_BSTR(&in) = new_url; + V_VT(&out) = VT_BOOL; + V_BOOL(&out) = VARIANT_TRUE; + hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &in, &out); + IOleCommandTarget_Release(cmdtrg); + if(SUCCEEDED(hres)) + VariantClear(&out); + } + } + + /* FIXME: Why not set_ready_state? */ + This->readystate = READYSTATE_UNINITIALIZED; + + hres = CreateURLMoniker(NULL, new_url, &mon); + if(new_url != url) + SysFreeString(new_url); + if(FAILED(hres)) + return hres; + + if(post_data_var) { + if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) { + SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data); + post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements; + } + } + + if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) { + if(V_VT(headers_var) != VT_BSTR) + return E_INVALIDARG; + + headers = V_BSTR(headers_var); + } + + hres = create_channelbsc(mon, headers, post_data, post_data_size, &bsc); + if(post_data) + SafeArrayUnaccessData(V_ARRAY(post_data_var)); + if(FAILED(hres)) { + IMoniker_Release(mon); + return hres; + } + + hres = set_moniker(&This->doc_obj->basedoc, mon, NULL, bsc, TRUE); + if(SUCCEEDED(hres)) + hres = async_start_doc_binding(This, bsc); + + IUnknown_Release((IUnknown*)bsc); + IMoniker_Release(mon); + return hres; +} + +static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%p)\n", This, url); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%p)\n", This, cmdtrg); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%x)\n", This, arg); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLPrivateWindow_GetAddressBar(IHTMLPrivateWindow *iface, BSTR *url) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%p)\n", This, url); + return E_NOTIMPL; +} + +#undef HTMLPRIVWINDOW_THIS + +static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = { + HTMLPrivateWindow_QueryInterface, + HTMLPrivateWindow_AddRef, + HTMLPrivateWindow_Release, + HTMLPrivateWindow_SuperNavigate, + HTMLPrivateWindow_GetPendingUrl, + HTMLPrivateWindow_SetPICSTarget, + HTMLPrivateWindow_PICSComplete, + HTMLPrivateWindow_FindWindowByName, + HTMLPrivateWindow_GetAddressBar +}; + #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface) static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) @@ -1954,6 +2115,7 @@ HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTML window->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl; window->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl; window->lpHTMLWindow4Vtbl = &HTMLWindow4Vtbl; + window->lpIHTMLPrivateWindowVtbl = &HTMLPrivateWindowVtbl; window->lpIDispatchExVtbl = &WindowDispExVtbl; window->ref = 1; window->doc_obj = doc_obj; diff --git a/reactos/dll/win32/mshtml/mshtml_private.h b/reactos/dll/win32/mshtml/mshtml_private.h index c65bffa9f79..5a409b3cae5 100644 --- a/reactos/dll/win32/mshtml/mshtml_private.h +++ b/reactos/dll/win32/mshtml/mshtml_private.h @@ -172,9 +172,11 @@ BOOL dispex_query_interface(DispatchEx*,REFIID,void**); HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**); HRESULT get_dispids(tid_t,DWORD*,DISPID**); +typedef struct HTMLWindow HTMLWindow; typedef struct HTMLDocumentNode HTMLDocumentNode; typedef struct HTMLDocumentObj HTMLDocumentObj; typedef struct HTMLFrameBase HTMLFrameBase; +typedef struct NSContainer NSContainer; typedef enum { SCRIPTMODE_GECKO, @@ -226,11 +228,14 @@ typedef struct { LONG ref; } windowref_t; +typedef struct nsChannelBSC nsChannelBSC; + struct HTMLWindow { DispatchEx dispex; const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl; const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl; const IHTMLWindow4Vtbl *lpHTMLWindow4Vtbl; + const IHTMLPrivateWindowVtbl *lpIHTMLPrivateWindowVtbl; const IDispatchExVtbl *lpIDispatchExVtbl; LONG ref; @@ -393,7 +398,7 @@ struct HTMLDocumentObj { BOOL in_place_active; BOOL ui_active; BOOL window_active; - BOOL has_key_path; + BOOL hostui_setup; BOOL container_locked; BOOL focus; INT download_state; @@ -434,6 +439,11 @@ struct NSContainer { HWND reset_focus; /* hack */ }; +typedef struct nsWineURI nsWineURI; + +HRESULT set_wine_url(nsWineURI*,LPCWSTR); +nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*); + typedef struct { const nsIHttpChannelVtbl *lpHttpChannelVtbl; const nsIUploadChannelVtbl *lpUploadChannelVtbl; @@ -441,7 +451,7 @@ typedef struct { LONG ref; - nsIWineURI *uri; + nsWineURI *uri; nsIInputStream *post_data_stream; nsILoadGroup *load_group; nsIInterfaceRequestor *notif_callback; @@ -696,12 +706,13 @@ void release_nsio(void); BOOL install_wine_gecko(BOOL); HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*); -HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsIWineURI**); +HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**); +HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD); -HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD); +HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD,BOOL*); HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*); HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*); -HRESULT load_nsuri(HTMLWindow*,nsIWineURI*,DWORD); +HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL); void call_property_onchanged(ConnectionPoint*,DISPID); HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*); @@ -730,11 +741,12 @@ void add_nsevent_listener(HTMLDocumentNode*,LPCWSTR); void set_window_bscallback(HTMLWindow*,nsChannelBSC*); void set_current_mon(HTMLWindow*,IMoniker*); HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*); +HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*); void abort_document_bindings(HTMLDocumentNode*); HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*); -nsChannelBSC *create_channelbsc(IMoniker*); +HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**); HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*); void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*); IMoniker *get_channelbsc_mon(nsChannelBSC*); diff --git a/reactos/dll/win32/mshtml/navigate.c b/reactos/dll/win32/mshtml/navigate.c index b85de92e33d..a09ea7f64d6 100644 --- a/reactos/dll/win32/mshtml/navigate.c +++ b/reactos/dll/win32/mshtml/navigate.c @@ -717,8 +717,11 @@ HRESULT start_binding(HTMLWindow *window, HTMLDocumentNode *doc, BSCallback *bsc /* NOTE: IE7 calls IsSystemMoniker here*/ - if(window) + if(window) { + if(bscallback->mon != window->mon) + set_current_mon(window, bscallback->mon); call_docview_84(window->doc_obj); + } if(bctx) { RegisterBindStatusCallback(bctx, STATUSCLB(bscallback), NULL, 0); @@ -1087,7 +1090,7 @@ static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCW TRACE("redirect to %s\n", debugstr_w(status_text)); /* FIXME: We should find a better way to handle this */ - nsIWineURI_SetWineURL(This->nschannel->uri, status_text); + set_wine_url(This->nschannel->uri, status_text); } return S_OK; @@ -1113,13 +1116,38 @@ static const BSCallbackVtbl nsChannelBSCVtbl = { nsChannelBSC_on_response }; -nsChannelBSC *create_channelbsc(IMoniker *mon) +HRESULT create_channelbsc(IMoniker *mon, WCHAR *headers, BYTE *post_data, DWORD post_data_size, nsChannelBSC **retval) { - nsChannelBSC *ret = heap_alloc_zero(sizeof(*ret)); + nsChannelBSC *ret; + + ret = heap_alloc_zero(sizeof(*ret)); + if(!ret) + return E_OUTOFMEMORY; init_bscallback(&ret->bsc, &nsChannelBSCVtbl, mon, BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA); - return ret; + if(headers) { + ret->bsc.headers = heap_strdupW(headers); + if(!ret->bsc.headers) { + IBindStatusCallback_Release(STATUSCLB(&ret->bsc)); + return E_OUTOFMEMORY; + } + } + + if(post_data) { + ret->bsc.post_data = GlobalAlloc(0, post_data_size); + if(!ret->bsc.post_data) { + heap_free(ret->bsc.headers); + IBindStatusCallback_Release(STATUSCLB(&ret->bsc)); + return E_OUTOFMEMORY; + } + + memcpy(ret->bsc.post_data, post_data, post_data_size); + ret->bsc.post_data_len = post_data_size; + } + + *retval = ret; + return S_OK; } IMoniker *get_channelbsc_mon(nsChannelBSC *This) @@ -1148,6 +1176,36 @@ void set_window_bscallback(HTMLWindow *window, nsChannelBSC *callback) } } +typedef struct { + task_t header; + HTMLWindow *window; + nsChannelBSC *bscallback; +} start_doc_binding_task_t; + +static void start_doc_binding_proc(task_t *_task) +{ + start_doc_binding_task_t *task = (start_doc_binding_task_t*)_task; + + start_binding(task->window, NULL, (BSCallback*)task->bscallback, NULL); + IBindStatusCallback_Release(STATUSCLB(&task->bscallback->bsc)); +} + +HRESULT async_start_doc_binding(HTMLWindow *window, nsChannelBSC *bscallback) +{ + start_doc_binding_task_t *task; + + task = heap_alloc(sizeof(start_doc_binding_task_t)); + if(!task) + return E_OUTOFMEMORY; + + task->window = window; + task->bscallback = bscallback; + IBindStatusCallback_AddRef(STATUSCLB(&bscallback->bsc)); + + push_task(&task->header, start_doc_binding_proc, window->task_magic); + return S_OK; +} + void abort_document_bindings(HTMLDocumentNode *doc) { BSCallback *iter; @@ -1196,37 +1254,43 @@ void channelbsc_set_channel(nsChannelBSC *This, nsChannel *channel, nsIStreamLis } HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, - nsIInputStream *post_data_stream, DWORD hlnf) + nsIInputStream *post_data_stream, DWORD hlnf, BOOL *cancel) { IHlinkFrame *hlink_frame; + nsChannelBSC *callback; IServiceProvider *sp; - BSCallback *callback; IBindCtx *bindctx; IMoniker *mon; IHlink *hlink; HRESULT hres; + *cancel = FALSE; + hres = IOleClientSite_QueryInterface(doc->doc_obj->client, &IID_IServiceProvider, (void**)&sp); if(FAILED(hres)) - return hres; + return S_OK; hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hlink_frame); IServiceProvider_Release(sp); if(FAILED(hres)) + return S_OK; + + hres = create_channelbsc(NULL, NULL, NULL, 0, &callback); + if(FAILED(hres)) { + IHlinkFrame_Release(hlink_frame); return hres; - - callback = &create_channelbsc(NULL)->bsc; - - if(post_data_stream) { - parse_post_data(post_data_stream, &callback->headers, &callback->post_data, - &callback->post_data_len); - TRACE("headers = %s post_data = %s\n", debugstr_w(callback->headers), - debugstr_an(callback->post_data, callback->post_data_len)); } - hres = CreateAsyncBindCtx(0, STATUSCLB(callback), NULL, &bindctx); + if(post_data_stream) { + parse_post_data(post_data_stream, &callback->bsc.headers, &callback->bsc.post_data, + &callback->bsc.post_data_len); + TRACE("headers = %s post_data = %s\n", debugstr_w(callback->bsc.headers), + debugstr_an(callback->bsc.post_data, callback->bsc.post_data_len)); + } + + hres = CreateAsyncBindCtx(0, STATUSCLB(&callback->bsc), NULL, &bindctx); if(SUCCEEDED(hres)) hres = CoCreateInstance(&CLSID_StdHlink, NULL, CLSCTX_INPROC_SERVER, &IID_IHlink, (LPVOID*)&hlink); @@ -1242,50 +1306,22 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, IHlink_SetTargetFrameName(hlink, wszBlank); /* FIXME */ } - hres = IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx, STATUSCLB(callback), hlink); - + hres = IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx, STATUSCLB(&callback->bsc), hlink); IMoniker_Release(mon); + *cancel = hres == S_OK; + hres = S_OK; } IHlinkFrame_Release(hlink_frame); IBindCtx_Release(bindctx); - IBindStatusCallback_Release(STATUSCLB(callback)); + IBindStatusCallback_Release(STATUSCLB(&callback->bsc)); return hres; } -HRESULT load_nsuri(HTMLWindow *window, nsIWineURI *uri, DWORD flags) -{ - nsIWebNavigation *web_navigation; - nsIDocShell *doc_shell; - nsresult nsres; - - nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation); - if(NS_FAILED(nsres)) { - ERR("Could not get nsIWebNavigation interface: %08x\n", nsres); - return E_FAIL; - } - - nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell); - nsIWebNavigation_Release(web_navigation); - if(NS_FAILED(nsres)) { - ERR("Could not get nsIDocShell: %08x\n", nsres); - return E_FAIL; - } - - nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)uri, NULL, flags, FALSE); - nsIDocShell_Release(doc_shell); - if(NS_FAILED(nsres)) { - WARN("LoadURI failed: %08x\n", nsres); - return E_FAIL; - } - - return S_OK; -} - HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base_url) { WCHAR url[INTERNET_MAX_URL_LENGTH]; - nsIWineURI *uri; + nsWineURI *uri; HRESULT hres; if(!new_url) { @@ -1307,23 +1343,30 @@ HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, url, &translated_url); if(hres == S_OK) { + TRACE("%08x %s -> %s\n", hres, debugstr_w(url), debugstr_w(translated_url)); strcpyW(url, translated_url); CoTaskMemFree(translated_url); } } if(window->doc_obj && window == window->doc_obj->basedoc.window) { - hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0); - if(SUCCEEDED(hres)) + BOOL cancel; + + hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0, &cancel); + if(FAILED(hres)) + return hres; + + if(cancel) { + TRACE("Navigation handled by hlink frame\n"); return S_OK; - TRACE("hlink_frame_navigate failed: %08x\n", hres); + } } hres = create_doc_uri(window, url, &uri); if(FAILED(hres)) return hres; - hres = load_nsuri(window, uri, LOAD_FLAGS_NONE); - nsIWineURI_Release(uri); + hres = load_nsuri(window, uri, NULL, LOAD_FLAGS_NONE); + nsISupports_Release((nsISupports*)uri); return hres; } diff --git a/reactos/dll/win32/mshtml/nsembed.c b/reactos/dll/win32/mshtml/nsembed.c index 3415657fbcb..fa8aa41fedf 100644 --- a/reactos/dll/win32/mshtml/nsembed.c +++ b/reactos/dll/win32/mshtml/nsembed.c @@ -1124,41 +1124,12 @@ static nsrefcnt NSAPI nsURIContentListener_Release(nsIURIContentListener *iface) return nsIWebBrowserChrome_Release(NSWBCHROME(This)); } -static BOOL translate_url(HTMLDocumentObj *doc, nsIWineURI *nsuri) -{ - OLECHAR *new_url = NULL, *url; - BOOL ret = FALSE; - LPCWSTR wine_url; - HRESULT hres; - - if(!doc->hostui) - return FALSE; - - nsIWineURI_GetWineURL(nsuri, &wine_url); - - url = heap_strdupW(wine_url); - hres = IDocHostUIHandler_TranslateUrl(doc->hostui, 0, url, &new_url); - heap_free(url); - if(hres != S_OK || !new_url) - return FALSE; - - if(strcmpW(url, new_url)) { - FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url), debugstr_w(new_url)); - ret = TRUE; - } - - CoTaskMemFree(new_url); - return ret; -} - static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface, nsIURI *aURI, PRBool *_retval) { NSContainer *This = NSURICL_THIS(iface); - nsIWineURI *wine_uri; nsACString spec_str; const char *spec; - BOOL is_doc_uri; nsresult nsres; nsACString_Init(&spec_str, NULL); @@ -1169,22 +1140,9 @@ static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener nsACString_Finish(&spec_str); - nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri); - if(NS_FAILED(nsres)) { - WARN("Could not get nsIWineURI interface: %08x\n", nsres); - return NS_ERROR_NOT_IMPLEMENTED; - } - - nsIWineURI_GetIsDocumentURI(wine_uri, &is_doc_uri); - - if(!is_doc_uri) { - nsIWineURI_SetNSContainer(wine_uri, This); - nsIWineURI_SetIsDocumentURI(wine_uri, TRUE); - - *_retval = translate_url(This->doc->basedoc.doc_obj, wine_uri); - } - - nsIWineURI_Release(wine_uri); + nsres = on_start_uri_open(This, aURI, _retval); + if(NS_FAILED(nsres)) + return nsres; return !*_retval && This->content_listener ? nsIURIContentListener_OnStartURIOpen(This->content_listener, aURI, _retval) diff --git a/reactos/dll/win32/mshtml/nsiface.idl b/reactos/dll/win32/mshtml/nsiface.idl index af117622001..66ab8e6a49b 100644 --- a/reactos/dll/win32/mshtml/nsiface.idl +++ b/reactos/dll/win32/mshtml/nsiface.idl @@ -2820,32 +2820,3 @@ interface nsIDocumentObserver : nsIMutationObserver void BindToDocument(nsIDocument *aDocument, nsIContent *aContent); void DoneAddingChildren(nsIContent *aContent, PRBool aHaveNotified); } - -/* - * NOTE: - * This is a private Wine interface that is implemented by our implementation - * of nsIURI to store its owner. - */ -[ - object, - uuid(5088272e-900b-11da-c687-000fea57f21a), - local - /* INTERNAL */ -] -interface nsIWineURI : nsIURL -{ - typedef struct NSContainer NSContainer; - typedef struct HTMLWindow HTMLWindow; - typedef struct nsChannelBSC nsChannelBSC; - - nsresult GetNSContainer(NSContainer **aNSContainer); - nsresult SetNSContainer(NSContainer *aNSContainer); - nsresult GetWindow(HTMLWindow **aHTMLWindow); - nsresult SetWindow(HTMLWindow *aHTMLWindow); - nsresult GetChannelBSC(nsChannelBSC **aChannelBSC); - nsresult SetChannelBSC(nsChannelBSC *aChannelBSC); - nsresult GetIsDocumentURI(PRBool *aIsDocumentURI); - nsresult SetIsDocumentURI(PRBool aIsDocumentURI); - nsresult GetWineURL(LPCWSTR *aURL); - nsresult SetWineURL(LPCWSTR aURL); -} diff --git a/reactos/dll/win32/mshtml/nsio.c b/reactos/dll/win32/mshtml/nsio.c index 763e877eafd..f4e6f4bcb56 100644 --- a/reactos/dll/win32/mshtml/nsio.c +++ b/reactos/dll/win32/mshtml/nsio.c @@ -43,14 +43,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); static const IID NS_IOSERVICE_CID = {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}}; +static const IID IID_nsWineURI = + {0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}}; static nsIIOService *nsio = NULL; static nsINetUtil *net_util; static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; -typedef struct { - const nsIWineURIVtbl *lpWineURIVtbl; +struct nsWineURI { + const nsIURLVtbl *lpIURLVtbl; LONG ref; @@ -60,14 +62,14 @@ typedef struct { windowref_t *window_ref; nsChannelBSC *channel_bsc; LPWSTR wine_url; - PRBool is_doc_uri; + BOOL is_doc_uri; BOOL use_wine_url; -} nsURI; +}; -#define NSURI(x) ((nsIURI*) &(x)->lpWineURIVtbl) -#define NSWINEURI(x) ((nsIWineURI*) &(x)->lpWineURIVtbl) +#define NSURI(x) ((nsIURI*) &(x)->lpIURLVtbl) +#define NSURL(x) ((nsIURL*) &(x)->lpIURLVtbl) -static nsresult create_uri(nsIURI*,HTMLWindow*,NSContainer*,nsIWineURI**); +static nsresult create_uri(nsIURI*,HTMLWindow*,NSContainer*,nsWineURI**); static const char *debugstr_nsacstr(const nsACString *nsstr) { @@ -129,15 +131,9 @@ static BOOL before_async_open(nsChannel *channel, NSContainer *container) { HTMLDocumentObj *doc = container->doc; DWORD hlnf = 0; - LPCWSTR uri; + BOOL cancel; HRESULT hres; - nsIWineURI_GetWineURL(channel->uri, &uri); - if(!uri) { - ERR("GetWineURL returned NULL\n"); - return TRUE; - } - if(!doc) { NSContainer *container_iter = container; @@ -150,11 +146,163 @@ static BOOL before_async_open(nsChannel *channel, NSContainer *container) if(!doc->client) return TRUE; - if(!hlnf && !exec_shldocvw_67(doc, uri)) + if(!hlnf && !exec_shldocvw_67(doc, channel->uri->wine_url)) return FALSE; - hres = hlink_frame_navigate(&doc->basedoc, uri, channel->post_data_stream, hlnf); - return hres != S_OK; + hres = hlink_frame_navigate(&doc->basedoc, channel->uri->wine_url, channel->post_data_stream, hlnf, &cancel); + return FAILED(hres) || cancel; +} + +HRESULT load_nsuri(HTMLWindow *window, nsWineURI *uri, nsChannelBSC *channelbsc, DWORD flags) +{ + nsIWebNavigation *web_navigation; + nsIDocShell *doc_shell; + nsresult nsres; + + nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIWebNavigation interface: %08x\n", nsres); + return E_FAIL; + } + + nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell); + nsIWebNavigation_Release(web_navigation); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIDocShell: %08x\n", nsres); + return E_FAIL; + } + + + uri->channel_bsc = channelbsc; + nsres = nsIDocShell_LoadURI(doc_shell, NSURI(uri), NULL, flags, FALSE); + uri->channel_bsc = NULL; + nsIDocShell_Release(doc_shell); + if(NS_FAILED(nsres)) { + WARN("LoadURI failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; +} + +static BOOL translate_url(HTMLDocumentObj *doc, nsWineURI *uri) +{ + OLECHAR *new_url = NULL, *url; + BOOL ret = FALSE; + HRESULT hres; + + if(!doc->hostui) + return FALSE; + + url = heap_strdupW(uri->wine_url); + hres = IDocHostUIHandler_TranslateUrl(doc->hostui, 0, url, &new_url); + heap_free(url); + if(hres != S_OK || !new_url) + return FALSE; + + if(strcmpW(url, new_url)) { + FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url), debugstr_w(new_url)); + ret = TRUE; + } + + CoTaskMemFree(new_url); + return ret; +} + +nsresult on_start_uri_open(NSContainer *nscontainer, nsIURI *uri, PRBool *_retval) +{ + nsWineURI *wine_uri; + nsresult nsres; + + *_retval = FALSE; + + nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri); + if(NS_FAILED(nsres)) { + WARN("Could not get nsWineURI: %08x\n", nsres); + return NS_ERROR_NOT_IMPLEMENTED; + } + + if(!wine_uri->is_doc_uri) { + if(!wine_uri->container) { + nsIWebBrowserChrome_AddRef(NSWBCHROME(nscontainer)); + wine_uri->container = nscontainer; + } + + wine_uri->is_doc_uri = TRUE; + *_retval = translate_url(nscontainer->doc->basedoc.doc_obj, wine_uri); + } + + nsIURI_Release(NSURI(wine_uri)); + return NS_OK; +} + +HRESULT set_wine_url(nsWineURI *This, LPCWSTR url) +{ + static const WCHAR wszFtp[] = {'f','t','p',':'}; + static const WCHAR wszHttp[] = {'h','t','t','p',':'}; + static const WCHAR wszHttps[] = {'h','t','t','p','s',':'}; + + TRACE("(%p)->(%s)\n", This, debugstr_w(url)); + + if(url) { + WCHAR *new_url; + + new_url = heap_strdupW(url); + if(!new_url) + return E_OUTOFMEMORY; + heap_free(This->wine_url); + This->wine_url = new_url; + + if(This->uri) { + /* FIXME: Always use wine url */ + This->use_wine_url = + strncmpW(url, wszFtp, sizeof(wszFtp)/sizeof(WCHAR)) + && strncmpW(url, wszHttp, sizeof(wszHttp)/sizeof(WCHAR)) + && strncmpW(url, wszHttps, sizeof(wszHttps)/sizeof(WCHAR)); + }else { + This->use_wine_url = TRUE; + } + }else { + heap_free(This->wine_url); + This->wine_url = NULL; + This->use_wine_url = FALSE; + } + + return S_OK; +} + +static void set_uri_nscontainer(nsWineURI *This, NSContainer *nscontainer) +{ + if(This->container) { + if(This->container == nscontainer) + return; + TRACE("Changing %p -> %p\n", This->container, nscontainer); + nsIWebBrowserChrome_Release(NSWBCHROME(This->container)); + } + + if(nscontainer) + nsIWebBrowserChrome_AddRef(NSWBCHROME(nscontainer)); + This->container = nscontainer; +} + +static void set_uri_window(nsWineURI *This, HTMLWindow *window) +{ + if(This->window_ref) { + if(This->window_ref->window == window) + return; + TRACE("Changing %p -> %p\n", This->window_ref->window, window); + windowref_release(This->window_ref); + } + + if(window) { + windowref_addref(window->window_ref); + This->window_ref = window->window_ref; + + if(window->doc_obj) + set_uri_nscontainer(This, window->doc_obj->nscontainer); + }else { + This->window_ref = NULL; + } } static inline BOOL is_http_channel(nsChannel *This) @@ -215,7 +363,7 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface) LONG ref = InterlockedDecrement(&This->ref); if(!ref) { - nsIWineURI_Release(This->uri); + nsIURI_Release(NSURI(This->uri)); if(This->owner) nsISupports_Release(This->owner); if(This->post_data_stream) @@ -369,7 +517,7 @@ static nsresult NSAPI nsChannel_GetURI(nsIHttpChannel *iface, nsIURI **aURI) TRACE("(%p)->(%p)\n", This, aURI); - nsIWineURI_AddRef(This->uri); + nsIURI_AddRef(NSURI(This->uri)); *aURI = (nsIURI*)This->uri; return NS_OK; @@ -531,8 +679,7 @@ static nsresult NSAPI nsChannel_Open(nsIHttpChannel *iface, nsIInputStream **_re static HRESULT create_mon_for_nschannel(nsChannel *channel, IMoniker **mon) { - nsIWineURI *wine_uri; - LPCWSTR wine_url; + nsWineURI *wine_uri; nsresult nsres; HRESULT hres; @@ -541,22 +688,22 @@ static HRESULT create_mon_for_nschannel(nsChannel *channel, IMoniker **mon) return E_FAIL; } - nsres = nsIURI_QueryInterface(channel->original_uri, &IID_nsIWineURI, (void**)&wine_uri); + nsres = nsIURI_QueryInterface(channel->original_uri, &IID_nsWineURI, (void**)&wine_uri); if(NS_FAILED(nsres)) { - ERR("Could not get nsIWineURI: %08x\n", nsres); + ERR("Could not get nsWineURI: %08x\n", nsres); return E_FAIL; } - nsIWineURI_GetWineURL(wine_uri, &wine_url); - nsIWineURI_Release(wine_uri); - if(!wine_url) { + if(wine_uri->wine_url) { + hres = CreateURLMoniker(NULL, wine_uri->wine_url, mon); + if(FAILED(hres)) + WARN("CreateURLMoniker failed: %08x\n", hres); + }else { TRACE("wine_url == NULL\n"); - return E_FAIL; + hres = E_FAIL; } - hres = CreateURLMoniker(NULL, wine_url, mon); - if(FAILED(hres)) - WARN("CreateURLMoniker failed: %08x\n", hres); + nsIURI_Release(NSURI(wine_uri)); return hres; } @@ -566,7 +713,7 @@ static HTMLWindow *get_window_from_load_group(nsChannel *This) HTMLWindow *window; nsIChannel *channel; nsIRequest *req; - nsIWineURI *wine_uri; + nsWineURI *wine_uri; nsIURI *uri; nsresult nsres; @@ -593,15 +740,17 @@ static HTMLWindow *get_window_from_load_group(nsChannel *This) return NULL; } - nsres = nsIURI_QueryInterface(uri, &IID_nsIWineURI, (void**)&wine_uri); + nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri); nsIURI_Release(uri); if(NS_FAILED(nsres)) { - TRACE("Could not get nsIWineURI: %08x\n", nsres); + TRACE("Could not get nsWineURI: %08x\n", nsres); return NULL; } - nsIWineURI_GetWindow(wine_uri, &window); - nsIWineURI_Release(wine_uri); + window = wine_uri->window_ref ? wine_uri->window_ref->window : NULL; + if(window) + IHTMLWindow2_AddRef(HTMLWINDOW2(window)); + nsIURI_Release(NSURI(wine_uri)); return window; } @@ -660,19 +809,7 @@ static void start_binding_proc(task_t *_task) start_binding_task_t *task = (start_binding_task_t*)_task; start_binding(NULL, task->doc, (BSCallback*)task->bscallback, NULL); -} -typedef struct { - task_t header; - HTMLWindow *window; - nsChannelBSC *bscallback; -} start_doc_binding_task_t; - -static void start_doc_binding_proc(task_t *_task) -{ - start_doc_binding_task_t *task = (start_doc_binding_task_t*)_task; - - start_binding(task->window, NULL, (BSCallback*)task->bscallback, NULL); IUnknown_Release((IUnknown*)task->bscallback); } @@ -690,20 +827,17 @@ static nsresult async_open(nsChannel *This, HTMLWindow *window, BOOL is_doc_chan if(is_doc_channel) set_current_mon(window, mon); - bscallback = create_channelbsc(mon); + hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback); IMoniker_Release(mon); + if(FAILED(hres)) + return NS_ERROR_UNEXPECTED; channelbsc_set_channel(bscallback, This, listener, context); if(is_doc_channel) { - start_doc_binding_task_t *task; - set_window_bscallback(window, bscallback); - - task = heap_alloc(sizeof(start_doc_binding_task_t)); - task->window = window; - task->bscallback = bscallback; - push_task(&task->header, start_doc_binding_proc, window->task_magic); + async_start_doc_binding(window, bscallback); + IUnknown_Release((IUnknown*)bscallback); }else { start_binding_task_t *task = heap_alloc(sizeof(start_binding_task_t)); @@ -720,51 +854,37 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen { nsChannel *This = NSCHANNEL_THIS(iface); HTMLWindow *window = NULL; - PRBool is_doc_uri; BOOL open = TRUE; nsresult nsres = NS_OK; - TRACE("(%p)->(%p %p)\n", This, aListener, aContext); + TRACE("(%p)->(%p %p) opening %s\n", This, aListener, aContext, debugstr_w(This->uri->wine_url)); - if(TRACE_ON(mshtml)) { - LPCWSTR url; - - nsIWineURI_GetWineURL(This->uri, &url); - TRACE("opening %s\n", debugstr_w(url)); - } - - nsIWineURI_GetIsDocumentURI(This->uri, &is_doc_uri); - if(is_doc_uri) { + if(This->uri->is_doc_uri) { window = get_channel_window(This); if(window) { - nsIWineURI_SetWindow(This->uri, window); - }else { - NSContainer *nscontainer; + set_uri_window(This->uri, window); + }else if(This->uri->container) { + BOOL b; - nsIWineURI_GetNSContainer(This->uri, &nscontainer); - if(nscontainer) { - BOOL b; + /* nscontainer->doc should be NULL which means navigation to a new window */ + if(This->uri->container->doc) + FIXME("nscontainer->doc = %p\n", This->uri->container->doc); - /* nscontainer->doc should be NULL which means navigation to a new window */ - if(nscontainer->doc) - FIXME("nscontainer->doc = %p\n", nscontainer->doc); - - b = before_async_open(This, nscontainer); - nsIWebBrowserChrome_Release(NSWBCHROME(nscontainer)); - if(b) - FIXME("Navigation not cancelled\n"); - return NS_ERROR_UNEXPECTED; - } + b = before_async_open(This, This->uri->container); + if(b) + FIXME("Navigation not cancelled\n"); + return NS_ERROR_UNEXPECTED; } } if(!window) { - nsIWineURI_GetWindow(This->uri, &window); - - if(!window && This->load_group) { + if(This->uri->window_ref && This->uri->window_ref->window) { + window = This->uri->window_ref->window; + IHTMLWindow2_AddRef(HTMLWINDOW2(window)); + }else if(This->load_group) { window = get_window_from_load_group(This); if(window) - nsIWineURI_SetWindow(This->uri, window); + set_uri_window(This->uri, window); } } @@ -773,13 +893,9 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen return NS_ERROR_UNEXPECTED; } - if(is_doc_uri && window == window->doc_obj->basedoc.window) { - nsChannelBSC *channel_bsc; - - nsIWineURI_GetChannelBSC(This->uri, &channel_bsc); - if(channel_bsc) { - channelbsc_set_channel(channel_bsc, This, aListener, aContext); - IUnknown_Release((IUnknown*)channel_bsc); + if(This->uri->is_doc_uri && window == window->doc_obj->basedoc.window) { + if(This->uri->channel_bsc) { + channelbsc_set_channel(This->uri->channel_bsc, This, aListener, aContext); if(window->doc_obj->mime) { heap_free(This->content_type); @@ -797,7 +913,7 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen } if(open) - nsres = async_open(This, window, is_doc_uri, aListener, aContext); + nsres = async_open(This, window, This->uri->is_doc_uri, aListener, aContext); IHTMLWindow2_Release(HTMLWINDOW2(window)); return nsres; @@ -1225,11 +1341,11 @@ static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl = { nsHttpChannelInternal_SetForceAllowThirdPartyCookie }; -#define NSURI_THIS(iface) DEFINE_THIS(nsURI, WineURI, iface) +#define NSURI_THIS(iface) DEFINE_THIS(nsWineURI, IURL, iface) -static nsresult NSAPI nsURI_QueryInterface(nsIWineURI *iface, nsIIDRef riid, nsQIResult result) +static nsresult NSAPI nsURI_QueryInterface(nsIURL *iface, nsIIDRef riid, nsQIResult result) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); *result = NULL; @@ -1241,10 +1357,10 @@ static nsresult NSAPI nsURI_QueryInterface(nsIWineURI *iface, nsIIDRef riid, nsQ *result = NSURI(This); }else if(IsEqualGUID(&IID_nsIURL, riid)) { TRACE("(%p)->(IID_nsIURL %p)\n", This, result); - *result = NSURI(This); - }else if(IsEqualGUID(&IID_nsIWineURI, riid)) { - TRACE("(%p)->(IID_nsIWineURI %p)\n", This, result); - *result = NSURI(This); + *result = NSURL(This); + }else if(IsEqualGUID(&IID_nsWineURI, riid)) { + TRACE("(%p)->(IID_nsWineURI %p)\n", This, result); + *result = This; } if(*result) { @@ -1256,9 +1372,9 @@ static nsresult NSAPI nsURI_QueryInterface(nsIWineURI *iface, nsIIDRef riid, nsQ return This->uri ? nsIURI_QueryInterface(This->uri, riid, result) : NS_NOINTERFACE; } -static nsrefcnt NSAPI nsURI_AddRef(nsIWineURI *iface) +static nsrefcnt NSAPI nsURI_AddRef(nsIURL *iface) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -1266,9 +1382,9 @@ static nsrefcnt NSAPI nsURI_AddRef(nsIWineURI *iface) return ref; } -static nsrefcnt NSAPI nsURI_Release(nsIWineURI *iface) +static nsrefcnt NSAPI nsURI_Release(nsIURL *iface) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -1289,9 +1405,9 @@ static nsrefcnt NSAPI nsURI_Release(nsIWineURI *iface) return ref; } -static nsresult NSAPI nsURI_GetSpec(nsIWineURI *iface, nsACString *aSpec) +static nsresult NSAPI nsURI_GetSpec(nsIURL *iface, nsACString *aSpec) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aSpec); @@ -1311,9 +1427,9 @@ static nsresult NSAPI nsURI_GetSpec(nsIWineURI *iface, nsACString *aSpec) } -static nsresult NSAPI nsURI_SetSpec(nsIWineURI *iface, const nsACString *aSpec) +static nsresult NSAPI nsURI_SetSpec(nsIURL *iface, const nsACString *aSpec) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aSpec); @@ -1324,9 +1440,9 @@ static nsresult NSAPI nsURI_SetSpec(nsIWineURI *iface, const nsACString *aSpec) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetPrePath(nsIWineURI *iface, nsACString *aPrePath) +static nsresult NSAPI nsURI_GetPrePath(nsIURL *iface, nsACString *aPrePath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPrePath); @@ -1337,9 +1453,9 @@ static nsresult NSAPI nsURI_GetPrePath(nsIWineURI *iface, nsACString *aPrePath) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetScheme(nsIWineURI *iface, nsACString *aScheme) +static nsresult NSAPI nsURI_GetScheme(nsIURL *iface, nsACString *aScheme) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aScheme); @@ -1359,9 +1475,9 @@ static nsresult NSAPI nsURI_GetScheme(nsIWineURI *iface, nsACString *aScheme) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetScheme(nsIWineURI *iface, const nsACString *aScheme) +static nsresult NSAPI nsURI_SetScheme(nsIURL *iface, const nsACString *aScheme) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aScheme); @@ -1372,9 +1488,9 @@ static nsresult NSAPI nsURI_SetScheme(nsIWineURI *iface, const nsACString *aSche return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetUserPass(nsIWineURI *iface, nsACString *aUserPass) +static nsresult NSAPI nsURI_GetUserPass(nsIURL *iface, nsACString *aUserPass) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aUserPass); @@ -1385,9 +1501,9 @@ static nsresult NSAPI nsURI_GetUserPass(nsIWineURI *iface, nsACString *aUserPass return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetUserPass(nsIWineURI *iface, const nsACString *aUserPass) +static nsresult NSAPI nsURI_SetUserPass(nsIURL *iface, const nsACString *aUserPass) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aUserPass); @@ -1398,9 +1514,9 @@ static nsresult NSAPI nsURI_SetUserPass(nsIWineURI *iface, const nsACString *aUs return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetUsername(nsIWineURI *iface, nsACString *aUsername) +static nsresult NSAPI nsURI_GetUsername(nsIURL *iface, nsACString *aUsername) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aUsername); @@ -1411,9 +1527,9 @@ static nsresult NSAPI nsURI_GetUsername(nsIWineURI *iface, nsACString *aUsername return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetUsername(nsIWineURI *iface, const nsACString *aUsername) +static nsresult NSAPI nsURI_SetUsername(nsIURL *iface, const nsACString *aUsername) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aUsername); @@ -1424,9 +1540,9 @@ static nsresult NSAPI nsURI_SetUsername(nsIWineURI *iface, const nsACString *aUs return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetPassword(nsIWineURI *iface, nsACString *aPassword) +static nsresult NSAPI nsURI_GetPassword(nsIURL *iface, nsACString *aPassword) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPassword); @@ -1437,9 +1553,9 @@ static nsresult NSAPI nsURI_GetPassword(nsIWineURI *iface, nsACString *aPassword return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetPassword(nsIWineURI *iface, const nsACString *aPassword) +static nsresult NSAPI nsURI_SetPassword(nsIURL *iface, const nsACString *aPassword) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPassword); @@ -1450,9 +1566,9 @@ static nsresult NSAPI nsURI_SetPassword(nsIWineURI *iface, const nsACString *aPa return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetHostPort(nsIWineURI *iface, nsACString *aHostPort) +static nsresult NSAPI nsURI_GetHostPort(nsIURL *iface, nsACString *aHostPort) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aHostPort); @@ -1463,9 +1579,9 @@ static nsresult NSAPI nsURI_GetHostPort(nsIWineURI *iface, nsACString *aHostPort return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetHostPort(nsIWineURI *iface, const nsACString *aHostPort) +static nsresult NSAPI nsURI_SetHostPort(nsIURL *iface, const nsACString *aHostPort) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aHostPort); @@ -1476,9 +1592,9 @@ static nsresult NSAPI nsURI_SetHostPort(nsIWineURI *iface, const nsACString *aHo return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetHost(nsIWineURI *iface, nsACString *aHost) +static nsresult NSAPI nsURI_GetHost(nsIURL *iface, nsACString *aHost) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aHost); @@ -1489,9 +1605,9 @@ static nsresult NSAPI nsURI_GetHost(nsIWineURI *iface, nsACString *aHost) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetHost(nsIWineURI *iface, const nsACString *aHost) +static nsresult NSAPI nsURI_SetHost(nsIURL *iface, const nsACString *aHost) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aHost); @@ -1502,9 +1618,9 @@ static nsresult NSAPI nsURI_SetHost(nsIWineURI *iface, const nsACString *aHost) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetPort(nsIWineURI *iface, PRInt32 *aPort) +static nsresult NSAPI nsURI_GetPort(nsIURL *iface, PRInt32 *aPort) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPort); @@ -1515,9 +1631,9 @@ static nsresult NSAPI nsURI_GetPort(nsIWineURI *iface, PRInt32 *aPort) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetPort(nsIWineURI *iface, PRInt32 aPort) +static nsresult NSAPI nsURI_SetPort(nsIURL *iface, PRInt32 aPort) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%d)\n", This, aPort); @@ -1528,9 +1644,9 @@ static nsresult NSAPI nsURI_SetPort(nsIWineURI *iface, PRInt32 aPort) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetPath(nsIWineURI *iface, nsACString *aPath) +static nsresult NSAPI nsURI_GetPath(nsIURL *iface, nsACString *aPath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPath); @@ -1541,9 +1657,9 @@ static nsresult NSAPI nsURI_GetPath(nsIWineURI *iface, nsACString *aPath) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetPath(nsIWineURI *iface, const nsACString *aPath) +static nsresult NSAPI nsURI_SetPath(nsIURL *iface, const nsACString *aPath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); const char *path; nsACString_GetData(aPath, &path); @@ -1560,7 +1676,7 @@ static nsresult NSAPI nsURI_SetPath(nsIWineURI *iface, const nsACString *aPath) hres = UrlCombineW(This->wine_url, pathw, new_url, &size, 0); heap_free(pathw); if(SUCCEEDED(hres)) - nsIWineURI_SetWineURL(NSWINEURI(This), new_url); + set_wine_url(This, new_url); else WARN("UrlCombine failed: %08x\n", hres); } @@ -1571,11 +1687,10 @@ static nsresult NSAPI nsURI_SetPath(nsIWineURI *iface, const nsACString *aPath) return nsIURI_SetPath(This->uri, aPath); } -static nsresult NSAPI nsURI_Equals(nsIWineURI *iface, nsIURI *other, PRBool *_retval) +static nsresult NSAPI nsURI_Equals(nsIURL *iface, nsIURI *other, PRBool *_retval) { - nsURI *This = NSURI_THIS(iface); - nsIWineURI *wine_uri; - LPCWSTR other_url = NULL; + nsWineURI *This = NSURI_THIS(iface); + nsWineURI *wine_uri; nsresult nsres; TRACE("(%p)->(%p %p)\n", This, other, _retval); @@ -1583,23 +1698,22 @@ static nsresult NSAPI nsURI_Equals(nsIWineURI *iface, nsIURI *other, PRBool *_re if(This->uri) return nsIURI_Equals(This->uri, other, _retval); - nsres = nsIURI_QueryInterface(other, &IID_nsIWineURI, (void**)&wine_uri); + nsres = nsIURI_QueryInterface(other, &IID_nsWineURI, (void**)&wine_uri); if(NS_FAILED(nsres)) { - TRACE("Could not get nsIWineURI interface\n"); + TRACE("Could not get nsWineURI interface\n"); *_retval = FALSE; return NS_OK; } - nsIWineURI_GetWineURL(wine_uri, &other_url); - *_retval = other_url && !UrlCompareW(This->wine_url, other_url, TRUE); - nsIWineURI_Release(wine_uri); + *_retval = wine_uri->wine_url && !UrlCompareW(This->wine_url, wine_uri->wine_url, TRUE); + nsIURI_Release(NSURI(wine_uri)); return NS_OK; } -static nsresult NSAPI nsURI_SchemeIs(nsIWineURI *iface, const char *scheme, PRBool *_retval) +static nsresult NSAPI nsURI_SchemeIs(nsIURL *iface, const char *scheme, PRBool *_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s %p)\n", This, debugstr_a(scheme), _retval); @@ -1620,11 +1734,11 @@ static nsresult NSAPI nsURI_SchemeIs(nsIWineURI *iface, const char *scheme, PRBo return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_Clone(nsIWineURI *iface, nsIURI **_retval) +static nsresult NSAPI nsURI_Clone(nsIURL *iface, nsIURI **_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); nsIURI *nsuri = NULL; - nsIWineURI *wine_uri; + nsWineURI *wine_uri; nsresult nsres; TRACE("(%p)->(%p)\n", This, _retval); @@ -1643,14 +1757,16 @@ static nsresult NSAPI nsURI_Clone(nsIWineURI *iface, nsIURI **_retval) return nsres; } - *_retval = (nsIURI*)wine_uri; - return nsIWineURI_SetWineURL(wine_uri, This->wine_url); + set_wine_url(wine_uri, This->wine_url); + + *_retval = NSURI(wine_uri); + return NS_OK; } -static nsresult NSAPI nsURI_Resolve(nsIWineURI *iface, const nsACString *arelativePath, +static nsresult NSAPI nsURI_Resolve(nsIURL *iface, const nsACString *arelativePath, nsACString *_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p %p)\n", This, arelativePath, _retval); @@ -1661,9 +1777,9 @@ static nsresult NSAPI nsURI_Resolve(nsIWineURI *iface, const nsACString *arelati return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetAsciiSpec(nsIWineURI *iface, nsACString *aAsciiSpec) +static nsresult NSAPI nsURI_GetAsciiSpec(nsIURL *iface, nsACString *aAsciiSpec) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aAsciiSpec); @@ -1677,9 +1793,9 @@ static nsresult NSAPI nsURI_GetAsciiSpec(nsIWineURI *iface, nsACString *aAsciiSp return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetAsciiHost(nsIWineURI *iface, nsACString *aAsciiHost) +static nsresult NSAPI nsURI_GetAsciiHost(nsIURL *iface, nsACString *aAsciiHost) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aAsciiHost); @@ -1690,9 +1806,9 @@ static nsresult NSAPI nsURI_GetAsciiHost(nsIWineURI *iface, nsACString *aAsciiHo return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetOriginCharset(nsIWineURI *iface, nsACString *aOriginCharset) +static nsresult NSAPI nsURI_GetOriginCharset(nsIURL *iface, nsACString *aOriginCharset) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aOriginCharset); @@ -1703,9 +1819,9 @@ static nsresult NSAPI nsURI_GetOriginCharset(nsIWineURI *iface, nsACString *aOri return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetFilePath(nsIWineURI *iface, nsACString *aFilePath) +static nsresult NSAPI nsURL_GetFilePath(nsIURL *iface, nsACString *aFilePath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aFilePath); @@ -1716,9 +1832,9 @@ static nsresult NSAPI nsURL_GetFilePath(nsIWineURI *iface, nsACString *aFilePath return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetFilePath(nsIWineURI *iface, const nsACString *aFilePath) +static nsresult NSAPI nsURL_SetFilePath(nsIURL *iface, const nsACString *aFilePath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFilePath)); @@ -1729,9 +1845,9 @@ static nsresult NSAPI nsURL_SetFilePath(nsIWineURI *iface, const nsACString *aFi return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetParam(nsIWineURI *iface, nsACString *aParam) +static nsresult NSAPI nsURL_GetParam(nsIURL *iface, nsACString *aParam) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aParam); @@ -1742,9 +1858,9 @@ static nsresult NSAPI nsURL_GetParam(nsIWineURI *iface, nsACString *aParam) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetParam(nsIWineURI *iface, const nsACString *aParam) +static nsresult NSAPI nsURL_SetParam(nsIURL *iface, const nsACString *aParam) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aParam)); @@ -1755,9 +1871,9 @@ static nsresult NSAPI nsURL_SetParam(nsIWineURI *iface, const nsACString *aParam return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetQuery(nsIWineURI *iface, nsACString *aQuery) +static nsresult NSAPI nsURL_GetQuery(nsIURL *iface, nsACString *aQuery) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aQuery); @@ -1768,9 +1884,9 @@ static nsresult NSAPI nsURL_GetQuery(nsIWineURI *iface, nsACString *aQuery) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetQuery(nsIWineURI *iface, const nsACString *aQuery) +static nsresult NSAPI nsURL_SetQuery(nsIURL *iface, const nsACString *aQuery) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); const WCHAR *ptr1, *ptr2; const char *query; WCHAR *new_url, *ptr; @@ -1821,9 +1937,9 @@ static nsresult NSAPI nsURL_SetQuery(nsIWineURI *iface, const nsACString *aQuery return NS_OK; } -static nsresult NSAPI nsURL_GetRef(nsIWineURI *iface, nsACString *aRef) +static nsresult NSAPI nsURL_GetRef(nsIURL *iface, nsACString *aRef) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aRef); @@ -1834,9 +1950,9 @@ static nsresult NSAPI nsURL_GetRef(nsIWineURI *iface, nsACString *aRef) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetRef(nsIWineURI *iface, const nsACString *aRef) +static nsresult NSAPI nsURL_SetRef(nsIURL *iface, const nsACString *aRef) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); const char *refa; TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRef)); @@ -1852,9 +1968,9 @@ static nsresult NSAPI nsURL_SetRef(nsIWineURI *iface, const nsACString *aRef) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetDirectory(nsIWineURI *iface, nsACString *aDirectory) +static nsresult NSAPI nsURL_GetDirectory(nsIURL *iface, nsACString *aDirectory) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aDirectory); @@ -1865,9 +1981,9 @@ static nsresult NSAPI nsURL_GetDirectory(nsIWineURI *iface, nsACString *aDirecto return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetDirectory(nsIWineURI *iface, const nsACString *aDirectory) +static nsresult NSAPI nsURL_SetDirectory(nsIURL *iface, const nsACString *aDirectory) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aDirectory)); @@ -1878,9 +1994,9 @@ static nsresult NSAPI nsURL_SetDirectory(nsIWineURI *iface, const nsACString *aD return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetFileName(nsIWineURI *iface, nsACString *aFileName) +static nsresult NSAPI nsURL_GetFileName(nsIURL *iface, nsACString *aFileName) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aFileName); @@ -1891,9 +2007,9 @@ static nsresult NSAPI nsURL_GetFileName(nsIWineURI *iface, nsACString *aFileName return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetFileName(nsIWineURI *iface, const nsACString *aFileName) +static nsresult NSAPI nsURL_SetFileName(nsIURL *iface, const nsACString *aFileName) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileName)); @@ -1904,9 +2020,9 @@ static nsresult NSAPI nsURL_SetFileName(nsIWineURI *iface, const nsACString *aFi return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetFileBaseName(nsIWineURI *iface, nsACString *aFileBaseName) +static nsresult NSAPI nsURL_GetFileBaseName(nsIURL *iface, nsACString *aFileBaseName) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aFileBaseName); @@ -1917,9 +2033,9 @@ static nsresult NSAPI nsURL_GetFileBaseName(nsIWineURI *iface, nsACString *aFile return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetFileBaseName(nsIWineURI *iface, const nsACString *aFileBaseName) +static nsresult NSAPI nsURL_SetFileBaseName(nsIURL *iface, const nsACString *aFileBaseName) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileBaseName)); @@ -1930,9 +2046,9 @@ static nsresult NSAPI nsURL_SetFileBaseName(nsIWineURI *iface, const nsACString return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetFileExtension(nsIWineURI *iface, nsACString *aFileExtension) +static nsresult NSAPI nsURL_GetFileExtension(nsIURL *iface, nsACString *aFileExtension) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aFileExtension); @@ -1943,9 +2059,9 @@ static nsresult NSAPI nsURL_GetFileExtension(nsIWineURI *iface, nsACString *aFil return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetFileExtension(nsIWineURI *iface, const nsACString *aFileExtension) +static nsresult NSAPI nsURL_SetFileExtension(nsIURL *iface, const nsACString *aFileExtension) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileExtension)); @@ -1956,9 +2072,9 @@ static nsresult NSAPI nsURL_SetFileExtension(nsIWineURI *iface, const nsACString return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIWineURI *iface, nsIURI *aURIToCompare, nsACString *_retval) +static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIURL *iface, nsIURI *aURIToCompare, nsACString *_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p %p)\n", This, aURIToCompare, _retval); @@ -1969,9 +2085,9 @@ static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIWineURI *iface, nsIURI *aURIToC return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetRelativeSpec(nsIWineURI *iface, nsIURI *aURIToCompare, nsACString *_retval) +static nsresult NSAPI nsURL_GetRelativeSpec(nsIURL *iface, nsIURI *aURIToCompare, nsACString *_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p %p)\n", This, aURIToCompare, _retval); @@ -1982,174 +2098,9 @@ static nsresult NSAPI nsURL_GetRelativeSpec(nsIWineURI *iface, nsIURI *aURIToCom return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetNSContainer(nsIWineURI *iface, NSContainer **aContainer) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aContainer); - - if(This->container) - nsIWebBrowserChrome_AddRef(NSWBCHROME(This->container)); - *aContainer = This->container; - - return NS_OK; -} - -static nsresult NSAPI nsURI_SetNSContainer(nsIWineURI *iface, NSContainer *aContainer) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aContainer); - - if(This->container) { - if(This->container == aContainer) - return NS_OK; - TRACE("Changing %p -> %p\n", This->container, aContainer); - nsIWebBrowserChrome_Release(NSWBCHROME(This->container)); - } - - if(aContainer) - nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer)); - This->container = aContainer; - - return NS_OK; -} - -static nsresult NSAPI nsURI_GetWindow(nsIWineURI *iface, HTMLWindow **aHTMLWindow) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aHTMLWindow); - - if(This->window_ref && This->window_ref->window) { - IHTMLWindow2_AddRef(HTMLWINDOW2(This->window_ref->window)); - *aHTMLWindow = This->window_ref->window; - }else { - *aHTMLWindow = NULL; - } - - return NS_OK; -} - -static nsresult NSAPI nsURI_SetWindow(nsIWineURI *iface, HTMLWindow *aHTMLWindow) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aHTMLWindow); - - if(This->window_ref) { - if(This->window_ref->window == aHTMLWindow) - return NS_OK; - TRACE("Changing %p -> %p\n", This->window_ref->window, aHTMLWindow); - windowref_release(This->window_ref); - } - - if(aHTMLWindow) { - windowref_addref(aHTMLWindow->window_ref); - This->window_ref = aHTMLWindow->window_ref; - - if(aHTMLWindow->doc_obj) - nsIWineURI_SetNSContainer(NSWINEURI(This), aHTMLWindow->doc_obj->nscontainer); - }else { - This->window_ref = NULL; - } - - return NS_OK; -} - -static nsresult NSAPI nsURI_GetChannelBSC(nsIWineURI *iface, nsChannelBSC **aChannelBSC) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aChannelBSC); - - if(This->channel_bsc) - IUnknown_AddRef((IUnknown*)This->channel_bsc); - *aChannelBSC = This->channel_bsc; - return NS_OK; -} - -static nsresult NSAPI nsURI_SetChannelBSC(nsIWineURI *iface, nsChannelBSC *aChannelBSC) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aChannelBSC); - - if(This->channel_bsc) - IUnknown_Release((IUnknown*)This->channel_bsc); - if(aChannelBSC) - IUnknown_AddRef((IUnknown*)aChannelBSC); - This->channel_bsc = aChannelBSC; - return NS_OK; -} - -static nsresult NSAPI nsURI_GetIsDocumentURI(nsIWineURI *iface, PRBool *aIsDocumentURI) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aIsDocumentURI); - - *aIsDocumentURI = This->is_doc_uri; - return NS_OK; -} - -static nsresult NSAPI nsURI_SetIsDocumentURI(nsIWineURI *iface, PRBool aIsDocumentURI) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%x)\n", This, aIsDocumentURI); - - This->is_doc_uri = aIsDocumentURI; - return NS_OK; -} - -static nsresult NSAPI nsURI_GetWineURL(nsIWineURI *iface, LPCWSTR *aURL) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aURL); - - *aURL = This->wine_url; - return NS_OK; -} - -static nsresult NSAPI nsURI_SetWineURL(nsIWineURI *iface, LPCWSTR aURL) -{ - nsURI *This = NSURI_THIS(iface); - - static const WCHAR wszFtp[] = {'f','t','p',':'}; - static const WCHAR wszHttp[] = {'h','t','t','p',':'}; - static const WCHAR wszHttps[] = {'h','t','t','p','s',':'}; - - TRACE("(%p)->(%s)\n", This, debugstr_w(aURL)); - - heap_free(This->wine_url); - - if(aURL) { - int len = strlenW(aURL)+1; - This->wine_url = heap_alloc(len*sizeof(WCHAR)); - memcpy(This->wine_url, aURL, len*sizeof(WCHAR)); - - if(This->uri) { - /* FIXME: Always use wine url */ - This->use_wine_url = - strncmpW(aURL, wszFtp, sizeof(wszFtp)/sizeof(WCHAR)) - && strncmpW(aURL, wszHttp, sizeof(wszHttp)/sizeof(WCHAR)) - && strncmpW(aURL, wszHttps, sizeof(wszHttps)/sizeof(WCHAR)); - }else { - This->use_wine_url = TRUE; - } - }else { - This->wine_url = NULL; - This->use_wine_url = FALSE; - } - - return NS_OK; -} - #undef NSURI_THIS -static const nsIWineURIVtbl nsWineURIVtbl = { +static const nsIURLVtbl nsURLVtbl = { nsURI_QueryInterface, nsURI_AddRef, nsURI_Release, @@ -2196,51 +2147,39 @@ static const nsIWineURIVtbl nsWineURIVtbl = { nsURL_GetFileExtension, nsURL_SetFileExtension, nsURL_GetCommonBaseSpec, - nsURL_GetRelativeSpec, - nsURI_GetNSContainer, - nsURI_SetNSContainer, - nsURI_GetWindow, - nsURI_SetWindow, - nsURI_GetChannelBSC, - nsURI_SetChannelBSC, - nsURI_GetIsDocumentURI, - nsURI_SetIsDocumentURI, - nsURI_GetWineURL, - nsURI_SetWineURL + nsURL_GetRelativeSpec }; -static nsresult create_uri(nsIURI *uri, HTMLWindow *window, NSContainer *container, nsIWineURI **_retval) +static nsresult create_uri(nsIURI *uri, HTMLWindow *window, NSContainer *container, nsWineURI **_retval) { - nsURI *ret = heap_alloc_zero(sizeof(nsURI)); + nsWineURI *ret = heap_alloc_zero(sizeof(nsWineURI)); - ret->lpWineURIVtbl = &nsWineURIVtbl; + ret->lpIURLVtbl = &nsURLVtbl; ret->ref = 1; ret->uri = uri; - nsIWineURI_SetNSContainer(NSWINEURI(ret), container); - nsIWineURI_SetWindow(NSWINEURI(ret), window); + set_uri_nscontainer(ret, container); + set_uri_window(ret, window); if(uri) nsIURI_QueryInterface(uri, &IID_nsIURL, (void**)&ret->nsurl); - else - ret->nsurl = NULL; TRACE("retval=%p\n", ret); - *_retval = NSWINEURI(ret); + *_retval = ret; return NS_OK; } -HRESULT create_doc_uri(HTMLWindow *window, WCHAR *url, nsIWineURI **ret) +HRESULT create_doc_uri(HTMLWindow *window, WCHAR *url, nsWineURI **ret) { - nsIWineURI *uri; + nsWineURI *uri; nsresult nsres; nsres = create_uri(NULL, window, window->doc_obj->nscontainer, &uri); if(NS_FAILED(nsres)) return E_FAIL; - nsIWineURI_SetWineURL(uri, url); - nsIWineURI_SetIsDocumentURI(uri, TRUE); + set_wine_url(uri, url); + uri->is_doc_uri = TRUE; *ret = uri; return S_OK; @@ -2470,11 +2409,11 @@ static BOOL is_gecko_special_uri(const char *spec) static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString *aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) { + nsWineURI *wine_uri, *base_wine_uri = NULL; const char *spec = NULL; HTMLWindow *window = NULL; nsIURI *uri = NULL; LPCWSTR base_wine_url = NULL; - nsIWineURI *base_wine_uri = NULL, *wine_uri; BOOL is_wine_uri = FALSE; nsresult nsres; @@ -2494,16 +2433,19 @@ static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString * if(aBaseURI) { PARSEDURLA parsed_url = {sizeof(PARSEDURLA)}; - nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsIWineURI, (void**)&base_wine_uri); + nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsWineURI, (void**)&base_wine_uri); if(NS_SUCCEEDED(nsres)) { - nsIWineURI_GetWineURL(base_wine_uri, &base_wine_url); - nsIWineURI_GetWindow(base_wine_uri, &window); + base_wine_url = base_wine_uri->wine_url; + if(base_wine_uri->window_ref && base_wine_uri->window_ref->window) { + window = base_wine_uri->window_ref->window; + IHTMLWindow2_AddRef(HTMLWINDOW2(window)); + } TRACE("base url: %s window: %p\n", debugstr_w(base_wine_url), window); }else if(FAILED(ParseURLA(spec, &parsed_url))) { TRACE("not wraping\n"); return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval); }else { - WARN("Could not get base nsIWineURI: %08x\n", nsres); + WARN("Could not get base nsWineURI: %08x\n", nsres); } } @@ -2528,18 +2470,18 @@ static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString * URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, url, sizeof(url)/sizeof(WCHAR), &len, 0); if(SUCCEEDED(hres)) - nsIWineURI_SetWineURL(wine_uri, url); + set_wine_url(wine_uri, url); else WARN("CoCombineUrl failed: %08x\n", hres); }else if(is_wine_uri) { WCHAR url[INTERNET_MAX_URL_LENGTH]; MultiByteToWideChar(CP_ACP, 0, spec, -1, url, sizeof(url)/sizeof(WCHAR)); - nsIWineURI_SetWineURL(wine_uri, url); + set_wine_url(wine_uri, url); } if(base_wine_uri) - nsIWineURI_Release(base_wine_uri); + nsIURI_Release(NSURI(base_wine_uri)); return nsres; } @@ -2556,15 +2498,14 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI { PARSEDURLW parsed_url = {sizeof(PARSEDURLW)}; nsChannel *ret; - nsIWineURI *wine_uri; - const WCHAR *url; + nsWineURI *wine_uri; nsresult nsres; TRACE("(%p %p)\n", aURI, _retval); - nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri); + nsres = nsIURI_QueryInterface(aURI, &IID_nsWineURI, (void**)&wine_uri); if(NS_FAILED(nsres)) { - TRACE("Could not get nsIWineURI: %08x\n", nsres); + TRACE("Could not get nsWineURI: %08x\n", nsres); return nsIIOService_NewChannelFromURI(nsio, aURI, _retval); } @@ -2578,9 +2519,8 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI nsIURI_AddRef(aURI); ret->original_uri = aURI; - - nsIWineURI_GetWineURL(wine_uri, &url); - ret->url_scheme = url && SUCCEEDED(ParseURLW(url, &parsed_url)) ? parsed_url.nScheme : URL_SCHEME_UNKNOWN; + ret->url_scheme = wine_uri->wine_url && SUCCEEDED(ParseURLW(wine_uri->wine_url, &parsed_url)) + ? parsed_url.nScheme : URL_SCHEME_UNKNOWN; *_retval = NSCHANNEL(ret); return NS_OK; diff --git a/reactos/dll/win32/mshtml/oleobj.c b/reactos/dll/win32/mshtml/oleobj.c index 3dec3dc62dd..a33f4793ed8 100644 --- a/reactos/dll/win32/mshtml/oleobj.c +++ b/reactos/dll/win32/mshtml/oleobj.c @@ -34,9 +34,13 @@ #include "wine/debug.h" #include "mshtml_private.h" +#include "initguid.h" WINE_DEFAULT_DEBUG_CHANNEL(mshtml); +DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0); +#define DOCHOST_DOCCANNAVIGATE 0 + /********************************************************** * IOleObject implementation */ @@ -92,6 +96,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite HTMLDocument *This = OLEOBJ_THIS(iface); IDocHostUIHandler *pDocHostUIHandler = NULL; IOleCommandTarget *cmdtrg = NULL; + BOOL hostui_setup; VARIANT silent; HRESULT hres; @@ -116,6 +121,8 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite if(!pClientSite) return S_OK; + hostui_setup = This->doc_obj->hostui_setup; + hres = IOleObject_QueryInterface(pClientSite, &IID_IDocHostUIHandler, (void**)&pDocHostUIHandler); if(SUCCEEDED(hres)) { DOCHOSTUIINFO hostinfo; @@ -133,7 +140,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite This->doc_obj->hostinfo = hostinfo; } - if(!This->doc_obj->has_key_path) { + if(!hostui_setup) { hres = IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler, &key_path, 0); if(hres == S_OK && key_path) { if(key_path[0]) { @@ -157,7 +164,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite IDocHostUIHandler2_Release(pDocHostUIHandler2); } - This->doc_obj->has_key_path = TRUE; + This->doc_obj->hostui_setup = TRUE; } } @@ -179,6 +186,12 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite VARIANT var; OLECMD cmd = {OLECMDID_SETPROGRESSTEXT, 0}; + if(!hostui_setup) { + V_VT(&var) = VT_UNKNOWN; + V_UNKNOWN(&var) = (IUnknown*)HTMLWINDOW2(This->window); + IOleCommandTarget_Exec(cmdtrg, &CGID_DocHostCmdPriv, DOCHOST_DOCCANNAVIGATE, 0, &var, NULL); + } + IOleCommandTarget_QueryStatus(cmdtrg, NULL, 1, &cmd, NULL); V_VT(&var) = VT_I4; diff --git a/reactos/dll/win32/mshtml/persist.c b/reactos/dll/win32/mshtml/persist.c index d3014b8d330..720a58edbf8 100644 --- a/reactos/dll/win32/mshtml/persist.c +++ b/reactos/dll/win32/mshtml/persist.c @@ -155,6 +155,9 @@ static void set_downloading_proc(task_t *_task) doc->download_state = 1; } + if(doc->view_sink) + IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1); + if(doc->hostui) { IDropTarget *drop_target = NULL; @@ -166,50 +169,15 @@ static void set_downloading_proc(task_t *_task) } } -static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL set_download) +HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download) { nsChannelBSC *bscallback; - LPOLESTR url = NULL; docobj_task_t *task; download_proc_task_t *download_task; - nsIWineURI *nsuri; + nsWineURI *nsuri; + LPOLESTR url; HRESULT hres; - if(pibc) { - IUnknown *unk = NULL; - - /* FIXME: - * Use params: - * "__PrecreatedObject" - * "BIND_CONTEXT_PARAM" - * "__HTMLLOADOPTIONS" - * "__DWNBINDINFO" - * "URL Context" - * "CBinding Context" - * "_ITransData_Object_" - * "_EnumFORMATETC_" - */ - - IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk); - if(unk) { - IOleClientSite *client = NULL; - - hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client); - if(SUCCEEDED(hres)) { - TRACE("Got client site %p\n", client); - IOleObject_SetClientSite(OLEOBJ(This), client); - IOleClientSite_Release(client); - } - - IUnknown_Release(unk); - } - } - - set_ready_state(This->window, READYSTATE_LOADING); - update_doc(This, UPDATE_TITLE); - - HTMLDocument_LockContainer(This->doc_obj, TRUE); - hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url); if(FAILED(hres)) { WARN("GetDiaplayName failed: %08x\n", hres); @@ -218,11 +186,8 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO TRACE("got url: %s\n", debugstr_w(url)); - set_current_mon(This->window, mon); - if(This->doc_obj->client) { VARIANT silent, offline; - IOleCommandTarget *cmdtrg = NULL; hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent); if(SUCCEEDED(hres)) { @@ -240,15 +205,37 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO else if(V_BOOL(&silent)) FIXME("offline == true\n"); } + } + + if(This->window->mon) { + update_doc(This, UPDATE_TITLE|UPDATE_UI); + }else { + update_doc(This, UPDATE_TITLE); + set_current_mon(This->window, mon); + } + + set_ready_state(This->window, READYSTATE_LOADING); + + if(This->doc_obj->client) { + IOleCommandTarget *cmdtrg = NULL; hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget, (void**)&cmdtrg); if(SUCCEEDED(hres)) { - VARIANT var; + VARIANT var, out; - V_VT(&var) = VT_I4; - V_I4(&var) = 0; - IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL); + if(!async_bsc) { + V_VT(&var) = VT_I4; + V_I4(&var) = 0; + IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL); + }else { + V_VT(&var) = VT_UNKNOWN; + V_UNKNOWN(&var) = (IUnknown*)HTMLWINDOW2(This->window); + V_VT(&out) = VT_EMPTY; + hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 63, 0, &var, &out); + if(SUCCEEDED(hres)) + VariantClear(&out); + } IOleCommandTarget_Release(cmdtrg); } @@ -259,17 +246,25 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO if(FAILED(hres)) return hres; - bscallback = create_channelbsc(mon); + if(async_bsc) { + bscallback = async_bsc; + }else { + hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback); + if(FAILED(hres)) + return hres; + } - nsIWineURI_SetChannelBSC(nsuri, bscallback); - hres = load_nsuri(This->window, nsuri, LOAD_INITIAL_DOCUMENT_URI); - nsIWineURI_SetChannelBSC(nsuri, NULL); + hres = load_nsuri(This->window, nsuri, bscallback, LOAD_INITIAL_DOCUMENT_URI); + nsISupports_Release((nsISupports*)nsuri); /* FIXME */ if(SUCCEEDED(hres)) set_window_bscallback(This->window, bscallback); - IUnknown_Release((IUnknown*)bscallback); + if(bscallback != async_bsc) + IUnknown_Release((IUnknown*)bscallback); if(FAILED(hres)) return hres; + HTMLDocument_LockContainer(This->doc_obj, TRUE); + if(This->doc_obj->frame) { task = heap_alloc(sizeof(docobj_task_t)); task->doc = This->doc_obj; @@ -375,7 +370,36 @@ static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAva TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode); - hres = set_moniker(This, pimkName, pibc, TRUE); + if(pibc) { + IUnknown *unk = NULL; + + /* FIXME: + * Use params: + * "__PrecreatedObject" + * "BIND_CONTEXT_PARAM" + * "__HTMLLOADOPTIONS" + * "__DWNBINDINFO" + * "URL Context" + * "_ITransData_Object_" + * "_EnumFORMATETC_" + */ + + IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk); + if(unk) { + IOleClientSite *client = NULL; + + hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client); + if(SUCCEEDED(hres)) { + TRACE("Got client site %p\n", client); + IOleObject_SetClientSite(OLEOBJ(This), client); + IOleClientSite_Release(client); + } + + IUnknown_Release(unk); + } + } + + hres = set_moniker(This, pimkName, pibc, NULL, TRUE); if(FAILED(hres)) return hres; @@ -636,7 +660,7 @@ static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM return hres; } - hres = set_moniker(This, mon, NULL, TRUE); + hres = set_moniker(This, mon, NULL, NULL, TRUE); IMoniker_Release(mon); if(FAILED(hres)) return hres; @@ -682,44 +706,24 @@ static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface) { HTMLDocument *This = PERSTRINIT_THIS(iface); IMoniker *mon; - HGLOBAL body; - LPSTREAM stream; HRESULT hres; static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; - static const WCHAR html_bodyW[] = {'<','H','T','M','L','>','<','/','H','T','M','L','>',0}; TRACE("(%p)\n", This); - body = GlobalAlloc(0, sizeof(html_bodyW)); - if(!body) - return E_OUTOFMEMORY; - memcpy(body, html_bodyW, sizeof(html_bodyW)); - hres = CreateURLMoniker(NULL, about_blankW, &mon); if(FAILED(hres)) { WARN("CreateURLMoniker failed: %08x\n", hres); - GlobalFree(body); return hres; } - hres = set_moniker(This, mon, NULL, FALSE); + hres = set_moniker(This, mon, NULL, NULL, FALSE); IMoniker_Release(mon); - if(FAILED(hres)) { - GlobalFree(body); + if(FAILED(hres)) return hres; - } - hres = CreateStreamOnHGlobal(body, TRUE, &stream); - if(FAILED(hres)) { - GlobalFree(body); - return hres; - } - - hres = channelbsc_load_stream(This->window->bscallback, stream); - - IStream_Release(stream); - return hres; + return start_binding(This->window, NULL, (BSCallback*)This->window->bscallback, NULL); } #undef PERSTRINIT_THIS diff --git a/reactos/dll/win32/mshtml/rsrc.rc b/reactos/dll/win32/mshtml/rsrc.rc index 7df2d924d4b..40cc041225c 100644 --- a/reactos/dll/win32/mshtml/rsrc.rc +++ b/reactos/dll/win32/mshtml/rsrc.rc @@ -35,28 +35,31 @@ #include "Bg.rc" #include "Da.rc" -#include "De.rc" #include "En.rc" #include "Es.rc" #include "Fi.rc" -#include "Fr.rc" #include "Hu.rc" +#include "Ko.rc" +#include "Nl.rc" +#include "Pl.rc" +#include "Sv.rc" +#include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" #include "It.rc" #include "Ja.rc" -#include "Ko.rc" #include "Lt.rc" -#include "Nl.rc" #include "No.rc" -#include "Pl.rc" #include "Pt.rc" #include "Ro.rc" #include "Ru.rc" #include "Si.rc" -#include "Sv.rc" -#include "Tr.rc" #include "Uk.rc" #include "Zh.rc" + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL /* @makedep: mshtml.inf */ diff --git a/reactos/include/psdk/mshtml.idl b/reactos/include/psdk/mshtml.idl index 98edbbc32dc..1941b923b9e 100644 --- a/reactos/include/psdk/mshtml.idl +++ b/reactos/include/psdk/mshtml.idl @@ -15407,3 +15407,23 @@ interface IElementBehaviorFactory : IUnknown } } /* library MSHTML */ + +interface IOleCommandTarget; + +/***************************************************************************** + * IHTMLPrivateWindow interface + */ +[ + object, + uuid(3050f6dc-98b5-11cf-bb82-00aa00bdce0b), + local +] +interface IHTMLPrivateWindow : IUnknown +{ + HRESULT SuperNavigate(BSTR url, BSTR arg2, BSTR arg3, BSTR arg4, VARIANT *post_data, VARIANT *headers, ULONG flags); + HRESULT GetPendingUrl(BSTR *url); + HRESULT SetPICSTarget(IOleCommandTarget *cmdtrg); + HRESULT PICSComplete(int arg); + HRESULT FindWindowByName(LPCWSTR name, IHTMLWindow2 **ret); + HRESULT GetAddressBarUrl(BSTR *url); +} From bd5eff9b8536f33c9281c69e776cd6060625b535 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:43:08 +0000 Subject: [PATCH 133/211] [MSHTML_WINETEST] sync mshtml_winetest to wine 1.1.40 svn path=/trunk/; revision=45919 --- rostests/winetests/mshtml/dom.c | 163 +++++- rostests/winetests/mshtml/events.c | 84 +++ rostests/winetests/mshtml/htmldoc.c | 690 ++++++++++++++--------- rostests/winetests/mshtml/htmllocation.c | 147 +++-- rostests/winetests/mshtml/script.c | 9 + 5 files changed, 742 insertions(+), 351 deletions(-) diff --git a/rostests/winetests/mshtml/dom.c b/rostests/winetests/mshtml/dom.c index 5c7380ed8e4..25bf7641eb1 100644 --- a/rostests/winetests/mshtml/dom.c +++ b/rostests/winetests/mshtml/dom.c @@ -99,7 +99,8 @@ typedef enum { ET_TR, ET_TD, ET_IFRAME, - ET_FORM + ET_FORM, + ET_FRAME } elem_type_t; static const IID * const none_iids[] = { @@ -310,6 +311,19 @@ static const IID * const td_iids[] = { NULL }; +static const IID * const frame_iids[] = { + &IID_IHTMLDOMNode, + &IID_IHTMLDOMNode2, + &IID_IHTMLElement, + &IID_IHTMLElement2, + &IID_IHTMLElement3, + &IID_IHTMLFrameBase, + &IID_IHTMLFrameBase2, + &IID_IDispatchEx, + &IID_IConnectionPointContainer, + NULL +}; + static const IID * const iframe_iids[] = { &IID_IHTMLDOMNode, &IID_IHTMLDOMNode2, @@ -318,6 +332,7 @@ static const IID * const iframe_iids[] = { &IID_IHTMLElement3, &IID_IHTMLFrameBase, &IID_IHTMLFrameBase2, + &IID_IHTMLIFrameElement, &IID_IDispatchEx, &IID_IConnectionPointContainer, NULL @@ -389,7 +404,7 @@ static const elem_type_info_t elem_type_infos[] = { {"A", anchor_iids, &DIID_DispHTMLAnchorElement}, {"INPUT", input_iids, &DIID_DispHTMLInputElement}, {"SELECT", select_iids, &DIID_DispHTMLSelectElement}, - {"TEXTAREA", textarea_iids, NULL}, + {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement}, {"OPTION", option_iids, &DIID_DispHTMLOptionElement}, {"STYLE", elem_iids, NULL}, {"BLOCKQUOTE",elem_iids, NULL}, @@ -397,7 +412,7 @@ static const elem_type_info_t elem_type_infos[] = { {"BR", elem_iids, NULL}, {"TABLE", table_iids, &DIID_DispHTMLTable}, {"TBODY", elem_iids, NULL}, - {"SCRIPT", script_iids, NULL}, + {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement}, {"TEST", elem_iids, &DIID_DispHTMLUnknownElement}, {"TEST", generic_iids, &DIID_DispHTMLGenericElement}, {"!", comment_iids, &DIID_DispHTMLCommentElement}, @@ -405,7 +420,8 @@ static const elem_type_info_t elem_type_infos[] = { {"TR", tr_iids, &DIID_DispHTMLTableRow}, {"TD", td_iids, NULL}, {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}, - {"FORM", form_iids, &DIID_DispHTMLFormElement} + {"FORM", form_iids, &DIID_DispHTMLFormElement}, + {"FRAME", frame_iids, &DIID_DispHTMLFrameElement} }; static const char *dbgstr_guid(REFIID riid) @@ -668,6 +684,17 @@ static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk) return text; } +#define get_comment_iface(u) _get_comment_iface(__LINE__,u) +static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk) +{ + IHTMLCommentElement *comment; + HRESULT hres; + + hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment); + ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres); + return comment; +} + #define test_node_name(u,n) _test_node_name(__LINE__,u,n) static void _test_node_name(unsigned line, IUnknown *unk, const char *exname) { @@ -1086,6 +1113,22 @@ static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, co _test_option_value(line, option, value); } +#define test_comment_text(c,t) _test_comment_text(__LINE__,c,t) +static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext) +{ + IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk); + BSTR text; + HRESULT hres; + + text = a2bstr(extext); + hres = IHTMLCommentElement_get_text(comment, &text); + ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres); + ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext); + + IHTMLCommentElement_Release(comment); + SysFreeString(text); +} + #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v) static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc, const char *txt, const char *val) @@ -1129,8 +1172,8 @@ static void _test_img_width(unsigned line, IHTMLImgElement *img, const long exp) HRESULT hres; hres = IHTMLImgElement_get_width(img, &found); - todo_wine ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres); - todo_wine ok_(__FILE__,line) (found == exp, "width=%d\n", found); + ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres); + ok_(__FILE__,line) (found == exp, "width=%d\n", found); } #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w) @@ -1139,7 +1182,7 @@ static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const long HRESULT hres; hres = IHTMLImgElement_put_width(img, width); - todo_wine ok(hres == S_OK, "put_width failed: %08x\n", hres); + ok(hres == S_OK, "put_width failed: %08x\n", hres); _test_img_width(line, img, width); } @@ -1151,8 +1194,8 @@ static void _test_img_height(unsigned line, IHTMLImgElement *img, const long exp HRESULT hres; hres = IHTMLImgElement_get_height(img, &found); - todo_wine ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres); - todo_wine ok_(__FILE__,line) (found == exp, "height=%d\n", found); + ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres); + ok_(__FILE__,line) (found == exp, "height=%d\n", found); } #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w) @@ -1161,7 +1204,7 @@ static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const long HRESULT hres; hres = IHTMLImgElement_put_height(img, height); - todo_wine ok(hres == S_OK, "put_height failed: %08x\n", hres); + ok(hres == S_OK, "put_height failed: %08x\n", hres); _test_img_height(line, img, height); } @@ -1638,6 +1681,21 @@ static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *o SysFreeString(html); } +#define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t) +static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html) +{ + IHTMLElement *elem = _get_elem_iface(line, unk); + BSTR html; + HRESULT hres; + + hres = IHTMLElement_get_outerHTML(elem, &html); + ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres); + ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html); + + IHTMLElement_Release(elem); + SysFreeString(html); +} + #define get_first_child(n) _get_first_child(__LINE__,n) static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk) { @@ -3853,6 +3911,18 @@ static void test_default_style(IHTMLStyle *style) ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); + V_VT(&v) = VT_I4; + V_I4(&v) = 100; + hres = IHTMLStyle_put_width(style, v); + ok(hres == S_OK, "put_width failed: %08x\n", hres); + + V_VT(&v) = VT_EMPTY; + hres = IHTMLStyle_get_width(style, &v); + ok(hres == S_OK, "get_width failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v)); + ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + /* margin tests */ str = (void*)0xdeadbeef; hres = IHTMLStyle_get_margin(style, &str); @@ -4418,8 +4488,8 @@ static void test_default_style(IHTMLStyle *style) */ V_BSTR(&v) = NULL; hres = IHTMLStyle_get_borderRightColor(style, &v); - todo_wine ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres); - todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); V_BSTR(&v) = NULL; @@ -4452,8 +4522,8 @@ static void test_default_style(IHTMLStyle *style) */ V_BSTR(&v) = NULL; hres = IHTMLStyle_get_borderTopColor(style, &v); - todo_wine ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres); - todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); V_BSTR(&v) = NULL; @@ -4486,8 +4556,8 @@ static void test_default_style(IHTMLStyle *style) */ V_BSTR(&v) = NULL; hres = IHTMLStyle_get_borderBottomColor(style, &v); - todo_wine ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres); - todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); V_BSTR(&v) = NULL; @@ -4520,8 +4590,8 @@ static void test_default_style(IHTMLStyle *style) */ V_BSTR(&v) = NULL; hres = IHTMLStyle_get_borderLeftColor(style, &v); - todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres); - todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); V_BSTR(&v) = NULL; @@ -5142,10 +5212,12 @@ static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text) SafeArrayDestroy(sa); } -static void test_frame_doc(IUnknown *frame_elem) +static void test_frame_doc(IUnknown *frame_elem, BOOL iframe) { IHTMLDocument2 *window_doc, *elem_doc; + IHTMLFrameElement3 *frame_elem3; IHTMLWindow2 *content_window; + HRESULT hres; content_window = get_frame_content_window(frame_elem); window_doc = get_window_doc(content_window); @@ -5154,6 +5226,23 @@ static void test_frame_doc(IUnknown *frame_elem) elem_doc = get_elem_doc(frame_elem); ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n"); + if(!iframe) { + hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3); + if(SUCCEEDED(hres)) { + IDispatch *disp = NULL; + + hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp); + ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres); + ok(disp != NULL, "contentDocument == NULL\n"); + ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n"); + + IDispatch_Release(disp); + IHTMLFrameElement3_Release(frame_elem3); + }else { + win_skip("IHTMLFrameElement3 not supported\n"); + } + } + IHTMLDocument2_Release(elem_doc); IHTMLDocument2_Release(window_doc); } @@ -5176,7 +5265,7 @@ static void test_iframe_elem(IHTMLElement *elem) ET_BR }; - test_frame_doc((IUnknown*)elem); + test_frame_doc((IUnknown*)elem, TRUE); content_window = get_frame_content_window((IUnknown*)elem); test_window_length(content_window, 0); @@ -5503,9 +5592,18 @@ static void test_elems(IHTMLDocument2 *doc) { VARIANT_BOOL vb; + hres = IHTMLScriptElement_put_type (script, NULL); + ok(hres == S_OK, "put_type failed: %08x\n", hres); + hres = IHTMLScriptElement_get_type(script, &type); + ok(hres == S_OK, "get_type failed: %08x\n", hres); + ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type)); + + hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript")); + ok(hres == S_OK, "put_type failed: %08x\n", hres); hres = IHTMLScriptElement_get_type(script, &type); ok(hres == S_OK, "get_type failed: %08x\n", hres); ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type)); + SysFreeString(type); /* test defer */ @@ -5861,6 +5959,11 @@ static void test_create_elems(IHTMLDocument2 *doc) ok(type == 8, "type=%d, expected 8\n", type); test_node_get_value_str((IUnknown*)comment, "testing"); + test_elem_title((IUnknown*)comment, NULL); + test_elem_set_title((IUnknown*)comment, "comment title"); + test_elem_title((IUnknown*)comment, "comment title"); + test_comment_text((IUnknown*)comment, ""); + test_elem_outerhtml((IUnknown*)comment, ""); IHTMLDOMNode_Release(comment); } @@ -5871,6 +5974,22 @@ static void test_create_elems(IHTMLDocument2 *doc) IHTMLElement_Release(body); } +static void test_null_write(IHTMLDocument2 *doc) +{ + HRESULT hres; + + doc_write(doc, FALSE, NULL); + doc_write(doc, TRUE, NULL); + + hres = IHTMLDocument2_write(doc, NULL); + ok(hres == S_OK, + "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres); + + hres = IHTMLDocument2_writeln(doc, NULL); + ok(hres == S_OK, + "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres); +} + static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out) { IOleCommandTarget *cmdtrg; @@ -5964,7 +6083,8 @@ static void test_frame(IDispatch *disp, const char *exp_id) if(FAILED(hres)) return; - test_frame_doc((IUnknown*)frame_elem); + test_elem_type((IUnknown*)frame_elem, ET_FRAME); + test_frame_doc((IUnknown*)frame_elem, FALSE); test_elem_id((IUnknown*)frame_elem, exp_id); IHTMLElement_Release(frame_elem); @@ -6344,6 +6464,7 @@ START_TEST(dom) run_domtest(elem_test2_str, test_elems2); run_domtest(doc_blank, test_create_elems); run_domtest(doc_blank, test_defaults); + run_domtest(doc_blank, test_null_write); run_domtest(indent_test_str, test_indent); run_domtest(cond_comment_str, test_cond_comment); run_domtest(frameset_str, test_frameset); diff --git a/rostests/winetests/mshtml/events.c b/rostests/winetests/mshtml/events.c index 84bfae25347..16f727fdec7 100644 --- a/rostests/winetests/mshtml/events.c +++ b/rostests/winetests/mshtml/events.c @@ -63,6 +63,7 @@ DEFINE_EXPECT(div_onclick); DEFINE_EXPECT(div_onclick_attached); DEFINE_EXPECT(timeout); DEFINE_EXPECT(doccp_onclick); +DEFINE_EXPECT(div_onclick_disp); DEFINE_EXPECT(iframe_onreadystatechange_loading); DEFINE_EXPECT(iframe_onreadystatechange_interactive); DEFINE_EXPECT(iframe_onreadystatechange_complete); @@ -674,6 +675,20 @@ static void _elem_attach_event(unsigned line, IUnknown *unk, const char *namea, ok_(__FILE__,line)(res == VARIANT_TRUE, "attachEvent returned %x\n", res); } +#define elem_detach_event(a,b,c) _elem_detach_event(__LINE__,a,b,c) +static void _elem_detach_event(unsigned line, IUnknown *unk, const char *namea, IDispatch *disp) +{ + IHTMLElement2 *elem = _get_elem2_iface(line, unk); + BSTR name; + HRESULT hres; + + name = a2bstr(namea); + hres = IHTMLElement2_detachEvent(elem, name, disp); + IHTMLElement2_Release(elem); + SysFreeString(name); + ok_(__FILE__,line)(hres == S_OK, "detachEvent failed: %08x\n", hres); +} + static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) { *ppv = NULL; @@ -690,6 +705,23 @@ static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, return S_OK; } +static HRESULT WINAPI Dispatch_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) +{ + *ppv = NULL; + + if(IsEqualGUID(riid, &IID_IUnknown) + || IsEqualGUID(riid, &IID_IDispatch)) { + *ppv = iface; + }else if(IsEqualGUID(riid, &IID_IDispatchEx)) { + return E_NOINTERFACE; + }else { + ok(0, "unexpected riid %s\n", debugstr_guid(riid)); + return E_NOINTERFACE; + } + + return S_OK; +} + static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface) { return 2; @@ -1015,6 +1047,32 @@ static IDispatchExVtbl timeoutFuncVtbl = { static IDispatchEx timeoutFunc = { &timeoutFuncVtbl }; +static HRESULT WINAPI div_onclick_disp_Invoke(IDispatchEx *iface, DISPID id, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp, + VARIANT *pvarRes, EXCEPINFO *pei, UINT *puArgErr) +{ + CHECK_EXPECT(div_onclick_disp); + + test_attached_event_args(id, wFlags, pdp, pvarRes, pei); + + ok(IsEqualGUID(&IID_NULL, riid), "riid = %s\n", debugstr_guid(riid)); + ok(!puArgErr, "puArgErr = %p\n", puArgErr); + + return S_OK; +} + +static IDispatchExVtbl div_onclick_dispVtbl = { + Dispatch_QueryInterface, + DispatchEx_AddRef, + DispatchEx_Release, + DispatchEx_GetTypeInfoCount, + DispatchEx_GetTypeInfo, + DispatchEx_GetIDsOfNames, + div_onclick_disp_Invoke, +}; + +static IDispatchEx div_onclick_disp = { &div_onclick_dispVtbl }; + static void pump_msgs(BOOL *b) { MSG msg; @@ -1163,8 +1221,10 @@ static void test_onclick(IHTMLDocument2 *doc) CHECK_CALLED(document_onclick); cp_cookie = register_cp((IUnknown*)doc, &DIID_HTMLDocumentEvents, (IUnknown*)&doccp_obj); + elem_attach_event((IUnknown*)div, "onclick", (IDispatch*)&div_onclick_disp); SET_EXPECT(div_onclick); + SET_EXPECT(div_onclick_disp); SET_EXPECT(div_onclick_attached); SET_EXPECT(body_onclick); SET_EXPECT(document_onclick); @@ -1174,6 +1234,7 @@ static void test_onclick(IHTMLDocument2 *doc) ok(hres == S_OK, "click failed: %08x\n", hres); CHECK_CALLED(div_onclick); + CHECK_CALLED(div_onclick_disp); CHECK_CALLED(div_onclick_attached); CHECK_CALLED(body_onclick); CHECK_CALLED(document_onclick); @@ -1181,6 +1242,29 @@ static void test_onclick(IHTMLDocument2 *doc) unregister_cp((IUnknown*)doc, &DIID_HTMLDocumentEvents, cp_cookie); + V_VT(&v) = VT_NULL; + hres = IHTMLElement_put_onclick(div, v); + ok(hres == S_OK, "put_onclick failed: %08x\n", hres); + + hres = IHTMLElement_get_onclick(div, &v); + ok(hres == S_OK, "get_onclick failed: %08x\n", hres); + ok(V_VT(&v) == VT_NULL, "get_onclick returned vt %d\n", V_VT(&v)); + + elem_detach_event((IUnknown*)div, "onclick", (IDispatch*)&div_onclick_disp); + elem_detach_event((IUnknown*)div, "onclick", (IDispatch*)&div_onclick_disp); + elem_detach_event((IUnknown*)div, "test", (IDispatch*)&div_onclick_disp); + + SET_EXPECT(div_onclick_attached); + SET_EXPECT(body_onclick); + SET_EXPECT(document_onclick); + + hres = IHTMLElement_click(div); + ok(hres == S_OK, "click failed: %08x\n", hres); + + CHECK_CALLED(div_onclick_attached); + CHECK_CALLED(body_onclick); + CHECK_CALLED(document_onclick); + IHTMLElement_Release(div); IHTMLElement_Release(body); } diff --git a/rostests/winetests/mshtml/htmldoc.c b/rostests/winetests/mshtml/htmldoc.c index 166602091bf..c4c41a8b423 100644 --- a/rostests/winetests/mshtml/htmldoc.c +++ b/rostests/winetests/mshtml/htmldoc.c @@ -103,6 +103,8 @@ DEFINE_EXPECT(Exec_HTTPEQUIV_DONE); DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0); DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1); DEFINE_EXPECT(Exec_ShellDocView_37); +DEFINE_EXPECT(Exec_ShellDocView_63); +DEFINE_EXPECT(Exec_ShellDocView_67); DEFINE_EXPECT(Exec_ShellDocView_84); DEFINE_EXPECT(Exec_ShellDocView_103); DEFINE_EXPECT(Exec_ShellDocView_105); @@ -112,6 +114,7 @@ DEFINE_EXPECT(Exec_SETTITLE); DEFINE_EXPECT(Exec_HTTPEQUIV); DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE); DEFINE_EXPECT(Exec_Explorer_69); +DEFINE_EXPECT(Exec_DOCCANNAVIGATE); DEFINE_EXPECT(Invoke_AMBIENT_USERMODE); DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL); DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); @@ -151,13 +154,14 @@ DEFINE_EXPECT(Frame_EnableModeless_FALSE); DEFINE_EXPECT(Frame_GetWindow); DEFINE_EXPECT(TranslateUrl); DEFINE_EXPECT(Advise_Close); +DEFINE_EXPECT(OnViewChange); static IUnknown *doc_unk; static IMoniker *doc_mon; static BOOL expect_LockContainer_fLock; static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE; static BOOL ipsex, ipsw; -static BOOL set_clientsite = FALSE, container_locked = FALSE; +static BOOL set_clientsite, container_locked, navigated_load; static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream; static BOOL editmode = FALSE, show_failed; static BOOL inplace_deactivated; @@ -187,8 +191,10 @@ static const WCHAR http_urlW[] = static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0}; static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; +#define DOCHOST_DOCCANNAVIGATE 0 + static HRESULT QueryInterface(REFIID riid, void **ppv); -static void test_MSHTML_QueryStatus(IUnknown*,DWORD); +static void test_MSHTML_QueryStatus(IHTMLDocument2*,DWORD); #define test_readyState(u) _test_readyState(__LINE__,u) static void _test_readyState(unsigned,IUnknown*); @@ -202,6 +208,9 @@ static const char *debugstr_guid(REFIID riid) { static char buf[50]; + if(!riid) + return "(null)"; + sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", riid->Data1, riid->Data2, riid->Data3, riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4], @@ -328,7 +337,7 @@ static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, L hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url); ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres); - ok(!lstrcmpW(url, exurl), "unexpected url\n"); + ok(!lstrcmpW(url, exurl), "unexpected url %s\n", wine_dbgstr_w(url)); ok(!lstrcmpW(url, doc_url), "url != doc_url\n"); CoTaskMemFree(url); @@ -756,11 +765,7 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D case DISPID_READYSTATE: CHECK_EXPECT2(OnChanged_READYSTATE); - if(readystate_set_interactive) { - readystate_set_interactive = FALSE; - load_state = LD_INTERACTIVE; - } - else + if(!readystate_set_interactive) test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE) ? OLECMDF_ENABLED : 0)); @@ -2338,7 +2343,8 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) { - if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer)) + if((!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer)) + && (!pguidCmdGroup || !IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup) || nCmdID != 63)) test_readyState(NULL); if(!pguidCmdGroup) { @@ -2430,7 +2436,7 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID case 37: CHECK_EXPECT2(Exec_ShellDocView_37); - if(load_from_stream) + if(load_from_stream || navigated_load) test_GetCurMoniker(doc_unk, NULL, about_blank_url); else if(!editmode) test_GetCurMoniker(doc_unk, doc_mon, NULL); @@ -2442,6 +2448,38 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn)); } return S_OK; + + case 63: { + IHTMLPrivateWindow *priv_window; + HRESULT hres; + + CHECK_EXPECT(Exec_ShellDocView_63); + ok(pvaIn != NULL, "pvaIn == NULL\n"); + ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) = %d\n", V_VT(pvaIn)); + ok(V_UNKNOWN(pvaIn) != NULL, "VPUNKNOWN(pvaIn) = NULL\n"); + ok(pvaOut != NULL, "pvaOut == NULL\n"); + ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut) = %d\n", V_VT(pvaOut)); + + hres = IUnknown_QueryInterface(V_UNKNOWN(pvaIn), &IID_IHTMLPrivateWindow, (void**)&priv_window); + ok(hres == S_OK, "Could not get IHTMLPrivateWindow: %08x\n", hres); + if(SUCCEEDED(hres)) + IHTMLPrivateWindow_Release(priv_window); + + load_state = LD_LOADING; + return S_OK; /* TODO */ + } + + case 67: + CHECK_EXPECT(Exec_ShellDocView_67); + ok(pvaIn != NULL, "pvaIn == NULL\n"); + ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn) = %d\n", V_VT(pvaIn)); + ok(!strcmp_wa(V_BSTR(pvaIn), "about:blank"), "V_BSTR(pvaIn) = %s\n", wine_dbgstr_w(V_BSTR(pvaIn))); + ok(pvaOut != NULL, "pvaOut == NULL\n"); + ok(V_VT(pvaOut) == VT_BOOL, "V_VT(pvaOut) = %d\n", V_VT(pvaOut)); + ok(V_BOOL(pvaOut) == VARIANT_TRUE, "V_BOOL(pvaOut) = %x\n", V_BOOL(pvaOut)); + load_state = LD_DOLOAD; + return S_OK; + case 84: CHECK_EXPECT2(Exec_ShellDocView_84); @@ -2496,8 +2534,19 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID }; } - if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) - return E_FAIL; /* TODO */ + if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) { + switch(nCmdID) { + case DOCHOST_DOCCANNAVIGATE: + CHECK_EXPECT(Exec_DOCCANNAVIGATE); + ok(pvaIn != NULL, "pvaIn == NULL\n"); + ok(pvaOut == NULL, "pvaOut != NULL\n"); + ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) != VT_UNKNOWN\n"); + /* FIXME: test V_UNKNOWN(pvaIn) == window */ + return S_OK; + default: + return E_FAIL; /* TODO */ + } + } if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) { ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt); @@ -2664,50 +2713,60 @@ static const IServiceProviderVtbl ServiceProviderVtbl = { static IServiceProvider ServiceProvider = { &ServiceProviderVtbl }; -static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSink *iface, +static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSinkEx *iface, REFIID riid, void **ppv) { return QueryInterface(riid, ppv); } -static ULONG WINAPI AdviseSink_AddRef(IAdviseSink *iface) +static ULONG WINAPI AdviseSink_AddRef(IAdviseSinkEx *iface) { return 2; } -static ULONG WINAPI AdviseSink_Release(IAdviseSink *iface) +static ULONG WINAPI AdviseSink_Release(IAdviseSinkEx *iface) { return 1; } -static void WINAPI AdviseSink_OnDataChange(IAdviseSink *iface, +static void WINAPI AdviseSink_OnDataChange(IAdviseSinkEx *iface, FORMATETC *pFormatetc, STGMEDIUM *pStgmed) { ok(0, "unexpected call\n"); } -static void WINAPI AdviseSink_OnViewChange(IAdviseSink *iface, +static void WINAPI AdviseSink_OnViewChange(IAdviseSinkEx *iface, DWORD dwAspect, LONG lindex) { ok(0, "unexpected call\n"); } -static void WINAPI AdviseSink_OnRename(IAdviseSink *iface, IMoniker *pmk) +static void WINAPI AdviseSink_OnRename(IAdviseSinkEx *iface, IMoniker *pmk) { ok(0, "unexpected call\n"); } -static void WINAPI AdviseSink_OnSave(IAdviseSink *iface) +static void WINAPI AdviseSink_OnSave(IAdviseSinkEx *iface) { ok(0, "unexpected call\n"); } -static void WINAPI AdviseSink_OnClose(IAdviseSink *iface) +static void WINAPI AdviseSink_OnClose(IAdviseSinkEx *iface) +{ + ok(0, "unexpected call\n"); +} + +static void WINAPI AdviseSinkEx_OnViewStatusChange(IAdviseSinkEx *iface, DWORD dwViewStatus) +{ + ok(0, "unexpected call\n"); +} + +static void WINAPI ObjectAdviseSink_OnClose(IAdviseSinkEx *iface) { CHECK_EXPECT(Advise_Close); } -static const IAdviseSinkVtbl AdviseSinkVtbl = { +static const IAdviseSinkExVtbl AdviseSinkVtbl = { AdviseSink_QueryInterface, AdviseSink_AddRef, AdviseSink_Release, @@ -2715,10 +2774,47 @@ static const IAdviseSinkVtbl AdviseSinkVtbl = { AdviseSink_OnViewChange, AdviseSink_OnRename, AdviseSink_OnSave, - AdviseSink_OnClose + ObjectAdviseSink_OnClose, + AdviseSinkEx_OnViewStatusChange }; -static IAdviseSink AdviseSink = { &AdviseSinkVtbl }; +static IAdviseSinkEx AdviseSink = { &AdviseSinkVtbl }; + +static HRESULT WINAPI ViewAdviseSink_QueryInterface(IAdviseSinkEx *iface, + REFIID riid, void **ppv) +{ + if(IsEqualGUID(&IID_IAdviseSinkEx, riid)) { + *ppv = iface; + return S_OK; + } + + ok(0, "unexpected riid %s\n", debugstr_guid(riid)); + *ppv = NULL; + return E_NOINTERFACE; +} + +static void WINAPI ViewAdviseSink_OnViewChange(IAdviseSinkEx *iface, + DWORD dwAspect, LONG lindex) +{ + CHECK_EXPECT2(OnViewChange); + + ok(dwAspect == DVASPECT_CONTENT, "dwAspect = %d\n", dwAspect); + ok(lindex == -1, "lindex = %d\n", lindex); +} + +static const IAdviseSinkExVtbl ViewAdviseSinkVtbl = { + ViewAdviseSink_QueryInterface, + AdviseSink_AddRef, + AdviseSink_Release, + AdviseSink_OnDataChange, + ViewAdviseSink_OnViewChange, + AdviseSink_OnRename, + AdviseSink_OnSave, + AdviseSink_OnClose, + AdviseSinkEx_OnViewStatusChange +}; + +static IAdviseSinkEx ViewAdviseSink = { &ViewAdviseSinkVtbl }; DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */ DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD); @@ -2798,7 +2894,8 @@ static void test_doscroll(IUnknown *unk) switch(load_state) { case LD_DOLOAD: case LD_NO: - ok(!elem, "elem != NULL\n"); + if(!navigated_load) + ok(!elem, "elem != NULL\n"); default: break; case LD_INTERACTIVE: @@ -2905,6 +3002,20 @@ static void _test_readyState(unsigned line, IUnknown *unk) IHTMLDocument2_Release(htmldoc); } +static void test_ViewAdviseSink(IHTMLDocument2 *doc) +{ + IViewObject *view; + HRESULT hres; + + hres = IHTMLDocument2_QueryInterface(doc, &IID_IViewObject, (void**)&view); + ok(hres == S_OK, "QueryInterface(IID_IViewObject) failed: %08x\n", hres); + + hres = IViewObject_SetAdvise(view, DVASPECT_CONTENT, ADVF_PRIMEFIRST, (IAdviseSink*)&ViewAdviseSink); + ok(hres == S_OK, "SetAdvise failed: %08x\n", hres); + + IViewObject_Release(view); +} + static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid) { IConnectionPointContainer *tmp_container = NULL; @@ -2943,12 +3054,12 @@ static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID ri IConnectionPoint_Release(cp); } -static void test_ConnectionPointContainer(IUnknown *unk) +static void test_ConnectionPointContainer(IHTMLDocument2 *doc) { IConnectionPointContainer *container; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container); + hres = IUnknown_QueryInterface(doc, &IID_IConnectionPointContainer, (void**)&container); ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres); if(FAILED(hres)) return; @@ -2990,6 +3101,7 @@ static void test_Load(IPersistMoniker *persist, IMoniker *mon) SET_EXPECT(GetOptionKeyPath); SET_EXPECT(GetOverrideKeyPath); SET_EXPECT(GetWindow); + SET_EXPECT(Exec_DOCCANNAVIGATE); SET_EXPECT(QueryStatus_SETPROGRESSTEXT); SET_EXPECT(Exec_SETPROGRESSMAX); SET_EXPECT(Exec_SETPROGRESSPOS); @@ -3030,6 +3142,7 @@ static void test_Load(IPersistMoniker *persist, IMoniker *mon) CHECK_CALLED(GetOptionKeyPath); CHECK_CALLED(GetOverrideKeyPath); CHECK_CALLED(GetWindow); + CHECK_CALLED(Exec_DOCCANNAVIGATE); CHECK_CALLED(QueryStatus_SETPROGRESSTEXT); CHECK_CALLED(Exec_SETPROGRESSMAX); CHECK_CALLED(Exec_SETPROGRESSPOS); @@ -3084,6 +3197,7 @@ static void test_download(DWORD flags) SET_EXPECT(SetStatusText); if(!(flags & DWL_EMPTY)) SET_EXPECT(Exec_SETDOWNLOADSTATE_1); + SET_EXPECT(OnViewChange); SET_EXPECT(GetDropTarget); if(flags & DWL_TRYCSS) SET_EXPECT(Exec_ShellDocView_84); @@ -3100,7 +3214,9 @@ static void test_download(DWORD flags) SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */ SET_EXPECT(EnableModeless_FALSE); /* IE7 */ SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */ - if(doc_mon != &Moniker) { + if(navigated_load) + SET_EXPECT(Exec_ShellDocView_37); + if(flags & DWL_HTTP) { SET_EXPECT(OnChanged_1012); SET_EXPECT(Exec_HTTPEQUIV); SET_EXPECT(Exec_SETTITLE); @@ -3116,6 +3232,11 @@ static void test_download(DWORD flags) SET_EXPECT(Exec_MSHTML_PARSECOMPLETE); SET_EXPECT(Exec_HTTPEQUIV_DONE); SET_EXPECT(SetStatusText); + if(navigated_load) { + SET_EXPECT(UpdateUI); + SET_EXPECT(Exec_UPDATECOMMANDS); + SET_EXPECT(Exec_SETTITLE); + } expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */ while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) { @@ -3127,12 +3248,20 @@ static void test_download(DWORD flags) CHECK_CALLED(Exec_SETPROGRESSMAX); if(flags & DWL_HTTP) SET_CALLED(Exec_SETPROGRESSMAX); - if((flags & DWL_VERBDONE) && !load_from_stream) - CHECK_CALLED(GetHostInfo); + if((flags & DWL_VERBDONE) && !load_from_stream) { + if(navigated_load) + todo_wine CHECK_CALLED(GetHostInfo); + else + CHECK_CALLED(GetHostInfo); + } CHECK_CALLED(SetStatusText); if(!(flags & DWL_EMPTY)) CHECK_CALLED(Exec_SETDOWNLOADSTATE_1); - CHECK_CALLED(GetDropTarget); + CHECK_CALLED(OnViewChange); + if(navigated_load) + CHECK_CALLED(GetDropTarget); + else + SET_CALLED(GetDropTarget); if(flags & DWL_TRYCSS) SET_CALLED(Exec_ShellDocView_84); if(flags & DWL_CSS) { @@ -3148,7 +3277,9 @@ static void test_download(DWORD flags) SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */ SET_CALLED(EnableModeless_FALSE); /* IE7 */ SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */ - if(doc_mon != &Moniker) todo_wine { + if(navigated_load) + todo_wine CHECK_CALLED(Exec_ShellDocView_37); + if(flags & DWL_HTTP) todo_wine { CHECK_CALLED(OnChanged_1012); CHECK_CALLED(Exec_HTTPEQUIV); CHECK_CALLED(Exec_SETTITLE); @@ -3164,20 +3295,25 @@ static void test_download(DWORD flags) CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE); CHECK_CALLED(Exec_HTTPEQUIV_DONE); SET_CALLED(SetStatusText); + if(navigated_load) { /* avoiding race, FIXME: fund better way */ + SET_CALLED(UpdateUI); + SET_CALLED(Exec_UPDATECOMMANDS); + SET_CALLED(Exec_SETTITLE); + } load_state = LD_COMPLETE; test_readyState(NULL); } -static void test_Persist(IUnknown *unk, IMoniker *mon) +static void test_Persist(IHTMLDocument2 *doc, IMoniker *mon) { IPersistMoniker *persist_mon; IPersistFile *persist_file; GUID guid; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file); + hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&persist_file); ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres); if(SUCCEEDED(hres)) { hres = IPersist_GetClassID(persist_file, NULL); @@ -3190,7 +3326,7 @@ static void test_Persist(IUnknown *unk, IMoniker *mon) IPersist_Release(persist_file); } - hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon); + hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist_mon); ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres); if(SUCCEEDED(hres)) { hres = IPersistMoniker_GetClassID(persist_mon, NULL); @@ -3203,25 +3339,23 @@ static void test_Persist(IUnknown *unk, IMoniker *mon) if(load_state == LD_DOLOAD) test_Load(persist_mon, mon); - test_readyState(unk); + test_readyState((IUnknown*)doc); IPersistMoniker_Release(persist_mon); } } -static void test_put_href(IUnknown *unk) +static void test_put_href(IHTMLDocument2 *doc) { + IHTMLPrivateWindow *priv_window; + IHTMLWindow2 *window; IHTMLLocation *location; - IHTMLDocument2 *doc; - BSTR str; + BSTR str, str2; + VARIANT vempty; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc); - ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres); - location = NULL; hres = IHTMLDocument2_get_location(doc, &location); - IHTMLDocument2_Release(doc); ok(hres == S_OK, "get_location failed: %08x\n", hres); ok(location != NULL, "location == NULL\n"); @@ -3229,12 +3363,46 @@ static void test_put_href(IUnknown *unk) SET_EXPECT(Navigate); str = a2bstr("about:blank"); hres = IHTMLLocation_put_href(location, str); - SysFreeString(str); ok(hres == S_OK, "put_href failed: %08x\n", hres); CHECK_CALLED(TranslateUrl); CHECK_CALLED(Navigate); IHTMLLocation_Release(location); + + hres = IHTMLDocument2_get_parentWindow(doc, &window); + ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLPrivateWindow, (void**)&priv_window); + IHTMLWindow2_Release(window); + ok(hres == S_OK, "QueryInterface(IID_IHTMLPrivateWindow) failed: %08x\n", hres); + + readystate_set_loading = TRUE; + navigated_load = TRUE; + SET_EXPECT(TranslateUrl); + SET_EXPECT(Exec_ShellDocView_67); + SET_EXPECT(Invoke_AMBIENT_SILENT); + SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); + SET_EXPECT(OnChanged_READYSTATE); + SET_EXPECT(Exec_ShellDocView_63); + + str2 = a2bstr(""); + V_VT(&vempty) = VT_EMPTY; + hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, str2, NULL, NULL, &vempty, &vempty, 0); + SysFreeString(str); + SysFreeString(str2); + ok(hres == S_OK, "SuperNavigate failed: %08x\n", hres); + + CHECK_CALLED(TranslateUrl); + CHECK_CALLED(Exec_ShellDocView_67); + CHECK_CALLED(Invoke_AMBIENT_SILENT); + CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); + SET_CALLED(OnChanged_READYSTATE); /* not always called */ + CHECK_CALLED(Exec_ShellDocView_63); + + test_GetCurMoniker(doc_unk, doc_mon, NULL); + IHTMLPrivateWindow_Release(priv_window); + + test_download(DWL_VERBDONE); } static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = { @@ -3300,10 +3468,9 @@ static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG c ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf); } -static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf) +static void test_MSHTML_QueryStatus(IHTMLDocument2 *doc, DWORD cmdf) { - if(!unk) - unk = doc_unk; + IUnknown *unk = doc ? (IUnknown*)doc : doc_unk; test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf); test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf); @@ -3323,14 +3490,14 @@ static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf) test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf); } -static void test_OleCommandTarget(IUnknown *unk) +static void test_OleCommandTarget(IHTMLDocument2 *doc) { IOleCommandTarget *cmdtrg; OLECMD cmds[OLECMDID_GETPRINTTEMPLATE]; int i; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg); + hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg); ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres); if(FAILED(hres)) return; @@ -3361,7 +3528,7 @@ static void test_OleCommandTarget(IUnknown *unk) IOleCommandTarget_Release(cmdtrg); } -static void test_OleCommandTarget_fail(IUnknown *unk) +static void test_OleCommandTarget_fail(IHTMLDocument2 *doc) { IOleCommandTarget *cmdtrg; int i; @@ -3372,7 +3539,7 @@ static void test_OleCommandTarget_fail(IUnknown *unk) {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0} }; - hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg); + hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg); ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres); if(FAILED(hres)) return; @@ -3413,13 +3580,13 @@ static void test_OleCommandTarget_fail(IUnknown *unk) IOleCommandTarget_Release(cmdtrg); } -static void test_exec_onunload(IUnknown *unk) +static void test_exec_onunload(IHTMLDocument2 *doc) { IOleCommandTarget *cmdtrg; VARIANT var; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg); + hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg); ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres); if(FAILED(hres)) return; @@ -3568,14 +3735,14 @@ static void test_exec_noargs(IUnknown *unk, DWORD cmdid) IOleCommandTarget_Release(cmdtrg); } -static void test_IsDirty(IUnknown *unk, HRESULT exhres) +static void test_IsDirty(IHTMLDocument2 *doc, HRESULT exhres) { IPersistStreamInit *perinit; IPersistMoniker *permon; IPersistFile *perfile; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit); + hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&perinit); ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres); if(SUCCEEDED(hres)) { hres = IPersistStreamInit_IsDirty(perinit); @@ -3583,7 +3750,7 @@ static void test_IsDirty(IUnknown *unk, HRESULT exhres) IPersistStreamInit_Release(perinit); } - hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon); + hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&permon); ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres); if(SUCCEEDED(hres)) { hres = IPersistMoniker_IsDirty(permon); @@ -3591,7 +3758,7 @@ static void test_IsDirty(IUnknown *unk, HRESULT exhres) IPersistMoniker_Release(permon); } - hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile); + hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&perfile); ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres); if(SUCCEEDED(hres)) { hres = IPersistFile_IsDirty(perfile); @@ -3676,6 +3843,8 @@ static void test_ClientSite(IOleObject *oleobj, DWORD flags) SET_EXPECT(GetOverrideKeyPath); } SET_EXPECT(GetWindow); + if(flags & CLIENTSITE_EXPECTPATH) + SET_EXPECT(Exec_DOCCANNAVIGATE); SET_EXPECT(QueryStatus_SETPROGRESSTEXT); SET_EXPECT(Exec_SETPROGRESSMAX); SET_EXPECT(Exec_SETPROGRESSPOS); @@ -3695,6 +3864,8 @@ static void test_ClientSite(IOleObject *oleobj, DWORD flags) CHECK_CALLED(GetOverrideKeyPath); } CHECK_CALLED(GetWindow); + if(flags & CLIENTSITE_EXPECTPATH) + CHECK_CALLED(Exec_DOCCANNAVIGATE); CHECK_CALLED(QueryStatus_SETPROGRESSTEXT); CHECK_CALLED(Exec_SETPROGRESSMAX); CHECK_CALLED(Exec_SETPROGRESSPOS); @@ -3716,12 +3887,12 @@ static void test_ClientSite(IOleObject *oleobj, DWORD flags) ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite); } -static void test_OnAmbientPropertyChange(IUnknown *unk) +static void test_OnAmbientPropertyChange(IHTMLDocument2 *doc) { IOleControl *control = NULL; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control); + hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control); ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres); if(FAILED(hres)) return; @@ -3765,12 +3936,12 @@ static void test_OnAmbientPropertyChange(IUnknown *unk) -static void test_OnAmbientPropertyChange2(IUnknown *unk) +static void test_OnAmbientPropertyChange2(IHTMLDocument2 *doc) { IOleControl *control = NULL; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control); + hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control); ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres); if(FAILED(hres)) return; @@ -3781,12 +3952,12 @@ static void test_OnAmbientPropertyChange2(IUnknown *unk) IOleControl_Release(control); } -static void test_Close(IUnknown *unk, BOOL set_client) +static void test_Close(IHTMLDocument2 *doc, BOOL set_client) { IOleObject *oleobj = NULL; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj); + hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres); if(FAILED(hres)) return; @@ -3806,14 +3977,14 @@ static void test_Close(IUnknown *unk, BOOL set_client) IOleObject_Release(oleobj); } -static void test_Advise(IUnknown *unk) +static void test_Advise(IHTMLDocument2 *doc) { IOleObject *oleobj = NULL; IEnumSTATDATA *enum_advise = (void*)0xdeadbeef; DWORD conn; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj); + hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres); if(FAILED(hres)) return; @@ -3831,14 +4002,14 @@ static void test_Advise(IUnknown *unk) ok(hres == E_INVALIDARG || hres == S_OK, "Advise returned: %08x\n", hres); ok(conn == 0 || conn == 1, "conn = %d\n", conn); - hres = IOleObject_Advise(oleobj, &AdviseSink, NULL); + hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, NULL); ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres); - hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); + hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn); ok(hres == S_OK, "Advise returned: %08x\n", hres); ok(conn == 1, "conn = %d\n", conn); - hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); + hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn); ok(hres == S_OK, "Advise returned: %08x\n", hres); ok(conn == 2, "conn = %d\n", conn); @@ -3898,12 +4069,12 @@ static void test_OnFrameWindowActivate(IUnknown *unk) IOleInPlaceActiveObject_Release(inplaceact); } -static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call) +static void test_InPlaceDeactivate(IHTMLDocument2 *doc, BOOL expect_call) { IOleInPlaceObjectWindowless *windowlessobj = NULL; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless, + hres = IUnknown_QueryInterface(doc, &IID_IOleInPlaceObjectWindowless, (void**)&windowlessobj); ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres); if(FAILED(hres)) @@ -3929,7 +4100,7 @@ static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call) IOleInPlaceObjectWindowless_Release(windowlessobj); } -static void test_Activate(IUnknown *unk, DWORD flags) +static void test_Activate(IHTMLDocument2 *doc, DWORD flags) { IOleObject *oleobj = NULL; IOleDocumentView *docview; @@ -3942,7 +4113,7 @@ static void test_Activate(IUnknown *unk, DWORD flags) IOleDocumentView_Release(view); view = NULL; - hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj); + hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres); hres = IOleObject_GetUserClassID(oleobj, NULL); @@ -3952,10 +4123,10 @@ static void test_Activate(IUnknown *unk, DWORD flags) ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres); ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n"); - test_OnFrameWindowActivate(unk); + test_OnFrameWindowActivate((IUnknown*)doc); test_ClientSite(oleobj, flags); - test_InPlaceDeactivate(unk, FALSE); + test_InPlaceDeactivate(doc, FALSE); test_DoVerb(oleobj); if(call_UIActivate == CallUIActivate_AfterShow) { @@ -3983,10 +4154,10 @@ static void test_Activate(IUnknown *unk, DWORD flags) IOleObject_Release(oleobj); - test_OnFrameWindowActivate(unk); + test_OnFrameWindowActivate((IUnknown*)doc); } -static void test_Window(IUnknown *unk, BOOL expect_success) +static void test_Window(IHTMLDocument2 *doc, BOOL expect_success) { IOleInPlaceActiveObject *activeobject = NULL; HWND tmp_hwnd; @@ -4069,34 +4240,34 @@ static void test_Hide(void) ok(hres == S_OK, "Show failed: %08x\n", hres); } -static HRESULT create_document(IUnknown **unk) +static HRESULT create_document(IHTMLDocument2 **doc) { IHTMLDocument5 *doc5; HRESULT hres; hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, - &IID_IUnknown, (void**)unk); + &IID_IHTMLDocument2, (void**)doc); ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); if(FAILED(hres)) return hres; - hres = IUnknown_QueryInterface(*unk, &IID_IHTMLDocument5, (void**)&doc5); + hres = IHTMLDocument2_QueryInterface(*doc, &IID_IHTMLDocument5, (void**)&doc5); if(SUCCEEDED(hres)) { IHTMLDocument5_Release(doc5); }else { win_skip("Could not get IHTMLDocument5, probably too old IE\n"); - IUnknown_Release(*unk); + IHTMLDocument2_Release(*doc); } return hres; } -static void test_Navigate(IUnknown *unk) +static void test_Navigate(IHTMLDocument2 *doc) { IHlinkTarget *hlink; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink); + hres = IUnknown_QueryInterface(doc, &IID_IHlinkTarget, (void**)&hlink); ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres); SET_EXPECT(ActivateMe); @@ -4107,18 +4278,13 @@ static void test_Navigate(IUnknown *unk) IHlinkTarget_Release(hlink); } -static void test_external(IUnknown *unk, BOOL initialized) +static void test_external(IHTMLDocument2 *doc, BOOL initialized) { IDispatch *external; - IHTMLDocument2 *doc; IHTMLWindow2 *htmlwin; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc); - ok(hres == S_OK, "QueryInterface(IID_IHTMLWindow2) failed: %08x\n", hres); - hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin); - IHTMLDocument2_Release(doc); ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres); if(initialized) @@ -4137,12 +4303,12 @@ static void test_external(IUnknown *unk, BOOL initialized) IHTMLWindow2_Release(htmlwin); } -static void test_StreamLoad(IUnknown *unk) +static void test_StreamLoad(IHTMLDocument2 *doc) { IPersistStreamInit *init; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init); + hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init); ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres); if(FAILED(hres)) return; @@ -4164,17 +4330,17 @@ static void test_StreamLoad(IUnknown *unk) CHECK_CALLED(Read); test_timer(EXPECT_SETTITLE); - test_GetCurMoniker(unk, NULL, about_blank_url); + test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url); IPersistStreamInit_Release(init); } -static void test_StreamInitNew(IUnknown *unk) +static void test_StreamInitNew(IHTMLDocument2 *doc) { IPersistStreamInit *init; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init); + hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init); ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres); if(FAILED(hres)) return; @@ -4194,12 +4360,12 @@ static void test_StreamInitNew(IUnknown *unk) CHECK_CALLED(OnChanged_READYSTATE); test_timer(EXPECT_SETTITLE); - test_GetCurMoniker(unk, NULL, about_blank_url); + test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url); IPersistStreamInit_Release(init); } -static void test_QueryInterface(IUnknown *unk) +static void test_QueryInterface(IHTMLDocument2 *doc) { IUnknown *qi; HRESULT hres; @@ -4208,32 +4374,42 @@ static void test_QueryInterface(IUnknown *unk) {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}}; qi = (void*)0xdeadbeef; - hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&qi); + hres = IUnknown_QueryInterface(doc, &IID_IRunnableObject, (void**)&qi); ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi); qi = (void*)0xdeadbeef; - hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&qi); + hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode, (void**)&qi); ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); ok(qi == NULL, "qi=%p, expected NULL\n", qi); qi = (void*)0xdeadbeef; - hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&qi); + hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode2, (void**)&qi); ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); ok(qi == NULL, "qi=%p, expected NULL\n", qi); qi = (void*)0xdeadbeef; - hres = IUnknown_QueryInterface(unk, &IID_IPersistPropertyBag, (void**)&qi); + hres = IUnknown_QueryInterface(doc, &IID_IPersistPropertyBag, (void**)&qi); ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); ok(qi == NULL, "qi=%p, expected NULL\n", qi); qi = (void*)0xdeadbeef; - hres = IUnknown_QueryInterface(unk, &IID_UndocumentedScriptIface, (void**)&qi); + hres = IUnknown_QueryInterface(doc, &IID_UndocumentedScriptIface, (void**)&qi); ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); ok(qi == NULL, "qi=%p, expected NULL\n", qi); qi = (void*)0xdeadbeef; - hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&qi); + hres = IUnknown_QueryInterface(doc, &IID_IMarshal, (void**)&qi); + ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); + ok(qi == NULL, "qi=%p, expected NULL\n", qi); + + qi = (void*)0xdeadbeef; + hres = IUnknown_QueryInterface(doc, &IID_IExternalConnection, (void**)&qi); + ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); + ok(qi == NULL, "qi=%p, expected NULL\n", qi); + + qi = (void*)0xdeadbeef; + hres = IUnknown_QueryInterface(doc, &IID_IStdMarshalInfo, (void**)&qi); ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); ok(qi == NULL, "qi=%p, expected NULL\n", qi); } @@ -4250,11 +4426,12 @@ static void init_test(enum load_state_t ls) { protocol_read = 0; ipsex = FALSE; inplace_deactivated = FALSE; + navigated_load = FALSE; } static void test_HTMLDocument(BOOL do_load) { - IUnknown *unk; + IHTMLDocument2 *doc; HRESULT hres; ULONG ref; @@ -4262,80 +4439,81 @@ static void test_HTMLDocument(BOOL do_load) init_test(do_load ? LD_DOLOAD : LD_NO); - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - doc_unk = unk; + doc_unk = (IUnknown*)doc; - test_QueryInterface(unk); - test_Advise(unk); - test_IsDirty(unk, S_FALSE); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); - test_external(unk, FALSE); - test_ConnectionPointContainer(unk); - test_GetCurMoniker(unk, NULL, NULL); - test_Persist(unk, &Moniker); + test_QueryInterface(doc); + test_Advise(doc); + test_IsDirty(doc, S_FALSE); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); + test_external(doc, FALSE); + test_ViewAdviseSink(doc); + test_ConnectionPointContainer(doc); + test_GetCurMoniker((IUnknown*)doc, NULL, NULL); + test_Persist(doc, &Moniker); if(!do_load) - test_OnAmbientPropertyChange2(unk); + test_OnAmbientPropertyChange2(doc); - test_Activate(unk, CLIENTSITE_EXPECTPATH); + test_Activate(doc, CLIENTSITE_EXPECTPATH); if(do_load) { test_download(DWL_CSS|DWL_TRYCSS); - test_GetCurMoniker(unk, &Moniker, NULL); + test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL); } - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); - test_OleCommandTarget_fail(unk); - test_OleCommandTarget(unk); - test_OnAmbientPropertyChange(unk); - test_Window(unk, TRUE); - test_external(unk, TRUE); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); + test_OleCommandTarget_fail(doc); + test_OleCommandTarget(doc); + test_OnAmbientPropertyChange(doc); + test_Window(doc, TRUE); + test_external(doc, TRUE); test_UIDeactivate(); - test_OleCommandTarget(unk); - test_Window(unk, TRUE); - test_InPlaceDeactivate(unk, TRUE); + test_OleCommandTarget(doc); + test_Window(doc, TRUE); + test_InPlaceDeactivate(doc, TRUE); /* Calling test_OleCommandTarget here causes Segmentation Fault with native * MSHTML. It doesn't with Wine. */ - test_Window(unk, FALSE); + test_Window(doc, FALSE); test_Hide(); - test_InPlaceDeactivate(unk, FALSE); + test_InPlaceDeactivate(doc, FALSE); test_CloseView(); - test_Close(unk, FALSE); + test_Close(doc, FALSE); /* Activate HTMLDocument again */ - test_Activate(unk, CLIENTSITE_SETNULL); - test_Window(unk, TRUE); - test_OleCommandTarget(unk); + test_Activate(doc, CLIENTSITE_SETNULL); + test_Window(doc, TRUE); + test_OleCommandTarget(doc); test_UIDeactivate(); - test_InPlaceDeactivate(unk, TRUE); - test_Close(unk, FALSE); + test_InPlaceDeactivate(doc, TRUE); + test_Close(doc, FALSE); /* Activate HTMLDocument again, this time without UIActivate */ call_UIActivate = CallUIActivate_None; - test_Activate(unk, CLIENTSITE_SETNULL); - test_Window(unk, TRUE); + test_Activate(doc, CLIENTSITE_SETNULL); + test_Window(doc, TRUE); test_UIDeactivate(); - test_InPlaceDeactivate(unk, TRUE); + test_InPlaceDeactivate(doc, TRUE); test_CloseView(); test_CloseView(); - test_Close(unk, TRUE); - test_OnAmbientPropertyChange2(unk); - test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL); + test_Close(doc, TRUE); + test_OnAmbientPropertyChange2(doc); + test_GetCurMoniker((IUnknown*)doc, do_load ? &Moniker : NULL, NULL); if(!do_load) { /* Activate HTMLDocument again, calling UIActivate after showing the window */ call_UIActivate = CallUIActivate_AfterShow; - test_Activate(unk, 0); - test_Window(unk, TRUE); - test_OleCommandTarget(unk); + test_Activate(doc, 0); + test_Window(doc, TRUE); + test_OleCommandTarget(doc); test_UIDeactivate(); - test_InPlaceDeactivate(unk, TRUE); - test_Close(unk, FALSE); + test_InPlaceDeactivate(doc, TRUE); + test_Close(doc, FALSE); call_UIActivate = CallUIActivate_None; } @@ -4345,7 +4523,7 @@ static void test_HTMLDocument(BOOL do_load) ok(IsWindow(hwnd), "hwnd is destroyed\n"); - ref = IUnknown_Release(unk); + ref = IHTMLDocument2_Release(doc); ok(ref == 0, "ref=%d, expected 0\n", ref); ok(!IsWindow(hwnd), "hwnd is not destroyed\n"); @@ -4353,7 +4531,7 @@ static void test_HTMLDocument(BOOL do_load) static void test_HTMLDocument_hlink(void) { - IUnknown *unk; + IHTMLDocument2 *doc; HRESULT hres; ULONG ref; @@ -4362,52 +4540,49 @@ static void test_HTMLDocument_hlink(void) init_test(LD_DOLOAD); ipsex = TRUE; - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - doc_unk = unk; + doc_unk = (IUnknown*)doc; - test_ConnectionPointContainer(unk); - test_GetCurMoniker(unk, NULL, NULL); - test_Persist(unk, &Moniker); - test_Navigate(unk); + test_ViewAdviseSink(doc); + test_ConnectionPointContainer(doc); + test_GetCurMoniker((IUnknown*)doc, NULL, NULL); + test_Persist(doc, &Moniker); + test_Navigate(doc); if(show_failed) { - IUnknown_Release(unk); + IUnknown_Release(doc); return; } test_download(DWL_CSS|DWL_TRYCSS); - test_IsDirty(unk, S_FALSE); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); + test_IsDirty(doc, S_FALSE); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); - test_exec_onunload(unk); - test_Window(unk, TRUE); - test_InPlaceDeactivate(unk, TRUE); - test_Close(unk, FALSE); - test_IsDirty(unk, S_FALSE); - test_GetCurMoniker(unk, &Moniker, NULL); + test_exec_onunload(doc); + test_Window(doc, TRUE); + test_InPlaceDeactivate(doc, TRUE); + test_Close(doc, FALSE); + test_IsDirty(doc, S_FALSE); + test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL); if(view) IOleDocumentView_Release(view); view = NULL; - ref = IUnknown_Release(unk); + ref = IHTMLDocument2_Release(doc); ok(ref == 0, "ref=%d, expected 0\n", ref); } -static void test_cookies(IUnknown *unk) +static void test_cookies(IHTMLDocument2 *doc) { WCHAR buf[1024]; - IHTMLDocument2 *doc; DWORD size; BSTR str, str2; BOOL b; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc); - ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres); - hres = IHTMLDocument2_get_cookie(doc, &str); ok(hres == S_OK, "get_cookie failed: %08x\n", hres); if(str) { @@ -4449,73 +4624,74 @@ static void test_cookies(IUnknown *unk) ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2)); SysFreeString(str); SysFreeString(str2); - - IHTMLDocument2_Release(doc); } static void test_HTMLDocument_http(void) { IMoniker *http_mon; - IUnknown *unk; + IHTMLDocument2 *doc; ULONG ref; HRESULT hres; trace("Testing HTMLDocument (http)...\n"); - hres = CreateURLMoniker(NULL, http_urlW, &http_mon); - ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres); + if(!winetest_interactive && is_ie_hardened()) { + win_skip("IE running in Enhanced Security Configuration\n"); + return; + } init_test(LD_DOLOAD); ipsex = TRUE; - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - doc_unk = unk; + doc_unk = (IUnknown*)doc; - test_ConnectionPointContainer(unk); - test_GetCurMoniker(unk, NULL, NULL); - test_Persist(unk, http_mon); - test_Navigate(unk); + hres = CreateURLMoniker(NULL, http_urlW, &http_mon); + ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres); + + test_ViewAdviseSink(doc); + test_ConnectionPointContainer(doc); + test_GetCurMoniker((IUnknown*)doc, NULL, NULL); + test_Persist(doc, http_mon); + test_Navigate(doc); if(show_failed) { - IUnknown_Release(unk); + IUnknown_Release(doc); return; } - if (winetest_interactive || ! is_ie_hardened()) - test_download(DWL_HTTP); - else - win_skip("IE running in Enhanced Security Configuration\n"); + test_download(DWL_HTTP); + test_cookies(doc); + test_IsDirty(doc, S_FALSE); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); + test_GetCurMoniker((IUnknown*)doc, http_mon, NULL); - test_cookies(unk); - test_IsDirty(unk, S_FALSE); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); + test_put_href(doc); - test_put_href(unk); - - test_InPlaceDeactivate(unk, TRUE); - test_Close(unk, FALSE); - test_IsDirty(unk, S_FALSE); - test_GetCurMoniker(unk, http_mon, NULL); + test_InPlaceDeactivate(doc, TRUE); + test_Close(doc, FALSE); + test_IsDirty(doc, S_FALSE); + test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url); if(view) IOleDocumentView_Release(view); view = NULL; - ref = IUnknown_Release(unk); + ref = IHTMLDocument2_Release(doc); ok(!ref, "ref=%d, expected 0\n", ref); ref = IMoniker_Release(http_mon); ok(!ref, "ref=%d, expected 0\n", ref); } -static void test_QueryService(IUnknown *unk, BOOL success) +static void test_QueryService(IHTMLDocument2 *doc, BOOL success) { IServiceProvider *sp; IHlinkFrame *hf; HRESULT hres; - hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&sp); + hres = IUnknown_QueryInterface(doc, &IID_IServiceProvider, (void**)&sp); ok(hres == S_OK, "QueryService returned %08x\n", hres); hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf); @@ -4529,8 +4705,8 @@ static void test_QueryService(IUnknown *unk, BOOL success) static void test_HTMLDocument_StreamLoad(void) { + IHTMLDocument2 *doc; IOleObject *oleobj; - IUnknown *unk; DWORD conn; HRESULT hres; ULONG ref; @@ -4540,39 +4716,40 @@ static void test_HTMLDocument_StreamLoad(void) init_test(LD_DOLOAD); load_from_stream = TRUE; - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - doc_unk = unk; + doc_unk = (IUnknown*)doc; - hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj); + hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres); - hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); + hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn); ok(hres == S_OK, "Advise failed: %08x\n", hres); - test_readyState(unk); - test_IsDirty(unk, S_FALSE); - test_ConnectionPointContainer(unk); - test_QueryService(unk, FALSE); + test_readyState((IUnknown*)doc); + test_IsDirty(doc, S_FALSE); + test_ViewAdviseSink(doc); + test_ConnectionPointContainer(doc); + test_QueryService(doc, FALSE); test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH); - test_QueryService(unk, TRUE); + test_QueryService(doc, TRUE); test_DoVerb(oleobj); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); IOleObject_Release(oleobj); - test_GetCurMoniker(unk, NULL, NULL); - test_StreamLoad(unk); + test_GetCurMoniker((IUnknown*)doc, NULL, NULL); + test_StreamLoad(doc); test_download(DWL_VERBDONE|DWL_TRYCSS); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); test_UIDeactivate(); - test_InPlaceDeactivate(unk, TRUE); + test_InPlaceDeactivate(doc, TRUE); SET_EXPECT(Advise_Close); - test_Close(unk, FALSE); + test_Close(doc, FALSE); CHECK_CALLED(Advise_Close); - test_IsDirty(unk, S_FALSE); + test_IsDirty(doc, S_FALSE); if(view) { IOleDocumentView_Release(view); @@ -4580,14 +4757,14 @@ static void test_HTMLDocument_StreamLoad(void) } - ref = IUnknown_Release(unk); + ref = IHTMLDocument2_Release(doc); ok(ref == 0, "ref=%d, expected 0\n", ref); } static void test_HTMLDocument_StreamInitNew(void) { + IHTMLDocument2 *doc; IOleObject *oleobj; - IUnknown *unk; DWORD conn; HRESULT hres; ULONG ref; @@ -4597,37 +4774,38 @@ static void test_HTMLDocument_StreamInitNew(void) init_test(LD_DOLOAD); load_from_stream = TRUE; - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - doc_unk = unk; + doc_unk = (IUnknown*)doc; - hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj); + hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres); - hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); + hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn); ok(hres == S_OK, "Advise failed: %08x\n", hres); - test_readyState(unk); - test_IsDirty(unk, S_FALSE); - test_ConnectionPointContainer(unk); + test_readyState((IUnknown*)doc); + test_IsDirty(doc, S_FALSE); + test_ViewAdviseSink(doc); + test_ConnectionPointContainer(doc); test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH); test_DoVerb(oleobj); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); IOleObject_Release(oleobj); - test_GetCurMoniker(unk, NULL, NULL); - test_StreamInitNew(unk); + test_GetCurMoniker((IUnknown*)doc, NULL, NULL); + test_StreamInitNew(doc); test_download(DWL_VERBDONE|DWL_TRYCSS|DWL_EMPTY); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); test_UIDeactivate(); - test_InPlaceDeactivate(unk, TRUE); + test_InPlaceDeactivate(doc, TRUE); SET_EXPECT(Advise_Close); - test_Close(unk, FALSE); + test_Close(doc, FALSE); CHECK_CALLED(Advise_Close); - test_IsDirty(unk, S_FALSE); + test_IsDirty(doc, S_FALSE); if(view) { IOleDocumentView_Release(view); @@ -4635,7 +4813,7 @@ static void test_HTMLDocument_StreamInitNew(void) } - ref = IUnknown_Release(unk); + ref = IHTMLDocument2_Release(doc); ok(ref == 0, "ref=%d, expected 0\n", ref); } @@ -4668,6 +4846,7 @@ static void test_edit_uiactivate(IOleObject *oleobj) static void test_editing_mode(BOOL do_load) { + IHTMLDocument2 *doc; IUnknown *unk; IOleObject *oleobj; DWORD conn; @@ -4679,40 +4858,41 @@ static void test_editing_mode(BOOL do_load) init_test(do_load ? LD_DOLOAD : LD_NO); call_UIActivate = CallUIActivate_AfterShow; - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - doc_unk = unk; + unk = doc_unk = (IUnknown*)doc; - hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj); + hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres); - hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); + hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn); ok(hres == S_OK, "Advise failed: %08x\n", hres); - test_readyState(unk); - test_ConnectionPointContainer(unk); + test_readyState((IUnknown*)doc); + test_ViewAdviseSink(doc); + test_ConnectionPointContainer(doc); test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH); test_DoVerb(oleobj); test_edit_uiactivate(oleobj); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); if(do_load) - test_Persist(unk, &Moniker); + test_Persist(doc, &Moniker); stream_read = protocol_read = 0; test_exec_editmode(unk, do_load); test_UIDeactivate(); call_UIActivate = CallUIActivate_None; IOleObject_Release(oleobj); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); test_download(DWL_VERBDONE | (do_load ? DWL_CSS|DWL_TRYCSS : 0)); SET_EXPECT(SetStatusText); /* ignore race in native mshtml */ test_timer(EXPECT_UPDATEUI); SET_CALLED(SetStatusText); - test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED); + test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED|OLECMDF_ENABLED); if(!do_load) { test_exec_fontname(unk, NULL, wszTimesNewRoman); @@ -4739,9 +4919,9 @@ static void test_editing_mode(BOOL do_load) } test_UIDeactivate(); - test_InPlaceDeactivate(unk, TRUE); + test_InPlaceDeactivate(doc, TRUE); SET_EXPECT(Advise_Close); - test_Close(unk, FALSE); + test_Close(doc, FALSE); CHECK_CALLED(Advise_Close); if(view) { @@ -4755,7 +4935,7 @@ static void test_editing_mode(BOOL do_load) static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw) { - IUnknown *unk; + IHTMLDocument2 *doc; IOleObject *oleobj; IOleInPlaceSite *inplacesite; HRESULT hres; @@ -4765,18 +4945,18 @@ static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw) init_test(do_load ? LD_DOLOAD : LD_NO); - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - doc_unk = unk; + doc_unk = (IUnknown*)doc; ipsex = use_ipsex; ipsw = use_ipsw; - hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj); + hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres); - hres = IUnknown_QueryInterface(unk, &IID_IOleDocumentView, (void**)&view); + hres = IUnknown_QueryInterface(doc, &IID_IOleDocumentView, (void**)&view); ok(hres == S_OK, "QueryInterface(IID_IOleDocumentView) failed: %08x\n", hres); SET_EXPECT(Invoke_AMBIENT_USERMODE); @@ -4789,6 +4969,7 @@ static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw) SET_EXPECT(GetOptionKeyPath); SET_EXPECT(GetOverrideKeyPath); SET_EXPECT(GetWindow); + SET_EXPECT(Exec_DOCCANNAVIGATE); SET_EXPECT(QueryStatus_SETPROGRESSTEXT); SET_EXPECT(Exec_SETPROGRESSMAX); SET_EXPECT(Exec_SETPROGRESSPOS); @@ -4806,6 +4987,7 @@ static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw) CHECK_CALLED(GetOptionKeyPath); CHECK_CALLED(GetOverrideKeyPath); CHECK_CALLED(GetWindow); + CHECK_CALLED(Exec_DOCCANNAVIGATE); CHECK_CALLED(QueryStatus_SETPROGRESSTEXT); CHECK_CALLED(Exec_SETPROGRESSMAX); CHECK_CALLED(Exec_SETPROGRESSPOS); @@ -4893,13 +5075,13 @@ static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw) else CHECK_CALLED(OnInPlaceDeactivate); - test_Close(unk, TRUE); + test_Close(doc, TRUE); IOleObject_Release(oleobj); IOleDocumentView_Release(view); view = NULL; - ref = IUnknown_Release(unk); + ref = IHTMLDocument2_Release(doc); ok(ref == 0, "ref=%d, expected 0\n", ref); } @@ -4922,16 +5104,16 @@ static void register_protocol(void) static void test_HTMLDoc_ISupportErrorInfo(void) { + IHTMLDocument2 *doc; HRESULT hres; - IUnknown *unk; ISupportErrorInfo *sinfo; LONG ref; - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - hres = IUnknown_QueryInterface(unk, &IID_ISupportErrorInfo, (void**)&sinfo); + hres = IUnknown_QueryInterface(doc, &IID_ISupportErrorInfo, (void**)&sinfo); ok(hres == S_OK, "got %x\n", hres); ok(sinfo != NULL, "got %p\n", sinfo); if(sinfo) @@ -4941,27 +5123,27 @@ static void test_HTMLDoc_ISupportErrorInfo(void) IUnknown_Release(sinfo); } - ref = IUnknown_Release(unk); + ref = IHTMLDocument2_Release(doc); ok(ref == 0, "ref=%d, expected 0\n", ref); } static void test_IPersistHistory(void) { + IHTMLDocument2 *doc; HRESULT hres; - IUnknown *unk; LONG ref; IPersistHistory *phist; - hres = create_document(&unk); + hres = create_document(&doc); if(FAILED(hres)) return; - hres = IUnknown_QueryInterface(unk, &IID_IPersistHistory, (void**)&phist); + hres = IUnknown_QueryInterface(doc, &IID_IPersistHistory, (void**)&phist); ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres); if(hres == S_OK) IPersistHistory_Release(phist); - ref = IUnknown_Release(unk); + ref = IHTMLDocument2_Release(doc); ok(ref == 0, "ref=%d, expected 0\n", ref); } diff --git a/rostests/winetests/mshtml/htmllocation.c b/rostests/winetests/mshtml/htmllocation.c index 60a1f204cc4..7de9a94166e 100644 --- a/rostests/winetests/mshtml/htmllocation.c +++ b/rostests/winetests/mshtml/htmllocation.c @@ -22,10 +22,11 @@ #include #include "mshtml.h" +#include "wininet.h" struct location_test { const char *name; - const WCHAR *url; + const char *url; const char *href; const char *protocol; @@ -37,75 +38,68 @@ struct location_test { const char *hash; }; -static const WCHAR http_url[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','?','s','e','a','r','c','h','#','h','a','s','h',0}; -static const struct location_test http_test = { - "HTTP", - http_url, - "http://www.winehq.org/?search#hash", - "http:", - "www.winehq.org:80", - "www.winehq.org", - "80", - "", - "?search", - "#hash" - }; - -static const WCHAR http_file_url[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','f','i','l','e','?','s','e','a','r','c','h','#','h','a','s','h',0}; -static const struct location_test http_file_test = { - "HTTP with file", - http_file_url, - "http://www.winehq.org/file?search#hash", - "http:", - "www.winehq.org:80", - "www.winehq.org", - "80", - "file", - "?search", - "#hash" - }; - -static const WCHAR ftp_url[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g','/',0}; -static const struct location_test ftp_test = { - "FTP", - ftp_url, - "ftp://ftp.winehq.org/", - "ftp:", - "ftp.winehq.org:21", - "ftp.winehq.org", - "21", - "", - NULL, - NULL - }; - -static const WCHAR ftp_file_url[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g','/','f','i','l','e',0}; -static const struct location_test ftp_file_test = { - "FTP with file", - ftp_file_url, - "ftp://ftp.winehq.org/file", - "ftp:", - "ftp.winehq.org:21", - "ftp.winehq.org", - "21", - "file", - NULL, - NULL - }; - -static const WCHAR file_url[] = {'f','i','l','e',':','/','/','C',':','\\','w','i','n','d','o','w','s','\\','w','i','n','.','i','n','i',0}; -static const struct location_test file_test = { - "FILE", - file_url, - "file:///C:/windows/win.ini", - "file:", - NULL, - NULL, - "", - "C:\\windows\\win.ini", - NULL, - NULL - }; +static const struct location_test location_tests[] = { + { + "HTTP", + "http://www.winehq.org?search#hash", + "http://www.winehq.org/?search#hash", + "http:", + "www.winehq.org:80", + "www.winehq.org", + "80", + "", + "?search", + "#hash" + }, + { + "HTTP with file", + "http://www.winehq.org/file?search#hash", + "http://www.winehq.org/file?search#hash", + "http:", + "www.winehq.org:80", + "www.winehq.org", + "80", + "file", + "?search", + "#hash" + }, + { + "FTP", + "ftp://ftp.winehq.org/", + "ftp://ftp.winehq.org/", + "ftp:", + "ftp.winehq.org:21", + "ftp.winehq.org", + "21", + "", + NULL, + NULL + }, + { + "FTP with file", + "ftp://ftp.winehq.org/file", + "ftp://ftp.winehq.org/file", + "ftp:", + "ftp.winehq.org:21", + "ftp.winehq.org", + "21", + "file", + NULL, + NULL + }, + { + "FILE", + "file://C:\\windows\\win.ini", + "file:///C:/windows/win.ini", + "file:", + NULL, + NULL, + "", + "C:\\windows\\win.ini", + NULL, + NULL + } +}; static int str_eq_wa(LPCWSTR strw, const char *stra) { @@ -267,6 +261,7 @@ static void test_hash(IHTMLLocation *loc, const struct location_test *test) static void perform_test(const struct location_test* test) { + WCHAR url[INTERNET_MAX_URL_LENGTH]; HRESULT hres; IBindCtx *bc; IMoniker *url_mon; @@ -280,7 +275,8 @@ static void perform_test(const struct location_test* test) if(FAILED(hres)) return; - hres = CreateURLMoniker(NULL, test->url, &url_mon); + MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, sizeof(url)/sizeof(WCHAR)); + hres = CreateURLMoniker(NULL, url, &url_mon); ok(hres == S_OK, "%s: CreateURLMoniker failed: 0x%08x\n", test->name, hres); if(FAILED(hres)){ IBindCtx_Release(bc); @@ -356,13 +352,12 @@ static void perform_test(const struct location_test* test) START_TEST(htmllocation) { + int i; + CoInitialize(NULL); - perform_test(&http_test); - perform_test(&http_file_test); - perform_test(&ftp_test); - perform_test(&ftp_file_test); - perform_test(&file_test); + for(i=0; i < sizeof(location_tests)/sizeof(*location_tests); i++) + perform_test(location_tests+i); CoUninitialize(); } diff --git a/rostests/winetests/mshtml/script.c b/rostests/winetests/mshtml/script.c index fae49c8bcee..6a0cbe36906 100644 --- a/rostests/winetests/mshtml/script.c +++ b/rostests/winetests/mshtml/script.c @@ -1803,6 +1803,11 @@ static HRESULT WINAPI ActiveScriptParse_ParseScriptText(IActiveScriptParse *ifac test_func(dispex); test_nextdispid(dispex); + + tmp = a2bstr("test"); + hres = IDispatchEx_DeleteMemberByName(dispex, tmp, fdexNameCaseSensitive); + ok(hres == E_NOTIMPL, "DeleteMemberByName failed: %08x\n", hres); + IDispatchEx_Release(dispex); script_disp = (IDispatch*)&scriptDisp; @@ -1843,6 +1848,10 @@ static HRESULT WINAPI ActiveScriptParse_ParseScriptText(IActiveScriptParse *ifac CHECK_CALLED(script_testprop2_d); SysFreeString(tmp); + tmp = a2bstr("test"); + hres = IDispatchEx_DeleteMemberByName(window_dispex, tmp, fdexNameCaseSensitive); + ok(hres == E_NOTIMPL, "DeleteMemberByName failed: %08x\n", hres); + test_global_id(); test_security(); From ecd20ad2a1f3977bb3d32bd6454b085fb94ca722 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:44:48 +0000 Subject: [PATCH 134/211] [SHDOCVW] sync shdocvw to wine 1.1.40 svn path=/trunk/; revision=45920 --- reactos/dll/win32/shdocvw/client.c | 2 +- reactos/dll/win32/shdocvw/taskbarlist.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/shdocvw/client.c b/reactos/dll/win32/shdocvw/client.c index a351bd1e37f..17fa35f96d1 100644 --- a/reactos/dll/win32/shdocvw/client.c +++ b/reactos/dll/win32/shdocvw/client.c @@ -73,7 +73,7 @@ static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID ri return S_OK; } - WARN("Unsupported intrface %s\n", debugstr_guid(riid)); + WARN("Unsupported interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; } diff --git a/reactos/dll/win32/shdocvw/taskbarlist.c b/reactos/dll/win32/shdocvw/taskbarlist.c index 028169584f0..2c380800ddf 100644 --- a/reactos/dll/win32/shdocvw/taskbarlist.c +++ b/reactos/dll/win32/shdocvw/taskbarlist.c @@ -81,9 +81,9 @@ static ULONG STDMETHODCALLTYPE taskbar_list_Release(ITaskbarList *iface) static HRESULT STDMETHODCALLTYPE taskbar_list_HrInit(ITaskbarList *iface) { - FIXME("iface %p stub!\n", iface); + TRACE("iface %p\n", iface); - return E_NOTIMPL; + return S_OK; } static HRESULT STDMETHODCALLTYPE taskbar_list_AddTab(ITaskbarList *iface, HWND hwnd) From 60da8fe57683a1bdc676f5d61394605b216551b6 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 11:53:27 +0000 Subject: [PATCH 135/211] [PSTOREC] sync pstorec to wine 1.1.40 svn path=/trunk/; revision=45921 --- reactos/dll/win32/pstorec/pstorec.c | 1 - reactos/dll/win32/pstorec/pstorec.rbuild | 12 +++++++++- reactos/dll/win32/pstorec/pstorec_tlb.idl | 21 ++++++++++++++++ reactos/dll/win32/pstorec/rsrc.rc | 29 +++++++++++++++++++++++ reactos/include/psdk/pstore.idl | 22 +++++++++++++---- 5 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 reactos/dll/win32/pstorec/pstorec_tlb.idl create mode 100644 reactos/dll/win32/pstorec/rsrc.rc diff --git a/reactos/dll/win32/pstorec/pstorec.c b/reactos/dll/win32/pstorec/pstorec.c index 7e6acc40c13..5b3f7e04c30 100644 --- a/reactos/dll/win32/pstorec/pstorec.c +++ b/reactos/dll/win32/pstorec/pstorec.c @@ -388,6 +388,5 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("\n"); return S_OK; } diff --git a/reactos/dll/win32/pstorec/pstorec.rbuild b/reactos/dll/win32/pstorec/pstorec.rbuild index 7bc8a8ae92b..c9d6818a777 100644 --- a/reactos/dll/win32/pstorec/pstorec.rbuild +++ b/reactos/dll/win32/pstorec/pstorec.rbuild @@ -1,8 +1,18 @@ + + + + + stdole2 + pstorec_tlb.idl + - . + . + pstorec_tlb wine uuid pstorec.c + rsrc.rc + diff --git a/reactos/dll/win32/pstorec/pstorec_tlb.idl b/reactos/dll/win32/pstorec/pstorec_tlb.idl new file mode 100644 index 00000000000..dff2e9fcb3b --- /dev/null +++ b/reactos/dll/win32/pstorec/pstorec_tlb.idl @@ -0,0 +1,21 @@ +/* + * Typelib for pstorec + * + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "pstore.idl" diff --git a/reactos/dll/win32/pstorec/rsrc.rc b/reactos/dll/win32/pstorec/rsrc.rc new file mode 100644 index 00000000000..85b6205eec8 --- /dev/null +++ b/reactos/dll/win32/pstorec/rsrc.rc @@ -0,0 +1,29 @@ +/* + * Resource file for pstorec + * + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winnls.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +/* @makedep: pstorec_tlb.tlb */ +1 TYPELIB LOADONCALL DISCARDABLE pstorec_tlb.tlb diff --git a/reactos/include/psdk/pstore.idl b/reactos/include/psdk/pstore.idl index 62ce00b8da1..590b905df3d 100644 --- a/reactos/include/psdk/pstore.idl +++ b/reactos/include/psdk/pstore.idl @@ -34,6 +34,18 @@ typedef DWORD PST_KEY; typedef DWORD PST_PROVIDERCAPABILITIES; typedef GUID PST_PROVIDERID, *PPST_PROVIDERID; +/***************************************************************************** + * PSTOREC library + */ +[ + uuid(5a6f1ebd-2db1-11d0-8c39-00c04fd9126b), + version(1.0), + helpstring("PStore 1.0 Type Library") +] +library PSTORECLib +{ + importlib("stdole2.tlb"); + typedef struct _PST_PROVIDERINFO { DWORD cbSize; @@ -50,27 +62,27 @@ typedef struct _PST_PROMPTINFO LPCWSTR szPrompt; } PST_PROMPTINFO, *PPST_PROMPTINFO; -typedef struct { +typedef struct _PST_ACCESSCLAUSE { DWORD cbSize; PST_ACCESSCLAUSETYPE ClauseType; DWORD cbClauseData; BYTE* pbClauseData; } PST_ACCESSCLAUSE, *PPST_ACCESSCLAUSE; -typedef struct { +typedef struct _PST_ACCESSRULE { DWORD cbSize; PST_ACCESSMODE AccessModeFlags; DWORD cClauses; PST_ACCESSCLAUSE* rgClauses; } PST_ACCESSRULE, *PPST_ACCESSRULE; -typedef struct { +typedef struct _PST_ACCESSRULESET { DWORD cbSize; DWORD cClause; PST_ACCESSRULE* rgRules; } PST_ACCESSRULESET, *PPST_ACCESSRULESET; -typedef struct { +typedef struct _PST_TYPEINFO { DWORD cbSize; LPWSTR szDisplayName; } PST_TYPEINFO, *PPST_TYPEINFO; @@ -259,3 +271,5 @@ interface IPStore : IUnknown [in] DWORD dwFlags, [in] IEnumPStoreItems** ppenum ); } + +}; From a107cd5ed212fac6b556262d7d4505261ea85480 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:05:00 +0000 Subject: [PATCH 136/211] [ACTXPRXY] partially sync actxprxy to wine 1.1.40 (shlobjidl.idl needs fixing!!!) svn path=/trunk/; revision=45922 --- reactos/dll/win32/actxprxy/actxprxy.rbuild | 19 +++- .../dll/win32/actxprxy/actxprxy_activscp.idl | 21 ++++ .../dll/win32/actxprxy/actxprxy_comcat.idl | 21 ++++ .../dll/win32/actxprxy/actxprxy_docobj.idl | 21 ++++ reactos/dll/win32/actxprxy/actxprxy_hlink.idl | 21 ++++ .../dll/win32/actxprxy/actxprxy_htiframe.idl | 21 ++++ .../dll/win32/actxprxy/actxprxy_objsafe.idl | 21 ++++ reactos/dll/win32/actxprxy/actxprxy_ocmm.idl | 21 ++++ .../dll/win32/actxprxy/actxprxy_shobjidl.idl | 21 ++++ .../dll/win32/actxprxy/actxprxy_urlhist.idl | 21 ++++ reactos/dll/win32/actxprxy/usrmarshal.c | 106 ++++++++++++++++++ 11 files changed, 309 insertions(+), 5 deletions(-) create mode 100644 reactos/dll/win32/actxprxy/actxprxy_activscp.idl create mode 100644 reactos/dll/win32/actxprxy/actxprxy_comcat.idl create mode 100644 reactos/dll/win32/actxprxy/actxprxy_docobj.idl create mode 100644 reactos/dll/win32/actxprxy/actxprxy_hlink.idl create mode 100644 reactos/dll/win32/actxprxy/actxprxy_htiframe.idl create mode 100644 reactos/dll/win32/actxprxy/actxprxy_objsafe.idl create mode 100644 reactos/dll/win32/actxprxy/actxprxy_ocmm.idl create mode 100644 reactos/dll/win32/actxprxy/actxprxy_shobjidl.idl create mode 100644 reactos/dll/win32/actxprxy/actxprxy_urlhist.idl diff --git a/reactos/dll/win32/actxprxy/actxprxy.rbuild b/reactos/dll/win32/actxprxy/actxprxy.rbuild index 87a50a17c83..f5272b585cf 100644 --- a/reactos/dll/win32/actxprxy/actxprxy.rbuild +++ b/reactos/dll/win32/actxprxy/actxprxy.rbuild @@ -9,20 +9,29 @@ . wine - actxprxy_interface actxprxy_proxy ntdll rpcrt4 + ole32 + oleaut32 + uuid pseh usrmarshal.c - - actxprxy_servprov.idl - - "{ 0xb8da6310, 0xe19b, 0x11d0, { 0x93, 0x3c, 0x00, 0xa0, 0xc9, 0x0d, 0xca, 0xa9 } }" + + actxprxy_activscp.idl + actxprxy_comcat.idl + actxprxy_docobj.idl + actxprxy_hlink.idl + actxprxy_htiframe.idl + actxprxy_objsafe.idl + actxprxy_ocmm.idl actxprxy_servprov.idl + + actxprxy_urlhist.idl + diff --git a/reactos/dll/win32/actxprxy/actxprxy_activscp.idl b/reactos/dll/win32/actxprxy/actxprxy_activscp.idl new file mode 100644 index 00000000000..c056a0ebd15 --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_activscp.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for activscp.idl */ + +#include "activscp.idl" diff --git a/reactos/dll/win32/actxprxy/actxprxy_comcat.idl b/reactos/dll/win32/actxprxy/actxprxy_comcat.idl new file mode 100644 index 00000000000..6c8155fe29f --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_comcat.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for comcat.idl */ + +#include "comcat.idl" diff --git a/reactos/dll/win32/actxprxy/actxprxy_docobj.idl b/reactos/dll/win32/actxprxy/actxprxy_docobj.idl new file mode 100644 index 00000000000..711c3851e3d --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_docobj.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for docobj.idl */ + +#include "docobj.idl" diff --git a/reactos/dll/win32/actxprxy/actxprxy_hlink.idl b/reactos/dll/win32/actxprxy/actxprxy_hlink.idl new file mode 100644 index 00000000000..820967d2de4 --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_hlink.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for hlink.idl */ + +#include "hlink.idl" diff --git a/reactos/dll/win32/actxprxy/actxprxy_htiframe.idl b/reactos/dll/win32/actxprxy/actxprxy_htiframe.idl new file mode 100644 index 00000000000..146b0a2e4c6 --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_htiframe.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for htiframe.idl */ + +#include "htiframe.idl" diff --git a/reactos/dll/win32/actxprxy/actxprxy_objsafe.idl b/reactos/dll/win32/actxprxy/actxprxy_objsafe.idl new file mode 100644 index 00000000000..67e878b69cd --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_objsafe.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for objsafe.idl */ + +#include "objsafe.idl" diff --git a/reactos/dll/win32/actxprxy/actxprxy_ocmm.idl b/reactos/dll/win32/actxprxy/actxprxy_ocmm.idl new file mode 100644 index 00000000000..2df49ce8995 --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_ocmm.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for ocmm.idl */ + +#include "ocmm.idl" diff --git a/reactos/dll/win32/actxprxy/actxprxy_shobjidl.idl b/reactos/dll/win32/actxprxy/actxprxy_shobjidl.idl new file mode 100644 index 00000000000..71912fd0eb4 --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_shobjidl.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for shobjidl.idl */ + +#include "shobjidl.idl" diff --git a/reactos/dll/win32/actxprxy/actxprxy_urlhist.idl b/reactos/dll/win32/actxprxy/actxprxy_urlhist.idl new file mode 100644 index 00000000000..18861b3a713 --- /dev/null +++ b/reactos/dll/win32/actxprxy/actxprxy_urlhist.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for urlhist.idl */ + +#include "urlhist.idl" diff --git a/reactos/dll/win32/actxprxy/usrmarshal.c b/reactos/dll/win32/actxprxy/usrmarshal.c index 9d5318fcec5..f2aacf85a30 100644 --- a/reactos/dll/win32/actxprxy/usrmarshal.c +++ b/reactos/dll/win32/actxprxy/usrmarshal.c @@ -32,6 +32,8 @@ #include "winerror.h" #include "objbase.h" #include "servprov.h" +#include "comcat.h" +#include "docobj.h" #include "wine/debug.h" @@ -62,3 +64,107 @@ HRESULT __RPC_STUB IServiceProvider_QueryService_Stub( return IServiceProvider_QueryService(This, guidService, riid, (void **)ppvObject); } + +HRESULT CALLBACK ICatInformation_EnumClassesOfCategories_Proxy( + ICatInformation *This, + ULONG cImplemented, + CATID rgcatidImpl[], + ULONG cRequired, + CATID rgcatidReq[], + IEnumCLSID** ppenumClsid ) +{ + TRACE("(%p)\n", This); + return ICatInformation_RemoteEnumClassesOfCategories_Proxy( This, cImplemented, rgcatidImpl, + cRequired, rgcatidReq, ppenumClsid ); +} + +HRESULT __RPC_STUB ICatInformation_EnumClassesOfCategories_Stub( + ICatInformation *This, + ULONG cImplemented, + CATID rgcatidImpl[], + ULONG cRequired, + CATID rgcatidReq[], + IEnumCLSID** ppenumClsid ) +{ + TRACE("(%p)\n", This); + return ICatInformation_EnumClassesOfCategories( This, cImplemented, rgcatidImpl, + cRequired, rgcatidReq, ppenumClsid ); +} + +HRESULT CALLBACK ICatInformation_IsClassOfCategories_Proxy( + ICatInformation *This, + REFCLSID rclsid, + ULONG cImplemented, + CATID rgcatidImpl[], + ULONG cRequired, + CATID rgcatidReq[] ) +{ + TRACE("(%p)\n", This); + return ICatInformation_RemoteIsClassOfCategories_Proxy( This, rclsid, cImplemented, rgcatidImpl, + cRequired, rgcatidReq ); +} + +HRESULT __RPC_STUB ICatInformation_IsClassOfCategories_Stub( + ICatInformation *This, + REFCLSID rclsid, + ULONG cImplemented, + CATID rgcatidImpl[], + ULONG cRequired, + CATID rgcatidReq[] ) +{ + TRACE("(%p)\n", This); + return ICatInformation_IsClassOfCategories( This, rclsid, cImplemented, rgcatidImpl, + cRequired, rgcatidReq ); +} + +HRESULT CALLBACK IPrint_Print_Proxy( + IPrint *This, + DWORD grfFlags, + DVTARGETDEVICE **pptd, + PAGESET **ppPageSet, + STGMEDIUM *pstgmOptions, + IContinueCallback *pcallback, + LONG nFirstPage, + LONG *pcPagesPrinted, + LONG *pnLastPage ) +{ + TRACE("(%p)\n", This); + return IPrint_RemotePrint_Proxy( This, grfFlags, pptd, ppPageSet, (RemSTGMEDIUM *)pstgmOptions, + pcallback, nFirstPage, pcPagesPrinted, pnLastPage ); +} + +HRESULT __RPC_STUB IPrint_Print_Stub( + IPrint *This, + DWORD grfFlags, + DVTARGETDEVICE **pptd, + PAGESET **ppPageSet, + RemSTGMEDIUM *pstgmOptions, + IContinueCallback *pcallback, + LONG nFirstPage, + LONG *pcPagesPrinted, + LONG *pnLastPage ) +{ + TRACE("(%p)\n", This); + return IPrint_Print( This, grfFlags, pptd, ppPageSet, (STGMEDIUM *)pstgmOptions, + pcallback, nFirstPage, pcPagesPrinted, pnLastPage ); +} + +HRESULT CALLBACK IEnumOleDocumentViews_Next_Proxy( + IEnumOleDocumentViews *This, + ULONG cViews, + IOleDocumentView **rgpView, + ULONG *pcFetched ) +{ + TRACE("(%p)\n", This); + return IEnumOleDocumentViews_RemoteNext_Proxy( This, cViews, rgpView, pcFetched ); +} + +HRESULT __RPC_STUB IEnumOleDocumentViews_Next_Stub( + IEnumOleDocumentViews *This, + ULONG cViews, + IOleDocumentView **rgpView, + ULONG *pcFetched ) +{ + TRACE("(%p)\n", This); + return IEnumOleDocumentViews_Next( This, cViews, rgpView, pcFetched ); +} From e162d33ac40a52924cdcdd18db2e7c8d3a797543 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:08:51 +0000 Subject: [PATCH 137/211] [SHLWAPI] sync shlwapi to wine 1.1.40 svn path=/trunk/; revision=45923 --- reactos/dll/win32/shlwapi/ordinal.c | 95 +++++++++++++++++++++++------ reactos/dll/win32/shlwapi/url.c | 48 ++++++++++++--- reactos/include/psdk/shlwapi.h | 11 ++++ 3 files changed, 127 insertions(+), 27 deletions(-) diff --git a/reactos/dll/win32/shlwapi/ordinal.c b/reactos/dll/win32/shlwapi/ordinal.c index 315208c1614..375ddaf7ad2 100644 --- a/reactos/dll/win32/shlwapi/ordinal.c +++ b/reactos/dll/win32/shlwapi/ordinal.c @@ -1082,23 +1082,25 @@ HRESULT WINAPI IUnknown_Exec(IUnknown* lpUnknown, REFGUID pguidCmdGroup, * PARAMS * hWnd [I] Window to get value from * offset [I] Offset of value - * wMask [I] Mask for uiFlags - * wFlags [I] Bits to set in window value + * mask [I] Mask for flags + * flags [I] Bits to set in window value * * RETURNS * The new value as it was set, or 0 if any parameter is invalid. * * NOTES - * Any bits set in uiMask are cleared from the value, then any bits set in - * uiFlags are set in the value. + * Only bits specified in mask are affected - set if present in flags and + * reset otherwise. */ -LONG WINAPI SHSetWindowBits(HWND hwnd, INT offset, UINT wMask, UINT wFlags) +LONG WINAPI SHSetWindowBits(HWND hwnd, INT offset, UINT mask, UINT flags) { - LONG ret = GetWindowLongA(hwnd, offset); - LONG newFlags = (wFlags & wMask) | (ret & ~wFlags); + LONG ret = GetWindowLongW(hwnd, offset); + LONG new_flags = (flags & mask) | (ret & ~mask); - if (newFlags != ret) - ret = SetWindowLongA(hwnd, offset, newFlags); + TRACE("%p %d %x %x\n", hwnd, offset, mask, flags); + + if (new_flags != ret) + ret = SetWindowLongW(hwnd, offset, new_flags); return ret; } @@ -4659,7 +4661,7 @@ HRESULT WINAPI SHGetViewStatePropertyBag(LPCITEMIDLIST pidl, LPWSTR bag_name, * fileTime [I] Pointer to FILETIME structure specifying the time * flags [I] Flags specifying the desired output * buf [O] Pointer to buffer for output - * bufSize [I] Number of characters that can be contained in buffer + * size [I] Number of characters that can be contained in buffer * * RETURNS * success: number of characters written to the buffer @@ -4667,10 +4669,65 @@ HRESULT WINAPI SHGetViewStatePropertyBag(LPCITEMIDLIST pidl, LPWSTR bag_name, * */ INT WINAPI SHFormatDateTimeW(const FILETIME UNALIGNED *fileTime, DWORD *flags, - LPWSTR buf, UINT bufSize) + LPWSTR buf, UINT size) { - FIXME("%p %p %s %d STUB\n", fileTime, flags, debugstr_w(buf), bufSize); - return 0; +#define SHFORMATDT_UNSUPPORTED_FLAGS (FDTF_RELATIVE | FDTF_LTRDATE | FDTF_RTLDATE | FDTF_NOAUTOREADINGORDER) + DWORD fmt_flags = flags ? *flags : FDTF_DEFAULT; + SYSTEMTIME st; + FILETIME ft; + INT ret = 0; + + TRACE("%p %p %p %u\n", fileTime, flags, buf, size); + + if (!buf || !size) + return 0; + + if (fmt_flags & SHFORMATDT_UNSUPPORTED_FLAGS) + FIXME("ignoring some flags - 0x%08x\n", fmt_flags & SHFORMATDT_UNSUPPORTED_FLAGS); + + FileTimeToLocalFileTime(fileTime, &ft); + FileTimeToSystemTime(&ft, &st); + + /* first of all date */ + if (fmt_flags & (FDTF_LONGDATE | FDTF_SHORTDATE)) + { + static const WCHAR sep1[] = {',',' ',0}; + static const WCHAR sep2[] = {' ',0}; + + DWORD date = fmt_flags & FDTF_LONGDATE ? DATE_LONGDATE : DATE_SHORTDATE; + ret = GetDateFormatW(LOCALE_USER_DEFAULT, date, &st, NULL, buf, size); + if (ret >= size) return ret; + + /* add separator */ + if (ret < size && (fmt_flags & (FDTF_LONGTIME | FDTF_SHORTTIME))) + { + if ((fmt_flags & FDTF_LONGDATE) && (ret < size + 2)) + { + if (ret < size + 2) + { + lstrcatW(&buf[ret-1], sep1); + ret += 2; + } + } + else + { + lstrcatW(&buf[ret-1], sep2); + ret++; + } + } + } + /* time part */ + if (fmt_flags & (FDTF_LONGTIME | FDTF_SHORTTIME)) + { + DWORD time = fmt_flags & FDTF_LONGTIME ? 0 : TIME_NOSECONDS; + + if (ret) ret--; + ret += GetTimeFormatW(LOCALE_USER_DEFAULT, time, &st, NULL, &buf[ret], size - ret); + } + + return ret; + +#undef SHFORMATDT_UNSUPPORTED_FLAGS } /*********************************************************************** @@ -4680,21 +4737,19 @@ INT WINAPI SHFormatDateTimeW(const FILETIME UNALIGNED *fileTime, DWORD *flags, * */ INT WINAPI SHFormatDateTimeA(const FILETIME UNALIGNED *fileTime, DWORD *flags, - LPCSTR buf, UINT bufSize) + LPSTR buf, UINT size) { WCHAR *bufW; - DWORD buflenW, convlen; INT retval; - if (!buf || !bufSize) + if (!buf || !size) return 0; - buflenW = bufSize; - bufW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * buflenW); - retval = SHFormatDateTimeW(fileTime, flags, bufW, buflenW); + bufW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * size); + retval = SHFormatDateTimeW(fileTime, flags, bufW, size); if (retval != 0) - convlen = WideCharToMultiByte(CP_ACP, 0, bufW, -1, (LPSTR) buf, bufSize, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, size, NULL, NULL); HeapFree(GetProcessHeap(), 0, bufW); return retval; diff --git a/reactos/dll/win32/shlwapi/url.c b/reactos/dll/win32/shlwapi/url.c index 4a93b23b5c1..2fdae3de523 100644 --- a/reactos/dll/win32/shlwapi/url.c +++ b/reactos/dll/win32/shlwapi/url.c @@ -630,6 +630,8 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, process_case = 1; } else do { + BOOL manual_search = FALSE; + /* mk is a special case */ if(base.nScheme == URL_SCHEME_MK) { static const WCHAR wsz[] = {':',':',0}; @@ -659,13 +661,45 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, } } - /* Change .sizep2 to not have the last leaf in it, - * Note: we need to start after the location (if it exists) - */ - work = strrchrW((base.pszSuffix+sizeloc), '/'); - if (work) { - len = (DWORD)(work - base.pszSuffix + 1); - base.cchSuffix = len; + /* If there is a '#' and the characters immediately preceeding it are + * ".htm[l]", then begin looking for the last leaf starting from + * the '#'. Otherwise the '#' is not meaningful and just start + * looking from the end. */ + if ((work = strchrW(base.pszSuffix + sizeloc, '#'))) { + const WCHAR htmlW[] = {'.','h','t','m','l',0}; + const int len_htmlW = 5; + const WCHAR htmW[] = {'.','h','t','m',0}; + const int len_htmW = 4; + + if (work - base.pszSuffix > len_htmW * sizeof(WCHAR)) { + work -= len_htmW; + if (strncmpiW(work, htmW, len_htmW) == 0) + manual_search = TRUE; + work += len_htmW; + } + + if (!manual_search && + work - base.pszSuffix > len_htmlW * sizeof(WCHAR)) { + work -= len_htmlW; + if (strncmpiW(work, htmlW, len_htmlW) == 0) + manual_search = TRUE; + work += len_htmlW; + } + } + + if (manual_search) { + /* search backwards starting from the current position */ + while (*work != '/' && work > base.pszSuffix + sizeloc) + --work; + if (work > base.pszSuffix + sizeloc) + base.cchSuffix = work - base.pszSuffix + 1; + }else { + /* search backwards starting from the end of the string */ + work = strrchrW((base.pszSuffix+sizeloc), '/'); + if (work) { + len = (DWORD)(work - base.pszSuffix + 1); + base.cchSuffix = len; + } } /* diff --git a/reactos/include/psdk/shlwapi.h b/reactos/include/psdk/shlwapi.h index 0af11622d3b..29e70b76d8c 100644 --- a/reactos/include/psdk/shlwapi.h +++ b/reactos/include/psdk/shlwapi.h @@ -1092,6 +1092,17 @@ BOOL WINAPI IsOS(DWORD); #define TPS_EXECUTEIO 0x00000001 #define TPS_LONGEXECTIME 0x00000008 +/* SHFormatDateTimeA/SHFormatDateTimeW flags */ +#define FDTF_SHORTTIME 0x00000001 +#define FDTF_SHORTDATE 0x00000002 +#define FDTF_DEFAULT (FDTF_SHORTDATE | FDTF_SHORTTIME) +#define FDTF_LONGDATE 0x00000004 +#define FDTF_LONGTIME 0x00000008 +#define FDTF_RELATIVE 0x00000010 +#define FDTF_LTRDATE 0x00000100 +#define FDTF_RTLDATE 0x00000200 +#define FDTF_NOAUTOREADINGORDER 0x00000400 + #include #ifdef __cplusplus From 640aaf3a2e5ea798563a0b68aa9db43baec90b63 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:15:38 +0000 Subject: [PATCH 138/211] [GDIPLUS] sync gdiplus to wine 1.1.40 svn path=/trunk/; revision=45924 --- reactos/dll/win32/gdiplus/gdiplus.spec | 4 +- reactos/dll/win32/gdiplus/gdiplus_private.h | 7 +++ reactos/dll/win32/gdiplus/graphics.c | 5 ++- reactos/dll/win32/gdiplus/image.c | 50 ++++++++++++++------- reactos/dll/win32/gdiplus/imageattributes.c | 19 +++++--- reactos/dll/win32/gdiplus/region.c | 12 +++++ reactos/include/psdk/gdipluscolormatrix.h | 2 +- 7 files changed, 74 insertions(+), 25 deletions(-) diff --git a/reactos/dll/win32/gdiplus/gdiplus.spec b/reactos/dll/win32/gdiplus/gdiplus.spec index 1da91d3edca..e6cea5ad443 100644 --- a/reactos/dll/win32/gdiplus/gdiplus.spec +++ b/reactos/dll/win32/gdiplus/gdiplus.spec @@ -290,7 +290,7 @@ @ stdcall GdipGetImageGraphicsContext(ptr ptr) @ stdcall GdipGetImageHeight(ptr ptr) @ stdcall GdipGetImageHorizontalResolution(ptr ptr) -@ stub GdipGetImageItemData +@ stdcall GdipGetImageItemData(ptr ptr) @ stdcall GdipGetImagePalette(ptr ptr long) @ stdcall GdipGetImagePaletteSize(ptr ptr) @ stdcall GdipGetImagePixelFormat(ptr ptr) @@ -381,7 +381,7 @@ @ stdcall GdipGetRegionDataSize(ptr ptr) @ stdcall GdipGetRegionHRgn(ptr ptr ptr) @ stub GdipGetRegionScans -@ stub GdipGetRegionScansCount +@ stdcall GdipGetRegionScansCount(ptr ptr ptr) @ stub GdipGetRegionScansI @ stub GdipGetRenderingOrigin @ stdcall GdipGetSmoothingMode(ptr ptr) diff --git a/reactos/dll/win32/gdiplus/gdiplus_private.h b/reactos/dll/win32/gdiplus/gdiplus_private.h index 8e26eb18db9..ca1cba6175c 100644 --- a/reactos/dll/win32/gdiplus/gdiplus_private.h +++ b/reactos/dll/win32/gdiplus/gdiplus_private.h @@ -264,10 +264,17 @@ struct color_matrix{ ColorMatrix graymatrix; }; +struct color_remap_table{ + BOOL enabled; + INT mapsize; + GDIPCONST ColorMap *colormap; +}; + struct GpImageAttributes{ WrapMode wrap; struct color_key colorkeys[ColorAdjustTypeCount]; struct color_matrix colormatrices[ColorAdjustTypeCount]; + struct color_remap_table colorremaptables[ColorAdjustTypeCount]; BOOL gamma_enabled[ColorAdjustTypeCount]; REAL gamma[ColorAdjustTypeCount]; }; diff --git a/reactos/dll/win32/gdiplus/graphics.c b/reactos/dll/win32/gdiplus/graphics.c index 359b954ebe6..1fd870e3d42 100644 --- a/reactos/dll/win32/gdiplus/graphics.c +++ b/reactos/dll/win32/gdiplus/graphics.c @@ -3173,9 +3173,10 @@ GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics *graphics, return Ok; } +/* FIXME: Need to handle color depths less than 24bpp */ GpStatus WINGDIPAPI GdipGetNearestColor(GpGraphics *graphics, ARGB* argb) { - FIXME("(%p, %p): stub\n", graphics, argb); + FIXME("(%p, %p): Passing color unmodified\n", graphics, argb); if(!graphics || !argb) return InvalidParameter; @@ -3183,7 +3184,7 @@ GpStatus WINGDIPAPI GdipGetNearestColor(GpGraphics *graphics, ARGB* argb) if(graphics->busy) return ObjectBusy; - return NotImplemented; + return Ok; } GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics *graphics, REAL *scale) diff --git a/reactos/dll/win32/gdiplus/image.c b/reactos/dll/win32/gdiplus/image.c index 1d48a0b7427..d72d4cfbb8a 100644 --- a/reactos/dll/win32/gdiplus/image.c +++ b/reactos/dll/win32/gdiplus/image.c @@ -1614,7 +1614,7 @@ static GpStatus get_screen_resolution(REAL *xres, REAL *yres) GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE* scan0, GpBitmap** bitmap) { - BITMAPINFOHEADER bmih; + BITMAPINFO* pbmi; HBITMAP hbitmap; INT row_size, dib_stride; HDC hdc; @@ -1644,26 +1644,33 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, if(stride == 0) stride = dib_stride; - bmih.biSize = sizeof(BITMAPINFOHEADER); - bmih.biWidth = width; - bmih.biHeight = -height; - bmih.biPlanes = 1; + pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); + if (!pbmi) + return OutOfMemory; + + pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + pbmi->bmiHeader.biWidth = width; + pbmi->bmiHeader.biHeight = -height; + pbmi->bmiHeader.biPlanes = 1; /* FIXME: use the rest of the data from format */ - bmih.biBitCount = PIXELFORMATBPP(format); - bmih.biCompression = BI_RGB; - bmih.biSizeImage = 0; - bmih.biXPelsPerMeter = 0; - bmih.biYPelsPerMeter = 0; - bmih.biClrUsed = 0; - bmih.biClrImportant = 0; + pbmi->bmiHeader.biBitCount = PIXELFORMATBPP(format); + pbmi->bmiHeader.biCompression = BI_RGB; + pbmi->bmiHeader.biSizeImage = 0; + pbmi->bmiHeader.biXPelsPerMeter = 0; + pbmi->bmiHeader.biYPelsPerMeter = 0; + pbmi->bmiHeader.biClrUsed = 0; + pbmi->bmiHeader.biClrImportant = 0; hdc = CreateCompatibleDC(NULL); - if (!hdc) return GenericError; + if (!hdc) { + GdipFree(pbmi); + return GenericError; + } - hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&bits, - NULL, 0); + hbitmap = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); DeleteDC(hdc); + GdipFree(pbmi); if (!hbitmap) return GenericError; @@ -1837,6 +1844,7 @@ GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) { GdipFree(((GpBitmap*)image)->bitmapbits); DeleteDC(((GpBitmap*)image)->hdc); + DeleteObject(((GpBitmap*)image)->hbitmap); } GdipFree(image->palette_entries); GdipFree(image); @@ -1859,6 +1867,18 @@ GpStatus WINGDIPAPI GdipFindFirstImageItem(GpImage *image, ImageItemData* item) return NotImplemented; } +GpStatus WINGDIPAPI GdipGetImageItemData(GpImage *image, ImageItemData *item) +{ + static int calls; + + TRACE("(%p,%p)\n", image, item); + + if (!(calls++)) + FIXME("not implemented\n"); + + return NotImplemented; +} + GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, GpUnit *srcUnit) { diff --git a/reactos/dll/win32/gdiplus/imageattributes.c b/reactos/dll/win32/gdiplus/imageattributes.c index c9c3bcc9060..1a7118df773 100644 --- a/reactos/dll/win32/gdiplus/imageattributes.c +++ b/reactos/dll/win32/gdiplus/imageattributes.c @@ -204,14 +204,23 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt ColorAdjustType type, BOOL enableFlag, UINT mapSize, GDIPCONST ColorMap *map) { - static int calls; - TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map); - if(!(calls++)) - FIXME("not implemented\n"); + if(!imageAttr || type >= ColorAdjustTypeCount) + return InvalidParameter; - return NotImplemented; + if (enableFlag) + { + if(!map || !mapSize) + return InvalidParameter; + + imageAttr->colorremaptables[type].mapsize = mapSize; + imageAttr->colorremaptables[type].colormap = map; + } + + imageAttr->colorremaptables[type].enabled = enableFlag; + + return Ok; } GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr, diff --git a/reactos/dll/win32/gdiplus/region.c b/reactos/dll/win32/gdiplus/region.c index eab9b8fa5db..decaaf9e837 100644 --- a/reactos/dll/win32/gdiplus/region.c +++ b/reactos/dll/win32/gdiplus/region.c @@ -1306,3 +1306,15 @@ GpStatus WINGDIPAPI GdipTranslateRegionI(GpRegion *region, INT dx, INT dy) return GdipTranslateRegion(region, (REAL)dx, (REAL)dy); } + +GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMatrix *matrix) +{ + static int calls; + + TRACE("(%p, %p, %p)\n", region, count, matrix); + + if (!(calls++)) + FIXME("not implemented\n"); + + return NotImplemented; +} diff --git a/reactos/include/psdk/gdipluscolormatrix.h b/reactos/include/psdk/gdipluscolormatrix.h index 532e8f4c788..fbf1b2a402f 100644 --- a/reactos/include/psdk/gdipluscolormatrix.h +++ b/reactos/include/psdk/gdipluscolormatrix.h @@ -45,7 +45,7 @@ enum ColorAdjustType struct ColorMap { Color oldColor; - Color newCOlor; + Color newColor; }; #ifndef __cplusplus From 0c34c5a6ec75db94402d236f475bb0e2685ce559 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:23:59 +0000 Subject: [PATCH 139/211] [AMSTREAM] sync amstream to wine 1.1.40 svn path=/trunk/; revision=45925 --- reactos/dll/directx/amstream/amstream.c | 30 ++++++++++++++----- reactos/dll/directx/amstream/mediastream.c | 15 +++++----- .../dll/directx/amstream/mediastreamfilter.c | 6 ++-- reactos/dll/directx/amstream/regsvr.c | 7 +++++ 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/reactos/dll/directx/amstream/amstream.c b/reactos/dll/directx/amstream/amstream.c index 9e4d45aef04..f8ae2a6e39b 100644 --- a/reactos/dll/directx/amstream/amstream.c +++ b/reactos/dll/directx/amstream/amstream.c @@ -35,7 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(amstream); typedef struct { - IAMMultiMediaStream lpVtbl; + const IAMMultiMediaStreamVtbl *lpVtbl; LONG ref; IGraphBuilder* pFilterGraph; IPin* ipin; @@ -63,7 +63,7 @@ HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) return E_OUTOFMEMORY; } - object->lpVtbl.lpVtbl = &AM_Vtbl; + object->lpVtbl = &AM_Vtbl; object->ref = 1; *ppObj = object; @@ -129,7 +129,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream MSPID PurposeId; unsigned int i; - TRACE("(%p/%p)->(%p,%p)\n", This, iface, idPurpose, ppMediaStream); + TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(idPurpose), ppMediaStream); for (i = 0; i < This->nbStreams; i++) { @@ -214,7 +214,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* if IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface; HRESULT hr = S_OK; - FIXME("(%p/%p)->(%x,%x,%p) partial stub!\n", This, iface, (DWORD)StreamType, dwFlags, pFilterGraph); + TRACE("(%p/%p)->(%x,%x,%p)\n", This, iface, (DWORD)StreamType, dwFlags, pFilterGraph); if (pFilterGraph) { @@ -238,9 +238,17 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream { IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface; - FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppGraphBuilder); + TRACE("(%p/%p)->(%p)\n", This, iface, ppGraphBuilder); - return E_NOTIMPL; + if (!ppGraphBuilder) + return E_POINTER; + + if (This->pFilterGraph) + return IFilterGraph_QueryInterface(This->pFilterGraph, &IID_IGraphBuilder, (void**)ppGraphBuilder); + else + *ppGraphBuilder = NULL; + + return S_OK; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream* iface, IMediaStreamFilter** ppFilter) @@ -260,7 +268,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream IMediaStream* pStream; IMediaStream** pNewStreams; - FIXME("(%p/%p)->(%p,%p,%x,%p) partial stub!\n", This, iface, pStreamObject, PurposeId, dwFlags, ppNewStream); + FIXME("(%p/%p)->(%p,%s,%x,%p) partial stub!\n", This, iface, pStreamObject, debugstr_guid(PurposeId), dwFlags, ppNewStream); if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo)) hr = DirectDrawMediaStream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream); @@ -341,6 +349,14 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* ifac goto end; } + /* If Initialize was not called before, we do it here */ + if (!This->pFilterGraph) + { + ret = IAMMultiMediaStream_Initialize(iface, STREAMTYPE_READ, 0, NULL); + if (FAILED(ret)) + goto end; + } + ret = IFilterGraph_QueryInterface(This->pFilterGraph, &IID_IGraphBuilder, (void**)&This->GraphBuilder); if(ret != S_OK) { diff --git a/reactos/dll/directx/amstream/mediastream.c b/reactos/dll/directx/amstream/mediastream.c index bf197aadcf7..dc4ec642cf9 100644 --- a/reactos/dll/directx/amstream/mediastream.c +++ b/reactos/dll/directx/amstream/mediastream.c @@ -29,13 +29,14 @@ #include "wingdi.h" #include "amstream_private.h" -#include "ddstream.h" #include "amstream.h" +#include "ddstream.h" + WINE_DEFAULT_DEBUG_CHANNEL(amstream); typedef struct { - IMediaStream lpVtbl; + const IMediaStreamVtbl *lpVtbl; LONG ref; IMultiMediaStream* Parent; MSPID PurposeId; @@ -43,7 +44,7 @@ typedef struct { } IMediaStreamImpl; typedef struct { - IDirectDrawMediaStream lpVtbl; + const IDirectDrawMediaStreamVtbl *lpVtbl; LONG ref; IMultiMediaStream* Parent; MSPID PurposeId; @@ -57,7 +58,7 @@ HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, S { IMediaStreamImpl* object; - TRACE("(%p,%p,%p)\n", Parent, pPurposeId, ppMediaStream); + TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl)); if (!object) @@ -66,7 +67,7 @@ HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, S return E_OUTOFMEMORY; } - object->lpVtbl.lpVtbl = &MediaStream_Vtbl; + object->lpVtbl = &MediaStream_Vtbl; object->ref = 1; object->Parent = Parent; @@ -197,7 +198,7 @@ HRESULT DirectDrawMediaStream_create(IMultiMediaStream* Parent, const MSPID* pPu { IDirectDrawMediaStreamImpl* object; - TRACE("(%p,%p,%p)\n", Parent, pPurposeId, ppMediaStream); + TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl)); if (!object) @@ -206,7 +207,7 @@ HRESULT DirectDrawMediaStream_create(IMultiMediaStream* Parent, const MSPID* pPu return E_OUTOFMEMORY; } - object->lpVtbl.lpVtbl = &DirectDrawMediaStream_Vtbl; + object->lpVtbl = &DirectDrawMediaStream_Vtbl; object->ref = 1; object->Parent = Parent; diff --git a/reactos/dll/directx/amstream/mediastreamfilter.c b/reactos/dll/directx/amstream/mediastreamfilter.c index af335fdeafe..4a4d7123e16 100644 --- a/reactos/dll/directx/amstream/mediastreamfilter.c +++ b/reactos/dll/directx/amstream/mediastreamfilter.c @@ -36,7 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(amstream); typedef struct { - IMediaStreamFilter lpVtbl; + const IMediaStreamFilterVtbl *lpVtbl; LONG ref; CRITICAL_SECTION csFilter; FILTER_STATE state; @@ -63,7 +63,7 @@ HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj) return E_OUTOFMEMORY; } - object->lpVtbl.lpVtbl = &MediaStreamFilter_Vtbl; + object->lpVtbl = &MediaStreamFilter_Vtbl; object->ref = 1; *ppObj = object; @@ -120,7 +120,7 @@ static ULONG WINAPI MediaStreamFilterImpl_Release(IMediaStreamFilter * iface) if (!refCount) { - This->lpVtbl.lpVtbl = NULL; + This->lpVtbl = NULL; HeapFree(GetProcessHeap(), 0, This); } diff --git a/reactos/dll/directx/amstream/regsvr.c b/reactos/dll/directx/amstream/regsvr.c index 028c68de754..9c328914749 100644 --- a/reactos/dll/directx/amstream/regsvr.c +++ b/reactos/dll/directx/amstream/regsvr.c @@ -456,6 +456,13 @@ static struct regsvr_coclass const coclass_list[] = { "Both" }, + { &CLSID_MediaStreamFilter, + "SFilter Class", + NULL, + "amstream.dll", + "Both" + }, + { NULL } /* list terminator */ }; From dce2b349823024953641d5292d1177ac619e017b Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:26:31 +0000 Subject: [PATCH 140/211] [CABINET_WINETEST] sync cabinet_winetest to wine 1.1.40 svn path=/trunk/; revision=45926 --- rostests/winetests/cabinet/extract.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rostests/winetests/cabinet/extract.c b/rostests/winetests/cabinet/extract.c index 76bd7b7e162..29fd1c7353a 100644 --- a/rostests/winetests/cabinet/extract.c +++ b/rostests/winetests/cabinet/extract.c @@ -670,6 +670,7 @@ static void test_Extract(void) lstrcpyA(session.Destination, "dest"); session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES; res = pExtract(&session, "extract.cab"); + node = session.FileList; todo_wine { ok(res == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) || res == E_FAIL, @@ -694,8 +695,8 @@ static void test_Extract(void) todo_wine { ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n"); + ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n"); } - ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n"); ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(!check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(!check_list(&node, "a.txt", TRUE), "list entry wrong\n"); From bb43ba6b4feece47d9f60cd9777033faf9353660 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:27:21 +0000 Subject: [PATCH 141/211] [HLINK_WINETEST] sync hlink_winetest to wine 1.1.40 svn path=/trunk/; revision=45927 --- rostests/winetests/hlink/hlink.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/rostests/winetests/hlink/hlink.c b/rostests/winetests/hlink/hlink.c index 1802196431f..30b06f093b3 100644 --- a/rostests/winetests/hlink/hlink.c +++ b/rostests/winetests/hlink/hlink.c @@ -135,6 +135,13 @@ static void test_reference(void) ok(r == S_OK, "failed\n"); CoTaskMemFree(str); + r = IHlink_GetStringReference(lnk, -1, NULL, NULL); + ok(r == S_OK, "failed, r=%08x\n", r); + + r = IHlink_GetStringReference(lnk, -1, NULL, &str); + ok(r == S_OK, "failed, r=%08x\n", r); + ok(str == NULL, "string should be null\n"); + r = IHlink_GetStringReference(lnk, HLINKGETREF_DEFAULT, &str, NULL); ok(r == S_OK, "failed\n"); ok(!lstrcmpW(str, url2), "url wrong\n"); @@ -1212,6 +1219,18 @@ static void test_HlinkGetSetStringReference(void) CoTaskMemFree(fnd_tgt); CoTaskMemFree(fnd_loc); + hres = IHlink_GetStringReference(link, -1, &fnd_tgt, NULL); + todo_wine ok(hres == E_FAIL, "IHlink_GetStringReference should have failed " + "with E_FAIL (0x%08x), instead: 0x%08x\n", E_FAIL, hres); + CoTaskMemFree(fnd_tgt); + + hres = IHlink_GetStringReference(link, -1, NULL, NULL); + ok(hres == S_OK, "failed, hres=%08x\n", hres); + + hres = IHlink_GetStringReference(link, -1, NULL, &fnd_loc); + ok(hres == S_OK, "failed, hres=%08x\n", hres); + CoTaskMemFree(fnd_loc); + hres = IHlink_GetStringReference(link, -1, &fnd_tgt, &fnd_loc); todo_wine ok(hres == E_FAIL, "IHlink_GetStringReference should have failed " "with E_FAIL (0x%08x), instead: 0x%08x\n", E_FAIL, hres); From 57aba9879ad8a35d359ab3194b5f174f2cd06432 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:31:57 +0000 Subject: [PATCH 142/211] [MCIWAVE] sync mciwave to wine 1.1.40 svn path=/trunk/; revision=45928 --- reactos/dll/win32/mciwave/mciwave.c | 749 +++++++++++++++------------- 1 file changed, 414 insertions(+), 335 deletions(-) diff --git a/reactos/dll/win32/mciwave/mciwave.c b/reactos/dll/win32/mciwave/mciwave.c index c533e857797..24e75ee9dac 100644 --- a/reactos/dll/win32/mciwave/mciwave.c +++ b/reactos/dll/win32/mciwave/mciwave.c @@ -1,9 +1,10 @@ /* - * Sample Wine Driver for MCI wave forms + * Wine Driver for MCI wave forms * * Copyright 1994 Martin Ayotte * 1999,2000,2005 Eric Pouech * 2000 Francois Jacques + * 2009 Jörg Höhle * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,6 +21,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include "windef.h" @@ -38,11 +40,12 @@ typedef struct { UINT wDevID; HANDLE hWave; int nUseCount; /* Incremented for each shared open */ - BOOL fShareable; /* TRUE if first open was shareable */ HMMIO hFile; /* mmio file handle open as Element */ - MCI_WAVE_OPEN_PARMSW openParms; + MCIDEVICEID wNotifyDeviceID; /* MCI device ID with a pending notification */ + HANDLE hCallback; /* Callback handle for pending notification */ + LPWSTR lpFileName; /* Name of file (if any) */ WAVEFORMATEX wfxRef; - LPWAVEFORMATEX lpWaveFormat; + LPWAVEFORMATEX lpWaveFormat; /* Points to wfxRef until set by OPEN or RECORD */ BOOL fInput; /* FALSE = Output, TRUE = Input */ volatile WORD dwStatus; /* one from MCI_MODE_xxxx */ DWORD dwMciTimeFormat;/* One of the supported MCI_FORMAT_xxxx */ @@ -62,9 +65,12 @@ typedef struct { * =================================================================== * =================================================================== */ +typedef DWORD (*async_cmd)(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE evt); + struct SCA { + async_cmd cmd; + HANDLE evt; UINT wDevID; - UINT wMsg; DWORD_PTR dwParam1; DWORD_PTR dwParam2; }; @@ -77,32 +83,29 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg) struct SCA* sca = (struct SCA*)arg; DWORD ret; - TRACE("In thread before async command (%08x,%u,%08lx,%08lx)\n", - sca->wDevID, sca->wMsg, sca->dwParam1, sca->dwParam2); - ret = mciSendCommandA(sca->wDevID, sca->wMsg, sca->dwParam1 | MCI_WAIT, sca->dwParam2); - TRACE("In thread after async command (%08x,%u,%08lx,%08lx)\n", - sca->wDevID, sca->wMsg, sca->dwParam1, sca->dwParam2); + TRACE("In thread before async command (%08x,%08lx,%08lx)\n", + sca->wDevID, sca->dwParam1, sca->dwParam2); + ret = sca->cmd(sca->wDevID, sca->dwParam1 | MCI_WAIT, sca->dwParam2, sca->evt); + TRACE("In thread after async command (%08x,%08lx,%08lx)\n", + sca->wDevID, sca->dwParam1, sca->dwParam2); HeapFree(GetProcessHeap(), 0, sca); - ExitThread(ret); - WARN("Should not happen ? what's wrong\n"); - /* should not go after this point */ return ret; } /************************************************************************** * MCI_SendCommandAsync [internal] */ -static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD_PTR dwParam1, +static DWORD MCI_SendCommandAsync(UINT wDevID, async_cmd cmd, DWORD_PTR dwParam1, DWORD_PTR dwParam2, UINT size) { - HANDLE handle; + HANDLE handles[2]; struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size); if (sca == 0) return MCIERR_OUT_OF_MEMORY; sca->wDevID = wDevID; - sca->wMsg = wMsg; + sca->cmd = cmd; sca->dwParam1 = dwParam1; if (size && dwParam2) { @@ -115,12 +118,22 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD_PTR dwParam1, sca->dwParam2 = dwParam2; } - if ((handle = CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL)) == 0) { + if ((sca->evt = handles[1] = CreateEventW(NULL, FALSE, FALSE, NULL)) == NULL || + (handles[0] = CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL)) == 0) { WARN("Couldn't allocate thread for async command handling, sending synchronously\n"); + if (handles[1]) CloseHandle(handles[1]); + sca->evt = NULL; return MCI_SCAStarter(&sca); } - SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); - CloseHandle(handle); + + SetThreadPriority(handles[0], THREAD_PRIORITY_TIME_CRITICAL); + /* wait until either: + * - the thread has finished (handles[0], likely an error) + * - init phase of async command is done (handles[1]) + */ + WaitForMultipleObjects(2, handles, FALSE, INFINITE); + CloseHandle(handles[0]); + CloseHandle(handles[1]); return 0; } @@ -189,6 +202,24 @@ static WINE_MCIWAVE *WAVE_mciGetOpenDev(MCIDEVICEID wDevID) return wmw; } +/************************************************************************** + * WAVE_mciNotify [internal] + * + * Notifications in MCI work like a 1-element queue. + * Each new notification request supersedes the previous one. + * This affects Play and Record; other commands are immediate. + */ +static void WAVE_mciNotify(DWORD_PTR hWndCallBack, WINE_MCIWAVE* wmw, UINT wStatus) +{ + /* We simply save one parameter by not passing the wDevID local + * to the command. They are the same (via mciGetDriverData). + */ + MCIDEVICEID wDevID = wmw->wNotifyDeviceID; + HANDLE old = InterlockedExchangePointer(&wmw->hCallback, NULL); + if (old) mciDriverNotify(old, wDevID, MCI_NOTIFY_SUPERSEDED); + mciDriverNotify(HWND_32(LOWORD(hWndCallBack)), wDevID, wStatus); +} + /************************************************************************** * WAVE_ConvertByteToTimeFormat [internal] */ @@ -203,8 +234,8 @@ static DWORD WAVE_ConvertByteToTimeFormat(WINE_MCIWAVE* wmw, DWORD val, LPDWORD case MCI_FORMAT_BYTES: ret = val; break; - case MCI_FORMAT_SAMPLES: /* FIXME: is this correct ? */ - ret = (val * 8) / (wmw->lpWaveFormat->wBitsPerSample ? wmw->lpWaveFormat->wBitsPerSample : 1); + case MCI_FORMAT_SAMPLES: + ret = MulDiv(val,wmw->lpWaveFormat->nSamplesPerSec,wmw->lpWaveFormat->nAvgBytesPerSec); break; default: WARN("Bad time format %u!\n", wmw->dwMciTimeFormat); @@ -223,13 +254,13 @@ static DWORD WAVE_ConvertTimeFormatToByte(WINE_MCIWAVE* wmw, DWORD val) switch (wmw->dwMciTimeFormat) { case MCI_FORMAT_MILLISECONDS: - ret = (val * wmw->lpWaveFormat->nAvgBytesPerSec) / 1000; + ret = MulDiv(val,wmw->lpWaveFormat->nAvgBytesPerSec,1000); break; case MCI_FORMAT_BYTES: ret = val; break; - case MCI_FORMAT_SAMPLES: /* FIXME: is this correct ? */ - ret = (val * wmw->lpWaveFormat->wBitsPerSample) / 8; + case MCI_FORMAT_SAMPLES: + ret = MulDiv(val,wmw->lpWaveFormat->nAvgBytesPerSec,wmw->lpWaveFormat->nSamplesPerSec); break; default: WARN("Bad time format %u!\n", wmw->dwMciTimeFormat); @@ -245,6 +276,7 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF) { MMCKINFO mmckInfo; long r; + LPWAVEFORMATEX pwfx; mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' '); if (mmioDescend(wmw->hFile, &mmckInfo, pckMainRIFF, MMIO_FINDCHUNK) != 0) @@ -252,20 +284,28 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF) TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08X\n", (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize); - wmw->lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); - if (!wmw->lpWaveFormat) return MMSYSERR_NOMEM; - r = mmioRead(wmw->hFile, (HPSTR)wmw->lpWaveFormat, mmckInfo.cksize); - if (r < sizeof(WAVEFORMAT)) - return MCIERR_INVALID_FILE; + pwfx = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); + if (!pwfx) return MCIERR_OUT_OF_MEMORY; - TRACE("wFormatTag=%04X !\n", wmw->lpWaveFormat->wFormatTag); - TRACE("nChannels=%d\n", wmw->lpWaveFormat->nChannels); - TRACE("nSamplesPerSec=%d\n", wmw->lpWaveFormat->nSamplesPerSec); - TRACE("nAvgBytesPerSec=%d\n", wmw->lpWaveFormat->nAvgBytesPerSec); - TRACE("nBlockAlign=%d\n", wmw->lpWaveFormat->nBlockAlign); - TRACE("wBitsPerSample=%u !\n", wmw->lpWaveFormat->wBitsPerSample); + r = mmioRead(wmw->hFile, (HPSTR)pwfx, mmckInfo.cksize); + if (r < sizeof(PCMWAVEFORMAT)) { + HeapFree(GetProcessHeap(), 0, pwfx); + return MCIERR_INVALID_FILE; + } + TRACE("wFormatTag=%04X !\n", pwfx->wFormatTag); + TRACE("nChannels=%d\n", pwfx->nChannels); + TRACE("nSamplesPerSec=%d\n", pwfx->nSamplesPerSec); + TRACE("nAvgBytesPerSec=%d\n", pwfx->nAvgBytesPerSec); + TRACE("nBlockAlign=%d\n", pwfx->nBlockAlign); + TRACE("wBitsPerSample=%u !\n", pwfx->wBitsPerSample); if (r >= (long)sizeof(WAVEFORMATEX)) - TRACE("cbSize=%u !\n", wmw->lpWaveFormat->cbSize); + TRACE("cbSize=%u !\n", pwfx->cbSize); + if ((pwfx->wFormatTag != WAVE_FORMAT_PCM) + && (r < sizeof(WAVEFORMATEX) || (r < sizeof(WAVEFORMATEX) + pwfx->cbSize))) { + HeapFree(GetProcessHeap(), 0, pwfx); + return MCIERR_INVALID_FILE; + } + wmw->lpWaveFormat = pwfx; mmioAscend(wmw->hFile, &mmckInfo, 0); wmw->ckWaveData.ckid = mmioFOURCC('d', 'a', 't', 'a'); @@ -275,28 +315,26 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF) } TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08X\n", (LPSTR)&wmw->ckWaveData.ckid, (LPSTR)&wmw->ckWaveData.fccType, wmw->ckWaveData.cksize); - TRACE("nChannels=%d nSamplesPerSec=%d\n", - wmw->lpWaveFormat->nChannels, wmw->lpWaveFormat->nSamplesPerSec); - return 0; } /************************************************************************** - * WAVE_mciDefaultFmt [internal] + * WAVE_mciDefaultFmt [internal] + * + * wmw->lpWaveFormat points to the default wave format at wmw->wfxRef + * until either Open File or Record. It becomes immutable afterwards, + * i.e. Set wave format or channels etc. is subsequently refused. */ -static DWORD WAVE_mciDefaultFmt(WINE_MCIWAVE* wmw) +static void WAVE_mciDefaultFmt(WINE_MCIWAVE* wmw) { - wmw->lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, sizeof(*wmw->lpWaveFormat)); - if (!wmw->lpWaveFormat) return MMSYSERR_NOMEM; - + wmw->lpWaveFormat = &wmw->wfxRef; wmw->lpWaveFormat->wFormatTag = WAVE_FORMAT_PCM; wmw->lpWaveFormat->nChannels = 1; - wmw->lpWaveFormat->nSamplesPerSec = 44000; - wmw->lpWaveFormat->nAvgBytesPerSec = 44000; + wmw->lpWaveFormat->nSamplesPerSec = 11025; + wmw->lpWaveFormat->nAvgBytesPerSec = 11025; wmw->lpWaveFormat->nBlockAlign = 1; wmw->lpWaveFormat->wBitsPerSample = 8; - - return 0; + wmw->lpWaveFormat->cbSize = 0; } /************************************************************************** @@ -319,24 +357,41 @@ static DWORD WAVE_mciCreateRIFFSkeleton(WINE_MCIWAVE* wmw) ckWaveFormat.ckid = mmioFOURCC('f', 'm', 't', ' '); ckWaveFormat.cksize = sizeof(PCMWAVEFORMAT); - if (!wmw->lpWaveFormat) - { - wmw->lpWaveFormat = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wmw->lpWaveFormat)); - if (!wmw->lpWaveFormat) return MMSYSERR_NOMEM; - *wmw->lpWaveFormat = wmw->wfxRef; + /* Set wave format accepts PCM only, however open an + * existing ADPCM file, record into it and the MCI will + * happily save back in that format. */ + if (wmw->lpWaveFormat->wFormatTag == WAVE_FORMAT_PCM) { + if (wmw->lpWaveFormat->nBlockAlign != + wmw->lpWaveFormat->nChannels * wmw->lpWaveFormat->wBitsPerSample/8) { + WORD size = wmw->lpWaveFormat->nChannels * + wmw->lpWaveFormat->wBitsPerSample/8; + WARN("Incorrect nBlockAlign (%d), setting it to %d\n", + wmw->lpWaveFormat->nBlockAlign, size); + wmw->lpWaveFormat->nBlockAlign = size; + } + if (wmw->lpWaveFormat->nAvgBytesPerSec != + wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) { + DWORD speed = wmw->lpWaveFormat->nSamplesPerSec * + wmw->lpWaveFormat->nBlockAlign; + WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n", + wmw->lpWaveFormat->nAvgBytesPerSec, speed); + wmw->lpWaveFormat->nAvgBytesPerSec = speed; + } + } + if (wmw->lpWaveFormat == &wmw->wfxRef) { + LPWAVEFORMATEX pwfx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WAVEFORMATEX)); + if (!pwfx) return MCIERR_OUT_OF_MEMORY; + /* Set wave format accepts PCM only so the size is known. */ + assert(wmw->wfxRef.wFormatTag == WAVE_FORMAT_PCM); + *pwfx = wmw->wfxRef; + wmw->lpWaveFormat = pwfx; } - - /* we can only record PCM files... there is no way in the MCI API to specify - * the necessary data to initialize the extra bytes of the WAVEFORMATEX - * structure - */ - if (wmw->lpWaveFormat->wFormatTag != WAVE_FORMAT_PCM) - goto err; if (MMSYSERR_NOERROR != mmioCreateChunk(wmw->hFile, &ckWaveFormat, 0)) goto err; - if (-1 == mmioWrite(wmw->hFile, (HPCSTR)wmw->lpWaveFormat, sizeof(PCMWAVEFORMAT))) + if (-1 == mmioWrite(wmw->hFile, (HPCSTR)wmw->lpWaveFormat, (WAVE_FORMAT_PCM==wmw->lpWaveFormat->wFormatTag) + ? sizeof(PCMWAVEFORMAT) : sizeof(WAVEFORMATEX)+wmw->lpWaveFormat->cbSize)) goto err; if (MMSYSERR_NOERROR != mmioAscend(wmw->hFile, &ckWaveFormat, 0)) @@ -353,8 +408,7 @@ static DWORD WAVE_mciCreateRIFFSkeleton(WINE_MCIWAVE* wmw) return 0; err: - HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat); - wmw->lpWaveFormat = NULL; + /* mciClose takes care of wmw->lpWaveFormat. */ return MCIERR_INVALID_FILE; } @@ -371,6 +425,7 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName) if (!GetTempPathW(sizeof(szTmpPath)/sizeof(szTmpPath[0]), szTmpPath)) { WARN("can't retrieve temp path!\n"); + *pszTmpFileName = NULL; return MCIERR_FILE_NOT_FOUND; } @@ -400,16 +455,16 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName) return dwRet; } -static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, const WCHAR* filename) +static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, LPCWSTR filename) { LRESULT dwRet = MMSYSERR_NOERROR; - WCHAR* fn; + LPWSTR fn; fn = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR)); if (!fn) return MCIERR_OUT_OF_MEMORY; strcpyW(fn, filename); - HeapFree(GetProcessHeap(), 0, (void*)wmw->openParms.lpstrElementName); - wmw->openParms.lpstrElementName = fn; + HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName); + wmw->lpFileName = fn; if (strlenW(filename) > 0) { /* FIXME : what should be done if wmw->hFile is already != 0, or the driver is playin' */ @@ -463,7 +518,7 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; if (dwFlags & MCI_OPEN_SHAREABLE) - return MCIERR_HARDWARE; + return MCIERR_UNSUPPORTED_FUNCTION; if (wmw->nUseCount > 0) { /* The driver is already opened on this channel @@ -478,11 +533,13 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P wmw->hWave = 0; wmw->dwStatus = MCI_MODE_NOT_READY; wmw->hFile = 0; - memcpy(&wmw->openParms, lpOpenParms, sizeof(MCI_WAVE_OPEN_PARMSA)); - /* will be set by WAVE_mciOpenFile */ - wmw->openParms.lpstrElementName = NULL; + wmw->lpFileName = NULL; /* will be set by WAVE_mciOpenFile */ + wmw->hCallback = NULL; + WAVE_mciDefaultFmt(wmw); TRACE("wDevID=%04X (lpParams->wDeviceID=%08X)\n", wDevID, lpOpenParms->wDeviceID); + /* Logs show the native winmm calls us with 0 still in lpOpenParms.wDeviceID */ + wmw->wNotifyDeviceID = wDevID; if (dwFlags & MCI_OPEN_ELEMENT) { if (dwFlags & MCI_OPEN_ELEMENT_ID) { @@ -494,32 +551,15 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P dwRet = WAVE_mciOpenFile(wmw, lpOpenParms->lpstrElementName); } } - TRACE("hFile=%p\n", wmw->hFile); - if (dwRet == 0 && !wmw->lpWaveFormat) - dwRet = WAVE_mciDefaultFmt(wmw); - if (dwRet == 0) { - if (wmw->lpWaveFormat) { - switch (wmw->lpWaveFormat->wFormatTag) { - case WAVE_FORMAT_PCM: - if (wmw->lpWaveFormat->nAvgBytesPerSec != - wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) { - WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n", - wmw->lpWaveFormat->nAvgBytesPerSec, - wmw->lpWaveFormat->nSamplesPerSec * - wmw->lpWaveFormat->nBlockAlign); - wmw->lpWaveFormat->nAvgBytesPerSec = - wmw->lpWaveFormat->nSamplesPerSec * - wmw->lpWaveFormat->nBlockAlign; - } - break; - } - } wmw->dwPosition = 0; wmw->dwStatus = MCI_MODE_STOP; + + if (dwFlags & MCI_NOTIFY) + WAVE_mciNotify(lpOpenParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); } else { wmw->nUseCount--; if (wmw->hFile != 0) @@ -532,46 +572,38 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P /************************************************************************** * WAVE_mciCue [internal] */ -static DWORD WAVE_mciCue(MCIDEVICEID wDevID, LPARAM dwParam, LPMCI_GENERIC_PARMS lpParms) +static DWORD WAVE_mciCue(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { - /* - FIXME - - This routine is far from complete. At the moment only a check is done on the - MCI_WAVE_INPUT flag. No explicit check on MCI_WAVE_OUTPUT is done since that - is the default. - - The flags MCI_NOTIFY (and the callback parameter in lpParms) and MCI_WAIT - are ignored - */ - - DWORD dwRet; WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); - FIXME("(%u, %08lX, %p); likely to fail\n", wDevID, dwParam, lpParms); + TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); - if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; + /* Tests on systems without sound drivers show that Cue, like + * Record and Play, opens winmm, returning MCIERR_WAVE_xyPUTSUNSUITABLE. + * The first Cue Notify does not immediately return the + * notification, as if a player or recorder thread is started. + * PAUSE mode is reported when successful, but this mode is + * different from the normal Pause, because a) Pause then returns + * NONAPPLICABLE_FUNCTION instead of 0 and b) Set Channels etc. is + * still accepted, returning the original notification as ABORTED. + * I.e. Cue allows subsequent format changes, unlike Record or + * Open file, closes winmm if the format changes and stops this + * thread. + * Wine creates one player or recorder thread per async. Play or + * Record command. Notification behaviour suggests that MS-W* + * reuses a single thread to improve response times. Having Cue + * start this thread early helps to improve Play/Record's initial + * response time. In effect, Cue is a performance hint, which + * justifies our almost no-op implementation. + */ - /* FIXME */ - /* always close elements ? */ - if (wmw->hFile != 0) { - mmioClose(wmw->hFile, 0); - wmw->hFile = 0; - } + if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; + if (wmw->dwStatus != MCI_MODE_STOP) return MCIERR_NONAPPLICABLE_FUNCTION; - dwRet = MMSYSERR_NOERROR; /* assume success */ + if ((dwFlags & MCI_NOTIFY) && lpParms) + WAVE_mciNotify(lpParms->dwCallback,wmw,MCI_NOTIFY_SUCCESSFUL); - if ((dwParam & MCI_WAVE_INPUT) && !wmw->fInput) { - dwRet = waveOutClose(wmw->hWave); - if (dwRet != MMSYSERR_NOERROR) return MCIERR_INTERNAL; - wmw->fInput = TRUE; - } else if (wmw->fInput) { - dwRet = waveInClose(wmw->hWave); - if (dwRet != MMSYSERR_NOERROR) return MCIERR_INTERNAL; - wmw->fInput = FALSE; - } - wmw->hWave = 0; - return (dwRet == MMSYSERR_NOERROR) ? 0 : MCIERR_INTERNAL; + return MMSYSERR_NOERROR; } /************************************************************************** @@ -586,6 +618,11 @@ static DWORD WAVE_mciStop(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; + if (wmw->dwStatus != MCI_MODE_STOP) { + HANDLE old = InterlockedExchangePointer(&wmw->hCallback, NULL); + if (old) mciDriverNotify(old, wDevID, MCI_NOTIFY_ABORTED); + } + /* wait for playback thread (if any) to exit before processing further */ switch (wmw->dwStatus) { case MCI_MODE_PAUSE: @@ -602,15 +639,11 @@ static DWORD WAVE_mciStop(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS break; } - wmw->dwPosition = 0; - /* sanity resets */ wmw->dwStatus = MCI_MODE_STOP; - if ((dwFlags & MCI_NOTIFY) && lpParms) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL); - } + if ((dwFlags & MCI_NOTIFY) && lpParms && MMSYSERR_NOERROR==dwRet) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return dwRet; } @@ -628,6 +661,7 @@ static DWORD WAVE_mciClose(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; if (wmw->dwStatus != MCI_MODE_STOP) { + /* mciStop handles MCI_NOTIFY_ABORTED */ dwRet = WAVE_mciStop(wDevID, MCI_WAIT, lpParms); } @@ -640,15 +674,15 @@ static DWORD WAVE_mciClose(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM } } - HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat); - wmw->lpWaveFormat = NULL; - HeapFree(GetProcessHeap(), 0, (void*)wmw->openParms.lpstrElementName); - wmw->openParms.lpstrElementName = NULL; + if (wmw->lpWaveFormat != &wmw->wfxRef) + HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat); + wmw->lpWaveFormat = &wmw->wfxRef; + HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName); + wmw->lpFileName = NULL; if ((dwFlags & MCI_NOTIFY) && lpParms) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, - (dwRet == 0) ? MCI_NOTIFY_SUCCESSFUL : MCI_NOTIFY_FAILURE); + WAVE_mciNotify(lpParms->dwCallback, wmw, + (dwRet == 0) ? MCI_NOTIFY_SUCCESSFUL : MCI_NOTIFY_FAILURE); } return 0; @@ -678,9 +712,7 @@ static void CALLBACK WAVE_mciPlayCallback(HWAVEOUT hwo, UINT uMsg, } /****************************************************************** - * WAVE_mciPlayWaitDone - * - * + * WAVE_mciPlayWaitDone [internal] */ static void WAVE_mciPlayWaitDone(WINE_MCIWAVE* wmw) { @@ -698,28 +730,28 @@ static void WAVE_mciPlayWaitDone(WINE_MCIWAVE* wmw) /************************************************************************** * WAVE_mciPlay [internal] */ -static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) +static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE hEvent) { + LPMCI_PLAY_PARMS lpParms = (void*)pmt; DWORD end; LONG bufsize, count, left; - DWORD dwRet = 0; + DWORD dwRet; LPWAVEHDR waveHdr = NULL; WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); + HANDLE oldcb; int whidx; - TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); + TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms); if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; - wmw->fInput = FALSE; - if (wmw->hFile == 0) { - WARN("Can't play: no file=%s!\n", debugstr_w(wmw->openParms.lpstrElementName)); + WARN("Can't play: no file=%s!\n", debugstr_w(wmw->lpFileName)); return MCIERR_FILE_NOT_FOUND; } - if (wmw->dwStatus == MCI_MODE_PAUSE) { + if (wmw->dwStatus == MCI_MODE_PAUSE && !wmw->fInput) { /* FIXME: parameters (start/end) in lpParams may not be used */ return WAVE_mciResume(wDevID, dwFlags, (LPMCI_GENERIC_PARMS)lpParms); } @@ -732,56 +764,65 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp return MCIERR_INTERNAL; } + if (wmw->lpWaveFormat->wFormatTag == WAVE_FORMAT_PCM) { + if (wmw->lpWaveFormat->nBlockAlign != + wmw->lpWaveFormat->nChannels * wmw->lpWaveFormat->wBitsPerSample/8) { + WARN("Incorrect nBlockAlign (%d), setting it to %d\n", + wmw->lpWaveFormat->nBlockAlign, + wmw->lpWaveFormat->nChannels * + wmw->lpWaveFormat->wBitsPerSample/8); + wmw->lpWaveFormat->nBlockAlign = + wmw->lpWaveFormat->nChannels * + wmw->lpWaveFormat->wBitsPerSample/8; + } + if (wmw->lpWaveFormat->nAvgBytesPerSec != + wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) { + WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n", + wmw->lpWaveFormat->nAvgBytesPerSec, + wmw->lpWaveFormat->nSamplesPerSec * + wmw->lpWaveFormat->nBlockAlign); + wmw->lpWaveFormat->nAvgBytesPerSec = + wmw->lpWaveFormat->nSamplesPerSec * + wmw->lpWaveFormat->nBlockAlign; + } + } + + end = wmw->ckWaveData.cksize; + if (lpParms && (dwFlags & MCI_TO)) { + DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); + if (position > end) return MCIERR_OUTOFRANGE; + end = position; + } + if (lpParms && (dwFlags & MCI_FROM)) { + DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom); + if (position > end) return MCIERR_OUTOFRANGE; + /* Seek rounds down, so do we. */ + position /= wmw->lpWaveFormat->nBlockAlign; + position *= wmw->lpWaveFormat->nBlockAlign; + wmw->dwPosition = position; + } + if (end < wmw->dwPosition) return MCIERR_OUTOFRANGE; + left = end - wmw->dwPosition; + if (0==left) return MMSYSERR_NOERROR; /* FIXME: NOTIFY */ + + wmw->fInput = FALSE; /* FIXME: waveInOpen may have been called. */ wmw->dwStatus = MCI_MODE_PLAY; if (!(dwFlags & MCI_WAIT)) { - return MCI_SendCommandAsync(wmw->openParms.wDeviceID, MCI_PLAY, dwFlags, + return MCI_SendCommandAsync(wDevID, WAVE_mciPlay, dwFlags, (DWORD_PTR)lpParms, sizeof(MCI_PLAY_PARMS)); } - end = 0xFFFFFFFF; - if (lpParms && (dwFlags & MCI_FROM)) { - wmw->dwPosition = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom); - } - if (lpParms && (dwFlags & MCI_TO)) { - end = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); - } - TRACE("Playing from byte=%u to byte=%u\n", wmw->dwPosition, end); - if (end <= wmw->dwPosition) - return TRUE; - + oldcb = InterlockedExchangePointer(&wmw->hCallback, + (dwFlags & MCI_NOTIFY) ? HWND_32(LOWORD(lpParms->dwCallback)) : NULL); + if (oldcb) mciDriverNotify(oldcb, wDevID, MCI_NOTIFY_ABORTED); + oldcb = NULL; #define WAVE_ALIGN_ON_BLOCK(wmw,v) \ ((((v) + (wmw)->lpWaveFormat->nBlockAlign - 1) / (wmw)->lpWaveFormat->nBlockAlign) * (wmw)->lpWaveFormat->nBlockAlign) - wmw->dwPosition = WAVE_ALIGN_ON_BLOCK(wmw, wmw->dwPosition); - wmw->ckWaveData.cksize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->ckWaveData.cksize); - - if (dwRet == 0) { - if (wmw->lpWaveFormat) { - switch (wmw->lpWaveFormat->wFormatTag) { - case WAVE_FORMAT_PCM: - if (wmw->lpWaveFormat->nAvgBytesPerSec != - wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) { - WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n", - wmw->lpWaveFormat->nAvgBytesPerSec, - wmw->lpWaveFormat->nSamplesPerSec * - wmw->lpWaveFormat->nBlockAlign); - wmw->lpWaveFormat->nAvgBytesPerSec = - wmw->lpWaveFormat->nSamplesPerSec * - wmw->lpWaveFormat->nBlockAlign; - } - break; - } - } - } else { - TRACE("can't retrieve wave format %d\n", dwRet); - goto cleanUp; - } - - /* go back to beginning of chunk plus the requested position */ /* FIXME: I'm not sure this is correct, notably because some data linked to * the decompression state machine will not be correctly initialized. @@ -790,9 +831,6 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp */ mmioSeek(wmw->hFile, wmw->ckWaveData.dwDataOffset + wmw->dwPosition, SEEK_SET); /* >= 0 */ - /* By default the device will be opened for output, the MCI_CUE function is there to - * change from output to input and back - */ /* FIXME: how to choose between several output channels ? here mapper is forced */ dwRet = waveOutOpen((HWAVEOUT *)&wmw->hWave, WAVE_MAPPER, wmw->lpWaveFormat, (DWORD_PTR)WAVE_mciPlayCallback, (DWORD_PTR)wmw, CALLBACK_FUNCTION); @@ -821,11 +859,11 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp } whidx = 0; - left = min(wmw->ckWaveData.cksize, end - wmw->dwPosition); wmw->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wmw->dwEventCount = 1L; /* for first buffer */ TRACE("Playing (normalized) from byte=%u for %u bytes\n", wmw->dwPosition, left); + if (hEvent) SetEvent(hEvent); /* FIXME: this doesn't work if wmw->dwPosition != 0 */ while (left > 0 && wmw->dwStatus != MCI_MODE_STOP && wmw->dwStatus != MCI_MODE_NOT_READY) { @@ -838,14 +876,18 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp */ waveHdr[whidx].dwBufferLength = count; waveHdr[whidx].dwFlags &= ~WHDR_DONE; - TRACE("before WODM_WRITE lpWaveHdr=%p dwBufferLength=%u dwBytesRecorded=%u\n", - &waveHdr[whidx], waveHdr[whidx].dwBufferLength, - waveHdr[whidx].dwBytesRecorded); + TRACE("before WODM_WRITE lpWaveHdr=%p dwBufferLength=%u\n", + &waveHdr[whidx], waveHdr[whidx].dwBufferLength); dwRet = waveOutWrite(wmw->hWave, &waveHdr[whidx], sizeof(WAVEHDR)); + if (dwRet) { + ERR("Aborting play loop, WODM_WRITE error %d\n", dwRet); + dwRet = MCIERR_HARDWARE; + break; + } left -= count; wmw->dwPosition += count; TRACE("after WODM_WRITE dwPosition=%u\n", wmw->dwPosition); - + /* InterlockedDecrement if and only if waveOutWrite is successful */ WAVE_mciPlayWaitDone(wmw); whidx ^= 1; } @@ -858,9 +900,10 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp waveOutUnprepareHeader(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR)); waveOutUnprepareHeader(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR)); - dwRet = 0; - cleanUp: + if (dwFlags & MCI_NOTIFY) + oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL); + HeapFree(GetProcessHeap(), 0, waveHdr); if (wmw->hWave) { @@ -869,19 +912,17 @@ cleanUp: } CloseHandle(wmw->hEvent); - if (lpParms && (dwFlags & MCI_NOTIFY)) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, - dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL); - } - wmw->dwStatus = MCI_MODE_STOP; + /* Let the potentically asynchronous commands support FAILURE notification. */ + if (oldcb) mciDriverNotify(oldcb, wDevID, + dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL); + return dwRet; } /************************************************************************** - * WAVE_mciPlayCallback [internal] + * WAVE_mciRecordCallback [internal] */ static void CALLBACK WAVE_mciRecordCallback(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, @@ -924,8 +965,7 @@ static void CALLBACK WAVE_mciRecordCallback(HWAVEOUT hwo, UINT uMsg, } /****************************************************************** - * bWAVE_mciRecordWaitDone - * + * WAVE_mciRecordWaitDone [internal] */ static void WAVE_mciRecordWaitDone(WINE_MCIWAVE* wmw) { @@ -943,41 +983,39 @@ static void WAVE_mciRecordWaitDone(WINE_MCIWAVE* wmw) /************************************************************************** * WAVE_mciRecord [internal] */ -static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_RECORD_PARMS lpParms) +static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE hEvent) { + LPMCI_RECORD_PARMS lpParms = (void*)pmt; DWORD end; DWORD dwRet = MMSYSERR_NOERROR; LONG bufsize; LPWAVEHDR waveHdr = NULL; WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); + HANDLE oldcb; - TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); + TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms); if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; - /* FIXME : since there is no way to determine in which mode the device is - * open (recording/playback) automatically switch from a mode to another - */ - wmw->fInput = TRUE; - - if (wmw->dwStatus == MCI_MODE_PAUSE) { + if (wmw->dwStatus == MCI_MODE_PAUSE && wmw->fInput) { /* FIXME: parameters (start/end) in lpParams may not be used */ return WAVE_mciResume(wDevID, dwFlags, (LPMCI_GENERIC_PARMS)lpParms); } /** This function will be called again by a thread when async is used. - * We have to set MCI_MODE_PLAY before we do this so that the app can spin + * We have to set MCI_MODE_RECORD before we do this so that the app can spin * on MCI_STATUS, so we have to allow it here if we're not going to start this thread. */ if ((wmw->dwStatus != MCI_MODE_STOP) && ((wmw->dwStatus != MCI_MODE_RECORD) && (dwFlags & MCI_WAIT))) { return MCIERR_INTERNAL; } + wmw->fInput = TRUE; /* FIXME: waveOutOpen may have been called. */ wmw->dwStatus = MCI_MODE_RECORD; if (!(dwFlags & MCI_WAIT)) { - return MCI_SendCommandAsync(wmw->openParms.wDeviceID, MCI_RECORD, dwFlags, + return MCI_SendCommandAsync(wDevID, WAVE_mciRecord, dwFlags, (DWORD_PTR)lpParms, sizeof(MCI_RECORD_PARMS)); } @@ -985,34 +1023,37 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_RECORD_PARM * we don't modify the wave part of an existing file (ie. we always erase an * existing content, we don't overwrite) */ - HeapFree(GetProcessHeap(), 0, (void*)wmw->openParms.lpstrElementName); - dwRet = create_tmp_file(&wmw->hFile, (WCHAR**)&wmw->openParms.lpstrElementName); + HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName); + dwRet = create_tmp_file(&wmw->hFile, (WCHAR**)&wmw->lpFileName); if (dwRet != 0) return dwRet; - /* new RIFF file */ + /* new RIFF file, lpWaveFormat now valid */ dwRet = WAVE_mciCreateRIFFSkeleton(wmw); - if (dwRet != 0) return dwRet; /* FIXME: we leak resources */ - - end = 0xFFFFFFFF; - if (lpParms && (dwFlags & MCI_FROM)) { - wmw->dwPosition = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom); - } + if (dwRet != 0) return dwRet; if (lpParms && (dwFlags & MCI_TO)) { end = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); + } else end = 0xFFFFFFFF; + if (lpParms && (dwFlags & MCI_FROM)) { + DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom); + if (wmw->ckWaveData.cksize < position) return MCIERR_OUTOFRANGE; + /* Seek rounds down, so do we. */ + position /= wmw->lpWaveFormat->nBlockAlign; + position *= wmw->lpWaveFormat->nBlockAlign; + wmw->dwPosition = position; } + if (end==wmw->dwPosition) return MMSYSERR_NOERROR; /* FIXME: NOTIFY */ TRACE("Recording from byte=%u to byte=%u\n", wmw->dwPosition, end); - if (end <= wmw->dwPosition) - { - return TRUE; - } + oldcb = InterlockedExchangePointer(&wmw->hCallback, + (dwFlags & MCI_NOTIFY) ? HWND_32(LOWORD(lpParms->dwCallback)) : NULL); + if (oldcb) mciDriverNotify(oldcb, wDevID, MCI_NOTIFY_ABORTED); + oldcb = NULL; #define WAVE_ALIGN_ON_BLOCK(wmw,v) \ ((((v) + (wmw)->lpWaveFormat->nBlockAlign - 1) / (wmw)->lpWaveFormat->nBlockAlign) * (wmw)->lpWaveFormat->nBlockAlign) - wmw->dwPosition = WAVE_ALIGN_ON_BLOCK(wmw, wmw->dwPosition); wmw->ckWaveData.cksize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->ckWaveData.cksize); /* Go back to the beginning of the chunk plus the requested position */ @@ -1067,10 +1108,16 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_RECORD_PARM dwRet = waveInStart(wmw->hWave); + if (hEvent) SetEvent(hEvent); + while (wmw->dwPosition < end && wmw->dwStatus != MCI_MODE_STOP && wmw->dwStatus != MCI_MODE_NOT_READY) { WAVE_mciRecordWaitDone(wmw); } - + /* Grab callback before another thread kicks in after we change dwStatus. */ + if (dwFlags & MCI_NOTIFY) { + oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL); + dwFlags &= ~MCI_NOTIFY; + } /* needed so that the callback above won't add again the buffers returned by the reset */ wmw->dwStatus = MCI_MODE_STOP; @@ -1082,6 +1129,9 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_RECORD_PARM dwRet = 0; cleanUp: + if (dwFlags & MCI_NOTIFY) + oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL); + HeapFree(GetProcessHeap(), 0, waveHdr); if (wmw->hWave) { @@ -1090,14 +1140,11 @@ cleanUp: } CloseHandle(wmw->hEvent); - if (lpParms && (dwFlags & MCI_NOTIFY)) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, - dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL); - } - wmw->dwStatus = MCI_MODE_STOP; + if (oldcb) mciDriverNotify(oldcb, wDevID, + dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL); + return dwRet; } @@ -1112,17 +1159,34 @@ static DWORD WAVE_mciPause(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); - if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; - if (wmw->dwStatus == MCI_MODE_PLAY) { - wmw->dwStatus = MCI_MODE_PAUSE; + switch (wmw->dwStatus) { + case MCI_MODE_PLAY: + dwRet = waveOutPause(wmw->hWave); + if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PAUSE; + else { /* When playthread was not started yet, winmm not opened, error 5 MMSYSERR_INVALHANDLE */ + ERR("waveOutPause error %d\n",dwRet); + dwRet = MCIERR_INTERNAL; + } + break; + case MCI_MODE_RECORD: + dwRet = waveInStop(wmw->hWave); + if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PAUSE; + else { + ERR("waveInStop error %d\n",dwRet); + dwRet = MCIERR_INTERNAL; + } + break; + case MCI_MODE_PAUSE: + dwRet = MMSYSERR_NOERROR; + break; + default: + dwRet = MCIERR_NONAPPLICABLE_FUNCTION; } - - if (wmw->fInput) dwRet = waveInStop(wmw->hWave); - else dwRet = waveOutPause(wmw->hWave); - - return (dwRet == MMSYSERR_NOERROR) ? 0 : MCIERR_INTERNAL; + if (MMSYSERR_NOERROR==dwRet && (dwFlags & MCI_NOTIFY) && lpParms) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); + return dwRet; } /************************************************************************** @@ -1131,19 +1195,41 @@ static DWORD WAVE_mciPause(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM static DWORD WAVE_mciResume(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); - DWORD dwRet = 0; + DWORD dwRet; TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; - if (wmw->dwStatus == MCI_MODE_PAUSE) { - wmw->dwStatus = MCI_MODE_PLAY; + switch (wmw->dwStatus) { + case MCI_MODE_PAUSE: + /* Only update dwStatus if wave* succeeds and will exchange buffers buffers. */ + if (wmw->fInput) { + dwRet = waveInStart(wmw->hWave); + if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_RECORD; + else { + ERR("waveInStart error %d\n",dwRet); + dwRet = MCIERR_INTERNAL; + } + } else { + dwRet = waveOutRestart(wmw->hWave); + if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PLAY; + else { + ERR("waveOutRestart error %d\n",dwRet); + dwRet = MCIERR_INTERNAL; + } + } + break; + case MCI_MODE_PLAY: + case MCI_MODE_RECORD: + dwRet = MMSYSERR_NOERROR; + break; + default: + dwRet = MCIERR_NONAPPLICABLE_FUNCTION; } - - if (wmw->fInput) dwRet = waveInStart(wmw->hWave); - else dwRet = waveOutRestart(wmw->hWave); - return (dwRet == MMSYSERR_NOERROR) ? 0 : MCIERR_INTERNAL; + if (MMSYSERR_NOERROR==dwRet && (dwFlags & MCI_NOTIFY) && lpParms) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); + return dwRet; } /************************************************************************** @@ -1151,37 +1237,43 @@ static DWORD WAVE_mciResume(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PAR */ static DWORD WAVE_mciSeek(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms) { - DWORD ret = 0; WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); + DWORD position, dwRet; TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpParms); - if (lpParms == NULL) { - ret = MCIERR_NULL_PARAMETER_BLOCK; - } else if (wmw == NULL) { - ret = MCIERR_INVALID_DEVICE_ID; + if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; + if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; + + position = dwFlags & (MCI_SEEK_TO_START|MCI_SEEK_TO_END|MCI_TO); + if (!position) return MCIERR_MISSING_PARAMETER; + if (position&(position-1)) return MCIERR_FLAGS_NOT_COMPATIBLE; + + /* Stop sends MCI_NOTIFY_ABORTED when needed */ + dwRet = WAVE_mciStop(wDevID, MCI_WAIT, 0); + if (dwRet != MMSYSERR_NOERROR) return dwRet; + + if (dwFlags & MCI_TO) { + position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); + if (position > wmw->ckWaveData.cksize) + return MCIERR_OUTOFRANGE; + } else if (dwFlags & MCI_SEEK_TO_START) { + position = 0; } else { - WAVE_mciStop(wDevID, MCI_WAIT, 0); - - if (dwFlags & MCI_SEEK_TO_START) { - wmw->dwPosition = 0; - } else if (dwFlags & MCI_SEEK_TO_END) { - wmw->dwPosition = wmw->ckWaveData.cksize; - } else if (dwFlags & MCI_TO) { - wmw->dwPosition = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); - } else { - WARN("dwFlag doesn't tell where to seek to...\n"); - return MCIERR_MISSING_PARAMETER; - } - - TRACE("Seeking to position=%u bytes\n", wmw->dwPosition); - - if (dwFlags & MCI_NOTIFY) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL); - } + position = wmw->ckWaveData.cksize; } - return ret; + /* Seek rounds down, unless at end */ + if (position != wmw->ckWaveData.cksize) { + position /= wmw->lpWaveFormat->nBlockAlign; + position *= wmw->lpWaveFormat->nBlockAlign; + } + wmw->dwPosition = position; + TRACE("Seeking to position=%u bytes\n", position); + + if (dwFlags & MCI_NOTIFY) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); + + return MMSYSERR_NOERROR; } /************************************************************************** @@ -1253,30 +1345,40 @@ static DWORD WAVE_mciSet(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpPa TRACE("MCI_WAVE_SET_ANYINPUT !\n"); if (dwFlags & MCI_WAVE_SET_ANYOUTPUT) TRACE("MCI_WAVE_SET_ANYOUTPUT !\n"); + /* Set wave format parameters is refused after Open or Record.*/ + if (dwFlags & MCI_WAVE_SET_FORMATTAG) { + TRACE("MCI_WAVE_SET_FORMATTAG = %d\n", ((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag); + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; + if (((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag != WAVE_FORMAT_PCM) + return MCIERR_OUTOFRANGE; + } if (dwFlags & MCI_WAVE_SET_AVGBYTESPERSEC) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.nAvgBytesPerSec = ((LPMCI_WAVE_SET_PARMS)lpParms)->nAvgBytesPerSec; TRACE("MCI_WAVE_SET_AVGBYTESPERSEC = %d\n", wmw->wfxRef.nAvgBytesPerSec); } if (dwFlags & MCI_WAVE_SET_BITSPERSAMPLE) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.wBitsPerSample = ((LPMCI_WAVE_SET_PARMS)lpParms)->wBitsPerSample; TRACE("MCI_WAVE_SET_BITSPERSAMPLE = %d\n", wmw->wfxRef.wBitsPerSample); } if (dwFlags & MCI_WAVE_SET_BLOCKALIGN) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.nBlockAlign = ((LPMCI_WAVE_SET_PARMS)lpParms)->nBlockAlign; TRACE("MCI_WAVE_SET_BLOCKALIGN = %d\n", wmw->wfxRef.nBlockAlign); } if (dwFlags & MCI_WAVE_SET_CHANNELS) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.nChannels = ((LPMCI_WAVE_SET_PARMS)lpParms)->nChannels; TRACE("MCI_WAVE_SET_CHANNELS = %d\n", wmw->wfxRef.nChannels); } - if (dwFlags & MCI_WAVE_SET_FORMATTAG) { - wmw->wfxRef.wFormatTag = ((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag; - TRACE("MCI_WAVE_SET_FORMATTAG = %d\n", wmw->wfxRef.wFormatTag); - } if (dwFlags & MCI_WAVE_SET_SAMPLESPERSEC) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.nSamplesPerSec = ((LPMCI_WAVE_SET_PARMS)lpParms)->nSamplesPerSec; TRACE("MCI_WAVE_SET_SAMPLESPERSEC = %d\n", wmw->wfxRef.nSamplesPerSec); } + if (dwFlags & MCI_NOTIFY) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return 0; } @@ -1287,7 +1389,6 @@ static DWORD WAVE_mciSave(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SAVE_PARMSW l { WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); DWORD ret = MCIERR_FILE_NOT_SAVED, tmpRet; - WPARAM wparam = MCI_NOTIFY_FAILURE; TRACE("%d, %08X, %p);\n", wDevID, dwFlags, lpParms); if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; @@ -1318,16 +1419,14 @@ static DWORD WAVE_mciSave(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SAVE_PARMSW l DeleteFileW (lpParms->lpfilename); SetLastError(tmpRet); - if (0 == mmioRenameW(wmw->openParms.lpstrElementName, lpParms->lpfilename, 0, 0 )) { + /* FIXME: Open file.wav; Save; must not rename the original file. + * Nor must Save a.wav; Save b.wav rename a. */ + if (0 == mmioRenameW(wmw->lpFileName, lpParms->lpfilename, 0, 0 )) { ret = MMSYSERR_NOERROR; } - if (dwFlags & MCI_NOTIFY) { - if (ret == MMSYSERR_NOERROR) wparam = MCI_NOTIFY_SUCCESSFUL; - - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, wparam); - } + if (MMSYSERR_NOERROR==ret && (dwFlags & MCI_NOTIFY)) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); if (ret == MMSYSERR_NOERROR) ret = WAVE_mciOpenFile(wmw, lpParms->lpfilename); @@ -1413,71 +1512,47 @@ static DWORD WAVE_mciStatus(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_STATUS_PARM lpParms->dwReturn = id; } else { lpParms->dwReturn = 0; - ret = MCIERR_WAVE_INPUTUNSPECIFIED; + ret = MCIERR_WAVE_OUTPUTUNSPECIFIED; } } break; + /* It is always ok to query wave format parameters, + * except on auto-open yield MCIERR_UNSUPPORTED_FUNCTION. */ case MCI_WAVE_STATUS_AVGBYTESPERSEC: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->nAvgBytesPerSec; - TRACE("MCI_WAVE_STATUS_AVGBYTESPERSEC => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_STATUS_AVGBYTESPERSEC => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_BITSPERSAMPLE: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->wBitsPerSample; - TRACE("MCI_WAVE_STATUS_BITSPERSAMPLE => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_STATUS_BITSPERSAMPLE => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_BLOCKALIGN: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->nBlockAlign; - TRACE("MCI_WAVE_STATUS_BLOCKALIGN => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_STATUS_BLOCKALIGN => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_CHANNELS: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->nChannels; - TRACE("MCI_WAVE_STATUS_CHANNELS => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_STATUS_CHANNELS => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_FORMATTAG: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->wFormatTag; - TRACE("MCI_WAVE_FORMATTAG => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_FORMATTAG => %lu\n", lpParms->dwReturn); + break; + case MCI_WAVE_STATUS_SAMPLESPERSEC: + lpParms->dwReturn = wmw->lpWaveFormat->nSamplesPerSec; + TRACE("MCI_WAVE_STATUS_SAMPLESPERSEC => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_LEVEL: TRACE("MCI_WAVE_STATUS_LEVEL !\n"); lpParms->dwReturn = 0xAAAA5555; break; - case MCI_WAVE_STATUS_SAMPLESPERSEC: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } - lpParms->dwReturn = wmw->lpWaveFormat->nSamplesPerSec; - TRACE("MCI_WAVE_STATUS_SAMPLESPERSEC => %lu\n", lpParms->dwReturn); - break; default: WARN("unknown command %08X !\n", lpParms->dwItem); return MCIERR_UNRECOGNIZED_COMMAND; } } - if (dwFlags & MCI_NOTIFY) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL); - } + if ((dwFlags & MCI_NOTIFY) && HRESULT_CODE(ret)==0) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return ret; } @@ -1534,10 +1609,10 @@ static DWORD WAVE_mciGetDevCaps(MCIDEVICEID wDevID, DWORD dwFlags, ret = MCI_RESOURCE_RETURNED; break; case MCI_WAVE_GETDEVCAPS_INPUTS: - lpParms->dwReturn = 1; + lpParms->dwReturn = waveInGetNumDevs(); break; case MCI_WAVE_GETDEVCAPS_OUTPUTS: - lpParms->dwReturn = 1; + lpParms->dwReturn = waveOutGetNumDevs(); break; default: FIXME("Unknown capability (%08x) !\n", lpParms->dwItem); @@ -1547,6 +1622,8 @@ static DWORD WAVE_mciGetDevCaps(MCIDEVICEID wDevID, DWORD dwFlags, WARN("No GetDevCaps-Item !\n"); return MCIERR_UNRECOGNIZED_COMMAND; } + if ((dwFlags & MCI_NOTIFY) && HRESULT_CODE(ret)==0) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return ret; } @@ -1561,9 +1638,10 @@ static DWORD WAVE_mciInfo(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW l TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); - if (lpParms == NULL || lpParms->lpstrReturn == NULL) { - ret = MCIERR_NULL_PARAMETER_BLOCK; - } else if (wmw == NULL) { + if (!lpParms || !lpParms->lpstrReturn) + return MCIERR_NULL_PARAMETER_BLOCK; + + if (wmw == NULL) { ret = MCIERR_INVALID_DEVICE_ID; } else { static const WCHAR wszAudio [] = {'W','i','n','e','\'','s',' ','a','u','d','i','o',' ','p','l','a','y','e','r',0}; @@ -1574,7 +1652,7 @@ static DWORD WAVE_mciInfo(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW l switch (dwFlags & ~(MCI_WAIT|MCI_NOTIFY)) { case MCI_INFO_PRODUCT: str = wszAudio; break; - case MCI_INFO_FILE: str = wmw->openParms.lpstrElementName; break; + case MCI_INFO_FILE: str = wmw->lpFileName; break; case MCI_WAVE_INPUT: str = wszWaveIn; break; case MCI_WAVE_OUTPUT: str = wszWaveOut; break; default: @@ -1591,7 +1669,8 @@ static DWORD WAVE_mciInfo(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW l } else { lpParms->lpstrReturn[0] = 0; } - + if (MMSYSERR_NOERROR==ret && (dwFlags & MCI_NOTIFY)) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return ret; } @@ -1612,7 +1691,7 @@ LRESULT CALLBACK MCIWAVE_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, case DRV_ENABLE: return 1; case DRV_DISABLE: return 1; case DRV_QUERYCONFIGURE: return 1; - case DRV_CONFIGURE: MessageBoxA(0, "Sample MultiMedia Driver !", "OSS Driver", MB_OK); return 1; + case DRV_CONFIGURE: MessageBoxA(0, "MCI waveaudio Driver !", "Wine Driver", MB_OK); return 1; case DRV_INSTALL: return DRVCNF_RESTART; case DRV_REMOVE: return DRVCNF_RESTART; } @@ -1623,8 +1702,8 @@ LRESULT CALLBACK MCIWAVE_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, case MCI_OPEN_DRIVER: return WAVE_mciOpen (dwDevID, dwParam1, (LPMCI_WAVE_OPEN_PARMSW) dwParam2); case MCI_CLOSE_DRIVER: return WAVE_mciClose (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2); case MCI_CUE: return WAVE_mciCue (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2); - case MCI_PLAY: return WAVE_mciPlay (dwDevID, dwParam1, (LPMCI_PLAY_PARMS) dwParam2); - case MCI_RECORD: return WAVE_mciRecord (dwDevID, dwParam1, (LPMCI_RECORD_PARMS) dwParam2); + case MCI_PLAY: return WAVE_mciPlay (dwDevID, dwParam1, dwParam2, NULL); + case MCI_RECORD: return WAVE_mciRecord (dwDevID, dwParam1, dwParam2, NULL); case MCI_STOP: return WAVE_mciStop (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2); case MCI_SET: return WAVE_mciSet (dwDevID, dwParam1, (LPMCI_SET_PARMS) dwParam2); case MCI_PAUSE: return WAVE_mciPause (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2); From cc1ac868057cad03e75e24c21482ce9f6e671f41 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:46:57 +0000 Subject: [PATCH 143/211] [TAPI32] sync tapi32 to wine 1.1.40 svn path=/trunk/; revision=45929 --- reactos/dll/win32/tapi32/line.c | 90 +++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/reactos/dll/win32/tapi32/line.c b/reactos/dll/win32/tapi32/line.c index 214e504c084..6ccdf13eb0a 100644 --- a/reactos/dll/win32/tapi32/line.c +++ b/reactos/dll/win32/tapi32/line.c @@ -53,12 +53,21 @@ DWORD WINAPI lineAccept(HCALL hCall, LPCSTR lpsUserUserInfo, DWORD dwSize) } /*********************************************************************** - * lineAddProvider (TAPI32.@) + * lineAddProviderA (TAPI32.@) */ DWORD WINAPI lineAddProviderA(LPCSTR lpszProviderName, HWND hwndOwner, LPDWORD lpdwPermanentProviderID) { FIXME("(%s, %p, %p): stub.\n", lpszProviderName, hwndOwner, lpdwPermanentProviderID); - return 1; + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineAddProviderW (TAPI32.@) + */ +DWORD WINAPI lineAddProviderW(LPCWSTR lpszProviderName, HWND hwndOwner, LPDWORD lpdwPermanentProviderID) +{ + FIXME("(%s, %p, %p): stub.\n", wine_dbgstr_w(lpszProviderName), hwndOwner, lpdwPermanentProviderID); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** @@ -457,12 +466,25 @@ DWORD WINAPI lineGetCountryA(DWORD dwCountryID, DWORD dwAPIVersion, LPLINECOUNTR } /*********************************************************************** - * lineGetDevCaps (TAPI32.@) + * lineGetDevCapsW (TAPI32.@) */ -DWORD WINAPI lineGetDevCapsA(HLINEAPP hLineApp, DWORD dwDeviceID, DWORD dwAPIVersion, DWORD dwExtVersion, LPLINEDEVCAPS lpLineDevCaps) +DWORD WINAPI lineGetDevCapsW(HLINEAPP hLineApp, DWORD dwDeviceID, DWORD dwAPIVersion, + DWORD dwExtVersion, LPLINEDEVCAPS lpLineDevCaps) { - FIXME("(%p, %08x, %08x, %08x, %p): stub.\n", hLineApp, dwDeviceID, dwAPIVersion, dwExtVersion, lpLineDevCaps); - return 0; + FIXME("(%p, %08x, %08x, %08x, %p): stub.\n", hLineApp, dwDeviceID, dwAPIVersion, + dwExtVersion, lpLineDevCaps); + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineGetDevCapsA (TAPI32.@) + */ +DWORD WINAPI lineGetDevCapsA(HLINEAPP hLineApp, DWORD dwDeviceID, DWORD dwAPIVersion, + DWORD dwExtVersion, LPLINEDEVCAPS lpLineDevCaps) +{ + FIXME("(%p, %08x, %08x, %08x, %p): stub.\n", hLineApp, dwDeviceID, dwAPIVersion, + dwExtVersion, lpLineDevCaps); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** @@ -475,12 +497,26 @@ DWORD WINAPI lineGetDevConfigA(DWORD dwDeviceID, LPVARSTRING lpDeviceConfig, LPC } /*********************************************************************** - * lineGetID (TAPI32.@) + * lineGetIDW (TAPI32.@) */ -DWORD WINAPI lineGetIDA(HLINE hLine, DWORD dwAddressID, HCALL hCall, DWORD dwSelect, LPVARSTRING lpDeviceID, LPCSTR lpszDeviceClass) +DWORD WINAPI lineGetIDW(HLINE hLine, DWORD dwAddressID, HCALL hCall, DWORD dwSelect, + LPVARSTRING lpDeviceID, LPCWSTR lpszDeviceClass) { - FIXME("(%p, %08x, %p, %08x, %p, %s): stub.\n", hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass); - return 0; + FIXME("(%p, %08x, %p, %08x, %p, %s): stub.\n", hLine, dwAddressID, hCall, + dwSelect, lpDeviceID, + debugstr_w(lpszDeviceClass)); + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineGetIDA (TAPI32.@) + */ +DWORD WINAPI lineGetIDA(HLINE hLine, DWORD dwAddressID, HCALL hCall, DWORD dwSelect, + LPVARSTRING lpDeviceID, LPCSTR lpszDeviceClass) +{ + FIXME("(%p, %08x, %p, %08x, %p, %s): stub.\n", hLine, dwAddressID, hCall, + dwSelect, lpDeviceID, lpszDeviceClass); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** @@ -520,12 +556,21 @@ DWORD WINAPI lineGetNumRings(HLINE hLine, DWORD dwAddressID, LPDWORD lpdwNumRing } /*********************************************************************** - * lineGetProviderList (TAPI32.@) + * lineGetProviderListA (TAPI32.@) */ DWORD WINAPI lineGetProviderListA(DWORD dwAPIVersion, LPLINEPROVIDERLIST lpProviderList) { FIXME("(%08x, %p): stub.\n", dwAPIVersion, lpProviderList); - return 0; + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineGetProviderListW (TAPI32.@) + */ +DWORD WINAPI lineGetProviderListW(DWORD dwAPIVersion, LPLINEPROVIDERLIST lpProviderList) +{ + FIXME("(%08x, %p): stub.\n", dwAPIVersion, lpProviderList); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** @@ -974,12 +1019,25 @@ LONG WINAPI lineInitializeExA(LPHLINEAPP lphLineApp, HINSTANCE hInstance, LINECA } /*********************************************************************** - * lineMakeCall (TAPI32.@) + * lineMakeCallW (TAPI32.@) */ -DWORD WINAPI lineMakeCallA(HLINE hLine, LPHCALL lphCall, LPCSTR lpszDestAddress, DWORD dwCountryCode, LPLINECALLPARAMS lpCallParams) +DWORD WINAPI lineMakeCallW(HLINE hLine, LPHCALL lphCall, LPCWSTR lpszDestAddress, + DWORD dwCountryCode, LPLINECALLPARAMS lpCallParams) { - FIXME("(%p, %p, %s, %08x, %p): stub.\n", hLine, lphCall, lpszDestAddress, dwCountryCode, lpCallParams); - return 1; + FIXME("(%p, %p, %s, %08x, %p): stub.\n", hLine, lphCall, debugstr_w(lpszDestAddress), + dwCountryCode, lpCallParams); + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineMakeCallA (TAPI32.@) + */ +DWORD WINAPI lineMakeCallA(HLINE hLine, LPHCALL lphCall, LPCSTR lpszDestAddress, + DWORD dwCountryCode, LPLINECALLPARAMS lpCallParams) +{ + FIXME("(%p, %p, %s, %08x, %p): stub.\n", hLine, lphCall, lpszDestAddress, + dwCountryCode, lpCallParams); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** From 750f99a535811227593c813a816431263c89afc7 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:48:13 +0000 Subject: [PATCH 144/211] [URLMON] sync urlmon to wine 1.1.40 svn path=/trunk/; revision=45930 --- reactos/dll/win32/urlmon/umon.c | 11 +++++++++++ reactos/dll/win32/urlmon/urlmon.spec | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/urlmon/umon.c b/reactos/dll/win32/urlmon/umon.c index e6e20b9d11c..5e6a8f6c21f 100644 --- a/reactos/dll/win32/urlmon/umon.c +++ b/reactos/dll/win32/urlmon/umon.c @@ -755,3 +755,14 @@ HRESULT WINAPI GetSoftwareUpdateInfo( LPCWSTR szDistUnit, LPSOFTDISTINFO psdi ) FIXME("%s %p\n", debugstr_w(szDistUnit), psdi ); return E_FAIL; } + +/*********************************************************************** + * AsyncInstallDistributionUnit (URLMON.@) + */ +HRESULT WINAPI AsyncInstallDistributionUnit( LPCWSTR szDistUnit, LPCWSTR szTYPE, + LPCWSTR szExt, DWORD dwFileVersionMS, DWORD dwFileVersionLS, + LPCWSTR szURL, IBindCtx *pbc, LPVOID pvReserved, DWORD flags ) +{ + FIXME(": stub\n"); + return E_NOTIMPL; +} diff --git a/reactos/dll/win32/urlmon/urlmon.spec b/reactos/dll/win32/urlmon/urlmon.spec index dbb8fa974c6..a67004a9b0b 100644 --- a/reactos/dll/win32/urlmon/urlmon.spec +++ b/reactos/dll/win32/urlmon/urlmon.spec @@ -6,7 +6,7 @@ #3 stub IsJITInProgress @ stub AsyncGetClassBits -@ stub AsyncInstallDistributionUnit +@ stdcall AsyncInstallDistributionUnit(ptr ptr ptr long long ptr ptr ptr long) @ stdcall BindAsyncMoniker(ptr long ptr ptr ptr) @ stdcall CoGetClassObjectFromURL(ptr wstr long long wstr ptr long ptr ptr ptr) @ stub CoInstall From feebaff19f7b1b96d0447bd887663984a40dc77d Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:53:26 +0000 Subject: [PATCH 145/211] [WIDL] sync widl to wine 1.1.40 svn path=/trunk/; revision=45931 --- reactos/tools/widl/parser.tab.c | 1 + reactos/tools/widl/parser.y | 1 + 2 files changed, 2 insertions(+) diff --git a/reactos/tools/widl/parser.tab.c b/reactos/tools/widl/parser.tab.c index cdb7eeb41a1..2dcd1ef2291 100644 --- a/reactos/tools/widl/parser.tab.c +++ b/reactos/tools/widl/parser.tab.c @@ -6510,6 +6510,7 @@ static void check_field_common(const type_t *container_type, default: /* should be no other container types */ assert(0); + return; } if (is_attr(arg->attrs, ATTR_LENGTHIS) && diff --git a/reactos/tools/widl/parser.y b/reactos/tools/widl/parser.y index 2af7742d172..71b7ed69142 100644 --- a/reactos/tools/widl/parser.y +++ b/reactos/tools/widl/parser.y @@ -2348,6 +2348,7 @@ static void check_field_common(const type_t *container_type, default: /* should be no other container types */ assert(0); + return; } if (is_attr(arg->attrs, ATTR_LENGTHIS) && From 8fc089778a7b46ef179a90ec21c712ce29712dab Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 12:53:36 +0000 Subject: [PATCH 146/211] [UXTHEME] sync uxtheme to wine 1.1.40 svn path=/trunk/; revision=45932 --- reactos/dll/win32/uxtheme/draw.c | 5 ++--- reactos/dll/win32/uxtheme/msstyles.c | 12 +++++++++--- reactos/dll/win32/uxtheme/system.c | 7 ++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/reactos/dll/win32/uxtheme/draw.c b/reactos/dll/win32/uxtheme/draw.c index 9e220254db3..17900f8352b 100644 --- a/reactos/dll/win32/uxtheme/draw.c +++ b/reactos/dll/win32/uxtheme/draw.c @@ -56,7 +56,7 @@ HRESULT WINAPI EnableThemeDialogTexture(HWND hwnd, DWORD dwFlags) TRACE("(%p,0x%08x\n", hwnd, dwFlags); res = SetPropW (hwnd, (LPCWSTR)MAKEINTATOM(atDialogThemeEnabled), - (HANDLE)(dwFlags|0x80000000)); + UlongToHandle(dwFlags|0x80000000)); /* 0x80000000 serves as a "flags set" flag */ if (!res) return HRESULT_FROM_WIN32(GetLastError()); @@ -74,8 +74,7 @@ BOOL WINAPI IsThemeDialogTextureEnabled(HWND hwnd) DWORD dwDialogTextureFlags; TRACE("(%p)\n", hwnd); - dwDialogTextureFlags = (DWORD)GetPropW (hwnd, - (LPCWSTR)MAKEINTATOM(atDialogThemeEnabled)); + dwDialogTextureFlags = HandleToUlong( GetPropW( hwnd, (LPCWSTR)MAKEINTATOM(atDialogThemeEnabled) )); if (dwDialogTextureFlags == 0) /* Means EnableThemeDialogTexture wasn't called for this dialog */ return TRUE; diff --git a/reactos/dll/win32/uxtheme/msstyles.c b/reactos/dll/win32/uxtheme/msstyles.c index 825645d2f4b..0adb70d529a 100644 --- a/reactos/dll/win32/uxtheme/msstyles.c +++ b/reactos/dll/win32/uxtheme/msstyles.c @@ -364,7 +364,10 @@ static BOOL MSSTYLES_ParseIniSectionName(LPCWSTR lpSection, DWORD dwLen, LPWSTR lstrcpynW(part, comp, sizeof(part)/sizeof(part[0])); comp = tmp; /* now get the state */ - *strchrW(comp, ')') = 0; + tmp = strchrW(comp, ')'); + if (!tmp) + return FALSE; + *tmp = 0; lstrcpynW(state, comp, sizeof(state)/sizeof(state[0])); } else { @@ -378,7 +381,10 @@ static BOOL MSSTYLES_ParseIniSectionName(LPCWSTR lpSection, DWORD dwLen, LPWSTR lstrcpynW(szClassName, comp, MAX_THEME_CLASS_NAME); comp = tmp; /* now get the state */ - *strchrW(comp, ')') = 0; + tmp = strchrW(comp, ')'); + if (!tmp) + return FALSE; + *tmp = 0; lstrcpynW(state, comp, sizeof(state)/sizeof(state[0])); } else { @@ -1087,7 +1093,7 @@ static BOOL prepare_alpha (HBITMAP bmp, BOOL* hasAlpha) *hasAlpha = TRUE; p = dib.dsBm.bmBits; - n = abs(dib.dsBmih.biHeight) * dib.dsBmih.biWidth; + n = dib.dsBmih.biHeight * dib.dsBmih.biWidth; /* AlphaBlend() wants premultiplied alpha, so do that now */ while (n-- > 0) { diff --git a/reactos/dll/win32/uxtheme/system.c b/reactos/dll/win32/uxtheme/system.c index 28395393729..b84e978dba8 100644 --- a/reactos/dll/win32/uxtheme/system.c +++ b/reactos/dll/win32/uxtheme/system.c @@ -393,8 +393,7 @@ static void UXTHEME_RestoreSystemMetrics(void) if (RegQueryValueExW (hKey, bsp->keyName, 0, &type, (LPBYTE)&value, &count) == ERROR_SUCCESS) { - SystemParametersInfoW (bsp->spiSet, 0, (LPVOID)value, - SPIF_UPDATEINIFILE); + SystemParametersInfoW (bsp->spiSet, 0, UlongToPtr(value), SPIF_UPDATEINIFILE); } bsp++; @@ -445,9 +444,7 @@ static void UXTHEME_SaveSystemMetrics(void) DWORD value; SystemParametersInfoW (bsp->spiGet, 0, &value, 0); - SystemParametersInfoW (bsp->spiSet, 0, (LPVOID)value, - SPIF_UPDATEINIFILE); - + SystemParametersInfoW (bsp->spiSet, 0, UlongToPtr(value), SPIF_UPDATEINIFILE); bsp++; } From 3bdf74f576fb44e33e7bcde4ebb101c83279bc6a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 13:20:39 +0000 Subject: [PATCH 147/211] [MSVCRT_WINETEST] sync msvcrt_winetest to wine 1.1.40 svn path=/trunk/; revision=45933 --- rostests/winetests/msvcrt/string.c | 122 +++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/rostests/winetests/msvcrt/string.c b/rostests/winetests/msvcrt/string.c index 85447355027..a7b34047afe 100644 --- a/rostests/winetests/msvcrt/string.c +++ b/rostests/winetests/msvcrt/string.c @@ -345,6 +345,29 @@ static void test_mbcp(void) else skip("Current locale has double-byte charset - could leave to false positives\n"); + _setmbcp(1361); + expect_eq(_ismbblead(0x80), 0, int, "%d"); + todo_wine { + expect_eq(_ismbblead(0x81), 1, int, "%d"); + expect_eq(_ismbblead(0x83), 1, int, "%d"); + } + expect_eq(_ismbblead(0x84), 1, int, "%d"); + expect_eq(_ismbblead(0xd3), 1, int, "%d"); + expect_eq(_ismbblead(0xd7), 0, int, "%d"); + todo_wine { + expect_eq(_ismbblead(0xd8), 1, int, "%d"); + } + expect_eq(_ismbblead(0xd9), 1, int, "%d"); + + expect_eq(_ismbbtrail(0x30), 0, int, "%d"); + expect_eq(_ismbbtrail(0x31), 1, int, "%d"); + expect_eq(_ismbbtrail(0x7e), 1, int, "%d"); + expect_eq(_ismbbtrail(0x7f), 0, int, "%d"); + expect_eq(_ismbbtrail(0x80), 0, int, "%d"); + expect_eq(_ismbbtrail(0x81), 1, int, "%d"); + expect_eq(_ismbbtrail(0xfe), 1, int, "%d"); + expect_eq(_ismbbtrail(0xff), 0, int, "%d"); + _setmbcp(curr_mbcp); } @@ -707,6 +730,103 @@ static void test_mbcjisjms(void) } while(jisjms[i++][0] != 0); } +static void test_mbctombb(void) +{ + static const unsigned int mbcmbb_932[][2] = { + {0x829e, 0x829e}, {0x829f, 0xa7}, {0x82f1, 0xdd}, {0x82f2, 0x82f2}, + {0x833f, 0x833f}, {0x8340, 0xa7}, {0x837e, 0xd0}, {0x837f, 0x837f}, + {0x8380, 0xd1}, {0x8396, 0xb9}, {0x8397, 0x8397}, {0x813f, 0x813f}, + {0x8140, 0x20}, {0x814c, 0x814c}, {0x814f, 0x5e}, {0x8197, 0x40}, + {0x8198, 0x8198}, {0x8258, 0x39}, {0x8259, 0x8259}, {0x825f, 0x825f}, + {0x8260, 0x41}, {0x82f1, 0xdd}, {0x82f2, 0x82f2}, {0,0}}; + unsigned int exp, ret, i; + unsigned int prev_cp = _getmbcp(); + + _setmbcp(932); + for (i = 0; mbcmbb_932[i][0] != 0; i++) + { + ret = _mbctombb(mbcmbb_932[i][0]); + exp = mbcmbb_932[i][1]; + ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret); + } + _setmbcp(prev_cp); +} + +static void test_ismbclegal(void) { + unsigned int prev_cp = _getmbcp(); + int ret, exp, err; + unsigned int i; + + _setmbcp(932); /* Japanese */ + err = 0; + for(i = 0; i < 0x10000; i++) { + ret = _ismbclegal(i); + exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0x9F) || + (HIBYTE(i) >= 0xE0 && HIBYTE(i) <= 0xFC)) && + ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) || + (LOBYTE(i) >= 0x80 && LOBYTE(i) <= 0xFC)); + if(ret != exp) { + err = 1; + break; + } + } + ok(!err, "_ismbclegal (932) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i); + _setmbcp(936); /* Chinese (GBK) */ + err = 0; + for(i = 0; i < 0x10000; i++) { + ret = _ismbclegal(i); + exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE && + LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0xFE; + if(ret != exp) { + err = 1; + break; + } + } + ok(!err, "_ismbclegal (936) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i); + _setmbcp(949); /* Korean */ + err = 0; + for(i = 0; i < 0x10000; i++) { + ret = _ismbclegal(i); + exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE && + LOBYTE(i) >= 0x41 && LOBYTE(i) <= 0xFE; + if(ret != exp) { + err = 1; + break; + } + } + ok(!err, "_ismbclegal (949) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i); + _setmbcp(950); /* Chinese (Big5) */ + err = 0; + for(i = 0; i < 0x10000; i++) { + ret = _ismbclegal(i); + exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE && + ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) || + (LOBYTE(i) >= 0xA1 && LOBYTE(i) <= 0xFE)); + if(ret != exp) { + err = 1; + break; + } + } + ok(!err, "_ismbclegal (950) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i); + _setmbcp(1361); /* Korean (Johab) */ + err = 0; + for(i = 0; i < 0x10000; i++) { + ret = _ismbclegal(i); + exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xD3) || + (HIBYTE(i) >= 0xD8 && HIBYTE(i) <= 0xF9)) && + ((LOBYTE(i) >= 0x31 && LOBYTE(i) <= 0x7E) || + (LOBYTE(i) >= 0x81 && LOBYTE(i) <= 0xFE)) && + HIBYTE(i) != 0xDF; + if(ret != exp) { + err = 1; + break; + } + } + todo_wine ok(!err, "_ismbclegal (1361) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i); + + _setmbcp(prev_cp); +} + static const struct { const char* string; const char* delimiter; @@ -833,6 +953,8 @@ START_TEST(string) test_strcat_s(); test__mbsnbcpy_s(); test_mbcjisjms(); + test_mbctombb(); + test_ismbclegal(); test_strtok(); test_wcscpy_s(); test__wcsupr_s(); From 3ee840b9020caab191e54b3ec7efe84976784e9e Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 13:22:03 +0000 Subject: [PATCH 148/211] [MSXML3_WINETEST] sync msxml3_winetest to wine 1.1.40 svn path=/trunk/; revision=45934 --- rostests/winetests/msxml3/domdoc.c | 126 ++++++++++++++++++++++++----- 1 file changed, 104 insertions(+), 22 deletions(-) diff --git a/rostests/winetests/msxml3/domdoc.c b/rostests/winetests/msxml3/domdoc.c index e2de5df75b8..5f06d93f381 100644 --- a/rostests/winetests/msxml3/domdoc.c +++ b/rostests/winetests/msxml3/domdoc.c @@ -639,6 +639,9 @@ static void test_domdoc( void ) r = IXMLDOMElement_QueryInterface( element, &IID_IObjectIdentity, (LPVOID*)&ident ); ok( r == E_NOINTERFACE, "ret %08x\n", r); + r = IXMLDOMElement_get_tagName( element, NULL ); + ok( r == E_INVALIDARG, "ret %08x\n", r); + /* check if the tag is correct */ r = IXMLDOMElement_get_tagName( element, &tag ); ok( r == S_OK, "couldn't get tag name\n"); @@ -5289,6 +5292,41 @@ static void test_put_nodeValue(void) IXMLDOMDocument_Release(doc); } +static void test_IObjectSafety_set(IObjectSafety *safety, HRESULT result, HRESULT result2, DWORD set, DWORD mask, DWORD expected, DWORD expected2) +{ + HRESULT hr; + DWORD enabled, supported; + + trace("testing IObjectSafety: enable=%08x, mask=%08x\n", set, mask); + + hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, set, mask); + if (result == result2) + ok(hr == result, "SetInterfaceSafetyOptions: expected %08x, returned %08x\n", result, hr ); + else + ok(broken(hr == result) || hr == result2, + "SetInterfaceSafetyOptions: expected %08x, got %08x\n", result2, hr ); + + supported = enabled = 0xCAFECAFE; + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); + ok(hr == S_OK, "ret %08x\n", hr ); + if (expected == expected2) + ok(enabled == expected, "Expected %08x, got %08x\n", expected, enabled); + else + ok(broken(enabled == expected) || enabled == expected2, + "Expected %08x, got %08x\n", expected2, enabled); + + /* reset the safety options */ + + hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, + INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER, + 0); + ok(hr == S_OK, "ret %08x\n", hr ); + + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(enabled == 0, "Expected 0, got %08x\n", enabled); +} + static void test_document_IObjectSafety(void) { IXMLDOMDocument *doc; @@ -5311,41 +5349,85 @@ static void test_document_IObjectSafety(void) hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); ok(hr == S_OK, "ret %08x\n", hr ); - ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA), - "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA)," + ok(broken(supported == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA)) || + supported == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER) /* msxml3 SP8+ */, + "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), " "got %08x\n", supported); ok(enabled == 0, "Expected 0, got %08x\n", enabled); - /* set */ - hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, - INTERFACESAFE_FOR_UNTRUSTED_CALLER, - INTERFACESAFE_FOR_UNTRUSTED_CALLER); - ok(hr == S_OK, "ret %08x\n", hr ); - hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); - ok(hr == S_OK, "ret %08x\n", hr ); - ok(enabled == INTERFACESAFE_FOR_UNTRUSTED_CALLER, - "Expected INTERFACESAFE_FOR_UNTRUSTED_CALLER, got %08x\n", enabled); - /* set unsupported */ - hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, - INTERFACE_USES_SECURITY_MANAGER | - INTERFACESAFE_FOR_UNTRUSTED_CALLER, - INTERFACE_USES_SECURITY_MANAGER); - ok(hr == S_OK, "ret %08x\n", hr ); - hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); - ok(hr == S_OK, "ret %08x\n", hr ); - ok(enabled == 0, "Expected 0, got %08x\n", enabled); + + /* set -- individual flags */ + + test_IObjectSafety_set(safety, S_OK, S_OK, + INTERFACESAFE_FOR_UNTRUSTED_CALLER, INTERFACESAFE_FOR_UNTRUSTED_CALLER, + INTERFACESAFE_FOR_UNTRUSTED_CALLER, INTERFACESAFE_FOR_UNTRUSTED_CALLER); + + test_IObjectSafety_set(safety, S_OK, S_OK, + INTERFACESAFE_FOR_UNTRUSTED_DATA, INTERFACESAFE_FOR_UNTRUSTED_DATA, + INTERFACESAFE_FOR_UNTRUSTED_DATA, INTERFACESAFE_FOR_UNTRUSTED_DATA); + + test_IObjectSafety_set(safety, S_OK, S_OK, + INTERFACE_USES_SECURITY_MANAGER, INTERFACE_USES_SECURITY_MANAGER, + 0, INTERFACE_USES_SECURITY_MANAGER /* msxml3 SP8+ */); + + /* set INTERFACE_USES_DISPEX */ + + test_IObjectSafety_set(safety, S_OK, E_FAIL /* msxml3 SP8+ */, + INTERFACE_USES_DISPEX, INTERFACE_USES_DISPEX, + 0, 0); + + test_IObjectSafety_set(safety, S_OK, E_FAIL /* msxml3 SP8+ */, + INTERFACE_USES_DISPEX, 0, + 0, 0); + + test_IObjectSafety_set(safety, S_OK, S_OK /* msxml3 SP8+ */, + 0, INTERFACE_USES_DISPEX, + 0, 0); + + /* set option masking */ + + test_IObjectSafety_set(safety, S_OK, S_OK, + INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA, + INTERFACESAFE_FOR_UNTRUSTED_CALLER, + INTERFACESAFE_FOR_UNTRUSTED_CALLER, + INTERFACESAFE_FOR_UNTRUSTED_CALLER); + + test_IObjectSafety_set(safety, S_OK, S_OK, + INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA, + INTERFACESAFE_FOR_UNTRUSTED_DATA, + INTERFACESAFE_FOR_UNTRUSTED_DATA, + INTERFACESAFE_FOR_UNTRUSTED_DATA); + + test_IObjectSafety_set(safety, S_OK, S_OK, + INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA, + INTERFACE_USES_SECURITY_MANAGER, + 0, + 0); + + /* set -- inheriting previous settings */ hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, INTERFACESAFE_FOR_UNTRUSTED_CALLER, INTERFACESAFE_FOR_UNTRUSTED_CALLER); ok(hr == S_OK, "ret %08x\n", hr ); + hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); + ok(hr == S_OK, "ret %08x\n", hr ); + todo_wine + ok(broken(enabled == INTERFACESAFE_FOR_UNTRUSTED_CALLER) || + enabled == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACE_USES_SECURITY_MANAGER) /* msxml3 SP8+ */, + "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACE_USES_SECURITY_MANAGER), " + "got %08x\n", enabled); + hr = IObjectSafety_SetInterfaceSafetyOptions(safety, NULL, INTERFACESAFE_FOR_UNTRUSTED_DATA, INTERFACESAFE_FOR_UNTRUSTED_DATA); ok(hr == S_OK, "ret %08x\n", hr ); hr = IObjectSafety_GetInterfaceSafetyOptions(safety, NULL, &supported, &enabled); ok(hr == S_OK, "ret %08x\n", hr ); - ok(enabled == INTERFACESAFE_FOR_UNTRUSTED_DATA, - "Expected INTERFACESAFE_FOR_UNTRUSTED_DATA, got %08x\n", enabled); + todo_wine + ok(broken(enabled == INTERFACESAFE_FOR_UNTRUSTED_DATA) || + enabled == (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA) /* msxml3 SP8+ */, + "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA), " + "got %08x\n", enabled); IObjectSafety_Release(safety); From be0dd1fa5c2d212c5d085c86eaf482282c3898d3 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 13:26:12 +0000 Subject: [PATCH 149/211] [OLEACC] sync oleacc to wine 1.1.40 svn path=/trunk/; revision=45935 --- reactos/dll/win32/oleacc/oleacc.rc | 10 ++- reactos/dll/win32/oleacc/oleacc_De.rc | 94 ++++++++++++++++++++++++++ reactos/dll/win32/oleacc/oleacc_En.rc | 2 + reactos/dll/win32/oleacc/oleacc_Fr.rc | 54 ++++++++------- reactos/dll/win32/oleacc/oleacc_Ko.rc | 2 + reactos/dll/win32/oleacc/oleacc_Lt.rc | 95 +++++++++++++++++++++++++++ reactos/dll/win32/oleacc/oleacc_Nl.rc | 6 +- reactos/dll/win32/oleacc/oleacc_No.rc | 95 +++++++++++++++++++++++++++ reactos/dll/win32/oleacc/oleacc_Pl.rc | 2 + reactos/dll/win32/oleacc/oleacc_Pt.rc | 94 ++++++++++++++++++++++++++ reactos/dll/win32/oleacc/oleacc_Ro.rc | 93 ++++++++++++++++++++++++++ 11 files changed, 520 insertions(+), 27 deletions(-) create mode 100644 reactos/dll/win32/oleacc/oleacc_De.rc create mode 100644 reactos/dll/win32/oleacc/oleacc_Lt.rc create mode 100644 reactos/dll/win32/oleacc/oleacc_No.rc create mode 100644 reactos/dll/win32/oleacc/oleacc_Pt.rc create mode 100644 reactos/dll/win32/oleacc/oleacc_Ro.rc diff --git a/reactos/dll/win32/oleacc/oleacc.rc b/reactos/dll/win32/oleacc/oleacc.rc index fcffbc11ce9..460ff1bf8a1 100644 --- a/reactos/dll/win32/oleacc/oleacc.rc +++ b/reactos/dll/win32/oleacc/oleacc.rc @@ -22,7 +22,15 @@ #include "oleacc.h" #include "oleacc_En.rc" -#include "oleacc_Fr.rc" #include "oleacc_Ko.rc" #include "oleacc_Nl.rc" #include "oleacc_Pl.rc" + +/* UTF-8 */ +#include "oleacc_De.rc" +#include "oleacc_Fr.rc" +#include "oleacc_Lt.rc" +#include "oleacc_No.rc" +#include "oleacc_Pt.rc" +#include "oleacc_Ro.rc" + diff --git a/reactos/dll/win32/oleacc/oleacc_De.rc b/reactos/dll/win32/oleacc/oleacc_De.rc new file mode 100644 index 00000000000..f15cc2dcbba --- /dev/null +++ b/reactos/dll/win32/oleacc/oleacc_De.rc @@ -0,0 +1,94 @@ +/* + * German resources for oleacc + * + * Copyright 2009 André Hentschel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +#pragma code_page(65001) + +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + 0 "unbekanntes Objekt" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "Titelleiste" + ROLE_SYSTEM_MENUBAR "Menüleiste" + ROLE_SYSTEM_SCROLLBAR "Bildlaufleiste" + ROLE_SYSTEM_GRIP "Fangpunkt" + ROLE_SYSTEM_SOUND "Audio" + ROLE_SYSTEM_CURSOR "Cursor" + ROLE_SYSTEM_CARET "Caret-Zeichen" + ROLE_SYSTEM_ALERT "Warnung" + ROLE_SYSTEM_WINDOW "Fenster" + ROLE_SYSTEM_CLIENT "Client" + ROLE_SYSTEM_MENUPOPUP "Kontextmenü" + ROLE_SYSTEM_MENUITEM "Menübefehl" + ROLE_SYSTEM_TOOLTIP "Tooltip" + ROLE_SYSTEM_APPLICATION "Anwendung" + ROLE_SYSTEM_DOCUMENT "Dokument" + ROLE_SYSTEM_PANE "Ausschnitt" + ROLE_SYSTEM_CHART "Diagramm" + ROLE_SYSTEM_DIALOG "Dialog" + ROLE_SYSTEM_BORDER "Rahmen" + ROLE_SYSTEM_GROUPING "Gruppierung" + ROLE_SYSTEM_SEPARATOR "Trennlinie" + ROLE_SYSTEM_TOOLBAR "Symbolleiste" + ROLE_SYSTEM_STATUSBAR "Statusleiste" + ROLE_SYSTEM_TABLE "Tabelle" + ROLE_SYSTEM_COLUMNHEADER "Spaltenkopf" + ROLE_SYSTEM_ROWHEADER "Zeilenkopf" + ROLE_SYSTEM_COLUMN "Spalte" + ROLE_SYSTEM_ROW "Zeile" + ROLE_SYSTEM_CELL "Zelle" + ROLE_SYSTEM_LINK "Link" + ROLE_SYSTEM_HELPBALLOON "Hilfesprechblase" + ROLE_SYSTEM_CHARACTER "Assistent" + ROLE_SYSTEM_LIST "Liste" + ROLE_SYSTEM_LISTITEM "Listenelement" + ROLE_SYSTEM_OUTLINE "Gliederung" + ROLE_SYSTEM_OUTLINEITEM "Gliederungselement" + ROLE_SYSTEM_PAGETAB "Registerkarte" + ROLE_SYSTEM_PROPERTYPAGE "Eigenschaftenseite" + ROLE_SYSTEM_INDICATOR "Anzeige" + ROLE_SYSTEM_GRAPHIC "Grafik" + ROLE_SYSTEM_STATICTEXT "Text" + ROLE_SYSTEM_TEXT "Text" + ROLE_SYSTEM_PUSHBUTTON "Schaltfläche" + ROLE_SYSTEM_CHECKBUTTON "Kontrollkästchen" + ROLE_SYSTEM_RADIOBUTTON "Optionskästchen" + ROLE_SYSTEM_COMBOBOX "Kombinationsfeld" + ROLE_SYSTEM_DROPLIST "Drop Down" + ROLE_SYSTEM_PROGRESSBAR "Fortschrittsanzeige" + ROLE_SYSTEM_DIAL "wählen" + ROLE_SYSTEM_HOTKEYFIELD "Schnellzugriffsfeld" + ROLE_SYSTEM_SLIDER "Schieberegler" + ROLE_SYSTEM_SPINBUTTON "Drehfeld" + ROLE_SYSTEM_DIAGRAM "Diagramm" + ROLE_SYSTEM_ANIMATION "Animation" + ROLE_SYSTEM_EQUATION "Gleichung" + ROLE_SYSTEM_BUTTONDROPDOWN "Dropdown Schaltfläche" + ROLE_SYSTEM_BUTTONMENU "Menü Schaltfläche" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "Raster Dropdown Schaltfläche" + ROLE_SYSTEM_WHITESPACE "Leerzeichen" + ROLE_SYSTEM_PAGETABLIST "Register" + ROLE_SYSTEM_CLOCK "Uhr" + ROLE_SYSTEM_SPLITBUTTON "Trenn Schaltfläche" + ROLE_SYSTEM_IPADDRESS "IP Addresse" + ROLE_SYSTEM_OUTLINEBUTTON "Gliederung Schaltfläche" +} diff --git a/reactos/dll/win32/oleacc/oleacc_En.rc b/reactos/dll/win32/oleacc/oleacc_En.rc index 992d29c93f0..5c1af2de217 100644 --- a/reactos/dll/win32/oleacc/oleacc_En.rc +++ b/reactos/dll/win32/oleacc/oleacc_En.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/oleacc/oleacc_Fr.rc b/reactos/dll/win32/oleacc/oleacc_Fr.rc index 87bea0b5247..8eabc3cd4d5 100644 --- a/reactos/dll/win32/oleacc/oleacc_Fr.rc +++ b/reactos/dll/win32/oleacc/oleacc_Fr.rc @@ -2,6 +2,7 @@ * French resources for oleacc * * Copyright 2008 Jonathan Ernst + * Copyright 2009 Frédéric Delanoy * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,32 +19,37 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { - 0 "objet inconnu" /* undocumented */ + 0 "objet inconnu" /* non documenté */ ROLE_SYSTEM_TITLEBAR "barre de titre" - ROLE_SYSTEM_MENUBAR "barre de menu" + ROLE_SYSTEM_MENUBAR "barre de menus" ROLE_SYSTEM_SCROLLBAR "barre de défilement" - ROLE_SYSTEM_GRIP "grip" + ROLE_SYSTEM_GRIP "poignée" ROLE_SYSTEM_SOUND "son" ROLE_SYSTEM_CURSOR "curseur" - ROLE_SYSTEM_CARET "caret" + ROLE_SYSTEM_CARET "curseur texte" ROLE_SYSTEM_ALERT "alerte" ROLE_SYSTEM_WINDOW "fenêtre" ROLE_SYSTEM_CLIENT "client" - ROLE_SYSTEM_MENUPOPUP "menu popup" + ROLE_SYSTEM_MENUPOPUP "menu contextuel" ROLE_SYSTEM_MENUITEM "élément de menu" ROLE_SYSTEM_TOOLTIP "infobulle" ROLE_SYSTEM_APPLICATION "application" ROLE_SYSTEM_DOCUMENT "document" - ROLE_SYSTEM_PANE "pane" - ROLE_SYSTEM_CHART "chart" + ROLE_SYSTEM_PANE "panneau" + ROLE_SYSTEM_CHART "diagramme" ROLE_SYSTEM_DIALOG "boîte de dialogue" ROLE_SYSTEM_BORDER "bordure" - ROLE_SYSTEM_GROUPING "grouping" - ROLE_SYSTEM_SEPARATOR "separateur" + ROLE_SYSTEM_GROUPING "groupement" + ROLE_SYSTEM_SEPARATOR "séparateur" ROLE_SYSTEM_TOOLBAR "barre d'outils" ROLE_SYSTEM_STATUSBAR "barre d'état" ROLE_SYSTEM_TABLE "table" @@ -57,8 +63,8 @@ STRINGTABLE DISCARDABLE ROLE_SYSTEM_CHARACTER "caractère" ROLE_SYSTEM_LIST "liste" ROLE_SYSTEM_LISTITEM "élément de liste" - ROLE_SYSTEM_OUTLINE "outline" - ROLE_SYSTEM_OUTLINEITEM "outline item" + ROLE_SYSTEM_OUTLINE "plan" + ROLE_SYSTEM_OUTLINEITEM "élément du plan" ROLE_SYSTEM_PAGETAB "onglet de page" ROLE_SYSTEM_PROPERTYPAGE "page de propriétés" ROLE_SYSTEM_INDICATOR "indicateur" @@ -68,23 +74,23 @@ STRINGTABLE DISCARDABLE ROLE_SYSTEM_PUSHBUTTON "bouton pressoir" ROLE_SYSTEM_CHECKBUTTON "case à cocher" ROLE_SYSTEM_RADIOBUTTON "bouton radio" - ROLE_SYSTEM_COMBOBOX "combo box" - ROLE_SYSTEM_DROPLIST "drop down" + ROLE_SYSTEM_COMBOBOX "boîte combinée" + ROLE_SYSTEM_DROPLIST "liste déroulante" ROLE_SYSTEM_PROGRESSBAR "barre de progression" - ROLE_SYSTEM_DIAL "dial" - ROLE_SYSTEM_HOTKEYFIELD "hot key field" - ROLE_SYSTEM_SLIDER "slider" - ROLE_SYSTEM_SPINBUTTON "spin box" + ROLE_SYSTEM_DIAL "cadran" + ROLE_SYSTEM_HOTKEYFIELD "champ avec raccourci clavier" + ROLE_SYSTEM_SLIDER "glissière" + ROLE_SYSTEM_SPINBUTTON "bouton fléché" ROLE_SYSTEM_DIAGRAM "diagramme" ROLE_SYSTEM_ANIMATION "animation" ROLE_SYSTEM_EQUATION "équation" - ROLE_SYSTEM_BUTTONDROPDOWN "drop down button" + ROLE_SYSTEM_BUTTONDROPDOWN "bouton avec liste déroulante" ROLE_SYSTEM_BUTTONMENU "bouton de menu" - ROLE_SYSTEM_BUTTONDROPDOWNGRID "grid drop down button" - ROLE_SYSTEM_WHITESPACE "espace blanc" - ROLE_SYSTEM_PAGETABLIST "page tab list" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "bouton avec grille déroulante" + ROLE_SYSTEM_WHITESPACE "blanc" + ROLE_SYSTEM_PAGETABLIST "liste d'onglets de pages" ROLE_SYSTEM_CLOCK "horloge" - ROLE_SYSTEM_SPLITBUTTON "split button" - ROLE_SYSTEM_IPADDRESS "Adresse IP" - ROLE_SYSTEM_OUTLINEBUTTON "outline button" + ROLE_SYSTEM_SPLITBUTTON "bouton avec menu" + ROLE_SYSTEM_IPADDRESS "adresse IP" + ROLE_SYSTEM_OUTLINEBUTTON "bouton de résumé" } diff --git a/reactos/dll/win32/oleacc/oleacc_Ko.rc b/reactos/dll/win32/oleacc/oleacc_Ko.rc index a1993f133f9..919b8d4e5f2 100644 --- a/reactos/dll/win32/oleacc/oleacc_Ko.rc +++ b/reactos/dll/win32/oleacc/oleacc_Ko.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/oleacc/oleacc_Lt.rc b/reactos/dll/win32/oleacc/oleacc_Lt.rc new file mode 100644 index 00000000000..4056c3dd9d6 --- /dev/null +++ b/reactos/dll/win32/oleacc/oleacc_Lt.rc @@ -0,0 +1,95 @@ +/* + * Lithuanian resources for oleacc + * + * Copyright 2009 Aurimas FiÅ¡eras + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + 0 "nežinomas objektas" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "lango antraÅ¡tÄ—s juosta" + ROLE_SYSTEM_MENUBAR "meniu juosta" + ROLE_SYSTEM_SCROLLBAR "slankjuostÄ—" + ROLE_SYSTEM_GRIP "rankenÄ—lÄ—" + ROLE_SYSTEM_SOUND "garsas" + ROLE_SYSTEM_CURSOR "pelÄ—s žymeklis" + ROLE_SYSTEM_CARET "žymeklis" + ROLE_SYSTEM_ALERT "įspÄ—jimas" + ROLE_SYSTEM_WINDOW "langas" + ROLE_SYSTEM_CLIENT "klientas" + ROLE_SYSTEM_MENUPOPUP "iÅ¡kylantis meniu" + ROLE_SYSTEM_MENUITEM "meniu elementas" + ROLE_SYSTEM_TOOLTIP "paaiÅ¡kinimas" + ROLE_SYSTEM_APPLICATION "programa" + ROLE_SYSTEM_DOCUMENT "dokumentas" + ROLE_SYSTEM_PANE "polangis" + ROLE_SYSTEM_CHART "diagrama" + ROLE_SYSTEM_DIALOG "dialogo langas" + ROLE_SYSTEM_BORDER "rÄ—melis" + ROLE_SYSTEM_GROUPING "grupavimas" + ROLE_SYSTEM_SEPARATOR "skirtukas" + ROLE_SYSTEM_TOOLBAR "įrankių juosta" + ROLE_SYSTEM_STATUSBAR "bÅ«senos juosta" + ROLE_SYSTEM_TABLE "lentelÄ—" + ROLE_SYSTEM_COLUMNHEADER "stulpelio antraÅ¡tÄ—" + ROLE_SYSTEM_ROWHEADER "eilutÄ—s antraÅ¡tÄ—" + ROLE_SYSTEM_COLUMN "stulpelis" + ROLE_SYSTEM_ROW "eilutÄ—" + ROLE_SYSTEM_CELL "langelis" + ROLE_SYSTEM_LINK "nuoroda" + ROLE_SYSTEM_HELPBALLOON "pagalbos balionas" + ROLE_SYSTEM_CHARACTER "personažas" + ROLE_SYSTEM_LIST "sÄ…raÅ¡as" + ROLE_SYSTEM_LISTITEM "sÄ…raÅ¡o elementas" + ROLE_SYSTEM_OUTLINE "planas" + ROLE_SYSTEM_OUTLINEITEM "plano elementas" + ROLE_SYSTEM_PAGETAB "kortelÄ—" + ROLE_SYSTEM_PROPERTYPAGE "savybių lapas" + ROLE_SYSTEM_INDICATOR "indikatorius" + ROLE_SYSTEM_GRAPHIC "grafika" + ROLE_SYSTEM_STATICTEXT "statinis tekstas" + ROLE_SYSTEM_TEXT "tekstas" + ROLE_SYSTEM_PUSHBUTTON "mygtukas" + ROLE_SYSTEM_CHECKBUTTON "žymimasis langelis" + ROLE_SYSTEM_RADIOBUTTON "akutÄ—" + ROLE_SYSTEM_COMBOBOX "jungtinis langelis" + ROLE_SYSTEM_DROPLIST "iÅ¡skleidžiamasis sÄ…raÅ¡as" + ROLE_SYSTEM_PROGRESSBAR "eigos juosta" + ROLE_SYSTEM_DIAL "sukiojama rankenÄ—lÄ—" + ROLE_SYSTEM_HOTKEYFIELD "sparÄiojo klaviÅ¡o laukas" + ROLE_SYSTEM_SLIDER "Å¡liaužiklis" + ROLE_SYSTEM_SPINBUTTON "suktukas" + ROLE_SYSTEM_DIAGRAM "schema" + ROLE_SYSTEM_ANIMATION "animacija" + ROLE_SYSTEM_EQUATION "lygtis" + ROLE_SYSTEM_BUTTONDROPDOWN "iÅ¡skleidžiamasis mygtukas" + ROLE_SYSTEM_BUTTONMENU "meniu mygtukas" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "tinklelio iÅ¡skleidžiamasis mygtukas" + ROLE_SYSTEM_WHITESPACE "matomas tarpas" + ROLE_SYSTEM_PAGETABLIST "kortelių sÄ…raÅ¡as" + ROLE_SYSTEM_CLOCK "laikrodis" + ROLE_SYSTEM_SPLITBUTTON "iÅ¡skleidimo mygtukas" + ROLE_SYSTEM_IPADDRESS "IP adresas" + ROLE_SYSTEM_OUTLINEBUTTON "plano mygtukas" +} diff --git a/reactos/dll/win32/oleacc/oleacc_Nl.rc b/reactos/dll/win32/oleacc/oleacc_Nl.rc index b639128a9d9..47daa1fba20 100644 --- a/reactos/dll/win32/oleacc/oleacc_Nl.rc +++ b/reactos/dll/win32/oleacc/oleacc_Nl.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE @@ -76,8 +78,8 @@ STRINGTABLE DISCARDABLE ROLE_SYSTEM_SLIDER "schuifknop" ROLE_SYSTEM_SPINBUTTON "spin box" ROLE_SYSTEM_DIAGRAM "diagram" - ROLE_SYSTEM_ANIMATION "animation" - ROLE_SYSTEM_EQUATION "formula" + ROLE_SYSTEM_ANIMATION "animatie" + ROLE_SYSTEM_EQUATION "formule" ROLE_SYSTEM_BUTTONDROPDOWN "dropdown knop" ROLE_SYSTEM_BUTTONMENU "menu knop" ROLE_SYSTEM_BUTTONDROPDOWNGRID "dropdown grid knop" diff --git a/reactos/dll/win32/oleacc/oleacc_No.rc b/reactos/dll/win32/oleacc/oleacc_No.rc new file mode 100644 index 00000000000..1bbadf0507c --- /dev/null +++ b/reactos/dll/win32/oleacc/oleacc_No.rc @@ -0,0 +1,95 @@ +/* + * Norwegian BokmÃ¥l resources for oleacc + * + * Copyright 2009 Alexander N. Sørnes + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL + +STRINGTABLE DISCARDABLE +{ + 0 "unknown object" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "tittellinje" + ROLE_SYSTEM_MENUBAR "menylinje" + ROLE_SYSTEM_SCROLLBAR "rullefelt" + ROLE_SYSTEM_GRIP "grip" + ROLE_SYSTEM_SOUND "lyd" + ROLE_SYSTEM_CURSOR "peker" + ROLE_SYSTEM_CARET "markør" + ROLE_SYSTEM_ALERT "varsel" + ROLE_SYSTEM_WINDOW "vindu" + ROLE_SYSTEM_CLIENT "klient" + ROLE_SYSTEM_MENUPOPUP "sprettoppmeny" + ROLE_SYSTEM_MENUITEM "menyelement" + ROLE_SYSTEM_TOOLTIP "verktøytips" + ROLE_SYSTEM_APPLICATION "program" + ROLE_SYSTEM_DOCUMENT "dokument" + ROLE_SYSTEM_PANE "panel" + ROLE_SYSTEM_CHART "diagram" + ROLE_SYSTEM_DIALOG "meldingsvindu" + ROLE_SYSTEM_BORDER "kant" + ROLE_SYSTEM_GROUPING "gruppering" + ROLE_SYSTEM_SEPARATOR "skille" + ROLE_SYSTEM_TOOLBAR "verktøylinje" + ROLE_SYSTEM_STATUSBAR "status bar" + ROLE_SYSTEM_TABLE "tabell" + ROLE_SYSTEM_COLUMNHEADER "kolonneoverskrift" + ROLE_SYSTEM_ROWHEADER "radoverskrift" + ROLE_SYSTEM_COLUMN "kolonne" + ROLE_SYSTEM_ROW "rad" + ROLE_SYSTEM_CELL "celle" + ROLE_SYSTEM_LINK "kobling" + ROLE_SYSTEM_HELPBALLOON "hjelpetekst" + ROLE_SYSTEM_CHARACTER "tegn" + ROLE_SYSTEM_LIST "liste" + ROLE_SYSTEM_LISTITEM "listeelement" + ROLE_SYSTEM_OUTLINE "utheving" + ROLE_SYSTEM_OUTLINEITEM "uthevet element" + ROLE_SYSTEM_PAGETAB "sidefane" + ROLE_SYSTEM_PROPERTYPAGE "fane" + ROLE_SYSTEM_INDICATOR "indikator" + ROLE_SYSTEM_GRAPHIC "grafikk" + ROLE_SYSTEM_STATICTEXT "statisk tekst" + ROLE_SYSTEM_TEXT "tekst" + ROLE_SYSTEM_PUSHBUTTON "knapp" + ROLE_SYSTEM_CHECKBUTTON "avkrysningsboks" + ROLE_SYSTEM_RADIOBUTTON "radioknapp" + ROLE_SYSTEM_COMBOBOX "komboboks" + ROLE_SYSTEM_DROPLIST "rullemeny" + ROLE_SYSTEM_PROGRESSBAR "framgangsindikator" + ROLE_SYSTEM_DIAL "hjul" + ROLE_SYSTEM_HOTKEYFIELD "felt for hurtigtaster" + ROLE_SYSTEM_SLIDER "rullefelt" + ROLE_SYSTEM_SPINBUTTON "rullemeny" + ROLE_SYSTEM_DIAGRAM "diagram" + ROLE_SYSTEM_ANIMATION "animasjon" + ROLE_SYSTEM_EQUATION "likning" + ROLE_SYSTEM_BUTTONDROPDOWN "knapp for rullemeny" + ROLE_SYSTEM_BUTTONMENU "menyknapp" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "felt for rullemeny-knapp" + ROLE_SYSTEM_WHITESPACE "mellomrom" + ROLE_SYSTEM_PAGETABLIST "faneliste" + ROLE_SYSTEM_CLOCK "klokke" + ROLE_SYSTEM_SPLITBUTTON "oppdelt knapp" + ROLE_SYSTEM_IPADDRESS "IP-adresse" + ROLE_SYSTEM_OUTLINEBUTTON "utheving for knapp" +} diff --git a/reactos/dll/win32/oleacc/oleacc_Pl.rc b/reactos/dll/win32/oleacc/oleacc_Pl.rc index fc93cb052c3..5d45368cf13 100644 --- a/reactos/dll/win32/oleacc/oleacc_Pl.rc +++ b/reactos/dll/win32/oleacc/oleacc_Pl.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + LANGUAGE LANG_POLISH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/oleacc/oleacc_Pt.rc b/reactos/dll/win32/oleacc/oleacc_Pt.rc new file mode 100644 index 00000000000..395324a4330 --- /dev/null +++ b/reactos/dll/win32/oleacc/oleacc_Pt.rc @@ -0,0 +1,94 @@ +/* + * Portuguese resources for oleacc + * + * Copyright 2009 Ricardo Filipe + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +#pragma code_page(65001) + +LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE + +STRINGTABLE DISCARDABLE +{ + 0 "objecto desconhecido" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "barra de título" + ROLE_SYSTEM_MENUBAR "barra de menu" + ROLE_SYSTEM_SCROLLBAR "barra de scroll" + ROLE_SYSTEM_GRIP "grip" + ROLE_SYSTEM_SOUND "som" + ROLE_SYSTEM_CURSOR "cursor" + ROLE_SYSTEM_CARET "caret" + ROLE_SYSTEM_ALERT "alerta" + ROLE_SYSTEM_WINDOW "janela" + ROLE_SYSTEM_CLIENT "cliente" + ROLE_SYSTEM_MENUPOPUP "popup menu" + ROLE_SYSTEM_MENUITEM "item do menu" + ROLE_SYSTEM_TOOLTIP "dica" + ROLE_SYSTEM_APPLICATION "aplicação" + ROLE_SYSTEM_DOCUMENT "documento" + ROLE_SYSTEM_PANE "painel" + ROLE_SYSTEM_CHART "gráfico" + ROLE_SYSTEM_DIALOG "diálogo" + ROLE_SYSTEM_BORDER "margem" + ROLE_SYSTEM_GROUPING "agrupamento" + ROLE_SYSTEM_SEPARATOR "separador" + ROLE_SYSTEM_TOOLBAR "barra de ferramentas" + ROLE_SYSTEM_STATUSBAR "barra de estado" + ROLE_SYSTEM_TABLE "tabela" + ROLE_SYSTEM_COLUMNHEADER "cabeçalho da coluna" + ROLE_SYSTEM_ROWHEADER "cabeçalho da linha" + ROLE_SYSTEM_COLUMN "coluna" + ROLE_SYSTEM_ROW "linha" + ROLE_SYSTEM_CELL "célula" + ROLE_SYSTEM_LINK "ligação" + ROLE_SYSTEM_HELPBALLOON "balão de ajuda" + ROLE_SYSTEM_CHARACTER "caracter" + ROLE_SYSTEM_LIST "lista" + ROLE_SYSTEM_LISTITEM "item da lista" + ROLE_SYSTEM_OUTLINE "delinear" + ROLE_SYSTEM_OUTLINEITEM "item delinear" + ROLE_SYSTEM_PAGETAB "tab de página" + ROLE_SYSTEM_PROPERTYPAGE "página de propriedades" + ROLE_SYSTEM_INDICATOR "indicador" + ROLE_SYSTEM_GRAPHIC "gráfico" + ROLE_SYSTEM_STATICTEXT "texto estático" + ROLE_SYSTEM_TEXT "texto" + ROLE_SYSTEM_PUSHBUTTON "push button" + ROLE_SYSTEM_CHECKBUTTON "check button" + ROLE_SYSTEM_RADIOBUTTON "radio button" + ROLE_SYSTEM_COMBOBOX "combo box" + ROLE_SYSTEM_DROPLIST "drop down" + ROLE_SYSTEM_PROGRESSBAR "barra de progresso" + ROLE_SYSTEM_DIAL "dial" + ROLE_SYSTEM_HOTKEYFIELD "hot key field" + ROLE_SYSTEM_SLIDER "slider" + ROLE_SYSTEM_SPINBUTTON "spin box" + ROLE_SYSTEM_DIAGRAM "diagrama" + ROLE_SYSTEM_ANIMATION "animação" + ROLE_SYSTEM_EQUATION "equação" + ROLE_SYSTEM_BUTTONDROPDOWN "drop down button" + ROLE_SYSTEM_BUTTONMENU "menu button" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "grid drop down button" + ROLE_SYSTEM_WHITESPACE "espaço em branco" + ROLE_SYSTEM_PAGETABLIST "page tab list" + ROLE_SYSTEM_CLOCK "relógio" + ROLE_SYSTEM_SPLITBUTTON "split button" + ROLE_SYSTEM_IPADDRESS "endereço IP" + ROLE_SYSTEM_OUTLINEBUTTON "outline button" +} diff --git a/reactos/dll/win32/oleacc/oleacc_Ro.rc b/reactos/dll/win32/oleacc/oleacc_Ro.rc new file mode 100644 index 00000000000..52fc47b7dcb --- /dev/null +++ b/reactos/dll/win32/oleacc/oleacc_Ro.rc @@ -0,0 +1,93 @@ +/* + * Copyright 2008 Nikolay Sivov + * Copyright 2009 Michael Stefaniuc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL + +#pragma code_page(65001) + +STRINGTABLE DISCARDABLE +{ + 0 "obiect necunoscut" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "bară de titlu" + ROLE_SYSTEM_MENUBAR "bară de meniu" + ROLE_SYSTEM_SCROLLBAR "bară de defilare" + ROLE_SYSTEM_GRIP "ghidaj" + ROLE_SYSTEM_SOUND "sunet" + ROLE_SYSTEM_CURSOR "cursor" + ROLE_SYSTEM_CARET "circumflex" + ROLE_SYSTEM_ALERT "atenÈ›ionare" + ROLE_SYSTEM_WINDOW "fereastră" + ROLE_SYSTEM_CLIENT "client" + ROLE_SYSTEM_MENUPOPUP "meniu contextual" + ROLE_SYSTEM_MENUITEM "element de meniu" + ROLE_SYSTEM_TOOLTIP "indiciu" + ROLE_SYSTEM_APPLICATION "aplicaÈ›ie" + ROLE_SYSTEM_DOCUMENT "document" + ROLE_SYSTEM_PANE "panou" + ROLE_SYSTEM_CHART "diagramă" + ROLE_SYSTEM_DIALOG "dialog" + ROLE_SYSTEM_BORDER "margine" + ROLE_SYSTEM_GROUPING "grupare" + ROLE_SYSTEM_SEPARATOR "separator" + ROLE_SYSTEM_TOOLBAR "bară de unelte" + ROLE_SYSTEM_STATUSBAR "bară de stare" + ROLE_SYSTEM_TABLE "tabel" + ROLE_SYSTEM_COLUMNHEADER "antet de coloană" + ROLE_SYSTEM_ROWHEADER "antet de rând" + ROLE_SYSTEM_COLUMN "coloană" + ROLE_SYSTEM_ROW "rând" + ROLE_SYSTEM_CELL "celulă" + ROLE_SYSTEM_LINK "legătură" + ROLE_SYSTEM_HELPBALLOON "balon de ajutor" + ROLE_SYSTEM_CHARACTER "caracter" + ROLE_SYSTEM_LIST "listă" + ROLE_SYSTEM_LISTITEM "element din listă" + ROLE_SYSTEM_OUTLINE "contur" + ROLE_SYSTEM_OUTLINEITEM "conturare element" + ROLE_SYSTEM_PAGETAB "filă" + ROLE_SYSTEM_PROPERTYPAGE "pagină de proprietăți" + ROLE_SYSTEM_INDICATOR "indicator" + ROLE_SYSTEM_GRAPHIC "grafică" + ROLE_SYSTEM_STATICTEXT "text static" + ROLE_SYSTEM_TEXT "text" + ROLE_SYSTEM_PUSHBUTTON "buton de comandă" + ROLE_SYSTEM_CHECKBUTTON "buton de bifare" + ROLE_SYSTEM_RADIOBUTTON "buton radio" + ROLE_SYSTEM_COMBOBOX "căsuță combinată" + ROLE_SYSTEM_DROPLIST "listă verticală" + ROLE_SYSTEM_PROGRESSBAR "bară de progres" + ROLE_SYSTEM_DIAL "apelator" + ROLE_SYSTEM_HOTKEYFIELD "câmp de tastă rapidă" + ROLE_SYSTEM_SLIDER "glisor" + ROLE_SYSTEM_SPINBUTTON "căsuță incrementală" + ROLE_SYSTEM_DIAGRAM "diagramă" + ROLE_SYSTEM_ANIMATION "animaÈ›ie" + ROLE_SYSTEM_EQUATION "ecuaÈ›ie" + ROLE_SYSTEM_BUTTONDROPDOWN "buton listă verticală" + ROLE_SYSTEM_BUTTONMENU "buton meniu" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "buton listă verticală de grilă" + ROLE_SYSTEM_WHITESPACE "spaÈ›iu gol" + ROLE_SYSTEM_PAGETABLIST "listă de file" + ROLE_SYSTEM_CLOCK "ceas" + ROLE_SYSTEM_SPLITBUTTON "buton separare" + ROLE_SYSTEM_IPADDRESS "adresă IP" + ROLE_SYSTEM_OUTLINEBUTTON "buton contur" +} From cd689e02dfa72d0e676212c444e6369bb1e85acb Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 13:27:36 +0000 Subject: [PATCH 150/211] [QUERY] sync query to wine 1.1.40 svn path=/trunk/; revision=45936 --- reactos/dll/win32/query/query_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/reactos/dll/win32/query/query_main.c b/reactos/dll/win32/query/query_main.c index cdf0966b052..2d4e4ae3043 100644 --- a/reactos/dll/win32/query/query_main.c +++ b/reactos/dll/win32/query/query_main.c @@ -64,7 +64,6 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("\n"); return S_FALSE; } From a609bd9f70abe5fab931ebbf43fe2f59bb66a2ac Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 13:32:24 +0000 Subject: [PATCH 151/211] [SHDOCLC] reduce diff to wine svn path=/trunk/; revision=45937 --- reactos/dll/win32/shdoclc/De.rc | 1 - reactos/dll/win32/shdoclc/Fr.rc | 1 - reactos/dll/win32/shdoclc/Lt.rc | 1 - reactos/dll/win32/shdoclc/Si.rc | 1 - reactos/dll/win32/shdoclc/rsrc.rc | 13 ++++++++----- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/reactos/dll/win32/shdoclc/De.rc b/reactos/dll/win32/shdoclc/De.rc index 3fbb536f6f0..f41619faeee 100644 --- a/reactos/dll/win32/shdoclc/De.rc +++ b/reactos/dll/win32/shdoclc/De.rc @@ -250,4 +250,3 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Scrolle rechts", IDM_SCROLL_RIGHT } } -#pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/Fr.rc b/reactos/dll/win32/shdoclc/Fr.rc index c74f0a43757..9277938bb45 100644 --- a/reactos/dll/win32/shdoclc/Fr.rc +++ b/reactos/dll/win32/shdoclc/Fr.rc @@ -252,4 +252,3 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Défilement vers la droite", IDM_SCROLL_RIGHT } } -#pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/Lt.rc b/reactos/dll/win32/shdoclc/Lt.rc index 93a34cd2c71..e6c812d3bfe 100644 --- a/reactos/dll/win32/shdoclc/Lt.rc +++ b/reactos/dll/win32/shdoclc/Lt.rc @@ -249,4 +249,3 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Slinkti deÅ¡inÄ—n", IDM_SCROLL_RIGHT } } -#pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/Si.rc b/reactos/dll/win32/shdoclc/Si.rc index 26a039a13c7..c95dc017089 100644 --- a/reactos/dll/win32/shdoclc/Si.rc +++ b/reactos/dll/win32/shdoclc/Si.rc @@ -248,4 +248,3 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Drsenje desno", IDM_SCROLL_RIGHT } } -#pragma code_page(default) diff --git a/reactos/dll/win32/shdoclc/rsrc.rc b/reactos/dll/win32/shdoclc/rsrc.rc index 3e048af673f..4759265aaf9 100644 --- a/reactos/dll/win32/shdoclc/rsrc.rc +++ b/reactos/dll/win32/shdoclc/rsrc.rc @@ -24,21 +24,24 @@ #include "Bg.rc" #include "Da.rc" -#include "De.rc" #include "En.rc" #include "Es.rc" #include "Fi.rc" -#include "Fr.rc" #include "Hu.rc" #include "Ko.rc" -#include "Lt.rc" #include "Nl.rc" #include "No.rc" +#include "Sv.rc" +#include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "Lt.rc" #include "Pt.rc" #include "Ro.rc" #include "Ru.rc" #include "Si.rc" -#include "Sv.rc" -#include "Tr.rc" #include "Uk.rc" #include "Zh.rc" + From ad6f16492913c311db2280fc356034494f72b4ea Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 13:36:22 +0000 Subject: [PATCH 152/211] [KERNEL32_WINETEST] sync kernel32_winetest to wine 1.1.40 svn path=/trunk/; revision=45938 --- rostests/winetests/kernel32/change.c | 1 + rostests/winetests/kernel32/debugger.c | 113 +++++++++++++++++++++++ rostests/winetests/kernel32/file.c | 6 +- rostests/winetests/kernel32/format_msg.c | 4 +- rostests/winetests/kernel32/thread.c | 18 +++- 5 files changed, 136 insertions(+), 6 deletions(-) diff --git a/rostests/winetests/kernel32/change.c b/rostests/winetests/kernel32/change.c index 50d899a424f..08d14174039 100755 --- a/rostests/winetests/kernel32/change.c +++ b/rostests/winetests/kernel32/change.c @@ -79,6 +79,7 @@ static DWORD FinishNotificationThread(HANDLE thread) ok(status == WAIT_OBJECT_0, "WaitForSingleObject status %d error %d\n", status, GetLastError()); ok(GetExitCodeThread(thread, &exitcode), "Could not retrieve thread exit code\n"); + CloseHandle(thread); return exitcode; } diff --git a/rostests/winetests/kernel32/debugger.c b/rostests/winetests/kernel32/debugger.c index b0f3b40b4aa..98d0e123848 100644 --- a/rostests/winetests/kernel32/debugger.c +++ b/rostests/winetests/kernel32/debugger.c @@ -31,6 +31,14 @@ #define STATUS_DEBUGGER_INACTIVE ((NTSTATUS) 0xC0000354) #endif +#ifdef __GNUC__ +#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args))) +#else +#define PRINTF_ATTR(fmt,args) +#endif + +#define child_ok (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_child_ok + static int myARGC; static char** myARGV; @@ -38,6 +46,18 @@ static BOOL (WINAPI *pCheckRemoteDebuggerPresent)(HANDLE,PBOOL); static BOOL (WINAPI *pDebugActiveProcessStop)(DWORD); static BOOL (WINAPI *pDebugSetProcessKillOnExit)(BOOL); +static LONG child_failures; + +static void PRINTF_ATTR(2, 3) test_child_ok(int condition, const char *msg, ...) +{ + va_list valist; + + va_start(valist, msg); + winetest_vok(condition, msg, valist); + va_end(valist); + if (!condition) ++child_failures; +} + /* Copied from the process test */ static void get_file_name(char* buf) { @@ -468,6 +488,94 @@ static void test_RemoteDebugger(void) "expected error ERROR_INVALID_PARAMETER, got %d/%x\n",GetLastError(), GetLastError()); } +struct child_blackbox +{ + LONG failures; +}; + +static void doChild(int argc, char **argv) +{ + struct child_blackbox blackbox; + const char *blackbox_file; + HANDLE parent; + DWORD ppid; + BOOL ret; + + blackbox_file = argv[4]; + sscanf(argv[3], "%08x", &ppid); + + parent = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ppid); + child_ok(!!parent, "OpenProcess failed, last error %#x.\n", GetLastError()); + + ret = DebugActiveProcess(ppid); + child_ok(ret, "DebugActiveProcess failed, last error %#x.\n", GetLastError()); + + ret = pDebugActiveProcessStop(ppid); + child_ok(ret, "DebugActiveProcessStop failed, last error %#x.\n", GetLastError()); + + ret = CloseHandle(parent); + child_ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError()); + + blackbox.failures = child_failures; + save_blackbox(blackbox_file, &blackbox, sizeof(blackbox)); +} + +static void test_debug_loop(int argc, char **argv) +{ + const char *arguments = " debugger child "; + struct child_blackbox blackbox; + char blackbox_file[MAX_PATH]; + PROCESS_INFORMATION pi; + STARTUPINFOA si; + DWORD pid; + char *cmd; + BOOL ret; + + if (!pDebugActiveProcessStop) + { + win_skip("DebugActiveProcessStop not available, skipping test.\n"); + return; + } + + pid = GetCurrentProcessId(); + get_file_name(blackbox_file); + cmd = HeapAlloc(GetProcessHeap(), 0, strlen(argv[0]) + strlen(arguments) + strlen(blackbox_file) + 10); + sprintf(cmd, "%s%s%08x %s", argv[0], arguments, pid, blackbox_file); + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + ret = CreateProcessA(NULL, cmd, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &si, &pi); + ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError()); + + HeapFree(GetProcessHeap(), 0, cmd); + + for (;;) + { + DEBUG_EVENT ev; + + ret = WaitForDebugEvent(&ev, INFINITE); + ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError()); + if (!ret) break; + + if (ev.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) break; + + ret = ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, DBG_CONTINUE); + ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError()); + if (!ret) break; + } + + ret = CloseHandle(pi.hThread); + ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError()); + ret = CloseHandle(pi.hProcess); + ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError()); + + load_blackbox(blackbox_file, &blackbox, sizeof(blackbox)); + ok(!blackbox.failures, "Got %d failures from child process.\n", blackbox.failures); + + ret = DeleteFileA(blackbox_file); + ok(ret, "DeleteFileA failed, last error %#x.\n", GetLastError()); +} + START_TEST(debugger) { HMODULE hdll; @@ -486,9 +594,14 @@ START_TEST(debugger) { doDebugger(myARGC, myARGV); } + else if (myARGC >= 5 && !strcmp(myARGV[2], "child")) + { + doChild(myARGC, myARGV); + } else { test_ExitCode(); test_RemoteDebugger(); + test_debug_loop(myARGC, myARGV); } } diff --git a/rostests/winetests/kernel32/file.c b/rostests/winetests/kernel32/file.c index 3493ff34ac4..b6f066e26bb 100755 --- a/rostests/winetests/kernel32/file.c +++ b/rostests/winetests/kernel32/file.c @@ -1602,12 +1602,12 @@ static void test_LockFile(void) /* zero-byte lock */ ok( LockFile( handle, 100, 0, 0, 0 ), "LockFile 100,0 failed\n" ); - limited_LockFile || ok( !LockFile( handle, 98, 0, 4, 0 ), "LockFile 98,4 succeeded\n" ); + if (!limited_LockFile) ok( !LockFile( handle, 98, 0, 4, 0 ), "LockFile 98,4 succeeded\n" ); ok( LockFile( handle, 90, 0, 10, 0 ), "LockFile 90,10 failed\n" ); - limited_LockFile || ok( !LockFile( handle, 100, 0, 10, 0 ), "LockFile 100,10 failed\n" ); + if (!limited_LockFile) ok( !LockFile( handle, 100, 0, 10, 0 ), "LockFile 100,10 failed\n" ); ok( UnlockFile( handle, 90, 0, 10, 0 ), "UnlockFile 90,10 failed\n" ); - !ok( UnlockFile( handle, 100, 0, 10, 0 ), "UnlockFile 100,10 failed\n" ); + ok( !UnlockFile( handle, 100, 0, 10, 0 ), "UnlockFile 100,10 succeeded\n" ); ok( UnlockFile( handle, 100, 0, 0, 0 ), "UnlockFile 100,0 failed\n" ); diff --git a/rostests/winetests/kernel32/format_msg.c b/rostests/winetests/kernel32/format_msg.c index 822667ccd24..228f4d07682 100755 --- a/rostests/winetests/kernel32/format_msg.c +++ b/rostests/winetests/kernel32/format_msg.c @@ -709,6 +709,7 @@ static void test_message_from_hmodule(void) ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); ok(error == ERROR_RESOURCE_LANG_NOT_FOUND || error == ERROR_MR_MID_NOT_FOUND || + error == ERROR_MUI_FILE_NOT_FOUND || error == ERROR_MUI_FILE_NOT_LOADED, "last error %u\n", error); @@ -719,7 +720,8 @@ static void test_message_from_hmodule(void) ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); ok(error == ERROR_RESOURCE_LANG_NOT_FOUND || error == ERROR_MR_MID_NOT_FOUND || - error == ERROR_MUI_FILE_NOT_FOUND, + error == ERROR_MUI_FILE_NOT_FOUND || + error == ERROR_MUI_FILE_NOT_LOADED, "last error %u\n", error); } diff --git a/rostests/winetests/kernel32/thread.c b/rostests/winetests/kernel32/thread.c index 69203fea050..afa67592a4a 100755 --- a/rostests/winetests/kernel32/thread.c +++ b/rostests/winetests/kernel32/thread.c @@ -421,7 +421,17 @@ static VOID test_CreateThread_basic(void) "Thread did not execute successfully\n"); ok(CloseHandle(thread[i])!=0,"CloseHandle failed\n"); } - ok(TlsFree(tlsIndex)!=0,"TlsFree failed\n"); + + SetLastError(0xCAFEF00D); + ok(TlsFree(tlsIndex)!=0,"TlsFree failed: %08x\n", GetLastError()); + ok(GetLastError()==0xCAFEF00D, + "GetLastError: expected 0xCAFEF00D, got %08x\n", GetLastError()); + + /* Test freeing an already freed TLS index */ + SetLastError(0xCAFEF00D); + ok(TlsFree(tlsIndex)==0,"TlsFree succeeded\n"); + ok(GetLastError()==ERROR_INVALID_PARAMETER, + "GetLastError: expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); /* Test how passing NULL as a pointer to threadid works */ SetLastError(0xFACEaBAD); @@ -780,7 +790,7 @@ static VOID test_GetThreadTimes(void) static VOID test_thread_processor(void) { HANDLE curthread,curproc; - DWORD_PTR processMask,systemMask; + DWORD_PTR processMask,systemMask,retMask; SYSTEM_INFO sysInfo; int error=0; BOOL is_wow64; @@ -803,6 +813,10 @@ static VOID test_thread_processor(void) "SetThreadAffinityMask failed\n"); ok(SetThreadAffinityMask(curthread,processMask+1)==0, "SetThreadAffinityMask passed for an illegal processor\n"); +/* NOTE: Pre-Vista does not recognize the "all processors" flag (all bits set) */ + retMask = SetThreadAffinityMask(curthread,~0UL); + ok(broken(retMask==0) || retMask==processMask, + "SetThreadAffinityMask(thread,-1) failed to request all processors.\n"); /* NOTE: This only works on WinNT/2000/XP) */ if (pSetThreadIdealProcessor) { SetLastError(0xdeadbeef); From b0254b03efea70971617438aaad65d731f1b1827 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 13:42:21 +0000 Subject: [PATCH 153/211] [MPR] partial sync to wine 1.1.40 svn path=/trunk/; revision=45939 --- reactos/dll/win32/mpr/mpr.rc | 16 ++-- reactos/dll/win32/mpr/mpr_Bg.rc | 2 + reactos/dll/win32/mpr/mpr_Cs.rc | 2 + reactos/dll/win32/mpr/mpr_Da.rc | 2 + reactos/dll/win32/mpr/mpr_De.rc | 4 + reactos/dll/win32/mpr/mpr_En.rc | 2 + reactos/dll/win32/mpr/mpr_Eo.rc | 2 + reactos/dll/win32/mpr/mpr_Es.rc | 2 + reactos/dll/win32/mpr/mpr_Fr.rc | 35 +++++---- reactos/dll/win32/mpr/mpr_Hu.rc | 2 + reactos/dll/win32/mpr/mpr_It.rc | 2 + reactos/dll/win32/mpr/mpr_Ja.rc | 22 +++++- reactos/dll/win32/mpr/mpr_Ko.rc | 2 + reactos/dll/win32/mpr/mpr_Lt.rc | 51 +++++++++++++ reactos/dll/win32/mpr/mpr_Nl.rc | 2 + reactos/dll/win32/mpr/mpr_No.rc | 2 + reactos/dll/win32/mpr/mpr_Pl.rc | 2 + reactos/dll/win32/mpr/mpr_Pt.rc | 12 ++- reactos/dll/win32/mpr/mpr_Ro.rc | 4 +- reactos/dll/win32/mpr/mpr_Ru.rc | 21 ++++-- reactos/dll/win32/mpr/mpr_Si.rc | 4 +- reactos/dll/win32/mpr/mpr_Sv.rc | 2 + reactos/dll/win32/mpr/mpr_Tr.rc | 2 + reactos/dll/win32/mpr/mpr_Uk.rc | 28 ++++--- reactos/dll/win32/mpr/mpr_Zh.rc | 4 +- reactos/dll/win32/mpr/mpr_main.c | 1 - reactos/dll/win32/mpr/mpr_ros.diff | 114 ----------------------------- reactos/dll/win32/mpr/mprres.h | 3 + reactos/dll/win32/mpr/wnet.c | 9 ++- 29 files changed, 189 insertions(+), 167 deletions(-) create mode 100644 reactos/dll/win32/mpr/mpr_Lt.rc delete mode 100644 reactos/dll/win32/mpr/mpr_ros.diff diff --git a/reactos/dll/win32/mpr/mpr.rc b/reactos/dll/win32/mpr/mpr.rc index b1e4704b976..05c1020a04a 100644 --- a/reactos/dll/win32/mpr/mpr.rc +++ b/reactos/dll/win32/mpr/mpr.rc @@ -27,23 +27,27 @@ #include "mpr_Bg.rc" #include "mpr_Cs.rc" #include "mpr_Da.rc" -#include "mpr_De.rc" #include "mpr_En.rc" #include "mpr_Eo.rc" #include "mpr_Es.rc" -#include "mpr_Fr.rc" #include "mpr_Hu.rc" #include "mpr_It.rc" -#include "mpr_Ja.rc" #include "mpr_Ko.rc" #include "mpr_Nl.rc" #include "mpr_No.rc" #include "mpr_Pl.rc" +#include "mpr_Sv.rc" +#include "mpr_Tr.rc" + +/* UTF-8 */ +#include "mpr_De.rc" +#include "mpr_Fr.rc" +#include "mpr_Ja.rc" +#include "mpr_Lt.rc" #include "mpr_Pt.rc" #include "mpr_Ro.rc" #include "mpr_Ru.rc" #include "mpr_Si.rc" -#include "mpr_Sv.rc" -#include "mpr_Tr.rc" -#include "mpr_Zh.rc" #include "mpr_Uk.rc" +#include "mpr_Zh.rc" + diff --git a/reactos/dll/win32/mpr/mpr_Bg.rc b/reactos/dll/win32/mpr/mpr_Bg.rc index a37f7961be1..52353d2a066 100644 --- a/reactos/dll/win32/mpr/mpr_Bg.rc +++ b/reactos/dll/win32/mpr/mpr_Bg.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Cs.rc b/reactos/dll/win32/mpr/mpr_Cs.rc index 6085e7160c6..8e32de4747e 100644 --- a/reactos/dll/win32/mpr/mpr_Cs.rc +++ b/reactos/dll/win32/mpr/mpr_Cs.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_CZECH, SUBLANG_DEFAULT /* Czech strings in CP1250 */ diff --git a/reactos/dll/win32/mpr/mpr_Da.rc b/reactos/dll/win32/mpr/mpr_Da.rc index 5b6f99fbd04..52dc635d19a 100644 --- a/reactos/dll/win32/mpr/mpr_Da.rc +++ b/reactos/dll/win32/mpr/mpr_Da.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_DANISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_De.rc b/reactos/dll/win32/mpr/mpr_De.rc index 41429be5501..d8b1298ac41 100644 --- a/reactos/dll/win32/mpr/mpr_De.rc +++ b/reactos/dll/win32/mpr/mpr_De.rc @@ -18,6 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + +#pragma code_page(65001) + LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_En.rc b/reactos/dll/win32/mpr/mpr_En.rc index c71840423f4..c6fdf727785 100644 --- a/reactos/dll/win32/mpr/mpr_En.rc +++ b/reactos/dll/win32/mpr/mpr_En.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Eo.rc b/reactos/dll/win32/mpr/mpr_Eo.rc index 0ed9f470d40..2701f759507 100644 --- a/reactos/dll/win32/mpr/mpr_Eo.rc +++ b/reactos/dll/win32/mpr/mpr_Eo.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_ESPERANTO, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Es.rc b/reactos/dll/win32/mpr/mpr_Es.rc index d82758cbeae..630a9fe9141 100644 --- a/reactos/dll/win32/mpr/mpr_Es.rc +++ b/reactos/dll/win32/mpr/mpr_Es.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Fr.rc b/reactos/dll/win32/mpr/mpr_Fr.rc index ba43eefa077..4481639ad35 100644 --- a/reactos/dll/win32/mpr/mpr_Fr.rc +++ b/reactos/dll/win32/mpr/mpr_Fr.rc @@ -19,29 +19,34 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { - IDS_ENTIRENETWORK "Le réseau entier" + IDS_ENTIRENETWORK "Le réseau entier" } -IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 +IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 210, 146 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Entrez le mot de passe réseau" +CAPTION "Entrez le mot de passe réseau" FONT 8, "MS Shell Dlg" { - LTEXT "Veuillez saisir votre nom d'utilisateur et votre mot de passe:", IDC_EXPLAIN, 40, 6, 150, 15 - LTEXT "Proxy", -1, 40, 26, 50, 10 + LTEXT "Veuillez saisir votre nom d'utilisateur et votre mot de passe :", IDC_EXPLAIN, 10, 6, 150, 17 + LTEXT "Proxy", -1, 10, 31, 50, 10 /* LTEXT "Realm", -1, 40, 46, 50, 10 */ - LTEXT "Utilisateur", -1, 40, 66, 50, 10 - LTEXT "Mot de passe", -1, 40, 86, 50, 10 - LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 - LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 - EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP - EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD - CHECKBOX "&Enregistrer ce mot de passe (risqué)", IDC_SAVEPASSWORD, - 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP - PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON - PUSHBUTTON "Annuler", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP + LTEXT "Utilisateur", -1, 10, 68, 45, 10 + LTEXT "Mot de passe", -1, 10, 88, 45, 10 + LTEXT "" IDC_PROXY, 56, 32, 144, 14, 0 + LTEXT "" IDC_REALM, 56, 46, 144, 14, 0 + EDITTEXT IDC_USERNAME, 56, 66, 144, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PASSWORD, 56, 86, 144, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD + CHECKBOX "&Enregistrer ce mot de passe (risqué)", IDC_SAVEPASSWORD, + 56, 106, 144, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 68, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "Annuler", IDCANCEL, 128, 126, 56, 14, WS_GROUP | WS_TABSTOP } diff --git a/reactos/dll/win32/mpr/mpr_Hu.rc b/reactos/dll/win32/mpr/mpr_Hu.rc index d3561cb3fe6..32c32dd6da6 100644 --- a/reactos/dll/win32/mpr/mpr_Hu.rc +++ b/reactos/dll/win32/mpr/mpr_Hu.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_It.rc b/reactos/dll/win32/mpr/mpr_It.rc index 501644d0978..7067ee37d96 100644 --- a/reactos/dll/win32/mpr/mpr_It.rc +++ b/reactos/dll/win32/mpr/mpr_It.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Ja.rc b/reactos/dll/win32/mpr/mpr_Ja.rc index ad1a45685b3..a662ce7223d 100644 --- a/reactos/dll/win32/mpr/mpr_Ja.rc +++ b/reactos/dll/win32/mpr/mpr_Ja.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + /* UTF-8 */ #pragma code_page(65001) @@ -28,4 +30,22 @@ STRINGTABLE DISCARDABLE IDS_ENTIRENETWORK "ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯å…¨ä½“" } -#pragma code_page(default) +IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯ç”¨ãƒ‘スワードを入力" +FONT 8, "MS Shell Dlg" +{ + LTEXT "ユーザーåã¨ãƒ‘スワードを入力ã—ã¦ãã ã•ã„:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "プロキシ", -1, 40, 26, 50, 10 +/* LTEXT "Realm", -1, 40, 46, 50, 10 */ + LTEXT "ユーザーå", -1, 40, 66, 50, 10 + LTEXT "パスワード", -1, 40, 86, 50, 10 + LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 + LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 + EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD + CHECKBOX "パスワードをä¿å­˜ã™ã‚‹(&S)(セキュアã§ã¯ã‚りã¾ã›ã‚“)", IDC_SAVEPASSWORD, + 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "キャンセル", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP +} diff --git a/reactos/dll/win32/mpr/mpr_Ko.rc b/reactos/dll/win32/mpr/mpr_Ko.rc index 75688cda4e8..4ebbd8f3575 100644 --- a/reactos/dll/win32/mpr/mpr_Ko.rc +++ b/reactos/dll/win32/mpr/mpr_Ko.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Lt.rc b/reactos/dll/win32/mpr/mpr_Lt.rc new file mode 100644 index 00000000000..d086d94c3b7 --- /dev/null +++ b/reactos/dll/win32/mpr/mpr_Lt.rc @@ -0,0 +1,51 @@ +/* + * MPR dll resources + * + * Copyright 2009 Aurimas FiÅ¡eras + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "mprres.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_ENTIRENETWORK "Visas tinklas" +} + +IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Ä®veskite tinklo slaptažodį" +FONT 8, "MS Shell Dlg" +{ + LTEXT "Ä®veskite savo naudotojo vardÄ… ir slaptažodį:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "Ä®galiot. serv.", -1, 40, 26, 50, 10 +/* LTEXT "Sritis", -1, 40, 46, 50, 10 */ + LTEXT "Naudotojas", -1, 40, 66, 50, 10 + LTEXT "Slaptažodis", -1, 40, 86, 50, 10 + LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 + LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 + EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD + CHECKBOX "Ä®&raÅ¡yti šį slaptažodį (nesaugu)", IDC_SAVEPASSWORD, + 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Gerai", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "Atsisakyti", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP +} diff --git a/reactos/dll/win32/mpr/mpr_Nl.rc b/reactos/dll/win32/mpr/mpr_Nl.rc index 430ac6aa8c8..b1c67819799 100644 --- a/reactos/dll/win32/mpr/mpr_Nl.rc +++ b/reactos/dll/win32/mpr/mpr_Nl.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_No.rc b/reactos/dll/win32/mpr/mpr_No.rc index 32833542db9..150ee509edb 100644 --- a/reactos/dll/win32/mpr/mpr_No.rc +++ b/reactos/dll/win32/mpr/mpr_No.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Pl.rc b/reactos/dll/win32/mpr/mpr_Pl.rc index a6f2446f3ea..afdd3ba6343 100644 --- a/reactos/dll/win32/mpr/mpr_Pl.rc +++ b/reactos/dll/win32/mpr/mpr_Pl.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_POLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Pt.rc b/reactos/dll/win32/mpr/mpr_Pt.rc index f79a96dcab8..b0191939094 100644 --- a/reactos/dll/win32/mpr/mpr_Pt.rc +++ b/reactos/dll/win32/mpr/mpr_Pt.rc @@ -2,7 +2,7 @@ * MPR dll resources * * Copyright (C) 2004 Marcelo Duarte - * Copyright (C) 2006 Américo José Melo + * Copyright (C) 2006 Américo José Melo * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN +#include "mprres.h" + +#pragma code_page(65001) + +LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { @@ -34,10 +38,10 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Entre a senha da rede" FONT 8, "MS Shell Dlg" { - LTEXT "Por favor, entre como o nome de usuário e a senha:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "Por favor, entre como o nome de usuário e a senha:", IDC_EXPLAIN, 40, 6, 150, 15 LTEXT "Proxy", -1, 40, 26, 50, 10 /* LTEXT "Realm", -1, 40, 46, 50, 10 */ - LTEXT "Usuário", -1, 40, 66, 50, 10 + LTEXT "Usuário", -1, 40, 66, 50, 10 LTEXT "Senha", -1, 40, 86, 50, 10 LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 diff --git a/reactos/dll/win32/mpr/mpr_Ro.rc b/reactos/dll/win32/mpr/mpr_Ro.rc index ce06328ef80..ab7d137e2b2 100644 --- a/reactos/dll/win32/mpr/mpr_Ro.rc +++ b/reactos/dll/win32/mpr/mpr_Ro.rc @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL #pragma code_page(65001) @@ -44,5 +46,3 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON PUSHBUTTON "Renunță", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } - -#pragma code_page(default) diff --git a/reactos/dll/win32/mpr/mpr_Ru.rc b/reactos/dll/win32/mpr/mpr_Ru.rc index d093c0612bb..3d17a0a93a5 100644 --- a/reactos/dll/win32/mpr/mpr_Ru.rc +++ b/reactos/dll/win32/mpr/mpr_Ru.rc @@ -18,29 +18,34 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { - IDS_ENTIRENETWORK "Âñÿ ñåòü" + IDS_ENTIRENETWORK "Ð’ÑÑ Ñеть" } IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Ââåäèòå ñåòåâîé ïàðîëü" +CAPTION "Введите Ñетевой пароль" FONT 8, "MS Shell Dlg" { - LTEXT "Ââåäèòå âàøè èìÿ è ïàðîëü ïîëüçîâàòåëÿ:", IDC_EXPLAIN, 40, 6, 150, 15 - LTEXT "Ïðîêñè", -1, 40, 26, 50, 10 + LTEXT "Введите ваши Ð¸Ð¼Ñ Ð¸ пароль пользователÑ:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "ПрокÑи", -1, 40, 26, 50, 10 /* LTEXT "Realm", -1, 40, 46, 50, 10 */ - LTEXT "Èìÿ", -1, 40, 66, 50, 10 - LTEXT "Ïàðîëü", -1, 40, 86, 50, 10 + LTEXT "ИмÑ", -1, 40, 66, 50, 10 + LTEXT "Пароль", -1, 40, 86, 50, 10 LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD - CHECKBOX "&Ñîõðàíèòü ýòîò ïàðîëü (íåáåçîïàñíî!)", IDC_SAVEPASSWORD, + CHECKBOX "&Сохранить Ñтот пароль (небезопаÑно!)", IDC_SAVEPASSWORD, 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON - PUSHBUTTON "Îòìåíà", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "Отмена", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } diff --git a/reactos/dll/win32/mpr/mpr_Si.rc b/reactos/dll/win32/mpr/mpr_Si.rc index 064bf525978..8f4022e402f 100644 --- a/reactos/dll/win32/mpr/mpr_Si.rc +++ b/reactos/dll/win32/mpr/mpr_Si.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + #pragma code_page(65001) LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT @@ -46,5 +48,3 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "V redu", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON PUSHBUTTON "PrekliÄi", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } - -#pragma code_page(default) diff --git a/reactos/dll/win32/mpr/mpr_Sv.rc b/reactos/dll/win32/mpr/mpr_Sv.rc index ef6a685c44d..86d0db6602a 100644 --- a/reactos/dll/win32/mpr/mpr_Sv.rc +++ b/reactos/dll/win32/mpr/mpr_Sv.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Tr.rc b/reactos/dll/win32/mpr/mpr_Tr.rc index b9f3af1fa03..0f48a156a31 100644 --- a/reactos/dll/win32/mpr/mpr_Tr.rc +++ b/reactos/dll/win32/mpr/mpr_Tr.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/mpr/mpr_Uk.rc b/reactos/dll/win32/mpr/mpr_Uk.rc index c5181f11208..67b781d82ad 100644 --- a/reactos/dll/win32/mpr/mpr_Uk.rc +++ b/reactos/dll/win32/mpr/mpr_Uk.rc @@ -1,7 +1,8 @@ /* - * MPR dll resources (Ukrainian) + * MPR dll Ukrainian resources * - * Copyright 2006 Artem Reznikov + * Copyright (C) 2004 Juan Lang + * Copyright (C) 2007 Artem Reznikov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -15,32 +16,37 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { - IDS_ENTIRENETWORK "Âñÿ Ìåðåæà" + IDS_ENTIRENETWORK "Ð’ÑÑ ÐœÐµÑ€ÐµÐ¶Ð°" } IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Ââåä³òü Ìåðåæíèé Ïàðîëü" +CAPTION "Введіть Мережний Пароль" FONT 8, "MS Shell Dlg" { - LTEXT "Áóäü ëàñêà, ââåä³òü Âàø³ ³ì'ÿ òà ïàðîëü:", IDC_EXPLAIN, 40, 6, 150, 15 - LTEXT "Ïðîêñ³", -1, 40, 26, 50, 10 + LTEXT "Будь лаÑка, введіть Ваші ім'Ñ Ñ‚Ð° пароль:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "ПрокÑÑ–", -1, 40, 26, 50, 10 /* LTEXT "Realm", -1, 40, 46, 50, 10 */ - LTEXT "Êîðèñòóâà÷", -1, 40, 66, 50, 10 - LTEXT "Ïàðîëü", -1, 40, 86, 50, 10 + LTEXT "КориÑтувач", -1, 40, 66, 50, 10 + LTEXT "Пароль", -1, 40, 86, 50, 10 LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD - CHECKBOX "&Çáåðåãòè öåé ïàðîëü (íåáåçïå÷íî)", IDC_SAVEPASSWORD, + CHECKBOX "&Зберегти цей пароль (небезпечно)", IDC_SAVEPASSWORD, 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON - PUSHBUTTON "Ñêàñóâàòè", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "СкаÑувати", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } diff --git a/reactos/dll/win32/mpr/mpr_Zh.rc b/reactos/dll/win32/mpr/mpr_Zh.rc index 47eb629131b..661e6b4afcd 100644 --- a/reactos/dll/win32/mpr/mpr_Zh.rc +++ b/reactos/dll/win32/mpr/mpr_Zh.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + /* Chinese text is encoded in UTF-8 */ #pragma code_page(65001) @@ -74,5 +76,3 @@ FONT 9, "MS Shell Dlg" PUSHBUTTON "確定", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON PUSHBUTTON "å–æ¶ˆ", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } - -#pragma code_page(default) diff --git a/reactos/dll/win32/mpr/mpr_main.c b/reactos/dll/win32/mpr/mpr_main.c index 3f9ea4a3c21..5ec6b2209d0 100644 --- a/reactos/dll/win32/mpr/mpr_main.c +++ b/reactos/dll/win32/mpr/mpr_main.c @@ -78,7 +78,6 @@ BOOL WINAPI _MPR_25( LPBYTE lpMem, INT len ) */ HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("Stub\n"); return S_OK; } diff --git a/reactos/dll/win32/mpr/mpr_ros.diff b/reactos/dll/win32/mpr/mpr_ros.diff deleted file mode 100644 index d8337d176b1..00000000000 --- a/reactos/dll/win32/mpr/mpr_ros.diff +++ /dev/null @@ -1,114 +0,0 @@ -Index: mpr.rc -=================================================================== ---- mpr.rc (revision 23782) -+++ mpr.rc (working copy) -@@ -39,5 +39,7 @@ - #include "mpr_No.rc" - #include "mpr_Pl.rc" - #include "mpr_Pt.rc" -+#include "mpr_Ru.rc" - #include "mpr_Sv.rc" - #include "mpr_Tr.rc" -+#include "mpr_Uk.rc" -Index: mpr_Ru.rc -=================================================================== ---- mpr_Ru.rc (revision 23782) -+++ mpr_Ru.rc (working copy) -@@ -0,0 +1,46 @@ -+/* -+ * MPR dll resources -+ * -+ * Copyright (C) 2005 Mikhail Y. Zvyozdochkin -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -+ -+STRINGTABLE DISCARDABLE -+{ -+ IDS_ENTIRENETWORK "Âñÿ ñåòü" -+} -+ -+IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 -+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -+CAPTION "Ââåäèòå Ñåòåâîé Ïàðîëü" -+FONT 8, "MS Shell Dlg" -+{ -+ LTEXT "Ïîæàëóéñòà, ââåäèòå Âàøè èìÿ è ïàðîëü:", IDC_EXPLAIN, 40, 6, 150, 15 -+ LTEXT "Ïðîêñè-ñåðâåð", -1, 40, 26, 50, 10 -+/* LTEXT "Realm", -1, 40, 46, 50, 10 */ -+ LTEXT "Èìÿ ïîëüçîâàòåëÿ", -1, 40, 66, 50, 10 -+ LTEXT "Ïàðîëü", -1, 40, 86, 50, 10 -+ LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 -+ LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 -+ EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP -+ EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD -+ CHECKBOX "&Ñîõðàíèòü ïàðîëü (íåáåçîïàñíî)", IDC_SAVEPASSWORD, -+ 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP -+ PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON -+ PUSHBUTTON "Îòìåíà", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP -+} -Index: mpr_Uk.rc -=================================================================== ---- mpr_Uk.rc (revision 23782) -+++ mpr_Uk.rc (working copy) -@@ -0,0 +1,46 @@ -+/* -+ * MPR dll resources (Ukrainian) -+ * -+ * Copyright 2006 Artem Reznikov -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT -+ -+STRINGTABLE DISCARDABLE -+{ -+ IDS_ENTIRENETWORK "Âñÿ Ìåðåæà" -+} -+ -+IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 -+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -+CAPTION "Ââåä³òü Ìåðåæíèé Ïàðîëü" -+FONT 8, "MS Shell Dlg" -+{ -+ LTEXT "Áóäü ëàñêà, ââåä³òü Âàø³ ³ì'ÿ òà ïàðîëü:", IDC_EXPLAIN, 40, 6, 150, 15 -+ LTEXT "Ïðîêñ³", -1, 40, 26, 50, 10 -+/* LTEXT "Realm", -1, 40, 46, 50, 10 */ -+ LTEXT "Êîðèñòóâà÷", -1, 40, 66, 50, 10 -+ LTEXT "Ïàðîëü", -1, 40, 86, 50, 10 -+ LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 -+ LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 -+ EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP -+ EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD -+ CHECKBOX "&Çáåðåãòè öåé ïàðîëü (íåáåçïå÷íî)", IDC_SAVEPASSWORD, -+ 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP -+ PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON -+ PUSHBUTTON "Ñêàñóâàòè", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP -+} diff --git a/reactos/dll/win32/mpr/mprres.h b/reactos/dll/win32/mpr/mprres.h index 292b4765260..5c42e565477 100644 --- a/reactos/dll/win32/mpr/mprres.h +++ b/reactos/dll/win32/mpr/mprres.h @@ -18,6 +18,9 @@ #ifndef __WINE_MPRRES_H__ #define __WINE_MPRRES_H__ +#include +#include + #define IDS_ENTIRENETWORK 1 #define IDD_PROXYDLG 0x400 diff --git a/reactos/dll/win32/mpr/wnet.c b/reactos/dll/win32/mpr/wnet.c index c199cb3aa7e..f5b0bc940c8 100644 --- a/reactos/dll/win32/mpr/wnet.c +++ b/reactos/dll/win32/mpr/wnet.c @@ -24,6 +24,7 @@ #include "windef.h" #include "winbase.h" #include "winnls.h" +#include "winioctl.h" #include "winnetwk.h" #include "npapi.h" #include "winreg.h" @@ -634,7 +635,10 @@ DWORD WINAPI WNetOpenEnumA( DWORD dwScope, DWORD dwType, DWORD dwUsage, if (!lphEnum) ret = WN_BAD_POINTER; else if (!providerTable || providerTable->numProviders == 0) + { + lphEnum = NULL; ret = WN_NO_NETWORK; + } else { if (lpNet) @@ -723,7 +727,10 @@ DWORD WINAPI WNetOpenEnumW( DWORD dwScope, DWORD dwType, DWORD dwUsage, if (!lphEnum) ret = WN_BAD_POINTER; else if (!providerTable || providerTable->numProviders == 0) + { + lphEnum = NULL; ret = WN_NO_NETWORK; + } else { switch (dwScope) @@ -1923,7 +1930,7 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel, break; } - SetLastError(err); + if (err != WN_NO_ERROR) SetLastError(err); return err; } From 2088d65d5ef25a7a42c0c446ee72900020d40beb Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 14:04:11 +0000 Subject: [PATCH 154/211] [WINDOWSCODECS] sync windowscodecs to wine 1.1.40 svn path=/trunk/; revision=45940 --- reactos/dll/win32/windowscodecs/pngformat.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/reactos/dll/win32/windowscodecs/pngformat.c b/reactos/dll/win32/windowscodecs/pngformat.c index 482ea90089d..22b37b063f4 100644 --- a/reactos/dll/win32/windowscodecs/pngformat.c +++ b/reactos/dll/win32/windowscodecs/pngformat.c @@ -60,7 +60,11 @@ MAKE_FUNCPTR(png_get_PLTE); MAKE_FUNCPTR(png_get_tRNS); MAKE_FUNCPTR(png_set_bgr); MAKE_FUNCPTR(png_set_error_fn); +#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 MAKE_FUNCPTR(png_set_expand_gray_1_2_4_to_8); +#else +MAKE_FUNCPTR(png_set_gray_1_2_4_to_8); +#endif MAKE_FUNCPTR(png_set_filler); MAKE_FUNCPTR(png_set_gray_to_rgb); MAKE_FUNCPTR(png_set_IHDR); @@ -103,7 +107,11 @@ static void *load_libpng(void) LOAD_FUNCPTR(png_get_tRNS); LOAD_FUNCPTR(png_set_bgr); LOAD_FUNCPTR(png_set_error_fn); +#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 LOAD_FUNCPTR(png_set_expand_gray_1_2_4_to_8); +#else + LOAD_FUNCPTR(png_set_gray_1_2_4_to_8); +#endif LOAD_FUNCPTR(png_set_filler); LOAD_FUNCPTR(png_set_gray_to_rgb); LOAD_FUNCPTR(png_set_IHDR); @@ -306,7 +314,11 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p { if (bit_depth < 8) { +#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 ppng_set_expand_gray_1_2_4_to_8(This->png_ptr); +#else + ppng_set_gray_1_2_4_to_8(This->png_ptr); +#endif bit_depth = 8; } ppng_set_gray_to_rgb(This->png_ptr); From e89f7e5a124892edfc6be2cd4cf791cc8df97b2f Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sat, 6 Mar 2010 14:06:08 +0000 Subject: [PATCH 155/211] [framebuf_new] Attempt to fix release build. svn path=/trunk/; revision=45941 --- reactos/drivers/video/displays/framebuf_new/driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/video/displays/framebuf_new/driver.h b/reactos/drivers/video/displays/framebuf_new/driver.h index 77306ca5ba6..e9e617190c0 100755 --- a/reactos/drivers/video/displays/framebuf_new/driver.h +++ b/reactos/drivers/video/displays/framebuf_new/driver.h @@ -7,7 +7,7 @@ * ReactOS Portable Systems Group */ -#define DBG 1 +//#define DBG 1 #include "stddef.h" #include #include "windef.h" From f24740da76b649f980fe986e21aebe9e34a3b795 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 14:06:19 +0000 Subject: [PATCH 156/211] [WINTRUST] sync wintrust to wine 1.1.40 svn path=/trunk/; revision=45942 --- reactos/dll/win32/wintrust/softpub.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/reactos/dll/win32/wintrust/softpub.c b/reactos/dll/win32/wintrust/softpub.c index f753c9302e6..9fa0d05d406 100644 --- a/reactos/dll/win32/wintrust/softpub.c +++ b/reactos/dll/win32/wintrust/softpub.c @@ -845,7 +845,7 @@ HRESULT WINAPI WintrustCertificateTrust(CRYPT_PROVIDER_DATA *data) HRESULT WINAPI GenericChainCertificateTrust(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err; WTD_GENERIC_CHAIN_POLICY_DATA *policyData = data->pWintrustData->pPolicyCallbackData; @@ -854,15 +854,11 @@ HRESULT WINAPI GenericChainCertificateTrust(CRYPT_PROVIDER_DATA *data) if (policyData && policyData->u.cbSize != sizeof(WTD_GENERIC_CHAIN_POLICY_CREATE_INFO)) { - SetLastError(ERROR_INVALID_PARAMETER); - ret = FALSE; + err = ERROR_INVALID_PARAMETER; goto end; } if (!data->csSigners) - { - ret = FALSE; - SetLastError(TRUST_E_NOSIGNATURE); - } + err = TRUST_E_NOSIGNATURE; else { DWORD i; @@ -880,19 +876,18 @@ HRESULT WINAPI GenericChainCertificateTrust(CRYPT_PROVIDER_DATA *data) pChainPara = &chainPara; pCreateInfo = &createInfo; } - ret = TRUE; - for (i = 0; i < data->csSigners; i++) - ret = WINTRUST_CreateChainForSigner(data, i, pCreateInfo, + err = ERROR_SUCCESS; + for (i = 0; !err && i < data->csSigners; i++) + err = WINTRUST_CreateChainForSigner(data, i, pCreateInfo, pChainPara); } end: - if (!ret) - data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] = - GetLastError(); - TRACE("returning %d (%08x)\n", ret ? S_OK : S_FALSE, + if (err) + data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] = err; + TRACE("returning %d (%08x)\n", !err ? S_OK : S_FALSE, data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV]); - return ret ? S_OK : S_FALSE; + return !err ? S_OK : S_FALSE; } HRESULT WINAPI SoftpubAuthenticode(CRYPT_PROVIDER_DATA *data) From 5a9ef42d46f09e1068680a62fafe5ea84bfab065 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 14:12:31 +0000 Subject: [PATCH 157/211] [XMLLITE_WINETEST] add xmllite_winetest from wine 1.1.40 svn path=/trunk/; revision=45943 --- rostests/winetests/directory.rbuild | 3 + rostests/winetests/xmllite/reader.c | 623 ++++++++++++++++++++++ rostests/winetests/xmllite/testlist.c | 15 + rostests/winetests/xmllite/xmllite.rbuild | 14 + 4 files changed, 655 insertions(+) create mode 100644 rostests/winetests/xmllite/reader.c create mode 100644 rostests/winetests/xmllite/testlist.c create mode 100644 rostests/winetests/xmllite/xmllite.rbuild diff --git a/rostests/winetests/directory.rbuild b/rostests/winetests/directory.rbuild index e4df81b16f1..5e7a7698b93 100644 --- a/rostests/winetests/directory.rbuild +++ b/rostests/winetests/directory.rbuild @@ -250,4 +250,7 @@ + + + diff --git a/rostests/winetests/xmllite/reader.c b/rostests/winetests/xmllite/reader.c new file mode 100644 index 00000000000..9bf18ac7f8d --- /dev/null +++ b/rostests/winetests/xmllite/reader.c @@ -0,0 +1,623 @@ +/* + * XMLLite IXmlReader tests + * + * Copyright 2010 (C) Nikolay Sivov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "initguid.h" +#include "ole2.h" +#include "xmllite.h" +#include "wine/test.h" + +DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda); + +HRESULT WINAPI (*pCreateXmlReader)(REFIID riid, void **ppvObject, IMalloc *pMalloc); +HRESULT WINAPI (*pCreateXmlReaderInputWithEncodingName)(IUnknown *stream, + IMalloc *pMalloc, + LPCWSTR encoding, + BOOL hint, + LPCWSTR base_uri, + IXmlReaderInput **ppInput); +static const char *debugstr_guid(REFIID riid) +{ + static char buf[50]; + + sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", + riid->Data1, riid->Data2, riid->Data3, riid->Data4[0], + riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4], + riid->Data4[5], riid->Data4[6], riid->Data4[7]); + + return buf; +} + +static const char xmldecl_full[] = "\n"; + +static IStream *create_stream_on_data(const char *data, int size) +{ + IStream *stream = NULL; + HGLOBAL hglobal; + void *ptr; + HRESULT hr; + + hglobal = GlobalAlloc(GHND, size); + ptr = GlobalLock(hglobal); + + memcpy(ptr, data, size); + + hr = CreateStreamOnHGlobal(hglobal, TRUE, &stream); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok(stream != NULL, "Expected non-NULL stream\n"); + + GlobalUnlock(hglobal); + + return stream; +} + +static void ok_pos_(IXmlReader *reader, int line, int pos, int line_broken, + int pos_broken, int todo, int _line_) +{ + UINT l, p; + HRESULT hr; + int broken_state; + + hr = IXmlReader_GetLineNumber(reader, &l); + ok_(__FILE__, _line_)(hr == S_OK, "Expected S_OK, got %08x\n", hr); + hr = IXmlReader_GetLinePosition(reader, &p); + ok_(__FILE__, _line_)(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + if (line_broken == -1 && pos_broken == -1) + broken_state = 0; + else + broken_state = broken((line_broken == -1 ? line : line_broken) == l && + (pos_broken == -1 ? pos : pos_broken) == p); + + if (todo) + todo_wine + ok_(__FILE__, _line_)((l == line && pos == p) || broken_state, + "Expected (%d,%d), got (%d,%d)\n", line, pos, l, p); + else + { + ok_(__FILE__, _line_)((l == line && pos == p) || broken_state, + "Expected (%d,%d), got (%d,%d)\n", line, pos, l, p); + } +} +#define ok_pos(reader, l, p, l_brk, p_brk, todo) ok_pos_(reader, l, p, l_brk, p_brk, todo, __LINE__) + +typedef struct input_iids_t { + IID iids[10]; + int count; +} input_iids_t; + +static const IID *setinput_full[] = { + &IID_IXmlReaderInput, + &IID_IStream, + &IID_ISequentialStream, + NULL +}; + +/* this applies to early xmllite versions */ +static const IID *setinput_full_old[] = { + &IID_IXmlReaderInput, + &IID_ISequentialStream, + &IID_IStream, + NULL +}; + +/* after ::SetInput(IXmlReaderInput*) */ +static const IID *setinput_readerinput[] = { + &IID_IStream, + &IID_ISequentialStream, + NULL +}; + +static const IID *empty_seq[] = { + NULL +}; + +static input_iids_t input_iids; + +static void ok_iids_(const input_iids_t *iids, const IID **expected, const IID **exp_broken, int todo, int line) +{ + int i = 0, size = 0; + + while (expected[i++]) size++; + + if (todo) { + todo_wine + ok_(__FILE__, line)(iids->count == size, "Sequence size mismatch (%d), got (%d)\n", size, iids->count); + } + else + ok_(__FILE__, line)(iids->count == size, "Sequence size mismatch (%d), got (%d)\n", size, iids->count); + + if (iids->count != size) return; + + for (i = 0; i < size; i++) { + ok_(__FILE__, line)(IsEqualGUID(&iids->iids[i], expected[i]) || + (exp_broken ? broken(IsEqualGUID(&iids->iids[i], exp_broken[i])) : FALSE), + "Wrong IID(%d), got (%s)\n", i, debugstr_guid(&iids->iids[i])); + } +} +#define ok_iids(got, exp, brk, todo) ok_iids_(got, exp, brk, todo, __LINE__) + +static const char *state_to_str(XmlReadState state) +{ + static const char* state_names[] = { + "XmlReadState_Initial", + "XmlReadState_Interactive", + "XmlReadState_Error", + "XmlReadState_EndOfFile", + "XmlReadState_Closed" + }; + + static const char unknown[] = "unknown"; + + switch (state) + { + case XmlReadState_Initial: + case XmlReadState_Interactive: + case XmlReadState_Error: + case XmlReadState_EndOfFile: + case XmlReadState_Closed: + return state_names[state]; + default: + return unknown; + } +} + +static const char *type_to_str(XmlNodeType type) +{ + static const char* type_names[] = { + "XmlNodeType_None", + "XmlNodeType_Element", + "XmlNodeType_Attribute", + "XmlNodeType_Text", + "XmlNodeType_CDATA", + "", "", + "XmlNodeType_ProcessingInstruction", + "XmlNodeType_Comment", + "", + "XmlNodeType_DocumentType", + "", "", + "XmlNodeType_Whitespace", + "", + "XmlNodeType_EndElement", + "", + "XmlNodeType_XmlDeclaration" + }; + + static const char unknown[] = "unknown"; + + switch (type) + { + case XmlNodeType_None: + case XmlNodeType_Element: + case XmlNodeType_Attribute: + case XmlNodeType_Text: + case XmlNodeType_CDATA: + case XmlNodeType_ProcessingInstruction: + case XmlNodeType_Comment: + case XmlNodeType_DocumentType: + case XmlNodeType_Whitespace: + case XmlNodeType_EndElement: + case XmlNodeType_XmlDeclaration: + return type_names[type]; + default: + return unknown; + } +} + +static void test_read_state_(IXmlReader *reader, XmlReadState expected, + XmlReadState exp_broken, int todo, int line) +{ + XmlReadState state; + HRESULT hr; + int broken_state; + + state = -1; /* invalid value */ + hr = IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, (LONG_PTR*)&state); + ok_(__FILE__, line)(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + if (exp_broken == -1) + broken_state = 0; + else + broken_state = broken(exp_broken == state); + + if (todo) + { + todo_wine + ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n", + state_to_str(expected), state_to_str(state)); + } + else + ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n", + state_to_str(expected), state_to_str(state)); +} + +#define test_read_state(reader, exp, brk, todo) test_read_state_(reader, exp, brk, todo, __LINE__) + +typedef struct _testinput +{ + const IUnknownVtbl *lpVtbl; + LONG ref; +} testinput; + +static inline testinput *impl_from_IUnknown(IUnknown *iface) +{ + return (testinput *)((char*)iface - FIELD_OFFSET(testinput, lpVtbl)); +} + +static HRESULT WINAPI testinput_QueryInterface(IUnknown *iface, REFIID riid, void** ppvObj) +{ + if (IsEqualGUID( riid, &IID_IUnknown )) + { + *ppvObj = iface; + IUnknown_AddRef(iface); + return S_OK; + } + + input_iids.iids[input_iids.count++] = *riid; + + *ppvObj = NULL; + + return E_NOINTERFACE; +} + +static ULONG WINAPI testinput_AddRef(IUnknown *iface) +{ + testinput *This = impl_from_IUnknown(iface); + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI testinput_Release(IUnknown *iface) +{ + testinput *This = impl_from_IUnknown(iface); + LONG ref; + + ref = InterlockedDecrement(&This->ref); + if (ref == 0) + { + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static const struct IUnknownVtbl testinput_vtbl = +{ + testinput_QueryInterface, + testinput_AddRef, + testinput_Release +}; + +static HRESULT testinput_createinstance(void **ppObj) +{ + testinput *input; + + input = HeapAlloc(GetProcessHeap(), 0, sizeof (*input)); + if(!input) return E_OUTOFMEMORY; + + input->lpVtbl = &testinput_vtbl; + input->ref = 1; + + *ppObj = &input->lpVtbl; + + return S_OK; +} + +static BOOL init_pointers(void) +{ + /* don't free module here, it's to be unloaded on exit */ + HMODULE mod = LoadLibraryA("xmllite.dll"); + + if (!mod) + { + win_skip("xmllite library not available\n"); + return FALSE; + } + +#define MAKEFUNC(f) if (!(p##f = (void*)GetProcAddress(mod, #f))) return FALSE; + MAKEFUNC(CreateXmlReader); + MAKEFUNC(CreateXmlReaderInputWithEncodingName); +#undef MAKEFUNC + + return TRUE; +} + +static void test_reader_create(void) +{ + HRESULT hr; + IXmlReader *reader; + IUnknown *input; + + /* crashes native */ + if (0) + { + hr = pCreateXmlReader(&IID_IXmlReader, NULL, NULL); + hr = pCreateXmlReader(NULL, (LPVOID*)&reader, NULL); + } + + hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_read_state(reader, XmlReadState_Closed, -1, FALSE); + + /* Null input pointer, releases previous input */ + hr = IXmlReader_SetInput(reader, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_read_state(reader, XmlReadState_Initial, XmlReadState_Closed, FALSE); + + /* test input interface selection sequence */ + hr = testinput_createinstance((void**)&input); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + input_iids.count = 0; + hr = IXmlReader_SetInput(reader, input); + ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr); + ok_iids(&input_iids, setinput_full, setinput_full_old, FALSE); + + IUnknown_Release(input); + + IXmlReader_Release(reader); +} + +static void test_readerinput(void) +{ + IXmlReaderInput *reader_input; + IXmlReader *reader, *reader2; + IUnknown *obj, *input; + IStream *stream; + HRESULT hr; + LONG ref; + + hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, NULL); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); + hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, &reader_input); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); + + hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + ref = IStream_AddRef(stream); + ok(ref == 2, "Expected 2, got %d\n", ref); + IStream_Release(stream); + hr = pCreateXmlReaderInputWithEncodingName((IUnknown*)stream, NULL, NULL, FALSE, NULL, &reader_input); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + /* IXmlReaderInput grabs a stream reference */ + ref = IStream_AddRef(stream); + ok(ref == 3, "Expected 3, got %d\n", ref); + IStream_Release(stream); + + /* try ::SetInput() with valid IXmlReaderInput */ + hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + ref = IUnknown_AddRef(reader_input); + ok(ref == 2, "Expected 2, got %d\n", ref); + IUnknown_Release(reader_input); + + hr = IXmlReader_SetInput(reader, reader_input); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_read_state(reader, XmlReadState_Initial, -1, FALSE); + + /* IXmlReader grabs a IXmlReaderInput reference */ + ref = IUnknown_AddRef(reader_input); + ok(ref == 3, "Expected 3, got %d\n", ref); + IUnknown_Release(reader_input); + + ref = IStream_AddRef(stream); + ok(ref == 4, "Expected 4, got %d\n", ref); + IStream_Release(stream); + + /* reset input and check state */ + hr = IXmlReader_SetInput(reader, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_read_state(reader, XmlReadState_Initial, XmlReadState_Closed, FALSE); + + IXmlReader_Release(reader); + + ref = IStream_AddRef(stream); + ok(ref == 3, "Expected 3, got %d\n", ref); + IStream_Release(stream); + + ref = IUnknown_AddRef(reader_input); + ok(ref == 2, "Expected 2, got %d\n", ref); + IUnknown_Release(reader_input); + + /* IID_IXmlReaderInput */ + /* it returns a kind of private undocumented vtable incompatible with IUnknown, + so it's not a COM interface actually. + Such query will be used only to check if input is really IXmlReaderInput */ + obj = (IUnknown*)0xdeadbeef; + hr = IUnknown_QueryInterface(reader_input, &IID_IXmlReaderInput, (void**)&obj); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ref = IUnknown_AddRef(reader_input); + ok(ref == 3, "Expected 3, got %d\n", ref); + IUnknown_Release(reader_input); + + IUnknown_Release(reader_input); + IUnknown_Release(reader_input); + IStream_Release(stream); + + /* test input interface selection sequence */ + hr = testinput_createinstance((void**)&input); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + input_iids.count = 0; + ref = IUnknown_AddRef(input); + ok(ref == 2, "Expected 2, got %d\n", ref); + IUnknown_Release(input); + hr = pCreateXmlReaderInputWithEncodingName(input, NULL, NULL, FALSE, NULL, &reader_input); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok_iids(&input_iids, empty_seq, NULL, FALSE); + /* IXmlReaderInput stores stream interface as IUnknown */ + ref = IUnknown_AddRef(input); + ok(ref == 3, "Expected 3, got %d\n", ref); + IUnknown_Release(input); + + hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + input_iids.count = 0; + ref = IUnknown_AddRef(reader_input); + ok(ref == 2, "Expected 2, got %d\n", ref); + IUnknown_Release(reader_input); + ref = IUnknown_AddRef(input); + ok(ref == 3, "Expected 3, got %d\n", ref); + IUnknown_Release(input); + hr = IXmlReader_SetInput(reader, reader_input); + ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr); + ok_iids(&input_iids, setinput_readerinput, NULL, FALSE); + + test_read_state(reader, XmlReadState_Closed, -1, FALSE); + + ref = IUnknown_AddRef(input); + ok(ref == 3, "Expected 3, got %d\n", ref); + IUnknown_Release(input); + + ref = IUnknown_AddRef(reader_input); + ok(ref == 3 || broken(ref == 2) /* versions 1.0.x and 1.1.x - XP, Vista */, + "Expected 3, got %d\n", ref); + IUnknown_Release(reader_input); + /* repeat another time, no check or caching here */ + input_iids.count = 0; + hr = IXmlReader_SetInput(reader, reader_input); + ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr); + ok_iids(&input_iids, setinput_readerinput, NULL, FALSE); + + /* another reader */ + hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader2, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + /* resolving from IXmlReaderInput to IStream/ISequentialStream is done at + ::SetInput() level, each time it's called */ + input_iids.count = 0; + hr = IXmlReader_SetInput(reader2, reader_input); + ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr); + ok_iids(&input_iids, setinput_readerinput, NULL, FALSE); + + IXmlReader_Release(reader2); + IXmlReader_Release(reader); + + IUnknown_Release(reader_input); + IUnknown_Release(input); +} + +static void test_reader_state(void) +{ + IXmlReader *reader; + HRESULT hr; + + hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + /* invalid arguments */ + hr = IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, NULL); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); + + IXmlReader_Release(reader); +} + +static void test_read_xmldeclaration(void) +{ + IXmlReader *reader; + IStream *stream; + HRESULT hr; + XmlNodeType type; + UINT count = 0; + + hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + /* position methods with Null args */ + hr = IXmlReader_GetLineNumber(reader, NULL); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); + + hr = IXmlReader_GetLinePosition(reader, NULL); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); + + stream = create_stream_on_data(xmldecl_full, sizeof(xmldecl_full)); + + hr = IXmlReader_SetInput(reader, (IUnknown*)stream); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + ok_pos(reader, 0, 0, -1, -1, FALSE); + + type = -1; + hr = IXmlReader_Read(reader, &type); +todo_wine { + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok(type == XmlNodeType_XmlDeclaration, + "Expected XmlNodeType_XmlDeclaration, got %s\n", type_to_str(type)); +} + /* new version 1.2.x and 1.3.x properly update postition for */ + ok_pos(reader, 1, 3, -1, 55, TRUE); + + /* check attributes */ + hr = IXmlReader_MoveToNextAttribute(reader); + todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok_pos(reader, 1, 7, -1, 55, TRUE); + + hr = IXmlReader_MoveToFirstAttribute(reader); + todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok_pos(reader, 1, 7, -1, 55, TRUE); + + hr = IXmlReader_GetAttributeCount(reader, &count); +todo_wine { + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok(count == 3, "Expected 3, got %d\n", count); +} + hr = IXmlReader_GetDepth(reader, &count); +todo_wine { + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok(count == 1, "Expected 1, got %d\n", count); +} + + IStream_Release(stream); + IXmlReader_Release(reader); +} + +START_TEST(reader) +{ + HRESULT r; + + r = CoInitialize( NULL ); + ok( r == S_OK, "failed to init com\n"); + + if (!init_pointers()) + { + CoUninitialize(); + return; + } + + test_reader_create(); + test_readerinput(); + test_reader_state(); + test_read_xmldeclaration(); + + CoUninitialize(); +} diff --git a/rostests/winetests/xmllite/testlist.c b/rostests/winetests/xmllite/testlist.c new file mode 100644 index 00000000000..eb154d6a012 --- /dev/null +++ b/rostests/winetests/xmllite/testlist.c @@ -0,0 +1,15 @@ +/* Automatically generated file; DO NOT EDIT!! */ + +#define WIN32_LEAN_AND_MEAN +#include + +#define STANDALONE +#include "wine/test.h" + +extern void func_reader(void); + +const struct test winetest_testlist[] = +{ + { "reader", func_reader }, + { 0, 0 } +}; diff --git a/rostests/winetests/xmllite/xmllite.rbuild b/rostests/winetests/xmllite/xmllite.rbuild new file mode 100644 index 00000000000..3c0f23c8dd6 --- /dev/null +++ b/rostests/winetests/xmllite/xmllite.rbuild @@ -0,0 +1,14 @@ + + + + + . + + wine + xmllite + ole32 + ntdll + reader.c + testlist.c + + From 002ea545f9311d5cc28c63a5dbb19782b4fee7dd Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 14:18:56 +0000 Subject: [PATCH 158/211] add xmllite_winetest to bootcd svn path=/trunk/; revision=45944 --- reactos/boot/bootdata/packages/reactos.dff | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/boot/bootdata/packages/reactos.dff b/reactos/boot/bootdata/packages/reactos.dff index e41d90082a1..0b988cc18ff 100644 --- a/reactos/boot/bootdata/packages/reactos.dff +++ b/reactos/boot/bootdata/packages/reactos.dff @@ -798,6 +798,7 @@ modules\rostests\winetests\winmm\winmm_winetest.exe 7 o modules\rostests\winetests\wintrust\wintrust_winetest.exe 7 optional modules\rostests\winetests\wlanapi\wlanapi_winetest.exe 7 optional modules\rostests\winetests\ws2_32\ws2_32_winetest.exe 7 optional +modules\rostests\winetests\xmllite\xmllite_winetest.exe 7 optional modules\wallpaper\Angelus_02_ROSWP.bmp 4 optional From 8592512f2ff6827ca1333728cbf5536be3f79ebe Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 14:29:56 +0000 Subject: [PATCH 159/211] [RTL] sync find_query_actctx with wine 1.1.40 svn path=/trunk/; revision=45945 --- reactos/lib/rtl/actctx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reactos/lib/rtl/actctx.c b/reactos/lib/rtl/actctx.c index 896d1fbf069..f7d727099fb 100644 --- a/reactos/lib/rtl/actctx.c +++ b/reactos/lib/rtl/actctx.c @@ -2096,6 +2096,8 @@ static NTSTATUS find_query_actctx( HANDLE *handle, DWORD flags, ULONG class ) if (flags & QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX) { + if (*handle) return STATUS_INVALID_PARAMETER; + if (NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame) *handle = NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame->ActivationContext; } @@ -2104,6 +2106,8 @@ static NTSTATUS find_query_actctx( HANDLE *handle, DWORD flags, ULONG class ) ULONG magic; LDR_DATA_TABLE_ENTRY *pldr; + if (!*handle) return STATUS_INVALID_PARAMETER; + LdrLockLoaderLock( 0, NULL, &magic ); if (!LdrFindEntryForAddress( *handle, &pldr )) { From 7632ce84a0ec86880c1bbb02435c258c214a4bd0 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 14:40:19 +0000 Subject: [PATCH 160/211] [CRT] add TrailBytes-info for codepage 1361 svn path=/trunk/; revision=45946 --- reactos/lib/sdk/crt/locale/locale.c | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/lib/sdk/crt/locale/locale.c b/reactos/lib/sdk/crt/locale/locale.c index d0f385ecf82..627234ed67d 100644 --- a/reactos/lib/sdk/crt/locale/locale.c +++ b/reactos/lib/sdk/crt/locale/locale.c @@ -44,6 +44,7 @@ static struct cp_extra_info_t g_cpextrainfo[] = {936, {0x40, 0xfe, 0, 0}}, {949, {0x41, 0xfe, 0, 0}}, {950, {0x40, 0x7e, 0xa1, 0xfe, 0, 0}}, + {1361, {0x31, 0x7e, 0x81, 0xfe, 0, 0}}, {20932, {1, 255, 0, 0}}, /* seems to give different results on different systems */ {0, {1, 255, 0, 0}} /* match all with FIXME */ }; From b7fbeda3eb7d5b1fa2f85c6356c8790cf2a11b2d Mon Sep 17 00:00:00 2001 From: Kamil Hornicek Date: Sat, 6 Mar 2010 14:49:14 +0000 Subject: [PATCH 161/211] - sync wined3d, ddraw, d3d8 and d3d9 with Wine 1.1.40 svn path=/trunk/; revision=45947 --- reactos/dll/directx/wine/d3d8/d3d8_main.c | 16 +- reactos/dll/directx/wine/d3d8/d3d8_private.h | 12 - reactos/dll/directx/wine/d3d8/device.c | 2 +- reactos/dll/directx/wine/d3d9/d3d9_main.c | 4 +- reactos/dll/directx/wine/d3d9/d3d9_private.h | 13 +- reactos/dll/directx/wine/d3d9/device.c | 136 +- reactos/dll/directx/wine/d3d9/directx.c | 4 +- reactos/dll/directx/wine/d3d9/query.c | 51 +- reactos/dll/directx/wine/d3d9/stateblock.c | 96 +- reactos/dll/directx/wine/d3d9/swapchain.c | 4 +- reactos/dll/directx/wine/ddraw/device.c | 35 +- reactos/dll/directx/wine/ddraw/main.c | 13 +- reactos/dll/directx/wine/ddraw/vertexbuffer.c | 11 +- reactos/dll/directx/wine/ddraw/viewport.c | 46 +- .../directx/wine/wined3d/arb_program_shader.c | 265 +- .../wine/wined3d/ati_fragment_shader.c | 2 +- reactos/dll/directx/wine/wined3d/baseshader.c | 1439 ----- reactos/dll/directx/wine/wined3d/buffer.c | 105 +- reactos/dll/directx/wine/wined3d/context.c | 78 +- reactos/dll/directx/wine/wined3d/device.c | 366 +- reactos/dll/directx/wine/wined3d/directx.c | 1610 ++++-- reactos/dll/directx/wine/wined3d/drawprim.c | 7 +- .../dll/directx/wine/wined3d/glsl_shader.c | 399 +- .../wine/wined3d/nvidia_texture_shader.c | 5 +- reactos/dll/directx/wine/wined3d/query.c | 576 +- reactos/dll/directx/wine/wined3d/shader.c | 1423 +++++ reactos/dll/directx/wine/wined3d/shader_sm1.c | 7 +- reactos/dll/directx/wine/wined3d/shader_sm4.c | 24 +- reactos/dll/directx/wine/wined3d/state.c | 208 +- reactos/dll/directx/wine/wined3d/surface.c | 137 +- reactos/dll/directx/wine/wined3d/swapchain.c | 25 +- reactos/dll/directx/wine/wined3d/utils.c | 124 +- .../dll/directx/wine/wined3d/wined3d.rbuild | 1 - reactos/dll/directx/wine/wined3d/wined3d_gl.h | 5076 +++++++++-------- .../directx/wine/wined3d/wined3d_private.h | 211 +- reactos/include/reactos/wine/config.h | 3 + reactos/include/reactos/wine/wined3d.idl | 35 +- 37 files changed, 6908 insertions(+), 5661 deletions(-) delete mode 100644 reactos/dll/directx/wine/wined3d/baseshader.c diff --git a/reactos/dll/directx/wine/d3d8/d3d8_main.c b/reactos/dll/directx/wine/d3d8/d3d8_main.c index 6300371842a..c471049714b 100644 --- a/reactos/dll/directx/wine/d3d8/d3d8_main.c +++ b/reactos/dll/directx/wine/d3d8/d3d8_main.c @@ -35,7 +35,7 @@ void WINAPI DebugSetMute(void) { /* nothing to do */ } -IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion) { +IDirect3D8* WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT SDKVersion) { IDirect3D8Impl* object; TRACE("SDKVersion = %x\n", SDKVersion); @@ -79,7 +79,12 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, BOOL bool, DWORD* toto) { HRESULT ret; - FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto); + static BOOL warned; + + if (TRACE_ON(d3d8) || !warned) { + FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto); + warned = TRUE; + } if (!vertexshader) return E_FAIL; @@ -109,7 +114,12 @@ HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL bool, DWORD* toto) { HRESULT ret; - FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto); + static BOOL warned; + + if (TRACE_ON(d3d8) || !warned) { + FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto); + warned = TRUE; + } if (!pixelshader) return E_FAIL; diff --git a/reactos/dll/directx/wine/d3d8/d3d8_private.h b/reactos/dll/directx/wine/d3d8/d3d8_private.h index 2c5f66f1d5f..4ba399b5d92 100644 --- a/reactos/dll/directx/wine/d3d8/d3d8_private.h +++ b/reactos/dll/directx/wine/d3d8/d3d8_private.h @@ -275,18 +275,6 @@ HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *devic UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN; -/* ------------------ */ -/* IDirect3DResource8 */ -/* ------------------ */ - -/***************************************************************************** - * Predeclare the interface implementation structures - */ -extern const IDirect3DResource8Vtbl Direct3DResource8_Vtbl DECLSPEC_HIDDEN; - -/***************************************************************************** - * IDirect3DResource8 implementation structure - */ struct IDirect3DResource8Impl { /* IUnknown fields */ diff --git a/reactos/dll/directx/wine/d3d8/device.c b/reactos/dll/directx/wine/d3d8/device.c index 5365640fd06..11697b2ff26 100644 --- a/reactos/dll/directx/wine/d3d8/device.c +++ b/reactos/dll/directx/wine/d3d8/device.c @@ -1047,7 +1047,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface) { return hr; } -static HRESULT WINAPI IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; HRESULT hr; diff --git a/reactos/dll/directx/wine/d3d9/d3d9_main.c b/reactos/dll/directx/wine/d3d9/d3d9_main.c index 339cc61c3be..c405a5747d7 100644 --- a/reactos/dll/directx/wine/d3d9/d3d9_main.c +++ b/reactos/dll/directx/wine/d3d9/d3d9_main.c @@ -33,7 +33,7 @@ void WINAPI DebugSetMute(void) { /* nothing to do */ } -IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) { +IDirect3D9* WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT SDKVersion) { IDirect3D9Impl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl)); object->lpVtbl = &Direct3D9_Vtbl; @@ -53,7 +53,7 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) { return (IDirect3D9*) object; } -HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **direct3d9ex) { +HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **direct3d9ex) { IDirect3D9 *ret; IDirect3D9Impl* object; diff --git a/reactos/dll/directx/wine/d3d9/d3d9_private.h b/reactos/dll/directx/wine/d3d9/d3d9_private.h index 7736beace67..eb3a032f18b 100644 --- a/reactos/dll/directx/wine/d3d9/d3d9_private.h +++ b/reactos/dll/directx/wine/d3d9/d3d9_private.h @@ -187,11 +187,6 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(IDirect3DDevice9Ex *iface, UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain) DECLSPEC_HIDDEN; extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *iface, - D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9 **ppSB) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, - IDirect3DStateBlock9 **ppSB) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9Ex *iface, IDirect3DVertexDeclaration9 *pDecl) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface, @@ -228,9 +223,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(IDirect3DDevi UINT StartRegister, const BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(IDirect3DDevice9Ex *iface, UINT StartRegister, BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface, - D3DQUERYTYPE Type, IDirect3DQuery9 **ppQuery) DECLSPEC_HIDDEN; - /* ---------------- */ /* IDirect3DVolume9 */ @@ -470,6 +462,8 @@ typedef struct IDirect3DStateBlock9Impl { LPDIRECT3DDEVICE9EX parentDevice; } IDirect3DStateBlock9Impl; +HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device, + D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock) DECLSPEC_HIDDEN; /* --------------------------- */ /* IDirect3DVertexDeclaration9 */ @@ -564,4 +558,7 @@ typedef struct IDirect3DQuery9Impl { LPDIRECT3DDEVICE9EX parentDevice; } IDirect3DQuery9Impl; +HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, + D3DQUERYTYPE type) DECLSPEC_HIDDEN; + #endif /* __WINE_D3D9_PRIVATE_H */ diff --git a/reactos/dll/directx/wine/d3d9/device.c b/reactos/dll/directx/wine/d3d9/device.c index 6b70c84cf27..79a9ba01834 100644 --- a/reactos/dll/directx/wine/d3d9/device.c +++ b/reactos/dll/directx/wine/d3d9/device.c @@ -248,7 +248,7 @@ static ULONG WINAPI IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9EX iface) { return ref; } -static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface) { +static ULONG WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; ULONG ref; @@ -452,7 +452,7 @@ static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX ifac return ret; } -static HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDevice9Ex *iface, +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDevice9Ex *iface, D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain9 **swapchain) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; @@ -541,7 +541,7 @@ static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data return ret; } -static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS* pPresentationParameters) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS* pPresentationParameters) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; WINED3DPRESENT_PARAMETERS localParameters; HRESULT hr; @@ -619,7 +619,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3DP return hr; } -static HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -1182,7 +1182,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX ifac return hr; } -static HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -1388,7 +1388,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX if return hr; } -static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface, D3DRENDERSTATETYPE State, DWORD Value) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface, D3DRENDERSTATETYPE State, DWORD Value) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -1414,6 +1414,97 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX return hr; } +static HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *iface, + D3DSTATEBLOCKTYPE type, IDirect3DStateBlock9 **stateblock) +{ + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + IDirect3DStateBlock9Impl *object; + HRESULT hr; + + TRACE("iface %p, type %#x, stateblock %p.\n", iface, type, stateblock); + + if (type != D3DSBT_ALL && type != D3DSBT_PIXELSTATE && type != D3DSBT_VERTEXSTATE) + { + WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL.\n"); + return D3DERR_INVALIDCALL; + } + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate stateblock memory.\n"); + return E_OUTOFMEMORY; + } + + hr = stateblock_init(object, This, type, NULL); + if (FAILED(hr)) + { + WARN("Failed to initialize stateblock, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created stateblock %p.\n", object); + *stateblock = (IDirect3DStateBlock9 *)object; + + return D3D_OK; +} + +static HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface) +{ + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hr; + + TRACE("iface %p.\n", iface); + + wined3d_mutex_lock(); + hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice); + wined3d_mutex_unlock(); + + return hr; +} + +static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **stateblock) +{ + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + IWineD3DStateBlock *wined3d_stateblock; + IDirect3DStateBlock9Impl *object; + HRESULT hr; + + TRACE("iface %p, stateblock %p.\n", iface, stateblock); + + wined3d_mutex_lock(); + hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice, &wined3d_stateblock); + wined3d_mutex_unlock(); + if (FAILED(hr)) + { + WARN("IWineD3DDevice_EndStateBlock() failed, hr %#x.\n", hr); + return hr; + } + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate stateblock memory.\n"); + IWineD3DStateBlock_Release(wined3d_stateblock); + return E_OUTOFMEMORY; + } + + hr = stateblock_init(object, This, 0, wined3d_stateblock); + if (FAILED(hr)) + { + WARN("Failed to initialize stateblock, hr %#x.\n", hr); + IWineD3DStateBlock_Release(wined3d_stateblock); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created stateblock %p.\n", object); + *stateblock = (IDirect3DStateBlock9 *)object; + + return D3D_OK; +} + static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface, CONST D3DCLIPSTATUS9* pClipStatus) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -1559,7 +1650,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(IDirect3DDevice9Ex *i return hr; } -static HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -2178,6 +2269,37 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX ifa return hr; } +static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface, + D3DQUERYTYPE type, IDirect3DQuery9 **query) +{ + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + IDirect3DQuery9Impl *object; + HRESULT hr; + + TRACE("iface %p, type %#x, query %p.\n", iface, type, query); + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate query memory.\n"); + return E_OUTOFMEMORY; + } + + hr = query_init(object, This, type); + if (FAILED(hr)) + { + WARN("Failed to initialize query, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created query %p.\n", object); + if (query) *query = (IDirect3DQuery9 *)object; + else IDirect3DQuery9_Release((IDirect3DQuery9 *)object); + + return D3D_OK; +} + static HRESULT WINAPI IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(IDirect3DDevice9Ex *iface, UINT width, UINT height, float *rows, float *columns) { diff --git a/reactos/dll/directx/wine/d3d9/directx.c b/reactos/dll/directx/wine/d3d9/directx.c index 5f5e8f913d4..1fcc8c47fcf 100644 --- a/reactos/dll/directx/wine/d3d9/directx.c +++ b/reactos/dll/directx/wine/d3d9/directx.c @@ -407,7 +407,7 @@ static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UIN return ret; } -static HRESULT WINAPI IDirect3D9Impl_CreateDevice(IDirect3D9Ex *iface, UINT adapter, +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9Impl_CreateDevice(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, IDirect3DDevice9 **device) { @@ -465,7 +465,7 @@ static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *ifa return D3DERR_DRIVERINTERNALERROR; } -static HRESULT WINAPI IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface, +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device) { diff --git a/reactos/dll/directx/wine/d3d9/query.c b/reactos/dll/directx/wine/d3d9/query.c index ecb2e718eeb..a38dc9d15fb 100644 --- a/reactos/dll/directx/wine/d3d9/query.c +++ b/reactos/dll/directx/wine/d3d9/query.c @@ -150,49 +150,24 @@ static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl = IDirect3DQuery9Impl_GetData }; +HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3DQUERYTYPE type) +{ + HRESULT hr; -/* IDirect3DDevice9 IDirect3DQuery9 Methods follow: */ -HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - IDirect3DQuery9Impl *object = NULL; - HRESULT hr = D3D_OK; + query->lpVtbl = &Direct3DQuery9_Vtbl; + query->ref = 1; - TRACE("iface %p, type %#x, query %p.\n", iface, Type, ppQuery); - - if (!ppQuery) + wined3d_mutex_lock(); + hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery, (IUnknown *)query); + wined3d_mutex_unlock(); + if (FAILED(hr)) { - wined3d_mutex_lock(); - hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL); - wined3d_mutex_unlock(); - + WARN("Failed to create wined3d query, hr %#x.\n", hr); return hr; } - /* Allocate the storage for the device */ - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl)); - if (NULL == object) { - ERR("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n"); - return D3DERR_OUTOFVIDEOMEMORY; - } + query->parentDevice = (IDirect3DDevice9Ex *)device; + IDirect3DDevice9Ex_AddRef(query->parentDevice); - object->lpVtbl = &Direct3DQuery9_Vtbl; - object->ref = 1; - - wined3d_mutex_lock(); - hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object); - wined3d_mutex_unlock(); - - if (FAILED(hr)) { - - /* free up object */ - WARN("(%p) call to IWineD3DDevice_CreateQuery failed\n", This); - HeapFree(GetProcessHeap(), 0, object); - } else { - IDirect3DDevice9Ex_AddRef(iface); - object->parentDevice = iface; - *ppQuery = (LPDIRECT3DQUERY9) object; - TRACE("(%p) : Created query %p\n", This , object); - } - TRACE("(%p) : returning %x\n", This, hr); - return hr; + return D3D_OK; } diff --git a/reactos/dll/directx/wine/d3d9/stateblock.c b/reactos/dll/directx/wine/d3d9/stateblock.c index 7cd3ba629e0..c4941db254b 100644 --- a/reactos/dll/directx/wine/d3d9/stateblock.c +++ b/reactos/dll/directx/wine/d3d9/stateblock.c @@ -123,87 +123,33 @@ static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl = IDirect3DStateBlock9Impl_Apply }; - -/* IDirect3DDevice9 IDirect3DStateBlock9 Methods follow: */ -HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9EX iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppStateBlock) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - IDirect3DStateBlock9Impl* object; - HRESULT hrc = D3D_OK; - - TRACE("iface %p, type %#x, stateblock %p.\n", iface, Type, ppStateBlock); - - if(Type != D3DSBT_ALL && Type != D3DSBT_PIXELSTATE && - Type != D3DSBT_VERTEXSTATE ) { - WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL\n"); - return D3DERR_INVALIDCALL; - } - - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl)); - if (NULL == object) return E_OUTOFMEMORY; - object->lpVtbl = &Direct3DStateBlock9_Vtbl; - object->ref = 1; - - wined3d_mutex_lock(); - hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown*)object); - wined3d_mutex_unlock(); - - if(hrc != D3D_OK){ - FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This); - HeapFree(GetProcessHeap(), 0, object); - } else { - IDirect3DDevice9Ex_AddRef(iface); - object->parentDevice = iface; - *ppStateBlock = (IDirect3DStateBlock9*)object; - TRACE("(%p) : Created stateblock %p\n", This, object); - } - TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object); - return hrc; -} - -HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface) +HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device, + D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; - TRACE("iface %p.\n", iface); + stateblock->lpVtbl = &Direct3DStateBlock9_Vtbl; + stateblock->ref = 1; - wined3d_mutex_lock(); - hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice); - wined3d_mutex_unlock(); - - return hr; -} - -HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **ppSB) -{ - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - IWineD3DStateBlock *wineD3DStateBlock; - IDirect3DStateBlock9Impl *object; - HRESULT hr; - - TRACE("iface %p, stateblock %p.\n", iface, ppSB); - - /* Tell wineD3D to endstateblock before anything else (in case we run out - * of memory later and cause locking problems) */ - wined3d_mutex_lock(); - hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock); - wined3d_mutex_unlock(); - - if (hr!= D3D_OK) + if (wined3d_stateblock) { - WARN("IWineD3DDevice_EndStateBlock returned an error\n"); - return hr; + stateblock->wineD3DStateBlock = wined3d_stateblock; + } + else + { + wined3d_mutex_lock(); + hr = IWineD3DDevice_CreateStateBlock(device->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)type, + &stateblock->wineD3DStateBlock, (IUnknown *)stateblock); + wined3d_mutex_unlock(); + if (FAILED(hr)) + { + WARN("Failed to create wined3d stateblock, hr %#x.\n", hr); + return hr; + } } - /* allocate a new IDirectD3DStateBlock */ - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl)); - if (!object) return E_OUTOFMEMORY; - object->ref = 1; - object->lpVtbl = &Direct3DStateBlock9_Vtbl; - object->wineD3DStateBlock = wineD3DStateBlock; - IDirect3DDevice9Ex_AddRef(iface); - object->parentDevice = iface; - *ppSB=(IDirect3DStateBlock9*)object; - TRACE("(%p) Returning *ppSB %p, wineD3DStateBlock %p\n", This, *ppSB, wineD3DStateBlock); + stateblock->parentDevice = (IDirect3DDevice9Ex *)device; + IDirect3DDevice9Ex_AddRef(stateblock->parentDevice); + return D3D_OK; } diff --git a/reactos/dll/directx/wine/d3d9/swapchain.c b/reactos/dll/directx/wine/d3d9/swapchain.c index 207504559ee..c692371a258 100644 --- a/reactos/dll/directx/wine/d3d9/swapchain.c +++ b/reactos/dll/directx/wine/d3d9/swapchain.c @@ -79,7 +79,7 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface) } /* IDirect3DSwapChain9 parts follow: */ -static HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) { IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; HRESULT hr; @@ -269,7 +269,7 @@ HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl return D3D_OK; } -HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) { +HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hrc = D3D_OK; IWineD3DSwapChain *swapchain = NULL; diff --git a/reactos/dll/directx/wine/ddraw/device.c b/reactos/dll/directx/wine/ddraw/device.c index 67fc6f5e266..13ecfa133ac 100644 --- a/reactos/dll/directx/wine/ddraw/device.c +++ b/reactos/dll/directx/wine/ddraw/device.c @@ -1705,13 +1705,13 @@ IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7 *iface) else return D3DERR_SCENE_NOT_IN_SCENE; } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_7_EndScene_FPUSetup(IDirect3DDevice7 *iface) { return IDirect3DDeviceImpl_7_EndScene(iface); } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_7_EndScene_FPUPreserve(IDirect3DDevice7 *iface) { HRESULT hr; @@ -1724,7 +1724,7 @@ IDirect3DDeviceImpl_7_EndScene_FPUPreserve(IDirect3DDevice7 *iface) return hr; } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3 *iface) { IDirect3DDeviceImpl *This = device_from_device3(iface); @@ -1732,7 +1732,7 @@ Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3 *iface) return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)This); } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2 *iface) { IDirect3DDeviceImpl *This = device_from_device2(iface); @@ -1740,7 +1740,7 @@ Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2 *iface) return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)This); } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice *iface) { IDirect3DDeviceImpl *This = device_from_device1(iface); @@ -2580,7 +2580,8 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface, } if (!(colorop == WINED3DTOP_MODULATE && colorarg1 == WINED3DTA_TEXTURE && colorarg2 == WINED3DTA_CURRENT && - alphaop == WINED3DTOP_SELECTARG1 && alphaarg1 == (tex_alpha ? WINED3DTA_TEXTURE : WINED3DTA_CURRENT))) + alphaop == (tex_alpha ? WINED3DTOP_SELECTARG1 : WINED3DTOP_SELECTARG2) && + alphaarg1 == WINED3DTA_TEXTURE && alphaarg2 == WINED3DTA_CURRENT)) { ERR("Unexpected texture stage state setup, returning D3DTBLEND_MODULATE - likely erroneous\n"); } @@ -2852,16 +2853,12 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface, IWineD3DBaseTexture_Release(tex); } - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1); if (tex_alpha) - { - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE); - } + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1); else - { - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_CURRENT); - } - + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2); + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE); + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT); IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE); IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT); IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE); @@ -4664,15 +4661,11 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface, IWineD3DBaseTexture_Release(tex); } - /* alphaop is WINED3DTOP_SELECTARG1 if it's D3DTBLEND_MODULATE, so only modify alphaarg1 */ + /* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */ if (tex_alpha) - { - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE); - } + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1); else - { - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_CURRENT); - } + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2); } LeaveCriticalSection(&ddraw_cs); diff --git a/reactos/dll/directx/wine/ddraw/main.c b/reactos/dll/directx/wine/ddraw/main.c index 079800d9a2b..bc23987ed81 100644 --- a/reactos/dll/directx/wine/ddraw/main.c +++ b/reactos/dll/directx/wine/ddraw/main.c @@ -302,7 +302,7 @@ err_out: * Arguments, return values: See DDRAW_Create * ***********************************************************************/ -HRESULT WINAPI +HRESULT WINAPI DECLSPEC_HOTPATCH DirectDrawCreate(GUID *GUID, LPDIRECTDRAW *DD, IUnknown *UnkOuter) @@ -325,7 +325,7 @@ DirectDrawCreate(GUID *GUID, * Arguments, return values: See DDRAW_Create * ***********************************************************************/ -HRESULT WINAPI +HRESULT WINAPI DECLSPEC_HOTPATCH DirectDrawCreateEx(GUID *GUID, LPVOID *DD, REFIID iid, @@ -742,14 +742,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) */ HRESULT WINAPI DllCanUnloadNow(void) { - HRESULT hr; - FIXME("(void): stub\n"); - - EnterCriticalSection(&ddraw_cs); - hr = S_FALSE; - LeaveCriticalSection(&ddraw_cs); - - return hr; + return S_FALSE; } /******************************************************************************* diff --git a/reactos/dll/directx/wine/ddraw/vertexbuffer.c b/reactos/dll/directx/wine/ddraw/vertexbuffer.c index df7528b45cb..f16cf124392 100644 --- a/reactos/dll/directx/wine/ddraw/vertexbuffer.c +++ b/reactos/dll/directx/wine/ddraw/vertexbuffer.c @@ -236,8 +236,17 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface; WINED3DBUFFER_DESC Desc; HRESULT hr; + DWORD wined3d_flags = 0; TRACE("(%p)->(%08x,%p,%p)\n", This, Flags, Data, Size); + /* Writeonly: Pointless. Event: Unsupported by native according to the sdk + * nosyslock: Not applicable + */ + if(!(Flags & DDLOCK_WAIT)) wined3d_flags |= WINED3DLOCK_DONOTWAIT; + if(Flags & DDLOCK_READONLY) wined3d_flags |= WINED3DLOCK_READONLY; + if(Flags & DDLOCK_NOOVERWRITE) wined3d_flags |= WINED3DLOCK_NOOVERWRITE; + if(Flags & DDLOCK_DISCARDCONTENTS) wined3d_flags |= WINED3DLOCK_DISCARD; + EnterCriticalSection(&ddraw_cs); if(Size) { @@ -253,7 +262,7 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, } hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, 0 /* OffsetToLock */, - 0 /* SizeToLock, 0 == Full lock */, (BYTE **)Data, Flags); + 0 /* SizeToLock, 0 == Full lock */, (BYTE **)Data, wined3d_flags); LeaveCriticalSection(&ddraw_cs); return hr; } diff --git a/reactos/dll/directx/wine/ddraw/viewport.c b/reactos/dll/directx/wine/ddraw/viewport.c index 9b0698903f5..b637df1b0f5 100644 --- a/reactos/dll/directx/wine/ddraw/viewport.c +++ b/reactos/dll/directx/wine/ddraw/viewport.c @@ -255,14 +255,25 @@ IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface, TRACE("(%p/%p)->(%p)\n", This, iface, lpData); EnterCriticalSection(&ddraw_cs); - if (This->use_vp2 != 0) { - ERR(" Requesting to get a D3DVIEWPORT struct where a D3DVIEWPORT2 was set !\n"); - LeaveCriticalSection(&ddraw_cs); - return DDERR_INVALIDPARAMS; - } dwSize = lpData->dwSize; memset(lpData, 0, dwSize); - memcpy(lpData, &(This->viewports.vp1), dwSize); + if (!This->use_vp2) + memcpy(lpData, &(This->viewports.vp1), dwSize); + else { + D3DVIEWPORT vp1; + vp1.dwSize = sizeof(vp1); + vp1.dwX = This->viewports.vp2.dwX; + vp1.dwY = This->viewports.vp2.dwY; + vp1.dwWidth = This->viewports.vp2.dwWidth; + vp1.dwHeight = This->viewports.vp2.dwHeight; + vp1.dvMaxX = 0.0; + vp1.dvMaxY = 0.0; + vp1.dvScaleX = 0.0; + vp1.dvScaleY = 0.0; + vp1.dvMinZ = This->viewports.vp2.dvMinZ; + vp1.dvMaxZ = This->viewports.vp2.dvMaxZ; + memcpy(lpData, &vp1, dwSize); + } if (TRACE_ON(d3d7)) { TRACE(" returning D3DVIEWPORT :\n"); @@ -908,14 +919,25 @@ IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface, TRACE("(%p)->(%p)\n", This, lpData); EnterCriticalSection(&ddraw_cs); - if (This->use_vp2 != 1) { - ERR(" Requesting to get a D3DVIEWPORT2 struct where a D3DVIEWPORT was set !\n"); - LeaveCriticalSection(&ddraw_cs); - return DDERR_INVALIDPARAMS; - } dwSize = lpData->dwSize; memset(lpData, 0, dwSize); - memcpy(lpData, &(This->viewports.vp2), dwSize); + if (This->use_vp2) + memcpy(lpData, &(This->viewports.vp2), dwSize); + else { + D3DVIEWPORT2 vp2; + vp2.dwSize = sizeof(vp2); + vp2.dwX = This->viewports.vp1.dwX; + vp2.dwY = This->viewports.vp1.dwY; + vp2.dwWidth = This->viewports.vp1.dwWidth; + vp2.dwHeight = This->viewports.vp1.dwHeight; + vp2.dvClipX = 0.0; + vp2.dvClipY = 0.0; + vp2.dvClipWidth = 0.0; + vp2.dvClipHeight = 0.0; + vp2.dvMinZ = This->viewports.vp1.dvMinZ; + vp2.dvMaxZ = This->viewports.vp1.dvMaxZ; + memcpy(lpData, &vp2, dwSize); + } if (TRACE_ON(d3d7)) { TRACE(" returning D3DVIEWPORT2 :\n"); diff --git a/reactos/dll/directx/wine/wined3d/arb_program_shader.c b/reactos/dll/directx/wine/wined3d/arb_program_shader.c index 1fdae2a4105..cf7638605eb 100644 --- a/reactos/dll/directx/wine/wined3d/arb_program_shader.c +++ b/reactos/dll/directx/wine/wined3d/arb_program_shader.c @@ -41,6 +41,45 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d); #define GLINFO_LOCATION (*gl_info) +/* Extract a line. Note that this modifies the source string. */ +static char *get_line(char **ptr) +{ + char *p, *q; + + p = *ptr; + if (!(q = strstr(p, "\n"))) + { + if (!*p) return NULL; + *ptr += strlen(p); + return p; + } + *q = '\0'; + *ptr = q + 1; + + return p; +} + +static void shader_arb_dump_program_source(const char *source) +{ + unsigned long source_size; + char *ptr, *line, *tmp; + + source_size = strlen(source) + 1; + tmp = HeapAlloc(GetProcessHeap(), 0, source_size); + if (!tmp) + { + ERR("Failed to allocate %lu bytes for shader source.\n", source_size); + return; + } + memcpy(tmp, source, source_size); + + ptr = tmp; + while ((line = get_line(&ptr))) FIXME(" %s\n", line); + FIXME("\n"); + + HeapFree(GetProcessHeap(), 0, tmp); +} + /* GL locking for state handlers is done by the caller. */ static BOOL need_mova_const(IWineD3DBaseShader *shader, const struct wined3d_gl_info *gl_info) { @@ -1122,10 +1161,10 @@ static void gen_color_correction(struct wined3d_shader_buffer *buffer, const cha { DWORD mask; - if (is_yuv_fixup(fixup)) + if (is_complex_fixup(fixup)) { - enum yuv_fixup yuv_fixup = get_yuv_fixup(fixup); - FIXME("YUV fixup (%#x) not supported\n", yuv_fixup); + enum complex_fixup complex_fixup = get_complex_fixup(fixup); + FIXME("Complex fixup (%#x) not supported\n", complex_fixup); return; } @@ -1761,8 +1800,8 @@ static void pshader_hw_texkill(const struct wined3d_shader_instruction *ins) static void pshader_hw_tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; const struct wined3d_shader_dst_param *dst = &ins->dst[0]; DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major, ins->ctx->reg_maps->shader_version.minor); @@ -1856,8 +1895,8 @@ static void pshader_hw_texcoord(const struct wined3d_shader_instruction *ins) static void pshader_hw_texreg2ar(const struct wined3d_shader_instruction *ins) { struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD flags; DWORD reg1 = ins->dst[0].reg.idx; @@ -1904,7 +1943,8 @@ static void pshader_hw_texreg2rgb(const struct wined3d_shader_instruction *ins) static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device; const struct wined3d_shader_dst_param *dst = &ins->dst[0]; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; char reg_coord[40], dst_reg[50], src_reg[50]; @@ -1936,8 +1976,8 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) /* with projective textures, texbem only divides the static texture coord, not the displacement, * so we can't let the GL handle this. */ - if (((IWineD3DDeviceImpl*) This->baseShader.device)->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] - & WINED3DTTFF_PROJECTED) { + if (device->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] & WINED3DTTFF_PROJECTED) + { shader_addline(buffer, "RCP TB.w, %s.w;\n", reg_coord); shader_addline(buffer, "MUL TB.xy, %s, TB.w;\n", reg_coord); shader_addline(buffer, "ADD TA.xy, TA, TB;\n"); @@ -1975,8 +2015,8 @@ static void pshader_hw_texm3x2pad(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -1997,10 +2037,10 @@ static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char src0_name[50], dst_name[50]; struct wined3d_shader_register tmp_reg = ins->dst[0].reg; BOOL is_color; @@ -2020,12 +2060,12 @@ static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char dst_str[50]; char src0_name[50], dst_name[50]; BOOL is_color; @@ -2043,12 +2083,12 @@ static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char dst_str[50]; char src0_name[50]; char dst_reg[50]; @@ -2085,11 +2125,11 @@ static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; char dst_str[50]; char src0_name[50]; @@ -3046,8 +3086,9 @@ static GLuint create_arb_blt_vertex_program(const struct wined3d_gl_info *gl_inf glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); if (pos != -1) { - FIXME("Vertex program error at position %d: %s\n", pos, + FIXME("Vertex program error at position %d: %s\n\n", pos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(blt_vprogram); } else { @@ -3108,8 +3149,9 @@ static GLuint create_arb_blt_fragment_program(const struct wined3d_gl_info *gl_i glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); if (pos != -1) { - FIXME("Fragment program error at position %d: %s\n", pos, + FIXME("Fragment program error at position %d: %s\n\n", pos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(blt_fprograms[tex_type]); } else { @@ -3564,8 +3606,9 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos); if (errPos != -1) { - FIXME("HW PixelShader Error at position %d: %s\n", + FIXME("HW PixelShader Error at position %d: %s\n\n", errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer->buffer); retval = 0; } else @@ -3974,8 +4017,9 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos); if (errPos != -1) { - FIXME("HW VertexShader Error at position %d: %s\n", + FIXME("HW VertexShader Error at position %d: %s\n\n", errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer->buffer); ret = -1; } else @@ -4448,8 +4492,7 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type)) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface; - struct arb_pshader_private *shader_data = This->baseShader.backend_data; + struct arb_pshader_private *shader_data = baseShader->baseShader.backend_data; UINT i; if(!shader_data) return; /* This can happen if a shader was never compiled */ @@ -4471,10 +4514,11 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); HeapFree(GetProcessHeap(), 0, shader_data); - This->baseShader.backend_data = NULL; - } else { - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *) iface; - struct arb_vshader_private *shader_data = This->baseShader.backend_data; + baseShader->baseShader.backend_data = NULL; + } + else + { + struct arb_vshader_private *shader_data = baseShader->baseShader.backend_data; UINT i; if(!shader_data) return; /* This can happen if a shader was never compiled */ @@ -4496,7 +4540,7 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); HeapFree(GetProcessHeap(), 0, shader_data); - This->baseShader.backend_data = NULL; + baseShader->baseShader.backend_data = NULL; } } @@ -4565,8 +4609,7 @@ static BOOL shader_arb_dirty_const(IWineD3DDevice *iface) { return TRUE; } -static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, - struct shader_caps *pCaps) +static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps) { DWORD vs_consts = min(gl_info->limits.arb_vs_float_constants, gl_info->limits.arb_vs_native_constants); DWORD ps_consts = min(gl_info->limits.arb_ps_float_constants, gl_info->limits.arb_ps_native_constants); @@ -4574,7 +4617,7 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_ /* We don't have an ARB fixed function pipeline yet, so let the none backend set its caps, * then overwrite the shader specific ones */ - none_shader_backend.shader_get_caps(devtype, gl_info, pCaps); + none_shader_backend.shader_get_caps(gl_info, pCaps); if (gl_info->supported[ARB_VERTEX_PROGRAM]) { @@ -4630,8 +4673,8 @@ static BOOL shader_arb_color_fixup_supported(struct color_fixup_desc fixup) dump_color_fixup_desc(fixup); } - /* We support everything except YUV conversions. */ - if (!is_yuv_fixup(fixup)) + /* We support everything except complex conversions. */ + if (!is_complex_fixup(fixup)) { TRACE("[OK]\n"); return TRUE; @@ -4678,6 +4721,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_CMP */ pshader_hw_cmp, /* WINED3DSIH_CND */ pshader_hw_cnd, /* WINED3DSIH_CRS */ shader_hw_map2gl, + /* WINED3DSIH_CUT */ NULL, /* WINED3DSIH_DCL */ NULL, /* WINED3DSIH_DEF */ NULL, /* WINED3DSIH_DEFB */ NULL, @@ -4689,20 +4733,24 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_DSX */ shader_hw_map2gl, /* WINED3DSIH_DSY */ shader_hw_dsy, /* WINED3DSIH_ELSE */ shader_hw_else, + /* WINED3DSIH_EMIT */ NULL, /* WINED3DSIH_ENDIF */ shader_hw_endif, /* WINED3DSIH_ENDLOOP */ shader_hw_endloop, /* WINED3DSIH_ENDREP */ shader_hw_endrep, /* WINED3DSIH_EXP */ shader_hw_scalar_op, /* WINED3DSIH_EXPP */ shader_hw_scalar_op, /* WINED3DSIH_FRC */ shader_hw_map2gl, + /* WINED3DSIH_IADD */ NULL, /* WINED3DSIH_IF */ NULL /* Hardcoded into the shader */, /* WINED3DSIH_IFC */ shader_hw_ifc, + /* WINED3DSIH_IGE */ NULL, /* WINED3DSIH_LABEL */ shader_hw_label, /* WINED3DSIH_LIT */ shader_hw_map2gl, /* WINED3DSIH_LOG */ shader_hw_log_pow, /* WINED3DSIH_LOGP */ shader_hw_log_pow, /* WINED3DSIH_LOOP */ shader_hw_loop, /* WINED3DSIH_LRP */ shader_hw_lrp, + /* WINED3DSIH_LT */ NULL, /* WINED3DSIH_M3x2 */ shader_hw_mnxn, /* WINED3DSIH_M3x3 */ shader_hw_mnxn, /* WINED3DSIH_M3x4 */ shader_hw_mnxn, @@ -5229,7 +5277,7 @@ static void arbfp_free(IWineD3DDevice *iface) { } } -static void arbfp_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) +static void arbfp_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) { caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE | WINED3DTEXOPCAPS_SELECTARG1 | @@ -5858,8 +5906,9 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); if (pos != -1) { - FIXME("Fragment program error at position %d: %s\n", pos, + FIXME("Fragment program error at position %d: %s\n\n", pos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer.buffer); } else { @@ -6180,6 +6229,7 @@ struct arbfp_blit_priv { GLenum yuy2_rect_shader, yuy2_2d_shader; GLenum uyvy_rect_shader, uyvy_2d_shader; GLenum yv12_rect_shader, yv12_2d_shader; + GLenum p8_rect_shader, p8_2d_shader; }; static HRESULT arbfp_blit_alloc(IWineD3DDevice *iface) { @@ -6204,20 +6254,22 @@ static void arbfp_blit_free(IWineD3DDevice *iface) { GL_EXTCALL(glDeleteProgramsARB(1, &priv->uyvy_2d_shader)); GL_EXTCALL(glDeleteProgramsARB(1, &priv->yv12_rect_shader)); GL_EXTCALL(glDeleteProgramsARB(1, &priv->yv12_2d_shader)); - checkGLcall("Delete yuv programs"); + GL_EXTCALL(glDeleteProgramsARB(1, &priv->p8_rect_shader)); + GL_EXTCALL(glDeleteProgramsARB(1, &priv->p8_2d_shader)); + checkGLcall("Delete yuv and p8 programs"); LEAVE_GL(); HeapFree(GetProcessHeap(), 0, device->blit_priv); device->blit_priv = NULL; } -static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum yuv_fixup yuv_fixup, +static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum complex_fixup fixup, GLenum textype, char *luminance) { char chroma; const char *tex, *texinstr; - if (yuv_fixup == YUV_FIXUP_UYVY) { + if (fixup == COMPLEX_FIXUP_UYVY) { chroma = 'x'; *luminance = 'w'; } else { @@ -6445,8 +6497,74 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, GLenum textype, return TRUE; } +static GLuint gen_p8_shader(IWineD3DDeviceImpl *device, GLenum textype) +{ + GLenum shader; + struct wined3d_shader_buffer buffer; + struct arbfp_blit_priv *priv = device->blit_priv; + GLint pos; + + /* Shader header */ + if (!shader_buffer_init(&buffer)) + { + ERR("Failed to initialize shader buffer.\n"); + return 0; + } + + ENTER_GL(); + GL_EXTCALL(glGenProgramsARB(1, &shader)); + GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader)); + LEAVE_GL(); + if(!shader) { + shader_buffer_free(&buffer); + return 0; + } + + shader_addline(&buffer, "!!ARBfp1.0\n"); + shader_addline(&buffer, "TEMP index;\n"); + + /* { 255/256, 0.5/255*255/256, 0, 0 } */ + shader_addline(&buffer, "PARAM constants = { 0.996, 0.00195, 0, 0 };\n"); + + /* The alpha-component contains the palette index */ + if(textype == GL_TEXTURE_RECTANGLE_ARB) + shader_addline(&buffer, "TXP index, fragment.texcoord[0], texture[0], RECT;\n"); + else + shader_addline(&buffer, "TEX index, fragment.texcoord[0], texture[0], 2D;\n"); + + /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */ + shader_addline(&buffer, "MAD index.a, index.a, constants.x, constants.y;\n"); + + /* Use the alpha-component as an index in the palette to get the final color */ + shader_addline(&buffer, "TEX result.color, index.a, texture[1], 1D;\n"); + shader_addline(&buffer, "END\n"); + + ENTER_GL(); + GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(buffer.buffer), buffer.buffer)); + checkGLcall("glProgramStringARB()"); + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); + if (pos != -1) + { + FIXME("Fragment program error at position %d: %s\n\n", pos, + debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer.buffer); + } + + if (textype == GL_TEXTURE_RECTANGLE_ARB) + priv->p8_rect_shader = shader; + else + priv->p8_2d_shader = shader; + + shader_buffer_free(&buffer); + LEAVE_GL(); + + return shader; +} + /* Context activation is done by the caller. */ -static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixup, GLenum textype) +static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum complex_fixup yuv_fixup, GLenum textype) { GLenum shader; struct wined3d_shader_buffer buffer; @@ -6519,8 +6637,8 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu switch (yuv_fixup) { - case YUV_FIXUP_UYVY: - case YUV_FIXUP_YUY2: + case COMPLEX_FIXUP_UYVY: + case COMPLEX_FIXUP_YUY2: if (!gen_planar_yuv_read(&buffer, yuv_fixup, textype, &luminance_component)) { shader_buffer_free(&buffer); @@ -6528,7 +6646,7 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu } break; - case YUV_FIXUP_YV12: + case COMPLEX_FIXUP_YV12: if (!gen_yv12_read(&buffer, textype, &luminance_component)) { shader_buffer_free(&buffer); @@ -6562,8 +6680,9 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); if (pos != -1) { - FIXME("Fragment program error at position %d: %s\n", pos, + FIXME("Fragment program error at position %d: %s\n\n", pos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer.buffer); } else { @@ -6579,20 +6698,22 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu switch (yuv_fixup) { - case YUV_FIXUP_YUY2: + case COMPLEX_FIXUP_YUY2: if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yuy2_rect_shader = shader; else priv->yuy2_2d_shader = shader; break; - case YUV_FIXUP_UYVY: + case COMPLEX_FIXUP_UYVY: if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->uyvy_rect_shader = shader; else priv->uyvy_2d_shader = shader; break; - case YUV_FIXUP_YV12: + case COMPLEX_FIXUP_YV12: if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yv12_rect_shader = shader; else priv->yv12_2d_shader = shader; break; + default: + ERR("Unsupported complex fixup: %d\n", yuv_fixup); } return shader; @@ -6606,9 +6727,9 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatD IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface; float size[4] = {width, height, 1, 1}; struct arbfp_blit_priv *priv = device->blit_priv; - enum yuv_fixup yuv_fixup; + enum complex_fixup fixup; - if (!is_yuv_fixup(format_desc->color_fixup)) + if (!is_complex_fixup(format_desc->color_fixup)) { TRACE("Fixup:\n"); dump_color_fixup_desc(format_desc->color_fixup); @@ -6620,24 +6741,29 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatD return WINED3D_OK; } - yuv_fixup = get_yuv_fixup(format_desc->color_fixup); + fixup = get_complex_fixup(format_desc->color_fixup); - switch(yuv_fixup) + switch(fixup) { - case YUV_FIXUP_YUY2: + case COMPLEX_FIXUP_YUY2: shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yuy2_rect_shader : priv->yuy2_2d_shader; break; - case YUV_FIXUP_UYVY: + case COMPLEX_FIXUP_UYVY: shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->uyvy_rect_shader : priv->uyvy_2d_shader; break; - case YUV_FIXUP_YV12: + case COMPLEX_FIXUP_YV12: shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yv12_rect_shader : priv->yv12_2d_shader; break; + case COMPLEX_FIXUP_P8: + shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->p8_rect_shader : priv->p8_2d_shader; + if (!shader) shader = gen_p8_shader(device, textype); + break; + default: - FIXME("Unsupported YUV fixup %#x, not setting a shader\n", yuv_fixup); + FIXME("Unsupported complex fixup %#x, not setting a shader\n", fixup); ENTER_GL(); glEnable(textype); checkGLcall("glEnable(textype)"); @@ -6645,7 +6771,7 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatD return E_NOTIMPL; } - if (!shader) shader = gen_yuv_shader(device, yuv_fixup, textype); + if (!shader) shader = gen_yuv_shader(device, fixup, textype); ENTER_GL(); glEnable(GL_FRAGMENT_PROGRAM_ARB); @@ -6684,7 +6810,7 @@ static void arbfp_blit_unset(IWineD3DDevice *iface) { static BOOL arbfp_blit_color_fixup_supported(struct color_fixup_desc fixup) { - enum yuv_fixup yuv_fixup; + enum complex_fixup complex_fixup; if (TRACE_ON(d3d_shader) && TRACE_ON(d3d)) { @@ -6699,23 +6825,24 @@ static BOOL arbfp_blit_color_fixup_supported(struct color_fixup_desc fixup) } /* We only support YUV conversions. */ - if (!is_yuv_fixup(fixup)) + if (!is_complex_fixup(fixup)) { TRACE("[FAILED]\n"); return FALSE; } - yuv_fixup = get_yuv_fixup(fixup); - switch(yuv_fixup) + complex_fixup = get_complex_fixup(fixup); + switch(complex_fixup) { - case YUV_FIXUP_YUY2: - case YUV_FIXUP_UYVY: - case YUV_FIXUP_YV12: + case COMPLEX_FIXUP_YUY2: + case COMPLEX_FIXUP_UYVY: + case COMPLEX_FIXUP_YV12: + case COMPLEX_FIXUP_P8: TRACE("[OK]\n"); return TRUE; default: - FIXME("Unsupported YUV fixup %#x\n", yuv_fixup); + FIXME("Unsupported YUV fixup %#x\n", complex_fixup); TRACE("[FAILED]\n"); return FALSE; } diff --git a/reactos/dll/directx/wine/wined3d/ati_fragment_shader.c b/reactos/dll/directx/wine/wined3d/ati_fragment_shader.c index becd4475d0a..0f911e9dc15 100644 --- a/reactos/dll/directx/wine/wined3d/ati_fragment_shader.c +++ b/reactos/dll/directx/wine/wined3d/ati_fragment_shader.c @@ -1061,7 +1061,7 @@ static void atifs_enable(IWineD3DDevice *iface, BOOL enable) { LEAVE_GL(); } -static void atifs_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) +static void atifs_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) { caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE | WINED3DTEXOPCAPS_SELECTARG1 | diff --git a/reactos/dll/directx/wine/wined3d/baseshader.c b/reactos/dll/directx/wine/wined3d/baseshader.c deleted file mode 100644 index 14416c47197..00000000000 --- a/reactos/dll/directx/wine/wined3d/baseshader.c +++ /dev/null @@ -1,1439 +0,0 @@ -/* - * shaders implementation - * - * Copyright 2002-2003 Jason Edmeades - * Copyright 2002-2003 Raphael Junqueira - * Copyright 2004 Christian Costa - * Copyright 2005 Oliver Stieber - * Copyright 2006 Ivan Gyurdiev - * Copyright 2007-2008 Stefan Dösinger for CodeWeavers - * Copyright 2009 Henri Verbeet for CodeWeavers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "config.h" -#include -#include -#include "wined3d_private.h" - -WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); -WINE_DECLARE_DEBUG_CHANNEL(d3d); - -static const char *shader_opcode_names[] = -{ - /* WINED3DSIH_ABS */ "abs", - /* WINED3DSIH_ADD */ "add", - /* WINED3DSIH_BEM */ "bem", - /* WINED3DSIH_BREAK */ "break", - /* WINED3DSIH_BREAKC */ "breakc", - /* WINED3DSIH_BREAKP */ "breakp", - /* WINED3DSIH_CALL */ "call", - /* WINED3DSIH_CALLNZ */ "callnz", - /* WINED3DSIH_CMP */ "cmp", - /* WINED3DSIH_CND */ "cnd", - /* WINED3DSIH_CRS */ "crs", - /* WINED3DSIH_DCL */ "dcl", - /* WINED3DSIH_DEF */ "def", - /* WINED3DSIH_DEFB */ "defb", - /* WINED3DSIH_DEFI */ "defi", - /* WINED3DSIH_DP2ADD */ "dp2add", - /* WINED3DSIH_DP3 */ "dp3", - /* WINED3DSIH_DP4 */ "dp4", - /* WINED3DSIH_DST */ "dst", - /* WINED3DSIH_DSX */ "dsx", - /* WINED3DSIH_DSY */ "dsy", - /* WINED3DSIH_ELSE */ "else", - /* WINED3DSIH_ENDIF */ "endif", - /* WINED3DSIH_ENDLOOP */ "endloop", - /* WINED3DSIH_ENDREP */ "endrep", - /* WINED3DSIH_EXP */ "exp", - /* WINED3DSIH_EXPP */ "expp", - /* WINED3DSIH_FRC */ "frc", - /* WINED3DSIH_IF */ "if", - /* WINED3DSIH_IFC */ "ifc", - /* WINED3DSIH_LABEL */ "label", - /* WINED3DSIH_LIT */ "lit", - /* WINED3DSIH_LOG */ "log", - /* WINED3DSIH_LOGP */ "logp", - /* WINED3DSIH_LOOP */ "loop", - /* WINED3DSIH_LRP */ "lrp", - /* WINED3DSIH_M3x2 */ "m3x2", - /* WINED3DSIH_M3x3 */ "m3x3", - /* WINED3DSIH_M3x4 */ "m3x4", - /* WINED3DSIH_M4x3 */ "m4x3", - /* WINED3DSIH_M4x4 */ "m4x4", - /* WINED3DSIH_MAD */ "mad", - /* WINED3DSIH_MAX */ "max", - /* WINED3DSIH_MIN */ "min", - /* WINED3DSIH_MOV */ "mov", - /* WINED3DSIH_MOVA */ "mova", - /* WINED3DSIH_MUL */ "mul", - /* WINED3DSIH_NOP */ "nop", - /* WINED3DSIH_NRM */ "nrm", - /* WINED3DSIH_PHASE */ "phase", - /* WINED3DSIH_POW */ "pow", - /* WINED3DSIH_RCP */ "rcp", - /* WINED3DSIH_REP */ "rep", - /* WINED3DSIH_RET */ "ret", - /* WINED3DSIH_RSQ */ "rsq", - /* WINED3DSIH_SETP */ "setp", - /* WINED3DSIH_SGE */ "sge", - /* WINED3DSIH_SGN */ "sgn", - /* WINED3DSIH_SINCOS */ "sincos", - /* WINED3DSIH_SLT */ "slt", - /* WINED3DSIH_SUB */ "sub", - /* WINED3DSIH_TEX */ "texld", - /* WINED3DSIH_TEXBEM */ "texbem", - /* WINED3DSIH_TEXBEML */ "texbeml", - /* WINED3DSIH_TEXCOORD */ "texcrd", - /* WINED3DSIH_TEXDEPTH */ "texdepth", - /* WINED3DSIH_TEXDP3 */ "texdp3", - /* WINED3DSIH_TEXDP3TEX */ "texdp3tex", - /* WINED3DSIH_TEXKILL */ "texkill", - /* WINED3DSIH_TEXLDD */ "texldd", - /* WINED3DSIH_TEXLDL */ "texldl", - /* WINED3DSIH_TEXM3x2DEPTH */ "texm3x2depth", - /* WINED3DSIH_TEXM3x2PAD */ "texm3x2pad", - /* WINED3DSIH_TEXM3x2TEX */ "texm3x2tex", - /* WINED3DSIH_TEXM3x3 */ "texm3x3", - /* WINED3DSIH_TEXM3x3DIFF */ "texm3x3diff", - /* WINED3DSIH_TEXM3x3PAD */ "texm3x3pad", - /* WINED3DSIH_TEXM3x3SPEC */ "texm3x3spec", - /* WINED3DSIH_TEXM3x3TEX */ "texm3x3tex", - /* WINED3DSIH_TEXM3x3VSPEC */ "texm3x3vspec", - /* WINED3DSIH_TEXREG2AR */ "texreg2ar", - /* WINED3DSIH_TEXREG2GB */ "texreg2gb", - /* WINED3DSIH_TEXREG2RGB */ "texreg2rgb", -}; - -const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) -{ - switch (version_token >> 16) - { - case WINED3D_SM1_VS: - case WINED3D_SM1_PS: - return &sm1_shader_frontend; - - case WINED3D_SM4_PS: - case WINED3D_SM4_VS: - case WINED3D_SM4_GS: - return &sm4_shader_frontend; - - default: - FIXME("Unrecognised version token %#x\n", version_token); - return NULL; - } -} - -void shader_buffer_clear(struct wined3d_shader_buffer *buffer) -{ - buffer->buffer[0] = '\0'; - buffer->bsize = 0; - buffer->lineNo = 0; - buffer->newline = TRUE; -} - -BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) -{ - buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE); - if (!buffer->buffer) - { - ERR("Failed to allocate shader buffer memory.\n"); - return FALSE; - } - - shader_buffer_clear(buffer); - return TRUE; -} - -void shader_buffer_free(struct wined3d_shader_buffer *buffer) -{ - HeapFree(GetProcessHeap(), 0, buffer->buffer); -} - -int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *format, va_list args) -{ - char* base = buffer->buffer + buffer->bsize; - int rc; - - rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args); - - if (rc < 0 /* C89 */ || (unsigned int)rc > SHADER_PGMSIZE - 1 - buffer->bsize /* C99 */) - { - ERR("The buffer allocated for the shader program string " - "is too small at %d bytes.\n", SHADER_PGMSIZE); - buffer->bsize = SHADER_PGMSIZE - 1; - return -1; - } - - if (buffer->newline) { - TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base); - buffer->newline = FALSE; - } else { - TRACE("%s", base); - } - - buffer->bsize += rc; - if (buffer->buffer[buffer->bsize-1] == '\n') { - buffer->lineNo++; - buffer->newline = TRUE; - } - return 0; -} - -int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...) -{ - int ret; - va_list args; - - va_start(args, format); - ret = shader_vaddline(buffer, format, args); - va_end(args); - - return ret; -} - -void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device, - IUnknown *parent, const struct wined3d_parent_ops *parent_ops) -{ - shader->ref = 1; - shader->device = (IWineD3DDevice *)device; - shader->parent = parent; - shader->parent_ops = parent_ops; - list_init(&shader->linked_programs); - list_add_head(&device->shaders, &shader->shader_list_entry); -} - -/* Convert floating point offset relative - * to a register file to an absolute offset for float constants */ -static unsigned int shader_get_float_offset(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx) -{ - switch (register_type) - { - case WINED3DSPR_CONST: return register_idx; - case WINED3DSPR_CONST2: return 2048 + register_idx; - case WINED3DSPR_CONST3: return 4096 + register_idx; - case WINED3DSPR_CONST4: return 6144 + register_idx; - default: - FIXME("Unsupported register type: %d\n", register_type); - return register_idx; - } -} - -static void shader_delete_constant_list(struct list* clist) { - - struct list *ptr; - struct local_constant* constant; - - ptr = list_head(clist); - while (ptr) { - constant = LIST_ENTRY(ptr, struct local_constant, entry); - ptr = list_next(clist, ptr); - HeapFree(GetProcessHeap(), 0, constant); - } - list_init(clist); -} - -static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit) -{ - DWORD idx, shift; - idx = bit >> 5; - shift = bit & 0x1f; - bitmap[idx] |= (1 << shift); -} - -static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct shader_reg_maps *reg_maps, - const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type) -{ - switch (reg->type) - { - case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */ - if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx; - else reg_maps->address |= 1 << reg->idx; - break; - - case WINED3DSPR_TEMP: - reg_maps->temporary |= 1 << reg->idx; - break; - - case WINED3DSPR_INPUT: - if (shader_type == WINED3D_SHADER_TYPE_PIXEL) - { - if (reg->rel_addr) - { - /* If relative addressing is used, we must assume that all registers - * are used. Even if it is a construct like v3[aL], we can't assume - * that v0, v1 and v2 aren't read because aL can be negative */ - unsigned int i; - for (i = 0; i < MAX_REG_INPUT; ++i) - { - ((IWineD3DPixelShaderImpl *)This)->input_reg_used[i] = TRUE; - } - } - else - { - ((IWineD3DPixelShaderImpl *)This)->input_reg_used[reg->idx] = TRUE; - } - } - else reg_maps->input_registers |= 1 << reg->idx; - break; - - case WINED3DSPR_RASTOUT: - if (reg->idx == 1) reg_maps->fog = 1; - break; - - case WINED3DSPR_MISCTYPE: - if (shader_type == WINED3D_SHADER_TYPE_PIXEL) - { - if (reg->idx == 0) reg_maps->vpos = 1; - else if (reg->idx == 1) reg_maps->usesfacing = 1; - } - break; - - case WINED3DSPR_CONST: - if (reg->rel_addr) - { - if (shader_type != WINED3D_SHADER_TYPE_PIXEL) - { - if (reg->idx < ((IWineD3DVertexShaderImpl *)This)->min_rel_offset) - { - ((IWineD3DVertexShaderImpl *)This)->min_rel_offset = reg->idx; - } - if (reg->idx > ((IWineD3DVertexShaderImpl *)This)->max_rel_offset) - { - ((IWineD3DVertexShaderImpl *)This)->max_rel_offset = reg->idx; - } - } - reg_maps->usesrelconstF = TRUE; - } - else - { - set_bitmap_bit(reg_maps->constf, reg->idx); - } - break; - - case WINED3DSPR_CONSTINT: - reg_maps->integer_constants |= (1 << reg->idx); - break; - - case WINED3DSPR_CONSTBOOL: - reg_maps->boolean_constants |= (1 << reg->idx); - break; - - case WINED3DSPR_COLOROUT: - reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx); - break; - - default: - TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx); - break; - } -} - -static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param) -{ - switch(instr) - { - case WINED3DSIH_M4x4: - case WINED3DSIH_M3x4: - return param == 1 ? 3 : 0; - - case WINED3DSIH_M4x3: - case WINED3DSIH_M3x3: - return param == 1 ? 2 : 0; - - case WINED3DSIH_M3x2: - return param == 1 ? 1 : 0; - - default: - return 0; - } -} - -static const char *semantic_names[] = -{ - /* WINED3DDECLUSAGE_POSITION */ "SV_POSITION", - /* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT", - /* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES", - /* WINED3DDECLUSAGE_NORMAL */ "NORMAL", - /* WINED3DDECLUSAGE_PSIZE */ "PSIZE", - /* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD", - /* WINED3DDECLUSAGE_TANGENT */ "TANGENT", - /* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL", - /* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR", - /* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT", - /* WINED3DDECLUSAGE_COLOR */ "COLOR", - /* WINED3DDECLUSAGE_FOG */ "FOG", - /* WINED3DDECLUSAGE_DEPTH */ "DEPTH", - /* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE", -}; - -static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage) -{ - if (usage >= sizeof(semantic_names) / sizeof(*semantic_names)) - { - FIXME("Unrecognized usage %#x\n", usage); - return "UNRECOGNIZED"; - } - - return semantic_names[usage]; -} - -WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *name) -{ - unsigned int i; - - for (i = 0; i < sizeof(semantic_names) / sizeof(*semantic_names); ++i) - { - if (!strcmp(name, semantic_names[i])) return i; - } - - return ~0U; -} - -BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) -{ - return !strcmp(semantic_name, shader_semantic_name_from_usage(usage)); -} - -static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e, - const struct wined3d_shader_semantic *s) -{ - e->semantic_name = shader_semantic_name_from_usage(s->usage); - e->semantic_idx = s->usage_idx; - e->sysval_semantic = 0; - e->component_type = 0; - e->register_idx = s->reg.reg.idx; - e->mask = s->reg.write_mask; -} - -/* Note that this does not count the loop register - * as an address register. */ - -HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, - struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature, - struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size) -{ - IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; - void *fe_data = This->baseShader.frontend_data; - struct wined3d_shader_version shader_version; - unsigned int cur_loop_depth = 0, max_loop_depth = 0; - const DWORD* pToken = byte_code; - - /* There are some minor differences between pixel and vertex shaders */ - - memset(reg_maps, 0, sizeof(*reg_maps)); - - /* get_registers_used is called on every compile on some 1.x shaders, which can result - * in stacking up a collection of local constants. Delete the old constants if existing - */ - shader_delete_constant_list(&This->baseShader.constantsF); - shader_delete_constant_list(&This->baseShader.constantsB); - shader_delete_constant_list(&This->baseShader.constantsI); - - fe->shader_read_header(fe_data, &pToken, &shader_version); - reg_maps->shader_version = shader_version; - - reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(*reg_maps->constf) * ((constf_size + 31) / 32)); - if(!reg_maps->constf) { - ERR("Out of memory\n"); - return E_OUTOFMEMORY; - } - - while (!fe->shader_is_end(fe_data, &pToken)) - { - struct wined3d_shader_instruction ins; - const char *comment; - UINT param_size; - - /* Skip comments */ - fe->shader_read_comment(&pToken, &comment); - if (comment) continue; - - /* Fetch opcode */ - fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size); - - /* Unhandled opcode, and its parameters */ - if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) - { - TRACE("Skipping unrecognized instruction.\n"); - pToken += param_size; - continue; - } - - /* Handle declarations */ - if (ins.handler_idx == WINED3DSIH_DCL) - { - struct wined3d_shader_semantic semantic; - - fe->shader_read_semantic(&pToken, &semantic); - - switch (semantic.reg.reg.type) - { - /* Mark input registers used. */ - case WINED3DSPR_INPUT: - reg_maps->input_registers |= 1 << semantic.reg.reg.idx; - shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic); - break; - - /* Vshader: mark 3.0 output registers used, save token */ - case WINED3DSPR_OUTPUT: - reg_maps->output_registers |= 1 << semantic.reg.reg.idx; - shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic); - if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1; - break; - - /* Save sampler usage token */ - case WINED3DSPR_SAMPLER: - reg_maps->sampler_type[semantic.reg.reg.idx] = semantic.sampler_type; - break; - - default: - TRACE("Not recording DCL register type %#x.\n", semantic.reg.reg.type); - break; - } - } - else if (ins.handler_idx == WINED3DSIH_DEF) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); - if (!lconst) return E_OUTOFMEMORY; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - lconst->idx = dst.reg.idx; - - memcpy(lconst->value, pToken, 4 * sizeof(DWORD)); - pToken += 4; - - /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */ - if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL) - { - float *value = (float *) lconst->value; - if (value[0] < -1.0f) value[0] = -1.0f; - else if (value[0] > 1.0f) value[0] = 1.0f; - if (value[1] < -1.0f) value[1] = -1.0f; - else if (value[1] > 1.0f) value[1] = 1.0f; - if (value[2] < -1.0f) value[2] = -1.0f; - else if (value[2] > 1.0f) value[2] = 1.0f; - if (value[3] < -1.0f) value[3] = -1.0f; - else if (value[3] > 1.0f) value[3] = 1.0f; - } - - list_add_head(&This->baseShader.constantsF, &lconst->entry); - } - else if (ins.handler_idx == WINED3DSIH_DEFI) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); - if (!lconst) return E_OUTOFMEMORY; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - lconst->idx = dst.reg.idx; - - memcpy(lconst->value, pToken, 4 * sizeof(DWORD)); - pToken += 4; - - list_add_head(&This->baseShader.constantsI, &lconst->entry); - reg_maps->local_int_consts |= (1 << dst.reg.idx); - } - else if (ins.handler_idx == WINED3DSIH_DEFB) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); - if (!lconst) return E_OUTOFMEMORY; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - lconst->idx = dst.reg.idx; - - memcpy(lconst->value, pToken, sizeof(DWORD)); - ++pToken; - - list_add_head(&This->baseShader.constantsB, &lconst->entry); - reg_maps->local_bool_consts |= (1 << dst.reg.idx); - } - /* If there's a loop in the shader */ - else if (ins.handler_idx == WINED3DSIH_LOOP - || ins.handler_idx == WINED3DSIH_REP) - { - struct wined3d_shader_src_param src, rel_addr; - - fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr); - - /* Rep and Loop always use an integer constant for the control parameters */ - if (ins.handler_idx == WINED3DSIH_REP) - { - reg_maps->integer_constants |= 1 << src.reg.idx; - } - else - { - fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr); - reg_maps->integer_constants |= 1 << src.reg.idx; - } - - cur_loop_depth++; - if(cur_loop_depth > max_loop_depth) - max_loop_depth = cur_loop_depth; - } - else if (ins.handler_idx == WINED3DSIH_ENDLOOP - || ins.handler_idx == WINED3DSIH_ENDREP) - { - cur_loop_depth--; - } - /* For subroutine prototypes */ - else if (ins.handler_idx == WINED3DSIH_LABEL) - { - struct wined3d_shader_src_param src, rel_addr; - - fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr); - reg_maps->labels |= 1 << src.reg.idx; - } - /* Set texture, address, temporary registers */ - else - { - int i, limit; - BOOL color0_mov = FALSE; - - /* This will loop over all the registers and try to - * make a bitmask of the ones we're interested in. - * - * Relative addressing tokens are ignored, but that's - * okay, since we'll catch any address registers when - * they are initialized (required by spec) */ - - if (ins.dst_count) - { - struct wined3d_shader_dst_param dst_param; - struct wined3d_shader_src_param dst_rel_addr; - - fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr); - - shader_record_register_usage(This, reg_maps, &dst_param.reg, shader_version.type); - - /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and - * is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel - * shaders because TECRDOUT isn't used in them, but future register types might cause issues */ - if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX && shader_version.major < 3 - && dst_param.reg.type == WINED3DSPR_TEXCRDOUT) - { - reg_maps->texcoord_mask[dst_param.reg.idx] |= dst_param.write_mask; - } - - if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL) - { - IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)This; - - if(dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0) - { - /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to - * COLOROUT 0. If we know this in advance, the ARB shader backend can skip - * the mov and perform the sRGB write correction from the source register. - * - * However, if the mov is only partial, we can't do this, and if the write - * comes from an instruction other than MOV it is hard to do as well. If - * COLOROUT 0 is overwritten partially later, the marker is dropped again. */ - - ps->color0_mov = FALSE; - if (ins.handler_idx == WINED3DSIH_MOV) - { - /* Used later when the source register is read. */ - color0_mov = TRUE; - } - } - /* Also drop the MOV marker if the source register is overwritten prior to the shader - * end - */ - else if(dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg) - { - ps->color0_mov = FALSE; - } - } - - /* Declare 1.X samplers implicitly, based on the destination reg. number */ - if (shader_version.major == 1 - && (ins.handler_idx == WINED3DSIH_TEX - || ins.handler_idx == WINED3DSIH_TEXBEM - || ins.handler_idx == WINED3DSIH_TEXBEML - || ins.handler_idx == WINED3DSIH_TEXDP3TEX - || ins.handler_idx == WINED3DSIH_TEXM3x2TEX - || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC - || ins.handler_idx == WINED3DSIH_TEXM3x3TEX - || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC - || ins.handler_idx == WINED3DSIH_TEXREG2AR - || ins.handler_idx == WINED3DSIH_TEXREG2GB - || ins.handler_idx == WINED3DSIH_TEXREG2RGB)) - { - /* Fake sampler usage, only set reserved bit and ttype */ - DWORD sampler_code = dst_param.reg.idx; - - TRACE("Setting fake 2D sampler for 1.x pixelshader\n"); - reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D; - - /* texbem is only valid with < 1.4 pixel shaders */ - if (ins.handler_idx == WINED3DSIH_TEXBEM - || ins.handler_idx == WINED3DSIH_TEXBEML) - { - reg_maps->bumpmat |= 1 << dst_param.reg.idx; - if (ins.handler_idx == WINED3DSIH_TEXBEML) - { - reg_maps->luminanceparams |= 1 << dst_param.reg.idx; - } - } - } - else if (ins.handler_idx == WINED3DSIH_BEM) - { - reg_maps->bumpmat |= 1 << dst_param.reg.idx; - } - } - - if (ins.handler_idx == WINED3DSIH_NRM) - { - reg_maps->usesnrm = 1; - } - else if (ins.handler_idx == WINED3DSIH_DSY) - { - reg_maps->usesdsy = 1; - } - else if (ins.handler_idx == WINED3DSIH_DSX) - { - reg_maps->usesdsx = 1; - } - else if(ins.handler_idx == WINED3DSIH_TEXLDD) - { - reg_maps->usestexldd = 1; - } - else if(ins.handler_idx == WINED3DSIH_TEXLDL) - { - reg_maps->usestexldl = 1; - } - else if(ins.handler_idx == WINED3DSIH_MOVA) - { - reg_maps->usesmova = 1; - } - else if(ins.handler_idx == WINED3DSIH_IFC) - { - reg_maps->usesifc = 1; - } - else if(ins.handler_idx == WINED3DSIH_CALL) - { - reg_maps->usescall = 1; - } - - limit = ins.src_count + (ins.predicate ? 1 : 0); - for (i = 0; i < limit; ++i) - { - struct wined3d_shader_src_param src_param, src_rel_addr; - unsigned int count; - - fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr); - count = get_instr_extra_regcount(ins.handler_idx, i); - - shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type); - while (count) - { - ++src_param.reg.idx; - shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type); - --count; - } - - if(color0_mov) - { - IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) This; - if(src_param.reg.type == WINED3DSPR_TEMP && - src_param.swizzle == WINED3DSP_NOSWIZZLE) - { - ps->color0_mov = TRUE; - ps->color0_reg = src_param.reg.idx; - } - } - } - } - } - reg_maps->loop_depth = max_loop_depth; - - This->baseShader.functionLength = ((const char *)pToken - (const char *)byte_code); - - return WINED3D_OK; -} - -unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) -{ - DWORD map = 1 << max; - map |= map - 1; - map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers; - - return wined3d_log2i(map); -} - -static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic, - const struct wined3d_shader_version *shader_version) -{ - TRACE("dcl"); - - if (semantic->reg.reg.type == WINED3DSPR_SAMPLER) - { - switch (semantic->sampler_type) - { - case WINED3DSTT_2D: TRACE("_2d"); break; - case WINED3DSTT_CUBE: TRACE("_cube"); break; - case WINED3DSTT_VOLUME: TRACE("_volume"); break; - default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type); - } - } - else - { - /* Pixel shaders 3.0 don't have usage semantics */ - if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL) - return; - else - TRACE("_"); - - switch (semantic->usage) - { - case WINED3DDECLUSAGE_POSITION: - TRACE("position%d", semantic->usage_idx); - break; - case WINED3DDECLUSAGE_BLENDINDICES: - TRACE("blend"); - break; - case WINED3DDECLUSAGE_BLENDWEIGHT: - TRACE("weight"); - break; - case WINED3DDECLUSAGE_NORMAL: - TRACE("normal%d", semantic->usage_idx); - break; - case WINED3DDECLUSAGE_PSIZE: - TRACE("psize"); - break; - case WINED3DDECLUSAGE_COLOR: - if (semantic->usage_idx == 0) TRACE("color"); - else TRACE("specular%d", (semantic->usage_idx - 1)); - break; - case WINED3DDECLUSAGE_TEXCOORD: - TRACE("texture%d", semantic->usage_idx); - break; - case WINED3DDECLUSAGE_TANGENT: - TRACE("tangent"); - break; - case WINED3DDECLUSAGE_BINORMAL: - TRACE("binormal"); - break; - case WINED3DDECLUSAGE_TESSFACTOR: - TRACE("tessfactor"); - break; - case WINED3DDECLUSAGE_POSITIONT: - TRACE("positionT%d", semantic->usage_idx); - break; - case WINED3DDECLUSAGE_FOG: - TRACE("fog"); - break; - case WINED3DDECLUSAGE_DEPTH: - TRACE("depth"); - break; - case WINED3DDECLUSAGE_SAMPLE: - TRACE("sample"); - break; - default: - FIXME("unknown_semantics(0x%08x)", semantic->usage); - } - } -} - -static void shader_dump_register(const struct wined3d_shader_register *reg, - const struct wined3d_shader_version *shader_version) -{ - static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"}; - static const char * const misctype_reg_names[] = {"vPos", "vFace"}; - UINT offset = reg->idx; - - switch (reg->type) - { - case WINED3DSPR_TEMP: - TRACE("r"); - break; - - case WINED3DSPR_INPUT: - TRACE("v"); - break; - - case WINED3DSPR_CONST: - case WINED3DSPR_CONST2: - case WINED3DSPR_CONST3: - case WINED3DSPR_CONST4: - TRACE("c"); - offset = shader_get_float_offset(reg->type, reg->idx); - break; - - case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */ - TRACE("%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a'); - break; - - case WINED3DSPR_RASTOUT: - TRACE("%s", rastout_reg_names[reg->idx]); - break; - - case WINED3DSPR_COLOROUT: - TRACE("oC"); - break; - - case WINED3DSPR_DEPTHOUT: - TRACE("oDepth"); - break; - - case WINED3DSPR_ATTROUT: - TRACE("oD"); - break; - - case WINED3DSPR_TEXCRDOUT: - /* Vertex shaders >= 3.0 use general purpose output registers - * (WINED3DSPR_OUTPUT), which can include an address token */ - if (shader_version->major >= 3) TRACE("o"); - else TRACE("oT"); - break; - - case WINED3DSPR_CONSTINT: - TRACE("i"); - break; - - case WINED3DSPR_CONSTBOOL: - TRACE("b"); - break; - - case WINED3DSPR_LABEL: - TRACE("l"); - break; - - case WINED3DSPR_LOOP: - TRACE("aL"); - break; - - case WINED3DSPR_SAMPLER: - TRACE("s"); - break; - - case WINED3DSPR_MISCTYPE: - if (reg->idx > 1) FIXME("Unhandled misctype register %d\n", reg->idx); - else TRACE("%s", misctype_reg_names[reg->idx]); - break; - - case WINED3DSPR_PREDICATE: - TRACE("p"); - break; - - case WINED3DSPR_IMMCONST: - TRACE("l"); - break; - - case WINED3DSPR_CONSTBUFFER: - TRACE("cb"); - break; - - default: - TRACE("unhandled_rtype(%#x)", reg->type); - break; - } - - if (reg->type == WINED3DSPR_IMMCONST) - { - TRACE("("); - switch (reg->immconst_type) - { - case WINED3D_IMMCONST_FLOAT: - TRACE("%.8e", *(const float *)reg->immconst_data); - break; - - case WINED3D_IMMCONST_FLOAT4: - TRACE("%.8e, %.8e, %.8e, %.8e", - *(const float *)®->immconst_data[0], *(const float *)®->immconst_data[1], - *(const float *)®->immconst_data[2], *(const float *)®->immconst_data[3]); - break; - - default: - TRACE("", reg->immconst_type); - break; - } - TRACE(")"); - } - else if (reg->type != WINED3DSPR_RASTOUT && reg->type != WINED3DSPR_MISCTYPE) - { - if (reg->array_idx != ~0U) - { - TRACE("%u[%u", offset, reg->array_idx); - if (reg->rel_addr) - { - TRACE(" + "); - shader_dump_src_param(reg->rel_addr, shader_version); - } - TRACE("]"); - } - else - { - if (reg->rel_addr) - { - TRACE("["); - shader_dump_src_param(reg->rel_addr, shader_version); - TRACE(" + "); - } - TRACE("%u", offset); - if (reg->rel_addr) TRACE("]"); - } - } -} - -void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, - const struct wined3d_shader_version *shader_version) -{ - DWORD write_mask = param->write_mask; - - shader_dump_register(¶m->reg, shader_version); - - if (write_mask != WINED3DSP_WRITEMASK_ALL) - { - static const char *write_mask_chars = "xyzw"; - - TRACE("."); - if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]); - if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]); - if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]); - if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]); - } -} - -void shader_dump_src_param(const struct wined3d_shader_src_param *param, - const struct wined3d_shader_version *shader_version) -{ - DWORD src_modifier = param->modifiers; - DWORD swizzle = param->swizzle; - - if (src_modifier == WINED3DSPSM_NEG - || src_modifier == WINED3DSPSM_BIASNEG - || src_modifier == WINED3DSPSM_SIGNNEG - || src_modifier == WINED3DSPSM_X2NEG - || src_modifier == WINED3DSPSM_ABSNEG) - TRACE("-"); - else if (src_modifier == WINED3DSPSM_COMP) - TRACE("1-"); - else if (src_modifier == WINED3DSPSM_NOT) - TRACE("!"); - - if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG) - TRACE("abs("); - - shader_dump_register(¶m->reg, shader_version); - - if (src_modifier) - { - switch (src_modifier) - { - case WINED3DSPSM_NONE: break; - case WINED3DSPSM_NEG: break; - case WINED3DSPSM_NOT: break; - case WINED3DSPSM_BIAS: TRACE("_bias"); break; - case WINED3DSPSM_BIASNEG: TRACE("_bias"); break; - case WINED3DSPSM_SIGN: TRACE("_bx2"); break; - case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break; - case WINED3DSPSM_COMP: break; - case WINED3DSPSM_X2: TRACE("_x2"); break; - case WINED3DSPSM_X2NEG: TRACE("_x2"); break; - case WINED3DSPSM_DZ: TRACE("_dz"); break; - case WINED3DSPSM_DW: TRACE("_dw"); break; - case WINED3DSPSM_ABSNEG: TRACE(")"); break; - case WINED3DSPSM_ABS: TRACE(")"); break; - default: - TRACE("_unknown_modifier(%#x)", src_modifier); - } - } - - if (swizzle != WINED3DSP_NOSWIZZLE) - { - static const char *swizzle_chars = "xyzw"; - DWORD swizzle_x = swizzle & 0x03; - DWORD swizzle_y = (swizzle >> 2) & 0x03; - DWORD swizzle_z = (swizzle >> 4) & 0x03; - DWORD swizzle_w = (swizzle >> 6) & 0x03; - - if (swizzle_x == swizzle_y - && swizzle_x == swizzle_z - && swizzle_x == swizzle_w) - { - TRACE(".%c", swizzle_chars[swizzle_x]); - } - else - { - TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y], - swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]); - } - } -} - -/* Shared code in order to generate the bulk of the shader string. - * NOTE: A description of how to parse tokens can be found on msdn */ -void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer, - const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) -{ - IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; - IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */ - const struct wined3d_shader_frontend *fe = This->baseShader.frontend; - void *fe_data = This->baseShader.frontend_data; - struct wined3d_shader_src_param src_rel_addr[4]; - struct wined3d_shader_src_param src_param[4]; - struct wined3d_shader_version shader_version; - struct wined3d_shader_src_param dst_rel_addr; - struct wined3d_shader_dst_param dst_param; - struct wined3d_shader_instruction ins; - struct wined3d_shader_context ctx; - const DWORD *pToken = pFunction; - DWORD i; - - /* Initialize current parsing state */ - ctx.shader = iface; - ctx.reg_maps = reg_maps; - ctx.buffer = buffer; - ctx.backend_data = backend_ctx; - - ins.ctx = &ctx; - ins.dst = &dst_param; - ins.src = src_param; - This->baseShader.parse_state.current_row = 0; - - fe->shader_read_header(fe_data, &pToken, &shader_version); - - while (!fe->shader_is_end(fe_data, &pToken)) - { - const char *comment; - UINT param_size; - - /* Skip comment tokens */ - fe->shader_read_comment(&pToken, &comment); - if (comment) continue; - - /* Read opcode */ - fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size); - - /* Unknown opcode and its parameters */ - if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) - { - TRACE("Skipping unrecognized instruction.\n"); - pToken += param_size; - continue; - } - - /* Nothing to do */ - if (ins.handler_idx == WINED3DSIH_DCL - || ins.handler_idx == WINED3DSIH_NOP - || ins.handler_idx == WINED3DSIH_DEF - || ins.handler_idx == WINED3DSIH_DEFI - || ins.handler_idx == WINED3DSIH_DEFB - || ins.handler_idx == WINED3DSIH_PHASE) - { - pToken += param_size; - continue; - } - - /* Destination token */ - if (ins.dst_count) fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr); - - /* Predication token */ - if (ins.predicate) ins.predicate = *pToken++; - - /* Other source tokens */ - for (i = 0; i < ins.src_count; ++i) - { - fe->shader_read_src_param(fe_data, &pToken, &src_param[i], &src_rel_addr[i]); - } - - /* Call appropriate function for output target */ - device->shader_backend->shader_handle_instruction(&ins); - } -} - -static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst) -{ - DWORD mmask = dst->modifiers; - - switch (dst->shift) - { - case 0: break; - case 13: TRACE("_d8"); break; - case 14: TRACE("_d4"); break; - case 15: TRACE("_d2"); break; - case 1: TRACE("_x2"); break; - case 2: TRACE("_x4"); break; - case 3: TRACE("_x8"); break; - default: TRACE("_unhandled_shift(%d)", dst->shift); break; - } - - if (mmask & WINED3DSPDM_SATURATE) TRACE("_sat"); - if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp"); - if (mmask & WINED3DSPDM_MSAMPCENTROID) TRACE("_centroid"); - - mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID); - if (mmask) - FIXME("_unrecognized_modifier(%#x)", mmask); -} - -void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) -{ - struct wined3d_shader_version shader_version; - const DWORD* pToken = pFunction; - const char *type_prefix; - DWORD i; - - TRACE("Parsing %p\n", pFunction); - - fe->shader_read_header(fe_data, &pToken, &shader_version); - - switch (shader_version.type) - { - case WINED3D_SHADER_TYPE_VERTEX: - type_prefix = "vs"; - break; - - case WINED3D_SHADER_TYPE_GEOMETRY: - type_prefix = "gs"; - break; - - case WINED3D_SHADER_TYPE_PIXEL: - type_prefix = "ps"; - break; - - default: - FIXME("Unhandled shader type %#x.\n", shader_version.type); - type_prefix = "unknown"; - break; - } - - TRACE("%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor); - - while (!fe->shader_is_end(fe_data, &pToken)) - { - struct wined3d_shader_instruction ins; - const char *comment; - UINT param_size; - - /* comment */ - fe->shader_read_comment(&pToken, &comment); - if (comment) - { - TRACE("//%s\n", comment); - continue; - } - - fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size); - if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) - { - TRACE("Skipping unrecognized instruction.\n"); - pToken += param_size; - continue; - } - - if (ins.handler_idx == WINED3DSIH_DCL) - { - struct wined3d_shader_semantic semantic; - - fe->shader_read_semantic(&pToken, &semantic); - - shader_dump_decl_usage(&semantic, &shader_version); - shader_dump_ins_modifiers(&semantic.reg); - TRACE(" "); - shader_dump_dst_param(&semantic.reg, &shader_version); - } - else if (ins.handler_idx == WINED3DSIH_DEF) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - - TRACE("def c%u = %f, %f, %f, %f", shader_get_float_offset(dst.reg.type, dst.reg.idx), - *(const float *)(pToken), - *(const float *)(pToken + 1), - *(const float *)(pToken + 2), - *(const float *)(pToken + 3)); - pToken += 4; - } - else if (ins.handler_idx == WINED3DSIH_DEFI) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - - TRACE("defi i%u = %d, %d, %d, %d", dst.reg.idx, - *(pToken), - *(pToken + 1), - *(pToken + 2), - *(pToken + 3)); - pToken += 4; - } - else if (ins.handler_idx == WINED3DSIH_DEFB) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - - TRACE("defb b%u = %s", dst.reg.idx, *pToken ? "true" : "false"); - ++pToken; - } - else - { - struct wined3d_shader_src_param dst_rel_addr, src_rel_addr; - struct wined3d_shader_dst_param dst_param; - struct wined3d_shader_src_param src_param; - - if (ins.dst_count) - { - fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr); - } - - /* Print out predication source token first - it follows - * the destination token. */ - if (ins.predicate) - { - fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr); - TRACE("("); - shader_dump_src_param(&src_param, &shader_version); - TRACE(") "); - } - - /* PixWin marks instructions with the coissue flag with a '+' */ - if (ins.coissue) TRACE("+"); - - TRACE("%s", shader_opcode_names[ins.handler_idx]); - - if (ins.handler_idx == WINED3DSIH_IFC - || ins.handler_idx == WINED3DSIH_BREAKC) - { - switch (ins.flags) - { - case COMPARISON_GT: TRACE("_gt"); break; - case COMPARISON_EQ: TRACE("_eq"); break; - case COMPARISON_GE: TRACE("_ge"); break; - case COMPARISON_LT: TRACE("_lt"); break; - case COMPARISON_NE: TRACE("_ne"); break; - case COMPARISON_LE: TRACE("_le"); break; - default: TRACE("_(%u)", ins.flags); - } - } - else if (ins.handler_idx == WINED3DSIH_TEX - && shader_version.major >= 2 - && (ins.flags & WINED3DSI_TEXLD_PROJECT)) - { - TRACE("p"); - } - - /* We already read the destination token, print it. */ - if (ins.dst_count) - { - shader_dump_ins_modifiers(&dst_param); - TRACE(" "); - shader_dump_dst_param(&dst_param, &shader_version); - } - - /* Other source tokens */ - for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i) - { - fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr); - TRACE(!i ? " " : ", "); - shader_dump_src_param(&src_param, &shader_version); - } - } - TRACE("\n"); - } -} - -void shader_cleanup(IWineD3DBaseShader *iface) -{ - IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface; - - ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_destroy(iface); - HeapFree(GetProcessHeap(), 0, This->baseShader.reg_maps.constf); - HeapFree(GetProcessHeap(), 0, This->baseShader.function); - shader_delete_constant_list(&This->baseShader.constantsF); - shader_delete_constant_list(&This->baseShader.constantsB); - shader_delete_constant_list(&This->baseShader.constantsI); - list_remove(&This->baseShader.shader_list_entry); - - if (This->baseShader.frontend && This->baseShader.frontend_data) - { - This->baseShader.frontend->shader_free(This->baseShader.frontend_data); - } -} - -static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {} -static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {} -static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {} -static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {} -static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {} -static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {} -static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {} -static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {} -static void shader_none_destroy(IWineD3DBaseShader *iface) {} -static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;} -static void shader_none_free(IWineD3DDevice *iface) {} -static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;} - -static void shader_none_get_caps(WINED3DDEVTYPE devtype, - const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps) -{ - /* Set the shader caps to 0 for the none shader backend */ - pCaps->VertexShaderVersion = 0; - pCaps->PixelShaderVersion = 0; - pCaps->PixelShader1xMaxValue = 0.0f; -} - -static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) -{ - if (TRACE_ON(d3d_shader) && TRACE_ON(d3d)) - { - TRACE("Checking support for fixup:\n"); - dump_color_fixup_desc(fixup); - } - - /* Faked to make some apps happy. */ - if (!is_yuv_fixup(fixup)) - { - TRACE("[OK]\n"); - return TRUE; - } - - TRACE("[FAILED]\n"); - return FALSE; -} - -const shader_backend_t none_shader_backend = { - shader_none_handle_instruction, - shader_none_select, - shader_none_select_depth_blt, - shader_none_deselect_depth_blt, - shader_none_update_float_vertex_constants, - shader_none_update_float_pixel_constants, - shader_none_load_constants, - shader_none_load_np2fixup_constants, - shader_none_destroy, - shader_none_alloc, - shader_none_free, - shader_none_dirty_const, - shader_none_get_caps, - shader_none_color_fixup_supported, -}; diff --git a/reactos/dll/directx/wine/wined3d/buffer.c b/reactos/dll/directx/wine/wined3d/buffer.c index 20201b12eb3..e22d311beb9 100644 --- a/reactos/dll/directx/wine/wined3d/buffer.c +++ b/reactos/dll/directx/wine/wined3d/buffer.c @@ -3,7 +3,7 @@ * Copyright 2002-2005 Raphael Junqueira * Copyright 2004 Christian Costa * Copyright 2005 Oliver Stieber - * Copyright 2007 Stefan Dösinger for CodeWeavers + * Copyright 2007-2010 Stefan Dösinger for CodeWeavers * Copyright 2009 Henri Verbeet for CodeWeavers * * This library is free software; you can redistribute it and/or @@ -56,7 +56,13 @@ static inline BOOL buffer_add_dirty_area(struct wined3d_buffer *This, UINT offse } } - if(!offset && !size) + if(offset > This->resource.size || offset + size > This->resource.size) + { + WARN("Invalid range dirtified, marking entire buffer dirty\n"); + offset = 0; + size = This->resource.size; + } + else if(!offset && !size) { size = This->resource.size; } @@ -145,11 +151,6 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This) { TRACE("Gl usage = GL_STREAM_DRAW_ARB\n"); gl_usage = GL_STREAM_DRAW_ARB; - } - else - { - TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n"); - gl_usage = GL_DYNAMIC_DRAW_ARB; if(gl_info->supported[APPLE_FLUSH_BUFFER_RANGE]) { @@ -157,6 +158,12 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This) checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE)"); This->flags |= WINED3D_BUFFER_FLUSH; } + /* No setup is needed here for GL_ARB_map_buffer_range */ + } + else + { + TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n"); + gl_usage = GL_DYNAMIC_DRAW_ARB; } /* Reserve memory for the buffer. The amount of data won't change @@ -483,7 +490,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This) * FLOAT16s if not supported. Also, we can't iterate over the array, so use macros to generate code for all * the attributes that our current fixed function pipeline implementation cares for. */ - BOOL support_d3dcolor = gl_info->supported[EXT_VERTEX_ARRAY_BGRA]; + BOOL support_d3dcolor = gl_info->supported[ARB_VERTEX_ARRAY_BGRA]; ret = buffer_check_attribute(This, si, WINED3D_FFP_POSITION, TRUE, TRUE, FALSE, &stride_this_run, &float16_used) || ret; ret = buffer_check_attribute(This, si, WINED3D_FFP_NORMAL, @@ -1026,6 +1033,51 @@ static WINED3DRESOURCETYPE STDMETHODCALLTYPE buffer_GetType(IWineD3DBuffer *ifac /* IWineD3DBuffer methods */ +static DWORD buffer_sanitize_flags(DWORD flags) +{ + /* Not all flags make sense together, but Windows never returns an error. Catch the + * cases that could cause issues */ + if(flags & WINED3DLOCK_READONLY) + { + if(flags & WINED3DLOCK_DISCARD) + { + WARN("WINED3DLOCK_READONLY combined with WINED3DLOCK_DISCARD, ignoring flags\n"); + return 0; + } + if(flags & WINED3DLOCK_NOOVERWRITE) + { + WARN("WINED3DLOCK_READONLY combined with WINED3DLOCK_NOOVERWRITE, ignoring flags\n"); + return 0; + } + } + else if((flags & (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE)) == (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE)) + { + WARN("WINED3DLOCK_DISCARD and WINED3DLOCK_NOOVERWRITE used together, ignoring\n"); + return 0; + } + + return flags; +} + +static GLbitfield buffer_gl_map_flags(DWORD d3d_flags) +{ + GLbitfield ret = 0; + + if (!(d3d_flags & WINED3DLOCK_READONLY)) ret = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT; + + if (d3d_flags & (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE)) + { + if(d3d_flags & WINED3DLOCK_DISCARD) ret |= GL_MAP_INVALIDATE_BUFFER_BIT; + ret |= GL_MAP_UNSYNCHRONIZED_BIT; + } + else + { + ret |= GL_MAP_READ_BIT; + } + + return ret; +} + static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, UINT size, BYTE **data, DWORD flags) { struct wined3d_buffer *This = (struct wined3d_buffer *)iface; @@ -1033,7 +1085,11 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, TRACE("iface %p, offset %u, size %u, data %p, flags %#x\n", iface, offset, size, data, flags); - if (!buffer_add_dirty_area(This, offset, size)) return E_OUTOFMEMORY; + flags = buffer_sanitize_flags(flags); + if (!(flags & WINED3DLOCK_READONLY)) + { + if (!buffer_add_dirty_area(This, offset, size)) return E_OUTOFMEMORY; + } count = InterlockedIncrement(&This->lock_count); @@ -1043,6 +1099,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, { IWineD3DDeviceImpl *device = This->resource.device; struct wined3d_context *context; + const struct wined3d_gl_info *gl_info; if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB) { @@ -1050,9 +1107,20 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, } context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + gl_info = context->gl_info; ENTER_GL(); GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object)); - This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB)); + + if (gl_info->supported[ARB_MAP_BUFFER_RANGE]) + { + GLbitfield mapflags = buffer_gl_map_flags(flags); + This->resource.allocatedMemory = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0, + This->resource.size, mapflags)); + } + else + { + This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB)); + } LEAVE_GL(); context_release(context); } @@ -1093,6 +1161,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface) if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER) && This->buffer_object) { IWineD3DDeviceImpl *device = This->resource.device; + const struct wined3d_gl_info *gl_info; struct wined3d_context *context; if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB) @@ -1101,10 +1170,21 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface) } context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + gl_info = context->gl_info; ENTER_GL(); GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object)); - if(This->flags & WINED3D_BUFFER_FLUSH) + if (gl_info->supported[ARB_MAP_BUFFER_RANGE]) + { + for(i = 0; i < This->modified_areas; i++) + { + GL_EXTCALL(glFlushMappedBufferRange(This->buffer_type_hint, + This->maps[i].offset, + This->maps[i].size)); + checkGLcall("glFlushMappedBufferRange"); + } + } + else if (This->flags & WINED3D_BUFFER_FLUSH) { for(i = 0; i < This->modified_areas; i++) { @@ -1196,8 +1276,7 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device, TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n", buffer->resource.size, buffer->resource.usage, debug_d3dformat(buffer->resource.format_desc->format), buffer->resource.allocatedMemory, buffer); - /* TODO: GL_ARB_map_buffer_range */ - dynamic_buffer_ok = gl_info->supported[APPLE_FLUSH_BUFFER_RANGE]; + dynamic_buffer_ok = gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] || gl_info->supported[ARB_MAP_BUFFER_RANGE]; /* Observations show that drawStridedSlow is faster on dynamic VBs than converting + * drawStridedFast (half-life 2 and others). diff --git a/reactos/dll/directx/wine/wined3d/context.c b/reactos/dll/directx/wine/wined3d/context.c index 2aec7d6bfd3..08789855812 100644 --- a/reactos/dll/directx/wine/wined3d/context.c +++ b/reactos/dll/directx/wine/wined3d/context.c @@ -114,7 +114,7 @@ static void context_destroy_fbo(struct wined3d_context *context, GLuint *fbo) } /* GL locking is done by the caller */ -static void context_apply_attachment_filter_states(IWineD3DSurface *surface, BOOL force_preload) +static void context_apply_attachment_filter_states(IWineD3DSurface *surface) { const IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface; IWineD3DDeviceImpl *device = surface_impl->resource.device; @@ -148,7 +148,7 @@ static void context_apply_attachment_filter_states(IWineD3DSurface *surface, BOO IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture_impl); } - if (update_minfilter || update_magfilter || force_preload) + if (update_minfilter || update_magfilter) { GLenum target, bind_target; GLint old_binding; @@ -166,8 +166,6 @@ static void context_apply_attachment_filter_states(IWineD3DSurface *surface, BOO glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding); } - surface_internal_preload(surface, SRGB_RGB); - glBindTexture(bind_target, surface_impl->texture_name); if (update_minfilter) glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); if (update_magfilter) glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -208,7 +206,8 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context, } else { - context_apply_attachment_filter_states(depth_stencil, TRUE); + surface_prepare_texture(depth_stencil_impl, FALSE); + context_apply_attachment_filter_states(depth_stencil); if (format_flags & WINED3DFMT_FLAG_DEPTH) { @@ -253,14 +252,15 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context, void context_attach_surface_fbo(const struct wined3d_context *context, GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) { - const IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface; + IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface; const struct wined3d_gl_info *gl_info = context->gl_info; TRACE("Attach surface %p to %u\n", surface, idx); if (surface) { - context_apply_attachment_filter_states(surface, TRUE); + surface_prepare_texture(surface_impl, FALSE); + context_apply_attachment_filter_states(surface); gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx, surface_impl->texture_target, surface_impl->texture_name, surface_impl->texture_level); @@ -431,10 +431,10 @@ static void context_apply_fbo_entry(struct wined3d_context *context, struct fbo_ for (i = 0; i < gl_info->limits.buffers; ++i) { if (device->render_targets[i]) - context_apply_attachment_filter_states(device->render_targets[i], FALSE); + context_apply_attachment_filter_states(device->render_targets[i]); } if (device->stencilBufferTarget) - context_apply_attachment_filter_states(device->stencilBufferTarget, FALSE); + context_apply_attachment_filter_states(device->stencilBufferTarget); } for (i = 0; i < gl_info->limits.buffers; ++i) @@ -532,32 +532,38 @@ void context_alloc_event_query(struct wined3d_context *context, struct wined3d_e if (context->free_event_query_count) { - query->id = context->free_event_queries[--context->free_event_query_count]; + query->object = context->free_event_queries[--context->free_event_query_count]; } else { - if (gl_info->supported[APPLE_FENCE]) + if (gl_info->supported[ARB_SYNC]) + { + /* Using ARB_sync, not much to do here. */ + query->object.sync = NULL; + TRACE("Allocated event query %p in context %p.\n", query->object.sync, context); + } + else if (gl_info->supported[APPLE_FENCE]) { ENTER_GL(); - GL_EXTCALL(glGenFencesAPPLE(1, &query->id)); + GL_EXTCALL(glGenFencesAPPLE(1, &query->object.id)); checkGLcall("glGenFencesAPPLE"); LEAVE_GL(); - TRACE("Allocated event query %u in context %p.\n", query->id, context); + TRACE("Allocated event query %u in context %p.\n", query->object.id, context); } else if(gl_info->supported[NV_FENCE]) { ENTER_GL(); - GL_EXTCALL(glGenFencesNV(1, &query->id)); + GL_EXTCALL(glGenFencesNV(1, &query->object.id)); checkGLcall("glGenFencesNV"); LEAVE_GL(); - TRACE("Allocated event query %u in context %p.\n", query->id, context); + TRACE("Allocated event query %u in context %p.\n", query->object.id, context); } else { WARN("Event queries not supported, not allocating query id.\n"); - query->id = 0; + query->object.id = 0; } } @@ -575,12 +581,12 @@ void context_free_event_query(struct wined3d_event_query *query) if (context->free_event_query_count >= context->free_event_query_size - 1) { UINT new_size = context->free_event_query_size << 1; - GLuint *new_data = HeapReAlloc(GetProcessHeap(), 0, context->free_event_queries, + union wined3d_gl_query_object *new_data = HeapReAlloc(GetProcessHeap(), 0, context->free_event_queries, new_size * sizeof(*context->free_event_queries)); if (!new_data) { - ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context); + ERR("Failed to grow free list, leaking query %u in context %p.\n", query->object.id, context); return; } @@ -588,7 +594,7 @@ void context_free_event_query(struct wined3d_event_query *query) context->free_event_queries = new_data; } - context->free_event_queries[context->free_event_query_count++] = query->id; + context->free_event_queries[context->free_event_query_count++] = query->object; } void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource, WINED3DRESOURCETYPE type) @@ -661,6 +667,7 @@ static void context_destroy_gl_resources(struct wined3d_context *context) struct fbo_entry *entry, *entry2; HGLRC restore_ctx; HDC restore_dc; + unsigned int i; restore_ctx = pwglGetCurrentContext(); restore_dc = pwglGetCurrentDC(); @@ -682,8 +689,12 @@ static void context_destroy_gl_resources(struct wined3d_context *context) { if (context->valid) { - if (gl_info->supported[APPLE_FENCE]) GL_EXTCALL(glDeleteFencesAPPLE(1, &event_query->id)); - else if (gl_info->supported[NV_FENCE]) GL_EXTCALL(glDeleteFencesNV(1, &event_query->id)); + if (gl_info->supported[ARB_SYNC]) + { + if (event_query->object.sync) GL_EXTCALL(glDeleteSync(event_query->object.sync)); + } + else if (gl_info->supported[APPLE_FENCE]) GL_EXTCALL(glDeleteFencesAPPLE(1, &event_query->object.id)); + else if (gl_info->supported[NV_FENCE]) GL_EXTCALL(glDeleteFencesNV(1, &event_query->object.id)); } event_query->context = NULL; } @@ -720,10 +731,24 @@ static void context_destroy_gl_resources(struct wined3d_context *context) if (gl_info->supported[ARB_OCCLUSION_QUERY]) GL_EXTCALL(glDeleteQueriesARB(context->free_occlusion_query_count, context->free_occlusion_queries)); - if (gl_info->supported[APPLE_FENCE]) - GL_EXTCALL(glDeleteFencesAPPLE(context->free_event_query_count, context->free_event_queries)); + if (gl_info->supported[ARB_SYNC]) + { + if (event_query->object.sync) GL_EXTCALL(glDeleteSync(event_query->object.sync)); + } + else if (gl_info->supported[APPLE_FENCE]) + { + for (i = 0; i < context->free_event_query_count; ++i) + { + GL_EXTCALL(glDeleteFencesAPPLE(1, &context->free_event_queries[i].id)); + } + } else if (gl_info->supported[NV_FENCE]) - GL_EXTCALL(glDeleteFencesNV(context->free_event_query_count, context->free_event_queries)); + { + for (i = 0; i < context->free_event_query_count; ++i) + { + GL_EXTCALL(glDeleteFencesNV(1, &context->free_event_queries[i].id)); + } + } checkGLcall("context cleanup"); } @@ -2131,6 +2156,8 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI if (context->render_offscreen) { FIXME("Activating for CTXUSAGE_BLIT for an offscreen target with ORM_FBO. This should be avoided.\n"); + surface_internal_preload(context->current_rt, SRGB_RGB); + ENTER_GL(); context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo); context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, context->current_rt); @@ -2189,6 +2216,9 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI } IWineD3DDeviceImpl_FindTexUnitMap(device); + device_preload_textures(device); + if (isStateDirty(context, STATE_VDECL)) + device_update_stream_info(device, context->gl_info); ENTER_GL(); for (i = 0; i < context->numDirtyEntries; ++i) diff --git a/reactos/dll/directx/wine/wined3d/device.c b/reactos/dll/directx/wine/wined3d/device.c index 34495d396d9..6682aa4635e 100644 --- a/reactos/dll/directx/wine/wined3d/device.c +++ b/reactos/dll/directx/wine/wined3d/device.c @@ -179,8 +179,6 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, { /* We need to deal with frequency data! */ IWineD3DVertexDeclarationImpl *declaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl; - UINT stream_count = This->stateBlock->streamIsUP ? 0 : declaration->num_streams; - const DWORD *streams = declaration->streams; unsigned int i; stream_info->use_map = 0; @@ -298,7 +296,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, stream_info->elements[idx].stream_idx = element->input_slot; stream_info->elements[idx].buffer_object = buffer_object; - if (!This->adapter->gl_info.supported[EXT_VERTEX_ARRAY_BGRA] + if (!This->adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA] && element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) { stream_info->swizzle_map |= 1 << idx; @@ -307,17 +305,29 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, } } - /* Now call PreLoad on all the vertex buffers. In the very rare case - * that the buffers stopps converting PreLoad will dirtify the VDECL again. - * The vertex buffer can now use the strided structure in the device instead of finding its - * own again. - * - * NULL streams won't be recorded in the array, UP streams won't be either. A stream is only - * once in there. */ - for (i = 0; i < stream_count; ++i) + if (!This->stateBlock->streamIsUP) { - IWineD3DBuffer *vb = This->stateBlock->streamSource[streams[i]]; - if (vb) IWineD3DBuffer_PreLoad(vb); + WORD map = stream_info->use_map; + + /* PreLoad all the vertex buffers. */ + for (i = 0; map; map >>= 1, ++i) + { + struct wined3d_stream_info_element *element; + struct wined3d_buffer *buffer; + + if (!(map & 1)) continue; + + element = &stream_info->elements[i]; + buffer = (struct wined3d_buffer *)This->stateBlock->streamSource[element->stream_idx]; + IWineD3DBuffer_PreLoad((IWineD3DBuffer *)buffer); + + /* If PreLoad dropped the buffer object, update the stream info. */ + if (buffer->buffer_object != element->buffer_object) + { + element->buffer_object = 0; + element->data = buffer_get_sysmem(buffer) + (ptrdiff_t)element->data; + } + } } } @@ -332,7 +342,7 @@ static void stream_info_element_from_strided(const struct wined3d_gl_info *gl_in e->buffer_object = 0; } -void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, +static void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) { unsigned int i; @@ -361,7 +371,7 @@ void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, { if (!stream_info->elements[i].format_desc) continue; - if (!gl_info->supported[EXT_VERTEX_ARRAY_BGRA] + if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && stream_info->elements[i].format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) { stream_info->swizzle_map |= 1 << i; @@ -370,6 +380,120 @@ void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, } } +static void device_trace_strided_stream_info(const struct wined3d_stream_info *stream_info) +{ + TRACE("Strided Data:\n"); + TRACE_STRIDED(stream_info, WINED3D_FFP_POSITION); + TRACE_STRIDED(stream_info, WINED3D_FFP_BLENDWEIGHT); + TRACE_STRIDED(stream_info, WINED3D_FFP_BLENDINDICES); + TRACE_STRIDED(stream_info, WINED3D_FFP_NORMAL); + TRACE_STRIDED(stream_info, WINED3D_FFP_PSIZE); + TRACE_STRIDED(stream_info, WINED3D_FFP_DIFFUSE); + TRACE_STRIDED(stream_info, WINED3D_FFP_SPECULAR); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD0); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD1); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD2); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD3); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD4); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD5); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD6); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD7); +} + +/* Context activation is done by the caller. */ +void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) +{ + struct wined3d_stream_info *stream_info = &device->strided_streams; + IWineD3DStateBlockImpl *stateblock = device->stateBlock; + BOOL vs = stateblock->vertexShader && device->vs_selected_mode != SHADER_NONE; + BOOL fixup = FALSE; + + if (device->up_strided) + { + /* Note: this is a ddraw fixed-function code path. */ + TRACE("=============================== Strided Input ================================\n"); + device_stream_info_from_strided(gl_info, device->up_strided, stream_info); + if (TRACE_ON(d3d)) device_trace_strided_stream_info(stream_info); + } + else + { + TRACE("============================= Vertex Declaration =============================\n"); + device_stream_info_from_declaration(device, vs, stream_info, &fixup); + } + + if (vs && !stream_info->position_transformed) + { + if (((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->half_float_conv_needed && !fixup) + { + TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion.\n"); + device->useDrawStridedSlow = TRUE; + } + else + { + device->useDrawStridedSlow = FALSE; + } + } + else + { + WORD slow_mask = (1 << WINED3D_FFP_PSIZE); + slow_mask |= -!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] + & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR)); + + if ((stream_info->position_transformed || (stream_info->use_map & slow_mask)) && !fixup) + { + device->useDrawStridedSlow = TRUE; + } + else + { + device->useDrawStridedSlow = FALSE; + } + } +} + +static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned int idx) +{ + IWineD3DBaseTextureImpl *texture; + enum WINED3DSRGB srgb; + + if (!(texture = (IWineD3DBaseTextureImpl *)stateblock->textures[idx])) return; + srgb = stateblock->samplerState[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB; + texture->baseTexture.internal_preload((IWineD3DBaseTexture *)texture, srgb); +} + +void device_preload_textures(IWineD3DDeviceImpl *device) +{ + IWineD3DStateBlockImpl *stateblock = device->stateBlock; + unsigned int i; + + if (use_vs(stateblock)) + { + for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) + { + if (((IWineD3DBaseShaderImpl *)stateblock->vertexShader)->baseShader.reg_maps.sampler_type[i]) + device_preload_texture(stateblock, MAX_FRAGMENT_SAMPLERS + i); + } + } + + if (use_ps(stateblock)) + { + for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) + { + if (((IWineD3DBaseShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.sampler_type[i]) + device_preload_texture(stateblock, i); + } + } + else + { + WORD ffu_map = device->fixed_function_usage_map; + + for (i = 0; ffu_map; ffu_map >>= 1, ++i) + { + if (ffu_map & 1) + device_preload_texture(stateblock, i); + } + } +} + /********************************************************** * IUnknown parts follows **********************************************************/ @@ -596,7 +720,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UI IWineD3DSurfaceImpl *object; HRESULT hr; - TRACE("(%p) Create surface\n",This); + TRACE("iface %p, width %u, height %u, format %s (%#x), lockable %#x, discard %#x, level %u\n", + iface, Width, Height, debug_d3dformat(Format), Format, Lockable, Discard, Level); + TRACE("surface %p, usage %s (%#x), pool %s (%#x), multisample_type %#x, multisample_quality %u\n", + ppSurface, debug_d3dusage(Usage), Usage, debug_d3dpool(Pool), Pool, MultiSample, MultisampleQuality); + TRACE("surface_type %#x, parent %p, parent_ops %p.\n", Impl, parent, parent_ops); if (Impl == SURFACE_OPENGL && !This->adapter) { @@ -784,104 +912,33 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface return WINED3D_OK; } -static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown* parent) { +static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, + WINED3DQUERYTYPE type, IWineD3DQuery **query, IUnknown *parent) +{ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; - IWineD3DQueryImpl *object; /*NOTE: impl ref allowed since this is a create function */ - HRESULT hr = WINED3DERR_NOTAVAILABLE; - const IWineD3DQueryVtbl *vtable; + IWineD3DQueryImpl *object; + HRESULT hr; - /* Just a check to see if we support this type of query */ - switch(Type) { - case WINED3DQUERYTYPE_OCCLUSION: - TRACE("(%p) occlusion query\n", This); - if (gl_info->supported[ARB_OCCLUSION_QUERY]) - hr = WINED3D_OK; - else - WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n"); + TRACE("iface %p, type %#x, query %p, parent %p.\n", iface, type, query, parent); - vtable = &IWineD3DOcclusionQuery_Vtbl; - break; - - case WINED3DQUERYTYPE_EVENT: - if (!gl_info->supported[NV_FENCE] && !gl_info->supported[APPLE_FENCE]) - { - /* Half-Life 2 needs this query. It does not render the main menu correctly otherwise - * Pretend to support it, faking this query does not do much harm except potentially lowering performance - */ - FIXME("(%p) Event query: Unimplemented, but pretending to be supported\n", This); - } - vtable = &IWineD3DEventQuery_Vtbl; - hr = WINED3D_OK; - break; - - case WINED3DQUERYTYPE_VCACHE: - case WINED3DQUERYTYPE_RESOURCEMANAGER: - case WINED3DQUERYTYPE_VERTEXSTATS: - case WINED3DQUERYTYPE_TIMESTAMP: - case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: - case WINED3DQUERYTYPE_TIMESTAMPFREQ: - case WINED3DQUERYTYPE_PIPELINETIMINGS: - case WINED3DQUERYTYPE_INTERFACETIMINGS: - case WINED3DQUERYTYPE_VERTEXTIMINGS: - case WINED3DQUERYTYPE_PIXELTIMINGS: - case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: - case WINED3DQUERYTYPE_CACHEUTILIZATION: - default: - /* Use the base Query vtable until we have a special one for each query */ - vtable = &IWineD3DQuery_Vtbl; - FIXME("(%p) Unhandled query type %d\n", This, Type); + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate query memory.\n"); + return E_OUTOFMEMORY; } - if(NULL == ppQuery || hr != WINED3D_OK) { + + hr = query_init(object, This, type, parent); + if (FAILED(hr)) + { + WARN("Failed to initialize query, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); return hr; } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if(!object) - { - ERR("Out of memory\n"); - *ppQuery = NULL; - return WINED3DERR_OUTOFVIDEOMEMORY; - } + TRACE("Created query %p.\n", object); + *query = (IWineD3DQuery *)object; - object->lpVtbl = vtable; - object->type = Type; - object->state = QUERY_CREATED; - object->device = This; - object->parent = parent; - object->ref = 1; - - *ppQuery = (IWineD3DQuery *)object; - - /* allocated the 'extended' data based on the type of query requested */ - switch(Type){ - case WINED3DQUERYTYPE_OCCLUSION: - object->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query)); - ((struct wined3d_occlusion_query *)object->extendedData)->context = NULL; - break; - - case WINED3DQUERYTYPE_EVENT: - object->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_event_query)); - ((struct wined3d_event_query *)object->extendedData)->context = NULL; - break; - - case WINED3DQUERYTYPE_VCACHE: - case WINED3DQUERYTYPE_RESOURCEMANAGER: - case WINED3DQUERYTYPE_VERTEXSTATS: - case WINED3DQUERYTYPE_TIMESTAMP: - case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: - case WINED3DQUERYTYPE_TIMESTAMPFREQ: - case WINED3DQUERYTYPE_PIPELINETIMINGS: - case WINED3DQUERYTYPE_INTERFACETIMINGS: - case WINED3DQUERYTYPE_VERTEXTIMINGS: - case WINED3DQUERYTYPE_PIXELTIMINGS: - case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: - case WINED3DQUERYTYPE_CACHEUTILIZATION: - default: - object->extendedData = 0; - FIXME("(%p) Unhandled query type %d\n",This , Type); - } - TRACE("(%p) : Created Query %p\n", This, object); return WINED3D_OK; } @@ -1663,14 +1720,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, } } - /* Delete the palette conversion shader if it is around */ - if(This->paletteConversionShader) { - ENTER_GL(); - GL_EXTCALL(glDeleteProgramsARB(1, &This->paletteConversionShader)); - LEAVE_GL(); - This->paletteConversionShader = 0; - } - /* Delete the pbuffer context if there is any */ if(This->pbufferContext) context_destroy(This, This->pbufferContext); @@ -3054,15 +3103,17 @@ static void device_update_fixed_function_usage_map(IWineD3DDeviceImpl *This) { } } -static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) { +static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info) +{ unsigned int i, tex; WORD ffu_map; device_update_fixed_function_usage_map(This); ffu_map = This->fixed_function_usage_map; - if (This->max_ffp_textures == This->max_ffp_texture_stages || - This->stateBlock->lowest_disabled_stage <= This->max_ffp_textures) { + if (This->max_ffp_textures == gl_info->limits.texture_stages + || This->stateBlock->lowest_disabled_stage <= This->max_ffp_textures) + { for (i = 0; ffu_map; ffu_map >>= 1, ++i) { if (!(ffu_map & 1)) continue; @@ -3092,7 +3143,8 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) { } } -static void device_map_psamplers(IWineD3DDeviceImpl *This) { +static void device_map_psamplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info) +{ const WINED3DSAMPLER_TEXTURE_TYPE *sampler_type = ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.sampler_type; unsigned int i; @@ -3102,7 +3154,8 @@ static void device_map_psamplers(IWineD3DDeviceImpl *This) { { device_map_stage(This, i, i); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i)); - if (i < MAX_TEXTURES) { + if (i < gl_info->limits.texture_stages) + { markTextureStagesDirty(This, i); } } @@ -3133,11 +3186,12 @@ static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const DWORD *pshad return !vshader_sampler_tokens[current_mapping - MAX_FRAGMENT_SAMPLERS]; } -static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) { +static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct wined3d_gl_info *gl_info) +{ const WINED3DSAMPLER_TEXTURE_TYPE *vshader_sampler_type = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.sampler_type; const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_type = NULL; - int start = min(MAX_COMBINED_SAMPLERS, This->adapter->gl_info.limits.combined_samplers) - 1; + int start = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers) - 1; int i; if (ps) { @@ -3174,7 +3228,9 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) { } } -void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) { +void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) +{ + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; BOOL vs = use_vs(This->stateBlock); BOOL ps = use_ps(This->stateBlock); /* @@ -3184,15 +3240,10 @@ void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) { * -> When the mapping of a stage is changed, sampler and ALL texture stage states have * to be reset. Because of that try to work with a 1:1 mapping as much as possible */ - if (ps) { - device_map_psamplers(This); - } else { - device_map_fixed_function_samplers(This); - } + if (ps) device_map_psamplers(This, gl_info); + else device_map_fixed_function_samplers(This, gl_info); - if (vs) { - device_map_vsamplers(This, ps); - } + if (vs) device_map_vsamplers(This, ps, gl_info); } static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader) { @@ -3806,11 +3857,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD Value) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; DWORD oldValue = This->updateStateBlock->textureState[Stage][Type]; + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; TRACE("(%p) : Stage=%d, Type=%s(%d), Value=%d\n", This, Stage, debug_d3dtexturestate(Type), Type, Value); - if (Stage >= MAX_TEXTURES) { - WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring\n", Stage, MAX_TEXTURES - 1); + if (Stage >= gl_info->limits.texture_stages) + { + WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring.\n", + Stage, gl_info->limits.texture_stages - 1); return WINED3D_OK; } @@ -3891,6 +3945,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, DWORD stage, IWineD3DBaseTexture *texture) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; IWineD3DBaseTexture *prev; TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture); @@ -3949,7 +4004,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADER); } - if (!prev && stage < MAX_TEXTURES) + if (!prev && stage < gl_info->limits.texture_stages) { /* The source arguments for color and alpha ops have different * meanings when a NULL texture is bound, so the COLOROP and @@ -3968,7 +4023,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, IWineD3DBaseTexture_Release(prev); - if (!texture && stage < MAX_TEXTURES) + if (!texture && stage < gl_info->limits.texture_stages) { IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP)); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP)); @@ -4206,7 +4261,6 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa const WINED3DVIEWPORT *vp = &This->stateBlock->viewport; UINT drawable_width, drawable_height; IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *) This->stencilBufferTarget; - IWineD3DSwapChainImpl *swapchain = NULL; struct wined3d_context *context; /* When we're clearing parts of the drawable, make sure that the target surface is well up to date in the @@ -4376,12 +4430,7 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa LEAVE_GL(); - if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)target, &IID_IWineD3DSwapChain, (void **)&swapchain))) { - if (target == (IWineD3DSurfaceImpl*) swapchain->frontBuffer) { - wglFlush(); - } - IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain); - } + wglFlush(); /* Flush to ensure ordering across contexts. */ context_release(context); @@ -5340,6 +5389,9 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; struct wined3d_context *context; + if (rect) IWineD3DSurface_LoadLocation(surface, SFLAG_INDRAWABLE, NULL); + IWineD3DSurface_ModifyLocation(surface, SFLAG_INDRAWABLE, TRUE); + if (!surface_is_offscreen(surface)) { TRACE("Surface %p is onscreen\n", surface); @@ -5386,6 +5438,9 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, checkGLcall("glClear"); LEAVE_GL(); + + wglFlush(); /* Flush to ensure ordering across contexts. */ + context_release(context); } @@ -5685,6 +5740,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *ifa if(Swapchain->backBuffer[0]) { IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], (IWineD3DBase *) Swapchain); ((IWineD3DSurfaceImpl *)Swapchain->backBuffer[0])->Flags |= SFLAG_SWAPCHAIN; + Swapchain->presentParms.BackBufferWidth = BackImpl->currentDesc.Width; + Swapchain->presentParms.BackBufferHeight = BackImpl->currentDesc.Height; + Swapchain->presentParms.BackBufferFormat = BackImpl->resource.format_desc->format; } else { HeapFree(GetProcessHeap(), 0, Swapchain->backBuffer); Swapchain->backBuffer = NULL; @@ -5738,6 +5796,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED break; } + /* Make sure the drawables are up-to-date. Note that loading the + * destination surface isn't strictly required if we overwrite the + * entire surface. */ + IWineD3DSurface_LoadLocation(src_surface, SFLAG_INDRAWABLE, NULL); + IWineD3DSurface_LoadLocation(dst_surface, SFLAG_INDRAWABLE, NULL); + /* Attach src surface to src fbo */ src_swapchain = get_swapchain(src_surface); dst_swapchain = get_swapchain(dst_surface); @@ -5753,9 +5817,6 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED GLenum buffer = surface_get_gl_buffer(src_surface); TRACE("Source surface %p is onscreen\n", src_surface); - /* Make sure the drawable is up to date. In the offscreen case - * attach_surface_fbo() implicitly takes care of this. */ - IWineD3DSurface_LoadLocation(src_surface, SFLAG_INDRAWABLE, NULL); if(buffer == GL_FRONT) { RECT windowsize; @@ -5792,9 +5853,6 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED GLenum buffer = surface_get_gl_buffer(dst_surface); TRACE("Destination surface %p is onscreen\n", dst_surface); - /* Make sure the drawable is up to date. In the offscreen case - * attach_surface_fbo() implicitly takes care of this. */ - IWineD3DSurface_LoadLocation(dst_surface, SFLAG_INDRAWABLE, NULL); if(buffer == GL_FRONT) { RECT windowsize; @@ -5839,6 +5897,9 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED } LEAVE_GL(); + + wglFlush(); /* Flush to ensure ordering across contexts. */ + context_release(context); IWineD3DSurface_ModifyLocation(dst_surface, SFLAG_INDRAWABLE, TRUE); @@ -6982,20 +7043,19 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, for (i = 0; i < PATCHMAP_SIZE; ++i) list_init(&device->patches[i]); select_shader_mode(&adapter->gl_info, &device->ps_selected_mode, &device->vs_selected_mode); - device->shader_backend = select_shader_backend(adapter, device_type); + device->shader_backend = adapter->shader_backend; memset(&shader_caps, 0, sizeof(shader_caps)); - device->shader_backend->shader_get_caps(device_type, &adapter->gl_info, &shader_caps); + device->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps); device->d3d_vshader_constantF = shader_caps.MaxVertexShaderConst; device->d3d_pshader_constantF = shader_caps.MaxPixelShaderConst; device->vs_clipping = shader_caps.VSClipping; memset(&ffp_caps, 0, sizeof(ffp_caps)); - fragment_pipeline = select_fragment_implementation(adapter, device_type); + fragment_pipeline = adapter->fragment_pipe; device->frag_pipe = fragment_pipeline; - fragment_pipeline->get_caps(device_type, &adapter->gl_info, &ffp_caps); + fragment_pipeline->get_caps(&adapter->gl_info, &ffp_caps); device->max_ffp_textures = ffp_caps.MaxSimultaneousTextures; - device->max_ffp_texture_stages = ffp_caps.MaxTextureBlendStages; hr = compile_state_table(device->StateTable, device->multistate_funcs, &adapter->gl_info, ffp_vertexstate_template, fragment_pipeline, misc_state_template); @@ -7006,7 +7066,7 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, return hr; } - device->blitter = select_blit_implementation(adapter, device_type); + device->blitter = adapter->blitter; return WINED3D_OK; } diff --git a/reactos/dll/directx/wine/wined3d/directx.c b/reactos/dll/directx/wine/wined3d/directx.c index 855f97ffdda..812e5ccc9e8 100644 --- a/reactos/dll/directx/wine/wined3d/directx.c +++ b/reactos/dll/directx/wine/wined3d/directx.c @@ -30,6 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DECLARE_DEBUG_CHANNEL(d3d_caps); #define GLINFO_LOCATION (*gl_info) +#define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024) +#define MAKEDWORD_VERSION(maj, min) ((maj & 0xffff) << 16) | (min & 0xffff) /* The d3d device ID */ static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } }; @@ -43,17 +45,10 @@ static const struct { /* APPLE */ {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE, 0 }, {"GL_APPLE_fence", APPLE_FENCE, 0 }, - {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER, 0 }, - {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422, 0 }, {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS, 0 }, {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE, 0 }, - - /* ATI */ - {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL, 0 }, - {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3, 0 }, - {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE, 0 }, - {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER, 0 }, - {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC, 0 }, + {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER, 0 }, + {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422, 0 }, /* ARB */ {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT, 0 }, @@ -66,7 +61,9 @@ static const struct { {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT, 0 }, {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4, 0 }, {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL, 0 }, + {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 }, {"GL_ARB_imaging", ARB_IMAGING, 0 }, + {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE, 0 }, {"GL_ARB_multisample", ARB_MULTISAMPLE, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */ {"GL_ARB_multitexture", ARB_MULTITEXTURE, 0 }, {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY, 0 }, @@ -74,6 +71,10 @@ static const struct { {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS, 0 }, {"GL_ARB_point_sprite", ARB_POINT_SPRITE, 0 }, {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX, 0 }, + {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS, 0 }, + {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD, 0 }, + {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100, 0 }, + {"GL_ARB_sync", ARB_SYNC, 0 }, {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP, 0 }, {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION, 0 }, {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP, 0 }, @@ -85,23 +86,30 @@ static const struct { {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0) }, {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 }, {"GL_ARB_texture_rg", ARB_TEXTURE_RG, 0 }, + {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA, 0 }, {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 }, {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 }, {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 }, {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER, 0 }, - {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS, 0 }, - {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD, 0 }, - {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 }, + + /* ATI */ + {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER, 0 }, + {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL, 0 }, + {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC, 0 }, + {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3, 0 }, + {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE, 0 }, /* EXT */ {"GL_EXT_blend_color", EXT_BLEND_COLOR, 0 }, - {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 }, {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE, 0 }, {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE, 0 }, + {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 }, {"GL_EXT_fog_coord", EXT_FOG_COORD, 0 }, {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT, 0 }, {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE, 0 }, {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT, 0 }, + {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 }, + {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4, 0 }, {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL, 0 }, {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE, 0 }, {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS, 0 }, @@ -110,42 +118,36 @@ static const struct { {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE, 0 }, {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP, 0 }, {"GL_EXT_texture3D", EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2) }, - {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 }, {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC, 0 }, + {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 }, {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD, 0 }, {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 }, {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 }, - {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 }, - {"GL_EXT_texture_swizzle", EXT_TEXTURE_SWIZZLE, 0 }, {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 }, - {"GL_EXT_texture_lod", EXT_TEXTURE_LOD, 0 }, {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 }, + {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 }, {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA, 0 }, - {"GL_EXT_vertex_shader", EXT_VERTEX_SHADER, 0 }, - {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 }, /* NV */ - {"GL_NV_half_float", NV_HALF_FLOAT, 0 }, + {"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 }, {"GL_NV_fence", NV_FENCE, 0 }, {"GL_NV_fog_distance", NV_FOG_DISTANCE, 0 }, {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM, 0 }, {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2, 0 }, + {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION, 0 }, + {"GL_NV_half_float", NV_HALF_FLOAT, 0 }, + {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 }, {"GL_NV_register_combiners", NV_REGISTER_COMBINERS, 0 }, {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2, 0 }, {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION, 0 }, {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4, 0 }, {"GL_NV_texture_shader", NV_TEXTURE_SHADER, 0 }, {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2, 0 }, - {"GL_NV_texture_shader3", NV_TEXTURE_SHADER3, 0 }, - {"GL_NV_occlusion_query", NV_OCCLUSION_QUERY, 0 }, {"GL_NV_vertex_program", NV_VERTEX_PROGRAM, 0 }, {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1, 0 }, {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2, 0 }, {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION, 0 }, {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3, 0 }, - {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION, 0 }, - {"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 }, - {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 }, /* SGI */ {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP, 0 }, @@ -435,9 +437,9 @@ static DWORD ver_for_ext(GL_SupportedExt ext) } static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (vendor != VENDOR_ATI) return FALSE; + if (card_vendor != HW_VENDOR_ATI) return FALSE; if (device == CARD_ATI_RADEON_9500) return TRUE; if (device == CARD_ATI_RADEON_X700) return TRUE; if (device == CARD_ATI_RADEON_X1600) return TRUE; @@ -445,9 +447,9 @@ static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const c } static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (vendor == VENDOR_NVIDIA) + if (card_vendor == HW_VENDOR_NVIDIA) { if (device == CARD_NVIDIA_GEFORCEFX_5800 || device == CARD_NVIDIA_GEFORCEFX_5600) { @@ -458,7 +460,7 @@ static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl } static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to @@ -470,18 +472,15 @@ static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_re * like client storage might be supported on other implementations too, but GL_APPLE_flush_render * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So * the chance that other implementations support them is rather small since Win32 QuickTime uses - * DirectDraw, not OpenGL. */ - if (gl_info->supported[APPLE_FENCE] - && gl_info->supported[APPLE_CLIENT_STORAGE] - && gl_info->supported[APPLE_FLUSH_RENDER] - && gl_info->supported[APPLE_YCBCR_422]) + * DirectDraw, not OpenGL. + * + * This test has been moved into wined3d_guess_gl_vendor() + */ + if (gl_vendor == GL_VENDOR_APPLE) { return TRUE; } - else - { - return FALSE; - } + return FALSE; } /* Context activation is done by the caller. */ @@ -554,31 +553,29 @@ static void test_pbo_functionality(struct wined3d_gl_info *gl_info) } static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - return vendor == VENDOR_INTEL && match_apple(gl_info, gl_renderer, vendor, device); + return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE); } static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (!match_apple(gl_info, gl_renderer, vendor, device)) return FALSE; - if (vendor != VENDOR_ATI) return FALSE; + if (gl_vendor != GL_VENDOR_APPLE) return FALSE; + if (card_vendor != HW_VENDOR_ATI) return FALSE; if (device == CARD_ATI_RADEON_X1600) return FALSE; return TRUE; } static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (vendor != VENDOR_ATI) return FALSE; - if (match_apple(gl_info, gl_renderer, vendor, device)) return FALSE; - if (strstr(gl_renderer, "DRI")) return FALSE; /* Filter out Mesa DRI drivers. */ - return TRUE; + return (gl_vendor == GL_VENDOR_ATI); + } static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card. @@ -592,7 +589,7 @@ static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char /* A GL context is provided by the caller */ static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { GLenum error; DWORD data[16]; @@ -619,15 +616,15 @@ static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const } static BOOL match_apple_nvts(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (!match_apple(gl_info, gl_renderer, vendor, device)) return FALSE; + if (!match_apple(gl_info, gl_renderer, gl_vendor, card_vendor, device)) return FALSE; return gl_info->supported[NV_TEXTURE_SHADER]; } /* A GL context is provided by the caller */ static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { GLuint prog; BOOL ret = FALSE; @@ -793,7 +790,6 @@ static void quirk_apple_nvts(struct wined3d_gl_info *gl_info) { gl_info->supported[NV_TEXTURE_SHADER] = FALSE; gl_info->supported[NV_TEXTURE_SHADER2] = FALSE; - gl_info->supported[NV_TEXTURE_SHADER3] = FALSE; } static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info) @@ -804,7 +800,7 @@ static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info) struct driver_quirk { BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device); + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device); void (*apply)(struct wined3d_gl_info *gl_info); const char *description; }; @@ -923,51 +919,51 @@ static const struct driver_version_information driver_version_table[] = * TNT/Geforce1/2 up to 71.x - driver uses numbering 7.1.8.6 for 71.86 * * All version numbers used below are from the Linux nvidia drivers. */ - {VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", 1, 8, 6 }, - {VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", 1, 8, 6 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", 1, 8, 6 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", 6, 4, 3 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", 1, 8, 6 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", 6, 10, 9371 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", 6, 10, 9371 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", 6, 10, 9371 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", 15, 11, 7516 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", 15, 11, 7516 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", 15, 11, 7516 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", 15, 11, 8585 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", 15, 11, 8585 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", 15, 11, 8585 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", 1, 8, 6 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", 1, 8, 6 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", 1, 8, 6 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", 6, 4, 3 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", 1, 8, 6 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", 6, 10, 9371 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", 6, 10, 9371 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", 6, 10, 9371 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", 15, 11, 7516 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", 15, 11, 7516 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", 15, 11, 7516 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", 15, 11, 8585 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", 15, 11, 8585 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", 15, 11, 8585 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", 15, 11, 8618 }, /* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode. */ - {VENDOR_ATI, CARD_ATI_RADEON_9500, "ATI Radeon 9500", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_X700, "ATI Radeon X700 SE", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_X1600, "ATI Radeon X1600 Series", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD2300, "ATI Mobility Radeon HD 2300", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD2600, "ATI Mobility Radeon HD 2600", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD2900, "ATI Radeon HD 2900 XT", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD4350, "ATI Radeon HD 4350", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD4600, "ATI Radeon HD 4600 Series", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD4700, "ATI Radeon HD 4700 Series", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD4800, "ATI Radeon HD 4800 Series", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD5700, "ATI Radeon HD 5700 Series", 14, 10, 8681 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD5800, "ATI Radeon HD 5800 Series", 14, 10, 8681 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_9500, "ATI Radeon 9500", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_X700, "ATI Radeon X700 SE", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_X1600, "ATI Radeon X1600 Series", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2300, "ATI Mobility Radeon HD 2300", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2600, "ATI Mobility Radeon HD 2600", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2900, "ATI Radeon HD 2900 XT", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4350, "ATI Radeon HD 4350", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4600, "ATI Radeon HD 4600 Series", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4700, "ATI Radeon HD 4700 Series", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4800, "ATI Radeon HD 4800 Series", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD5700, "ATI Radeon HD 5700 Series", 14, 10, 8681 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD5800, "ATI Radeon HD 5800 Series", 14, 10, 8681 }, /* TODO: Add information about legacy ATI hardware, Intel and other cards. */ }; @@ -995,14 +991,15 @@ static void init_driver_info(struct wined3d_driver_info *driver_info, switch (vendor) { - case VENDOR_ATI: + case HW_VENDOR_ATI: driver_info->name = "ati2dvag.dll"; break; - case VENDOR_NVIDIA: + case HW_VENDOR_NVIDIA: driver_info->name = "nv4_disp.dll"; break; + case HW_VENDOR_INTEL: default: FIXME_(d3d_caps)("Unhandled vendor %04x.\n", vendor); driver_info->name = "Display"; @@ -1077,13 +1074,13 @@ static void init_driver_info(struct wined3d_driver_info *driver_info, /* Context activation is done by the caller. */ static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { unsigned int i; for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i) { - if (!quirk_table[i].match(gl_info, gl_renderer, vendor, device)) continue; + if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue; TRACE_(d3d_caps)("Applying driver quirk \"%s\".\n", quirk_table[i].description); quirk_table[i].apply(gl_info); } @@ -1110,34 +1107,760 @@ static DWORD wined3d_parse_gl_version(const char *gl_version) return MAKEDWORD_VERSION(major, minor); } -static enum wined3d_pci_vendor wined3d_guess_vendor(const char *gl_vendor, const char *gl_renderer) +static enum wined3d_gl_vendor wined3d_guess_gl_vendor(struct wined3d_gl_info *gl_info, const char *gl_vendor_string, const char *gl_renderer) { - if (strstr(gl_vendor, "NVIDIA")) - return VENDOR_NVIDIA; - if (strstr(gl_vendor, "ATI")) - return VENDOR_ATI; + /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from + * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to + * detect the Apple OpenGL implementation to apply some extension fixups afterwards. + * + * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks + * aren't sufficient either because a Linux binary may display on a macos X server via remote X11. + * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions + * like client storage might be supported on other implementations too, but GL_APPLE_flush_render + * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So + * the chance that other implementations support them is rather small since Win32 QuickTime uses + * DirectDraw, not OpenGL. */ + if (gl_info->supported[APPLE_FENCE] + && gl_info->supported[APPLE_CLIENT_STORAGE] + && gl_info->supported[APPLE_FLUSH_RENDER] + && gl_info->supported[APPLE_YCBCR_422]) + return GL_VENDOR_APPLE; - if (strstr(gl_vendor, "Intel(R)") + if (strstr(gl_vendor_string, "NVIDIA")) + return GL_VENDOR_NVIDIA; + + if (strstr(gl_vendor_string, "ATI")) + return GL_VENDOR_ATI; + + if (strstr(gl_vendor_string, "Intel(R)") || strstr(gl_renderer, "Intel(R)") - || strstr(gl_vendor, "Intel Inc.")) - return VENDOR_INTEL; + || strstr(gl_vendor_string, "Intel Inc.")) + return GL_VENDOR_INTEL; - if (strstr(gl_vendor, "Mesa") - || strstr(gl_vendor, "DRI R300 Project") - || strstr(gl_vendor, "Tungsten Graphics, Inc") - || strstr(gl_vendor, "VMware, Inc.")) - return VENDOR_MESA; + if (strstr(gl_vendor_string, "Mesa") + || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.") + || strstr(gl_vendor_string, "DRI R300 Project") + || strstr(gl_vendor_string, "X.Org R300 Project") + || strstr(gl_vendor_string, "Tungsten Graphics, Inc") + || strstr(gl_vendor_string, "VMware, Inc.") + || strstr(gl_renderer, "Mesa") + || strstr(gl_renderer, "Gallium")) + return GL_VENDOR_MESA; - FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning VENDOR_WINE.\n", debugstr_a(gl_vendor)); + FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_WINE.\n", debugstr_a(gl_vendor_string)); - return VENDOR_WINE; + return GL_VENDOR_WINE; } -static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor *vendor, unsigned int *vidmem) +static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer) { - /* Below is a list of Nvidia and ATI GPUs. Both vendors have dozens of + if (strstr(gl_vendor_string, "NVIDIA")) + return HW_VENDOR_NVIDIA; + + if (strstr(gl_vendor_string, "ATI") + || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.") + || strstr(gl_vendor_string, "X.Org R300 Project") + || strstr(gl_vendor_string, "DRI R300 Project")) + return HW_VENDOR_ATI; + + if (strstr(gl_vendor_string, "Intel(R)") + || strstr(gl_renderer, "Intel(R)") + || strstr(gl_vendor_string, "Intel Inc.")) + return HW_VENDOR_INTEL; + + if (strstr(gl_vendor_string, "Mesa") + || strstr(gl_vendor_string, "Tungsten Graphics, Inc") + || strstr(gl_vendor_string, "VMware, Inc.")) + return HW_VENDOR_WINE; + + FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string)); + + return HW_VENDOR_NVIDIA; +} + + + +enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more + * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx. + */ + if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3]) + { + /* Geforce 200 - highend */ + if (strstr(gl_renderer, "GTX 280") + || strstr(gl_renderer, "GTX 285") + || strstr(gl_renderer, "GTX 295")) + { + *vidmem = 1024; + return CARD_NVIDIA_GEFORCE_GTX280; + } + + /* Geforce 200 - midend high */ + if (strstr(gl_renderer, "GTX 275")) + { + *vidmem = 896; + return CARD_NVIDIA_GEFORCE_GTX275; + } + + /* Geforce 200 - midend */ + if (strstr(gl_renderer, "GTX 260")) + { + *vidmem = 1024; + return CARD_NVIDIA_GEFORCE_GTX260; + } + /* Geforce 200 - midend */ + if (strstr(gl_renderer, "GT 240")) + { + *vidmem = 512; + return CARD_NVIDIA_GEFORCE_GT240; + } + + /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */ + if (strstr(gl_renderer, "9800") + || strstr(gl_renderer, "GTS 150") + || strstr(gl_renderer, "GTS 250")) + { + *vidmem = 512; + return CARD_NVIDIA_GEFORCE_9800GT; + } + + /* Geforce9 - midend */ + if (strstr(gl_renderer, "9600")) + { + *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */ + return CARD_NVIDIA_GEFORCE_9600GT; + } + + /* Geforce9 - midend low / Geforce 200 - low */ + if (strstr(gl_renderer, "9500") + || strstr(gl_renderer, "GT 120") + || strstr(gl_renderer, "GT 130")) + { + *vidmem = 256; /* The 9500GT has 256-1024MB */ + return CARD_NVIDIA_GEFORCE_9500GT; + } + + /* Geforce9 - lowend */ + if (strstr(gl_renderer, "9400")) + { + *vidmem = 256; /* The 9400GT has 256-1024MB */ + return CARD_NVIDIA_GEFORCE_9400GT; + } + + /* Geforce9 - lowend low */ + if (strstr(gl_renderer, "9100") + || strstr(gl_renderer, "9200") + || strstr(gl_renderer, "9300") + || strstr(gl_renderer, "G 100")) + { + *vidmem = 256; /* The 9100-9300 cards have 256MB */ + return CARD_NVIDIA_GEFORCE_9200; + } + + /* Geforce8 - highend */ + if (strstr(gl_renderer, "8800")) + { + *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */ + return CARD_NVIDIA_GEFORCE_8800GTS; + } + + /* Geforce8 - midend mobile */ + if (strstr(gl_renderer, "8600 M")) + { + *vidmem = 512; + return CARD_NVIDIA_GEFORCE_8600MGT; + } + + /* Geforce8 - midend */ + if (strstr(gl_renderer, "8600") + || strstr(gl_renderer, "8700")) + { + *vidmem = 256; + return CARD_NVIDIA_GEFORCE_8600GT; + } + + /* Geforce8 - lowend */ + if (strstr(gl_renderer, "8100") + || strstr(gl_renderer, "8200") + || strstr(gl_renderer, "8300") + || strstr(gl_renderer, "8400") + || strstr(gl_renderer, "8500")) + { + *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */ + return CARD_NVIDIA_GEFORCE_8300GS; + } + + /* Geforce7 - highend */ + if (strstr(gl_renderer, "7800") + || strstr(gl_renderer, "7900") + || strstr(gl_renderer, "7950") + || strstr(gl_renderer, "Quadro FX 4") + || strstr(gl_renderer, "Quadro FX 5")) + { + *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */ + return CARD_NVIDIA_GEFORCE_7800GT; + } + + /* Geforce7 midend */ + if (strstr(gl_renderer, "7600") + || strstr(gl_renderer, "7700")) + { + *vidmem = 256; /* The 7600 uses 256-512MB */ + return CARD_NVIDIA_GEFORCE_7600; + } + + /* Geforce7 lower medium */ + if (strstr(gl_renderer, "7400")) + { + *vidmem = 256; /* The 7400 uses 256-512MB */ + return CARD_NVIDIA_GEFORCE_7400; + } + + /* Geforce7 lowend */ + if (strstr(gl_renderer, "7300")) + { + *vidmem = 256; /* Mac Pros with this card have 256 MB */ + return CARD_NVIDIA_GEFORCE_7300; + } + + /* Geforce6 highend */ + if (strstr(gl_renderer, "6800")) + { + *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */ + return CARD_NVIDIA_GEFORCE_6800; + } + + /* Geforce6 - midend */ + if (strstr(gl_renderer, "6600") + || strstr(gl_renderer, "6610") + || strstr(gl_renderer, "6700")) + { + *vidmem = 128; /* A 6600GT has 128-256MB */ + return CARD_NVIDIA_GEFORCE_6600GT; + } + + /* Geforce6/7 lowend */ + *vidmem = 64; /* */ + return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */ + } + + if (WINE_D3D9_CAPABLE(gl_info)) + { + /* GeforceFX - highend */ + if (strstr(gl_renderer, "5800") + || strstr(gl_renderer, "5900") + || strstr(gl_renderer, "5950") + || strstr(gl_renderer, "Quadro FX")) + { + *vidmem = 256; /* 5800-5900 cards use 256MB */ + return CARD_NVIDIA_GEFORCEFX_5800; + } + + /* GeforceFX - midend */ + if (strstr(gl_renderer, "5600") + || strstr(gl_renderer, "5650") + || strstr(gl_renderer, "5700") + || strstr(gl_renderer, "5750")) + { + *vidmem = 128; /* A 5600 uses 128-256MB */ + return CARD_NVIDIA_GEFORCEFX_5600; + } + + /* GeforceFX - lowend */ + *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */ + return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */ + } + + if (WINE_D3D8_CAPABLE(gl_info)) + { + if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4")) + { + *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */ + return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */ + } + + *vidmem = 64; /* Geforce3 cards have 64-128MB */ + return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */ + } + + if (WINE_D3D7_CAPABLE(gl_info)) + { + if (strstr(gl_renderer, "GeForce4 MX")) + { + /* Most Geforce4MX GPUs have at least 64MB of memory, some + * early models had 32MB but most have 64MB or even 128MB. */ + *vidmem = 64; + return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */ + } + + if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR")) + { + *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */ + return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */ + } + + if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2")) + { + *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */ + return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */ + } + + /* Most Geforce1 cards have 32MB, there are also some rare 16 + * and 64MB (Dell) models. */ + *vidmem = 32; + return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */ + } + + if (strstr(gl_renderer, "TNT2")) + { + *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */ + return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */ + } + + *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */ + return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */ + +} + +enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx + * + * Beware: renderer string do not match exact card model, + * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */ + if (WINE_D3D9_CAPABLE(gl_info)) + { + /* Radeon EG CYPRESS XT / PRO HD5800 - highend */ + if (strstr(gl_renderer, "HD 5800") /* Radeon EG CYPRESS HD58xx generic renderer string */ + || strstr(gl_renderer, "HD 5850") /* Radeon EG CYPRESS XT */ + || strstr(gl_renderer, "HD 5870")) /* Radeon EG CYPRESS PRO */ + { + *vidmem = 1024; /* note: HD58xx cards use 1024MB */ + return CARD_ATI_RADEON_HD5800; + } + + /* Radeon EG JUNIPER XT / LE HD5700 - midend */ + if (strstr(gl_renderer, "HD 5700") /* Radeon EG JUNIPER HD57xx generic renderer string */ + || strstr(gl_renderer, "HD 5750") /* Radeon EG JUNIPER LE */ + || strstr(gl_renderer, "HD 5770")) /* Radeon EG JUNIPER XT */ + { + *vidmem = 512; /* note: HD5770 cards use 1024MB and HD5750 cards use 512MB or 1024MB */ + return CARD_ATI_RADEON_HD5700; + } + + /* Radeon R7xx HD4800 - highend */ + if (strstr(gl_renderer, "HD 4800") /* Radeon RV7xx HD48xx generic renderer string */ + || strstr(gl_renderer, "HD 4830") /* Radeon RV770 */ + || strstr(gl_renderer, "HD 4850") /* Radeon RV770 */ + || strstr(gl_renderer, "HD 4870") /* Radeon RV770 */ + || strstr(gl_renderer, "HD 4890")) /* Radeon RV790 */ + { + *vidmem = 512; /* note: HD4890 cards use 1024MB */ + return CARD_ATI_RADEON_HD4800; + } + + /* Radeon R740 HD4700 - midend */ + if (strstr(gl_renderer, "HD 4700") /* Radeon RV770 */ + || strstr(gl_renderer, "HD 4770")) /* Radeon RV740 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4700; + } + + /* Radeon R730 HD4600 - midend */ + if (strstr(gl_renderer, "HD 4600") /* Radeon RV730 */ + || strstr(gl_renderer, "HD 4650") /* Radeon RV730 */ + || strstr(gl_renderer, "HD 4670")) /* Radeon RV730 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4600; + } + + /* Radeon R710 HD4500/HD4350 - lowend */ + if (strstr(gl_renderer, "HD 4350") /* Radeon RV710 */ + || strstr(gl_renderer, "HD 4550")) /* Radeon RV710 */ + { + *vidmem = 256; + return CARD_ATI_RADEON_HD4350; + } + + /* Radeon R6xx HD2900/HD3800 - highend */ + if (strstr(gl_renderer, "HD 2900") + || strstr(gl_renderer, "HD 3870") + || strstr(gl_renderer, "HD 3850")) + { + *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */ + return CARD_ATI_RADEON_HD2900; + } + + /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */ + if (strstr(gl_renderer, "HD 2600") + || strstr(gl_renderer, "HD 3830") + || strstr(gl_renderer, "HD 3690") + || strstr(gl_renderer, "HD 3650")) + { + *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */ + return CARD_ATI_RADEON_HD2600; + } + + /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */ + if (strstr(gl_renderer, "HD 2300") + || strstr(gl_renderer, "HD 2400") + || strstr(gl_renderer, "HD 3470") + || strstr(gl_renderer, "HD 3450") + || strstr(gl_renderer, "HD 3430") + || strstr(gl_renderer, "HD 3400")) + { + *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */ + return CARD_ATI_RADEON_HD2300; + } + + /* Radeon R6xx/R7xx integrated */ + if (strstr(gl_renderer, "HD 3100") + || strstr(gl_renderer, "HD 3200") + || strstr(gl_renderer, "HD 3300")) + { + *vidmem = 128; /* 128MB */ + return CARD_ATI_RADEON_HD3200; + } + + /* Radeon R5xx */ + if (strstr(gl_renderer, "X1600") + || strstr(gl_renderer, "X1650") + || strstr(gl_renderer, "X1800") + || strstr(gl_renderer, "X1900") + || strstr(gl_renderer, "X1950")) + { + *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */ + return CARD_ATI_RADEON_X1600; + } + + /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */ + if (strstr(gl_renderer, "X700") + || strstr(gl_renderer, "X800") + || strstr(gl_renderer, "X850") + || strstr(gl_renderer, "X1300") + || strstr(gl_renderer, "X1400") + || strstr(gl_renderer, "X1450") + || strstr(gl_renderer, "X1550")) + { + *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */ + return CARD_ATI_RADEON_X700; + } + + /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */ + if (strstr(gl_renderer, "Radeon Xpress")) + { + *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */ + return CARD_ATI_RADEON_XPRESS_200M; + } + + /* Radeon R3xx */ + *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */ + return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */ + } + + if (WINE_D3D8_CAPABLE(gl_info)) + { + *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */ + return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */ + } + + if (WINE_D3D7_CAPABLE(gl_info)) + { + *vidmem = 32; /* There are models with up to 64MB */ + return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */ + } + + *vidmem = 16; /* There are 16-32MB models */ + return CARD_ATI_RAGE_128PRO; + +} + +enum wined3d_pci_device select_card_intel_binary(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + if (strstr(gl_renderer, "X3100")) + { + /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */ + *vidmem = 128; + return CARD_INTEL_X3100; + } + + if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM")) + { + /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */ + *vidmem = 64; + return CARD_INTEL_I945GM; + } + + if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM; + if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G; + if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G; + if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G; + if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G; + return CARD_INTEL_I915G; + +} + +enum wined3d_pci_device (select_card_ati_mesa)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx + * + * Beware: renderer string do not match exact card model, + * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */ + if (strstr(gl_renderer, "Gallium")) + { + /* Radeon R7xx HD4800 - highend */ + if (strstr(gl_renderer, "R700") /* Radeon R7xx HD48xx generic renderer string */ + || strstr(gl_renderer, "RV770") /* Radeon RV770 */ + || strstr(gl_renderer, "RV790")) /* Radeon RV790 */ + { + *vidmem = 512; /* note: HD4890 cards use 1024MB */ + return CARD_ATI_RADEON_HD4800; + } + + /* Radeon R740 HD4700 - midend */ + if (strstr(gl_renderer, "RV740")) /* Radeon RV740 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4700; + } + + /* Radeon R730 HD4600 - midend */ + if (strstr(gl_renderer, "RV730")) /* Radeon RV730 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4600; + } + + /* Radeon R710 HD4500/HD4350 - lowend */ + if (strstr(gl_renderer, "RV710")) /* Radeon RV710 */ + { + *vidmem = 256; + return CARD_ATI_RADEON_HD4350; + } + + /* Radeon R6xx HD2900/HD3800 - highend */ + if (strstr(gl_renderer, "R600") + || strstr(gl_renderer, "RV670") + || strstr(gl_renderer, "R680")) + { + *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */ + return CARD_ATI_RADEON_HD2900; + } + + /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */ + if (strstr(gl_renderer, "RV630") + || strstr(gl_renderer, "RV635")) + { + *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */ + return CARD_ATI_RADEON_HD2600; + } + + /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */ + if (strstr(gl_renderer, "RV610") + || strstr(gl_renderer, "RV620")) + { + *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */ + return CARD_ATI_RADEON_HD2300; + } + + /* Radeon R6xx/R7xx integrated */ + if (strstr(gl_renderer, "RS780") + || strstr(gl_renderer, "RS880")) + { + *vidmem = 128; /* 128MB */ + return CARD_ATI_RADEON_HD3200; + } + + /* Radeon R5xx */ + if (strstr(gl_renderer, "RV530") + || strstr(gl_renderer, "RV535") + || strstr(gl_renderer, "RV560") + || strstr(gl_renderer, "R520") + || strstr(gl_renderer, "RV570") + || strstr(gl_renderer, "R580")) + { + *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */ + return CARD_ATI_RADEON_X1600; + } + + /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */ + if (strstr(gl_renderer, "R410") + || strstr(gl_renderer, "R420") + || strstr(gl_renderer, "R423") + || strstr(gl_renderer, "R430") + || strstr(gl_renderer, "R480") + || strstr(gl_renderer, "R481") + || strstr(gl_renderer, "RV410") + || strstr(gl_renderer, "RV515") + || strstr(gl_renderer, "RV516")) + { + *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */ + return CARD_ATI_RADEON_X700; + } + + /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */ + if (strstr(gl_renderer, "RS400") + || strstr(gl_renderer, "RS480") + || strstr(gl_renderer, "RS482") + || strstr(gl_renderer, "RS485") + || strstr(gl_renderer, "RS600") + || strstr(gl_renderer, "RS690") + || strstr(gl_renderer, "RS740")) + { + *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */ + return CARD_ATI_RADEON_XPRESS_200M; + } + + /* Radeon R3xx */ + if (strstr(gl_renderer, "R300") + || strstr(gl_renderer, "RV350") + || strstr(gl_renderer, "RV351") + || strstr(gl_renderer, "RV360") + || strstr(gl_renderer, "RV370") + || strstr(gl_renderer, "R350") + || strstr(gl_renderer, "R360")) + { + *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */ + return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */ + } + } + + if (WINE_D3D9_CAPABLE(gl_info)) + { + /* Radeon R7xx HD4800 - highend */ + if (strstr(gl_renderer, "(R700") /* Radeon R7xx HD48xx generic renderer string */ + || strstr(gl_renderer, "(RV770") /* Radeon RV770 */ + || strstr(gl_renderer, "(RV790")) /* Radeon RV790 */ + { + *vidmem = 512; /* note: HD4890 cards use 1024MB */ + return CARD_ATI_RADEON_HD4800; + } + + /* Radeon R740 HD4700 - midend */ + if (strstr(gl_renderer, "(RV740")) /* Radeon RV740 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4700; + } + + /* Radeon R730 HD4600 - midend */ + if (strstr(gl_renderer, "(RV730")) /* Radeon RV730 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4600; + } + + /* Radeon R710 HD4500/HD4350 - lowend */ + if (strstr(gl_renderer, "(RV710")) /* Radeon RV710 */ + { + *vidmem = 256; + return CARD_ATI_RADEON_HD4350; + } + + /* Radeon R6xx HD2900/HD3800 - highend */ + if (strstr(gl_renderer, "(R600") + || strstr(gl_renderer, "(RV670") + || strstr(gl_renderer, "(R680")) + { + *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */ + return CARD_ATI_RADEON_HD2900; + } + + /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */ + if (strstr(gl_renderer, "(RV630") + || strstr(gl_renderer, "(RV635")) + { + *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */ + return CARD_ATI_RADEON_HD2600; + } + + /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */ + if (strstr(gl_renderer, "(RV610") + || strstr(gl_renderer, "(RV620")) + { + *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */ + return CARD_ATI_RADEON_HD2300; + } + + /* Radeon R6xx/R7xx integrated */ + if (strstr(gl_renderer, "(RS780") + || strstr(gl_renderer, "(RS880")) + { + *vidmem = 128; /* 128MB */ + return CARD_ATI_RADEON_HD3200; + } + } + + if (WINE_D3D8_CAPABLE(gl_info)) + { + *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */ + return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */ + } + + if (WINE_D3D7_CAPABLE(gl_info)) + { + *vidmem = 32; /* There are models with up to 64MB */ + return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */ + } + + *vidmem = 16; /* There are 16-32MB models */ + return CARD_ATI_RAGE_128PRO; + +} + +enum wined3d_pci_device (select_card_nvidia_mesa)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + FIXME_(d3d_caps)("Card selection not handled for Mesa Nouveau driver\n"); + if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600; + if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3; + if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE; + if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT; + return CARD_NVIDIA_RIVA_128; +} + +enum wined3d_pci_device (select_card_intel_mesa)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + FIXME_(d3d_caps)("Card selection not handled for Mesa Intel driver\n"); + return CARD_INTEL_I915G; +} + + +struct vendor_card_selection +{ + enum wined3d_gl_vendor gl_vendor; + enum wined3d_pci_vendor card_vendor; + const char *description; /* Description of the card selector i.e. Apple OS/X Intel */ + enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ); +}; + +static const struct vendor_card_selection vendor_card_select_table[] = +{ + {GL_VENDOR_NVIDIA, HW_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary}, + {GL_VENDOR_APPLE, HW_VENDOR_NVIDIA, "Apple OSX NVidia binary driver", select_card_nvidia_binary}, + {GL_VENDOR_APPLE, HW_VENDOR_ATI, "Apple OSX AMD/ATI binary driver", select_card_ati_binary}, + {GL_VENDOR_APPLE, HW_VENDOR_INTEL, "Apple OSX Intel binary driver", select_card_intel_binary}, + {GL_VENDOR_ATI, HW_VENDOR_ATI, "AMD/ATI binary driver", select_card_ati_binary}, + {GL_VENDOR_MESA, HW_VENDOR_ATI, "Mesa AMD/ATI driver", select_card_ati_mesa}, + {GL_VENDOR_MESA, HW_VENDOR_NVIDIA, "Mesa Nouveau driver", select_card_nvidia_mesa}, + {GL_VENDOR_MESA, HW_VENDOR_INTEL, "Mesa Intel driver", select_card_intel_mesa} +}; + + +static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor, unsigned int *vidmem) +{ + /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of * different GPUs with roughly the same features. In most cases GPUs from a * certain family differ in clockspeeds, the amount of video memory and the * number of shader pipelines. @@ -1192,451 +1915,84 @@ static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info * * memory behind our backs if really needed. Note that the amount of video * memory can be overruled using a registry setting. */ - switch (*vendor) + int i; + + for (i = 0; i < (sizeof(vendor_card_select_table) / sizeof(*vendor_card_select_table)); ++i) { - case VENDOR_NVIDIA: - /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more - * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx. - */ - if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3]) - { - /* Geforce 200 - highend */ - if (strstr(gl_renderer, "GTX 280") - || strstr(gl_renderer, "GTX 285") - || strstr(gl_renderer, "GTX 295")) - { - *vidmem = 1024; - return CARD_NVIDIA_GEFORCE_GTX280; - } - - /* Geforce 200 - midend high */ - if (strstr(gl_renderer, "GTX 275")) - { - *vidmem = 896; - return CARD_NVIDIA_GEFORCE_GTX275; - } - - /* Geforce 200 - midend */ - if (strstr(gl_renderer, "GTX 260")) - { - *vidmem = 1024; - return CARD_NVIDIA_GEFORCE_GTX260; - } - /* Geforce 200 - midend */ - if (strstr(gl_renderer, "GT 240")) - { - *vidmem = 512; - return CARD_NVIDIA_GEFORCE_GT240; - } - - /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */ - if (strstr(gl_renderer, "9800") - || strstr(gl_renderer, "GTS 150") - || strstr(gl_renderer, "GTS 250")) - { - *vidmem = 512; - return CARD_NVIDIA_GEFORCE_9800GT; - } - - /* Geforce9 - midend */ - if (strstr(gl_renderer, "9600")) - { - *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */ - return CARD_NVIDIA_GEFORCE_9600GT; - } - - /* Geforce9 - midend low / Geforce 200 - low */ - if (strstr(gl_renderer, "9500") - || strstr(gl_renderer, "GT 120") - || strstr(gl_renderer, "GT 130")) - { - *vidmem = 256; /* The 9500GT has 256-1024MB */ - return CARD_NVIDIA_GEFORCE_9500GT; - } - - /* Geforce9 - lowend */ - if (strstr(gl_renderer, "9400")) - { - *vidmem = 256; /* The 9400GT has 256-1024MB */ - return CARD_NVIDIA_GEFORCE_9400GT; - } - - /* Geforce9 - lowend low */ - if (strstr(gl_renderer, "9100") - || strstr(gl_renderer, "9200") - || strstr(gl_renderer, "9300") - || strstr(gl_renderer, "G 100")) - { - *vidmem = 256; /* The 9100-9300 cards have 256MB */ - return CARD_NVIDIA_GEFORCE_9200; - } - - /* Geforce8 - highend */ - if (strstr(gl_renderer, "8800")) - { - *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */ - return CARD_NVIDIA_GEFORCE_8800GTS; - } - - /* Geforce8 - midend mobile */ - if (strstr(gl_renderer, "8600 M")) - { - *vidmem = 512; - return CARD_NVIDIA_GEFORCE_8600MGT; - } - - /* Geforce8 - midend */ - if (strstr(gl_renderer, "8600") - || strstr(gl_renderer, "8700")) - { - *vidmem = 256; - return CARD_NVIDIA_GEFORCE_8600GT; - } - - /* Geforce8 - lowend */ - if (strstr(gl_renderer, "8100") - || strstr(gl_renderer, "8200") - || strstr(gl_renderer, "8300") - || strstr(gl_renderer, "8400") - || strstr(gl_renderer, "8500")) - { - *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */ - return CARD_NVIDIA_GEFORCE_8300GS; - } - - /* Geforce7 - highend */ - if (strstr(gl_renderer, "7800") - || strstr(gl_renderer, "7900") - || strstr(gl_renderer, "7950") - || strstr(gl_renderer, "Quadro FX 4") - || strstr(gl_renderer, "Quadro FX 5")) - { - *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */ - return CARD_NVIDIA_GEFORCE_7800GT; - } - - /* Geforce7 midend */ - if (strstr(gl_renderer, "7600") - || strstr(gl_renderer, "7700")) - { - *vidmem = 256; /* The 7600 uses 256-512MB */ - return CARD_NVIDIA_GEFORCE_7600; - } - - /* Geforce7 lower medium */ - if (strstr(gl_renderer, "7400")) - { - *vidmem = 256; /* The 7400 uses 256-512MB */ - return CARD_NVIDIA_GEFORCE_7400; - } - - /* Geforce7 lowend */ - if (strstr(gl_renderer, "7300")) - { - *vidmem = 256; /* Mac Pros with this card have 256 MB */ - return CARD_NVIDIA_GEFORCE_7300; - } - - /* Geforce6 highend */ - if (strstr(gl_renderer, "6800")) - { - *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */ - return CARD_NVIDIA_GEFORCE_6800; - } - - /* Geforce6 - midend */ - if (strstr(gl_renderer, "6600") - || strstr(gl_renderer, "6610") - || strstr(gl_renderer, "6700")) - { - *vidmem = 128; /* A 6600GT has 128-256MB */ - return CARD_NVIDIA_GEFORCE_6600GT; - } - - /* Geforce6/7 lowend */ - *vidmem = 64; /* */ - return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */ - } - - if (WINE_D3D9_CAPABLE(gl_info)) - { - /* GeforceFX - highend */ - if (strstr(gl_renderer, "5800") - || strstr(gl_renderer, "5900") - || strstr(gl_renderer, "5950") - || strstr(gl_renderer, "Quadro FX")) - { - *vidmem = 256; /* 5800-5900 cards use 256MB */ - return CARD_NVIDIA_GEFORCEFX_5800; - } - - /* GeforceFX - midend */ - if (strstr(gl_renderer, "5600") - || strstr(gl_renderer, "5650") - || strstr(gl_renderer, "5700") - || strstr(gl_renderer, "5750")) - { - *vidmem = 128; /* A 5600 uses 128-256MB */ - return CARD_NVIDIA_GEFORCEFX_5600; - } - - /* GeforceFX - lowend */ - *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */ - return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */ - } - - if (WINE_D3D8_CAPABLE(gl_info)) - { - if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4")) - { - *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */ - return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */ - } - - *vidmem = 64; /* Geforce3 cards have 64-128MB */ - return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */ - } - - if (WINE_D3D7_CAPABLE(gl_info)) - { - if (strstr(gl_renderer, "GeForce4 MX")) - { - /* Most Geforce4MX GPUs have at least 64MB of memory, some - * early models had 32MB but most have 64MB or even 128MB. */ - *vidmem = 64; - return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */ - } - - if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR")) - { - *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */ - return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */ - } - - if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2")) - { - *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */ - return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */ - } - - /* Most Geforce1 cards have 32MB, there are also some rare 16 - * and 64MB (Dell) models. */ - *vidmem = 32; - return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */ - } - - if (strstr(gl_renderer, "TNT2")) - { - *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */ - return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */ - } - - *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */ - return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */ - - case VENDOR_ATI: - /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx - * - * Beware: renderer string do not match exact card model, - * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */ - if (WINE_D3D9_CAPABLE(gl_info)) - { - /* Radeon EG CYPRESS XT / PRO HD5800 - highend */ - if (strstr(gl_renderer, "HD 5800") /* Radeon EG CYPRESS HD58xx generic renderer string */ - || strstr(gl_renderer, "HD 5850") /* Radeon EG CYPRESS XT */ - || strstr(gl_renderer, "HD 5870")) /* Radeon EG CYPRESS PRO */ - { - *vidmem = 1024; /* note: HD58xx cards use 1024MB */ - return CARD_ATI_RADEON_HD5800; - } - - /* Radeon EG JUNIPER XT / LE HD5700 - midend */ - if (strstr(gl_renderer, "HD 5700") /* Radeon EG JUNIPER HD57xx generic renderer string */ - || strstr(gl_renderer, "HD 5750") /* Radeon EG JUNIPER LE */ - || strstr(gl_renderer, "HD 5770")) /* Radeon EG JUNIPER XT */ - { - *vidmem = 512; /* note: HD5770 cards use 1024MB and HD5750 cards use 512MB or 1024MB */ - return CARD_ATI_RADEON_HD5700; - } - - /* Radeon R7xx HD4800 - highend */ - if (strstr(gl_renderer, "HD 4800") /* Radeon RV7xx HD48xx generic renderer string */ - || strstr(gl_renderer, "HD 4830") /* Radeon RV770 */ - || strstr(gl_renderer, "HD 4850") /* Radeon RV770 */ - || strstr(gl_renderer, "HD 4870") /* Radeon RV770 */ - || strstr(gl_renderer, "HD 4890")) /* Radeon RV790 */ - { - *vidmem = 512; /* note: HD4890 cards use 1024MB */ - return CARD_ATI_RADEON_HD4800; - } - - /* Radeon R740 HD4700 - midend */ - if (strstr(gl_renderer, "HD 4700") /* Radeon RV770 */ - || strstr(gl_renderer, "HD 4770")) /* Radeon RV740 */ - { - *vidmem = 512; - return CARD_ATI_RADEON_HD4700; - } - - /* Radeon R730 HD4600 - midend */ - if (strstr(gl_renderer, "HD 4600") /* Radeon RV730 */ - || strstr(gl_renderer, "HD 4650") /* Radeon RV730 */ - || strstr(gl_renderer, "HD 4670")) /* Radeon RV730 */ - { - *vidmem = 512; - return CARD_ATI_RADEON_HD4600; - } - - /* Radeon R710 HD4500/HD4350 - lowend */ - if (strstr(gl_renderer, "HD 4350") /* Radeon RV710 */ - || strstr(gl_renderer, "HD 4550")) /* Radeon RV710 */ - { - *vidmem = 256; - return CARD_ATI_RADEON_HD4350; - } - - /* Radeon R6xx HD2900/HD3800 - highend */ - if (strstr(gl_renderer, "HD 2900") - || strstr(gl_renderer, "HD 3870") - || strstr(gl_renderer, "HD 3850")) - { - *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */ - return CARD_ATI_RADEON_HD2900; - } - - /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */ - if (strstr(gl_renderer, "HD 2600") - || strstr(gl_renderer, "HD 3830") - || strstr(gl_renderer, "HD 3690") - || strstr(gl_renderer, "HD 3650")) - { - *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */ - return CARD_ATI_RADEON_HD2600; - } - - /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */ - if (strstr(gl_renderer, "HD 2300") - || strstr(gl_renderer, "HD 2400") - || strstr(gl_renderer, "HD 3470") - || strstr(gl_renderer, "HD 3450") - || strstr(gl_renderer, "HD 3430") - || strstr(gl_renderer, "HD 3400")) - { - *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */ - return CARD_ATI_RADEON_HD2300; - } - - /* Radeon R6xx/R7xx integrated */ - if (strstr(gl_renderer, "HD 3100") - || strstr(gl_renderer, "HD 3200") - || strstr(gl_renderer, "HD 3300")) - { - *vidmem = 128; /* 128MB */ - return CARD_ATI_RADEON_HD3200; - } - - /* Radeon R5xx */ - if (strstr(gl_renderer, "X1600") - || strstr(gl_renderer, "X1650") - || strstr(gl_renderer, "X1800") - || strstr(gl_renderer, "X1900") - || strstr(gl_renderer, "X1950")) - { - *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */ - return CARD_ATI_RADEON_X1600; - } - - /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */ - if (strstr(gl_renderer, "X700") - || strstr(gl_renderer, "X800") - || strstr(gl_renderer, "X850") - || strstr(gl_renderer, "X1300") - || strstr(gl_renderer, "X1400") - || strstr(gl_renderer, "X1450") - || strstr(gl_renderer, "X1550")) - { - *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */ - return CARD_ATI_RADEON_X700; - } - - /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */ - if (strstr(gl_renderer, "Radeon Xpress")) - { - *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */ - return CARD_ATI_RADEON_XPRESS_200M; - } - - /* Radeon R3xx */ - *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */ - return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */ - } - - if (WINE_D3D8_CAPABLE(gl_info)) - { - *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */ - return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */ - } - - if (WINE_D3D7_CAPABLE(gl_info)) - { - *vidmem = 32; /* There are models with up to 64MB */ - return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */ - } - - *vidmem = 16; /* There are 16-32MB models */ - return CARD_ATI_RAGE_128PRO; - - case VENDOR_INTEL: - if (strstr(gl_renderer, "X3100")) - { - /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */ - *vidmem = 128; - return CARD_INTEL_X3100; - } - - if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM")) - { - /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */ - *vidmem = 64; - return CARD_INTEL_I945GM; - } - - if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM; - if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G; - if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G; - if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G; - if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G; - return CARD_INTEL_I915G; - - case VENDOR_MESA: - case VENDOR_WINE: - default: - /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice - * for Nvidia was because the hardware and drivers they make are of good quality. This makes - * them a good generic choice. */ - *vendor = VENDOR_NVIDIA; - if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600; - if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3; - if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE; - if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT; - return CARD_NVIDIA_RIVA_128; + if ((vendor_card_select_table[i].gl_vendor != *gl_vendor) + || (vendor_card_select_table[i].card_vendor != *card_vendor)) + continue; + TRACE_(d3d_caps)("Applying card_selector \"%s\".\n", vendor_card_select_table[i].description); + return vendor_card_select_table[i].select_card(gl_info, gl_renderer, vidmem); } + + FIXME_(d3d_caps)("No card selector available for GL vendor %d and card vendor %04x.\n", + *gl_vendor, *card_vendor); + + /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice + * for Nvidia was because the hardware and drivers they make are of good quality. This makes + * them a good generic choice. */ + *card_vendor = HW_VENDOR_NVIDIA; + if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600; + if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3; + if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE; + if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT; + return CARD_NVIDIA_RIVA_128; +} + +static const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter) +{ + const struct wined3d_gl_info *gl_info = &adapter->gl_info; + int vs_selected_mode, ps_selected_mode; + + select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode); + if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) + && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_fragment_pipeline; + else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline; + else if (gl_info->supported[NV_REGISTER_COMBINERS] + && gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline; + else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline; + else return &ffp_fragment_pipeline; +} + +static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter) +{ + int vs_selected_mode, ps_selected_mode; + + select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode); + if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend; + if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend; + return &none_shader_backend; +} + +static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter) +{ + const struct wined3d_gl_info *gl_info = &adapter->gl_info; + int vs_selected_mode, ps_selected_mode; + + select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode); + if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) + && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit; + else return &ffp_blit; } /* Context activation is done by the caller. */ -static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, struct wined3d_gl_info *gl_info) +static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter) { + struct wined3d_driver_info *driver_info = &adapter->driver_info; + struct wined3d_gl_info *gl_info = &adapter->gl_info; const char *GL_Extensions = NULL; const char *WGL_Extensions = NULL; - const char *gl_string = NULL; - enum wined3d_pci_vendor vendor; + const char *gl_vendor_str, *gl_renderer_str, *gl_version_str; + struct fragment_caps fragment_caps; + enum wined3d_gl_vendor gl_vendor; + enum wined3d_pci_vendor card_vendor; enum wined3d_pci_device device; GLint gl_max; GLfloat gl_floatv[2]; unsigned i; HDC hdc; unsigned int vidmem=0; - char *gl_renderer; DWORD gl_version; size_t len; @@ -1644,48 +2000,34 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str ENTER_GL(); - gl_string = (const char *)glGetString(GL_RENDERER); - TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_string)); - if (!gl_string) + gl_renderer_str = (const char *)glGetString(GL_RENDERER); + TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str)); + if (!gl_renderer_str) { LEAVE_GL(); ERR_(d3d_caps)("Received a NULL GL_RENDERER.\n"); return FALSE; } - len = strlen(gl_string) + 1; - gl_renderer = HeapAlloc(GetProcessHeap(), 0, len); - if (!gl_renderer) - { - LEAVE_GL(); - ERR_(d3d_caps)("Failed to allocate gl_renderer memory.\n"); - return FALSE; - } - memcpy(gl_renderer, gl_string, len); - - gl_string = (const char *)glGetString(GL_VENDOR); - TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_string)); - if (!gl_string) + gl_vendor_str = (const char *)glGetString(GL_VENDOR); + TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str)); + if (!gl_vendor_str) { LEAVE_GL(); ERR_(d3d_caps)("Received a NULL GL_VENDOR.\n"); - HeapFree(GetProcessHeap(), 0, gl_renderer); return FALSE; } - vendor = wined3d_guess_vendor(gl_string, gl_renderer); - TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x)\n", debugstr_a(gl_string), vendor); /* Parse the GL_VERSION field into major and minor information */ - gl_string = (const char *)glGetString(GL_VERSION); - TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_string)); - if (!gl_string) + gl_version_str = (const char *)glGetString(GL_VERSION); + TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_version_str)); + if (!gl_version_str) { LEAVE_GL(); ERR_(d3d_caps)("Received a NULL GL_VERSION.\n"); - HeapFree(GetProcessHeap(), 0, gl_renderer); return FALSE; } - gl_version = wined3d_parse_gl_version(gl_string); + gl_version = wined3d_parse_gl_version(gl_version_str); /* * Initialize openGL extension related variables @@ -1694,7 +2036,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str memset(gl_info->supported, 0, sizeof(gl_info->supported)); gl_info->limits.buffers = 1; gl_info->limits.textures = 1; - gl_info->limits.texture_stages = 1; gl_info->limits.fragment_samplers = 1; gl_info->limits.vertex_samplers = 0; gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers; @@ -1734,7 +2075,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str { LEAVE_GL(); ERR_(d3d_caps)("Received a NULL GL_EXTENSIONS.\n"); - HeapFree(GetProcessHeap(), 0, gl_renderer); return FALSE; } @@ -1831,6 +2171,12 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE; } } + if (gl_info->supported[ARB_MAP_BUFFER_RANGE]) + { + /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same + * functionality. Prefer the ARB extension */ + gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE; + } if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) { TRACE_(d3d_caps)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n"); @@ -1841,6 +2187,11 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str TRACE_(d3d_caps)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n"); gl_info->supported[ARB_DEPTH_CLAMP] = TRUE; } + if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) + { + TRACE_(d3d_caps)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n"); + gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE; + } if (gl_info->supported[NV_TEXTURE_SHADER2]) { if (gl_info->supported[NV_REGISTER_COMBINERS]) @@ -1851,6 +2202,13 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE; } } + + if (gl_info->supported[NV_REGISTER_COMBINERS]) + { + glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max); + gl_info->limits.general_combiners = gl_max; + TRACE_(d3d_caps)("Max general combiners: %d.\n", gl_max); + } if (gl_info->supported[ARB_DRAW_BUFFERS]) { glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max); @@ -1863,18 +2221,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->limits.textures = min(MAX_TEXTURES, gl_max); TRACE_(d3d_caps)("Max textures: %d.\n", gl_info->limits.textures); - if (gl_info->supported[NV_REGISTER_COMBINERS]) - { - GLint tmp; - glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &tmp); - gl_info->limits.texture_stages = min(MAX_TEXTURES, tmp); - } - else - { - gl_info->limits.texture_stages = min(MAX_TEXTURES, gl_max); - } - TRACE_(d3d_caps)("Max texture stages: %d.\n", gl_info->limits.texture_stages); - if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) { GLint tmp; @@ -1998,6 +2344,11 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->limits.glsl_varyings = gl_max; TRACE_(d3d_caps)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4); } + if (gl_info->supported[ARB_SHADING_LANGUAGE_100]) + { + const char *str = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB); + TRACE_(d3d_caps)("GLSL version string: %s.\n", debugstr_a(str)); + } if (gl_info->supported[NV_LIGHT_MAX_EXPONENT]) { glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess); @@ -2024,7 +2375,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE; gl_info->supported[NV_TEXTURE_SHADER] = FALSE; gl_info->supported[NV_TEXTURE_SHADER2] = FALSE; - gl_info->supported[NV_TEXTURE_SHADER3] = FALSE; } if (gl_info->supported[NV_HALF_FLOAT]) { @@ -2043,6 +2393,14 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str LEAVE_GL(); + adapter->fragment_pipe = select_fragment_implementation(adapter); + adapter->shader_backend = select_shader_backend(adapter); + adapter->blitter = select_blit_implementation(adapter); + + adapter->fragment_pipe->get_caps(gl_info, &fragment_caps); + gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages; + TRACE_(d3d_caps)("Max texture stages: %u.\n", gl_info->limits.texture_stages); + /* In some cases the number of texture stages can be larger than the number * of samplers. The GF4 for example can use only 2 samplers (no fragment * shaders), but 8 texture stages (register combiners). */ @@ -2113,8 +2471,12 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->limits.buffers = 1; } - device = wined3d_guess_card(gl_info, gl_renderer, &vendor, &vidmem); - TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", vendor, device); + gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str); + card_vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str); + TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str), gl_vendor, card_vendor); + + device = wined3d_guess_card(gl_info, gl_renderer_str, &gl_vendor, &card_vendor, &vidmem); + TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor, device); /* If we have an estimate use it, else default to 64MB; */ if(vidmem) @@ -2176,11 +2538,10 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str } } - fixup_extensions(gl_info, gl_renderer, vendor, device); - init_driver_info(driver_info, vendor, device); + fixup_extensions(gl_info, gl_renderer_str, gl_vendor, card_vendor, device); + init_driver_info(driver_info, card_vendor, device); add_gl_compat_wrappers(gl_info); - HeapFree(GetProcessHeap(), 0, gl_renderer); return TRUE; } @@ -2644,7 +3005,10 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U continue; if(cfgs[i].blueSize != blueSize) continue; - if(cfgs[i].alphaSize != alphaSize) + /* Not all drivers report alpha-less formats since they use 32-bit anyway, so accept alpha even if we didn't ask for it. */ + if(alphaSize && cfgs[i].alphaSize != alphaSize) + continue; + if(cfgs[i].colorSize != (glDesc->byte_count << 3)) continue; TRACE("Found iPixelFormat=%d to support MultiSampleType=%d for format %s\n", cfgs[i].iPixelFormat, MultiSampleType, debug_d3dformat(SurfaceFormat)); @@ -2748,8 +3112,6 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter static BOOL CheckBumpMapCapability(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc) { - const struct fragment_pipeline *fp; - switch(format_desc->format) { case WINED3DFMT_R8G8_SNORM: @@ -2760,8 +3122,7 @@ static BOOL CheckBumpMapCapability(struct wined3d_adapter *adapter, /* Ask the fixed function pipeline implementation if it can deal * with the conversion. If we've got a GL extension giving native * support this will be an identity conversion. */ - fp = select_fragment_implementation(adapter, DeviceType); - if (fp->color_fixup_supported(format_desc->color_fixup)) + if (adapter->fragment_pipe->color_fixup_supported(format_desc->color_fixup)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; @@ -2951,8 +3312,6 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc) { const struct wined3d_gl_info *gl_info = &adapter->gl_info; - const shader_backend_t *shader_backend; - const struct fragment_pipeline *fp; switch (format_desc->format) { @@ -3030,8 +3389,7 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, /* Ask the shader backend if it can deal with the conversion. If * we've got a GL extension giving native support this will be an * identity conversion. */ - shader_backend = select_shader_backend(adapter, DeviceType); - if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup)) + if (adapter->shader_backend->shader_color_fixup_supported(format_desc->color_fixup)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; @@ -3147,10 +3505,8 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC] || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC]) { - shader_backend = select_shader_backend(adapter, DeviceType); - fp = select_fragment_implementation(adapter, DeviceType); - if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup) - && fp->color_fixup_supported(format_desc->color_fixup)) + if (adapter->shader_backend->shader_color_fixup_supported(format_desc->color_fixup) + && adapter->fragment_pipe->color_fixup_supported(format_desc->color_fixup)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; @@ -3186,8 +3542,6 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter, const struct GlPixelFormatDesc *adapter_format_desc, WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *check_format_desc, WINED3DSURFTYPE SurfaceType) { - const struct blit_shader *blitter; - if(SurfaceType == SURFACE_GDI) { switch(check_format_desc->format) { @@ -3223,8 +3577,7 @@ static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter, const struct if (CheckDepthStencilCapability(adapter, adapter_format_desc, check_format_desc)) return TRUE; /* If opengl can't process the format natively, the blitter may be able to convert it */ - blitter = select_blit_implementation(adapter, DeviceType); - if (blitter->color_fixup_supported(check_format_desc->color_fixup)) + if (adapter->blitter->color_fixup_supported(check_format_desc->color_fixup)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; @@ -3789,8 +4142,6 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, int ps_selected_mode; struct shader_caps shader_caps; struct fragment_caps fragment_caps; - const shader_backend_t *shader_backend; - const struct fragment_pipeline *frag_pipeline = NULL; DWORD ckey_caps, blit_caps, fx_caps; TRACE_(d3d_caps)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps); @@ -4167,12 +4518,10 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, pCaps->VertexTextureFilterCaps = 0; memset(&shader_caps, 0, sizeof(shader_caps)); - shader_backend = select_shader_backend(adapter, DeviceType); - shader_backend->shader_get_caps(DeviceType, &adapter->gl_info, &shader_caps); + adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps); memset(&fragment_caps, 0, sizeof(fragment_caps)); - frag_pipeline = select_fragment_implementation(adapter, DeviceType); - frag_pipeline->get_caps(DeviceType, &adapter->gl_info, &fragment_caps); + adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps); /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */ pCaps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps; @@ -4697,7 +5046,7 @@ BOOL InitAdapters(IWineD3DImpl *This) goto nogl_adapter; } - ret = IWineD3DImpl_FillGLCaps(&adapter->driver_info, &adapter->gl_info); + ret = IWineD3DImpl_FillGLCaps(adapter); if(!ret) { ERR("Failed to initialize gl caps for default adapter\n"); WineD3D_ReleaseFakeGLContext(&fake_gl_ctx); @@ -4729,8 +5078,8 @@ BOOL InitAdapters(IWineD3DImpl *This) if (gl_info->supported[WGL_ARB_PIXEL_FORMAT]) { int attribute; - int attribs[10]; - int values[10]; + int attribs[11]; + int values[11]; int nAttribs = 0; attribute = WGL_NUMBER_PIXEL_FORMATS_ARB; @@ -4742,6 +5091,7 @@ BOOL InitAdapters(IWineD3DImpl *This) attribs[nAttribs++] = WGL_GREEN_BITS_ARB; attribs[nAttribs++] = WGL_BLUE_BITS_ARB; attribs[nAttribs++] = WGL_ALPHA_BITS_ARB; + attribs[nAttribs++] = WGL_COLOR_BITS_ARB; attribs[nAttribs++] = WGL_DEPTH_BITS_ARB; attribs[nAttribs++] = WGL_STENCIL_BITS_ARB; attribs[nAttribs++] = WGL_DRAW_TO_WINDOW_ARB; @@ -4762,12 +5112,13 @@ BOOL InitAdapters(IWineD3DImpl *This) cfgs->greenSize = values[1]; cfgs->blueSize = values[2]; cfgs->alphaSize = values[3]; - cfgs->depthSize = values[4]; - cfgs->stencilSize = values[5]; - cfgs->windowDrawable = values[6]; - cfgs->iPixelType = values[7]; - cfgs->doubleBuffer = values[8]; - cfgs->auxBuffers = values[9]; + cfgs->colorSize = values[4]; + cfgs->depthSize = values[5]; + cfgs->stencilSize = values[6]; + cfgs->windowDrawable = values[7]; + cfgs->iPixelType = values[8]; + cfgs->doubleBuffer = values[9]; + cfgs->auxBuffers = values[10]; cfgs->pbufferDrawable = FALSE; /* Check for pbuffer support when it is around as @@ -4794,7 +5145,7 @@ BOOL InitAdapters(IWineD3DImpl *This) } } - TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable); + TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, samples=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->numSamples, cfgs->windowDrawable, cfgs->pbufferDrawable); cfgs++; } } @@ -4828,6 +5179,7 @@ BOOL InitAdapters(IWineD3DImpl *This) cfgs->greenSize = ppfd.cGreenBits; cfgs->blueSize = ppfd.cBlueBits; cfgs->alphaSize = ppfd.cAlphaBits; + cfgs->colorSize = ppfd.cColorBits; cfgs->depthSize = ppfd.cDepthBits; cfgs->stencilSize = ppfd.cStencilBits; cfgs->pbufferDrawable = 0; diff --git a/reactos/dll/directx/wine/wined3d/drawprim.c b/reactos/dll/directx/wine/wined3d/drawprim.c index dbeb7993f9f..b29d012b9d1 100644 --- a/reactos/dll/directx/wine/wined3d/drawprim.c +++ b/reactos/dll/directx/wine/wined3d/drawprim.c @@ -334,7 +334,7 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format GL_EXTCALL(glVertexAttrib4ubvARB(index, ptr)); break; case WINED3DFMT_B8G8R8A8_UNORM: - if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) + if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) { const DWORD *src = ptr; DWORD c = *src & 0xff00ff00; @@ -690,6 +690,9 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT /* Finished updating the screen, restore lock */ LEAVE_GL(); + + wglFlush(); /* Flush to ensure ordering across contexts. */ + context_release(context); TRACE("Done all gl drawing\n"); @@ -1100,7 +1103,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, if(patch->has_texcoords) { vtxStride += 4 * sizeof(float); } - memset(&patch->strided, 0, sizeof(&patch->strided)); + memset(&patch->strided, 0, sizeof(patch->strided)); patch->strided.position.format = WINED3DFMT_R32G32B32_FLOAT; patch->strided.position.lpData = (BYTE *) patch->mem; patch->strided.position.dwStride = vtxStride; diff --git a/reactos/dll/directx/wine/wined3d/glsl_shader.c b/reactos/dll/directx/wine/wined3d/glsl_shader.c index 90b5092d38f..cb23ee6aa0e 100644 --- a/reactos/dll/directx/wine/wined3d/glsl_shader.c +++ b/reactos/dll/directx/wine/wined3d/glsl_shader.c @@ -156,6 +156,20 @@ struct glsl_vshader_private UINT num_gl_shaders, shader_array_size; }; +static const char *debug_gl_shader_type(GLenum type) +{ + switch (type) + { +#define WINED3D_TO_STR(u) case u: return #u + WINED3D_TO_STR(GL_VERTEX_SHADER_ARB); + WINED3D_TO_STR(GL_GEOMETRY_SHADER_ARB); + WINED3D_TO_STR(GL_FRAGMENT_SHADER_ARB); +#undef WINED3D_TO_STR + default: + return wine_dbg_sprintf("UNKNOWN(%#x)", type); + } +} + /* Extract a line from the info log. * Note that this modifies the source string. */ static char *get_info_log_line(char **ptr) @@ -238,6 +252,81 @@ static void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLhandleA } } +/* GL locking is done by the caller. */ +static void shader_glsl_dump_program_source(const struct wined3d_gl_info *gl_info, GLhandleARB program) +{ + GLint i, object_count, source_size; + GLhandleARB *objects; + char *source = NULL; + + GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_ATTACHED_OBJECTS_ARB, &object_count)); + objects = HeapAlloc(GetProcessHeap(), 0, object_count * sizeof(*objects)); + if (!objects) + { + ERR("Failed to allocate object array memory.\n"); + return; + } + + GL_EXTCALL(glGetAttachedObjectsARB(program, object_count, NULL, objects)); + for (i = 0; i < object_count; ++i) + { + char *ptr, *line; + GLint tmp; + + GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &tmp)); + + if (!source || source_size < tmp) + { + HeapFree(GetProcessHeap(), 0, source); + + source = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, tmp); + if (!source) + { + ERR("Failed to allocate %d bytes for shader source.\n", tmp); + HeapFree(GetProcessHeap(), 0, objects); + return; + } + source_size = tmp; + } + + FIXME("Object %u:\n", objects[i]); + GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_SUBTYPE_ARB, &tmp)); + FIXME(" GL_OBJECT_SUBTYPE_ARB: %s.\n", debug_gl_shader_type(tmp)); + GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_COMPILE_STATUS_ARB, &tmp)); + FIXME(" GL_OBJECT_COMPILE_STATUS_ARB: %d.\n", tmp); + FIXME("\n"); + + ptr = source; + GL_EXTCALL(glGetShaderSourceARB(objects[i], source_size, NULL, source)); + while ((line = get_info_log_line(&ptr))) FIXME(" %s\n", line); + FIXME("\n"); + } + + HeapFree(GetProcessHeap(), 0, source); + HeapFree(GetProcessHeap(), 0, objects); +} + +/* GL locking is done by the caller. */ +static void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLhandleARB program) +{ + GLint tmp; + + if (!TRACE_ON(d3d_shader) && !FIXME_ON(d3d_shader)) return; + + GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_TYPE_ARB, &tmp)); + if (tmp == GL_PROGRAM_OBJECT_ARB) + { + GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB, &tmp)); + if (!tmp) + { + FIXME("Program %u link status invalid.\n", program); + shader_glsl_dump_program_source(gl_info, program); + } + } + + print_glsl_info_log(gl_info, program); +} + /** * Loads (pixel shader) samplers */ @@ -1083,6 +1172,8 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont } } + shader_addline(buffer, "const float FLT_MAX = 1e38;\n"); + /* Start the main program */ shader_addline(buffer, "void main() {\n"); if(pshader && reg_maps->vpos) { @@ -1194,8 +1285,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * static const char * const hwrastout_reg_names[] = { "gl_Position", "gl_FogFragCoord", "gl_PointSize" }; IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; - const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; char pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type); *is_color = FALSE; @@ -1552,7 +1642,8 @@ static inline const char *shader_get_comp_op(DWORD op) } } -static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, glsl_sample_function_t *sample_function) +static void shader_glsl_get_sample_function(const struct wined3d_gl_info *gl_info, + DWORD sampler_type, DWORD flags, glsl_sample_function_t *sample_function) { BOOL projected = flags & WINED3D_GLSL_SAMPLE_PROJECTED; BOOL texrect = flags & WINED3D_GLSL_SAMPLE_RECT; @@ -1564,9 +1655,21 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, gls case WINED3DSTT_1D: if(lod) { sample_function->name = projected ? "texture1DProjLod" : "texture1DLod"; - } else if(grad) { - sample_function->name = projected ? "texture1DProjGradARB" : "texture1DGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = projected ? "texture1DProjGrad" : "texture1DGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = projected ? "texture1DProjGradARB" : "texture1DGradARB"; + else + { + FIXME("Unsupported 1D grad function.\n"); + sample_function->name = "unsupported1DGrad"; + } + } + else + { sample_function->name = projected ? "texture1DProj" : "texture1D"; } sample_function->coord_mask = WINED3DSP_WRITEMASK_0; @@ -1575,20 +1678,41 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, gls if(texrect) { if(lod) { sample_function->name = projected ? "texture2DRectProjLod" : "texture2DRectLod"; - } else if(grad) { - /* What good are texrect grad functions? I don't know, but GL_EXT_gpu_shader4 defines them. - * There is no GL_ARB_shader_texture_lod spec yet, so I don't know if they're defined there - */ - sample_function->name = projected ? "shadow2DRectProjGradARB" : "shadow2DRectGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = projected ? "texture2DRectProjGrad" : "texture2DRectGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = projected ? "texture2DRectProjGradARB" : "texture2DRectGradARB"; + else + { + FIXME("Unsupported RECT grad function.\n"); + sample_function->name = "unsupported2DRectGrad"; + } + } + else + { sample_function->name = projected ? "texture2DRectProj" : "texture2DRect"; } } else { if(lod) { sample_function->name = projected ? "texture2DProjLod" : "texture2DLod"; - } else if(grad) { - sample_function->name = projected ? "texture2DProjGradARB" : "texture2DGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = projected ? "texture2DProjGrad" : "texture2DGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = projected ? "texture2DProjGradARB" : "texture2DGradARB"; + else + { + FIXME("Unsupported 2D grad function.\n"); + sample_function->name = "unsupported2DGrad"; + } + } + else + { sample_function->name = projected ? "texture2DProj" : "texture2D"; } } @@ -1597,9 +1721,21 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, gls case WINED3DSTT_CUBE: if(lod) { sample_function->name = "textureCubeLod"; - } else if(grad) { - sample_function->name = "textureCubeGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = "textureCubeGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = "textureCubeGradARB"; + else + { + FIXME("Unsupported Cube grad function.\n"); + sample_function->name = "unsupportedCubeGrad"; + } + } + else + { sample_function->name = "textureCube"; } sample_function->coord_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; @@ -1607,9 +1743,21 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, gls case WINED3DSTT_VOLUME: if(lod) { sample_function->name = projected ? "texture3DProjLod" : "texture3DLod"; - } else if(grad) { - sample_function->name = projected ? "texture3DProjGradARB" : "texture3DGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = projected ? "texture3DProjGrad" : "texture3DGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = projected ? "texture3DProjGradARB" : "texture3DGradARB"; + else + { + FIXME("Unsupported 3D grad function.\n"); + sample_function->name = "unsupported3DGrad"; + } + } + else + { sample_function->name = projected ? "texture3DProj" : "texture3D"; } sample_function->coord_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; @@ -1681,10 +1829,10 @@ static void shader_glsl_color_correction(const struct wined3d_shader_instruction if (!mask) return; /* Nothing to do */ - if (is_yuv_fixup(fixup)) + if (is_complex_fixup(fixup)) { - enum yuv_fixup yuv_fixup = get_yuv_fixup(fixup); - FIXME("YUV fixup (%#x) not supported\n", yuv_fixup); + enum complex_fixup complex_fixup = get_complex_fixup(fixup); + FIXME("Complex fixup (%#x) not supported\n",complex_fixup); return; } @@ -1822,6 +1970,7 @@ static void shader_glsl_arith(const struct wined3d_shader_instruction *ins) /* Process the WINED3DSIO_MOV opcode using GLSL (dst = src) */ static void shader_glsl_mov(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; glsl_src_param_t src0_param; DWORD write_mask; @@ -1847,12 +1996,26 @@ static void shader_glsl_mov(const struct wined3d_shader_instruction *ins) { /* We need to *round* to the nearest int here. */ unsigned int mask_size = shader_glsl_get_write_mask_size(write_mask); - if (mask_size > 1) { - shader_addline(buffer, "ivec%d(floor(abs(%s) + vec%d(0.5)) * sign(%s)));\n", mask_size, src0_param.param_str, mask_size, src0_param.param_str); - } else { - shader_addline(buffer, "int(floor(abs(%s) + 0.5) * sign(%s)));\n", src0_param.param_str, src0_param.param_str); + + if (gl_info->supported[EXT_GPU_SHADER4]) + { + if (mask_size > 1) + shader_addline(buffer, "ivec%d(round(%s)));\n", mask_size, src0_param.param_str); + else + shader_addline(buffer, "int(round(%s)));\n", src0_param.param_str); } - } else { + else + { + if (mask_size > 1) + shader_addline(buffer, "ivec%d(floor(abs(%s) + vec%d(0.5)) * sign(%s)));\n", + mask_size, src0_param.param_str, mask_size, src0_param.param_str); + else + shader_addline(buffer, "int(floor(abs(%s) + 0.5) * sign(%s)));\n", + src0_param.param_str, src0_param.param_str); + } + } + else + { shader_addline(buffer, "%s);\n", src0_param.param_str); } } @@ -1942,10 +2105,15 @@ static void shader_glsl_log(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src0_param); - if (dst_size > 1) { - shader_addline(buffer, "vec%d(log2(abs(%s))));\n", dst_size, src0_param.param_str); - } else { - shader_addline(buffer, "log2(abs(%s)));\n", src0_param.param_str); + if (dst_size > 1) + { + shader_addline(buffer, "vec%d(%s == 0.0 ? -FLT_MAX : log2(abs(%s))));\n", + dst_size, src0_param.param_str, src0_param.param_str); + } + else + { + shader_addline(buffer, "%s == 0.0 ? -FLT_MAX : log2(abs(%s)));\n", + src0_param.param_str, src0_param.param_str); } } @@ -1966,7 +2134,6 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) case WINED3DSIH_MAX: instruction = "max"; break; case WINED3DSIH_ABS: instruction = "abs"; break; case WINED3DSIH_FRC: instruction = "fract"; break; - case WINED3DSIH_NRM: instruction = "normalize"; break; case WINED3DSIH_EXP: instruction = "exp2"; break; case WINED3DSIH_DSX: instruction = "dFdx"; break; case WINED3DSIH_DSY: instruction = "ycorrection.y * dFdy"; break; @@ -1993,6 +2160,22 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) shader_addline(buffer, "));\n"); } +static void shader_glsl_nrm(const struct wined3d_shader_instruction *ins) +{ + struct wined3d_shader_buffer *buffer = ins->ctx->buffer; + glsl_src_param_t src_param; + DWORD write_mask; + char dst_mask[6]; + + write_mask = shader_glsl_get_write_mask(ins->dst, dst_mask); + shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src_param); + + shader_addline(buffer, "tmp0.x = length(%s);\n", src_param.param_str); + shader_glsl_append_dst(buffer, ins); + shader_addline(buffer, "tmp0.x == 0.0 ? (%s * FLT_MAX) : (%s / tmp0.x));", + src_param.param_str, src_param.param_str); +} + /** Process the WINED3DSIO_EXPP instruction in GLSL: * For shader model 1.x, do the following (and honor the writemask, so use a temporary variable): * dst.x = 2^(floor(src)) @@ -2046,10 +2229,15 @@ static void shader_glsl_rcp(const struct wined3d_shader_instruction *ins) mask_size = shader_glsl_get_write_mask_size(write_mask); shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &src_param); - if (mask_size > 1) { - shader_addline(ins->ctx->buffer, "vec%d(1.0 / %s));\n", mask_size, src_param.param_str); - } else { - shader_addline(ins->ctx->buffer, "1.0 / %s);\n", src_param.param_str); + if (mask_size > 1) + { + shader_addline(ins->ctx->buffer, "vec%d(%s == 0.0 ? FLT_MAX : 1.0 / %s));\n", + mask_size, src_param.param_str, src_param.param_str); + } + else + { + shader_addline(ins->ctx->buffer, "%s == 0.0 ? FLT_MAX : 1.0 / %s);\n", + src_param.param_str, src_param.param_str); } } @@ -2065,10 +2253,15 @@ static void shader_glsl_rsq(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &src_param); - if (mask_size > 1) { - shader_addline(buffer, "vec%d(inversesqrt(%s)));\n", mask_size, src_param.param_str); - } else { - shader_addline(buffer, "inversesqrt(%s));\n", src_param.param_str); + if (mask_size > 1) + { + shader_addline(buffer, "vec%d(%s == 0.0 ? FLT_MAX : inversesqrt(abs(%s))));\n", + mask_size, src_param.param_str, src_param.param_str); + } + else + { + shader_addline(buffer, "%s == 0.0 ? FLT_MAX : inversesqrt(abs(%s)));\n", + src_param.param_str, src_param.param_str); } } @@ -2671,10 +2864,11 @@ static void shader_glsl_ret(const struct wined3d_shader_instruction *ins) ********************************************/ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major, ins->ctx->reg_maps->shader_version.minor); + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; DWORD sample_flags = 0; WINED3DSAMPLER_TEXTURE_TYPE sampler_type; @@ -2728,7 +2922,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins) sample_flags |= WINED3D_GLSL_SAMPLE_RECT; } - shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function); mask |= sample_function.coord_mask; if (shader_version < WINED3D_SHADER_VERSION(2,0)) swizzle = WINED3DSP_NOSWIZZLE; @@ -2762,7 +2956,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins) { IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; - const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; glsl_src_param_t coord_param, dx_param, dy_param; DWORD sample_flags = WINED3D_GLSL_SAMPLE_GRAD; @@ -2770,7 +2964,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins) DWORD sampler_idx; DWORD swizzle = ins->src[1].swizzle; - if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] && !gl_info->supported[EXT_GPU_SHADER4]) { FIXME("texldd used, but not supported by hardware. Falling back to regular tex\n"); return shader_glsl_tex(ins); @@ -2783,7 +2977,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins) sample_flags |= WINED3D_GLSL_SAMPLE_RECT; } - shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function); shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param); shader_glsl_add_src_param(ins, &ins->src[2], sample_function.coord_mask, &dx_param); shader_glsl_add_src_param(ins, &ins->src[3], sample_function.coord_mask, &dy_param); @@ -2796,7 +2990,7 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins) { IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; - const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; glsl_src_param_t coord_param, lod_param; DWORD sample_flags = WINED3D_GLSL_SAMPLE_LOD; @@ -2810,12 +3004,12 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins) IWineD3DBaseTexture_GetTextureDimensions(deviceImpl->stateBlock->textures[sampler_idx]) == GL_TEXTURE_RECTANGLE_ARB) { sample_flags |= WINED3D_GLSL_SAMPLE_RECT; } - shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function); shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param); shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &lod_param); - if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] + if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] && !gl_info->supported[EXT_GPU_SHADER4] && shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type)) { /* The GLSL spec claims the Lod sampling functions are only supported in vertex shaders. @@ -2877,6 +3071,7 @@ static void shader_glsl_texcoord(const struct wined3d_shader_instruction *ins) * then perform a 1D texture lookup from stage dstregnum, place into dst. */ static void shader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; glsl_sample_function_t sample_function; DWORD sampler_idx = ins->dst[0].reg.idx; @@ -2891,7 +3086,7 @@ static void shader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins) * * It is a dependent read - not valid with conditional NP2 textures */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); mask_size = shader_glsl_get_write_mask_size(sample_function.coord_mask); switch(mask_size) @@ -2990,7 +3185,7 @@ static void shader_glsl_texm3x2pad(const struct wined3d_shader_instruction *ins) * Calculate the 1st or 2nd row of a 3-row matrix multiplication. */ static void shader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -3004,6 +3199,7 @@ static void shader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins) static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -3014,7 +3210,7 @@ static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param); shader_addline(buffer, "tmp0.y = dot(T%u.xyz, %s);\n", reg, src0_param.param_str); - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); /* Sample the texture using the calculated coordinates */ shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xy"); @@ -3025,10 +3221,11 @@ static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins) static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins) { DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD reg = ins->dst[0].reg.idx; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[reg]; glsl_sample_function_t sample_function; @@ -3036,7 +3233,7 @@ static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins) shader_addline(ins->ctx->buffer, "tmp0.z = dot(T%u.xyz, %s);\n", reg, src0_param.param_str); /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); /* Sample the texture using the calculated coordinates */ shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz"); @@ -3049,11 +3246,11 @@ static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins) static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins) { DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; glsl_src_param_t src0_param; char dst_mask[6]; DWORD reg = ins->dst[0].reg.idx; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param); @@ -3068,7 +3265,8 @@ static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins) * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; DWORD reg = ins->dst[0].reg.idx; glsl_src_param_t src0_param; glsl_src_param_t src1_param; @@ -3087,7 +3285,7 @@ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins shader_addline(buffer, "tmp0.xyz = -reflect((%s), normalize(tmp0.xyz));\n", src1_param.param_str); /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(stype, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, stype, 0, &sample_function); /* Sample the texture */ shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz"); @@ -3099,7 +3297,8 @@ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state; @@ -3119,7 +3318,7 @@ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *in shader_addline(buffer, "tmp0.xyz = -reflect(tmp1.xyz, normalize(tmp0.xyz));\n"); /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); /* Sample the texture using the calculated coordinates */ shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz"); @@ -3133,8 +3332,9 @@ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *in */ static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; glsl_src_param_t coord_param; WINED3DSAMPLER_TEXTURE_TYPE sampler_type; @@ -3148,7 +3348,7 @@ static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins) sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); mask = sample_function.coord_mask; shader_glsl_write_mask_to_str(mask, coord_mask); @@ -3207,6 +3407,7 @@ static void shader_glsl_bem(const struct wined3d_shader_instruction *ins) * Sample 2D texture at dst using the alpha & red (wx) components of src as texture coordinates */ static void shader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD sampler_idx = ins->dst[0].reg.idx; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; @@ -3214,7 +3415,7 @@ static void shader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_ALL, &src0_param); - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "%s.wx", src0_param.reg_name); } @@ -3223,6 +3424,7 @@ static void shader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins) * Sample 2D texture at dst using the green & blue (yz) components of src as texture coordinates */ static void shader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD sampler_idx = ins->dst[0].reg.idx; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; @@ -3230,7 +3432,7 @@ static void shader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_ALL, &src0_param); - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "%s.yz", src0_param.reg_name); } @@ -3239,13 +3441,14 @@ static void shader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins) * Sample texture at dst using the rgb (xyz) components of src as texture coordinates */ static void shader_glsl_texreg2rgb(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD sampler_idx = ins->dst[0].reg.idx; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; glsl_sample_function_t sample_function; /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &src0_param); shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, @@ -3759,6 +3962,10 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context */ shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n"); } + if (gl_info->supported[EXT_GPU_SHADER4]) + { + shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); + } /* Base Declarations */ shader_generate_glsl_declarations(context, buffer, (IWineD3DBaseShader *)This, reg_maps, &priv_ctx); @@ -3846,6 +4053,11 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context shader_addline(buffer, "#version 120\n"); + if (gl_info->supported[EXT_GPU_SHADER4]) + { + shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); + } + memset(&priv_ctx, 0, sizeof(priv_ctx)); priv_ctx.cur_vs_args = args; @@ -4149,7 +4361,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, /* Link the program */ TRACE("Linking GLSL shader program %u\n", programId); GL_EXTCALL(glLinkProgramARB(programId)); - print_glsl_info_log(gl_info, programId); + shader_glsl_validate_link(gl_info, programId); entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * gl_info->limits.glsl_vs_float_constants); @@ -4230,10 +4442,12 @@ static void set_glsl_shader_program(const struct wined3d_context *context, * load them now to have them hardcoded in the GLSL program. This saves some CPU cycles * later */ - if(pshader && !((IWineD3DPixelShaderImpl*)pshader)->baseShader.load_local_constsF) { + if (pshader && !((IWineD3DBaseShaderImpl *)pshader)->baseShader.load_local_constsF) + { hardcode_local_constants((IWineD3DBaseShaderImpl *) pshader, gl_info, programId, 'P'); } - if(vshader && !((IWineD3DVertexShaderImpl*)vshader)->baseShader.load_local_constsF) { + if (vshader && !((IWineD3DBaseShaderImpl *)vshader)->baseShader.load_local_constsF) + { hardcode_local_constants((IWineD3DBaseShaderImpl *) vshader, gl_info, programId, 'V'); } } @@ -4303,7 +4517,7 @@ static GLhandleARB create_glsl_blt_shader(const struct wined3d_gl_info *gl_info, GL_EXTCALL(glAttachObjectARB(program_id, pshader_id)); GL_EXTCALL(glLinkProgramARB(program_id)); - print_glsl_info_log(gl_info, program_id); + shader_glsl_validate_link(gl_info, program_id); /* Once linked we can mark the shaders for deletion. They will be deleted once the program * is destroyed @@ -4394,8 +4608,6 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device; struct shader_glsl_priv *priv = device->shader_priv; const struct wined3d_gl_info *gl_info; - IWineD3DPixelShaderImpl *ps = NULL; - IWineD3DVertexShaderImpl *vs = NULL; struct wined3d_context *context; /* Note: Do not use QueryInterface here to find out which shader type this is because this code @@ -4405,12 +4617,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { if(pshader) { struct glsl_pshader_private *shader_data; - ps = (IWineD3DPixelShaderImpl *) This; - shader_data = ps->baseShader.backend_data; + shader_data = This->baseShader.backend_data; if(!shader_data || shader_data->num_gl_shaders == 0) { HeapFree(GetProcessHeap(), 0, shader_data); - ps->baseShader.backend_data = NULL; + This->baseShader.backend_data = NULL; return; } @@ -4425,12 +4636,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } } else { struct glsl_vshader_private *shader_data; - vs = (IWineD3DVertexShaderImpl *) This; - shader_data = vs->baseShader.backend_data; + shader_data = This->baseShader.backend_data; if(!shader_data || shader_data->num_gl_shaders == 0) { HeapFree(GetProcessHeap(), 0, shader_data); - vs->baseShader.backend_data = NULL; + This->baseShader.backend_data = NULL; return; } @@ -4466,7 +4676,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { if(pshader) { UINT i; - struct glsl_pshader_private *shader_data = ps->baseShader.backend_data; + struct glsl_pshader_private *shader_data = This->baseShader.backend_data; ENTER_GL(); for(i = 0; i < shader_data->num_gl_shaders; i++) { @@ -4476,11 +4686,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } LEAVE_GL(); HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); - HeapFree(GetProcessHeap(), 0, shader_data); - ps->baseShader.backend_data = NULL; - } else { + } + else + { UINT i; - struct glsl_vshader_private *shader_data = vs->baseShader.backend_data; + struct glsl_vshader_private *shader_data = This->baseShader.backend_data; ENTER_GL(); for(i = 0; i < shader_data->num_gl_shaders; i++) { @@ -4490,10 +4700,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } LEAVE_GL(); HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); - HeapFree(GetProcessHeap(), 0, shader_data); - vs->baseShader.backend_data = NULL; } + HeapFree(GetProcessHeap(), 0, This->baseShader.backend_data); + This->baseShader.backend_data = NULL; + context_release(context); } @@ -4632,8 +4843,7 @@ static BOOL shader_glsl_dirty_const(IWineD3DDevice *iface) { return FALSE; } -static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, - const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps) +static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps) { /* Nvidia Geforce6/7 or Ati R4xx/R5xx cards with GLSL support, support VS 3.0 but older Nvidia/Ati * models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support based @@ -4697,7 +4907,7 @@ static BOOL shader_glsl_color_fixup_supported(struct color_fixup_desc fixup) } /* We support everything except YUV conversions. */ - if (!is_yuv_fixup(fixup)) + if (!is_complex_fixup(fixup)) { TRACE("[OK]\n"); return TRUE; @@ -4720,6 +4930,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_CMP */ shader_glsl_cmp, /* WINED3DSIH_CND */ shader_glsl_cnd, /* WINED3DSIH_CRS */ shader_glsl_cross, + /* WINED3DSIH_CUT */ NULL, /* WINED3DSIH_DCL */ NULL, /* WINED3DSIH_DEF */ NULL, /* WINED3DSIH_DEFB */ NULL, @@ -4731,20 +4942,24 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_DSX */ shader_glsl_map2gl, /* WINED3DSIH_DSY */ shader_glsl_map2gl, /* WINED3DSIH_ELSE */ shader_glsl_else, + /* WINED3DSIH_EMIT */ NULL, /* WINED3DSIH_ENDIF */ shader_glsl_end, /* WINED3DSIH_ENDLOOP */ shader_glsl_end, /* WINED3DSIH_ENDREP */ shader_glsl_end, /* WINED3DSIH_EXP */ shader_glsl_map2gl, /* WINED3DSIH_EXPP */ shader_glsl_expp, /* WINED3DSIH_FRC */ shader_glsl_map2gl, + /* WINED3DSIH_IADD */ NULL, /* WINED3DSIH_IF */ shader_glsl_if, /* WINED3DSIH_IFC */ shader_glsl_ifc, + /* WINED3DSIH_IGE */ NULL, /* WINED3DSIH_LABEL */ shader_glsl_label, /* WINED3DSIH_LIT */ shader_glsl_lit, /* WINED3DSIH_LOG */ shader_glsl_log, /* WINED3DSIH_LOGP */ shader_glsl_log, /* WINED3DSIH_LOOP */ shader_glsl_loop, /* WINED3DSIH_LRP */ shader_glsl_lrp, + /* WINED3DSIH_LT */ NULL, /* WINED3DSIH_M3x2 */ shader_glsl_mnxn, /* WINED3DSIH_M3x3 */ shader_glsl_mnxn, /* WINED3DSIH_M3x4 */ shader_glsl_mnxn, @@ -4757,7 +4972,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_MOVA */ shader_glsl_mov, /* WINED3DSIH_MUL */ shader_glsl_arith, /* WINED3DSIH_NOP */ NULL, - /* WINED3DSIH_NRM */ shader_glsl_map2gl, + /* WINED3DSIH_NRM */ shader_glsl_nrm, /* WINED3DSIH_PHASE */ NULL, /* WINED3DSIH_POW */ shader_glsl_pow, /* WINED3DSIH_RCP */ shader_glsl_rcp, diff --git a/reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c b/reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c index 82a71dab3b9..64bb883d6c8 100644 --- a/reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c +++ b/reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c @@ -627,8 +627,7 @@ static void nvts_enable(IWineD3DDevice *iface, BOOL enable) { LEAVE_GL(); } -static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, - const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps) +static void nvrc_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps) { pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD | WINED3DTEXOPCAPS_ADDSIGNED | @@ -671,7 +670,7 @@ static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, WINED3DTEXOPCAPS_PREMODULATE */ #endif - pCaps->MaxTextureBlendStages = gl_info->limits.texture_stages; + pCaps->MaxTextureBlendStages = min(MAX_TEXTURES, gl_info->limits.general_combiners); pCaps->MaxSimultaneousTextures = gl_info->limits.textures; pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_TSSARGTEMP; diff --git a/reactos/dll/directx/wine/wined3d/query.c b/reactos/dll/directx/wine/wined3d/query.c index 1280a3b629d..3860e2c95b5 100644 --- a/reactos/dll/directx/wine/wined3d/query.c +++ b/reactos/dll/directx/wine/wined3d/query.c @@ -24,15 +24,164 @@ #include "config.h" #include "wined3d_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d); +#define GLINFO_LOCATION (*gl_info) + +static HRESULT wined3d_event_query_init(const struct wined3d_gl_info *gl_info, struct wined3d_event_query **query) +{ + struct wined3d_event_query *ret; + *query = NULL; + if (!gl_info->supported[ARB_SYNC] && !gl_info->supported[NV_FENCE] + && !gl_info->supported[APPLE_FENCE]) return E_NOTIMPL; + + ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret)); + if (!ret) + { + ERR("Failed to allocate a wined3d event query structure.\n"); + return E_OUTOFMEMORY; + } + ret->context = NULL; + *query = ret; + return WINED3D_OK; +} + +static void wined3d_event_query_destroy(struct wined3d_event_query *query) +{ + if (query->context) context_free_event_query(query); + HeapFree(GetProcessHeap(), 0, query); +} + +static enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) +{ + struct wined3d_context *context; + const struct wined3d_gl_info *gl_info; + enum wined3d_event_query_result ret; + BOOL fence_result; + + TRACE("(%p) : device %p\n", query, device); + + if (query->context == NULL) + { + TRACE("Query not started\n"); + return WINED3D_EVENT_QUERY_NOT_STARTED; + } + + if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) + { + WARN("Event query tested from wrong thread\n"); + return WINED3D_EVENT_QUERY_WRONG_THREAD; + } + + context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); + gl_info = context->gl_info; + + ENTER_GL(); + + if (gl_info->supported[ARB_SYNC]) + { + GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, 0)); + checkGLcall("glClientWaitSync"); + + switch (gl_ret) + { + case GL_ALREADY_SIGNALED: + case GL_CONDITION_SATISFIED: + ret = WINED3D_EVENT_QUERY_OK; + break; + + case GL_TIMEOUT_EXPIRED: + ret = WINED3D_EVENT_QUERY_WAITING; + break; + + case GL_WAIT_FAILED: + default: + ERR("glClientWaitSync returned %#x.\n", gl_ret); + ret = WINED3D_EVENT_QUERY_ERROR; + } + } + else if (gl_info->supported[APPLE_FENCE]) + { + fence_result = GL_EXTCALL(glTestFenceAPPLE(query->object.id)); + checkGLcall("glTestFenceAPPLE"); + if (fence_result) ret = WINED3D_EVENT_QUERY_OK; + else ret = WINED3D_EVENT_QUERY_WAITING; + } + else if (gl_info->supported[NV_FENCE]) + { + fence_result = GL_EXTCALL(glTestFenceNV(query->object.id)); + checkGLcall("glTestFenceNV"); + if (fence_result) ret = WINED3D_EVENT_QUERY_OK; + else ret = WINED3D_EVENT_QUERY_WAITING; + } + else + { + ERR("Event query created despite lack of GL support\n"); + ret = WINED3D_EVENT_QUERY_ERROR; + } + + LEAVE_GL(); + + context_release(context); + return ret; +} + +static void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) +{ + const struct wined3d_gl_info *gl_info; + struct wined3d_context *context; + + if (query->context) + { + if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) + { + context_free_event_query(query); + context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + context_alloc_event_query(context, query); + } + else + { + context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); + } + } + else + { + context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + context_alloc_event_query(context, query); + } + + gl_info = context->gl_info; + + ENTER_GL(); + + if (gl_info->supported[ARB_SYNC]) + { + if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync)); + checkGLcall("glDeleteSync"); + query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)); + checkGLcall("glFenceSync"); + } + else if (gl_info->supported[APPLE_FENCE]) + { + GL_EXTCALL(glSetFenceAPPLE(query->object.id)); + checkGLcall("glSetFenceAPPLE"); + } + else if (gl_info->supported[NV_FENCE]) + { + GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV)); + checkGLcall("glSetFenceNV"); + } + + LEAVE_GL(); + + context_release(context); +} + /* * Occlusion Queries: * http://www.gris.uni-tuebingen.de/~bartz/Publications/paper/hww98.pdf * http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt */ -WINE_DEFAULT_DEBUG_CHANNEL(d3d); -#define GLINFO_LOCATION This->device->adapter->gl_info - /* ******************************************* IWineD3DQuery IUnknown parts follow ******************************************* */ @@ -70,17 +219,16 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) { if (This->type == WINED3DQUERYTYPE_EVENT) { struct wined3d_event_query *query = This->extendedData; - - if (query->context) context_free_event_query(query); + if (query) wined3d_event_query_destroy(query); } else if (This->type == WINED3DQUERYTYPE_OCCLUSION) { struct wined3d_occlusion_query *query = This->extendedData; if (query->context) context_free_occlusion_query(query); + HeapFree(GetProcessHeap(), 0, This->extendedData); } - HeapFree(GetProcessHeap(), 0, This->extendedData); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -101,168 +249,6 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetParent(IWineD3DQuery *iface, IUnknown return WINED3D_OK; } -static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags){ - IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; - HRESULT res = S_OK; - - TRACE("(%p) : type %#x, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, This->type, pData, dwSize, dwGetDataFlags); - - switch (This->type){ - - case WINED3DQUERYTYPE_VCACHE: - { - - WINED3DDEVINFO_VCACHE *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VCACHE\n", This); - if(pData == NULL || dwSize == 0) break; - data->Pattern = WINEMAKEFOURCC('C','A','C','H'); - data->OptMethod = 0; /*0 get longest strips, 1 optimize vertex cache*/ - data->CacheSize = 0; /*cache size, only required if OptMethod == 1*/ - data->MagicNumber = 0; /*only required if OptMethod == 1 (used internally)*/ - - } - break; - case WINED3DQUERYTYPE_RESOURCEMANAGER: - { - WINED3DDEVINFO_RESOURCEMANAGER *data = pData; - int i; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_RESOURCEMANAGER\n", This); - if(pData == NULL || dwSize == 0) break; - for(i = 0; i < WINED3DRTYPECOUNT; i++){ - /*I'm setting the default values to 1 so as to reduce the risk of a div/0 in the caller*/ - /* isTextureResident could be used to get some of this information */ - data->stats[i].bThrashing = FALSE; - data->stats[i].ApproxBytesDownloaded = 1; - data->stats[i].NumEvicts = 1; - data->stats[i].NumVidCreates = 1; - data->stats[i].LastPri = 1; - data->stats[i].NumUsed = 1; - data->stats[i].NumUsedInVidMem = 1; - data->stats[i].WorkingSet = 1; - data->stats[i].WorkingSetBytes = 1; - data->stats[i].TotalManaged = 1; - data->stats[i].TotalBytes = 1; - } - - } - break; - case WINED3DQUERYTYPE_VERTEXSTATS: - { - WINED3DDEVINFO_VERTEXSTATS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VERTEXSTATS\n", This); - if(pData == NULL || dwSize == 0) break; - data->NumRenderedTriangles = 1; - data->NumExtraClippingTriangles = 1; - - } - break; - case WINED3DQUERYTYPE_TIMESTAMP: - { - UINT64* data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMP\n", This); - if(pData == NULL || dwSize == 0) break; - *data = 1; /*Don't know what this is supposed to be*/ - } - break; - case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: - { - BOOL* data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMPDISJOINT\n", This); - if(pData == NULL || dwSize == 0) break; - *data = FALSE; /*Don't know what this is supposed to be*/ - } - break; - case WINED3DQUERYTYPE_TIMESTAMPFREQ: - { - UINT64* data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMPFREQ\n", This); - if(pData == NULL || dwSize == 0) break; - *data = 1; /*Don't know what this is supposed to be*/ - } - break; - case WINED3DQUERYTYPE_PIPELINETIMINGS: - { - WINED3DDEVINFO_PIPELINETIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_PIPELINETIMINGS\n", This); - if(pData == NULL || dwSize == 0) break; - - data->VertexProcessingTimePercent = 1.0f; - data->PixelProcessingTimePercent = 1.0f; - data->OtherGPUProcessingTimePercent = 97.0f; - data->GPUIdleTimePercent = 1.0f; - } - break; - case WINED3DQUERYTYPE_INTERFACETIMINGS: - { - WINED3DDEVINFO_INTERFACETIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_INTERFACETIMINGS\n", This); - - if(pData == NULL || dwSize == 0) break; - data->WaitingForGPUToUseApplicationResourceTimePercent = 1.0f; - data->WaitingForGPUToAcceptMoreCommandsTimePercent = 1.0f; - data->WaitingForGPUToStayWithinLatencyTimePercent = 1.0f; - data->WaitingForGPUExclusiveResourceTimePercent = 1.0f; - data->WaitingForGPUOtherTimePercent = 96.0f; - } - - break; - case WINED3DQUERYTYPE_VERTEXTIMINGS: - { - WINED3DDEVINFO_STAGETIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VERTEXTIMINGS\n", This); - - if(pData == NULL || dwSize == 0) break; - data->MemoryProcessingPercent = 50.0f; - data->ComputationProcessingPercent = 50.0f; - - } - break; - case WINED3DQUERYTYPE_PIXELTIMINGS: - { - WINED3DDEVINFO_STAGETIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_PIXELTIMINGS\n", This); - - if(pData == NULL || dwSize == 0) break; - data->MemoryProcessingPercent = 50.0f; - data->ComputationProcessingPercent = 50.0f; - } - break; - case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: - { - WINED3DDEVINFO_BANDWIDTHTIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_BANDWIDTHTIMINGS\n", This); - - if(pData == NULL || dwSize == 0) break; - data->MaxBandwidthUtilized = 1.0f; - data->FrontEndUploadMemoryUtilizedPercent = 1.0f; - data->VertexRateUtilizedPercent = 1.0f; - data->TriangleSetupRateUtilizedPercent = 1.0f; - data->FillRateUtilizedPercent = 97.0f; - } - break; - case WINED3DQUERYTYPE_CACHEUTILIZATION: - { - WINED3DDEVINFO_CACHEUTILIZATION *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_CACHEUTILIZATION\n", This); - - if(pData == NULL || dwSize == 0) break; - data->TextureCacheHitRate = 1.0f; - data->PostTransformVertexCacheHitRate = 1.0f; - } - - - break; - default: - FIXME("(%p) Unhandled query type %d\n",This , This->type); - - }; - - /*dwGetDataFlags = 0 || D3DGETDATA_FLUSH - D3DGETDATA_FLUSH may return WINED3DERR_DEVICELOST if the device is lost - */ - return res; /* S_OK if the query data is available*/ -} - static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface; struct wined3d_occlusion_query *query = This->extendedData; @@ -341,108 +327,44 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface; struct wined3d_event_query *query = This->extendedData; - struct wined3d_context *context; BOOL *data = pData; + enum wined3d_event_query_result ret; TRACE("(%p) : type D3DQUERY_EVENT, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags); if (!pData || !dwSize) return S_OK; - - if (!query->context) + if (!query) { - TRACE("Query not started, returning TRUE.\n"); + WARN("(%p): Event query not supported by GL, reporting GPU idle\n", This); *data = TRUE; - return S_OK; } - if (query->context->tid != GetCurrentThreadId()) + ret = wined3d_event_query_test(query, This->device); + switch(ret) { - /* See comment in IWineD3DQuery::Issue, event query codeblock */ - FIXME("Wrong thread, reporting GPU idle.\n"); - *data = TRUE; + case WINED3D_EVENT_QUERY_OK: + case WINED3D_EVENT_QUERY_NOT_STARTED: + *data = TRUE; + break; - return S_OK; + case WINED3D_EVENT_QUERY_WAITING: + *data = FALSE; + break; + + case WINED3D_EVENT_QUERY_WRONG_THREAD: + FIXME("(%p) Wrong thread, reporting GPU idle.\n", This); + *data = TRUE; + break; + + case WINED3D_EVENT_QUERY_ERROR: + ERR("The GL event query failed, returning D3DERR_INVALIDCALL\n"); + return WINED3DERR_INVALIDCALL; } - context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); - - ENTER_GL(); - - if (context->gl_info->supported[APPLE_FENCE]) - { - *data = GL_EXTCALL(glTestFenceAPPLE(query->id)); - checkGLcall("glTestFenceAPPLE"); - } - else if (context->gl_info->supported[NV_FENCE]) - { - *data = GL_EXTCALL(glTestFenceNV(query->id)); - checkGLcall("glTestFenceNV"); - } - else - { - WARN("(%p): reporting GPU idle\n", This); - *data = TRUE; - } - - LEAVE_GL(); - - context_release(context); - return S_OK; } -static DWORD WINAPI IWineD3DQueryImpl_GetDataSize(IWineD3DQuery* iface){ - IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; - int dataSize = 0; - TRACE("(%p) : type %#x\n", This, This->type); - switch(This->type){ - case WINED3DQUERYTYPE_VCACHE: - dataSize = sizeof(WINED3DDEVINFO_VCACHE); - break; - case WINED3DQUERYTYPE_RESOURCEMANAGER: - dataSize = sizeof(WINED3DDEVINFO_RESOURCEMANAGER); - break; - case WINED3DQUERYTYPE_VERTEXSTATS: - dataSize = sizeof(WINED3DDEVINFO_VERTEXSTATS); - break; - case WINED3DQUERYTYPE_EVENT: - dataSize = sizeof(BOOL); - break; - case WINED3DQUERYTYPE_TIMESTAMP: - dataSize = sizeof(UINT64); - break; - case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: - dataSize = sizeof(BOOL); - break; - case WINED3DQUERYTYPE_TIMESTAMPFREQ: - dataSize = sizeof(UINT64); - break; - case WINED3DQUERYTYPE_PIPELINETIMINGS: - dataSize = sizeof(WINED3DDEVINFO_PIPELINETIMINGS); - break; - case WINED3DQUERYTYPE_INTERFACETIMINGS: - dataSize = sizeof(WINED3DDEVINFO_INTERFACETIMINGS); - break; - case WINED3DQUERYTYPE_VERTEXTIMINGS: - dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS); - break; - case WINED3DQUERYTYPE_PIXELTIMINGS: - dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS); - break; - case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: - dataSize = sizeof(WINED3DQUERYTYPE_BANDWIDTHTIMINGS); - break; - case WINED3DQUERYTYPE_CACHEUTILIZATION: - dataSize = sizeof(WINED3DDEVINFO_CACHEUTILIZATION); - break; - default: - FIXME("(%p) Unhandled query type %d\n",This , This->type); - dataSize = 0; - } - return dataSize; -} - static DWORD WINAPI IWineD3DEventQueryImpl_GetDataSize(IWineD3DQuery* iface){ TRACE("(%p) : type D3DQUERY_EVENT\n", iface); @@ -460,7 +382,6 @@ static WINED3DQUERYTYPE WINAPI IWineD3DQueryImpl_GetType(IWineD3DQuery* iface){ return This->type; } - static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; @@ -468,43 +389,11 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD if (dwIssueFlags & WINED3DISSUE_END) { struct wined3d_event_query *query = This->extendedData; - struct wined3d_context *context; - if (query->context) - { - if (query->context->tid != GetCurrentThreadId()) - { - context_free_event_query(query); - context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD); - context_alloc_event_query(context, query); - } - else - { - context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); - } - } - else - { - context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD); - context_alloc_event_query(context, query); - } + /* Faked event query support */ + if (!query) return WINED3D_OK; - ENTER_GL(); - - if (context->gl_info->supported[APPLE_FENCE]) - { - GL_EXTCALL(glSetFenceAPPLE(query->id)); - checkGLcall("glSetFenceAPPLE"); - } - else if (context->gl_info->supported[NV_FENCE]) - { - GL_EXTCALL(glSetFenceNV(query->id, GL_ALL_COMPLETED_NV)); - checkGLcall("glSetFenceNV"); - } - - LEAVE_GL(); - - context_release(context); + wined3d_event_query_issue(query, This->device); } else if(dwIssueFlags & WINED3DISSUE_BEGIN) { @@ -604,43 +493,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */ } -static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags){ - IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; - - TRACE("(%p) : dwIssueFlags %#x, type %#x\n", This, dwIssueFlags, This->type); - - /* The fixme is printed when the app asks for the resulting data */ - WARN("(%p) : Unhandled query type %#x\n", This, This->type); - - if(dwIssueFlags & WINED3DISSUE_BEGIN) { - This->state = QUERY_BUILDING; - } else { - This->state = QUERY_SIGNALLED; - } - - return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */ -} - - -/********************************************************** - * IWineD3DQuery VTbl follows - **********************************************************/ - -const IWineD3DQueryVtbl IWineD3DQuery_Vtbl = -{ - /*** IUnknown methods ***/ - IWineD3DQueryImpl_QueryInterface, - IWineD3DQueryImpl_AddRef, - IWineD3DQueryImpl_Release, - /*** IWineD3Dquery methods ***/ - IWineD3DQueryImpl_GetParent, - IWineD3DQueryImpl_GetData, - IWineD3DQueryImpl_GetDataSize, - IWineD3DQueryImpl_GetType, - IWineD3DQueryImpl_Issue -}; - -const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl = +static const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl = { /*** IUnknown methods ***/ IWineD3DQueryImpl_QueryInterface, @@ -654,7 +507,7 @@ const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl = IWineD3DEventQueryImpl_Issue }; -const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl = +static const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl = { /*** IUnknown methods ***/ IWineD3DQueryImpl_QueryInterface, @@ -667,3 +520,72 @@ const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl = IWineD3DQueryImpl_GetType, IWineD3DOcclusionQueryImpl_Issue }; + +HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, + WINED3DQUERYTYPE type, IUnknown *parent) +{ + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; + HRESULT hr; + + switch (type) + { + case WINED3DQUERYTYPE_OCCLUSION: + TRACE("Occlusion query.\n"); + if (!gl_info->supported[ARB_OCCLUSION_QUERY]) + { + WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY.\n"); + return WINED3DERR_NOTAVAILABLE; + } + query->lpVtbl = &IWineD3DOcclusionQuery_Vtbl; + query->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query)); + if (!query->extendedData) + { + ERR("Failed to allocate occlusion query extended data.\n"); + return E_OUTOFMEMORY; + } + ((struct wined3d_occlusion_query *)query->extendedData)->context = NULL; + break; + + case WINED3DQUERYTYPE_EVENT: + TRACE("Event query.\n"); + query->lpVtbl = &IWineD3DEventQuery_Vtbl; + hr = wined3d_event_query_init(gl_info, (struct wined3d_event_query **) &query->extendedData); + if (hr == E_NOTIMPL) + { + /* Half-Life 2 needs this query. It does not render the main + * menu correctly otherwise. Pretend to support it, faking + * this query does not do much harm except potentially + * lowering performance. */ + FIXME("Event query: Unimplemented, but pretending to be supported.\n"); + } + else if(FAILED(hr)) + { + return hr; + } + break; + + case WINED3DQUERYTYPE_VCACHE: + case WINED3DQUERYTYPE_RESOURCEMANAGER: + case WINED3DQUERYTYPE_VERTEXSTATS: + case WINED3DQUERYTYPE_TIMESTAMP: + case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: + case WINED3DQUERYTYPE_TIMESTAMPFREQ: + case WINED3DQUERYTYPE_PIPELINETIMINGS: + case WINED3DQUERYTYPE_INTERFACETIMINGS: + case WINED3DQUERYTYPE_VERTEXTIMINGS: + case WINED3DQUERYTYPE_PIXELTIMINGS: + case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: + case WINED3DQUERYTYPE_CACHEUTILIZATION: + default: + FIXME("Unhandled query type %#x.\n", type); + return WINED3DERR_NOTAVAILABLE; + } + + query->type = type; + query->state = QUERY_CREATED; + query->device = device; + query->parent = parent; + query->ref = 1; + + return WINED3D_OK; +} diff --git a/reactos/dll/directx/wine/wined3d/shader.c b/reactos/dll/directx/wine/wined3d/shader.c index 398ea641835..307cadf804c 100644 --- a/reactos/dll/directx/wine/wined3d/shader.c +++ b/reactos/dll/directx/wine/wined3d/shader.c @@ -26,10 +26,1433 @@ #include #include +#include #include "wined3d_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); +WINE_DECLARE_DEBUG_CHANNEL(d3d); + +static const char *shader_opcode_names[] = +{ + /* WINED3DSIH_ABS */ "abs", + /* WINED3DSIH_ADD */ "add", + /* WINED3DSIH_BEM */ "bem", + /* WINED3DSIH_BREAK */ "break", + /* WINED3DSIH_BREAKC */ "breakc", + /* WINED3DSIH_BREAKP */ "breakp", + /* WINED3DSIH_CALL */ "call", + /* WINED3DSIH_CALLNZ */ "callnz", + /* WINED3DSIH_CMP */ "cmp", + /* WINED3DSIH_CND */ "cnd", + /* WINED3DSIH_CRS */ "crs", + /* WINED3DSIH_CUT */ "cut", + /* WINED3DSIH_DCL */ "dcl", + /* WINED3DSIH_DEF */ "def", + /* WINED3DSIH_DEFB */ "defb", + /* WINED3DSIH_DEFI */ "defi", + /* WINED3DSIH_DP2ADD */ "dp2add", + /* WINED3DSIH_DP3 */ "dp3", + /* WINED3DSIH_DP4 */ "dp4", + /* WINED3DSIH_DST */ "dst", + /* WINED3DSIH_DSX */ "dsx", + /* WINED3DSIH_DSY */ "dsy", + /* WINED3DSIH_ELSE */ "else", + /* WINED3DSIH_EMIT */ "emit", + /* WINED3DSIH_ENDIF */ "endif", + /* WINED3DSIH_ENDLOOP */ "endloop", + /* WINED3DSIH_ENDREP */ "endrep", + /* WINED3DSIH_EXP */ "exp", + /* WINED3DSIH_EXPP */ "expp", + /* WINED3DSIH_FRC */ "frc", + /* WINED3DSIH_IADD */ "iadd", + /* WINED3DSIH_IF */ "if", + /* WINED3DSIH_IFC */ "ifc", + /* WINED3DSIH_IGE */ "ige", + /* WINED3DSIH_LABEL */ "label", + /* WINED3DSIH_LIT */ "lit", + /* WINED3DSIH_LOG */ "log", + /* WINED3DSIH_LOGP */ "logp", + /* WINED3DSIH_LOOP */ "loop", + /* WINED3DSIH_LRP */ "lrp", + /* WINED3DSIH_LT */ "lt", + /* WINED3DSIH_M3x2 */ "m3x2", + /* WINED3DSIH_M3x3 */ "m3x3", + /* WINED3DSIH_M3x4 */ "m3x4", + /* WINED3DSIH_M4x3 */ "m4x3", + /* WINED3DSIH_M4x4 */ "m4x4", + /* WINED3DSIH_MAD */ "mad", + /* WINED3DSIH_MAX */ "max", + /* WINED3DSIH_MIN */ "min", + /* WINED3DSIH_MOV */ "mov", + /* WINED3DSIH_MOVA */ "mova", + /* WINED3DSIH_MUL */ "mul", + /* WINED3DSIH_NOP */ "nop", + /* WINED3DSIH_NRM */ "nrm", + /* WINED3DSIH_PHASE */ "phase", + /* WINED3DSIH_POW */ "pow", + /* WINED3DSIH_RCP */ "rcp", + /* WINED3DSIH_REP */ "rep", + /* WINED3DSIH_RET */ "ret", + /* WINED3DSIH_RSQ */ "rsq", + /* WINED3DSIH_SETP */ "setp", + /* WINED3DSIH_SGE */ "sge", + /* WINED3DSIH_SGN */ "sgn", + /* WINED3DSIH_SINCOS */ "sincos", + /* WINED3DSIH_SLT */ "slt", + /* WINED3DSIH_SUB */ "sub", + /* WINED3DSIH_TEX */ "texld", + /* WINED3DSIH_TEXBEM */ "texbem", + /* WINED3DSIH_TEXBEML */ "texbeml", + /* WINED3DSIH_TEXCOORD */ "texcrd", + /* WINED3DSIH_TEXDEPTH */ "texdepth", + /* WINED3DSIH_TEXDP3 */ "texdp3", + /* WINED3DSIH_TEXDP3TEX */ "texdp3tex", + /* WINED3DSIH_TEXKILL */ "texkill", + /* WINED3DSIH_TEXLDD */ "texldd", + /* WINED3DSIH_TEXLDL */ "texldl", + /* WINED3DSIH_TEXM3x2DEPTH */ "texm3x2depth", + /* WINED3DSIH_TEXM3x2PAD */ "texm3x2pad", + /* WINED3DSIH_TEXM3x2TEX */ "texm3x2tex", + /* WINED3DSIH_TEXM3x3 */ "texm3x3", + /* WINED3DSIH_TEXM3x3DIFF */ "texm3x3diff", + /* WINED3DSIH_TEXM3x3PAD */ "texm3x3pad", + /* WINED3DSIH_TEXM3x3SPEC */ "texm3x3spec", + /* WINED3DSIH_TEXM3x3TEX */ "texm3x3tex", + /* WINED3DSIH_TEXM3x3VSPEC */ "texm3x3vspec", + /* WINED3DSIH_TEXREG2AR */ "texreg2ar", + /* WINED3DSIH_TEXREG2GB */ "texreg2gb", + /* WINED3DSIH_TEXREG2RGB */ "texreg2rgb", +}; + +static const char *semantic_names[] = +{ + /* WINED3DDECLUSAGE_POSITION */ "SV_POSITION", + /* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT", + /* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES", + /* WINED3DDECLUSAGE_NORMAL */ "NORMAL", + /* WINED3DDECLUSAGE_PSIZE */ "PSIZE", + /* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD", + /* WINED3DDECLUSAGE_TANGENT */ "TANGENT", + /* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL", + /* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR", + /* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT", + /* WINED3DDECLUSAGE_COLOR */ "COLOR", + /* WINED3DDECLUSAGE_FOG */ "FOG", + /* WINED3DDECLUSAGE_DEPTH */ "DEPTH", + /* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE", +}; + +static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage) +{ + if (usage >= sizeof(semantic_names) / sizeof(*semantic_names)) + { + FIXME("Unrecognized usage %#x.\n", usage); + return "UNRECOGNIZED"; + } + + return semantic_names[usage]; +} + +static WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *name) +{ + unsigned int i; + + for (i = 0; i < sizeof(semantic_names) / sizeof(*semantic_names); ++i) + { + if (!strcmp(name, semantic_names[i])) return i; + } + + return ~0U; +} + +BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) +{ + return !strcmp(semantic_name, shader_semantic_name_from_usage(usage)); +} + +static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e, + const struct wined3d_shader_semantic *s) +{ + e->semantic_name = shader_semantic_name_from_usage(s->usage); + e->semantic_idx = s->usage_idx; + e->sysval_semantic = 0; + e->component_type = 0; + e->register_idx = s->reg.reg.idx; + e->mask = s->reg.write_mask; +} + +static const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) +{ + switch (version_token >> 16) + { + case WINED3D_SM1_VS: + case WINED3D_SM1_PS: + return &sm1_shader_frontend; + + case WINED3D_SM4_PS: + case WINED3D_SM4_VS: + case WINED3D_SM4_GS: + return &sm4_shader_frontend; + + default: + FIXME("Unrecognised version token %#x\n", version_token); + return NULL; + } +} + +void shader_buffer_clear(struct wined3d_shader_buffer *buffer) +{ + buffer->buffer[0] = '\0'; + buffer->bsize = 0; + buffer->lineNo = 0; + buffer->newline = TRUE; +} + +BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) +{ + buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE); + if (!buffer->buffer) + { + ERR("Failed to allocate shader buffer memory.\n"); + return FALSE; + } + + shader_buffer_clear(buffer); + return TRUE; +} + +void shader_buffer_free(struct wined3d_shader_buffer *buffer) +{ + HeapFree(GetProcessHeap(), 0, buffer->buffer); +} + +int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *format, va_list args) +{ + char *base = buffer->buffer + buffer->bsize; + int rc; + + rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args); + + if (rc < 0 /* C89 */ || (unsigned int)rc > SHADER_PGMSIZE - 1 - buffer->bsize /* C99 */) + { + ERR("The buffer allocated for the shader program string " + "is too small at %d bytes.\n", SHADER_PGMSIZE); + buffer->bsize = SHADER_PGMSIZE - 1; + return -1; + } + + if (buffer->newline) + { + TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base); + buffer->newline = FALSE; + } + else + { + TRACE("%s", base); + } + + buffer->bsize += rc; + if (buffer->buffer[buffer->bsize-1] == '\n') + { + ++buffer->lineNo; + buffer->newline = TRUE; + } + + return 0; +} + +int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...) +{ + va_list args; + int ret; + + va_start(args, format); + ret = shader_vaddline(buffer, format, args); + va_end(args); + + return ret; +} + +static void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device, + IUnknown *parent, const struct wined3d_parent_ops *parent_ops) +{ + shader->ref = 1; + shader->device = (IWineD3DDevice *)device; + shader->parent = parent; + shader->parent_ops = parent_ops; + list_init(&shader->linked_programs); + list_add_head(&device->shaders, &shader->shader_list_entry); +} + +/* Convert floating point offset relative to a register file to an absolute + * offset for float constants. */ +static unsigned int shader_get_float_offset(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx) +{ + switch (register_type) + { + case WINED3DSPR_CONST: return register_idx; + case WINED3DSPR_CONST2: return 2048 + register_idx; + case WINED3DSPR_CONST3: return 4096 + register_idx; + case WINED3DSPR_CONST4: return 6144 + register_idx; + default: + FIXME("Unsupported register type: %u.\n", register_type); + return register_idx; + } +} + +static void shader_delete_constant_list(struct list *clist) +{ + struct local_constant *constant; + struct list *ptr; + + ptr = list_head(clist); + while (ptr) + { + constant = LIST_ENTRY(ptr, struct local_constant, entry); + ptr = list_next(clist, ptr); + HeapFree(GetProcessHeap(), 0, constant); + } + list_init(clist); +} + +static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit) +{ + DWORD idx, shift; + idx = bit >> 5; + shift = bit & 0x1f; + bitmap[idx] |= (1 << shift); +} + +static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct shader_reg_maps *reg_maps, + const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type) +{ + switch (reg->type) + { + case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */ + if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx; + else reg_maps->address |= 1 << reg->idx; + break; + + case WINED3DSPR_TEMP: + reg_maps->temporary |= 1 << reg->idx; + break; + + case WINED3DSPR_INPUT: + if (shader_type == WINED3D_SHADER_TYPE_PIXEL) + { + if (reg->rel_addr) + { + /* If relative addressing is used, we must assume that all registers + * are used. Even if it is a construct like v3[aL], we can't assume + * that v0, v1 and v2 aren't read because aL can be negative */ + unsigned int i; + for (i = 0; i < MAX_REG_INPUT; ++i) + { + ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[i] = TRUE; + } + } + else + { + ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[reg->idx] = TRUE; + } + } + else reg_maps->input_registers |= 1 << reg->idx; + break; + + case WINED3DSPR_RASTOUT: + if (reg->idx == 1) reg_maps->fog = 1; + break; + + case WINED3DSPR_MISCTYPE: + if (shader_type == WINED3D_SHADER_TYPE_PIXEL) + { + if (reg->idx == 0) reg_maps->vpos = 1; + else if (reg->idx == 1) reg_maps->usesfacing = 1; + } + break; + + case WINED3DSPR_CONST: + if (reg->rel_addr) + { + if (shader_type != WINED3D_SHADER_TYPE_PIXEL) + { + if (reg->idx < ((IWineD3DVertexShaderImpl *)shader)->min_rel_offset) + { + ((IWineD3DVertexShaderImpl *)shader)->min_rel_offset = reg->idx; + } + if (reg->idx > ((IWineD3DVertexShaderImpl *)shader)->max_rel_offset) + { + ((IWineD3DVertexShaderImpl *)shader)->max_rel_offset = reg->idx; + } + } + reg_maps->usesrelconstF = TRUE; + } + else + { + set_bitmap_bit(reg_maps->constf, reg->idx); + } + break; + + case WINED3DSPR_CONSTINT: + reg_maps->integer_constants |= (1 << reg->idx); + break; + + case WINED3DSPR_CONSTBOOL: + reg_maps->boolean_constants |= (1 << reg->idx); + break; + + case WINED3DSPR_COLOROUT: + reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx); + break; + + default: + TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx); + break; + } +} + +static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param) +{ + switch (instr) + { + case WINED3DSIH_M4x4: + case WINED3DSIH_M3x4: + return param == 1 ? 3 : 0; + + case WINED3DSIH_M4x3: + case WINED3DSIH_M3x3: + return param == 1 ? 2 : 0; + + case WINED3DSIH_M3x2: + return param == 1 ? 1 : 0; + + default: + return 0; + } +} + +/* Note that this does not count the loop register as an address register. */ +static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, + struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature, + struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size) +{ + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface; + unsigned int cur_loop_depth = 0, max_loop_depth = 0; + void *fe_data = shader->baseShader.frontend_data; + struct wined3d_shader_version shader_version; + const DWORD *ptr = byte_code; + + memset(reg_maps, 0, sizeof(*reg_maps)); + + /* get_registers_used() is called on every compile on some 1.x shaders, + * which can result in stacking up a collection of local constants. + * Delete the old constants if existing. */ + shader_delete_constant_list(&shader->baseShader.constantsF); + shader_delete_constant_list(&shader->baseShader.constantsB); + shader_delete_constant_list(&shader->baseShader.constantsI); + + fe->shader_read_header(fe_data, &ptr, &shader_version); + reg_maps->shader_version = shader_version; + + reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(*reg_maps->constf) * ((constf_size + 31) / 32)); + if (!reg_maps->constf) + { + ERR("Failed to allocate constant map memory.\n"); + return E_OUTOFMEMORY; + } + + while (!fe->shader_is_end(fe_data, &ptr)) + { + struct wined3d_shader_instruction ins; + const char *comment; + UINT comment_size; + UINT param_size; + + /* Skip comments. */ + fe->shader_read_comment(&ptr, &comment, &comment_size); + if (comment) continue; + + /* Fetch opcode. */ + fe->shader_read_opcode(fe_data, &ptr, &ins, ¶m_size); + + /* Unhandled opcode, and its parameters. */ + if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) + { + TRACE("Skipping unrecognized instruction.\n"); + ptr += param_size; + continue; + } + + /* Handle declarations. */ + if (ins.handler_idx == WINED3DSIH_DCL) + { + struct wined3d_shader_semantic semantic; + + fe->shader_read_semantic(&ptr, &semantic); + + switch (semantic.reg.reg.type) + { + /* Mark input registers used. */ + case WINED3DSPR_INPUT: + reg_maps->input_registers |= 1 << semantic.reg.reg.idx; + shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic); + break; + + /* Vertex shader: mark 3.0 output registers used, save token. */ + case WINED3DSPR_OUTPUT: + reg_maps->output_registers |= 1 << semantic.reg.reg.idx; + shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic); + if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1; + break; + + /* Save sampler usage token. */ + case WINED3DSPR_SAMPLER: + reg_maps->sampler_type[semantic.reg.reg.idx] = semantic.sampler_type; + break; + + default: + TRACE("Not recording DCL register type %#x.\n", semantic.reg.reg.type); + break; + } + } + else if (ins.handler_idx == WINED3DSIH_DEF) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); + if (!lconst) return E_OUTOFMEMORY; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + lconst->idx = dst.reg.idx; + + memcpy(lconst->value, ptr, 4 * sizeof(DWORD)); + ptr += 4; + + /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */ + if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL) + { + float *value = (float *)lconst->value; + if (value[0] < -1.0f) value[0] = -1.0f; + else if (value[0] > 1.0f) value[0] = 1.0f; + if (value[1] < -1.0f) value[1] = -1.0f; + else if (value[1] > 1.0f) value[1] = 1.0f; + if (value[2] < -1.0f) value[2] = -1.0f; + else if (value[2] > 1.0f) value[2] = 1.0f; + if (value[3] < -1.0f) value[3] = -1.0f; + else if (value[3] > 1.0f) value[3] = 1.0f; + } + + list_add_head(&shader->baseShader.constantsF, &lconst->entry); + } + else if (ins.handler_idx == WINED3DSIH_DEFI) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); + if (!lconst) return E_OUTOFMEMORY; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + lconst->idx = dst.reg.idx; + + memcpy(lconst->value, ptr, 4 * sizeof(DWORD)); + ptr += 4; + + list_add_head(&shader->baseShader.constantsI, &lconst->entry); + reg_maps->local_int_consts |= (1 << dst.reg.idx); + } + else if (ins.handler_idx == WINED3DSIH_DEFB) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); + if (!lconst) return E_OUTOFMEMORY; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + lconst->idx = dst.reg.idx; + + memcpy(lconst->value, ptr, sizeof(DWORD)); + ++ptr; + + list_add_head(&shader->baseShader.constantsB, &lconst->entry); + reg_maps->local_bool_consts |= (1 << dst.reg.idx); + } + /* If there's a loop in the shader. */ + else if (ins.handler_idx == WINED3DSIH_LOOP + || ins.handler_idx == WINED3DSIH_REP) + { + struct wined3d_shader_src_param src, rel_addr; + + fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr); + + /* Rep and Loop always use an integer constant for the control parameters. */ + if (ins.handler_idx == WINED3DSIH_REP) + { + reg_maps->integer_constants |= 1 << src.reg.idx; + } + else + { + fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr); + reg_maps->integer_constants |= 1 << src.reg.idx; + } + + cur_loop_depth++; + if (cur_loop_depth > max_loop_depth) max_loop_depth = cur_loop_depth; + } + else if (ins.handler_idx == WINED3DSIH_ENDLOOP + || ins.handler_idx == WINED3DSIH_ENDREP) + { + cur_loop_depth--; + } + /* For subroutine prototypes. */ + else if (ins.handler_idx == WINED3DSIH_LABEL) + { + struct wined3d_shader_src_param src, rel_addr; + + fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr); + reg_maps->labels |= 1 << src.reg.idx; + } + /* Set texture, address, temporary registers. */ + else + { + BOOL color0_mov = FALSE; + int i, limit; + + /* This will loop over all the registers and try to + * make a bitmask of the ones we're interested in. + * + * Relative addressing tokens are ignored, but that's + * okay, since we'll catch any address registers when + * they are initialized (required by spec). */ + if (ins.dst_count) + { + struct wined3d_shader_src_param dst_rel_addr; + struct wined3d_shader_dst_param dst_param; + + fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr); + + shader_record_register_usage(shader, reg_maps, &dst_param.reg, shader_version.type); + + /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and + * is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel + * shaders because TECRDOUT isn't used in them, but future register types might cause issues */ + if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX && shader_version.major < 3 + && dst_param.reg.type == WINED3DSPR_TEXCRDOUT) + { + reg_maps->texcoord_mask[dst_param.reg.idx] |= dst_param.write_mask; + } + + if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL) + { + IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader; + + if (dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0) + { + /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to + * COLOROUT 0. If we know this in advance, the ARB shader backend can skip + * the mov and perform the sRGB write correction from the source register. + * + * However, if the mov is only partial, we can't do this, and if the write + * comes from an instruction other than MOV it is hard to do as well. If + * COLOROUT 0 is overwritten partially later, the marker is dropped again. */ + + ps->color0_mov = FALSE; + if (ins.handler_idx == WINED3DSIH_MOV) + { + /* Used later when the source register is read. */ + color0_mov = TRUE; + } + } + /* Also drop the MOV marker if the source register is overwritten prior to the shader + * end + */ + else if (dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg) + { + ps->color0_mov = FALSE; + } + } + + /* Declare 1.x samplers implicitly, based on the destination reg. number. */ + if (shader_version.major == 1 + && (ins.handler_idx == WINED3DSIH_TEX + || ins.handler_idx == WINED3DSIH_TEXBEM + || ins.handler_idx == WINED3DSIH_TEXBEML + || ins.handler_idx == WINED3DSIH_TEXDP3TEX + || ins.handler_idx == WINED3DSIH_TEXM3x2TEX + || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC + || ins.handler_idx == WINED3DSIH_TEXM3x3TEX + || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC + || ins.handler_idx == WINED3DSIH_TEXREG2AR + || ins.handler_idx == WINED3DSIH_TEXREG2GB + || ins.handler_idx == WINED3DSIH_TEXREG2RGB)) + { + /* Fake sampler usage, only set reserved bit and type. */ + DWORD sampler_code = dst_param.reg.idx; + + TRACE("Setting fake 2D sampler for 1.x pixelshader.\n"); + reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D; + + /* texbem is only valid with < 1.4 pixel shaders */ + if (ins.handler_idx == WINED3DSIH_TEXBEM + || ins.handler_idx == WINED3DSIH_TEXBEML) + { + reg_maps->bumpmat |= 1 << dst_param.reg.idx; + if (ins.handler_idx == WINED3DSIH_TEXBEML) + { + reg_maps->luminanceparams |= 1 << dst_param.reg.idx; + } + } + } + else if (ins.handler_idx == WINED3DSIH_BEM) + { + reg_maps->bumpmat |= 1 << dst_param.reg.idx; + } + } + + if (ins.handler_idx == WINED3DSIH_NRM) reg_maps->usesnrm = 1; + else if (ins.handler_idx == WINED3DSIH_DSY) reg_maps->usesdsy = 1; + else if (ins.handler_idx == WINED3DSIH_DSX) reg_maps->usesdsx = 1; + else if (ins.handler_idx == WINED3DSIH_TEXLDD) reg_maps->usestexldd = 1; + else if (ins.handler_idx == WINED3DSIH_TEXLDL) reg_maps->usestexldl = 1; + else if (ins.handler_idx == WINED3DSIH_MOVA) reg_maps->usesmova = 1; + else if (ins.handler_idx == WINED3DSIH_IFC) reg_maps->usesifc = 1; + else if (ins.handler_idx == WINED3DSIH_CALL) reg_maps->usescall = 1; + + limit = ins.src_count + (ins.predicate ? 1 : 0); + for (i = 0; i < limit; ++i) + { + struct wined3d_shader_src_param src_param, src_rel_addr; + unsigned int count; + + fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr); + count = get_instr_extra_regcount(ins.handler_idx, i); + + shader_record_register_usage(shader, reg_maps, &src_param.reg, shader_version.type); + while (count) + { + ++src_param.reg.idx; + shader_record_register_usage(shader, reg_maps, &src_param.reg, shader_version.type); + --count; + } + + if (color0_mov) + { + IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader; + if (src_param.reg.type == WINED3DSPR_TEMP + && src_param.swizzle == WINED3DSP_NOSWIZZLE) + { + ps->color0_mov = TRUE; + ps->color0_reg = src_param.reg.idx; + } + } + } + } + } + reg_maps->loop_depth = max_loop_depth; + + shader->baseShader.functionLength = ((const char *)ptr - (const char *)byte_code); + + return WINED3D_OK; +} + +unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) +{ + DWORD map = 1 << max; + map |= map - 1; + map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers; + + return wined3d_log2i(map); +} + +static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic, + const struct wined3d_shader_version *shader_version) +{ + TRACE("dcl"); + + if (semantic->reg.reg.type == WINED3DSPR_SAMPLER) + { + switch (semantic->sampler_type) + { + case WINED3DSTT_2D: TRACE("_2d"); break; + case WINED3DSTT_CUBE: TRACE("_cube"); break; + case WINED3DSTT_VOLUME: TRACE("_volume"); break; + default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type); + } + } + else + { + /* Pixel shaders 3.0 don't have usage semantics. */ + if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL) return; + else TRACE("_"); + + switch (semantic->usage) + { + case WINED3DDECLUSAGE_POSITION: + TRACE("position%u", semantic->usage_idx); + break; + + case WINED3DDECLUSAGE_BLENDINDICES: + TRACE("blend"); + break; + + case WINED3DDECLUSAGE_BLENDWEIGHT: + TRACE("weight"); + break; + + case WINED3DDECLUSAGE_NORMAL: + TRACE("normal%u", semantic->usage_idx); + break; + + case WINED3DDECLUSAGE_PSIZE: + TRACE("psize"); + break; + + case WINED3DDECLUSAGE_COLOR: + if (semantic->usage_idx == 0) TRACE("color"); + else TRACE("specular%u", (semantic->usage_idx - 1)); + break; + + case WINED3DDECLUSAGE_TEXCOORD: + TRACE("texture%u", semantic->usage_idx); + break; + + case WINED3DDECLUSAGE_TANGENT: + TRACE("tangent"); + break; + + case WINED3DDECLUSAGE_BINORMAL: + TRACE("binormal"); + break; + + case WINED3DDECLUSAGE_TESSFACTOR: + TRACE("tessfactor"); + break; + + case WINED3DDECLUSAGE_POSITIONT: + TRACE("positionT%u", semantic->usage_idx); + break; + + case WINED3DDECLUSAGE_FOG: + TRACE("fog"); + break; + + case WINED3DDECLUSAGE_DEPTH: + TRACE("depth"); + break; + + case WINED3DDECLUSAGE_SAMPLE: + TRACE("sample"); + break; + + default: + FIXME("unknown_semantics(0x%08x)", semantic->usage); + } + } +} + +static void shader_dump_register(const struct wined3d_shader_register *reg, + const struct wined3d_shader_version *shader_version) +{ + static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"}; + static const char * const misctype_reg_names[] = {"vPos", "vFace"}; + UINT offset = reg->idx; + + switch (reg->type) + { + case WINED3DSPR_TEMP: + TRACE("r"); + break; + + case WINED3DSPR_INPUT: + TRACE("v"); + break; + + case WINED3DSPR_CONST: + case WINED3DSPR_CONST2: + case WINED3DSPR_CONST3: + case WINED3DSPR_CONST4: + TRACE("c"); + offset = shader_get_float_offset(reg->type, reg->idx); + break; + + case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */ + TRACE("%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a'); + break; + + case WINED3DSPR_RASTOUT: + TRACE("%s", rastout_reg_names[reg->idx]); + break; + + case WINED3DSPR_COLOROUT: + TRACE("oC"); + break; + + case WINED3DSPR_DEPTHOUT: + TRACE("oDepth"); + break; + + case WINED3DSPR_ATTROUT: + TRACE("oD"); + break; + + case WINED3DSPR_TEXCRDOUT: + /* Vertex shaders >= 3.0 use general purpose output registers + * (WINED3DSPR_OUTPUT), which can include an address token. */ + if (shader_version->major >= 3) TRACE("o"); + else TRACE("oT"); + break; + + case WINED3DSPR_CONSTINT: + TRACE("i"); + break; + + case WINED3DSPR_CONSTBOOL: + TRACE("b"); + break; + + case WINED3DSPR_LABEL: + TRACE("l"); + break; + + case WINED3DSPR_LOOP: + TRACE("aL"); + break; + + case WINED3DSPR_SAMPLER: + TRACE("s"); + break; + + case WINED3DSPR_MISCTYPE: + if (reg->idx > 1) FIXME("Unhandled misctype register %u.\n", reg->idx); + else TRACE("%s", misctype_reg_names[reg->idx]); + break; + + case WINED3DSPR_PREDICATE: + TRACE("p"); + break; + + case WINED3DSPR_IMMCONST: + TRACE("l"); + break; + + case WINED3DSPR_CONSTBUFFER: + TRACE("cb"); + break; + + default: + TRACE("unhandled_rtype(%#x)", reg->type); + break; + } + + if (reg->type == WINED3DSPR_IMMCONST) + { + TRACE("("); + switch (reg->immconst_type) + { + case WINED3D_IMMCONST_FLOAT: + TRACE("%.8e", *(const float *)reg->immconst_data); + break; + + case WINED3D_IMMCONST_FLOAT4: + TRACE("%.8e, %.8e, %.8e, %.8e", + *(const float *)®->immconst_data[0], *(const float *)®->immconst_data[1], + *(const float *)®->immconst_data[2], *(const float *)®->immconst_data[3]); + break; + + default: + TRACE("", reg->immconst_type); + break; + } + TRACE(")"); + } + else if (reg->type != WINED3DSPR_RASTOUT && reg->type != WINED3DSPR_MISCTYPE) + { + if (reg->array_idx != ~0U) + { + TRACE("%u[%u", offset, reg->array_idx); + if (reg->rel_addr) + { + TRACE(" + "); + shader_dump_src_param(reg->rel_addr, shader_version); + } + TRACE("]"); + } + else + { + if (reg->rel_addr) + { + TRACE("["); + shader_dump_src_param(reg->rel_addr, shader_version); + TRACE(" + "); + } + TRACE("%u", offset); + if (reg->rel_addr) TRACE("]"); + } + } +} + +void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, + const struct wined3d_shader_version *shader_version) +{ + DWORD write_mask = param->write_mask; + + shader_dump_register(¶m->reg, shader_version); + + if (write_mask != WINED3DSP_WRITEMASK_ALL) + { + static const char *write_mask_chars = "xyzw"; + + TRACE("."); + if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]); + if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]); + if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]); + if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]); + } +} + +void shader_dump_src_param(const struct wined3d_shader_src_param *param, + const struct wined3d_shader_version *shader_version) +{ + DWORD src_modifier = param->modifiers; + DWORD swizzle = param->swizzle; + + if (src_modifier == WINED3DSPSM_NEG + || src_modifier == WINED3DSPSM_BIASNEG + || src_modifier == WINED3DSPSM_SIGNNEG + || src_modifier == WINED3DSPSM_X2NEG + || src_modifier == WINED3DSPSM_ABSNEG) + TRACE("-"); + else if (src_modifier == WINED3DSPSM_COMP) + TRACE("1-"); + else if (src_modifier == WINED3DSPSM_NOT) + TRACE("!"); + + if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG) + TRACE("abs("); + + shader_dump_register(¶m->reg, shader_version); + + if (src_modifier) + { + switch (src_modifier) + { + case WINED3DSPSM_NONE: break; + case WINED3DSPSM_NEG: break; + case WINED3DSPSM_NOT: break; + case WINED3DSPSM_BIAS: TRACE("_bias"); break; + case WINED3DSPSM_BIASNEG: TRACE("_bias"); break; + case WINED3DSPSM_SIGN: TRACE("_bx2"); break; + case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break; + case WINED3DSPSM_COMP: break; + case WINED3DSPSM_X2: TRACE("_x2"); break; + case WINED3DSPSM_X2NEG: TRACE("_x2"); break; + case WINED3DSPSM_DZ: TRACE("_dz"); break; + case WINED3DSPSM_DW: TRACE("_dw"); break; + case WINED3DSPSM_ABSNEG: TRACE(")"); break; + case WINED3DSPSM_ABS: TRACE(")"); break; + default: TRACE("_unknown_modifier(%#x)", src_modifier); + } + } + + if (swizzle != WINED3DSP_NOSWIZZLE) + { + static const char *swizzle_chars = "xyzw"; + DWORD swizzle_x = swizzle & 0x03; + DWORD swizzle_y = (swizzle >> 2) & 0x03; + DWORD swizzle_z = (swizzle >> 4) & 0x03; + DWORD swizzle_w = (swizzle >> 6) & 0x03; + + if (swizzle_x == swizzle_y + && swizzle_x == swizzle_z + && swizzle_x == swizzle_w) + { + TRACE(".%c", swizzle_chars[swizzle_x]); + } + else + { + TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y], + swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]); + } + } +} + +/* Shared code in order to generate the bulk of the shader string. + * NOTE: A description of how to parse tokens can be found on MSDN. */ +void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer, + const shader_reg_maps *reg_maps, const DWORD *byte_code, void *backend_ctx) +{ + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface; + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device; + const struct wined3d_shader_frontend *fe = shader->baseShader.frontend; + void *fe_data = shader->baseShader.frontend_data; + struct wined3d_shader_src_param src_rel_addr[4]; + struct wined3d_shader_src_param src_param[4]; + struct wined3d_shader_version shader_version; + struct wined3d_shader_src_param dst_rel_addr; + struct wined3d_shader_dst_param dst_param; + struct wined3d_shader_instruction ins; + struct wined3d_shader_context ctx; + const DWORD *ptr = byte_code; + DWORD i; + + /* Initialize current parsing state. */ + ctx.shader = iface; + ctx.gl_info = &device->adapter->gl_info; + ctx.reg_maps = reg_maps; + ctx.buffer = buffer; + ctx.backend_data = backend_ctx; + + ins.ctx = &ctx; + ins.dst = &dst_param; + ins.src = src_param; + shader->baseShader.parse_state.current_row = 0; + + fe->shader_read_header(fe_data, &ptr, &shader_version); + + while (!fe->shader_is_end(fe_data, &ptr)) + { + const char *comment; + UINT comment_size; + UINT param_size; + + /* Skip comment tokens. */ + fe->shader_read_comment(&ptr, &comment, &comment_size); + if (comment) continue; + + /* Read opcode. */ + fe->shader_read_opcode(fe_data, &ptr, &ins, ¶m_size); + + /* Unknown opcode and its parameters. */ + if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) + { + TRACE("Skipping unrecognized instruction.\n"); + ptr += param_size; + continue; + } + + /* Nothing to do. */ + if (ins.handler_idx == WINED3DSIH_DCL + || ins.handler_idx == WINED3DSIH_NOP + || ins.handler_idx == WINED3DSIH_DEF + || ins.handler_idx == WINED3DSIH_DEFI + || ins.handler_idx == WINED3DSIH_DEFB + || ins.handler_idx == WINED3DSIH_PHASE) + { + ptr += param_size; + continue; + } + + /* Destination token */ + if (ins.dst_count) fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr); + + /* Predication token */ + if (ins.predicate) ins.predicate = *ptr++; + + /* Other source tokens */ + for (i = 0; i < ins.src_count; ++i) + { + fe->shader_read_src_param(fe_data, &ptr, &src_param[i], &src_rel_addr[i]); + } + + /* Call appropriate function for output target */ + device->shader_backend->shader_handle_instruction(&ins); + } +} + +static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst) +{ + DWORD mmask = dst->modifiers; + + switch (dst->shift) + { + case 0: break; + case 13: TRACE("_d8"); break; + case 14: TRACE("_d4"); break; + case 15: TRACE("_d2"); break; + case 1: TRACE("_x2"); break; + case 2: TRACE("_x4"); break; + case 3: TRACE("_x8"); break; + default: TRACE("_unhandled_shift(%d)", dst->shift); break; + } + + if (mmask & WINED3DSPDM_SATURATE) TRACE("_sat"); + if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp"); + if (mmask & WINED3DSPDM_MSAMPCENTROID) TRACE("_centroid"); + + mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID); + if (mmask) FIXME("_unrecognized_modifier(%#x)", mmask); +} + +static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *byte_code) +{ + struct wined3d_shader_version shader_version; + const DWORD *ptr = byte_code; + const char *type_prefix; + DWORD i; + + TRACE("Parsing %p.\n", byte_code); + + fe->shader_read_header(fe_data, &ptr, &shader_version); + + switch (shader_version.type) + { + case WINED3D_SHADER_TYPE_VERTEX: + type_prefix = "vs"; + break; + + case WINED3D_SHADER_TYPE_GEOMETRY: + type_prefix = "gs"; + break; + + case WINED3D_SHADER_TYPE_PIXEL: + type_prefix = "ps"; + break; + + default: + FIXME("Unhandled shader type %#x.\n", shader_version.type); + type_prefix = "unknown"; + break; + } + + TRACE("%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor); + + while (!fe->shader_is_end(fe_data, &ptr)) + { + struct wined3d_shader_instruction ins; + const char *comment; + UINT comment_size; + UINT param_size; + + /* comment */ + fe->shader_read_comment(&ptr, &comment, &comment_size); + if (comment) + { + if (comment_size > 4 && *(const DWORD *)comment == WINEMAKEFOURCC('T', 'E', 'X', 'T')) + { + const char *end = comment + comment_size; + const char *ptr = comment + 4; + const char *line = ptr; + + TRACE("// TEXT\n"); + while (ptr != end) + { + if (*ptr == '\n') + { + UINT len = ptr - line; + if (len && *(ptr - 1) == '\r') --len; + TRACE("// %s\n", debugstr_an(line, len)); + line = ++ptr; + } + else ++ptr; + } + if (line != ptr) TRACE("// %s\n", debugstr_an(line, ptr - line)); + } + else TRACE("// %s\n", debugstr_an(comment, comment_size)); + continue; + } + + fe->shader_read_opcode(fe_data, &ptr, &ins, ¶m_size); + if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) + { + TRACE("Skipping unrecognized instruction.\n"); + ptr += param_size; + continue; + } + + if (ins.handler_idx == WINED3DSIH_DCL) + { + struct wined3d_shader_semantic semantic; + + fe->shader_read_semantic(&ptr, &semantic); + + shader_dump_decl_usage(&semantic, &shader_version); + shader_dump_ins_modifiers(&semantic.reg); + TRACE(" "); + shader_dump_dst_param(&semantic.reg, &shader_version); + } + else if (ins.handler_idx == WINED3DSIH_DEF) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + + TRACE("def c%u = %f, %f, %f, %f", shader_get_float_offset(dst.reg.type, dst.reg.idx), + *(const float *)(ptr), + *(const float *)(ptr + 1), + *(const float *)(ptr + 2), + *(const float *)(ptr + 3)); + ptr += 4; + } + else if (ins.handler_idx == WINED3DSIH_DEFI) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + + TRACE("defi i%u = %d, %d, %d, %d", dst.reg.idx, + *(ptr), + *(ptr + 1), + *(ptr + 2), + *(ptr + 3)); + ptr += 4; + } + else if (ins.handler_idx == WINED3DSIH_DEFB) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + + TRACE("defb b%u = %s", dst.reg.idx, *ptr ? "true" : "false"); + ++ptr; + } + else + { + struct wined3d_shader_src_param dst_rel_addr, src_rel_addr; + struct wined3d_shader_dst_param dst_param; + struct wined3d_shader_src_param src_param; + + if (ins.dst_count) + { + fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr); + } + + /* Print out predication source token first - it follows + * the destination token. */ + if (ins.predicate) + { + fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr); + TRACE("("); + shader_dump_src_param(&src_param, &shader_version); + TRACE(") "); + } + + /* PixWin marks instructions with the coissue flag with a '+' */ + if (ins.coissue) TRACE("+"); + + TRACE("%s", shader_opcode_names[ins.handler_idx]); + + if (ins.handler_idx == WINED3DSIH_IFC + || ins.handler_idx == WINED3DSIH_BREAKC) + { + switch (ins.flags) + { + case COMPARISON_GT: TRACE("_gt"); break; + case COMPARISON_EQ: TRACE("_eq"); break; + case COMPARISON_GE: TRACE("_ge"); break; + case COMPARISON_LT: TRACE("_lt"); break; + case COMPARISON_NE: TRACE("_ne"); break; + case COMPARISON_LE: TRACE("_le"); break; + default: TRACE("_(%u)", ins.flags); + } + } + else if (ins.handler_idx == WINED3DSIH_TEX + && shader_version.major >= 2 + && (ins.flags & WINED3DSI_TEXLD_PROJECT)) + { + TRACE("p"); + } + + /* We already read the destination token, print it. */ + if (ins.dst_count) + { + shader_dump_ins_modifiers(&dst_param); + TRACE(" "); + shader_dump_dst_param(&dst_param, &shader_version); + } + + /* Other source tokens */ + for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i) + { + fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr); + TRACE(!i ? " " : ", "); + shader_dump_src_param(&src_param, &shader_version); + } + } + TRACE("\n"); + } +} + +static void shader_cleanup(IWineD3DBaseShader *iface) +{ + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface; + + ((IWineD3DDeviceImpl *)shader->baseShader.device)->shader_backend->shader_destroy(iface); + HeapFree(GetProcessHeap(), 0, shader->baseShader.reg_maps.constf); + HeapFree(GetProcessHeap(), 0, shader->baseShader.function); + shader_delete_constant_list(&shader->baseShader.constantsF); + shader_delete_constant_list(&shader->baseShader.constantsB); + shader_delete_constant_list(&shader->baseShader.constantsI); + list_remove(&shader->baseShader.shader_list_entry); + + if (shader->baseShader.frontend && shader->baseShader.frontend_data) + { + shader->baseShader.frontend->shader_free(shader->baseShader.frontend_data); + } +} + +static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {} +static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {} +static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {} +static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {} +static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {} +static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {} +static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {} +static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {} +static void shader_none_destroy(IWineD3DBaseShader *iface) {} +static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;} +static void shader_none_free(IWineD3DDevice *iface) {} +static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;} + +static void shader_none_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps) +{ + /* Set the shader caps to 0 for the none shader backend */ + caps->VertexShaderVersion = 0; + caps->PixelShaderVersion = 0; + caps->PixelShader1xMaxValue = 0.0f; +} + +static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) +{ + if (TRACE_ON(d3d_shader) && TRACE_ON(d3d)) + { + TRACE("Checking support for fixup:\n"); + dump_color_fixup_desc(fixup); + } + + /* Faked to make some apps happy. */ + if (!is_complex_fixup(fixup)) + { + TRACE("[OK]\n"); + return TRUE; + } + + TRACE("[FAILED]\n"); + return FALSE; +} + +const shader_backend_t none_shader_backend = { + shader_none_handle_instruction, + shader_none_select, + shader_none_select_depth_blt, + shader_none_deselect_depth_blt, + shader_none_update_float_vertex_constants, + shader_none_update_float_pixel_constants, + shader_none_load_constants, + shader_none_load_np2fixup_constants, + shader_none_destroy, + shader_none_alloc, + shader_none_free, + shader_none_dirty_const, + shader_none_get_caps, + shader_none_color_fixup_supported, +}; static void shader_get_parent(IWineD3DBaseShaderImpl *shader, IUnknown **parent) { diff --git a/reactos/dll/directx/wine/wined3d/shader_sm1.c b/reactos/dll/directx/wine/wined3d/shader_sm1.c index 64876b38032..aa1da56c5ba 100644 --- a/reactos/dll/directx/wine/wined3d/shader_sm1.c +++ b/reactos/dll/directx/wine/wined3d/shader_sm1.c @@ -641,9 +641,10 @@ static void shader_sm1_read_semantic(const DWORD **ptr, struct wined3d_shader_se shader_parse_dst_param(dst_token, NULL, &semantic->reg); } -static void shader_sm1_read_comment(const DWORD **ptr, const char **comment) +static void shader_sm1_read_comment(const DWORD **ptr, const char **comment, UINT *comment_size) { DWORD token = **ptr; + UINT size; if ((token & WINED3DSI_OPCODE_MASK) != WINED3D_SM1_OP_COMMENT) { @@ -651,8 +652,10 @@ static void shader_sm1_read_comment(const DWORD **ptr, const char **comment) return; } + size = (token & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT; *comment = (const char *)++(*ptr); - *ptr += (token & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT; + *comment_size = size * sizeof(DWORD); + *ptr += size; } static BOOL shader_sm1_is_end(void *data, const DWORD **ptr) diff --git a/reactos/dll/directx/wine/wined3d/shader_sm4.c b/reactos/dll/directx/wine/wined3d/shader_sm4.c index 91aa882c888..b4637904f10 100644 --- a/reactos/dll/directx/wine/wined3d/shader_sm4.c +++ b/reactos/dll/directx/wine/wined3d/shader_sm4.c @@ -49,10 +49,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); enum wined3d_sm4_opcode { WINED3D_SM4_OP_ADD = 0x00, + WINED3D_SM4_OP_BREAK = 0x02, + WINED3D_SM4_OP_BREAKC = 0x03, + WINED3D_SM4_OP_CUT = 0x09, WINED3D_SM4_OP_DP3 = 0x10, WINED3D_SM4_OP_DP4 = 0x11, + WINED3D_SM4_OP_EMIT = 0x13, + WINED3D_SM4_OP_ENDIF = 0x15, + WINED3D_SM4_OP_ENDLOOP = 0x16, WINED3D_SM4_OP_EXP = 0x19, + WINED3D_SM4_OP_IADD = 0x1e, + WINED3D_SM4_OP_IF = 0x1f, + WINED3D_SM4_OP_IGE = 0x21, WINED3D_SM4_OP_LOG = 0x2f, + WINED3D_SM4_OP_LT = 0x31, WINED3D_SM4_OP_MIN = 0x33, WINED3D_SM4_OP_MAX = 0x34, WINED3D_SM4_OP_MOV = 0x36, @@ -102,10 +112,20 @@ struct sysval_map static const struct wined3d_sm4_opcode_info opcode_table[] = { {WINED3D_SM4_OP_ADD, WINED3DSIH_ADD, 1, 2}, + {WINED3D_SM4_OP_BREAK, WINED3DSIH_BREAK, 0, 0}, + {WINED3D_SM4_OP_BREAKC, WINED3DSIH_BREAKP, 0, 1}, + {WINED3D_SM4_OP_CUT, WINED3DSIH_CUT, 0, 0}, {WINED3D_SM4_OP_DP3, WINED3DSIH_DP3, 1, 2}, {WINED3D_SM4_OP_DP4, WINED3DSIH_DP4, 1, 2}, + {WINED3D_SM4_OP_EMIT, WINED3DSIH_EMIT, 0, 0}, + {WINED3D_SM4_OP_ENDIF, WINED3DSIH_ENDIF, 0, 0}, + {WINED3D_SM4_OP_ENDLOOP,WINED3DSIH_ENDLOOP, 0, 0}, {WINED3D_SM4_OP_EXP, WINED3DSIH_EXP, 1, 1}, + {WINED3D_SM4_OP_IADD, WINED3DSIH_IADD, 1, 2}, + {WINED3D_SM4_OP_IF, WINED3DSIH_IF, 0, 1}, + {WINED3D_SM4_OP_IGE, WINED3DSIH_IGE, 1, 2}, {WINED3D_SM4_OP_LOG, WINED3DSIH_LOG, 1, 1}, + {WINED3D_SM4_OP_LT, WINED3DSIH_LT, 1, 2}, {WINED3D_SM4_OP_MIN, WINED3DSIH_MIN, 1, 2}, {WINED3D_SM4_OP_MAX, WINED3DSIH_MAX, 1, 2}, {WINED3D_SM4_OP_MOV, WINED3DSIH_MOV, 1, 1}, @@ -386,9 +406,9 @@ static void shader_sm4_read_semantic(const DWORD **ptr, struct wined3d_shader_se FIXME("ptr %p, semantic %p stub!\n", ptr, semantic); } -static void shader_sm4_read_comment(const DWORD **ptr, const char **comment) +static void shader_sm4_read_comment(const DWORD **ptr, const char **comment, UINT *comment_size) { - FIXME("ptr %p, comment %p stub!\n", ptr, comment); + FIXME("ptr %p, comment %p, comment_size %p stub!\n", ptr, comment, comment_size); *comment = NULL; } diff --git a/reactos/dll/directx/wine/wined3d/state.c b/reactos/dll/directx/wine/wined3d/state.c index adb426b904b..5efe069bb19 100644 --- a/reactos/dll/directx/wine/wined3d/state.c +++ b/reactos/dll/directx/wine/wined3d/state.c @@ -584,6 +584,10 @@ static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock, stru glEnable(GL_DEPTH_CLAMP); checkGLcall("glEnable(GL_DEPTH_CLAMP)"); } + else + { + FIXME("Clipping disabled, but ARB_depth_clamp isn't supported.\n"); + } } if (enable & WINED3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); } @@ -3523,7 +3527,6 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine if(stateblock->textures[sampler]) { BOOL srgb = stateblock->samplerState[sampler][WINED3DSAMP_SRGBTEXTURE]; IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler]; - tex_impl->baseTexture.internal_preload(stateblock->textures[sampler], srgb ? SRGB_SRGB : SRGB_RGB); IWineD3DBaseTexture_BindTexture(stateblock->textures[sampler], srgb); basetexture_apply_state_changes(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler], gl_info); @@ -3597,9 +3600,9 @@ void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w } } else { /* Disabled the pixel shader - color ops weren't applied - * while it was enabled, so re-apply them. - */ - for(i=0; i < MAX_TEXTURES; i++) { + * while it was enabled, so re-apply them. */ + for (i = 0; i < context->gl_info->limits.texture_stages; ++i) + { if(!isStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) { device->StateTable[STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP)].apply (STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock, context); @@ -3880,62 +3883,18 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock glLoadIdentity(); checkGLcall("glLoadIdentity"); - if(context->last_was_rhw) { - double X, Y, height, width, minZ, maxZ; + if (context->last_was_rhw) + { + double x = stateblock->viewport.X; + double y = stateblock->viewport.Y; + double w = stateblock->viewport.Width; + double h = stateblock->viewport.Height; - X = stateblock->viewport.X; - Y = stateblock->viewport.Y; - height = stateblock->viewport.Height; - width = stateblock->viewport.Width; - minZ = stateblock->viewport.MinZ; - maxZ = stateblock->viewport.MaxZ; - - if (!stateblock->device->untransformed) - { - /* Transformed vertices are supposed to bypass the whole transform pipeline including - * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to - * suppress depth clipping. This can be done because it is an orthogonal projection and - * the Z coordinate does not affect the size of the primitives. Half Life 1 and Prince of - * Persia 3D need this. - * - * Note that using minZ and maxZ here doesn't entirely fix the problem, since view frustum - * clipping is still enabled, but it seems to fix it for all apps tested so far. A minor - * problem can be witnessed in half-life 1 engine based games, the weapon is clipped close - * to the viewer. - * - * Also note that this breaks z comparison against z values filled in with clear, - * but no app depending on that and disabled clipping has been found yet. Comparing - * primitives against themselves works, so the Z buffer is still intact for normal hidden - * surface removal. - * - * We could disable clipping entirely by setting the near to infinity and far to -infinity, - * but this would break Z buffer operation. Raising the range to something less than - * infinity would help a bit at the cost of Z precision, but it wouldn't eliminate the - * problem either. - */ - TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ); - if (context->render_offscreen) - { - glOrtho(X, X + width, -Y, -Y - height, -minZ, -maxZ); - } else { - glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ); - } - } else { - /* If the app mixes transformed and untransformed primitives we can't use the coordinate system - * trick above because this would mess up transformed and untransformed Z order. Pass the z position - * unmodified to opengl. - * - * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline - * replacement shader. - */ - TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0); - if (context->render_offscreen) - { - glOrtho(X, X + width, -Y, -Y - height, 0.0, -1.0); - } else { - glOrtho(X, X + width, Y + height, Y, 0.0, -1.0); - } - } + TRACE("Calling glOrtho with x %.8e, y %.8e, w %.8e, h %.8e.\n", x, y, w, h); + if (context->render_offscreen) + glOrtho(x, x + w, -y, -y - h, 0.0, -1.0); + else + glOrtho(x, x + w, y + h, y, 0.0, -1.0); checkGLcall("glOrtho"); /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */ @@ -4167,7 +4126,7 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, GL_EXTCALL(glVertexAttrib4NubvARB(i, ptr)); break; case WINED3DFMT_B8G8R8A8_UNORM: - if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) + if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) { const DWORD *src = (const DWORD *)ptr; DWORD c = *src & 0xff00ff00; @@ -4479,87 +4438,11 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB loadTexCoords(context, stateblock, si, &curVBO); } -static inline void drawPrimitiveTraceDataLocations(const struct wined3d_stream_info *dataLocations) -{ - /* Dump out what parts we have supplied */ - TRACE("Strided Data:\n"); - TRACE_STRIDED((dataLocations), WINED3D_FFP_POSITION); - TRACE_STRIDED((dataLocations), WINED3D_FFP_BLENDWEIGHT); - TRACE_STRIDED((dataLocations), WINED3D_FFP_BLENDINDICES); - TRACE_STRIDED((dataLocations), WINED3D_FFP_NORMAL); - TRACE_STRIDED((dataLocations), WINED3D_FFP_PSIZE); - TRACE_STRIDED((dataLocations), WINED3D_FFP_DIFFUSE); - TRACE_STRIDED((dataLocations), WINED3D_FFP_SPECULAR); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD0); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD1); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD2); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD3); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD4); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD5); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD6); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD7); -} - static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) { - const struct wined3d_gl_info *gl_info = context->gl_info; IWineD3DDeviceImpl *device = stateblock->device; - BOOL fixup = FALSE; - struct wined3d_stream_info *dataLocations = &device->strided_streams; - BOOL useVertexShaderFunction; - BOOL load_numbered = FALSE; - BOOL load_named = FALSE; - - useVertexShaderFunction = (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader) ? TRUE : FALSE; - - if(device->up_strided) { - /* Note: this is a ddraw fixed-function code path */ - TRACE("================ Strided Input ===================\n"); - device_stream_info_from_strided(gl_info, device->up_strided, dataLocations); - - if(TRACE_ON(d3d)) { - drawPrimitiveTraceDataLocations(dataLocations); - } - } else { - /* Note: This is a fixed function or shader codepath. - * This means it must handle both types of strided data. - * Shaders must go through here to zero the strided data, even if they - * don't set any declaration at all - */ - TRACE("================ Vertex Declaration ===================\n"); - device_stream_info_from_declaration(device, useVertexShaderFunction, dataLocations, &fixup); - } - - if (dataLocations->position_transformed) useVertexShaderFunction = FALSE; - - if(useVertexShaderFunction) { - if(((IWineD3DVertexDeclarationImpl *) stateblock->vertexDecl)->half_float_conv_needed && !fixup) { - TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n"); - device->useDrawStridedSlow = TRUE; - } else { - load_numbered = TRUE; - device->useDrawStridedSlow = FALSE; - } - } - else - { - WORD slow_mask = (1 << WINED3D_FFP_PSIZE); - slow_mask |= -!gl_info->supported[EXT_VERTEX_ARRAY_BGRA] - & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR)); - - if (fixup || (!dataLocations->position_transformed - && !(dataLocations->use_map & slow_mask))) - { - /* Load the vertex data using named arrays */ - load_named = TRUE; - device->useDrawStridedSlow = FALSE; - } - else - { - TRACE("Not loading vertex data\n"); - device->useDrawStridedSlow = TRUE; - } - } + BOOL load_numbered = use_vs(stateblock) && !device->useDrawStridedSlow; + BOOL load_named = !use_vs(stateblock) && !device->useDrawStridedSlow; if (context->numberedArraysLoaded && !load_numbered) { @@ -4576,13 +4459,13 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi if (load_numbered) { TRACE("Loading numbered arrays\n"); - loadNumberedArrays(stateblock, dataLocations, context); + loadNumberedArrays(stateblock, &device->strided_streams, context); context->numberedArraysLoaded = TRUE; } else if (load_named) { TRACE("Loading vertex data\n"); - loadVertexData(context, stateblock, dataLocations); + loadVertexData(context, stateblock, &device->strided_streams); context->namedArraysLoaded = TRUE; } } @@ -5634,8 +5517,7 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = { /* Context activation is done by the caller. */ static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { } -static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, - const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps) +static void ffp_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps) { pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD | WINED3DTEXOPCAPS_ADDSIGNED | @@ -5670,7 +5552,7 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, if (gl_info->supported[ARB_TEXTURE_ENV_DOT3]) pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_DOTPRODUCT3; - pCaps->MaxTextureBlendStages = gl_info->limits.texture_stages; + pCaps->MaxTextureBlendStages = gl_info->limits.textures; pCaps->MaxSimultaneousTextures = gl_info->limits.textures; } @@ -5725,6 +5607,43 @@ static void multistate_apply_3(DWORD state, IWineD3DStateBlockImpl *stateblock, stateblock->device->multistate_funcs[state][2](state, stateblock, context); } +static void prune_invalid_states(struct StateEntry *state_table, const struct wined3d_gl_info *gl_info) +{ + unsigned int start, last, i; + + start = STATE_TEXTURESTAGE(gl_info->limits.texture_stages, 0); + last = STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE); + for (i = start; i <= last; ++i) + { + state_table[i].representative = 0; + state_table[i].apply = state_undefined; + } + + start = STATE_TRANSFORM(WINED3DTS_TEXTURE0 + gl_info->limits.texture_stages); + last = STATE_TRANSFORM(WINED3DTS_TEXTURE0 + MAX_TEXTURES - 1); + for (i = start; i <= last; ++i) + { + state_table[i].representative = 0; + state_table[i].apply = state_undefined; + } +} + +static void validate_state_table(struct StateEntry *state_table) +{ + unsigned int i; + + for (i = 0; i < STATE_HIGHEST + 1; ++i) + { + DWORD rep = state_table[i].representative; + if (rep && !state_table[rep].representative) + { + ERR("State %s (%#x) has invalid representative %s (%#x).\n", + debug_d3dstate(i), i, debug_d3dstate(rep), rep); + state_table[i].representative = 0; + } + } +} + HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs, const struct wined3d_gl_info *gl_info, const struct StateEntryTemplate *vertex, const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) @@ -5824,6 +5743,9 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_ } } + prune_invalid_states(StateTable, gl_info); + validate_state_table(StateTable); + return WINED3D_OK; out_of_mem: diff --git a/reactos/dll/directx/wine/wined3d/surface.c b/reactos/dll/directx/wine/wined3d/surface.c index 8dcc6915bbf..d17d35cc16d 100644 --- a/reactos/dll/directx/wine/wined3d/surface.c +++ b/reactos/dll/directx/wine/wined3d/surface.c @@ -1253,6 +1253,37 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb) TRACE("Updated target %d\n", This->texture_target); } +/* Context activation is done by the caller. */ +void surface_prepare_texture(IWineD3DSurfaceImpl *surface, BOOL srgb) +{ + DWORD alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED; + GLenum format, internal, type; + GLsizei width, height; + CONVERT_TYPES convert; + int bpp; + + if (surface->Flags & alloc_flag) return; + + d3dfmt_get_conv(surface, TRUE, TRUE, &format, &internal, &type, &convert, &bpp, srgb); + if(convert != NO_CONVERSION) surface->Flags |= SFLAG_CONVERTED; + else surface->Flags &= ~SFLAG_CONVERTED; + + if ((surface->Flags & SFLAG_NONPOW2) && !(surface->Flags & SFLAG_OVERSIZE)) + { + width = surface->pow2Width; + height = surface->pow2Height; + } + else + { + width = surface->glRect.right - surface->glRect.left; + height = surface->glRect.bottom - surface->glRect.top; + } + + surface_bind_and_dirtify(surface, srgb); + surface_allocate_surface(surface, internal, width, height, format, type); + surface->Flags |= alloc_flag; +} + static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This) { IWineD3DDeviceImpl *device = This->resource.device; @@ -1822,7 +1853,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ * in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which * conflicts with this. */ - if (!(gl_info->supported[EXT_PALETTED_TEXTURE] || (gl_info->supported[ARB_FRAGMENT_PROGRAM] + if (!(gl_info->supported[EXT_PALETTED_TEXTURE] || (device->blitter->color_fixup_supported(This->resource.format_desc->color_fixup) && device->render_targets && This == (IWineD3DSurfaceImpl*)device->render_targets[0])) || colorkey_active || !use_texturing) { @@ -1836,7 +1867,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ *convert = CONVERT_PALETTED; } } - else if (!gl_info->supported[EXT_PALETTED_TEXTURE] && gl_info->supported[ARB_FRAGMENT_PROGRAM]) + else if (!gl_info->supported[EXT_PALETTED_TEXTURE] && device->blitter->color_fixup_supported(This->resource.format_desc->color_fixup)) { *format = GL_ALPHA; *type = GL_UNSIGNED_BYTE; @@ -2553,34 +2584,10 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve * The 8bit pixel data will be used as an index in this palette texture to retrieve the final color. */ TRACE("Using fragment shaders for emulating 8-bit paletted texture support\n"); + device->blitter->set_shader((IWineD3DDevice *) device, This->resource.format_desc, + This->texture_target, This->pow2Width, This->pow2Height); + ENTER_GL(); - - /* Create the fragment program if we don't have it */ - if(!device->paletteConversionShader) - { - const char *fragment_palette_conversion = - "!!ARBfp1.0\n" - "TEMP index;\n" - /* { 255/256, 0.5/255*255/256, 0, 0 } */ - "PARAM constants = { 0.996, 0.00195, 0, 0 };\n" - /* The alpha-component contains the palette index */ - "TEX index, fragment.texcoord[0], texture[0], 2D;\n" - /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */ - "MAD index.a, index.a, constants.x, constants.y;\n" - /* Use the alpha-component as an index in the palette to get the final color */ - "TEX result.color, index.a, texture[1], 1D;\n" - "END"; - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - GL_EXTCALL(glGenProgramsARB(1, &device->paletteConversionShader)); - GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader)); - GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(fragment_palette_conversion), fragment_palette_conversion)); - glDisable(GL_FRAGMENT_PROGRAM_ARB); - } - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader)); - GL_EXTCALL(glActiveTextureARB(GL_TEXTURE1)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); @@ -2594,7 +2601,6 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve /* Rebind the texture because it isn't bound anymore */ glBindTexture(This->texture_target, This->texture_name); - LEAVE_GL(); } } @@ -2700,7 +2706,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BO static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb) { /* TODO: check for locks */ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; - IWineD3DDeviceImpl *device = This->resource.device; IWineD3DBaseTexture *baseTexture = NULL; TRACE("(%p)Checking to see if the container is a base texture\n", This); @@ -2711,13 +2716,11 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL } else { - struct wined3d_context *context = NULL; GLuint *name; TRACE("(%p) : Binding surface\n", This); name = srgb ? &This->texture_name_srgb : &This->texture_name; - if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); ENTER_GL(); @@ -2751,8 +2754,6 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL checkGLcall("glBindTexture"); LEAVE_GL(); - - if (context) context_release(context); } } @@ -3447,6 +3448,9 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine } LEAVE_GL(); + + wglFlush(); /* Flush to ensure ordering across contexts. */ + context_release(context); /* The texture is now most up to date - If the surface is a render target and has a drawable, this @@ -3921,9 +3925,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const /* Leave the opengl state valid for blitting */ myDevice->blitter->unset_shader((IWineD3DDevice *) myDevice); - /* Flush in case the drawable is used by multiple GL contexts */ - if(dstSwapchain && (This == (IWineD3DSurfaceImpl *) dstSwapchain->frontBuffer || dstSwapchain->num_contexts >= 2)) - wglFlush(); + wglFlush(); /* Flush to ensure ordering across contexts. */ context_release(context); @@ -4552,7 +4554,11 @@ void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *co else context_bind_fbo(context, GL_FRAMEBUFFER, NULL); LEAVE_GL(); - } else { + + wglFlush(); /* Flush to ensure ordering across contexts. */ + } + else + { FIXME("No up to date depth stencil location\n"); } } else if (location == SFLAG_DS_ONSCREEN) { @@ -4569,7 +4575,11 @@ void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *co if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER, &context->current_fbo->id); LEAVE_GL(); - } else { + + wglFlush(); /* Flush to ensure ordering across contexts. */ + } + else + { FIXME("No up to date depth stencil location\n"); } } else { @@ -4656,11 +4666,10 @@ static inline void cube_coords_float(const RECT *r, UINT w, UINT h, struct float static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT *rect_in) { IWineD3DDeviceImpl *device = This->resource.device; + IWineD3DBaseTextureImpl *texture; struct wined3d_context *context; struct coords coords[4]; RECT rect; - IWineD3DSwapChain *swapchain; - IWineD3DBaseTexture *texture; GLenum bind_target; struct float_rect f; @@ -4802,25 +4811,16 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT LEAVE_GL(); - if(SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DSwapChain, (void **) &swapchain))) - { - /* Make sure to flush the buffers. This is needed in apps like Red Alert II and Tiberian SUN that use multiple WGL contexts. */ - if(((IWineD3DSwapChainImpl*)swapchain)->frontBuffer == (IWineD3DSurface*)This || - ((IWineD3DSwapChainImpl*)swapchain)->num_contexts >= 2) - wglFlush(); + wglFlush(); /* Flush to ensure ordering across contexts. */ - IWineD3DSwapChain_Release(swapchain); - } else { - /* We changed the filtering settings on the texture. Inform the container about this to get the filters - * reset properly next draw - */ - if(SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DBaseTexture, (void **) &texture))) - { - ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT; - ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; - ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE; - IWineD3DBaseTexture_Release(texture); - } + /* We changed the filtering settings on the texture. Inform the + * container about this to get the filters reset properly next draw. */ + if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)This, &IID_IWineD3DBaseTexture, (void **)&texture))) + { + texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT; + texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; + texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE; + IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture); } context_release(context); @@ -4977,7 +4977,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D { /* Upload from system memory */ BOOL srgb = flag == SFLAG_INSRGBTEX; - DWORD alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED; struct wined3d_context *context = NULL; d3dfmt_get_conv(This, TRUE /* We need color keying */, TRUE /* We will use textures */, @@ -5004,6 +5003,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D } if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + + surface_prepare_texture(This, srgb); surface_bind_and_dirtify(This, srgb); if(This->CKeyFlags & WINEDDSD_CKSRCBLT) { @@ -5037,17 +5038,13 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D return WINED3DERR_OUTOFVIDEOMEMORY; } d3dfmt_convert_surface(This->resource.allocatedMemory, mem, pitch, width, height, outpitch, convert, This); - - This->Flags |= SFLAG_CONVERTED; } else if (This->resource.format_desc->format == WINED3DFMT_P8_UINT - && (gl_info->supported[EXT_PALETTED_TEXTURE] || gl_info->supported[ARB_FRAGMENT_PROGRAM])) + && (gl_info->supported[EXT_PALETTED_TEXTURE] || device->blitter->color_fixup_supported(This->resource.format_desc->color_fixup))) { d3dfmt_p8_upload_palette(iface, convert); - This->Flags &= ~SFLAG_CONVERTED; mem = This->resource.allocatedMemory; } else { - This->Flags &= ~SFLAG_CONVERTED; mem = This->resource.allocatedMemory; } @@ -5058,10 +5055,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D if ((This->Flags & SFLAG_NONPOW2) && !(This->Flags & SFLAG_OVERSIZE)) { TRACE("non power of two support\n"); - if(!(This->Flags & alloc_flag)) { - surface_allocate_surface(This, internal, This->pow2Width, This->pow2Height, format, type); - This->Flags |= alloc_flag; - } if (mem || (This->Flags & SFLAG_PBO)) { surface_upload_data(This, internal, This->currentDesc.Width, This->currentDesc.Height, format, type, mem); } @@ -5069,10 +5062,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D /* When making the realloc conditional, keep in mind that GL_APPLE_client_storage may be in use, and This->resource.allocatedMemory * changed. So also keep track of memory changes. In this case the texture has to be reallocated */ - if(!(This->Flags & alloc_flag)) { - surface_allocate_surface(This, internal, This->glRect.right - This->glRect.left, This->glRect.bottom - This->glRect.top, format, type); - This->Flags |= alloc_flag; - } if (mem || (This->Flags & SFLAG_PBO)) { surface_upload_data(This, internal, This->glRect.right - This->glRect.left, This->glRect.bottom - This->glRect.top, format, type, mem); } diff --git a/reactos/dll/directx/wine/wined3d/swapchain.c b/reactos/dll/directx/wine/wined3d/swapchain.c index 6493704014b..cbdb961f705 100644 --- a/reactos/dll/directx/wine/wined3d/swapchain.c +++ b/reactos/dll/directx/wine/wined3d/swapchain.c @@ -217,6 +217,8 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO unsigned int sync; int retval; + IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride); + context = context_acquire(This->device, This->backBuffer[0], CTXUSAGE_RESOURCELOAD); /* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */ @@ -272,12 +274,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO IWineD3DSurface_BltFast(This->backBuffer[0], 0, 0, This->device->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY); } - TRACE("presetting HDC %p\n", This->context[0]->hdc); - - /* Don't call checkGLcall, as glGetError is not applicable here */ - if (hDestWindowOverride && This->win_handle != hDestWindowOverride) { - IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride); - } + TRACE("Presenting HDC %p.\n", context->hdc); render_to_fbo = This->render_to_fbo; @@ -343,7 +340,8 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO swapchain_blit(This, context, &src_rect, &dst_rect); } - SwapBuffers(This->context[0]->hdc); /* TODO: cycle through the swapchain buffers */ + if (This->num_contexts > 1) wglFinish(); + SwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */ TRACE("SwapBuffers called, Starting new frame\n"); /* FPS support */ @@ -521,7 +519,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapCh WINED3DLOCKED_RECT r; BYTE *mem; - if(window == This->win_handle) return WINED3D_OK; + if (!window || window == This->win_handle) return WINED3D_OK; TRACE("Performing dest override of swapchain %p from window %p to %p\n", This, This->win_handle, window); if (This->context[0] == This->device->contexts[0]) @@ -913,10 +911,15 @@ err: HeapFree(GetProcessHeap(), 0, swapchain->backBuffer); } - if (swapchain->context && swapchain->context[0]) + if (swapchain->context) { - context_release(swapchain->context[0]); - context_destroy(device, swapchain->context[0]); + if (swapchain->context[0]) + { + context_release(swapchain->context[0]); + context_destroy(device, swapchain->context[0]); + swapchain->num_contexts = 0; + } + HeapFree(GetProcessHeap(), 0, swapchain->context); } if (swapchain->frontBuffer) IWineD3DSurface_Release(swapchain->frontBuffer); diff --git a/reactos/dll/directx/wine/wined3d/utils.c b/reactos/dll/directx/wine/wined3d/utils.c index c1e921da976..2ff16752c33 100644 --- a/reactos/dll/directx/wine/wined3d/utils.c +++ b/reactos/dll/directx/wine/wined3d/utils.c @@ -387,7 +387,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, - {WINED3DFMT_R16G16_UNORM, GL_RGB16_EXT, GL_RGB16_EXT, GL_RGBA16_EXT, + {WINED3DFMT_R16G16_UNORM, GL_RGB16, GL_RGB16, GL_RGBA16, GL_RGB, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, @@ -395,7 +395,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = { GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, - {WINED3DFMT_R16G16B16A16_UNORM, GL_RGBA16_EXT, GL_RGBA16_EXT, 0, + {WINED3DFMT_R16G16B16A16_UNORM, GL_RGBA16, GL_RGBA16, 0, GL_RGBA, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET, WINED3D_GL_EXT_NONE}, @@ -445,7 +445,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = { GL_RGBA, GL_BYTE, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, NV_TEXTURE_SHADER}, - {WINED3DFMT_R16G16_SNORM, GL_RGB16_EXT, GL_RGB16_EXT, 0, + {WINED3DFMT_R16G16_SNORM, GL_RGB16, GL_RGB16, 0, GL_BGR, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, @@ -506,7 +506,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = { GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH, ARB_DEPTH_TEXTURE}, - {WINED3DFMT_L16_UNORM, GL_LUMINANCE16_EXT, GL_LUMINANCE16_EXT, 0, + {WINED3DFMT_L16_UNORM, GL_LUMINANCE16, GL_LUMINANCE16, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, @@ -950,7 +950,7 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3 if(wined3d_settings.offscreen_rendering_mode != ORM_FBO) { WARN("No FBO support, or no FBO ORM, guessing filter info from GL caps\n"); - if (vendor == VENDOR_NVIDIA && gl_info->supported[ARB_TEXTURE_FLOAT]) + if (vendor == HW_VENDOR_NVIDIA && gl_info->supported[ARB_TEXTURE_FLOAT]) { TRACE("Nvidia card with texture_float support: Assuming float16 blending\n"); filtered = TRUE; @@ -1088,17 +1088,20 @@ static void apply_format_fixups(struct wined3d_gl_info *gl_info) if (!gl_info->supported[APPLE_YCBCR_422]) { idx = getFmtIdx(WINED3DFMT_YUY2); - gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YUY2); + gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2); idx = getFmtIdx(WINED3DFMT_UYVY); - gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_UYVY); + gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY); } idx = getFmtIdx(WINED3DFMT_YV12); gl_info->gl_formats[idx].heightscale = 1.5f; - gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YV12); + gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12); - if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) + idx = getFmtIdx(WINED3DFMT_P8_UINT); + gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8); + + if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) { idx = getFmtIdx(WINED3DFMT_B8G8R8A8_UNORM); gl_info->gl_formats[idx].gl_vtx_format = GL_BGRA; @@ -1786,6 +1789,51 @@ const char* debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype) { } } +const char *debug_d3dstate(DWORD state) +{ + if (STATE_IS_RENDER(state)) + return wine_dbg_sprintf("STATE_RENDER(%s)", debug_d3drenderstate(state - STATE_RENDER(0))); + if (STATE_IS_TEXTURESTAGE(state)) + { + DWORD texture_stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); + DWORD texture_state = state - STATE_TEXTURESTAGE(texture_stage, 0); + return wine_dbg_sprintf("STATE_TEXTURESTAGE(%#x, %s)", + texture_stage, debug_d3dtexturestate(texture_state)); + } + if (STATE_IS_SAMPLER(state)) + return wine_dbg_sprintf("STATE_SAMPLER(%#x)", state - STATE_SAMPLER(0)); + if (STATE_IS_PIXELSHADER(state)) + return "STATE_PIXELSHADER"; + if (STATE_IS_TRANSFORM(state)) + return wine_dbg_sprintf("STATE_TRANSFORM(%s)", debug_d3dtstype(state - STATE_TRANSFORM(0))); + if (STATE_IS_STREAMSRC(state)) + return "STATE_STREAMSRC"; + if (STATE_IS_INDEXBUFFER(state)) + return "STATE_INDEXBUFFER"; + if (STATE_IS_VDECL(state)) + return "STATE_VDECL"; + if (STATE_IS_VSHADER(state)) + return "STATE_VSHADER"; + if (STATE_IS_VIEWPORT(state)) + return "STATE_VIEWPORT"; + if (STATE_IS_VERTEXSHADERCONSTANT(state)) + return "STATE_VERTEXSHADERCONSTANT"; + if (STATE_IS_PIXELSHADERCONSTANT(state)) + return "STATE_PIXELSHADERCONSTANT"; + if (STATE_IS_ACTIVELIGHT(state)) + return wine_dbg_sprintf("STATE_ACTIVELIGHT(%#x)", state - STATE_ACTIVELIGHT(0)); + if (STATE_IS_SCISSORRECT(state)) + return "STATE_SCISSORRECT"; + if (STATE_IS_CLIPPLANE(state)) + return wine_dbg_sprintf("STATE_CLIPPLANE(%#x)", state - STATE_CLIPPLANE(0)); + if (STATE_IS_MATERIAL(state)) + return "STATE_MATERIAL"; + if (STATE_IS_FRONTFACE(state)) + return "STATE_FRONTFACE"; + + return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state); +} + const char* debug_d3dpool(WINED3DPOOL Pool) { switch (Pool) { #define POOL_TO_STR(p) case p: return #p @@ -1868,8 +1916,8 @@ static const char *debug_fixup_channel_source(enum fixup_channel_source source) WINED3D_TO_STR(CHANNEL_SOURCE_Y); WINED3D_TO_STR(CHANNEL_SOURCE_Z); WINED3D_TO_STR(CHANNEL_SOURCE_W); - WINED3D_TO_STR(CHANNEL_SOURCE_YUV0); - WINED3D_TO_STR(CHANNEL_SOURCE_YUV1); + WINED3D_TO_STR(CHANNEL_SOURCE_COMPLEX0); + WINED3D_TO_STR(CHANNEL_SOURCE_COMPLEX1); #undef WINED3D_TO_STR default: FIXME("Unrecognized fixup_channel_source %#x\n", source); @@ -1877,26 +1925,27 @@ static const char *debug_fixup_channel_source(enum fixup_channel_source source) } } -static const char *debug_yuv_fixup(enum yuv_fixup yuv_fixup) +static const char *debug_complex_fixup(enum complex_fixup fixup) { - switch(yuv_fixup) + switch(fixup) { #define WINED3D_TO_STR(x) case x: return #x - WINED3D_TO_STR(YUV_FIXUP_YUY2); - WINED3D_TO_STR(YUV_FIXUP_UYVY); - WINED3D_TO_STR(YUV_FIXUP_YV12); + WINED3D_TO_STR(COMPLEX_FIXUP_YUY2); + WINED3D_TO_STR(COMPLEX_FIXUP_UYVY); + WINED3D_TO_STR(COMPLEX_FIXUP_YV12); + WINED3D_TO_STR(COMPLEX_FIXUP_P8); #undef WINED3D_TO_STR default: - FIXME("Unrecognized YUV fixup %#x\n", yuv_fixup); + FIXME("Unrecognized complex fixup %#x\n", fixup); return "unrecognized"; } } void dump_color_fixup_desc(struct color_fixup_desc fixup) { - if (is_yuv_fixup(fixup)) + if (is_complex_fixup(fixup)) { - TRACE("\tYUV: %s\n", debug_yuv_fixup(get_yuv_fixup(fixup))); + TRACE("\tComplex: %s\n", debug_complex_fixup(get_complex_fixup(fixup))); return; } @@ -2795,40 +2844,3 @@ void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, else if (gl_info->supported[ATI_FRAGMENT_SHADER]) *ps_selected = SHADER_ATI; else *ps_selected = SHADER_NONE; } - -const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type) -{ - int vs_selected_mode, ps_selected_mode; - - select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode); - if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend; - if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend; - return &none_shader_backend; -} - -const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter, - WINED3DDEVTYPE device_type) -{ - const struct wined3d_gl_info *gl_info = &adapter->gl_info; - int vs_selected_mode, ps_selected_mode; - - select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode); - if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) - && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_fragment_pipeline; - else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline; - else if (gl_info->supported[NV_REGISTER_COMBINERS] - && gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline; - else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline; - else return &ffp_fragment_pipeline; -} - -const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type) -{ - const struct wined3d_gl_info *gl_info = &adapter->gl_info; - int vs_selected_mode, ps_selected_mode; - - select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode); - if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) - && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit; - else return &ffp_blit; -} diff --git a/reactos/dll/directx/wine/wined3d/wined3d.rbuild b/reactos/dll/directx/wine/wined3d/wined3d.rbuild index 7262e66e4b5..5a42ff6064a 100644 --- a/reactos/dll/directx/wine/wined3d/wined3d.rbuild +++ b/reactos/dll/directx/wine/wined3d/wined3d.rbuild @@ -16,7 +16,6 @@ ati_fragment_shader.c arb_program_shader.c - baseshader.c basetexture.c buffer.c clipper.c diff --git a/reactos/dll/directx/wine/wined3d/wined3d_gl.h b/reactos/dll/directx/wine/wined3d/wined3d_gl.h index d6d9794933f..f8097d65cb9 100644 --- a/reactos/dll/directx/wine/wined3d/wined3d_gl.h +++ b/reactos/dll/directx/wine/wined3d/wined3d_gl.h @@ -75,6 +75,9 @@ typedef double GLclampd; typedef void GLvoid; typedef ptrdiff_t GLintptr; typedef ptrdiff_t GLsizeiptr; +typedef INT64 GLint64; +typedef UINT64 GLuint64; +typedef struct __GLsync *GLsync; /* Booleans */ #define GL_FALSE 0x0 @@ -804,6 +807,197 @@ typedef ptrdiff_t GLsizeiptr; #define GL_SAMPLE_COVERAGE_INVERT 0x80AB #define GL_MULTISAMPLE_BIT 0x20000000 +/* GL_VERSION_2_0 */ +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882a +#define GL_DRAW_BUFFER6 0x882b +#define GL_DRAW_BUFFER7 0x882c +#define GL_DRAW_BUFFER8 0x882d +#define GL_DRAW_BUFFER9 0x882e +#define GL_DRAW_BUFFER10 0x882f +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883d +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886a +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8b30 +#define GL_VERTEX_SHADER 0x8b31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8b49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8b4a +#define GL_MAX_VARYING_FLOATS 0x8b4b +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8b4c +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8b4d +#define GL_SHADER_TYPE 0x8b4f +#define GL_FLOAT_VEC2 0x8b50 +#define GL_FLOAT_VEC3 0x8b51 +#define GL_FLOAT_VEC4 0x8b52 +#define GL_INT_VEC2 0x8b53 +#define GL_INT_VEC3 0x8b54 +#define GL_INT_VEC4 0x8b55 +#define GL_BOOL 0x8b56 +#define GL_BOOL_VEC2 0x8b57 +#define GL_BOOL_VEC3 0x8b58 +#define GL_BOOL_VEC4 0x8b59 +#define GL_FLOAT_MAT2 0x8b5a +#define GL_FLOAT_MAT3 0x8b5b +#define GL_FLOAT_MAT4 0x8b5c +#define GL_SAMPLER_1D 0x8b5d +#define GL_SAMPLER_2D 0x8b5e +#define GL_SAMPLER_3D 0x8b5f +#define GL_SAMPLER_CUBE 0x8b60 +#define GL_SAMPLER_1D_SHADOW 0x8b61 +#define GL_SAMPLER_2D_SHADOW 0x8b62 +#define GL_DELETE_STATUS 0x8b80 +#define GL_COMPILE_STATUS 0x8b81 +#define GL_LINK_STATUS 0x8b82 +#define GL_VALIDATE_STATUS 0x8b83 +#define GL_INFO_LOG_LENGTH 0x8b84 +#define GL_ATTACHED_SHADERS 0x8b85 +#define GL_ACTIVE_UNIFORMS 0x8b86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8b87 +#define GL_SHADER_SOURCE_LENGTH 0x8b88 +#define GL_ACTIVE_ATTRIBUTES 0x8b89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8b8a +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8b8b +#define GL_SHADING_LANGUAGE_VERSION 0x8b8c +#define GL_CURRENT_PROGRAM 0x8b8d +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8ca0 +#define GL_LOWER_LEFT 0x8ca1 +#define GL_UPPER_LEFT 0x8ca2 +#define GL_STENCIL_BACK_REF 0x8ca3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8ca4 +#define GL_STENCIL_BACK_WRITEMASK 0x8ca5 +typedef char GLchar; +#endif +typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); +typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSPROC)(GLsizei n, const GLenum *bufs); +typedef void (WINE_GLAPI *PGLFNSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (WINE_GLAPI *PGLFNSTENCILFUNCSEPARATEPROC)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (WINE_GLAPI *PGLFNSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); +typedef void (WINE_GLAPI *PGLFNATTACHSHADERPROC)(GLuint program, GLuint shader); +typedef void (WINE_GLAPI *PGLFNBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar *name); +typedef void (WINE_GLAPI *PGLFNCOMPILESHADERPROC)(GLuint shader); +typedef GLuint (WINE_GLAPI *PGLFNCREATEPROGRAMPROC)(void); +typedef GLuint (WINE_GLAPI *PGLFNCREATESHADERPROC)(GLenum type); +typedef void (WINE_GLAPI *PGLFNDELETEPROGRAMPROC)(GLuint program); +typedef void (WINE_GLAPI *PGLFNDELETESHADERPROC)(GLuint shader); +typedef void (WINE_GLAPI *PGLFNDETACHSHADERPROC)(GLuint program, GLuint shader); +typedef void (WINE_GLAPI *PGLFNDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void (WINE_GLAPI *PGLFNENABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void (WINE_GLAPI *PGLFNGETACTIVEATTRIBPROC)(GLuint program, + GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (WINE_GLAPI *PGLFNGETACTIVEUNIFORMPROC)(GLuint program, + GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (WINE_GLAPI *PGLFNGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (WINE_GLAPI *PGLFNGETATTRIBLOCATIONPROC)(GLuint program, const GLchar *name); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMINFOLOGPROC)(GLuint program, + GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (WINE_GLAPI *PGLFNGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (WINE_GLAPI *PGLFNGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (WINE_GLAPI *PGLFNGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar *name); +typedef void (WINE_GLAPI *PGLFNGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETUNIFORMIVPROC)(GLuint program, GLint location, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (WINE_GLAPI *PGLFNISPROGRAMPROC)(GLuint program); +typedef GLboolean (WINE_GLAPI *PGLFNISSHADERPROC)(GLuint shader); +typedef void (WINE_GLAPI *PGLFNLINKPROGRAMPROC)(GLuint program); +typedef void (WINE_GLAPI *PGLFNSHADERSOURCEPROC)(GLuint shader, + GLsizei count, const GLchar* *string, const GLint *length); +typedef void (WINE_GLAPI *PGLFNUSEPROGRAMPROC)(GLuint program); +typedef void (WINE_GLAPI *PGLFNUNIFORM1FPROC)(GLint location, GLfloat v0); +typedef void (WINE_GLAPI *PGLFNUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); +typedef void (WINE_GLAPI *PGLFNUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (WINE_GLAPI *PGLFNUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (WINE_GLAPI *PGLFNUNIFORM1IPROC)(GLint location, GLint v0); +typedef void (WINE_GLAPI *PGLFNUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); +typedef void (WINE_GLAPI *PGLFNUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); +typedef void (WINE_GLAPI *PGLFNUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (WINE_GLAPI *PGLFNUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX2FVPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX3FVPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX4FVPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNVALIDATEPROGRAMPROC)(GLuint program); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SPROC)(GLuint index, GLshort x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NIVPROC)(GLuint index, const GLint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4IVPROC)(GLuint index, const GLint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4USVPROC)(GLuint index, const GLushort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBPOINTERPROC)(GLuint index, + GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); + void (WINE_GLAPI *glAccum)(GLenum op, GLfloat value) DECLSPEC_HIDDEN; void (WINE_GLAPI *glAlphaFunc)(GLenum func, GLclampf ref) DECLSPEC_HIDDEN; GLboolean (WINE_GLAPI *glAreTexturesResident)(GLsizei n, const GLuint *textures, GLboolean *residences) DECLSPEC_HIDDEN; @@ -1524,68 +1718,273 @@ BOOL (WINAPI *pwglShareLists)(HGLRC, HGLRC) DECLSPEC_HIDDEN; USE_WGL_FUNC(wglMakeCurrent) \ USE_WGL_FUNC(wglShareLists) +/* OpenGL extensions. */ +typedef enum wined3d_gl_extension +{ + WINED3D_GL_EXT_NONE, -/**************************************************** - * OpenGL Extensions (EXT and ARB) - * #defines and functions pointer - ****************************************************/ + /* APPLE */ + APPLE_CLIENT_STORAGE, + APPLE_FENCE, + APPLE_FLOAT_PIXELS, + APPLE_FLUSH_BUFFER_RANGE, + APPLE_FLUSH_RENDER, + APPLE_YCBCR_422, + /* ARB */ + ARB_COLOR_BUFFER_FLOAT, + ARB_DEPTH_BUFFER_FLOAT, + ARB_DEPTH_CLAMP, + ARB_DEPTH_TEXTURE, + ARB_DRAW_BUFFERS, + ARB_FRAGMENT_PROGRAM, + ARB_FRAGMENT_SHADER, + ARB_FRAMEBUFFER_OBJECT, + ARB_GEOMETRY_SHADER4, + ARB_HALF_FLOAT_PIXEL, + ARB_HALF_FLOAT_VERTEX, + ARB_IMAGING, + ARB_MAP_BUFFER_RANGE, + ARB_MULTISAMPLE, + ARB_MULTITEXTURE, + ARB_OCCLUSION_QUERY, + ARB_PIXEL_BUFFER_OBJECT, + ARB_POINT_PARAMETERS, + ARB_POINT_SPRITE, + ARB_PROVOKING_VERTEX, + ARB_SHADER_OBJECTS, + ARB_SHADER_TEXTURE_LOD, + ARB_SHADING_LANGUAGE_100, + ARB_SYNC, + ARB_TEXTURE_BORDER_CLAMP, + ARB_TEXTURE_COMPRESSION, + ARB_TEXTURE_CUBE_MAP, + ARB_TEXTURE_ENV_ADD, + ARB_TEXTURE_ENV_COMBINE, + ARB_TEXTURE_ENV_DOT3, + ARB_TEXTURE_FLOAT, + ARB_TEXTURE_MIRRORED_REPEAT, + ARB_TEXTURE_NON_POWER_OF_TWO, + ARB_TEXTURE_RECTANGLE, + ARB_TEXTURE_RG, + ARB_VERTEX_ARRAY_BGRA, + ARB_VERTEX_BLEND, + ARB_VERTEX_BUFFER_OBJECT, + ARB_VERTEX_PROGRAM, + ARB_VERTEX_SHADER, + /* ATI */ + ATI_FRAGMENT_SHADER, + ATI_SEPARATE_STENCIL, + ATI_TEXTURE_COMPRESSION_3DC, + ATI_TEXTURE_ENV_COMBINE3, + ATI_TEXTURE_MIRROR_ONCE, + /* EXT */ + EXT_BLEND_COLOR, + EXT_BLEND_EQUATION_SEPARATE, + EXT_BLEND_FUNC_SEPARATE, + EXT_BLEND_MINMAX, + EXT_FOG_COORD, + EXT_FRAMEBUFFER_BLIT, + EXT_FRAMEBUFFER_MULTISAMPLE, + EXT_FRAMEBUFFER_OBJECT, + EXT_GPU_PROGRAM_PARAMETERS, + EXT_GPU_SHADER4, + EXT_PACKED_DEPTH_STENCIL, + EXT_PALETTED_TEXTURE, + EXT_POINT_PARAMETERS, + EXT_PROVOKING_VERTEX, + EXT_SECONDARY_COLOR, + EXT_STENCIL_TWO_SIDE, + EXT_STENCIL_WRAP, + EXT_TEXTURE3D, + EXT_TEXTURE_COMPRESSION_RGTC, + EXT_TEXTURE_COMPRESSION_S3TC, + EXT_TEXTURE_ENV_ADD, + EXT_TEXTURE_ENV_COMBINE, + EXT_TEXTURE_ENV_DOT3, + EXT_TEXTURE_FILTER_ANISOTROPIC, + EXT_TEXTURE_LOD_BIAS, + EXT_TEXTURE_SRGB, + EXT_VERTEX_ARRAY_BGRA, + /* NVIDIA */ + NV_DEPTH_CLAMP, + NV_FENCE, + NV_FOG_DISTANCE, + NV_FRAGMENT_PROGRAM, + NV_FRAGMENT_PROGRAM2, + NV_FRAGMENT_PROGRAM_OPTION, + NV_HALF_FLOAT, + NV_LIGHT_MAX_EXPONENT, + NV_REGISTER_COMBINERS, + NV_REGISTER_COMBINERS2, + NV_TEXGEN_REFLECTION, + NV_TEXTURE_ENV_COMBINE4, + NV_TEXTURE_SHADER, + NV_TEXTURE_SHADER2, + NV_VERTEX_PROGRAM, + NV_VERTEX_PROGRAM1_1, + NV_VERTEX_PROGRAM2, + NV_VERTEX_PROGRAM2_OPTION, + NV_VERTEX_PROGRAM3, + /* SGI */ + SGIS_GENERATE_MIPMAP, + SGI_VIDEO_SYNC, + /* WGL extensions */ + WGL_ARB_PBUFFER, + WGL_ARB_PIXEL_FORMAT, + WGL_WINE_PIXEL_FORMAT_PASSTHROUGH, + /* Internally used */ + WINE_NORMALIZED_TEXRECT, + + WINED3D_GL_EXT_COUNT, +} GL_SupportedExt; + +/* GL_APPLE_client_storage */ +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85b2 +#endif + +/* GL_APPLE_fence */ +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8a0a +#define GL_FENCE_APPLE 0x8a0b +#endif +typedef void (WINE_GLAPI *PGLFNGENFENCESAPPLEPROC)(GLsizei, GLuint *); +typedef void (WINE_GLAPI *PGLFNDELETEFENCESAPPLEPROC)(GLuint, const GLuint *); +typedef void (WINE_GLAPI *PGLFNSETFENCEAPPLEPROC)(GLuint); +typedef GLboolean (WINE_GLAPI *PGLFNTESTFENCEAPPLEPROC)(GLuint); +typedef void (WINE_GLAPI *PGLFNFINISHFENCEAPPLEPROC)(GLuint); +typedef GLboolean (WINE_GLAPI *PGLFNISFENCEAPPLEPROC)(GLuint); +typedef GLboolean (WINE_GLAPI *PGLFNTESTOBJECTAPPLEPROC)(GLenum, GLuint); +typedef void (WINE_GLAPI *PGLFNFINISHOBJECTAPPLEPROC)(GLenum, GLuint); + +/* GL_APPLE_float_pixels */ +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140b +#define GL_COLOR_FLOAT_APPLE 0x8a0f +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881a +#define GL_RGB_FLOAT16_APPLE 0x881b +#define GL_ALPHA_FLOAT16_APPLE 0x881c +#define GL_INTENSITY_FLOAT16_APPLE 0x881d +#define GL_LUMINANCE_FLOAT16_APPLE 0x881e +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881f +#endif + +/* GL_APPLE_flush_buffer_range */ +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8a12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8a13 +typedef void (WINE_GLAPI *PGLFNBUFFERPARAMETERIAPPLE)(GLenum target, GLenum pname, GLint param); +typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE)(GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +/* GL_APPLE_flush_render */ +typedef void (WINE_GLAPI *PGLFNFLUSHRENDERAPPLEPROC)(void); +typedef void (WINE_GLAPI *PGLFNFINISHRENDERAPPLEPROC)(void); + +/* GL_APPLE_ycbcr_422 */ +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85b9 +#define UNSIGNED_SHORT_8_8_APPLE 0x85ba +#define UNSIGNED_SHORT_8_8_REV_APPLE 0x85bb +#endif /* GL_ARB_color_buffer_float */ #ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891a +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891b +#define GL_CLAMP_READ_COLOR_ARB 0x891c +#define GL_FIXED_ONLY_ARB 0x891d #endif -typedef void (WINE_GLAPI *PGLFNCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +typedef void (WINE_GLAPI *PGLFNCLAMPCOLORARBPROC)(GLenum target, GLenum clamp); /* GL_ARB_depth_buffer_float */ #ifndef GL_ARB_depth_buffer_float #define GL_ARB_depth_buffer_float 1 -#define GL_DEPTH_COMPONENT32F 0x8cac -#define GL_DEPTH32F_STENCIL8 0x8cad -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8dad +#define GL_DEPTH_COMPONENT32F 0x8cac +#define GL_DEPTH32F_STENCIL8 0x8cad +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8dad #endif /* GL_ARB_depth_clamp */ #ifndef GL_ARB_depth_clamp #define GL_ARB_depth_clamp 1 -#define GL_DEPTH_CLAMP 0x864f +#define GL_DEPTH_CLAMP 0x864f #endif /* GL_ARB_depth_texture */ #ifndef GL_ARB_depth_texture #define GL_ARB_depth_texture 1 -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#define GL_DEPTH_COMPONENT16_ARB 0x81a5 +#define GL_DEPTH_COMPONENT24_ARB 0x81a6 +#define GL_DEPTH_COMPONENT32_ARB 0x81a7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884a +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884b #endif /* GL_ARB_draw_buffers */ #ifndef GL_ARB_draw_buffers #define GL_ARB_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882a +#define GL_DRAW_BUFFER6_ARB 0x882b +#define GL_DRAW_BUFFER7_ARB 0x882c +#define GL_DRAW_BUFFER8_ARB 0x882d +#define GL_DRAW_BUFFER9_ARB 0x882e +#define GL_DRAW_BUFFER10_ARB 0x882f +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif +typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC)(GLsizei n, const GLenum *bufs); + +/* GL_ARB_fragment_program */ +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880a +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880b +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880c +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880d +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880e +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880f +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +/* GL_ARB_fragment_shader */ +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8b30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8b49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8b8b #endif -typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); /* GL_ARB_framebuffer_object */ #ifndef GL_ARB_framebuffer_object @@ -1665,58 +2064,59 @@ typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *buf #define GL_DEPTH24_STENCIL8 0x88f0 #define GL_TEXTURE_STENCIL_SIZE 0x88f1 #endif -typedef GLboolean (WINE_GLAPI * PGLFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers); -typedef void (WINE_GLAPI * PGLFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers); -typedef void (WINE_GLAPI * PGLFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, +typedef GLboolean (WINE_GLAPI *PGLFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers); +typedef void (WINE_GLAPI *PGLFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers); +typedef void (WINE_GLAPI *PGLFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, +typedef void (WINE_GLAPI *PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (WINE_GLAPI * PGLFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); -typedef GLboolean (WINE_GLAPI * PGLFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); -typedef void (WINE_GLAPI * PGLFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); -typedef void (WINE_GLAPI * PGLFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers); -typedef void (WINE_GLAPI * PGLFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers); -typedef GLenum (WINE_GLAPI * PGLFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef GLboolean (WINE_GLAPI *PGLFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); +typedef void (WINE_GLAPI *PGLFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); +typedef void (WINE_GLAPI *PGLFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers); +typedef void (WINE_GLAPI *PGLFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers); +typedef GLenum (WINE_GLAPI *PGLFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, +typedef void (WINE_GLAPI *PGLFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (WINE_GLAPI * PGLFNGLGENERATEMIPMAPPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGLGENERATEMIPMAPPROC)(GLenum target); /* GL_ARB_geometry_shader4 */ #ifndef GL_ARB_geometry_shader4 -#define GL_GEOMETRY_SHADER_ARB 0x8dd9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8dda -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8ddb -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8ddc -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8c29 -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8ddd -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8dde -#define GL_MAX_VARYING_COMPONENTS_ARB 0x8b4b -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8ddf -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8de0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8de1 -#define GL_LINES_ADJACENCY_ARB 0x000a -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000b -#define GL_TRIANGLES_ADJACENCY_ARB 0x000c -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000d -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8da8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8da9 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8da7 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8cd4 -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_ARB_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_ARB 0x8dd9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8dda +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8ddb +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8ddc +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8c29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8ddd +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8dde +#define GL_MAX_VARYING_COMPONENTS_ARB 0x8b4b +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8ddf +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8de0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8de1 +#define GL_LINES_ADJACENCY_ARB 0x000a +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000b +#define GL_TRIANGLES_ADJACENCY_ARB 0x000c +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000d +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8da8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8da9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8da7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8cd4 +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 #endif typedef void (WINE_GLAPI *PGLFNPROGRAMPARAMETERIARBPROC)(GLuint program, GLenum pname, GLint value); typedef void (WINE_GLAPI *PGLFNFRAMEBUFFERTEXTUREARBPROC)(GLenum target, GLenum attachment, @@ -1726,380 +2126,1067 @@ typedef void (WINE_GLAPI *PGLFNFRAMEBUFFERTEXTURELAYERARBPROC)(GLenum target, GL typedef void (WINE_GLAPI *PGLFNFRAMEBUFFERTEXTUREFACEARBPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +/* GL_ARB_half_float_pixel */ +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#define GL_HALF_FLOAT_ARB 0x140b +#endif + +/* GL_ARB_half_float_vertex */ +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +/* No _ARB, see extension spec */ +#define GL_HALF_FLOAT 0x140b +#endif + /* GL_ARB_imaging */ #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800a +#define GL_FUNC_REVERSE_SUBTRACT 0x800b +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801a +#define GL_MAX_CONVOLUTION_HEIGHT 0x801b +#define GL_POST_CONVOLUTION_RED_SCALE 0x801d +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801f +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801e +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801f +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802a +#define GL_HISTOGRAM_ALPHA_SIZE 0x802b +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802c +#define GL_HISTOGRAM_SINK 0x802d +#define GL_MINMAX 0x802e +#define GL_MINMAX_FORMAT 0x802f +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80b1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80b2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80b3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80b4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80b5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80b6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80b7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80b8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80b9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80ba +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80bb +#define GL_COLOR_TABLE 0x80d0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80d1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80d2 +#define GL_PROXY_COLOR_TABLE 0x80d3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80d4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80d5 +#define GL_COLOR_TABLE_SCALE 0x80d6 +#define GL_COLOR_TABLE_BIAS 0x80d7 +#define GL_COLOR_TABLE_FORMAT 0x80d8 +#define GL_COLOR_TABLE_WIDTH 0x80d9 +#define GL_COLOR_TABLE_RED_SIZE 0x80da +#define GL_COLOR_TABLE_GREEN_SIZE 0x80db +#define GL_COLOR_TABLE_BLUE_SIZE 0x80dc +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80dd +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80de +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80df +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 #endif -typedef void (WINE_GLAPI *PGLFNBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONPROC) (GLenum mode); +typedef void (WINE_GLAPI *PGLFNBLENDCOLORPROC)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONPROC)(GLenum mode); + +/* GL_ARB_map_buffer_range */ +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif +typedef GLvoid *(WINE_GLAPI *PGLFNMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length); + +/* GL_ARB_multisample */ +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809d +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809e +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809f +#define GL_SAMPLE_COVERAGE_ARB 0x80a0 +#define GL_SAMPLE_BUFFERS_ARB 0x80a8 +#define GL_SAMPLES_ARB 0x80a9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80aa +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80ab +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif +typedef void (WINE_GLAPI *WINED3D_PFNGLSAMPLECOVERAGEARBPROC)(GLclampf value, GLboolean invert); + /* GL_ARB_multitexture */ #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#define GL_TEXTURE0_ARB 0x84c0 +#define GL_TEXTURE1_ARB 0x84c1 +#define GL_TEXTURE2_ARB 0x84c2 +#define GL_TEXTURE3_ARB 0x84c3 +#define GL_TEXTURE4_ARB 0x84c4 +#define GL_TEXTURE5_ARB 0x84c5 +#define GL_TEXTURE6_ARB 0x84c6 +#define GL_TEXTURE7_ARB 0x84c7 +#define GL_TEXTURE8_ARB 0x84c8 +#define GL_TEXTURE9_ARB 0x84c9 +#define GL_TEXTURE10_ARB 0x84ca +#define GL_TEXTURE11_ARB 0x84cb +#define GL_TEXTURE12_ARB 0x84cc +#define GL_TEXTURE13_ARB 0x84cd +#define GL_TEXTURE14_ARB 0x84ce +#define GL_TEXTURE15_ARB 0x84cf +#define GL_TEXTURE16_ARB 0x84d0 +#define GL_TEXTURE17_ARB 0x84d1 +#define GL_TEXTURE18_ARB 0x84d2 +#define GL_TEXTURE19_ARB 0x84d3 +#define GL_TEXTURE20_ARB 0x84d4 +#define GL_TEXTURE21_ARB 0x84d5 +#define GL_TEXTURE22_ARB 0x84d6 +#define GL_TEXTURE23_ARB 0x84d7 +#define GL_TEXTURE24_ARB 0x84d8 +#define GL_TEXTURE25_ARB 0x84d9 +#define GL_TEXTURE26_ARB 0x84da +#define GL_TEXTURE27_ARB 0x84db +#define GL_TEXTURE28_ARB 0x84dc +#define GL_TEXTURE29_ARB 0x84dd +#define GL_TEXTURE30_ARB 0x84de +#define GL_TEXTURE31_ARB 0x84df +#define GL_ACTIVE_TEXTURE_ARB 0x84e0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84e1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84e2 #endif -typedef void (WINE_GLAPI *WINED3D_PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (WINE_GLAPI *WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLACTIVETEXTUREARBPROC)(GLenum texture); +typedef void (WINE_GLAPI *WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC)(GLenum texture); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FARBPROC)(GLenum target, GLfloat s); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FVARBPROC)(GLenum target, const GLfloat *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FARBPROC)(GLenum target, GLfloat s, GLfloat t); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FVARBPROC)(GLenum target, const GLfloat *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FARBPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FVARBPROC)(GLenum target, const GLfloat *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FARBPROC)(GLenum target, + GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FVARBPROC)(GLenum target, const GLfloat *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2SVARBPROC)(GLenum target, const GLshort *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4SVARBPROC)(GLenum target, const GLshort *v); -/* GL_ARB_texture_cube_map */ -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +/* GL_ARB_occlusion_query */ +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#endif +typedef void (WINE_GLAPI *PGLFNGENQUERIESARBPROC)(GLsizei n, GLuint *queries); +typedef void (WINE_GLAPI *PGLFNDELETEQUERIESARBPROC)(GLsizei n, const GLuint *queries); +typedef GLboolean (WINE_GLAPI *PGLFNISQUERYARBPROC)(GLuint query); +typedef void (WINE_GLAPI *PGLFNBEGINQUERYARBPROC)(GLenum target, GLuint query); +typedef void (WINE_GLAPI *PGLFNENDQUERYARBPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGETQUERYIVARBPROC)(GLenum target, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETQUERYOBJECTIVARBPROC)(GLuint query, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETQUERYOBJECTUIVARBPROC)(GLuint query, GLenum pname, GLuint *params); + +/* GL_ARB_pixel_buffer_object */ +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88eb +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88ec +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ed +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88ef #endif /* GL_ARB_point_parameters */ #ifndef GL_ARB_point_parameters #define GL_ARB_point_parameters 1 -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif +typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFARBPROC)(GLenum pname, GLfloat param); +typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFVARBPROC)(GLenum pname, const GLfloat *params); + +/* GL_ARB_point_sprite */ +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 #endif -typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); /* GL_ARB_provoking_vertex */ #ifndef GL_ARB_provoking_vertex #define GL_ARB_provoking_vertex 1 -#define GL_FIRST_VERTEX_CONVENTION 0x8e4d -#define GL_LAST_VERTEX_CONVENTION 0x8e4e -#define GL_PROVOKING_VERTEX 0x8e4f -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8e4c +#define GL_FIRST_VERTEX_CONVENTION 0x8e4d +#define GL_LAST_VERTEX_CONVENTION 0x8e4e +#define GL_PROVOKING_VERTEX 0x8e4f +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8e4c +#endif +typedef void (WINE_GLAPI *PGLFNGLPROVOKINGVERTEXPROC)(GLenum mode); + +/* GL_ARB_shader_objects */ +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +typedef char GLcharARB; +typedef unsigned int GLhandleARB; +#define GL_PROGRAM_OBJECT_ARB 0x8b40 +#define GL_OBJECT_TYPE_ARB 0x8b4e +#define GL_OBJECT_SUBTYPE_ARB 0x8b4f +#define GL_OBJECT_DELETE_STATUS_ARB 0x8b80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8b81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8b82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8b83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8b84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8b85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8b86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8b87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8b88 +#define GL_SHADER_OBJECT_ARB 0x8b48 +#define GL_FLOAT_VEC2_ARB 0x8b50 +#define GL_FLOAT_VEC3_ARB 0x8b51 +#define GL_FLOAT_VEC4_ARB 0x8b52 +#define GL_INT_VEC2_ARB 0x8b53 +#define GL_INT_VEC3_ARB 0x8b54 +#define GL_INT_VEC4_ARB 0x8b55 +#define GL_BOOL_ARB 0x8b56 +#define GL_BOOL_VEC2_ARB 0x8b57 +#define GL_BOOL_VEC3_ARB 0x8b58 +#define GL_BOOL_VEC4_ARB 0x8b59 +#define GL_FLOAT_MAT2_ARB 0x8b5a +#define GL_FLOAT_MAT3_ARB 0x8b5b +#define GL_FLOAT_MAT4_ARB 0x8b5c +#define GL_SAMPLER_1D_ARB 0x8b5d +#define GL_SAMPLER_2D_ARB 0x8b5e +#define GL_SAMPLER_3D_ARB 0x8b5f +#define GL_SAMPLER_CUBE_ARB 0x8b60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8b61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8b62 +#define GL_SAMPLER_2D_RECT_ARB 0x8b63 +#define GL_SAMPELR_2D_RECT_SHADOW_ARB 0x8b64 +#endif + +/* GL_ARB_shading_language_100 */ +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8b8c +#endif + +/* GL_ARB_sync */ +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xffffffffffffffffULL +#define GL_ALREADY_SIGNALED 0x911a +#define GL_TIMEOUT_EXPIRED 0x911b +#define GL_CONDITION_SATISFIED 0x911c +#define GL_WAIT_FAILED 0x911d +#endif +typedef GLsync (WINE_GLAPI *PGLFNFENCESYNCPROC)(GLenum condition, GLbitfield flags); +typedef GLboolean (WINE_GLAPI *PGLFNISSYNCPROC)(GLsync sync); +typedef GLvoid (WINE_GLAPI *PGLFNDELETESYNCPROC)(GLsync sync); +typedef GLenum (WINE_GLAPI *PGLFNCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef GLvoid (WINE_GLAPI *PGLFNWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef GLvoid (WINE_GLAPI *PGLFNGETINTEGER64VPROC)(GLenum pname, GLint64 *params); +typedef GLvoid (WINE_GLAPI *PGLFNGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei bufsize, + GLsizei *length, GLint *values); + +/* GL_ARB_texture_border_clamp */ +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812d +#endif + +/* GL_ARB_texture_cube_map */ +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851a +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851b +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851c +#endif + +/* GL_ARB_texture_env_dot3 */ +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86ae +#define GL_DOT3_RGBA_ARB 0x86af +#endif + +/* GL_ARB_texture_float */ +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_RGBA16F_ARB 0x881a +#define GL_RGB16F_ARB 0x881b +#endif + +/* GL_ARB_texture_mirrored_repeat */ +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +/* GL_ARB_texture_rectangle */ +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84f5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84f6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84f7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84f8 +#define GL_SAMPLER_2D_RECT_ARB 0x8b63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8b64 +#endif + +/* GL_ARB_texture_rg */ +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822a +#define GL_RG8 0x822b +#define GL_RG16 0x822c +#define GL_R16F 0x822d +#define GL_R32F 0x822e +#define GL_RG16F 0x822f +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823a +#define GL_RG32I 0x823b +#define GL_RG32UI 0x823c #endif -typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXPROC)(GLenum mode); /* GL_ARB_vertex_blend */ #ifndef GL_ARB_vertex_blend #define GL_ARB_vertex_blend 1 -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F +#define GL_MAX_VERTEX_UNITS_ARB 0x86a4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86a5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86a6 +#define GL_VERTEX_BLEND_ARB 0x86a7 +#define GL_CURRENT_WEIGHT_ARB 0x86a8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86a9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86aa +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86ab +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86ac +#define GL_WEIGHT_ARRAY_ARB 0x86ad +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850a +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872a +#define GL_MODELVIEW11_ARB 0x872b +#define GL_MODELVIEW12_ARB 0x872c +#define GL_MODELVIEW13_ARB 0x872d +#define GL_MODELVIEW14_ARB 0x872e +#define GL_MODELVIEW15_ARB 0x872f +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873a +#define GL_MODELVIEW27_ARB 0x873b +#define GL_MODELVIEW28_ARB 0x873c +#define GL_MODELVIEW29_ARB 0x873d +#define GL_MODELVIEW30_ARB 0x873e +#define GL_MODELVIEW31_ARB 0x873f #endif -typedef void (WINE_GLAPI * PGLFNGLWEIGHTPOINTERARB) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTBV) (GLint size, const GLbyte *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTSV) (GLint size, const GLshort *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTIV) (GLint size, const GLint *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTFV) (GLint size, const GLfloat *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTDV) (GLint size, const GLdouble *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTUBV) (GLint size, const GLubyte *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTUSV) (GLint size, const GLushort *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTUIV) (GLint size, const GLuint *weights); -typedef void (WINE_GLAPI * PGLFNGLVERTEXBLENDARB) (GLint count); -/* GL_ARB_pixel_buffer_object */ -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -/* GL_EXT_framebuffer_object */ -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +typedef void (WINE_GLAPI *PGLFNGLWEIGHTPOINTERARB)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTBV)(GLint size, const GLbyte *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTSV)(GLint size, const GLshort *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTIV)(GLint size, const GLint *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTFV)(GLint size, const GLfloat *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTDV)(GLint size, const GLdouble *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTUBV)(GLint size, const GLubyte *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTUSV)(GLint size, const GLushort *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTUIV)(GLint size, const GLuint *weights); +typedef void (WINE_GLAPI *PGLFNGLVERTEXBLENDARB)(GLint count); +/* GL_ARB_vertex_buffer_object */ +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889a +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889b +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889c +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889d +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889e +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889f +#define GL_READ_ONLY_ARB 0x88b8 +#define GL_WRITE_ONLY_ARB 0x88b9 +#define GL_READ_WRITE_ARB 0x88ba +#define GL_BUFFER_ACCESS_ARB 0x88bb +#define GL_BUFFER_MAPPED_ARB 0x88bc +#define GL_BUFFER_MAP_POINTER_ARB 0x88bd +#define GL_STREAM_DRAW_ARB 0x88e0 +#define GL_STREAM_READ_ARB 0x88e1 +#define GL_STREAM_COPY_ARB 0x88e2 +#define GL_STATIC_DRAW_ARB 0x88e4 +#define GL_STATIC_READ_ARB 0x88e5 +#define GL_STATIC_COPY_ARB 0x88e6 +#define GL_DYNAMIC_DRAW_ARB 0x88e8 +#define GL_DYNAMIC_READ_ARB 0x88e9 +#define GL_DYNAMIC_COPY_ARB 0x88ea #endif -typedef GLboolean (WINE_GLAPI * PGLFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers); -typedef void (WINE_GLAPI * PGLFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers); -typedef void (WINE_GLAPI * PGLFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (WINE_GLAPI * PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params); -typedef GLboolean (WINE_GLAPI * PGLFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer); -typedef void (WINE_GLAPI * PGLFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer); -typedef void (WINE_GLAPI * PGLFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers); -typedef void (WINE_GLAPI * PGLFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers); -typedef GLenum (WINE_GLAPI * PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGLGENERATEMIPMAPEXTPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNBINDBUFFERARBPROC)(GLenum target, GLuint buffer); +typedef void (WINE_GLAPI *PGLFNDELETEBUFFERSARBPROC)(GLsizei n, const GLuint *buffers); +typedef void (WINE_GLAPI *PGLFNGENBUFFERSARBPROC)(GLsizei n, GLuint *buffers); +typedef GLboolean (WINE_GLAPI *PGLFNISBUFFERARBPROC)(GLuint buffer); +typedef void (WINE_GLAPI *PGLFNBUFFERDATAARBPROC)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (WINE_GLAPI *PGLFNBUFFERSUBDATAARBPROC)(GLenum target, + GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNGETBUFFERSUBDATAARBPROC)(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (WINE_GLAPI *PGLFNMAPBUFFERARBPROC)(GLenum target, GLenum access); +typedef GLboolean (WINE_GLAPI *PGLFNUNMAPBUFFERARBPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGETBUFFERPARAMETERIVARBPROC)(GLenum target, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETBUFFERPOINTERVARBPROC)(GLenum target, GLenum pname, GLvoid* *params); + +/* GL_ARB_vertex_program */ +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886a +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88a0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88a1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88a2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88a3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88a4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88a5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88a6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88a7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88a8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88a9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88aa +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88ab +#define GL_PROGRAM_ATTRIBS_ARB 0x88ac +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88ad +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88ae +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88af +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88b0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88b1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88b2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88b3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88b4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88b5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88b6 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864b +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88b7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862f +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862e +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88c0 +#define GL_MATRIX1_ARB 0x88c1 +#define GL_MATRIX2_ARB 0x88c2 +#define GL_MATRIX3_ARB 0x88c3 +#define GL_MATRIX4_ARB 0x88c4 +#define GL_MATRIX5_ARB 0x88c5 +#define GL_MATRIX6_ARB 0x88c6 +#define GL_MATRIX7_ARB 0x88c7 +#define GL_MATRIX8_ARB 0x88c8 +#define GL_MATRIX9_ARB 0x88c9 +#define GL_MATRIX10_ARB 0x88ca +#define GL_MATRIX11_ARB 0x88cb +#define GL_MATRIX12_ARB 0x88cc +#define GL_MATRIX13_ARB 0x88cd +#define GL_MATRIX14_ARB 0x88ce +#define GL_MATRIX15_ARB 0x88cf +#define GL_MATRIX16_ARB 0x88d0 +#define GL_MATRIX17_ARB 0x88d1 +#define GL_MATRIX18_ARB 0x88d2 +#define GL_MATRIX19_ARB 0x88d3 +#define GL_MATRIX20_ARB 0x88d4 +#define GL_MATRIX21_ARB 0x88d5 +#define GL_MATRIX22_ARB 0x88d6 +#define GL_MATRIX23_ARB 0x88d7 +#define GL_MATRIX24_ARB 0x88d8 +#define GL_MATRIX25_ARB 0x88d9 +#define GL_MATRIX26_ARB 0x88da +#define GL_MATRIX27_ARB 0x88db +#define GL_MATRIX28_ARB 0x88dc +#define GL_MATRIX29_ARB 0x88dd +#define GL_MATRIX30_ARB 0x88de +#define GL_MATRIX31_ARB 0x88df +#endif +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DARBPROC)(GLuint index, GLdouble x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DVARBPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FARBPROC)(GLuint index, GLfloat x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FVARBPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SARBPROC)(GLuint index, GLshort x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DARBPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DVARBPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FARBPROC)(GLuint index, GLfloat x, GLfloat y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FVARBPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SARBPROC)(GLuint index, GLshort x, GLshort y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DVARBPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FVARBPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NBVARBPROC)(GLuint index, const GLbyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NIVARBPROC)(GLuint index, const GLint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NSVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBARBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBVARBPROC)(GLuint index, const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUIVARBPROC)(GLuint index, const GLuint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUSVARBPROC)(GLuint index, const GLushort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4BVARBPROC)(GLuint index, const GLbyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DVARBPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FVARBPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4IVARBPROC)(GLuint index, const GLint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UBVARBPROC)(GLuint index, const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UIVARBPROC)(GLuint index, const GLuint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4USVARBPROC)(GLuint index, const GLushort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBPOINTERARBPROC)(GLuint index, GLint size, + GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (WINE_GLAPI *PGLFNENABLEVERTEXATTRIBARRAYARBPROC)(GLuint index); +typedef void (WINE_GLAPI *PGLFNDISABLEVERTEXATTRIBARRAYARBPROC)(GLuint index); +typedef void (WINE_GLAPI *PGLFNPROGRAMSTRINGARBPROC)(GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (WINE_GLAPI *PGLFNBINDPROGRAMARBPROC)(GLenum target, GLuint program); +typedef void (WINE_GLAPI *PGLFNDELETEPROGRAMSARBPROC)(GLsizei n, const GLuint *programs); +typedef void (WINE_GLAPI *PGLFNGENPROGRAMSARBPROC)(GLsizei n, GLuint *programs); +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4DARBPROC)(GLenum target, + GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble *params); +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4FARBPROC)(GLenum target, + GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4DARBPROC)(GLenum target, + GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble *params); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4FARBPROC)(GLenum target, + GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMENVPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMENVPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMLOCALPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMLOCALPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMIVARBPROC)(GLenum target, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMSTRINGARBPROC)(GLenum target, GLenum pname, GLvoid *string); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBDVARBPROC)(GLuint index, GLenum pname, GLdouble *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBFVARBPROC)(GLuint index, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBIVARBPROC)(GLuint index, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBPOINTERVARBPROC)(GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (WINE_GLAPI *PGLFNISPROGRAMARBPROC)(GLuint program); + +/* GL_ARB_vertex_shader */ +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8b31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8b4a +#define GL_MAX_VARYING_FLOATS_ARB 0x8b4b +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8b4c +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8b4d +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8b89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8b8a +#endif +typedef void (WINE_GLAPI *WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC)(GLhandleARB obj, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC)(GLhandleARB obj, GLenum pname, GLfloat *params); +typedef GLint (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB *name); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETACTIVEUNIFORMARBPROC)(GLhandleARB programObj, GLuint index, + GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1IARBPROC)(GLint location, GLint v0); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2IARBPROC)(GLint location, GLint v0, GLint v1); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3IARBPROC)(GLint location, GLint v0, GLint v1, GLint v2); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4IARBPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1FARBPROC)(GLint location, GLfloat v0); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2FARBPROC)(GLint location, GLfloat v0, GLfloat v1); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3FARBPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4FARBPROC)(GLint location, + GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1IVARBPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2IVARBPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3IVARBPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4IVARBPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1FVARBPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2FVARBPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3FVARBPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4FVARBPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMFVARBPROC)(GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMIVARBPROC)(GLhandleARB programObj, GLint location, GLint *params); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETINFOLOGARBPROC)(GLhandleARB obj, + GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (WINE_GLAPI *WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC)(GLhandleARB programObj); +typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLCREATESHADEROBJECTARBPROC)(GLenum shaderType); +typedef void (WINE_GLAPI *WINED3D_PFNGLSHADERSOURCEARBPROC)(GLhandleARB shaderObj, + GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (WINE_GLAPI *WINED3D_PFNGLCOMPILESHADERARBPROC)(GLhandleARB shaderObj); +typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC)(void); +typedef void (WINE_GLAPI *WINED3D_PFNGLATTACHOBJECTARBPROC)(GLhandleARB containerObj, GLhandleARB obj); +typedef void (WINE_GLAPI *WINED3D_PFNGLLINKPROGRAMARBPROC)(GLhandleARB programObj); +typedef void (WINE_GLAPI *WINED3D_PFNGLDETACHOBJECTARBPROC)(GLhandleARB containerObj, GLhandleARB attachedObj); +typedef void (WINE_GLAPI *WINED3D_PFNGLDELETEOBJECTARBPROC)(GLhandleARB obj); +typedef void (WINE_GLAPI *WINED3D_PFNGLVALIDATEPROGRAMARBPROC)(GLhandleARB programObj); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC)(GLhandleARB containerObj, + GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLGETHANDLEARBPROC)(GLenum pname); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETSHADERSOURCEARBPROC)(GLhandleARB obj, + GLsizei maxLength, GLsizei *length, GLcharARB *source); +typedef void (WINE_GLAPI *WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC)(GLhandleARB programObj, + GLuint index, const GLcharARB *name); +typedef GLint (WINE_GLAPI *WINED3D_PFNGLGETATTRIBLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB *name); + +/* GL_ATI_fragment_shader */ +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896a +#define GL_CND0_ATI 0x896b +#define GL_DOT2_ADD_ATI 0x896c +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896d +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif +typedef GLuint (WINE_GLAPI *PGLFNGENFRAGMENTSHADERSATI)(GLuint range); +typedef void (WINE_GLAPI *PGLFNBINDFRAGMENTSHADERATI)(GLuint id); +typedef void (WINE_GLAPI *PGLFNDELETEFRAGMENTSHADERATI)(GLuint id); +typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI)(void); +typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI)(void); +typedef void (WINE_GLAPI *PGLFNPASSTEXCOORDATI)(GLuint dst, GLuint coord, GLenum swizzle); +typedef void (WINE_GLAPI *PGLFNSAMPLEMAPATI)(GLuint dst, GLuint interp, GLenum swizzle); +typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP1ATI)(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP2ATI)(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod); +typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP3ATI)(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, + GLuint arg3Mod); +typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP1ATI)(GLenum op, GLuint dst, GLuint dstMod, + GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP2ATI)(GLenum op, GLuint dst, GLuint dstMod, + GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, + GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP3ATI)(GLenum op, GLuint dst, GLuint dstMod, + GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, + GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, + GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI)(GLuint dst, const GLfloat *value); + +/* GL_ATI_separate_stencil */ +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif +typedef void (WINE_GLAPI *PGLFNSTENCILOPSEPARATEATIPROC)(GLenum, GLenum, GLenum, GLenum); +typedef void (WINE_GLAPI *PGLFNSTENCILFUNCSEPARATEATIPROC)(GLenum, GLenum, GLint, GLuint); + +/* GL_ATI_texture_compression_3dc */ +#ifndef GL_ATI_texture_compression_3dc +#define GL_ATI_texture_compression_3dc 1 +#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 +#endif + +/* GL_ATI_texture_env_combine3 */ +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +/* #define ONE */ +/* #define ZERO */ +#endif + +/* GL_ATI_texture_mirror_once */ +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +/* GL_EXT_blend_equation_separate */ +typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONSEPARATEEXTPROC)(GLenum modeRGB, GLenum modeAlpha); + +/* GL_EXT_blend_func_separate */ +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80c8 +#define GL_BLEND_SRC_RGB_EXT 0x80c9 +#define GL_BLEND_DST_ALPHA_EXT 0x80ca +#define GL_BLEND_SRC_ALPHA_EXT 0x80cb +#endif +typedef void (WINE_GLAPI *PGLFNBLENDFUNCSEPARATEEXTPROC)(GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorAlpha, GLenum dfactorAlpha); + +/* GL_EXT_fog_coord */ +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDFEXTPROC)(GLfloat coord); +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDFVEXTPROC)(const GLfloat *coord); +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDDEXTPROC)(GLdouble coord); +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDDVEXTPROC)(const GLdouble *coord); +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDPOINTEREXTPROC)(GLenum type, GLsizei stride, GLvoid *data); + /* GL_EXT_framebuffer_blit */ #ifndef GL_EXT_framebuffer_blit #define GL_EXT_framebuffer_blit 1 -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#define GL_READ_FRAMEBUFFER_EXT 0x8ca8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8ca9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8ca6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8caa #endif -typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (WINE_GLAPI *PGLFNGLBLITFRAMEBUFFEREXTPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); /* GL_EXT_framebuffer_multisample */ #ifndef GL_EXT_framebuffer_multisample #define GL_EXT_framebuffer_multisample 1 -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8cab -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8d56 -#define GL_MAX_SAMPLES_EXT 0x8d57 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8cab +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8d56 +#define GL_MAX_SAMPLES_EXT 0x8d57 #endif -typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (WINE_GLAPI *PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, + GLenum internalformat, GLsizei width, GLsizei height); + +/* GL_EXT_framebuffer_object */ +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_FRAMEBUFFER_EXT 0x8d40 +#define GL_RENDERBUFFER_EXT 0x8d41 +#define GL_STENCIL_INDEX1_EXT 0x8d46 +#define GL_STENCIL_INDEX4_EXT 0x8d47 +#define GL_STENCIL_INDEX8_EXT 0x8d48 +#define GL_STENCIL_INDEX16_EXT 0x8d49 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8d42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8d43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8d44 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8d50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8d51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8d52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8d53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8d54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8d55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8cd0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8cd1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8cd2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8cd3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8cd4 +#define GL_COLOR_ATTACHMENT0_EXT 0x8ce0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8ce1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8ce2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8ce3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8ce4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8ce5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8ce6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8ce7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8ce8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8ce9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8cea +#define GL_COLOR_ATTACHMENT11_EXT 0x8ceb +#define GL_COLOR_ATTACHMENT12_EXT 0x8cec +#define GL_COLOR_ATTACHMENT13_EXT 0x8ced +#define GL_COLOR_ATTACHMENT14_EXT 0x8cee +#define GL_COLOR_ATTACHMENT15_EXT 0x8cef +#define GL_DEPTH_ATTACHMENT_EXT 0x8d00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8d20 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8cd5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8cd6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8cd7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8cd9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8cda +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8cdb +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8cdc +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8cdd +#define GL_FRAMEBUFFER_BINDING_EXT 0x8ca6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8ca7 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8cdF +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84e8 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#endif +typedef GLboolean (WINE_GLAPI *PGLFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers); +typedef void (WINE_GLAPI *PGLFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers); +typedef void (WINE_GLAPI *PGLFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, + GLenum internalformat, GLsizei width, GLsizei height); +typedef void (WINE_GLAPI *PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params); +typedef GLboolean (WINE_GLAPI *PGLFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer); +typedef void (WINE_GLAPI *PGLFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer); +typedef void (WINE_GLAPI *PGLFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers); +typedef void (WINE_GLAPI *PGLFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers); +typedef GLenum (WINE_GLAPI *PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, + GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, + GLenum attachment, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGLGENERATEMIPMAPEXTPROC)(GLenum target); + +/* GL_EXT_gpu_program_parameters */ +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETERS4FVEXTPROC)(GLenum target, + GLuint index, GLsizei count, const float *params); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC)(GLenum target, + GLuint index, GLsizei count, const float *params); +#endif + +/* GL_EXT_gpu_shader4 */ +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88fd +#define GL_SAMPLER_1D_ARRAY_EXT 0x8dc0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8dc1 +#define GL_SAMPLER_BUFFER_EXT 0x8dc2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8dc3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8dc4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8dc5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8dc6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8dc7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8dc8 +#define GL_INT_SAMPLER_1D_EXT 0x8dc9 +#define GL_INT_SAMPLER_2D_EXT 0x8dca +#define GL_INT_SAMPLER_3D_EXT 0x8dcb +#define GL_INT_SAMPLER_CUBE_EXT 0x8dcc +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8dcd +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8dce +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8dcf +#define GL_INT_SAMPLER_BUFFER_EXT 0x8dd0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8dd1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8dd2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8dd3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8dd4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8dd5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8dd6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8dd7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8dd8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +#endif +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1IEXTPROC)(GLuint index, GLint x); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2IEXTPROC)(GLuint index, GLint x, GLint y); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3IEXTPROC)(GLuint index, GLint x, GLint y, GLint z); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4IEXTPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1UIEXTPROC)(GLuint index, GLuint x); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2UIEXTPROC)(GLuint index, GLuint x, GLuint y); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3UIEXTPROC)(GLuint index, GLuint x, GLuint y, GLuint z); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UIEXTPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1IVEXTPROC)(GLuint index, const GLint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2IVEXTPROC)(GLuint index, const GLint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3IVEXTPROC)(GLuint index, const GLint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4IVEXTPROC)(GLuint index, const GLint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1UIVEXTPROC)(GLuint index, const GLuint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2UIVEXTPROC)(GLuint index, const GLuint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3UIVEXTPROC)(GLuint index, const GLuint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UIVEXTPROC)(GLuint index, const GLuint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4BVEXTPROC)(GLuint index, const GLbyte *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4SVEXTPROC)(GLuint index, const GLshort *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UBVEXTPROC)(GLuint index, const GLubyte *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4USVEXTPROC)(GLuint index, const GLushort *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBIPOINTEREXTPROC)(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *pointer); +typedef GLvoid (WINE_GLAPI *PGLFNGETVERTEXATTRIBIIVEXTPROC)(GLuint index, GLenum pname, GLint *params); +typedef GLvoid (WINE_GLAPI *PGLFNGETVERTEXATTRIBIUIVEXTPROC)(GLuint index, GLenum pname, GLuint *params); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM1UIEXTPROC)(GLint location, GLuint v0); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM2UIEXTPROC)(GLint location, GLuint v0, GLuint v1); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM3UIEXTPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM4UIEXTPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM1UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM2UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM3UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM4UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value); +typedef GLvoid (WINE_GLAPI *PGLFNGETUNIFORMUIVEXTPROC)(GLuint program, GLint location, const GLuint *params); +typedef GLvoid (WINE_GLAPI *PGLFNBINDFRAGDATALOCATIONEXTPROC)(GLuint program, GLuint color_number, const GLchar *name); +typedef GLint (WINE_GLAPI *PGLFNGETFRAGDATALOCATIONEXTPROC)(GLuint program, const GLchar *name); /* GL_EXT_packed_depth_stencil */ #ifndef GL_EXT_packed_depth_stencil #define GL_EXT_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_EXT 0x84f9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84fa -#define GL_DEPTH24_STENCIL8_EXT 0x88f0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88f1 +#define GL_DEPTH_STENCIL_EXT 0x84f9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84fa +#define GL_DEPTH24_STENCIL8_EXT 0x88f0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88f1 #endif -/* GL_EXT_secondary_color */ -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); /* GL_EXT_paletted_texture */ #ifndef GL_EXT_paletted_texture #define GL_EXT_paletted_texture 1 -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#define GL_COLOR_INDEX1_EXT 0x80e2 +#define GL_COLOR_INDEX2_EXT 0x80e3 +#define GL_COLOR_INDEX4_EXT 0x80e4 +#define GL_COLOR_INDEX8_EXT 0x80e5 +#define GL_COLOR_INDEX12_EXT 0x80e6 +#define GL_COLOR_INDEX16_EXT 0x80e7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ed #endif -typedef void (WINE_GLAPI * PGLFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (WINE_GLAPI *PGLFNGLCOLORTABLEEXTPROC)(GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, const GLvoid *table); + /* GL_EXT_point_parameters */ #ifndef GL_EXT_point_parameters #define GL_EXT_point_parameters 1 -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 #endif -typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFEXTPROC)(GLenum pname, GLfloat param); +typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFVEXTPROC)(GLenum pname, const GLfloat *params); /* GL_EXT_provoking_vertex */ #ifndef GL_EXT_provoking_vertex @@ -2109,2025 +3196,1304 @@ typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const #define GL_PROVOKING_VERTEX_EXT 0x8e4f #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8e4c #endif -typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXEXTPROC)(GLenum mode); +typedef void (WINE_GLAPI *PGLFNGLPROVOKINGVERTEXEXTPROC)(GLenum mode); + +/* GL_EXT_secondary_color */ +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845a +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845b +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845c +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845d +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845e +#endif +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3FEXTPROC)(GLfloat red, GLfloat green, GLfloat blue); +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3FVEXTPROC)(const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3UBEXTPROC)(GLubyte red, GLubyte green, GLubyte blue); +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3UBVEXTPROC)(const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLORPOINTEREXTPROC)(GLint size, GLenum type, + GLsizei stride, const GLvoid *pointer); + +/* GL_EXT_stencil_two_side */ +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif +typedef void (WINE_GLAPI *PGLFNACTIVESTENCILFACEEXTPROC)(GLenum face); + +/* GL_EXT_stencil_wrap */ +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_texture3D */ #ifndef GL_EXT_texture3D #define GL_EXT_texture3D 1 -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#define GL_PACK_SKIP_IMAGES_EXT 0x806b +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806c +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806d +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806e +#define GL_TEXTURE_3D_EXT 0x806f +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 #endif -typedef void (WINE_GLAPI * PGLFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (WINE_GLAPI * PGLFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -/* GL_EXT_texture_env_combine */ -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_SUBTRACT_EXT 0x84E7 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE3_RGB_EXT 0x8583 -#define GL_SOURCE4_RGB_EXT 0x8584 -#define GL_SOURCE5_RGB_EXT 0x8585 -#define GL_SOURCE6_RGB_EXT 0x8586 -#define GL_SOURCE7_RGB_EXT 0x8587 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_SOURCE3_ALPHA_EXT 0x858B -#define GL_SOURCE4_ALPHA_EXT 0x858C -#define GL_SOURCE5_ALPHA_EXT 0x858D -#define GL_SOURCE6_ALPHA_EXT 0x858E -#define GL_SOURCE7_ALPHA_EXT 0x858F -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND3_RGB_EXT 0x8593 -#define GL_OPERAND4_RGB_EXT 0x8594 -#define GL_OPERAND5_RGB_EXT 0x8595 -#define GL_OPERAND6_RGB_EXT 0x8596 -#define GL_OPERAND7_RGB_EXT 0x8597 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#define GL_OPERAND3_ALPHA_EXT 0x859B -#define GL_OPERAND4_ALPHA_EXT 0x859C -#define GL_OPERAND5_ALPHA_EXT 0x859D -#define GL_OPERAND6_ALPHA_EXT 0x859E -#define GL_OPERAND7_ALPHA_EXT 0x859F -#endif -/* GL_EXT_texture_env_dot3 */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif -/* GL_EXT_texture_lod_bias */ -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif -/* GL_ARB_texture_border_clamp */ -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif -/* GL_ARB_texture_mirrored_repeat (full support GL1.4) */ -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif -/* GL_ATI_texture_mirror_once */ -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif -/* GL_ARB_texture_env_dot3 */ -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif -/* GL_EXT_texture_env_dot3 */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif -/* GL_EXT_texture_sRGB */ -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif -/* GL_ARB_texture_float */ -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#endif -/* GL_ARB_texture_rg */ -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif -/* GL_EXT_texture_swizzle */ -#ifndef GL_EXT_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif -/* GL_ARB_half_float_pixel */ -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif -/* GL_ARB_vertex_program */ -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (WINE_GLAPI * PGLFNENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (WINE_GLAPI * PGLFNDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (WINE_GLAPI * PGLFNPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (WINE_GLAPI * PGLFNBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (WINE_GLAPI * PGLFNDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (WINE_GLAPI * PGLFNGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (WINE_GLAPI * PGLFNISPROGRAMARBPROC) (GLuint program); -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif -/* GL_ARB_multisample */ -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif -typedef void (WINE_GLAPI * WINED3D_PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -/* GL_ARB_vertex_buffer_object */ -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif -typedef void (WINE_GLAPI * PGLFNBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (WINE_GLAPI * PGLFNDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (WINE_GLAPI * PGLFNGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (WINE_GLAPI * PGLFNISBUFFERARBPROC) (GLuint buffer); -typedef void (WINE_GLAPI * PGLFNBUFFERDATAARBPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (WINE_GLAPI * PGLFNBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (WINE_GLAPI * PGLFNMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (WINE_GLAPI * PGLFNUNMAPBUFFERARBPROC) (GLenum target); -typedef void (WINE_GLAPI * PGLFNGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -/* GL_EXT_blend_equation_separate */ -typedef void (WINE_GLAPI * PGLFNBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -/* GL_EXT_blend_func_separate */ -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif -typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -/* GL_EXT_fog_coord */ -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif /* GL_EXT_fog_coord */ -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, GLvoid *data); -/* GL_ARB_shader_objects (GLSL) */ -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPELR_2D_RECT_SHADOW_ARB 0x8B64 -#endif -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif -typedef void (WINE_GLAPI * WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef GLint (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (WINE_GLAPI * WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (WINE_GLAPI * WINED3D_PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (WINE_GLAPI * WINED3D_PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (WINE_GLAPI * WINED3D_PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (WINE_GLAPI * WINED3D_PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (WINE_GLAPI * WINED3D_PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef void (WINE_GLAPI * WINED3D_PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef void (WINE_GLAPI * WINED3D_PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -typedef void (WINE_GLAPI * WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef GLint (WINE_GLAPI * WINED3D_PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -/* GL_ARB_pixel_buffer_object */ -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif -/* GL_EXT_texture */ -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +typedef void (WINE_GLAPI *PGLFNGLTEXIMAGE3DEXTPROC)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (WINE_GLAPI *PGLFNGLTEXSUBIMAGE3DEXTPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + +/* GL_EXT_texture_compression_rgtc */ +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8dbb +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8dbc +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8dbd +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8dbe #endif + /* GL_EXT_texture_compression_s3tc */ #ifndef GL_EXT_texture_compression_s3tc #define GL_EXT_texture_compression_s3tc 1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83f0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83f1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83f2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83f3 #endif -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); -/* GL_EXT_stencil_wrap */ -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void *img); + +/* GL_EXT_texture_env_combine */ +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_SUBTRACT_EXT 0x84e7 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE3_RGB_EXT 0x8583 +#define GL_SOURCE4_RGB_EXT 0x8584 +#define GL_SOURCE5_RGB_EXT 0x8585 +#define GL_SOURCE6_RGB_EXT 0x8586 +#define GL_SOURCE7_RGB_EXT 0x8587 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858a +#define GL_SOURCE3_ALPHA_EXT 0x858b +#define GL_SOURCE4_ALPHA_EXT 0x858c +#define GL_SOURCE5_ALPHA_EXT 0x858d +#define GL_SOURCE6_ALPHA_EXT 0x858e +#define GL_SOURCE7_ALPHA_EXT 0x858f +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND3_RGB_EXT 0x8593 +#define GL_OPERAND4_RGB_EXT 0x8594 +#define GL_OPERAND5_RGB_EXT 0x8595 +#define GL_OPERAND6_RGB_EXT 0x8596 +#define GL_OPERAND7_RGB_EXT 0x8597 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859a +#define GL_OPERAND3_ALPHA_EXT 0x859b +#define GL_OPERAND4_ALPHA_EXT 0x859c +#define GL_OPERAND5_ALPHA_EXT 0x859d +#define GL_OPERAND6_ALPHA_EXT 0x859e +#define GL_OPERAND7_ALPHA_EXT 0x859f #endif -/* GL_ARB_half_float_vertex */ -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex -/* No _ARB, see extension spec */ -#define GL_HALF_FLOAT 0x140B +/* GL_EXT_texture_env_dot3 */ +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 #endif -/* GL_NV_half_float */ -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -typedef unsigned short GLhalfNV; -#define GL_HALF_FLOAT_NV 0x140B + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84fe +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84ff #endif -typedef void (WINE_GLAPI * PGLFNVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (WINE_GLAPI * PGLFNVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (WINE_GLAPI * PGLFNVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (WINE_GLAPI * PGLFNVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (WINE_GLAPI * PGLFNNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (WINE_GLAPI * PGLFNCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (WINE_GLAPI * PGLFNCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (WINE_GLAPI * PGLFNTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (WINE_GLAPI * PGLFNTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (WINE_GLAPI * PGLFNTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (WINE_GLAPI * PGLFNTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (WINE_GLAPI * PGLFNFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (WINE_GLAPI * PGLFNSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (WINE_GLAPI * PGLFNSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (WINE_GLAPI * PGLFNVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); + +/* GL_EXT_texture_lod_bias */ +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84fd +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +/* GL_EXT_texture_sRGB */ +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8c40 +#define GL_SRGB8_EXT 0x8c41 +#define GL_SRGB_ALPHA_EXT 0x8c42 +#define GL_SRGB8_ALPHA8_EXT 0x8c43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8c44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8c45 +#define GL_SLUMINANCE_EXT 0x8c46 +#define GL_SLUMINANCE8_EXT 0x8c47 +#define GL_COMPRESSED_SRGB_EXT 0x8c48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8c49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8c4a +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8c4b +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8c4c +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8c4d +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8c4e +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8c4f +#endif + +/* GL_NV_depth_clamp */ +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864f +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84f2 +#define GL_FENCE_STATUS_NV 0x84f3 +#define GL_FENCE_CONDITION_NV 0x84f4 +#endif +typedef void (WINE_GLAPI *PGLFNGENFENCESNVPROC)(GLsizei, GLuint *); +typedef void (WINE_GLAPI *PGLFNDELETEFENCESNVPROC)(GLuint, const GLuint *); +typedef void (WINE_GLAPI *PGLFNSETFENCENVPROC)(GLuint, GLenum); +typedef GLboolean (WINE_GLAPI *PGLFNTESTFENCENVPROC)(GLuint); +typedef void (WINE_GLAPI *PGLFNFINISHFENCENVPROC)(GLuint); +typedef GLboolean (WINE_GLAPI *PGLFNISFENCENVPROC)(GLuint); +typedef void (WINE_GLAPI *PGLFNGETFENCEIVNVPROC)(GLuint, GLenum, GLint *); /* GL_NV_fog_distance */ #ifndef GL_NV_fog_distance #define GL_NV_fog_distance 1 -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#define GL_FOG_DISTANCE_MODE_NV 0x855a +#define GL_EYE_RADIAL_NV 0x855b +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855c /* reuse GL_EYE_PLANE */ #endif -/* GL_NV_texgen_reflection */ -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 + +/* GL_NV_half_float */ +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140b #endif -/* GL_NV_texture_env_combine4 */ -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B +typedef void (WINE_GLAPI *PGLFNVERTEX2HNVPROC)(GLhalfNV x, GLhalfNV y); +typedef void (WINE_GLAPI *PGLFNVERTEX2HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEX3HNVPROC)(GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (WINE_GLAPI *PGLFNVERTEX3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEX4HNVPROC)(GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (WINE_GLAPI *PGLFNVERTEX4HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNNORMAL3HNVPROC)(GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (WINE_GLAPI *PGLFNNORMAL3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNCOLOR3HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (WINE_GLAPI *PGLFNCOLOR3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNCOLOR4HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (WINE_GLAPI *PGLFNCOLOR4HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNTEXCOORD1HNVPROC)(GLhalfNV s); +typedef void (WINE_GLAPI *PGLFNTEXCOORD1HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNTEXCOORD2HNVPROC)(GLhalfNV s, GLhalfNV t); +typedef void (WINE_GLAPI *PGLFNTEXCOORD2HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNTEXCOORD3HNVPROC)(GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (WINE_GLAPI *PGLFNTEXCOORD3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNTEXCOORD4HNVPROC)(GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (WINE_GLAPI *PGLFNTEXCOORD4HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD1HNVPROC)(GLenum target, GLhalfNV s); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD1HVNVPROC)(GLenum target, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD2HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD2HVNVPROC)(GLenum target, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD3HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD3HVNVPROC)(GLenum target, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD4HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD4HVNVPROC)(GLenum target, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNFOGCOORDHNVPROC)(GLhalfNV fog); +typedef void (WINE_GLAPI *PGLFNFOGCOORDHVNVPROC)(const GLhalfNV *fog); +typedef void (WINE_GLAPI *PGLFNSECONDARYCOLOR3HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (WINE_GLAPI *PGLFNSECONDARYCOLOR3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXWEIGHTHNVPROC)(GLhalfNV weight); +typedef void (WINE_GLAPI *PGLFNVERTEXWEIGHTHVNVPROC)(const GLhalfNV *weight); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1HNVPROC)(GLuint index, GLhalfNV x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1HVNVPROC)(GLuint index, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2HVNVPROC)(GLuint index, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3HVNVPROC)(GLuint index, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4HVNVPROC)(GLuint index, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS1HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS2HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS3HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS4HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v); + +/* GL_NV_light_max_exponent */ +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 #endif + /* GL_NV_register_combiners */ #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852a +#define GL_CONSTANT_COLOR1_NV 0x852b +#define GL_PRIMARY_COLOR_NV 0x852c +#define GL_SECONDARY_COLOR_NV 0x852d +#define GL_SPARE0_NV 0x852e +#define GL_SPARE1_NV 0x852f +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853a +#define GL_HALF_BIAS_NEGATE_NV 0x853b +#define GL_SIGNED_IDENTITY_NV 0x853c +#define GL_SIGNED_NEGATE_NV 0x853d +#define GL_SCALE_BY_TWO_NV 0x853e +#define GL_SCALE_BY_FOUR_NV 0x853f +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854a +#define GL_COMBINER_CD_OUTPUT_NV 0x854b +#define GL_COMBINER_SUM_OUTPUT_NV 0x854c +#define GL_MAX_GENERAL_COMBINERS_NV 0x854d +#define GL_NUM_GENERAL_COMBINERS_NV 0x854e +#define GL_COLOR_SUM_CLAMP_NV 0x854f +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 /* reuse GL_TEXTURE0_ARB */ /* reuse GL_TEXTURE1_ARB */ /* reuse GL_ZERO */ /* reuse GL_NONE */ /* reuse GL_FOG */ #endif -typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (WINE_GLAPI * PGLFNCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (WINE_GLAPI * PGLFNCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (WINE_GLAPI * PGLFNFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (WINE_GLAPI * PGLFNGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERFVNVPROC)(GLenum pname, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERFNVPROC)(GLenum pname, GLfloat param); +typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERIVNVPROC)(GLenum pname, const GLint *params); +typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERINVPROC)(GLenum pname, GLint param); +typedef void (WINE_GLAPI *PGLFNCOMBINERINPUTNVPROC)(GLenum stage, GLenum portion, + GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (WINE_GLAPI *PGLFNCOMBINEROUTPUTNVPROC)(GLenum stage, GLenum portion, + GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, + GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (WINE_GLAPI *PGLFNFINALCOMBINERINPUTNVPROC)(GLenum variable, GLenum input, + GLenum mapping, GLenum componentUsage); +typedef void (WINE_GLAPI *PGLFNGETCOMBINERINPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion, + GLenum variable, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETCOMBINERINPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion, + GLenum variable, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETCOMBINEROUTPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion, + GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETCOMBINEROUTPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion, + GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETFINALCOMBINERINPUTPARAMETERFVNVPROC)(GLenum variable, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETFINALCOMBINERINPUTPARAMETERIVNVPROC)(GLenum variable, GLenum pname, GLint *params); + /* GL_NV_register_combiners2 */ #ifndef GL_NV_register_combiners2 #define GL_NV_register_combiners2 1 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 #endif -typedef void (WINE_GLAPI * PGLFNCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNCOMBINERSTAGEPARAMETERFVNVPROC)(GLenum stage, GLenum pname, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC)(GLenum stage, GLenum pname, GLfloat *params); + +/* GL_NV_texgen_reflection */ +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +/* GL_NV_texture_env_combine4 */ +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858b +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859b +#endif + /* GL_NV_texture_shader */ #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864c +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864d +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864e +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86d9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86da +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86db +#define GL_DSDT_MAG_INTENSITY_NV 0x86dc +#define GL_SHADER_CONSISTENT_NV 0x86dd +#define GL_TEXTURE_SHADER_NV 0x86de +#define GL_SHADER_OPERATION_NV 0x86df +#define GL_CULL_MODES_NV 0x86e0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86e1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86e2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86e3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86e4 +#define GL_CONST_EYE_NV 0x86e5 +#define GL_PASS_THROUGH_NV 0x86e6 +#define GL_CULL_FRAGMENT_NV 0x86e7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86e8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86e9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86ea +#define GL_DOT_PRODUCT_NV 0x86ec +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ed +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86ee +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86f0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86f1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86f2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86f3 +#define GL_HILO_NV 0x86f4 +#define GL_DSDT_NV 0x86f5 +#define GL_DSDT_MAG_NV 0x86f6 +#define GL_DSDT_MAG_VIB_NV 0x86f7 +#define GL_HILO16_NV 0x86f8 +#define GL_SIGNED_HILO_NV 0x86f9 +#define GL_SIGNED_HILO16_NV 0x86fa +#define GL_SIGNED_RGBA_NV 0x86fb +#define GL_SIGNED_RGBA8_NV 0x86fc +#define GL_SIGNED_RGB_NV 0x86fe +#define GL_SIGNED_RGB8_NV 0x86ff +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870a +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870b +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870c +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870d +#define GL_HI_SCALE_NV 0x870e +#define GL_LO_SCALE_NV 0x870f +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871a +#define GL_TEXTURE_HI_SIZE_NV 0x871b +#define GL_TEXTURE_LO_SIZE_NV 0x871c +#define GL_TEXTURE_DS_SIZE_NV 0x871d +#define GL_TEXTURE_DT_SIZE_NV 0x871e +#define GL_TEXTURE_MAG_SIZE_NV 0x871f #endif + /* GL_NV_texture_shader2 */ #ifndef GL_NV_texture_shader2 #define GL_NV_texture_shader2 1 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif -/* GL_NV_texture_shader3 */ -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif -/* GL_ATI_texture_env_combine3 */ -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -/* #define ONE */ -/* #define ZERO */ -#endif - -/** - * Point sprites - */ -/* GL_ARB_point_sprite */ -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif -/** - * @TODO: GL_NV_point_sprite - */ - -/** - * Occlusion Queries - */ -/* GL_ARB_occlusion_query */ -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#endif -typedef void (WINE_GLAPI * PGLFNGENQUERIESARBPROC) (GLsizei n, GLuint *queries); -typedef void (WINE_GLAPI * PGLFNDELETEQUERIESARBPROC) (GLsizei n, const GLuint *queries); -typedef GLboolean (WINE_GLAPI * PGLFNISQUERYARBPROC) (GLuint query); -typedef void (WINE_GLAPI * PGLFNBEGINQUERYARBPROC) (GLenum target, GLuint query); -typedef void (WINE_GLAPI * PGLFNENDQUERYARBPROC) (GLenum target); -typedef void (WINE_GLAPI * PGLFNGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETQUERYOBJECTIVARBPROC) (GLuint query, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETQUERYOBJECTUIVARBPROC) (GLuint query, GLenum pname, GLuint *params); -/* GL_HP_occlusion_test isn't complete, but it's constants are used by GL_NV_occlusion_query */ -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8165 -#endif -/* GL_NV_occlusion_query */ -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif -typedef void (WINE_GLAPI * PGLFNGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (WINE_GLAPI * PGLFNDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (WINE_GLAPI * PGLFNISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (WINE_GLAPI * PGLFNBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (WINE_GLAPI * PGLFNENDOCCLUSIONQUERYNVPROC) (void); -typedef void (WINE_GLAPI * PGLFNGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -/* GL_EXT_stencil_two_side */ -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif -typedef void (WINE_GLAPI * PGLFNACTIVESTENCILFACEEXTPROC) (GLenum face); -/* GL_ATI_separate_stencil */ -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif -typedef void (WINE_GLAPI * PGLFNSTENCILOPSEPARATEATIPROC) (GLenum, GLenum, GLenum, GLenum); -typedef void (WINE_GLAPI * PGLFNSTENCILFUNCSEPARATEATIPROC) (GLenum, GLenum, GLint, GLuint); -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif -typedef void (WINE_GLAPI * PGLFNGENFENCESNVPROC) (GLsizei, GLuint *); -typedef void (WINE_GLAPI * PGLFNDELETEFENCESNVPROC) (GLuint, const GLuint *); -typedef void (WINE_GLAPI * PGLFNSETFENCENVPROC) (GLuint, GLenum); -typedef GLboolean (WINE_GLAPI * PGLFNTESTFENCENVPROC) (GLuint); -typedef void (WINE_GLAPI * PGLFNFINISHFENCENVPROC) (GLuint); -typedef GLboolean (WINE_GLAPI * PGLFNISFENCENVPROC) (GLuint); -typedef void (WINE_GLAPI * PGLFNGETFENCEIVNVPROC) (GLuint, GLenum, GLint *); -/* GL_APPLE_fence */ -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif -typedef void (WINE_GLAPI * PGLFNGENFENCESAPPLEPROC) (GLsizei, GLuint *); -typedef void (WINE_GLAPI * PGLFNDELETEFENCESAPPLEPROC) (GLuint, const GLuint *); -typedef void (WINE_GLAPI * PGLFNSETFENCEAPPLEPROC) (GLuint); -typedef GLboolean (WINE_GLAPI * PGLFNTESTFENCEAPPLEPROC) (GLuint); -typedef void (WINE_GLAPI * PGLFNFINISHFENCEAPPLEPROC) (GLuint); -typedef GLboolean (WINE_GLAPI * PGLFNISFENCEAPPLEPROC) (GLuint); -typedef GLboolean (WINE_GLAPI * PGLFNTESTOBJECTAPPLEPROC) (GLenum, GLuint); -typedef void (WINE_GLAPI * PGLFNFINISHOBJECTAPPLEPROC) (GLenum, GLuint); -/* GL_APPLE_client_storage */ -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif -/* GLX_SGI_video_sync */ -typedef int (WINE_GLAPI * PGLXFNGETVIDEOSYNCSGIPROC) (unsigned int *); -typedef int (WINE_GLAPI * PGLXFNWAITVIDEOSYNCSGIPROC) (int, int, unsigned int *); - -/* GL_SGIS_generate_mipmap */ -#ifndef GLX_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#define GLX_SGIS_generate_mipmap -#endif - -/* GL_NV_depth_clamp */ -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -/* GL_APPLE_flush_render */ -typedef void (WINE_GLAPI * PGLFNFLUSHRENDERAPPLEPROC) (void); -typedef void (WINE_GLAPI * PGLFNFINISHRENDERAPPLEPROC) (void); - -/* GL_APPLE_ycbcr_422 */ -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -/* GL_ARB_texture_rectangle */ -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#endif - -/* GL_APPLE_float_pixels */ -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels -#define GL_HALF_APPLE 0x140B -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#endif - -/* GL_EXT_gpu_program_parameters */ -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params); -#endif - -/* GL_NV_light_max_exponent */ -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -/* GL_ATI_fragment_shader */ -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader -typedef GLuint (WINE_GLAPI *PGLFNGENFRAGMENTSHADERSATI) (GLuint range); -typedef void (WINE_GLAPI *PGLFNBINDFRAGMENTSHADERATI) (GLuint id); -typedef void (WINE_GLAPI *PGLFNDELETEFRAGMENTSHADERATI) (GLuint id); -typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI) (void); -typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI) (void); -typedef void (WINE_GLAPI *PGLFNPASSTEXCOORDATI) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (WINE_GLAPI *PGLFNSAMPLEMAPATI) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP1ATI) (GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod); -typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP2ATI) (GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, - GLuint arg2Mod); -typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP3ATI) (GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, - GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, - GLuint arg3Mod); -typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP1ATI) (GLenum op, GLuint dst, GLuint dstMod, - GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP2ATI) (GLenum op, GLuint dst, GLuint dstMod, - GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, - GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP3ATI) (GLenum op, GLuint dst, GLuint dstMod, - GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, - GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, - GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI) (GLuint dst, const GLfloat *value); -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif -/* GL_ATI_texture_compression_3dc */ -#ifndef GL_ATI_texture_compression_3dc -#define GL_ATI_texture_compression_3dc -#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 -#endif -/* GL_EXT_texture_compression_rgtc */ -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86ef #endif /* GL_NV_vertex_program2_option */ #ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_NV_vertex_program2_option 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88f4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88f5 #endif -/* GL_APPLE_flush_buffer_range */ -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -typedef void (WINE_GLAPI *PGLFNBUFFERPARAMETERIAPPLE) (GLenum target, GLenum pname, GLint param); -typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE) (GLenum target, GLintptr offset, GLsizeiptr size); +/* GL_SGIS_generate_mipmap */ +#ifndef GLX_SGIS_generate_mipmap +#define GLX_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 #endif -/* GL_VERSION_2_0 */ -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -typedef char GLchar; -#endif -typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (WINE_GLAPI * PGLFNDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (WINE_GLAPI * PGLFNSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (WINE_GLAPI * PGLFNSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (WINE_GLAPI * PGLFNSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (WINE_GLAPI * PGLFNATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (WINE_GLAPI * PGLFNBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (WINE_GLAPI * PGLFNCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (WINE_GLAPI * PGLFNCREATEPROGRAMPROC) (void); -typedef GLuint (WINE_GLAPI * PGLFNCREATESHADERPROC) (GLenum type); -typedef void (WINE_GLAPI * PGLFNDELETEPROGRAMPROC) (GLuint program); -typedef void (WINE_GLAPI * PGLFNDELETESHADERPROC) (GLuint shader); -typedef void (WINE_GLAPI * PGLFNDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (WINE_GLAPI * PGLFNDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (WINE_GLAPI * PGLFNENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (WINE_GLAPI * PGLFNGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (WINE_GLAPI * PGLFNGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (WINE_GLAPI * PGLFNGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (WINE_GLAPI * PGLFNGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (WINE_GLAPI * PGLFNGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (WINE_GLAPI * PGLFNGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (WINE_GLAPI * PGLFNGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (WINE_GLAPI * PGLFNGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (WINE_GLAPI * PGLFNISPROGRAMPROC) (GLuint program); -typedef GLboolean (WINE_GLAPI * PGLFNISSHADERPROC) (GLuint shader); -typedef void (WINE_GLAPI * PGLFNLINKPROGRAMPROC) (GLuint program); -typedef void (WINE_GLAPI * PGLFNSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (WINE_GLAPI * PGLFNUSEPROGRAMPROC) (GLuint program); -typedef void (WINE_GLAPI * PGLFNUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (WINE_GLAPI * PGLFNUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (WINE_GLAPI * PGLFNUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (WINE_GLAPI * PGLFNUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (WINE_GLAPI * PGLFNUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (WINE_GLAPI * PGLFNUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (WINE_GLAPI * PGLFNUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (WINE_GLAPI * PGLFNUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (WINE_GLAPI * PGLFNUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNVALIDATEPROGRAMPROC) (GLuint program); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); - - -/**************************************************** - * OpenGL Official Version - * defines - ****************************************************/ -/* GL_VERSION_1_3 */ -#if !defined(GL_DOT3_RGBA) -# define GL_DOT3_RGBA 0x8741 -#endif -#if !defined(GL_SUBTRACT) -# define GL_SUBTRACT 0x84E7 -#endif - - -/**************************************************** - * Enumerated types - ****************************************************/ -#define WINE_DEFAULT_VIDMEM 64*1024*1024 - -#define MAKEDWORD_VERSION(maj, min) ((maj & 0x0000FFFF) << 16) | (min & 0x0000FFFF) - -/* OpenGL Supported Extensions (ARB and EXT) */ -typedef enum _GL_SupportedExt { - WINED3D_GL_EXT_NONE, - /* ARB */ - ARB_COLOR_BUFFER_FLOAT, - ARB_DEPTH_BUFFER_FLOAT, - ARB_DEPTH_CLAMP, - ARB_DEPTH_TEXTURE, - ARB_DRAW_BUFFERS, - ARB_FRAGMENT_PROGRAM, - ARB_FRAGMENT_SHADER, - ARB_FRAMEBUFFER_OBJECT, - ARB_GEOMETRY_SHADER4, - ARB_IMAGING, - ARB_MULTISAMPLE, - ARB_MULTITEXTURE, - ARB_OCCLUSION_QUERY, - ARB_POINT_PARAMETERS, - ARB_PROVOKING_VERTEX, - ARB_PIXEL_BUFFER_OBJECT, - ARB_POINT_SPRITE, - ARB_TEXTURE_COMPRESSION, - ARB_TEXTURE_CUBE_MAP, - ARB_TEXTURE_ENV_ADD, - ARB_TEXTURE_ENV_COMBINE, - ARB_TEXTURE_ENV_DOT3, - ARB_TEXTURE_FLOAT, - ARB_HALF_FLOAT_PIXEL, - ARB_TEXTURE_BORDER_CLAMP, - ARB_TEXTURE_MIRRORED_REPEAT, - ARB_TEXTURE_NON_POWER_OF_TWO, - ARB_TEXTURE_RECTANGLE, - ARB_TEXTURE_RG, - ARB_VERTEX_PROGRAM, - ARB_VERTEX_BLEND, - ARB_VERTEX_BUFFER_OBJECT, - ARB_VERTEX_SHADER, - ARB_SHADER_OBJECTS, - ARB_SHADER_TEXTURE_LOD, - ARB_HALF_FLOAT_VERTEX, - /* EXT */ - EXT_BLEND_COLOR, - EXT_BLEND_MINMAX, - EXT_BLEND_EQUATION_SEPARATE, - EXT_BLEND_FUNC_SEPARATE, - EXT_FOG_COORD, - EXT_FRAMEBUFFER_OBJECT, - EXT_FRAMEBUFFER_BLIT, - EXT_FRAMEBUFFER_MULTISAMPLE, - EXT_PACKED_DEPTH_STENCIL, - EXT_PALETTED_TEXTURE, - EXT_PIXEL_BUFFER_OBJECT, - EXT_POINT_PARAMETERS, - EXT_PROVOKING_VERTEX, - EXT_SECONDARY_COLOR, - EXT_STENCIL_TWO_SIDE, - EXT_STENCIL_WRAP, - EXT_TEXTURE3D, - EXT_TEXTURE_COMPRESSION_S3TC, - EXT_TEXTURE_COMPRESSION_RGTC, - EXT_TEXTURE_FILTER_ANISOTROPIC, - EXT_TEXTURE_LOD, - EXT_TEXTURE_LOD_BIAS, - EXT_TEXTURE_ENV_ADD, - EXT_TEXTURE_ENV_COMBINE, - EXT_TEXTURE_ENV_DOT3, - EXT_TEXTURE_SRGB, - EXT_TEXTURE_SWIZZLE, - EXT_GPU_PROGRAM_PARAMETERS, - EXT_VERTEX_ARRAY_BGRA, - /* NVIDIA */ - NV_HALF_FLOAT, - NV_FOG_DISTANCE, - NV_FRAGMENT_PROGRAM, - NV_FRAGMENT_PROGRAM2, - NV_OCCLUSION_QUERY, - NV_REGISTER_COMBINERS, - NV_REGISTER_COMBINERS2, - NV_TEXGEN_REFLECTION, - NV_TEXTURE_ENV_COMBINE4, - NV_TEXTURE_SHADER, - NV_TEXTURE_SHADER2, - NV_TEXTURE_SHADER3, - NV_VERTEX_PROGRAM, - NV_VERTEX_PROGRAM1_1, - NV_VERTEX_PROGRAM2, - NV_VERTEX_PROGRAM2_OPTION, - NV_VERTEX_PROGRAM3, - NV_FRAGMENT_PROGRAM_OPTION, - NV_FENCE, - NV_DEPTH_CLAMP, - NV_LIGHT_MAX_EXPONENT, - /* ATI */ - ATI_SEPARATE_STENCIL, - ATI_TEXTURE_ENV_COMBINE3, - ATI_TEXTURE_MIRROR_ONCE, - EXT_VERTEX_SHADER, - ATI_FRAGMENT_SHADER, - ATI_TEXTURE_COMPRESSION_3DC, - /* APPLE */ - APPLE_FENCE, - APPLE_CLIENT_STORAGE, - APPLE_FLUSH_RENDER, - APPLE_YCBCR_422, - APPLE_FLOAT_PIXELS, - APPLE_FLUSH_BUFFER_RANGE, - /* SGI */ - SGI_VIDEO_SYNC, - SGIS_GENERATE_MIPMAP, - - /* Internally used */ - WINE_NORMALIZED_TEXRECT, - - /* WGL extensions */ - WGL_ARB_PBUFFER, - WGL_ARB_PIXEL_FORMAT, - WGL_WINE_PIXEL_FORMAT_PASSTHROUGH, - - WINED3D_GL_EXT_COUNT, -} GL_SupportedExt; - - -/**************************************************** - * #Defines - ****************************************************/ -#define GL_EXT_FUNCS_GEN \ - /** ARB Extensions **/ \ - /* GL_ARB_color_buffer_float */ \ - USE_GL_FUNC(PGLFNCLAMPCOLORARBPROC, glClampColorARB, ARB_COLOR_BUFFER_FLOAT, NULL )\ - /* GL_ARB_draw_buffers */ \ - USE_GL_FUNC(PGLFNDRAWBUFFERSARBPROC, glDrawBuffersARB, ARB_DRAW_BUFFERS, NULL )\ - /* GL_ARB_framebuffer_object */ \ - USE_GL_FUNC(PGLFNGLISRENDERBUFFERPROC, glIsRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVPROC, glGetRenderbufferParameteriv, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLISFRAMEBUFFERPROC, glIsFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSPROC, glGenFramebuffers, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatus, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DPROC, glFramebufferTexture1D, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DPROC, glFramebufferTexture3D, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURELAYERPROC, glFramebufferTextureLayer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC, glGetFramebufferAttachmentParameteriv, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFERPROC, glBlitFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENERATEMIPMAPPROC, glGenerateMipmap, ARB_FRAMEBUFFER_OBJECT, NULL )\ - /* GL_ARB_geometry_shader4 */ \ - USE_GL_FUNC(PGLFNPROGRAMPARAMETERIARBPROC, glProgramParameteriARB, ARB_GEOMETRY_SHADER4, NULL ) \ - USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREARBPROC, glFramebufferTextureARB, ARB_GEOMETRY_SHADER4, NULL ) \ - USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTURELAYERARBPROC, glFramebufferTextureLayerARB, ARB_GEOMETRY_SHADER4, NULL ) \ - USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREFACEARBPROC, glFramebufferTextureFaceARB, ARB_GEOMETRY_SHADER4, NULL ) \ - /* GL_ARB_imaging, GL_EXT_blend_minmax */ \ - USE_GL_FUNC(PGLFNBLENDCOLORPROC, glBlendColorEXT, EXT_BLEND_COLOR, NULL )\ - USE_GL_FUNC(PGLFNBLENDEQUATIONPROC, glBlendEquationEXT, EXT_BLEND_MINMAX, NULL )\ - /* GL_ARB_multisample */ \ - USE_GL_FUNC(WINED3D_PFNGLSAMPLECOVERAGEARBPROC, glSampleCoverageARB, ARB_MULTISAMPLE, NULL )\ - /* GL_ARB_multitexture */ \ - USE_GL_FUNC(WINED3D_PFNGLACTIVETEXTUREARBPROC, glActiveTextureARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC, glClientActiveTextureARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FARBPROC, glMultiTexCoord1fARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FVARBPROC, glMultiTexCoord1fvARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FARBPROC, glMultiTexCoord2fARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FVARBPROC, glMultiTexCoord2fvARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FARBPROC, glMultiTexCoord3fARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FVARBPROC, glMultiTexCoord3fvARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FARBPROC, glMultiTexCoord4fARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FVARBPROC, glMultiTexCoord4fvARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2SVARBPROC, glMultiTexCoord2svARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4SVARBPROC, glMultiTexCoord4svARB, ARB_MULTITEXTURE, NULL )\ - /* GL_ARB_occlusion_query */ \ - USE_GL_FUNC(PGLFNGENQUERIESARBPROC, glGenQueriesARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNDELETEQUERIESARBPROC, glDeleteQueriesARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNBEGINQUERYARBPROC, glBeginQueryARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNENDQUERYARBPROC, glEndQueryARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNGETQUERYOBJECTIVARBPROC, glGetQueryObjectivARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNGETQUERYOBJECTUIVARBPROC, glGetQueryObjectuivARB, ARB_OCCLUSION_QUERY, NULL )\ - /* GL_ARB_point_parameters */ \ - USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC, glPointParameterfARB, ARB_POINT_PARAMETERS, NULL )\ - USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC, glPointParameterfvARB, ARB_POINT_PARAMETERS, NULL )\ - /* GL_ARB_provoking_vertex */ \ - USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXPROC, glProvokingVertex, ARB_PROVOKING_VERTEX, NULL)\ - /* GL_ARB_texture_compression */ \ - USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC, glCompressedTexImage2DARB, ARB_TEXTURE_COMPRESSION,NULL )\ - USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE3DPROC, glCompressedTexImage3DARB, ARB_TEXTURE_COMPRESSION,NULL )\ - USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC, glCompressedTexSubImage2DARB, ARB_TEXTURE_COMPRESSION,NULL )\ - USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedTexSubImage3DARB, ARB_TEXTURE_COMPRESSION,NULL )\ - USE_GL_FUNC(PGLFNGETCOMPRESSEDTEXIMAGEPROC, glGetCompressedTexImageARB, ARB_TEXTURE_COMPRESSION,NULL )\ - /* GL_ARB_vertex_blend */ \ - USE_GL_FUNC(PGLFNGLWEIGHTPOINTERARB, glWeightPointerARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTBV, glWeightbvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTSV, glWeightsvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTIV, glWeightivARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTFV, glWeightfvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTDV, glWeightdvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTUBV, glWeightubvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTUSV, glWeightusvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTUIV, glWeightuivARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLVERTEXBLENDARB, glVertexBlendARB, ARB_VERTEX_BLEND, NULL )\ - /* GL_ARB_vertex_buffer_object */ \ - USE_GL_FUNC(PGLFNBINDBUFFERARBPROC, glBindBufferARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNDELETEBUFFERSARBPROC, glDeleteBuffersARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNGENBUFFERSARBPROC, glGenBuffersARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNISBUFFERARBPROC, glIsBufferARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNBUFFERDATAARBPROC, glBufferDataARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNBUFFERSUBDATAARBPROC, glBufferSubDataARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNGETBUFFERSUBDATAARBPROC, glGetBufferSubDataARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNMAPBUFFERARBPROC, glMapBufferARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNUNMAPBUFFERARBPROC, glUnmapBufferARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNGETBUFFERPARAMETERIVARBPROC, glGetBufferParameterivARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNGETBUFFERPOINTERVARBPROC, glGetBufferPointervARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - /** EXT Extensions **/ \ - /* GL_EXT_blend_equation_separate */ \ - USE_GL_FUNC(PGLFNBLENDFUNCSEPARATEEXTPROC, glBlendFuncSeparateEXT, EXT_BLEND_FUNC_SEPARATE, NULL)\ - /* GL_EXT_blend_func_separate */ \ - USE_GL_FUNC(PGLFNBLENDEQUATIONSEPARATEEXTPROC, glBlendEquationSeparateEXT, EXT_BLEND_EQUATION_SEPARATE, NULL)\ - /* GL_EXT_fog_coord */ \ - USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC, glFogCoordfEXT, EXT_FOG_COORD, NULL )\ - USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC, glFogCoordfvEXT, EXT_FOG_COORD, NULL )\ - USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC, glFogCoorddEXT, EXT_FOG_COORD, NULL )\ - USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC, glFogCoorddvEXT, EXT_FOG_COORD, NULL )\ - USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC, glFogCoordPointerEXT, EXT_FOG_COORD, NULL )\ - /* GL_EXT_framebuffer_object */ \ - USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC, glIsRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBINDRENDERBUFFEREXTPROC, glBindRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSEXTPROC, glDeleteRenderbuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSEXTPROC, glGenRenderbuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEEXTPROC, glRenderbufferStorageEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLISFRAMEBUFFEREXTPROC, glIsFramebufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSEXTPROC, glDeleteFramebuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSEXTPROC, glGenFramebuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatusEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC, glFramebufferTexture1DEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC, glFramebufferTexture2DEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC, glFramebufferTexture3DEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC, glFramebufferRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENERATEMIPMAPEXTPROC, glGenerateMipmapEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC, glGetRenderbufferParameterivEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC, glGetFramebufferAttachmentParameterivEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - /* GL_EXT_framebuffer_blit */ \ - USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFEREXTPROC, glBlitFramebufferEXT, EXT_FRAMEBUFFER_BLIT, NULL )\ - /* GL_EXT_framebuffer_multisample */ \ - USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC, glRenderbufferStorageMultisampleEXT, EXT_FRAMEBUFFER_MULTISAMPLE, NULL )\ - /* GL_EXT_paletted_texture */ \ - USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC, glColorTableEXT, EXT_PALETTED_TEXTURE, NULL )\ - /* GL_EXT_point_parameters */ \ - USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC, glPointParameterfEXT, EXT_POINT_PARAMETERS, NULL )\ - USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC, glPointParameterfvEXT, EXT_POINT_PARAMETERS, NULL )\ - /* GL_EXT_provoking_vertex */ \ - USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXEXTPROC, glProvokingVertexEXT, EXT_PROVOKING_VERTEX, NULL)\ - /* GL_EXT_secondary_color */ \ - USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC, glSecondaryColor3ubEXT, EXT_SECONDARY_COLOR, NULL )\ - USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBVEXTPROC, glSecondaryColor3ubvEXT, EXT_SECONDARY_COLOR, NULL )\ - USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC, glSecondaryColor3fEXT, EXT_SECONDARY_COLOR, NULL )\ - USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC, glSecondaryColor3fvEXT, EXT_SECONDARY_COLOR, NULL )\ - USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC, glSecondaryColorPointerEXT, EXT_SECONDARY_COLOR, NULL )\ - /* GL_EXT_texture3D */ \ - USE_GL_FUNC(PGLFNGLTEXIMAGE3DEXTPROC, glTexImage3DEXT, EXT_TEXTURE3D, glTexImage3D)\ - USE_GL_FUNC(PGLFNGLTEXSUBIMAGE3DEXTPROC, glTexSubImage3DEXT, EXT_TEXTURE3D, glTexSubImage3D)\ - /* GL_ARB_vertex_program */ \ - USE_GL_FUNC(PGLFNGENPROGRAMSARBPROC, glGenProgramsARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNBINDPROGRAMARBPROC, glBindProgramARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNPROGRAMSTRINGARBPROC, glProgramStringARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNDELETEPROGRAMSARBPROC, glDeleteProgramsARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNPROGRAMENVPARAMETER4FVARBPROC, glProgramEnvParameter4fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETER4FVARBPROC, glProgramLocalParameter4fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointerARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC, glEnableVertexAttribArrayARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC, glDisableVertexAttribArrayARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1DARBPROC, glVertexAttrib1dARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1DVARBPROC, glVertexAttrib1dvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1FARBPROC, glVertexAttrib1fARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1FVARBPROC, glVertexAttrib1fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1SARBPROC, glVertexAttrib1sARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1SVARBPROC, glVertexAttrib1svARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2DARBPROC, glVertexAttrib2dARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2DVARBPROC, glVertexAttrib2dvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2FARBPROC, glVertexAttrib2fARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2FVARBPROC, glVertexAttrib2fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2SARBPROC, glVertexAttrib2sARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2SVARBPROC, glVertexAttrib2svARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3DARBPROC, glVertexAttrib3dARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3DVARBPROC, glVertexAttrib3dvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3FARBPROC, glVertexAttrib3fARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3FVARBPROC, glVertexAttrib3fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3SARBPROC, glVertexAttrib3sARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3SVARBPROC, glVertexAttrib3svARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NBVARBPROC, glVertexAttrib4NbvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NIVARBPROC, glVertexAttrib4NivARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NSVARBPROC, glVertexAttrib4NsvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBARBPROC, glVertexAttrib4NubARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBVARBPROC, glVertexAttrib4NubvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NUIVARBPROC, glVertexAttrib4NuivARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NUSVARBPROC, glVertexAttrib4NusvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4BVARBPROC, glVertexAttrib4bvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4DARBPROC, glVertexAttrib4dARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4DVARBPROC, glVertexAttrib4dvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4FARBPROC, glVertexAttrib4fARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4FVARBPROC, glVertexAttrib4fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4IVARBPROC, glVertexAttrib4ivARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4SARBPROC, glVertexAttrib4sARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4SVARBPROC, glVertexAttrib4svARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4UBVARBPROC, glVertexAttrib4ubvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4UIVARBPROC, glVertexAttrib4uivARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4USVARBPROC, glVertexAttrib4usvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNGETPROGRAMIVARBPROC, glGetProgramivARB, ARB_VERTEX_PROGRAM, NULL )\ - /* GL_ARB_shader_objects */ \ - USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC, glGetObjectParameterivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC, glGetObjectParameterfvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC, glGetUniformLocationARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETACTIVEUNIFORMARBPROC, glGetActiveUniformARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, glUniform1iARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IARBPROC, glUniform2iARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IARBPROC, glUniform3iARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IARBPROC, glUniform4iARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, glUniform1fARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FARBPROC, glUniform2fARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FARBPROC, glUniform3fARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FARBPROC, glUniform4fARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM1FVARBPROC, glUniform1fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FVARBPROC, glUniform2fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FVARBPROC, glUniform3fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FVARBPROC, glUniform4fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IVARBPROC, glUniform1ivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IVARBPROC, glUniform2ivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IVARBPROC, glUniform3ivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IVARBPROC, glUniform4ivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC, glUniformMatrix2fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC, glUniformMatrix3fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC, glUniformMatrix4fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC, glGetUniformfvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC, glGetUniformivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC, glGetInfoLogARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLSHADERSOURCEARBPROC, glShaderSourceARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLCOMPILESHADERARBPROC, glCompileShaderARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC, glCreateProgramObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLATTACHOBJECTARBPROC, glAttachObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLLINKPROGRAMARBPROC, glLinkProgramARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLDETACHOBJECTARBPROC, glDetachObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLDELETEOBJECTARBPROC, glDeleteObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLVALIDATEPROGRAMARBPROC, glValidateProgramARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC, glGetAttachedObjectsARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETHANDLEARBPROC, glGetHandleARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETSHADERSOURCEARBPROC, glGetShaderSourceARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC, glBindAttribLocationARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETATTRIBLOCATIONARBPROC, glGetAttribLocationARB, ARB_SHADER_OBJECTS, NULL )\ - /* GL_EXT_stencil_two_side */ \ - USE_GL_FUNC(PGLFNACTIVESTENCILFACEEXTPROC, glActiveStencilFaceEXT, EXT_STENCIL_TWO_SIDE, NULL )\ - /* GL_ATI_separate_stencil */ \ - USE_GL_FUNC(PGLFNSTENCILOPSEPARATEATIPROC, glStencilOpSeparateATI, ATI_SEPARATE_STENCIL, NULL )\ - USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEATIPROC, glStencilFuncSeparateATI, ATI_SEPARATE_STENCIL, NULL )\ - /* GL_NV_half_float */ \ - USE_GL_FUNC(PGLFNVERTEX2HNVPROC, glVertex2hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX2HVNVPROC, glVertex2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX3HNVPROC, glVertex3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX3HVNVPROC, glVertex3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX4HNVPROC, glVertex4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX4HVNVPROC, glVertex4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNNORMAL3HNVPROC, glNormal3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNNORMAL3HVNVPROC, glNormal3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNCOLOR3HNVPROC, glColor3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNCOLOR3HVNVPROC, glColor3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNCOLOR4HNVPROC, glColor4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNCOLOR4HVNVPROC, glColor4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD1HNVPROC, glTexCoord1hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD1HVNVPROC, glTexCoord1hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD2HNVPROC, glTexCoord2hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD2HVNVPROC, glTexCoord2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD3HNVPROC, glTexCoord3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD3HVNVPROC, glTexCoord3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD4HNVPROC, glTexCoord4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD4HVNVPROC, glTexCoord4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD1HNVPROC, glMultiTexCoord1hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD1HVNVPROC, glMultiTexCoord1hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD2HNVPROC, glMultiTexCoord2hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD2HVNVPROC, glMultiTexCoord2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD3HNVPROC, glMultiTexCoord3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD3HVNVPROC, glMultiTexCoord3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD4HNVPROC, glMultiTexCoord4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD4HVNVPROC, glMultiTexCoord4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNFOGCOORDHNVPROC, glFogCoordhNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNFOGCOORDHVNVPROC, glFogCoordhvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNSECONDARYCOLOR3HNVPROC, glSecondaryColor3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNSECONDARYCOLOR3HVNVPROC, glSecondaryColor3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXWEIGHTHNVPROC, glVertexWeighthNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXWEIGHTHVNVPROC, glVertexWeighthvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1HNVPROC, glVertexAttrib1hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1HVNVPROC, glVertexAttrib1hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2HNVPROC, glVertexAttrib2hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2HVNVPROC, glVertexAttrib2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3HNVPROC, glVertexAttrib3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3HVNVPROC, glVertexAttrib3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4HNVPROC, glVertexAttrib4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4HVNVPROC, glVertexAttrib4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBS1HVNVPROC, glVertexAttribs1hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBS2HVNVPROC, glVertexAttribs2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBS3HVNVPROC, glVertexAttribs3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBS4HVNVPROC, glVertexAttribs4hvNV, NV_HALF_FLOAT, NULL )\ - /* GL_NV_register_combiners */ \ - USE_GL_FUNC(PGLFNCOMBINERINPUTNVPROC, glCombinerInputNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINEROUTPUTNVPROC, glCombinerOutputNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINERPARAMETERFNVPROC, glCombinerParameterfNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINERPARAMETERFVNVPROC, glCombinerParameterfvNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINERPARAMETERINVPROC, glCombinerParameteriNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINERPARAMETERIVNVPROC, glCombinerParameterivNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC, glFinalCombinerInputNV, NV_REGISTER_COMBINERS, NULL )\ - /* GL_NV_fence */ \ - USE_GL_FUNC(PGLFNGENFENCESNVPROC, glGenFencesNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNDELETEFENCESNVPROC, glDeleteFencesNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNSETFENCENVPROC, glSetFenceNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNTESTFENCENVPROC, glTestFenceNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNFINISHFENCENVPROC, glFinishFenceNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNISFENCENVPROC, glIsFenceNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNGETFENCEIVNVPROC, glGetFenceivNV, NV_FENCE, NULL )\ - /* GL_APPLE_fence */ \ - USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC, glGenFencesAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNDELETEFENCESAPPLEPROC, glDeleteFencesAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNSETFENCEAPPLEPROC, glSetFenceAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNTESTFENCEAPPLEPROC, glTestFenceAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNFINISHFENCEAPPLEPROC, glFinishFenceAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNISFENCEAPPLEPROC, glIsFenceAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNTESTOBJECTAPPLEPROC, glTestObjectAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNFINISHOBJECTAPPLEPROC, glFinishObjectAPPLE, APPLE_FENCE, NULL )\ - /* GLX_SGI_video_sync */ \ - USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC, glXGetVideoSyncSGI, SGI_VIDEO_SYNC, NULL )\ - USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC, glXWaitVideoSyncSGI, SGI_VIDEO_SYNC, NULL )\ - /* GL_APPLE_flush_render */ \ - USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC, glFlushRenderAPPLE, APPLE_FLUSH_RENDER, NULL )\ - USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC, glFinishRenderAPPLE, APPLE_FLUSH_RENDER, NULL )\ - /* GL_EXT_gpu_program_parameters */ \ - USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC, glProgramEnvParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS,NULL )\ - USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC, glProgramLocalParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS,NULL )\ - /* GL_ATI_fragment_shader */ \ - USE_GL_FUNC(PGLFNGENFRAGMENTSHADERSATI, glGenFragmentShadersATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNBINDFRAGMENTSHADERATI, glBindFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNDELETEFRAGMENTSHADERATI, glDeleteFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNBEGINFRAGMENTSHADERATI, glBeginFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNENDFRAGMENTSHADERATI, glEndFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNPASSTEXCOORDATI, glPassTexCoordATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNSAMPLEMAPATI, glSampleMapATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNCOLORFRAGMENTOP1ATI, glColorFragmentOp1ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNCOLORFRAGMENTOP2ATI, glColorFragmentOp2ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNCOLORFRAGMENTOP3ATI, glColorFragmentOp3ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNALPHAFRAGMENTOP1ATI, glAlphaFragmentOp1ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNALPHAFRAGMENTOP2ATI, glAlphaFragmentOp2ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNALPHAFRAGMENTOP3ATI, glAlphaFragmentOp3ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNSETFRAGMENTSHADERCONSTANTATI, glSetFragmentShaderConstantATI, ATI_FRAGMENT_SHADER, NULL )\ - /* GL_APPLE_flush_buffer_range */ \ - USE_GL_FUNC(PGLFNBUFFERPARAMETERIAPPLE, glBufferParameteriAPPLE, APPLE_FLUSH_BUFFER_RANGE,NULL)\ - USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE, glFlushMappedBufferRangeAPPLE, APPLE_FLUSH_BUFFER_RANGE,NULL) - - -/**************************************************** - * OpenGL WGL defines and functions pointer - ****************************************************/ +/* GLX_SGI_video_sync */ +typedef int (WINE_GLAPI *PGLXFNGETVIDEOSYNCSGIPROC)(unsigned int *); +typedef int (WINE_GLAPI *PGLXFNWAITVIDEOSYNCSGIPROC)(int, int, unsigned int *); /* WGL_ARB_extensions_string */ -typedef const char * (WINAPI * WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +typedef const char *(WINAPI *WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc); + /* WGL_ARB_multisample */ #ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 #endif -/* WGL_ARB_pixel_format */ -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif -typedef BOOL (WINAPI * WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -/* WGL_ARB_make_current_read */ -typedef BOOL (WINAPI * WINED3D_PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * WINED3D_PFNWGLGETCURRENTREADDCARBPROC) (void); + /* WGL_ARB_pbuffer */ #ifndef WGL_ARB_pbuffer #define WGL_ARB_pbuffer 1 -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 +#define WGL_DRAW_TO_PBUFFER_ARB 0x202d +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202e +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202f +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 #endif DECLARE_HANDLE(HPBUFFERARB); -typedef HPBUFFERARB (WINAPI * WINED3D_PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * WINED3D_PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (WINAPI * WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); -typedef BOOL (WINAPI * WINED3D_PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * WINED3D_PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +typedef HPBUFFERARB (WINAPI *WINED3D_PFNWGLCREATEPBUFFERARBPROC)(HDC hDC, int iPixelFormat, + int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI *WINED3D_PFNWGLGETPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer); +typedef int (WINAPI *WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI *WINED3D_PFNWGLDESTROYPBUFFERARBPROC)(HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI *WINED3D_PFNWGLQUERYPBUFFERARBPROC)(HPBUFFERARB hPbuffer, int iAttribute, int *piValue); + +/* WGL_ARB_pixel_format */ +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200a +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203a +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203b +#define WGL_SHARE_DEPTH_ARB 0x200c +#define WGL_SHARE_STENCIL_ARB 0x200d +#define WGL_SHARE_ACCUM_ARB 0x200e +#define WGL_SUPPORT_GDI_ARB 0x200f +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201a +#define WGL_ALPHA_BITS_ARB 0x201b +#define WGL_ALPHA_SHIFT_ARB 0x201c +#define WGL_ACCUM_BITS_ARB 0x201d +#define WGL_ACCUM_RED_BITS_ARB 0x201e +#define WGL_ACCUM_GREEN_BITS_ARB 0x201f +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202a +#define WGL_TYPE_RGBA_ARB 0x202b +#define WGL_TYPE_COLORINDEX_ARB 0x202c +#endif +typedef BOOL (WINAPI *WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC hdc, int iPixelFormat, + int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI *WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC)(HDC hdc, int iPixelFormat, + int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI *WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int *piAttribIList, + const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); + +/* WGL_ARB_pixel_format_float */ #ifndef WGL_ARB_pixel_format_float #define WGL_ARB_pixel_format_float 1 -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21a0 #endif + /* WGL_WINE_pixel_format_passthrough */ -typedef BOOL (WINAPI * WINED3D_PFNWGLSETPIXELFORMATWINE) (HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR* ppfd); +typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelFormat, + const PIXELFORMATDESCRIPTOR *ppfd); + +#define GL_EXT_FUNCS_GEN \ + /* GL_APPLE_fence */ \ + USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC, \ + glGenFencesAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNDELETEFENCESAPPLEPROC, \ + glDeleteFencesAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNSETFENCEAPPLEPROC, \ + glSetFenceAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNTESTFENCEAPPLEPROC, \ + glTestFenceAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNFINISHFENCEAPPLEPROC, \ + glFinishFenceAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNISFENCEAPPLEPROC, \ + glIsFenceAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNTESTOBJECTAPPLEPROC, \ + glTestObjectAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNFINISHOBJECTAPPLEPROC, \ + glFinishObjectAPPLE, APPLE_FENCE, NULL) \ + /* GL_APPLE_flush_buffer_range */ \ + USE_GL_FUNC(PGLFNBUFFERPARAMETERIAPPLE, \ + glBufferParameteriAPPLE, APPLE_FLUSH_BUFFER_RANGE, NULL) \ + USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE, \ + glFlushMappedBufferRangeAPPLE, APPLE_FLUSH_BUFFER_RANGE, NULL) \ + /* GL_APPLE_flush_render */ \ + USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC, \ + glFlushRenderAPPLE, APPLE_FLUSH_RENDER, NULL) \ + USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC, \ + glFinishRenderAPPLE, APPLE_FLUSH_RENDER, NULL) \ + /* GL_ARB_color_buffer_float */ \ + USE_GL_FUNC(PGLFNCLAMPCOLORARBPROC, \ + glClampColorARB, ARB_COLOR_BUFFER_FLOAT, NULL) \ + /* GL_ARB_draw_buffers */ \ + USE_GL_FUNC(PGLFNDRAWBUFFERSARBPROC, \ + glDrawBuffersARB, ARB_DRAW_BUFFERS, NULL) \ + /* GL_ARB_framebuffer_object */ \ + USE_GL_FUNC(PGLFNGLISRENDERBUFFERPROC, \ + glIsRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBINDRENDERBUFFERPROC, \ + glBindRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSPROC, \ + glDeleteRenderbuffers, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSPROC, \ + glGenRenderbuffers, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEPROC, \ + glRenderbufferStorage, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC, \ + glRenderbufferStorageMultisample, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVPROC, \ + glGetRenderbufferParameteriv, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLISFRAMEBUFFERPROC, \ + glIsFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFERPROC, \ + glBindFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSPROC, \ + glDeleteFramebuffers, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSPROC, \ + glGenFramebuffers, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSPROC, \ + glCheckFramebufferStatus, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DPROC, \ + glFramebufferTexture1D, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DPROC, \ + glFramebufferTexture2D, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DPROC, \ + glFramebufferTexture3D, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURELAYERPROC, \ + glFramebufferTextureLayer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFERPROC, \ + glFramebufferRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC, \ + glGetFramebufferAttachmentParameteriv, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFERPROC, \ + glBlitFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENERATEMIPMAPPROC, \ + glGenerateMipmap, ARB_FRAMEBUFFER_OBJECT, NULL) \ + /* GL_ARB_geometry_shader4 */ \ + USE_GL_FUNC(PGLFNPROGRAMPARAMETERIARBPROC, \ + glProgramParameteriARB, ARB_GEOMETRY_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREARBPROC, \ + glFramebufferTextureARB, ARB_GEOMETRY_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTURELAYERARBPROC, \ + glFramebufferTextureLayerARB, ARB_GEOMETRY_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREFACEARBPROC, \ + glFramebufferTextureFaceARB, ARB_GEOMETRY_SHADER4, NULL) \ + /* GL_ARB_imaging, GL_EXT_blend_minmax */ \ + USE_GL_FUNC(PGLFNBLENDCOLORPROC, \ + glBlendColorEXT, EXT_BLEND_COLOR, NULL) \ + USE_GL_FUNC(PGLFNBLENDEQUATIONPROC, \ + glBlendEquationEXT, EXT_BLEND_MINMAX, NULL) \ + /* GL_ARB_map_buffer_range */ \ + USE_GL_FUNC(PGLFNMAPBUFFERRANGEPROC, \ + glMapBufferRange, ARB_MAP_BUFFER_RANGE, NULL) \ + USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEPROC, \ + glFlushMappedBufferRange, ARB_MAP_BUFFER_RANGE, NULL) \ + /* GL_ARB_multisample */ \ + USE_GL_FUNC(WINED3D_PFNGLSAMPLECOVERAGEARBPROC, \ + glSampleCoverageARB, ARB_MULTISAMPLE, NULL) \ + /* GL_ARB_multitexture */ \ + USE_GL_FUNC(WINED3D_PFNGLACTIVETEXTUREARBPROC, \ + glActiveTextureARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC, \ + glClientActiveTextureARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FARBPROC, \ + glMultiTexCoord1fARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FVARBPROC, \ + glMultiTexCoord1fvARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FARBPROC, \ + glMultiTexCoord2fARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FVARBPROC, \ + glMultiTexCoord2fvARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FARBPROC, \ + glMultiTexCoord3fARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FVARBPROC, \ + glMultiTexCoord3fvARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FARBPROC, \ + glMultiTexCoord4fARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FVARBPROC, \ + glMultiTexCoord4fvARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2SVARBPROC, \ + glMultiTexCoord2svARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4SVARBPROC, \ + glMultiTexCoord4svARB, ARB_MULTITEXTURE, NULL) \ + /* GL_ARB_occlusion_query */ \ + USE_GL_FUNC(PGLFNGENQUERIESARBPROC, \ + glGenQueriesARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNDELETEQUERIESARBPROC, \ + glDeleteQueriesARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNBEGINQUERYARBPROC, \ + glBeginQueryARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNENDQUERYARBPROC, \ + glEndQueryARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNGETQUERYOBJECTIVARBPROC, \ + glGetQueryObjectivARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNGETQUERYOBJECTUIVARBPROC, \ + glGetQueryObjectuivARB, ARB_OCCLUSION_QUERY, NULL) \ + /* GL_ARB_point_parameters */ \ + USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC, \ + glPointParameterfARB, ARB_POINT_PARAMETERS, NULL) \ + USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC, \ + glPointParameterfvARB, ARB_POINT_PARAMETERS, NULL) \ + /* GL_ARB_provoking_vertex */ \ + USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXPROC, \ + glProvokingVertex, ARB_PROVOKING_VERTEX, NULL) \ + /* GL_ARB_shader_objects */ \ + USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC, \ + glGetObjectParameterivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC, \ + glGetObjectParameterfvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC, \ + glGetUniformLocationARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETACTIVEUNIFORMARBPROC, \ + glGetActiveUniformARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, \ + glUniform1iARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IARBPROC, \ + glUniform2iARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IARBPROC, \ + glUniform3iARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IARBPROC, \ + glUniform4iARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, \ + glUniform1fARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FARBPROC, \ + glUniform2fARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FARBPROC, \ + glUniform3fARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FARBPROC, \ + glUniform4fARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM1FVARBPROC, \ + glUniform1fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FVARBPROC, \ + glUniform2fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FVARBPROC, \ + glUniform3fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FVARBPROC, \ + glUniform4fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IVARBPROC, \ + glUniform1ivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IVARBPROC, \ + glUniform2ivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IVARBPROC, \ + glUniform3ivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IVARBPROC, \ + glUniform4ivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC, \ + glUniformMatrix2fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC, \ + glUniformMatrix3fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC, \ + glUniformMatrix4fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC, \ + glGetUniformfvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC, \ + glGetUniformivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC, \ + glGetInfoLogARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC, \ + glUseProgramObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC, \ + glCreateShaderObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLSHADERSOURCEARBPROC, \ + glShaderSourceARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLCOMPILESHADERARBPROC, \ + glCompileShaderARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC, \ + glCreateProgramObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLATTACHOBJECTARBPROC, \ + glAttachObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLLINKPROGRAMARBPROC, \ + glLinkProgramARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLDETACHOBJECTARBPROC, \ + glDetachObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLDELETEOBJECTARBPROC, \ + glDeleteObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLVALIDATEPROGRAMARBPROC, \ + glValidateProgramARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC, \ + glGetAttachedObjectsARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETHANDLEARBPROC, \ + glGetHandleARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETSHADERSOURCEARBPROC, \ + glGetShaderSourceARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC, \ + glBindAttribLocationARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETATTRIBLOCATIONARBPROC, \ + glGetAttribLocationARB, ARB_SHADER_OBJECTS, NULL) \ + /* GL_ARB_sync */ \ + USE_GL_FUNC(PGLFNFENCESYNCPROC, \ + glFenceSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNISSYNCPROC, \ + glIsSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNDELETESYNCPROC, \ + glDeleteSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNCLIENTWAITSYNCPROC, \ + glClientWaitSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNWAITSYNCPROC, \ + glWaitSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNGETINTEGER64VPROC, \ + glGetInteger64v, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNGETSYNCIVPROC, \ + glGetSynciv, ARB_SYNC, NULL) \ + /* GL_ARB_texture_compression */ \ + USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC, \ + glCompressedTexImage2DARB, ARB_TEXTURE_COMPRESSION, NULL) \ + USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE3DPROC, \ + glCompressedTexImage3DARB, ARB_TEXTURE_COMPRESSION, NULL) \ + USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC, \ + glCompressedTexSubImage2DARB, ARB_TEXTURE_COMPRESSION, NULL) \ + USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC, \ + glCompressedTexSubImage3DARB, ARB_TEXTURE_COMPRESSION, NULL) \ + USE_GL_FUNC(PGLFNGETCOMPRESSEDTEXIMAGEPROC, \ + glGetCompressedTexImageARB, ARB_TEXTURE_COMPRESSION, NULL) \ + /* GL_ARB_vertex_blend */ \ + USE_GL_FUNC(PGLFNGLWEIGHTPOINTERARB, \ + glWeightPointerARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTBV, \ + glWeightbvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTSV, \ + glWeightsvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTIV, \ + glWeightivARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTFV, \ + glWeightfvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTDV, \ + glWeightdvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTUBV, \ + glWeightubvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTUSV, \ + glWeightusvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTUIV, \ + glWeightuivARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLVERTEXBLENDARB, \ + glVertexBlendARB, ARB_VERTEX_BLEND, NULL) \ + /* GL_ARB_vertex_buffer_object */ \ + USE_GL_FUNC(PGLFNBINDBUFFERARBPROC, \ + glBindBufferARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNDELETEBUFFERSARBPROC, \ + glDeleteBuffersARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGENBUFFERSARBPROC, \ + glGenBuffersARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNISBUFFERARBPROC, \ + glIsBufferARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNBUFFERDATAARBPROC, \ + glBufferDataARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNBUFFERSUBDATAARBPROC, \ + glBufferSubDataARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGETBUFFERSUBDATAARBPROC, \ + glGetBufferSubDataARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNMAPBUFFERARBPROC, \ + glMapBufferARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNUNMAPBUFFERARBPROC, \ + glUnmapBufferARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGETBUFFERPARAMETERIVARBPROC, \ + glGetBufferParameterivARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGETBUFFERPOINTERVARBPROC, \ + glGetBufferPointervARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + /* GL_ARB_vertex_program */ \ + USE_GL_FUNC(PGLFNGENPROGRAMSARBPROC, \ + glGenProgramsARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNBINDPROGRAMARBPROC, \ + glBindProgramARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNPROGRAMSTRINGARBPROC, \ + glProgramStringARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNDELETEPROGRAMSARBPROC, \ + glDeleteProgramsARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNPROGRAMENVPARAMETER4FVARBPROC, \ + glProgramEnvParameter4fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETER4FVARBPROC, \ + glProgramLocalParameter4fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC, \ + glVertexAttribPointerARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC, \ + glEnableVertexAttribArrayARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC, \ + glDisableVertexAttribArrayARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1DARBPROC, \ + glVertexAttrib1dARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1DVARBPROC, \ + glVertexAttrib1dvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1FARBPROC, \ + glVertexAttrib1fARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1FVARBPROC, \ + glVertexAttrib1fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1SARBPROC, \ + glVertexAttrib1sARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1SVARBPROC, \ + glVertexAttrib1svARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2DARBPROC, \ + glVertexAttrib2dARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2DVARBPROC, \ + glVertexAttrib2dvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2FARBPROC, \ + glVertexAttrib2fARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2FVARBPROC, \ + glVertexAttrib2fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2SARBPROC, \ + glVertexAttrib2sARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2SVARBPROC, \ + glVertexAttrib2svARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3DARBPROC, \ + glVertexAttrib3dARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3DVARBPROC, \ + glVertexAttrib3dvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3FARBPROC, \ + glVertexAttrib3fARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3FVARBPROC, \ + glVertexAttrib3fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3SARBPROC, \ + glVertexAttrib3sARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3SVARBPROC, \ + glVertexAttrib3svARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NBVARBPROC, \ + glVertexAttrib4NbvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NIVARBPROC, \ + glVertexAttrib4NivARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NSVARBPROC, \ + glVertexAttrib4NsvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBARBPROC, \ + glVertexAttrib4NubARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBVARBPROC, \ + glVertexAttrib4NubvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NUIVARBPROC, \ + glVertexAttrib4NuivARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NUSVARBPROC, \ + glVertexAttrib4NusvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4BVARBPROC, \ + glVertexAttrib4bvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4DARBPROC, \ + glVertexAttrib4dARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4DVARBPROC, \ + glVertexAttrib4dvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4FARBPROC, \ + glVertexAttrib4fARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4FVARBPROC, \ + glVertexAttrib4fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4IVARBPROC, \ + glVertexAttrib4ivARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4SARBPROC, \ + glVertexAttrib4sARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4SVARBPROC, \ + glVertexAttrib4svARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4UBVARBPROC, \ + glVertexAttrib4ubvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4UIVARBPROC, \ + glVertexAttrib4uivARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4USVARBPROC, \ + glVertexAttrib4usvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNGETPROGRAMIVARBPROC, \ + glGetProgramivARB, ARB_VERTEX_PROGRAM, NULL) \ + /* GL_ATI_fragment_shader */ \ + USE_GL_FUNC(PGLFNGENFRAGMENTSHADERSATI, \ + glGenFragmentShadersATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNBINDFRAGMENTSHADERATI, \ + glBindFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNDELETEFRAGMENTSHADERATI, \ + glDeleteFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNBEGINFRAGMENTSHADERATI, \ + glBeginFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNENDFRAGMENTSHADERATI, \ + glEndFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNPASSTEXCOORDATI, \ + glPassTexCoordATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNSAMPLEMAPATI, \ + glSampleMapATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNCOLORFRAGMENTOP1ATI, \ + glColorFragmentOp1ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNCOLORFRAGMENTOP2ATI, \ + glColorFragmentOp2ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNCOLORFRAGMENTOP3ATI, \ + glColorFragmentOp3ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNALPHAFRAGMENTOP1ATI, \ + glAlphaFragmentOp1ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNALPHAFRAGMENTOP2ATI, \ + glAlphaFragmentOp2ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNALPHAFRAGMENTOP3ATI, \ + glAlphaFragmentOp3ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNSETFRAGMENTSHADERCONSTANTATI, \ + glSetFragmentShaderConstantATI, ATI_FRAGMENT_SHADER, NULL) \ + /* GL_ATI_separate_stencil */ \ + USE_GL_FUNC(PGLFNSTENCILOPSEPARATEATIPROC, \ + glStencilOpSeparateATI, ATI_SEPARATE_STENCIL, NULL) \ + USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEATIPROC, \ + glStencilFuncSeparateATI, ATI_SEPARATE_STENCIL, NULL) \ + /* GL_EXT_blend_equation_separate */ \ + USE_GL_FUNC(PGLFNBLENDFUNCSEPARATEEXTPROC, \ + glBlendFuncSeparateEXT, EXT_BLEND_FUNC_SEPARATE, NULL) \ + /* GL_EXT_blend_func_separate */ \ + USE_GL_FUNC(PGLFNBLENDEQUATIONSEPARATEEXTPROC, \ + glBlendEquationSeparateEXT, EXT_BLEND_EQUATION_SEPARATE, NULL) \ + /* GL_EXT_fog_coord */ \ + USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC, \ + glFogCoordfEXT, EXT_FOG_COORD, NULL) \ + USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC, \ + glFogCoordfvEXT, EXT_FOG_COORD, NULL) \ + USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC, \ + glFogCoorddEXT, EXT_FOG_COORD, NULL) \ + USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC, \ + glFogCoorddvEXT, EXT_FOG_COORD, NULL) \ + USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC, \ + glFogCoordPointerEXT, EXT_FOG_COORD, NULL) \ + /* GL_EXT_framebuffer_blit */ \ + USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFEREXTPROC, \ + glBlitFramebufferEXT, EXT_FRAMEBUFFER_BLIT, NULL) \ + /* GL_EXT_framebuffer_multisample */ \ + USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC, \ + glRenderbufferStorageMultisampleEXT, EXT_FRAMEBUFFER_MULTISAMPLE, NULL) \ + /* GL_EXT_framebuffer_object */ \ + USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC, \ + glIsRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBINDRENDERBUFFEREXTPROC, \ + glBindRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSEXTPROC, \ + glDeleteRenderbuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSEXTPROC, \ + glGenRenderbuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEEXTPROC, \ + glRenderbufferStorageEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLISFRAMEBUFFEREXTPROC, \ + glIsFramebufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFEREXTPROC, \ + glBindFramebufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSEXTPROC, \ + glDeleteFramebuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSEXTPROC, \ + glGenFramebuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, \ + glCheckFramebufferStatusEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC, \ + glFramebufferTexture1DEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC, \ + glFramebufferTexture2DEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC, \ + glFramebufferTexture3DEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC, \ + glFramebufferRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENERATEMIPMAPEXTPROC, \ + glGenerateMipmapEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC, \ + glGetRenderbufferParameterivEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC, \ + glGetFramebufferAttachmentParameterivEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + /* GL_EXT_gpu_program_parameters */ \ + USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC, \ + glProgramEnvParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS, NULL) \ + USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC, \ + glProgramLocalParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS, NULL) \ + /* GL_EXT_gpu_shader4 */\ + USE_GL_FUNC(PGLFNVERTEXATTRIBI1IEXTPROC, \ + glVertexAttribI1iEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI2IEXTPROC, \ + glVertexAttribI2iEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI3IEXTPROC, \ + glVertexAttribI3iEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4IEXTPROC, \ + glVertexAttribI4iEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI1UIEXTPROC, \ + glVertexAttribI1uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI2UIEXTPROC, \ + glVertexAttribI2uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI3UIEXTPROC, \ + glVertexAttribI3uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4UIEXTPROC, \ + glVertexAttribI4uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI1IVEXTPROC, \ + glVertexAttribI1ivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI2IVEXTPROC, \ + glVertexAttribI2ivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI3IVEXTPROC, \ + glVertexAttribI3ivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4IVEXTPROC, \ + glVertexAttribI4ivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI1UIVEXTPROC, \ + glVertexAttribI1uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI2UIVEXTPROC, \ + glVertexAttribI2uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI3UIVEXTPROC, \ + glVertexAttribI3uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4UIVEXTPROC, \ + glVertexAttribI4uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4BVEXTPROC, \ + glVertexAttribI4bvEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4SVEXTPROC, \ + glVertexAttribI4svEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4UBVEXTPROC, \ + glVertexAttribI4ubvEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4USVEXTPROC, \ + glVertexAttribI4usvEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBIPOINTEREXTPROC, \ + glVertexAttribIPointerEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNGETVERTEXATTRIBIIVEXTPROC, \ + glVertexAttribIivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNGETVERTEXATTRIBIUIVEXTPROC, \ + glVertexAttribIuivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM1UIEXTPROC, \ + glUniform1uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM2UIEXTPROC, \ + glUniform2uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM3UIEXTPROC, \ + glUniform3uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM4UIEXTPROC, \ + glUniform4uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM1UIVEXTPROC, \ + glUniform1uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM2UIVEXTPROC, \ + glUniform2uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM3UIVEXTPROC, \ + glUniform3uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM4UIVEXTPROC, \ + glUniform4uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNGETUNIFORMUIVEXTPROC, \ + glGetUniformuivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNBINDFRAGDATALOCATIONEXTPROC, \ + glBindFragDataLocationEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNGETFRAGDATALOCATIONEXTPROC, \ + glGetFragDataLocationEXT, EXT_GPU_SHADER4, NULL) \ + /* GL_EXT_paletted_texture */ \ + USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC, \ + glColorTableEXT, EXT_PALETTED_TEXTURE, NULL) \ + /* GL_EXT_point_parameters */ \ + USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC, \ + glPointParameterfEXT, EXT_POINT_PARAMETERS, NULL) \ + USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC, \ + glPointParameterfvEXT, EXT_POINT_PARAMETERS, NULL) \ + /* GL_EXT_provoking_vertex */ \ + USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXEXTPROC, \ + glProvokingVertexEXT, EXT_PROVOKING_VERTEX, NULL) \ + /* GL_EXT_secondary_color */ \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC, \ + glSecondaryColor3ubEXT, EXT_SECONDARY_COLOR, NULL) \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBVEXTPROC, \ + glSecondaryColor3ubvEXT, EXT_SECONDARY_COLOR, NULL) \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC, \ + glSecondaryColor3fEXT, EXT_SECONDARY_COLOR, NULL) \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC, \ + glSecondaryColor3fvEXT, EXT_SECONDARY_COLOR, NULL) \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC, \ + glSecondaryColorPointerEXT, EXT_SECONDARY_COLOR, NULL) \ + /* GL_EXT_stencil_two_side */ \ + USE_GL_FUNC(PGLFNACTIVESTENCILFACEEXTPROC, \ + glActiveStencilFaceEXT, EXT_STENCIL_TWO_SIDE, NULL) \ + /* GL_EXT_texture3D */ \ + USE_GL_FUNC(PGLFNGLTEXIMAGE3DEXTPROC, \ + glTexImage3DEXT, EXT_TEXTURE3D, glTexImage3D) \ + USE_GL_FUNC(PGLFNGLTEXSUBIMAGE3DEXTPROC, \ + glTexSubImage3DEXT, EXT_TEXTURE3D, glTexSubImage3D) \ + /* GL_NV_fence */ \ + USE_GL_FUNC(PGLFNGENFENCESNVPROC, \ + glGenFencesNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNDELETEFENCESNVPROC, \ + glDeleteFencesNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNSETFENCENVPROC, \ + glSetFenceNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNTESTFENCENVPROC, \ + glTestFenceNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNFINISHFENCENVPROC, \ + glFinishFenceNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNISFENCENVPROC, \ + glIsFenceNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNGETFENCEIVNVPROC, \ + glGetFenceivNV, NV_FENCE, NULL) \ + /* GL_NV_half_float */ \ + USE_GL_FUNC(PGLFNVERTEX2HNVPROC, \ + glVertex2hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX2HVNVPROC, \ + glVertex2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX3HNVPROC, \ + glVertex3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX3HVNVPROC, \ + glVertex3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX4HNVPROC, \ + glVertex4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX4HVNVPROC, \ + glVertex4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNNORMAL3HNVPROC, \ + glNormal3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNNORMAL3HVNVPROC, \ + glNormal3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNCOLOR3HNVPROC, \ + glColor3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNCOLOR3HVNVPROC, \ + glColor3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNCOLOR4HNVPROC, \ + glColor4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNCOLOR4HVNVPROC, \ + glColor4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD1HNVPROC, \ + glTexCoord1hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD1HVNVPROC, \ + glTexCoord1hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD2HNVPROC, \ + glTexCoord2hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD2HVNVPROC, \ + glTexCoord2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD3HNVPROC, \ + glTexCoord3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD3HVNVPROC, \ + glTexCoord3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD4HNVPROC, \ + glTexCoord4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD4HVNVPROC, \ + glTexCoord4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD1HNVPROC, \ + glMultiTexCoord1hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD1HVNVPROC, \ + glMultiTexCoord1hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD2HNVPROC, \ + glMultiTexCoord2hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD2HVNVPROC, \ + glMultiTexCoord2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD3HNVPROC, \ + glMultiTexCoord3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD3HVNVPROC, \ + glMultiTexCoord3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD4HNVPROC, \ + glMultiTexCoord4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD4HVNVPROC, \ + glMultiTexCoord4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNFOGCOORDHNVPROC, \ + glFogCoordhNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNFOGCOORDHVNVPROC, \ + glFogCoordhvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNSECONDARYCOLOR3HNVPROC, \ + glSecondaryColor3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNSECONDARYCOLOR3HVNVPROC, \ + glSecondaryColor3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXWEIGHTHNVPROC, \ + glVertexWeighthNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXWEIGHTHVNVPROC, \ + glVertexWeighthvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1HNVPROC, \ + glVertexAttrib1hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1HVNVPROC, \ + glVertexAttrib1hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2HNVPROC, \ + glVertexAttrib2hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2HVNVPROC, \ + glVertexAttrib2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3HNVPROC, \ + glVertexAttrib3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3HVNVPROC, \ + glVertexAttrib3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4HNVPROC, \ + glVertexAttrib4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4HVNVPROC, \ + glVertexAttrib4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBS1HVNVPROC, \ + glVertexAttribs1hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBS2HVNVPROC, \ + glVertexAttribs2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBS3HVNVPROC, \ + glVertexAttribs3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBS4HVNVPROC, \ + glVertexAttribs4hvNV, NV_HALF_FLOAT, NULL) \ + /* GL_NV_register_combiners */ \ + USE_GL_FUNC(PGLFNCOMBINERINPUTNVPROC, \ + glCombinerInputNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINEROUTPUTNVPROC, \ + glCombinerOutputNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINERPARAMETERFNVPROC, \ + glCombinerParameterfNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINERPARAMETERFVNVPROC, \ + glCombinerParameterfvNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINERPARAMETERINVPROC, \ + glCombinerParameteriNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINERPARAMETERIVNVPROC, \ + glCombinerParameterivNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC, \ + glFinalCombinerInputNV, NV_REGISTER_COMBINERS, NULL) \ + /* GLX_SGI_video_sync */ \ + USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC, \ + glXGetVideoSyncSGI, SGI_VIDEO_SYNC, NULL) \ + USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC, \ + glXWaitVideoSyncSGI, SGI_VIDEO_SYNC, NULL) #define WGL_EXT_FUNCS_GEN \ - USE_GL_FUNC(WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLMAKECONTEXTCURRENTARBPROC, wglMakeContextCurrentARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLGETCURRENTREADDCARBPROC, wglGetCurrentReadDCARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL) - - -/**************************************************** - * Structures - ****************************************************/ - -struct wined3d_fbo_ops -{ - PGLFNGLISRENDERBUFFERPROC glIsRenderbuffer; - PGLFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; - PGLFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; - PGLFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; - PGLFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; - PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; - PGLFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv; - PGLFNGLISFRAMEBUFFERPROC glIsFramebuffer; - PGLFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; - PGLFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; - PGLFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; - PGLFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; - PGLFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; - PGLFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; - PGLFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; - PGLFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; - PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; - PGLFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; - PGLFNGLGENERATEMIPMAPPROC glGenerateMipmap; -}; - -struct wined3d_gl_limits -{ - UINT buffers; - UINT lights; - UINT textures; - UINT texture_stages; - UINT fragment_samplers; - UINT vertex_samplers; - UINT combined_samplers; - UINT sampler_stages; - UINT clipplanes; - UINT texture_size; - UINT texture3d_size; - float pointsize_max; - float pointsize_min; - UINT point_sprite_units; - UINT blends; - UINT anisotropy; - float shininess; - - UINT glsl_varyings; - UINT glsl_vs_float_constants; - UINT glsl_ps_float_constants; - - UINT arb_vs_float_constants; - UINT arb_vs_native_constants; - UINT arb_vs_instructions; - UINT arb_vs_temps; - UINT arb_ps_float_constants; - UINT arb_ps_local_constants; - UINT arb_ps_native_constants; - UINT arb_ps_instructions; - UINT arb_ps_temps; -}; - -#define USE_GL_FUNC(type, pfn, ext, replace) type pfn; - -struct wined3d_gl_info -{ - UINT vidmem; - struct wined3d_gl_limits limits; - DWORD reserved_glsl_constants; - DWORD quirks; - BOOL supported[WINED3D_GL_EXT_COUNT]; - GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1]; - - struct wined3d_fbo_ops fbo_ops; - /* GL function pointers */ - GL_EXT_FUNCS_GEN - /* WGL function pointers */ - WGL_EXT_FUNCS_GEN - - struct GlPixelFormatDesc *gl_formats; -}; - -#undef USE_GL_FUNC + USE_GL_FUNC(WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL) #endif /* __WINE_WINED3D_GL */ diff --git a/reactos/dll/directx/wine/wined3d/wined3d_private.h b/reactos/dll/directx/wine/wined3d/wined3d_private.h index de0bcdc2c54..1d5cd974645 100644 --- a/reactos/dll/directx/wine/wined3d/wined3d_private.h +++ b/reactos/dll/directx/wine/wined3d/wined3d_private.h @@ -61,15 +61,16 @@ enum fixup_channel_source CHANNEL_SOURCE_Y = 3, CHANNEL_SOURCE_Z = 4, CHANNEL_SOURCE_W = 5, - CHANNEL_SOURCE_YUV0 = 6, - CHANNEL_SOURCE_YUV1 = 7, + CHANNEL_SOURCE_COMPLEX0 = 6, + CHANNEL_SOURCE_COMPLEX1 = 7, }; -enum yuv_fixup +enum complex_fixup { - YUV_FIXUP_YUY2 = 0, - YUV_FIXUP_UYVY = 1, - YUV_FIXUP_YV12 = 2, + COMPLEX_FIXUP_YUY2 = 0, + COMPLEX_FIXUP_UYVY = 1, + COMPLEX_FIXUP_YV12 = 2, + COMPLEX_FIXUP_P8 = 3, }; #include @@ -103,14 +104,14 @@ static inline struct color_fixup_desc create_color_fixup_desc( return fixup; } -static inline struct color_fixup_desc create_yuv_fixup_desc(enum yuv_fixup yuv_fixup) +static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup) { struct color_fixup_desc fixup = { - 0, yuv_fixup & (1 << 0) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0, - 0, yuv_fixup & (1 << 1) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0, - 0, yuv_fixup & (1 << 2) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0, - 0, yuv_fixup & (1 << 3) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0, + 0, complex_fixup & (1 << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0, + 0, complex_fixup & (1 << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0, + 0, complex_fixup & (1 << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0, + 0, complex_fixup & (1 << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0, }; return fixup; } @@ -120,19 +121,19 @@ static inline BOOL is_identity_fixup(struct color_fixup_desc fixup) return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup)); } -static inline BOOL is_yuv_fixup(struct color_fixup_desc fixup) +static inline BOOL is_complex_fixup(struct color_fixup_desc fixup) { - return fixup.x_source == CHANNEL_SOURCE_YUV0 || fixup.x_source == CHANNEL_SOURCE_YUV1; + return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1; } -static inline enum yuv_fixup get_yuv_fixup(struct color_fixup_desc fixup) +static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup) { - enum yuv_fixup yuv_fixup = 0; - if (fixup.x_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 0); - if (fixup.y_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 1); - if (fixup.z_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 2); - if (fixup.w_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 3); - return yuv_fixup; + enum complex_fixup complex_fixup = 0; + if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 0); + if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 1); + if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 2); + if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 3); + return complex_fixup; } void *wined3d_rb_alloc(size_t size) DECLSPEC_HIDDEN; @@ -410,6 +411,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER WINED3DSIH_CMP, WINED3DSIH_CND, WINED3DSIH_CRS, + WINED3DSIH_CUT, WINED3DSIH_DCL, WINED3DSIH_DEF, WINED3DSIH_DEFB, @@ -421,20 +423,24 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER WINED3DSIH_DSX, WINED3DSIH_DSY, WINED3DSIH_ELSE, + WINED3DSIH_EMIT, WINED3DSIH_ENDIF, WINED3DSIH_ENDLOOP, WINED3DSIH_ENDREP, WINED3DSIH_EXP, WINED3DSIH_EXPP, WINED3DSIH_FRC, + WINED3DSIH_IADD, WINED3DSIH_IF, WINED3DSIH_IFC, + WINED3DSIH_IGE, WINED3DSIH_LABEL, WINED3DSIH_LIT, WINED3DSIH_LOG, WINED3DSIH_LOGP, WINED3DSIH_LOOP, WINED3DSIH_LRP, + WINED3DSIH_LT, WINED3DSIH_M3x2, WINED3DSIH_M3x3, WINED3DSIH_M3x4, @@ -544,6 +550,7 @@ typedef struct shader_reg_maps struct wined3d_shader_context { IWineD3DBaseShader *shader; + const struct wined3d_gl_info *gl_info; const struct shader_reg_maps *reg_maps; struct wined3d_shader_buffer *buffer; void *backend_data; @@ -619,7 +626,7 @@ struct wined3d_shader_frontend void (*shader_read_dst_param)(void *data, const DWORD **ptr, struct wined3d_shader_dst_param *dst_param, struct wined3d_shader_src_param *dst_rel_addr); void (*shader_read_semantic)(const DWORD **ptr, struct wined3d_shader_semantic *semantic); - void (*shader_read_comment)(const DWORD **ptr, const char **comment); + void (*shader_read_comment)(const DWORD **ptr, const char **comment, UINT *comment_size); BOOL (*shader_is_end)(void *data, const DWORD **ptr); }; @@ -714,7 +721,7 @@ typedef struct { HRESULT (*shader_alloc_private)(IWineD3DDevice *iface); void (*shader_free_private)(IWineD3DDevice *iface); BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface); - void (*shader_get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct shader_caps *caps); + void (*shader_get_caps)(const struct wined3d_gl_info *gl_info, struct shader_caps *caps); BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup); void (*shader_add_instruction_modifiers)(const struct wined3d_shader_instruction *ins); } shader_backend_t; @@ -988,8 +995,10 @@ extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIPPLANES - 1)) #define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIPPLANES)) +#define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL) #define STATE_FRONTFACE (STATE_MATERIAL + 1) +#define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE) #define STATE_HIGHEST (STATE_FRONTFACE) @@ -1008,13 +1017,28 @@ struct wined3d_occlusion_query struct wined3d_context *context; }; +union wined3d_gl_query_object +{ + GLuint id; + GLsync sync; +}; + struct wined3d_event_query { struct list entry; - GLuint id; + union wined3d_gl_query_object object; struct wined3d_context *context; }; +enum wined3d_event_query_result +{ + WINED3D_EVENT_QUERY_OK, + WINED3D_EVENT_QUERY_WAITING, + WINED3D_EVENT_QUERY_NOT_STARTED, + WINED3D_EVENT_QUERY_WRONG_THREAD, + WINED3D_EVENT_QUERY_ERROR +}; + struct wined3d_context { const struct wined3d_gl_info *gl_info; @@ -1084,7 +1108,7 @@ struct wined3d_context UINT free_occlusion_query_count; struct list occlusion_queries; - GLuint *free_event_queries; + union wined3d_gl_query_object *free_event_queries; UINT free_event_query_size; UINT free_event_query_count; struct list event_queries; @@ -1122,7 +1146,7 @@ struct fragment_caps struct fragment_pipeline { void (*enable_extension)(IWineD3DDevice *iface, BOOL enable); - void (*get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps); + void (*get_caps)(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps); HRESULT (*alloc_private)(IWineD3DDevice *iface); void (*free_private)(IWineD3DDevice *iface); BOOL (*color_fixup_supported)(struct color_fixup_desc fixup); @@ -1224,7 +1248,7 @@ typedef struct WineD3D_PixelFormat { int iPixelFormat; /* WGL pixel format */ int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */ - int redSize, greenSize, blueSize, alphaSize; + int redSize, greenSize, blueSize, alphaSize, colorSize; int depthSize, stencilSize; BOOL windowDrawable; BOOL pbufferDrawable; @@ -1233,13 +1257,23 @@ typedef struct WineD3D_PixelFormat int numSamples; } WineD3D_PixelFormat; +enum wined3d_gl_vendor +{ + GL_VENDOR_WINE, + GL_VENDOR_APPLE, + GL_VENDOR_ATI, + GL_VENDOR_INTEL, + GL_VENDOR_MESA, + GL_VENDOR_NVIDIA, +}; + + enum wined3d_pci_vendor { - VENDOR_WINE = 0x0000, - VENDOR_MESA = 0x0001, - VENDOR_ATI = 0x1002, - VENDOR_NVIDIA = 0x10de, - VENDOR_INTEL = 0x8086, + HW_VENDOR_WINE = 0x0000, + HW_VENDOR_ATI = 0x1002, + HW_VENDOR_NVIDIA = 0x10de, + HW_VENDOR_INTEL = 0x8086, }; enum wined3d_pci_device @@ -1323,6 +1357,85 @@ enum wined3d_pci_device CARD_INTEL_X3100 = 0x2a02, /* Found in Macs. Same as GMA 965? */ }; +struct wined3d_fbo_ops +{ + PGLFNGLISRENDERBUFFERPROC glIsRenderbuffer; + PGLFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; + PGLFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; + PGLFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; + PGLFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; + PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; + PGLFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv; + PGLFNGLISFRAMEBUFFERPROC glIsFramebuffer; + PGLFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; + PGLFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; + PGLFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; + PGLFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; + PGLFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; + PGLFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; + PGLFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; + PGLFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; + PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; + PGLFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; + PGLFNGLGENERATEMIPMAPPROC glGenerateMipmap; +}; + +struct wined3d_gl_limits +{ + UINT buffers; + UINT lights; + UINT textures; + UINT texture_stages; + UINT fragment_samplers; + UINT vertex_samplers; + UINT combined_samplers; + UINT general_combiners; + UINT sampler_stages; + UINT clipplanes; + UINT texture_size; + UINT texture3d_size; + float pointsize_max; + float pointsize_min; + UINT point_sprite_units; + UINT blends; + UINT anisotropy; + float shininess; + + UINT glsl_varyings; + UINT glsl_vs_float_constants; + UINT glsl_ps_float_constants; + + UINT arb_vs_float_constants; + UINT arb_vs_native_constants; + UINT arb_vs_instructions; + UINT arb_vs_temps; + UINT arb_ps_float_constants; + UINT arb_ps_local_constants; + UINT arb_ps_native_constants; + UINT arb_ps_instructions; + UINT arb_ps_temps; +}; + +struct wined3d_gl_info +{ + UINT vidmem; + struct wined3d_gl_limits limits; + DWORD reserved_glsl_constants; + DWORD quirks; + BOOL supported[WINED3D_GL_EXT_COUNT]; + GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1]; + + struct wined3d_fbo_ops fbo_ops; +#define USE_GL_FUNC(type, pfn, ext, replace) type pfn; + /* GL function pointers */ + GL_EXT_FUNCS_GEN + /* WGL function pointers */ + WGL_EXT_FUNCS_GEN +#undef USE_GL_FUNC + + struct GlPixelFormatDesc *gl_formats; +}; + struct wined3d_driver_info { enum wined3d_pci_vendor vendor; @@ -1348,6 +1461,10 @@ struct wined3d_adapter unsigned int TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */ unsigned int UsedTextureRam; LUID luid; + + const struct fragment_pipeline *fragment_pipe; + const shader_backend_t *shader_backend; + const struct blit_shader *blitter; }; BOOL initPixelFormats(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor) DECLSPEC_HIDDEN; @@ -1497,7 +1614,7 @@ struct IWineD3DDeviceImpl const struct fragment_pipeline *frag_pipe; const struct blit_shader *blitter; - unsigned int max_ffp_textures, max_ffp_texture_stages; + unsigned int max_ffp_textures; DWORD d3d_vshader_constantF, d3d_pshader_constantF; /* Advertised d3d caps, not GL ones */ DWORD vs_clipping; @@ -1547,7 +1664,6 @@ struct IWineD3DDeviceImpl UINT NumberOfPalettes; PALETTEENTRY **palettes; UINT currentPalette; - UINT paletteConversionShader; /* For rendering to a texture using glCopyTexImage */ GLenum *draw_buffers; @@ -1602,14 +1718,14 @@ struct IWineD3DDeviceImpl HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags, IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN; +void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN; void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN; -void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, - const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) DECLSPEC_HIDDEN; +void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count, const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN; void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) DECLSPEC_HIDDEN; @@ -1745,6 +1861,7 @@ typedef struct IWineD3DBaseTextureClass void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN; BOOL surface_init_sysmem(IWineD3DSurface *iface) DECLSPEC_HIDDEN; BOOL surface_is_offscreen(IWineD3DSurface *iface) DECLSPEC_HIDDEN; +void surface_prepare_texture(IWineD3DSurfaceImpl *surface, BOOL srgb) DECLSPEC_HIDDEN; typedef struct IWineD3DBaseTextureImpl { @@ -2342,9 +2459,8 @@ typedef struct IWineD3DQueryImpl void *extendedData; } IWineD3DQueryImpl; -extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl DECLSPEC_HIDDEN; -extern const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl DECLSPEC_HIDDEN; -extern const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl DECLSPEC_HIDDEN; +HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, + WINED3DQUERYTYPE type, IUnknown *parent) DECLSPEC_HIDDEN; /* IWineD3DBuffer */ @@ -2495,6 +2611,7 @@ const char *debug_d3ddeclusage(BYTE usage) DECLSPEC_HIDDEN; const char *debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType) DECLSPEC_HIDDEN; const char *debug_d3drenderstate(DWORD state) DECLSPEC_HIDDEN; const char *debug_d3dsamplerstate(DWORD state) DECLSPEC_HIDDEN; +const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN; const char *debug_d3dtexturefiltertype(WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN; const char *debug_d3dtexturestate(DWORD state) DECLSPEC_HIDDEN; const char *debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype) DECLSPEC_HIDDEN; @@ -2552,12 +2669,6 @@ void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED UINT wined3d_log2i(UINT32 x) DECLSPEC_HIDDEN; unsigned int count_bits(unsigned int mask) DECLSPEC_HIDDEN; -const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, - WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN; -const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter, - WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN; -const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, - WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN; void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected) DECLSPEC_HIDDEN; typedef struct local_constant { @@ -2601,8 +2712,6 @@ int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_li extern BOOL vshader_get_input(IWineD3DVertexShader *iface, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN; -extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) DECLSPEC_HIDDEN; - /***************************************************************************** * IDirect3DBaseShader implementation structure */ @@ -2651,7 +2760,6 @@ typedef struct IWineD3DBaseShaderImpl { void shader_buffer_clear(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; void shader_buffer_free(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; -void shader_cleanup(IWineD3DBaseShader *iface) DECLSPEC_HIDDEN; void shader_dump_src_param(const struct wined3d_shader_src_param *param, const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN; void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, @@ -2659,16 +2767,7 @@ void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) DECLSPEC_HIDDEN; void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer, const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN; -HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, - struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature, - struct wined3d_shader_signature_element *output_signature, - const DWORD *byte_code, DWORD constf_size) DECLSPEC_HIDDEN; -void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device, - IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) DECLSPEC_HIDDEN; -const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) DECLSPEC_HIDDEN; -void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) DECLSPEC_HIDDEN; -WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *semantic_name) DECLSPEC_HIDDEN; static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type) { diff --git a/reactos/include/reactos/wine/config.h b/reactos/include/reactos/wine/config.h index cb26f59512c..b677544aa1b 100644 --- a/reactos/include/reactos/wine/config.h +++ b/reactos/include/reactos/wine/config.h @@ -5,6 +5,9 @@ #define __WINE_CONFIG_H +/* Define to a function attribute for Microsoft hotpatch assembly prefix. */ +#define DECLSPEC_HOTPATCH + /* Specifies the compiler flag that forces a short wchar_t */ #define CC_FLAG_SHORT_WCHAR "-fshort-wchar" diff --git a/reactos/include/reactos/wine/wined3d.idl b/reactos/include/reactos/wine/wined3d.idl index 252c6e3aad9..ac4ee89f63b 100644 --- a/reactos/include/reactos/wine/wined3d.idl +++ b/reactos/include/reactos/wine/wined3d.idl @@ -26,6 +26,7 @@ import "unknwn.idl"; cpp_quote("#if 0") +typedef HANDLE HMONITOR; typedef struct _RGNDATAHEADER { @@ -134,6 +135,10 @@ typedef enum _WINED3DDEGREETYPE WINED3DDEGREE_FORCE_DWORD = 0x7fffffff } WINED3DDEGREETYPE; +#define WINEMAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \ + ((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24)) + typedef enum _WINED3DFORMAT { WINED3DFMT_UNKNOWN, @@ -253,21 +258,21 @@ typedef enum _WINED3DFORMAT WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_B8G8R8X8_UNORM, /* FOURCC formats. */ - WINED3DFMT_UYVY = 0x59565955, /* UYVY */ - WINED3DFMT_YUY2 = 0x32595559, /* YUY2 */ - WINED3DFMT_YV12 = 0x32315659, /* YV12 */ - WINED3DFMT_DXT1 = 0x31545844, /* DXT1 */ - WINED3DFMT_DXT2 = 0x32545844, /* DXT2 */ - WINED3DFMT_DXT3 = 0x33545844, /* DXT3 */ - WINED3DFMT_DXT4 = 0x34545844, /* DXT4 */ - WINED3DFMT_DXT5 = 0x35545844, /* DXT5 */ - WINED3DFMT_MULTI2_ARGB8 = 0x3154454d, /* MET1 */ - WINED3DFMT_G8R8_G8B8 = 0x42475247, /* GRGB */ - WINED3DFMT_R8G8_B8G8 = 0x47424752, /* RGBG */ - WINED3DFMT_ATI2N = 0x32495441, /* ATI2 */ - WINED3DFMT_INST = 0x54534e49, /* INST */ - WINED3DFMT_NVHU = 0x5548564e, /* NVHU */ - WINED3DFMT_NVHS = 0x5348564e, /* NVHS */ + WINED3DFMT_UYVY = WINEMAKEFOURCC('U','Y','V','Y'), + WINED3DFMT_YUY2 = WINEMAKEFOURCC('Y','U','Y','2'), + WINED3DFMT_YV12 = WINEMAKEFOURCC('Y','V','1','2'), + WINED3DFMT_DXT1 = WINEMAKEFOURCC('D','X','T','1'), + WINED3DFMT_DXT2 = WINEMAKEFOURCC('D','X','T','2'), + WINED3DFMT_DXT3 = WINEMAKEFOURCC('D','X','T','3'), + WINED3DFMT_DXT4 = WINEMAKEFOURCC('D','X','T','4'), + WINED3DFMT_DXT5 = WINEMAKEFOURCC('D','X','T','5'), + WINED3DFMT_MULTI2_ARGB8 = WINEMAKEFOURCC('M','E','T','1'), + WINED3DFMT_G8R8_G8B8 = WINEMAKEFOURCC('G','R','G','B'), + WINED3DFMT_R8G8_B8G8 = WINEMAKEFOURCC('R','G','B','G'), + WINED3DFMT_ATI2N = WINEMAKEFOURCC('A','T','I','2'), + WINED3DFMT_INST = WINEMAKEFOURCC('I','N','S','T'), + WINED3DFMT_NVHU = WINEMAKEFOURCC('N','V','H','U'), + WINED3DFMT_NVHS = WINEMAKEFOURCC('N','V','H','S'), WINED3DFMT_FORCE_DWORD = 0xffffffff } WINED3DFORMAT; From dd3fc3f8e79dc8137f7b48707073418a5e59cadb Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 14:53:55 +0000 Subject: [PATCH 162/211] [CRT] sync read_i with wine 1.1.40 svn path=/trunk/; revision=45948 --- reactos/lib/sdk/crt/stdio/file.c | 37 ++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/reactos/lib/sdk/crt/stdio/file.c b/reactos/lib/sdk/crt/stdio/file.c index e6371e28336..08213a69390 100644 --- a/reactos/lib/sdk/crt/stdio/file.c +++ b/reactos/lib/sdk/crt/stdio/file.c @@ -76,6 +76,7 @@ int *__p___mb_cur_max(void); #define WX_OPEN 0x01 #define WX_ATEOF 0x02 #define WX_READEOF 0x04 /* like ATEOF, but for underlying file rather than buffer */ +#define WX_READCR 0x08 /* underlying file is at \r */ #define WX_DONTINHERIT 0x10 #define WX_APPEND 0x20 #define WX_TEXT 0x80 @@ -1573,6 +1574,9 @@ static int read_i(int fd, void *buf, unsigned int count) char *bufstart = buf; HANDLE hand = fdtoh(fd); + if (count == 0) + return 0; + if (fdesc[fd].wxflag & WX_READEOF) { fdesc[fd].wxflag |= WX_ATEOF; TRACE("already at EOF, returning 0\n"); @@ -1589,9 +1593,29 @@ static int read_i(int fd, void *buf, unsigned int count) */ if (ReadFile(hand, bufstart, count, &num_read, NULL)) { - if (fdesc[fd].wxflag & WX_TEXT) + if (count != 0 && num_read == 0) + { + fdesc[fd].wxflag |= (WX_ATEOF|WX_READEOF); + TRACE(":EOF %s\n",debugstr_an(buf,num_read)); + } + else if (fdesc[fd].wxflag & WX_TEXT) { DWORD i, j; + if (bufstart[num_read-1] == '\r') + { + if(count == 1) + { + fdesc[fd].wxflag &= ~WX_READCR; + ReadFile(hand, bufstart, 1, &num_read, NULL); + } + else + { + fdesc[fd].wxflag |= WX_READCR; + num_read--; + } + } + else + fdesc[fd].wxflag &= ~WX_READCR; for (i=0, j=0; i Date: Sat, 6 Mar 2010 15:10:46 +0000 Subject: [PATCH 163/211] - fix build svn path=/trunk/; revision=45950 --- reactos/include/reactos/wine/wined3d.idl | 1 - 1 file changed, 1 deletion(-) diff --git a/reactos/include/reactos/wine/wined3d.idl b/reactos/include/reactos/wine/wined3d.idl index ac4ee89f63b..632266b6766 100644 --- a/reactos/include/reactos/wine/wined3d.idl +++ b/reactos/include/reactos/wine/wined3d.idl @@ -26,7 +26,6 @@ import "unknwn.idl"; cpp_quote("#if 0") -typedef HANDLE HMONITOR; typedef struct _RGNDATAHEADER { From 3ddf1ab66f1d9186099b751e03c11089fc2182ad Mon Sep 17 00:00:00 2001 From: Kamil Hornicek Date: Sat, 6 Mar 2010 15:28:23 +0000 Subject: [PATCH 164/211] - revert the last wined3d.idl changes svn path=/trunk/; revision=45951 --- reactos/include/reactos/wine/wined3d.idl | 34 +++++++++++------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/reactos/include/reactos/wine/wined3d.idl b/reactos/include/reactos/wine/wined3d.idl index 632266b6766..252c6e3aad9 100644 --- a/reactos/include/reactos/wine/wined3d.idl +++ b/reactos/include/reactos/wine/wined3d.idl @@ -134,10 +134,6 @@ typedef enum _WINED3DDEGREETYPE WINED3DDEGREE_FORCE_DWORD = 0x7fffffff } WINED3DDEGREETYPE; -#define WINEMAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \ - ((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24)) - typedef enum _WINED3DFORMAT { WINED3DFMT_UNKNOWN, @@ -257,21 +253,21 @@ typedef enum _WINED3DFORMAT WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_B8G8R8X8_UNORM, /* FOURCC formats. */ - WINED3DFMT_UYVY = WINEMAKEFOURCC('U','Y','V','Y'), - WINED3DFMT_YUY2 = WINEMAKEFOURCC('Y','U','Y','2'), - WINED3DFMT_YV12 = WINEMAKEFOURCC('Y','V','1','2'), - WINED3DFMT_DXT1 = WINEMAKEFOURCC('D','X','T','1'), - WINED3DFMT_DXT2 = WINEMAKEFOURCC('D','X','T','2'), - WINED3DFMT_DXT3 = WINEMAKEFOURCC('D','X','T','3'), - WINED3DFMT_DXT4 = WINEMAKEFOURCC('D','X','T','4'), - WINED3DFMT_DXT5 = WINEMAKEFOURCC('D','X','T','5'), - WINED3DFMT_MULTI2_ARGB8 = WINEMAKEFOURCC('M','E','T','1'), - WINED3DFMT_G8R8_G8B8 = WINEMAKEFOURCC('G','R','G','B'), - WINED3DFMT_R8G8_B8G8 = WINEMAKEFOURCC('R','G','B','G'), - WINED3DFMT_ATI2N = WINEMAKEFOURCC('A','T','I','2'), - WINED3DFMT_INST = WINEMAKEFOURCC('I','N','S','T'), - WINED3DFMT_NVHU = WINEMAKEFOURCC('N','V','H','U'), - WINED3DFMT_NVHS = WINEMAKEFOURCC('N','V','H','S'), + WINED3DFMT_UYVY = 0x59565955, /* UYVY */ + WINED3DFMT_YUY2 = 0x32595559, /* YUY2 */ + WINED3DFMT_YV12 = 0x32315659, /* YV12 */ + WINED3DFMT_DXT1 = 0x31545844, /* DXT1 */ + WINED3DFMT_DXT2 = 0x32545844, /* DXT2 */ + WINED3DFMT_DXT3 = 0x33545844, /* DXT3 */ + WINED3DFMT_DXT4 = 0x34545844, /* DXT4 */ + WINED3DFMT_DXT5 = 0x35545844, /* DXT5 */ + WINED3DFMT_MULTI2_ARGB8 = 0x3154454d, /* MET1 */ + WINED3DFMT_G8R8_G8B8 = 0x42475247, /* GRGB */ + WINED3DFMT_R8G8_B8G8 = 0x47424752, /* RGBG */ + WINED3DFMT_ATI2N = 0x32495441, /* ATI2 */ + WINED3DFMT_INST = 0x54534e49, /* INST */ + WINED3DFMT_NVHU = 0x5548564e, /* NVHU */ + WINED3DFMT_NVHS = 0x5348564e, /* NVHS */ WINED3DFMT_FORCE_DWORD = 0xffffffff } WINED3DFORMAT; From 2097d927f170f09d390e10fb397d13a8c43dea7f Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 15:51:12 +0000 Subject: [PATCH 165/211] [CRT] sync fseek with wine 1.1.40 (all msvcrt file tests pass now) svn path=/trunk/; revision=45952 --- reactos/lib/sdk/crt/stdio/file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/lib/sdk/crt/stdio/file.c b/reactos/lib/sdk/crt/stdio/file.c index 08213a69390..a3540ce28bd 100644 --- a/reactos/lib/sdk/crt/stdio/file.c +++ b/reactos/lib/sdk/crt/stdio/file.c @@ -914,6 +914,9 @@ int CDECL fseek(FILE* file, long offset, int whence) if (file->_ptr[i] == '\n') offset--; } + /* Black magic when reading CR at buffer boundary*/ + if(fdesc[file->_file].wxflag & WX_READCR) + offset--; } } /* Discard buffered input */ From e739983b3429db73b4d6a371c6faa5a56dbaf09d Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sat, 6 Mar 2010 16:00:22 +0000 Subject: [PATCH 166/211] Sync Winfile to Wine 1.1.40 svn path=/trunk/; revision=45953 --- rosapps/applications/winfile/De.rc | 1 - rosapps/applications/winfile/Fr.rc | 1 - rosapps/applications/winfile/Ja.rc | 1 - rosapps/applications/winfile/Lt.rc | 1 - rosapps/applications/winfile/Pt.rc | 1 - rosapps/applications/winfile/Ru.rc | 1 - rosapps/applications/winfile/Si.rc | 1 - rosapps/applications/winfile/Zh.rc | 1 - rosapps/applications/winfile/rsrc.rc | 16 +++++++++------- 9 files changed, 9 insertions(+), 15 deletions(-) diff --git a/rosapps/applications/winfile/De.rc b/rosapps/applications/winfile/De.rc index cc77fd84402..83e9f36c3dd 100644 --- a/rosapps/applications/winfile/De.rc +++ b/rosapps/applications/winfile/De.rc @@ -243,4 +243,3 @@ STRINGTABLE IDS_FREE_SPACE_FMT "%s von %s frei" } -#pragma code_page(default) diff --git a/rosapps/applications/winfile/Fr.rc b/rosapps/applications/winfile/Fr.rc index d1f5c3e1137..63eaeba5a13 100644 --- a/rosapps/applications/winfile/Fr.rc +++ b/rosapps/applications/winfile/Fr.rc @@ -250,4 +250,3 @@ STRINGTABLE IDS_FREE_SPACE_FMT "%s sur %s libre" } -#pragma code_page(default) diff --git a/rosapps/applications/winfile/Ja.rc b/rosapps/applications/winfile/Ja.rc index e6def891c04..a66eb1b0ff9 100644 --- a/rosapps/applications/winfile/Ja.rc +++ b/rosapps/applications/winfile/Ja.rc @@ -248,4 +248,3 @@ STRINGTABLE IDS_FREE_SPACE_FMT "%s of %s free" } -#pragma code_page(default) diff --git a/rosapps/applications/winfile/Lt.rc b/rosapps/applications/winfile/Lt.rc index d0c277d5b75..a5c2eb64e19 100644 --- a/rosapps/applications/winfile/Lt.rc +++ b/rosapps/applications/winfile/Lt.rc @@ -246,4 +246,3 @@ STRINGTABLE IDS_FREE_SPACE_FMT "%s iÅ¡ %s laisva" } -#pragma code_page(default) diff --git a/rosapps/applications/winfile/Pt.rc b/rosapps/applications/winfile/Pt.rc index 6f49ce48a9c..6c4ad680d04 100644 --- a/rosapps/applications/winfile/Pt.rc +++ b/rosapps/applications/winfile/Pt.rc @@ -396,4 +396,3 @@ STRINGTABLE IDS_FREE_SPACE_FMT "%s de %s livre" } -#pragma code_page(default) diff --git a/rosapps/applications/winfile/Ru.rc b/rosapps/applications/winfile/Ru.rc index c4c2a6272de..340f58bfc27 100644 --- a/rosapps/applications/winfile/Ru.rc +++ b/rosapps/applications/winfile/Ru.rc @@ -246,4 +246,3 @@ STRINGTABLE IDS_FREE_SPACE_FMT "%s из %s Ñвободно" } -#pragma code_page(default) diff --git a/rosapps/applications/winfile/Si.rc b/rosapps/applications/winfile/Si.rc index f3ffd45a05b..08e495c357d 100644 --- a/rosapps/applications/winfile/Si.rc +++ b/rosapps/applications/winfile/Si.rc @@ -245,4 +245,3 @@ STRINGTABLE IDS_FREE_SPACE_FMT "Prosto: %s od %s" } -#pragma code_page(default) diff --git a/rosapps/applications/winfile/Zh.rc b/rosapps/applications/winfile/Zh.rc index 12cc6a8a3c4..7b9af46a646 100644 --- a/rosapps/applications/winfile/Zh.rc +++ b/rosapps/applications/winfile/Zh.rc @@ -270,4 +270,3 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&關於 Winefile...", ID_ABOUT } } -#pragma code_page(default) diff --git a/rosapps/applications/winfile/rsrc.rc b/rosapps/applications/winfile/rsrc.rc index f6ddfcdc5ec..f67f4fdd097 100644 --- a/rosapps/applications/winfile/rsrc.rc +++ b/rosapps/applications/winfile/rsrc.rc @@ -54,22 +54,24 @@ IDB_IMAGES BITMAP DISCARDABLE images.bmp #include "Cs.rc" #include "Da.rc" -#include "De.rc" #include "En.rc" #include "Es.rc" -#include "Fr.rc" #include "Hu.rc" -#include "It.rc" -#include "Ja.rc" #include "Ko.rc" -#include "Lt.rc" #include "Nl.rc" #include "No.rc" #include "Pl.rc" +#include "Sv.rc" +#include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "It.rc" +#include "Ja.rc" +#include "Lt.rc" #include "Pt.rc" #include "Ru.rc" #include "Si.rc" -#include "Sv.rc" -#include "Tr.rc" #include "Uk.rc" #include "Zh.rc" From a4aa7d5b7e8747d16c3eb5f46033068282577fc9 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sat, 6 Mar 2010 16:04:27 +0000 Subject: [PATCH 167/211] Sync xcopy, winhlp32, wordpad, write and d3dx9_36 to Wine 1.1.40 svn path=/trunk/; revision=45954 --- .../base/applications/cmdutils/xcopy/De.rc | 1 - .../base/applications/cmdutils/xcopy/Fr.rc | 1 - .../base/applications/cmdutils/xcopy/It.rc | 1 - .../base/applications/cmdutils/xcopy/Ja.rc | 1 - .../base/applications/cmdutils/xcopy/Lt.rc | 1 - .../base/applications/cmdutils/xcopy/Nl.rc | 1 - .../base/applications/cmdutils/xcopy/Ru.rc | 1 - .../base/applications/cmdutils/xcopy/Si.rc | 1 - .../base/applications/cmdutils/xcopy/Uk.rc | 1 - .../base/applications/cmdutils/xcopy/rsrc.rc | 14 +- reactos/base/applications/winhlp32/De.rc | 1 - reactos/base/applications/winhlp32/Fr.rc | 1 - reactos/base/applications/winhlp32/It.rc | 1 - reactos/base/applications/winhlp32/Ja.rc | 1 - reactos/base/applications/winhlp32/Lt.rc | 1 - reactos/base/applications/winhlp32/Nl.rc | 1 - reactos/base/applications/winhlp32/Pt.rc | 1 - reactos/base/applications/winhlp32/Rm.rc | 1 - reactos/base/applications/winhlp32/Ro.rc | 1 - reactos/base/applications/winhlp32/Ru.rc | 1 - reactos/base/applications/winhlp32/Si.rc | 1 - reactos/base/applications/winhlp32/Zh.rc | 1 - reactos/base/applications/winhlp32/rsrc.rc | 20 +- reactos/base/applications/wordpad/Da.rc | 26 + reactos/base/applications/wordpad/De.rc | 33 +- reactos/base/applications/wordpad/En.rc | 26 + reactos/base/applications/wordpad/Fr.rc | 27 +- reactos/base/applications/wordpad/Hu.rc | 26 + reactos/base/applications/wordpad/It.rc | 27 +- reactos/base/applications/wordpad/Ja.rc | 27 +- reactos/base/applications/wordpad/Ko.rc | 32 +- reactos/base/applications/wordpad/Lt.rc | 27 +- reactos/base/applications/wordpad/Nl.rc | 26 + reactos/base/applications/wordpad/No.rc | 27 +- reactos/base/applications/wordpad/Pl.rc | 26 + reactos/base/applications/wordpad/Pt.rc | 27 +- reactos/base/applications/wordpad/Ru.rc | 31 +- reactos/base/applications/wordpad/Si.rc | 27 +- reactos/base/applications/wordpad/Sv.rc | 27 +- reactos/base/applications/wordpad/Tr.rc | 26 + reactos/base/applications/wordpad/Uk.rc | 27 +- reactos/base/applications/wordpad/Zh.rc | 27 +- .../base/applications/wordpad/formatbar.bmp | Bin 1014 -> 1142 bytes reactos/base/applications/wordpad/print.c | 1256 ++++++++++------- reactos/base/applications/wordpad/registry.c | 15 +- reactos/base/applications/wordpad/rsrc.rc | 20 +- reactos/base/applications/wordpad/wordpad.c | 66 +- reactos/base/applications/wordpad/wordpad.h | 31 +- reactos/base/applications/wordpad/zoom.cur | Bin 0 -> 766 bytes reactos/base/applications/write/De.rc | 1 - reactos/base/applications/write/Fr.rc | 1 - reactos/base/applications/write/It.rc | 1 - reactos/base/applications/write/Ja.rc | 1 - reactos/base/applications/write/Lt.rc | 1 - reactos/base/applications/write/Ro.rc | 1 - reactos/base/applications/write/Ru.rc | 1 - reactos/base/applications/write/Si.rc | 1 - reactos/base/applications/write/Uk.rc | 1 - reactos/base/applications/write/rsrc.rc | 14 +- .../dll/directx/wine/d3dx9_36/d3dx9_36.rbuild | 1 + .../dll/directx/wine/d3dx9_36/d3dx9_36.spec | 10 +- reactos/dll/directx/wine/d3dx9_36/shader.c | 419 +++++- reactos/dll/directx/wine/d3dx9_36/surface.c | 6 +- reactos/dll/directx/wine/d3dx9_36/texture.c | 37 + reactos/include/dxsdk/d3dx9shader.h | 142 ++ 65 files changed, 1986 insertions(+), 617 deletions(-) create mode 100644 reactos/base/applications/wordpad/zoom.cur create mode 100644 reactos/dll/directx/wine/d3dx9_36/texture.c diff --git a/reactos/base/applications/cmdutils/xcopy/De.rc b/reactos/base/applications/cmdutils/xcopy/De.rc index 3d15e780f6e..cd6e1b91384 100644 --- a/reactos/base/applications/cmdutils/xcopy/De.rc +++ b/reactos/base/applications/cmdutils/xcopy/De.rc @@ -80,4 +80,3 @@ Mit:\n\ \t\tQuelldateien kopiert, die neuer sind als die Zieldatei\n\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/Fr.rc b/reactos/base/applications/cmdutils/xcopy/Fr.rc index b4e387eb17c..047b4b3f739 100644 --- a/reactos/base/applications/cmdutils/xcopy/Fr.rc +++ b/reactos/base/applications/cmdutils/xcopy/Fr.rc @@ -81,4 +81,3 @@ où :\n\ \t\tque le fichier source\n\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/It.rc b/reactos/base/applications/cmdutils/xcopy/It.rc index 84ca52ca911..258cb3f4a7b 100644 --- a/reactos/base/applications/cmdutils/xcopy/It.rc +++ b/reactos/base/applications/cmdutils/xcopy/It.rc @@ -81,4 +81,3 @@ Dove:\n\ \t\tdella sorgente\n\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/Ja.rc b/reactos/base/applications/cmdutils/xcopy/Ja.rc index 1c4fe12b406..38487af8256 100644 --- a/reactos/base/applications/cmdutils/xcopy/Ja.rc +++ b/reactos/base/applications/cmdutils/xcopy/Ja.rc @@ -81,4 +81,3 @@ XCOPY é€ã‚Šå…ƒ [é€ã‚Šå…ˆ] [/I] [/S] [/Q] [/F] [/L] [/W] [/T] [/N] [/U]\n\ \t\tコピー先ãŒã‚³ãƒ”ー元よりå¤ã„ファイルã ã‘コピーã—ã¾ã™ã€‚\n\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/Lt.rc b/reactos/base/applications/cmdutils/xcopy/Lt.rc index f1254b61921..9d431de08fa 100644 --- a/reactos/base/applications/cmdutils/xcopy/Lt.rc +++ b/reactos/base/applications/cmdutils/xcopy/Lt.rc @@ -81,4 +81,3 @@ Kur:\n\ \t\tsenesnis už Å¡altinio failÄ…\n\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/Nl.rc b/reactos/base/applications/cmdutils/xcopy/Nl.rc index 868475e958b..4f5dee58b59 100644 --- a/reactos/base/applications/cmdutils/xcopy/Nl.rc +++ b/reactos/base/applications/cmdutils/xcopy/Nl.rc @@ -79,4 +79,3 @@ Parameters:\n\ \t\tdatum. Als geen detum wordt gegeven, copiëer alleen als bron nieuwer is.\n\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/Ru.rc b/reactos/base/applications/cmdutils/xcopy/Ru.rc index 4339e80dc72..154c999d357 100644 --- a/reactos/base/applications/cmdutils/xcopy/Ru.rc +++ b/reactos/base/applications/cmdutils/xcopy/Ru.rc @@ -84,4 +84,3 @@ XCOPY source [dest] [/I] [/S] [/Q] [/F] [/L] [/W] [/T] [/N] [/U]\n\ поÑле указанной даты. ЕÑли дата не указана, копирует только\n\ те файлы, которые новее в иÑходной папке.\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/Si.rc b/reactos/base/applications/cmdutils/xcopy/Si.rc index 8e45d498b99..1013837f402 100644 --- a/reactos/base/applications/cmdutils/xcopy/Si.rc +++ b/reactos/base/applications/cmdutils/xcopy/Si.rc @@ -80,4 +80,3 @@ Where:\n\ \t\tod izvora\n\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/Uk.rc b/reactos/base/applications/cmdutils/xcopy/Uk.rc index d25e6483dcf..6d59e1bfac6 100644 --- a/reactos/base/applications/cmdutils/xcopy/Uk.rc +++ b/reactos/base/applications/cmdutils/xcopy/Uk.rc @@ -82,4 +82,3 @@ Where:\n\ \t\tthan source\n\n" } -#pragma code_page(default) diff --git a/reactos/base/applications/cmdutils/xcopy/rsrc.rc b/reactos/base/applications/cmdutils/xcopy/rsrc.rc index 6d7817cf4cd..b82341cda08 100644 --- a/reactos/base/applications/cmdutils/xcopy/rsrc.rc +++ b/reactos/base/applications/cmdutils/xcopy/rsrc.rc @@ -27,17 +27,19 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include #include "Da.rc" -#include "De.rc" #include "En.rc" -#include "Fr.rc" -#include "It.rc" -#include "Ja.rc" #include "Ko.rc" -#include "Lt.rc" -#include "Nl.rc" #include "No.rc" #include "Pl.rc" #include "Pt.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "It.rc" +#include "Ja.rc" +#include "Lt.rc" +#include "Nl.rc" #include "Ru.rc" #include "Si.rc" #include "Uk.rc" diff --git a/reactos/base/applications/winhlp32/De.rc b/reactos/base/applications/winhlp32/De.rc index 0ec40add40f..2e14f70ad84 100644 --- a/reactos/base/applications/winhlp32/De.rc +++ b/reactos/base/applications/winhlp32/De.rc @@ -128,4 +128,3 @@ END MENUITEM "Systemfarben verwenden", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Fr.rc b/reactos/base/applications/winhlp32/Fr.rc index 2199e37ab9e..cedb0f694b7 100644 --- a/reactos/base/applications/winhlp32/Fr.rc +++ b/reactos/base/applications/winhlp32/Fr.rc @@ -131,4 +131,3 @@ BEGIN MENUITEM "Utiliser les couleurs système", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/It.rc b/reactos/base/applications/winhlp32/It.rc index cd16e4058bf..b5c53929bf4 100644 --- a/reactos/base/applications/winhlp32/It.rc +++ b/reactos/base/applications/winhlp32/It.rc @@ -89,4 +89,3 @@ STID_FILE_NOT_FOUND_s "Non è stato possibile trovare '%s'. Vuoi cercare questo STID_NO_RICHEDIT "Non è stato possibile trovare un'implementazione richedit... Annullando" STID_PSH_INDEX, "Argomenti di aiuto: " } -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Ja.rc b/reactos/base/applications/winhlp32/Ja.rc index a06b5f1df65..b73d18dd192 100644 --- a/reactos/base/applications/winhlp32/Ja.rc +++ b/reactos/base/applications/winhlp32/Ja.rc @@ -128,4 +128,3 @@ BEGIN MENUITEM "システム カラーを使ã†", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Lt.rc b/reactos/base/applications/winhlp32/Lt.rc index 5ee53f8aa16..f8e78681aae 100644 --- a/reactos/base/applications/winhlp32/Lt.rc +++ b/reactos/base/applications/winhlp32/Lt.rc @@ -129,4 +129,3 @@ BEGIN MENUITEM "Naudoti sistemos spalvas", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Nl.rc b/reactos/base/applications/winhlp32/Nl.rc index a7938406b65..029d58265b9 100644 --- a/reactos/base/applications/winhlp32/Nl.rc +++ b/reactos/base/applications/winhlp32/Nl.rc @@ -127,4 +127,3 @@ BEGIN MENUITEM "Gebruik systeem kleuren", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Pt.rc b/reactos/base/applications/winhlp32/Pt.rc index 5598bd77cd6..28933a22a6f 100644 --- a/reactos/base/applications/winhlp32/Pt.rc +++ b/reactos/base/applications/winhlp32/Pt.rc @@ -204,4 +204,3 @@ BEGIN MENUITEM "Usar cores do sistema", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Rm.rc b/reactos/base/applications/winhlp32/Rm.rc index 17293875f99..3b2a1fa9403 100644 --- a/reactos/base/applications/winhlp32/Rm.rc +++ b/reactos/base/applications/winhlp32/Rm.rc @@ -92,4 +92,3 @@ STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yoursel STID_NO_RICHEDIT "Cannot find a richedit implementation... Aborting" STID_PSH_INDEX, "Help topics: " } -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Ro.rc b/reactos/base/applications/winhlp32/Ro.rc index eaa530bc5bb..1f916ac21d5 100644 --- a/reactos/base/applications/winhlp32/Ro.rc +++ b/reactos/base/applications/winhlp32/Ro.rc @@ -130,4 +130,3 @@ BEGIN MENUITEM "Utilizează culorile sistemului", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Ru.rc b/reactos/base/applications/winhlp32/Ru.rc index a476b344c6c..165094f4720 100644 --- a/reactos/base/applications/winhlp32/Ru.rc +++ b/reactos/base/applications/winhlp32/Ru.rc @@ -121,4 +121,3 @@ BEGIN MENUITEM "ИÑпользовать ÑиÑтемные цвета", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Si.rc b/reactos/base/applications/winhlp32/Si.rc index 310ef45a8f7..527b45431ee 100644 --- a/reactos/base/applications/winhlp32/Si.rc +++ b/reactos/base/applications/winhlp32/Si.rc @@ -126,4 +126,3 @@ BEGIN MENUITEM "Uporabi sistemske barve", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/Zh.rc b/reactos/base/applications/winhlp32/Zh.rc index a68b699c44f..ed20356cf47 100644 --- a/reactos/base/applications/winhlp32/Zh.rc +++ b/reactos/base/applications/winhlp32/Zh.rc @@ -160,4 +160,3 @@ STID_FILE_NOT_FOUND_s "ä¸èƒ½é–‹å•Ÿæª”案 '%s'. 你想è¦è‡ªå·±æ‰¾é€™å€‹æª”案 STID_NO_RICHEDIT "找ä¸åˆ° richedit... 終止" STID_PSH_INDEX, "幫助內容: " } -#pragma code_page(default) diff --git a/reactos/base/applications/winhlp32/rsrc.rc b/reactos/base/applications/winhlp32/rsrc.rc index e45fc8a7ce5..28d8de35fe3 100644 --- a/reactos/base/applications/winhlp32/rsrc.rc +++ b/reactos/base/applications/winhlp32/rsrc.rc @@ -27,25 +27,27 @@ IDI_WINHELP ICON DISCARDABLE winhelp.ico #include "Bg.rc" #include "Cs.rc" #include "Da.rc" -#include "De.rc" #include "En.rc" #include "Es.rc" #include "Fi.rc" -#include "Fr.rc" #include "Hu.rc" -#include "It.rc" -#include "Ja.rc" #include "Ko.rc" -#include "Lt.rc" -#include "Nl.rc" #include "No.rc" #include "Pl.rc" +#include "Sk.rc" +#include "Sv.rc" +#include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "It.rc" +#include "Ja.rc" +#include "Lt.rc" +#include "Nl.rc" #include "Pt.rc" #include "Rm.rc" #include "Ro.rc" #include "Ru.rc" #include "Si.rc" -#include "Sk.rc" -#include "Sv.rc" -#include "Tr.rc" #include "Zh.rc" diff --git a/reactos/base/applications/wordpad/Da.rc b/reactos/base/applications/wordpad/Da.rc index 8d035955bd2..882cca7e8d8 100644 --- a/reactos/base/applications/wordpad/Da.rc +++ b/reactos/base/applications/wordpad/Da.rc @@ -106,6 +106,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Sort", ID_COLOR_BLACK + MENUITEM "Mørkerød", ID_COLOR_MAROON + MENUITEM "Grøn", ID_COLOR_GREEN + MENUITEM "Oliven" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Lilla" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Grå" ID_COLOR_GRAY + MENUITEM "Sølv" ID_COLOR_SILVER + MENUITEM "Rød" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Gul" ID_COLOR_YELLOW + MENUITEM "Blå" ID_COLOR_BLUE + MENUITEM "Violet" ID_COLOR_FUCHSIA + MENUITEM "Cyan" ID_COLOR_AQUA + MENUITEM "Hvid" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Dato og tid" @@ -221,6 +245,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Luk" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/reactos/base/applications/wordpad/De.rc b/reactos/base/applications/wordpad/De.rc index d552d9c21a5..ca11edd8bea 100644 --- a/reactos/base/applications/wordpad/De.rc +++ b/reactos/base/applications/wordpad/De.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Schwarz" ID_COLOR_BLACK + MENUITEM "Kastanienbraun" ID_COLOR_MAROON + MENUITEM "Grün" ID_COLOR_GREEN + MENUITEM "Olivgrün" ID_COLOR_OLIVE + MENUITEM "Dunkelblau" ID_COLOR_NAVY + MENUITEM "Lila" ID_COLOR_PURPLE + MENUITEM "Blaugrün" ID_COLOR_TEAL + MENUITEM "Grau" ID_COLOR_GRAY + MENUITEM "Silber" ID_COLOR_SILVER + MENUITEM "Rot" ID_COLOR_RED + MENUITEM "Hellgrün" ID_COLOR_LIME + MENUITEM "Gelb" ID_COLOR_YELLOW + MENUITEM "Blau" ID_COLOR_BLUE + MENUITEM "Pink" ID_COLOR_FUCHSIA + MENUITEM "Aquamarin" ID_COLOR_AQUA + MENUITEM "Weiß" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Datum und Uhrzeit" @@ -218,9 +242,13 @@ BEGIN STRING_PREVIEW_PRINT, "&Drucken" STRING_PREVIEW_NEXTPAGE, "&Nächste" STRING_PREVIEW_PREVPAGE, "&Vorherige" - STRING_PREVIEW_TWOPAGES, "Zwei Seiten" - STRING_PREVIEW_ONEPAGE, "Eine Seite" + STRING_PREVIEW_TWOPAGES, "&Zwei Seiten" + STRING_PREVIEW_ONEPAGE, "&Eine Seite" + STRING_PREVIEW_ZOOMIN, "Ver&größern" + STRING_PREVIEW_ZOOMOUT, "Ver&kleinern" STRING_PREVIEW_CLOSE, "&Schließen" + STRING_PREVIEW_PAGE, "Seite" + STRING_PREVIEW_PAGES, "Seiten" END STRINGTABLE DISCARDABLE @@ -246,4 +274,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Drucken ist nicht implementiert" STRING_MAX_TAB_STOPS, "Es können nur maximal 32 Tabstopps definiert werden." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/En.rc b/reactos/base/applications/wordpad/En.rc index 7af40bda4b8..0dec19bc650 100644 --- a/reactos/base/applications/wordpad/En.rc +++ b/reactos/base/applications/wordpad/En.rc @@ -106,6 +106,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Black", ID_COLOR_BLACK + MENUITEM "Maroon", ID_COLOR_MAROON + MENUITEM "Green", ID_COLOR_GREEN + MENUITEM "Olive" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Purple" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Gray" ID_COLOR_GRAY + MENUITEM "Silver" ID_COLOR_SILVER + MENUITEM "Red" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Yellow" ID_COLOR_YELLOW + MENUITEM "Blue" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "White" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Date and time" @@ -213,6 +237,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Close" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" STRING_UNITS_CM, "cm" END diff --git a/reactos/base/applications/wordpad/Fr.rc b/reactos/base/applications/wordpad/Fr.rc index b38daad137e..54ae0b992b8 100644 --- a/reactos/base/applications/wordpad/Fr.rc +++ b/reactos/base/applications/wordpad/Fr.rc @@ -109,6 +109,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Noir" ID_COLOR_BLACK + MENUITEM "Marron" ID_COLOR_MAROON + MENUITEM "Vert" ID_COLOR_GREEN + MENUITEM "Olive" ID_COLOR_OLIVE + MENUITEM "Bleu marine" ID_COLOR_NAVY + MENUITEM "Pourpre" ID_COLOR_PURPLE + MENUITEM "Sarcelle" ID_COLOR_TEAL + MENUITEM "Gris" ID_COLOR_GRAY + MENUITEM "Argent" ID_COLOR_SILVER + MENUITEM "Rouge" ID_COLOR_RED + MENUITEM "Citron vert" ID_COLOR_LIME + MENUITEM "Jaune" ID_COLOR_YELLOW + MENUITEM "Bleu" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Eau" ID_COLOR_AQUA + MENUITEM "Blanc" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Date et heure" @@ -224,6 +248,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom avant" STRING_PREVIEW_ZOOMOUT, "Zoom arrière" STRING_PREVIEW_CLOSE, "Fermer" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "L'impression n'est pas implémentée" STRING_MAX_TAB_STOPS, "Impossible d'ajouter plus de 32 taquets de tabulation." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Hu.rc b/reactos/base/applications/wordpad/Hu.rc index 1eeede3c8aa..3694062e355 100644 --- a/reactos/base/applications/wordpad/Hu.rc +++ b/reactos/base/applications/wordpad/Hu.rc @@ -106,6 +106,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Black", ID_COLOR_BLACK + MENUITEM "Maroon", ID_COLOR_MAROON + MENUITEM "Green", ID_COLOR_GREEN + MENUITEM "Olive" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Purple" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Gray" ID_COLOR_GRAY + MENUITEM "Silver" ID_COLOR_SILVER + MENUITEM "Red" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Yellow" ID_COLOR_YELLOW + MENUITEM "Blue" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "White" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Date and time" @@ -221,6 +245,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Close" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/reactos/base/applications/wordpad/It.rc b/reactos/base/applications/wordpad/It.rc index e0d3b890bc4..99968411776 100644 --- a/reactos/base/applications/wordpad/It.rc +++ b/reactos/base/applications/wordpad/It.rc @@ -110,6 +110,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Nero" ID_COLOR_BLACK + MENUITEM "Marrone rossiccio" ID_COLOR_MAROON + MENUITEM "Verde" ID_COLOR_GREEN + MENUITEM "Verde oliva" ID_COLOR_OLIVE + MENUITEM "Blu oltremare" ID_COLOR_NAVY + MENUITEM "Propora" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Grigio" ID_COLOR_GRAY + MENUITEM "Argento" ID_COLOR_SILVER + MENUITEM "Rosso" ID_COLOR_RED + MENUITEM "Verde cedro" ID_COLOR_LIME + MENUITEM "Giallo" ID_COLOR_YELLOW + MENUITEM "Blu" ID_COLOR_BLUE + MENUITEM "Fucsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "Bianco" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Data e ora" @@ -217,6 +241,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Ingrandisci" STRING_PREVIEW_ZOOMOUT, "Rimpicciolisci" STRING_PREVIEW_CLOSE, "Chiudi" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" STRING_UNITS_CM, "cm" END @@ -238,4 +264,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Stampa non implementata" STRING_MAX_TAB_STOPS, "Non si possono aggiungere più di 32 punti di fermata delle tabulazioni." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Ja.rc b/reactos/base/applications/wordpad/Ja.rc index 89b4b0041e2..bd5e4c9ea94 100644 --- a/reactos/base/applications/wordpad/Ja.rc +++ b/reactos/base/applications/wordpad/Ja.rc @@ -109,6 +109,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "é»’" ID_COLOR_BLACK + MENUITEM "茶色" ID_COLOR_MAROON + MENUITEM "ç·‘" ID_COLOR_GREEN + MENUITEM "オリーブ" ID_COLOR_OLIVE + MENUITEM "ç´º" ID_COLOR_NAVY + MENUITEM "ç´«" ID_COLOR_PURPLE + MENUITEM "é’ç·‘" ID_COLOR_TEAL + MENUITEM "ç°è‰²" ID_COLOR_GRAY + MENUITEM "銀色" ID_COLOR_SILVER + MENUITEM "赤" ID_COLOR_RED + MENUITEM "黄緑" ID_COLOR_LIME + MENUITEM "黄" ID_COLOR_YELLOW + MENUITEM "é’" ID_COLOR_BLUE + MENUITEM "赤紫" ID_COLOR_FUCHSIA + MENUITEM "水色" ID_COLOR_AQUA + MENUITEM "白" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "æ—¥ä»˜ã¨æ™‚刻" @@ -224,6 +248,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "é–‰ã˜ã‚‹" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "プリントãŒå®Ÿè£…ã•れã¦ã„ã¾ã›ã‚“。" STRING_MAX_TAB_STOPS, "32以上ãªã‚¿ãƒ–を追加ã§ãã¾ã›ã‚“。" END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Ko.rc b/reactos/base/applications/wordpad/Ko.rc index 20928221c02..81110831b75 100644 --- a/reactos/base/applications/wordpad/Ko.rc +++ b/reactos/base/applications/wordpad/Ko.rc @@ -107,6 +107,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "°ËÁ¤" ID_COLOR_BLACK + MENUITEM "¹ã»ö" ID_COLOR_MAROON + MENUITEM "³ì»ö" ID_COLOR_GREEN + MENUITEM "¿Ã¸®ºê»ö" ID_COLOR_OLIVE + MENUITEM "£Àº ³²»ö" ID_COLOR_NAVY + MENUITEM "½ÉÈ«»ö" ID_COLOR_PURPLE + MENUITEM "°ËÀº ¹°¿À¸®»ö" ID_COLOR_TEAL + MENUITEM "ȸ»ö" ID_COLOR_GRAY + MENUITEM "Àº»ö" ID_COLOR_SILVER + MENUITEM "»¡°­" ID_COLOR_RED + MENUITEM "¶óÀÓ»ö" ID_COLOR_LIME + MENUITEM "³ë¶û" ID_COLOR_YELLOW + MENUITEM "ÆÄ¶û" ID_COLOR_BLUE + MENUITEM "ÀÚÈ«»ö" ID_COLOR_FUCHSIA + MENUITEM "¹°»ö" ID_COLOR_AQUA + MENUITEM "ÇϾç" ID_COLOR_WHITE + MENUITEM "ÀÚµ¿" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "³¯Â¥¿Í ½Ã°£" @@ -212,10 +236,12 @@ BEGIN STRING_PREVIEW_PREVPAGE, "ÀÌÀü ÆäÀÌÁö" STRING_PREVIEW_TWOPAGES, "µÎ ÆäÀÌÁö" STRING_PREVIEW_ONEPAGE, "ÇÑ ÆäÀÌÁö" - STRING_PREVIEW_ZOOMIN, "Zoom in" - STRING_PREVIEW_ZOOMOUT, "Zoom out" + STRING_PREVIEW_ZOOMIN, "È®´ë" + STRING_PREVIEW_ZOOMOUT, "Ãà¼Ò" STRING_PREVIEW_CLOSE, "´Ý±â" - STRING_UNITS_CM, "cm" + STRING_PREVIEW_PAGE, "ÆäÀÌÁö" + STRING_PREVIEW_PAGES, "ÆäÀÌÁöµé" + STRING_UNITS_CM, "cm" END STRINGTABLE DISCARDABLE diff --git a/reactos/base/applications/wordpad/Lt.rc b/reactos/base/applications/wordpad/Lt.rc index a1c73126b74..c9f2571ccc1 100644 --- a/reactos/base/applications/wordpad/Lt.rc +++ b/reactos/base/applications/wordpad/Lt.rc @@ -109,6 +109,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Juoda" ID_COLOR_BLACK + MENUITEM "KaÅ¡toninÄ—" ID_COLOR_MAROON + MENUITEM "Žalia" ID_COLOR_GREEN + MENUITEM "AlyvinÄ—" ID_COLOR_OLIVE + MENUITEM "Ultramarinas" ID_COLOR_NAVY + MENUITEM "PurpurinÄ—" ID_COLOR_PURPLE + MENUITEM "Neutrali ciano" ID_COLOR_TEAL + MENUITEM "Pilka" ID_COLOR_GRAY + MENUITEM "SidabrinÄ—" ID_COLOR_SILVER + MENUITEM "Raudona" ID_COLOR_RED + MENUITEM "Gelsvai žalsva" ID_COLOR_LIME + MENUITEM "Geltona" ID_COLOR_YELLOW + MENUITEM "MÄ—lyna" ID_COLOR_BLUE + MENUITEM "Fuksija" ID_COLOR_FUCHSIA + MENUITEM "Žydra" ID_COLOR_AQUA + MENUITEM "Balta" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Data ir laikas" @@ -224,6 +248,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Didinti" STRING_PREVIEW_ZOOMOUT, "Mažinti" STRING_PREVIEW_CLOSE, "Užverti" + STRING_PREVIEW_PAGE, "Puslapis" + STRING_PREVIEW_PAGES, "Puslapiai" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Spausdinimas nerealizuotas" STRING_MAX_TAB_STOPS, "Negalima pridÄ—ti daugiau negu 32-jų tabuliavimo pozicijų." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Nl.rc b/reactos/base/applications/wordpad/Nl.rc index 581855eec98..5741dbea9b7 100644 --- a/reactos/base/applications/wordpad/Nl.rc +++ b/reactos/base/applications/wordpad/Nl.rc @@ -107,6 +107,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Zwart" ID_COLOR_BLACK + MENUITEM "Kastanjebruin" ID_COLOR_MAROON + MENUITEM "Groen" ID_COLOR_GREEN + MENUITEM "Olijfgroen" ID_COLOR_OLIVE + MENUITEM "Marineblauw" ID_COLOR_NAVY + MENUITEM "Paars" ID_COLOR_PURPLE + MENUITEM "Groenblauw" ID_COLOR_TEAL + MENUITEM "Grijs" ID_COLOR_GRAY + MENUITEM "Zilver" ID_COLOR_SILVER + MENUITEM "Rood" ID_COLOR_RED + MENUITEM "Lichtgroen" ID_COLOR_LIME + MENUITEM "Geel" ID_COLOR_YELLOW + MENUITEM "Blauw" ID_COLOR_BLUE + MENUITEM "Fuchsiapaars" ID_COLOR_FUCHSIA + MENUITEM "Zeeblauw" ID_COLOR_AQUA + MENUITEM "Wit" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Datum en tijd" @@ -214,6 +238,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Sluiten" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/reactos/base/applications/wordpad/No.rc b/reactos/base/applications/wordpad/No.rc index c8086582afe..fbca2a09bee 100644 --- a/reactos/base/applications/wordpad/No.rc +++ b/reactos/base/applications/wordpad/No.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Svart" ID_COLOR_BLACK + MENUITEM "Rødbrun" ID_COLOR_MAROON + MENUITEM "Grønn" ID_COLOR_GREEN + MENUITEM "Oliven" ID_COLOR_OLIVE + MENUITEM "MarineblÃ¥" ID_COLOR_NAVY + MENUITEM "Purpur" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "GrÃ¥" ID_COLOR_GRAY + MENUITEM "Sølv" ID_COLOR_SILVER + MENUITEM "Rød" ID_COLOR_RED + MENUITEM "Lime-grønn" ID_COLOR_LIME + MENUITEM "Gul" ID_COLOR_YELLOW + MENUITEM "BlÃ¥" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "Hvit" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Dato og klokkeslett" @@ -223,6 +247,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Lukk" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -248,4 +274,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Utskriftfunksjonen er ikke laget ennÃ¥." STRING_MAX_TAB_STOPS, "Kan ikke legge til mer enn 32 tabulatorstopp." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Pl.rc b/reactos/base/applications/wordpad/Pl.rc index 97d7288bc4c..4d403041858 100644 --- a/reactos/base/applications/wordpad/Pl.rc +++ b/reactos/base/applications/wordpad/Pl.rc @@ -107,6 +107,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Czarny" ID_COLOR_BLACK + MENUITEM "Kasztanowy" ID_COLOR_MAROON + MENUITEM "Zielony" ID_COLOR_GREEN + MENUITEM "Oliwkowy" ID_COLOR_OLIVE + MENUITEM "Granatowy" ID_COLOR_NAVY + MENUITEM "Purpurowy" ID_COLOR_PURPLE + MENUITEM "Zielonomodry" ID_COLOR_TEAL + MENUITEM "Szary" ID_COLOR_GRAY + MENUITEM "Srebrny" ID_COLOR_SILVER + MENUITEM "Czerwony" ID_COLOR_RED + MENUITEM "Limonowy" ID_COLOR_LIME + MENUITEM "¯ó³ty" ID_COLOR_YELLOW + MENUITEM "Niebieski" ID_COLOR_BLUE + MENUITEM "Fuksja" ID_COLOR_FUCHSIA + MENUITEM "Akwamaryna" ID_COLOR_AQUA + MENUITEM "Bia³y" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Data i godzina" @@ -222,6 +246,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Zamknij" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/reactos/base/applications/wordpad/Pt.rc b/reactos/base/applications/wordpad/Pt.rc index 8b0114af22c..2a2ae4b749b 100644 --- a/reactos/base/applications/wordpad/Pt.rc +++ b/reactos/base/applications/wordpad/Pt.rc @@ -110,6 +110,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Preto" ID_COLOR_BLACK + MENUITEM "Castanho" ID_COLOR_MAROON + MENUITEM "Verde" ID_COLOR_GREEN + MENUITEM "Verde-oliva" ID_COLOR_OLIVE + MENUITEM "Azul-marinho" ID_COLOR_NAVY + MENUITEM "Roxo" ID_COLOR_PURPLE + MENUITEM "Azul-petróleo" ID_COLOR_TEAL + MENUITEM "Cinza" ID_COLOR_GRAY + MENUITEM "Prateado" ID_COLOR_SILVER + MENUITEM "Vermelho" ID_COLOR_RED + MENUITEM "Verde-limão" ID_COLOR_LIME + MENUITEM "Amarelo" ID_COLOR_YELLOW + MENUITEM "Azul" ID_COLOR_BLUE + MENUITEM "Fúcsia" ID_COLOR_FUCHSIA + MENUITEM "Azul-piscina" ID_COLOR_AQUA + MENUITEM "Branco" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Data e hora" @@ -225,6 +249,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Fechar" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -250,4 +276,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Impressão não implementada" STRING_MAX_TAB_STOPS, "Não pode adicionar mais de 32 tabs." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Ru.rc b/reactos/base/applications/wordpad/Ru.rc index 70d9b96e743..230003b3c61 100644 --- a/reactos/base/applications/wordpad/Ru.rc +++ b/reactos/base/applications/wordpad/Ru.rc @@ -109,6 +109,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Чёрный" ID_COLOR_BLACK + MENUITEM "Тёмно-бордовый" ID_COLOR_MAROON + MENUITEM "Зелёный" ID_COLOR_GREEN + MENUITEM "Оливковый" ID_COLOR_OLIVE + MENUITEM "Тёмно-Ñиний" ID_COLOR_NAVY + MENUITEM "Пурпурный" ID_COLOR_PURPLE + MENUITEM "МорÑкой волны" ID_COLOR_TEAL + MENUITEM "Серый" ID_COLOR_GRAY + MENUITEM "СеребрÑный" ID_COLOR_SILVER + MENUITEM "КраÑный" ID_COLOR_RED + MENUITEM "Лимонный" ID_COLOR_LIME + MENUITEM "Жёлтый" ID_COLOR_YELLOW + MENUITEM "Синий" ID_COLOR_BLUE + MENUITEM "Ярко-розовый" ID_COLOR_FUCHSIA + MENUITEM "Голубой" ID_COLOR_AQUA + MENUITEM "Белый" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Дата и времÑ" @@ -221,9 +245,11 @@ BEGIN STRING_PREVIEW_PREVPAGE, "ÐŸÑ€ÐµÐ´Ñ‹Ð´ÑƒÑ‰Ð°Ñ Ñтраница" STRING_PREVIEW_TWOPAGES, "Две Ñтраницы" STRING_PREVIEW_ONEPAGE, "Одна Ñтраница" - STRING_PREVIEW_ZOOMIN, "Zoom in" - STRING_PREVIEW_ZOOMOUT, "Zoom out" + STRING_PREVIEW_ZOOMIN, "Приблизить" + STRING_PREVIEW_ZOOMOUT, "Отдалить" STRING_PREVIEW_CLOSE, "Закрыть" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Печать не поддерживаетÑÑ" STRING_MAX_TAB_STOPS, "ÐÐµÐ»ÑŒÐ·Ñ Ð´Ð¾Ð±Ð°Ð²Ð¸Ñ‚ÑŒ более 32 позиций табулÑции." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Si.rc b/reactos/base/applications/wordpad/Si.rc index dc0c8d08c0d..f7e0c722b46 100644 --- a/reactos/base/applications/wordpad/Si.rc +++ b/reactos/base/applications/wordpad/Si.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "ÄŒrna" ID_COLOR_BLACK + MENUITEM "Kostanjeva" ID_COLOR_MAROON + MENUITEM "Zelena" ID_COLOR_GREEN + MENUITEM "Olivna" ID_COLOR_OLIVE + MENUITEM "MornariÅ¡ka" ID_COLOR_NAVY + MENUITEM "VijoliÄna" ID_COLOR_PURPLE + MENUITEM "Zelenomodra" ID_COLOR_TEAL + MENUITEM "Siva" ID_COLOR_GRAY + MENUITEM "Srebrna" ID_COLOR_SILVER + MENUITEM "RdeÄa" ID_COLOR_RED + MENUITEM "Citronska" ID_COLOR_LIME + MENUITEM "Rumena" ID_COLOR_YELLOW + MENUITEM "Modra" ID_COLOR_BLUE + MENUITEM "Roza" ID_COLOR_FUCHSIA + MENUITEM "Akvamarin" ID_COLOR_AQUA + MENUITEM "Bela" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Datum in Äas" @@ -223,6 +247,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Zapri" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Tiskanje (Å¡e) ni na voljo" STRING_MAX_TAB_STOPS, "Ne morem vstaviti veÄ kot 32 položajev tabulatorja." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Sv.rc b/reactos/base/applications/wordpad/Sv.rc index c954dc1a7a7..edc35a9b24a 100644 --- a/reactos/base/applications/wordpad/Sv.rc +++ b/reactos/base/applications/wordpad/Sv.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Svart" ID_COLOR_BLACK + MENUITEM "Rödbrun" ID_COLOR_MAROON + MENUITEM "Grön" ID_COLOR_GREEN + MENUITEM "Oliv" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Lila" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "GrÃ¥" ID_COLOR_GRAY + MENUITEM "Silver" ID_COLOR_SILVER + MENUITEM "Röd" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Gul" ID_COLOR_YELLOW + MENUITEM "BlÃ¥" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "Vit" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Datum och tid" @@ -223,6 +247,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zooma in" STRING_PREVIEW_ZOOMOUT, "Zooma ut" STRING_PREVIEW_CLOSE, "Stäng" + STRING_PREVIEW_PAGE, "Sida" + STRING_PREVIEW_PAGES, "Sidor" END STRINGTABLE DISCARDABLE @@ -248,4 +274,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Utskrift ej implementerat." STRING_MAX_TAB_STOPS, "Kan ej lägga till mer än 32 tabbstopp." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Tr.rc b/reactos/base/applications/wordpad/Tr.rc index e8d9f982ffb..ef66aa40ad8 100644 --- a/reactos/base/applications/wordpad/Tr.rc +++ b/reactos/base/applications/wordpad/Tr.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Siyah" ID_COLOR_BLACK + MENUITEM "Koyu Kýrmýzý" ID_COLOR_MAROON + MENUITEM "Yeþil" ID_COLOR_GREEN + MENUITEM "Koyu Sarý" ID_COLOR_OLIVE + MENUITEM "Koyu Mavi" ID_COLOR_NAVY + MENUITEM "Mor" ID_COLOR_PURPLE + MENUITEM "Deniz Mavisi" ID_COLOR_TEAL + MENUITEM "Gri" ID_COLOR_GRAY + MENUITEM "Gümüþ" ID_COLOR_SILVER + MENUITEM "Kýrmýzý" ID_COLOR_RED + MENUITEM "Parlak Yeþil" ID_COLOR_LIME + MENUITEM "Sarý" ID_COLOR_YELLOW + MENUITEM "Mavi" ID_COLOR_BLUE + MENUITEM "Pembe" ID_COLOR_FUCHSIA + MENUITEM "Turkuaz" ID_COLOR_AQUA + MENUITEM "Beyaz" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Date and time" @@ -223,6 +247,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Close" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/reactos/base/applications/wordpad/Uk.rc b/reactos/base/applications/wordpad/Uk.rc index c71cbe1575c..35e35977e59 100644 --- a/reactos/base/applications/wordpad/Uk.rc +++ b/reactos/base/applications/wordpad/Uk.rc @@ -113,6 +113,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "×îðíèé" ID_COLOR_BLACK + MENUITEM "Ãðóíàòíèé" ID_COLOR_MAROON + MENUITEM "Çåëåíèé" ID_COLOR_GREEN + MENUITEM "Îëèâêîâèé" ID_COLOR_OLIVE + MENUITEM "Ñèí³é" ID_COLOR_NAVY + MENUITEM "Ãóðïóðíèé" ID_COLOR_PURPLE + MENUITEM "Çåëåíî-ñèí³é" ID_COLOR_TEAL + MENUITEM "ѳðèé" ID_COLOR_GRAY + MENUITEM "Ñð³áíèé" ID_COLOR_SILVER + MENUITEM "×åðâîíèé" ID_COLOR_RED + MENUITEM "Ñàëàòîâèé" ID_COLOR_LIME + MENUITEM "Æîâòèé" ID_COLOR_YELLOW + MENUITEM "Ãîëóáèé" ID_COLOR_BLUE + MENUITEM "Ô³îëåòîâèé" ID_COLOR_FUCHSIA + MENUITEM "Àêâàìàðèí" ID_COLOR_AQUA + MENUITEM "óëèé" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Дата та чаÑ" @@ -220,6 +244,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Збільшити" STRING_PREVIEW_ZOOMOUT, "Зменшити" STRING_PREVIEW_CLOSE, "Закрити" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" STRING_UNITS_CM, "cm" END @@ -250,4 +276,3 @@ BEGIN STRING_ALIGN_RIGHT, "По правому Краю" STRING_ALIGN_CENTER, "По Центру" END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/Zh.rc b/reactos/base/applications/wordpad/Zh.rc index 7fd7e120f3e..6adb30af43b 100644 --- a/reactos/base/applications/wordpad/Zh.rc +++ b/reactos/base/applications/wordpad/Zh.rc @@ -111,6 +111,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Black", ID_COLOR_BLACK + MENUITEM "Maroon", ID_COLOR_MAROON + MENUITEM "Green", ID_COLOR_GREEN + MENUITEM "Olive" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Purple" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Gray" ID_COLOR_GRAY + MENUITEM "Silver" ID_COLOR_SILVER + MENUITEM "Red" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Yellow" ID_COLOR_YELLOW + MENUITEM "Blue" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "White" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "日期和时间" @@ -226,6 +250,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "关闭" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -473,4 +499,3 @@ BEGIN STRING_OPEN_FAILED, "ä¸èƒ½é–‹å•Ÿæª”案." STRING_OPEN_ACCESS_DENIED, "你沒有開啟檔案的權力." END -#pragma code_page(default) diff --git a/reactos/base/applications/wordpad/formatbar.bmp b/reactos/base/applications/wordpad/formatbar.bmp index 9c643b11b9783be297bc99766d29b5e4d74a520e..310b596d92a7dfbca7ebad7815c1a289a3a526e5 100644 GIT binary patch delta 227 zcmeyy{*A-f$+wJ!0SwB3qy`W-0I>iNGcrIWfRqq71cSr{CK~rnoWL>h02^b&0;$j1rT@nSe~7C=*bW$#UW~vB~d%OmSwgf^uew$ 2) preview.pages_shown = 2; + } +} + + static void AddTextButton(HWND hRebarWnd, UINT string, UINT command, UINT id) { REBARBANDINFOW rb; @@ -244,24 +270,6 @@ static LPWSTR dialog_print_to_file(HWND hMainWnd) return FALSE; } -static int get_num_pages(HWND hEditorWnd, FORMATRANGE fr) -{ - int page = 0; - fr.chrg.cpMin = 0; - - do - { - int bottom = fr.rc.bottom; - page++; - fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, - (LPARAM)&fr); - fr.rc.bottom = bottom; - } - while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); - - return page; -} - static void char_from_pagenum(HWND hEditorWnd, FORMATRANGE *fr, int page) { int i; @@ -295,413 +303,6 @@ static void update_ruler(HWND hRulerWnd) redraw_ruler(hRulerWnd); } -static void print(LPPRINTDLGW pd, LPWSTR wszFileName) -{ - FORMATRANGE fr; - DOCINFOW di; - HWND hEditorWnd = GetDlgItem(pd->hwndOwner, IDC_EDITOR); - int printedPages = 0; - - fr.hdc = pd->hDC; - fr.hdcTarget = pd->hDC; - - fr.rc = get_print_rect(fr.hdc); - fr.rcPage.left = 0; - fr.rcPage.right = fr.rc.right + margins.right; - fr.rcPage.top = 0; - fr.rcPage.bottom = fr.rc.bottom + margins.bottom; - - ZeroMemory(&di, sizeof(di)); - di.cbSize = sizeof(di); - di.lpszDocName = wszFileName; - - if(pd->Flags & PD_PRINTTOFILE) - { - di.lpszOutput = dialog_print_to_file(pd->hwndOwner); - if(!di.lpszOutput) - return; - } - - if(pd->Flags & PD_SELECTION) - { - SendMessageW(hEditorWnd, EM_EXGETSEL, 0, (LPARAM)&fr.chrg); - } else - { - GETTEXTLENGTHEX gt; - gt.flags = GTL_DEFAULT; - gt.codepage = 1200; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - - if(pd->Flags & PD_PAGENUMS) - char_from_pagenum(hEditorWnd, &fr, pd->nToPage); - } - - StartDocW(fr.hdc, &di); - do - { - int bottom = fr.rc.bottom; - if(StartPage(fr.hdc) <= 0) - break; - - fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr); - - if(EndPage(fr.hdc) <= 0) - break; - bottom = fr.rc.bottom; - - printedPages++; - if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage))) - break; - } - while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); - - EndDoc(fr.hdc); - SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0); -} - -void dialog_printsetup(HWND hMainWnd) -{ - PAGESETUPDLGW ps; - - ZeroMemory(&ps, sizeof(ps)); - ps.lStructSize = sizeof(ps); - ps.hwndOwner = hMainWnd; - ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS; - ps.rtMargin.left = twips_to_centmm(margins.left); - ps.rtMargin.right = twips_to_centmm(margins.right); - ps.rtMargin.top = twips_to_centmm(margins.top); - ps.rtMargin.bottom = twips_to_centmm(margins.bottom); - ps.hDevMode = devMode; - ps.hDevNames = devNames; - - if(PageSetupDlgW(&ps)) - { - margins.left = centmm_to_twips(ps.rtMargin.left); - margins.right = centmm_to_twips(ps.rtMargin.right); - margins.top = centmm_to_twips(ps.rtMargin.top); - margins.bottom = centmm_to_twips(ps.rtMargin.bottom); - devMode = ps.hDevMode; - devNames = ps.hDevNames; - update_ruler(get_ruler_wnd(hMainWnd)); - } -} - -void get_default_printer_opts(void) -{ - PRINTDLGW pd; - ZeroMemory(&pd, sizeof(pd)); - - ZeroMemory(&pd, sizeof(pd)); - pd.lStructSize = sizeof(pd); - pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT; - pd.hDevMode = devMode; - - PrintDlgW(&pd); - - devMode = pd.hDevMode; - devNames = pd.hDevNames; -} - -void print_quick(LPWSTR wszFileName) -{ - PRINTDLGW pd; - - ZeroMemory(&pd, sizeof(pd)); - pd.hDC = make_dc(); - - print(&pd, wszFileName); -} - -void dialog_print(HWND hMainWnd, LPWSTR wszFileName) -{ - PRINTDLGW pd; - HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); - int from = 0; - int to = 0; - - ZeroMemory(&pd, sizeof(pd)); - pd.lStructSize = sizeof(pd); - pd.hwndOwner = hMainWnd; - pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; - pd.nMinPage = 1; - pd.nMaxPage = -1; - pd.hDevMode = devMode; - pd.hDevNames = devNames; - - SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to); - if(from == to) - pd.Flags |= PD_NOSELECTION; - - if(PrintDlgW(&pd)) - { - devMode = pd.hDevMode; - devNames = pd.hDevNames; - print(&pd, wszFileName); - update_ruler(get_ruler_wnd(hMainWnd)); - } -} - -static void preview_bar_show(HWND hMainWnd, BOOL show) -{ - HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); - int i; - - if(show) - { - REBARBANDINFOW rb; - HWND hStatic; - - AddTextButton(hReBar, STRING_PREVIEW_PRINT, ID_PRINT, BANDID_PREVIEW_BTN1); - AddTextButton(hReBar, STRING_PREVIEW_NEXTPAGE, ID_PREVIEW_NEXTPAGE, BANDID_PREVIEW_BTN2); - AddTextButton(hReBar, STRING_PREVIEW_PREVPAGE, ID_PREVIEW_PREVPAGE, BANDID_PREVIEW_BTN3); - AddTextButton(hReBar, STRING_PREVIEW_TWOPAGES, ID_PREVIEW_NUMPAGES, BANDID_PREVIEW_BTN4); - AddTextButton(hReBar, STRING_PREVIEW_ZOOMIN, ID_PREVIEW_ZOOMIN, BANDID_PREVIEW_BTN5); - AddTextButton(hReBar, STRING_PREVIEW_ZOOMOUT, ID_PREVIEW_ZOOMOUT, BANDID_PREVIEW_BTN6); - AddTextButton(hReBar, STRING_PREVIEW_CLOSE, ID_FILE_EXIT, BANDID_PREVIEW_BTN7); - - hStatic = CreateWindowW(WC_STATICW, NULL, - WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, - hReBar, NULL, NULL, NULL); - - rb.cbSize = REBARBANDINFOW_V6_SIZE; - rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID; - rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT; - rb.hwndChild = hStatic; - rb.cyChild = rb.cyMinChild = 22; - rb.cx = rb.cxMinChild = 90; - rb.cxIdeal = 100; - rb.wID = BANDID_PREVIEW_BUFFER; - - SendMessageW(hReBar, RB_INSERTBAND, -1, (LPARAM)&rb); - } else - { - for(i = 0; i <= PREVIEW_BUTTONS; i++) - SendMessageW(hReBar, RB_DELETEBAND, SendMessageW(hReBar, RB_IDTOINDEX, BANDID_PREVIEW_BTN1+i, 0), 0); - } -} - -static const int min_spacing = 10; - -static void update_preview_scrollbars(HWND hwndPreview, RECT *window) -{ - SCROLLINFO sbi; - sbi.cbSize = sizeof(sbi); - sbi.fMask = SIF_PAGE|SIF_RANGE; - sbi.nMin = 0; - if (preview.zoomlevel == 0) - { - /* Hide scrollbars when zoomed out. */ - sbi.nMax = 0; - sbi.nPage = window->right; - SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); - sbi.nPage = window->bottom; - SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); - } else { - if (!preview.hdc2) - sbi.nMax = preview.bmScaledSize.cx + min_spacing * 2; - else - sbi.nMax = preview.bmScaledSize.cx * 2 + min_spacing * 3; - sbi.nPage = window->right; - SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); - /* Change in the horizontal scrollbar visibility affects the - * client rect, so update the client rect. */ - GetClientRect(hwndPreview, window); - sbi.nMax = preview.bmScaledSize.cy + min_spacing * 2; - sbi.nPage = window->bottom; - SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); - } -} - -static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated) -{ - RECT window; - - GetClientRect(hwndPreview, &window); - - /* The zoom ratio isn't updated for partial zoom because of resizing the window. */ - if (zoomLevelUpdated || preview.zoomlevel != 1) - { - float ratio, ratioHeight, ratioWidth; - if (preview.zoomlevel == 2) - { - ratio = 1.0; - } else { - ratioHeight = (window.bottom - min_spacing * 2) / (float)preview.bmSize.cy; - - if(preview.hdc2) - ratioWidth = ((window.right - min_spacing * 3) / 2.0) / (float)preview.bmSize.cx; - else - ratioWidth = (window.right - min_spacing * 2) / (float)preview.bmSize.cx; - - if(ratioWidth > ratioHeight) - ratio = ratioHeight; - else - ratio = ratioWidth; - - if (preview.zoomlevel == 1) - ratio += (1.0 - ratio) / 2; - } - preview.zoomratio = ratio; - } - - preview.bmScaledSize.cx = preview.bmSize.cx * preview.zoomratio; - preview.bmScaledSize.cy = preview.bmSize.cy * preview.zoomratio; - - preview.spacing.cy = max(min_spacing, (window.bottom - preview.bmScaledSize.cy) / 2); - - if(!preview.hdc2) - preview.spacing.cx = (window.right - preview.bmScaledSize.cx) / 2; - else - preview.spacing.cx = (window.right - preview.bmScaledSize.cx * 2) / 3; - if (preview.spacing.cx < min_spacing) - preview.spacing.cx = min_spacing; - - update_preview_scrollbars(hwndPreview, &window); -} - -/* Update for zoom ratio changes with same page. */ -static void update_scaled_preview(HWND hMainWnd) -{ - HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); - preview.window.right = 0; - InvalidateRect(hwndPreview, NULL, TRUE); -} - -LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_CREATE: - { - HWND hEditorWnd = GetDlgItem(GetParent(hWnd), IDC_EDITOR); - FORMATRANGE fr; - GETTEXTLENGTHEX gt = {GTL_DEFAULT, 1200}; - HDC hdc = GetDC(hWnd); - HDC hdcTarget = make_dc(); - - fr.rc = preview.rcPage = get_print_rect(hdcTarget); - preview.rcPage.bottom += margins.bottom; - preview.rcPage.right += margins.right; - preview.rcPage.top = preview.rcPage.left = 0; - fr.rcPage = preview.rcPage; - - preview.bmSize.cx = twips_to_pixels(preview.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX)); - preview.bmSize.cy = twips_to_pixels(preview.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY)); - - fr.hdc = CreateCompatibleDC(hdc); - fr.hdcTarget = hdcTarget; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - preview.pages = get_num_pages(hEditorWnd, fr); - DeleteDC(fr.hdc); - - update_preview_sizes(hWnd, TRUE); - break; - } - - case WM_PAINT: - return print_preview(hWnd); - - case WM_SIZE: - { - update_preview_sizes(hWnd, FALSE); - update_scaled_preview(hWnd); - break; - } - - case WM_VSCROLL: - case WM_HSCROLL: - { - SCROLLINFO si; - RECT rc; - int nBar = (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ; - int origPos; - - GetClientRect(hWnd, &rc); - si.cbSize = sizeof(si); - si.fMask = SIF_ALL; - GetScrollInfo(hWnd, nBar, &si); - origPos = si.nPos; - switch(LOWORD(wParam)) - { - case SB_TOP: /* == SB_LEFT */ - si.nPos = si.nMin; - break; - case SB_BOTTOM: /* == SB_RIGHT */ - si.nPos = si.nMax; - break; - case SB_LINEUP: /* == SB_LINELEFT */ - si.nPos -= si.nPage / 10; - break; - case SB_LINEDOWN: /* == SB_LINERIGHT */ - si.nPos += si.nPage / 10; - break; - case SB_PAGEUP: /* == SB_PAGELEFT */ - si.nPos -= si.nPage; - break; - case SB_PAGEDOWN: /* SB_PAGERIGHT */ - si.nPos += si.nPage; - break; - case SB_THUMBTRACK: - si.nPos = si.nTrackPos; - break; - } - si.fMask = SIF_POS; - SetScrollInfo(hWnd, nBar, &si, TRUE); - GetScrollInfo(hWnd, nBar, &si); - if (si.nPos != origPos) - { - int amount = origPos - si.nPos; - if (msg == WM_VSCROLL) - ScrollWindow(hWnd, 0, amount, NULL, NULL); - else - ScrollWindow(hWnd, amount, 0, NULL, NULL); - } - return 0; - } - - default: - return DefWindowProcW(hWnd, msg, wParam, lParam); - } - - return 0; -} - -void init_preview(HWND hMainWnd, LPWSTR wszFileName) -{ - HWND hwndPreview; - HINSTANCE hInstance = GetModuleHandleW(0); - preview.page = 1; - preview.hdc = 0; - preview.hdc2 = 0; - preview.wszFileName = wszFileName; - preview.zoomratio = 0; - preview.zoomlevel = 0; - preview_bar_show(hMainWnd, TRUE); - - hwndPreview = CreateWindowExW(0, wszPreviewWndClass, NULL, - WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, - 0, 0, 200, 10, hMainWnd, (HMENU)IDC_PREVIEW, hInstance, NULL); -} - -void close_preview(HWND hMainWnd) -{ - HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); - preview.window.right = 0; - preview.window.bottom = 0; - preview.page = 0; - preview.pages = 0; - - preview_bar_show(hMainWnd, FALSE); - DestroyWindow(hwndPreview); -} - -BOOL preview_isactive(void) -{ - return preview.page != 0; -} - static void add_ruler_units(HDC hdcRuler, RECT* drawRect, BOOL NewMetrics, LONG EditLeftmost) { static HDC hdc; @@ -841,25 +442,296 @@ LRESULT CALLBACK ruler_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } -static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float ratio, int bmNewWidth, int bmNewHeight, int bmWidth, int bmHeight) +static void print(LPPRINTDLGW pd, LPWSTR wszFileName) +{ + FORMATRANGE fr; + DOCINFOW di; + HWND hEditorWnd = GetDlgItem(pd->hwndOwner, IDC_EDITOR); + int printedPages = 0; + + fr.hdc = pd->hDC; + fr.hdcTarget = pd->hDC; + + fr.rc = get_print_rect(fr.hdc); + fr.rcPage.left = 0; + fr.rcPage.right = fr.rc.right + margins.right; + fr.rcPage.top = 0; + fr.rcPage.bottom = fr.rc.bottom + margins.bottom; + + ZeroMemory(&di, sizeof(di)); + di.cbSize = sizeof(di); + di.lpszDocName = wszFileName; + + if(pd->Flags & PD_PRINTTOFILE) + { + di.lpszOutput = dialog_print_to_file(pd->hwndOwner); + if(!di.lpszOutput) + return; + } + + if(pd->Flags & PD_SELECTION) + { + SendMessageW(hEditorWnd, EM_EXGETSEL, 0, (LPARAM)&fr.chrg); + } else + { + GETTEXTLENGTHEX gt; + gt.flags = GTL_DEFAULT; + gt.codepage = 1200; + fr.chrg.cpMin = 0; + fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + + if(pd->Flags & PD_PAGENUMS) + char_from_pagenum(hEditorWnd, &fr, pd->nToPage); + } + + StartDocW(fr.hdc, &di); + do + { + int bottom = fr.rc.bottom; + if(StartPage(fr.hdc) <= 0) + break; + + fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr); + + if(EndPage(fr.hdc) <= 0) + break; + bottom = fr.rc.bottom; + + printedPages++; + if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage))) + break; + } + while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); + + EndDoc(fr.hdc); + SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0); +} + +void dialog_printsetup(HWND hMainWnd) +{ + PAGESETUPDLGW ps; + + ZeroMemory(&ps, sizeof(ps)); + ps.lStructSize = sizeof(ps); + ps.hwndOwner = hMainWnd; + ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS; + ps.rtMargin.left = twips_to_centmm(margins.left); + ps.rtMargin.right = twips_to_centmm(margins.right); + ps.rtMargin.top = twips_to_centmm(margins.top); + ps.rtMargin.bottom = twips_to_centmm(margins.bottom); + ps.hDevMode = devMode; + ps.hDevNames = devNames; + + if(PageSetupDlgW(&ps)) + { + margins.left = centmm_to_twips(ps.rtMargin.left); + margins.right = centmm_to_twips(ps.rtMargin.right); + margins.top = centmm_to_twips(ps.rtMargin.top); + margins.bottom = centmm_to_twips(ps.rtMargin.bottom); + devMode = ps.hDevMode; + devNames = ps.hDevNames; + update_ruler(get_ruler_wnd(hMainWnd)); + } +} + +void get_default_printer_opts(void) +{ + PRINTDLGW pd; + ZeroMemory(&pd, sizeof(pd)); + + ZeroMemory(&pd, sizeof(pd)); + pd.lStructSize = sizeof(pd); + pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT; + pd.hDevMode = devMode; + + PrintDlgW(&pd); + + devMode = pd.hDevMode; + devNames = pd.hDevNames; +} + +void print_quick(HWND hMainWnd, LPWSTR wszFileName) +{ + PRINTDLGW pd; + + ZeroMemory(&pd, sizeof(pd)); + pd.hwndOwner = hMainWnd; + pd.hDC = make_dc(); + + print(&pd, wszFileName); + DeleteDC(pd.hDC); +} + +void dialog_print(HWND hMainWnd, LPWSTR wszFileName) +{ + PRINTDLGW pd; + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + int from = 0; + int to = 0; + + ZeroMemory(&pd, sizeof(pd)); + pd.lStructSize = sizeof(pd); + pd.hwndOwner = hMainWnd; + pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; + pd.nMinPage = 1; + pd.nMaxPage = -1; + pd.hDevMode = devMode; + pd.hDevNames = devNames; + + SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to); + if(from == to) + pd.Flags |= PD_NOSELECTION; + + if(PrintDlgW(&pd)) + { + devMode = pd.hDevMode; + devNames = pd.hDevNames; + print(&pd, wszFileName); + update_ruler(get_ruler_wnd(hMainWnd)); + } +} + +static void preview_bar_show(HWND hMainWnd, BOOL show) +{ + HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); + int i; + + if(show) + { + REBARBANDINFOW rb; + HWND hStatic; + UINT num_pages_string = preview.pages_shown > 1 ? STRING_PREVIEW_ONEPAGE : + STRING_PREVIEW_TWOPAGES; + + AddTextButton(hReBar, STRING_PREVIEW_PRINT, ID_PRINT, BANDID_PREVIEW_BTN1); + AddTextButton(hReBar, STRING_PREVIEW_NEXTPAGE, ID_PREVIEW_NEXTPAGE, BANDID_PREVIEW_BTN2); + AddTextButton(hReBar, STRING_PREVIEW_PREVPAGE, ID_PREVIEW_PREVPAGE, BANDID_PREVIEW_BTN3); + AddTextButton(hReBar, num_pages_string, ID_PREVIEW_NUMPAGES, BANDID_PREVIEW_BTN4); + AddTextButton(hReBar, STRING_PREVIEW_ZOOMIN, ID_PREVIEW_ZOOMIN, BANDID_PREVIEW_BTN5); + AddTextButton(hReBar, STRING_PREVIEW_ZOOMOUT, ID_PREVIEW_ZOOMOUT, BANDID_PREVIEW_BTN6); + AddTextButton(hReBar, STRING_PREVIEW_CLOSE, ID_FILE_EXIT, BANDID_PREVIEW_BTN7); + + hStatic = CreateWindowW(WC_STATICW, NULL, + WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, + hReBar, NULL, NULL, NULL); + + rb.cbSize = REBARBANDINFOW_V6_SIZE; + rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID; + rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT; + rb.hwndChild = hStatic; + rb.cyChild = rb.cyMinChild = 22; + rb.cx = rb.cxMinChild = 90; + rb.cxIdeal = 100; + rb.wID = BANDID_PREVIEW_BUFFER; + + SendMessageW(hReBar, RB_INSERTBAND, -1, (LPARAM)&rb); + } else + { + for(i = 0; i <= PREVIEW_BUTTONS; i++) + SendMessageW(hReBar, RB_DELETEBAND, SendMessageW(hReBar, RB_IDTOINDEX, BANDID_PREVIEW_BTN1+i, 0), 0); + } +} + +static const int min_spacing = 10; + +static void update_preview_scrollbars(HWND hwndPreview, RECT *window) +{ + SCROLLINFO sbi; + sbi.cbSize = sizeof(sbi); + sbi.fMask = SIF_PAGE|SIF_RANGE; + sbi.nMin = 0; + if (preview.zoomlevel == 0) + { + /* Hide scrollbars when zoomed out. */ + sbi.nMax = 0; + sbi.nPage = window->right; + SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); + sbi.nPage = window->bottom; + SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); + } else { + sbi.nMax = preview.bmScaledSize.cx * preview.pages_shown + + min_spacing * (preview.pages_shown + 1); + sbi.nPage = window->right; + SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); + /* Change in the horizontal scrollbar visibility affects the + * client rect, so update the client rect. */ + GetClientRect(hwndPreview, window); + sbi.nMax = preview.bmScaledSize.cy + min_spacing * 2; + sbi.nPage = window->bottom; + SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); + } +} + +static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated) +{ + RECT window; + + GetClientRect(hwndPreview, &window); + + /* The zoom ratio isn't updated for partial zoom because of resizing the window. */ + if (zoomLevelUpdated || preview.zoomlevel != 1) + { + float ratio, ratioHeight, ratioWidth; + if (preview.zoomlevel == 2) + { + ratio = 1.0; + } else { + ratioHeight = (window.bottom - min_spacing * 2) / (float)preview.bmSize.cy; + + ratioWidth = (float)(window.right - + min_spacing * (preview.pages_shown + 1)) / + (preview.pages_shown * preview.bmSize.cx); + + if(ratioWidth > ratioHeight) + ratio = ratioHeight; + else + ratio = ratioWidth; + + if (preview.zoomlevel == 1) + ratio += (1.0 - ratio) / 2; + } + preview.zoomratio = ratio; + } + + preview.bmScaledSize.cx = preview.bmSize.cx * preview.zoomratio; + preview.bmScaledSize.cy = preview.bmSize.cy * preview.zoomratio; + + preview.spacing.cy = max(min_spacing, (window.bottom - preview.bmScaledSize.cy) / 2); + + preview.spacing.cx = (window.right - + preview.bmScaledSize.cx * preview.pages_shown) / + (preview.pages_shown + 1); + if (preview.spacing.cx < min_spacing) + preview.spacing.cx = min_spacing; + + update_preview_scrollbars(hwndPreview, &window); +} + +static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float ratio, int bmNewWidth, int bmNewHeight, int bmWidth, int bmHeight, BOOL draw_margins) { HBITMAP hBitmapScaled = CreateCompatibleBitmap(hdc, bmNewWidth, bmNewHeight); - HPEN hPen; + HBITMAP oldbm; + HPEN hPen, oldPen; int TopMargin = (int)((float)twips_to_pixels(lpFr->rc.top, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio); int BottomMargin = (int)((float)twips_to_pixels(lpFr->rc.bottom, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio); int LeftMargin = (int)((float)twips_to_pixels(lpFr->rc.left, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio); int RightMargin = (int)((float)twips_to_pixels(lpFr->rc.right, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio); - if(*hdcSized) - DeleteDC(*hdcSized); - *hdcSized = CreateCompatibleDC(hdc); - SelectObject(*hdcSized, hBitmapScaled); + if(*hdcSized) { + oldbm = SelectObject(*hdcSized, hBitmapScaled); + DeleteObject(oldbm); + } else { + *hdcSized = CreateCompatibleDC(hdc); + SelectObject(*hdcSized, hBitmapScaled); + } StretchBlt(*hdcSized, 0, 0, bmNewWidth, bmNewHeight, hdc, 0, 0, bmWidth, bmHeight, SRCCOPY); + if (!draw_margins) return; + /* Draw margin lines */ hPen = CreatePen(PS_DOT, 1, RGB(0,0,0)); - SelectObject(*hdcSized, hPen); + oldPen = SelectObject(*hdcSized, hPen); MoveToEx(*hdcSized, 0, TopMargin, NULL); LineTo(*hdcSized, bmNewWidth, TopMargin); @@ -871,18 +743,137 @@ static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float r MoveToEx(*hdcSized, RightMargin, 0, NULL); LineTo(*hdcSized, RightMargin, bmNewHeight); + SelectObject(*hdcSized, oldPen); + DeleteObject(hPen); } -static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, int bmWidth, int bmHeight, RECT* paper, int page) +static BOOL is_last_preview_page(int page) +{ + return preview.pageEnds[page - 1] >= preview.textlength; +} + +/* Update for zoom ratio changes with same page. */ +static void update_scaled_preview(HWND hMainWnd) +{ + FORMATRANGE fr; + HWND hwndPreview; + + /* This may occur on WM_CREATE before update_preview is called + * because a WM_SIZE message is generated from updating the + * scrollbars. */ + if (!preview.hdc) return; + + hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); + fr.hdcTarget = make_dc(); + fr.rc = fr.rcPage = preview.rcPage; + fr.rc.left += margins.left; + fr.rc.top += margins.top; + fr.rc.bottom -= margins.bottom; + fr.rc.right -= margins.right; + + draw_preview_page(preview.hdc, &preview.hdcSized, &fr, preview.zoomratio, + preview.bmScaledSize.cx, preview.bmScaledSize.cy, + preview.bmSize.cx, preview.bmSize.cy, TRUE); + + if(preview.pages_shown > 1) + { + draw_preview_page(preview.hdc2, &preview.hdcSized2, &fr, preview.zoomratio, + preview.bmScaledSize.cx, preview.bmScaledSize.cy, + preview.bmSize.cx, preview.bmSize.cy, + !is_last_preview_page(preview.page)); + } + + InvalidateRect(hwndPreview, NULL, TRUE); + DeleteDC(fr.hdcTarget); +} + +void init_preview(HWND hMainWnd, LPWSTR wszFileName) +{ + HWND hwndPreview; + HINSTANCE hInstance = GetModuleHandleW(0); + preview.page = 1; + preview.hdc = 0; + preview.hdc2 = 0; + preview.wszFileName = wszFileName; + preview.zoomratio = 0; + preview.zoomlevel = 0; + preview_bar_show(hMainWnd, TRUE); + + hwndPreview = CreateWindowExW(0, wszPreviewWndClass, NULL, + WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, + 0, 0, 200, 10, hMainWnd, (HMENU)IDC_PREVIEW, hInstance, NULL); +} + +void close_preview(HWND hMainWnd) +{ + HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); + preview.window.right = 0; + preview.window.bottom = 0; + preview.page = 0; + HeapFree(GetProcessHeap(), 0, preview.pageEnds); + preview.pageEnds = NULL; + preview.pageCapacity = 0; + if (preview.zoomlevel > 0) + preview.pages_shown = preview.saved_pages_shown; + if(preview.hdc) { + HBITMAP oldbm = GetCurrentObject(preview.hdc, OBJ_BITMAP); + DeleteDC(preview.hdc); + DeleteObject(oldbm); + preview.hdc = NULL; + } + if(preview.hdc2) { + HBITMAP oldbm = GetCurrentObject(preview.hdc2, OBJ_BITMAP); + DeleteDC(preview.hdc2); + DeleteObject(oldbm); + preview.hdc2 = NULL; + } + if(preview.hdcSized) { + HBITMAP oldbm = GetCurrentObject(preview.hdcSized, OBJ_BITMAP); + DeleteDC(preview.hdcSized); + DeleteObject(oldbm); + preview.hdcSized = NULL; + } + if(preview.hdcSized2) { + HBITMAP oldbm = GetCurrentObject(preview.hdcSized2, OBJ_BITMAP); + DeleteDC(preview.hdcSized2); + DeleteObject(oldbm); + preview.hdcSized2 = NULL; + } + + preview_bar_show(hMainWnd, FALSE); + DestroyWindow(hwndPreview); +} + +BOOL preview_isactive(void) +{ + return preview.page != 0; +} + +static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, RECT* paper, int page) { - HBITMAP hBitmapCapture = CreateCompatibleBitmap(lpFr->hdc, bmWidth, bmHeight); int bottom; - char_from_pagenum(hEditorWnd, lpFr, page); - SelectObject(lpFr->hdc, hBitmapCapture); + if (!preview.pageEnds) + { + preview.pageCapacity = 32; + preview.pageEnds = HeapAlloc(GetProcessHeap(), 0, + sizeof(int) * preview.pageCapacity); + if (!preview.pageEnds) return; + } else if (page >= preview.pageCapacity) { + int *new_buffer; + new_buffer = HeapReAlloc(GetProcessHeap(), 0, preview.pageEnds, + sizeof(int) * preview.pageCapacity * 2); + if (!new_buffer) return; + preview.pageCapacity *= 2; + preview.pageEnds = new_buffer; + } + FillRect(lpFr->hdc, paper, GetStockObject(WHITE_BRUSH)); + if (page > 1 && is_last_preview_page(page - 1)) return; + lpFr->chrg.cpMin = page <= 1 ? 0 : preview.pageEnds[page-2]; bottom = lpFr->rc.bottom; - SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)lpFr); + preview.pageEnds[page-1] = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)lpFr); + /* EM_FORMATRANGE sets fr.rc.bottom to indicate the area printed in, * but we want to keep the original for drawing margins */ lpFr->rc.bottom = bottom; @@ -893,70 +884,26 @@ static void update_preview_buttons(HWND hMainWnd) { HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_PREVPAGE), preview.page > 1); - EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), preview.hdc2 ? - (preview.page + 1) < preview.pages : - preview.page < preview.pages); - EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), preview.pages > 1 && preview.zoomlevel == 0); + EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), + !is_last_preview_page(preview.page) && + !is_last_preview_page(preview.page + preview.pages_shown - 1)); + EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), + preview.pages_shown > 1 || + (!is_last_preview_page(1) && preview.zoomlevel == 0)); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_ZOOMIN), preview.zoomlevel < 2); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_ZOOMOUT), preview.zoomlevel > 0); } LRESULT print_preview(HWND hwndPreview) { - FORMATRANGE fr; HDC hdc; RECT window, background; PAINTSTRUCT ps; - HWND hMainWnd = GetParent(hwndPreview); POINT scrollpos; hdc = BeginPaint(hwndPreview, &ps); GetClientRect(hwndPreview, &window); - fr.hdcTarget = make_dc(); - fr.rc = fr.rcPage = preview.rcPage; - fr.rc.left += margins.left; - fr.rc.top += margins.top; - fr.rc.bottom -= margins.bottom; - fr.rc.right -= margins.right; - - if(!preview.hdc) - { - GETTEXTLENGTHEX gt; - RECT paper; - HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); - - preview.hdc = CreateCompatibleDC(hdc); - - if(preview.hdc2) - { - if(preview.hdc2 != (HDC)-1) - DeleteDC(preview.hdc2); - preview.hdc2 = CreateCompatibleDC(hdc); - } - - gt.flags = GTL_DEFAULT; - gt.codepage = 1200; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - - paper.left = 0; - paper.right = preview.bmSize.cx; - paper.top = 0; - paper.bottom = preview.bmSize.cy; - - fr.hdc = preview.hdc; - draw_preview(hEditorWnd, &fr, preview.bmSize.cx, preview.bmSize.cy, &paper, preview.page); - - if(preview.hdc2) - { - fr.hdc = preview.hdc2; - draw_preview(hEditorWnd, &fr, preview.bmSize.cx, preview.bmSize.cy, &fr.rcPage, preview.page + 1); - } - - update_preview_buttons(hMainWnd); - } - FillRect(hdc, &window, GetStockObject(GRAY_BRUSH)); scrollpos.x = GetScrollPos(hwndPreview, SB_HORZ); @@ -969,7 +916,7 @@ LRESULT print_preview(HWND hwndPreview) FillRect(hdc, &background, GetStockObject(BLACK_BRUSH)); - if(preview.hdc2) + if(preview.pages_shown > 1) { background.left += preview.bmScaledSize.cx + preview.spacing.cx; background.right += preview.bmScaledSize.cx + preview.spacing.cx; @@ -977,32 +924,17 @@ LRESULT print_preview(HWND hwndPreview) FillRect(hdc, &background, GetStockObject(BLACK_BRUSH)); } - if(window.right != preview.window.right || window.bottom != preview.window.bottom) - { - draw_preview_page(preview.hdc, &preview.hdcSized, &fr, preview.zoomratio, - preview.bmScaledSize.cx, preview.bmScaledSize.cy, - preview.bmSize.cx, preview.bmSize.cy); - - if(preview.hdc2) - { - draw_preview_page(preview.hdc2, &preview.hdcSized2, &fr, preview.zoomratio, - preview.bmScaledSize.cx, preview.bmScaledSize.cy, - preview.bmSize.cx, preview.bmSize.cy); - } - } - BitBlt(hdc, preview.spacing.cx - scrollpos.x, preview.spacing.cy - scrollpos.y, preview.bmScaledSize.cx, preview.bmScaledSize.cy, preview.hdcSized, 0, 0, SRCCOPY); - if(preview.hdc2) + if(preview.pages_shown > 1) { BitBlt(hdc, preview.spacing.cx * 2 + preview.bmScaledSize.cx - scrollpos.x, preview.spacing.cy - scrollpos.y, preview.bmScaledSize.cx, preview.bmScaledSize.cy, preview.hdcSized2, 0, 0, SRCCOPY); } - DeleteDC(fr.hdcTarget); preview.window = window; EndPaint(hwndPreview, &ps); @@ -1010,13 +942,81 @@ LRESULT print_preview(HWND hwndPreview) return 0; } +static void update_preview_statusbar(HWND hMainWnd) +{ + HWND hStatusbar = GetDlgItem(hMainWnd, IDC_STATUSBAR); + HINSTANCE hInst = GetModuleHandleW(0); + WCHAR *p; + WCHAR wstr[MAX_STRING_LEN]; + + p = wstr; + if (preview.pages_shown < 2 || is_last_preview_page(preview.page)) + { + static const WCHAR fmt[] = {' ','%','d','\0'}; + p += LoadStringW(hInst, STRING_PREVIEW_PAGE, wstr, MAX_STRING_LEN); + wsprintfW(p, fmt, preview.page); + } else { + static const WCHAR fmt[] = {' ','%','d','-','%','d','\0'}; + p += LoadStringW(hInst, STRING_PREVIEW_PAGES, wstr, MAX_STRING_LEN); + wsprintfW(p, fmt, preview.page, preview.page + 1); + } + SetWindowTextW(hStatusbar, wstr); +} + /* Update for page changes. */ static void update_preview(HWND hMainWnd) { - DeleteDC(preview.hdc); - preview.hdc = 0; + RECT paper; + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); + HBITMAP hBitmapCapture; + FORMATRANGE fr; + HDC hdc = GetDC(hwndPreview); + + fr.hdcTarget = make_dc(); + fr.rc = fr.rcPage = preview.rcPage; + fr.rc.left += margins.left; + fr.rc.top += margins.top; + fr.rc.bottom -= margins.bottom; + fr.rc.right -= margins.right; + + fr.chrg.cpMin = 0; + fr.chrg.cpMax = preview.textlength; + + paper.left = 0; + paper.right = preview.bmSize.cx; + paper.top = 0; + paper.bottom = preview.bmSize.cy; + + if (!preview.hdc) { + preview.hdc = CreateCompatibleDC(hdc); + hBitmapCapture = CreateCompatibleBitmap(hdc, preview.bmSize.cx, preview.bmSize.cy); + SelectObject(preview.hdc, hBitmapCapture); + } + + fr.hdc = preview.hdc; + draw_preview(hEditorWnd, &fr, &paper, preview.page); + + if(preview.pages_shown > 1) + { + if (!preview.hdc2) + { + preview.hdc2 = CreateCompatibleDC(hdc); + hBitmapCapture = CreateCompatibleBitmap(hdc, + preview.bmSize.cx, + preview.bmSize.cy); + SelectObject(preview.hdc2, hBitmapCapture); + } + + fr.hdc = preview.hdc2; + draw_preview(hEditorWnd, &fr, &fr.rcPage, preview.page + 1); + } + DeleteDC(fr.hdcTarget); + ReleaseDC(hwndPreview, hdc); update_scaled_preview(hMainWnd); + update_preview_buttons(hMainWnd); + update_preview_statusbar(hMainWnd); } static void toggle_num_pages(HWND hMainWnd) @@ -1024,19 +1024,15 @@ static void toggle_num_pages(HWND hMainWnd) HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); WCHAR name[MAX_STRING_LEN]; HINSTANCE hInst = GetModuleHandleW(0); + int nPreviewPages; - if(preview.hdc2) - { - DeleteDC(preview.hdc2); - preview.hdc2 = 0; - } else - { - if(preview.page == preview.pages) - preview.page--; - preview.hdc2 = (HDC)-1; - } + preview.pages_shown = preview.pages_shown > 1 ? 1 : 2; - LoadStringW(hInst, preview.hdc2 ? STRING_PREVIEW_ONEPAGE : STRING_PREVIEW_TWOPAGES, + nPreviewPages = preview.zoomlevel > 0 ? preview.saved_pages_shown : + preview.pages_shown; + + LoadStringW(hInst, nPreviewPages > 1 ? STRING_PREVIEW_ONEPAGE : + STRING_PREVIEW_TWOPAGES, name, MAX_STRING_LEN); SetWindowTextW(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), name); @@ -1044,6 +1040,216 @@ static void toggle_num_pages(HWND hMainWnd) update_preview(hMainWnd); } +/* Returns the page shown that the point is in (1 or 2) or 0 if the point + * isn't inside either page */ +int preview_page_hittest(POINT pt) +{ + RECT rc; + rc.left = preview.spacing.cx; + rc.right = rc.left + preview.bmScaledSize.cx; + rc.top = preview.spacing.cy; + rc.bottom = rc.top + preview.bmScaledSize.cy; + if (PtInRect(&rc, pt)) + return 1; + + if (preview.pages_shown <= 1) + return 0; + + rc.left += preview.bmScaledSize.cx + preview.spacing.cx; + rc.right += preview.bmScaledSize.cx + preview.spacing.cx; + if (PtInRect(&rc, pt)) + return is_last_preview_page(preview.page) ? 1 : 2; + + return 0; +} + +LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_CREATE: + { + HWND hMainWnd = GetParent(hWnd); + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + FORMATRANGE fr; + GETTEXTLENGTHEX gt = {GTL_DEFAULT, 1200}; + HDC hdc = GetDC(hWnd); + HDC hdcTarget = make_dc(); + + fr.rc = preview.rcPage = get_print_rect(hdcTarget); + preview.rcPage.bottom += margins.bottom; + preview.rcPage.right += margins.right; + preview.rcPage.top = preview.rcPage.left = 0; + fr.rcPage = preview.rcPage; + + preview.bmSize.cx = twips_to_pixels(preview.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX)); + preview.bmSize.cy = twips_to_pixels(preview.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY)); + + preview.textlength = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + + fr.hdc = CreateCompatibleDC(hdc); + fr.hdcTarget = hdcTarget; + fr.chrg.cpMin = 0; + fr.chrg.cpMax = preview.textlength; + DeleteDC(fr.hdc); + DeleteDC(hdcTarget); + ReleaseDC(hWnd, hdc); + + update_preview_sizes(hWnd, TRUE); + update_preview(hMainWnd); + break; + } + + case WM_PAINT: + return print_preview(hWnd); + + case WM_SIZE: + { + update_preview_sizes(hWnd, FALSE); + update_scaled_preview(hWnd); + break; + } + + case WM_VSCROLL: + case WM_HSCROLL: + { + SCROLLINFO si; + RECT rc; + int nBar = (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ; + int origPos; + + GetClientRect(hWnd, &rc); + si.cbSize = sizeof(si); + si.fMask = SIF_ALL; + GetScrollInfo(hWnd, nBar, &si); + origPos = si.nPos; + switch(LOWORD(wParam)) + { + case SB_TOP: /* == SB_LEFT */ + si.nPos = si.nMin; + break; + case SB_BOTTOM: /* == SB_RIGHT */ + si.nPos = si.nMax; + break; + case SB_LINEUP: /* == SB_LINELEFT */ + si.nPos -= si.nPage / 10; + break; + case SB_LINEDOWN: /* == SB_LINERIGHT */ + si.nPos += si.nPage / 10; + break; + case SB_PAGEUP: /* == SB_PAGELEFT */ + si.nPos -= si.nPage; + break; + case SB_PAGEDOWN: /* SB_PAGERIGHT */ + si.nPos += si.nPage; + break; + case SB_THUMBTRACK: + si.nPos = si.nTrackPos; + break; + } + si.fMask = SIF_POS; + SetScrollInfo(hWnd, nBar, &si, TRUE); + GetScrollInfo(hWnd, nBar, &si); + if (si.nPos != origPos) + { + int amount = origPos - si.nPos; + if (msg == WM_VSCROLL) + ScrollWindow(hWnd, 0, amount, NULL, NULL); + else + ScrollWindow(hWnd, amount, 0, NULL, NULL); + } + return 0; + } + + case WM_SETCURSOR: + { + POINT pt; + RECT rc; + int bHittest = FALSE; + DWORD messagePos = GetMessagePos(); + pt.x = (short)LOWORD(messagePos); + pt.y = (short)HIWORD(messagePos); + ScreenToClient(hWnd, &pt); + + GetClientRect(hWnd, &rc); + if (PtInRect(&rc, pt)) + { + pt.x += GetScrollPos(hWnd, SB_HORZ); + pt.y += GetScrollPos(hWnd, SB_VERT); + bHittest = preview_page_hittest(pt); + } + + if (bHittest) + SetCursor(LoadCursorW(GetModuleHandleW(0), + MAKEINTRESOURCEW(IDC_ZOOM))); + else + SetCursor(LoadCursorW(NULL, (WCHAR*)IDC_ARROW)); + + return TRUE; + } + + case WM_LBUTTONDOWN: + { + int page; + POINT pt; + pt.x = (short)LOWORD(lParam) + GetScrollPos(hWnd, SB_HORZ); + pt.y = (short)HIWORD(lParam) + GetScrollPos(hWnd, SB_VERT); + if ((page = preview_page_hittest(pt)) > 0) + { + HWND hMainWnd = GetParent(hWnd); + + /* Convert point from client coordinate to unzoomed page + * coordinate. */ + pt.x -= preview.spacing.cx; + if (page > 1) + pt.x -= preview.bmScaledSize.cx + preview.spacing.cx; + pt.y -= preview.spacing.cy; + pt.x /= preview.zoomratio; + pt.y /= preview.zoomratio; + + if (preview.zoomlevel == 0) + preview.saved_pages_shown = preview.pages_shown; + preview.zoomlevel = (preview.zoomlevel + 1) % 3; + preview.zoomratio = 0; + if (preview.zoomlevel == 0 && preview.saved_pages_shown > 1) + { + toggle_num_pages(hMainWnd); + } else if (preview.pages_shown > 1) { + if (page >= 2) preview.page++; + toggle_num_pages(hMainWnd); + } else { + update_preview_sizes(hWnd, TRUE); + update_scaled_preview(hMainWnd); + update_preview_buttons(hMainWnd); + } + + if (preview.zoomlevel > 0) { + SCROLLINFO si; + /* Convert the coordinate back to client coordinate. */ + pt.x *= preview.zoomratio; + pt.y *= preview.zoomratio; + pt.x += preview.spacing.cx; + pt.y += preview.spacing.cy; + /* Scroll to center view at that point on the page */ + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE; + GetScrollInfo(hWnd, SB_HORZ, &si); + pt.x -= si.nPage / 2; + SetScrollPos(hWnd, SB_HORZ, pt.x, TRUE); + GetScrollInfo(hWnd, SB_VERT, &si); + pt.y -= si.nPage / 2; + SetScrollPos(hWnd, SB_VERT, pt.y, TRUE); + } + } + } + + default: + return DefWindowProcW(hWnd, msg, wParam, lParam); + } + + return 0; +} + LRESULT preview_command(HWND hWnd, WPARAM wParam) { switch(LOWORD(wParam)) @@ -1071,9 +1277,11 @@ LRESULT preview_command(HWND hWnd, WPARAM wParam) case ID_PREVIEW_ZOOMIN: if (preview.zoomlevel < 2) { + if (preview.zoomlevel == 0) + preview.saved_pages_shown = preview.pages_shown; preview.zoomlevel++; preview.zoomratio = 0; - if (preview.hdc2) + if (preview.pages_shown > 1) { /* Forced switch to one page when zooming in. */ toggle_num_pages(hWnd); @@ -1092,9 +1300,13 @@ LRESULT preview_command(HWND hWnd, WPARAM wParam) HWND hwndPreview = GetDlgItem(hWnd, IDC_PREVIEW); preview.zoomlevel--; preview.zoomratio = 0; - update_preview_sizes(hwndPreview, TRUE); - update_scaled_preview(hWnd); - update_preview_buttons(hWnd); + if (preview.zoomlevel == 0 && preview.saved_pages_shown > 1) { + toggle_num_pages(hWnd); + } else { + update_preview_sizes(hwndPreview, TRUE); + update_scaled_preview(hWnd); + update_preview_buttons(hWnd); + } } break; diff --git a/reactos/base/applications/wordpad/registry.c b/reactos/base/applications/wordpad/registry.c index c7edc5b1e50..7311fb68232 100644 --- a/reactos/base/applications/wordpad/registry.c +++ b/reactos/base/applications/wordpad/registry.c @@ -27,6 +27,7 @@ static const WCHAR key_recentfiles[] = {'R','e','c','e','n','t',' ','f','i','l','e', ' ','l','i','s','t',0}; static const WCHAR key_options[] = {'O','p','t','i','o','n','s',0}; +static const WCHAR key_settings[] = {'S','e','t','t','i','n','g','s',0}; static const WCHAR key_rtf[] = {'R','T','F',0}; static const WCHAR key_text[] = {'T','e','x','t',0}; @@ -94,9 +95,14 @@ void registry_set_options(HWND hMainWnd) RegSetValueExW(hKey, var_maximized, 0, REG_DWORD, (LPBYTE)&isMaximized, sizeof(DWORD)); registry_set_pagemargins(hKey); + RegCloseKey(hKey); } - RegCloseKey(hKey); + if(registry_get_handle(&hKey, &action, key_settings) == ERROR_SUCCESS) + { + registry_set_previewpages(hKey); + RegCloseKey(hKey); + } } void registry_read_winrect(RECT* rc) @@ -339,6 +345,13 @@ void registry_read_options(void) registry_read_pagemargins(hKey); RegCloseKey(hKey); } + + if(registry_get_handle(&hKey, 0, key_settings) != ERROR_SUCCESS) { + registry_read_previewpages(NULL); + } else { + registry_read_previewpages(hKey); + RegCloseKey(hKey); + } } static void registry_read_formatopts(int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[]) diff --git a/reactos/base/applications/wordpad/rsrc.rc b/reactos/base/applications/wordpad/rsrc.rc index 4a699aa9c15..a3f66c55e5c 100644 --- a/reactos/base/applications/wordpad/rsrc.rc +++ b/reactos/base/applications/wordpad/rsrc.rc @@ -1,4 +1,4 @@ -/* +/* * Copyright 2004 by Krzysztof Foltman * Copyright 2007 by Alexander N. Sørnes * @@ -61,22 +61,28 @@ IDI_WRI ICON "wri.ico" /* @makedep: txt.ico */ IDI_TXT ICON "txt.ico" +/* @makedep: zoom.cur */ +IDC_ZOOM CURSOR "zoom.cur" + + #include "Da.rc" -#include "De.rc" #include "En.rc" -#include "Fr.rc" #include "Hu.rc" +#include "Ko.rc" +#include "Nl.rc" +#include "Pl.rc" +#include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" #include "It.rc" #include "Ja.rc" -#include "Ko.rc" #include "Lt.rc" -#include "Nl.rc" #include "No.rc" -#include "Pl.rc" #include "Pt.rc" #include "Ru.rc" #include "Si.rc" #include "Sv.rc" -#include "Tr.rc" #include "Uk.rc" #include "Zh.rc" diff --git a/reactos/base/applications/wordpad/wordpad.c b/reactos/base/applications/wordpad/wordpad.c index 0bbe3604438..b9e6f3716a2 100644 --- a/reactos/base/applications/wordpad/wordpad.c +++ b/reactos/base/applications/wordpad/wordpad.c @@ -63,6 +63,7 @@ static HWND hMainWnd; static HWND hEditorWnd; static HWND hFindWnd; static HMENU hPopupMenu; +static HMENU hColorPopupMenu; static UINT ID_FINDMSGSTRING; @@ -1836,17 +1837,18 @@ static LRESULT OnCreate( HWND hWnd ) hFormatBarWnd = CreateToolbarEx(hReBarWnd, CCS_NOPARENTALIGN | CCS_NOMOVEY | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_BUTTON, - IDC_FORMATBAR, 7, hInstance, IDB_FORMATBAR, NULL, 0, 16, 16, 16, 16, sizeof(TBBUTTON)); + IDC_FORMATBAR, 8, hInstance, IDB_FORMATBAR, NULL, 0, 16, 16, 16, 16, sizeof(TBBUTTON)); AddButton(hFormatBarWnd, 0, ID_FORMAT_BOLD); AddButton(hFormatBarWnd, 1, ID_FORMAT_ITALIC); AddButton(hFormatBarWnd, 2, ID_FORMAT_UNDERLINE); + AddButton(hFormatBarWnd, 3, ID_FORMAT_COLOR); AddSeparator(hFormatBarWnd); - AddButton(hFormatBarWnd, 3, ID_ALIGN_LEFT); - AddButton(hFormatBarWnd, 4, ID_ALIGN_CENTER); - AddButton(hFormatBarWnd, 5, ID_ALIGN_RIGHT); + AddButton(hFormatBarWnd, 4, ID_ALIGN_LEFT); + AddButton(hFormatBarWnd, 5, ID_ALIGN_CENTER); + AddButton(hFormatBarWnd, 6, ID_ALIGN_RIGHT); AddSeparator(hFormatBarWnd); - AddButton(hFormatBarWnd, 6, ID_BULLET); + AddButton(hFormatBarWnd, 7, ID_BULLET); SendMessageW(hFormatBarWnd, TB_AUTOSIZE, 0, 0); @@ -2001,6 +2003,15 @@ static LRESULT OnNotify( HWND hWnd, LPARAM lParam) return 0; } +/* Copied from dlls/comdlg32/fontdlg.c */ +static const COLORREF textcolors[]= +{ + 0x00000000L,0x00000080L,0x00008000L,0x00008080L, + 0x00800000L,0x00800080L,0x00808000L,0x00808080L, + 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL, + 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL +}; + static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) { HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); @@ -2098,7 +2109,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) break; case ID_PRINT_QUICK: - print_quick(wszFileName); + print_quick(hMainWnd, wszFileName); target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); break; @@ -2106,7 +2117,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) { int index = reg_formatindex(fileFormat); DWORD tmp = barState[index]; - barState[index] = 0; + barState[index] = 1 << BANDID_STATUSBAR; set_bar_states(); barState[index] = tmp; ShowWindow(hEditorWnd, FALSE); @@ -2152,6 +2163,46 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) break; } + case ID_FORMAT_COLOR: + { + HWND hReBarWnd = GetDlgItem(hWnd, IDC_REBAR); + HWND hFormatBarWnd = GetDlgItem(hReBarWnd, IDC_FORMATBAR); + HMENU hPop; + RECT itemrc; + POINT pt; + int mid; + int itemidx = SendMessage(hFormatBarWnd, TB_COMMANDTOINDEX, ID_FORMAT_COLOR, 0); + + SendMessage(hFormatBarWnd, TB_GETITEMRECT, itemidx, (LPARAM)&itemrc); + pt.x = itemrc.left; + pt.y = itemrc.bottom; + ClientToScreen(hFormatBarWnd, &pt); + hPop = GetSubMenu(hColorPopupMenu, 0); + mid = TrackPopupMenu(hPop, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON | + TPM_RETURNCMD | TPM_NONOTIFY, + pt.x, pt.y, 0, hWnd, 0); + if (mid >= ID_COLOR_FIRST && mid <= ID_COLOR_AUTOMATIC) + { + CHARFORMAT2W fmt; + + ZeroMemory(&fmt, sizeof(fmt)); + fmt.cbSize = sizeof(fmt); + SendMessageW(hwndEditor, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); + + fmt.dwMask = CFM_COLOR; + + if (mid < ID_COLOR_AUTOMATIC) { + fmt.crTextColor = textcolors[mid - ID_COLOR_FIRST]; + fmt.dwEffects &= ~CFE_AUTOCOLOR; + } else { + fmt.dwEffects |= CFE_AUTOCOLOR; + } + + SendMessageW(hwndEditor, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); + } + break; + } + case ID_EDIT_CUT: PostMessageW(hwndEditor, WM_CUT, 0, 0); break; @@ -2618,6 +2669,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar set_bar_states(); set_fileformat(SF_RTF); hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP)); + hColorPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_COLOR_POPUP)); get_default_printer_opts(); target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); diff --git a/reactos/base/applications/wordpad/wordpad.h b/reactos/base/applications/wordpad/wordpad.h index 26aa41a1828..2f774c3aff0 100644 --- a/reactos/base/applications/wordpad/wordpad.h +++ b/reactos/base/applications/wordpad/wordpad.h @@ -80,6 +80,7 @@ #define ID_FORMAT_BOLD 1400 #define ID_FORMAT_ITALIC 1401 #define ID_FORMAT_UNDERLINE 1402 +#define ID_FORMAT_COLOR 1403 #define ID_TOGGLE_TOOLBAR 1500 #define ID_TOGGLE_FORMATBAR 1501 @@ -133,6 +134,25 @@ #define ID_ABOUT 1603 #define ID_VIEWPROPERTIES 1604 +#define ID_COLOR_FIRST 1800 +#define ID_COLOR_BLACK 1800 +#define ID_COLOR_MAROON 1801 +#define ID_COLOR_GREEN 1802 +#define ID_COLOR_OLIVE 1803 +#define ID_COLOR_NAVY 1804 +#define ID_COLOR_PURPLE 1805 +#define ID_COLOR_TEAL 1806 +#define ID_COLOR_GRAY 1807 +#define ID_COLOR_SILVER 1808 +#define ID_COLOR_RED 1809 +#define ID_COLOR_LIME 1810 +#define ID_COLOR_YELLOW 1811 +#define ID_COLOR_BLUE 1812 +#define ID_COLOR_FUCHSIA 1813 +#define ID_COLOR_AQUA 1814 +#define ID_COLOR_WHITE 1815 +#define ID_COLOR_AUTOMATIC 1816 + #define IDC_STATUSBAR 2000 #define IDC_EDITOR 2001 #define IDC_TOOLBAR 2002 @@ -159,6 +179,7 @@ #define IDM_MAINMENU 2200 #define IDM_POPUP 2201 +#define IDM_COLOR_POPUP 2202 #define IDB_TOOLBAR 100 #define IDB_FORMATBAR 101 @@ -168,6 +189,8 @@ #define IDI_WRI 104 #define IDI_TXT 105 +#define IDC_ZOOM 106 + #define STRING_ALL_FILES 1400 #define STRING_TEXT_FILES_TXT 1401 #define STRING_TEXT_FILES_UNICODE_TXT 1402 @@ -195,8 +218,10 @@ #define STRING_PREVIEW_ZOOMIN 1453 #define STRING_PREVIEW_ZOOMOUT 1454 #define STRING_PREVIEW_CLOSE 1455 +#define STRING_PREVIEW_PAGE 1456 +#define STRING_PREVIEW_PAGES 1457 -#define STRING_UNITS_CM 1456 +#define STRING_UNITS_CM 1458 #define STRING_DEFAULT_FILENAME 1700 #define STRING_PROMPT_SAVE_CHANGES 1701 @@ -217,7 +242,7 @@ LPWSTR file_basename(LPWSTR); void dialog_printsetup(HWND); void dialog_print(HWND, LPWSTR); void target_device(HWND, DWORD); -void print_quick(LPWSTR); +void print_quick(HWND, LPWSTR); LRESULT preview_command(HWND, WPARAM); void init_preview(HWND, LPWSTR); void close_preview(HWND); @@ -226,6 +251,8 @@ LRESULT print_preview(HWND); void get_default_printer_opts(void); void registry_set_pagemargins(HKEY); void registry_read_pagemargins(HKEY); +void registry_set_previewpages(HKEY hKey); +void registry_read_previewpages(HKEY hKey); LRESULT CALLBACK ruler_proc(HWND, UINT, WPARAM, LPARAM); void redraw_ruler(HWND); diff --git a/reactos/base/applications/wordpad/zoom.cur b/reactos/base/applications/wordpad/zoom.cur new file mode 100644 index 0000000000000000000000000000000000000000..26d1a8fa157eb6b448660210c49636b0a876020f GIT binary patch literal 766 zcmd^7u?~VT5Pgs)j5xW%=qI?rz<=4z(O+t!AA)gl)Q!RTd{;sW4w|@n z$dRG0fkNY&18V>qK`FFC1}6`AX_Ku)45N98V&0E0c~QY5gdlYiY+shader.c sprite.c surface.c + texture.c util.c version.rc diff --git a/reactos/dll/directx/wine/d3dx9_36/d3dx9_36.spec b/reactos/dll/directx/wine/d3dx9_36/d3dx9_36.spec index 08bb7f5db60..792408194d2 100644 --- a/reactos/dll/directx/wine/d3dx9_36/d3dx9_36.spec +++ b/reactos/dll/directx/wine/d3dx9_36/d3dx9_36.spec @@ -11,7 +11,7 @@ @ stub D3DXCleanMesh @ stdcall D3DXColorAdjustContrast(ptr ptr long) @ stdcall D3DXColorAdjustSaturation(ptr ptr long) -@ stub D3DXCompileShader +@ stdcall D3DXCompileShader(ptr long ptr ptr ptr ptr long ptr ptr ptr) @ stub D3DXCompileShaderFromFileA @ stub D3DXCompileShaderFromFileW @ stub D3DXCompileShaderFromResourceA @@ -92,7 +92,7 @@ @ stub D3DXCreateTeapot @ stub D3DXCreateTextA @ stub D3DXCreateTextW -@ stub D3DXCreateTexture +@ stdcall D3DXCreateTexture(ptr long long long long long long ptr) @ stub D3DXCreateTextureFromFileA @ stub D3DXCreateTextureFromFileExA @ stub D3DXCreateTextureFromFileExW @@ -129,7 +129,7 @@ @ stub D3DXFillVolumeTexture @ stub D3DXFillVolumeTextureTX @ stub D3DXFilterTexture -@ stub D3DXFindShaderComment +@ stdcall D3DXFindShaderComment(ptr long ptr ptr) @ stub D3DXFloat16To32Array @ stub D3DXFloat32To16Array @ stub D3DXFrameAppendChild @@ -157,8 +157,8 @@ @ stdcall D3DXGetImageInfoFromResourceA(long str ptr) @ stdcall D3DXGetImageInfoFromResourceW(long wstr ptr) @ stdcall D3DXGetPixelShaderProfile(ptr) -@ stub D3DXGetShaderConstantTable -@ stub D3DXGetShaderConstantTableEx +@ stdcall D3DXGetShaderConstantTable(ptr ptr) +@ stdcall D3DXGetShaderConstantTableEx(ptr long ptr) @ stub D3DXGetShaderInputSemantics @ stub D3DXGetShaderOutputSemantics @ stub D3DXGetShaderSamplers diff --git a/reactos/dll/directx/wine/d3dx9_36/shader.c b/reactos/dll/directx/wine/d3dx9_36/shader.c index c05f7b74d90..e4de6b32dca 100644 --- a/reactos/dll/directx/wine/d3dx9_36/shader.c +++ b/reactos/dll/directx/wine/d3dx9_36/shader.c @@ -23,6 +23,7 @@ #include "windef.h" #include "wingdi.h" #include "d3dx9.h" +#include "d3dx9shader.h" #include "d3dx9_36_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3dx); @@ -134,6 +135,41 @@ LPCSTR WINAPI D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device) return NULL; } +HRESULT WINAPI D3DXFindShaderComment(CONST DWORD* byte_code, DWORD fourcc, LPCVOID* data, UINT* size) +{ + CONST DWORD *ptr = byte_code; + + TRACE("(%p, %x, %p, %p)", byte_code, fourcc, data, size); + + if (!byte_code) + return D3DERR_INVALIDCALL; + + while (*++ptr != D3DSIO_END) + { + /* Check if it is a comment */ + if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT) + { + DWORD comment_size = (*ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; + + /* Check if this is the comment we are looking for */ + if (*(ptr + 1) == fourcc) + { + UINT ctab_size = (comment_size - 1) * sizeof(DWORD); + LPCVOID ctab_data = ptr + 2; + if (size) + *size = ctab_size; + if (data) + *data = ctab_data; + TRACE("Returning comment data at %p with size %d\n", ctab_data, ctab_size); + return D3D_OK; + } + ptr += comment_size; + } + } + + return S_FALSE; +} + HRESULT WINAPI D3DXAssembleShader(LPCSTR data, UINT data_len, CONST D3DXMACRO* defines, @@ -142,7 +178,7 @@ HRESULT WINAPI D3DXAssembleShader(LPCSTR data, LPD3DXBUFFER* shader, LPD3DXBUFFER* error_messages) { - FIXME("stub\n"); + FIXME("(%p, %d, %p, %p, %x, %p, %p): stub\n", data, data_len, defines, include, flags, shader, error_messages); return D3DERR_INVALIDCALL; } @@ -177,7 +213,7 @@ HRESULT WINAPI D3DXAssembleShaderFromFileW(LPCWSTR filename, LPD3DXBUFFER* shader, LPD3DXBUFFER* error_messages) { - FIXME("stub\n"); + FIXME("(%s, %p, %p, %x, %p, %p): stub\n", debugstr_w(filename), defines, include, flags, shader, error_messages); return D3DERR_INVALIDCALL; } @@ -220,3 +256,382 @@ HRESULT WINAPI D3DXAssembleShaderFromResourceW(HMODULE module, return D3DXAssembleShader(buffer, len, defines, include, flags, shader, error_messages); } + +HRESULT WINAPI D3DXCompileShader(LPCSTR pSrcData, + UINT srcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE * ppConstantTable) +{ + FIXME("(%p, %d, %p, %p, %p, %p, %d, %p, %p, %p): stub\n", + pSrcData, srcDataLen, pDefines, pInclude, pFunctionName, + pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); + return D3DERR_INVALIDCALL; +} + +static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl; + +typedef struct ID3DXConstantTableImpl { + const ID3DXConstantTableVtbl *lpVtbl; + LONG ref; + LPVOID ctab; + DWORD size; +} ID3DXConstantTableImpl; + +/*** IUnknown methods ***/ +static HRESULT WINAPI ID3DXConstantTableImpl_QueryInterface(ID3DXConstantTable* iface, REFIID riid, void** ppvObject) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_ID3DXConstantTable)) + { + ID3DXConstantTable_AddRef(iface); + *ppvObject = This; + return S_OK; + } + + ERR("Interface %s not found\n", debugstr_guid(riid)); + + return E_NOINTERFACE; +} + +static ULONG WINAPI ID3DXConstantTableImpl_AddRef(ID3DXConstantTable* iface) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + TRACE("(%p)->(): AddRef from %d\n", This, This->ref); + + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI ID3DXConstantTableImpl_Release(ID3DXConstantTable* iface) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(): Release from %d\n", This, ref + 1); + + if (!ref) + { + HeapFree(GetProcessHeap(), 0, This->ctab); + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +/*** ID3DXBuffer methods ***/ +static LPVOID WINAPI ID3DXConstantTableImpl_GetBufferPointer(ID3DXConstantTable* iface) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + TRACE("(%p)->()\n", This); + + return This->ctab; +} + +static DWORD WINAPI ID3DXConstantTableImpl_GetBufferSize(ID3DXConstantTable* iface) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + TRACE("(%p)->()\n", This); + + return This->size; +} + +/*** ID3DXConstantTable methods ***/ +static HRESULT WINAPI ID3DXConstantTableImpl_GetDesc(ID3DXConstantTable* iface, D3DXCONSTANTTABLE_DESC *desc) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p): stub\n", This, desc); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_GetConstantDesc(ID3DXConstantTable* iface, D3DXHANDLE constant, + D3DXCONSTANT_DESC *desc, UINT *count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p): stub\n", This, constant, desc, count); + + return E_NOTIMPL; +} + +static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstant(ID3DXConstantTable* iface, D3DXHANDLE constant, UINT index) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %d): stub\n", This, constant, index); + + return NULL; +} + +static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantByName(ID3DXConstantTable* iface, D3DXHANDLE constant, LPCSTR name) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %s): stub\n", This, constant, name); + + return NULL; +} + +static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantByElement(ID3DXConstantTable* iface, D3DXHANDLE constant, UINT index) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %d): stub\n", This, constant, index); + + return NULL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetDefaults(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p): stub\n", This, device); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetValue(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, LPCVOID data, UINT bytes) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, data, bytes); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetBool(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, BOOL b) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %d): stub\n", This, device, constant, b); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetBoolArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST BOOL* b, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, b, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetInt(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, D3DXHANDLE constant, INT n) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %d): stub\n", This, device, constant, n); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetIntArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST INT* n, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, n, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetFloat(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, FLOAT f) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %f): stub\n", This, device, constant, f); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetFloatArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST FLOAT* f, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, f, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetVector(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXVECTOR4* vector) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p): stub\n", This, device, constant, vector); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetVectorArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXVECTOR4* vector, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, vector, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrix(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX* matrix) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p): stub\n", This, device, constant, matrix); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX* matrix, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, matrix, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixPointerArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX** matrix, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, matrix, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTranspose(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX* matrix) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p): stub\n", This, device, constant, matrix); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTransposeArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX* matrix, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, matrix, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTransposePointerArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX** matrix, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, matrix, count); + + return E_NOTIMPL; +} + +static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl = +{ + /*** IUnknown methods ***/ + ID3DXConstantTableImpl_QueryInterface, + ID3DXConstantTableImpl_AddRef, + ID3DXConstantTableImpl_Release, + /*** ID3DXBuffer methods ***/ + ID3DXConstantTableImpl_GetBufferPointer, + ID3DXConstantTableImpl_GetBufferSize, + /*** ID3DXConstantTable methods ***/ + ID3DXConstantTableImpl_GetDesc, + ID3DXConstantTableImpl_GetConstantDesc, + ID3DXConstantTableImpl_GetConstant, + ID3DXConstantTableImpl_GetConstantByName, + ID3DXConstantTableImpl_GetConstantByElement, + ID3DXConstantTableImpl_SetDefaults, + ID3DXConstantTableImpl_SetValue, + ID3DXConstantTableImpl_SetBool, + ID3DXConstantTableImpl_SetBoolArray, + ID3DXConstantTableImpl_SetInt, + ID3DXConstantTableImpl_SetIntArray, + ID3DXConstantTableImpl_SetFloat, + ID3DXConstantTableImpl_SetFloatArray, + ID3DXConstantTableImpl_SetVector, + ID3DXConstantTableImpl_SetVectorArray, + ID3DXConstantTableImpl_SetMatrix, + ID3DXConstantTableImpl_SetMatrixArray, + ID3DXConstantTableImpl_SetMatrixPointerArray, + ID3DXConstantTableImpl_SetMatrixTranspose, + ID3DXConstantTableImpl_SetMatrixTransposeArray, + ID3DXConstantTableImpl_SetMatrixTransposePointerArray +}; + +HRESULT WINAPI D3DXGetShaderConstantTableEx(CONST DWORD* pFunction, + DWORD flags, + LPD3DXCONSTANTTABLE* ppConstantTable) +{ + ID3DXConstantTableImpl* object; + HRESULT hr; + LPCVOID data; + UINT size; + + FIXME("(%p, %x, %p): semi-stub\n", pFunction, flags, ppConstantTable); + + if (!pFunction || !ppConstantTable) + return D3DERR_INVALIDCALL; + + hr = D3DXFindShaderComment(pFunction, MAKEFOURCC('C','T','A','B'), &data, &size); + if (hr != D3D_OK) + return D3DXERR_INVALIDDATA; + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXConstantTableImpl)); + if (!object) + { + ERR("Out of memory\n"); + return E_OUTOFMEMORY; + } + + object->lpVtbl = &ID3DXConstantTable_Vtbl; + object->ref = 1; + + object->ctab = HeapAlloc(GetProcessHeap(), 0, size); + if (!object->ctab) + { + HeapFree(GetProcessHeap(), 0, object); + ERR("Out of memory\n"); + return E_OUTOFMEMORY; + } + object->size = size; + memcpy(object->ctab, data, object->size); + + *ppConstantTable = (LPD3DXCONSTANTTABLE)object; + + return D3D_OK; +} + +HRESULT WINAPI D3DXGetShaderConstantTable(CONST DWORD* pFunction, + LPD3DXCONSTANTTABLE* ppConstantTable) +{ + TRACE("(%p, %p): Forwarded to D3DXGetShaderConstantTableEx\n", pFunction, ppConstantTable); + + return D3DXGetShaderConstantTableEx(pFunction, 0, ppConstantTable); +} diff --git a/reactos/dll/directx/wine/d3dx9_36/surface.c b/reactos/dll/directx/wine/d3dx9_36/surface.c index 4d8d1f61346..6de6de77ab2 100644 --- a/reactos/dll/directx/wine/d3dx9_36/surface.c +++ b/reactos/dll/directx/wine/d3dx9_36/surface.c @@ -47,7 +47,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); */ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(LPCVOID data, UINT datasize, D3DXIMAGE_INFO *info) { - FIXME("stub\n"); + FIXME("(%p, %d, %p): stub\n", data, datasize, info); if(data && datasize && !info) return D3D_OK; if( !data || !datasize ) return D3DERR_INVALIDCALL; @@ -193,7 +193,9 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(LPDIRECT3DSURFACE9 pDestSurface, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo) { - FIXME("stub\n"); + FIXME("(%p, %p, %p, %p, %d, %p, %d, %x, %p): stub\n", pDestSurface, pDestPalette, + pDestRect, pSrcData, SrcDataSize, pSrcRect, dwFilter, Colorkey, pSrcInfo); + if( !pDestSurface || !pSrcData | !SrcDataSize ) return D3DERR_INVALIDCALL; return E_NOTIMPL; } diff --git a/reactos/dll/directx/wine/d3dx9_36/texture.c b/reactos/dll/directx/wine/d3dx9_36/texture.c new file mode 100644 index 00000000000..f47853a89df --- /dev/null +++ b/reactos/dll/directx/wine/d3dx9_36/texture.c @@ -0,0 +1,37 @@ +/* + * Copyright 2010 Christian Costa + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "wine/debug.h" +#include "d3dx9_36_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + +HRESULT WINAPI D3DXCreateTexture(LPDIRECT3DDEVICE9 pDevice, + UINT width, + UINT height, + UINT miplevels, + DWORD usage, + D3DFORMAT format, + D3DPOOL pool, + LPDIRECT3DTEXTURE9 *ppTexture) +{ + FIXME("(%p, %d, %d, %d, %x, %x, %x, %p): semi-stub\n", pDevice, width, height, miplevels, usage, format, + pool, ppTexture); + + return IDirect3DDevice9_CreateTexture(pDevice, width, height, miplevels, usage, format, pool, ppTexture, NULL); +} diff --git a/reactos/include/dxsdk/d3dx9shader.h b/reactos/include/dxsdk/d3dx9shader.h index a15cab600d6..766d4ca1089 100644 --- a/reactos/include/dxsdk/d3dx9shader.h +++ b/reactos/include/dxsdk/d3dx9shader.h @@ -44,6 +44,15 @@ typedef LPCSTR D3DXHANDLE; +typedef enum _D3DXREGISTER_SET +{ + D3DXRS_BOOL, + D3DXRS_INT4, + D3DXRS_FLOAT4, + D3DXRS_SAMPLER, + D3DXRS_FORCE_DWORD = 0x7fffffff +} D3DXREGISTER_SET, *LPD3DXREGISTER_SET; + typedef enum D3DXPARAMETER_CLASS { D3DXPC_SCALAR, @@ -80,6 +89,131 @@ typedef enum D3DXPARAMETER_TYPE D3DXPT_FORCE_DWORD = 0x7fffffff, } D3DXPARAMETER_TYPE, *LPD3DXPARAMETER_TYPE; +typedef struct _D3DXCONSTANTTABLE_DESC +{ + LPCSTR Creator; + DWORD Version; + UINT Constants; +} D3DXCONSTANTTABLE_DESC, *LPD3DXCONSTANTTABLE_DESC; + +typedef struct _D3DXCONSTANT_DESC +{ + LPCSTR Name; + D3DXREGISTER_SET RegisterSet; + UINT RegisterIndex; + UINT RegisterCount; + D3DXPARAMETER_CLASS Class; + D3DXPARAMETER_TYPE Type; + UINT Rows; + UINT Columns; + UINT Elements; + UINT StructMembers; + UINT Bytes; + LPCVOID DefaultValue; +} D3DXCONSTANT_DESC, *LPD3DXCONSTANT_DESC; + +DEFINE_GUID(IID_ID3DXConstantTable, 0x9dca3190, 0x38b9, 0x4fc3, 0x92, 0xe3, 0x39, 0xc6, 0xdd, 0xfb, 0x35, 0x8b); + +#undef INTERFACE +#define INTERFACE ID3DXConstantTable + +DECLARE_INTERFACE_(ID3DXConstantTable, ID3DXBuffer) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + /*** ID3DXBuffer methods ***/ + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; + /*** ID3DXConstantTable methods ***/ + STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE; + STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE; + STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; + STDMETHOD(SetDefaults)(THIS_ LPDIRECT3DDEVICE9 pDevice) PURE; + STDMETHOD(SetValue)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE; + STDMETHOD(SetBool)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, BOOL b) PURE; + STDMETHOD(SetBoolArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE; + STDMETHOD(SetInt)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, INT n) PURE; + STDMETHOD(SetIntArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE; + STDMETHOD(SetFloat)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, FLOAT f) PURE; + STDMETHOD(SetFloatArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE; + STDMETHOD(SetVector)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetVectorArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(SetMatrix)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixPointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTranspose)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixTransposeArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTransposePointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define ID3DXConstantTable_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define ID3DXConstantTable_AddRef(p) (p)->lpVtbl->AddRef(p) +#define ID3DXConstantTable_Release(p) (p)->lpVtbl->Release(p) +/*** ID3DXBuffer methods ***/ +#define ID3DXConstantTable_GetBufferPointer(p) (p)->lpVtbl->GetBufferPointer(p) +#define ID3DXConstantTable_GetBufferSize(p) (p)->lpVtbl->GetBufferSize(p) +/*** ID3DXConstantTable methods ***/ +#define ID3DXConstantTable_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define ID3DXConstantTable_GetConstantDesc(p,a,b,c) (p)->lpVtbl->GetConstantDesc(p,a,b,c) +#define ID3DXConstantTable_GetConstant(p,a,b) (p)->lpVtbl->GetConstant(p,a,b) +#define ID3DXConstantTable_GetConstantByName(p,a,b) (p)->lpVtbl->GetConstantByName(p,a,b) +#define ID3DXConstantTable_GetConstantElement(p,a,b) (p)->lpVtbl->GetConstantElement(p,a,b) +#define ID3DXConstantTable_SetDefaults(p,a) (p)->lpVtbl->SetDefaults(p,a) +#define ID3DXConstantTable_SetValue(p,a,b,c,d) (p)->lpVtbl->SetValue(p,a,b,c,d) +#define ID3DXConstantTable_SetBool(p,a,b,c) (p)->lpVtbl->SetBool(p,a,b,c) +#define ID3DXConstantTable_SetBoolArray(p,a,b,c,d) (p)->lpVtbl->SetBoolArray(p,a,b,c,d) +#define ID3DXConstantTable_SetInt(p,a,b,c) (p)->lpVtbl->SetInt(p,a,b,c) +#define ID3DXConstantTable_SetIntArray(p,a,b,c,d) (p)->lpVtbl->SetIntArray(p,a,b,c,d) +#define ID3DXConstantTable_SetFloat(p,a,b,c) (p)->lpVtbl->SetFloat(p,a,b,c) +#define ID3DXConstantTable_SetFloatArray(p,a,b,c,d) (p)->lpVtbl->SetFloatArray(p,a,b,c,d) +#define ID3DXConstantTable_SetVector(p,a,b,c) (p)->lpVtbl->SetVector(p,a,b,c) +#define ID3DXConstantTable_SetVectorArray(p,a,b,c,d) (p)->lpVtbl->SetVectorArray(p,a,b,c,d) +#define ID3DXConstantTable_SetMatrix(p,a,b,c) (p)->lpVtbl->SetMatrix(p,a,b,c) +#define ID3DXConstantTable_SetMatrixArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixArray(p,a,b,c,d) +#define ID3DXConstantTable_SetMatrixPointerArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixPointerArray(p,a,b,c,d) +#define ID3DXConstantTable_SetMatrixTranspose(p,a,b,c) (p)->lpVtbl->SetMatrixTranspose(p,a,b,c) +#define ID3DXConstantTable_SetMatrixTransposeArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixTransposeArray(p,a,b,c,d) +#define ID3DXConstantTable_SetMatrixTransposePointerArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixTransposePointerArray(p,a,b,c,d) +#else +/*** IUnknown methods ***/ +#define ID3DXConstantTable_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define ID3DXConstantTable_AddRef(p) (p)->AddRef() +#define ID3DXConstantTable_Release(p) (p)->Release() +/*** ID3DXBuffer methods ***/ +#define ID3DXConstantTable_GetBufferPointer(p) (p)->GetBufferPointer() +#define ID3DXConstantTable_GetBufferSize(p) (p)->GetBufferSize() +/*** ID3DXConstantTable methods ***/ +#define ID3DXConstantTable_GetDesc(p,a) (p)->GetDesc(a) +#define ID3DXConstantTable_GetConstantDesc(p,a,b,c) (p)->GetConstantDesc(a,b,c) +#define ID3DXConstantTable_GetConstant(p,a,b) (p)->GetConstant(a,b) +#define ID3DXConstantTable_GetConstantByName(p,a,b) (p)->GetConstantByName(a,b) +#define ID3DXConstantTable_GetConstantElement(p,a,b) (p)->GetConstantElement(a,b) +#define ID3DXConstantTable_SetDefaults(p,a) (p)->SetDefaults(a) +#define ID3DXConstantTable_SetValue(p,a,b,c,d) (p)->SetValue(a,b,c,d) +#define ID3DXConstantTable_SetBool(p,a,b,c) (p)->SetBool(a,b,c) +#define ID3DXConstantTable_SetBoolArray(p,a,b,c,d) (p)->SetBoolArray(a,b,c,d) +#define ID3DXConstantTable_SetInt(p,a,b,c) (p)->SetInt(a,b,c) +#define ID3DXConstantTable_SetIntArray(p,a,b,c,d) (p)->SetIntArray(a,b,c,d) +#define ID3DXConstantTable_SetFloat(p,a,b,c) (p)->SetFloat(a,b,c) +#define ID3DXConstantTable_SetFloatArray(p,a,b,c,d) (p)->SetFloatArray(a,b,c,d) +#define ID3DXConstantTable_SetVector(p,a,b,c) (p)->SetVector(a,b,c) +#define ID3DXConstantTable_SetVectorArray(p,a,b,c,d) (p)->SetVectorArray(a,b,c,d) +#define ID3DXConstantTable_SetMatrix(p,a,b,c) (p)->SetMatrix(a,b,c) +#define ID3DXConstantTable_SetMatrixArray(p,a,b,c,d) (p)->SetMatrixArray(a,b,c,d) +#define ID3DXConstantTable_SetMatrixPointerArray(p,a,b,c,d) (p)->SetMatrixPointerArray(a,b,c,d) +#define ID3DXConstantTable_SetMatrixTranspose(p,a,b,c) (p)->>SetMatrixTranspose(a,b,c) +#define ID3DXConstantTable_SetMatrixTransposeArray(p,a,b,c,d) (p)->SetMatrixTransposeArray(a,b,c,d) +#define ID3DXConstantTable_SetMatrixTransposePointerArray(p,a,b,c,d) (p)->SetMatrixTransposePointerArray(a,b,c,d) +#endif + +typedef struct ID3DXConstantTable *LPD3DXCONSTANTTABLE; + typedef struct _D3DXMACRO { LPCSTR Name; LPCSTR Definition; @@ -114,6 +248,7 @@ LPCSTR WINAPI D3DXGetPixelShaderProfile(LPDIRECT3DDEVICE9 device); UINT WINAPI D3DXGetShaderSize(const DWORD *byte_code); DWORD WINAPI D3DXGetShaderVersion(const DWORD *byte_code); LPCSTR WINAPI D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device); +HRESULT WINAPI D3DXFindShaderComment(CONST DWORD* byte_code, DWORD fourcc, LPCVOID* data, UINT* size); HRESULT WINAPI D3DXAssembleShaderFromFileA(LPCSTR filename, CONST D3DXMACRO* defines, @@ -153,6 +288,13 @@ HRESULT WINAPI D3DXAssembleShader(LPCSTR data, LPD3DXBUFFER* shader, LPD3DXBUFFER* error_messages); +HRESULT WINAPI D3DXGetShaderConstantTableEx(CONST DWORD* byte_code, + DWORD flags, + LPD3DXCONSTANTTABLE* constant_table); + +HRESULT WINAPI D3DXGetShaderConstantTable(CONST DWORD* byte_code, + LPD3DXCONSTANTTABLE* constant_table); + #ifdef __cplusplus } #endif From 93d7c1ee9fec3169563f275ee1fa5aebcac414b6 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sat, 6 Mar 2010 16:18:09 +0000 Subject: [PATCH 168/211] Add extrac32 from Wine 1.1.40 svn path=/trunk/; revision=45955 --- reactos/base/applications/applications.rbuild | 3 + reactos/base/applications/extrac32/extrac32.c | 179 ++++++++++++++++++ .../applications/extrac32/extrac32.rbuild | 9 + 3 files changed, 191 insertions(+) create mode 100644 reactos/base/applications/extrac32/extrac32.c create mode 100644 reactos/base/applications/extrac32/extrac32.rbuild diff --git a/reactos/base/applications/applications.rbuild b/reactos/base/applications/applications.rbuild index f4adbe4bd5a..d3c202051fb 100644 --- a/reactos/base/applications/applications.rbuild +++ b/reactos/base/applications/applications.rbuild @@ -22,6 +22,9 @@ + + + diff --git a/reactos/base/applications/extrac32/extrac32.c b/reactos/base/applications/extrac32/extrac32.c new file mode 100644 index 00000000000..fc1ae1c94ae --- /dev/null +++ b/reactos/base/applications/extrac32/extrac32.c @@ -0,0 +1,179 @@ +/* + * Extract - Wine-compatible program for extract *.cab files. + * + * Copyright 2007 Etersoft (Lyutin Anatoly) + * Copyright 2009 Ilya Shpigor + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include + +#include "wine/unicode.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(extrac32); + +static BOOL force_mode; + +static UINT WINAPI ExtCabCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2) +{ + FILE_IN_CABINET_INFO_W *pInfo; + FILEPATHS_W *pFilePaths; + + switch(Notification) + { + case SPFILENOTIFY_FILEINCABINET: + pInfo = (FILE_IN_CABINET_INFO_W*)Param1; + lstrcpyW(pInfo->FullTargetName, (LPCWSTR)Context); + lstrcatW(pInfo->FullTargetName, pInfo->NameInCabinet); + return FILEOP_DOIT; + case SPFILENOTIFY_FILEEXTRACTED: + pFilePaths = (FILEPATHS_W*)Param1; + WINE_TRACE("Extracted %s\n", wine_dbgstr_w(pFilePaths->Target)); + return NO_ERROR; + } + return NO_ERROR; +} + +static void extract(LPCWSTR cabfile, LPWSTR destdir) +{ + if (!SetupIterateCabinetW(cabfile, 0, ExtCabCallback, destdir)) + WINE_ERR("Could not extract cab file %s\n", wine_dbgstr_w(cabfile)); +} + +static void copy_file(LPCWSTR source, LPCWSTR destination) +{ + WCHAR destfile[MAX_PATH]; + + /* append source filename if destination is a directory */ + if (PathIsDirectoryW(destination)) + { + PathCombineW(destfile, destination, PathFindFileNameW(source)); + destination = destfile; + } + + if (PathFileExistsW(destination) && !force_mode) + { + static const WCHAR overwriteMsg[] = {'O','v','e','r','w','r','i','t','e',' ','"','%','s','"','?',0}; + static const WCHAR titleMsg[] = {'E','x','t','r','a','c','t',0}; + WCHAR msg[MAX_PATH+100]; + snprintfW(msg, sizeof(msg)/sizeof(msg[0]), overwriteMsg, destination); + if (MessageBoxW(NULL, msg, titleMsg, MB_YESNO | MB_ICONWARNING) != IDYES) + return; + } + + WINE_TRACE("copying %s to %s\n", wine_dbgstr_w(source), wine_dbgstr_w(destination)); + CopyFileW(source, destination, FALSE); +} + +int PASCAL wWinMain(HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int show) +{ + LPWSTR *argv; + int argc; + int i; + WCHAR check, cmd = 0; + WCHAR path[MAX_PATH]; + WCHAR backslash[] = {'\\',0}; + LPCWSTR cabfile = NULL; + + path[0] = 0; + argv = CommandLineToArgvW(cmdline, &argc); + + if(!argv) + { + WINE_ERR("Bad command line arguments\n"); + return 0; + } + + /* Parse arguments */ + for(i = 0; i < argc; i++) + { + /* Get cabfile */ + if (argv[i][0] != '/') + { + if (!cabfile) + { + cabfile = argv[i]; + continue; + } else + break; + } + /* Get parameters for commands */ + check = toupperW( argv[i][1] ); + switch(check) + { + case 'A': + WINE_FIXME("/A not implemented\n"); + break; + case 'Y': + force_mode = TRUE; + break; + case 'L': + if ((i + 1) >= argc) return 0; + if (!GetFullPathNameW(argv[++i], MAX_PATH, path, NULL)) + return 0; + break; + case 'C': + if (cmd) return 0; + cmd = check; + break; + case 'E': + case 'D': + if (cmd) return 0; + cmd = check; + break; + default: + return 0; + } + } + + if (!cabfile) + return 0; + + if (cmd == 'C') + { + if ((i + 1) != argc) return 0; + if (!GetFullPathNameW(argv[i], MAX_PATH, path, NULL)) + return 0; + } + + if (!path[0]) + GetCurrentDirectoryW(MAX_PATH, path); + + lstrcatW(path, backslash); + + /* Execute the specified command */ + switch(cmd) + { + case 'C': + /* Copy file */ + copy_file(cabfile, path); + break; + case 'E': + /* Extract CAB archive */ + extract(cabfile, path); + break; + case 0: + case 'D': + /* Display CAB archive */ + WINE_FIXME("/D not implemented\n"); + break; + } + return 0; +} diff --git a/reactos/base/applications/extrac32/extrac32.rbuild b/reactos/base/applications/extrac32/extrac32.rbuild new file mode 100644 index 00000000000..24532ddfd3d --- /dev/null +++ b/reactos/base/applications/extrac32/extrac32.rbuild @@ -0,0 +1,9 @@ + + . + wine + shell32 + setupapi + shlwapi + user32 + extrac32.c + From 9f0441645299eeb1c255843c939c439984a19032 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 16:19:07 +0000 Subject: [PATCH 169/211] sync RtlCreateActivationContext with wine 1.1.40 svn path=/trunk/; revision=45956 --- reactos/lib/rtl/actctx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/lib/rtl/actctx.c b/reactos/lib/rtl/actctx.c index f7d727099fb..7960f587490 100644 --- a/reactos/lib/rtl/actctx.c +++ b/reactos/lib/rtl/actctx.c @@ -2272,10 +2272,12 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, void *ptr ) { UNICODE_STRING dir; WCHAR *p; + HMODULE module; - if ((status = get_module_filename( NtCurrentTeb()->ProcessEnvironmentBlock->ImageBaseAddress, &dir, 0 ))) - goto error; + if (pActCtx->dwFlags & ACTCTX_FLAG_HMODULE_VALID) module = pActCtx->hModule; + else module = NtCurrentTeb()->ProcessEnvironmentBlock->ImageBaseAddress; + if ((status = get_module_filename( module, &dir, 0 ))) goto error; if ((p = strrchrW( dir.Buffer, '\\' ))) p[1] = 0; actctx->appdir.info = dir.Buffer; } @@ -2339,7 +2341,6 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, void *ptr ) if (status == STATUS_SUCCESS) *handle = actctx; else actctx_release( actctx ); - return status; error: From 055cd4a61f12b5dba85a836d7f25ad5f820f01e6 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 16:24:37 +0000 Subject: [PATCH 170/211] [GDIPLUS_WINETEST] sync gdiplus_winetest to wine 1.1.40 svn path=/trunk/; revision=45957 --- rostests/winetests/gdiplus/graphics.c | 153 +++++++++++++++++++++ rostests/winetests/gdiplus/image.c | 187 ++++++++++++++++++++++++++ 2 files changed, 340 insertions(+) diff --git a/rostests/winetests/gdiplus/graphics.c b/rostests/winetests/gdiplus/graphics.c index 45bd9f7871b..b2dc9b299fb 100644 --- a/rostests/winetests/gdiplus/graphics.c +++ b/rostests/winetests/gdiplus/graphics.c @@ -2270,6 +2270,158 @@ static void test_GdipIsVisibleRect(void) ReleaseDC(0, hdc); } +static void test_GdipGetNearestColor(void) +{ + GpStatus status; + GpGraphics *graphics; + GpBitmap *bitmap; + ARGB color = 0xdeadbeef; + HDC hdc = GetDC(0); + + /* create a graphics object */ + ok(hdc != NULL, "Expected HDC to be initialized\n"); + + status = GdipCreateFromHDC(hdc, &graphics); + expect(Ok, status); + ok(graphics != NULL, "Expected graphics to be initialized\n"); + + status = GdipGetNearestColor(graphics, NULL); + expect(InvalidParameter, status); + + status = GdipGetNearestColor(NULL, &color); + expect(InvalidParameter, status); + GdipDeleteGraphics(graphics); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status); + if (status == Ok) + { + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + } + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status); + if (status == Ok) + { + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + } + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status); + if (status == Ok) + { + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + } + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + todo_wine expect(OutOfMemory, status); + if (status == Ok) + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + expect(0xdeadbeef, color); + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + todo_wine expect(0xffa8bce8, color); + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + status = GdipGetNearestColor(graphics, &color); + expect(Ok, status); + todo_wine expect(0xffa8b8e8, color); + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); + + ReleaseDC(0, hdc); +} + START_TEST(graphics) { struct GdiplusStartupInput gdiplusStartupInput; @@ -2296,6 +2448,7 @@ START_TEST(graphics) test_GdipDrawLineI(); test_GdipDrawLinesI(); test_GdipDrawString(); + test_GdipGetNearestColor(); test_GdipGetVisibleClipBounds(); test_GdipIsVisiblePoint(); test_GdipIsVisibleRect(); diff --git a/rostests/winetests/gdiplus/image.c b/rostests/winetests/gdiplus/image.c index e7747e35a45..9085ef2cf2d 100644 --- a/rostests/winetests/gdiplus/image.c +++ b/rostests/winetests/gdiplus/image.c @@ -1625,6 +1625,191 @@ static void test_multiframegif(void) IStream_Release(stream); } +static void test_rotateflip(void) +{ + GpImage *bitmap; + GpStatus stat; + BYTE bits[24]; + static const BYTE orig_bits[24] = { + 0,0,0xff, 0,0xff,0, 0xff,0,0, 23,23,23, + 0xff,0xff,0, 0xff,0,0xff, 0,0xff,0xff, 23,23,23}; + UINT width, height; + ARGB color; + + memcpy(bits, orig_bits, sizeof(bits)); + stat = GdipCreateBitmapFromScan0(3, 2, 12, PixelFormat24bppRGB, bits, (GpBitmap**)&bitmap); + expect(Ok, stat); + + stat = GdipImageRotateFlip(bitmap, Rotate90FlipNone); + todo_wine expect(Ok, stat); + + stat = GdipGetImageWidth(bitmap, &width); + expect(Ok, stat); + stat = GdipGetImageHeight(bitmap, &height); + expect(Ok, stat); + todo_wine expect(2, width); + todo_wine expect(3, height); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 0, &color); + expect(Ok, stat); + todo_wine expect(0xff00ffff, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 1, 0, &color); + expect(Ok, stat); + todo_wine expect(0xffff0000, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 2, &color); + todo_wine expect(Ok, stat); + todo_wine expect(0xffffff00, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 1, 2, &color); + todo_wine expect(Ok, stat); + todo_wine expect(0xff0000ff, color); + + expect(0, bits[0]); + expect(0, bits[1]); + expect(0xff, bits[2]); + + GdipDisposeImage(bitmap); + + memcpy(bits, orig_bits, sizeof(bits)); + stat = GdipCreateBitmapFromScan0(3, 2, 12, PixelFormat24bppRGB, bits, (GpBitmap**)&bitmap); + expect(Ok, stat); + + stat = GdipImageRotateFlip(bitmap, RotateNoneFlipX); + todo_wine expect(Ok, stat); + + stat = GdipGetImageWidth(bitmap, &width); + expect(Ok, stat); + stat = GdipGetImageHeight(bitmap, &height); + expect(Ok, stat); + expect(3, width); + expect(2, height); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 0, &color); + expect(Ok, stat); + todo_wine expect(0xff0000ff, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 2, 0, &color); + expect(Ok, stat); + todo_wine expect(0xffff0000, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 1, &color); + expect(Ok, stat); + todo_wine expect(0xffffff00, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 2, 1, &color); + expect(Ok, stat); + todo_wine expect(0xff00ffff, color); + + expect(0, bits[0]); + expect(0, bits[1]); + expect(0xff, bits[2]); + + GdipDisposeImage(bitmap); + + memcpy(bits, orig_bits, sizeof(bits)); + stat = GdipCreateBitmapFromScan0(3, 2, 12, PixelFormat24bppRGB, bits, (GpBitmap**)&bitmap); + expect(Ok, stat); + + stat = GdipImageRotateFlip(bitmap, RotateNoneFlipY); + todo_wine expect(Ok, stat); + + stat = GdipGetImageWidth(bitmap, &width); + expect(Ok, stat); + stat = GdipGetImageHeight(bitmap, &height); + expect(Ok, stat); + expect(3, width); + expect(2, height); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 0, &color); + expect(Ok, stat); + todo_wine expect(0xff00ffff, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 2, 0, &color); + expect(Ok, stat); + todo_wine expect(0xffffff00, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 1, &color); + expect(Ok, stat); + todo_wine expect(0xffff0000, color); + + stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 2, 1, &color); + expect(Ok, stat); + todo_wine expect(0xff0000ff, color); + + expect(0, bits[0]); + expect(0, bits[1]); + expect(0xff, bits[2]); + + GdipDisposeImage(bitmap); +} + +static void test_remaptable(void) +{ + GpStatus stat; + GpImageAttributes *imageattr; + GpBitmap *bitmap1, *bitmap2; + GpGraphics *graphics; + ARGB color; + ColorMap *map; + + map = GdipAlloc(sizeof(ColorMap)); + + map->oldColor.Argb = 0xff00ff00; + map->newColor.Argb = 0xffff00ff; + + stat = GdipSetImageAttributesRemapTable(NULL, ColorAdjustTypeDefault, TRUE, 1, map); + expect(InvalidParameter, stat); + + stat = GdipCreateImageAttributes(&imageattr); + expect(Ok, stat); + + stat = GdipSetImageAttributesRemapTable(imageattr, ColorAdjustTypeDefault, TRUE, 1, NULL); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesRemapTable(imageattr, ColorAdjustTypeCount, TRUE, 1, map); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesRemapTable(imageattr, ColorAdjustTypeAny, TRUE, 1, map); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesRemapTable(imageattr, ColorAdjustTypeDefault, TRUE, 0, map); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesRemapTable(imageattr, ColorAdjustTypeDefault, FALSE, 0, NULL); + expect(Ok, stat); + + stat = GdipSetImageAttributesRemapTable(imageattr, ColorAdjustTypeDefault, TRUE, 1, map); + expect(Ok, stat); + + stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1); + expect(Ok, stat); + + stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap2); + expect(Ok, stat); + + stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff00ff00); + expect(Ok, stat); + + stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics); + expect(Ok, stat); + + stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1, + UnitPixel, imageattr, NULL, NULL); + expect(Ok, stat); + + stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color); + expect(Ok, stat); + todo_wine ok(color_match(0xffff00ff, color, 1), "Expected ffff00ff, got %.8x\n", color); + + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap1); + GdipDisposeImage((GpImage*)bitmap2); + GdipDisposeImageAttributes(imageattr); + GdipFree(map); +} + START_TEST(image) { struct GdiplusStartupInput gdiplusStartupInput; @@ -1659,6 +1844,8 @@ START_TEST(image) test_colormatrix(); test_gamma(); test_multiframegif(); + test_rotateflip(); + test_remaptable(); GdiplusShutdown(gdiplusToken); } From daa14c5f08775ba2322e038f0aefb75adb07fb01 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 6 Mar 2010 16:27:51 +0000 Subject: [PATCH 171/211] add dsound_winetest to bootcd svn path=/trunk/; revision=45958 --- reactos/boot/bootdata/packages/reactos.dff | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/boot/bootdata/packages/reactos.dff b/reactos/boot/bootdata/packages/reactos.dff index 0b988cc18ff..a0db0df1377 100644 --- a/reactos/boot/bootdata/packages/reactos.dff +++ b/reactos/boot/bootdata/packages/reactos.dff @@ -755,6 +755,7 @@ modules\rostests\winetests\comctl32\comctl32_winetest.exe 7 o modules\rostests\winetests\comdlg32\comdlg32_winetest.exe 7 optional modules\rostests\winetests\crypt32\crypt32_winetest.exe 7 optional modules\rostests\winetests\cryptnet\cryptnet_winetest.exe 7 optional +modules\rostests\winetests\dsound\dsound_winetest.exe 7 optional modules\rostests\winetests\gdi32\gdi32_winetest.exe 7 optional modules\rostests\winetests\gdiplus\gdiplus_winetest.exe 7 optional modules\rostests\winetests\hlink\hlink_winetest.exe 7 optional From 53a7ff99b918898f8d70a517d8b6e722651b917f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 6 Mar 2010 18:15:56 +0000 Subject: [PATCH 172/211] - Call acpi_bus_set_power instead of acpi_power_transition - Make sure the device has power management capabilities before calling acpi_bus_set_power - Report the new power state with PoSetPowerState - Initialize PDOs with the correct device power state (Patch by Samuel Serapion) - Initialze PDOs with the correct system power state svn path=/trunk/; revision=45959 --- reactos/drivers/bus/acpi/buspdo.c | 17 ++++++--------- reactos/drivers/bus/acpi/pnp.c | 35 +++++++++++++++++++++++++------ reactos/drivers/bus/acpi/power.c | 29 +++++++++++++------------ 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/reactos/drivers/bus/acpi/buspdo.c b/reactos/drivers/bus/acpi/buspdo.c index 87656388976..92bc18b4544 100644 --- a/reactos/drivers/bus/acpi/buspdo.c +++ b/reactos/drivers/bus/acpi/buspdo.c @@ -32,15 +32,10 @@ Bus_PDO_PnP ( ) { NTSTATUS status; - struct acpi_device *device = NULL; POWER_STATE state; PAGED_CODE (); - if (DeviceData->AcpiHandle) - acpi_bus_get_device(DeviceData->AcpiHandle, &device); - - // // NB: Because we are a bus enumerator, we have no one to whom we could // defer these irps. Therefore we do not pass them down but merely @@ -56,9 +51,10 @@ Bus_PDO_PnP ( // required to allow others to access this device. // Power up the device. // - if (device && !ACPI_SUCCESS(acpi_power_transition(device, ACPI_STATE_D0))) + if (DeviceData->AcpiHandle && acpi_bus_power_manageable(DeviceData->AcpiHandle) && + !ACPI_SUCCESS(acpi_bus_set_power(DeviceData->AcpiHandle, ACPI_STATE_D0))) { - DPRINT1("Device %x failed to start!\n", device); + DPRINT1("Device %x failed to start!\n", DeviceData->AcpiHandle); status = STATUS_UNSUCCESSFUL; break; } @@ -76,9 +72,10 @@ Bus_PDO_PnP ( // Here we shut down the device and give up and unmap any resources // we acquired for the device. // - if (device && !ACPI_SUCCESS(acpi_power_transition(device, ACPI_STATE_D3))) + if (DeviceData->AcpiHandle && acpi_bus_power_manageable(DeviceData->AcpiHandle) && + !ACPI_SUCCESS(acpi_bus_set_power(DeviceData->AcpiHandle, ACPI_STATE_D3))) { - DPRINT1("Device %x failed to stop!\n", device); + DPRINT1("Device %x failed to stop!\n", DeviceData->AcpiHandle); status = STATUS_UNSUCCESSFUL; break; } @@ -125,8 +122,6 @@ Bus_PDO_PnP ( // We did receive a query-stop, so restore. // RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); - if (device) - acpi_power_transition(device, ACPI_STATE_D0); } status = STATUS_SUCCESS;// We must not fail this IRP. break; diff --git a/reactos/drivers/bus/acpi/pnp.c b/reactos/drivers/bus/acpi/pnp.c index 5b2338dc58c..4778dc66c2e 100644 --- a/reactos/drivers/bus/acpi/pnp.c +++ b/reactos/drivers/bus/acpi/pnp.c @@ -417,6 +417,8 @@ Bus_InitializePdo ( ) { PPDO_DEVICE_DATA pdoData; + int acpistate; + DEVICE_POWER_STATE ntState; PAGED_CODE (); @@ -424,6 +426,31 @@ Bus_InitializePdo ( DPRINT("pdo 0x%p, extension 0x%p\n", Pdo, pdoData); + if (pdoData->AcpiHandle) + acpi_bus_get_power(pdoData->AcpiHandle, &acpistate); + else + acpistate = ACPI_STATE_D0; + + switch(acpistate) + { + case ACPI_STATE_D0: + ntState = PowerDeviceD0; + break; + case ACPI_STATE_D1: + ntState = PowerDeviceD1; + break; + case ACPI_STATE_D2: + ntState = PowerDeviceD2; + break; + case ACPI_STATE_D3: + ntState = PowerDeviceD3; + break; + default: + DPRINT1("Unknown power state (%d) returned by acpi\n",acpistate); + ntState = PowerDeviceUnspecified; + break; + } + // // Initialize the rest // @@ -435,12 +462,8 @@ Bus_InitializePdo ( INITIALIZE_PNP_STATE(pdoData->Common); - // - // PDO's usually start their life at D3 - // - - pdoData->Common.DevicePowerState = PowerDeviceD3; - pdoData->Common.SystemPowerState = PowerSystemWorking; + pdoData->Common.DevicePowerState = ntState; + pdoData->Common.SystemPowerState = FdoData->Common.SystemPowerState; Pdo->Flags |= DO_POWER_PAGABLE; diff --git a/reactos/drivers/bus/acpi/power.c b/reactos/drivers/bus/acpi/power.c index eda6cb62197..ac9c9f0f393 100644 --- a/reactos/drivers/bus/acpi/power.c +++ b/reactos/drivers/bus/acpi/power.c @@ -63,6 +63,7 @@ Bus_FDO_Power ( PIO_STACK_LOCATION stack; ULONG AcpiState; ACPI_STATUS AcpiStatus; + SYSTEM_POWER_STATE oldPowerState; stack = IoGetCurrentIrpStackLocation (Irp); powerType = stack->Parameters.Power.Type; @@ -77,8 +78,8 @@ Bus_FDO_Power ( DbgDevicePowerString(powerState.DeviceState))); } - if (powerType == SystemPowerState) { - status = STATUS_SUCCESS; + if (powerType == SystemPowerState) + { switch (powerState.SystemState) { case PowerSystemSleeping1: AcpiState = ACPI_STATE_S1; @@ -96,13 +97,17 @@ Bus_FDO_Power ( AcpiState = ACPI_STATE_S5; break; default: - return STATUS_UNSUCCESSFUL; - break; + AcpiState = ACPI_STATE_UNKNOWN; + ASSERT(FALSE); + break; } + oldPowerState = Data->Common.SystemPowerState; + Data->Common.SystemPowerState = powerState.SystemState; AcpiStatus = AcpiEnterSleepState(AcpiState); if (!ACPI_SUCCESS(AcpiStatus)) { DPRINT1("Failed to enter sleep state %d (Status 0x%X)\n", AcpiState, AcpiStatus); + Data->Common.SystemPowerState = oldPowerState; status = STATUS_UNSUCCESSFUL; } } @@ -124,15 +129,11 @@ Bus_PDO_Power ( POWER_STATE powerState; POWER_STATE_TYPE powerType; ULONG error; - struct acpi_device *device; stack = IoGetCurrentIrpStackLocation (Irp); powerType = stack->Parameters.Power.Type; powerState = stack->Parameters.Power.State; - if (PdoData->AcpiHandle) - acpi_bus_get_device(PdoData->AcpiHandle, &device); - switch (stack->MinorFunction) { case IRP_MN_SET_POWER: @@ -144,8 +145,9 @@ Bus_PDO_Power ( switch (powerType) { case DevicePowerState: - if (!device) + if (!PdoData->AcpiHandle || !acpi_bus_power_manageable(PdoData->AcpiHandle)) { + PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState); PdoData->Common.DevicePowerState = powerState.DeviceState; status = STATUS_SUCCESS; break; @@ -154,19 +156,19 @@ Bus_PDO_Power ( switch (powerState.DeviceState) { case PowerDeviceD0: - error = acpi_power_transition(device, ACPI_STATE_D0); + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D0); break; case PowerDeviceD1: - error = acpi_power_transition(device, ACPI_STATE_D1); + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D1); break; case PowerDeviceD2: - error = acpi_power_transition(device, ACPI_STATE_D2); + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D2); break; case PowerDeviceD3: - error = acpi_power_transition(device, ACPI_STATE_D3); + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D3); break; default: @@ -176,6 +178,7 @@ Bus_PDO_Power ( if (ACPI_SUCCESS(error)) { + PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState); PdoData->Common.DevicePowerState = powerState.DeviceState; status = STATUS_SUCCESS; } From f6b997c0d2154152251e57edf96bf88d563ae321 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 6 Mar 2010 18:30:55 +0000 Subject: [PATCH 173/211] - Add a stub for GetOwnerModuleFromTcpEntry - Patch by Olaf Siejka svn path=/trunk/; revision=45960 --- reactos/dll/win32/iphlpapi/iphlpapi.spec | 2 +- reactos/dll/win32/iphlpapi/iphlpapi_main.c | 27 ++++++++++++++++++++++ reactos/include/psdk/iphlpapi.h | 1 + reactos/include/psdk/iprtrmib.h | 17 ++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/iphlpapi/iphlpapi.spec b/reactos/dll/win32/iphlpapi/iphlpapi.spec index b07c464fb76..f65673b601f 100644 --- a/reactos/dll/win32/iphlpapi/iphlpapi.spec +++ b/reactos/dll/win32/iphlpapi/iphlpapi.spec @@ -61,7 +61,7 @@ @ stdcall GetNetworkParams( ptr ptr ) @ stdcall GetNumberOfInterfaces( ptr ) @ stub GetOwnerModuleFromTcp6Entry -@ stub GetOwnerModuleFromTcpEntry +@ stdcall GetOwnerModuleFromTcpEntry ( ptr long ptr ptr ) @ stub GetOwnerModuleFromUdp6Entry @ stub GetOwnerModuleFromUdpEntry @ stdcall GetPerAdapterInfo( long ptr ptr ) diff --git a/reactos/dll/win32/iphlpapi/iphlpapi_main.c b/reactos/dll/win32/iphlpapi/iphlpapi_main.c index 47146e6cd14..0bc146b6616 100644 --- a/reactos/dll/win32/iphlpapi/iphlpapi_main.c +++ b/reactos/dll/win32/iphlpapi/iphlpapi_main.c @@ -1505,6 +1505,33 @@ DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf) } +/****************************************************************** + * GetOwnerModuleFromTcpEntry (IPHLPAPI.@) + * + * Get data about the module that issued the context bind for a specific IPv4 TCP endpoint in a MIB table row + * + * PARAMS + * pTcpEntry [in] pointer to a MIB_TCPROW_OWNER_MODULE structure + * Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value + * Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data. + * pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes + * + * RETURNS + * Success: NO_ERROR + * Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY + * ERROR_NOT_FOUND or ERROR_PARTIAL_COPY + * + * NOTES + * The type of data returned in Buffer is indicated by the value of the Class parameter. + */ +DWORD WINAPI GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize) +{ + DWORD ret = NO_ERROR; + UNIMPLEMENTED; + return ret; +} + + /****************************************************************** * GetPerAdapterInfo (IPHLPAPI.@) * diff --git a/reactos/include/psdk/iphlpapi.h b/reactos/include/psdk/iphlpapi.h index 9637194b5d2..56c32fdc087 100644 --- a/reactos/include/psdk/iphlpapi.h +++ b/reactos/include/psdk/iphlpapi.h @@ -35,6 +35,7 @@ DWORD WINAPI GetIpStatistics(PMIB_IPSTATS); DWORD WINAPI GetIpStatisticsEx(PMIB_IPSTATS,DWORD); DWORD WINAPI GetNetworkParams(PFIXED_INFO,PULONG); DWORD WINAPI GetNumberOfInterfaces(PDWORD); +DWORD WINAPI GetOwnerModuleFromTcpEntry(PMIB_TCPROW_OWNER_MODULE,TCPIP_OWNER_MODULE_INFO_CLASS,PVOID,PDWORD); DWORD WINAPI GetPerAdapterInfo(ULONG,PIP_PER_ADAPTER_INFO, PULONG); BOOL WINAPI GetRTTAndHopCount(IPAddr,PULONG,ULONG,PULONG); DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS); diff --git a/reactos/include/psdk/iprtrmib.h b/reactos/include/psdk/iprtrmib.h index 6f182944fce..179a7938fde 100644 --- a/reactos/include/psdk/iprtrmib.h +++ b/reactos/include/psdk/iprtrmib.h @@ -25,6 +25,9 @@ #define MAXLEN_IFDESCR 256 #define MAXLEN_PHYSADDR 8 +//It should be 16 according to Lei Shen blog (http://www.mychinaworks.com/blog/lshen/2008/04/16/220/ +#define TCPIP_OWNING_MODULE_SIZE 16 + typedef struct _MIB_IFROW { WCHAR wszName[MAX_INTERFACE_NAME_LEN]; @@ -286,6 +289,20 @@ typedef struct _MIB_IPNETTABLE MIB_IPNETROW table[1]; } MIB_IPNETTABLE, *PMIB_IPNETTABLE; +typedef struct _MIB_TCPROW_OWNER_MODULE { + DWORD dwState; + DWORD dwLocalAddr; + DWORD dwLocalPort; + DWORD dwRemoteAddr; + DWORD dwRemotePort; + DWORD dwOwningPid; + LARGE_INTEGER liCreateTimestamp; + ULONGLONG OwningModuleInfo[TCPIP_OWNING_MODULE_SIZE]; +} MIB_TCPROW_OWNER_MODULE, *PMIB_TCPROW_OWNER_MODULE; + +typedef enum { + TCPIP_OWNER_MODULE_INFO_BASIC +} TCPIP_OWNER_MODULE_INFO_CLASS, *PTCPIP_OWNER_MODULE_INFO_CLASS; typedef enum { TCP_TABLE_BASIC_LISTENER, From 77013ae0dd16b90b8f653830960ddf31d5d72900 Mon Sep 17 00:00:00 2001 From: Matthias Kupfer Date: Sat, 6 Mar 2010 22:14:46 +0000 Subject: [PATCH 174/211] - fix palette index for the progress bar svn path=/trunk/; revision=45966 --- reactos/ntoskrnl/inbv/inbv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/inbv/inbv.c b/reactos/ntoskrnl/inbv/inbv.c index ca9c9013f71..52cc7108386 100644 --- a/reactos/ntoskrnl/inbv/inbv.c +++ b/reactos/ntoskrnl/inbv/inbv.c @@ -409,7 +409,7 @@ InbvUpdateProgressBar(IN ULONG Progress) ProgressBarTop, ProgressBarLeft + FillCount, ProgressBarTop + 12, - 11); + 15); /* Release the lock */ InbvReleaseLock(); From 8eca3e0dcd30d7569799ef177e303b187ee186dc Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sat, 6 Mar 2010 22:22:28 +0000 Subject: [PATCH 175/211] Make the shutdown with ACPI enabled actually work. Patch by Samuel Serapion. svn path=/trunk/; revision=45967 --- reactos/drivers/bus/acpi/busmgr/system.c | 7 +++---- reactos/drivers/bus/acpi/power.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/reactos/drivers/bus/acpi/busmgr/system.c b/reactos/drivers/bus/acpi/busmgr/system.c index 1ffee4c95c7..d0f0503f366 100644 --- a/reactos/drivers/bus/acpi/busmgr/system.c +++ b/reactos/drivers/bus/acpi/busmgr/system.c @@ -373,15 +373,14 @@ acpi_suspend ( // /* We don't support S4 under 2.4. Give up */ // return AE_ERROR; //} + AcpiEnterSleepStatePrep(state); status = AcpiEnterSleepState(state); if (!ACPI_SUCCESS(status) && state != ACPI_STATE_S5) return status; - AcpiEnterSleepStatePrep(state); - /* disable interrupts and flush caches */ - //ACPI_DISABLE_IRQS(); + _disable(); ACPI_FLUSH_CPU_CACHE(); /* perform OS-specific sleep actions */ @@ -395,7 +394,7 @@ acpi_suspend ( acpi_system_restore_state(state); /* make sure interrupts are enabled */ - //ACPI_ENABLE_IRQS(); + _enable(); /* reset firmware waking vector */ AcpiSetFirmwareWakingVector((ACPI_PHYSICAL_ADDRESS) 0); diff --git a/reactos/drivers/bus/acpi/power.c b/reactos/drivers/bus/acpi/power.c index ac9c9f0f393..3af99c96402 100644 --- a/reactos/drivers/bus/acpi/power.c +++ b/reactos/drivers/bus/acpi/power.c @@ -103,7 +103,7 @@ Bus_FDO_Power ( } oldPowerState = Data->Common.SystemPowerState; Data->Common.SystemPowerState = powerState.SystemState; - AcpiStatus = AcpiEnterSleepState(AcpiState); + AcpiStatus = acpi_suspend(AcpiState); if (!ACPI_SUCCESS(AcpiStatus)) { DPRINT1("Failed to enter sleep state %d (Status 0x%X)\n", AcpiState, AcpiStatus); From 8cc8a06a886b44beebb69b351ed04f4007121bfc Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sat, 6 Mar 2010 23:14:36 +0000 Subject: [PATCH 176/211] Stubplement WTSQueryUserToken. Patch by Olaf Siejka. svn path=/trunk/; revision=45969 --- reactos/dll/win32/wtsapi32/wtsapi32.c | 30 ++++++++++++++++++++++++ reactos/dll/win32/wtsapi32/wtsapi32.spec | 1 + 2 files changed, 31 insertions(+) diff --git a/reactos/dll/win32/wtsapi32/wtsapi32.c b/reactos/dll/win32/wtsapi32/wtsapi32.c index fc40494666f..880f3c9a925 100644 --- a/reactos/dll/win32/wtsapi32/wtsapi32.c +++ b/reactos/dll/win32/wtsapi32/wtsapi32.c @@ -487,6 +487,36 @@ BOOL WINAPI WTSQuerySessionInformationW( return FALSE; } +/************************************************************ + * WTSQueryUserToken (WTSAPI32.@) + * + * Obtains the primary access token of the logged-on user specified by the session ID. + * + * PARAMS + * SessionId [in] -- RDP session identifier + * phToken [out] -- pointer to the token handle for the logged-on user + * + * + * RETURNS + * - On success - pointer to the primary token of the user + * - On failure - zero + * + * + * NOTES + * - token handle should be closed after use with CloseHandle + * - on Failure, extended error information is available via GetLastError + * + */ +BOOL WINAPI WTSQueryUserToken( + ULONG SessionId, + PHANDLE phToken) +{ + *phToken = (HANDLE)0; + SetLastError(ERROR_NO_TOKEN); + FIXME("Stub %d\n", SessionId); + return FALSE; +} + /************************************************************ * WTSWaitSystemEvent (WTSAPI32.@) */ diff --git a/reactos/dll/win32/wtsapi32/wtsapi32.spec b/reactos/dll/win32/wtsapi32/wtsapi32.spec index 059b6daa540..2be9df00c9d 100644 --- a/reactos/dll/win32/wtsapi32/wtsapi32.spec +++ b/reactos/dll/win32/wtsapi32/wtsapi32.spec @@ -14,6 +14,7 @@ @ stdcall WTSQuerySessionInformationW(long long long ptr ptr) @ stub WTSQueryUserConfigA @ stub WTSQueryUserConfigW +@ stdcall WTSQueryUserToken(long ptr) @ stdcall WTSRegisterSessionNotification(long long) @ stub WTSSendMessageA @ stub WTSSendMessageW From 8bae50b03316944417bb34f775617c6264b4ef79 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 07:27:57 +0000 Subject: [PATCH 177/211] [ADVAPI32_WINETEST] sync advapi32_winetest to wine 1.1.40 svn path=/trunk/; revision=45974 --- rostests/winetests/advapi32/crypt.c | 32 ++ rostests/winetests/advapi32/eventlog.c | 37 ++- rostests/winetests/advapi32/registry.c | 429 ++++++++++++++++++++++++- rostests/winetests/advapi32/security.c | 11 +- rostests/winetests/advapi32/service.c | 8 +- 5 files changed, 482 insertions(+), 35 deletions(-) diff --git a/rostests/winetests/advapi32/crypt.c b/rostests/winetests/advapi32/crypt.c index f31723758dd..2a5993c00d5 100644 --- a/rostests/winetests/advapi32/crypt.c +++ b/rostests/winetests/advapi32/crypt.c @@ -64,6 +64,7 @@ static BOOL (WINAPI *pCryptSetHashParam)(HCRYPTKEY, DWORD, BYTE*, DWORD); static BOOL (WINAPI *pCryptSetKeyParam)(HCRYPTKEY, DWORD, BYTE*, DWORD); static BOOL (WINAPI *pCryptSetProvParam)(HCRYPTPROV, DWORD, BYTE*, DWORD); static BOOL (WINAPI *pCryptVerifySignatureW)(HCRYPTHASH, BYTE*, DWORD, HCRYPTKEY, LPCWSTR, DWORD); +static BOOL (WINAPI *pSystemFunction036)(PVOID, ULONG); static void init_function_pointers(void) { @@ -99,6 +100,7 @@ static void init_function_pointers(void) pCryptSetKeyParam = (void*)GetProcAddress(hadvapi32, "CryptSetKeyParam"); pCryptSetProvParam = (void*)GetProcAddress(hadvapi32, "CryptSetProvParam"); pCryptVerifySignatureW = (void*)GetProcAddress(hadvapi32, "CryptVerifySignatureW"); + pSystemFunction036 = (void*)GetProcAddress(hadvapi32, "SystemFunction036"); } static void init_environment(void) @@ -1073,6 +1075,35 @@ static void test_rc2_keylen(void) } } +static void test_SystemFunction036(void) +{ + BOOL ret; + int test; + + if (!pSystemFunction036) + { + win_skip("SystemFunction036 is not available\n"); + return; + } + + ret = pSystemFunction036(NULL, 0); + ok(ret == TRUE, "Expected SystemFunction036 to return TRUE, got %d\n", ret); + + /* Test crashes on Windows. */ + if (0) + { + SetLastError(0xdeadbeef); + ret = pSystemFunction036(NULL, 5); + trace("ret = %d, GetLastError() = %d\n", ret, GetLastError()); + } + + ret = pSystemFunction036(&test, 0); + ok(ret == TRUE, "Expected SystemFunction036 to return TRUE, got %d\n", ret); + + ret = pSystemFunction036(&test, sizeof(int)); + ok(ret == TRUE, "Expected SystemFunction036 to return TRUE, got %d\n", ret); +} + START_TEST(crypt) { init_function_pointers(); @@ -1091,4 +1122,5 @@ START_TEST(crypt) test_enum_provider_types(); test_get_default_provider(); test_set_provider_ex(); + test_SystemFunction036(); } diff --git a/rostests/winetests/advapi32/eventlog.c b/rostests/winetests/advapi32/eventlog.c index c0f516acd6f..ff3f658c184 100644 --- a/rostests/winetests/advapi32/eventlog.c +++ b/rostests/winetests/advapi32/eventlog.c @@ -767,33 +767,38 @@ static void test_readwrite(void) { win_skip("Win7 fails when using incorrect event types\n"); ret = ReportEvent(handle, 0, 0, 0, NULL, 0, 0, NULL, NULL); + ok(ret, "Expected success : %d\n", GetLastError()); } else { void *buf; - DWORD read, needed; + DWORD read, needed = 0; EVENTLOGRECORD *record; + ok(ret, "Expected success : %d\n", GetLastError()); + /* Needed to catch earlier Vista (with no ServicePack for example) */ buf = HeapAlloc(GetProcessHeap(), 0, sizeof(EVENTLOGRECORD)); - ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, - 0, buf, sizeof(EVENTLOGRECORD), &read, &needed); - - buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed); - ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, - 0, buf, needed, &read, &needed); - - record = (EVENTLOGRECORD *)buf; - - /* Vista and W2K8 return EVENTLOG_SUCCESS, Windows versions before return - * the written eventtype (0x20 in this case). - */ - if (record->EventType == EVENTLOG_SUCCESS) - on_vista = TRUE; + if (!(ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, + 0, buf, sizeof(EVENTLOGRECORD), &read, &needed)) && + GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed); + ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, + 0, buf, needed, &read, &needed); + } + if (ret) + { + record = (EVENTLOGRECORD *)buf; + /* Vista and W2K8 return EVENTLOG_SUCCESS, Windows versions before return + * the written eventtype (0x20 in this case). + */ + if (record->EventType == EVENTLOG_SUCCESS) + on_vista = TRUE; + } HeapFree(GetProcessHeap(), 0, buf); } - ok(ret, "Expected success : %d\n", GetLastError()); /* This will clear the eventlog. The record numbering for new * events however differs on Vista SP1+. Before Vista the first diff --git a/rostests/winetests/advapi32/registry.c b/rostests/winetests/advapi32/registry.c index dee7664ce27..3a6533979c4 100644 --- a/rostests/winetests/advapi32/registry.c +++ b/rostests/winetests/advapi32/registry.c @@ -24,6 +24,7 @@ #include "wine/test.h" #include "windef.h" #include "winbase.h" +#include "winternl.h" #include "winreg.h" #include "winsvc.h" #include "winerror.h" @@ -34,10 +35,13 @@ static DWORD GLE; static const char * sTestpath1 = "%LONGSYSTEMVAR%\\subdir1"; static const char * sTestpath2 = "%FOO%\\subdir1"; -static HMODULE hadvapi32; static DWORD (WINAPI *pRegGetValueA)(HKEY,LPCSTR,LPCSTR,DWORD,LPDWORD,PVOID,LPDWORD); static DWORD (WINAPI *pRegDeleteTreeA)(HKEY,LPCSTR); - +static DWORD (WINAPI *pRegDeleteKeyExA)(HKEY,LPCSTR,REGSAM,DWORD); +static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL); +static NTSTATUS (WINAPI * pNtDeleteKey)(HANDLE); +static NTSTATUS (WINAPI * pRtlFormatCurrentUserKeyPath)(UNICODE_STRING*); +static NTSTATUS (WINAPI * pRtlFreeUnicodeString)(PUNICODE_STRING); /* Debugging functions from wine/libs/wine/debug.c */ @@ -112,16 +116,23 @@ static const char *wine_debugstr_an( const char *str, int n ) } #define ADVAPI32_GET_PROC(func) \ - p ## func = (void*)GetProcAddress(hadvapi32, #func); - + p ## func = (void*)GetProcAddress(hadvapi32, #func) static void InitFunctionPtrs(void) { - hadvapi32 = GetModuleHandleA("advapi32.dll"); + HMODULE hntdll = GetModuleHandleA("ntdll.dll"); + HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); + HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll"); /* This function was introduced with Windows 2003 SP1 */ - ADVAPI32_GET_PROC(RegGetValueA) - ADVAPI32_GET_PROC(RegDeleteTreeA) + ADVAPI32_GET_PROC(RegGetValueA); + ADVAPI32_GET_PROC(RegDeleteTreeA); + ADVAPI32_GET_PROC(RegDeleteKeyExA); + + pIsWow64Process = (void *)GetProcAddress( hkernel32, "IsWow64Process" ); + pRtlFormatCurrentUserKeyPath = (void *)GetProcAddress( hntdll, "RtlFormatCurrentUserKeyPath" ); + pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString"); + pNtDeleteKey = (void *)GetProcAddress( hntdll, "NtDeleteKey" ); } /* delete key and all its subkeys */ @@ -916,9 +927,11 @@ static void test_reg_open_key(void) /* beginning backslash character */ ret = RegOpenKeyA(HKEY_CURRENT_USER, "\\Software\\Wine\\Test", &hkResult); - ok(ret == ERROR_BAD_PATHNAME || /* NT/2k/XP */ - ret == ERROR_FILE_NOT_FOUND /* Win9x,ME */ - , "expected ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret); + ok(ret == ERROR_BAD_PATHNAME || /* NT/2k/XP */ + ret == ERROR_FILE_NOT_FOUND || /* Win9x,ME */ + broken(ret == ERROR_SUCCESS), /* wow64 */ + "expected ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret); + if (!ret) RegCloseKey(hkResult); hkResult = NULL; ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, "\\clsid", 0, KEY_QUERY_VALUE, &hkResult); @@ -1503,6 +1516,400 @@ static void test_rw_order(void) ok(!RegDeleteKey(HKEY_CURRENT_USER, keyname), "Failed to delete key\n"); } +static void test_symlinks(void) +{ + static const WCHAR targetW[] = {'\\','S','o','f','t','w','a','r','e','\\','W','i','n','e', + '\\','T','e','s','t','\\','t','a','r','g','e','t',0}; + BYTE buffer[1024]; + UNICODE_STRING target_str; + WCHAR *target; + HKEY key, link; + NTSTATUS status; + DWORD target_len, type, len, dw, err; + + if (!pRtlFormatCurrentUserKeyPath || !pNtDeleteKey) + { + win_skip( "Can't perform symlink tests\n" ); + return; + } + + pRtlFormatCurrentUserKeyPath( &target_str ); + + target_len = target_str.Length + sizeof(targetW); + target = HeapAlloc( GetProcessHeap(), 0, target_len ); + memcpy( target, target_str.Buffer, target_str.Length ); + memcpy( target + target_str.Length/sizeof(WCHAR), targetW, sizeof(targetW) ); + + err = RegCreateKeyExA( hkey_main, "link", 0, NULL, REG_OPTION_CREATE_LINK, + KEY_ALL_ACCESS, NULL, &link, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyEx failed: %u\n", err ); + + /* REG_SZ is not allowed */ + err = RegSetValueExA( link, "SymbolicLinkValue", 0, REG_SZ, (BYTE *)"foobar", sizeof("foobar") ); + ok( err == ERROR_ACCESS_DENIED, "RegSetValueEx wrong error %u\n", err ); + err = RegSetValueExA( link, "SymbolicLinkValue", 0, REG_LINK, + (BYTE *)target, target_len - sizeof(WCHAR) ); + ok( err == ERROR_SUCCESS, "RegSetValueEx failed error %u\n", err ); + /* other values are not allowed */ + err = RegSetValueExA( link, "link", 0, REG_LINK, (BYTE *)target, target_len - sizeof(WCHAR) ); + ok( err == ERROR_ACCESS_DENIED, "RegSetValueEx wrong error %u\n", err ); + + /* try opening the target through the link */ + + err = RegOpenKeyA( hkey_main, "link", &key ); + ok( err == ERROR_FILE_NOT_FOUND, "RegOpenKey wrong error %u\n", err ); + + err = RegCreateKeyExA( hkey_main, "target", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyEx failed error %u\n", err ); + + dw = 0xbeef; + err = RegSetValueExA( key, "value", 0, REG_DWORD, (BYTE *)&dw, sizeof(dw) ); + ok( err == ERROR_SUCCESS, "RegSetValueEx failed error %u\n", err ); + RegCloseKey( key ); + + err = RegOpenKeyA( hkey_main, "link", &key ); + ok( err == ERROR_SUCCESS, "RegOpenKey failed error %u\n", err ); + + len = sizeof(buffer); + err = RegQueryValueExA( key, "value", NULL, &type, buffer, &len ); + ok( err == ERROR_SUCCESS, "RegOpenKey failed error %u\n", err ); + ok( len == sizeof(DWORD), "wrong len %u\n", len ); + + len = sizeof(buffer); + err = RegQueryValueExA( key, "SymbolicLinkValue", NULL, &type, buffer, &len ); + ok( err == ERROR_FILE_NOT_FOUND, "RegQueryValueEx wrong error %u\n", err ); + + /* REG_LINK can be created in non-link keys */ + err = RegSetValueExA( key, "SymbolicLinkValue", 0, REG_LINK, + (BYTE *)target, target_len - sizeof(WCHAR) ); + ok( err == ERROR_SUCCESS, "RegSetValueEx failed error %u\n", err ); + len = sizeof(buffer); + err = RegQueryValueExA( key, "SymbolicLinkValue", NULL, &type, buffer, &len ); + ok( err == ERROR_SUCCESS, "RegQueryValueEx failed error %u\n", err ); + ok( len == target_len - sizeof(WCHAR), "wrong len %u\n", len ); + err = RegDeleteValueA( key, "SymbolicLinkValue" ); + ok( err == ERROR_SUCCESS, "RegDeleteValue failed error %u\n", err ); + + RegCloseKey( key ); + + err = RegCreateKeyExA( hkey_main, "link", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyEx failed error %u\n", err ); + + len = sizeof(buffer); + err = RegQueryValueExA( key, "value", NULL, &type, buffer, &len ); + ok( err == ERROR_SUCCESS, "RegQueryValueEx failed error %u\n", err ); + ok( len == sizeof(DWORD), "wrong len %u\n", len ); + + err = RegQueryValueExA( key, "SymbolicLinkValue", NULL, &type, buffer, &len ); + ok( err == ERROR_FILE_NOT_FOUND, "RegQueryValueEx wrong error %u\n", err ); + RegCloseKey( key ); + + /* now open the symlink itself */ + + err = RegOpenKeyExA( hkey_main, "link", REG_OPTION_OPEN_LINK, KEY_ALL_ACCESS, &key ); + ok( err == ERROR_SUCCESS, "RegOpenKeyEx failed error %u\n", err ); + len = sizeof(buffer); + err = RegQueryValueExA( key, "SymbolicLinkValue", NULL, &type, buffer, &len ); + ok( err == ERROR_SUCCESS, "RegQueryValueEx failed error %u\n", err ); + ok( len == target_len - sizeof(WCHAR), "wrong len %u\n", len ); + RegCloseKey( key ); + + err = RegCreateKeyExA( hkey_main, "link", 0, NULL, REG_OPTION_OPEN_LINK, + KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyEx failed error %u\n", err ); + len = sizeof(buffer); + err = RegQueryValueExA( key, "SymbolicLinkValue", NULL, &type, buffer, &len ); + ok( err == ERROR_SUCCESS, "RegQueryValueEx failed error %u\n", err ); + ok( len == target_len - sizeof(WCHAR), "wrong len %u\n", len ); + RegCloseKey( key ); + + err = RegCreateKeyExA( hkey_main, "link", 0, NULL, REG_OPTION_CREATE_LINK, + KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_ALREADY_EXISTS, "RegCreateKeyEx wrong error %u\n", err ); + + err = RegCreateKeyExA( hkey_main, "link", 0, NULL, REG_OPTION_CREATE_LINK | REG_OPTION_OPEN_LINK, + KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_ALREADY_EXISTS, "RegCreateKeyEx wrong error %u\n", err ); + + err = RegDeleteKey( hkey_main, "target" ); + ok( err == ERROR_SUCCESS, "RegDeleteKey failed error %u\n", err ); + + err = RegDeleteKey( hkey_main, "link" ); + ok( err == ERROR_FILE_NOT_FOUND, "RegDeleteKey wrong error %u\n", err ); + + status = pNtDeleteKey( link ); + ok( !status, "NtDeleteKey failed: 0x%08x\n", status ); + RegCloseKey( link ); + + HeapFree( GetProcessHeap(), 0, target ); + pRtlFreeUnicodeString( &target_str ); +} + +static const DWORD ptr_size = 8 * sizeof(void*); + +static DWORD get_key_value( HKEY root, const char *name, DWORD flags ) +{ + HKEY key; + DWORD err, type, dw, len = sizeof(dw); + + err = RegCreateKeyExA( root, name, 0, NULL, 0, flags | KEY_ALL_ACCESS, NULL, &key, NULL ); + if (err == ERROR_FILE_NOT_FOUND) return 0; + ok( err == ERROR_SUCCESS, "%08x: RegCreateKeyEx failed: %u\n", flags, err ); + + err = RegQueryValueExA( key, "value", NULL, &type, (BYTE *)&dw, &len ); + if (err == ERROR_FILE_NOT_FOUND) + dw = 0; + else + ok( err == ERROR_SUCCESS, "%08x: RegQueryValueEx failed: %u\n", flags, err ); + RegCloseKey( key ); + return dw; +} + +static void _check_key_value( int line, HANDLE root, const char *name, DWORD flags, DWORD expect ) +{ + DWORD dw = get_key_value( root, name, flags ); + ok_(__FILE__,line)( dw == expect, "%08x: wrong value %u/%u\n", flags, dw, expect ); +} +#define check_key_value(root,name,flags,expect) _check_key_value( __LINE__, root, name, flags, expect ) + +static void test_redirection(void) +{ + DWORD err, type, dw, len; + HKEY key, root32, root64, key32, key64; + BOOL is_vista = FALSE; + + if (ptr_size != 64) + { + BOOL is_wow64; + if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 ) || !is_wow64) + { + skip( "Not on Wow64, no redirection\n" ); + return; + } + } + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0, + KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &root64, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0, + KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &root32, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", 0, NULL, 0, + KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &key64, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", 0, NULL, 0, + KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &key32, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + + dw = 64; + err = RegSetValueExA( key64, "value", 0, REG_DWORD, (BYTE *)&dw, sizeof(dw) ); + ok( err == ERROR_SUCCESS, "RegSetValueExA failed: %u\n", err ); + + dw = 32; + err = RegSetValueExA( key32, "value", 0, REG_DWORD, (BYTE *)&dw, sizeof(dw) ); + ok( err == ERROR_SUCCESS, "RegSetValueExA failed: %u\n", err ); + + dw = 0; + len = sizeof(dw); + err = RegQueryValueExA( key32, "value", NULL, &type, (BYTE *)&dw, &len ); + ok( err == ERROR_SUCCESS, "RegQueryValueExA failed: %u\n", err ); + ok( dw == 32, "wrong value %u\n", dw ); + + dw = 0; + len = sizeof(dw); + err = RegQueryValueExA( key64, "value", NULL, &type, (BYTE *)&dw, &len ); + ok( err == ERROR_SUCCESS, "RegQueryValueExA failed: %u\n", err ); + ok( dw == 64, "wrong value %u\n", dw ); + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + + if (ptr_size == 32) + { + /* the Vista mechanism allows opening Wow6432Node from a 32-bit key too */ + /* the new (and simpler) Win7 mechanism doesn't */ + if (get_key_value( key, "Wow6432Node\\Wine\\Winetest", 0 ) == 32) + { + trace( "using Vista-style Wow6432Node handling\n" ); + is_vista = TRUE; + } + check_key_value( key, "Wine\\Winetest", 0, 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, is_vista ? 32 : 0 ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 0 ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, is_vista ? 32 : 0 ); + } + else + { + if (get_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY ) == 64) + { + trace( "using Vista-style Wow6432Node handling\n" ); + is_vista = TRUE; + } + check_key_value( key, "Wine\\Winetest", 0, 64 ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, 32 ); + } + RegCloseKey( key ); + + if (ptr_size == 32) + { + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0, + KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + dw = get_key_value( key, "Wine\\Winetest", 0 ); + ok( dw == 64 || broken(dw == 32) /* xp64 */, "wrong value %u\n", dw ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, 64 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, 32 ); + dw = get_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY ); + ok( dw == 32 || broken(dw == 64) /* xp64 */, "wrong value %u\n", dw ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0, + KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + check_key_value( key, "Wine\\Winetest", 0, 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, is_vista ? 32 : 0 ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 0 ); + check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, is_vista ? 32 : 0 ); + RegCloseKey( key ); + } + + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", 0, ptr_size ); + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", 0, 32 ); + if (ptr_size == 64) + { + /* KEY_WOW64 flags have no effect on 64-bit */ + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", KEY_WOW64_64KEY, 64 ); + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + } + else + { + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", KEY_WOW64_64KEY, 64 ); + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + } + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node", 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + check_key_value( key, "Wine\\Winetest", 0, 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + + if (ptr_size == 32) + { + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node", 0, NULL, 0, + KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + dw = get_key_value( key, "Wine\\Winetest", 0 ); + ok( dw == (is_vista ? 64 : 32) || broken(dw == 32) /* xp64 */, "wrong value %u\n", dw ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node", 0, NULL, 0, + KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + check_key_value( key, "Wine\\Winetest", 0, 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + } + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine", 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + check_key_value( key, "Winetest", 0, 32 ); + check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + + if (ptr_size == 32) + { + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine", 0, NULL, 0, + KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + dw = get_key_value( key, "Winetest", 0 ); + ok( dw == 32 || (is_vista && dw == 64), "wrong value %u\n", dw ); + check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine", 0, NULL, 0, + KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + check_key_value( key, "Winetest", 0, 32 ); + check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + } + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + check_key_value( key, "Winetest", 0, ptr_size ); + check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : ptr_size ); + check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + + if (ptr_size == 32) + { + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0, + KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + dw = get_key_value( key, "Winetest", 0 ); + ok( dw == 64 || broken(dw == 32) /* xp64 */, "wrong value %u\n", dw ); + check_key_value( key, "Winetest", KEY_WOW64_64KEY, 64 ); + dw = get_key_value( key, "Winetest", KEY_WOW64_32KEY ); + todo_wine ok( dw == 32, "wrong value %u\n", dw ); + RegCloseKey( key ); + + err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0, + KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &key, NULL ); + ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err ); + check_key_value( key, "Winetest", 0, 32 ); + check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 ); + check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 ); + RegCloseKey( key ); + } + + if (pRegDeleteKeyExA) + { + err = pRegDeleteKeyExA( key32, "", KEY_WOW64_32KEY, 0 ); + ok( err == ERROR_SUCCESS, "RegDeleteKey failed: %u\n", err ); + err = pRegDeleteKeyExA( key64, "", KEY_WOW64_64KEY, 0 ); + ok( err == ERROR_SUCCESS, "RegDeleteKey failed: %u\n", err ); + pRegDeleteKeyExA( key64, "", KEY_WOW64_64KEY, 0 ); + pRegDeleteKeyExA( root64, "", KEY_WOW64_64KEY, 0 ); + } + else + { + err = RegDeleteKeyA( key32, "" ); + ok( err == ERROR_SUCCESS, "RegDeleteKey failed: %u\n", err ); + err = RegDeleteKeyA( key64, "" ); + ok( err == ERROR_SUCCESS, "RegDeleteKey failed: %u\n", err ); + RegDeleteKeyA( key64, "" ); + RegDeleteKeyA( root64, "" ); + } + RegCloseKey( key32 ); + RegCloseKey( key64 ); + RegCloseKey( root32 ); + RegCloseKey( root64 ); +} + START_TEST(registry) { /* Load pointers for functions that are not available in all Windows versions */ @@ -1520,6 +1927,8 @@ START_TEST(registry) test_reg_delete_key(); test_reg_query_value(); test_string_termination(); + test_symlinks(); + test_redirection(); /* SaveKey/LoadKey require the SE_BACKUP_NAME privilege to be set */ if (set_privileges(SE_BACKUP_NAME, TRUE) && diff --git a/rostests/winetests/advapi32/security.c b/rostests/winetests/advapi32/security.c index 001b909d958..029568c50a0 100644 --- a/rostests/winetests/advapi32/security.c +++ b/rostests/winetests/advapi32/security.c @@ -1490,7 +1490,7 @@ static void test_CreateWellKnownSid(void) } } - LocalFree(domainsid); + FreeSid(domainsid); } static void test_LookupAccountSid(void) @@ -1673,7 +1673,7 @@ static void test_LookupAccountSid(void) This assumes this process is running under the account of the current user.*/ ret = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &hToken); ret = GetTokenInformation(hToken, TokenUser, NULL, 0, &cbti); - ptiUser = (PTOKEN_USER) HeapAlloc(GetProcessHeap(), 0, cbti); + ptiUser = HeapAlloc(GetProcessHeap(), 0, cbti); if (GetTokenInformation(hToken, TokenUser, ptiUser, cbti, &cbti)) { acc_sizeA = dom_sizeA = MAX_PATH; @@ -1812,7 +1812,7 @@ static BOOL get_sid_info(PSID psid, LPSTR *user, LPSTR *dom) static void check_wellknown_name(const char* name, WELL_KNOWN_SID_TYPE result) { SID_IDENTIFIER_AUTHORITY ident = { SECURITY_NT_AUTHORITY }; - PSID domainsid; + PSID domainsid = NULL; char wk_sid[SECURITY_MAX_SID_SIZE]; DWORD cb; @@ -1862,6 +1862,7 @@ static void check_wellknown_name(const char* name, WELL_KNOWN_SID_TYPE result) ok(sid_use == SidTypeWellKnownGroup , "Expected Use (5), got %d\n", sid_use); cleanup: + FreeSid(domainsid); HeapFree(GetProcessHeap(),0,psid); HeapFree(GetProcessHeap(),0,domain); } @@ -2615,8 +2616,8 @@ static void test_SetEntriesInAcl(void) ok(NewAcl != NULL, "returned acl was NULL\n"); LocalFree(NewAcl); - LocalFree(UsersSid); - LocalFree(EveryoneSid); + FreeSid(UsersSid); + FreeSid(EveryoneSid); HeapFree(GetProcessHeap(), 0, OldAcl); } diff --git a/rostests/winetests/advapi32/service.c b/rostests/winetests/advapi32/service.c index 17f89d182a3..605f3842de7 100644 --- a/rostests/winetests/advapi32/service.c +++ b/rostests/winetests/advapi32/service.c @@ -1315,10 +1315,10 @@ static void test_enum_svc(void) */ if (status.dwServiceType & (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)) { - if (status.dwCurrentState == SERVICE_RUNNING) - servicecountactive--; - else + if (status.dwCurrentState == SERVICE_STOPPED) servicecountinactive--; + else + servicecountactive--; } } HeapFree(GetProcessHeap(), 0, services); @@ -1661,7 +1661,7 @@ static void test_enum_svc(void) if (status.dwServiceType & (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)) { - if (status.dwCurrentState == SERVICE_RUNNING) + if (status.dwCurrentState != SERVICE_STOPPED) { /* We expect a process id for every running service */ ok(status.dwProcessId > 0, "Expected a process id for this running service (%s)\n", From 08898832d7d709a3aa5fa2f6e3a09e417cdb1be2 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 07:29:40 +0000 Subject: [PATCH 178/211] [GDI32_WINETEST] sync gdi32_winetest to wine 1.1.40 svn path=/trunk/; revision=45975 --- rostests/winetests/gdi32/bitmap.c | 26 ++++-- rostests/winetests/gdi32/dc.c | 149 +++++++++++++++++++++++++++++- 2 files changed, 166 insertions(+), 9 deletions(-) diff --git a/rostests/winetests/gdi32/bitmap.c b/rostests/winetests/gdi32/bitmap.c index 517033c6887..f6a4434fd2f 100755 --- a/rostests/winetests/gdi32/bitmap.c +++ b/rostests/winetests/gdi32/bitmap.c @@ -301,7 +301,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER ok(bm.bmType == 0, "wrong bm.bmType %d\n", bm.bmType); ok(bm.bmWidth == bmih->biWidth, "wrong bm.bmWidth %d\n", bm.bmWidth); - ok(bm.bmHeight == bmih->biHeight, "wrong bm.bmHeight %d\n", bm.bmHeight); + ok(bm.bmHeight == abs(bmih->biHeight), "wrong bm.bmHeight %d\n", bm.bmHeight); dib_width_bytes = DIB_GetWidthBytes(bm.bmWidth, bm.bmBitsPixel); bm_width_bytes = BITMAP_GetWidthBytes(bm.bmWidth, bm.bmBitsPixel); if (bm.bmWidthBytes != dib_width_bytes) /* Win2k bug */ @@ -332,7 +332,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER ret = GetObject(hbm, sizeof(*bma) * 2, bma); ok(ret == sizeof(*bma) || broken(ret == sizeof(*bma) * 2 /* Win9x */), "wrong size %d\n", ret); ok(bm.bmWidth == bmih->biWidth, "wrong bm.bmWidth %d\n", bm.bmWidth); - ok(bm.bmHeight == bmih->biHeight, "wrong bm.bmHeight %d\n", bm.bmHeight); + ok(bm.bmHeight == abs(bmih->biHeight), "wrong bm.bmHeight %d\n", bm.bmHeight); ok(bm.bmBits == bits, "wrong bm.bmBits %p != %p\n", bm.bmBits, bits); ret = GetObject(hbm, sizeof(bm) / 2, &bm); @@ -363,20 +363,22 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER ds.dsBmih.biSizeImage = 0; ok(ds.dsBmih.biSize == bmih->biSize, "%u != %u\n", ds.dsBmih.biSize, bmih->biSize); - ok(ds.dsBmih.biWidth == bmih->biWidth, "%u != %u\n", ds.dsBmih.biWidth, bmih->biWidth); - ok(ds.dsBmih.biHeight == bmih->biHeight, "%u != %u\n", ds.dsBmih.biHeight, bmih->biHeight); + ok(ds.dsBmih.biWidth == bmih->biWidth, "%d != %d\n", ds.dsBmih.biWidth, bmih->biWidth); + ok(ds.dsBmih.biHeight == abs(bmih->biHeight) || + broken(ds.dsBmih.biHeight == bmih->biHeight), /* Win9x/WinMe */ + "%d != %d\n", ds.dsBmih.biHeight, abs(bmih->biHeight)); ok(ds.dsBmih.biPlanes == bmih->biPlanes, "%u != %u\n", ds.dsBmih.biPlanes, bmih->biPlanes); ok(ds.dsBmih.biBitCount == bmih->biBitCount, "%u != %u\n", ds.dsBmih.biBitCount, bmih->biBitCount); ok(ds.dsBmih.biCompression == bmih->biCompression, "%u != %u\n", ds.dsBmih.biCompression, bmih->biCompression); ok(ds.dsBmih.biSizeImage == bmih->biSizeImage, "%u != %u\n", ds.dsBmih.biSizeImage, bmih->biSizeImage); - ok(ds.dsBmih.biXPelsPerMeter == bmih->biXPelsPerMeter, "%u != %u\n", ds.dsBmih.biXPelsPerMeter, bmih->biXPelsPerMeter); - ok(ds.dsBmih.biYPelsPerMeter == bmih->biYPelsPerMeter, "%u != %u\n", ds.dsBmih.biYPelsPerMeter, bmih->biYPelsPerMeter); + ok(ds.dsBmih.biXPelsPerMeter == bmih->biXPelsPerMeter, "%d != %d\n", ds.dsBmih.biXPelsPerMeter, bmih->biXPelsPerMeter); + ok(ds.dsBmih.biYPelsPerMeter == bmih->biYPelsPerMeter, "%d != %d\n", ds.dsBmih.biYPelsPerMeter, bmih->biYPelsPerMeter); memset(&ds, 0xAA, sizeof(ds)); ret = GetObject(hbm, sizeof(ds) - 4, &ds); ok(ret == sizeof(ds.dsBm) || broken(ret == (sizeof(ds) - 4) /* Win9x */), "wrong size %d\n", ret); - ok(ds.dsBm.bmWidth == bmih->biWidth, "%u != %u\n", ds.dsBmih.biWidth, bmih->biWidth); - ok(ds.dsBm.bmHeight == bmih->biHeight, "%u != %u\n", ds.dsBmih.biHeight, bmih->biHeight); + ok(ds.dsBm.bmWidth == bmih->biWidth, "%d != %d\n", ds.dsBmih.biWidth, bmih->biWidth); + ok(ds.dsBm.bmHeight == abs(bmih->biHeight), "%d != %d\n", ds.dsBmih.biHeight, abs(bmih->biHeight)); ok(ds.dsBm.bmBits == bits, "%p != %p\n", ds.dsBm.bmBits, bits); ret = GetObject(hbm, 0, &ds); @@ -525,6 +527,14 @@ static void test_dibsections(void) test_dib_info(hdib, bits, &pbmi->bmiHeader); DeleteObject(hdib); + /* Test a top-down DIB. */ + pbmi->bmiHeader.biHeight = -100; + hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError()); + test_dib_info(hdib, bits, &pbmi->bmiHeader); + DeleteObject(hdib); + + pbmi->bmiHeader.biHeight = 100; pbmi->bmiHeader.biBitCount = 8; pbmi->bmiHeader.biCompression = BI_RLE8; SetLastError(0xdeadbeef); diff --git a/rostests/winetests/gdi32/dc.c b/rostests/winetests/gdi32/dc.c index 1efde38b134..193832c5e1f 100644 --- a/rostests/winetests/gdi32/dc.c +++ b/rostests/winetests/gdi32/dc.c @@ -69,7 +69,7 @@ static void test_savedc_2(void) assert(hrgn != 0); hdc = GetDC(hwnd); - ok(hdc != NULL, "CreateDC rets %p\n", hdc); + ok(hdc != NULL, "GetDC failed\n"); ret = GetClipBox(hdc, &rc_clip); ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret); @@ -328,6 +328,152 @@ static void test_DC_bitmap(void) ReleaseDC( 0, hdc ); } +static void test_DeleteDC(void) +{ + HWND hwnd; + HDC hdc, hdc_test; + WNDCLASSEX cls; + int ret; + + /* window DC */ + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0,0,100,100, + 0, 0, 0, NULL); + ok(hwnd != 0, "CreateWindowExA failed\n"); + + hdc = GetDC(hwnd); + ok(hdc != 0, "GetDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = DeleteDC(hdc); + ok(ret, "DeleteDC failed\n"); + ret = GetObjectType(hdc); + ok(!ret || broken(ret) /* win9x */, "GetObjectType should fail for a deleted DC\n"); + + hdc = GetWindowDC(hwnd); + ok(hdc != 0, "GetDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = DeleteDC(hdc); + ok(ret, "DeleteDC failed\n"); + ret = GetObjectType(hdc); + ok(!ret || broken(ret) /* win9x */, "GetObjectType should fail for a deleted DC\n"); + + DestroyWindow(hwnd); + + /* desktop window DC */ + hwnd = GetDesktopWindow(); + ok(hwnd != 0, "GetDesktopWindow failed\n"); + + hdc = GetDC(hwnd); + ok(hdc != 0, "GetDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = DeleteDC(hdc); + ok(ret, "DeleteDC failed\n"); + ret = GetObjectType(hdc); + ok(!ret || broken(ret) /* win9x */, "GetObjectType should fail for a deleted DC\n"); + + hdc = GetWindowDC(hwnd); + ok(hdc != 0, "GetDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = DeleteDC(hdc); + ok(ret, "DeleteDC failed\n"); + ret = GetObjectType(hdc); + ok(!ret || broken(ret) /* win9x */, "GetObjectType should fail for a deleted DC\n"); + + /* CS_CLASSDC */ + memset(&cls, 0, sizeof(cls)); + cls.cbSize = sizeof(cls); + cls.style = CS_CLASSDC; + cls.hInstance = GetModuleHandle(0); + cls.lpszClassName = "Wine class DC"; + cls.lpfnWndProc = DefWindowProcA; + ret = RegisterClassExA(&cls); + ok(ret, "RegisterClassExA failed\n"); + + hwnd = CreateWindowExA(0, "Wine class DC", NULL, WS_POPUP|WS_VISIBLE, 0,0,100,100, + 0, 0, 0, NULL); + ok(hwnd != 0, "CreateWindowExA failed\n"); + + hdc = GetDC(hwnd); + ok(hdc != 0, "GetDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = DeleteDC(hdc); + ok(ret, "DeleteDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = ReleaseDC(hwnd, hdc); + ok(ret, "ReleaseDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + + hdc_test = hdc; + + hdc = GetWindowDC(hwnd); + ok(hdc != 0, "GetDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = DeleteDC(hdc); + ok(ret, "DeleteDC failed\n"); + ret = GetObjectType(hdc); + ok(!ret || broken(ret) /* win9x */, "GetObjectType should fail for a deleted DC\n"); + + DestroyWindow(hwnd); + + ret = GetObjectType(hdc_test); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + + ret = UnregisterClassA("Wine class DC", GetModuleHandle(NULL)); + ok(ret, "UnregisterClassA failed\n"); + + ret = GetObjectType(hdc_test); +todo_wine + ok(!ret, "GetObjectType should fail for a deleted DC\n"); + + /* CS_OWNDC */ + memset(&cls, 0, sizeof(cls)); + cls.cbSize = sizeof(cls); + cls.style = CS_OWNDC; + cls.hInstance = GetModuleHandle(0); + cls.lpszClassName = "Wine own DC"; + cls.lpfnWndProc = DefWindowProcA; + ret = RegisterClassExA(&cls); + ok(ret, "RegisterClassExA failed\n"); + + hwnd = CreateWindowExA(0, "Wine own DC", NULL, WS_POPUP|WS_VISIBLE, 0,0,100,100, + 0, 0, 0, NULL); + ok(hwnd != 0, "CreateWindowExA failed\n"); + + hdc = GetDC(hwnd); + ok(hdc != 0, "GetDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = DeleteDC(hdc); + ok(ret, "DeleteDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = ReleaseDC(hwnd, hdc); + ok(ret, "ReleaseDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + + hdc = GetWindowDC(hwnd); + ok(hdc != 0, "GetDC failed\n"); + ret = GetObjectType(hdc); + ok(ret == OBJ_DC, "expected OBJ_DC, got %d\n", ret); + ret = DeleteDC(hdc); + ok(ret, "DeleteDC failed\n"); + ret = GetObjectType(hdc); + ok(!ret || broken(ret) /* win9x */, "GetObjectType should fail for a deleted DC\n"); + + DestroyWindow(hwnd); + + ret = UnregisterClassA("Wine own DC", GetModuleHandle(NULL)); + ok(ret, "UnregisterClassA failed\n"); +} + START_TEST(dc) { test_savedc(); @@ -335,4 +481,5 @@ START_TEST(dc) test_GdiConvertToDevmodeW(); test_CreateCompatibleDC(); test_DC_bitmap(); + test_DeleteDC(); } From 2b61353ce285bcb7296c817976f5613fafbeee22 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 07:32:14 +0000 Subject: [PATCH 179/211] [USER32_WINETEST] sync user32_winetest to wine 1.1.40 svn path=/trunk/; revision=45976 --- rostests/winetests/user32/dialog.c | 72 +++++++++++++++++++++++++++++- rostests/winetests/user32/edit.c | 52 +++++++++++++++++++++ rostests/winetests/user32/msg.c | 42 +++++++++++++++++ rostests/winetests/user32/scroll.c | 4 +- rostests/winetests/user32/win.c | 8 ++++ 5 files changed, 174 insertions(+), 4 deletions(-) diff --git a/rostests/winetests/user32/dialog.c b/rostests/winetests/user32/dialog.c index 204d854364b..1b36c5368c9 100755 --- a/rostests/winetests/user32/dialog.c +++ b/rostests/winetests/user32/dialog.c @@ -852,8 +852,8 @@ static void InitialFocusTest (void) ok ((g_hwndInitialFocusT1 == g_hwndButton2), "Error in initial focus when WM_INITDIALOG returned TRUE: " "Expected the second button (%p), got %s (%p).\n", - g_hwndButton2, GetHwndString(g_hwndInitialFocusT2), - g_hwndInitialFocusT2); + g_hwndButton2, GetHwndString(g_hwndInitialFocusT1), + g_hwndInitialFocusT1); ok ((g_hwndInitialFocusT2 == g_hwndButton2), "Error after first SetFocus() when WM_INITDIALOG returned TRUE: " @@ -926,6 +926,21 @@ static INT_PTR CALLBACK DestroyOnCloseDlgWinProc (HWND hDlg, UINT uiMsg, return FALSE; } +static INT_PTR CALLBACK TestInitDialogHandleProc (HWND hDlg, UINT uiMsg, + WPARAM wParam, LPARAM lParam) +{ + if (uiMsg == WM_INITDIALOG) + { + HWND expected = GetNextDlgTabItem(hDlg, NULL, FALSE); + ok(expected == (HWND)wParam, + "Expected wParam to be the handle to the first tabstop control (%p), got %p\n", + expected, (HWND)wParam); + + EndDialog(hDlg, LOWORD(SendMessage(hDlg, DM_GETDEFID, 0, 0))); + return TRUE; + } + return FALSE; +} static INT_PTR CALLBACK TestDefButtonDlgProc (HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) @@ -978,6 +993,9 @@ static void test_DialogBoxParamA(void) broken(GetLastError() == 0xdeadbeef), "got %d, expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError()); + ret = DialogBoxParamA(GetModuleHandle(NULL), "TEST_EMPTY_DIALOG", 0, TestInitDialogHandleProc, 0); + ok(ret == IDOK, "Expected IDOK\n"); + ret = DialogBoxParamA(GetModuleHandle(NULL), "TEST_EMPTY_DIALOG", 0, TestDefButtonDlgProc, 0); ok(ret == IDOK, "Expected IDOK\n"); } @@ -1139,6 +1157,55 @@ static void test_SaveRestoreFocus(void) DestroyWindow(hDlg); } +static INT_PTR CALLBACK timer_message_dlg_proc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + static int count; + BOOL visible; + + switch (msg) + { + case WM_INITDIALOG: + visible = GetWindowLong(wnd, GWL_STYLE) & WS_VISIBLE; + ok(!visible, "Dialog should not be visible.\n"); + SetTimer(wnd, 1, 100, NULL); + Sleep(200); + return FALSE; + + case WM_COMMAND: + if (LOWORD(wparam) != IDCANCEL) return FALSE; + EndDialog(wnd, LOWORD(wparam)); + return TRUE; + + case WM_TIMER: + if (wparam != 1) return FALSE; + visible = GetWindowLong(wnd, GWL_STYLE) & WS_VISIBLE; + if (!count++) + { + ok(!visible, "Dialog should not be visible.\n"); + PostMessage(wnd, WM_USER, 0, 0); + } + else + { + ok(visible, "Dialog should be visible.\n"); + PostMessage(wnd, WM_COMMAND, IDCANCEL, 0); + } + return TRUE; + + case WM_USER: + visible = GetWindowLong(wnd, GWL_STYLE) & WS_VISIBLE; + ok(visible, "Dialog should be visible.\n"); + return TRUE; + + default: + return FALSE; + } +} + +static void test_timer_message(void) +{ + DialogBoxA(g_hinst, "RADIO_TEST_DIALOG", NULL, timer_message_dlg_proc); +} + START_TEST(dialog) { g_hinst = GetModuleHandleA (0); @@ -1154,4 +1221,5 @@ START_TEST(dialog) test_DisabledDialogTest(); test_MessageBoxFontTest(); test_SaveRestoreFocus(); + test_timer_message(); } diff --git a/rostests/winetests/user32/edit.c b/rostests/winetests/user32/edit.c index 7ecee13b80a..ee181f21f6a 100755 --- a/rostests/winetests/user32/edit.c +++ b/rostests/winetests/user32/edit.c @@ -1316,6 +1316,57 @@ static void test_edit_control_limittext(void) DestroyWindow(hwEdit); } +/* Test EM_SCROLL */ +static void test_edit_control_scroll(void) +{ + static const char *single_line_str = "a"; + static const char *multiline_str = "Test\r\nText"; + HWND hwEdit; + LONG ret; + + /* Check the return value when EM_SCROLL doesn't scroll + * anything. Should not return true unless any lines were actually + * scrolled. */ + hwEdit = CreateWindow( + "EDIT", + single_line_str, + WS_VSCROLL | ES_MULTILINE, + 1, 1, 100, 100, + NULL, NULL, hinst, NULL); + + assert(hwEdit); + + ret = SendMessage(hwEdit, EM_SCROLL, SB_PAGEDOWN, 0); + ok(!ret, "Returned %x, expected 0.\n", ret); + + ret = SendMessage(hwEdit, EM_SCROLL, SB_PAGEUP, 0); + ok(!ret, "Returned %x, expected 0.\n", ret); + + ret = SendMessage(hwEdit, EM_SCROLL, SB_LINEUP, 0); + ok(!ret, "Returned %x, expected 0.\n", ret); + + ret = SendMessage(hwEdit, EM_SCROLL, SB_LINEDOWN, 0); + ok(!ret, "Returned %x, expected 0.\n", ret); + + DestroyWindow (hwEdit); + + /* SB_PAGEDOWN while at the beginning of a buffer with few lines + should not cause EM_SCROLL to return a negative value of + scrolled lines that would put us "before" the beginning. */ + hwEdit = CreateWindow( + "EDIT", + multiline_str, + WS_VSCROLL | ES_MULTILINE, + 0, 0, 100, 100, + NULL, NULL, hinst, NULL); + assert(hwEdit); + + ret = SendMessage(hwEdit, EM_SCROLL, SB_PAGEDOWN, 0); + ok(!ret, "Returned %x, expected 0.\n", ret); + + DestroyWindow (hwEdit); +} + static void test_margins(void) { HWND hwEdit; @@ -2319,6 +2370,7 @@ START_TEST(edit) test_edit_control_5(); test_edit_control_6(); test_edit_control_limittext(); + test_edit_control_scroll(); test_margins(); test_margins_font_change(); test_text_position(); diff --git a/rostests/winetests/user32/msg.c b/rostests/winetests/user32/msg.c index 492de627f11..714e57f4bcb 100755 --- a/rostests/winetests/user32/msg.c +++ b/rostests/winetests/user32/msg.c @@ -12080,6 +12080,13 @@ static const struct { 0, 0, FALSE }, { 0, WAIT_TIMEOUT, FALSE }, { 0, 0, FALSE }, + { 0, 0, FALSE }, +/* 15 */ { 0, 0, FALSE }, + { WAIT_TIMEOUT, 0, FALSE }, + { WAIT_TIMEOUT, 0, FALSE }, + { WAIT_TIMEOUT, 0, FALSE }, + { WAIT_TIMEOUT, 0, FALSE }, +/* 20 */ { WAIT_TIMEOUT, 0, FALSE }, }; static DWORD CALLBACK do_wait_idle_child_thread( void *arg ) @@ -12205,6 +12212,41 @@ static void do_wait_idle_child( int arg ) WaitForSingleObject( thread, 10000 ); CloseHandle( thread ); break; + case 14: + SetEvent( start_event ); + Sleep( 200 ); + PeekMessage( &msg, HWND_TOPMOST, 0, 0, PM_NOREMOVE ); + break; + case 15: + SetEvent( start_event ); + Sleep( 200 ); + PeekMessage( &msg, HWND_BROADCAST, 0, 0, PM_NOREMOVE ); + break; + case 16: + SetEvent( start_event ); + Sleep( 200 ); + PeekMessage( &msg, HWND_BOTTOM, 0, 0, PM_NOREMOVE ); + break; + case 17: + SetEvent( start_event ); + Sleep( 200 ); + PeekMessage( &msg, (HWND)0xdeadbeef, 0, 0, PM_NOREMOVE ); + break; + case 18: + SetEvent( start_event ); + Sleep( 200 ); + PeekMessage( &msg, HWND_NOTOPMOST, 0, 0, PM_NOREMOVE ); + break; + case 19: + SetEvent( start_event ); + Sleep( 200 ); + PeekMessage( &msg, HWND_MESSAGE, 0, 0, PM_NOREMOVE ); + break; + case 20: + SetEvent( start_event ); + Sleep( 200 ); + PeekMessage( &msg, GetDesktopWindow(), 0, 0, PM_NOREMOVE ); + break; } WaitForSingleObject( end_event, 2000 ); CloseHandle( start_event ); diff --git a/rostests/winetests/user32/scroll.c b/rostests/winetests/user32/scroll.c index 03725b92f48..0695639a458 100644 --- a/rostests/winetests/user32/scroll.c +++ b/rostests/winetests/user32/scroll.c @@ -411,8 +411,8 @@ START_TEST ( scroll ) WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0 ); - if ( !ok( hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n" ) ) - return; + ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n"); + if (!hMainWnd) return; assert( hScroll ); diff --git a/rostests/winetests/user32/win.c b/rostests/winetests/user32/win.c index 66387573c8d..ddfddb1e9fe 100644 --- a/rostests/winetests/user32/win.c +++ b/rostests/winetests/user32/win.c @@ -3424,6 +3424,14 @@ static void test_window_styles(void) check_window_style(WS_CHILD, WS_EX_DLGMODALFRAME|WS_EX_STATICEDGE, WS_CHILD, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME); check_window_style(WS_CAPTION, WS_EX_STATICEDGE, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE); check_window_style(0, WS_EX_APPWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_APPWINDOW|WS_EX_WINDOWEDGE); + + if (pGetLayeredWindowAttributes) + { + check_window_style(0, WS_EX_LAYERED, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_LAYERED|WS_EX_WINDOWEDGE); + check_window_style(0, WS_EX_LAYERED|WS_EX_TRANSPARENT, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_WINDOWEDGE); + check_window_style(0, WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOOLWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, + WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOOLWINDOW|WS_EX_WINDOWEDGE); + } } static void test_scrollwindow( HWND hwnd) From fbff905ed2f219a05d46d0de7c776bcb15cc31cd Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 07:34:02 +0000 Subject: [PATCH 180/211] [SHELL32_WINETEST] sync shell32_winetest to wine 1.1.40 svn path=/trunk/; revision=45977 --- rostests/winetests/shell32/autocomplete.c | 5 +- rostests/winetests/shell32/shlexec.c | 18 +-- rostests/winetests/shell32/shlfileop.c | 20 +++ rostests/winetests/shell32/shlfolder.c | 151 ++++++++++++++++++---- 4 files changed, 155 insertions(+), 39 deletions(-) diff --git a/rostests/winetests/shell32/autocomplete.c b/rostests/winetests/shell32/autocomplete.c index 042e238c2de..569625f8e7a 100644 --- a/rostests/winetests/shell32/autocomplete.c +++ b/rostests/winetests/shell32/autocomplete.c @@ -126,9 +126,8 @@ START_TEST(autocomplete) return; createMainWnd(); - - if(!ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n")) - return; + ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n"); + if (!hMainWnd) return; ac = test_init(); if (!ac) diff --git a/rostests/winetests/shell32/shlexec.c b/rostests/winetests/shell32/shlexec.c index c673f0a31b5..5d5db34d2b4 100755 --- a/rostests/winetests/shell32/shlexec.c +++ b/rostests/winetests/shell32/shlexec.c @@ -672,28 +672,28 @@ static int StrCmpPath(const char* s1, const char* s2) return 0; } -static int _okChildString(const char* file, int line, const char* key, const char* expected) +static void _okChildString(const char* file, int line, const char* key, const char* expected) { char* result; result=getChildString("Arguments", key); - return ok_(file, line)(lstrcmpiA(result, expected) == 0, - "%s expected '%s', got '%s'\n", key, expected, result); + ok_(file, line)(lstrcmpiA(result, expected) == 0, + "%s expected '%s', got '%s'\n", key, expected, result); } -static int _okChildPath(const char* file, int line, const char* key, const char* expected) +static void _okChildPath(const char* file, int line, const char* key, const char* expected) { char* result; result=getChildString("Arguments", key); - return ok_(file, line)(StrCmpPath(result, expected) == 0, - "%s expected '%s', got '%s'\n", key, expected, result); + ok_(file, line)(StrCmpPath(result, expected) == 0, + "%s expected '%s', got '%s'\n", key, expected, result); } -static int _okChildInt(const char* file, int line, const char* key, int expected) +static void _okChildInt(const char* file, int line, const char* key, int expected) { INT result; result=GetPrivateProfileIntA("Arguments", key, expected, child_file); - return ok_(file, line)(result == expected, - "%s expected %d, but got %d\n", key, expected, result); + ok_(file, line)(result == expected, + "%s expected %d, but got %d\n", key, expected, result); } #define okChildString(key, expected) _okChildString(__FILE__, __LINE__, (key), (expected)) diff --git a/rostests/winetests/shell32/shlfileop.c b/rostests/winetests/shell32/shlfileop.c index 777801e7786..08867c87d6c 100644 --- a/rostests/winetests/shell32/shlfileop.c +++ b/rostests/winetests/shell32/shlfileop.c @@ -965,6 +965,26 @@ static void test_copy(void) ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1 to exist\n"); + /* try to overwrite an existing write protected file */ + clean_after_shfo_tests(); + init_shfo_tests(); + tmp_flags = shfo.fFlags; + shfo.pFrom = "test1.txt\0"; + shfo.pTo = "test2.txt\0"; + /* suppress the error-dialog in win9x here */ + shfo.fFlags = FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT; + ok(SetFileAttributesA(shfo.pTo, FILE_ATTRIBUTE_READONLY), + "Failure to set file attributes (error %x)\n", GetLastError()); + retval = CopyFileA(shfo.pFrom, shfo.pTo, FALSE); + ok(!retval && GetLastError() == ERROR_ACCESS_DENIED, "CopyFileA should have fail with ERROR_ACCESS_DENIED\n"); + retval = SHFileOperationA(&shfo); + /* Does not work on Win95, Win95B, NT4WS and NT4SRV */ + ok(!retval || broken(retval == DE_OPCANCELLED), "SHFileOperationA failed to copy (error %x)\n", retval); + /* Set back normal attributes to make the file deletion succeed */ + ok(SetFileAttributesA(shfo.pTo, FILE_ATTRIBUTE_NORMAL), + "Failure to set file attributes (error %x)\n", GetLastError()); + shfo.fFlags = tmp_flags; + /* try to copy files to a file */ clean_after_shfo_tests(); init_shfo_tests(); diff --git a/rostests/winetests/shell32/shlfolder.c b/rostests/winetests/shell32/shlfolder.c index 31ae05a6ce5..bce7c3ebe44 100644 --- a/rostests/winetests/shell32/shlfolder.c +++ b/rostests/winetests/shell32/shlfolder.c @@ -54,7 +54,7 @@ static void (WINAPI *pILFree)(LPITEMIDLIST); static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST); static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**); static LPITEMIDLIST (WINAPI *pILCombine)(LPCITEMIDLIST,LPCITEMIDLIST); - +static HRESULT (WINAPI *pSHParseDisplayName)(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*); static void init_function_pointers(void) { @@ -62,17 +62,24 @@ static void init_function_pointers(void) HRESULT hr; hmod = GetModuleHandleA("shell32.dll"); - pSHBindToParent = (void*)GetProcAddress(hmod, "SHBindToParent"); - pSHGetFolderPathA = (void*)GetProcAddress(hmod, "SHGetFolderPathA"); - pSHGetFolderPathAndSubDirA = (void*)GetProcAddress(hmod, "SHGetFolderPathAndSubDirA"); - pSHGetPathFromIDListW = (void*)GetProcAddress(hmod, "SHGetPathFromIDListW"); - pSHGetSpecialFolderPathA = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathA"); - pSHGetSpecialFolderPathW = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathW"); - pILFindLastID = (void *)GetProcAddress(hmod, (LPCSTR)16); - pILFree = (void*)GetProcAddress(hmod, (LPSTR)155); - pILIsEqual = (void*)GetProcAddress(hmod, (LPSTR)21); - pSHCreateShellItem = (void*)GetProcAddress(hmod, "SHCreateShellItem"); - pILCombine = (void*)GetProcAddress(hmod, (LPSTR)25); + +#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f)) + MAKEFUNC(SHBindToParent); + MAKEFUNC(SHCreateShellItem); + MAKEFUNC(SHGetFolderPathA); + MAKEFUNC(SHGetFolderPathAndSubDirA); + MAKEFUNC(SHGetPathFromIDListW); + MAKEFUNC(SHGetSpecialFolderPathA); + MAKEFUNC(SHGetSpecialFolderPathW); + MAKEFUNC(SHParseDisplayName); +#undef MAKEFUNC + +#define MAKEFUNC_ORD(f, ord) (p##f = (void*)GetProcAddress(hmod, (LPSTR)(ord))) + MAKEFUNC_ORD(ILFindLastID, 16); + MAKEFUNC_ORD(ILIsEqual, 21); + MAKEFUNC_ORD(ILCombine, 25); + MAKEFUNC_ORD(ILFree, 155); +#undef MAKEFUNC_ORD hmod = GetModuleHandleA("shlwapi.dll"); pStrRetToBufW = (void*)GetProcAddress(hmod, "StrRetToBufW"); @@ -97,6 +104,24 @@ static void test_ParseDisplayName(void) hr = SHGetDesktopFolder(&IDesktopFolder); if(hr != S_OK) return; + /* Tests crash on W2K and below (SHCreateShellItem available as of XP) */ + if (pSHCreateShellItem) + { + /* null name and pidl */ + hr = IShellFolder_ParseDisplayName(IDesktopFolder, + NULL, NULL, NULL, NULL, NULL, 0); + ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr); + + /* null name */ + newPIDL = (ITEMIDLIST*)0xdeadbeef; + hr = IShellFolder_ParseDisplayName(IDesktopFolder, + NULL, NULL, NULL, NULL, &newPIDL, 0); + ok(newPIDL == 0, "expected null, got %p\n", newPIDL); + ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr); + } + else + win_skip("Tests would crash on W2K and below\n"); + MultiByteToWideChar(CP_ACP, 0, cInetTestA, -1, cTestDirW, MAX_PATH); hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0); @@ -331,11 +356,12 @@ static void test_BindToObject(void) hr = IShellFolder_BindToObject(psfMyComputer, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild); ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr); -#if 0 +if (0) +{ /* this call segfaults on 98SE */ hr = IShellFolder_BindToObject(psfMyComputer, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild); ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr); -#endif +} cChars = GetSystemDirectoryA(szSystemDir, MAX_PATH); ok (cChars > 0 && cChars < MAX_PATH, "GetSystemDirectoryA failed! LastError: %u\n", GetLastError()); @@ -361,13 +387,14 @@ static void test_BindToObject(void) hr = IShellFolder_BindToObject(psfSystemDir, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild); ok (hr == E_INVALIDARG, "FileSystem ShellFolder's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr); - -#if 0 + +if (0) +{ /* this call segfaults on 98SE */ hr = IShellFolder_BindToObject(psfSystemDir, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild); - ok (hr == E_INVALIDARG, + ok (hr == E_INVALIDARG, "FileSystem ShellFolder's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr); -#endif +} IShellFolder_Release(psfSystemDir); } @@ -1564,7 +1591,7 @@ static void test_ITEMIDLIST_format(void) { IShellFolder_Release(psfPersonal); } -static void testSHGetFolderPathAndSubDirA(void) +static void test_SHGetFolderPathAndSubDirA(void) { HRESULT ret; BOOL delret; @@ -1576,6 +1603,12 @@ static void testSHGetFolderPathAndSubDirA(void) static char testpath[MAX_PATH]; static char toolongpath[MAX_PATH+1]; + if(!pSHGetFolderPathAndSubDirA) + { + win_skip("SHGetFolderPathAndSubDirA not present!\n"); + return; + } + if(!pSHGetFolderPathA) { win_skip("SHGetFolderPathA not present!\n"); return; @@ -1797,6 +1830,12 @@ static void test_SHCreateShellItem(void) GetCurrentDirectoryA(MAX_PATH, curdirA); + if (!pSHCreateShellItem) + { + win_skip("SHCreateShellItem isn't available\n"); + return; + } + if (!lstrlenA(curdirA)) { win_skip("GetCurrentDirectoryA returned empty string, skipping test_SHCreateShellItem\n"); @@ -1942,6 +1981,69 @@ static void test_SHCreateShellItem(void) IShellFolder_Release(desktopfolder); } +static void test_SHParseDisplayName(void) +{ + static const WCHAR prefixW[] = {'w','t',0}; + LPITEMIDLIST pidl1, pidl2; + IShellFolder *desktop; + WCHAR dirW[MAX_PATH]; + WCHAR nameW[10]; + HRESULT hr; + BOOL ret; + + if (!pSHParseDisplayName) + { + win_skip("SHParseDisplayName isn't available\n"); + return; + } + +if (0) +{ + /* crashes on native */ + hr = pSHParseDisplayName(NULL, NULL, NULL, 0, NULL); + nameW[0] = 0; + hr = pSHParseDisplayName(nameW, NULL, NULL, 0, NULL); +} + + pidl1 = (LPITEMIDLIST)0xdeadbeef; + hr = pSHParseDisplayName(NULL, NULL, &pidl1, 0, NULL); + ok(broken(hr == E_OUTOFMEMORY) /* < Vista */ || + hr == E_INVALIDARG, "failed %08x\n", hr); + ok(pidl1 == 0, "expected null ptr, got %p\n", pidl1); + + /* dummy name */ + nameW[0] = 0; + hr = pSHParseDisplayName(nameW, NULL, &pidl1, 0, NULL); + ok(hr == S_OK, "failed %08x\n", hr); + hr = SHGetDesktopFolder(&desktop); + ok(hr == S_OK, "failed %08x\n", hr); + hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, nameW, NULL, &pidl2, NULL); + ok(hr == S_OK, "failed %08x\n", hr); + ret = pILIsEqual(pidl1, pidl2); + ok(ret == TRUE, "expected equal idls\n"); + pILFree(pidl1); + pILFree(pidl2); + + /* with path */ + GetTempPathW(sizeof(dirW)/sizeof(WCHAR), dirW); + GetTempFileNameW(dirW, prefixW, 0, dirW); + CreateFileW(dirW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + + hr = pSHParseDisplayName(dirW, NULL, &pidl1, 0, NULL); + ok(hr == S_OK, "failed %08x\n", hr); + hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, dirW, NULL, &pidl2, NULL); + ok(hr == S_OK, "failed %08x\n", hr); + + ret = pILIsEqual(pidl1, pidl2); + ok(ret == TRUE, "expected equal idls\n"); + pILFree(pidl1); + pILFree(pidl2); + + DeleteFileW(dirW); + + IShellFolder_Release(desktop); +} + START_TEST(shlfolder) { init_function_pointers(); @@ -1950,6 +2052,7 @@ START_TEST(shlfolder) OleInitialize(NULL); test_ParseDisplayName(); + test_SHParseDisplayName(); test_BindToObject(); test_EnumObjects_and_CompareIDs(); test_GetDisplayName(); @@ -1958,15 +2061,9 @@ START_TEST(shlfolder) test_CallForAttributes(); test_FolderShortcut(); test_ITEMIDLIST_format(); - if(pSHGetFolderPathAndSubDirA) - testSHGetFolderPathAndSubDirA(); - else - win_skip("SHGetFolderPathAndSubDirA not present\n"); + test_SHGetFolderPathAndSubDirA(); test_LocalizedNames(); - if(pSHCreateShellItem) - test_SHCreateShellItem(); - else - win_skip("SHCreateShellItem not present\n"); + test_SHCreateShellItem(); OleUninitialize(); } From 314b9e10be180710228b19ee9b21ac76f1dc2a1b Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 09:29:02 +0000 Subject: [PATCH 181/211] [OBJSEL] sync objsel to wine 1.1.40 svn path=/trunk/; revision=45978 --- reactos/dll/win32/objsel/factory.c | 2 +- reactos/dll/win32/objsel/objsel.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/objsel/factory.c b/reactos/dll/win32/objsel/factory.c index 11d81b90e69..090c1266a42 100644 --- a/reactos/dll/win32/objsel/factory.c +++ b/reactos/dll/win32/objsel/factory.c @@ -50,7 +50,7 @@ static HRESULT WINAPI OBJSEL_IClassFactory_QueryInterface( return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj); } - FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + FIXME("- no interface IID: %s\n", debugstr_guid(riid)); return E_NOINTERFACE; } diff --git a/reactos/dll/win32/objsel/objsel.c b/reactos/dll/win32/objsel/objsel.c index 51e8d0b594e..8179ce5e583 100644 --- a/reactos/dll/win32/objsel/objsel.c +++ b/reactos/dll/win32/objsel/objsel.c @@ -55,7 +55,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) if (IsEqualGUID(rclsid, &CLSID_DsObjectPicker)) return IClassFactory_QueryInterface((IClassFactory*)&OBJSEL_ClassFactory, iid, ppv); - FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid)); + FIXME("CLSID: %s, IID: %s\n", debugstr_guid(rclsid), debugstr_guid(iid)); return CLASS_E_CLASSNOTAVAILABLE; } @@ -147,7 +147,7 @@ static HRESULT WINAPI OBJSEL_IDsObjectPicker_QueryInterface( return S_OK; } - FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + FIXME("- no interface IID: %s\n", debugstr_guid(riid)); return E_NOINTERFACE; } From 6534ce1c51faf3b5fc99765c126ce6b7fd2abf20 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 09:32:58 +0000 Subject: [PATCH 182/211] [ITSS] sync itss to wine 1.1.40 svn path=/trunk/; revision=45979 --- reactos/dll/win32/itss/chm_lib.c | 32 +++++++++++++++++++++++++++ reactos/dll/win32/itss/chm_lib.h | 1 + reactos/dll/win32/itss/itss.inf | 10 ++++----- reactos/dll/win32/itss/storage.c | 37 ++++++++++++++++++++++++++++++-- 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/reactos/dll/win32/itss/chm_lib.c b/reactos/dll/win32/itss/chm_lib.c index a98c8ac6cac..ada9be118a8 100644 --- a/reactos/dll/win32/itss/chm_lib.c +++ b/reactos/dll/win32/itss/chm_lib.c @@ -829,6 +829,38 @@ struct chmFile *chm_openW(const WCHAR *filename) return newHandle; } +/* Duplicate an ITS archive handle */ +struct chmFile *chm_dup(struct chmFile *oldHandle) +{ + struct chmFile *newHandle=NULL; + + newHandle = HeapAlloc(GetProcessHeap(), 0, sizeof(struct chmFile)); + memcpy(newHandle, oldHandle, sizeof(struct chmFile)); + + /* duplicate fd handle */ + DuplicateHandle(GetCurrentProcess(), oldHandle->fd, + GetCurrentProcess(), &(newHandle->fd), + 0, FALSE, DUPLICATE_SAME_ACCESS); + newHandle->lzx_state = NULL; + newHandle->cache_blocks = NULL; + newHandle->cache_block_indices = NULL; + newHandle->cache_num_blocks = 0; + + /* initialize mutexes, if needed */ + InitializeCriticalSection(&newHandle->mutex); + newHandle->mutex.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": chmFile.mutex"); + InitializeCriticalSection(&newHandle->lzx_mutex); + newHandle->lzx_mutex.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": chmFile.lzx_mutex"); + InitializeCriticalSection(&newHandle->cache_mutex); + newHandle->cache_mutex.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": chmFile.cache_mutex"); + + /* initialize cache */ + chm_set_param(newHandle, CHM_PARAM_MAX_BLOCKS_CACHED, + CHM_MAX_BLOCKS_CACHED); + + return newHandle; +} + /* close an ITS archive */ void chm_close(struct chmFile *h) { diff --git a/reactos/dll/win32/itss/chm_lib.h b/reactos/dll/win32/itss/chm_lib.h index 564df5a1cc5..7a064172adf 100644 --- a/reactos/dll/win32/itss/chm_lib.h +++ b/reactos/dll/win32/itss/chm_lib.h @@ -73,6 +73,7 @@ struct chmUnitInfo }; struct chmFile* chm_openW(const WCHAR *filename); +struct chmFile *chm_dup(struct chmFile *oldHandle); /* close an ITS archive */ void chm_close(struct chmFile *h); diff --git a/reactos/dll/win32/itss/itss.inf b/reactos/dll/win32/itss/itss.inf index eeefbbb93bc..fcad4d1ae2f 100644 --- a/reactos/dll/win32/itss/itss.inf +++ b/reactos/dll/win32/itss/itss.inf @@ -16,7 +16,7 @@ DelReg=Classes.Reg, Misc.Reg HKCR,"CLSID\%CLSID_ITStorage%",,,"Microsoft InfoTech IStorage System" HKCR,"CLSID\%CLSID_ITStorage%\InProcServer32",,,"itss.dll" HKCR,"CLSID\%CLSID_ITStorage%\InProcServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_ITStorage%\NotInsertable",,,"" +HKCR,"CLSID\%CLSID_ITStorage%\NotInsertable",,16 HKCR,"CLSID\%CLSID_ITStorage%\ProgID",,,"MSITFS1.0" HKCR,"CLSID\%CLSID_ITStorage%\VersionIndependentProgID",,,"MSITFS" @@ -28,7 +28,7 @@ HKCR,"MSITFS\CurVer",,,"MSITFS1.0" HKCR,"CLSID\%CLSID_MSITStore%",,,"Microsoft InfoTech Protocol for IE 3.0" HKCR,"CLSID\%CLSID_MSITStore%\InProcServer32",,,"itss.dll" HKCR,"CLSID\%CLSID_MSITStore%\InProcServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_MSITStore%\NotInsertable",,,"" +HKCR,"CLSID\%CLSID_MSITStore%\NotInsertable",,16 HKCR,"CLSID\%CLSID_MSITStore%\ProgID",,,"MSITFS1.0" HKCR,"CLSID\%CLSID_MSITStore%\VersionIndependentProgID",,,"MSITFS" @@ -41,9 +41,9 @@ HKCR,"MSITStore\CurVer",,,"MSITStore1.0" HKCR,"CLSID\%CLSID_ITSProtocol%",,,"Microsoft InfoTech Protocol for IE 4.0" HKCR,"CLSID\%CLSID_ITSProtocol%\InProcServer32",,,"itss.dll" HKCR,"CLSID\%CLSID_ITSProtocol%\InProcServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_ITSProtocol%\NotInsertable",,,"" +HKCR,"CLSID\%CLSID_ITSProtocol%\NotInsertable",,16 HKCR,"CLSID\%CLSID_ITSProtocol%\ProgID",,,"MSITFS1.0" -HKCR,"CLSID\%CLSID_ITSProtocol%%\VersionIndependentProgID",,,"MSITFS" +HKCR,"CLSID\%CLSID_ITSProtocol%\VersionIndependentProgID",,,"MSITFS" HKCR,"ITSProtocol","Microsoft InfoTech Protocols for IE 4.0" HKCR,"ITSProtocol\CLSID",,,"%CLSID_ITSProtocol%" @@ -54,7 +54,7 @@ HKCR,"ITSProtocol\CurVer",,,"ITSProtocol1.0" HKCR,"CLSID\%CLSID_MSFSStore%",,,"Microsoft InfoTech IStorage for Win32 Files" HKCR,"CLSID\%CLSID_MSFSStore%\InProcServer32",,,"itss.dll" HKCR,"CLSID\%CLSID_MSFSStore%\InProcServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_MSFSStore%\NotInsertable",,,"" +HKCR,"CLSID\%CLSID_MSFSStore%\NotInsertable",,16 HKCR,"CLSID\%CLSID_MSFSStore%\ProgID",,,"MSITFS1.0" HKCR,"CLSID\%CLSID_MSFSStore%\VersionIndependentProgID",,,"MSITFS" diff --git a/reactos/dll/win32/itss/storage.c b/reactos/dll/win32/itss/storage.c index de0acfaee3e..79c863a4bc2 100644 --- a/reactos/dll/win32/itss/storage.c +++ b/reactos/dll/win32/itss/storage.c @@ -391,10 +391,43 @@ static HRESULT WINAPI ITSS_IStorageImpl_OpenStorage( IStorage** ppstg) { ITSS_IStorageImpl *This = (ITSS_IStorageImpl *)iface; + static const WCHAR szRoot[] = { '/', 0 }; + struct chmFile *chmfile; + WCHAR *path, *p; + DWORD len; - FIXME("%p %s %p %u %p %u %p\n", This, debugstr_w(pwcsName), + TRACE("%p %s %p %u %p %u %p\n", This, debugstr_w(pwcsName), pstgPriority, grfMode, snbExclude, reserved, ppstg); - return E_NOTIMPL; + + chmfile = chm_dup( This->chmfile ); + if( !chmfile ) + return E_FAIL; + + len = strlenW( This->dir ) + strlenW( pwcsName ) + 1; + path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + strcpyW( path, This->dir ); + + if( pwcsName[0] == '/' || pwcsName[0] == '\\' ) + { + p = &path[strlenW( path ) - 1]; + while( ( path <= p ) && ( *p == '/' ) ) + *p-- = 0; + } + strcatW( path, pwcsName ); + + for(p=path; *p; p++) { + if(*p == '\\') + *p = '/'; + } + + if(*--p == '/') + *p = 0; + + strcatW( path, szRoot ); + + TRACE("Resolving %s\n", debugstr_w(path)); + + return ITSS_create_chm_storage(chmfile, path, ppstg); } static HRESULT WINAPI ITSS_IStorageImpl_CopyTo( From ec5cdce304be58b43e15f45a24791ccc30b96e82 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 09:34:40 +0000 Subject: [PATCH 183/211] [PSAPI_WINETEST] sync psapi_winetest to wine 1.1.40 svn path=/trunk/; revision=45980 --- rostests/winetests/psapi/psapi_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rostests/winetests/psapi/psapi_main.c b/rostests/winetests/psapi/psapi_main.c index 6ef5b04c189..21a3d1aa269 100644 --- a/rostests/winetests/psapi/psapi_main.c +++ b/rostests/winetests/psapi/psapi_main.c @@ -157,8 +157,12 @@ static void test_GetMappedFileName(void) w32_err(pGetMappedFileNameA(NULL, hMod, szMapPath, sizeof(szMapPath)), ERROR_INVALID_HANDLE); w32_err(pGetMappedFileNameA(hpSR, hMod, szMapPath, sizeof(szMapPath)), ERROR_ACCESS_DENIED); - if(!w32_suc(ret = pGetMappedFileNameA(hpQI, hMod, szMapPath, sizeof(szMapPath)))) - return; + + SetLastError( 0xdeadbeef ); + ret = pGetMappedFileNameA(hpQI, hMod, szMapPath, sizeof(szMapPath)); + ok( ret || broken(GetLastError() == ERROR_UNEXP_NET_ERR), /* win2k */ + "GetMappedFileNameA failed with error %u\n", GetLastError() ); + if (!ret) return; ok(ret == strlen(szMapPath), "szMapPath=\"%s\" ret=%d\n", szMapPath, ret); ok(szMapPath[0] == '\\', "szMapPath=\"%s\"\n", szMapPath); szMapBaseName = strrchr(szMapPath, '\\'); /* That's close enough for us */ From c666e0e3e7737f26a6acad69d1628c48177d3332 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 09:48:42 +0000 Subject: [PATCH 184/211] [MSCTF] sync msctf to wine 1.1.40 svn path=/trunk/; revision=45982 --- reactos/dll/win32/msctf/langbarmgr.c | 193 +++++++++++++++++++++ reactos/dll/win32/msctf/msctf.c | 21 ++- reactos/dll/win32/msctf/msctf.rbuild | 9 +- reactos/dll/win32/msctf/msctf.spec | 4 +- reactos/dll/win32/msctf/msctf_internal.h | 1 + reactos/dll/win32/msctf/msctf_local.idl | 2 - reactos/dll/win32/msctf/regsvr.c | 11 +- reactos/dll/win32/msctf/textstor_local.idl | 2 - reactos/dll/win32/msctf/threadmgr.c | 160 +++++++++++------ reactos/include/psdk/ctfutb.idl | 73 ++++++++ reactos/include/psdk/msctf.idl | 17 +- reactos/include/psdk/psdk.rbuild | 1 + reactos/lib/sdk/uuid/uuid.c | 1 + 13 files changed, 426 insertions(+), 69 deletions(-) create mode 100644 reactos/dll/win32/msctf/langbarmgr.c delete mode 100644 reactos/dll/win32/msctf/msctf_local.idl delete mode 100644 reactos/dll/win32/msctf/textstor_local.idl create mode 100644 reactos/include/psdk/ctfutb.idl diff --git a/reactos/dll/win32/msctf/langbarmgr.c b/reactos/dll/win32/msctf/langbarmgr.c new file mode 100644 index 00000000000..272a8168727 --- /dev/null +++ b/reactos/dll/win32/msctf/langbarmgr.c @@ -0,0 +1,193 @@ +/* + * ITfLangBarMgr implementation + * + * Copyright 2010 Justin Chevrier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include "wine/debug.h" +#include "winbase.h" +#include "winreg.h" +#include "shlwapi.h" + +#include "msctf.h" +#include "msctf_internal.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msctf); + +typedef struct tagLangBarMgr { + const ITfLangBarMgrVtbl *LangBarMgrVtbl; + + LONG refCount; + +} LangBarMgr; + +static void LangBarMgr_Destructor(LangBarMgr *This) +{ + TRACE("destroying %p\n", This); + + HeapFree(GetProcessHeap(),0,This); +} + +static HRESULT WINAPI LangBarMgr_QueryInterface(ITfLangBarMgr *iface, REFIID iid, LPVOID *ppvOut) +{ + LangBarMgr *This = (LangBarMgr *)iface; + *ppvOut = NULL; + + if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfLangBarMgr)) + { + *ppvOut = This; + } + + if (*ppvOut) + { + IUnknown_AddRef(iface); + return S_OK; + } + + WARN("unsupported interface: %s\n", debugstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI LangBarMgr_AddRef(ITfLangBarMgr *iface) +{ + LangBarMgr *This = (LangBarMgr *)iface; + return InterlockedIncrement(&This->refCount); +} + +static ULONG WINAPI LangBarMgr_Release(ITfLangBarMgr *iface) +{ + LangBarMgr *This = (LangBarMgr *)iface; + ULONG ret; + + ret = InterlockedDecrement(&This->refCount); + if (ret == 0) + LangBarMgr_Destructor(This); + return ret; +} + +/***************************************************** + * ITfLangBarMgr functions + *****************************************************/ + +static HRESULT WINAPI LangBarMgr_AdviseEventSink( ITfLangBarMgr* iface, ITfLangBarEventSink *pSink, HWND hwnd, DWORD dwflags, DWORD *pdwCookie) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_UnAdviseEventSink( ITfLangBarMgr* iface, DWORD dwCookie) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_GetThreadMarshalInterface( ITfLangBarMgr* iface, DWORD dwThreadId, DWORD dwType, REFIID riid, IUnknown **ppunk) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_GetThreadLangBarItemMgr( ITfLangBarMgr* iface, DWORD dwThreadId, ITfLangBarItemMgr **pplbi, DWORD *pdwThreadid) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_GetInputProcessorProfiles( ITfLangBarMgr* iface, DWORD dwThreadId, ITfInputProcessorProfiles **ppaip, DWORD *pdwThreadid) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_RestoreLastFocus( ITfLangBarMgr* iface, DWORD *dwThreadId, BOOL fPrev) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_SetModalInput( ITfLangBarMgr* iface, ITfLangBarEventSink *pSink, DWORD dwThreadId, DWORD dwFlags) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_ShowFloating( ITfLangBarMgr* iface, DWORD dwFlags) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_GetShowFloatingStatus( ITfLangBarMgr* iface, DWORD *pdwFlags) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static const ITfLangBarMgrVtbl LangBarMgr_LangBarMgrVtbl = +{ + LangBarMgr_QueryInterface, + LangBarMgr_AddRef, + LangBarMgr_Release, + + LangBarMgr_AdviseEventSink, + LangBarMgr_UnAdviseEventSink, + LangBarMgr_GetThreadMarshalInterface, + LangBarMgr_GetThreadLangBarItemMgr, + LangBarMgr_GetInputProcessorProfiles, + LangBarMgr_RestoreLastFocus, + LangBarMgr_SetModalInput, + LangBarMgr_ShowFloating, + LangBarMgr_GetShowFloatingStatus +}; + +HRESULT LangBarMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) +{ + LangBarMgr *This; + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + + This = HeapAlloc(GetProcessHeap(),0,sizeof(LangBarMgr)); + if (This == NULL) + return E_OUTOFMEMORY; + + This->LangBarMgrVtbl= &LangBarMgr_LangBarMgrVtbl; + This->refCount = 1; + + TRACE("returning %p\n", This); + *ppOut = (IUnknown *)This; + return S_OK; +} diff --git a/reactos/dll/win32/msctf/msctf.c b/reactos/dll/win32/msctf/msctf.c index 82772787e41..62d1ff2abd8 100644 --- a/reactos/dll/win32/msctf/msctf.c +++ b/reactos/dll/win32/msctf/msctf.c @@ -87,6 +87,7 @@ static const struct { {&CLSID_TF_ThreadMgr, ThreadMgr_Constructor}, {&CLSID_TF_InputProcessorProfiles, InputProcessorProfiles_Constructor}, {&CLSID_TF_CategoryMgr, CategoryMgr_Constructor}, + {&CLSID_TF_LangBarMgr, LangBarMgr_Constructor}, {NULL, NULL} }; @@ -351,7 +352,7 @@ HRESULT add_active_textservice(TF_LANGUAGEPROFILE *lp) ActivatedTextService *actsvr; ITfCategoryMgr *catmgr; AtsEntry *entry; - ITfThreadMgr *tm = (ITfThreadMgr*)TlsGetValue(tlsIndex); + ITfThreadMgr *tm = TlsGetValue(tlsIndex); ITfClientId *clientid; if (!tm) return E_UNEXPECTED; @@ -608,3 +609,21 @@ HRESULT WINAPI TF_CreateInputProcessorProfiles( { return InputProcessorProfiles_Constructor(NULL,(IUnknown**)ppipr); } + +/*********************************************************************** + * TF_InvalidAssemblyListCacheIfExist(MSCTF.@) + */ +HRESULT WINAPI TF_InvalidAssemblyListCacheIfExist(void) +{ + FIXME("Stub\n"); + return S_OK; +} + +/*********************************************************************** + * TF_CreateLangBarMgr (MSCTF.@) + */ +HRESULT WINAPI TF_CreateLangBarMgr(ITfLangBarMgr **pppbm) +{ + TRACE("\n"); + return LangBarMgr_Constructor(NULL,(IUnknown**)pppbm); +} diff --git a/reactos/dll/win32/msctf/msctf.rbuild b/reactos/dll/win32/msctf/msctf.rbuild index d6c531ecbb1..de8f52bf64d 100644 --- a/reactos/dll/win32/msctf/msctf.rbuild +++ b/reactos/dll/win32/msctf/msctf.rbuild @@ -13,6 +13,7 @@ context.c documentmgr.c inputprocessor.c + langbarmgr.c msctf.c range.c regsvr.c @@ -24,14 +25,6 @@ oleaut32 user32 advapi32 - msctf_local_interface - textstor_local_interface ntdll - - msctf_local.idl - - - textstor_local.idl - diff --git a/reactos/dll/win32/msctf/msctf.spec b/reactos/dll/win32/msctf/msctf.spec index f7c35a3a64a..387af570021 100644 --- a/reactos/dll/win32/msctf/msctf.spec +++ b/reactos/dll/win32/msctf/msctf.spec @@ -13,7 +13,7 @@ @ stub TF_CreateDisplayAttributeMgr @ stdcall TF_CreateInputProcessorProfiles(ptr) @ stub TF_CreateLangBarItemMgr -@ stub TF_CreateLangBarMgr +@ stdcall TF_CreateLangBarMgr(ptr) @ stdcall TF_CreateThreadMgr(ptr) @ stub TF_DllDetachInOther @ stub TF_GetGlobalCompartment @@ -27,7 +27,7 @@ @ stub TF_InitMlngInfo @ stub TF_InitSystem @ stub TF_InvalidAssemblyListCache -@ stub TF_InvalidAssemblyListCacheIfExist +@ stdcall TF_InvalidAssemblyListCacheIfExist() @ stub TF_IsCtfmonRunning @ stub TF_IsInMarshaling @ stub TF_MlngInfoCount diff --git a/reactos/dll/win32/msctf/msctf_internal.h b/reactos/dll/win32/msctf/msctf_internal.h index 3bb0baa6ee7..57423e996fc 100644 --- a/reactos/dll/win32/msctf/msctf_internal.h +++ b/reactos/dll/win32/msctf/msctf_internal.h @@ -40,6 +40,7 @@ extern HRESULT CategoryMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut); extern HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD lockType, DWORD anchorStart, DWORD anchorEnd, ITfRange **ppOut); extern HRESULT CompartmentMgr_Constructor(IUnknown *pUnkOuter, REFIID riid, IUnknown **ppOut); extern HRESULT CompartmentMgr_Destructor(ITfCompartmentMgr *This); +extern HRESULT LangBarMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut); extern HRESULT Context_Initialize(ITfContext *cxt, ITfDocumentMgr *manager); extern HRESULT Context_Uninitialize(ITfContext *cxt); diff --git a/reactos/dll/win32/msctf/msctf_local.idl b/reactos/dll/win32/msctf/msctf_local.idl deleted file mode 100644 index cc8b7e65af5..00000000000 --- a/reactos/dll/win32/msctf/msctf_local.idl +++ /dev/null @@ -1,2 +0,0 @@ - -#include "msctf.idl" diff --git a/reactos/dll/win32/msctf/regsvr.c b/reactos/dll/win32/msctf/regsvr.c index a47d984296f..2af1f241154 100644 --- a/reactos/dll/win32/msctf/regsvr.c +++ b/reactos/dll/win32/msctf/regsvr.c @@ -462,6 +462,13 @@ static struct regsvr_coclass const coclass_list[] = { "msctf.dll", "Apartment" }, + { + &CLSID_TF_LangBarMgr, + "TF_LangBarMgr", + NULL, + "msctf.dll", + "Apartment" + }, { NULL } /* list terminator */ }; @@ -474,7 +481,7 @@ static struct regsvr_interface const interface_list[] = { }; /*********************************************************************** - * DllRegisterServer (HHCTRL.@) + * DllRegisterServer (MSCTF.@) */ HRESULT WINAPI DllRegisterServer(void) { @@ -489,7 +496,7 @@ HRESULT WINAPI DllRegisterServer(void) } /*********************************************************************** - * DllUnregisterServer (HHCTRL.@) + * DllUnregisterServer (MSCTF.@) */ HRESULT WINAPI DllUnregisterServer(void) { diff --git a/reactos/dll/win32/msctf/textstor_local.idl b/reactos/dll/win32/msctf/textstor_local.idl deleted file mode 100644 index a665b253969..00000000000 --- a/reactos/dll/win32/msctf/textstor_local.idl +++ /dev/null @@ -1,2 +0,0 @@ - -#include "textstor.idl" diff --git a/reactos/dll/win32/msctf/threadmgr.c b/reactos/dll/win32/msctf/threadmgr.c index b77e0f2c0b7..5f3a90abb5a 100644 --- a/reactos/dll/win32/msctf/threadmgr.c +++ b/reactos/dll/win32/msctf/threadmgr.c @@ -88,7 +88,7 @@ typedef struct tagACLMulti { /* const ITfConfigureSystemKeystrokeFeedVtbl *ConfigureSystemKeystrokeFeedVtbl; */ /* const ITfLangBarItemMgrVtbl *LangBarItemMgrVtbl; */ /* const ITfUIElementMgrVtbl *UIElementMgrVtbl; */ - /* const ITfSourceSingleVtbl *SourceSingleVtbl; */ + const ITfSourceSingleVtbl *SourceSingleVtbl; LONG refCount; /* Aggregation */ @@ -126,7 +126,6 @@ typedef struct tagEnumTfDocumentMgr { } EnumTfDocumentMgr; static HRESULT EnumTfDocumentMgr_Constructor(struct list* head, IEnumTfDocumentMgrs **ppOut); -LRESULT CALLBACK ThreadFocusHookProc(int nCode, WPARAM wParam, LPARAM lParam); static inline ThreadMgr *impl_from_ITfSourceVtbl(ITfSource *iface) { @@ -153,20 +152,10 @@ static inline ThreadMgr *impl_from_ITfThreadMgrEventSink(ITfThreadMgrEventSink * return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,ThreadMgrEventSinkVtbl)); } -static HRESULT SetupWindowsHook(ThreadMgr *This) +static inline ThreadMgr *impl_from_ITfSourceSingleVtbl(ITfSourceSingle* iface) + { - if (!This->focusHook) - { - This->focusHook = SetWindowsHookExW(WH_CBT, ThreadFocusHookProc, 0, - GetCurrentThreadId()); - if (!This->focusHook) - { - ERR("Unable to set focus hook\n"); - return E_FAIL; - } - return S_OK; - } - return S_FALSE; + return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,SourceSingleVtbl)); } static void free_sink(ThreadMgrSink *sink) @@ -283,6 +272,10 @@ static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, { *ppvOut = This->CompartmentMgr; } + else if (IsEqualIID(iid, &IID_ITfSourceSingle)) + { + *ppvOut = &This->SourceSingleVtbl; + } if (*ppvOut) { @@ -441,6 +434,58 @@ static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *p return S_OK; } +static LRESULT CALLBACK ThreadFocusHookProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + ThreadMgr *This; + + This = TlsGetValue(tlsIndex); + if (!This) + { + ERR("Hook proc but no ThreadMgr for this thread. Serious Error\n"); + return 0; + } + if (!This->focusHook) + { + ERR("Hook proc but no ThreadMgr focus Hook. Serious Error\n"); + return 0; + } + + if (nCode == HCBT_SETFOCUS) /* focus change within our thread */ + { + struct list *cursor; + + LIST_FOR_EACH(cursor, &This->AssociatedFocusWindows) + { + AssociatedWindow *wnd = LIST_ENTRY(cursor,AssociatedWindow,entry); + if (wnd->hwnd == (HWND)wParam) + { + TRACE("Triggering Associated window focus\n"); + if (This->focus != wnd->docmgr) + ThreadMgr_SetFocus((ITfThreadMgr*)This, wnd->docmgr); + break; + } + } + } + + return CallNextHookEx(This->focusHook, nCode, wParam, lParam); +} + +static HRESULT SetupWindowsHook(ThreadMgr *This) +{ + if (!This->focusHook) + { + This->focusHook = SetWindowsHookExW(WH_CBT, ThreadFocusHookProc, 0, + GetCurrentThreadId()); + if (!This->focusHook) + { + ERR("Unable to set focus hook\n"); + return E_FAIL; + } + return S_OK; + } + return S_FALSE; +} + static HRESULT WINAPI ThreadMgr_AssociateFocus( ITfThreadMgr* iface, HWND hwnd, ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev) { @@ -838,6 +883,7 @@ static HRESULT WINAPI KeystrokeMgr_PreserveKey(ITfKeystrokeMgr *iface, newkey->guid = *rguid; newkey->prekey = *prekey; newkey->tid = tid; + newkey->description = NULL; if (cchDesc) { newkey->description = HeapAlloc(GetProcessHeap(),0,cchDesc * sizeof(WCHAR)); @@ -1172,6 +1218,53 @@ static const ITfThreadMgrEventSinkVtbl ThreadMgr_ThreadMgrEventSinkVtbl = ThreadMgrEventSink_OnPopContext }; +/***************************************************** + * ITfSourceSingle functions + *****************************************************/ +static HRESULT WINAPI ThreadMgrSourceSingle_QueryInterface(ITfSourceSingle *iface, REFIID iid, LPVOID *ppvOut) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut); +} + +static ULONG WINAPI ThreadMgrSourceSingle_AddRef(ITfSourceSingle *iface) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + return ThreadMgr_AddRef((ITfThreadMgr *)This); +} + +static ULONG WINAPI ThreadMgrSourceSingle_Release(ITfSourceSingle *iface) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + return ThreadMgr_Release((ITfThreadMgr *)This); +} + +static HRESULT WINAPI ThreadMgrSourceSingle_AdviseSingleSink( ITfSourceSingle *iface, + TfClientId tid, REFIID riid, IUnknown *punk) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + FIXME("STUB:(%p) %i %s %p\n",This, tid, debugstr_guid(riid),punk); + return E_NOTIMPL; +} + +static HRESULT WINAPI ThreadMgrSourceSingle_UnadviseSingleSink( ITfSourceSingle *iface, + TfClientId tid, REFIID riid) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + FIXME("STUB:(%p) %i %s\n",This, tid, debugstr_guid(riid)); + return E_NOTIMPL; +} + +static const ITfSourceSingleVtbl ThreadMgr_SourceSingleVtbl = +{ + ThreadMgrSourceSingle_QueryInterface, + ThreadMgrSourceSingle_AddRef, + ThreadMgrSourceSingle_Release, + + ThreadMgrSourceSingle_AdviseSingleSink, + ThreadMgrSourceSingle_UnadviseSingleSink, +}; + HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) { ThreadMgr *This; @@ -1197,6 +1290,7 @@ HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) This->MessagePumpVtbl= &ThreadMgr_MessagePumpVtbl; This->ClientIdVtbl = &ThreadMgr_ClientIdVtbl; This->ThreadMgrEventSinkVtbl = &ThreadMgr_ThreadMgrEventSinkVtbl; + This->SourceSingleVtbl = &ThreadMgr_SourceSingleVtbl; This->refCount = 1; TlsSetValue(tlsIndex,This); @@ -1378,39 +1472,3 @@ void ThreadMgr_OnDocumentMgrDestruction(ITfThreadMgr *tm, ITfDocumentMgr *mgr) } FIXME("ITfDocumenMgr %p not found in this thread\n",mgr); } - -LRESULT CALLBACK ThreadFocusHookProc(int nCode, WPARAM wParam, LPARAM lParam) -{ - ThreadMgr *This; - - This = TlsGetValue(tlsIndex); - if (!This) - { - ERR("Hook proc but no ThreadMgr for this thread. Serious Error\n"); - return 0; - } - if (!This->focusHook) - { - ERR("Hook proc but no ThreadMgr focus Hook. Serious Error\n"); - return 0; - } - - if (nCode == HCBT_SETFOCUS) /* focus change within our thread */ - { - struct list *cursor; - - LIST_FOR_EACH(cursor, &This->AssociatedFocusWindows) - { - AssociatedWindow *wnd = LIST_ENTRY(cursor,AssociatedWindow,entry); - if (wnd->hwnd == (HWND)wParam) - { - TRACE("Triggering Associated window focus\n"); - if (This->focus != wnd->docmgr) - ThreadMgr_SetFocus((ITfThreadMgr*)This, wnd->docmgr); - break; - } - } - } - - return CallNextHookEx(This->focusHook, nCode, wParam, lParam); -} diff --git a/reactos/include/psdk/ctfutb.idl b/reactos/include/psdk/ctfutb.idl new file mode 100644 index 00000000000..6d80b3890dd --- /dev/null +++ b/reactos/include/psdk/ctfutb.idl @@ -0,0 +1,73 @@ +/* + * Copyright 2010 Justin Chevrier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef DO_NO_IMPORTS +import "oaidl.idl"; +#endif + +interface ITfLangBarEventSink; +interface ITfLangBarItemMgr; +interface ITfInputProcessorProfiles; + +[ + object, + uuid(87955690-e627-11d2-8ddb-00105a2799b5), + pointer_default(unique) +] +interface ITfLangBarMgr: IUnknown +{ + HRESULT AdviseEventSink( + [in] ITfLangBarEventSink *pSink, + [in] HWND hwnd, + [in] DWORD dwflags, + [in] DWORD *pdwCookie); + + HRESULT UnAdviseEventSink( + [in] DWORD dwCookie); + + HRESULT GetThreadMarshalInterface( + [in] DWORD dwThreadId, + [in] DWORD dwType, + [in] REFIID riid, + [out] IUnknown **ppunk); + + HRESULT GetThreadLangBarItemMgr( + [in] DWORD dwThreadId, + [out] ITfLangBarItemMgr **pplbie, + [out] DWORD *pdwThreadid); + + HRESULT GetInputProcessorProfiles( + [in] DWORD dwThreadId, + [out] ITfInputProcessorProfiles **ppaip, + [out] DWORD *pdwThreadid); + + HRESULT RestoreLastFocus( + [out] DWORD *dwThreadId, + [in] BOOL fPrev); + + HRESULT SetModalInput( + [in] ITfLangBarEventSink *pSink, + [in] DWORD dwThreadId, + [in] DWORD dwFlags); + + HRESULT ShowFloating( + [in] DWORD dwFlags); + + HRESULT GetShowFloatingStatus( + [out] DWORD *pdwFlags); +}; diff --git a/reactos/include/psdk/msctf.idl b/reactos/include/psdk/msctf.idl index 5d8cb2afa7d..e98df4d8e3c 100644 --- a/reactos/include/psdk/msctf.idl +++ b/reactos/include/psdk/msctf.idl @@ -20,7 +20,7 @@ import "oaidl.idl"; import "comcat.idl"; import "textstor.idl"; -/* import "ctfutb.idl"; */ +import "ctfutb.idl"; #endif cpp_quote("#include ") @@ -37,6 +37,7 @@ cpp_quote("#define TF_E_NOLOCK MAKE_HRESULT(SEVERITY_ERROR, FACILITY_IT cpp_quote("HRESULT WINAPI TF_CreateThreadMgr(ITfThreadMgr **pptim);") cpp_quote("HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim);") cpp_quote("HRESULT WINAPI TF_CreateInputProcessorProfiles(ITfInputProcessorProfiles **ppipr);") +cpp_quote("HRESULT WINAPI TF_CreateLangBarMgr(ITfLangBarMgr **pppbm);") cpp_quote("EXTERN_C const GUID GUID_PROP_TEXTOWNER;") cpp_quote("DEFINE_GUID(GUID_PROP_ATTRIBUTE,0x34b45670,0x7526,0x11d2,0xa1,0x47,0x00,0x10,0x5a,0x27,0x99,0xb5);") @@ -46,6 +47,7 @@ cpp_quote("EXTERN_C const GUID GUID_PROP_COMPOSING;") cpp_quote("EXTERN_C const CLSID CLSID_TF_ThreadMgr;") cpp_quote("EXTERN_C const CLSID CLSID_TF_InputProcessorProfiles;") +cpp_quote("EXTERN_C const CLSID CLSID_TF_LangBarMgr;") cpp_quote("EXTERN_C const CLSID CLSID_TF_CategoryMgr;") cpp_quote("DEFINE_GUID(CLSID_TF_DisplayAttributeMgr,0x3ce74de4,0x53d3,0x4d74,0x8b,0x83,0x43,0x1b,0x38,0x28,0xba,0x53);") @@ -1349,3 +1351,16 @@ interface ITfSourceSingle : IUnknown [in] TfClientId tid, [in] REFIID riid); }; + +[ + object, + local, + uuid(c0f1db0c-3a20-405c-a303-96b6010a885f), + pointer_default(unique) +] +interface ITfThreadFocusSink : IUnknown +{ + HRESULT OnSetThreadFocus(); + + HRESULT OnKillThreadFocus(); +}; diff --git a/reactos/include/psdk/psdk.rbuild b/reactos/include/psdk/psdk.rbuild index 6d5cc78d8dc..02256ebc338 100644 --- a/reactos/include/psdk/psdk.rbuild +++ b/reactos/include/psdk/psdk.rbuild @@ -10,6 +10,7 @@ bits.idl commoncontrols.idl control.idl + ctfutb.idl ctxtcall.idl dimm.idl dispex.idl diff --git a/reactos/lib/sdk/uuid/uuid.c b/reactos/lib/sdk/uuid/uuid.c index bd43f62e8db..cfa5b6e71c9 100644 --- a/reactos/lib/sdk/uuid/uuid.c +++ b/reactos/lib/sdk/uuid/uuid.c @@ -155,6 +155,7 @@ DEFINE_GUID(CLSID_InProcFreeMarshaler, 0x0000033a,0x0000,0x0000,0xc0,0x00,0x0 DEFINE_GUID(CLSID_TF_ThreadMgr, 0x529a9e6b,0x6587,0x4f23,0xab,0x9e,0x9c,0x7d,0x68,0x3e,0x3c,0x50); DEFINE_GUID(CLSID_TF_InputProcessorProfiles, 0x33c53a50,0xf456,0x4884,0xb0,0x49,0x85,0xfd,0x64,0x3e,0xcf,0xed); DEFINE_GUID(CLSID_TF_CategoryMgr, 0xA4B544A1,0x438D,0x4B41,0x93,0x25,0x86,0x95,0x23,0xE2,0xD6,0xC7); +DEFINE_GUID(CLSID_TF_LangBarMgr, 0xebb08c45,0x6c4a,0x4fdc,0xae,0x53,0x4e,0xb8,0xc4,0xc7,0xdb,0x8e); DEFINE_GUID(CLSID_TaskbarList, 0x56fdf344,0xfd6d,0x11d0,0x95,0x8a,0x00,0x60,0x97,0xc9,0xa0,0x90); DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD, 0x34745c63,0xb2f0,0x4784,0x8b,0x67,0x5e,0x12,0xc8,0x70,0x1a,0x31); DEFINE_GUID(GUID_TFCAT_TIP_SPEECH, 0xB5A73CD1,0x8355,0x426B,0xA1,0x61,0x25,0x98,0x08,0xF2,0x6B,0x14); From 5aded0fba97501a73a642e05bebe99db2cb19b0d Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 11:10:18 +0000 Subject: [PATCH 185/211] [PSDK] sync xmldom.idl to wine 1.1.40 svn path=/trunk/; revision=45983 --- reactos/include/psdk/xmldom.idl | 44 +++++++++++++++------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/reactos/include/psdk/xmldom.idl b/reactos/include/psdk/xmldom.idl index 89263c4b75c..d5d51ff2588 100644 --- a/reactos/include/psdk/xmldom.idl +++ b/reactos/include/psdk/xmldom.idl @@ -21,10 +21,6 @@ import "ocidl.idl"; -cpp_quote("#ifndef __xmldom_h__") -cpp_quote("#define __xmldom_h__") -cpp_quote("#endif") - interface IXMLDOMImplementation; interface IXMLDOMNode; interface IXMLDOMDocumentFragment; @@ -268,7 +264,7 @@ interface IXMLDOMDocument : IXMLDOMNode [out,retval] VARIANT_BOOL *isSuccessful ); [propget, id(DISPID_READYSTATE)] - HRESULT readyState( [out,retval] long *value ); + HRESULT readyState( [out,retval] LONG *value ); [propget, id(DISPID_XMLDOM_DOCUMENT_PARSEERROR)] HRESULT parseError( [out,retval] IXMLDOMParseError **errorObj ); @@ -334,11 +330,11 @@ pointer_default(unique) interface IXMLDOMNodeList : IDispatch { [propget, id(DISPID_VALUE)] - HRESULT item( [in] long index, + HRESULT item( [in] LONG index, [out,retval] IXMLDOMNode **listItem ); [propget, id(DISPID_DOM_NODELIST_LENGTH)] - HRESULT length( [out,retval] long *listLength ); + HRESULT length( [out,retval] LONG *listLength ); [id(DISPID_XMLDOM_NODELIST_NEXTNODE)] HRESULT nextNode( [out,retval] IXMLDOMNode **nextItem ); @@ -375,11 +371,11 @@ interface IXMLDOMNamedNodeMap : IDispatch [out,retval] IXMLDOMNode **namedItem ); [propget, id(DISPID_VALUE)] - HRESULT item( [in] long index, + HRESULT item( [in] LONG index, [out,retval] IXMLDOMNode **listItem ); [propget, id(DISPID_DOM_NODELIST_LENGTH)] - HRESULT length( [out,retval] long *listLength ); + HRESULT length( [out,retval] LONG *listLength ); [id(DISPID_XMLDOM_NAMEDNODEMAP_GETQUALIFIEDITEM)] HRESULT getQualifiedItem( [in] BSTR baseName, @@ -435,27 +431,27 @@ interface IXMLDOMCharacterData : IXMLDOMNode HRESULT data( [in] BSTR data ); [propget, id(DISPID_DOM_DATA_LENGTH)] - HRESULT length( [out,retval] long *dataLength ); + HRESULT length( [out,retval] LONG *dataLength ); [id(DISPID_DOM_DATA_SUBSTRING)] - HRESULT substringData( [in] long offset, - [in] long count, + HRESULT substringData( [in] LONG offset, + [in] LONG count, [out,retval] BSTR *data ); [id(DISPID_DOM_DATA_APPEND)] HRESULT appendData( [in] BSTR data ); [id(DISPID_DOM_DATA_INSERT)] - HRESULT insertData( [in] long offset, + HRESULT insertData( [in] LONG offset, [in] BSTR data ); [id(DISPID_DOM_DATA_DELETE)] - HRESULT deleteData( [in] long offset, - [in] long count ); + HRESULT deleteData( [in] LONG offset, + [in] LONG count ); [id(DISPID_DOM_DATA_REPLACE)] - HRESULT replaceData( [in] long offset, - [in] long count, + HRESULT replaceData( [in] LONG offset, + [in] LONG count, [in] BSTR data ); } @@ -540,7 +536,7 @@ pointer_default(unique) interface IXMLDOMText : IXMLDOMCharacterData { [id(DISPID_DOM_TEXT_SPLITTEXT)] - HRESULT splitText( [in] long offset, + HRESULT splitText( [in] LONG offset, [out,retval] IXMLDOMText **rightHandTextNode ); } @@ -703,7 +699,7 @@ uuid (3efaa426-272f-11d2-836f-0000f87a7782) interface IXMLDOMParseError : IDispatch { [propget, id(DISPID_VALUE)] - HRESULT errorCode([retval, out] long *errCode); + HRESULT errorCode([retval, out] LONG *errCode); [propget, id(DISPID_DOM_ERROR_URL)] HRESULT url([retval, out] BSTR *p); @@ -715,13 +711,13 @@ interface IXMLDOMParseError : IDispatch HRESULT srcText([retval, out] BSTR *p); [propget, id(DISPID_DOM_ERROR_LINE)] - HRESULT line([retval, out] long *lineNo); + HRESULT line([retval, out] LONG *lineNo); [propget, id(DISPID_DOM_ERROR_LINEPOS)] - HRESULT linepos([retval, out] long * linePos); + HRESULT linepos([retval, out] LONG * linePos); [propget, id(DISPID_DOM_ERROR_FILEPOS)] - HRESULT filepos([retval, out] long * filePos); + HRESULT filepos([retval, out] LONG * filePos); } [ @@ -788,7 +784,7 @@ interface IXMLHttpRequest : IDispatch HRESULT abort(); [propget, id(7)] - HRESULT status([out, retval] long *plStatus); + HRESULT status([out, retval] LONG *plStatus); [propget, id(8)] HRESULT statusText([out, retval] BSTR *bstrStatus); @@ -806,7 +802,7 @@ interface IXMLHttpRequest : IDispatch HRESULT responseStream([out, retval] VARIANT *pvarBody); [propget, id(13)] - HRESULT readyState([out, retval] long *plState); + HRESULT readyState([out, retval] LONG *plState); [propput, id(14)] HRESULT onreadystatechange([in] IDispatch *pReadyStateSink); From 799cad4cd009122eb2da4c768e41bf6b625fbefb Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 11:15:16 +0000 Subject: [PATCH 186/211] [CLUSAPI] sync clusapi to wine 1.1.40 svn path=/trunk/; revision=45984 --- reactos/dll/win32/clusapi/clusapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/clusapi/clusapi.c b/reactos/dll/win32/clusapi/clusapi.c index fa90de31ef3..f782d43708b 100644 --- a/reactos/dll/win32/clusapi/clusapi.c +++ b/reactos/dll/win32/clusapi/clusapi.c @@ -40,7 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(clusapi); */ DWORD WINAPI GetNodeClusterState(LPCWSTR lpszNodeName, LPDWORD pdwClusterState) { - FIXME("(%s,%p,%u) stub!\n",debugstr_w(lpszNodeName),pdwClusterState, *pdwClusterState); + FIXME("(%s,%p) stub!\n",debugstr_w(lpszNodeName),pdwClusterState); *pdwClusterState = 0; @@ -97,7 +97,7 @@ DWORD WINAPI ClusterCloseEnum(HCLUSENUM hEnum) */ DWORD WINAPI ClusterEnum(HCLUSENUM hEnum, DWORD dwIndex, LPDWORD lpdwType, LPWSTR lpszName, LPDWORD lpcchName) { - FIXME("(%p, %u, %u, %p, %u) stub!\n", hEnum, dwIndex, *lpdwType, lpszName, *lpcchName); + FIXME("(%p, %u, %p, %p, %u) stub!\n", hEnum, dwIndex, lpdwType, lpszName, *lpcchName); return ERROR_NO_MORE_ITEMS; } From 0245cc953538fb274018483f76f642e31d4c23eb Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 11:20:29 +0000 Subject: [PATCH 187/211] [ICCVID] sync iccvid to wine 1.1.40 svn path=/trunk/; revision=45985 --- reactos/dll/win32/iccvid/iccvid_Da.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_De.rc | 4 +++ reactos/dll/win32/iccvid/iccvid_En.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_Es.rc | 30 +++++++++++++++++++++++ reactos/dll/win32/iccvid/iccvid_Fr.rc | 9 +++++-- reactos/dll/win32/iccvid/iccvid_Hu.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_Ja.rc | 30 +++++++++++++++++++++++ reactos/dll/win32/iccvid/iccvid_Ko.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_Lt.rc | 30 +++++++++++++++++++++++ reactos/dll/win32/iccvid/iccvid_Nl.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_No.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_Pl.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_Pt.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_Ro.rc | 4 +++ reactos/dll/win32/iccvid/iccvid_Ru.rc | 9 +++++-- reactos/dll/win32/iccvid/iccvid_Si.rc | 4 +-- reactos/dll/win32/iccvid/iccvid_Sv.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_Tr.rc | 2 ++ reactos/dll/win32/iccvid/iccvid_private.h | 2 ++ reactos/dll/win32/iccvid/rsrc.rc | 14 ++++++++--- 20 files changed, 146 insertions(+), 10 deletions(-) create mode 100644 reactos/dll/win32/iccvid/iccvid_Es.rc create mode 100644 reactos/dll/win32/iccvid/iccvid_Ja.rc create mode 100644 reactos/dll/win32/iccvid/iccvid_Lt.rc diff --git a/reactos/dll/win32/iccvid/iccvid_Da.rc b/reactos/dll/win32/iccvid/iccvid_Da.rc index 185b1bb92ab..bbdc03ed4f2 100644 --- a/reactos/dll/win32/iccvid/iccvid_Da.rc +++ b/reactos/dll/win32/iccvid/iccvid_Da.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_DANISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_De.rc b/reactos/dll/win32/iccvid/iccvid_De.rc index c101f3ad714..d1a3cef3131 100644 --- a/reactos/dll/win32/iccvid/iccvid_De.rc +++ b/reactos/dll/win32/iccvid/iccvid_De.rc @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + +#pragma code_page(65001) + LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_En.rc b/reactos/dll/win32/iccvid/iccvid_En.rc index c71b0a449a0..91d848a0841 100644 --- a/reactos/dll/win32/iccvid/iccvid_En.rc +++ b/reactos/dll/win32/iccvid/iccvid_En.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_Es.rc b/reactos/dll/win32/iccvid/iccvid_Es.rc new file mode 100644 index 00000000000..e86d5250a01 --- /dev/null +++ b/reactos/dll/win32/iccvid/iccvid_Es.rc @@ -0,0 +1,30 @@ +/* + * Copyright 2010 José Manuel Ferrer Ortiz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_NAME "Códec de vídeo Cinepak" + IDS_DESCRIPTION "Códec de vídeo Cinepak" +} diff --git a/reactos/dll/win32/iccvid/iccvid_Fr.rc b/reactos/dll/win32/iccvid/iccvid_Fr.rc index 4d276e68a15..79d9cfd23ce 100644 --- a/reactos/dll/win32/iccvid/iccvid_Fr.rc +++ b/reactos/dll/win32/iccvid/iccvid_Fr.rc @@ -16,10 +16,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { - IDS_NAME "codec vidéo Cinepak" - IDS_DESCRIPTION "codec vidéo Cinepak" + IDS_NAME "Codec vidéo Cinepak" + IDS_DESCRIPTION "Codec vidéo Cinepak" } diff --git a/reactos/dll/win32/iccvid/iccvid_Hu.rc b/reactos/dll/win32/iccvid/iccvid_Hu.rc index b24cf8eaf25..69faccd6a0d 100644 --- a/reactos/dll/win32/iccvid/iccvid_Hu.rc +++ b/reactos/dll/win32/iccvid/iccvid_Hu.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_Ja.rc b/reactos/dll/win32/iccvid/iccvid_Ja.rc new file mode 100644 index 00000000000..b845af4a1c3 --- /dev/null +++ b/reactos/dll/win32/iccvid/iccvid_Ja.rc @@ -0,0 +1,30 @@ +/* + * Copyright 2009 Aric Stewart, CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_NAME "Cinepak ビデオコーデック" + IDS_DESCRIPTION "Cinepak ビデオコーデック" +} diff --git a/reactos/dll/win32/iccvid/iccvid_Ko.rc b/reactos/dll/win32/iccvid/iccvid_Ko.rc index 0cfbe3ea95d..f47eb8ca89a 100644 --- a/reactos/dll/win32/iccvid/iccvid_Ko.rc +++ b/reactos/dll/win32/iccvid/iccvid_Ko.rc @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_Lt.rc b/reactos/dll/win32/iccvid/iccvid_Lt.rc new file mode 100644 index 00000000000..2e31cd398ed --- /dev/null +++ b/reactos/dll/win32/iccvid/iccvid_Lt.rc @@ -0,0 +1,30 @@ +/* + * Copyright 2009 Aurimas FiÅ¡eras + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_NAME "Cinepak vaizdo kodekas" + IDS_DESCRIPTION "Cinepak vaizdo kodekas" +} diff --git a/reactos/dll/win32/iccvid/iccvid_Nl.rc b/reactos/dll/win32/iccvid/iccvid_Nl.rc index 0c58dd16d85..fbc4024bf22 100644 --- a/reactos/dll/win32/iccvid/iccvid_Nl.rc +++ b/reactos/dll/win32/iccvid/iccvid_Nl.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_No.rc b/reactos/dll/win32/iccvid/iccvid_No.rc index dd64108523b..4cefc0013fd 100644 --- a/reactos/dll/win32/iccvid/iccvid_No.rc +++ b/reactos/dll/win32/iccvid/iccvid_No.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_Pl.rc b/reactos/dll/win32/iccvid/iccvid_Pl.rc index e276e8703a1..0a4c0f51678 100644 --- a/reactos/dll/win32/iccvid/iccvid_Pl.rc +++ b/reactos/dll/win32/iccvid/iccvid_Pl.rc @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_POLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_Pt.rc b/reactos/dll/win32/iccvid/iccvid_Pt.rc index 5e4ad5cabd3..659224f8966 100644 --- a/reactos/dll/win32/iccvid/iccvid_Pt.rc +++ b/reactos/dll/win32/iccvid/iccvid_Pt.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_Ro.rc b/reactos/dll/win32/iccvid/iccvid_Ro.rc index 85cb1da2d38..d99a0b2d36b 100644 --- a/reactos/dll/win32/iccvid/iccvid_Ro.rc +++ b/reactos/dll/win32/iccvid/iccvid_Ro.rc @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + +#pragma code_page(65001) + LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_Ru.rc b/reactos/dll/win32/iccvid/iccvid_Ru.rc index c78ee72ff16..7a77b349eaf 100644 --- a/reactos/dll/win32/iccvid/iccvid_Ru.rc +++ b/reactos/dll/win32/iccvid/iccvid_Ru.rc @@ -16,10 +16,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { - IDS_NAME "Âèäåî êîäåð-äåêîäåð Cinepak" - IDS_DESCRIPTION "Âèäåî êîäåð-äåêîäåð Cinepak" + IDS_NAME "Видео кодер-декодер Cinepak" + IDS_DESCRIPTION "Видео кодер-декодер Cinepak" } diff --git a/reactos/dll/win32/iccvid/iccvid_Si.rc b/reactos/dll/win32/iccvid/iccvid_Si.rc index 82bbd05fee4..9635480e091 100644 --- a/reactos/dll/win32/iccvid/iccvid_Si.rc +++ b/reactos/dll/win32/iccvid/iccvid_Si.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + #pragma code_page(65001) LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT @@ -25,5 +27,3 @@ STRINGTABLE DISCARDABLE IDS_NAME "Cinepak Video kodek" IDS_DESCRIPTION "Cinepak Video kodek" } - -#pragma code_page(default) diff --git a/reactos/dll/win32/iccvid/iccvid_Sv.rc b/reactos/dll/win32/iccvid/iccvid_Sv.rc index 55eb468125b..34762d69071 100644 --- a/reactos/dll/win32/iccvid/iccvid_Sv.rc +++ b/reactos/dll/win32/iccvid/iccvid_Sv.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_Tr.rc b/reactos/dll/win32/iccvid/iccvid_Tr.rc index 929f44fcbb2..8eabf9f6909 100644 --- a/reactos/dll/win32/iccvid/iccvid_Tr.rc +++ b/reactos/dll/win32/iccvid/iccvid_Tr.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/reactos/dll/win32/iccvid/iccvid_private.h b/reactos/dll/win32/iccvid/iccvid_private.h index 8400e775207..56b082d844d 100644 --- a/reactos/dll/win32/iccvid/iccvid_private.h +++ b/reactos/dll/win32/iccvid/iccvid_private.h @@ -19,6 +19,8 @@ #ifndef __ICCVID_PRIVATE_H #define __ICCVID_PRIVATE_H +#include + #define IDS_NAME 100 #define IDS_DESCRIPTION 101 diff --git a/reactos/dll/win32/iccvid/rsrc.rc b/reactos/dll/win32/iccvid/rsrc.rc index e7512207c82..ab655d7e199 100644 --- a/reactos/dll/win32/iccvid/rsrc.rc +++ b/reactos/dll/win32/iccvid/rsrc.rc @@ -20,17 +20,23 @@ #include "iccvid_private.h" #include "iccvid_Da.rc" -#include "iccvid_De.rc" #include "iccvid_En.rc" -#include "iccvid_Fr.rc" #include "iccvid_Hu.rc" #include "iccvid_Ko.rc" #include "iccvid_Nl.rc" #include "iccvid_No.rc" #include "iccvid_Pl.rc" #include "iccvid_Pt.rc" +#include "iccvid_Sv.rc" +#include "iccvid_Tr.rc" + +/* UTF-8 */ +#include "iccvid_De.rc" +#include "iccvid_Es.rc" +#include "iccvid_Fr.rc" +#include "iccvid_Ja.rc" +#include "iccvid_Lt.rc" #include "iccvid_Ro.rc" #include "iccvid_Ru.rc" #include "iccvid_Si.rc" -#include "iccvid_Sv.rc" -#include "iccvid_Tr.rc" + From aa25097d0d4cf156865134ed846ce50759f0c5b2 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 11:21:31 +0000 Subject: [PATCH 188/211] [ITIRCL] sync itircl to wine 1.1.40 svn path=/trunk/; revision=45986 --- reactos/dll/win32/itircl/itircl_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/reactos/dll/win32/itircl/itircl_main.c b/reactos/dll/win32/itircl/itircl_main.c index b8d57517a35..e2f1ed35035 100644 --- a/reactos/dll/win32/itircl/itircl_main.c +++ b/reactos/dll/win32/itircl/itircl_main.c @@ -71,6 +71,5 @@ HRESULT WINAPI DllUnregisterServer(void) */ HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("stub\n"); return S_FALSE; } From aeda2ffa1013f868db944fedd79466adc4081932 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 11:27:14 +0000 Subject: [PATCH 189/211] [IMM32] sync imm32 to wine 1.1.40 svn path=/trunk/; revision=45987 --- reactos/dll/win32/imm32/imm.c | 2895 +++++++++++++++------------- reactos/dll/win32/imm32/imm32.spec | 15 +- 2 files changed, 1598 insertions(+), 1312 deletions(-) diff --git a/reactos/dll/win32/imm32/imm.c b/reactos/dll/win32/imm32/imm.c index 4ba1d631313..6f9744872b6 100644 --- a/reactos/dll/win32/imm32/imm.c +++ b/reactos/dll/win32/imm32/imm.c @@ -20,6 +20,7 @@ */ #include +#include #include "windef.h" #include "winbase.h" @@ -35,10 +36,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm); -#define FROM_IME 0xcafe1337 - -static void (*pX11DRV_ForceXIMReset)(HWND); - typedef struct tagIMCCInternal { DWORD dwLock; @@ -76,15 +73,12 @@ typedef struct _tagImmHkl{ typedef struct tagInputContextData { - BOOL bInternalState; - BOOL bRead; - BOOL bInComposition; - HFONT textfont; - DWORD dwLock; INPUTCONTEXT IMC; ImmHkl *immKbd; + HWND imeWnd; + UINT lastVK; } InputContextData; typedef struct _tagTRANSMSG { @@ -93,12 +87,12 @@ typedef struct _tagTRANSMSG { LPARAM lParam; } TRANSMSG, *LPTRANSMSG; -static InputContextData *root_context = NULL; -static HWND hwndDefault = NULL; -static HANDLE hImeInst; -static const WCHAR WC_IMECLASSNAME[] = {'I','M','E',0}; -static ATOM atIMEClass = 0; +typedef struct _tagIMMThreadData { + HIMC defaultContext; + HWND hwndDefault; +} IMMThreadData; +static DWORD tlsIndex = 0; static struct list ImmHklList = LIST_INIT(ImmHklList); /* MSIME messages */ @@ -111,15 +105,174 @@ static UINT WM_MSIME_QUERYPOSITION; static UINT WM_MSIME_DOCUMENTFEED; static const WCHAR szwWineIMCProperty[] = {'W','i','n','e','I','m','m','H','I','M','C','P','r','o','p','e','r','t','y',0}; -/* - * prototypes - */ -static LRESULT WINAPI IME_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, - LPARAM lParam); -static void UpdateDataInDefaultIMEWindow(HWND hwnd, BOOL showable); -static void ImmInternalPostIMEMessage(InputContextData*, UINT, WPARAM, LPARAM); -static void ImmInternalSetOpenStatus(BOOL fOpen); -static HIMCC updateResultStr(HIMCC old, LPWSTR resultstr, DWORD len); + +static const WCHAR szImeFileW[] = {'I','m','e',' ','F','i','l','e',0}; +static const WCHAR szLayoutTextW[] = {'L','a','y','o','u','t',' ','T','e','x','t',0}; +static const WCHAR szImeRegFmt[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s','\\','%','0','8','l','x',0}; + + +#define is_himc_ime_unicode(p) (p->immKbd->imeInfo.fdwProperty & IME_PROP_UNICODE) +#define is_kbd_ime_unicode(p) (p->imeInfo.fdwProperty & IME_PROP_UNICODE) + +static BOOL IMM_DestroyContext(HIMC hIMC); + +static inline WCHAR *strdupAtoW( const char *str ) +{ + WCHAR *ret = NULL; + if (str) + { + DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); + } + return ret; +} + +static inline CHAR *strdupWtoA( const WCHAR *str ) +{ + CHAR *ret = NULL; + if (str) + { + DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); + if ((ret = HeapAlloc( GetProcessHeap(), 0, len ))) + WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); + } + return ret; +} + +static DWORD convert_candidatelist_WtoA( + LPCANDIDATELIST lpSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen) +{ + DWORD ret, i, len; + + ret = FIELD_OFFSET( CANDIDATELIST, dwOffset[lpSrc->dwCount] ); + if ( lpDst && dwBufLen > 0 ) + { + *lpDst = *lpSrc; + lpDst->dwOffset[0] = ret; + } + + for ( i = 0; i < lpSrc->dwCount; i++) + { + LPBYTE src = (LPBYTE)lpSrc + lpSrc->dwOffset[i]; + + if ( lpDst && dwBufLen > 0 ) + { + LPBYTE dest = (LPBYTE)lpDst + lpDst->dwOffset[i]; + + len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, + (LPSTR)dest, dwBufLen, NULL, NULL); + + if ( i + 1 < lpSrc->dwCount ) + lpDst->dwOffset[i+1] = lpDst->dwOffset[i] + len * sizeof(char); + dwBufLen -= len * sizeof(char); + } + else + len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, NULL, 0, NULL, NULL); + + ret += len * sizeof(char); + } + + if ( lpDst ) + lpDst->dwSize = ret; + + return ret; +} + +static DWORD convert_candidatelist_AtoW( + LPCANDIDATELIST lpSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen) +{ + DWORD ret, i, len; + + ret = FIELD_OFFSET( CANDIDATELIST, dwOffset[lpSrc->dwCount] ); + if ( lpDst && dwBufLen > 0 ) + { + *lpDst = *lpSrc; + lpDst->dwOffset[0] = ret; + } + + for ( i = 0; i < lpSrc->dwCount; i++) + { + LPBYTE src = (LPBYTE)lpSrc + lpSrc->dwOffset[i]; + + if ( lpDst && dwBufLen > 0 ) + { + LPBYTE dest = (LPBYTE)lpDst + lpDst->dwOffset[i]; + + len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, + (LPWSTR)dest, dwBufLen); + + if ( i + 1 < lpSrc->dwCount ) + lpDst->dwOffset[i+1] = lpDst->dwOffset[i] + len * sizeof(WCHAR); + dwBufLen -= len * sizeof(WCHAR); + } + else + len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, NULL, 0); + + ret += len * sizeof(WCHAR); + } + + if ( lpDst ) + lpDst->dwSize = ret; + + return ret; +} + +static IMMThreadData* IMM_GetThreadData(void) +{ + IMMThreadData* data = TlsGetValue(tlsIndex); + if (!data) + { + data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(IMMThreadData)); + TlsSetValue(tlsIndex,data); + TRACE("Thread Data Created\n"); + } + return data; +} + +static void IMM_FreeThreadData(void) +{ + IMMThreadData* data = TlsGetValue(tlsIndex); + if (data) + { + IMM_DestroyContext(data->defaultContext); + DestroyWindow(data->hwndDefault); + HeapFree(GetProcessHeap(),0,data); + TRACE("Thread Data Destroyed\n"); + } +} + +static HMODULE LoadDefaultWineIME(void) +{ + char buffer[MAX_PATH], libname[32], *name, *next; + HMODULE module = 0; + HKEY hkey; + + TRACE("Attempting to fall back to wine default IME\n"); + + strcpy( buffer, "x11" ); /* default value */ + /* @@ Wine registry key: HKCU\Software\Wine\Drivers */ + if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey )) + { + DWORD type, count = sizeof(buffer); + RegQueryValueExA( hkey, "Ime", 0, &type, (LPBYTE) buffer, &count ); + RegCloseKey( hkey ); + } + + name = buffer; + while (name) + { + next = strchr( name, ',' ); + if (next) *next++ = 0; + + snprintf( libname, sizeof(libname), "wine%s.drv", name ); + if ((module = LoadLibraryA( libname )) != 0) break; + name = next; + } + + return module; +} /* ImmHkl loading and freeing */ #define LOAD_FUNCPTR(f) if((ptr->p##f = (LPVOID)GetProcAddress(ptr->hIME, #f)) == NULL){WARN("Can't find function %s in ime\n", #f);} @@ -128,7 +281,7 @@ static ImmHkl *IMM_GetImmHkl(HKL hkl) ImmHkl *ptr; WCHAR filename[MAX_PATH]; - TRACE("Seeking ime for keyboard 0x%x\n",(unsigned)hkl); + TRACE("Seeking ime for keyboard %p\n",hkl); LIST_FOR_EACH_ENTRY(ptr, &ImmHklList, ImmHkl, entry) { @@ -141,32 +294,49 @@ static ImmHkl *IMM_GetImmHkl(HKL hkl) ptr->hkl = hkl; if (ImmGetIMEFileNameW(hkl, filename, MAX_PATH)) ptr->hIME = LoadLibraryW(filename); + if (!ptr->hIME) + ptr->hIME = LoadDefaultWineIME(); if (ptr->hIME) { LOAD_FUNCPTR(ImeInquire); - LOAD_FUNCPTR(ImeDestroy); - LOAD_FUNCPTR(ImeSelect); - if (!ptr->pImeInquire || !ptr->pImeDestroy || !ptr->pImeSelect) + if (!ptr->pImeInquire || !ptr->pImeInquire(&ptr->imeInfo, ptr->imeClassName, NULL)) { FreeLibrary(ptr->hIME); ptr->hIME = NULL; } else { - ptr->pImeInquire(&ptr->imeInfo, ptr->imeClassName, NULL); - LOAD_FUNCPTR(ImeConfigure); - LOAD_FUNCPTR(ImeEscape); - LOAD_FUNCPTR(ImeSetActiveContext); - LOAD_FUNCPTR(ImeToAsciiEx); - LOAD_FUNCPTR(NotifyIME); - LOAD_FUNCPTR(ImeRegisterWord); - LOAD_FUNCPTR(ImeUnregisterWord); - LOAD_FUNCPTR(ImeEnumRegisterWord); - LOAD_FUNCPTR(ImeSetCompositionString); - LOAD_FUNCPTR(ImeConversionList); - LOAD_FUNCPTR(ImeProcessKey); - LOAD_FUNCPTR(ImeGetRegisterWordStyle); - LOAD_FUNCPTR(ImeGetImeMenuItems); + LOAD_FUNCPTR(ImeDestroy); + LOAD_FUNCPTR(ImeSelect); + if (!ptr->pImeSelect || !ptr->pImeDestroy) + { + FreeLibrary(ptr->hIME); + ptr->hIME = NULL; + } + else + { + LOAD_FUNCPTR(ImeConfigure); + LOAD_FUNCPTR(ImeEscape); + LOAD_FUNCPTR(ImeSetActiveContext); + LOAD_FUNCPTR(ImeToAsciiEx); + LOAD_FUNCPTR(NotifyIME); + LOAD_FUNCPTR(ImeRegisterWord); + LOAD_FUNCPTR(ImeUnregisterWord); + LOAD_FUNCPTR(ImeEnumRegisterWord); + LOAD_FUNCPTR(ImeSetCompositionString); + LOAD_FUNCPTR(ImeConversionList); + LOAD_FUNCPTR(ImeProcessKey); + LOAD_FUNCPTR(ImeGetRegisterWordStyle); + LOAD_FUNCPTR(ImeGetImeMenuItems); + /* make sure our classname is WCHAR */ + if (!is_kbd_ime_unicode(ptr)) + { + WCHAR bufW[17]; + MultiByteToWideChar(CP_ACP, 0, (LPSTR)ptr->imeClassName, + -1, bufW, 17); + lstrcpyW(ptr->imeClassName, bufW); + } + } } } list_add_head(&ImmHklList,&ptr->entry); @@ -191,54 +361,6 @@ static void IMM_FreeAllImmHkl(void) } } -static VOID IMM_PostResult(InputContextData *data) -{ - unsigned int i; - LPCOMPOSITIONSTRING compstr; - LPBYTE compdata; - LPWSTR ResultStr; - HIMCC newCompStr; - - TRACE("Posting result as IME_CHAR\n"); - compdata = ImmLockIMCC(root_context->IMC.hCompStr); - compstr = (LPCOMPOSITIONSTRING)compdata; - ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset); - - for (i = 0; i < compstr->dwResultStrLen; i++) - ImmInternalPostIMEMessage (root_context, WM_IME_CHAR, ResultStr[i], 1); - - ImmUnlockIMCC(root_context->IMC.hCompStr); - - /* clear the buffer */ - newCompStr = updateResultStr(root_context->IMC.hCompStr, NULL, 0); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; -} - -static void IMM_Register(void) -{ - WNDCLASSW wndClass; - ZeroMemory(&wndClass, sizeof(WNDCLASSW)); - wndClass.style = CS_GLOBALCLASS | CS_IME | CS_HREDRAW | CS_VREDRAW; - wndClass.lpfnWndProc = (WNDPROC) IME_WindowProc; - wndClass.cbClsExtra = 0; - wndClass.cbWndExtra = 0; - wndClass.hInstance = hImeInst; - wndClass.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW); - wndClass.hIcon = NULL; - wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW +1); - wndClass.lpszMenuName = 0; - wndClass.lpszClassName = WC_IMECLASSNAME; - atIMEClass = RegisterClassW(&wndClass); -} - -static void IMM_Unregister(void) -{ - if (atIMEClass) { - UnregisterClassW(WC_IMECLASSNAME, NULL); - } -} - static void IMM_RegisterMessages(void) { WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService"); @@ -250,29 +372,26 @@ static void IMM_RegisterMessages(void) WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed"); } - BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved) { - HMODULE x11drv; - TRACE("%p, %x, %p\n",hInstDLL,fdwReason,lpReserved); switch (fdwReason) { case DLL_PROCESS_ATTACH: - DisableThreadLibraryCalls(hInstDLL); - hImeInst = hInstDLL; IMM_RegisterMessages(); - x11drv = GetModuleHandleA("winex11.drv"); - if (x11drv) pX11DRV_ForceXIMReset = (void *)GetProcAddress( x11drv, "ForceXIMReset"); + tlsIndex = TlsAlloc(); + if (tlsIndex == TLS_OUT_OF_INDEXES) + return FALSE; + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + IMM_FreeThreadData(); break; case DLL_PROCESS_DETACH: - if (hwndDefault) - { - DestroyWindow(hwndDefault); - hwndDefault = 0; - } - IMM_Unregister(); + IMM_FreeThreadData(); IMM_FreeAllImmHkl(); + TlsFree(tlsIndex); break; } return TRUE; @@ -306,337 +425,25 @@ static HIMCC ImmCreateBlankCompStr(void) HIMCC rc; LPCOMPOSITIONSTRING ptr; rc = ImmCreateIMCC(sizeof(COMPOSITIONSTRING)); - ptr = (LPCOMPOSITIONSTRING)ImmLockIMCC(rc); + ptr = ImmLockIMCC(rc); memset(ptr,0,sizeof(COMPOSITIONSTRING)); ptr->dwSize = sizeof(COMPOSITIONSTRING); ImmUnlockIMCC(rc); return rc; } -static void ImmInternalSetOpenStatus(BOOL fOpen) -{ - TRACE("Setting internal state to %s\n",(fOpen)?"OPEN":"CLOSED"); - - if (root_context->IMC.fOpen && fOpen == FALSE) - { - ShowWindow(hwndDefault,SW_HIDE); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = ImmCreateBlankCompStr(); - } - - root_context->IMC.fOpen = fOpen; - root_context->bInternalState = fOpen; - - ImmInternalSendIMENotify(root_context, IMN_SETOPENSTATUS, 0); -} - -static int updateField(DWORD origLen, DWORD origOffset, DWORD currentOffset, - LPBYTE target, LPBYTE source, DWORD* lenParam, - DWORD* offsetParam, BOOL wchars ) -{ - if (origLen > 0 && origOffset > 0) - { - int truelen = origLen; - if (wchars) - truelen *= sizeof(WCHAR); - - memcpy(&target[currentOffset], &source[origOffset], truelen); - - *lenParam = origLen; - *offsetParam = currentOffset; - currentOffset += truelen; - } - return currentOffset; -} - -static HIMCC updateCompStr(HIMCC old, LPWSTR compstr, DWORD len) -{ - /* we need to make sure the CompStr, CompClaus and CompAttr fields are all - * set and correct */ - int needed_size; - HIMCC rc; - LPBYTE newdata = NULL; - LPBYTE olddata = NULL; - LPCOMPOSITIONSTRING new_one; - LPCOMPOSITIONSTRING lpcs = NULL; - INT current_offset = 0; - - TRACE("%s, %i\n",debugstr_wn(compstr,len),len); - - if (old == NULL && compstr == NULL && len == 0) - return NULL; - - if (old != NULL) - { - olddata = ImmLockIMCC(old); - lpcs = (LPCOMPOSITIONSTRING)olddata; - } - - needed_size = sizeof(COMPOSITIONSTRING) + len * sizeof(WCHAR) + - len + sizeof(DWORD) * 2; - - if (lpcs != NULL) - { - needed_size += lpcs->dwCompReadAttrLen; - needed_size += lpcs->dwCompReadClauseLen; - needed_size += lpcs->dwCompReadStrLen * sizeof(DWORD); - needed_size += lpcs->dwResultReadClauseLen; - needed_size += lpcs->dwResultReadStrLen * sizeof(DWORD); - needed_size += lpcs->dwResultClauseLen; - needed_size += lpcs->dwResultStrLen * sizeof(DWORD); - needed_size += lpcs->dwPrivateSize; - } - rc = ImmCreateIMCC(needed_size); - newdata = ImmLockIMCC(rc); - new_one = (LPCOMPOSITIONSTRING)newdata; - - new_one->dwSize = needed_size; - current_offset = sizeof(COMPOSITIONSTRING); - if (lpcs != NULL) - { - current_offset = updateField(lpcs->dwCompReadAttrLen, - lpcs->dwCompReadAttrOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadAttrLen, - &new_one->dwCompReadAttrOffset, FALSE); - - current_offset = updateField(lpcs->dwCompReadClauseLen, - lpcs->dwCompReadClauseOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadClauseLen, - &new_one->dwCompReadClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwCompReadStrLen, - lpcs->dwCompReadStrOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadStrLen, - &new_one->dwCompReadStrOffset, TRUE); - - /* new CompAttr, CompClause, CompStr, dwCursorPos */ - new_one->dwDeltaStart = 0; - - current_offset = updateField(lpcs->dwResultReadClauseLen, - lpcs->dwResultReadClauseOffset, - current_offset, newdata, olddata, - &new_one->dwResultReadClauseLen, - &new_one->dwResultReadClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwResultReadStrLen, - lpcs->dwResultReadStrOffset, - current_offset, newdata, olddata, - &new_one->dwResultReadStrLen, - &new_one->dwResultReadStrOffset, TRUE); - - current_offset = updateField(lpcs->dwResultClauseLen, - lpcs->dwResultClauseOffset, - current_offset, newdata, olddata, - &new_one->dwResultClauseLen, - &new_one->dwResultClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwResultStrLen, - lpcs->dwResultStrOffset, - current_offset, newdata, olddata, - &new_one->dwResultStrLen, - &new_one->dwResultStrOffset, TRUE); - - current_offset = updateField(lpcs->dwPrivateSize, - lpcs->dwPrivateOffset, - current_offset, newdata, olddata, - &new_one->dwPrivateSize, - &new_one->dwPrivateOffset, FALSE); - } - - /* set new data */ - /* CompAttr */ - new_one->dwCompAttrLen = len; - if (len > 0) - { - new_one->dwCompAttrOffset = current_offset; - memset(&newdata[current_offset],ATTR_INPUT,len); - current_offset += len; - } - - /* CompClause */ - if (len > 0) - { - new_one->dwCompClauseLen = sizeof(DWORD) * 2; - new_one->dwCompClauseOffset = current_offset; - *(DWORD*)(&newdata[current_offset]) = 0; - current_offset += sizeof(DWORD); - *(DWORD*)(&newdata[current_offset]) = len; - current_offset += sizeof(DWORD); - } - - /* CompStr */ - new_one->dwCompStrLen = len; - if (len > 0) - { - new_one->dwCompStrOffset = current_offset; - memcpy(&newdata[current_offset],compstr,len*sizeof(WCHAR)); - } - - /* CursorPos */ - new_one->dwCursorPos = len; - - ImmUnlockIMCC(rc); - if (lpcs) - ImmUnlockIMCC(old); - - return rc; -} - -static HIMCC updateResultStr(HIMCC old, LPWSTR resultstr, DWORD len) -{ - /* we need to make sure the ResultStr and ResultClause fields are all - * set and correct */ - int needed_size; - HIMCC rc; - LPBYTE newdata = NULL; - LPBYTE olddata = NULL; - LPCOMPOSITIONSTRING new_one; - LPCOMPOSITIONSTRING lpcs = NULL; - INT current_offset = 0; - - TRACE("%s, %i\n",debugstr_wn(resultstr,len),len); - - if (old == NULL && resultstr == NULL && len == 0) - return NULL; - - if (old != NULL) - { - olddata = ImmLockIMCC(old); - lpcs = (LPCOMPOSITIONSTRING)olddata; - } - - needed_size = sizeof(COMPOSITIONSTRING) + len * sizeof(WCHAR) + - sizeof(DWORD) * 2; - - if (lpcs != NULL) - { - needed_size += lpcs->dwCompReadAttrLen; - needed_size += lpcs->dwCompReadClauseLen; - needed_size += lpcs->dwCompReadStrLen * sizeof(DWORD); - needed_size += lpcs->dwCompAttrLen; - needed_size += lpcs->dwCompClauseLen; - needed_size += lpcs->dwCompStrLen * sizeof(DWORD); - needed_size += lpcs->dwResultReadClauseLen; - needed_size += lpcs->dwResultReadStrLen * sizeof(DWORD); - needed_size += lpcs->dwPrivateSize; - } - rc = ImmCreateIMCC(needed_size); - newdata = ImmLockIMCC(rc); - new_one = (LPCOMPOSITIONSTRING)newdata; - - new_one->dwSize = needed_size; - current_offset = sizeof(COMPOSITIONSTRING); - if (lpcs != NULL) - { - current_offset = updateField(lpcs->dwCompReadAttrLen, - lpcs->dwCompReadAttrOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadAttrLen, - &new_one->dwCompReadAttrOffset, FALSE); - - current_offset = updateField(lpcs->dwCompReadClauseLen, - lpcs->dwCompReadClauseOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadClauseLen, - &new_one->dwCompReadClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwCompReadStrLen, - lpcs->dwCompReadStrOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadStrLen, - &new_one->dwCompReadStrOffset, TRUE); - - current_offset = updateField(lpcs->dwCompAttrLen, - lpcs->dwCompAttrOffset, - current_offset, newdata, olddata, - &new_one->dwCompAttrLen, - &new_one->dwCompAttrOffset, FALSE); - - current_offset = updateField(lpcs->dwCompClauseLen, - lpcs->dwCompClauseOffset, - current_offset, newdata, olddata, - &new_one->dwCompClauseLen, - &new_one->dwCompClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwCompStrLen, - lpcs->dwCompStrOffset, - current_offset, newdata, olddata, - &new_one->dwCompStrLen, - &new_one->dwCompStrOffset, TRUE); - - new_one->dwCursorPos = lpcs->dwCursorPos; - new_one->dwDeltaStart = 0; - - current_offset = updateField(lpcs->dwResultReadClauseLen, - lpcs->dwResultReadClauseOffset, - current_offset, newdata, olddata, - &new_one->dwResultReadClauseLen, - &new_one->dwResultReadClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwResultReadStrLen, - lpcs->dwResultReadStrOffset, - current_offset, newdata, olddata, - &new_one->dwResultReadStrLen, - &new_one->dwResultReadStrOffset, TRUE); - - /* new ResultClause , ResultStr */ - - current_offset = updateField(lpcs->dwPrivateSize, - lpcs->dwPrivateOffset, - current_offset, newdata, olddata, - &new_one->dwPrivateSize, - &new_one->dwPrivateOffset, FALSE); - } - - /* set new data */ - /* ResultClause */ - if (len > 0) - { - new_one->dwResultClauseLen = sizeof(DWORD) * 2; - new_one->dwResultClauseOffset = current_offset; - *(DWORD*)(&newdata[current_offset]) = 0; - current_offset += sizeof(DWORD); - *(DWORD*)(&newdata[current_offset]) = len; - current_offset += sizeof(DWORD); - } - - /* ResultStr */ - new_one->dwResultStrLen = len; - if (len > 0) - { - new_one->dwResultStrOffset = current_offset; - memcpy(&newdata[current_offset],resultstr,len*sizeof(WCHAR)); - } - ImmUnlockIMCC(rc); - if (lpcs) - ImmUnlockIMCC(old); - - return rc; -} - - - /*********************************************************************** * ImmAssociateContext (IMM32.@) */ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) { HIMC old = NULL; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p):\n", hWnd, hIMC); - /* - * WINE SPECIFIC! MAY CONFLICT - * associate the root context we have an XIM created - */ - if (hWnd == 0x000) - { - root_context = (InputContextData*)hIMC; - } + if (!IMM_GetThreadData()->defaultContext) + IMM_GetThreadData()->defaultContext = ImmCreateContext(); /* * If already associated just return @@ -646,19 +453,26 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) if (hWnd) { - old = (HIMC)RemovePropW(hWnd,szwWineIMCProperty); + old = RemovePropW(hWnd,szwWineIMCProperty); if (old == NULL) - old = (HIMC)root_context; + old = IMM_GetThreadData()->defaultContext; else if (old == (HIMC)-1) old = NULL; - if (hIMC != (HIMC)root_context) + if (hIMC != IMM_GetThreadData()->defaultContext) { if (hIMC == NULL) /* Meaning disable imm for that window*/ SetPropW(hWnd,szwWineIMCProperty,(HANDLE)-1); else - SetPropW(hWnd,szwWineIMCProperty,(HANDLE)hIMC); + SetPropW(hWnd,szwWineIMCProperty,hIMC); + } + + if (old) + { + InputContextData *old_data = old; + if (old_data->IMC.hWnd == hWnd) + old_data->IMC.hWnd = NULL; } } @@ -686,14 +500,48 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) return old; } + +/* + * Helper function for ImmAssociateContextEx + */ +static BOOL CALLBACK _ImmAssociateContextExEnumProc(HWND hwnd, LPARAM lParam) +{ + HIMC hImc = (HIMC)lParam; + ImmAssociateContext(hwnd,hImc); + return TRUE; +} + /*********************************************************************** * ImmAssociateContextEx (IMM32.@) */ BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags) { - FIXME("(%p, %p, %d): stub\n", hWnd, hIMC, dwFlags); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + TRACE("(%p, %p, %d): stub\n", hWnd, hIMC, dwFlags); + + if (!IMM_GetThreadData()->defaultContext) + IMM_GetThreadData()->defaultContext = ImmCreateContext(); + + if (dwFlags == IACE_DEFAULT) + { + ImmAssociateContext(hWnd,IMM_GetThreadData()->defaultContext); + return TRUE; + } + else if (dwFlags == IACE_IGNORENOCONTEXT) + { + if (GetPropW(hWnd,szwWineIMCProperty)) + ImmAssociateContext(hWnd,hIMC); + return TRUE; + } + else if (dwFlags == IACE_CHILDREN) + { + EnumChildWindows(hWnd,_ImmAssociateContextExEnumProc,(LPARAM)hIMC); + return TRUE; + } + else + { + ERR("Unknown dwFlags 0x%x\n",dwFlags); + return FALSE; + } } /*********************************************************************** @@ -702,11 +550,33 @@ BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags) BOOL WINAPI ImmConfigureIMEA( HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData) { - FIXME("(%p, %p, %d, %p): stub\n", - hKL, hWnd, dwMode, lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + + TRACE("(%p, %p, %d, %p):\n", hKL, hWnd, dwMode, lpData); + + if (dwMode == IME_CONFIG_REGISTERWORD && !lpData) + return FALSE; + + if (immHkl->hIME && immHkl->pImeConfigure) + { + if (dwMode != IME_CONFIG_REGISTERWORD || !is_kbd_ime_unicode(immHkl)) + return immHkl->pImeConfigure(hKL,hWnd,dwMode,lpData); + else + { + REGISTERWORDW rww; + REGISTERWORDA *rwa = lpData; + BOOL rc; + + rww.lpReading = strdupAtoW(rwa->lpReading); + rww.lpWord = strdupAtoW(rwa->lpWord); + rc = immHkl->pImeConfigure(hKL,hWnd,dwMode,&rww); + HeapFree(GetProcessHeap(),0,rww.lpReading); + HeapFree(GetProcessHeap(),0,rww.lpWord); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -715,11 +585,33 @@ BOOL WINAPI ImmConfigureIMEA( BOOL WINAPI ImmConfigureIMEW( HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData) { - FIXME("(%p, %p, %d, %p): stub\n", - hKL, hWnd, dwMode, lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + + TRACE("(%p, %p, %d, %p):\n", hKL, hWnd, dwMode, lpData); + + if (dwMode == IME_CONFIG_REGISTERWORD && !lpData) + return FALSE; + + if (immHkl->hIME && immHkl->pImeConfigure) + { + if (dwMode != IME_CONFIG_REGISTERWORD || is_kbd_ime_unicode(immHkl)) + return immHkl->pImeConfigure(hKL,hWnd,dwMode,lpData); + else + { + REGISTERWORDW *rww = lpData; + REGISTERWORDA rwa; + BOOL rc; + + rwa.lpReading = strdupWtoA(rww->lpReading); + rwa.lpWord = strdupWtoA(rww->lpWord); + rc = immHkl->pImeConfigure(hKL,hWnd,dwMode,&rwa); + HeapFree(GetProcessHeap(),0,rwa.lpReading); + HeapFree(GetProcessHeap(),0,rwa.lpWord); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -728,54 +620,67 @@ BOOL WINAPI ImmConfigureIMEW( HIMC WINAPI ImmCreateContext(void) { InputContextData *new_context; + LPGUIDELINE gl; + LPCANDIDATEINFO ci; new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData)); /* Load the IME */ new_context->immKbd = IMM_GetImmHkl(GetKeyboardLayout(0)); - /* - * Once we depend on the IME for all the processing like we should - * these will become hard errors and result in creation failures - */ if (!new_context->immKbd->hIME) + { TRACE("IME dll could not be loaded\n"); + HeapFree(GetProcessHeap(),0,new_context); + return 0; + } - /* hCompStr is never NULL */ + /* the HIMCCs are never NULL */ new_context->IMC.hCompStr = ImmCreateBlankCompStr(); - new_context->IMC.hMsgBuf = ImmCreateIMCC(1); + new_context->IMC.hMsgBuf = ImmCreateIMCC(0); + new_context->IMC.hCandInfo = ImmCreateIMCC(sizeof(CANDIDATEINFO)); + ci = ImmLockIMCC(new_context->IMC.hCandInfo); + memset(ci,0,sizeof(CANDIDATEINFO)); + ci->dwSize = sizeof(CANDIDATEINFO); + ImmUnlockIMCC(new_context->IMC.hCandInfo); + new_context->IMC.hGuideLine = ImmCreateIMCC(sizeof(GUIDELINE)); + gl = ImmLockIMCC(new_context->IMC.hGuideLine); + memset(gl,0,sizeof(GUIDELINE)); + gl->dwSize = sizeof(GUIDELINE); + ImmUnlockIMCC(new_context->IMC.hGuideLine); /* Initialize the IME Private */ new_context->IMC.hPrivate = ImmCreateIMCC(new_context->immKbd->imeInfo.dwPrivateDataSize); - if (new_context->immKbd->hIME && - !new_context->immKbd->pImeSelect(new_context, TRUE)) + if (!new_context->immKbd->pImeSelect(new_context, TRUE)) { TRACE("Selection of IME failed\n"); - ImmDestroyContext(new_context); + IMM_DestroyContext(new_context); return 0; } + SendMessageW(GetFocus(), WM_IME_SELECT, TRUE, (LPARAM)GetKeyboardLayout(0)); new_context->immKbd->uSelected++; - TRACE("Created context 0x%x\n",(UINT)new_context); + TRACE("Created context %p\n",new_context); - return (HIMC)new_context; + return new_context; } -/*********************************************************************** - * ImmDestroyContext (IMM32.@) - */ -BOOL WINAPI ImmDestroyContext(HIMC hIMC) +static BOOL IMM_DestroyContext(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("Destroying %p\n",hIMC); if (hIMC) { data->immKbd->uSelected --; - if (data->immKbd->hIME) - data->immKbd->pImeSelect(hIMC, FALSE); + data->immKbd->pImeSelect(hIMC, FALSE); + SendMessageW(data->IMC.hWnd, WM_IME_SELECT, FALSE, (LPARAM)GetKeyboardLayout(0)); + + if (IMM_GetThreadData()->hwndDefault == data->imeWnd) + IMM_GetThreadData()->hwndDefault = NULL; + DestroyWindow(data->imeWnd); ImmDestroyIMCC(data->IMC.hCompStr); ImmDestroyIMCC(data->IMC.hCandInfo); @@ -783,17 +688,22 @@ BOOL WINAPI ImmDestroyContext(HIMC hIMC) ImmDestroyIMCC(data->IMC.hPrivate); ImmDestroyIMCC(data->IMC.hMsgBuf); - if (data->textfont) - { - DeleteObject(data->textfont); - data->textfont = NULL; - } - HeapFree(GetProcessHeap(),0,data); } return TRUE; } +/*********************************************************************** + * ImmDestroyContext (IMM32.@) + */ +BOOL WINAPI ImmDestroyContext(HIMC hIMC) +{ + if (hIMC != IMM_GetThreadData()->defaultContext) + return IMM_DestroyContext(hIMC); + else + return FALSE; +} + /*********************************************************************** * ImmDisableIME (IMM32.@) */ @@ -811,13 +721,31 @@ UINT WINAPI ImmEnumRegisterWordA( LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszRegister, LPVOID lpData) { - FIXME("(%p, %p, %s, %d, %s, %p): stub\n", - hKL, lpfnEnumProc, - debugstr_a(lpszReading), dwStyle, - debugstr_a(lpszRegister), lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %s, %d, %s, %p):\n", hKL, lpfnEnumProc, + debugstr_a(lpszReading), dwStyle, debugstr_a(lpszRegister), lpData); + if (immHkl->hIME && immHkl->pImeEnumRegisterWord) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeEnumRegisterWord((REGISTERWORDENUMPROCW)lpfnEnumProc, + (LPCWSTR)lpszReading, dwStyle, (LPCWSTR)lpszRegister, lpData); + else + { + LPWSTR lpszwReading = strdupAtoW(lpszReading); + LPWSTR lpszwRegister = strdupAtoW(lpszRegister); + BOOL rc; + + rc = immHkl->pImeEnumRegisterWord((REGISTERWORDENUMPROCW)lpfnEnumProc, + lpszwReading, dwStyle, lpszwRegister, + lpData); + + HeapFree(GetProcessHeap(),0,lpszwReading); + HeapFree(GetProcessHeap(),0,lpszwRegister); + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -828,13 +756,40 @@ UINT WINAPI ImmEnumRegisterWordW( LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszRegister, LPVOID lpData) { - FIXME("(%p, %p, %s, %d, %s, %p): stub\n", - hKL, lpfnEnumProc, - debugstr_w(lpszReading), dwStyle, - debugstr_w(lpszRegister), lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %s, %d, %s, %p):\n", hKL, lpfnEnumProc, + debugstr_w(lpszReading), dwStyle, debugstr_w(lpszRegister), lpData); + if (immHkl->hIME && immHkl->pImeEnumRegisterWord) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeEnumRegisterWord(lpfnEnumProc, lpszReading, dwStyle, + lpszRegister, lpData); + else + { + LPSTR lpszaReading = strdupWtoA(lpszReading); + LPSTR lpszaRegister = strdupWtoA(lpszRegister); + BOOL rc; + + rc = immHkl->pImeEnumRegisterWord(lpfnEnumProc, (LPCWSTR)lpszaReading, + dwStyle, (LPCWSTR)lpszaRegister, lpData); + + HeapFree(GetProcessHeap(),0,lpszaReading); + HeapFree(GetProcessHeap(),0,lpszaRegister); + return rc; + } + } + else + return 0; +} + +static inline BOOL EscapeRequiresWA(UINT uEscape) +{ + if (uEscape == IME_ESC_GET_EUDC_DICTIONARY || + uEscape == IME_ESC_SET_EUDC_DICTIONARY || + uEscape == IME_ESC_IME_NAME || + uEscape == IME_ESC_GETHELPFILENAME) + return TRUE; + return FALSE; } /*********************************************************************** @@ -844,11 +799,32 @@ LRESULT WINAPI ImmEscapeA( HKL hKL, HIMC hIMC, UINT uEscape, LPVOID lpData) { - FIXME("(%p, %p, %d, %p): stub\n", - hKL, hIMC, uEscape, lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %d, %p):\n", hKL, hIMC, uEscape, lpData); + + if (immHkl->hIME && immHkl->pImeEscape) + { + if (!EscapeRequiresWA(uEscape) || !is_kbd_ime_unicode(immHkl)) + return immHkl->pImeEscape(hIMC,uEscape,lpData); + else + { + WCHAR buffer[81]; /* largest required buffer should be 80 */ + LRESULT rc; + if (uEscape == IME_ESC_SET_EUDC_DICTIONARY) + { + MultiByteToWideChar(CP_ACP,0,lpData,-1,buffer,81); + rc = immHkl->pImeEscape(hIMC,uEscape,buffer); + } + else + { + rc = immHkl->pImeEscape(hIMC,uEscape,buffer); + WideCharToMultiByte(CP_ACP,0,buffer,-1,lpData,80, NULL, NULL); + } + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -858,26 +834,72 @@ LRESULT WINAPI ImmEscapeW( HKL hKL, HIMC hIMC, UINT uEscape, LPVOID lpData) { - FIXME("(%p, %p, %d, %p): stub\n", - hKL, hIMC, uEscape, lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %d, %p):\n", hKL, hIMC, uEscape, lpData); + + if (immHkl->hIME && immHkl->pImeEscape) + { + if (!EscapeRequiresWA(uEscape) || is_kbd_ime_unicode(immHkl)) + return immHkl->pImeEscape(hIMC,uEscape,lpData); + else + { + CHAR buffer[81]; /* largest required buffer should be 80 */ + LRESULT rc; + if (uEscape == IME_ESC_SET_EUDC_DICTIONARY) + { + WideCharToMultiByte(CP_ACP,0,lpData,-1,buffer,81, NULL, NULL); + rc = immHkl->pImeEscape(hIMC,uEscape,buffer); + } + else + { + rc = immHkl->pImeEscape(hIMC,uEscape,buffer); + MultiByteToWideChar(CP_ACP,0,buffer,-1,lpData,80); + } + return rc; + } + } + else + return 0; } /*********************************************************************** * ImmGetCandidateListA (IMM32.@) */ DWORD WINAPI ImmGetCandidateListA( - HIMC hIMC, DWORD deIndex, + HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen) { - FIXME("(%p, %d, %p, %d): stub\n", - hIMC, deIndex, - lpCandList, dwBufLen - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + InputContextData *data = hIMC; + LPCANDIDATEINFO candinfo; + LPCANDIDATELIST candlist; + DWORD ret = 0; + + TRACE("%p, %d, %p, %d\n", hIMC, dwIndex, lpCandList, dwBufLen); + + if (!data || !data->IMC.hCandInfo) + return 0; + + candinfo = ImmLockIMCC(data->IMC.hCandInfo); + if ( dwIndex >= candinfo->dwCount || + dwIndex >= (sizeof(candinfo->dwOffset) / sizeof(DWORD)) ) + goto done; + + candlist = (LPCANDIDATELIST)((LPBYTE)candinfo + candinfo->dwOffset[dwIndex]); + if ( !candlist->dwSize || !candlist->dwCount ) + goto done; + + if ( !is_himc_ime_unicode(data) ) + { + ret = candlist->dwSize; + if ( lpCandList && dwBufLen >= ret ) + memcpy(lpCandList, candlist, ret); + } + else + ret = convert_candidatelist_WtoA( candlist, lpCandList, dwBufLen); + +done: + ImmUnlockIMCC(data->IMC.hCandInfo); + return ret; } /*********************************************************************** @@ -886,9 +908,30 @@ DWORD WINAPI ImmGetCandidateListA( DWORD WINAPI ImmGetCandidateListCountA( HIMC hIMC, LPDWORD lpdwListCount) { - FIXME("(%p, %p): stub\n", hIMC, lpdwListCount); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + InputContextData *data = hIMC; + LPCANDIDATEINFO candinfo; + DWORD ret, count; + + TRACE("%p, %p\n", hIMC, lpdwListCount); + + if (!data || !lpdwListCount || !data->IMC.hCandInfo) + return 0; + + candinfo = ImmLockIMCC(data->IMC.hCandInfo); + + *lpdwListCount = count = candinfo->dwCount; + + if ( !is_himc_ime_unicode(data) ) + ret = candinfo->dwSize; + else + { + ret = sizeof(CANDIDATEINFO); + while ( count-- ) + ret += ImmGetCandidateListA(hIMC, count, NULL, 0); + } + + ImmUnlockIMCC(data->IMC.hCandInfo); + return ret; } /*********************************************************************** @@ -897,35 +940,91 @@ DWORD WINAPI ImmGetCandidateListCountA( DWORD WINAPI ImmGetCandidateListCountW( HIMC hIMC, LPDWORD lpdwListCount) { - FIXME("(%p, %p): stub\n", hIMC, lpdwListCount); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + InputContextData *data = hIMC; + LPCANDIDATEINFO candinfo; + DWORD ret, count; + + TRACE("%p, %p\n", hIMC, lpdwListCount); + + if (!data || !lpdwListCount || !data->IMC.hCandInfo) + return 0; + + candinfo = ImmLockIMCC(data->IMC.hCandInfo); + + *lpdwListCount = count = candinfo->dwCount; + + if ( is_himc_ime_unicode(data) ) + ret = candinfo->dwSize; + else + { + ret = sizeof(CANDIDATEINFO); + while ( count-- ) + ret += ImmGetCandidateListW(hIMC, count, NULL, 0); + } + + ImmUnlockIMCC(data->IMC.hCandInfo); + return ret; } /*********************************************************************** * ImmGetCandidateListW (IMM32.@) */ DWORD WINAPI ImmGetCandidateListW( - HIMC hIMC, DWORD deIndex, + HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen) { - FIXME("(%p, %d, %p, %d): stub\n", - hIMC, deIndex, - lpCandList, dwBufLen - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + InputContextData *data = hIMC; + LPCANDIDATEINFO candinfo; + LPCANDIDATELIST candlist; + DWORD ret = 0; + + TRACE("%p, %d, %p, %d\n", hIMC, dwIndex, lpCandList, dwBufLen); + + if (!data || !data->IMC.hCandInfo) + return 0; + + candinfo = ImmLockIMCC(data->IMC.hCandInfo); + if ( dwIndex >= candinfo->dwCount || + dwIndex >= (sizeof(candinfo->dwOffset) / sizeof(DWORD)) ) + goto done; + + candlist = (LPCANDIDATELIST)((LPBYTE)candinfo + candinfo->dwOffset[dwIndex]); + if ( !candlist->dwSize || !candlist->dwCount ) + goto done; + + if ( is_himc_ime_unicode(data) ) + { + ret = candlist->dwSize; + if ( lpCandList && dwBufLen >= ret ) + memcpy(lpCandList, candlist, ret); + } + else + ret = convert_candidatelist_AtoW( candlist, lpCandList, dwBufLen); + +done: + ImmUnlockIMCC(data->IMC.hCandInfo); + return ret; } /*********************************************************************** * ImmGetCandidateWindow (IMM32.@) */ BOOL WINAPI ImmGetCandidateWindow( - HIMC hIMC, DWORD dwBufLen, LPCANDIDATEFORM lpCandidate) + HIMC hIMC, DWORD dwIndex, LPCANDIDATEFORM lpCandidate) { - FIXME("(%p, %d, %p): stub\n", hIMC, dwBufLen, lpCandidate); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + InputContextData *data = hIMC; + + TRACE("%p, %d, %p\n", hIMC, dwIndex, lpCandidate); + + if (!data || !lpCandidate) + return FALSE; + + if ( dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) ) + return FALSE; + + *lpCandidate = data->IMC.cfCandForm[dwIndex]; + + return TRUE; } /*********************************************************************** @@ -939,13 +1038,13 @@ BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) TRACE("(%p, %p):\n", hIMC, lplf); rc = ImmGetCompositionFontW(hIMC,&lfW); - if (rc) - { - memcpy(lplf,&lfW,sizeof(LOGFONTA)); - WideCharToMultiByte(CP_ACP, 0, lfW.lfFaceName, -1, lplf->lfFaceName, + if (!rc || !lplf) + return FALSE; + + memcpy(lplf,&lfW,sizeof(LOGFONTA)); + WideCharToMultiByte(CP_ACP, 0, lfW.lfFaceName, -1, lplf->lfFaceName, LF_FACESIZE, NULL, NULL); - } - return rc; + return TRUE; } /*********************************************************************** @@ -953,11 +1052,11 @@ BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) */ BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p):\n", hIMC, lplf); - if (!data) + if (!data || !lplf) return FALSE; *lplf = data->IMC.lfFont.W; @@ -965,112 +1064,270 @@ BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) return TRUE; } + +/* Helpers for the GetCompositionString functions */ + +static INT CopyCompStringIMEtoClient(InputContextData *data, LPBYTE source, INT slen, LPBYTE target, INT tlen, + BOOL unicode ) +{ + INT rc; + + if (is_himc_ime_unicode(data) && !unicode) + rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)source, slen, (LPSTR)target, tlen, NULL, NULL); + else if (!is_himc_ime_unicode(data) && unicode) + rc = MultiByteToWideChar(CP_ACP, 0, (LPSTR)source, slen, (LPWSTR)target, tlen) * sizeof(WCHAR); + else + { + int dlen = (unicode)?sizeof(WCHAR):sizeof(CHAR); + memcpy( target, source, min(slen,tlen)*dlen); + rc = slen*dlen; + } + + return rc; +} + +static INT CopyCompAttrIMEtoClient(InputContextData *data, LPBYTE source, INT slen, LPBYTE ssource, INT sslen, + LPBYTE target, INT tlen, BOOL unicode ) +{ + INT rc; + + if (is_himc_ime_unicode(data) && !unicode) + { + rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)ssource, sslen, NULL, 0, NULL, NULL); + if (tlen) + { + const BYTE *src = source; + LPBYTE dst = target; + int i, j = 0, k = 0; + + if (rc < tlen) + tlen = rc; + for (i = 0; i < sslen; ++i) + { + int len; + + len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)ssource + i, 1, + NULL, 0, NULL, NULL); + for (; len > 0; --len) + { + dst[j++] = src[k]; + + if (j >= tlen) + goto end; + } + ++k; + } + end: + rc = j; + } + } + else if (!is_himc_ime_unicode(data) && unicode) + { + rc = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ssource, sslen, NULL, 0); + if (tlen) + { + const BYTE *src = source; + LPBYTE dst = target; + int i, j = 0; + + if (rc < tlen) + tlen = rc; + for (i = 0; i < sslen; ++i) + { + if (IsDBCSLeadByte(((LPSTR)ssource)[i])) + continue; + + dst[j++] = src[i]; + + if (j >= tlen) + break; + } + rc = j; + } + } + else + { + memcpy( target, source, min(slen,tlen)); + rc = slen; + } + + return rc; +} + +static INT CopyCompClauseIMEtoClient(InputContextData *data, LPBYTE source, INT slen, LPBYTE ssource, INT sslen, + LPBYTE target, INT tlen, BOOL unicode ) +{ + INT rc; + + if (is_himc_ime_unicode(data) && !unicode) + { + if (tlen) + { + int i; + + if (slen < tlen) + tlen = slen; + tlen /= sizeof (DWORD); + for (i = 0; i < tlen; ++i) + { + ((DWORD *)target)[i] = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)ssource, + ((DWORD *)source)[i], + NULL, 0, + NULL, NULL); + } + rc = sizeof (DWORD) * i; + } + else + rc = slen; + } + else if (!is_himc_ime_unicode(data) && unicode) + { + if (tlen) + { + int i; + + if (slen < tlen) + tlen = slen; + tlen /= sizeof (DWORD); + for (i = 0; i < tlen; ++i) + { + ((DWORD *)target)[i] = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ssource, + ((DWORD *)source)[i], + NULL, 0); + } + rc = sizeof (DWORD) * i; + } + else + rc = slen; + } + else + { + memcpy( target, source, min(slen,tlen)); + rc = slen; + } + + return rc; +} + +static INT CopyCompOffsetIMEtoClient(InputContextData *data, DWORD offset, LPBYTE ssource, BOOL unicode) +{ + int rc; + + if (is_himc_ime_unicode(data) && !unicode) + { + rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)ssource, offset, NULL, 0, NULL, NULL); + } + else if (!is_himc_ime_unicode(data) && unicode) + { + rc = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ssource, offset, NULL, 0); + } + else + rc = offset; + + return rc; +} + +static LONG ImmGetCompositionStringT( HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, + DWORD dwBufLen, BOOL unicode) +{ + LONG rc = 0; + InputContextData *data = hIMC; + LPCOMPOSITIONSTRING compstr; + LPBYTE compdata; + + TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen); + + if (!data) + return FALSE; + + if (!data->IMC.hCompStr) + return FALSE; + + compdata = ImmLockIMCC(data->IMC.hCompStr); + compstr = (LPCOMPOSITIONSTRING)compdata; + + switch (dwIndex) + { + case GCS_RESULTSTR: + TRACE("GCS_RESULTSTR\n"); + rc = CopyCompStringIMEtoClient(data, compdata + compstr->dwResultStrOffset, compstr->dwResultStrLen, lpBuf, dwBufLen, unicode); + break; + case GCS_COMPSTR: + TRACE("GCS_COMPSTR\n"); + rc = CopyCompStringIMEtoClient(data, compdata + compstr->dwCompStrOffset, compstr->dwCompStrLen, lpBuf, dwBufLen, unicode); + break; + case GCS_COMPATTR: + TRACE("GCS_COMPATTR\n"); + rc = CopyCompAttrIMEtoClient(data, compdata + compstr->dwCompAttrOffset, compstr->dwCompAttrLen, + compdata + compstr->dwCompStrOffset, compstr->dwCompStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_COMPCLAUSE: + TRACE("GCS_COMPCLAUSE\n"); + rc = CopyCompClauseIMEtoClient(data, compdata + compstr->dwCompClauseOffset,compstr->dwCompClauseLen, + compdata + compstr->dwCompStrOffset, compstr->dwCompStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_RESULTCLAUSE: + TRACE("GCS_RESULTCLAUSE\n"); + rc = CopyCompClauseIMEtoClient(data, compdata + compstr->dwResultClauseOffset,compstr->dwResultClauseLen, + compdata + compstr->dwResultStrOffset, compstr->dwResultStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_RESULTREADSTR: + TRACE("GCS_RESULTREADSTR\n"); + rc = CopyCompStringIMEtoClient(data, compdata + compstr->dwResultReadStrOffset, compstr->dwResultReadStrLen, lpBuf, dwBufLen, unicode); + break; + case GCS_RESULTREADCLAUSE: + TRACE("GCS_RESULTREADCLAUSE\n"); + rc = CopyCompClauseIMEtoClient(data, compdata + compstr->dwResultReadClauseOffset,compstr->dwResultReadClauseLen, + compdata + compstr->dwResultStrOffset, compstr->dwResultStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_COMPREADSTR: + TRACE("GCS_COMPREADSTR\n"); + rc = CopyCompStringIMEtoClient(data, compdata + compstr->dwCompReadStrOffset, compstr->dwCompReadStrLen, lpBuf, dwBufLen, unicode); + break; + case GCS_COMPREADATTR: + TRACE("GCS_COMPREADATTR\n"); + rc = CopyCompAttrIMEtoClient(data, compdata + compstr->dwCompReadAttrOffset, compstr->dwCompReadAttrLen, + compdata + compstr->dwCompReadStrOffset, compstr->dwCompReadStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_COMPREADCLAUSE: + TRACE("GCS_COMPREADCLAUSE\n"); + rc = CopyCompClauseIMEtoClient(data, compdata + compstr->dwCompReadClauseOffset,compstr->dwCompReadClauseLen, + compdata + compstr->dwCompStrOffset, compstr->dwCompStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_CURSORPOS: + TRACE("GCS_CURSORPOS\n"); + rc = CopyCompOffsetIMEtoClient(data, compstr->dwCursorPos, compdata + compstr->dwCompStrOffset, unicode); + break; + case GCS_DELTASTART: + TRACE("GCS_DELTASTART\n"); + rc = CopyCompOffsetIMEtoClient(data, compstr->dwDeltaStart, compdata + compstr->dwCompStrOffset, unicode); + break; + default: + FIXME("Unhandled index 0x%x\n",dwIndex); + break; + } + + ImmUnlockIMCC(data->IMC.hCompStr); + + return rc; +} + /*********************************************************************** * ImmGetCompositionStringA (IMM32.@) */ LONG WINAPI ImmGetCompositionStringA( HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen) { - CHAR *buf; - LONG rc = 0; - InputContextData *data = (InputContextData*)hIMC; - LPCOMPOSITIONSTRING compstr; - LPBYTE compdata; - - TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen); - - if (!data) - return FALSE; - - if (!data->IMC.hCompStr) - return FALSE; - - compdata = ImmLockIMCC(data->IMC.hCompStr); - compstr = (LPCOMPOSITIONSTRING)compdata; - - if (dwIndex == GCS_RESULTSTR && compstr->dwResultStrLen > 0 && - compstr->dwResultStrOffset > 0) - { - LPWSTR ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset); - - TRACE("GSC_RESULTSTR %p %i\n",ResultStr, - compstr->dwResultStrLen); - - buf = HeapAlloc( GetProcessHeap(), 0, compstr->dwResultStrLen * 3 ); - rc = WideCharToMultiByte(CP_ACP, 0, ResultStr, - compstr->dwResultStrLen , buf, - compstr->dwResultStrLen * 3, NULL, NULL); - if (dwBufLen >= rc) - memcpy(lpBuf,buf,rc); - - data->bRead = TRUE; - HeapFree( GetProcessHeap(), 0, buf ); - } - else if (dwIndex == GCS_COMPSTR && compstr->dwCompStrLen > 0 && - compstr->dwCompStrOffset > 0) - { - LPWSTR CompString = (LPWSTR)(compdata + compstr->dwCompStrOffset); - - TRACE("GSC_COMPSTR %p %i\n", CompString, compstr->dwCompStrLen); - - buf = HeapAlloc( GetProcessHeap(), 0, compstr->dwCompStrLen * 3 ); - rc = WideCharToMultiByte(CP_ACP, 0, CompString, - compstr->dwCompStrLen, buf, - compstr->dwCompStrLen * 3, NULL, NULL); - if (dwBufLen >= rc) - memcpy(lpBuf,buf,rc); - HeapFree( GetProcessHeap(), 0, buf ); - } - else if (dwIndex == GCS_COMPATTR && compstr->dwCompAttrLen > 0 && - compstr->dwCompAttrOffset > 0) - { - LPWSTR Compattr = (LPWSTR)(compdata + compstr->dwCompAttrOffset); - TRACE("GSC_COMPATTR %p %i\n", Compattr , compstr->dwCompAttrLen); - - rc = compstr->dwCompAttrLen; - if (dwBufLen >= rc) - memcpy(lpBuf,Compattr,rc); - } - else if (dwIndex == GCS_COMPCLAUSE && compstr->dwCompClauseLen > 0 && - compstr->dwCompClauseOffset > 0) - { - LPWSTR Compclause = (LPWSTR)(compdata + compstr->dwCompClauseOffset); - TRACE("GSC_COMPCLAUSE %p %i\n", Compclause, compstr->dwCompClauseLen); - - rc = compstr->dwCompClauseLen; - if (dwBufLen >= compstr->dwCompClauseLen) - memcpy(lpBuf,Compclause,rc); - } - else if (dwIndex == GCS_RESULTCLAUSE && compstr->dwResultClauseLen > 0 && - compstr->dwResultClauseOffset > 0) - { - LPWSTR Resultclause = (LPWSTR)(compdata + compstr->dwResultClauseOffset); - TRACE("GSC_RESULTCLAUSE %p %i\n", Resultclause, compstr->dwResultClauseLen); - - rc = compstr->dwResultClauseLen; - if (dwBufLen >= compstr->dwResultClauseLen) - memcpy(lpBuf,Resultclause,rc); - } - else if (dwIndex == GCS_CURSORPOS) - { - TRACE("GSC_CURSORPOS\n"); - rc = compstr->dwCursorPos; - } - else if (dwIndex == GCS_DELTASTART) - { - TRACE("GCS_DELTASTART\n"); - rc = compstr->dwDeltaStart; - } - else - { - FIXME("Unhandled index 0x%x\n",dwIndex); - } - - ImmUnlockIMCC(data->IMC.hCompStr); - - return rc; + return ImmGetCompositionStringT(hIMC, dwIndex, lpBuf, dwBufLen, FALSE); } + /*********************************************************************** * ImmGetCompositionStringW (IMM32.@) */ @@ -1078,96 +1335,7 @@ LONG WINAPI ImmGetCompositionStringW( HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen) { - LONG rc = 0; - InputContextData *data = (InputContextData*)hIMC; - LPCOMPOSITIONSTRING compstr; - LPBYTE compdata; - - TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen); - - if (!data) - return FALSE; - - if (!data->IMC.hCompStr) - return FALSE; - - compdata = ImmLockIMCC(data->IMC.hCompStr); - compstr = (LPCOMPOSITIONSTRING)compdata; - - if (dwIndex == GCS_RESULTSTR && compstr->dwResultStrLen > 0 && - compstr->dwResultStrOffset > 0) - { - LPWSTR ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset); - data->bRead = TRUE; - rc = compstr->dwResultStrLen * sizeof(WCHAR); - - if (dwBufLen >= rc) - memcpy(lpBuf,ResultStr,rc); - } - else if (dwIndex == GCS_RESULTREADSTR && compstr->dwResultReadStrLen > 0 && - compstr->dwResultReadStrOffset > 0) - { - LPWSTR ResultReadString = (LPWSTR)(compdata + compstr->dwResultReadStrOffset); - - rc = compstr->dwResultReadStrLen * sizeof(WCHAR); - if (dwBufLen >= rc) - memcpy(lpBuf,ResultReadString,rc); - } - else if (dwIndex == GCS_COMPSTR && compstr->dwCompStrLen > 0 && - compstr->dwCompStrOffset > 0) - { - LPWSTR CompString = (LPWSTR)(compdata + compstr->dwCompStrOffset); - rc = compstr->dwCompStrLen * sizeof(WCHAR); - if (dwBufLen >= rc) - memcpy(lpBuf,CompString,rc); - } - else if (dwIndex == GCS_COMPATTR && compstr->dwCompAttrLen > 0 && - compstr->dwCompAttrOffset > 0) - { - - LPWSTR Compattr = (LPWSTR)(compdata + compstr->dwCompAttrOffset); - - rc = compstr->dwCompAttrLen; - if (dwBufLen >= rc) - memcpy(lpBuf,Compattr,rc); - } - else if (dwIndex == GCS_COMPCLAUSE && compstr->dwCompClauseLen > 0 && - compstr->dwCompClauseOffset > 0) - { - LPWSTR Compclause = (LPWSTR)(compdata + compstr->dwCompClauseOffset); - - rc = compstr->dwCompClauseLen; - if (dwBufLen >= compstr->dwCompClauseLen) - memcpy(lpBuf,Compclause,rc); - } - else if (dwIndex == GCS_COMPREADSTR && compstr->dwCompReadStrLen > 0 && - compstr->dwCompReadStrOffset > 0) - { - LPWSTR CompReadString = (LPWSTR)(compdata + compstr->dwCompReadStrOffset); - - rc = compstr->dwCompReadStrLen * sizeof(WCHAR); - - if (dwBufLen >= rc) - memcpy(lpBuf,CompReadString,rc); - } - else if (dwIndex == GCS_CURSORPOS) - { - TRACE("GSC_CURSORPOS\n"); - rc = compstr->dwCursorPos; - } - else if (dwIndex == GCS_DELTASTART) - { - TRACE("GCS_DELTASTART\n"); - rc = compstr->dwDeltaStart; - } - else - { - FIXME("Unhandled index 0x%x\n",dwIndex); - } - - ImmUnlockIMCC(data->IMC.hCompStr); - - return rc; + return ImmGetCompositionStringT(hIMC, dwIndex, lpBuf, dwBufLen, TRUE); } /*********************************************************************** @@ -1175,7 +1343,7 @@ LONG WINAPI ImmGetCompositionStringW( */ BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpCompForm); @@ -1195,16 +1363,18 @@ HIMC WINAPI ImmGetContext(HWND hWnd) HIMC rc = NULL; TRACE("%p\n", hWnd); + if (!IMM_GetThreadData()->defaultContext) + IMM_GetThreadData()->defaultContext = ImmCreateContext(); - rc = (HIMC)GetPropW(hWnd,szwWineIMCProperty); + rc = GetPropW(hWnd,szwWineIMCProperty); if (rc == (HIMC)-1) rc = NULL; else if (rc == NULL) - rc = (HIMC)root_context; + rc = IMM_GetThreadData()->defaultContext; if (rc) { - InputContextData *data = (InputContextData*)rc; + InputContextData *data = rc; data->IMC.hWnd = hWnd; } TRACE("returning %p\n", rc); @@ -1220,11 +1390,34 @@ DWORD WINAPI ImmGetConversionListA( LPCSTR pSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen, UINT uFlag) { - FIXME("(%p, %p, %s, %p, %d, %d): stub\n", - hKL, hIMC, debugstr_a(pSrc), lpDst, dwBufLen, uFlag - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %s, %p, %d, %d):\n", hKL, hIMC, debugstr_a(pSrc), lpDst, + dwBufLen, uFlag); + if (immHkl->hIME && immHkl->pImeConversionList) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeConversionList(hIMC,(LPCWSTR)pSrc,lpDst,dwBufLen,uFlag); + else + { + LPCANDIDATELIST lpwDst; + DWORD ret = 0, len; + LPWSTR pwSrc = strdupAtoW(pSrc); + + len = immHkl->pImeConversionList(hIMC, pwSrc, NULL, 0, uFlag); + lpwDst = HeapAlloc(GetProcessHeap(), 0, len); + if ( lpwDst ) + { + immHkl->pImeConversionList(hIMC, pwSrc, lpwDst, len, uFlag); + ret = convert_candidatelist_WtoA( lpwDst, lpDst, dwBufLen); + HeapFree(GetProcessHeap(), 0, lpwDst); + } + HeapFree(GetProcessHeap(), 0, pwSrc); + + return ret; + } + } + else + return 0; } /*********************************************************************** @@ -1235,11 +1428,34 @@ DWORD WINAPI ImmGetConversionListW( LPCWSTR pSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen, UINT uFlag) { - FIXME("(%p, %p, %s, %p, %d, %d): stub\n", - hKL, hIMC, debugstr_w(pSrc), lpDst, dwBufLen, uFlag - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %s, %p, %d, %d):\n", hKL, hIMC, debugstr_w(pSrc), lpDst, + dwBufLen, uFlag); + if (immHkl->hIME && immHkl->pImeConversionList) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeConversionList(hIMC,pSrc,lpDst,dwBufLen,uFlag); + else + { + LPCANDIDATELIST lpaDst; + DWORD ret = 0, len; + LPSTR paSrc = strdupWtoA(pSrc); + + len = immHkl->pImeConversionList(hIMC, (LPCWSTR)paSrc, NULL, 0, uFlag); + lpaDst = HeapAlloc(GetProcessHeap(), 0, len); + if ( lpaDst ) + { + immHkl->pImeConversionList(hIMC, (LPCWSTR)paSrc, lpaDst, len, uFlag); + ret = convert_candidatelist_AtoW( lpaDst, lpDst, dwBufLen); + HeapFree(GetProcessHeap(), 0, lpaDst); + } + HeapFree(GetProcessHeap(), 0, paSrc); + + return ret; + } + } + else + return 0; } /*********************************************************************** @@ -1248,11 +1464,18 @@ DWORD WINAPI ImmGetConversionListW( BOOL WINAPI ImmGetConversionStatus( HIMC hIMC, LPDWORD lpfdwConversion, LPDWORD lpfdwSentence) { - TRACE("(%p, %p, %p): best guess\n", hIMC, lpfdwConversion, lpfdwSentence); + InputContextData *data = hIMC; + + TRACE("%p %p %p\n", hIMC, lpfdwConversion, lpfdwSentence); + + if (!data) + return FALSE; + if (lpfdwConversion) - *lpfdwConversion = IME_CMODE_NATIVE; + *lpfdwConversion = data->IMC.fdwConversion; if (lpfdwSentence) - *lpfdwSentence = IME_SMODE_NONE; + *lpfdwSentence = data->IMC.fdwSentence; + return TRUE; } @@ -1261,26 +1484,8 @@ BOOL WINAPI ImmGetConversionStatus( */ HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd) { - static int shown = 0; - - if (!shown) { - FIXME("(%p - %p %p ): semi-stub\n", hWnd,hwndDefault, root_context); - shown = 1; - } - - if (hwndDefault == NULL) - { - static const WCHAR the_name[] = {'I','M','E','\0'}; - - IMM_Register(); - hwndDefault = CreateWindowExW( WS_EX_TOOLWINDOW, WC_IMECLASSNAME, - the_name, WS_POPUP, 0, 0, 1, 1, 0, 0, - hImeInst, 0); - - TRACE("Default created (%p)\n",hwndDefault); - } - - return hwndDefault; + TRACE("Default is %p\n",IMM_GetThreadData()->hwndDefault); + return IMM_GetThreadData()->hwndDefault; } /*********************************************************************** @@ -1391,15 +1596,12 @@ UINT WINAPI ImmGetIMEFileNameA( HKL hKL, LPSTR lpszFileName, UINT uBufLen) */ UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT uBufLen) { - static const WCHAR szImeFileW[] = {'I','m','e',' ','F','i','l','e',0}; - static const WCHAR fmt[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s','\\','%','0','8','x',0}; - HKEY hkey; DWORD length; DWORD rc; - WCHAR regKey[sizeof(fmt)/sizeof(WCHAR)+8]; + WCHAR regKey[sizeof(szImeRegFmt)/sizeof(WCHAR)+8]; - wsprintfW( regKey, fmt, (unsigned)hKL ); + wsprintfW( regKey, szImeRegFmt, (ULONG_PTR)hKL ); rc = RegOpenKeyW( HKEY_LOCAL_MACHINE, regKey, &hkey); if (rc != ERROR_SUCCESS) { @@ -1440,7 +1642,7 @@ UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT uBufLen) */ BOOL WINAPI ImmGetOpenStatus(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; if (!data) return FALSE; @@ -1455,40 +1657,24 @@ BOOL WINAPI ImmGetOpenStatus(HIMC hIMC) DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex) { DWORD rc = 0; - TRACE("(%p, %d)\n", hKL, fdwIndex); + ImmHkl *kbd; - switch (fdwIndex) + TRACE("(%p, %d)\n", hKL, fdwIndex); + kbd = IMM_GetImmHkl(hKL); + + if (kbd && kbd->hIME) { - case IGP_PROPERTY: - TRACE("(%s)\n", "IGP_PROPERTY"); - rc = IME_PROP_UNICODE | IME_PROP_AT_CARET; - break; - case IGP_CONVERSION: - FIXME("(%s)\n", "IGP_CONVERSION"); - rc = IME_CMODE_NATIVE; - break; - case IGP_SENTENCE: - FIXME("%s)\n", "IGP_SENTENCE"); - rc = IME_SMODE_AUTOMATIC; - break; - case IGP_SETCOMPSTR: - TRACE("(%s)\n", "IGP_SETCOMPSTR"); - rc = 0; - break; - case IGP_SELECT: - TRACE("(%s)\n", "IGP_SELECT"); - rc = SELECT_CAP_CONVERSION | SELECT_CAP_SENTENCE; - break; - case IGP_GETIMEVERSION: - TRACE("(%s)\n", "IGP_GETIMEVERSION"); - rc = IMEVER_0400; - break; - case IGP_UI: - TRACE("(%s)\n", "IGP_UI"); - rc = 0; - break; - default: - rc = 0; + switch (fdwIndex) + { + case IGP_PROPERTY: rc = kbd->imeInfo.fdwProperty; break; + case IGP_CONVERSION: rc = kbd->imeInfo.fdwConversionCaps; break; + case IGP_SENTENCE: rc = kbd->imeInfo.fdwSentenceCaps; break; + case IGP_SETCOMPSTR: rc = kbd->imeInfo.fdwSCSCaps; break; + case IGP_SELECT: rc = kbd->imeInfo.fdwSelectCaps; break; + case IGP_GETIMEVERSION: rc = IMEVER_0400; break; + case IGP_UI: rc = 0; break; + default: rc = 0; + } } return rc; } @@ -1499,9 +1685,26 @@ DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex) UINT WINAPI ImmGetRegisterWordStyleA( HKL hKL, UINT nItem, LPSTYLEBUFA lpStyleBuf) { - FIXME("(%p, %d, %p): stub\n", hKL, nItem, lpStyleBuf); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %d, %p):\n", hKL, nItem, lpStyleBuf); + if (immHkl->hIME && immHkl->pImeGetRegisterWordStyle) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeGetRegisterWordStyle(nItem,(LPSTYLEBUFW)lpStyleBuf); + else + { + STYLEBUFW sbw; + UINT rc; + + rc = immHkl->pImeGetRegisterWordStyle(nItem,&sbw); + WideCharToMultiByte(CP_ACP, 0, sbw.szDescription, -1, + lpStyleBuf->szDescription, 32, NULL, NULL); + lpStyleBuf->dwStyle = sbw.dwStyle; + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -1510,9 +1713,26 @@ UINT WINAPI ImmGetRegisterWordStyleA( UINT WINAPI ImmGetRegisterWordStyleW( HKL hKL, UINT nItem, LPSTYLEBUFW lpStyleBuf) { - FIXME("(%p, %d, %p): stub\n", hKL, nItem, lpStyleBuf); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %d, %p):\n", hKL, nItem, lpStyleBuf); + if (immHkl->hIME && immHkl->pImeGetRegisterWordStyle) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeGetRegisterWordStyle(nItem,lpStyleBuf); + else + { + STYLEBUFA sba; + UINT rc; + + rc = immHkl->pImeGetRegisterWordStyle(nItem,(LPSTYLEBUFW)&sba); + MultiByteToWideChar(CP_ACP, 0, sba.szDescription, -1, + lpStyleBuf->szDescription, 32); + lpStyleBuf->dwStyle = sba.dwStyle; + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -1520,9 +1740,16 @@ UINT WINAPI ImmGetRegisterWordStyleW( */ BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) { - FIXME("(%p, %p): stub\n", hIMC, lpptPos); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + InputContextData *data = hIMC; + + TRACE("(%p, %p)\n", hIMC, lpptPos); + + if (!data || !lpptPos) + return FALSE; + + *lpptPos = data->IMC.ptStatusWndPos; + + return TRUE; } /*********************************************************************** @@ -1531,7 +1758,12 @@ BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) UINT WINAPI ImmGetVirtualKey(HWND hWnd) { OSVERSIONINFOA version; - FIXME("(%p): stub\n", hWnd); + InputContextData *data = ImmGetContext( hWnd ); + TRACE("%p\n", hWnd); + + if ( data ) + return data->lastVK; + GetVersionExA( &version ); switch(version.dwPlatformId) { @@ -1551,11 +1783,21 @@ UINT WINAPI ImmGetVirtualKey(HWND hWnd) HKL WINAPI ImmInstallIMEA( LPCSTR lpszIMEFileName, LPCSTR lpszLayoutText) { - FIXME("(%s, %s): stub\n", - debugstr_a(lpszIMEFileName), debugstr_a(lpszLayoutText) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return NULL; + LPWSTR lpszwIMEFileName; + LPWSTR lpszwLayoutText; + HKL hkl; + + TRACE ("(%s, %s)\n", debugstr_a(lpszIMEFileName), + debugstr_a(lpszLayoutText)); + + lpszwIMEFileName = strdupAtoW(lpszIMEFileName); + lpszwLayoutText = strdupAtoW(lpszLayoutText); + + hkl = ImmInstallIMEW(lpszwIMEFileName, lpszwLayoutText); + + HeapFree(GetProcessHeap(),0,lpszwIMEFileName); + HeapFree(GetProcessHeap(),0,lpszwLayoutText); + return hkl; } /*********************************************************************** @@ -1564,11 +1806,56 @@ HKL WINAPI ImmInstallIMEA( HKL WINAPI ImmInstallIMEW( LPCWSTR lpszIMEFileName, LPCWSTR lpszLayoutText) { - FIXME("(%s, %s): stub\n", - debugstr_w(lpszIMEFileName), debugstr_w(lpszLayoutText) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return NULL; + INT lcid = GetUserDefaultLCID(); + INT count; + HKL hkl; + DWORD rc; + HKEY hkey; + WCHAR regKey[sizeof(szImeRegFmt)/sizeof(WCHAR)+8]; + + TRACE ("(%s, %s):\n", debugstr_w(lpszIMEFileName), + debugstr_w(lpszLayoutText)); + + /* Start with 2. e001 will be blank and so default to the wine internal IME */ + count = 2; + + while (count < 0xfff) + { + DWORD disposition = 0; + + hkl = (HKL)MAKELPARAM( lcid, 0xe000 | count ); + wsprintfW( regKey, szImeRegFmt, (ULONG_PTR)hkl); + + rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, regKey, 0, NULL, 0, KEY_WRITE, NULL, &hkey, &disposition); + if (rc == ERROR_SUCCESS && disposition == REG_CREATED_NEW_KEY) + break; + else if (rc == ERROR_SUCCESS) + RegCloseKey(hkey); + + count++; + } + + if (count == 0xfff) + { + WARN("Unable to find slot to install IME\n"); + return 0; + } + + if (rc == ERROR_SUCCESS) + { + rc = RegSetValueExW(hkey, szImeFileW, 0, REG_SZ, (LPBYTE)lpszIMEFileName, + (lstrlenW(lpszIMEFileName) + 1) * sizeof(WCHAR)); + if (rc == ERROR_SUCCESS) + rc = RegSetValueExW(hkey, szLayoutTextW, 0, REG_SZ, (LPBYTE)lpszLayoutText, + (lstrlenW(lpszLayoutText) + 1) * sizeof(WCHAR)); + RegCloseKey(hkey); + return hkl; + } + else + { + WARN("Unable to set IME registry values\n"); + return 0; + } } /*********************************************************************** @@ -1576,12 +1863,10 @@ HKL WINAPI ImmInstallIMEW( */ BOOL WINAPI ImmIsIME(HKL hKL) { - TRACE("(%p): semi-stub\n", hKL); - /* - * FIXME: Dead key locales will return TRUE here when they should not - * There is probably a more proper way to check this. - */ - return (root_context != NULL); + ImmHkl *ptr; + TRACE("(%p):\n", hKL); + ptr = IMM_GetImmHkl(hKL); + return (ptr && ptr->hIME); } /*********************************************************************** @@ -1604,11 +1889,11 @@ BOOL WINAPI ImmIsUIMessageA( (msg == WM_MSIME_DOCUMENTFEED)) { - if (!hwndDefault) + if (!IMM_GetThreadData()->hwndDefault) ImmGetDefaultIMEWnd(NULL); if (hWndIME == NULL) - PostMessageA(hwndDefault, msg, wParam, lParam); + PostMessageA(IMM_GetThreadData()->hwndDefault, msg, wParam, lParam); rc = TRUE; } @@ -1622,7 +1907,7 @@ BOOL WINAPI ImmIsUIMessageW( HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL rc = FALSE; - TRACE("(%p, %d, %ld, %ld): stub\n", hWndIME, msg, wParam, lParam); + TRACE("(%p, %d, %ld, %ld):\n", hWndIME, msg, wParam, lParam); if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) || (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) || (msg == WM_MSIME_SERVICE) || @@ -1642,126 +1927,15 @@ BOOL WINAPI ImmIsUIMessageW( BOOL WINAPI ImmNotifyIME( HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue) { - BOOL rc = FALSE; + InputContextData *data = hIMC; TRACE("(%p, %d, %d, %d)\n", hIMC, dwAction, dwIndex, dwValue); - if (!root_context) - return rc; + if (!data || ! data->immKbd->pNotifyIME) + return FALSE; - switch(dwAction) - { - case NI_CHANGECANDIDATELIST: - FIXME("%s\n","NI_CHANGECANDIDATELIST"); - break; - case NI_CLOSECANDIDATE: - FIXME("%s\n","NI_CLOSECANDIDATE"); - break; - case NI_COMPOSITIONSTR: - switch (dwIndex) - { - case CPS_CANCEL: - TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_CANCEL"); - { - BOOL send; - LPCOMPOSITIONSTRING lpCompStr; - - if (pX11DRV_ForceXIMReset) - pX11DRV_ForceXIMReset(root_context->IMC.hWnd); - - lpCompStr = ImmLockIMCC(root_context->IMC.hCompStr); - send = (lpCompStr->dwCompStrLen != 0); - ImmUnlockIMCC(root_context->IMC.hCompStr); - - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = ImmCreateBlankCompStr(); - - if (send) - ImmInternalPostIMEMessage(root_context, WM_IME_COMPOSITION, 0, - GCS_COMPSTR); - rc = TRUE; - } - break; - case CPS_COMPLETE: - TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_COMPLETE"); - if (hIMC != (HIMC)FROM_IME && pX11DRV_ForceXIMReset) - pX11DRV_ForceXIMReset(root_context->IMC.hWnd); - { - HIMCC newCompStr; - DWORD cplen = 0; - LPWSTR cpstr; - LPCOMPOSITIONSTRING cs = NULL; - LPBYTE cdata = NULL; - - /* clear existing result */ - newCompStr = updateResultStr(root_context->IMC.hCompStr, NULL, 0); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - - if (root_context->IMC.hCompStr) - { - cdata = ImmLockIMCC(root_context->IMC.hCompStr); - cs = (LPCOMPOSITIONSTRING)cdata; - cplen = cs->dwCompStrLen; - cpstr = (LPWSTR)&(cdata[cs->dwCompStrOffset]); - ImmUnlockIMCC(root_context->IMC.hCompStr); - } - if (cplen > 0) - { - WCHAR param = cpstr[0]; - newCompStr = updateResultStr(root_context->IMC.hCompStr, cpstr, cplen); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - newCompStr = updateCompStr(root_context->IMC.hCompStr, NULL, 0); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - - root_context->bRead = FALSE; - - ImmInternalPostIMEMessage(root_context, WM_IME_COMPOSITION, 0, - GCS_COMPSTR); - - ImmInternalPostIMEMessage(root_context, WM_IME_COMPOSITION, - param, - GCS_RESULTSTR|GCS_RESULTCLAUSE); - } - - ImmInternalPostIMEMessage(root_context, WM_IME_ENDCOMPOSITION, 0, 0); - root_context->bInComposition = FALSE; - } - break; - case CPS_CONVERT: - FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_CONVERT"); - break; - case CPS_REVERT: - FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_REVERT"); - break; - default: - ERR("%s - %s (%i)\n","NI_COMPOSITIONSTR","UNKNOWN",dwIndex); - break; - } - break; - case NI_IMEMENUSELECTED: - FIXME("%s\n", "NI_IMEMENUSELECTED"); - break; - case NI_OPENCANDIDATE: - FIXME("%s\n", "NI_OPENCANDIDATE"); - break; - case NI_SELECTCANDIDATESTR: - FIXME("%s\n", "NI_SELECTCANDIDATESTR"); - break; - case NI_SETCANDIDATE_PAGESIZE: - FIXME("%s\n", "NI_SETCANDIDATE_PAGESIZE"); - break; - case NI_SETCANDIDATE_PAGESTART: - FIXME("%s\n", "NI_SETCANDIDATE_PAGESTART"); - break; - default: - ERR("Unknown\n"); - } - - return rc; + return data->immKbd->pNotifyIME(hIMC,dwAction,dwIndex,dwValue); } /*********************************************************************** @@ -1770,11 +1944,28 @@ BOOL WINAPI ImmNotifyIME( BOOL WINAPI ImmRegisterWordA( HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszRegister) { - FIXME("(%p, %s, %d, %s): stub\n", - hKL, debugstr_a(lpszReading), dwStyle, debugstr_a(lpszRegister) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_a(lpszReading), dwStyle, + debugstr_a(lpszRegister)); + if (immHkl->hIME && immHkl->pImeRegisterWord) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeRegisterWord((LPCWSTR)lpszReading,dwStyle, + (LPCWSTR)lpszRegister); + else + { + LPWSTR lpszwReading = strdupAtoW(lpszReading); + LPWSTR lpszwRegister = strdupAtoW(lpszRegister); + BOOL rc; + + rc = immHkl->pImeRegisterWord(lpszwReading,dwStyle,lpszwRegister); + HeapFree(GetProcessHeap(),0,lpszwReading); + HeapFree(GetProcessHeap(),0,lpszwRegister); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -1783,11 +1974,28 @@ BOOL WINAPI ImmRegisterWordA( BOOL WINAPI ImmRegisterWordW( HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszRegister) { - FIXME("(%p, %s, %d, %s): stub\n", - hKL, debugstr_w(lpszReading), dwStyle, debugstr_w(lpszRegister) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_w(lpszReading), dwStyle, + debugstr_w(lpszRegister)); + if (immHkl->hIME && immHkl->pImeRegisterWord) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeRegisterWord(lpszReading,dwStyle,lpszRegister); + else + { + LPSTR lpszaReading = strdupWtoA(lpszReading); + LPSTR lpszaRegister = strdupWtoA(lpszRegister); + BOOL rc; + + rc = immHkl->pImeRegisterWord((LPCWSTR)lpszaReading,dwStyle, + (LPCWSTR)lpszaRegister); + HeapFree(GetProcessHeap(),0,lpszaReading); + HeapFree(GetProcessHeap(),0,lpszaRegister); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -1804,15 +2012,63 @@ BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC) return TRUE; } +/*********************************************************************** +* ImmRequestMessageA(IMM32.@) +*/ +LRESULT WINAPI ImmRequestMessageA(HIMC hIMC, WPARAM wParam, LPARAM lParam) +{ + InputContextData *data = hIMC; + + TRACE("%p %ld %ld\n", hIMC, wParam, wParam); + + if (data && IsWindow(data->IMC.hWnd)) + return SendMessageA(data->IMC.hWnd, WM_IME_REQUEST, wParam, lParam); + + return 0; +} + +/*********************************************************************** +* ImmRequestMessageW(IMM32.@) +*/ +LRESULT WINAPI ImmRequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam) +{ + InputContextData *data = hIMC; + + TRACE("%p %ld %ld\n", hIMC, wParam, wParam); + + if (data && IsWindow(data->IMC.hWnd)) + return SendMessageW(data->IMC.hWnd, WM_IME_REQUEST, wParam, lParam); + + return 0; +} + /*********************************************************************** * ImmSetCandidateWindow (IMM32.@) */ BOOL WINAPI ImmSetCandidateWindow( HIMC hIMC, LPCANDIDATEFORM lpCandidate) { - FIXME("(%p, %p): stub\n", hIMC, lpCandidate); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + InputContextData *data = hIMC; + + TRACE("(%p, %p)\n", hIMC, lpCandidate); + + if (!data || !lpCandidate) + return FALSE; + + TRACE("\t%x, %x, (%i,%i), (%i,%i - %i,%i)\n", + lpCandidate->dwIndex, lpCandidate->dwStyle, + lpCandidate->ptCurrentPos.x, lpCandidate->ptCurrentPos.y, + lpCandidate->rcArea.top, lpCandidate->rcArea.left, + lpCandidate->rcArea.bottom, lpCandidate->rcArea.right); + + if ( lpCandidate->dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) ) + return FALSE; + + data->IMC.cfCandForm[lpCandidate->dwIndex] = *lpCandidate; + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, 0, IMC_SETCANDIDATEPOS); + ImmInternalSendIMENotify(data, IMN_SETCANDIDATEPOS, 1 << lpCandidate->dwIndex); + + return TRUE; } /*********************************************************************** @@ -1820,25 +2076,18 @@ BOOL WINAPI ImmSetCandidateWindow( */ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lplf); - if (!data) + if (!data || !lplf) return FALSE; memcpy(&data->IMC.lfFont.W,lplf,sizeof(LOGFONTA)); MultiByteToWideChar(CP_ACP, 0, lplf->lfFaceName, -1, data->IMC.lfFont.W.lfFaceName, LF_FACESIZE); - + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, 0, IMC_SETCOMPOSITIONFONT); ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONFONT, 0); - if (data->textfont) - { - DeleteObject(data->textfont); - data->textfont = NULL; - } - - data->textfont = CreateFontIndirectW(&data->IMC.lfFont.W); return TRUE; } @@ -1847,21 +2096,16 @@ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) */ BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lplf); - if (!data) + if (!data || !lplf) return FALSE; data->IMC.lfFont.W = *lplf; + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, 0, IMC_SETCOMPOSITIONFONT); ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONFONT, 0); - if (data->textfont) - { - DeleteObject(data->textfont); - data->textfont = NULL; - } - data->textfont = CreateFontIndirectW(&data->IMC.lfFont.W); return TRUE; } @@ -1878,10 +2122,25 @@ BOOL WINAPI ImmSetCompositionStringA( WCHAR *CompBuffer = NULL; WCHAR *ReadBuffer = NULL; BOOL rc; + InputContextData *data = hIMC; - TRACE("(%p, %d, %p, %d, %p, %d): stub\n", + TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen); + if (!data) + return FALSE; + + if (!(dwIndex == SCS_SETSTR || + dwIndex == SCS_CHANGEATTR || + dwIndex == SCS_CHANGECLAUSE || + dwIndex == SCS_SETRECONVERTSTRING || + dwIndex == SCS_QUERYRECONVERTSTRING)) + return FALSE; + + if (!is_himc_ime_unicode(data)) + return data->immKbd->pImeSetCompositionString(hIMC, dwIndex, lpComp, + dwCompLen, lpRead, dwReadLen); + comp_len = MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, NULL, 0); if (comp_len) { @@ -1913,64 +2172,55 @@ BOOL WINAPI ImmSetCompositionStringW( LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen) { - DWORD flags = 0; - WCHAR wParam = 0; + DWORD comp_len; + DWORD read_len; + CHAR *CompBuffer = NULL; + CHAR *ReadBuffer = NULL; + BOOL rc; + InputContextData *data = hIMC; - TRACE("(%p, %d, %p, %d, %p, %d): stub\n", - hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen); + TRACE("(%p, %d, %p, %d, %p, %d):\n", + hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen); + if (!data) + return FALSE; - if (hIMC != (HIMC)FROM_IME) - FIXME("PROBLEM: This only sets the wine level string\n"); + if (!(dwIndex == SCS_SETSTR || + dwIndex == SCS_CHANGEATTR || + dwIndex == SCS_CHANGECLAUSE || + dwIndex == SCS_SETRECONVERTSTRING || + dwIndex == SCS_QUERYRECONVERTSTRING)) + return FALSE; - /* - * Explanation: - * this sets the composition string in the imm32.dll level - * of the composition buffer. we cannot manipulate the xim level - * buffer, which means that once the xim level buffer changes again - * any call to this function from the application will be lost - */ + if (is_himc_ime_unicode(data)) + return data->immKbd->pImeSetCompositionString(hIMC, dwIndex, lpComp, + dwCompLen, lpRead, dwReadLen); - if (lpRead && dwReadLen) - FIXME("Reading string unimplemented\n"); - - /* - * app operating this api to also receive the message from xim - */ - - if (dwIndex == SCS_SETSTR) + comp_len = WideCharToMultiByte(CP_ACP, 0, lpComp, dwCompLen, NULL, 0, NULL, + NULL); + if (comp_len) { - HIMCC newCompStr; - if (!root_context->bInComposition) - { - ImmInternalPostIMEMessage(root_context, WM_IME_STARTCOMPOSITION, 0, 0); - root_context->bInComposition = TRUE; - } - - flags = GCS_COMPSTR; - - if (dwCompLen && lpComp) - { - newCompStr = updateCompStr(root_context->IMC.hCompStr, (LPWSTR)lpComp, dwCompLen / sizeof(WCHAR)); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - - wParam = ((const WCHAR*)lpComp)[0]; - flags |= GCS_COMPCLAUSE | GCS_COMPATTR | GCS_DELTASTART; - } - else - { - newCompStr = updateCompStr(root_context->IMC.hCompStr, NULL, 0); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - } + CompBuffer = HeapAlloc(GetProcessHeap(),0,comp_len); + WideCharToMultiByte(CP_ACP, 0, lpComp, dwCompLen, CompBuffer, comp_len, + NULL, NULL); } - UpdateDataInDefaultIMEWindow(hwndDefault,FALSE); + read_len = WideCharToMultiByte(CP_ACP, 0, lpRead, dwReadLen, NULL, 0, NULL, + NULL); + if (read_len) + { + ReadBuffer = HeapAlloc(GetProcessHeap(),0,read_len); + WideCharToMultiByte(CP_ACP, 0, lpRead, dwReadLen, ReadBuffer, read_len, + NULL, NULL); + } - ImmInternalPostIMEMessage(root_context, WM_IME_COMPOSITION, wParam, flags); + rc = ImmSetCompositionStringA(hIMC, dwIndex, CompBuffer, comp_len, + ReadBuffer, read_len); - return TRUE; + HeapFree(GetProcessHeap(), 0, CompBuffer); + HeapFree(GetProcessHeap(), 0, ReadBuffer); + + return rc; } /*********************************************************************** @@ -1980,7 +2230,7 @@ BOOL WINAPI ImmSetCompositionWindow( HIMC hIMC, LPCOMPOSITIONFORM lpCompForm) { BOOL reshow = FALSE; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpCompForm); TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm->dwStyle, @@ -1992,16 +2242,16 @@ BOOL WINAPI ImmSetCompositionWindow( data->IMC.cfCompForm = *lpCompForm; - if (IsWindowVisible(hwndDefault)) + if (IsWindowVisible(IMM_GetThreadData()->hwndDefault)) { reshow = TRUE; - ShowWindow(hwndDefault,SW_HIDE); + ShowWindow(IMM_GetThreadData()->hwndDefault,SW_HIDE); } /* FIXME: this is a partial stub */ if (reshow) - ShowWindow(hwndDefault,SW_SHOWNOACTIVATE); + ShowWindow(IMM_GetThreadData()->hwndDefault,SW_SHOWNOACTIVATE); ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONWINDOW, 0); return TRUE; @@ -2013,16 +2263,30 @@ BOOL WINAPI ImmSetCompositionWindow( BOOL WINAPI ImmSetConversionStatus( HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence) { - static int shown = 0; + DWORD oldConversion, oldSentence; + InputContextData *data = hIMC; - if (!shown) { - FIXME("(%p, %d, %d): stub\n", - hIMC, fdwConversion, fdwSentence - ); - shown = 1; - } - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + TRACE("%p %d %d\n", hIMC, fdwConversion, fdwSentence); + + if (!data) + return FALSE; + + if ( fdwConversion != data->IMC.fdwConversion ) + { + oldConversion = data->IMC.fdwConversion; + data->IMC.fdwConversion = fdwConversion; + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, oldConversion, IMC_SETCONVERSIONMODE); + ImmInternalSendIMENotify(data, IMN_SETCONVERSIONMODE, 0); + } + if ( fdwSentence != data->IMC.fdwSentence ) + { + oldSentence = data->IMC.fdwSentence; + data->IMC.fdwSentence = fdwSentence; + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, oldSentence, IMC_SETSENTENCEMODE); + ImmInternalSendIMENotify(data, IMN_SETSENTENCEMODE, 0); + } + + return TRUE; } /*********************************************************************** @@ -2030,40 +2294,30 @@ BOOL WINAPI ImmSetConversionStatus( */ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%p %d\n", hIMC, fOpen); - if (hIMC == (HIMC)FROM_IME) - { - ImmInternalSetOpenStatus(fOpen); - ImmInternalSendIMENotify(root_context, IMN_SETOPENSTATUS, 0); - return TRUE; - } - if (!data) return FALSE; - if (fOpen != data->bInternalState) + if (data->imeWnd == NULL) { - if (fOpen == FALSE && pX11DRV_ForceXIMReset) - pX11DRV_ForceXIMReset(data->IMC.hWnd); - - if (fOpen == FALSE) - ImmInternalPostIMEMessage(data, WM_IME_ENDCOMPOSITION,0,0); - else - ImmInternalPostIMEMessage(data, WM_IME_STARTCOMPOSITION,0,0); - - ImmInternalSetOpenStatus(fOpen); - ImmInternalSetOpenStatus(!fOpen); - - if (data->IMC.fOpen == FALSE) - ImmInternalPostIMEMessage(data, WM_IME_ENDCOMPOSITION,0,0); - else - ImmInternalPostIMEMessage(data, WM_IME_STARTCOMPOSITION,0,0); - - return FALSE; + /* create the ime window */ + data->imeWnd = CreateWindowExW( WS_EX_TOOLWINDOW, + data->immKbd->imeClassName, NULL, WS_POPUP, 0, 0, 1, 1, 0, + 0, data->immKbd->hIME, 0); + SetWindowLongPtrW(data->imeWnd, IMMGWL_IMC, (LONG_PTR)data); + IMM_GetThreadData()->hwndDefault = data->imeWnd; } + + if (!fOpen != !data->IMC.fOpen) + { + data->IMC.fOpen = fOpen; + ImmNotifyIME( hIMC, NI_CONTEXTUPDATED, 0, IMC_SETOPENSTATUS); + ImmInternalSendIMENotify(data, IMN_SETOPENSTATUS, 0); + } + return TRUE; } @@ -2072,9 +2326,50 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) */ BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) { - FIXME("(%p, %p): stub\n", hIMC, lpptPos); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + InputContextData *data = hIMC; + + TRACE("(%p, %p)\n", hIMC, lpptPos); + + if (!data || !lpptPos) + return FALSE; + + TRACE("\t(%i,%i)\n", lpptPos->x, lpptPos->y); + + data->IMC.ptStatusWndPos = *lpptPos; + ImmNotifyIME( hIMC, NI_CONTEXTUPDATED, 0, IMC_SETSTATUSWINDOWPOS); + ImmInternalSendIMENotify(data, IMN_SETSTATUSWINDOWPOS, 0); + + return TRUE; +} + +/*********************************************************************** + * ImmCreateSoftKeyboard(IMM32.@) + */ +HWND WINAPI ImmCreateSoftKeyboard(UINT uType, UINT hOwner, int x, int y) +{ + FIXME("(%d, %d, %d, %d): stub\n", uType, hOwner, x, y); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/*********************************************************************** + * ImmDestroySoftKeyboard(IMM32.@) + */ +BOOL WINAPI ImmDestroySoftKeyboard(HWND hSoftWnd) +{ + FIXME("(%p): stub\n", hSoftWnd); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/*********************************************************************** + * ImmShowSoftKeyboard(IMM32.@) + */ +BOOL WINAPI ImmShowSoftKeyboard(HWND hSoftWnd, int nCmdShow) +{ + FIXME("(%p, %d): stub\n", hSoftWnd, nCmdShow); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /*********************************************************************** @@ -2093,11 +2388,28 @@ BOOL WINAPI ImmSimulateHotKey(HWND hWnd, DWORD dwHotKeyID) BOOL WINAPI ImmUnregisterWordA( HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszUnregister) { - FIXME("(%p, %s, %d, %s): stub\n", - hKL, debugstr_a(lpszReading), dwStyle, debugstr_a(lpszUnregister) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_a(lpszReading), dwStyle, + debugstr_a(lpszUnregister)); + if (immHkl->hIME && immHkl->pImeUnregisterWord) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeUnregisterWord((LPCWSTR)lpszReading,dwStyle, + (LPCWSTR)lpszUnregister); + else + { + LPWSTR lpszwReading = strdupAtoW(lpszReading); + LPWSTR lpszwUnregister = strdupAtoW(lpszUnregister); + BOOL rc; + + rc = immHkl->pImeUnregisterWord(lpszwReading,dwStyle,lpszwUnregister); + HeapFree(GetProcessHeap(),0,lpszwReading); + HeapFree(GetProcessHeap(),0,lpszwUnregister); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -2106,11 +2418,28 @@ BOOL WINAPI ImmUnregisterWordA( BOOL WINAPI ImmUnregisterWordW( HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszUnregister) { - FIXME("(%p, %s, %d, %s): stub\n", - hKL, debugstr_w(lpszReading), dwStyle, debugstr_w(lpszUnregister) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_w(lpszReading), dwStyle, + debugstr_w(lpszUnregister)); + if (immHkl->hIME && immHkl->pImeUnregisterWord) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeUnregisterWord(lpszReading,dwStyle,lpszUnregister); + else + { + LPSTR lpszaReading = strdupWtoA(lpszReading); + LPSTR lpszaUnregister = strdupWtoA(lpszUnregister); + BOOL rc; + + rc = immHkl->pImeUnregisterWord((LPCWSTR)lpszaReading,dwStyle, + (LPCWSTR)lpszaUnregister); + HeapFree(GetProcessHeap(),0,lpszaReading); + HeapFree(GetProcessHeap(),0,lpszaUnregister); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -2120,9 +2449,61 @@ DWORD WINAPI ImmGetImeMenuItemsA( HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOA lpImeParentMenu, LPIMEMENUITEMINFOA lpImeMenu, DWORD dwSize) { - FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC, dwFlags, dwType, - lpImeParentMenu, lpImeMenu, dwSize); - return 0; + InputContextData *data = hIMC; + TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType, + lpImeParentMenu, lpImeMenu, dwSize); + if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems) + { + if (!is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu)) + return data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, + (IMEMENUITEMINFOW*)lpImeParentMenu, + (IMEMENUITEMINFOW*)lpImeMenu, dwSize); + else + { + IMEMENUITEMINFOW lpImeParentMenuW; + IMEMENUITEMINFOW *lpImeMenuW, *parent = NULL; + DWORD rc; + + if (lpImeParentMenu) + parent = &lpImeParentMenuW; + if (lpImeMenu) + { + int count = dwSize / sizeof(LPIMEMENUITEMINFOA); + dwSize = count * sizeof(IMEMENUITEMINFOW); + lpImeMenuW = HeapAlloc(GetProcessHeap(), 0, dwSize); + } + else + lpImeMenuW = NULL; + + rc = data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, + parent, lpImeMenuW, dwSize); + + if (lpImeParentMenu) + { + memcpy(lpImeParentMenu,&lpImeParentMenuW,sizeof(IMEMENUITEMINFOA)); + lpImeParentMenu->hbmpItem = lpImeParentMenuW.hbmpItem; + WideCharToMultiByte(CP_ACP, 0, lpImeParentMenuW.szString, + -1, lpImeParentMenu->szString, IMEMENUITEM_STRING_SIZE, + NULL, NULL); + } + if (lpImeMenu && rc) + { + unsigned int i; + for (i = 0; i < rc; i++) + { + memcpy(&lpImeMenu[i],&lpImeMenuW[1],sizeof(IMEMENUITEMINFOA)); + lpImeMenu[i].hbmpItem = lpImeMenuW[i].hbmpItem; + WideCharToMultiByte(CP_ACP, 0, lpImeMenuW[i].szString, + -1, lpImeMenu[i].szString, IMEMENUITEM_STRING_SIZE, + NULL, NULL); + } + } + HeapFree(GetProcessHeap(),0,lpImeMenuW); + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -2132,9 +2513,59 @@ DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize) { - FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC, dwFlags, dwType, - lpImeParentMenu, lpImeMenu, dwSize); - return 0; + InputContextData *data = hIMC; + TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType, + lpImeParentMenu, lpImeMenu, dwSize); + if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems) + { + if (is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu)) + return data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, + lpImeParentMenu, lpImeMenu, dwSize); + else + { + IMEMENUITEMINFOA lpImeParentMenuA; + IMEMENUITEMINFOA *lpImeMenuA, *parent = NULL; + DWORD rc; + + if (lpImeParentMenu) + parent = &lpImeParentMenuA; + if (lpImeMenu) + { + int count = dwSize / sizeof(LPIMEMENUITEMINFOW); + dwSize = count * sizeof(IMEMENUITEMINFOA); + lpImeMenuA = HeapAlloc(GetProcessHeap(), 0, dwSize); + } + else + lpImeMenuA = NULL; + + rc = data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, + (IMEMENUITEMINFOW*)parent, + (IMEMENUITEMINFOW*)lpImeMenuA, dwSize); + + if (lpImeParentMenu) + { + memcpy(lpImeParentMenu,&lpImeParentMenuA,sizeof(IMEMENUITEMINFOA)); + lpImeParentMenu->hbmpItem = lpImeParentMenuA.hbmpItem; + MultiByteToWideChar(CP_ACP, 0, lpImeParentMenuA.szString, + -1, lpImeParentMenu->szString, IMEMENUITEM_STRING_SIZE); + } + if (lpImeMenu && rc) + { + unsigned int i; + for (i = 0; i < rc; i++) + { + memcpy(&lpImeMenu[i],&lpImeMenuA[1],sizeof(IMEMENUITEMINFOA)); + lpImeMenu[i].hbmpItem = lpImeMenuA[i].hbmpItem; + MultiByteToWideChar(CP_ACP, 0, lpImeMenuA[i].szString, + -1, lpImeMenu[i].szString, IMEMENUITEM_STRING_SIZE); + } + } + HeapFree(GetProcessHeap(),0,lpImeMenuA); + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -2142,7 +2573,7 @@ DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType, */ LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; if (!data) return NULL; @@ -2155,7 +2586,7 @@ LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC) */ BOOL WINAPI ImmUnlockIMC(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; data->dwLock--; return (data->dwLock!=0); } @@ -2165,7 +2596,7 @@ BOOL WINAPI ImmUnlockIMC(HIMC hIMC) */ DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; return data->dwLock; } @@ -2182,7 +2613,7 @@ HIMCC WINAPI ImmCreateIMCC(DWORD size) return NULL; internal->dwSize = size; - return (HIMCC)internal; + return internal; } /*********************************************************************** @@ -2200,7 +2631,7 @@ HIMCC WINAPI ImmDestroyIMCC(HIMCC block) LPVOID WINAPI ImmLockIMCC(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; internal->dwLock ++; return internal + 1; @@ -2212,7 +2643,7 @@ LPVOID WINAPI ImmLockIMCC(HIMCC imcc) BOOL WINAPI ImmUnlockIMCC(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; internal->dwLock --; return (internal->dwLock!=0); @@ -2224,7 +2655,7 @@ BOOL WINAPI ImmUnlockIMCC(HIMCC imcc) DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; return internal->dwLock; } @@ -2237,7 +2668,7 @@ HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size) IMCCInternal *internal,*newone; int real_size = size + sizeof(IMCCInternal); - internal = (IMCCInternal*) imcc; + internal = imcc; newone = HeapReAlloc(GetProcessHeap(), 0, internal, real_size); newone->dwSize = size; @@ -2251,7 +2682,7 @@ HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size) DWORD WINAPI ImmGetIMCCSize(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; return internal->dwSize; } @@ -2261,15 +2692,15 @@ DWORD WINAPI ImmGetIMCCSize(HIMCC imcc) */ BOOL WINAPI ImmGenerateMessage(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%i messages queued\n",data->IMC.dwNumMsgBuf); if (data->IMC.dwNumMsgBuf > 0) { LPTRANSMSG lpTransMsg; - INT i; + DWORD i; - lpTransMsg = (LPTRANSMSG)ImmLockIMCC(data->IMC.hMsgBuf); + lpTransMsg = ImmLockIMCC(data->IMC.hMsgBuf); for (i = 0; i < data->IMC.dwNumMsgBuf; i++) ImmInternalPostIMEMessage(data, lpTransMsg[i].message, lpTransMsg[i].wParam, lpTransMsg[i].lParam); @@ -2281,252 +2712,106 @@ BOOL WINAPI ImmGenerateMessage(HIMC hIMC) return TRUE; } -/***** - * Internal functions to help with IME window management - */ -static void PaintDefaultIMEWnd(HWND hwnd) +/*********************************************************************** +* ImmTranslateMessage(IMM32.@) +* ( Undocumented, call internally and from user32.dll ) +*/ +BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lKeyData) { - PAINTSTRUCT ps; - RECT rect; - HDC hdc = BeginPaint(hwnd,&ps); - LPCOMPOSITIONSTRING compstr; - LPBYTE compdata = NULL; - HMONITOR monitor; - MONITORINFO mon_info; - INT offX=0, offY=0; + InputContextData *data; + HIMC imc = ImmGetContext(hwnd); + BYTE state[256]; + UINT scancode; + LPVOID list = 0; + UINT msg_count; + UINT uVirtKey; + static const DWORD list_count = 10; - GetClientRect(hwnd,&rect); - FillRect(hdc, &rect, (HBRUSH)(COLOR_WINDOW + 1)); + TRACE("%p %x %x %x\n",hwnd, msg, (UINT)wParam, (UINT)lKeyData); - compdata = ImmLockIMCC(root_context->IMC.hCompStr); - compstr = (LPCOMPOSITIONSTRING)compdata; - - if (compstr->dwCompStrLen && compstr->dwCompStrOffset) - { - SIZE size; - POINT pt; - HFONT oldfont = NULL; - LPWSTR CompString; - - CompString = (LPWSTR)(compdata + compstr->dwCompStrOffset); - if (root_context->textfont) - oldfont = SelectObject(hdc,root_context->textfont); - - - GetTextExtentPoint32W(hdc, CompString, compstr->dwCompStrLen, &size); - pt.x = size.cx; - pt.y = size.cy; - LPtoDP(hdc,&pt,1); - - /* - * How this works based on tests on windows: - * CFS_POINT: then we start our window at the point and grow it as large - * as it needs to be for the string. - * CFS_RECT: we still use the ptCurrentPos as a starting point and our - * window is only as large as we need for the string, but we do not - * grow such that our window exceeds the given rect. Wrapping if - * needed and possible. If our ptCurrentPos is outside of our rect - * then no window is displayed. - * CFS_FORCE_POSITION: appears to behave just like CFS_POINT - * maybe becase the default MSIME does not do any IME adjusting. - */ - if (root_context->IMC.cfCompForm.dwStyle != CFS_DEFAULT) - { - POINT cpt = root_context->IMC.cfCompForm.ptCurrentPos; - ClientToScreen(root_context->IMC.hWnd,&cpt); - rect.left = cpt.x; - rect.top = cpt.y; - rect.right = rect.left + pt.x; - rect.bottom = rect.top + pt.y; - monitor = MonitorFromPoint(cpt, MONITOR_DEFAULTTOPRIMARY); - } - else /* CFS_DEFAULT */ - { - /* Windows places the default IME window in the bottom left */ - HWND target = root_context->IMC.hWnd; - if (!target) target = GetFocus(); - - GetWindowRect(target,&rect); - rect.top = rect.bottom; - rect.right = rect.left + pt.x + 20; - rect.bottom = rect.top + pt.y + 20; - offX=offY=10; - monitor = MonitorFromWindow(target, MONITOR_DEFAULTTOPRIMARY); - } - - if (root_context->IMC.cfCompForm.dwStyle == CFS_RECT) - { - RECT client; - client =root_context->IMC.cfCompForm.rcArea; - MapWindowPoints( root_context->IMC.hWnd, 0, (POINT *)&client, 2 ); - IntersectRect(&rect,&rect,&client); - /* TODO: Wrap the input if needed */ - } - - if (root_context->IMC.cfCompForm.dwStyle == CFS_DEFAULT) - { - /* make sure we are on the desktop */ - mon_info.cbSize = sizeof(mon_info); - GetMonitorInfoW(monitor, &mon_info); - - if (rect.bottom > mon_info.rcWork.bottom) - { - int shift = rect.bottom - mon_info.rcWork.bottom; - rect.top -= shift; - rect.bottom -= shift; - } - if (rect.left < 0) - { - rect.right -= rect.left; - rect.left = 0; - } - if (rect.right > mon_info.rcWork.right) - { - int shift = rect.right - mon_info.rcWork.right; - rect.left -= shift; - rect.right -= shift; - } - } - - SetWindowPos(hwnd, HWND_TOPMOST, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE); - - TextOutW(hdc, offX,offY, CompString, compstr->dwCompStrLen); - - if (oldfont) - SelectObject(hdc,oldfont); - } - - ImmUnlockIMCC(root_context->IMC.hCompStr); - - EndPaint(hwnd,&ps); -} - -static void UpdateDataInDefaultIMEWindow(HWND hwnd, BOOL showable) -{ - LPCOMPOSITIONSTRING compstr; - - if (root_context->IMC.hCompStr) - compstr = ImmLockIMCC(root_context->IMC.hCompStr); + if (imc) + data = imc; else - compstr = NULL; + return FALSE; - if (compstr == NULL || compstr->dwCompStrLen == 0) - ShowWindow(hwndDefault,SW_HIDE); - else if (showable) - ShowWindow(hwndDefault,SW_SHOWNOACTIVATE); + if (!data->immKbd->hIME || !data->immKbd->pImeToAsciiEx) + return FALSE; - RedrawWindow(hwnd,NULL,NULL,RDW_ERASENOW|RDW_INVALIDATE); + GetKeyboardState(state); + scancode = lKeyData >> 0x10 & 0xff; - if (compstr != NULL) - ImmUnlockIMCC(root_context->IMC.hCompStr); + list = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list_count * sizeof(TRANSMSG) + sizeof(DWORD)); + ((DWORD*)list)[0] = list_count; + + if (data->immKbd->imeInfo.fdwProperty & IME_PROP_KBD_CHAR_FIRST) + { + WCHAR chr; + + if (!is_himc_ime_unicode(data)) + ToAscii(data->lastVK, scancode, state, &chr, 0); + else + ToUnicodeEx(data->lastVK, scancode, state, &chr, 1, 0, GetKeyboardLayout(0)); + uVirtKey = MAKELONG(data->lastVK,chr); + } + else + uVirtKey = data->lastVK; + + msg_count = data->immKbd->pImeToAsciiEx(uVirtKey, scancode, state, list, 0, imc); + TRACE("%i messages generated\n",msg_count); + if (msg_count && msg_count <= list_count) + { + UINT i; + LPTRANSMSG msgs = (LPTRANSMSG)((LPBYTE)list + sizeof(DWORD)); + + for (i = 0; i < msg_count; i++) + ImmInternalPostIMEMessage(data, msgs[i].message, msgs[i].wParam, msgs[i].lParam); + } + else if (msg_count > list_count) + ImmGenerateMessage(imc); + + HeapFree(GetProcessHeap(),0,list); + + data->lastVK = VK_PROCESSKEY; + + return (msg_count > 0); } -/* - * The window proc for the default IME window - */ -static LRESULT WINAPI IME_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) +/*********************************************************************** +* ImmProcessKey(IMM32.@) +* ( Undocumented, called from user32.dll ) +*/ +BOOL WINAPI ImmProcessKey(HWND hwnd, HKL hKL, UINT vKey, LPARAM lKeyData, DWORD unknown) { - LRESULT rc = 0; + InputContextData *data; + HIMC imc = ImmGetContext(hwnd); + BYTE state[256]; - TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", msg, (UINT)wParam, - (UINT)lParam); + TRACE("%p %p %x %x %x\n",hwnd, hKL, vKey, (UINT)lKeyData, unknown); - switch(msg) - { - case WM_PAINT: - PaintDefaultIMEWnd(hwnd); - return FALSE; + if (imc) + data = imc; + else + return FALSE; - case WM_NCCREATE: - return TRUE; + if (!data->immKbd->hIME || !data->immKbd->pImeProcessKey) + return FALSE; - case WM_CREATE: - SetWindowTextA(hwnd,"Wine Ime Active"); - return TRUE; + GetKeyboardState(state); + if (data->immKbd->pImeProcessKey(imc, vKey, lKeyData, state)) + { + data->lastVK = vKey; + return TRUE; + } - case WM_SETFOCUS: - if (wParam) - SetFocus((HWND)wParam); - else - FIXME("Received focus, should never have focus\n"); - break; - case WM_IME_COMPOSITION: - TRACE("IME message %s, 0x%x, 0x%x (%i)\n", - "WM_IME_COMPOSITION", (UINT)wParam, (UINT)lParam, - root_context->bRead); - if (lParam & GCS_RESULTSTR) - IMM_PostResult(root_context); - else - UpdateDataInDefaultIMEWindow(hwnd,TRUE); - break; - case WM_IME_STARTCOMPOSITION: - TRACE("IME message %s, 0x%x, 0x%x\n", - "WM_IME_STARTCOMPOSITION", (UINT)wParam, (UINT)lParam); - root_context->IMC.hWnd = GetFocus(); - ShowWindow(hwndDefault,SW_SHOWNOACTIVATE); - break; - case WM_IME_ENDCOMPOSITION: - TRACE("IME message %s, 0x%x, 0x%x\n", - "WM_IME_ENDCOMPOSITION", (UINT)wParam, (UINT)lParam); - ShowWindow(hwndDefault,SW_HIDE); - break; - case WM_IME_SELECT: - TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_SELECT", - (UINT)wParam, (UINT)lParam); - break; - case WM_IME_CONTROL: - TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_CONTROL", - (UINT)wParam, (UINT)lParam); - rc = 1; - break; - case WM_IME_NOTIFY: - TRACE("!! IME NOTIFY\n"); - break; - default: - TRACE("Non-standard message 0x%x\n",msg); - } - /* check the MSIME messages */ - if (msg == WM_MSIME_SERVICE) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_SERVICE", - (UINT)wParam, (UINT)lParam); - rc = FALSE; - } - else if (msg == WM_MSIME_RECONVERTOPTIONS) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTOPTIONS", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_MOUSE) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_MOUSE", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_RECONVERTREQUEST) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTREQUEST", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_RECONVERT) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERT", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_QUERYPOSITION) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_QUERYPOSITION", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_DOCUMENTFEED) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_DOCUMENTFEED", - (UINT)wParam, (UINT)lParam); - } - /* DefWndProc if not an IME message */ - else if (!rc && !((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) || - (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP))) - rc = DefWindowProcW(hwnd,msg,wParam,lParam); - - return rc; + data->lastVK = VK_PROCESSKEY; + return FALSE; +} + +/*********************************************************************** +* ImmDisableTextFrameService(IMM32.@) +*/ +BOOL WINAPI ImmDisableTextFrameService(DWORD idThread) +{ + FIXME("Stub\n"); + return FALSE; } diff --git a/reactos/dll/win32/imm32/imm32.spec b/reactos/dll/win32/imm32/imm32.spec index 0ecd1f93fa8..0d053627d50 100644 --- a/reactos/dll/win32/imm32/imm32.spec +++ b/reactos/dll/win32/imm32/imm32.spec @@ -5,12 +5,13 @@ @ stdcall ImmConfigureIMEW(long long long ptr) @ stdcall ImmCreateContext() @ stdcall ImmCreateIMCC(long) -@ stub ImmCreateSoftKeyboard +@ stdcall ImmCreateSoftKeyboard(long long long long) @ stdcall ImmDestroyContext(long) @ stdcall ImmDestroyIMCC(long) -@ stub ImmDestroySoftKeyboard +@ stdcall ImmDestroySoftKeyboard(long) @ stdcall ImmDisableIME(long) @ stdcall ImmDisableIme(long) ImmDisableIME +@ stdcall ImmDisableTextFrameService(long) @ stub ImmEnumInputContext @ stdcall ImmEnumRegisterWordA(long ptr str long str ptr) @ stdcall ImmEnumRegisterWordW(long ptr wstr long wstr ptr) @@ -72,15 +73,15 @@ @ stub ImmLockImeDpi @ stdcall ImmNotifyIME(long long long long) @ stub ImmPenAuxInput -@ stub ImmProcessKey +@ stdcall ImmProcessKey(long long long long long) @ stub ImmPutImeMenuItemsIntoMappedFile @ stdcall ImmReSizeIMCC(long long) @ stub ImmRegisterClient @ stdcall ImmRegisterWordA(long str long str) @ stdcall ImmRegisterWordW(long wstr long wstr) @ stdcall ImmReleaseContext(long long) -@ stub ImmRequestMessageA -@ stub ImmRequestMessageW +@ stdcall ImmRequestMessageA(ptr long long) +@ stdcall ImmRequestMessageW(ptr long long) @ stub ImmSendIMEMessageExA @ stub ImmSendIMEMessageExW @ stub ImmSendMessageToActiveDefImeWndW @@ -96,10 +97,10 @@ #@ stdcall ImmSetHotKey(long long long ptr) user32.CliImmSetHotKey @ stdcall ImmSetOpenStatus(long long) @ stdcall ImmSetStatusWindowPos(long ptr) -@ stub ImmShowSoftKeyboard +@ stdcall ImmShowSoftKeyboard(long long) @ stdcall ImmSimulateHotKey(long long) @ stub ImmSystemHandler -@ stub ImmTranslateMessage +@ stdcall ImmTranslateMessage(long long long long) @ stub ImmUnlockClientImc @ stdcall ImmUnlockIMC(long) @ stdcall ImmUnlockIMCC(long) From fcaa30c5418b514c7df20b06e0087c959333eba3 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 7 Mar 2010 11:51:02 +0000 Subject: [PATCH 190/211] Polish translation update by Maciej Bialas. svn path=/trunk/; revision=45988 --- reactos/base/applications/paint/lang/pl-PL.rc | 16 +++--- reactos/base/applications/rapps/lang/pl-PL.rc | 50 +++++++++---------- reactos/base/setup/reactos/lang/pl-PL.rc | 22 ++++---- reactos/base/shell/cmd/lang/pl-PL.rc | 36 ++++++------- reactos/dll/cpl/desk/lang/pl-PL.rc | 24 ++++----- reactos/dll/win32/netid/lang/pl-PL.rc | 8 +-- reactos/dll/win32/shell32/lang/pl-PL.rc | 2 +- 7 files changed, 79 insertions(+), 79 deletions(-) diff --git a/reactos/base/applications/paint/lang/pl-PL.rc b/reactos/base/applications/paint/lang/pl-PL.rc index 3449a3add71..b37039a4def 100644 --- a/reactos/base/applications/paint/lang/pl-PL.rc +++ b/reactos/base/applications/paint/lang/pl-PL.rc @@ -49,7 +49,7 @@ BEGIN MENUITEM SEPARATOR POPUP "Powiêkszenie" BEGIN - POPUP "User defined" + POPUP "Zdefiniowane przez u¿ytkownika" BEGIN MENUITEM "12,5%", IDM_VIEWZOOM125 MENUITEM "25%", IDM_VIEWZOOM25 @@ -60,8 +60,8 @@ BEGIN MENUITEM "800%", IDM_VIEWZOOM800 END MENUITEM SEPARATOR - MENUITEM "Show grid", IDM_VIEWSHOWGRID - MENUITEM "Show miniature", IDM_VIEWSHOWMINIATURE + MENUITEM "Poka¿ siatkê", IDM_VIEWSHOWGRID + MENUITEM "Poka¿ miniaturê", IDM_VIEWSHOWMINIATURE END MENUITEM "Pe³ny ekran\tCtrl+F", IDM_VIEWFULLSCREEN END @@ -181,7 +181,7 @@ BEGIN IDS_INFOTEXT, "Paint dla ReactOS jest dostêpny na licencji GNU Lesser General Public License (LGPL) wersja 3 (www.gnu.org)" IDS_SAVEPROMPTTEXT, "Czy chcesz zapisaæ zmiany do %s?" IDS_DEFAULTFILENAME, "Nienazwany.bmp" - IDS_MINIATURETITLE, "Miniature" + IDS_MINIATURETITLE, "Miniatura" IDS_TOOLTIP1, "Zaznaczenie dowolne" IDS_TOOLTIP2, "Zaznaczenie" IDS_TOOLTIP3, "Gumka" @@ -190,16 +190,16 @@ BEGIN IDS_TOOLTIP6, "Przybli¿enie" IDS_TOOLTIP7, "O³ówek" IDS_TOOLTIP8, "Pêdzel" - IDS_TOOLTIP9, "Spray" + IDS_TOOLTIP9, "Aerograf" IDS_TOOLTIP10, "Tekst" IDS_TOOLTIP11, "Linia" IDS_TOOLTIP12, "Krzywa Beziera" IDS_TOOLTIP13, "Prostok¹t" - IDS_TOOLTIP14, "Polygon" + IDS_TOOLTIP14, "Wielok¹t" IDS_TOOLTIP15, "Elipsa" IDS_TOOLTIP16, "Zaokr¹glony Prostok¹t" IDS_OPENFILTER, "Pliki Bitmapy (*.bmp;*.dib)\1*.bmp;*.dib\1Wszystkie pliki (*.*)\1*.*\1" IDS_SAVEFILTER, "Bitmapa 24 bit (*.bmp;*.dib)\1*.bmp;*.dib\1" - IDS_FILESIZE, "%d bytes" - IDS_PRINTRES, "%d x %d pixels per meter" + IDS_FILESIZE, "%d bajtów" + IDS_PRINTRES, "%d x %d pikseli na metr" END diff --git a/reactos/base/applications/rapps/lang/pl-PL.rc b/reactos/base/applications/rapps/lang/pl-PL.rc index fc79e8a205b..60fd20b7530 100644 --- a/reactos/base/applications/rapps/lang/pl-PL.rc +++ b/reactos/base/applications/rapps/lang/pl-PL.rc @@ -16,7 +16,7 @@ BEGIN MENUITEM "&Odinstaluj",ID_UNINSTALL MENUITEM "&Modyfikuj", ID_MODIFY MENUITEM SEPARATOR - MENUITEM "&Remove from Registry", ID_REGREMOVE + MENUITEM "&Usuñ z rejestru", ID_REGREMOVE MENUITEM SEPARATOR MENUITEM "O&dœwie¿", ID_REFRESH END @@ -44,7 +44,7 @@ BEGIN MENUITEM "&odinstaluj", ID_UNINSTALL MENUITEM "&Modyfikuj", ID_MODIFY MENUITEM SEPARATOR - MENUITEM "&Remove from Registry", ID_REGREMOVE + MENUITEM "&Usuñ z rejestru", ID_REGREMOVE MENUITEM SEPARATOR MENUITEM "&Odœwie¿", ID_REFRESH END @@ -52,37 +52,37 @@ END IDD_SETTINGS_DIALOG DIALOGEX DISCARDABLE 0, 0, 250, 144 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Settings" +CAPTION "Ustawienia" FONT 8, "MS Shell Dlg" BEGIN - GROUPBOX "General", -1, 4, 2, 240, 61 - AUTOCHECKBOX "&Save window position", IDC_SAVE_WINDOW_POS, 15, 12, 219, 12 - AUTOCHECKBOX "&Update the list of accessible programs at start", IDC_UPDATE_AVLIST, 15, 29, 219, 12 - AUTOCHECKBOX "&Log of installation and removal of programs", IDC_LOG_ENABLED, 15, 46, 219, 12 + GROUPBOX "Ogólne", -1, 4, 2, 240, 61 + AUTOCHECKBOX "&Zapisz pozycjê okna", IDC_SAVE_WINDOW_POS, 15, 12, 219, 12 + AUTOCHECKBOX "&Aktualizuj listê dostêpnych programów przy ka¿dym uruchomieniu", IDC_UPDATE_AVLIST, 15, 29, 219, 12 + AUTOCHECKBOX "Zap&isuj dziennik instalacji i usuwania programów", IDC_LOG_ENABLED, 15, 46, 219, 12 - GROUPBOX "Downloading", -1, 4, 65, 240, 51 - LTEXT "Folder for downloadings:", -1, 16, 75, 100, 9 + GROUPBOX "Pobieranie", -1, 4, 65, 240, 51 + LTEXT "Katalog dla pobranych plików:", -1, 16, 75, 100, 9 EDITTEXT IDC_DOWNLOAD_DIR_EDIT, 15, 86, 166, 12, WS_CHILD | WS_VISIBLE | WS_GROUP - PUSHBUTTON "&Choose", IDC_CHOOSE, 187, 85, 50, 14 - AUTOCHECKBOX "&Delete installers of programs after installation", IDC_DEL_AFTER_INSTALL, 16, 100, 218, 12 + PUSHBUTTON "&Wybierz", IDC_CHOOSE, 187, 85, 50, 14 + AUTOCHECKBOX "&Usuñ instalatory programów po ich zainstalowaniu", IDC_DEL_AFTER_INSTALL, 16, 100, 218, 12 - PUSHBUTTON "Default", IDC_DEFAULT_SETTINGS, 8, 124, 60, 14 + PUSHBUTTON "Domyœlne", IDC_DEFAULT_SETTINGS, 8, 124, 60, 14 PUSHBUTTON "OK", IDOK, 116, 124, 60, 14 - PUSHBUTTON "Cancel", IDCANCEL, 181, 124, 60, 14 + PUSHBUTTON "Anuluj", IDCANCEL, 181, 124, 60, 14 END IDD_INSTALL_DIALOG DIALOGEX DISCARDABLE 0, 0, 216, 97 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Program installation" +CAPTION "Instalacja programu" FONT 8, "MS Shell Dlg" BEGIN LTEXT "...", IDC_INSTALL_TEXT, 4, 5, 209, 35 - AUTORADIOBUTTON "&Install from a disk (CD or DVD)", IDC_CD_INSTALL, 10, 46, 197, 11, WS_GROUP - AUTORADIOBUTTON "&Download and install", IDC_DOWNLOAD_INSTALL, 10, 59, 197, 11, NOT WS_TABSTOP + AUTORADIOBUTTON "&Zainstaluj z dysku (CD or DVD)", IDC_CD_INSTALL, 10, 46, 197, 11, WS_GROUP + AUTORADIOBUTTON "&Pobierz i zainstaluj", IDC_DOWNLOAD_INSTALL, 10, 59, 197, 11, NOT WS_TABSTOP PUSHBUTTON "OK", IDOK, 86, 78, 60, 14 - PUSHBUTTON "Cancel", IDCANCEL, 150, 78, 60, 14 + PUSHBUTTON "Anuluj", IDCANCEL, 150, 78, 60, 14 END IDD_DOWNLOAD_DIALOG DIALOGEX LOADONCALL MOVEABLE DISCARDABLE 0, 0, 220, 76 @@ -101,7 +101,7 @@ CAPTION "O programie" FONT 8, "MS Shell Dlg" BEGIN LTEXT "ReactOS Applications Manager\nCopyright (C) 2009\nby Dmitry Chapyshev (dmitry@reactos.org)", IDC_STATIC, 48, 7, 130, 39 - PUSHBUTTON "Close", IDOK, 133, 46, 50, 14 + PUSHBUTTON "Zamknij", IDOK, 133, 46, 50, 14 ICON IDI_MAIN, IDC_STATIC, 10, 10, 7, 30 END @@ -139,7 +139,7 @@ BEGIN IDS_INFO_INSTLOCATION "\nScie¿ka instalacji: " IDS_INFO_INSTALLSRC "\nród³o instalacji: " IDS_INFO_UNINSTALLSTR "\nKomenda deinstalacji: " - IDS_INFO_MODIFYPATH "\nModify Path: " + IDS_INFO_MODIFYPATH "\nModyfikacja œcie¿ki instalacji: " IDS_INFO_INSTALLDATE "\nData instalacji: " END @@ -186,10 +186,10 @@ BEGIN IDS_AVAILABLEFORINST "Dostêpne" IDS_UPDATES "Uaktualnienia" IDS_APPLICATIONS "Aplikacje" - IDS_CHOOSE_FOLDER_TEXT "Choose a folder which will be used for downloading of programs:" - IDS_CHOOSE_FOLDER_ERROR "You have specified a nonexistent folder!" - IDS_USER_NOT_ADMIN "You should be administrator for start ""ReactOS Applications Manager""!" - IDS_APP_REG_REMOVE "Are you sure you want to delete the data on the installed program from the registry?" - IDS_INFORMATION "Information" - IDS_UNABLE_TO_REMOVE "Unable to remove data on the program from the registry!" + IDS_CHOOSE_FOLDER_TEXT "Wybierz katalog w którym bêda zapisywane pobrane programy:" + IDS_CHOOSE_FOLDER_ERROR "Wybra³eœ nieistniej¹cy katalog!" + IDS_USER_NOT_ADMIN "Musisz mieæ uprawnienia administratora aby uruchomiæ ""ReactOS Applications Manager""!" + IDS_APP_REG_REMOVE "Czy na pewno chcesz usun¹æ wpis tego programu z rejestru?" + IDS_INFORMATION "Informacja" + IDS_UNABLE_TO_REMOVE "Nie mo¿na by³o usun¹æ wpisu z rejestru!" END diff --git a/reactos/base/setup/reactos/lang/pl-PL.rc b/reactos/base/setup/reactos/lang/pl-PL.rc index 97cff875b7d..31c951397cf 100644 --- a/reactos/base/setup/reactos/lang/pl-PL.rc +++ b/reactos/base/setup/reactos/lang/pl-PL.rc @@ -66,25 +66,25 @@ BEGIN LISTBOX IDC_PARTITION, 20,12,278,142,LBS_HASSTRINGS | WS_VSCROLL PUSHBUTTON "&Stwórz", IDC_PARTCREATE, 20,155,50,15 PUSHBUTTON "&Usuñ", IDC_PARTDELETE, 76,155,50,15 - PUSHBUTTON "D&river", IDC_DEVICEDRIVER, 162,155,50,15, WS_DISABLED + PUSHBUTTON "s&terownik", IDC_DEVICEDRIVER, 162,155,50,15, WS_DISABLED PUSHBUTTON "&Opcje zaawansowane...", IDC_PARTMOREOPTS, 218,155,80,15 LTEXT "Naciœnij Dalej aby rozpocz¹æ proces instalacji.", IDC_STATIC, 10, 180 ,277, 20 END IDD_PARTITION DIALOGEX DISCARDABLE 0, 0, 145, 90 STYLE WS_VISIBLE|WS_CAPTION|WS_THICKFRAME -CAPTION "Create Partition" +CAPTION "Stwórz partycjê" FONT 8, "MS Shell Dlg" BEGIN CONTROL "",IDC_UPDOWN1,"msctls_updown32", WS_VISIBLE,104,22,9,13 - CONTROL "Create and format partition",IDC_STATIC,"Button",BS_GROUPBOX,7,5,129,57 - LTEXT "Size:",IDC_STATIC, 13,24,27,9 + CONTROL "Stwórz i sformatuj partycjê",IDC_STATIC,"Button",BS_GROUPBOX,7,5,129,57 + LTEXT "Rozmiar:",IDC_STATIC, 13,24,27,9 EDITTEXT IDC_PARTSIZE,52,23,53,13, WS_VISIBLE|WS_TABSTOP LTEXT "GB",IDC_UNIT, 117,24,14,9 - LTEXT "Filesystem:",IDC_STATIC,13,46,35,9 + LTEXT "System plików:",IDC_STATIC,13,46,35,9 CONTROL "",IDC_FSTYPE,"ComboBox",WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,52,42,79,50 PUSHBUTTON "&OK",IDOK,35,68,47,15, WS_VISIBLE|WS_TABSTOP - PUSHBUTTON "&Cancel",IDCANCEL,87,68,47,15, WS_VISIBLE|WS_TABSTOP + PUSHBUTTON "&Anuluj",IDCANCEL,87,68,47,15, WS_VISIBLE|WS_TABSTOP END IDD_BOOTOPTIONS DIALOGEX DISCARDABLE 0, 0, 305, 105 @@ -105,11 +105,11 @@ END IDD_SUMMARYPAGE DIALOGEX 0, 0, 317, 193 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "ReactOS Setup" +CAPTION "Instalator ReactOS" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "Installation summary", IDC_ACTION, "Button", BS_GROUPBOX, 10,0,297,172 - LTEXT "Click Next to start the installation process.", IDC_STATIC, 10, 180 ,277, 20 + CONTROL "Podsumowanie instalacji", IDC_ACTION, "Button", BS_GROUPBOX, 10,0,297,172 + LTEXT "Kliknij Dalej aby rozpocz¹æ proces instalacji.", IDC_STATIC, 10, 180 ,277, 20 END IDD_PROCESSPAGE DIALOGEX 0, 0, 317, 193 @@ -151,8 +151,8 @@ BEGIN IDS_PROCESSSUBTITLE "Przygotuj i sformatuj partycjê, skopiuj pliki, skopiuj i zainstaluj bootloader" IDS_RESTARTTITLE "Pierwszy etap instalacji zakoñczony sukcesem" IDS_RESTARTSUBTITLE "Pierwszy etap instalacji zosta³ zakoñczony, uruchom ponownie komputer aby przejœæ do drugiego etapu" - IDS_SUMMARYTITLE "Installation Summary" - IDS_SUMMARYSUBTITLE "List installation properties to check before apply to the installation device" + IDS_SUMMARYTITLE "Podsumowanie instalacji" + IDS_SUMMARYSUBTITLE "SprawdŸ ustawienia instalacji przed dokonaniem zmian na dysku" IDS_ABORTSETUP "Instalacja ReactOS nie zosta³a ukoñczona na tym komputerze. Jeœli teraz zakoñczysz instalacjê, bêdziesz musia³ uruchomiæ Instalator ponownie, aby zainstalowaæ Reactos. Na pewno zakoñczyæ?" IDS_ABORTSETUP2 "Przerwaæ instalacjê?" END diff --git a/reactos/base/shell/cmd/lang/pl-PL.rc b/reactos/base/shell/cmd/lang/pl-PL.rc index 58bdadfc262..f8d2cb79a02 100644 --- a/reactos/base/shell/cmd/lang/pl-PL.rc +++ b/reactos/base/shell/cmd/lang/pl-PL.rc @@ -8,13 +8,13 @@ LANGUAGE LANG_POLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE BEGIN -STRING_ASSOC_HELP, "Modify file extension associations.\n\n\ -assoc [.ext[=[FileType]]]\n\ +STRING_ASSOC_HELP, "Modyfikuje skojarzenia rozszerzeñ plików.\n\n\ +assoc [.ext[=[typPliku]]]\n\ \n\ -assoc (print all associations)\n\ -assoc .ext (print specific association)\n\ -assoc .ext= (remove specific association)\n\ -assoc .ext=FileType (add new association)\n" +assoc (wyœwietla wszystkie skojarzenia)\n\ +assoc .ext (wyœwietla okreœlone skojarzenie)\n\ +assoc .ext= (usuwa okreœlone skojarzenie)\n\ +assoc .ext=typPliku (dodaje nowe skojarzenie)\n" STRING_ATTRIB_HELP, "Wyœwietla lub zmienia atrybuty plików.\n\n\ ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] nazwa_pliku ...\n\ @@ -298,12 +298,12 @@ STRING_LOCALE_HELP1, "Czas bie STRING_MKDIR_HELP, "Tworzy katalog.\n\n\ MKDIR [napêd:]œcie¿ka\nMD [napêd:]œcie¿ka" -STRING_MKLINK_HELP, "Creates a filesystem link object.\n\n\ -MKLINK [/D | /H | /J] linkname target\n\n\ - /D Indicates that the symbolic link target is a directory.\n\ - /H Create a hard link.\n\ - /J Create a directory junction.\n\n\ -If neither /H or /J is specified, a symbolic link is created." +STRING_MKLINK_HELP, "Tworzy dowi¹zanie obiektu w systemie plików.\n\n\ +MKLINK [/D | /H | /J] nazwa_linku element_docelowy\n\n\ + /D Oznacza, ¿e dowi¹zanie symboliczne elementu docelowego jest katalogiem.\n\ + /H Tworzy dowi¹zanie twarde.\n\ + /J Tworzy punkt po³¹czenia katalogów.\n\n\ +Jeœli nie zosta³y u¿yte zarówno /H jak i /J, zostanie utworzone dowi¹zanie symboliczne." STRING_MEMMORY_HELP1, "Wyœwietla iloœæ pamiêci systemowej.\n\nMEMORY" @@ -546,7 +546,7 @@ IF Przetwarzanie warunkowe w programach wsadowych.\n\ LABEL Tworzy, zmienia lub kasuje etykietê woluminu w danym napêdzie.\n\ MD Tworzy katalog.\n\ MKDIR Tworzy katalog.\n\ -MKLINK Creates a filesystem link object.\n\ +MKLINK Tworzy dowi¹zanie obiektu w systemie plików.\n\ MOVE Przenosi jeden lub wiêcej plików z jednego katalogu do drugiego.\n\ PATH Wyœwietla lub ustawia œcie¿ki dostêpu dla programów.\n\ PAUSE Zawiesza przetwarzanie programu wsadowego i wyœwietla komunikat.\n\ @@ -656,11 +656,11 @@ STRING_FOR_ERROR, "z STRING_SCREEN_COL, "nieprawid³owy numer kolumny" STRING_SCREEN_ROW, "nieprawid³owy numer rzêdu" STRING_TIMER_TIME "Stoper %d czas - %s: " -STRING_MKLINK_CREATED_SYMBOLIC, "Symbolic link created for %s <<===>> %s\n" -STRING_MKLINK_CREATED_HARD, "Hard link created for %s <<===>> %s\n" -STRING_MKLINK_CREATED_JUNCTION, "Junction created for %s <<===>> %s\n" -STRING_MORE, "More? " -STRING_CANCEL_BATCH_FILE, "\r\nCtrl-Break pressed. Cancel batch file? (Tak/Nie/Zawsze) " +STRING_MKLINK_CREATED_SYMBOLIC, "Dowi¹zanie symboliczne utworzone dla %s <<===>> %s\n" +STRING_MKLINK_CREATED_HARD, "Dowi¹zanie twarde utworzone dla %s <<===>> %s\n" +STRING_MKLINK_CREATED_JUNCTION, "Punkt dowi¹zania katalogów utworzony dla %s <<===>> %s\n" +STRING_MORE, "Wiêcej? " +STRING_CANCEL_BATCH_FILE, "\r\nWciœniêto Ctrl-Break. Anulowaæ wykonanie pliku wsadowego? (Tak/Nie/Zawsze) " STRING_INVALID_OPERAND, "Nieprawid³owy argument operatora." STRING_EXPECTED_CLOSE_PAREN, "Oczekiwano ')'." diff --git a/reactos/dll/cpl/desk/lang/pl-PL.rc b/reactos/dll/cpl/desk/lang/pl-PL.rc index 0c4761b23e3..01d7c796d70 100644 --- a/reactos/dll/cpl/desk/lang/pl-PL.rc +++ b/reactos/dll/cpl/desk/lang/pl-PL.rc @@ -63,7 +63,7 @@ BEGIN WS_VISIBLE | WS_BORDER, 7, 7, 232, 120 LTEXT "Schemat kolorów", IDC_STATIC, 7, 140, 64, 7 COMBOBOX IDC_APPEARANCE_UI_ITEM, 7, 169, 120, 54, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&Effects...", IDC_APPEARANCE_EFFECTS, 182, 150, 56, 15 + PUSHBUTTON "&Efekty...", IDC_APPEARANCE_EFFECTS, 182, 150, 56, 15 PUSHBUTTON "Zaawansowane", IDC_APPEARANCE_ADVANCED, 182, 170, 56, 15 END @@ -108,24 +108,24 @@ END IDD_EFFAPPEARANCE DIALOGEX DISCARDABLE 0, 0, 285, 185 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE -CAPTION "Effects" +CAPTION "Efekty" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "&Use the following transition effect for menus and tooltips:",IDC_EFFAPPEARANCE_ANIMATION,"button", + CONTROL "&U¿yj nastêpuj¹cego efektu przejœcia dla menu i etykiet narzêdzi:",IDC_EFFAPPEARANCE_ANIMATION,"button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 5, 285, 19 COMBOBOX IDC_EFFAPPEARANCE_ANIMATIONTYPE, 20, 25, 80, 19 , CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VSCROLL | WS_TABSTOP - CONTROL "U&se the following method to smooth edges of screen fonts:",IDC_EFFAPPEARANCE_SMOOTHING,"button", + CONTROL "U¿&yj nastêpuj¹cej metody wyg³adzania krawêdzi czcionek ekranowych:",IDC_EFFAPPEARANCE_SMOOTHING,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 42, 285, 19 COMBOBOX IDC_EFFAPPEARANCE_SMOOTHINGTYPE, 20, 62, 80, 19 , CBS_DROPDOWNLIST | CBS_HASSTRINGS | CBS_SORT | WS_VSCROLL | WS_TABSTOP | WS_DISABLED - CONTROL "Us&e large icons",IDC_EFFAPPEARANCE_LARGEICONS,"button", + CONTROL "U¿y&j du¿ych ikon",IDC_EFFAPPEARANCE_LARGEICONS,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 80, 285, 19 - CONTROL "Show sh&adows under menus",IDC_EFFAPPEARANCE_SETDROPSHADOW,"button", + CONTROL "Pok&a¿ cienie pod menu",IDC_EFFAPPEARANCE_SETDROPSHADOW,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 95, 285, 19 - CONTROL "Show &window contents while dragging",IDC_EFFAPPEARANCE_DRAGFULLWINDOWS,"button", + CONTROL "Poka¿ za&wartoœæ okna podczas przeci¹gania",IDC_EFFAPPEARANCE_DRAGFULLWINDOWS,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 110, 285, 19 - CONTROL "&Hide underlined letters for keyboard navigation until I press the Alt key",IDC_EFFAPPEARANCE_KEYBOARDCUES,"button", + CONTROL "U&kryj podkreœlenie liter do nawigacji klawiatur¹ dopóki nie nacisnê klawisza Alt",IDC_EFFAPPEARANCE_KEYBOARDCUES,"button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 125, 285, 19 - PUSHBUTTON "Cancel", IDCANCEL, 226, 165, 50, 14 + PUSHBUTTON "Anuluj", IDCANCEL, 226, 165, 50, 14 DEFPUSHBUTTON "OK", IDOK, 172, 165, 50, 14 END @@ -188,13 +188,13 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_SLIDEEFFECT "Slide effect" - IDS_FADEEFFECT "Fade effect" + IDS_SLIDEEFFECT "Efekt przewijania" + IDS_FADEEFFECT "Efekt przejœcia" END STRINGTABLE DISCARDABLE BEGIN - IDS_STANDARDEFFECT "Standard" + IDS_STANDARDEFFECT "Standardowe" IDS_CLEARTYPEEFFECT "ClearType" END diff --git a/reactos/dll/win32/netid/lang/pl-PL.rc b/reactos/dll/win32/netid/lang/pl-PL.rc index 2bb82a0e6e2..3f0cbe9812d 100644 --- a/reactos/dll/win32/netid/lang/pl-PL.rc +++ b/reactos/dll/win32/netid/lang/pl-PL.rc @@ -75,12 +75,12 @@ BEGIN 22 "Witamy w grupie roboczej %1." 23 "Witamy w domenie %1." 24 "Musisz zrestartowaæ komputer aby zmiany odnios³y skutek." - 25 "You can change the name and the membership of this computer. Changes may affect access to network resources." + 25 "Mo¿esz zmieniæ nazwê i cz³onkostwo tego komputera. Zmiany mog¹ mieæ wp³yw na dostêp do zasobów sieciowych." 1021 "Uwaga: Tylko Administratorzy mog¹ zmieniaæ identyfikator tego komputera." 1022 "Uwaga: Identyfikator tego komputera nie zosta³ zmieniony, powód:" - 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?" + 1030 "Nowa nazwa komputera ""%s"" zawiera niedozwolone znaki. Do niedozwolonych znaków nale¿¹ ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / oraz ?" 3210 "&Szczegó³y >>" 3220 "<< &Szczegó³y" - 4000 "Information" - 4001 "Can't set new a computer name!" + 4000 "Informacja" + 4001 "Nie mo¿na zmieniæ nazwy komputera!" END diff --git a/reactos/dll/win32/shell32/lang/pl-PL.rc b/reactos/dll/win32/shell32/lang/pl-PL.rc index c7877828959..b6d33a64fd4 100644 --- a/reactos/dll/win32/shell32/lang/pl-PL.rc +++ b/reactos/dll/win32/shell32/lang/pl-PL.rc @@ -755,5 +755,5 @@ BEGIN IDS_INSTALLNEWFONT "Zainstaluj Now¹ Czcionkê..." IDS_DEFAULT_CLUSTER_SIZE "Domyœlny rozmiar jednostki alokacji" - IDS_COPY_OF "Copy of" + IDS_COPY_OF "Kopia" END From 96363863d3d09768f2a54511b486d9a40f12c7a9 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 7 Mar 2010 12:48:05 +0000 Subject: [PATCH 191/211] [HHCTRL.OCX] sync hhctrl.ocx to wine 1.1.40 svn path=/trunk/; revision=45990 --- reactos/dll/win32/hhctrl.ocx/Cs.rc | 2 + reactos/dll/win32/hhctrl.ocx/Da.rc | 2 + reactos/dll/win32/hhctrl.ocx/De.rc | 12 +- reactos/dll/win32/hhctrl.ocx/El.rc | 2 + reactos/dll/win32/hhctrl.ocx/En.rc | 12 + reactos/dll/win32/hhctrl.ocx/Es.rc | 63 +++ reactos/dll/win32/hhctrl.ocx/Fi.rc | 2 + reactos/dll/win32/hhctrl.ocx/Fr.rc | 13 +- reactos/dll/win32/hhctrl.ocx/Hu.rc | 2 + reactos/dll/win32/hhctrl.ocx/Ko.rc | 2 + reactos/dll/win32/hhctrl.ocx/Lt.rc | 4 +- reactos/dll/win32/hhctrl.ocx/Nl.rc | 2 + reactos/dll/win32/hhctrl.ocx/No.rc | 2 + reactos/dll/win32/hhctrl.ocx/Pl.rc | 2 + reactos/dll/win32/hhctrl.ocx/Pt.rc | 2 + reactos/dll/win32/hhctrl.ocx/Ru.rc | 61 +-- reactos/dll/win32/hhctrl.ocx/Si.rc | 4 +- reactos/dll/win32/hhctrl.ocx/Sv.rc | 2 + reactos/dll/win32/hhctrl.ocx/Tr.rc | 2 + reactos/dll/win32/hhctrl.ocx/Uk.rc | 75 ++++ reactos/dll/win32/hhctrl.ocx/Zh.rc | 4 +- reactos/dll/win32/hhctrl.ocx/chm.c | 6 +- reactos/dll/win32/hhctrl.ocx/content.c | 131 +------ reactos/dll/win32/hhctrl.ocx/help.c | 513 ++++++++++++++++++++++++- reactos/dll/win32/hhctrl.ocx/hhctrl.c | 37 +- reactos/dll/win32/hhctrl.ocx/hhctrl.h | 50 ++- reactos/dll/win32/hhctrl.ocx/hhctrl.rc | 15 +- reactos/dll/win32/hhctrl.ocx/index.c | 295 ++++++++++++++ reactos/dll/win32/hhctrl.ocx/search.c | 246 ++++++++++++ reactos/dll/win32/hhctrl.ocx/stream.c | 179 +++++++++ reactos/dll/win32/hhctrl.ocx/stream.h | 48 +++ 31 files changed, 1590 insertions(+), 202 deletions(-) create mode 100644 reactos/dll/win32/hhctrl.ocx/Es.rc create mode 100644 reactos/dll/win32/hhctrl.ocx/Uk.rc create mode 100644 reactos/dll/win32/hhctrl.ocx/index.c create mode 100644 reactos/dll/win32/hhctrl.ocx/search.c create mode 100644 reactos/dll/win32/hhctrl.ocx/stream.c create mode 100644 reactos/dll/win32/hhctrl.ocx/stream.h diff --git a/reactos/dll/win32/hhctrl.ocx/Cs.rc b/reactos/dll/win32/hhctrl.ocx/Cs.rc index ec564d830d1..b9147627278 100644 --- a/reactos/dll/win32/hhctrl.ocx/Cs.rc +++ b/reactos/dll/win32/hhctrl.ocx/Cs.rc @@ -21,6 +21,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_CZECH, SUBLANG_DEFAULT /* Czech strings in CP1250 */ diff --git a/reactos/dll/win32/hhctrl.ocx/Da.rc b/reactos/dll/win32/hhctrl.ocx/Da.rc index e425ef0e567..1832d71c334 100644 --- a/reactos/dll/win32/hhctrl.ocx/Da.rc +++ b/reactos/dll/win32/hhctrl.ocx/Da.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_DANISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/De.rc b/reactos/dll/win32/hhctrl.ocx/De.rc index ef6e6997bd5..20b20f8c468 100644 --- a/reactos/dll/win32/hhctrl.ocx/De.rc +++ b/reactos/dll/win32/hhctrl.ocx/De.rc @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + +#pragma code_page(65001) + LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL STRINGTABLE @@ -33,14 +37,14 @@ STRINGTABLE BEGIN IDTB_EXPAND "Anzeigen" IDTB_CONTRACT "Verstecken" - IDTB_STOP "Stop" + IDTB_STOP "Stopp" IDTB_REFRESH "Aktualisieren" - IDTB_BACK "Zurück" + IDTB_BACK "Zurück" IDTB_HOME "Startseite" IDTB_SYNC "Synchronisieren" IDTB_PRINT "Drucken" IDTB_OPTIONS "Einstellungen" - IDTB_FORWARD "Vorwärts" + IDTB_FORWARD "Vorwärts" IDTB_NOTES "IDTB_NOTES" IDTB_BROWSE_FWD "IDTB_BROWSE_FWD" IDTB_BROWSE_BACK "IDT_BROWSE_BACK" @@ -52,7 +56,7 @@ BEGIN IDTB_JUMP1 "Sprung1" IDTB_JUMP2 "Sprung2" IDTB_CUSTOMIZE "Anpassen" - IDTB_ZOOM "Vergrößern" + IDTB_ZOOM "Vergrößern" IDTB_TOC_NEXT "IDTB_TOC_NEXT" IDTB_TOC_PREV "IDTB_TOC_PREV" END diff --git a/reactos/dll/win32/hhctrl.ocx/El.rc b/reactos/dll/win32/hhctrl.ocx/El.rc index dd81eb68da2..4fa79a2dcd8 100644 --- a/reactos/dll/win32/hhctrl.ocx/El.rc +++ b/reactos/dll/win32/hhctrl.ocx/El.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_GREEK, SUBLANG_DEFAULT STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/En.rc b/reactos/dll/win32/hhctrl.ocx/En.rc index 83917f6e3d6..b69383e1898 100644 --- a/reactos/dll/win32/hhctrl.ocx/En.rc +++ b/reactos/dll/win32/hhctrl.ocx/En.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE @@ -56,3 +58,13 @@ BEGIN IDTB_TOC_NEXT "IDTB_TOC_NEXT" IDTB_TOC_PREV "IDTB_TOC_PREV" END + +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_CONTENTS "&Contents" + IDS_INDEX "I&ndex" + IDS_SEARCH "&Search" + IDS_FAVORITES "Favour&ites" +END diff --git a/reactos/dll/win32/hhctrl.ocx/Es.rc b/reactos/dll/win32/hhctrl.ocx/Es.rc new file mode 100644 index 00000000000..d7681aa8ca4 --- /dev/null +++ b/reactos/dll/win32/hhctrl.ocx/Es.rc @@ -0,0 +1,63 @@ +/* + * HTML Help resources + * Spanish Language Support + * + * Copyright 2010 José Manuel Ferrer Ortiz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_CONTENTS "&Contenido" + IDS_INDEX "Ã&ndice" + IDS_SEARCH "&Buscar" + IDS_FAVORITES "Favor&itos" +END + +STRINGTABLE +BEGIN + IDTB_EXPAND "Mostrar" + IDTB_CONTRACT "Ocultar" + IDTB_STOP "Parar" + IDTB_REFRESH "Recargar" + IDTB_BACK "Atrás" + IDTB_HOME "Inicio" + IDTB_SYNC "Sincronizar" + IDTB_PRINT "Imprimir" + IDTB_OPTIONS "Opciones" + IDTB_FORWARD "Adelante" + IDTB_NOTES "IDTB_NOTES" + IDTB_BROWSE_FWD "IDTB_BROWSE_FWD" + IDTB_BROWSE_BACK "IDT_BROWSE_BACK" + IDTB_CONTENTS "IDTB_CONTENTS" + IDTB_INDEX "IDTB_INDEX" + IDTB_SEARCH "IDTB_SEARCH" + IDTB_HISTORY "IDTB_HISTORY" + IDTB_FAVORITES "IDTB_FAVORITES" + IDTB_JUMP1 "Jump1" + IDTB_JUMP2 "Jump2" + IDTB_CUSTOMIZE "Personalizar" + IDTB_ZOOM "Zoom" + IDTB_TOC_NEXT "IDTB_TOC_NEXT" + IDTB_TOC_PREV "IDTB_TOC_PREV" +END diff --git a/reactos/dll/win32/hhctrl.ocx/Fi.rc b/reactos/dll/win32/hhctrl.ocx/Fi.rc index 975ce1f49aa..825422e57d6 100644 --- a/reactos/dll/win32/hhctrl.ocx/Fi.rc +++ b/reactos/dll/win32/hhctrl.ocx/Fi.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/Fr.rc b/reactos/dll/win32/hhctrl.ocx/Fr.rc index 0e5dd4f9591..2146a3c7ae1 100644 --- a/reactos/dll/win32/hhctrl.ocx/Fr.rc +++ b/reactos/dll/win32/hhctrl.ocx/Fr.rc @@ -19,6 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE @@ -33,9 +38,9 @@ STRINGTABLE BEGIN IDTB_EXPAND "Afficher" IDTB_CONTRACT "Cacher" - IDTB_STOP "Arrêter" + IDTB_STOP "Arrêter" IDTB_REFRESH "A&ctualiser" - IDTB_BACK "Précédent" + IDTB_BACK "Précédent" IDTB_HOME "Sommaire" IDTB_SYNC "Synchroniser" IDTB_PRINT "Imprimer" @@ -49,8 +54,8 @@ BEGIN IDTB_SEARCH "IDTB_SEARCH" IDTB_HISTORY "IDTB_HISTORY" IDTB_FAVORITES "IDTB_FAVORITES" - IDTB_JUMP1 "Jump1" - IDTB_JUMP2 "Jump2" + IDTB_JUMP1 "Saut1" + IDTB_JUMP2 "Saut2" IDTB_CUSTOMIZE "Personnaliser" IDTB_ZOOM "Zoom" IDTB_TOC_NEXT "IDTB_TOC_NEXT" diff --git a/reactos/dll/win32/hhctrl.ocx/Hu.rc b/reactos/dll/win32/hhctrl.ocx/Hu.rc index 225c04a82d7..0cab8cdae81 100644 --- a/reactos/dll/win32/hhctrl.ocx/Hu.rc +++ b/reactos/dll/win32/hhctrl.ocx/Hu.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/Ko.rc b/reactos/dll/win32/hhctrl.ocx/Ko.rc index 169eb70e472..37831dfcb7c 100644 --- a/reactos/dll/win32/hhctrl.ocx/Ko.rc +++ b/reactos/dll/win32/hhctrl.ocx/Ko.rc @@ -20,6 +20,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/Lt.rc b/reactos/dll/win32/hhctrl.ocx/Lt.rc index fed6b40e400..8c813ba1ef1 100644 --- a/reactos/dll/win32/hhctrl.ocx/Lt.rc +++ b/reactos/dll/win32/hhctrl.ocx/Lt.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + /* UTF-8 */ #pragma code_page(65001) @@ -59,5 +61,3 @@ BEGIN IDTB_TOC_NEXT "IDTB_TOC_NEXT" IDTB_TOC_PREV "IDTB_TOC_PREV" END - -#pragma code_page(default) diff --git a/reactos/dll/win32/hhctrl.ocx/Nl.rc b/reactos/dll/win32/hhctrl.ocx/Nl.rc index 929ac39f6da..99c12faf10d 100644 --- a/reactos/dll/win32/hhctrl.ocx/Nl.rc +++ b/reactos/dll/win32/hhctrl.ocx/Nl.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/No.rc b/reactos/dll/win32/hhctrl.ocx/No.rc index 5ff634d02df..a76ad3147a7 100644 --- a/reactos/dll/win32/hhctrl.ocx/No.rc +++ b/reactos/dll/win32/hhctrl.ocx/No.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/Pl.rc b/reactos/dll/win32/hhctrl.ocx/Pl.rc index 40d3089af84..f3ce6f2c76c 100644 --- a/reactos/dll/win32/hhctrl.ocx/Pl.rc +++ b/reactos/dll/win32/hhctrl.ocx/Pl.rc @@ -20,6 +20,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_POLISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/Pt.rc b/reactos/dll/win32/hhctrl.ocx/Pt.rc index d196ff499b9..13476ce843f 100644 --- a/reactos/dll/win32/hhctrl.ocx/Pt.rc +++ b/reactos/dll/win32/hhctrl.ocx/Pt.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/Ru.rc b/reactos/dll/win32/hhctrl.ocx/Ru.rc index a530f80b637..0634c39da21 100644 --- a/reactos/dll/win32/hhctrl.ocx/Ru.rc +++ b/reactos/dll/win32/hhctrl.ocx/Ru.rc @@ -19,40 +19,45 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT STRINGTABLE BEGIN - IDS_CONTENTS "&Ñîäåðæàíèå" - IDS_INDEX "&Îãëàâëåíèå" - IDS_SEARCH "&Ïîèñê" - IDS_FAVORITES "&Èçáðàííîå" + IDS_CONTENTS "&Содержание" + IDS_INDEX "&Оглавление" + IDS_SEARCH "&ПоиÑк" + IDS_FAVORITES "&Избранное" END STRINGTABLE BEGIN - IDTB_EXPAND "Ïîêàçàòü" - IDTB_CONTRACT "Ñïðÿòàòü" - IDTB_STOP "Îñòàíîâèòü" - IDTB_REFRESH "Îáíîâèòü" - IDTB_BACK "Íàçàä" - IDTB_HOME " íà÷àëî" - IDTB_SYNC "Ñèíõðîíèçèðîâàòü" - IDTB_PRINT "Ïå÷àòü" - IDTB_OPTIONS "Íàñòðîéêè" - IDTB_FORWARD "Âïåð¸ä" - IDTB_NOTES "Çàïèñêè" - IDTB_BROWSE_FWD "Ïðîñìîòð âïåð¸ä" - IDTB_BROWSE_BACK "Ïðîñìîòð íàçàä" - IDTB_CONTENTS "Ñîäåðæàíèå" - IDTB_INDEX "Îãëàâëåíèå" - IDTB_SEARCH "Ïîèñê" - IDTB_HISTORY "Èñòîðèÿ" - IDTB_FAVORITES "Èçáðàííîå" - IDTB_JUMP1 "Ïåðåõîä 1" - IDTB_JUMP2 "Ïåðåõîä 2" - IDTB_CUSTOMIZE "Ïåðñîíàëèçîâàòü" - IDTB_ZOOM "Ìàñøòàá" - IDTB_TOC_NEXT "Ñëåäóþùàÿ ãëàâà" - IDTB_TOC_PREV "Ïðåäûäóùàÿ ãëàâà" + IDTB_EXPAND "Показать" + IDTB_CONTRACT "СпрÑтать" + IDTB_STOP "ОÑтановить" + IDTB_REFRESH "Обновить" + IDTB_BACK "Ðазад" + IDTB_HOME "Ð’ начало" + IDTB_SYNC "Синхронизировать" + IDTB_PRINT "Печать" + IDTB_OPTIONS "ÐаÑтройки" + IDTB_FORWARD "Вперёд" + IDTB_NOTES "ЗапиÑки" + IDTB_BROWSE_FWD "ПроÑмотр вперёд" + IDTB_BROWSE_BACK "ПроÑмотр назад" + IDTB_CONTENTS "Содержание" + IDTB_INDEX "Оглавление" + IDTB_SEARCH "ПоиÑк" + IDTB_HISTORY "ИÑториÑ" + IDTB_FAVORITES "Избранное" + IDTB_JUMP1 "Переход 1" + IDTB_JUMP2 "Переход 2" + IDTB_CUSTOMIZE "ПерÑонализовать" + IDTB_ZOOM "МаÑштаб" + IDTB_TOC_NEXT "Ð¡Ð»ÐµÐ´ÑƒÑŽÑ‰Ð°Ñ Ð³Ð»Ð°Ð²Ð°" + IDTB_TOC_PREV "ÐŸÑ€ÐµÐ´Ñ‹Ð´ÑƒÑ‰Ð°Ñ Ð³Ð»Ð°Ð²Ð°" END diff --git a/reactos/dll/win32/hhctrl.ocx/Si.rc b/reactos/dll/win32/hhctrl.ocx/Si.rc index c8ea447f5ed..bc8ca1d3705 100644 --- a/reactos/dll/win32/hhctrl.ocx/Si.rc +++ b/reactos/dll/win32/hhctrl.ocx/Si.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + #pragma code_page(65001) LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT @@ -58,5 +60,3 @@ BEGIN IDTB_TOC_NEXT "IDTB_TOC_NEXT" IDTB_TOC_PREV "IDTB_TOC_PREV" END - -#pragma code_page(default) diff --git a/reactos/dll/win32/hhctrl.ocx/Sv.rc b/reactos/dll/win32/hhctrl.ocx/Sv.rc index cb3e4e26a5d..b92c63c2bbd 100644 --- a/reactos/dll/win32/hhctrl.ocx/Sv.rc +++ b/reactos/dll/win32/hhctrl.ocx/Sv.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/Tr.rc b/reactos/dll/win32/hhctrl.ocx/Tr.rc index 748899908f7..f1011b1dc48 100644 --- a/reactos/dll/win32/hhctrl.ocx/Tr.rc +++ b/reactos/dll/win32/hhctrl.ocx/Tr.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/reactos/dll/win32/hhctrl.ocx/Uk.rc b/reactos/dll/win32/hhctrl.ocx/Uk.rc new file mode 100644 index 00000000000..40d96b86a28 --- /dev/null +++ b/reactos/dll/win32/hhctrl.ocx/Uk.rc @@ -0,0 +1,75 @@ +/* + * HTML Help resources + * Ukrainian Language Support + * + * Copyright 2005 James Hawkins + * Copyright 2007 Artem Reznikov + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE +BEGIN + IDS_CONTENTS "&ЗміÑÑ‚" + IDS_INDEX "&Вказівник" + IDS_SEARCH "&Пошук" + IDS_FAVORITES "&Обране" +END + +STRINGTABLE +BEGIN + IDTB_EXPAND "Показувати" + IDTB_CONTRACT "Приховати" + IDTB_STOP "Зупинити" + IDTB_REFRESH "Оновити" + IDTB_BACK "Ðазад" + IDTB_HOME "Додому" + IDTB_SYNC "Синхронізувати" + IDTB_PRINT "Друк" + IDTB_OPTIONS "Параметри" + IDTB_FORWARD "Вперед" + IDTB_NOTES "IDTB_NOTES" + IDTB_BROWSE_FWD "IDTB_BROWSE_FWD" + IDTB_BROWSE_BACK "IDT_BROWSE_BACK" + IDTB_CONTENTS "IDTB_CONTENTS" + IDTB_INDEX "IDTB_INDEX" + IDTB_SEARCH "IDTB_SEARCH" + IDTB_HISTORY "IDTB_HISTORY" + IDTB_FAVORITES "IDTB_FAVORITES" + IDTB_JUMP1 "Jump1" + IDTB_JUMP2 "Jump2" + IDTB_CUSTOMIZE "ÐалаштуваннÑ" + IDTB_ZOOM "ЗбільшеннÑ" + IDTB_TOC_NEXT "IDTB_TOC_NEXT" + IDTB_TOC_PREV "IDTB_TOC_PREV" +END + +LANGUAGE LANG_UKRAINIAN, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_CONTENTS "&ЗміÑÑ‚" + IDS_INDEX "&Вказівник" + IDS_SEARCH "&Пошук" + IDS_FAVORITES "&Обране" +END diff --git a/reactos/dll/win32/hhctrl.ocx/Zh.rc b/reactos/dll/win32/hhctrl.ocx/Zh.rc index a7ccab0da74..d6295a96d20 100644 --- a/reactos/dll/win32/hhctrl.ocx/Zh.rc +++ b/reactos/dll/win32/hhctrl.ocx/Zh.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + /* Chinese text is encoded in UTF-8 */ #pragma code_page(65001) @@ -96,5 +98,3 @@ BEGIN IDTB_TOC_NEXT "後一項" IDTB_TOC_PREV "å‰ä¸€é …" END - -#pragma code_page(default) diff --git a/reactos/dll/win32/hhctrl.ocx/chm.c b/reactos/dll/win32/hhctrl.ocx/chm.c index b7df8e72c7d..cf5b8bf2e90 100644 --- a/reactos/dll/win32/hhctrl.ocx/chm.c +++ b/reactos/dll/win32/hhctrl.ocx/chm.c @@ -38,12 +38,13 @@ static LPCSTR GetChmString(CHMInfo *chm, DWORD offset) return NULL; if(chm->strings_size <= (offset >> BLOCK_BITS)) { + chm->strings_size = (offset >> BLOCK_BITS)+1; if(chm->strings) chm->strings = heap_realloc_zero(chm->strings, - chm->strings_size = ((offset >> BLOCK_BITS)+1)*sizeof(char*)); + chm->strings_size*sizeof(char*)); else chm->strings = heap_alloc_zero( - chm->strings_size = ((offset >> BLOCK_BITS)+1)*sizeof(char*)); + chm->strings_size*sizeof(char*)); } @@ -388,7 +389,6 @@ CHMInfo *OpenCHM(LPCWSTR szFile) WARN("Could not open storage: %08x\n", hres); return CloseCHM(ret); } - hres = IStorage_OpenStream(ret->pStorage, wszSTRINGS, NULL, STGM_READ, 0, &ret->strings_stream); if(FAILED(hres)) { diff --git a/reactos/dll/win32/hhctrl.ocx/content.c b/reactos/dll/win32/hhctrl.ocx/content.c index 4fc017656c5..bfe25cf9453 100644 --- a/reactos/dll/win32/hhctrl.ocx/content.c +++ b/reactos/dll/win32/hhctrl.ocx/content.c @@ -20,13 +20,12 @@ #define NONAMELESSSTRUCT #include "hhctrl.h" +#include "stream.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); -#define BLOCK_SIZE 0x1000 - typedef enum { INSERT_NEXT, INSERT_CHILD @@ -50,134 +49,6 @@ static void free_content_item(ContentItem *item) } } -typedef struct { - char *buf; - int size; - int len; -} strbuf_t; - -static void strbuf_init(strbuf_t *buf) -{ - buf->size = 8; - buf->len = 0; - buf->buf = heap_alloc(buf->size); -} - -static void strbuf_zero(strbuf_t *buf) -{ - buf->len = 0; -} - -static void strbuf_free(strbuf_t *buf) -{ - heap_free(buf->buf); -} - -static void strbuf_append(strbuf_t *buf, const char *data, int len) -{ - if(buf->len+len > buf->size) { - buf->size = buf->len+len; - buf->buf = heap_realloc(buf->buf, buf->size); - } - - memcpy(buf->buf+buf->len, data, len); - buf->len += len; -} - -typedef struct { - IStream *str; - char buf[BLOCK_SIZE]; - ULONG size; - ULONG p; -} stream_t; - -static void stream_init(stream_t *stream, IStream *str) -{ - memset(stream, 0, sizeof(stream_t)); - stream->str = str; -} - -static BOOL stream_chr(stream_t *stream, strbuf_t *buf, char c) -{ - BOOL b = TRUE; - ULONG i; - - while(b) { - for(i=stream->p; isize; i++) { - if(stream->buf[i] == c) { - b = FALSE; - break; - } - } - - if(buf && i > stream->p) - strbuf_append(buf, stream->buf+stream->p, i-stream->p); - stream->p = i; - - if(stream->p == stream->size) { - stream->p = 0; - IStream_Read(stream->str, stream->buf, sizeof(stream->buf), &stream->size); - if(!stream->size) - break; - } - } - - return stream->size != 0; -} - -static void get_node_name(strbuf_t *node, strbuf_t *name) -{ - const char *ptr = node->buf+1; - - strbuf_zero(name); - - while(*ptr != '>' && !isspace(*ptr)) - ptr++; - - strbuf_append(name, node->buf+1, ptr-node->buf-1); - strbuf_append(name, "", 1); -} - -static BOOL next_node(stream_t *stream, strbuf_t *buf) -{ - if(!stream_chr(stream, NULL, '<')) - return FALSE; - - if(!stream_chr(stream, buf, '>')) - return FALSE; - - strbuf_append(buf, ">", 2); - - return TRUE; -} - -static const char *get_attr(const char *node, const char *name, int *len) -{ - const char *ptr, *ptr2; - char name_buf[32]; - int nlen; - - nlen = strlen(name); - memcpy(name_buf, name, nlen); - name_buf[nlen++] = '='; - name_buf[nlen++] = '\"'; - name_buf[nlen] = 0; - - ptr = strstr(node, name_buf); - if(!ptr) { - WARN("name not found\n"); - return NULL; - } - - ptr += nlen; - ptr2 = strchr(ptr, '\"'); - if(!ptr2) - return NULL; - - *len = ptr2-ptr; - return ptr; -} - static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text) { const char *ptr; diff --git a/reactos/dll/win32/hhctrl.ocx/help.c b/reactos/dll/win32/hhctrl.ocx/help.c index 092e97e8784..30cb008bd27 100644 --- a/reactos/dll/win32/hhctrl.ocx/help.c +++ b/reactos/dll/win32/hhctrl.ocx/help.c @@ -44,6 +44,7 @@ static LRESULT Help_OnSize(HWND hWnd); #define TAB_TOP_PADDING 8 #define TAB_RIGHT_PADDING 4 #define TAB_MARGIN 8 +#define EDIT_HEIGHT 20 static const WCHAR szEmpty[] = {0}; @@ -320,8 +321,10 @@ static LRESULT Child_OnPaint(HWND hWnd) return 0; } -static void ResizeTabChild(HHInfo *info, HWND hwnd) +static void ResizeTabChild(HHInfo *info, int tab) { + HWND hwnd = info->tabs[tab].hwnd; + INT width, height; RECT rect, tabrc; DWORD cnt; @@ -333,9 +336,47 @@ static void ResizeTabChild(HHInfo *info, HWND hwnd) rect.top = TAB_TOP_PADDING + cnt*(tabrc.bottom-tabrc.top) + TAB_MARGIN; rect.right -= TAB_RIGHT_PADDING + TAB_MARGIN; rect.bottom -= TAB_MARGIN; + width = rect.right-rect.left; + height = rect.bottom-rect.top; - SetWindowPos(hwnd, NULL, rect.left, rect.top, rect.right-rect.left, - rect.bottom-rect.top, SWP_NOZORDER | SWP_NOACTIVATE); + SetWindowPos(hwnd, NULL, rect.left, rect.top, width, height, + SWP_NOZORDER | SWP_NOACTIVATE); + + switch (tab) + { + case TAB_INDEX: { + int scroll_width = GetSystemMetrics(SM_CXVSCROLL); + int border_width = GetSystemMetrics(SM_CXBORDER); + int edge_width = GetSystemMetrics(SM_CXEDGE); + + /* Resize the tab widget column to perfectly fit the tab window and + * leave sufficient space for the scroll widget. + */ + SendMessageW(info->tabs[TAB_INDEX].hwnd, LVM_SETCOLUMNWIDTH, 0, + width-scroll_width-2*border_width-2*edge_width); + + break; + } + case TAB_SEARCH: { + int scroll_width = GetSystemMetrics(SM_CXVSCROLL); + int border_width = GetSystemMetrics(SM_CXBORDER); + int edge_width = GetSystemMetrics(SM_CXEDGE); + int top_pos = 0; + + SetWindowPos(info->search.hwndEdit, NULL, 0, top_pos, width, + EDIT_HEIGHT, SWP_NOZORDER | SWP_NOACTIVATE); + top_pos += EDIT_HEIGHT + TAB_MARGIN; + SetWindowPos(info->search.hwndList, NULL, 0, top_pos, width, + height-top_pos, SWP_NOZORDER | SWP_NOACTIVATE); + /* Resize the tab widget column to perfectly fit the tab window and + * leave sufficient space for the scroll widget. + */ + SendMessageW(info->search.hwndList, LVM_SETCOLUMNWIDTH, 0, + width-scroll_width-2*border_width-2*edge_width); + + break; + } + } } static LRESULT Child_OnSize(HWND hwnd) @@ -351,7 +392,8 @@ static LRESULT Child_OnSize(HWND hwnd) rect.right - TAB_RIGHT_PADDING, rect.bottom - TAB_TOP_PADDING, SWP_NOMOVE); - ResizeTabChild(info, info->tabs[TAB_CONTENTS].hwnd); + ResizeTabChild(info, TAB_CONTENTS); + ResizeTabChild(info, TAB_INDEX); return 0; } @@ -375,29 +417,101 @@ static LRESULT OnTabChange(HWND hwnd) return 0; } -static LRESULT OnTopicChange(HWND hwnd, ContentItem *item) +static LRESULT OnTopicChange(HHInfo *info, void *user_data) { - HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, GWLP_USERDATA); - LPCWSTR chmfile = NULL; - ContentItem *iter = item; + LPCWSTR chmfile = NULL, name = NULL, local = NULL; + ContentItem *citer; + SearchItem *siter; + IndexItem *iiter; - if(!item || !info) + if(!user_data || !info) return 0; - TRACE("name %s loal %s\n", debugstr_w(item->name), debugstr_w(item->local)); - - while(iter) { - if(iter->merge.chm_file) { - chmfile = iter->merge.chm_file; - break; + switch (info->current_tab) + { + case TAB_CONTENTS: + citer = (ContentItem *) user_data; + name = citer->name; + local = citer->local; + while(citer) { + if(citer->merge.chm_file) { + chmfile = citer->merge.chm_file; + break; + } + citer = citer->parent; } - iter = iter->parent; + break; + case TAB_INDEX: + iiter = (IndexItem *) user_data; + if(iiter->nItems == 0) { + FIXME("No entries for this item!\n"); + return 0; + } + if(iiter->nItems > 1) { + int i = 0; + LVITEMW lvi; + + SendMessageW(info->popup.hwndList, LVM_DELETEALLITEMS, 0, 0); + for(i=0;inItems;i++) { + IndexSubItem *item = &iiter->items[i]; + WCHAR *name = iiter->keyword; + + if(item->name) + name = item->name; + memset(&lvi, 0, sizeof(lvi)); + lvi.iItem = i; + lvi.mask = LVIF_TEXT|LVIF_PARAM; + lvi.cchTextMax = strlenW(name)+1; + lvi.pszText = name; + lvi.lParam = (LPARAM) item; + SendMessageW(info->popup.hwndList, LVM_INSERTITEMW, 0, (LPARAM)&lvi); + } + ShowWindow(info->popup.hwndPopup, SW_SHOW); + return 0; + } + name = iiter->items[0].name; + local = iiter->items[0].local; + chmfile = iiter->merge.chm_file; + break; + case TAB_SEARCH: + siter = (SearchItem *) user_data; + name = siter->filename; + local = siter->filename; + chmfile = info->pCHMInfo->szFile; + break; + default: + FIXME("Unhandled operation for this tab!\n"); + return 0; } - NavigateToChm(info, chmfile, item->local); + if(!chmfile) + { + FIXME("No help file found for this item!\n"); + return 0; + } + + TRACE("name %s loal %s\n", debugstr_w(name), debugstr_w(local)); + + NavigateToChm(info, chmfile, local); return 0; } +/* Capture the Enter/Return key and send it up to Child_WndProc as an NM_RETURN message */ +static LRESULT CALLBACK EditChild_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + WNDPROC editWndProc = (WNDPROC)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + + if(message == WM_KEYUP && wParam == VK_RETURN) + { + NMHDR nmhdr; + + nmhdr.hwndFrom = hWnd; + nmhdr.code = NM_RETURN; + SendMessageW(GetParent(GetParent(hWnd)), WM_NOTIFY, wParam, (LPARAM)&nmhdr); + } + return editWndProc(hWnd, message, wParam, lParam); +} + static LRESULT CALLBACK Child_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -407,12 +521,71 @@ static LRESULT CALLBACK Child_WndProc(HWND hWnd, UINT message, WPARAM wParam, LP case WM_SIZE: return Child_OnSize(hWnd); case WM_NOTIFY: { + HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); NMHDR *nmhdr = (NMHDR*)lParam; + switch(nmhdr->code) { case TCN_SELCHANGE: return OnTabChange(hWnd); case TVN_SELCHANGEDW: - return OnTopicChange(hWnd, (ContentItem*)((NMTREEVIEWW *)lParam)->itemNew.lParam); + return OnTopicChange(info, (void*)((NMTREEVIEWW *)lParam)->itemNew.lParam); + case NM_DBLCLK: + if(!info) + return 0; + switch(info->current_tab) + { + case TAB_INDEX: + return OnTopicChange(info, (void*)((NMITEMACTIVATE *)lParam)->lParam); + case TAB_SEARCH: + return OnTopicChange(info, (void*)((NMITEMACTIVATE *)lParam)->lParam); + } + break; + case NM_RETURN: + if(!info) + return 0; + switch(info->current_tab) { + case TAB_INDEX: { + HWND hwndList = info->tabs[TAB_INDEX].hwnd; + LVITEMW lvItem; + + lvItem.iItem = (int) SendMessageW(hwndList, LVM_GETSELECTIONMARK, 0, 0); + lvItem.mask = TVIF_PARAM; + SendMessageW(hwndList, LVM_GETITEMW, 0, (LPARAM)&lvItem); + OnTopicChange(info, (void*) lvItem.lParam); + return 0; + } + case TAB_SEARCH: { + if(nmhdr->hwndFrom == info->search.hwndEdit) { + char needle[100]; + DWORD i, len; + + len = GetWindowTextA(info->search.hwndEdit, needle, sizeof(needle)); + if(!len) + { + FIXME("Unable to get search text.\n"); + return 0; + } + /* Convert the requested text for comparison later against the + * lower case version of HTML file contents. + */ + for(i=0;ihwndFrom == info->search.hwndList) { + HWND hwndList = info->search.hwndList; + LVITEMW lvItem; + + lvItem.iItem = (int) SendMessageW(hwndList, LVM_GETSELECTIONMARK, 0, 0); + lvItem.mask = TVIF_PARAM; + SendMessageW(hwndList, LVM_GETITEMW, 0, (LPARAM)&lvItem); + OnTopicChange(info, (void*) lvItem.lParam); + return 0; + } + break; + } + } + break; } break; } @@ -729,6 +902,8 @@ static BOOL HH_AddHTMLPane(HHInfo *pHHInfo) static BOOL AddContentTab(HHInfo *info) { + if(info->tabs[TAB_CONTENTS].id == -1) + return TRUE; /* No "Contents" tab */ info->tabs[TAB_CONTENTS].hwnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, szEmpty, WS_CHILD | WS_BORDER | 0x25, 50, 50, 100, 100, info->WinType.hwndNavigation, NULL, hhctrl_hinstance, NULL); @@ -737,12 +912,293 @@ static BOOL AddContentTab(HHInfo *info) return FALSE; } - ResizeTabChild(info, info->tabs[TAB_CONTENTS].hwnd); + ResizeTabChild(info, TAB_CONTENTS); ShowWindow(info->tabs[TAB_CONTENTS].hwnd, SW_SHOW); return TRUE; } +static BOOL AddIndexTab(HHInfo *info) +{ + char hidden_column[] = "Column"; + LVCOLUMNA lvc; + + if(info->tabs[TAB_INDEX].id == -1) + return TRUE; /* No "Index" tab */ + info->tabs[TAB_INDEX].hwnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, + szEmpty, WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT | LVS_NOCOLUMNHEADER, 50, 50, 100, 100, + info->WinType.hwndNavigation, NULL, hhctrl_hinstance, NULL); + if(!info->tabs[TAB_INDEX].hwnd) { + ERR("Could not create ListView control\n"); + return FALSE; + } + memset(&lvc, 0, sizeof(lvc)); + lvc.mask = LVCF_TEXT; + lvc.pszText = hidden_column; + if(SendMessageW(info->tabs[TAB_INDEX].hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM) &lvc) == -1) + { + ERR("Could not create ListView column\n"); + return FALSE; + } + + ResizeTabChild(info, TAB_INDEX); + ShowWindow(info->tabs[TAB_INDEX].hwnd, SW_HIDE); + + return TRUE; +} + +static BOOL AddSearchTab(HHInfo *info) +{ + HWND hwndList, hwndEdit, hwndContainer; + char hidden_column[] = "Column"; + WNDPROC editWndProc; + LVCOLUMNA lvc; + + if(info->tabs[TAB_SEARCH].id == -1) + return TRUE; /* No "Search" tab */ + hwndContainer = CreateWindowExW(WS_EX_CONTROLPARENT, szChildClass, szEmpty, + WS_CHILD, 0, 0, 0, 0, info->WinType.hwndNavigation, + NULL, hhctrl_hinstance, NULL); + if(!hwndContainer) { + ERR("Could not create search window container control.\n"); + return FALSE; + } + hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE, WC_EDITW, szEmpty, WS_CHILD + | WS_VISIBLE | ES_LEFT | SS_NOTIFY, 0, 0, 0, 0, + hwndContainer, NULL, hhctrl_hinstance, NULL); + if(!hwndEdit) { + ERR("Could not create search ListView control.\n"); + return FALSE; + } + if(SendMessageW(hwndEdit, WM_SETFONT, (WPARAM) info->hFont, (LPARAM) FALSE) == -1) + { + ERR("Could not set font for edit control.\n"); + return FALSE; + } + editWndProc = (WNDPROC) SetWindowLongPtrW(hwndEdit, GWLP_WNDPROC, (LONG_PTR)EditChild_WndProc); + if(!editWndProc) { + ERR("Could not redirect messages for edit control.\n"); + return FALSE; + } + SetWindowLongPtrW(hwndEdit, GWLP_USERDATA, (LONG_PTR)editWndProc); + hwndList = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, szEmpty, + WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_SINGLESEL + | LVS_REPORT | LVS_NOCOLUMNHEADER, 0, 0, 0, 0, + hwndContainer, NULL, hhctrl_hinstance, NULL); + if(!hwndList) { + ERR("Could not create search ListView control.\n"); + return FALSE; + } + memset(&lvc, 0, sizeof(lvc)); + lvc.mask = LVCF_TEXT; + lvc.pszText = hidden_column; + if(SendMessageW(hwndList, LVM_INSERTCOLUMNA, 0, (LPARAM) &lvc) == -1) + { + ERR("Could not create ListView column\n"); + return FALSE; + } + + info->search.hwndEdit = hwndEdit; + info->search.hwndList = hwndList; + info->search.hwndContainer = hwndContainer; + info->tabs[TAB_SEARCH].hwnd = hwndContainer; + + SetWindowLongPtrW(hwndContainer, GWLP_USERDATA, (LONG_PTR)info); + + ResizeTabChild(info, TAB_SEARCH); + + return TRUE; +} + +/* The Index tab's sub-topic popup */ + +static void ResizePopupChild(HHInfo *info) +{ + int scroll_width = GetSystemMetrics(SM_CXVSCROLL); + int border_width = GetSystemMetrics(SM_CXBORDER); + int edge_width = GetSystemMetrics(SM_CXEDGE); + INT width, height; + RECT rect; + + if(!info) + return; + + GetClientRect(info->popup.hwndPopup, &rect); + SetWindowPos(info->popup.hwndCallback, HWND_TOP, 0, 0, + rect.right, rect.bottom, SWP_NOMOVE); + + rect.left = TAB_MARGIN; + rect.top = TAB_TOP_PADDING + TAB_MARGIN; + rect.right -= TAB_RIGHT_PADDING + TAB_MARGIN; + rect.bottom -= TAB_MARGIN; + width = rect.right-rect.left; + height = rect.bottom-rect.top; + + SetWindowPos(info->popup.hwndList, NULL, rect.left, rect.top, width, height, + SWP_NOZORDER | SWP_NOACTIVATE); + + SendMessageW(info->popup.hwndList, LVM_SETCOLUMNWIDTH, 0, + width-scroll_width-2*border_width-2*edge_width); +} + +static LRESULT CALLBACK HelpPopup_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + + switch (message) + { + case WM_SIZE: + ResizePopupChild(info); + return 0; + case WM_DESTROY: + DestroyWindow(hWnd); + return 0; + case WM_CLOSE: + ShowWindow(hWnd, SW_HIDE); + return 0; + + default: + return DefWindowProcW(hWnd, message, wParam, lParam); + } + + return 0; +} + +static LRESULT CALLBACK PopupChild_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_NOTIFY: { + NMHDR *nmhdr = (NMHDR*)lParam; + switch(nmhdr->code) + { + case NM_DBLCLK: { + HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + IndexSubItem *iter; + + if(info == 0 || lParam == 0) + return 0; + iter = (IndexSubItem*) ((NMITEMACTIVATE *)lParam)->lParam; + if(iter == 0) + return 0; + NavigateToChm(info, info->index->merge.chm_file, iter->local); + ShowWindow(info->popup.hwndPopup, SW_HIDE); + return 0; + } + case NM_RETURN: { + HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + IndexSubItem *iter; + LVITEMW lvItem; + + if(info == 0) + return 0; + + lvItem.iItem = (int) SendMessageW(info->popup.hwndList, LVM_GETSELECTIONMARK, 0, 0); + lvItem.mask = TVIF_PARAM; + SendMessageW(info->popup.hwndList, LVM_GETITEMW, 0, (LPARAM)&lvItem); + iter = (IndexSubItem*) lvItem.lParam; + NavigateToChm(info, info->index->merge.chm_file, iter->local); + ShowWindow(info->popup.hwndPopup, SW_HIDE); + return 0; + } + } + break; + } + default: + return DefWindowProcW(hWnd, message, wParam, lParam); + } + + return 0; +} + +static BOOL AddIndexPopup(HHInfo *info) +{ + static const WCHAR szPopupChildClass[] = {'H','H',' ','P','o','p','u','p',' ','C','h','i','l','d',0}; + static const WCHAR windowCaptionW[] = {'S','e','l','e','c','t',' ','T','o','p','i','c',':',0}; + static const WCHAR windowClassW[] = {'H','H',' ','P','o','p','u','p',0}; + HWND hwndList, hwndPopup, hwndCallback; + char hidden_column[] = "Column"; + WNDCLASSEXW wcex; + LVCOLUMNA lvc; + + if(info->tabs[TAB_INDEX].id == -1) + return TRUE; /* No "Index" tab */ + + wcex.cbSize = sizeof(WNDCLASSEXW); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = HelpPopup_WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hhctrl_hinstance; + wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); + wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_MENU + 1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = windowClassW; + wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); + RegisterClassExW(&wcex); + + wcex.cbSize = sizeof(WNDCLASSEXW); + wcex.style = 0; + wcex.lpfnWndProc = PopupChild_WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hhctrl_hinstance; + wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); + wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = szPopupChildClass; + wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); + RegisterClassExW(&wcex); + + hwndPopup = CreateWindowExW(WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_APPWINDOW + | WS_EX_WINDOWEDGE | WS_EX_RIGHTSCROLLBAR, + windowClassW, windowCaptionW, WS_POPUPWINDOW + | WS_OVERLAPPEDWINDOW | WS_VISIBLE + | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, + CW_USEDEFAULT, 300, 200, info->WinType.hwndHelp, + NULL, hhctrl_hinstance, NULL); + if (!hwndPopup) + return FALSE; + + hwndCallback = CreateWindowExW(WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, + szPopupChildClass, szEmpty, WS_CHILDWINDOW | WS_VISIBLE, + 0, 0, 0, 0, + hwndPopup, NULL, hhctrl_hinstance, NULL); + if (!hwndCallback) + return FALSE; + + ShowWindow(hwndPopup, SW_HIDE); + hwndList = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, szEmpty, + WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT + | LVS_NOCOLUMNHEADER, 50, 50, 100, 100, + hwndCallback, NULL, hhctrl_hinstance, NULL); + if(!hwndList) { + ERR("Could not create popup ListView control\n"); + return FALSE; + } + memset(&lvc, 0, sizeof(lvc)); + lvc.mask = LVCF_TEXT; + lvc.pszText = hidden_column; + if(SendMessageW(hwndList, LVM_INSERTCOLUMNA, 0, (LPARAM) &lvc) == -1) + { + ERR("Could not create popup ListView column\n"); + return FALSE; + } + + info->popup.hwndCallback = hwndCallback; + info->popup.hwndPopup = hwndPopup; + info->popup.hwndList = hwndList; + SetWindowLongPtrW(hwndPopup, GWLP_USERDATA, (LONG_PTR)info); + SetWindowLongPtrW(hwndCallback, GWLP_USERDATA, (LONG_PTR)info); + + ResizePopupChild(info); + ShowWindow(hwndList, SW_SHOW); + + return TRUE; +} + /* Viewer Window */ static LRESULT Help_OnSize(HWND hWnd) @@ -918,7 +1374,17 @@ static BOOL CreateViewer(HHInfo *pHHInfo) if (!AddContentTab(pHHInfo)) return FALSE; + if (!AddIndexTab(pHHInfo)) + return FALSE; + + if (!AddIndexPopup(pHHInfo)) + return FALSE; + + if (!AddSearchTab(pHHInfo)) + return FALSE; + InitContent(pHHInfo); + InitIndex(pHHInfo); return TRUE; } @@ -947,6 +1413,8 @@ void ReleaseHelpViewer(HHInfo *info) ReleaseWebBrowser(info); ReleaseContent(info); + ReleaseIndex(info); + ReleaseSearch(info); if(info->WinType.hwndHelp) DestroyWindow(info->WinType.hwndHelp); @@ -958,6 +1426,13 @@ void ReleaseHelpViewer(HHInfo *info) HHInfo *CreateHelpViewer(LPCWSTR filename) { HHInfo *info = heap_alloc_zero(sizeof(HHInfo)); + int i; + + /* Set the invalid tab ID (-1) as the default value for all + * of the tabs, this matches a failed TCM_INSERTITEM call. + */ + for(i=0;itabs)/sizeof(HHTab);i++) + info->tabs[i].id = -1; OleInitialize(NULL); diff --git a/reactos/dll/win32/hhctrl.ocx/hhctrl.c b/reactos/dll/win32/hhctrl.ocx/hhctrl.c index 8268a21f34b..99f713059e3 100644 --- a/reactos/dll/win32/hhctrl.ocx/hhctrl.c +++ b/reactos/dll/win32/hhctrl.ocx/hhctrl.c @@ -272,12 +272,41 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine) { MSG msg; - int len, buflen; + int len, buflen, mapid = -1; WCHAR *filename; char *endq = NULL; hh_process = TRUE; + /* Parse command line option of the HTML Help command. + * + * Note: The only currently handled action is "mapid", + * which corresponds to opening a specific page. + */ + while(*szCmdLine == '-') + { + LPSTR space, ptr; + + ptr = szCmdLine + 1; + space = strchr(ptr, ' '); + if(!strncmp(ptr, "mapid", space-ptr)) + { + char idtxt[10]; + + ptr += strlen("mapid")+1; + space = strchr(ptr, ' '); + memcpy(idtxt, ptr, space-ptr); + idtxt[space-ptr] = '\0'; + mapid = atoi(idtxt); + szCmdLine = space+1; + } + else + { + FIXME("Unhandled HTML Help command line parameter! (%.*s)\n", space-szCmdLine, szCmdLine); + return 0; + } + } + /* FIXME: Check szCmdLine for bad arguments */ if (*szCmdLine == '\"') endq = strchr(++szCmdLine, '\"'); @@ -291,7 +320,11 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine) MultiByteToWideChar(CP_ACP, 0, szCmdLine, len, filename, buflen); filename[buflen-1] = 0; - HtmlHelpW(GetDesktopWindow(), filename, HH_DISPLAY_TOPIC, 0); + /* Open a specific help topic */ + if(mapid != -1) + HtmlHelpW(GetDesktopWindow(), filename, HH_HELP_CONTEXT, mapid); + else + HtmlHelpW(GetDesktopWindow(), filename, HH_DISPLAY_TOPIC, 0); heap_free(filename); diff --git a/reactos/dll/win32/hhctrl.ocx/hhctrl.h b/reactos/dll/win32/hhctrl.ocx/hhctrl.h index 795bea4d13e..91d3a775ace 100644 --- a/reactos/dll/win32/hhctrl.ocx/hhctrl.h +++ b/reactos/dll/win32/hhctrl.ocx/hhctrl.h @@ -65,11 +65,37 @@ typedef struct ContentItem { ChmPath merge; } ContentItem; +typedef struct IndexSubItem { + LPWSTR name; + LPWSTR local; +} IndexSubItem; + +typedef struct IndexItem { + struct IndexItem *next; + + HTREEITEM id; + LPWSTR keyword; + ChmPath merge; + + int nItems; + int itemFlags; + int indentLevel; + IndexSubItem *items; +} IndexItem; + +typedef struct SearchItem { + struct SearchItem *next; + + HTREEITEM id; + LPWSTR title; + LPWSTR filename; +} SearchItem; + typedef struct CHMInfo { IITStorage *pITStorage; IStorage *pStorage; - LPCWSTR szFile; + WCHAR *szFile; IStream *strings_stream; char **strings; @@ -90,6 +116,19 @@ typedef struct { DWORD id; } HHTab; +typedef struct { + HWND hwndList; + HWND hwndPopup; + HWND hwndCallback; +} IndexPopup; + +typedef struct { + SearchItem *root; + HWND hwndEdit; + HWND hwndList; + HWND hwndContainer; +} SearchTab; + typedef struct { IOleClientSite *client_site; IWebBrowser2 *web_browser; @@ -111,6 +150,9 @@ typedef struct { CHMInfo *pCHMInfo; ContentItem *content; + IndexItem *index; + IndexPopup popup; + SearchTab search; HWND hwndTabCtrl; HWND hwndSizeBar; HFONT hFont; @@ -127,6 +169,9 @@ void DoPageAction(HHInfo*,DWORD); void InitContent(HHInfo*); void ReleaseContent(HHInfo*); +void InitIndex(HHInfo*); +void ReleaseIndex(HHInfo*); + CHMInfo *OpenCHM(LPCWSTR szFile); BOOL LoadWinTypeFromCHM(HHInfo *info); CHMInfo *CloseCHM(CHMInfo *pCHMInfo); @@ -139,6 +184,9 @@ void ReleaseHelpViewer(HHInfo*); BOOL NavigateToUrl(HHInfo*,LPCWSTR); BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR); +void InitSearch(HHInfo *info, const char *needle); +void ReleaseSearch(HHInfo *info); + /* memory allocation functions */ static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len) diff --git a/reactos/dll/win32/hhctrl.ocx/hhctrl.rc b/reactos/dll/win32/hhctrl.ocx/hhctrl.rc index 8618819ed12..8e76454218e 100644 --- a/reactos/dll/win32/hhctrl.ocx/hhctrl.rc +++ b/reactos/dll/win32/hhctrl.ocx/hhctrl.rc @@ -31,20 +31,25 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include "Cs.rc" #include "Da.rc" -#include "De.rc" #include "El.rc" #include "En.rc" -#include "Fr.rc" #include "Fi.rc" #include "Hu.rc" #include "Ko.rc" -#include "Lt.rc" #include "Nl.rc" #include "No.rc" #include "Pl.rc" #include "Pt.rc" -#include "Ru.rc" -#include "Si.rc" #include "Sv.rc" #include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Es.rc" +#include "Fr.rc" +#include "Lt.rc" +#include "Ru.rc" +#include "Si.rc" +#include "Uk.rc" #include "Zh.rc" + diff --git a/reactos/dll/win32/hhctrl.ocx/index.c b/reactos/dll/win32/hhctrl.ocx/index.c new file mode 100644 index 00000000000..e9385c35429 --- /dev/null +++ b/reactos/dll/win32/hhctrl.ocx/index.c @@ -0,0 +1,295 @@ +/* + * Copyright 2007 Jacek Caban for CodeWeavers + * Copyright 2010 Erich Hoover + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT + +#include "hhctrl.h" +#include "stream.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); + +/* Fill the TreeView object corresponding to the Index items */ +static void fill_index_tree(HWND hwnd, IndexItem *item) +{ + int index = 0; + LVITEMW lvi; + + while(item) { + TRACE("tree debug: %s\n", debugstr_w(item->keyword)); + + if(!item->keyword) + { + FIXME("HTML Help index item has no keyword.\n"); + item = item->next; + continue; + } + memset(&lvi, 0, sizeof(lvi)); + lvi.iItem = index++; + lvi.mask = LVIF_TEXT|LVIF_PARAM|LVIF_INDENT; + lvi.iIndent = item->indentLevel; + lvi.cchTextMax = strlenW(item->keyword)+1; + lvi.pszText = item->keyword; + lvi.lParam = (LPARAM)item; + item->id = (HTREEITEM)SendMessageW(hwnd, LVM_INSERTITEMW, 0, (LPARAM)&lvi); + item = item->next; + } +} + +/* Parse the attributes correspond to a list item, including sub-topics. + * + * Each list item has, at minimum, a param of type "keyword" and two + * parameters corresponding to a "sub-topic." For each sub-topic there + * must be a "name" param and a "local" param, if there is only one + * sub-topic then there isn't really a sub-topic, the index will jump + * directly to the requested item. + */ +static void parse_index_obj_node_param(IndexItem *item, const char *text) +{ + const char *ptr; + LPWSTR *param; + int len, wlen; + + ptr = get_attr(text, "name", &len); + if(!ptr) { + WARN("name attr not found\n"); + return; + } + + /* Allocate a new sub-item, either on the first run or whenever a + * sub-topic has filled out both the "name" and "local" params. + */ + if(item->itemFlags == 0x11 && (!strncasecmp("name", ptr, len) || !strncasecmp("local", ptr, len))) { + item->nItems++; + item->items = heap_realloc(item->items, sizeof(IndexSubItem)*item->nItems); + item->items[item->nItems-1].name = NULL; + item->items[item->nItems-1].local = NULL; + item->itemFlags = 0x00; + } + if(!strncasecmp("keyword", ptr, len)) { + param = &item->keyword; + }else if(!item->keyword && !strncasecmp("name", ptr, len)) { + /* Some HTML Help index files use an additional "name" parameter + * rather than the "keyword" parameter. In this case, the first + * occurance of the "name" parameter is the keyword. + */ + param = &item->keyword; + }else if(!strncasecmp("name", ptr, len)) { + item->itemFlags |= 0x01; + param = &item->items[item->nItems-1].name; + }else if(!strncasecmp("local", ptr, len)) { + item->itemFlags |= 0x10; + param = &item->items[item->nItems-1].local; + }else { + WARN("unhandled param %s\n", debugstr_an(ptr, len)); + return; + } + + ptr = get_attr(text, "value", &len); + if(!ptr) { + WARN("value attr not found\n"); + return; + } + + wlen = MultiByteToWideChar(CP_ACP, 0, ptr, len, NULL, 0); + *param = heap_alloc((wlen+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, ptr, len, *param, wlen); + (*param)[wlen] = 0; +} + +/* Parse the object tag corresponding to a list item. + * + * At this step we look for all of the "param" child tags, using this information + * to build up the information about the list item. When we reach the + * tag we know that we've finished parsing this list item. + */ +static IndexItem *parse_index_sitemap_object(HHInfo *info, stream_t *stream) +{ + strbuf_t node, node_name; + IndexItem *item; + + strbuf_init(&node); + strbuf_init(&node_name); + + item = heap_alloc_zero(sizeof(IndexItem)); + item->nItems = 0; + item->items = heap_alloc_zero(0); + item->itemFlags = 0x11; + + while(next_node(stream, &node)) { + get_node_name(&node, &node_name); + + TRACE("%s\n", node.buf); + + if(!strcasecmp(node_name.buf, "param")) { + parse_index_obj_node_param(item, node.buf); + }else if(!strcasecmp(node_name.buf, "/object")) { + break; + }else { + WARN("Unhandled tag! %s\n", node_name.buf); + } + + strbuf_zero(&node); + } + + strbuf_free(&node); + strbuf_free(&node_name); + + return item; +} + +/* Parse the HTML list item node corresponding to a specific help entry. + * + * At this stage we look for the only child tag we expect to find under + * the list item: the tag. We also only expect to find object + * tags with the "type" attribute set to "text/sitemap". + */ +static IndexItem *parse_li(HHInfo *info, stream_t *stream) +{ + strbuf_t node, node_name; + IndexItem *ret = NULL; + + strbuf_init(&node); + strbuf_init(&node_name); + + while(next_node(stream, &node)) { + get_node_name(&node, &node_name); + + TRACE("%s\n", node.buf); + + if(!strcasecmp(node_name.buf, "object")) { + const char *ptr; + int len; + + static const char sz_text_sitemap[] = "text/sitemap"; + + ptr = get_attr(node.buf, "type", &len); + + if(ptr && len == sizeof(sz_text_sitemap)-1 + && !memcmp(ptr, sz_text_sitemap, len)) { + ret = parse_index_sitemap_object(info, stream); + break; + } + }else { + WARN("Unhandled tag! %s\n", node_name.buf); + } + + strbuf_zero(&node); + } + + strbuf_free(&node); + strbuf_free(&node_name); + + return ret; +} + +/* Parse the HTML Help page corresponding to all of the Index items. + * + * At this high-level stage we locate out each HTML list item tag. + * Since there is no end-tag for the
  • item, we must hope that + * the
  • entry is parsed correctly or tags might get lost. + * + * Within each entry it is also possible to encounter an additional + *
      tag. When this occurs the tag indicates that the topics + * contained within it are related to the parent
    • topic and + * should be inset by an indent. + */ +static void parse_hhindex(HHInfo *info, IStream *str, IndexItem *item) +{ + stream_t stream; + strbuf_t node, node_name; + int indent_level = -1; + + strbuf_init(&node); + strbuf_init(&node_name); + + stream_init(&stream, str); + + while(next_node(&stream, &node)) { + get_node_name(&node, &node_name); + + TRACE("%s\n", node.buf); + + if(!strcasecmp(node_name.buf, "li")) { + item->next = parse_li(info, &stream); + item->next->merge = item->merge; + item = item->next; + item->indentLevel = indent_level; + }else if(!strcasecmp(node_name.buf, "ul")) { + indent_level++; + }else if(!strcasecmp(node_name.buf, "/ul")) { + indent_level--; + }else { + WARN("Unhandled tag! %s\n", node_name.buf); + } + + strbuf_zero(&node); + } + + strbuf_free(&node); + strbuf_free(&node_name); +} + +/* Initialize the HTML Help Index tab */ +void InitIndex(HHInfo *info) +{ + IStream *stream; + + info->index = heap_alloc_zero(sizeof(IndexItem)); + info->index->nItems = 0; + SetChmPath(&info->index->merge, info->pCHMInfo->szFile, info->WinType.pszIndex); + + stream = GetChmStream(info->pCHMInfo, info->pCHMInfo->szFile, &info->index->merge); + if(!stream) { + TRACE("Could not get index stream\n"); + return; + } + + parse_hhindex(info, stream, info->index); + IStream_Release(stream); + + fill_index_tree(info->tabs[TAB_INDEX].hwnd, info->index->next); +} + +/* Free all of the Index items, including all of the "sub-items" that + * correspond to different sub-topics. + */ +void ReleaseIndex(HHInfo *info) +{ + IndexItem *item = info->index, *next; + int i; + + /* Note: item->merge is identical for all items, only free once */ + heap_free(item->merge.chm_file); + heap_free(item->merge.chm_index); + while(item) { + next = item->next; + + heap_free(item->keyword); + for(i=0;inItems;i++) { + heap_free(item->items[i].name); + heap_free(item->items[i].local); + } + heap_free(item->items); + + item = next; + } +} diff --git a/reactos/dll/win32/hhctrl.ocx/search.c b/reactos/dll/win32/hhctrl.ocx/search.c new file mode 100644 index 00000000000..f81e46cbf79 --- /dev/null +++ b/reactos/dll/win32/hhctrl.ocx/search.c @@ -0,0 +1,246 @@ +/* + * Copyright 2010 Erich Hoover + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT + +#include "hhctrl.h" +#include "stream.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); + +static SearchItem *SearchCHM_Folder(SearchItem *item, IStorage *pStorage, + const WCHAR *folder, const char *needle); + +/* Allocate a ListView entry for a search result. */ +static SearchItem *alloc_search_item(WCHAR *title, const WCHAR *filename) +{ + int filename_len = filename ? (strlenW(filename)+1)*sizeof(WCHAR) : 0; + SearchItem *item; + + item = heap_alloc_zero(sizeof(SearchItem)); + if(filename) + { + item->filename = heap_alloc(filename_len); + memcpy(item->filename, filename, filename_len); + } + item->title = title; /* Already allocated */ + + return item; +} + +/* Fill the ListView object corresponding to the found Search tab items */ +static void fill_search_tree(HWND hwndList, SearchItem *item) +{ + int index = 0; + LVITEMW lvi; + + SendMessageW(hwndList, LVM_DELETEALLITEMS, 0, 0); + while(item) { + TRACE("list debug: %s\n", debugstr_w(item->filename)); + + memset(&lvi, 0, sizeof(lvi)); + lvi.iItem = index++; + lvi.mask = LVIF_TEXT|LVIF_PARAM; + lvi.cchTextMax = strlenW(item->title)+1; + lvi.pszText = item->title; + lvi.lParam = (LPARAM)item; + item->id = (HTREEITEM)SendMessageW(hwndList, LVM_INSERTITEMW, 0, (LPARAM)&lvi); + item = item->next; + } +} + +/* Search the CHM storage stream (an HTML file) for the requested text. + * + * Before searching the HTML file all HTML tags are removed so that only + * the content of the document is scanned. If the search string is found + * then the title of the document is returned. + */ +static WCHAR *SearchCHM_File(IStorage *pStorage, const WCHAR *file, const char *needle) +{ + char *buffer = heap_alloc(BLOCK_SIZE); + strbuf_t content, node, node_name; + IStream *temp_stream = NULL; + DWORD i, buffer_size = 0; + WCHAR *title = NULL; + BOOL found = FALSE; + stream_t stream; + HRESULT hres; + + hres = IStorage_OpenStream(pStorage, file, NULL, STGM_READ, 0, &temp_stream); + if(FAILED(hres)) { + FIXME("Could not open '%s' stream: %08x\n", debugstr_w(file), hres); + goto cleanup; + } + + strbuf_init(&node); + strbuf_init(&content); + strbuf_init(&node_name); + + stream_init(&stream, temp_stream); + + /* Remove all HTML formatting and record the title */ + while(next_node(&stream, &node)) { + get_node_name(&node, &node_name); + + if(next_content(&stream, &content) && content.len > 1) + { + char *text = &content.buf[1]; + int textlen = content.len-1; + + if(!strcasecmp(node_name.buf, "title")) + { + int wlen = MultiByteToWideChar(CP_ACP, 0, text, textlen, NULL, 0); + title = heap_alloc((wlen+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, text, textlen, title, wlen); + title[wlen] = 0; + } + + buffer = heap_realloc(buffer, buffer_size + textlen + 1); + memcpy(&buffer[buffer_size], text, textlen); + buffer[buffer_size + textlen] = '\0'; + buffer_size += textlen; + } + + strbuf_zero(&node); + strbuf_zero(&content); + } + + /* Convert the buffer to lower case for comparison against the + * requested text (already in lower case). + */ + for(i=0;inext = alloc_search_item(title, entries.pwcsName); + item = item->next; + } + } + break; + default: + FIXME("Unhandled IStorage stream element.\n"); + } + } + return item; +} + +/* Open a CHM storage object (folder) by name and find all items with + * the requested text. The last found item is returned. + */ +static SearchItem *SearchCHM_Folder(SearchItem *item, IStorage *pStorage, + const WCHAR *folder, const char *needle) +{ + IStorage *temp_storage = NULL; + HRESULT hres; + + hres = IStorage_OpenStorage(pStorage, folder, NULL, STGM_READ, NULL, 0, &temp_storage); + if(FAILED(hres)) + { + FIXME("Could not open '%s' storage object: %08x\n", debugstr_w(folder), hres); + return NULL; + } + item = SearchCHM_Storage(item, temp_storage, needle); + + IStorage_Release(temp_storage); + return item; +} + +/* Search the entire CHM file for the requested text and add all of + * the found items to a ListView for the user to choose the item + * they want. + */ +void InitSearch(HHInfo *info, const char *needle) +{ + CHMInfo *chm = info->pCHMInfo; + SearchItem *root_item = alloc_search_item(NULL, NULL); + + SearchCHM_Storage(root_item, chm->pStorage, needle); + fill_search_tree(info->search.hwndList, root_item->next); + if(info->search.root) + ReleaseSearch(info); + info->search.root = root_item; +} + +/* Free all of the found Search items. */ +void ReleaseSearch(HHInfo *info) +{ + SearchItem *item = info->search.root; + + info->search.root = NULL; + while(item) { + heap_free(item->filename); + item = item->next; + } +} diff --git a/reactos/dll/win32/hhctrl.ocx/stream.c b/reactos/dll/win32/hhctrl.ocx/stream.c new file mode 100644 index 00000000000..317eeebabcf --- /dev/null +++ b/reactos/dll/win32/hhctrl.ocx/stream.c @@ -0,0 +1,179 @@ +/* + * Copyright 2007 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "hhctrl.h" +#include "stream.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); + +void strbuf_init(strbuf_t *buf) +{ + buf->size = 8; + buf->len = 0; + buf->buf = heap_alloc(buf->size); +} + +void strbuf_zero(strbuf_t *buf) +{ + buf->len = 0; +} + +void strbuf_free(strbuf_t *buf) +{ + heap_free(buf->buf); +} + +void strbuf_append(strbuf_t *buf, const char *data, int len) +{ + if(buf->len+len > buf->size) { + buf->size = buf->len+len; + buf->buf = heap_realloc(buf->buf, buf->size); + } + + memcpy(buf->buf+buf->len, data, len); + buf->len += len; +} + +void stream_init(stream_t *stream, IStream *str) +{ + memset(stream, 0, sizeof(stream_t)); + stream->str = str; +} + +BOOL stream_chr(stream_t *stream, strbuf_t *buf, char c) +{ + BOOL b = TRUE; + ULONG i; + + while(b) { + for(i=stream->p; isize; i++) { + if(stream->buf[i] == c) { + b = FALSE; + break; + } + } + + if(buf && i > stream->p) + strbuf_append(buf, stream->buf+stream->p, i-stream->p); + stream->p = i; + + if(stream->p == stream->size) { + stream->p = 0; + IStream_Read(stream->str, stream->buf, sizeof(stream->buf), &stream->size); + if(!stream->size) + break; + } + } + + return stream->size != 0; +} + +void get_node_name(strbuf_t *node, strbuf_t *name) +{ + const char *ptr = node->buf+1; + + strbuf_zero(name); + + while(*ptr != '>' && !isspace(*ptr)) + ptr++; + + strbuf_append(name, node->buf+1, ptr-node->buf-1); + strbuf_append(name, "", 1); +} + +/* Return the stream content up to the next HTML tag. + * + * Note: the first returned character is the end of the last tag (>). + */ +BOOL next_content(stream_t *stream, strbuf_t *buf) +{ + if(!stream_chr(stream, buf, '<')) + return FALSE; + + return TRUE; +} + +BOOL next_node(stream_t *stream, strbuf_t *buf) +{ + if(!stream_chr(stream, NULL, '<')) + return FALSE; + + if(!stream_chr(stream, buf, '>')) + return FALSE; + + strbuf_append(buf, ">", 2); + + return TRUE; +} + +/* + * Find the value of a named HTML attribute. + * + * Note: Attribute names are case insensitive, so it is necessary to + * put both the node text and the attribute name in the same case + * before attempting a string search. + */ +const char *get_attr(const char *node, const char *name, int *len) +{ + const char *ptr, *ptr2; + int name_len, node_len; + char name_buf[32]; + char *node_buf; + int i; + + /* Create a lower case copy of the node */ + node_len = strlen(node)+1; + node_buf = heap_alloc(node_len*sizeof(char)); + if(!node_buf) + return NULL; + memcpy(node_buf, node, node_len); + for(i=0;i Date: Sun, 7 Mar 2010 13:26:27 +0000 Subject: [PATCH 192/211] [HHCTRL.OCX] fix build svn path=/trunk/; revision=45991 --- reactos/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild b/reactos/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild index cf043e00031..9cd7d4cfdfd 100644 --- a/reactos/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild +++ b/reactos/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild @@ -14,7 +14,10 @@ content.c help.c hhctrl.c + index.c regsvr.c + search.c + stream.c webbrowser.c hhctrl.rc wine From fa403d4bf101251409e79e223a8fe599e6fda681 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 7 Mar 2010 14:59:15 +0000 Subject: [PATCH 193/211] Update reg and msiexec to Wine 1.1.40. svn path=/trunk/; revision=45992 --- reactos/base/applications/cmdutils/reg/De.rc | 2 +- reactos/base/applications/cmdutils/reg/It.rc | 40 +++++++++++++++++ reactos/base/applications/cmdutils/reg/Uk.rc | 43 +++++++++++++++++++ reactos/base/applications/cmdutils/reg/reg.c | 15 +++++++ .../base/applications/cmdutils/reg/rsrc.rc | 16 ++++--- reactos/base/system/msiexec/msiexec.rbuild | 3 +- reactos/base/system/msiexec/rsrc.rc | 11 ++++- reactos/base/system/msiexec/version.rc | 28 ------------ reactos/media/doc/README.WINE | 6 +-- 9 files changed, 123 insertions(+), 41 deletions(-) create mode 100644 reactos/base/applications/cmdutils/reg/It.rc create mode 100644 reactos/base/applications/cmdutils/reg/Uk.rc delete mode 100644 reactos/base/system/msiexec/version.rc diff --git a/reactos/base/applications/cmdutils/reg/De.rc b/reactos/base/applications/cmdutils/reg/De.rc index 504359d67a6..0940640306c 100644 --- a/reactos/base/applications/cmdutils/reg/De.rc +++ b/reactos/base/applications/cmdutils/reg/De.rc @@ -35,6 +35,6 @@ STRINGTABLE STRING_SUCCESS, "Der Vorgang wurde erfolgreich abgeschlossen\n" STRING_INVALID_KEY, "Fehler: Ungültiger Schlüssel\n" STRING_INVALID_CMDLINE, "Fehler: Ungültige Befehlszeilenargumente\n" - STRING_NO_REMOTE, "Fehler: Konnte Schlüssel nicht zum entfernten Rechner hinzufügen\n" + STRING_NO_REMOTE, "Fehler: Konnte Schlüssel nicht zum remote Rechner hinzufügen\n" STRING_CANNOT_FIND, "Fehler: Der angegebene Schlüssel oder Wert konnte nicht gefunden werden\n" } diff --git a/reactos/base/applications/cmdutils/reg/It.rc b/reactos/base/applications/cmdutils/reg/It.rc new file mode 100644 index 00000000000..09d38fd4025 --- /dev/null +++ b/reactos/base/applications/cmdutils/reg/It.rc @@ -0,0 +1,40 @@ +/* + * REG.EXE - Wine-compatible reg program. + * Italian language support + * + * Copyright 2010 Luca Bennati + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "reg.h" + +/*UTF-8*/ +#pragma code_page(65001) + +LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL + +STRINGTABLE +{ + STRING_USAGE, "La sintassi di questo comando è:\n\nREG [ ADD | DELETE | QUERY ]\nREG comando /?\n" + STRING_ADD_USAGE, "REG ADD nome_della_chiave [/v nome_del_valore | /ve] [/t tipo] [/s separatore] [/d dati] [/f]\n" + STRING_DELETE_USAGE, "REG DELETE nome_della_chiave [/v nome_del_valore | /ve | /va] [/f]\n" + STRING_QUERY_USAGE, "REG QUERY nome_della_chiave [/v nome_del_valore | /ve] [/s]\n" + STRING_SUCCESS, "Operazione completata con successo\n" + STRING_INVALID_KEY, "Errore: nome della chiave non valido\n" + STRING_INVALID_CMDLINE, "Errore: parametri della linea di comando non validi\n" + STRING_NO_REMOTE, "Errore: Impossibile aggiungere chiavi alla macchina remota\n" + STRING_CANNOT_FIND, "Errore: Il sistema non è riuscito a trovare la chiave di registro o il valore specificati\n" +} diff --git a/reactos/base/applications/cmdutils/reg/Uk.rc b/reactos/base/applications/cmdutils/reg/Uk.rc new file mode 100644 index 00000000000..70c86f70cb9 --- /dev/null +++ b/reactos/base/applications/cmdutils/reg/Uk.rc @@ -0,0 +1,43 @@ +/* + * REG.EXE - Wine-compatible reg program. + * + * Copyright 2008 Andrew Riedi + * + * Ukrainian language support + * + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "reg.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE +{ + STRING_USAGE, "СинтакÑÐ¸Ñ Ñ†Ñ–Ñ”Ñ— команди наÑтупний:\n\nREG [ ADD | DELETE | QUERY ]\nREG command /?\n" + STRING_ADD_USAGE, "REG ADD key_name [/v value_name | /ve] [/t type] [/s separator] [/d data] [/f]\n" + STRING_DELETE_USAGE, "REG DELETE key_name [/v value_name | /ve | /va] [/f]\n" + STRING_QUERY_USAGE, "REG QUERY key_name [/v value_name | /ve] [/s]\n" + STRING_SUCCESS, "ÐžÐ¿ÐµÑ€Ð°Ñ†Ñ–Ñ ÑƒÑпішно завершена\n" + STRING_INVALID_KEY, "Помилка: неправильне ім'Ñ ÐºÐ»ÑŽÑ‡Ð°\n" + STRING_INVALID_CMDLINE, "Помилка: неправильні параметри командного Ñ€Ñдка\n" + STRING_NO_REMOTE, "Помилка: неможливо додати ключі на віддаленій машині\n" + STRING_CANNOT_FIND, "Помилка: не вдалоÑÑŒ знайти вказаний ключ реєÑтру чи значеннÑ\n" +} diff --git a/reactos/base/applications/cmdutils/reg/reg.c b/reactos/base/applications/cmdutils/reg/reg.c index 07dbdbff367..f65a3c8bc93 100644 --- a/reactos/base/applications/cmdutils/reg/reg.c +++ b/reactos/base/applications/cmdutils/reg/reg.c @@ -124,6 +124,21 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r lstrcpyW((LPWSTR)out_data,data); break; } + case REG_DWORD: + { + LPWSTR rest; + DWORD val; + val = strtolW(data, &rest, 0); + if (rest == data) { + static const WCHAR nonnumber[] = {'E','r','r','o','r',':',' ','/','d',' ','r','e','q','u','i','r','e','s',' ','n','u','m','b','e','r','.','\n',0}; + reg_printfW(nonnumber); + break; + } + *reg_count = sizeof(DWORD); + out_data = HeapAlloc(GetProcessHeap(),0,*reg_count); + ((LPDWORD)out_data)[0] = val; + break; + } default: { static const WCHAR unhandled[] = {'U','n','h','a','n','d','l','e','d',' ','T','y','p','e',' ','0','x','%','x',' ',' ','d','a','t','a',' ','%','s','\n',0}; diff --git a/reactos/base/applications/cmdutils/reg/rsrc.rc b/reactos/base/applications/cmdutils/reg/rsrc.rc index 1ab7f7f3b97..c145fe91a21 100644 --- a/reactos/base/applications/cmdutils/reg/rsrc.rc +++ b/reactos/base/applications/cmdutils/reg/rsrc.rc @@ -1,13 +1,17 @@ #include "Da.rc" -#include "De.rc" #include "En.rc" -#include "Fr.rc" -#include "Ja.rc" -//#include "Ko.rc" -#include "Lt.rc" +#include "Ko.rc" #include "Nl.rc" +#include "Pl.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "It.rc" +#include "Ja.rc" +#include "Lt.rc" #include "No.rc" -//#include "Pl.rc" #include "Pt.rc" #include "Ru.rc" #include "Si.rc" +#include "Uk.rc" diff --git a/reactos/base/system/msiexec/msiexec.rbuild b/reactos/base/system/msiexec/msiexec.rbuild index a3a24950930..228875d72c7 100644 --- a/reactos/base/system/msiexec/msiexec.rbuild +++ b/reactos/base/system/msiexec/msiexec.rbuild @@ -12,7 +12,6 @@ ole32 msi msiexec.c - rsrc.rc service.c - version.rc + rsrc.rc diff --git a/reactos/base/system/msiexec/rsrc.rc b/reactos/base/system/msiexec/rsrc.rc index 01e43befe19..cfc89370039 100644 --- a/reactos/base/system/msiexec/rsrc.rc +++ b/reactos/base/system/msiexec/rsrc.rc @@ -18,7 +18,16 @@ #include -#include "version.rc" +#define WINE_FILEDESCRIPTION_STR "Wine Installer" +#define WINE_FILENAME_STR "msiexec.exe" +#define WINE_FILETYPE VFT_APP +#define WINE_FILEVERSION 3,1,4000,1823 +#define WINE_FILEVERSION_STR "3.1.4000.1823" +#define WINE_PRODUCTVERSION 3,1,4000,1823 +#define WINE_PRODUCTVERSION_STR "3.1.4000.1823" +#define WINE_PRODUCTNAME_STR "Wine Installer" + +#include "wine/wine_common_ver.rc" LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL diff --git a/reactos/base/system/msiexec/version.rc b/reactos/base/system/msiexec/version.rc deleted file mode 100644 index 077759431e2..00000000000 --- a/reactos/base/system/msiexec/version.rc +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004 Mike McCormack - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define WINE_FILEDESCRIPTION_STR "Wine Installer" -#define WINE_FILENAME_STR "msiexec.exe" -#define WINE_FILETYPE VFT_APP -#define WINE_FILEVERSION 3,1,4000,1823 -#define WINE_FILEVERSION_STR "3.1.4000.1823" -#define WINE_PRODUCTVERSION 3,1,4000,1823 -#define WINE_PRODUCTVERSION_STR "3.1.4000.1823" -#define WINE_PRODUCTNAME_STR "Wine Installer" - -#include "wine/wine_common_ver.rc" diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index a69885a153d..4eadfce1da2 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -188,13 +188,13 @@ reactos/base/applications/cmdutils/xcopy # Autosync reactos/base/applications/games/winemine # Out of sync reactos/base/applications/iexplore # Autosync reactos/base/applications/notepad # Forked at Wine-20041201 -reactos/base/applications/reg # Synced to Wine-1_1_31 +reactos/base/applications/reg # Autosync reactos/base/applications/regedit # Out of sync reactos/base/applications/winhlp32 # Autosync reactos/base/applications/wordpad # Autosync reactos/base/services/rpcss # Synced to Wine-20081105 -reactos/base/system/expand # Synced to Wine-1_1_37 -reactos/base/system/msiexec # Synced to Wine-1_1_23 +reactos/base/system/expand # Autosync +reactos/base/system/msiexec # Autosync reactos/modules/rosapps/winfile # Autosync In addition the following libs, dlls and source files are mostly based on code ported From 19b65ab3fef51a549533162afae69d0d723a1037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 7 Mar 2010 20:12:28 +0000 Subject: [PATCH 194/211] [freeldr] Add SCSIPORT category to debug messages Add missing PELOADER entry + fix one debug message svn path=/trunk/; revision=45994 --- reactos/boot/freeldr/freeldr/debug.c | 12 ++++++++++++ reactos/boot/freeldr/freeldr/include/debug.h | 1 + reactos/boot/freeldr/freeldr/windows/peloader.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/reactos/boot/freeldr/freeldr/debug.c b/reactos/boot/freeldr/freeldr/debug.c index bd8bc74bbb4..0de49f52320 100644 --- a/reactos/boot/freeldr/freeldr/debug.c +++ b/reactos/boot/freeldr/freeldr/debug.c @@ -173,6 +173,12 @@ VOID DebugPrintHeader(ULONG Mask) case DPRINT_HWDETECT: DbgPrint("HWDETECT: "); break; + case DPRINT_PELOADER: + DbgPrint("PELOADER: "); + break; + case DPRINT_SCSIPORT: + DbgPrint("SCSIPORT: "); + break; default: DbgPrint("UNKNOWN: "); break; @@ -194,6 +200,12 @@ VOID DbgPrintMask(ULONG Mask, char *format, ...) return; } + // Disable file/line for scsiport messages + if (Mask & DPRINT_SCSIPORT) + { + DebugStartOfLine = FALSE; + } + // Print the header if we have started a new line if (DebugStartOfLine) { diff --git a/reactos/boot/freeldr/freeldr/include/debug.h b/reactos/boot/freeldr/freeldr/include/debug.h index c7d57f6fb49..1e855360491 100644 --- a/reactos/boot/freeldr/freeldr/include/debug.h +++ b/reactos/boot/freeldr/freeldr/include/debug.h @@ -35,6 +35,7 @@ #define DPRINT_HWDETECT 0x00000400 // OR this with DebugPrintMask to enable hardware detection messages #define DPRINT_WINDOWS 0x00000800 // OR this with DebugPrintMask to enable messages from Windows loader #define DPRINT_PELOADER 0x00001000 // OR this with DebugPrintMask to enable messages from PE images loader +#define DPRINT_SCSIPORT 0x00002000 // OR this with DebugPrintMask to enable messages from SCSI miniport extern char* g_file; extern int g_line; diff --git a/reactos/boot/freeldr/freeldr/windows/peloader.c b/reactos/boot/freeldr/freeldr/windows/peloader.c index f4c731e7254..8f5d81140df 100644 --- a/reactos/boot/freeldr/freeldr/windows/peloader.c +++ b/reactos/boot/freeldr/freeldr/windows/peloader.c @@ -56,7 +56,7 @@ WinLdrCheckForLoadedDll(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock, PLDR_DATA_TABLE_ENTRY DataTableEntry; LIST_ENTRY *ModuleEntry; - DPRINTM(DPRINT_PELOADER, "WinLdrCheckForLoadedDll: DllName %X, LoadedEntry: %X\n", + DPRINTM(DPRINT_PELOADER, "WinLdrCheckForLoadedDll: DllName %s, LoadedEntry: %X\n", DllName, LoadedEntry); /* Just go through each entry in the LoadOrderList and compare loaded module's From 3812c4f83c2c54c605c7f886c6092768f266cffe Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 7 Mar 2010 21:18:52 +0000 Subject: [PATCH 195/211] - [User32] Sync Mdi to wine 1.1.40. svn path=/trunk/; revision=45995 --- reactos/dll/win32/user32/windows/mdi.c | 319 ++++++++++++++-------- reactos/dll/win32/user32/windows/window.c | 21 -- reactos/media/doc/README.WINE | 2 +- 3 files changed, 199 insertions(+), 143 deletions(-) diff --git a/reactos/dll/win32/user32/windows/mdi.c b/reactos/dll/win32/user32/windows/mdi.c index fcf053ce43d..cde115d6a14 100644 --- a/reactos/dll/win32/user32/windows/mdi.c +++ b/reactos/dll/win32/user32/windows/mdi.c @@ -100,7 +100,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(mdi); typedef struct { + /* At some points, particularly when switching MDI children, active and + * maximized MDI children may be not the same window, so we need to track + * them separately. + * The only place where we switch to/from maximized state is DefMDIChildProc + * WM_SIZE/SIZE_MAXIMIZED handler. We get that notification only after the + * ShowWindow(SW_SHOWMAXIMIZED) request, therefore window is guaranteed to + * be visible at the time we get the notification, and it's safe to assume + * that hwndChildMaximized is always visible. + * If the app plays games with WS_VISIBLE, WS_MAXIMIZE or any other window + * states it must keep coherency with USER32 on its own. This is true for + * Windows as well. + */ UINT nActiveChildren; + HWND hwndChildMaximized; HWND hwndActiveChild; HWND *child; /* array of tracked children */ HMENU hFrameMenu; @@ -116,15 +129,13 @@ typedef struct //static HBITMAP hBmpClose = 0; /* ----------------- declarations ----------------- */ -static void MDI_UpdateFrameText( HWND, HWND, LPCWSTR); +static void MDI_UpdateFrameText( HWND, HWND, BOOL, LPCWSTR); static BOOL MDI_AugmentFrameMenu( HWND, HWND ); static BOOL MDI_RestoreFrameMenu( HWND, HWND, HBITMAP ); static LONG MDI_ChildActivate( HWND, HWND ); static LRESULT MDI_RefreshMenu(MDICLIENTINFO *); static HWND MDI_MoreWindowsDialog(HWND); -//static LRESULT WINAPI MDIClientWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); -//static LRESULT WINAPI MDIClientWndProcW( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); HWND* WIN_ListChildren (HWND hWndparent) { @@ -220,13 +231,15 @@ static MDICLIENTINFO *get_client_info( HWND client ) WND *win = WIN_GetPtr( client ); if (win) { - if (win == WND_OTHER_PROCESS) + if (win == WND_OTHER_PROCESS || win == WND_DESKTOP) { - if (IsWindow(client)) ERR( "client %p belongs to other process\n", client ); + if (IsWindow(client)) WARN( "client %p belongs to other process\n", client ); return NULL; } - if (win->cbWndExtra < sizeof(MDICLIENTINFO)) WARN( "%p is not an MDI client\n", client ); - else ret = (MDICLIENTINFO *)win->wExtra; + if (win->flags & WIN_ISMDICLIENT) + ret = (MDICLIENTINFO *)win->wExtra; + else + WARN( "%p is not an MDI client\n", client ); WIN_ReleasePtr( win ); } return ret; @@ -247,7 +260,6 @@ static BOOL is_close_enabled(HWND hwnd, HMENU hSysMenu) return TRUE; } - /********************************************************************** * MDI_GetWindow * @@ -343,12 +355,14 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, if (!(ci = get_client_info( hwnd ))) return 0; + TRACE("old frame menu %p, old window menu %p\n", ci->hFrameMenu, ci->hWindowMenu); + if (hmenuFrame) { if (hmenuFrame == ci->hFrameMenu) return (LRESULT)hmenuFrame; - if (IsZoomed(ci->hwndActiveChild)) - MDI_RestoreFrameMenu( hwndFrame, ci->hwndActiveChild, ci->hBmpClose ); + if (ci->hwndChildMaximized) + MDI_RestoreFrameMenu( hwndFrame, ci->hwndChildMaximized, ci->hBmpClose ); } if( hmenuWindow && hmenuWindow != ci->hWindowMenu ) @@ -382,8 +396,8 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, HMENU oldFrameMenu = ci->hFrameMenu; ci->hFrameMenu = hmenuFrame; - if (IsZoomed(ci->hwndActiveChild) && (GetWindowLongPtrW(ci->hwndActiveChild, GWL_STYLE) & WS_VISIBLE)) - MDI_AugmentFrameMenu( hwndFrame, ci->hwndActiveChild ); + if (ci->hwndChildMaximized) + MDI_AugmentFrameMenu( hwndFrame, ci->hwndChildMaximized ); return (LRESULT)oldFrameMenu; } @@ -396,8 +410,8 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, * that the "if" to this "else" wouldn't catch the need to * augment the frame menu. */ - if( IsZoomed(ci->hwndActiveChild) ) - MDI_AugmentFrameMenu( hwndFrame, ci->hwndActiveChild ); + if( ci->hwndChildMaximized ) + MDI_AugmentFrameMenu( hwndFrame, ci->hwndChildMaximized ); } return 0; @@ -577,12 +591,15 @@ static LRESULT MDIDestroyChild( HWND client, MDICLIENTINFO *ci, else { ShowWindow(child, SW_HIDE); - if (IsZoomed(child)) + if (child == ci->hwndChildMaximized) { - MDI_RestoreFrameMenu(GetParent(client), child, ci->hBmpClose); - MDI_UpdateFrameText(GetParent(client), client, NULL); + HWND frame = GetParent(client); + MDI_RestoreFrameMenu(frame, child, ci->hBmpClose); + ci->hwndChildMaximized = 0; + MDI_UpdateFrameText(frame, client, TRUE, NULL); } - MDI_ChildActivate(client, 0); + if (flagDestroy) + MDI_ChildActivate(client, 0); } } @@ -613,10 +630,9 @@ static LRESULT MDIDestroyChild( HWND client, MDICLIENTINFO *ci, } } - SendMessageW(client, WM_MDIREFRESHMENU, 0, 0); - if (flagDestroy) { + SendMessageW(client, WM_MDIREFRESHMENU, 0, 0); MDI_PostUpdate(GetParent(child), ci, SB_BOTH+1); DestroyWindow(child); } @@ -663,7 +679,13 @@ static LONG MDI_ChildActivate( HWND client, HWND child ) if( isActiveFrameWnd ) { SendMessageW( child, WM_NCACTIVATE, TRUE, 0L); - SetFocus( client ); + /* Let the client window manage focus for children, but if the focus + * is already on the client (for instance this is the 1st child) then + * SetFocus won't work. It appears that Windows sends WM_SETFOCUS + * manually in this case. + */ + if (SetFocus( client ) == client) + SendMessageW( client, WM_SETFOCUS, (WPARAM)client, 0 ); } SendMessageW( child, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child ); @@ -715,8 +737,8 @@ static LONG MDICascade( HWND client, MDICLIENTINFO *ci ) BOOL has_icons = FALSE; int i, total; - if (IsZoomed(ci->hwndActiveChild)) - SendMessageW(client, WM_MDIRESTORE, (WPARAM)ci->hwndActiveChild, 0); + if (ci->hwndChildMaximized) + SendMessageW(client, WM_MDIRESTORE, (WPARAM)ci->hwndChildMaximized, 0); if (ci->nActiveChildren == 0) return 0; @@ -745,13 +767,17 @@ static LONG MDICascade( HWND client, MDICLIENTINFO *ci ) /* walk the list (backwards) and move windows */ for (i = total - 1; i >= 0; i--) { - MDI_CalcDefaultChildPos(client, n++, pos, delta, NULL); + LONG style; + LONG posOptions = SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER; + MDI_CalcDefaultChildPos(client, n++, pos, delta, NULL); TRACE("move %p to (%ld,%ld) size [%ld,%ld]\n", win_array[i], pos[0].x, pos[0].y, pos[1].x, pos[1].y); + style = GetWindowLongW(win_array[i], GWL_STYLE); + if (!(style & WS_SIZEBOX)) posOptions |= SWP_NOSIZE; SetWindowPos( win_array[i], 0, pos[0].x, pos[0].y, pos[1].x, pos[1].y, - SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); + posOptions); } } HeapFree( GetProcessHeap(), 0, win_array ); @@ -769,8 +795,8 @@ static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam ) int i, total; BOOL has_icons = FALSE; - if (IsZoomed(ci->hwndActiveChild)) - SendMessageW(client, WM_MDIRESTORE, (WPARAM)ci->hwndActiveChild, 0); + if (ci->hwndChildMaximized) + SendMessageW(client, WM_MDIRESTORE, (WPARAM)ci->hwndChildMaximized, 0); if (ci->nActiveChildren == 0) return; @@ -831,8 +857,11 @@ static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam ) y = 0; for (r = 1; r <= rows && *pWnd; r++, i++) { - SetWindowPos(*pWnd, 0, x, y, xsize, ysize, - SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); + LONG posOptions = SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER; + LONG style = GetWindowLongW(win_array[i], GWL_STYLE); + if (!(style & WS_SIZEBOX)) posOptions |= SWP_NOSIZE; + + SetWindowPos(*pWnd, 0, x, y, xsize, ysize, posOptions); y += ysize; pWnd++; } @@ -854,23 +883,26 @@ static BOOL MDI_AugmentFrameMenu( HWND frame, HWND hChild ) HMENU menu = GetMenu( frame ); HMENU hSysPopup = 0; HBITMAP hSysMenuBitmap = 0; + HICON hIcon; INT nItems; UINT iId; - HICON hIcon; TRACE("frame %p,child %p\n",frame,hChild); if( !menu ) return 0; - +//// ReactOS start /* if the system buttons already exist do not add them again */ nItems = GetMenuItemCount(menu) - 1; iId = GetMenuItemID(menu,nItems) ; if (iId == SC_RESTORE || iId == SC_CLOSE) - return 0; + return 0; /* create a copy of sysmenu popup and insert it into frame menu bar */ if (!(hSysPopup = GetSystemMenu(hChild, FALSE))) - return 0; + { + TRACE("child %p doesn't have a system menu\n", hChild); + return 0; + } AppendMenuW(menu, MF_HELP | MF_BITMAP, SC_MINIMIZE, (LPCWSTR)HBMMENU_MBAR_MINIMIZE ) ; @@ -886,6 +918,7 @@ static BOOL MDI_AugmentFrameMenu( HWND frame, HWND hChild ) hIcon = (HICON)GetClassLongPtrW(hChild, GCLP_HICON); if (!hIcon) hIcon = LoadIconW(NULL, IDI_APPLICATION); +//// End if (hIcon) { HDC hMemDC; @@ -938,15 +971,17 @@ static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild, HBITMAP hBmpClose ) { MENUITEMINFOW menuInfo; HMENU menu = GetMenu( frame ); - INT nItems = GetMenuItemCount(menu) - 1; - UINT iId = GetMenuItemID(menu,nItems) ; + INT nItems; + UINT iId; - TRACE("frame %p,child %p,nIt=%d,iId=%d\n",frame,hChild,nItems,iId); + TRACE("frame %p,child %p\n",frame, hChild); if( !menu ) return 0; /* if there is no system buttons then nothing to do */ - if(!(iId == SC_RESTORE || iId == SC_CLOSE) ) + nItems = GetMenuItemCount(menu) - 1; + iId = GetMenuItemID(menu,nItems) ; + if( !(iId == SC_RESTORE || iId == SC_CLOSE) ) return 0; /* @@ -994,7 +1029,7 @@ static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild, HBITMAP hBmpClose ) * * Note: lpTitle can be NULL */ -static void MDI_UpdateFrameText( HWND frame, HWND hClient, LPCWSTR lpTitle ) +static void MDI_UpdateFrameText( HWND frame, HWND hClient, BOOL repaint, LPCWSTR lpTitle ) { WCHAR lpBuffer[MDI_MAXTITLELENGTH+1]; MDICLIENTINFO *ci = get_client_info( hClient ); @@ -1019,7 +1054,7 @@ static void MDI_UpdateFrameText( HWND frame, HWND hClient, LPCWSTR lpTitle ) if (ci->frameTitle) { - if (IsZoomed(ci->hwndActiveChild) && IsWindowVisible(ci->hwndActiveChild)) + if (ci->hwndChildMaximized) { /* combine frame title and child title if possible */ @@ -1048,6 +1083,10 @@ static void MDI_UpdateFrameText( HWND frame, HWND hClient, LPCWSTR lpTitle ) lpBuffer[0] = '\0'; DefWindowProcW( frame, WM_SETTEXT, 0, (LPARAM)lpBuffer ); + + if (repaint) + SetWindowPos( frame, 0,0,0,0,0, SWP_FRAMECHANGED | + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER ); } @@ -1057,63 +1096,43 @@ static void MDI_UpdateFrameText( HWND frame, HWND hClient, LPCWSTR lpTitle ) /********************************************************************** * MDIClientWndProc_common */ -LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam, BOOL unicode ) +LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, BOOL unicode ) { MDICLIENTINFO *ci = NULL; TRACE("%p %04x (%s) %08lx %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam); - if (WM_NCCREATE != message && NULL == (ci = get_client_info(hwnd))) + if (!(ci = get_client_info(hwnd))) { - return 0; - } - -#ifndef __REACTOS__ - if (!(ci = get_client_info( hwnd ))) return 0; + if (message == WM_NCCREATE) + { +#ifdef __REACTOS__ + if (!(ci = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ci)))) + return FALSE; + SetWindowLongPtrW( hwnd, 0, (LONG_PTR)ci ); + ci->hBmpClose = 0; +#else + WND *wndPtr = WIN_GetPtr( hwnd ); + wndPtr->flags |= WIN_ISMDICLIENT; + WIN_ReleasePtr( wndPtr ); #endif + } + return unicode ? DefWindowProcW( hwnd, message, wParam, lParam ) : + DefWindowProcA( hwnd, message, wParam, lParam ); + } switch (message) { -#ifdef __REACTOS__ - case WM_NCCREATE: - if (!(ci = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ci)))) - return FALSE; - SetWindowLongPtrW( hwnd, 0, (LONG_PTR)ci ); - ci->hBmpClose = 0; - return TRUE; -#endif - case WM_CREATE: { /* Since we are using only cs->lpCreateParams, we can safely * cast to LPCREATESTRUCTA here */ - LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam; -#ifndef __REACTOS__ - WND *wndPtr = WIN_GetPtr( hwnd ); + LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam; + LPCLIENTCREATESTRUCT ccs = (LPCLIENTCREATESTRUCT)cs->lpCreateParams; - wndPtr->flags |= WIN_ISMDICLIENT; -#endif - /* Translation layer doesn't know what's in the cs->lpCreateParams - * so we have to keep track of what environment we're in. */ - -#ifndef __REACTOS__ - if( wndPtr->flags & WIN_ISWIN32 ) -#endif - { - LPCLIENTCREATESTRUCT ccs = (LPCLIENTCREATESTRUCT)cs->lpCreateParams; - ci->hWindowMenu = ccs->hWindowMenu; - ci->idFirstChild = ccs->idFirstChild; - } -#ifndef __REACTOS__ - else - { - LPCLIENTCREATESTRUCT16 ccs = MapSL((SEGPTR)cs->lpCreateParams); - ci->hWindowMenu = HMENU_32(ccs->hWindowMenu); - ci->idFirstChild = ccs->idFirstChild; - } - WIN_ReleasePtr( wndPtr ); -#endif + ci->hWindowMenu = ccs->hWindowMenu; + ci->idFirstChild = ccs->idFirstChild; + ci->hwndChildMaximized = 0; ci->child = NULL; ci->nActiveChildren = 0; ci->nTotalCreated = 0; @@ -1130,8 +1149,8 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, case WM_DESTROY: { - if( IsZoomed(ci->hwndActiveChild) ) - MDI_RestoreFrameMenu(GetParent(hwnd), ci->hwndActiveChild, ci->hBmpClose); + if( ci->hwndChildMaximized ) + MDI_RestoreFrameMenu(GetParent(hwnd), ci->hwndChildMaximized, ci->hBmpClose); ci->nActiveChildren = 0; MDI_RefreshMenu(ci); @@ -1147,7 +1166,8 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, case WM_MDIACTIVATE: { - MDI_SwitchActiveChild( ci, (HWND)wParam, TRUE ); + if( ci->hwndActiveChild != (HWND)wParam ) + SetWindowPos((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE); return 0; } @@ -1177,18 +1197,13 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, hwnd, 0, csA->hOwner, (LPVOID)csA->lParam); } - - if (IsZoomed(ci->hwndActiveChild)) - { - MDI_AugmentFrameMenu(GetParent(hwnd), child); - MDI_UpdateFrameText(GetParent(hwnd), hwnd, NULL); - } return (LRESULT)child; } return 0; case WM_MDIDESTROY: return MDIDestroyChild( hwnd, ci, (HWND)wParam, TRUE ); + case WM_MDIGETACTIVE: if (lParam) *(BOOL *)lParam = IsZoomed(ci->hwndActiveChild); return (LRESULT)ci->hwndActiveChild; @@ -1212,7 +1227,7 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, } case WM_MDIRESTORE: - SendMessageW( (HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0); + ShowWindow( (HWND)wParam, SW_SHOWNORMAL ); return 0; case WM_MDISETMENU: @@ -1251,11 +1266,15 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, case WM_CREATE: if (GetWindowLongPtrW((HWND)lParam, GWL_EXSTYLE) & WS_EX_MDICHILD) { + // ReactOS See rev 33503 if (!ci->child) ci->child = HeapAlloc(GetProcessHeap(), 0, sizeof(HWND)); else ci->child = HeapReAlloc(GetProcessHeap(), 0, ci->child, sizeof(HWND) * (ci->nActiveChildren + 1)); + TRACE("Adding MDI child %p, # of children %d\n", + (HWND)lParam, ci->nActiveChildren); + if (ci->child != NULL) { ci->child[ci->nActiveChildren] = (HWND)lParam; @@ -1279,12 +1298,14 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, SetWindowPos(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE ); break; } + + case WM_DESTROY: + return MDIDestroyChild( hwnd, ci, WIN_GetFullHandle( (HWND)lParam ), FALSE ); } return 0; case WM_SIZE: - if( IsWindow(ci->hwndActiveChild) && IsZoomed(ci->hwndActiveChild) && - (GetWindowLongPtrW(ci->hwndActiveChild, GWL_STYLE) & WS_VISIBLE) ) + if( ci->hwndActiveChild && IsZoomed(ci->hwndActiveChild) ) { RECT rect; @@ -1292,7 +1313,6 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, rect.top = 0; rect.right = LOWORD(lParam); rect.bottom = HIWORD(lParam); - AdjustWindowRectEx(&rect, GetWindowLongPtrA(ci->hwndActiveChild, GWL_STYLE), 0, GetWindowLongPtrA(ci->hwndActiveChild, GWL_EXSTYLE) ); MoveWindow(ci->hwndActiveChild, rect.left, rect.top, @@ -1351,7 +1371,7 @@ LRESULT WINAPI DefFrameProcA( HWND hwnd, HWND hwndMDIClient, if (text == NULL) return 0; MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, text, len ); - MDI_UpdateFrameText( hwnd, hwndMDIClient, text ); + MDI_UpdateFrameText( hwnd, hwndMDIClient, FALSE, text ); HeapFree( GetProcessHeap(), 0, text ); } return 1; /* success. FIXME: check text length */ @@ -1389,7 +1409,7 @@ LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient, if (id < ci->idFirstChild || id >= ci->idFirstChild + ci->nActiveChildren) { if( (id - 0xf000) & 0xf00f ) break; - if( !IsZoomed(ci->hwndActiveChild) ) break; + if( !ci->hwndChildMaximized ) break; switch( id ) { case SC_CLOSE: @@ -1426,7 +1446,7 @@ LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient, break; case WM_SETTEXT: - MDI_UpdateFrameText( hwnd, hwndMDIClient, (LPWSTR)lParam ); + MDI_UpdateFrameText( hwnd, hwndMDIClient, FALSE, (LPWSTR)lParam ); return 1; /* success. FIXME: check text length */ case WM_SETFOCUS: @@ -1482,8 +1502,8 @@ LRESULT WINAPI DefMDIChildProcA( HWND hwnd, UINT message, { case WM_SETTEXT: DefWindowProcA(hwnd, message, wParam, lParam); - if( ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild) ) - MDI_UpdateFrameText( GetParent(client), client, NULL ); + if( ci->hwndChildMaximized == hwnd ) + MDI_UpdateFrameText( GetParent(client), client, TRUE, NULL ); return 1; /* success. FIXME: check text length */ case WM_GETMINMAXINFO: @@ -1516,6 +1536,7 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, MDICLIENTINFO *ci = get_client_info( client ); TRACE("%p %04x (%s) %08lx %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam); + hwnd = WIN_GetFullHandle( hwnd ); if (!ci) return DefWindowProcW( hwnd, message, wParam, lParam ); @@ -1523,8 +1544,8 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, { case WM_SETTEXT: DefWindowProcW(hwnd, message, wParam, lParam); - if( ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild) ) - MDI_UpdateFrameText( GetParent(client), client, NULL ); + if( ci->hwndChildMaximized == hwnd ) + MDI_UpdateFrameText( GetParent(client), client, TRUE, NULL ); return 1; /* success. FIXME: check text length */ case WM_GETMINMAXINFO: @@ -1538,22 +1559,27 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, SendMessageW( client, WM_MDIDESTROY, (WPARAM)hwnd, 0 ); return 0; + case WM_SETFOCUS: + if (ci->hwndActiveChild != hwnd) + MDI_ChildActivate( client, hwnd ); + break; + case WM_CHILDACTIVATE: MDI_ChildActivate( client, hwnd ); return 0; case WM_SYSCOMMAND: - switch( wParam ) + switch( wParam & 0xfff0) { case SC_MOVE: - if( ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild)) + if( ci->hwndChildMaximized == hwnd ) return 0; break; case SC_RESTORE: case SC_MINIMIZE: break; case SC_MAXIMIZE: - if (ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild)) + if (ci->hwndChildMaximized == hwnd ) return SendMessageW( GetParent(client), message, wParam, lParam); break; case SC_NEXTWINDOW: @@ -1569,25 +1595,60 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, #ifndef __REACTOS__ case WM_SETVISIBLE: #endif - if (IsZoomed(ci->hwndActiveChild)) ci->mdiFlags &= ~MDIF_NEEDUPDATE; + if (ci->hwndChildMaximized) ci->mdiFlags &= ~MDIF_NEEDUPDATE; else MDI_PostUpdate(client, ci, SB_BOTH+1); break; case WM_SIZE: - if( hwnd == ci->hwndActiveChild ) - { - if( wParam == SIZE_MAXIMIZED ) - { - TRACE("maximizing child %p\n", hwnd ); + /* This is the only place where we switch to/from maximized state */ + /* do not change */ + TRACE("current active %p, maximized %p\n", ci->hwndActiveChild, ci->hwndChildMaximized); - MDI_AugmentFrameMenu( GetParent(client), hwnd ); - } - else - MDI_RestoreFrameMenu( GetParent(client), hwnd , ci->hBmpClose); + if( ci->hwndChildMaximized == hwnd && wParam != SIZE_MAXIMIZED) + { + HWND frame; + + ci->hwndChildMaximized = 0; + + frame = GetParent(client); + MDI_RestoreFrameMenu( frame, hwnd, ci->hBmpClose ); + MDI_UpdateFrameText( frame, client, TRUE, NULL ); } - MDI_UpdateFrameText( GetParent(client), client, NULL ); - MDI_RefreshMenu(ci); + if( wParam == SIZE_MAXIMIZED ) + { + HWND frame, hMaxChild = ci->hwndChildMaximized; + + if( hMaxChild == hwnd ) break; + + if( hMaxChild) + { + SendMessageW( hMaxChild, WM_SETREDRAW, FALSE, 0 ); + + MDI_RestoreFrameMenu( GetParent(client), hMaxChild, ci->hBmpClose ); + ShowWindow( hMaxChild, SW_SHOWNOACTIVATE ); + + SendMessageW( hMaxChild, WM_SETREDRAW, TRUE, 0 ); + } + + TRACE("maximizing child %p\n", hwnd ); + + /* keep track of the maximized window. */ + ci->hwndChildMaximized = hwnd; /* !!! */ + + frame = GetParent(client); + MDI_AugmentFrameMenu( frame, hwnd ); + MDI_UpdateFrameText( frame, client, TRUE, NULL ); + } + + if( wParam == SIZE_MINIMIZED ) + { + HWND switchTo = MDI_GetWindow( ci, hwnd, TRUE, WS_MINIMIZE ); + + if (!switchTo) switchTo = hwnd; + SendMessageW( switchTo, WM_CHILDACTIVATE, 0, 0 ); + } + MDI_PostUpdate(client, ci, SB_BOTH+1); break; @@ -1613,7 +1674,7 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, case WM_SYSCHAR: if (wParam == '-') { - SendMessageW( hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (DWORD)VK_SPACE); + SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE); return 0; } break; @@ -1716,7 +1777,7 @@ BOOL WINAPI TranslateMDISysAccel( HWND hwndClient, LPMSG msg ) return 0; } TRACE("wParam = %04lx\n", wParam); - SendMessageW(ci->hwndActiveChild, WM_SYSCOMMAND, wParam, (LPARAM)msg->wParam); + SendMessageW(ci->hwndActiveChild, WM_SYSCOMMAND, wParam, msg->wParam); return 1; } } @@ -1903,6 +1964,14 @@ CascadeWindows (HWND hwndParent, UINT wFlags, LPCRECT lpRect, return 0; } +/*********************************************************************** + * CascadeChildWindows (USER32.@) + */ +WORD WINAPI CascadeChildWindows( HWND parent, UINT flags ) +{ + return CascadeWindows( parent, flags, NULL, 0, NULL ); +} + /****************************************************************************** * TileWindows (USER32.@) Tiles MDI child windows @@ -1919,6 +1988,15 @@ TileWindows (HWND hwndParent, UINT wFlags, LPCRECT lpRect, return 0; } +/*********************************************************************** + * TileChildWindows (USER32.@) + */ +WORD WINAPI TileChildWindows( HWND parent, UINT flags ) +{ + return TileWindows( parent, flags, NULL, 0, NULL ); +} + + /************************************************************************ * "More Windows..." functionality */ @@ -2022,7 +2100,6 @@ static HWND MDI_MoreWindowsDialog(HWND hwnd) if (template == 0) return 0; - return (HWND) DialogBoxIndirectParamA(User32Instance, - (const DLGTEMPLATE*) template, - hwnd, MDI_MoreWindowsDlgProc, (LPARAM) hwnd); + return (HWND) DialogBoxIndirectParamA(User32Instance, template, hwnd, + MDI_MoreWindowsDlgProc, (LPARAM) hwnd); } diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 5fbcd0281ba..6ed38cce020 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -103,17 +103,6 @@ SwitchToThisWindow(HWND hwnd, BOOL fUnknown) } -/* - * @implemented - */ -WORD -WINAPI -CascadeChildWindows ( HWND hWndParent, WORD wFlags ) -{ - return CascadeWindows(hWndParent, wFlags, NULL, 0, NULL); -} - - /* * @implemented */ @@ -1982,16 +1971,6 @@ ScrollWindowEx(HWND hWnd, flags); } -/* - * @implemented - */ -WORD -WINAPI -TileChildWindows(HWND hWndParent, WORD wFlags) -{ - return TileWindows(hWndParent, wFlags, NULL, 0, NULL); -} - /* * @implemented */ diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 4eadfce1da2..78a24c54163 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -250,7 +250,7 @@ User32 - reactos/dll/win32/user32/windows/defwnd.c # Forked reactos/dll/win32/user32/windows/draw.c # Forked at Wine-20020904 (uitools.c) - reactos/dll/win32/user32/windows/mdi.c # Synced at 20060703 + reactos/dll/win32/user32/windows/mdi.c # Synced to Wine-1_1_40 reactos/dll/win32/user32/windows/menu.c # Forked reactos/dll/win32/user32/windows/messagebox.c # Forked reactos/dll/win32/user32/windows/rect.c # Forked (uitools.c) From 95a13b7f8ffd39c69e76288d73f7a1d15e74ebb9 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 8 Mar 2010 20:30:51 +0000 Subject: [PATCH 196/211] - Silent traces svn path=/trunk/; revision=46000 --- reactos/dll/directx/bdaplgin/precomp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/directx/bdaplgin/precomp.h b/reactos/dll/directx/bdaplgin/precomp.h index e4776ea20a1..771a798f2c3 100644 --- a/reactos/dll/directx/bdaplgin/precomp.h +++ b/reactos/dll/directx/bdaplgin/precomp.h @@ -1,7 +1,7 @@ #ifndef PRECOMP_H__ #define PRECOMP_H__ -#define BDAPLGIN_TRACE +//#define BDAPLGIN_TRACE #define BUILDING_KS #define _KSDDK_ #include From a15d2634ea8aed760920a0021a8b030e7fe25815 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 8 Mar 2010 20:37:24 +0000 Subject: [PATCH 197/211] [NTOS]: Implement CmSetLazyFlushState to disable lazy writing in the Cm. [NTOS]: Implement ExSwapInWorkerThreads to in-swap any worker threads when needed. [NTOS]: Add HAL stubs for HalEndOfBoot and HalSetWakeEnable since most HALs set this to NULL. [DDK]: Add some missing definitions. svn path=/trunk/; revision=46001 --- reactos/include/ddk/winddk.h | 35 ++++++++++ reactos/ntoskrnl/config/cmlazy.c | 8 +++ reactos/ntoskrnl/ex/work.c | 87 ++++++++++++++++++++++++- reactos/ntoskrnl/fstub/halstub.c | 20 +++++- reactos/ntoskrnl/include/internal/cm.h | 6 ++ reactos/ntoskrnl/include/internal/ex.h | 5 ++ reactos/ntoskrnl/include/internal/hal.h | 12 ++++ 7 files changed, 169 insertions(+), 4 deletions(-) diff --git a/reactos/include/ddk/winddk.h b/reactos/include/ddk/winddk.h index a2bbeb1e3d2..a5fc2c975fd 100644 --- a/reactos/include/ddk/winddk.h +++ b/reactos/include/ddk/winddk.h @@ -898,6 +898,41 @@ typedef union _POWER_STATE { DEVICE_POWER_STATE DeviceState; } POWER_STATE, *PPOWER_STATE; +typedef struct _POWER_ACTION_POLICY { + POWER_ACTION Action; + ULONG Flags; + ULONG EventCode; +} POWER_ACTION_POLICY, *PPOWER_ACTION_POLICY; + +/* POWER_ACTION_POLICY.Flags constants */ +#define POWER_ACTION_QUERY_ALLOWED 0x00000001 +#define POWER_ACTION_UI_ALLOWED 0x00000002 +#define POWER_ACTION_OVERRIDE_APPS 0x00000004 +#define POWER_ACTION_LIGHTEST_FIRST 0x10000000 +#define POWER_ACTION_LOCK_CONSOLE 0x20000000 +#define POWER_ACTION_DISABLE_WAKES 0x40000000 +#define POWER_ACTION_CRITICAL 0x80000000 + +/* POWER_ACTION_POLICY.EventCode constants */ +#define POWER_LEVEL_USER_NOTIFY_TEXT 0x00000001 +#define POWER_LEVEL_USER_NOTIFY_SOUND 0x00000002 +#define POWER_LEVEL_USER_NOTIFY_EXEC 0x00000004 +#define POWER_USER_NOTIFY_BUTTON 0x00000008 +#define POWER_USER_NOTIFY_SHUTDOWN 0x00000010 +#define POWER_FORCE_TRIGGER_RESET 0x80000000 + +#define DISCHARGE_POLICY_CRITICAL 0 +#define DISCHARGE_POLICY_LOW 1 +#define NUM_DISCHARGE_POLICIES 4 + +#define PO_THROTTLE_NONE 0 +#define PO_THROTTLE_CONSTANT 1 +#define PO_THROTTLE_DEGRADE 2 +#define PO_THROTTLE_ADAPTIVE 3 +#define PO_THROTTLE_MAXIMUM 4 + + + typedef enum _POWER_STATE_TYPE { SystemPowerState, DevicePowerState diff --git a/reactos/ntoskrnl/config/cmlazy.c b/reactos/ntoskrnl/config/cmlazy.c index 4b0f01cec5c..bfe56542a23 100644 --- a/reactos/ntoskrnl/config/cmlazy.c +++ b/reactos/ntoskrnl/config/cmlazy.c @@ -298,4 +298,12 @@ CmpShutdownWorkers(VOID) KeCancelTimer(&CmpLazyFlushTimer); } +VOID +NTAPI +CmSetLazyFlushState(IN BOOLEAN Enable) +{ + /* Set state for lazy flusher */ + CmpHoldLazyFlush = !Enable; +} + /* EOF */ diff --git a/reactos/ntoskrnl/ex/work.c b/reactos/ntoskrnl/ex/work.c index abedd6b4985..d3cf4b5643e 100644 --- a/reactos/ntoskrnl/ex/work.c +++ b/reactos/ntoskrnl/ex/work.c @@ -43,7 +43,7 @@ ULONG ExpAdditionalDelayedWorkerThreads; /* Future support for stack swapping worker threads */ BOOLEAN ExpWorkersCanSwap; LIST_ENTRY ExpWorkerListHead; -KMUTANT ExpWorkerSwapinMutex; +FAST_MUTEX ExpWorkerSwapinMutex; /* The worker balance set manager events */ KEVENT ExpThreadSetManagerEvent; @@ -513,7 +513,7 @@ ExpInitializeWorkerThreads(VOID) ULONG i; /* Setup the stack swap support */ - KeInitializeMutex(&ExpWorkerSwapinMutex, FALSE); + ExInitializeFastMutex(&ExpWorkerSwapinMutex); InitializeListHead(&ExpWorkerListHead); ExpWorkersCanSwap = TRUE; @@ -589,6 +589,89 @@ ExpInitializeWorkerThreads(VOID) ObCloseHandle(ThreadHandle, KernelMode); } +VOID +NTAPI +ExpSetSwappingKernelApc(IN PKAPC Apc, + OUT PKNORMAL_ROUTINE *NormalRoutine, + IN OUT PVOID *NormalContext, + IN OUT PVOID *SystemArgument1, + IN OUT PVOID *SystemArgument2) +{ + PBOOLEAN AllowSwap; + PKEVENT Event = (PKEVENT)*SystemArgument1; + + /* Make sure it's an active worker */ + if (PsGetCurrentThread()->ActiveExWorker) + { + /* Read the setting from the context flag */ + AllowSwap = (PBOOLEAN)NormalContext; + KeSetKernelStackSwapEnable(*AllowSwap); + } + + /* Let caller know that we're done */ + KeSetEvent(Event, 0, FALSE); +} + +VOID +NTAPI +ExSwapinWorkerThreads(IN BOOLEAN AllowSwap) +{ + KEVENT Event; + PETHREAD CurrentThread = PsGetCurrentThread(), Thread; + PEPROCESS Process = PsInitialSystemProcess; + KAPC Apc; + PAGED_CODE(); + + /* Initialize an event so we know when we're done */ + KeInitializeEvent(&Event, NotificationEvent, FALSE); + + /* Lock this routine */ + ExAcquireFastMutex(&ExpWorkerSwapinMutex); + + /* New threads cannot swap anymore */ + ExpWorkersCanSwap = AllowSwap; + + /* Loop all threads in the system process */ + Thread = PsGetNextProcessThread(Process, NULL); + while (Thread) + { + /* Skip threads with explicit permission to do this */ + if (Thread->ExWorkerCanWaitUser) goto Next; + + /* Check if we reached ourselves */ + if (Thread == CurrentThread) + { + /* Do it inline */ + KeSetKernelStackSwapEnable(AllowSwap); + } + else + { + /* Queue an APC */ + KeInitializeApc(&Apc, + &Thread->Tcb, + InsertApcEnvironment, + ExpSetSwappingKernelApc, + NULL, + NULL, + KernelMode, + &AllowSwap); + if (KeInsertQueueApc(&Apc, &Event, NULL, 3)) + { + /* Wait for the APC to run */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + KeClearEvent(&Event); + } + } + + /* Next thread */ +Next: + Thread = PsGetNextProcessThread(Process, Thread); + } + + /* Release the lock */ + ExReleaseFastMutex(&ExpWorkerSwapinMutex); +} + /* PUBLIC FUNCTIONS **********************************************************/ /*++ diff --git a/reactos/ntoskrnl/fstub/halstub.c b/reactos/ntoskrnl/fstub/halstub.c index a6469458ac9..38eec69b014 100644 --- a/reactos/ntoskrnl/fstub/halstub.c +++ b/reactos/ntoskrnl/fstub/halstub.c @@ -36,7 +36,7 @@ HAL_DISPATCH HalDispatchTable = (pHalStartMirroring)NULL, (pHalEndMirroring)NULL, (pHalMirrorPhysicalMemory)NULL, - (pHalEndOfBoot)NULL, + xHalEndOfBoot, (pHalMirrorVerify)NULL }; @@ -47,7 +47,7 @@ HAL_PRIVATE_DISPATCH HalPrivateDispatchTable = (pHalHandlerForConfigSpace)NULL, (pHalLocateHiberRanges)NULL, (pHalRegisterBusHandler)NULL, - (pHalSetWakeEnable)NULL, + xHalSetWakeEnable, (pHalSetWakeAlarm)NULL, (pHalTranslateBusAddress)NULL, (pHalAssignSlotResources)NULL, @@ -81,3 +81,19 @@ xHalHaltSystem(VOID) /* Halt execution */ while (TRUE); } + +VOID +NTAPI +xHalEndOfBoot(VOID) +{ + /* Nothing */ + return; +} + +VOID +NTAPI +xHalSetWakeEnable(IN BOOLEAN Enable) +{ + /* Nothing */ + return; +} diff --git a/reactos/ntoskrnl/include/internal/cm.h b/reactos/ntoskrnl/include/internal/cm.h index 9218e0741f0..537111a4f29 100644 --- a/reactos/ntoskrnl/include/internal/cm.h +++ b/reactos/ntoskrnl/include/internal/cm.h @@ -1454,6 +1454,12 @@ CmShutdownSystem( VOID ); +VOID +NTAPI +CmSetLazyFlushState( + IN BOOLEAN Enable +); + // // Global variables accessible from all of Cm // diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index a8bf90d70fa..8f72e6b3a7c 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -26,6 +26,7 @@ extern ULONG NtGlobalFlag; extern ULONG ExpInitializationPhase; extern ULONG ExpAltTimeZoneBias; extern LIST_ENTRY ExSystemLookasideListHead; +extern PCALLBACK_OBJECT PowerStateCallback; typedef struct _EXHANDLE { @@ -158,6 +159,10 @@ VOID NTAPI ExpInitializeWorkerThreads(VOID); +VOID +NTAPI +ExSwapinWorkerThreads(IN BOOLEAN AllowSwap); + VOID NTAPI ExpInitLookasideLists(VOID); diff --git a/reactos/ntoskrnl/include/internal/hal.h b/reactos/ntoskrnl/include/internal/hal.h index 9c0c77ffa65..47b76beee48 100644 --- a/reactos/ntoskrnl/include/internal/hal.h +++ b/reactos/ntoskrnl/include/internal/hal.h @@ -53,6 +53,18 @@ xHalHaltSystem( VOID ); +VOID +NTAPI +xHalEndOfBoot( + VOID +); + +VOID +NTAPI +xHalSetWakeEnable( + IN BOOLEAN Enable +); + UCHAR NTAPI xHalVectorToIDTEntry( From 02f2e242ff3334d456b0a452468d932d68826a75 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 8 Mar 2010 20:42:48 +0000 Subject: [PATCH 198/211] SEH-Protect the call to RSetServiceStatus in SetServiceStatus. This keeps services from crashing when the connection to the service manager fails. svn path=/trunk/; revision=46002 --- reactos/dll/win32/advapi32/service/sctrl.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/advapi32/service/sctrl.c b/reactos/dll/win32/advapi32/service/sctrl.c index 60516cdfd89..ca6f1648fe0 100644 --- a/reactos/dll/win32/advapi32/service/sctrl.c +++ b/reactos/dll/win32/advapi32/service/sctrl.c @@ -651,9 +651,18 @@ SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, TRACE("SetServiceStatus() called\n"); TRACE("hServiceStatus %lu\n", hServiceStatus); - /* Call to services.exe using RPC */ - dwError = RSetServiceStatus((RPC_SERVICE_STATUS_HANDLE)hServiceStatus, - lpServiceStatus); + RpcTryExcept + { + /* Call to services.exe using RPC */ + dwError = RSetServiceStatus((RPC_SERVICE_STATUS_HANDLE)hServiceStatus, + lpServiceStatus); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwError = ScmRpcStatusToWinError(RpcExceptionCode()); + } + RpcEndExcept; + if (dwError != ERROR_SUCCESS) { ERR("ScmrSetServiceStatus() failed (Error %lu)\n", dwError); From c14fc3dc56705be5aac64409b186830f35201c40 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 8 Mar 2010 20:46:53 +0000 Subject: [PATCH 199/211] [CMLIB]: Just use UNIMPLEMENTED. svn path=/trunk/; revision=46003 --- reactos/lib/cmlib/hivewrt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/lib/cmlib/hivewrt.c b/reactos/lib/cmlib/hivewrt.c index a4e3d3c3ccc..5cc20cfe503 100644 --- a/reactos/lib/cmlib/hivewrt.c +++ b/reactos/lib/cmlib/hivewrt.c @@ -23,7 +23,7 @@ HvpWriteLog( PVOID BlockPtr; BOOLEAN Success; - DPRINT1("FIXME: HvpWriteLog doesn't do anything atm\n"); + UNIMPLEMENTED; return TRUE; ASSERT(RegistryHive->ReadOnly == FALSE); From 8a4845b4092b1a865dc0e678ab4545216a70e111 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 8 Mar 2010 20:47:10 +0000 Subject: [PATCH 200/211] [NTOS]: Have I/O Manager Volume Device Objects register with the Power Manager so that they can receive dope. [NTOS]: Reimplement NtShutdownSystem. [NTOS]: Implement NtSetSystemPowerState for the shutdown/reboot cases. [NTOS]: Use the dope from the volume device objects to flush all writeable (non-floppy) devices. Pending hard-disk changes are now flushed to disks before shutdown. [NTOS]: Flush \\REGISTRY during shutdown. This flushes all pending changes. [NTOS]: Call into Cc to flush lazy writer during shutdown. [NTOS]: Stop killing processes on shutdown. The kernel should not be doing this. [NTOS]: Don't only shutdown disk file systems, but also cdrom and tape. [NTOS]: Don't only notify drivers of first-chance shutdown -- also parse the last-change shutdown list. [NTOS]: Reference drivers registering for shutdown notifications so that they remain loaded for them to get the notification at shutdown. [NTOS]: Notify drivers that have registered/opened the Power State callback. [NTOS]: A lot of the Po* power state code is highly simplified, but provides a good roadmap to anyone interested in this functionality long-term. svn path=/trunk/; revision=46004 --- reactos/ntoskrnl/ex/shutdown.c | 141 ++-------- reactos/ntoskrnl/include/internal/io.h | 8 +- reactos/ntoskrnl/include/internal/po.h | 263 ++++++++++++++++++ reactos/ntoskrnl/io/iomgr/device.c | 162 ++++++++--- reactos/ntoskrnl/io/iomgr/volume.c | 6 +- reactos/ntoskrnl/ntoskrnl-generic.rbuild | 4 +- reactos/ntoskrnl/po/poshtdwn.c | 196 +++++++++++++ reactos/ntoskrnl/po/povolume.c | 334 +++++++++++++++++++++++ reactos/ntoskrnl/po/power.c | 144 ++++++++++ 9 files changed, 1102 insertions(+), 156 deletions(-) create mode 100644 reactos/ntoskrnl/po/poshtdwn.c create mode 100644 reactos/ntoskrnl/po/povolume.c diff --git a/reactos/ntoskrnl/ex/shutdown.c b/reactos/ntoskrnl/ex/shutdown.c index 9a84bd45c19..30f8606724e 100644 --- a/reactos/ntoskrnl/ex/shutdown.c +++ b/reactos/ntoskrnl/ex/shutdown.c @@ -14,123 +14,40 @@ /* FUNCTIONS *****************************************************************/ -VOID NTAPI -ShutdownThreadMain(PVOID Context) -{ - SHUTDOWN_ACTION Action = (SHUTDOWN_ACTION)Context; - PUCHAR Logo1, Logo2; - ULONG i; - - /* Run the thread on the boot processor */ - KeSetSystemAffinityThread(1); - - PspShutdownProcessManager(); - - CmShutdownSystem(); - IoShutdownRegisteredFileSystems(); - IoShutdownRegisteredDevices(); - - if (Action == ShutdownNoReboot) - { - /* Try the platform driver */ - PopSetSystemPowerState(PowerSystemShutdown); - - /* If that didn't work, try legacy switch off */ - //HalReturnToFirmware(HalPowerDownRoutine); - - /* If that still didn't work, stop all interrupts */ - KeRaiseIrqlToDpcLevel(); - _disable(); - - /* Do we have boot video */ - if (InbvIsBootDriverInstalled()) - { - /* Yes we do, cleanup for shutdown screen */ - if (!InbvCheckDisplayOwnership()) InbvAcquireDisplayOwnership(); - InbvResetDisplay(); - InbvSolidColorFill(0, 0, 639, 479, 0); - InbvEnableDisplayString(TRUE); - InbvSetScrollRegion(0, 0, 639, 479); - - /* Display shutdown logo and message */ - Logo1 = InbvGetResourceAddress(IDB_SHUTDOWN_LOGO); - Logo2 = InbvGetResourceAddress(IDB_LOGO); - if ((Logo1) && (Logo2)) - { - InbvBitBlt(Logo1, 215, 352); - InbvBitBlt(Logo2, 217, 111); - } - } - else - { - /* Do it in text-mode */ - for (i = 0; i < 25; i++) InbvDisplayString("\n"); - InbvDisplayString(" "); - InbvDisplayString("The system may be powered off now.\n"); - } - - /* Hang the system */ - for (;;) HalHaltSystem(); - } - else if (Action == ShutdownReboot) - { - HalReturnToFirmware (HalRebootRoutine); - } - else - { - HalReturnToFirmware (HalHaltRoutine); - } -} - - -NTSTATUS NTAPI -NtSetSystemPowerState(IN POWER_ACTION SystemAction, - IN SYSTEM_POWER_STATE MinSystemState, - IN ULONG Flags) -{ - /* Windows 2000 only */ - return(STATUS_NOT_IMPLEMENTED); -} - /* * @implemented */ -NTSTATUS NTAPI +NTSTATUS +NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action) { - NTSTATUS Status; - HANDLE ThreadHandle; - PETHREAD ShutdownThread; - - if (Action > ShutdownPowerOff) - return STATUS_INVALID_PARAMETER; - Status = PsCreateSystemThread(&ThreadHandle, - THREAD_ALL_ACCESS, - NULL, - NULL, - NULL, - ShutdownThreadMain, - (PVOID)Action); - if (!NT_SUCCESS(Status)) - { - ASSERT(FALSE); - } - Status = ObReferenceObjectByHandle(ThreadHandle, - THREAD_ALL_ACCESS, - PsThreadType, - KernelMode, - (PVOID*)&ShutdownThread, - NULL); - NtClose(ThreadHandle); - if (!NT_SUCCESS(Status)) - { - ASSERT(FALSE); - } - - KeSetPriorityThread(&ShutdownThread->Tcb, LOW_REALTIME_PRIORITY + 1); - ObDereferenceObject(ShutdownThread); - - return STATUS_SUCCESS; + POWER_ACTION PowerAction; + + /* Convert to power action */ + if (Action == ShutdownNoReboot) + { + PowerAction = PowerActionShutdown; + } + else if (Action == ShutdownReboot) + { + PowerAction = PowerActionShutdownReset; + } + else if (Action == ShutdownPowerOff) + { + PowerAction = PowerActionShutdownOff; + } + else + { + return STATUS_INVALID_PARAMETER; + } + + /* Now call the power manager */ + DPRINT1("Setting state to: %lx\n", PowerAction); + return NtSetSystemPowerState(PowerAction, + PowerSystemSleeping3, + POWER_ACTION_OVERRIDE_APPS | + POWER_ACTION_DISABLE_WAKES | + POWER_ACTION_CRITICAL); } /* EOF */ diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index cf45a025943..c8b671693af 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -743,14 +743,14 @@ IoInitShutdownNotification( VOID NTAPI -IoShutdownRegisteredDevices( - VOID +IoShutdownSystem( + IN ULONG Phase ); VOID NTAPI -IoShutdownRegisteredFileSystems( - VOID +IopShutdownBaseFileSystems( + IN PLIST_ENTRY ListHead ); // diff --git a/reactos/ntoskrnl/include/internal/po.h b/reactos/ntoskrnl/include/internal/po.h index e45a0d95957..01ddf3b5c37 100644 --- a/reactos/ntoskrnl/include/internal/po.h +++ b/reactos/ntoskrnl/include/internal/po.h @@ -32,6 +32,228 @@ #define POTRACE(x, ...) DPRINT(__VA_ARGS__) #endif +typedef struct _PO_HIBER_PERF +{ + ULONGLONG IoTicks; + ULONGLONG InitTicks; + ULONGLONG CopyTicks; + ULONGLONG StartCount; + ULONG ElapsedTime; + ULONG IoTime; + ULONG CopyTime; + ULONG InitTime; + ULONG PagesWritten; + ULONG PagesProcessed; + ULONG BytesCopied; + ULONG DumpCount; + ULONG FileRuns; +} PO_HIBER_PERF, *PPO_HIBER_PERF; + +typedef struct _PO_MEMORY_IMAGE +{ + ULONG Signature; + ULONG Version; + ULONG CheckSum; + ULONG LengthSelf; + PFN_NUMBER PageSelf; + ULONG PageSize; + ULONG ImageType; + LARGE_INTEGER SystemTime; + ULONGLONG InterruptTime; + ULONG FeatureFlags; + UCHAR HiberFlags; + UCHAR spare[3]; + ULONG NoHiberPtes; + ULONG_PTR HiberVa; + PHYSICAL_ADDRESS HiberPte; + ULONG NoFreePages; + ULONG FreeMapCheck; + ULONG WakeCheck; + PFN_NUMBER TotalPages; + PFN_NUMBER FirstTablePage; + PFN_NUMBER LastFilePage; + PO_HIBER_PERF PerfInfo; +} PO_MEMORY_IMAGE, *PPO_MEMORY_IMAGE; + +typedef struct _PO_MEMORY_RANGE_ARRAY_RANGE +{ + PFN_NUMBER PageNo; + PFN_NUMBER StartPage; + PFN_NUMBER EndPage; + ULONG CheckSum; +} PO_MEMORY_RANGE_ARRAY_RANGE; + +typedef struct _PO_MEMORY_RANGE_ARRAY_LINK +{ + struct _PO_MEMORY_RANGE_ARRAY *Next; + PFN_NUMBER NextTable; + ULONG CheckSum; + ULONG EntryCount; +} PO_MEMORY_RANGE_ARRAY_LINK; + +typedef struct _PO_MEMORY_RANGE_ARRAY +{ + union + { + PO_MEMORY_RANGE_ARRAY_RANGE Range; + PO_MEMORY_RANGE_ARRAY_LINK Link; + }; +} PO_MEMORY_RANGE_ARRAY, *PPO_MEMORY_RANGE_ARRAY; + +typedef struct _POP_HIBER_CONTEXT +{ + BOOLEAN WriteToFile; + BOOLEAN ReserveLoaderMemory; + BOOLEAN ReserveFreeMemory; + BOOLEAN VerifyOnWake; + BOOLEAN Reset; + UCHAR HiberFlags; + BOOLEAN LinkFile; + HANDLE LinkFileHandle; + PKSPIN_LOCK Lock; + BOOLEAN MapFrozen; + RTL_BITMAP MemoryMap; + LIST_ENTRY ClonedRanges; + ULONG ClonedRangeCount; + PLIST_ENTRY NextCloneRange; + PFN_NUMBER NextPreserve; + PMDL LoaderMdl; + PMDL Clones; + PUCHAR NextClone; + ULONG NoClones; + PMDL Spares; + ULONGLONG PagesOut; + PVOID IoPage; + PVOID CurrentMcb; + PVOID DumpStack; + PKPROCESSOR_STATE WakeState; + ULONG NoRanges; + ULONG_PTR HiberVa; + PHYSICAL_ADDRESS HiberPte; + NTSTATUS Status; + PPO_MEMORY_IMAGE MemoryImage; + PPO_MEMORY_RANGE_ARRAY TableHead; + PVOID CompressionWorkspace; + PUCHAR CompressedWriteBuffer; + PULONG PerformanceStats; + PVOID CompressionBlock; + PVOID DmaIO; + PVOID TemporaryHeap; + PO_HIBER_PERF PerfInfo; +} POP_HIBER_CONTEXT, *PPOP_HIBER_CONTEXT; + +typedef struct _PO_NOTIFY_ORDER_LEVEL +{ + KEVENT LevelReady; + ULONG DeviceCount; + ULONG ActiveCount; + LIST_ENTRY WaitSleep; + LIST_ENTRY ReadySleep; + LIST_ENTRY Pending; + LIST_ENTRY Complete; + LIST_ENTRY ReadyS0; + LIST_ENTRY WaitS0; +} PO_NOTIFY_ORDER_LEVEL, *PPO_NOTIFY_ORDER_LEVEL; + +typedef struct _POP_SHUTDOWN_BUG_CHECK +{ + HANDLE ThreadHandle; + HANDLE ThreadId; + HANDLE ProcessId; + ULONG Code; + ULONG_PTR Parameter1; + ULONG_PTR Parameter2; + ULONG_PTR Parameter3; + ULONG_PTR Parameter4; +} POP_SHUTDOWN_BUG_CHECK, *PPOP_SHUTDOWN_BUG_CHECK; + +typedef struct _POP_DEVICE_POWER_IRP +{ + SINGLE_LIST_ENTRY Free; + PIRP Irp; + PPO_DEVICE_NOTIFY Notify; + LIST_ENTRY Pending; + LIST_ENTRY Complete; + LIST_ENTRY Abort; + LIST_ENTRY Failed; +} POP_DEVICE_POWER_IRP, *PPOP_DEVICE_POWER_IRP; + +typedef struct _PO_DEVICE_NOTIFY_ORDER +{ + ULONG DevNodeSequence; + PDEVICE_OBJECT *WarmEjectPdoPointer; + PO_NOTIFY_ORDER_LEVEL OrderLevel[8]; +} PO_DEVICE_NOTIFY_ORDER, *PPO_DEVICE_NOTIFY_ORDER; + +typedef struct _POP_DEVICE_SYS_STATE +{ + UCHAR IrpMinor; + SYSTEM_POWER_STATE SystemState; + PKEVENT Event; + KSPIN_LOCK SpinLock; + PKTHREAD Thread; + BOOLEAN GetNewDeviceList; + PO_DEVICE_NOTIFY_ORDER Order; + NTSTATUS Status; + PDEVICE_OBJECT FailedDevice; + BOOLEAN Waking; + BOOLEAN Cancelled; + BOOLEAN IgnoreErrors; + BOOLEAN IgnoreNotImplemented; + BOOLEAN _WaitAny; + BOOLEAN _WaitAll; + LIST_ENTRY PresentIrpQueue; + POP_DEVICE_POWER_IRP Head; + POP_DEVICE_POWER_IRP PowerIrpState[20]; +} POP_DEVICE_SYS_STATE, *PPOP_DEVICE_SYS_STATE; + +typedef struct _POP_POWER_ACTION +{ + UCHAR Updates; + UCHAR State; + BOOLEAN Shutdown; + POWER_ACTION Action; + SYSTEM_POWER_STATE LightestState; + ULONG Flags; + NTSTATUS Status; + UCHAR IrpMinor; + SYSTEM_POWER_STATE SystemState; + SYSTEM_POWER_STATE NextSystemState; + PPOP_SHUTDOWN_BUG_CHECK ShutdownBugCode; + PPOP_DEVICE_SYS_STATE DevState; + PPOP_HIBER_CONTEXT HiberContext; + ULONGLONG WakeTime; + ULONGLONG SleepTime; +} POP_POWER_ACTION, *PPOP_POWER_ACTION; + +typedef enum _POP_DEVICE_IDLE_TYPE +{ + DeviceIdleNormal, + DeviceIdleDisk, +} POP_DEVICE_IDLE_TYPE, *PPOP_DEVICE_IDLE_TYPE; + +typedef struct _POWER_CHANNEL_SUMMARY +{ + ULONG Signature; + ULONG TotalCount; + ULONG D0Count; + LIST_ENTRY NotifyList; +} POWER_CHANNEL_SUMMARY, *PPOWER_CHANNEL_SUMMARY; + +typedef struct _DEVICE_OBJECT_POWER_EXTENSION +{ + ULONG IdleCount; + ULONG ConservationIdleTime; + ULONG PerformanceIdleTime; + PDEVICE_OBJECT DeviceObject; + LIST_ENTRY IdleList; + DEVICE_POWER_STATE State; + LIST_ENTRY NotifySourceList; + LIST_ENTRY NotifyTargetList; + POWER_CHANNEL_SUMMARY PowerChannelSummary; + LIST_ENTRY Volume; +} DEVICE_OBJECT_POWER_EXTENSION, *PDEVICE_OBJECT_POWER_EXTENSION; + // // Initialization routines // @@ -47,6 +269,21 @@ PoInitializePrcb( IN PKPRCB Prcb ); +// +// I/O Routines +// +VOID +NTAPI +PoInitializeDeviceObject( + IN OUT PDEVOBJ_EXTENSION DeviceObjectExtension +); + +VOID +NTAPI +PoVolumeDevice( + IN PDEVICE_OBJECT DeviceObject +); + // // Power State routines // @@ -78,7 +315,33 @@ PoNotifySystemTimeSet( VOID ); +// +// Shutdown routines +// +VOID +NTAPI +PopReadShutdownPolicy( + VOID +); + +VOID +NTAPI +PopGracefulShutdown( + IN PVOID Context +); + +VOID +NTAPI +PopFlushVolumes( + IN BOOLEAN ShuttingDown +); + // // Global data inside the Power Manager // extern PDEVICE_NODE PopSystemPowerDeviceNode; +extern KGUARDED_MUTEX PopVolumeLock; +extern LIST_ENTRY PopVolumeDevices; +extern KSPIN_LOCK PopDopeGlobalLock; +extern POP_POWER_ACTION PopAction; + diff --git a/reactos/ntoskrnl/io/iomgr/device.c b/reactos/ntoskrnl/io/iomgr/device.c index 482f7300fc9..7434970734f 100644 --- a/reactos/ntoskrnl/io/iomgr/device.c +++ b/reactos/ntoskrnl/io/iomgr/device.c @@ -17,9 +17,11 @@ /* GLOBALS ********************************************************************/ ULONG IopDeviceObjectNumber = 0; - LIST_ENTRY ShutdownListHead, LastChanceShutdownListHead; KSPIN_LOCK ShutdownListLock; +extern LIST_ENTRY IopDiskFsListHead; +extern LIST_ENTRY IopCdRomFsListHead; +extern LIST_ENTRY IopTapeFsListHead; /* PRIVATE FUNCTIONS **********************************************************/ @@ -95,7 +97,15 @@ IopAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, VOID NTAPI -IoShutdownRegisteredDevices(VOID) +IoShutdownPnpDevices(VOID) +{ + /* This routine is only used by Driver Verifier to validate shutdown */ + return; +} + +VOID +NTAPI +IoShutdownSystem(IN ULONG Phase) { PLIST_ENTRY ListEntry; PDEVICE_OBJECT DeviceObject; @@ -104,46 +114,108 @@ IoShutdownRegisteredDevices(VOID) PIRP Irp; KEVENT Event; NTSTATUS Status; - + /* Initialize an event to wait on */ KeInitializeEvent(&Event, NotificationEvent, FALSE); - - /* Get the first entry and start looping */ - ListEntry = ExInterlockedRemoveHeadList(&ShutdownListHead, - &ShutdownListLock); - while (ListEntry) + + /* What phase? */ + if (Phase == 0) { - /* Get the shutdown entry */ - ShutdownEntry = CONTAINING_RECORD(ListEntry, - SHUTDOWN_ENTRY, - ShutdownList); + /* Shutdown PnP */ + IoShutdownPnpDevices(); - /* Get the attached device */ - DeviceObject = IoGetAttachedDevice(ShutdownEntry->DeviceObject); - - /* Build the shutdown IRP and call the driver */ - Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN, - DeviceObject, - NULL, - 0, - NULL, - &Event, - &StatusBlock); - Status = IoCallDriver(DeviceObject, Irp); - if (Status == STATUS_PENDING) - { - /* Wait on the driver */ - KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); - } - - /* Free the shutdown entry and reset the event */ - ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); - KeClearEvent(&Event); - - /* Go to the next entry */ + /* Loop first-chance shutdown notifications */ ListEntry = ExInterlockedRemoveHeadList(&ShutdownListHead, &ShutdownListLock); - } + while (ListEntry) + { + /* Get the shutdown entry */ + ShutdownEntry = CONTAINING_RECORD(ListEntry, + SHUTDOWN_ENTRY, + ShutdownList); + + /* Get the attached device */ + DeviceObject = IoGetAttachedDevice(ShutdownEntry->DeviceObject); + + /* Build the shutdown IRP and call the driver */ + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN, + DeviceObject, + NULL, + 0, + NULL, + &Event, + &StatusBlock); + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait on the driver */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + } + + /* Get rid of our reference to it */ + ObDereferenceObject(DeviceObject); + + /* Free the shutdown entry and reset the event */ + ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); + KeClearEvent(&Event); + + /* Go to the next entry */ + ListEntry = ExInterlockedRemoveHeadList(&ShutdownListHead, + &ShutdownListLock); + } + } + else if (Phase == 1) + { + /* Shutdown disk file systems */ + IopShutdownBaseFileSystems(&IopDiskFsListHead); + + /* Shutdown cdrom file systems */ + IopShutdownBaseFileSystems(&IopCdRomFsListHead); + + /* Shutdown tape filesystems */ + IopShutdownBaseFileSystems(&IopTapeFsListHead); + + /* Loop last-chance shutdown notifications */ + ListEntry = ExInterlockedRemoveHeadList(&LastChanceShutdownListHead, + &ShutdownListLock); + while (ListEntry) + { + /* Get the shutdown entry */ + ShutdownEntry = CONTAINING_RECORD(ListEntry, + SHUTDOWN_ENTRY, + ShutdownList); + + /* Get the attached device */ + DeviceObject = IoGetAttachedDevice(ShutdownEntry->DeviceObject); + + /* Build the shutdown IRP and call the driver */ + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN, + DeviceObject, + NULL, + 0, + NULL, + &Event, + &StatusBlock); + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait on the driver */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + } + + /* Get rid of our reference to it */ + ObDereferenceObject(DeviceObject); + + /* Free the shutdown entry and reset the event */ + ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); + KeClearEvent(&Event); + + /* Go to the next entry */ + ListEntry = ExInterlockedRemoveHeadList(&LastChanceShutdownListHead, + &ShutdownListLock); + } + + } } NTSTATUS @@ -843,6 +915,9 @@ IoCreateDevice(IN PDRIVER_OBJECT DriverObject, /* Set the Type and Size. Question: why is Size 0 on Windows? */ DeviceObjectExtension->Type = IO_TYPE_DEVICE_OBJECT_EXTENSION; DeviceObjectExtension->Size = 0; + + /* Initialize with Power Manager */ + PoInitializeDeviceObject(DeviceObjectExtension); /* Link the Object and Extension */ DeviceObjectExtension->DeviceObject = CreatedDeviceObject; @@ -932,6 +1007,9 @@ IoCreateDevice(IN PDRIVER_OBJECT DriverObject, ASSERT((DriverObject->Flags & DRVO_UNLOAD_INVOKED) == 0); CreatedDeviceObject->DriverObject = DriverObject; IopEditDeviceList(DriverObject, CreatedDeviceObject, IopAdd); + + /* Link with the power manager */ + if (CreatedDeviceObject->Vpb) PoVolumeDevice(CreatedDeviceObject); /* Close the temporary handle and return to caller */ ObCloseHandle(TempHandle, KernelMode); @@ -1351,6 +1429,9 @@ IoRegisterLastChanceShutdownNotification(IN PDEVICE_OBJECT DeviceObject) /* Set the DO */ Entry->DeviceObject = DeviceObject; + + /* Reference it so it doesn't go away */ + ObReferenceObject(DeviceObject); /* Insert it into the list */ ExInterlockedInsertHeadList(&LastChanceShutdownListHead, @@ -1379,6 +1460,9 @@ IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject) /* Set the DO */ Entry->DeviceObject = DeviceObject; + + /* Reference it so it doesn't go away */ + ObReferenceObject(DeviceObject); /* Insert it into the list */ ExInterlockedInsertHeadList(&ShutdownListHead, @@ -1420,6 +1504,9 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject) /* Free the entry */ ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); + + /* Get rid of our reference to it */ + ObDereferenceObject(DeviceObject); } /* Go to the next entry */ @@ -1444,6 +1531,9 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject) /* Free the entry */ ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); + + /* Get rid of our reference to it */ + ObDereferenceObject(DeviceObject); } /* Go to the next entry */ diff --git a/reactos/ntoskrnl/io/iomgr/volume.c b/reactos/ntoskrnl/io/iomgr/volume.c index 3f019534e4b..606f8fd3b35 100644 --- a/reactos/ntoskrnl/io/iomgr/volume.c +++ b/reactos/ntoskrnl/io/iomgr/volume.c @@ -245,7 +245,7 @@ IopNotifyFileSystemChange(IN PDEVICE_OBJECT DeviceObject, VOID NTAPI -IoShutdownRegisteredFileSystems(VOID) +IopShutdownBaseFileSystems(IN PLIST_ENTRY ListHead) { PLIST_ENTRY ListEntry; PDEVICE_OBJECT DeviceObject; @@ -260,8 +260,8 @@ IoShutdownRegisteredFileSystems(VOID) KeInitializeEvent(&Event, NotificationEvent, FALSE); /* Get the first entry and start looping */ - ListEntry = IopDiskFsListHead.Flink; - while (ListEntry != &IopDiskFsListHead) + ListEntry = ListHead->Flink; + while (ListEntry != ListHead) { /* Get the device object */ DeviceObject = CONTAINING_RECORD(ListEntry, diff --git a/reactos/ntoskrnl/ntoskrnl-generic.rbuild b/reactos/ntoskrnl/ntoskrnl-generic.rbuild index abf321949a9..c1211761c4f 100644 --- a/reactos/ntoskrnl/ntoskrnl-generic.rbuild +++ b/reactos/ntoskrnl/ntoskrnl-generic.rbuild @@ -438,8 +438,10 @@ obwait.c + events.c power.c - events.c + poshtdwn.c + povolume.c diff --git a/reactos/ntoskrnl/po/poshtdwn.c b/reactos/ntoskrnl/po/poshtdwn.c new file mode 100644 index 00000000000..25ee2e3ddf4 --- /dev/null +++ b/reactos/ntoskrnl/po/poshtdwn.c @@ -0,0 +1,196 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: ntoskrnl/po/poshtdwn.c + * PURPOSE: Power Manager Shutdown Code + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS *******************************************************************/ + +ULONG PopShutdownPowerOffPolicy; + +/* PRIVATE FUNCTIONS *********************************************************/ + +VOID +NTAPI +PopShutdownHandler(VOID) +{ + PUCHAR Logo1, Logo2; + ULONG i; + + /* Stop all interrupts */ + KeRaiseIrqlToDpcLevel(); + _disable(); + + /* Do we have boot video */ + if (InbvIsBootDriverInstalled()) + { + /* Yes we do, cleanup for shutdown screen */ + if (!InbvCheckDisplayOwnership()) InbvAcquireDisplayOwnership(); + InbvResetDisplay(); + InbvSolidColorFill(0, 0, 639, 479, 0); + InbvEnableDisplayString(TRUE); + InbvSetScrollRegion(0, 0, 639, 479); + + /* Display shutdown logo and message */ + Logo1 = InbvGetResourceAddress(IDB_SHUTDOWN_LOGO); + Logo2 = InbvGetResourceAddress(IDB_LOGO); + if ((Logo1) && (Logo2)) + { + InbvBitBlt(Logo1, 215, 352); + InbvBitBlt(Logo2, 217, 111); + } + } + else + { + /* Do it in text-mode */ + for (i = 0; i < 25; i++) InbvDisplayString("\n"); + InbvDisplayString(" "); + InbvDisplayString("The system may be powered off now.\n"); + } + + /* Hang the system */ + for (;;) HalHaltSystem(); +} + +VOID +NTAPI +PopShutdownSystem(IN POWER_ACTION SystemAction) +{ + /* Note should notify caller of NtPowerInformation(PowerShutdownNotification) */ + + /* Unload symbols */ + DPRINT1("It's the final countdown...%lx\n", SystemAction); + DbgUnLoadImageSymbols(NULL, (PVOID)-1, 0); + + /* Run the thread on the boot processor */ + KeSetSystemAffinityThread(1); + + /* Now check what the caller wants */ + switch (SystemAction) + { + /* Reset */ + case PowerActionShutdownReset: + + /* Try platform driver first, then legacy */ + //PopInvokeSystemStateHandler(PowerStateShutdownReset, NULL); + HalReturnToFirmware(HalRebootRoutine); + break; + + case PowerActionShutdown: + + /* Check for group policy that says to use "it is now safe" screen */ + if (PopShutdownPowerOffPolicy) + { + /* FIXFIX: Switch to legacy shutdown handler */ + //PopPowerStateHandlers[PowerStateShutdownOff].Handler = PopShutdownHandler; + } + + case PowerActionShutdownOff: + + /* Call shutdown handler */ + //PopInvokeSystemStateHandler(PowerStateShutdownOff, NULL); + + /* ReactOS Hack */ + PopSetSystemPowerState(PowerSystemShutdown); + PopShutdownHandler(); + + /* If that didn't work, call the HAL */ + HalReturnToFirmware(HalPowerDownRoutine); + break; + + default: + break; + } + + /* Anything else should not happen */ + KeBugCheckEx(INTERNAL_POWER_ERROR, 5, 0, 0, 0); +} + +VOID +NTAPI +PopGracefulShutdown(IN PVOID Context) +{ + /* First, the HAL handles any "end of boot" special functionality */ + DPRINT1("HAL shutting down\n"); + HalEndOfBoot(); + + /* In this step, the I/O manager does first-chance shutdown notification */ + DPRINT1("I/O manager shutting down in phase 0\n"); + IoShutdownSystem(0); + + /* In this step, all workers are killed and hives are flushed */ + DPRINT1("Configuration Manager shutting down\n"); + CmShutdownSystem(); + + /* Note that modified pages should be written here (MiShutdownSystem) */ + + /* In this step, the I/O manager does last-chance shutdown notification */ + DPRINT1("I/O manager shutting down in phase 1\n"); + IoShutdownSystem(1); + CcWaitForCurrentLazyWriterActivity(); + + /* Note that here, we should broadcast the power IRP to devices */ + + /* In this step, the HAL disables any wake timers */ + DPRINT1("Disabling wake timers\n"); + HalSetWakeEnable(FALSE); + + /* And finally the power request is sent */ + DPRINT1("Taking the system down\n"); + PopShutdownSystem(PopAction.Action); +} + +VOID +NTAPI +PopReadShutdownPolicy(VOID) +{ + UNICODE_STRING KeyString; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; + HANDLE KeyHandle; + ULONG Length; + UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)]; + PKEY_VALUE_PARTIAL_INFORMATION Info = (PVOID)Buffer; + + /* Setup object attributes */ + RtlInitUnicodeString(&KeyString, + L"\\Registry\\Machine\\Software\\Policies\\Microsoft\\Windows NT"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyString, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* Open the key */ + Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + /* Open the policy value and query it */ + RtlInitUnicodeString(&KeyString, L"DontPowerOffAfterShutdown"); + Status = ZwQueryValueKey(KeyHandle, + &KeyString, + KeyValuePartialInformation, + &Info, + sizeof(Info), + &Length); + if ((NT_SUCCESS(Status)) && (Info->Type == REG_DWORD)) + { + /* Read the policy */ + PopShutdownPowerOffPolicy = *Info->Data == 1; + } + + /* Close the key */ + ZwClose(KeyHandle); + } +} + +/* PUBLIC FUNCTIONS **********************************************************/ + diff --git a/reactos/ntoskrnl/po/povolume.c b/reactos/ntoskrnl/po/povolume.c new file mode 100644 index 00000000000..58cc3327deb --- /dev/null +++ b/reactos/ntoskrnl/po/povolume.c @@ -0,0 +1,334 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: ntoskrnl/po/povolume.c + * PURPOSE: Power Manager DOPE and Volume Management + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS *******************************************************************/ + +typedef struct _POP_FLUSH_VOLUME +{ + LIST_ENTRY List; + LONG Count; + KEVENT Wait; +} POP_FLUSH_VOLUME, *PPOP_FLUSH_VOLUME; + +ULONG PopFlushPolicy = 0; + +KGUARDED_MUTEX PopVolumeLock; +LIST_ENTRY PopVolumeDevices; +KSPIN_LOCK PopDopeGlobalLock; + +/* PRIVATE FUNCTIONS *********************************************************/ + +PDEVICE_OBJECT_POWER_EXTENSION +NTAPI +PopGetDope(IN PDEVICE_OBJECT DeviceObject) +{ + PEXTENDED_DEVOBJ_EXTENSION DeviceExtension; + PDEVICE_OBJECT_POWER_EXTENSION Dope; + KIRQL OldIrql; + PAGED_CODE(); + + /* If the device already has the dope, return it */ + DeviceExtension = IoGetDevObjExtension(DeviceObject); + if (DeviceExtension->Dope) goto Return; + + /* Allocate some dope for the device */ + Dope = ExAllocatePoolWithTag(NonPagedPool, + sizeof(DEVICE_OBJECT_POWER_EXTENSION), + 'Dope'); + if (!Dope) goto Return; + + /* Initialize the initial contents of the dope */ + RtlZeroMemory(Dope, sizeof(DEVICE_OBJECT_POWER_EXTENSION)); + Dope->DeviceObject = DeviceObject; + Dope->State = PowerDeviceUnspecified; + InitializeListHead(&Dope->IdleList); + + /* Make sure only one caller can assign dope to a device */ + KeAcquireSpinLock(&PopDopeGlobalLock, &OldIrql); + + /* Make sure the device still has no dope */ + if (!DeviceExtension->Dope) + { + /* Give the local dope to this device, and remember we won the race */ + DeviceExtension->Dope = (PVOID)Dope; + Dope = NULL; + } + + /* Allow other dope transactions now */ + KeReleaseSpinLock(&PopDopeGlobalLock, OldIrql); + + /* Check if someone other than us already assigned the dope, so free ours */ + if (Dope) ExFreePoolWithTag(Dope, 'Dope'); + + /* Return the dope to the caller */ +Return: + return (PDEVICE_OBJECT_POWER_EXTENSION)DeviceExtension->Dope; +} + +VOID +NTAPI +PoVolumeDevice(IN PDEVICE_OBJECT DeviceObject) +{ + PDEVICE_OBJECT_POWER_EXTENSION Dope; + PAGED_CODE(); + + /* Get dope from the device (if the device has no dope, it will receive some) */ + DPRINT1("New volume: %p\n", DeviceObject); + Dope = PopGetDope(DeviceObject); + if (Dope) + { + /* Make sure we can flush safely */ + DPRINT1("Acquiring volume lock\n"); + KeAcquireGuardedMutex(&PopVolumeLock); + + /* Add this volume into the list of power-manager volumes */ + DPRINT1("Got DOPE: %p\n", Dope); + if (!Dope->Volume.Flink) InsertTailList(&PopVolumeDevices, &Dope->Volume); + + /* Allow flushes to go through */ + KeReleaseGuardedMutex(&PopVolumeLock); + } +} + +VOID +NTAPI +PopFlushVolumeWorker(IN PVOID Context) +{ + PPOP_FLUSH_VOLUME FlushContext = (PPOP_FLUSH_VOLUME)Context; + PDEVICE_OBJECT_POWER_EXTENSION Dope; + PLIST_ENTRY NextEntry; + NTSTATUS Status; + UCHAR Buffer[sizeof(OBJECT_NAME_INFORMATION) + 512]; + POBJECT_NAME_INFORMATION NameInfo = (PVOID)Buffer; + ULONG Length; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE VolumeHandle; + IO_STATUS_BLOCK IoStatusBlock; + + /* Acquire the flush lock since we're messing with the list */ + KeAcquireGuardedMutex(&PopVolumeLock); + + /* Loop the flush list */ + while (!IsListEmpty(&FlushContext->List)) + { + /* Grab the next (ie: current) entry and remove it */ + NextEntry = FlushContext->List.Flink; + RemoveEntryList(NextEntry); + + /* Add it back on the volume list */ + InsertTailList(&PopVolumeDevices, NextEntry); + + /* Done touching the volume list */ + KeReleaseGuardedMutex(&PopVolumeLock); + + /* Get the dope from the volume link */ + Dope = CONTAINING_RECORD(NextEntry, DEVICE_OBJECT_POWER_EXTENSION, Volume); + + /* Get the name */ + Status = ObQueryNameString(Dope->DeviceObject, + NameInfo, + sizeof(Buffer), + &Length); + if ((NT_SUCCESS(Status)) && (NameInfo->Name.Buffer)) + { + /* Open the volume */ + DPRINT1("Opening: %wZ\n", &NameInfo->Name); + InitializeObjectAttributes(&ObjectAttributes, + &NameInfo->Name, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + 0, + 0); + Status = ZwCreateFile(&VolumeHandle, + SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA, + &ObjectAttributes, + &IoStatusBlock, + NULL, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_OPEN, + 0, + NULL, + 0); + if (NT_SUCCESS(Status)) + { + /* Flush it and close it */ + DPRINT1("Sending flush to: %lx\n", VolumeHandle); + ZwFlushBuffersFile(VolumeHandle, &IoStatusBlock); + ZwClose(VolumeHandle); + } + } + + /* Acquire the flush lock again since we'll touch the list */ + KeAcquireGuardedMutex(&PopVolumeLock); + } + + /* One more flush completed... if it was the last, signal the caller */ + if (!--FlushContext->Count) KeSetEvent(&FlushContext->Wait, IO_NO_INCREMENT, FALSE); + + /* Serialize with flushers */ + KeReleaseGuardedMutex(&PopVolumeLock); +} + +VOID +NTAPI +PopFlushVolumes(IN BOOLEAN ShuttingDown) +{ + POP_FLUSH_VOLUME FlushContext = {{0}}; + ULONG FlushPolicy; + UNICODE_STRING RegistryName = RTL_CONSTANT_STRING(L"\\Registry"); + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE RegistryHandle; + PLIST_ENTRY NextEntry; + PDEVICE_OBJECT_POWER_EXTENSION Dope; + ULONG VolumeCount = 0; + NTSTATUS Status; + HANDLE ThreadHandle; + ULONG ThreadCount; + + /* Setup the flush context */ + InitializeListHead(&FlushContext.List); + KeInitializeEvent(&FlushContext.Wait, NotificationEvent, FALSE); + + /* What to flush */ + FlushPolicy = ShuttingDown ? 1 | 2 : PopFlushPolicy; + if ((FlushPolicy & 1)) + { + /* Registry flush requested, so open it */ + DPRINT1("Opening registry\n"); + InitializeObjectAttributes(&ObjectAttributes, + &RegistryName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + Status = ZwOpenKey(&RegistryHandle, KEY_READ, &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + /* Flush the registry */ + DPRINT1("Flushing registry\n"); + ZwFlushKey(RegistryHandle); + ZwClose(RegistryHandle); + } + } + + /* Serialize with other flushes */ + KeAcquireGuardedMutex(&PopVolumeLock); + + /* Scan the volume list */ + NextEntry = PopVolumeDevices.Flink; + while (NextEntry != &PopVolumeDevices) + { + /* Get the dope from the link */ + Dope = CONTAINING_RECORD(NextEntry, DEVICE_OBJECT_POWER_EXTENSION, Volume); + + /* Grab the next entry now, since we'll be modifying the list */ + NextEntry = NextEntry->Flink; + + /* Make sure the object is mounted, writable, exists, and is not a floppy */ + if (!(Dope->DeviceObject->Vpb->Flags & VPB_MOUNTED) || + (Dope->DeviceObject->Characteristics & FILE_FLOPPY_DISKETTE) || + (Dope->DeviceObject->Characteristics & FILE_READ_ONLY_DEVICE) || + ((Dope->DeviceObject->Vpb->RealDevice) && + (Dope->DeviceObject->Vpb->RealDevice->Characteristics & FILE_FLOPPY_DISKETTE))) + { + /* Not flushable */ + continue; + } + + /* Remove it from the dope and add it to the flush context list */ + RemoveEntryList(&Dope->Volume); + InsertTailList(&FlushContext.List, &Dope->Volume); + + /* Next */ + VolumeCount++; + } + + /* Check if we should skip non-removable devices */ + if (!(FlushPolicy & 2)) + { + /* ReactOS only implements this routine for shutdown, which requires it */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check if there were no volumes at all */ + if (!VolumeCount) + { + /* Nothing to do */ + KeReleaseGuardedMutex(&PopVolumeLock); + return; + } + + /* Allocate up to 8 flusher threads */ + ThreadCount = min(VolumeCount, 8); + InitializeObjectAttributes(&ObjectAttributes, + NULL, + OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* We will ourselves become a flusher thread */ + FlushContext.Count = 1; + ThreadCount--; + + /* Look for any extra ones we might need */ + while (ThreadCount > 0) + { + /* Create a new one */ + ThreadCount--; + DPRINT1("Creating flush thread\n"); + Status = PsCreateSystemThread(&ThreadHandle, + THREAD_ALL_ACCESS, + &ObjectAttributes, + 0L, + NULL, + PopFlushVolumeWorker, + &FlushContext); + if (NT_SUCCESS(Status)) + { + /* One more created... */ + FlushContext.Count++; + ZwClose(ThreadHandle); + } + } + + /* Allow flushes to go through */ + KeReleaseGuardedMutex(&PopVolumeLock); + + /* Enter the flush work */ + DPRINT1("Local flush\n"); + PopFlushVolumeWorker(&FlushContext); + + /* Wait for all flushes to be over */ + DPRINT1("Waiting for flushes\n"); + KeWaitForSingleObject(&FlushContext.Wait, Executive, KernelMode, FALSE, NULL); + DPRINT1("Flushes have completed\n"); +} + +VOID +NTAPI +PoInitializeDeviceObject(IN OUT PDEVOBJ_EXTENSION DeviceObjectExtension) +{ + PEXTENDED_DEVOBJ_EXTENSION DeviceExtension = (PVOID)DeviceObjectExtension; + PAGED_CODE(); + + /* Initialize the power flags */ + DeviceExtension->PowerFlags = PowerSystemUnspecified & 0xF; + DeviceExtension->PowerFlags |= ((PowerDeviceUnspecified << 4) & 0xF0); + + /* The device object is not on drugs yet */ + DeviceExtension->Dope = NULL; +} + +/* PUBLIC FUNCTIONS **********************************************************/ + diff --git a/reactos/ntoskrnl/po/power.c b/reactos/ntoskrnl/po/power.c index f103898d2f5..96a211b5680 100644 --- a/reactos/ntoskrnl/po/power.c +++ b/reactos/ntoskrnl/po/power.c @@ -24,6 +24,8 @@ typedef struct _REQUEST_POWER_ITEM PDEVICE_NODE PopSystemPowerDeviceNode = NULL; BOOLEAN PopAcpiPresent = FALSE; +POP_POWER_ACTION PopAction; +WORK_QUEUE_ITEM PopShutdownWorkItem; /* PRIVATE FUNCTIONS *********************************************************/ @@ -165,6 +167,13 @@ PoInitSystem(IN ULONG BootPhase) PopAcpiPresent = KeLoaderBlock->Extension->AcpiTable != NULL ? TRUE : FALSE; } + + /* Initialize volume support */ + InitializeListHead(&PopVolumeDevices); + KeInitializeGuardedMutex(&PopVolumeLock); + + /* Initialize support for dope */ + KeInitializeSpinLock(&PopDopeGlobalLock); return TRUE; } @@ -636,3 +645,138 @@ NtSetThreadExecutionState(IN EXECUTION_STATE esFlags, /* All is good */ return STATUS_SUCCESS; } + +NTSTATUS +NTAPI +NtSetSystemPowerState(IN POWER_ACTION SystemAction, + IN SYSTEM_POWER_STATE MinSystemState, + IN ULONG Flags) +{ + KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); + POP_POWER_ACTION Action = {0}; + NTSTATUS Status; + + /* Check for invalid parameter combinations */ + if ((MinSystemState >= PowerSystemMaximum) || + (MinSystemState <= PowerSystemUnspecified) || + (SystemAction > PowerActionWarmEject) || + (SystemAction < PowerActionReserved) || + (Flags & ~(POWER_ACTION_QUERY_ALLOWED | + POWER_ACTION_UI_ALLOWED | + POWER_ACTION_OVERRIDE_APPS | + POWER_ACTION_LIGHTEST_FIRST | + POWER_ACTION_LOCK_CONSOLE | + POWER_ACTION_DISABLE_WAKES | + POWER_ACTION_CRITICAL))) + { + DPRINT1("NtSetSystemPowerState: Bad parameters!\n"); + DPRINT1(" SystemAction: 0x%x\n", SystemAction); + DPRINT1(" MinSystemState: 0x%x\n", MinSystemState); + DPRINT1(" Flags: 0x%x\n", Flags); + return STATUS_INVALID_PARAMETER; + } + + /* Check for user caller */ + if (PreviousMode != KernelMode) + { + /* Check for shutdown permission */ + if (!SeSinglePrivilegeCheck(SeShutdownPrivilege, PreviousMode)) + { + /* Not granted */ + DPRINT1("ERROR: Privilege not held for shutdown\n"); + //return STATUS_PRIVILEGE_NOT_HELD; HACK! + } + + /* Do it as a kernel-mode caller for consistency with system state */ + return ZwSetSystemPowerState (SystemAction, MinSystemState, Flags); + } + + /* Read policy settings (partial shutdown vs. full shutdown) */ + if (SystemAction == PowerActionShutdown) PopReadShutdownPolicy(); + + /* Disable lazy flushing of registry */ + DPRINT1("Stopping lazy flush\n"); + CmSetLazyFlushState(FALSE); + + /* Setup the power action */ + Action.Action = SystemAction; + Action.Flags = Flags; + + /* Notify callbacks */ + DPRINT1("Notifying callbacks\n"); + ExNotifyCallback(PowerStateCallback, (PVOID)3, NULL); + + /* Swap in any worker thread stacks */ + DPRINT1("Swapping worker threads\n"); + ExSwapinWorkerThreads(FALSE); + + /* Make our action global */ + PopAction = Action; + + /* Start power loop */ + Status = STATUS_CANCELLED; + while (TRUE) + { + /* Break out if there's nothing to do */ + if (Action.Action == PowerActionNone) break; + + /* Check for first-pass or restart */ + if (Status == STATUS_CANCELLED) + { + /* Check for shutdown action */ + if ((PopAction.Action == PowerActionShutdown) || + (PopAction.Action == PowerActionShutdownReset) || + (PopAction.Action == PowerActionShutdownOff)) + { + /* Set the action */ + PopAction.Shutdown = TRUE; + } + + /* Now we are good to go */ + Status = STATUS_SUCCESS; + } + + /* Check if we're still in an invalid status */ + if (!NT_SUCCESS(Status)) break; + + /* Flush all volumes and the registry */ + DPRINT1("Flushing volumes\n"); + PopFlushVolumes(PopAction.Shutdown); + + /* Set IRP for drivers */ + PopAction.IrpMinor = IRP_MN_SET_POWER; + if (PopAction.Shutdown) + { + DPRINT1("Queueing shutdown thread\n"); + /* Check if we are running in the system context */ + if (PsGetCurrentProcess() != PsInitialSystemProcess) + { + /* We're not, so use a worker thread for shutdown */ + ExInitializeWorkItem(&PopShutdownWorkItem, + &PopGracefulShutdown, + NULL); + + ExQueueWorkItem(&PopShutdownWorkItem, CriticalWorkQueue); + + /* Spend us -- when we wake up, the system is good to go down */ + KeSuspendThread(KeGetCurrentThread()); + Status = STATUS_SYSTEM_SHUTDOWN; + goto Exit; + + } + else + { + /* Do the shutdown inline */ + PopGracefulShutdown(NULL); + } + } + + /* You should not have made it this far */ + ASSERT(FALSE && "System is still up and running?!"); + break; + } + +Exit: + /* We're done, return */ + return Status; +} From f5a35ee9b27ad29cb416c227e2080295aed7c2a1 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 8 Mar 2010 20:51:33 +0000 Subject: [PATCH 201/211] [PSDK] - Update all IDLs to Wine-1.1.40. If you feel some of your change was lost, it wasn't needed for building. Please recommit if you still think it's of a high value. svn path=/trunk/; revision=46005 --- reactos/dll/win32/msi/msiserver.idl | 1 - reactos/dll/win32/shell32/dataobject.c | 4 +- reactos/dll/win32/shell32/pidl.c | 4 +- reactos/dll/win32/shell32/she_ocmenu.c | 2 +- reactos/dll/win32/shell32/shelllink.c | 18 +- reactos/dll/win32/shell32/shfldr_fs.c | 2 +- reactos/dll/win32/shell32/shlfolder.c | 2 +- reactos/dll/win32/shell32/shlview.c | 2 +- reactos/dll/win32/shell32/shv_def_cmenu.c | 4 +- reactos/dll/win32/shell32/stubs.c | 2 +- reactos/include/dxsdk/axextend.idl | 4 + reactos/include/psdk/access.idl | 79 +++++ reactos/include/psdk/asynot.idl | 59 ++++ reactos/include/psdk/asysta.idl | 51 +++ reactos/include/psdk/binres.idl | 49 +++ reactos/include/psdk/bits.idl | 4 + reactos/include/psdk/cmdbas.idl | 62 ++++ reactos/include/psdk/cmdtxt.idl | 44 +++ reactos/include/psdk/control.idl | 154 ++++----- reactos/include/psdk/crtrow.idl | 51 +++ reactos/include/psdk/dbccmd.idl | 36 ++ reactos/include/psdk/dbcses.idl | 36 ++ reactos/include/psdk/dbdsad.idl | 75 +++++ reactos/include/psdk/dbprop.idl | 11 +- reactos/include/psdk/dbs.idl | 244 ++++++++++++++ reactos/include/psdk/dimm.idl | 2 - reactos/include/psdk/dispex.idl | 26 +- reactos/include/psdk/hlink.idl | 2 +- reactos/include/psdk/mlang.idl | 61 ++-- reactos/include/psdk/mscoree.idl | 4 + reactos/include/psdk/msctf.idl | 5 - reactos/include/psdk/objidl.idl | 7 +- reactos/include/psdk/oledb.idl | 41 ++- reactos/include/psdk/opnrst.idl | 47 +++ reactos/include/psdk/propidl.idl | 12 +- reactos/include/psdk/row.idl | 42 +++ reactos/include/psdk/rowchg.idl | 30 ++ reactos/include/psdk/rstbas.idl | 51 +++ reactos/include/psdk/rstinf.idl | 58 ++++ reactos/include/psdk/rstloc.idl | 67 ++++ reactos/include/psdk/sensevts.idl | 4 + reactos/include/psdk/sesprp.idl | 51 +++ reactos/include/psdk/shlobj.h | 388 +++++++++++++++------- reactos/include/psdk/shobjidl.idl | 20 +- reactos/include/psdk/shtypes.idl | 87 ++--- reactos/include/psdk/tom.idl | 286 ++++++++-------- reactos/include/psdk/wtypes.idl | 56 +--- reactos/include/reactos/wine/wined3d.idl | 1 + 48 files changed, 1819 insertions(+), 529 deletions(-) create mode 100644 reactos/include/psdk/access.idl create mode 100644 reactos/include/psdk/asynot.idl create mode 100644 reactos/include/psdk/asysta.idl create mode 100644 reactos/include/psdk/binres.idl create mode 100644 reactos/include/psdk/cmdbas.idl create mode 100644 reactos/include/psdk/cmdtxt.idl create mode 100644 reactos/include/psdk/crtrow.idl create mode 100644 reactos/include/psdk/dbccmd.idl create mode 100644 reactos/include/psdk/dbcses.idl create mode 100644 reactos/include/psdk/dbdsad.idl create mode 100644 reactos/include/psdk/opnrst.idl create mode 100644 reactos/include/psdk/row.idl create mode 100644 reactos/include/psdk/rowchg.idl create mode 100644 reactos/include/psdk/rstbas.idl create mode 100644 reactos/include/psdk/rstinf.idl create mode 100644 reactos/include/psdk/rstloc.idl create mode 100644 reactos/include/psdk/sesprp.idl diff --git a/reactos/dll/win32/msi/msiserver.idl b/reactos/dll/win32/msi/msiserver.idl index aa934361b49..25210fee155 100644 --- a/reactos/dll/win32/msi/msiserver.idl +++ b/reactos/dll/win32/msi/msiserver.idl @@ -29,7 +29,6 @@ typedef int INSTALLMESSAGE; typedef int MSICONDITION; typedef int MSIRUNMODE; typedef int INSTALLSTATE; -typedef WORD LANGID; cpp_quote("#endif") [ diff --git a/reactos/dll/win32/shell32/dataobject.c b/reactos/dll/win32/shell32/dataobject.c index 503ff4568d4..6da709528c8 100644 --- a/reactos/dll/win32/shell32/dataobject.c +++ b/reactos/dll/win32/shell32/dataobject.c @@ -428,9 +428,9 @@ LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, dto->apidl = _ILCopyaPidl(apidl, cidl); dto->cidl = cidl; - dto->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + dto->cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); dto->cfFileNameA = RegisterClipboardFormatA(CFSTR_FILENAMEA); - dto->cfFileNameW = RegisterClipboardFormatA(CFSTR_FILENAMEW); + dto->cfFileNameW = RegisterClipboardFormatW(CFSTR_FILENAMEW); InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL); InitFormatEtc(dto->pFormatEtc[1], CF_HDROP, TYMED_HGLOBAL); InitFormatEtc(dto->pFormatEtc[2], dto->cfFileNameA, TYMED_HGLOBAL); diff --git a/reactos/dll/win32/shell32/pidl.c b/reactos/dll/win32/shell32/pidl.c index 0b4f226031b..f229bd9626a 100644 --- a/reactos/dll/win32/shell32/pidl.c +++ b/reactos/dll/win32/shell32/pidl.c @@ -413,7 +413,7 @@ HRESULT WINAPI SHILCreateFromPathAW (LPCVOID path, LPITEMIDLIST * ppidl, DWORD * * Caller is responsible for deallocating the returned ItemIDList with the * shells IMalloc interface, aka ILFree. */ -PIDLIST_ABSOLUTE WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate) +LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate) { LPITEMIDLIST ppidl; TRACE_(shell)("(hwnd=%p,csidl=0x%x,%s).\n", hwndOwner, nFolder, fCreate ? "T" : "F"); @@ -696,7 +696,7 @@ HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEM STGMEDIUM medium; FORMATETC fmt; - fmt.cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); fmt.ptd = NULL; fmt.dwAspect = DVASPECT_CONTENT; fmt.lindex = -1; diff --git a/reactos/dll/win32/shell32/she_ocmenu.c b/reactos/dll/win32/shell32/she_ocmenu.c index 618d6ad8cf4..dc66376cdea 100644 --- a/reactos/dll/win32/shell32/she_ocmenu.c +++ b/reactos/dll/win32/shell32/she_ocmenu.c @@ -1185,7 +1185,7 @@ SHEOW_LoadOpenWithItems(SHEOWImpl *This, IDataObject *pdtobj) LPWSTR szPtr; static const WCHAR szShortCut[] = { '.','l','n','k', 0 }; - fmt.cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); fmt.ptd = NULL; fmt.dwAspect = DVASPECT_CONTENT; fmt.lindex = -1; diff --git a/reactos/dll/win32/shell32/shelllink.c b/reactos/dll/win32/shell32/shelllink.c index 5e05bc59a94..2d9ef1c20ee 100644 --- a/reactos/dll/win32/shell32/shelllink.c +++ b/reactos/dll/win32/shell32/shelllink.c @@ -734,30 +734,30 @@ static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str ) TRACE("%p\n",stm); - r = IStream_Read( stm, &buffer.cbSize, sizeof (DWORD), &count ); + r = IStream_Read( stm, &buffer.dbh.cbSize, sizeof (DWORD), &count ); if( FAILED( r ) ) return r; /* make sure that we read the size of the structure even on error */ size = sizeof buffer - sizeof (DWORD); - if( buffer.cbSize != sizeof buffer ) + if( buffer.dbh.cbSize != sizeof buffer ) { ERR("Ooops. This structure is not as expected...\n"); return E_FAIL; } - r = IStream_Read( stm, &buffer.dwSignature, size, &count ); + r = IStream_Read( stm, &buffer.dbh.dwSignature, size, &count ); if( FAILED( r ) ) return r; if( count != size ) return E_FAIL; - TRACE("magic %08x string = %s\n", buffer.dwSignature, debugstr_w(buffer.szwDarwinID)); + TRACE("magic %08x string = %s\n", buffer.dbh.dwSignature, debugstr_w(buffer.szwDarwinID)); - if( (buffer.dwSignature&0xffff0000) != 0xa0000000 ) + if( (buffer.dbh.dwSignature&0xffff0000) != 0xa0000000 ) { - ERR("Unknown magic number %08x in advertised shortcut\n", buffer.dwSignature); + ERR("Unknown magic number %08x in advertised shortcut\n", buffer.dbh.dwSignature); return E_FAIL; } @@ -1031,8 +1031,8 @@ static EXP_DARWIN_LINK* shelllink_build_darwinid( LPCWSTR string, DWORD magic ) EXP_DARWIN_LINK *buffer; buffer = LocalAlloc( LMEM_ZEROINIT, sizeof *buffer ); - buffer->cbSize = sizeof *buffer; - buffer->dwSignature = magic; + buffer->dbh.cbSize = sizeof *buffer; + buffer->dbh.dwSignature = magic; lstrcpynW( buffer->szwDarwinID, string, MAX_PATH ); WideCharToMultiByte(CP_ACP, 0, string, -1, buffer->szDarwinID, MAX_PATH, NULL, NULL ); @@ -1048,7 +1048,7 @@ static HRESULT Stream_WriteAdvertiseInfo( IStream* stm, LPCWSTR string, DWORD ma buffer = shelllink_build_darwinid( string, magic ); - return IStream_Write( stm, buffer, buffer->cbSize, &count ); + return IStream_Write( stm, buffer, buffer->dbh.cbSize, &count ); } /************************************************************************ diff --git a/reactos/dll/win32/shell32/shfldr_fs.c b/reactos/dll/win32/shell32/shfldr_fs.c index da1391807b5..6a0c9537f2f 100644 --- a/reactos/dll/win32/shell32/shfldr_fs.c +++ b/reactos/dll/win32/shell32/shfldr_fs.c @@ -97,7 +97,7 @@ static void SF_RegisterClipFmt (IGenericSFImpl * This) TRACE ("(%p)\n", This); if (!This->cfShellIDList) { - This->cfShellIDList = RegisterClipboardFormatA (CFSTR_SHELLIDLIST); + This->cfShellIDList = RegisterClipboardFormatW (CFSTR_SHELLIDLIST); } } diff --git a/reactos/dll/win32/shell32/shlfolder.c b/reactos/dll/win32/shell32/shlfolder.c index a08b755deb6..f9d5c1eea5e 100644 --- a/reactos/dll/win32/shell32/shlfolder.c +++ b/reactos/dll/win32/shell32/shlfolder.c @@ -554,7 +554,7 @@ HRESULT WINAPI SHCreateLinks( HWND hWnd, LPCSTR lpszDir, LPDATAOBJECT lpDataObje */ HRESULT WINAPI -SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, +SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY *apidl, DWORD dwFlags) diff --git a/reactos/dll/win32/shell32/shlview.c b/reactos/dll/win32/shell32/shlview.c index 696cd11e46b..ef7f587f7c1 100644 --- a/reactos/dll/win32/shell32/shlview.c +++ b/reactos/dll/win32/shell32/shlview.c @@ -914,7 +914,7 @@ static HRESULT ShellView_OpenSelectedItems(IShellViewImpl * This) if (0 == CF_IDLIST) { - CF_IDLIST = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); } fetc.cfFormat = CF_IDLIST; fetc.ptd = NULL; diff --git a/reactos/dll/win32/shell32/shv_def_cmenu.c b/reactos/dll/win32/shell32/shv_def_cmenu.c index 3df3dd21e74..71c25a7d407 100644 --- a/reactos/dll/win32/shell32/shv_def_cmenu.c +++ b/reactos/dll/win32/shell32/shv_def_cmenu.c @@ -294,7 +294,7 @@ HasClipboardData() TRACE("pda=%p\n", pda); /* Set the FORMATETC structure*/ - InitFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); + InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); if(SUCCEEDED(IDataObject_GetData(pda,&formatetc,&medium))) { ret = TRUE; @@ -1018,7 +1018,7 @@ DoPaste( if (OleGetClipboard(&pda) != S_OK) return E_FAIL; - InitFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); + InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); hr = IDataObject_GetData(pda,&formatetc,&medium); if (FAILED(hr)) diff --git a/reactos/dll/win32/shell32/stubs.c b/reactos/dll/win32/shell32/stubs.c index 1ead574e1f4..b3192ea2c25 100644 --- a/reactos/dll/win32/shell32/stubs.c +++ b/reactos/dll/win32/shell32/stubs.c @@ -381,7 +381,7 @@ CDefFolderMenu_MergeMenu(HINSTANCE hInstance, */ HRESULT WINAPI -CDefFolderMenu_Create(PCIDLIST_ABSOLUTE pidlFolder, +CDefFolderMenu_Create(LPITEMIDLIST pidlFolder, HWND hwnd, UINT uidl, PCUITEMID_CHILD_ARRAY *apidl, diff --git a/reactos/include/dxsdk/axextend.idl b/reactos/include/dxsdk/axextend.idl index 8b52d79d023..66e43f151ca 100644 --- a/reactos/include/dxsdk/axextend.idl +++ b/reactos/include/dxsdk/axextend.idl @@ -420,6 +420,10 @@ interface IOverlayNotify : IUnknown typedef IOverlayNotify *POVERLAYNOTIFY; +cpp_quote("#if 0") +typedef HANDLE HMONITOR; +cpp_quote("#endif /* 0 */") + [ object, local, diff --git a/reactos/include/psdk/access.idl b/reactos/include/psdk/access.idl new file mode 100644 index 00000000000..d3d94240384 --- /dev/null +++ b/reactos/include/psdk/access.idl @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a8c-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IAccessor : IUnknown +{ + + typedef DWORD DBACCESSORFLAGS; + + typedef DWORD DBBINDSTATUS; + + [local] + HRESULT AddRefAccessor([in] HACCESSOR hAccessor, + [in, out, unique, annotation("__out_opt")] DBREFCOUNT *pcRefCount); + + [call_as(AddRefAccessor)] + HRESULT RemoteAddRefAccessor([in] HACCESSOR hAccessor, + [in, out, unique, annotation("__out_opt")] DBREFCOUNT *pcRefCount, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT CreateAccessor([in] DBACCESSORFLAGS dwAccessorFlags, + [in] DBCOUNTITEM cBindings, + [in, size_is(cBindings), annotation("__in_ecount(cBindings)")] const DBBINDING rgBindings[], + [in] DBLENGTH cbRowSize, + [out, annotation("__out")] HACCESSOR *phAccessor, + [out, size_is(cBindings), annotation("__out_ecount_opt(cBindings)")] DBBINDSTATUS rgStatus[]); + + [call_as(CreateAccessor)] + HRESULT RemoteCreateAccessor([in] DBACCESSORFLAGS dwAccessorFlags, + [in] DBCOUNTITEM cBindings, + [in, unique, size_is(cBindings)] DBBINDING *rgBindings, + [in] DBLENGTH cbRowSize, + [out] HACCESSOR *phAccessor, + [in, out, unique, size_is(cBindings)] DBBINDSTATUS *rgStatus, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT GetBindings([in] HACCESSOR hAccessor, + [out, annotation("__out")] DBACCESSORFLAGS *pdwAccessorFlags, + [in, out, annotation("__out_opt")] DBCOUNTITEM *pcBindings, + [out, size_is(,*pcBindings), annotation("__deref_out_ecount_opt(*pcBindings)")] DBBINDING **prgBindings); + + [call_as(GetBindings)] + HRESULT RemoteGetBindings([in] HACCESSOR hAccessor, + [out] DBACCESSORFLAGS *pdwAccessorFlags, + [in, out] DBCOUNTITEM *pcBindings, + [out, size_is(,*pcBindings)] DBBINDING **prgBindings, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT ReleaseAccessor([in] HACCESSOR hAccessor, + [in, out, unique, annotation("__out_opt")] DBREFCOUNT *pcRefCount); + + [call_as(ReleaseAccessor)] + HRESULT RemoteReleaseAccessor([in] HACCESSOR hAccessor, + [in, out, unique] DBREFCOUNT *pcRefCount, + [out] IErrorInfo **ppErrorInfoRem); + +}; diff --git a/reactos/include/psdk/asynot.idl b/reactos/include/psdk/asynot.idl new file mode 100644 index 00000000000..b745bd9c796 --- /dev/null +++ b/reactos/include/psdk/asynot.idl @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a96-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBAsynchNotify : IUnknown +{ + [local] + HRESULT OnLowResource([in] DB_DWRESERVE dwReserved); + + [call_as(OnLowResource)] + HRESULT RemoteOnLowResource([in] DB_DWRESERVE dwReserved); + + [local] + HRESULT OnProgress([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in] DBCOUNTITEM ulProgress, + [in] DBCOUNTITEM ulProgressMax, + [in] DBASYNCHPHASE eAsynchPhase, + [in, annotation("__in_opt")] LPOLESTR pwszStatusText); + + [call_as(OnProgress)] + HRESULT RemoteOnProgress([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in] DBCOUNTITEM ulProgress, + [in] DBCOUNTITEM ulProgressMax, + [in] DBASYNCHPHASE eAsynchPhase, + [in, unique, string] LPOLESTR pwszStatusText); + + [local] + HRESULT OnStop([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in] HRESULT hrStatus, + [in, annotation("__in_opt")] LPOLESTR pwszStatusText); + + [call_as(OnStop)] + HRESULT RemoteOnStop([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in] HRESULT hrStatus, + [in, unique, string] LPOLESTR pwszStatusText); +} diff --git a/reactos/include/psdk/asysta.idl b/reactos/include/psdk/asysta.idl new file mode 100644 index 00000000000..40bca846530 --- /dev/null +++ b/reactos/include/psdk/asysta.idl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a95-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBAsynchStatus : IUnknown +{ + [local] + HRESULT Abort([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation); + + [call_as(Abort)] + HRESULT RemoteAbort([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT GetStatus([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [out, annotation("__out_opt")] DBCOUNTITEM *pulProgress, + [out, annotation("__out_opt")] DBCOUNTITEM *pulProgressMax, + [out, annotation("__out")] DBASYNCHPHASE *peAsynchPhase, + [out, annotation("__deref_opt_inout_opt")] LPOLESTR *ppwszStatusText); + + [call_as(GetStatus)] + HRESULT RemoteGetStatus([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in, out, unique] DBCOUNTITEM *pulProgress, + [in, out, unique] DBCOUNTITEM *pulProgressMax, + [in, out, unique] DBASYNCHPHASE *peAsynchPhase, + [in, out, unique] LPOLESTR *ppwszStatusText, + [out] IErrorInfo **ppErrorInfoRem); +} diff --git a/reactos/include/psdk/binres.idl b/reactos/include/psdk/binres.idl new file mode 100644 index 00000000000..f09d124fdef --- /dev/null +++ b/reactos/include/psdk/binres.idl @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733ab1-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IBindResource : IUnknown +{ + [local] + HRESULT Bind([in] IUnknown *pUnkOuter, + [in] LPCOLESTR pwszURL, + [in] DBBINDURLFLAG dwBindURLFlags, + [in] REFGUID rguid, + [in] REFIID riid, + [in] IAuthenticate *pAuthenticate, + [in, out, unique] DBIMPLICITSESSION *pImplSession, + [in, out, unique] DBBINDURLSTATUS *pdwBindStatus, + [out, iid_is(riid)] IUnknown **ppUnk); + + [call_as(Bind)] + HRESULT RemoteBind([in] IUnknown *pUnkOuter, + [in] LPCOLESTR pwszURL, + [in] DBBINDURLFLAG dwBindURLFlags, + [in] REFGUID rguid, + [in] REFIID riid, + [in] IAuthenticate *pAuthenticate, + [in] IUnknown *pSessionUnkOuter, + [in, unique] IID *piid, + [in, out, unique, iid_is(piid)] IUnknown **ppSession, + [in, out, unique] DBBINDURLSTATUS *pdwBindStatus, + [out, iid_is(riid)] IUnknown **ppUnk); +} diff --git a/reactos/include/psdk/bits.idl b/reactos/include/psdk/bits.idl index 386d6c00b75..89b916d0a2c 100644 --- a/reactos/include/psdk/bits.idl +++ b/reactos/include/psdk/bits.idl @@ -30,6 +30,10 @@ cpp_quote("#define BG_NOTIFY_JOB_ERROR 0x0002") cpp_quote("#define BG_NOTIFY_DISABLE 0x0004") cpp_quote("#define BG_NOTIFY_JOB_MODIFICATION 0x0008") +cpp_quote("#ifdef WINE_NO_UNICODE_MACROS") +cpp_quote("#undef EnumJobs") +cpp_quote("#undef GetJob") +cpp_quote("#endif") #define BG_ENUM_SIZEIS(maxcount) maxcount #define BG_ENUM_LENGTHIS(maxcount,lengthptr) lengthptr ? *lengthptr : maxcount diff --git a/reactos/include/psdk/cmdbas.idl b/reactos/include/psdk/cmdbas.idl new file mode 100644 index 00000000000..01be4604f38 --- /dev/null +++ b/reactos/include/psdk/cmdbas.idl @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a63-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface ICommand : IUnknown +{ + [local] + HRESULT Cancel(); + + [call_as(Cancel)] + HRESULT RemoteCancel([out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT Execute([in, annotation("__in_opt")] IUnknown *pUnkOuter, + [in] REFIID riid, + [in, out, annotation("__inout_opt")] DBPARAMS *pParams, + [out, annotation("__out_opt")] DBROWCOUNT *pcRowsAffected, + [out, iid_is(riid), annotation("__deref_opt_out")] IUnknown **ppRowset); + + [call_as(Execute)] + HRESULT RemoteExecute([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [in] HACCESSOR hAccessor, + [in] DB_UPARAMS cParamSets, + [in, unique] GUID *pGuid, + [in] ULONG ulGuidOffset, + [in, unique] RMTPACK *pInputParams, + [in, out, unique] RMTPACK *pOutputParams, + [in] DBCOUNTITEM cBindings, + [in, unique, size_is(cBindings)] DBBINDING *rgBindings, + [in, out, unique, size_is(cBindings)] DBSTATUS *rgStatus, + [in, out, unique] DBROWCOUNT *pcRowsAffected, + [in, out, unique, iid_is(riid)] IUnknown **ppRowset); + + [local] + HRESULT GetDBSession([in] REFIID riid, + [out, iid_is(riid), annotation("__deref_out_opt")] IUnknown **ppSession); + + [call_as(GetDBSession)] + HRESULT RemoteGetDBSession([in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppSession, + [out] IErrorInfo **ppErrorInfoRem); +}; diff --git a/reactos/include/psdk/cmdtxt.idl b/reactos/include/psdk/cmdtxt.idl new file mode 100644 index 00000000000..32208848353 --- /dev/null +++ b/reactos/include/psdk/cmdtxt.idl @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a27-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface ICommandText : ICommand +{ + [local] + HRESULT GetCommandText([in, out /*, annotation("__inout_opt")*/] GUID *pguidDialect, + [out /*, annotation("__deref_out")*/] LPOLESTR *ppwszCommand); + + [call_as(GetCommandText)] + HRESULT RemoteGetCommandText([in, out, unique] GUID *pguidDialect, + [out] LPOLESTR *ppwszCommand, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT SetCommandText([in] REFGUID rguidDialect, + [in, unique /*, annotation("__in_z_opt")*/] LPCOLESTR pwszCommand); + + [call_as(SetCommandText)] + HRESULT RemoteSetCommandText([in] REFGUID rguidDialect, + [in, unique] LPCOLESTR pwszCommand, + [out] IErrorInfo **ppErrorInfoRem); + +}; diff --git a/reactos/include/psdk/control.idl b/reactos/include/psdk/control.idl index c0b1914a02b..84a4f88e6a9 100644 --- a/reactos/include/psdk/control.idl +++ b/reactos/include/psdk/control.idl @@ -27,7 +27,7 @@ interface IMediaEvent; interface IMediaEventEx; interface IMediaPosition; -typedef long OAFilterState; +typedef LONG OAFilterState; typedef LONG_PTR OAHWND; typedef LONG_PTR OAEVENT; @@ -68,10 +68,10 @@ interface IMediaControl : IDispatch ] interface IBasicAudio : IDispatch { - [propput] HRESULT Volume( [in] long lVolume ); - [propget] HRESULT Volume( [out] long *plVolume ); - [propput] HRESULT Balance( [in] long lBalance ); - [propget] HRESULT Balance( [out] long *plBalance ); + [propput] HRESULT Volume( [in] LONG lVolume ); + [propget] HRESULT Volume( [out] LONG *plVolume ); + [propput] HRESULT Balance( [in] LONG lBalance ); + [propget] HRESULT Balance( [out] LONG *plBalance ); } @@ -87,43 +87,43 @@ interface IVideoWindow : IDispatch { [propput] HRESULT Caption( [in] BSTR strCaption ); [propget] HRESULT Caption( [out] BSTR *strCaption ); - [propput] HRESULT WindowStyle( [in] long WindowStyle ); - [propget] HRESULT WindowStyle( [out] long *WindowStyle ); - [propput] HRESULT WindowStyleEx( [in] long WindowStyleEx ); - [propget] HRESULT WindowStyleEx( [out] long *WindowStyleEx ); - [propput] HRESULT AutoShow( [in] long AutoShow ); - [propget] HRESULT AutoShow( [out] long *AutoShow ); - [propput] HRESULT WindowState( [in] long WindowState ); - [propget] HRESULT WindowState( [out] long *WindowState ); - [propput] HRESULT BackgroundPalette( [in] long BackgroundPalette ); - [propget] HRESULT BackgroundPalette( [out] long *pBackgroundPalette ); - [propput] HRESULT Visible( [in] long Visible ); - [propget] HRESULT Visible( [out] long *pVisible ); - [propput] HRESULT Left( [in] long Left ); - [propget] HRESULT Left( [out] long *pLeft ); - [propput] HRESULT Width( [in] long Width ); - [propget] HRESULT Width( [out] long *pWidth ); - [propput] HRESULT Top( [in] long Top ); - [propget] HRESULT Top( [out] long *pTop ); - [propput] HRESULT Height( [in] long Height ); - [propget] HRESULT Height( [out] long *pHeight ); + [propput] HRESULT WindowStyle( [in] LONG WindowStyle ); + [propget] HRESULT WindowStyle( [out] LONG *WindowStyle ); + [propput] HRESULT WindowStyleEx( [in] LONG WindowStyleEx ); + [propget] HRESULT WindowStyleEx( [out] LONG *WindowStyleEx ); + [propput] HRESULT AutoShow( [in] LONG AutoShow ); + [propget] HRESULT AutoShow( [out] LONG *AutoShow ); + [propput] HRESULT WindowState( [in] LONG WindowState ); + [propget] HRESULT WindowState( [out] LONG *WindowState ); + [propput] HRESULT BackgroundPalette( [in] LONG BackgroundPalette ); + [propget] HRESULT BackgroundPalette( [out] LONG *pBackgroundPalette ); + [propput] HRESULT Visible( [in] LONG Visible ); + [propget] HRESULT Visible( [out] LONG *pVisible ); + [propput] HRESULT Left( [in] LONG Left ); + [propget] HRESULT Left( [out] LONG *pLeft ); + [propput] HRESULT Width( [in] LONG Width ); + [propget] HRESULT Width( [out] LONG *pWidth ); + [propput] HRESULT Top( [in] LONG Top ); + [propget] HRESULT Top( [out] LONG *pTop ); + [propput] HRESULT Height( [in] LONG Height ); + [propget] HRESULT Height( [out] LONG *pHeight ); [propput] HRESULT Owner( [in] OAHWND Owner ); [propget] HRESULT Owner( [out] OAHWND *Owner ); [propput] HRESULT MessageDrain( [in] OAHWND Drain ); [propget] HRESULT MessageDrain( [out] OAHWND *Drain ); - [propget] HRESULT BorderColor( [out] long *Color ); - [propput] HRESULT BorderColor( [in] long Color ); - [propget] HRESULT FullScreenMode( [out] long *FullScreenMode ); - [propput] HRESULT FullScreenMode( [in] long FullScreenMode ); - HRESULT SetWindowForeground( [in] long Focus ); - HRESULT NotifyOwnerMessage( [in] OAHWND hwnd, [in] long uMsg, [in] LONG_PTR wParam, [in] LONG_PTR lParam ); - HRESULT SetWindowPosition( [in] long Left, [in] long Top, [in] long Width, [in] long Height ); - HRESULT GetWindowPosition( [out] long *pLeft, [out] long *pTop, [out] long *pWidth, [out] long *pHeight ); - HRESULT GetMinIdealImageSize( [out] long *pWidth, [out] long *pHeight ); - HRESULT GetMaxIdealImageSize( [out] long *pWidth, [out] long *pHeight ); - HRESULT GetRestorePosition( [out] long *pLeft, [out] long *pTop, [out] long *pWidth, [out] long *pHeight ); - HRESULT HideCursor( [in] long HideCursor ); - HRESULT IsCursorHidden( [out] long *CursorHidden ); + [propget] HRESULT BorderColor( [out] LONG *Color ); + [propput] HRESULT BorderColor( [in] LONG Color ); + [propget] HRESULT FullScreenMode( [out] LONG *FullScreenMode ); + [propput] HRESULT FullScreenMode( [in] LONG FullScreenMode ); + HRESULT SetWindowForeground( [in] LONG Focus ); + HRESULT NotifyOwnerMessage( [in] OAHWND hwnd, [in] LONG uMsg, [in] LONG_PTR wParam, [in] LONG_PTR lParam ); + HRESULT SetWindowPosition( [in] LONG Left, [in] LONG Top, [in] LONG Width, [in] LONG Height ); + HRESULT GetWindowPosition( [out] LONG *pLeft, [out] LONG *pTop, [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT GetMinIdealImageSize( [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT GetMaxIdealImageSize( [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT GetRestorePosition( [out] LONG *pLeft, [out] LONG *pTop, [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT HideCursor( [in] LONG HideCursor ); + HRESULT IsCursorHidden( [out] LONG *CursorHidden ); } @@ -138,39 +138,39 @@ interface IVideoWindow : IDispatch interface IBasicVideo : IDispatch { [propget] HRESULT AvgTimePerFrame( [out] REFTIME *pAvgTimePerFrame ); - [propget] HRESULT BitRate( [out] long *pBitRate ); - [propget] HRESULT BitErrorRate( [out] long *pBitErrorRate ); - [propget] HRESULT VideoWidth( [out] long *pVideoWidth ); - [propget] HRESULT VideoHeight( [out] long *pVideoHeight ); - [propput] HRESULT SourceLeft( [in] long SourceLeft ); - [propget] HRESULT SourceLeft( [out] long *pSourceLeft ); - [propput] HRESULT SourceWidth( [in] long SourceWidth ); - [propget] HRESULT SourceWidth( [out] long *pSourceWidth ); - [propput] HRESULT SourceTop( [in] long SourceTop ); - [propget] HRESULT SourceTop( [out] long *pSourceTop ); - [propput] HRESULT SourceHeight( [in] long SourceHeight ); - [propget] HRESULT SourceHeight( [out] long *pSourceHeight ); - [propput] HRESULT DestinationLeft( [in] long DestinationLeft ); - [propget] HRESULT DestinationLeft( [out] long *pDestinationLeft ); - [propput] HRESULT DestinationWidth( [in] long DestinationWidth ); - [propget] HRESULT DestinationWidth( [out] long *pDestinationWidth ); - [propput] HRESULT DestinationTop( [in] long DestinationTop ); - [propget] HRESULT DestinationTop( [out] long *pDestinationTop ); - [propput] HRESULT DestinationHeight( [in] long DestinationHeight ); - [propget] HRESULT DestinationHeight( [out] long *pDestinationHeight ); - HRESULT SetSourcePosition( [in] long Left, [in] long Top, [in] long Width, [in] long Height ); - HRESULT GetSourcePosition( [out] long *pLeft, [out] long *pTop, [out] long *pWidth, [out] long *pHeight ); + [propget] HRESULT BitRate( [out] LONG *pBitRate ); + [propget] HRESULT BitErrorRate( [out] LONG *pBitErrorRate ); + [propget] HRESULT VideoWidth( [out] LONG *pVideoWidth ); + [propget] HRESULT VideoHeight( [out] LONG *pVideoHeight ); + [propput] HRESULT SourceLeft( [in] LONG SourceLeft ); + [propget] HRESULT SourceLeft( [out] LONG *pSourceLeft ); + [propput] HRESULT SourceWidth( [in] LONG SourceWidth ); + [propget] HRESULT SourceWidth( [out] LONG *pSourceWidth ); + [propput] HRESULT SourceTop( [in] LONG SourceTop ); + [propget] HRESULT SourceTop( [out] LONG *pSourceTop ); + [propput] HRESULT SourceHeight( [in] LONG SourceHeight ); + [propget] HRESULT SourceHeight( [out] LONG *pSourceHeight ); + [propput] HRESULT DestinationLeft( [in] LONG DestinationLeft ); + [propget] HRESULT DestinationLeft( [out] LONG *pDestinationLeft ); + [propput] HRESULT DestinationWidth( [in] LONG DestinationWidth ); + [propget] HRESULT DestinationWidth( [out] LONG *pDestinationWidth ); + [propput] HRESULT DestinationTop( [in] LONG DestinationTop ); + [propget] HRESULT DestinationTop( [out] LONG *pDestinationTop ); + [propput] HRESULT DestinationHeight( [in] LONG DestinationHeight ); + [propget] HRESULT DestinationHeight( [out] LONG *pDestinationHeight ); + HRESULT SetSourcePosition( [in] LONG Left, [in] LONG Top, [in] LONG Width, [in] LONG Height ); + HRESULT GetSourcePosition( [out] LONG *pLeft, [out] LONG *pTop, [out] LONG *pWidth, [out] LONG *pHeight ); HRESULT SetDefaultSourcePosition(); - HRESULT SetDestinationPosition( [in] long Left, [in] long Top, [in] long Width, [in] long Height ); - HRESULT GetDestinationPosition( [out] long *pLeft, [out] long *pTop, [out] long *pWidth, [out] long *pHeight ); + HRESULT SetDestinationPosition( [in] LONG Left, [in] LONG Top, [in] LONG Width, [in] LONG Height ); + HRESULT GetDestinationPosition( [out] LONG *pLeft, [out] LONG *pTop, [out] LONG *pWidth, [out] LONG *pHeight ); HRESULT SetDefaultDestinationPosition(); - HRESULT GetVideoSize( [out] long *pWidth, [out] long *pHeight ); - HRESULT GetVideoPaletteEntries( [in] long StartIndex, - [in] long Entries, - [out] long *pRetrieved, - [out, size_is(Entries), length_is(*pRetrieved)] long *pPalette ); - HRESULT GetCurrentImage( [in, out] long *pBufferSize, - [out, size_is(*pBufferSize), length_is(*pBufferSize)] long *pDIBImage ); + HRESULT GetVideoSize( [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT GetVideoPaletteEntries( [in] LONG StartIndex, + [in] LONG Entries, + [out] LONG *pRetrieved, + [out, size_is(Entries), length_is(*pRetrieved)] LONG *pPalette ); + HRESULT GetCurrentImage( [in, out] LONG *pBufferSize, + [out, size_is(*pBufferSize), length_is(*pBufferSize)] LONG *pDIBImage ); HRESULT IsUsingDefaultSource(); HRESULT IsUsingDefaultDestination(); } @@ -198,11 +198,11 @@ interface IBasicVideo2 : IBasicVideo interface IMediaEvent : IDispatch { HRESULT GetEventHandle( [out] OAEVENT *hEvent ); - HRESULT GetEvent( [out] long *lEventCode, [out] LONG_PTR *lParam1, [out] LONG_PTR *lParam2, [in] long msTimeout ); - HRESULT WaitForCompletion( [in] long msTimeout, [out] long *pEvCode ); - HRESULT CancelDefaultHandling( [in] long lEvCode ); - HRESULT RestoreDefaultHandling( [in] long lEvCode ); - HRESULT FreeEventParams( [in] long lEvCode, [in] LONG_PTR lParam1, [in] LONG_PTR lParam2 ); + HRESULT GetEvent( [out] LONG *lEventCode, [out] LONG_PTR *lParam1, [out] LONG_PTR *lParam2, [in] LONG msTimeout ); + HRESULT WaitForCompletion( [in] LONG msTimeout, [out] LONG *pEvCode ); + HRESULT CancelDefaultHandling( [in] LONG lEvCode ); + HRESULT RestoreDefaultHandling( [in] LONG lEvCode ); + HRESULT FreeEventParams( [in] LONG lEvCode, [in] LONG_PTR lParam1, [in] LONG_PTR lParam2 ); } @@ -216,9 +216,9 @@ interface IMediaEvent : IDispatch ] interface IMediaEventEx : IMediaEvent { - HRESULT SetNotifyWindow( [in] OAHWND hwnd, [in] long lMsg, [in] LONG_PTR lInstanceData ); - HRESULT SetNotifyFlags( [in] long lNoNotifyFlags ); - HRESULT GetNotifyFlags( [out] long *lplNoNotifyFlags ); + HRESULT SetNotifyWindow( [in] OAHWND hwnd, [in] LONG lMsg, [in] LONG_PTR lInstanceData ); + HRESULT SetNotifyFlags( [in] LONG lNoNotifyFlags ); + HRESULT GetNotifyFlags( [out] LONG *lplNoNotifyFlags ); } diff --git a/reactos/include/psdk/crtrow.idl b/reactos/include/psdk/crtrow.idl new file mode 100644 index 00000000000..7088e00e721 --- /dev/null +++ b/reactos/include/psdk/crtrow.idl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733ab2-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface ICreateRow : IUnknown +{ + [local] + HRESULT CreateRow([in, unique] IUnknown *pUnkOuter, + [in] LPCOLESTR pwszURL, + [in] DBBINDURLFLAG dwBindURLFlags, + [in] REFGUID rguid, + [in] REFIID riid, + [in, unique] IAuthenticate *pAuthenticate, + [in, out, unique] DBIMPLICITSESSION *pImplSession, + [in, out, unique] DBBINDURLSTATUS *pdwBindStatus, + [out, annotation("__deref_opt_out_opt")] LPOLESTR *ppwszNewURL, + [out, iid_is(riid)] IUnknown **ppUnk); + + [call_as(CreateRow)] + HRESULT RemoteCreateRow([in] IUnknown *pUnkOuter, + [in] LPCOLESTR pwszURL, + [in] DBBINDURLFLAG dwBindURLFlags, + [in] REFGUID rguid, + [in] REFIID riid, + [in] IAuthenticate *pAuthenticate, + [in] IUnknown *pSessionUnkOuter, + [in, unique] IID *piid, + [in, out, unique, iid_is(piid)] IUnknown **ppSession, + [in, out, unique] DBBINDURLSTATUS *pdwBindStatus, + [in, out, unique] LPOLESTR *ppwszNewURL, + [out, iid_is(riid)] IUnknown **ppUnk); +} diff --git a/reactos/include/psdk/dbccmd.idl b/reactos/include/psdk/dbccmd.idl new file mode 100644 index 00000000000..99274bc05ba --- /dev/null +++ b/reactos/include/psdk/dbccmd.idl @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a1d-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBCreateCommand : IUnknown +{ + [local] + HRESULT CreateCommand([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppCommand); + + [call_as(CreateCommand)] + HRESULT RemoteCreateCommand([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppCommand, + [out] IErrorInfo **ppErrorInfoRem); +} diff --git a/reactos/include/psdk/dbcses.idl b/reactos/include/psdk/dbcses.idl new file mode 100644 index 00000000000..3bdb0d779d4 --- /dev/null +++ b/reactos/include/psdk/dbcses.idl @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a5d-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBCreateSession : IUnknown +{ + [local] + HRESULT CreateSession([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppDBSession); + + [call_as(CreateSession)] + HRESULT RemoteCreateSession([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppDBSession, + [out] IErrorInfo **ppErrorInfoRem); +} diff --git a/reactos/include/psdk/dbdsad.idl b/reactos/include/psdk/dbdsad.idl new file mode 100644 index 00000000000..c6fb2b4ea4b --- /dev/null +++ b/reactos/include/psdk/dbdsad.idl @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a7a-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBDataSourceAdmin : IUnknown +{ + [local] + HRESULT CreateDataSource([in] ULONG cPropertySets, + [in, out, size_is(cPropertySets)] DBPROPSET rgPropertySets[], + [in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppDBSession); + + [call_as(CreateDataSource)] + HRESULT RemoteCreateDataSource([in] ULONG cPropertySets, + [in, unique, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [in] IUnknown *pUnkOuter, + [in] REFIID riid, + [in, out, unique, iid_is(riid)] IUnknown **ppDBSession, + [in] ULONG cTotalProps, + [out, size_is(cTotalProps)] DBPROPSTATUS *rgPropStatus, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT DestroyDataSource(); + + [call_as(DestroyDataSource)] + HRESULT RemoteDestroyDataSource([out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT GetCreationProperties([in] ULONG cPropertyIDSets, + [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], + [in, out] ULONG *pcPropertyInfoSets, + [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets, + [out, annotation("__deref_out_z_opt")] OLECHAR **ppDescBuffer); + + [call_as(GetCreationProperties)] + HRESULT RemoteGetCreationProperties([in] ULONG cPropertyIDSets, + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, + [in, out] ULONG *pcPropertyInfoSets, + [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets, + [in, out] DBCOUNTITEM *pcOffsets, + [out, size_is(,(ULONG)*pcOffsets)] DBBYTEOFFSET **prgDescOffsets, + [in, out] ULONG *pcbDescBuffer, + [in, out, unique, size_is(,*pcbDescBuffer)] OLECHAR **ppDescBuffer, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT ModifyDataSource([in] ULONG cPropertySets, + [in, size_is(cPropertySets)] DBPROPSET rgPropertySets[]); + + [call_as(ModifyDataSource)] + HRESULT RemoteModifyDataSource([in] ULONG cPropertySets, + [in, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [out] IErrorInfo **ppErrorInfoRem); +} diff --git a/reactos/include/psdk/dbprop.idl b/reactos/include/psdk/dbprop.idl index 5ed5301385f..782191a4554 100644 --- a/reactos/include/psdk/dbprop.idl +++ b/reactos/include/psdk/dbprop.idl @@ -30,7 +30,7 @@ interface IDBProperties : IUnknown { [call_as(GetProperties)] HRESULT RemoteGetProperties( [in] ULONG cPropertyIDSets, - [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, [in, out] ULONG *pcPropertySets, [out, size_is(,*pcPropertySets)] DBPROPSET **prgPropertySets, [out] IErrorInfo **ppErrorInfoRem); @@ -39,17 +39,18 @@ interface IDBProperties : IUnknown { [in] ULONG cPropertyIDSets, [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], [in, out] ULONG *pcPropertyInfoSets, - [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets); + [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets, + [out, annotation("__deref_out_z_opt")] OLECHAR **ppDescBuffer); [call_as(GetPropertyInfo)] HRESULT RemoteGetPropertyInfo( [in] ULONG cPropertyIDSets, - [in,size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, [in, out] ULONG *pcPropertyInfoSets, [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets, [in, out] ULONG *pcOffsets, [out, size_is(,*pcOffsets)] DBBYTEOFFSET **prgDescOffsets, [in, out] ULONG *pcbDescBuffer, - [out, size_is(,*pcbDescBuffer)] OLECHAR **ppDescBuffer, + [in, out, unique, size_is(,*pcbDescBuffer)] OLECHAR **ppDescBuffer, [out] IErrorInfo **ppErrorInfoRem); [local] HRESULT SetProperties( @@ -58,7 +59,7 @@ interface IDBProperties : IUnknown { [call_as(SetProperties)] HRESULT RemoteSetProperties( [in] ULONG cPropertySets, - [in, out, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [in, unique, size_is(cPropertySets)] DBPROPSET *rgPropertySets, [in] ULONG cTotalProps, [out, size_is(cTotalProps)] DBPROPSTATUS *rgPropStatus, [out] IErrorInfo **ppErrorInfoRem); diff --git a/reactos/include/psdk/dbs.idl b/reactos/include/psdk/dbs.idl index 19c2997b3ab..8ca2e2ae659 100644 --- a/reactos/include/psdk/dbs.idl +++ b/reactos/include/psdk/dbs.idl @@ -99,3 +99,247 @@ typedef struct tagDBPROPINFOSET { ULONG cPropertyInfos; GUID guidPropertySet; } DBPROPINFOSET; + +typedef DWORD DBBINDURLFLAG; +typedef DWORD DBBINDURLSTATUS; + +typedef struct tagDBIMPLICITSESSION +{ + IUnknown *pUnkOuter; + IID *piid; + IUnknown *pSession; +} DBIMPLICITSESSION; + +typedef WORD DBTYPE; + +enum DBTYPEENUM +{ + DBTYPE_EMPTY = 0, + DBTYPE_NULL = 1, + DBTYPE_I2 = 2, + DBTYPE_I4 = 3, + DBTYPE_R4 = 4, + DBTYPE_R8 = 5, + DBTYPE_CY = 6, + DBTYPE_DATE = 7, + DBTYPE_BSTR = 8, + DBTYPE_IDISPATCH = 9, + DBTYPE_ERROR = 10, + DBTYPE_BOOL = 11, + DBTYPE_VARIANT = 12, + DBTYPE_IUNKNOWN = 13, + DBTYPE_DECIMAL = 14, + DBTYPE_I1 = 16, + DBTYPE_UI1 = 17, + DBTYPE_UI2 = 18, + DBTYPE_UI4 = 19, + DBTYPE_I8 = 20, + DBTYPE_UI8 = 21, + DBTYPE_GUID = 72, + DBTYPE_BYTES = 128, + DBTYPE_STR = 129, + DBTYPE_WSTR = 130, + DBTYPE_NUMERIC = 131, + DBTYPE_UDT = 132, + DBTYPE_DBDATE = 133, + DBTYPE_DBTIME = 134, + DBTYPE_DBTIMESTAMP = 135, + + DBTYPE_VECTOR = 0x1000, + DBTYPE_ARRAY = 0x2000, + DBTYPE_BYREF = 0x4000, + DBTYPE_RESERVED = 0x8000 +}; + +enum DBTYPEENUM15 +{ + DBTYPE_HCHAPTER = 136 +}; + +enum DBTYPEENUM20 +{ + DBTYPE_FILETIME = 64, + DBTYPE_PROPVARIANT = 138, + DBTYPE_VARNUMERIC = 139 +}; + +typedef DWORD DBSTATUS; + +enum DBSTATUSENUM +{ + DBSTATUS_S_OK = 0, + DBSTATUS_E_BADACCESSOR = 1, + DBSTATUS_E_CANTCONVERTVALUE = 2, + DBSTATUS_S_ISNULL = 3, + DBSTATUS_S_TRUNCATED = 4, + DBSTATUS_E_SIGNMISMATCH = 5, + DBSTATUS_E_DATAOVERFLOW = 6, + DBSTATUS_E_CANTCREATE = 7, + DBSTATUS_E_UNAVAILABLE = 8, + DBSTATUS_E_PERMISSIONDENIED = 9, + DBSTATUS_E_INTEGRITYVIOLATION = 10, + DBSTATUS_E_SCHEMAVIOLATION = 11, + DBSTATUS_E_BADSTATUS = 12, + DBSTATUS_S_DEFAULT = 13 +}; + +cpp_quote("#ifdef DBINITCONSTANTS") +cpp_quote("#ifdef __cplusplus") +cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\") +cpp_quote(" EXTERN_C const GUID name DECLSPEC_HIDDEN; \\") +cpp_quote(" EXTERN_C const GUID name = \\") +cpp_quote(" { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }") +cpp_quote("#else") +cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\") +cpp_quote(" const GUID name DECLSPEC_HIDDEN; \\") +cpp_quote(" const GUID name = \\") +cpp_quote(" { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }") +cpp_quote("#endif") +cpp_quote("#else") +cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\") +cpp_quote(" EXTERN_C const GUID name DECLSPEC_HIDDEN") +cpp_quote("#endif") + +cpp_quote("DEFINE_DBGUID(DBGUID_SESSION, 0xc8b522f5, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);") +cpp_quote("DEFINE_DBGUID(DBGUID_ROWSET, 0xc8b522f6, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);") +cpp_quote("DEFINE_DBGUID(DBGUID_ROW, 0xc8b522f7, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);") +cpp_quote("DEFINE_DBGUID(DBGUID_STREAM, 0xc8b522f9, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);") + +typedef struct tagDBCOLUMNACCESS +{ + void *pData; + DBID columnid; + DBLENGTH cbDataLen; + DBSTATUS dwStatus; + DBLENGTH cbMaxLen; + DB_DWRESERVE dwReserved; + DBTYPE wType; + BYTE bPrecision; + BYTE bScale; +} DBCOLUMNACCESS; + +typedef DWORD DBROWSTATUS; + +enum DBROWSTATUSENUM +{ + DBROWSTATUS_S_OK = 0, + /* FIXME */ + DBROWSTATUS_E_FAIL = 19, + +}; + +typedef DWORD DBPART; + +enum DBPARTENUM +{ + DBPART_INVALID = 0, + DBPART_VALUE = 1, + DBPART_LENGTH = 2, + DBPART_STATUS = 4, +}; + +typedef DWORD DBPARAMIO; + +enum DBPARAMIOENUM +{ + DBPARAMIO_NOTPARAM = 0, + DBPARAMIO_INPUT = 1, + DBPARAMIO_OUTPUT = 2, +}; + +typedef DWORD DBMEMOWNER; + +enum DBMEMOWNERENUM +{ + DBMEMOWNER_CLIENTOWNED = 0, + DBMEMOWNER_PROVIDEROWNED = 1, +}; + +typedef struct tagDBOBJECT +{ + DWORD dwFlags; + IID iid; +} DBOBJECT; + +typedef struct tagDBBINDEXT +{ + [size_is((ULONG)ulExtension)] BYTE *pExtension; + DBCOUNTITEM ulExtension; +} DBBINDEXT; + +typedef struct tagDBBINDING +{ + DBORDINAL iOrdinal; + DBBYTEOFFSET obValue; + DBBYTEOFFSET obLength; + DBBYTEOFFSET obStatus; + ITypeInfo *pTypeInfo; + DBOBJECT *pObject; + DBBINDEXT *pBindExt; + DBPART dwPart; + DBMEMOWNER dwMemOwner; + DBPARAMIO eParamIO; + DBLENGTH cbMaxLen; + DWORD dwFlags; + DBTYPE wType; + BYTE bPrecision; + BYTE bScale; +} DBBINDING; + +typedef ULONG_PTR HACCESSOR; + +cpp_quote("#define DB_INVALID_HACCESSOR 0x00") + +typedef ULONG_PTR HROW; + +cpp_quote("#define DB_NULL_HROW 0x00") + +typedef ULONG_PTR HWATCHREGION; + +cpp_quote("#define DBWATCHREGION_NULL NULL") + +typedef ULONG_PTR HCHAPTER; + +cpp_quote("#define DB_NULL_HCHAPTER 0x00") + +typedef struct tagDBPARAMS +{ + void *pData; + DB_UPARAMS cParamSets; + HACCESSOR hAccessor; +} DBPARAMS; + +typedef DWORD DBASYNCHOP; + +enum DBASYNCHOPENUM +{ + DBSYNCHOP_OPEN, +}; + +typedef DWORD DBASYNCHPHASE; + +enum DBASYNCHPHASEENUM +{ + DBASYNCHPHASE_INITIALIZATION, + DBASYNCHPHASE_POPULATION, + DBASYNCHPHASE_COMPLETE, + DBASYNCHPHASE_CANCELED, +}; + +typedef struct tagRMTPACK +{ + ISequentialStream *pISeqStream; + ULONG cbData; + ULONG cBSTR; + [size_is(cBSTR)] BSTR *rgBSTR; + ULONG cVARIANT; + [size_is(cVARIANT)] VARIANT *rgVARIANT; + ULONG cIDISPATCH; + [size_is(cIDISPATCH)] IDispatch **rgIDISPATCH; + ULONG cIUNKNOWN; + [size_is(cIUNKNOWN)] IUnknown **rgIUNKNOWN; + ULONG cPROPVARIANT; + [size_is(cPROPVARIANT)] PROPVARIANT *rgPROPVARIANT; + ULONG cArray; + [size_is(cArray)] VARIANT *rgArray; +} RMTPACK; diff --git a/reactos/include/psdk/dimm.idl b/reactos/include/psdk/dimm.idl index 07e04b2e22f..851ec90cfd1 100644 --- a/reactos/include/psdk/dimm.idl +++ b/reactos/include/psdk/dimm.idl @@ -24,8 +24,6 @@ cpp_quote("#include ") cpp_quote("#if 0") -typedef WORD LANGID; - typedef struct { LPSTR lpReading; LPSTR lpWord; diff --git a/reactos/include/psdk/dispex.idl b/reactos/include/psdk/dispex.idl index b1759ddb890..6f1c5453a61 100644 --- a/reactos/include/psdk/dispex.idl +++ b/reactos/include/psdk/dispex.idl @@ -81,13 +81,13 @@ interface IDispatchEx : IDispatch [local] HRESULT InvokeEx( - [in] DISPID id, - [in] LCID lcid, - [in] WORD wFlags, - [in] DISPPARAMS *pdp, - [out] VARIANT *pvarRes, - [out] EXCEPINFO *pei, - [in, unique] IServiceProvider *pspCaller); + [in, annotation("__in")] DISPID id, + [in, annotation("__in")] LCID lcid, + [in, annotation("__in")] WORD wFlags, + [in, annotation("__in")] DISPPARAMS *pdp, + [out, annotation("__out_opt")] VARIANT *pvarRes, + [out, annotation("__out_opt")] EXCEPINFO *pei, + [in, unique, annotation("__in_opt")] IServiceProvider *pspCaller); [call_as(InvokeEx)] HRESULT RemoteInvokeEx( @@ -191,3 +191,15 @@ interface ICanHandleException : IUnknown [in] EXCEPINFO *pExcepInfo, [in] VARIANT *pvar); } + +[ + object, + uuid(10e2414a-ec59-49d2-bc51-5add2c36febc), + pointer_default(unique) +] +interface IProvideRuntimeContext : IUnknown +{ + HRESULT GetCurrentSourceContext( + [out] DWORD_PTR *pdwContext, + [out] VARIANT_BOOL *pfExecutingGlobalCode); +} diff --git a/reactos/include/psdk/hlink.idl b/reactos/include/psdk/hlink.idl index 886acb36411..af3f8f5f683 100644 --- a/reactos/include/psdk/hlink.idl +++ b/reactos/include/psdk/hlink.idl @@ -151,7 +151,7 @@ interface IHlink: IUnknown } /***************************************************************************** - * IHlink interface + * IHlinkSite interface */ [ object, diff --git a/reactos/include/psdk/mlang.idl b/reactos/include/psdk/mlang.idl index c9d90cb4458..a5b1b473f20 100644 --- a/reactos/include/psdk/mlang.idl +++ b/reactos/include/psdk/mlang.idl @@ -25,11 +25,6 @@ interface IStream; cpp_quote("#define CPIOD_PEEK 0x40000000") cpp_quote("#define CPIOD_FORCE_PROMPT 0x80000000") -/* FIXME: LANGID is defined in winnt.h and mlang.h in the platform SDK */ -cpp_quote("#ifndef _WINNT_H") -typedef WORD LANGID; -cpp_quote("#endif") - [ object, uuid(359f3443-bd4a-11d0-b188-00aa0038c969), @@ -42,10 +37,10 @@ interface IMLangCodePages : IUnknown [out] DWORD *pdwCodePages); HRESULT GetStrCodePages( [in, size_is(cchSrc)] const WCHAR *pszSrc, - [in] long cchSrc, + [in] LONG cchSrc, [in] DWORD dwPriorityCodePages, [out] DWORD *pdwCodePages, - [out] long *pcchCodePages); + [out] LONG *pcchCodePages); HRESULT CodePageToCodePages( [in] UINT uCodePage, [out] DWORD *pdwCodePages); @@ -233,11 +228,11 @@ interface IMLangString : IUnknown { #ifdef NEWMLSTR HRESULT LockMLStr( - [in] long lPos, + [in] LONG lPos, [in] DWORD dwFlags, [out] DWORD* pdwCookie, - [out] long* plActualPos, - [out] long* plActualLen); + [out] LONG* plActualPos, + [out] LONG* plActualLen); HRESULT UnlockMLStr( [in] DWORD dwCookie); @@ -246,13 +241,13 @@ interface IMLangString : IUnknown [in] BOOL fNoAccess); #endif HRESULT GetLength( - [out, retval] long* plLen); + [out, retval] LONG* plLen); HRESULT SetMLStr( - [in] long lDestPos, - [in] long lDestLen, + [in] LONG lDestPos, + [in] LONG lDestLen, [in] IUnknown *pSrcMLStr, - [in] long lSrcPos, - [in] long lSrcLen); + [in] LONG lSrcPos, + [in] LONG lSrcLen); #ifdef NEWMLSTR HRESULT RegisterAttr( [in] IUnknown *pUnk, @@ -267,14 +262,14 @@ interface IMLangString : IUnknown [out] IUnknown **ppUnk); #else HRESULT GetMLStr( - [in] long lSrcPos, - [in] long lSrcLen, + [in] LONG lSrcPos, + [in] LONG lSrcLen, [in] IUnknown *pUnkOuter, [in] DWORD dwClsContext, [in] const IID* piid, [out] IUnknown** ppDestMLStr, - [out] long* plDestPos, - [out] long* plDestLen); + [out] LONG* plDestPos, + [out] LONG* plDestLen); #endif } @@ -287,29 +282,29 @@ interface IMLangLineBreakConsole : IUnknown { HRESULT BreakLineML( [in] IMLangString* pSrcMLStr, - [in] long lSrcPos, - [in] long lSrcLen, - [in] long cMinColumns, - [in] long cMaxColumns, - [out] long* plLineLen, - [out] long* plSkipLen); + [in] LONG lSrcPos, + [in] LONG lSrcLen, + [in] LONG cMinColumns, + [in] LONG cMaxColumns, + [out] LONG* plLineLen, + [out] LONG* plSkipLen); HRESULT BreakLineW( [in] LCID locale, [in, size_is(cchSrc)] const WCHAR* pszSrc, - [in] long cchSrc, - [in] long cMaxColumns, - [out] long* pcchLine, - [out] long* pcchSkip ); + [in] LONG cchSrc, + [in] LONG cMaxColumns, + [out] LONG* pcchLine, + [out] LONG* pcchSkip ); HRESULT BreakLineA( [in] LCID locale, [in] UINT uCodePage, [in, size_is(cchSrc)] const CHAR* pszSrc, - [in] long cchSrc, - [in] long cMaxColumns, - [out] long* pcchLine, - [out] long* pcchSkip); + [in] LONG cchSrc, + [in] LONG cMaxColumns, + [out] LONG* pcchLine, + [out] LONG* pcchSkip); } [ diff --git a/reactos/include/psdk/mscoree.idl b/reactos/include/psdk/mscoree.idl index aed31da4bdf..19749fbfba3 100644 --- a/reactos/include/psdk/mscoree.idl +++ b/reactos/include/psdk/mscoree.idl @@ -27,7 +27,11 @@ cpp_quote("HRESULT WINAPI GetCORSystemDirectory(LPWSTR,DWORD,DWORD*);") cpp_quote("HRESULT WINAPI GetCORVersion(LPWSTR,DWORD,DWORD*);") cpp_quote("HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR,LPCWSTR,LPCWSTR,DWORD,DWORD,LPWSTR,DWORD,DWORD*,LPWSTR,DWORD,DWORD*);") cpp_quote("HRESULT WINAPI LoadLibraryShim(LPCWSTR,LPCWSTR,LPVOID,HMODULE*);") +cpp_quote("#ifdef WINE_STRICT_PROTOTYPES") +cpp_quote("typedef HRESULT (__stdcall *FLockClrVersionCallback)(void);") +cpp_quote("#else") cpp_quote("typedef HRESULT (__stdcall *FLockClrVersionCallback)();") +cpp_quote("#endif") cpp_quote("HRESULT WINAPI LockClrVersion(FLockClrVersionCallback,FLockClrVersionCallback*,FLockClrVersionCallback*);") typedef void* HDOMAINENUM; diff --git a/reactos/include/psdk/msctf.idl b/reactos/include/psdk/msctf.idl index e98df4d8e3c..fcb568e0a49 100644 --- a/reactos/include/psdk/msctf.idl +++ b/reactos/include/psdk/msctf.idl @@ -24,11 +24,6 @@ import "ctfutb.idl"; #endif cpp_quote("#include ") -/* FIXME: LANGID is defined in winnt.h and mlang.h in the platform SDK */ -cpp_quote("#ifndef _WINNT_H") -typedef WORD LANGID; -cpp_quote("#endif") - cpp_quote("#define TF_E_STACKFULL MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0501)") cpp_quote("#define TF_E_DISCONNECTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0504)") cpp_quote("#define TF_E_ALREADY_EXISTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0506)") diff --git a/reactos/include/psdk/objidl.idl b/reactos/include/psdk/objidl.idl index e54fb1c7446..70f93ab3179 100644 --- a/reactos/include/psdk/objidl.idl +++ b/reactos/include/psdk/objidl.idl @@ -907,7 +907,7 @@ interface IStorage : IUnknown [call_as(OpenStream)] HRESULT RemoteOpenStream( [in] LPCOLESTR pwcsName, - [in] ULONG cbReserved1, + [in] unsigned long cbReserved1, [in, unique, size_is(cbReserved1)] byte *reserved1, [in] DWORD grfMode, [in] DWORD reserved2, @@ -955,7 +955,7 @@ interface IStorage : IUnknown [call_as(EnumElements)] HRESULT RemoteEnumElements( [in] DWORD reserved1, - [in] ULONG cbReserved2, + [in] unsigned long cbReserved2, [in, unique, size_is(cbReserved2)] byte *reserved2, [in] DWORD reserved3, [out] IEnumSTATSTG **ppenum); @@ -1950,6 +1950,9 @@ interface IClientSecurity : IUnknown void *pAuthInfo; } SOLE_AUTHENTICATION_INFO; + const OLECHAR *COLE_DEFAULT_PRINCIPAL = (OLECHAR*) -1; + const void *COLE_DEFAULT_AUTHINFO = (void*) -1; + typedef struct tagSOLE_AUTHENTICATION_LIST { DWORD cAuthInfo; SOLE_AUTHENTICATION_INFO *aAuthInfo; diff --git a/reactos/include/psdk/oledb.idl b/reactos/include/psdk/oledb.idl index dd6b2181307..127df2b4906 100644 --- a/reactos/include/psdk/oledb.idl +++ b/reactos/include/psdk/oledb.idl @@ -15,14 +15,53 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +cpp_quote("#ifdef _WIN64") +cpp_quote("#include ") +cpp_quote("#else") +cpp_quote("#include ") +cpp_quote("#endif") +cpp_quote("") import "wtypes.idl"; import "oaidl.idl"; import "ocidl.idl"; import "propidl.idl"; +import "urlmon.idl"; typedef ULONG DBBYTEOFFSET; +typedef LONG DBROWOFFSET; +typedef LONG DBROWCOUNT; +typedef ULONG DBCOUNTITEM; +typedef ULONG DBLENGTH; +typedef ULONG DBORDINAL; +typedef ULONG DBBKMARK; +typedef DWORD DB_DWRESERVE; +typedef ULONG DBREFCOUNT; +typedef ULONG DB_UPARAMS; +typedef LONG DB_LPARAMS; +typedef DWORD DBHASHVALUE; -#include "dbinit.idl" #include "dbs.idl" + +#include "access.idl" +#include "rstbas.idl" +#include "rstinf.idl" +#include "rstloc.idl" +#include "cmdbas.idl" +#include "cmdtxt.idl" +#include "dbccmd.idl" +#include "dbcses.idl" #include "dbprop.idl" +#include "dbinit.idl" +#include "dbdsad.idl" +#include "asynot.idl" +#include "asysta.idl" +#include "sesprp.idl" +#include "opnrst.idl" +#include "row.idl" +#include "rowchg.idl" +#include "binres.idl" +#include "crtrow.idl" + +cpp_quote("#include ") +cpp_quote("") diff --git a/reactos/include/psdk/opnrst.idl b/reactos/include/psdk/opnrst.idl new file mode 100644 index 00000000000..e6b5237ee57 --- /dev/null +++ b/reactos/include/psdk/opnrst.idl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a69-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IOpenRowset : IUnknown +{ + [local] + HRESULT OpenRowset([in] IUnknown *pUnkOuter, + [in, unique] DBID *pTableID, + [in, unique] DBID *pIndexID, + [in] REFIID riid, + [in] ULONG cPropertySets, + [in, out, size_is(cPropertySets)] DBPROPSET rgPropertySets[], + [out, iid_is(riid)] IUnknown **ppRowset); + + [call_as(OpenRowset)] + HRESULT RemoteOpenRowset([in] IUnknown *pUnkOuter, + [in, unique] DBID *pTableID, + [in, unique] DBID *pIndexID, + [in] REFIID riid, + [in] ULONG cPropertySets, + [in, unique, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [in, out, unique, iid_is(riid)] IUnknown **ppRowset, + [in] ULONG cTotalProps, + [out, size_is(cTotalProps)] DBPROPSTATUS *rgPropStatus, + [out] IErrorInfo **ppErrorInfoRem); + +} diff --git a/reactos/include/psdk/propidl.idl b/reactos/include/psdk/propidl.idl index be673943d9a..e2da625fb44 100644 --- a/reactos/include/psdk/propidl.idl +++ b/reactos/include/psdk/propidl.idl @@ -206,7 +206,17 @@ interface IPropertyStorage : IUnknown typedef struct tagPROPVARIANT *LPPROPVARIANT; - cpp_quote("#define REFPROPVARIANT const PROPVARIANT *") + cpp_quote("#if 0") + typedef const PROPVARIANT * REFPROPVARIANT; + cpp_quote("#endif") + cpp_quote("#ifndef _REFPROPVARIANT_DEFINED") + cpp_quote("#define _REFPROPVARIANT_DEFINED") + cpp_quote("#ifdef __cplusplus") + cpp_quote("#define REFPROPVARIANT const PROPVARIANT &") + cpp_quote("#else") + cpp_quote("#define REFPROPVARIANT const PROPVARIANT * __MIDL_CONST") + cpp_quote("#endif") + cpp_quote("#endif") cpp_quote("#define PIDDI_THUMBNAIL 0x00000002L /* VT_BLOB */") cpp_quote("") diff --git a/reactos/include/psdk/row.idl b/reactos/include/psdk/row.idl new file mode 100644 index 00000000000..59df27948a5 --- /dev/null +++ b/reactos/include/psdk/row.idl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + local, + object, + uuid(0c733ab4-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRow : IUnknown +{ + [local] + HRESULT GetColumns([in] DBORDINAL cColumns, + [in, out, size_is(cColumns), annotation("__inout_ecount(cColumns)")] DBCOLUMNACCESS rgColumns[]); + + + HRESULT GetSourceRowset([in, annotation("__in")] REFIID riid, + [out, iid_is(riid), annotation("__deref_opt_out_opt")] IUnknown **ppRowset, + [out, annotation("__out_opt")] HROW *phRow); + + HRESULT Open([in, unique, annotation("__in_opt")] IUnknown *pUnkOuter, + [in, annotation("__in")] DBID *pColumnID, + [in, annotation("__in")] REFGUID rguidColumnType, + [in] DWORD dwBindFlags, + [in, annotation("__in")] REFIID riid, + [out, iid_is(riid), annotation("__deref_opt_out")] IUnknown **ppUnk); +} diff --git a/reactos/include/psdk/rowchg.idl b/reactos/include/psdk/rowchg.idl new file mode 100644 index 00000000000..86c7ad49655 --- /dev/null +++ b/reactos/include/psdk/rowchg.idl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + local, + object, + uuid(0c733ab5-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRowChange : IUnknown +{ + [local] + HRESULT SetColumns([in] DBORDINAL cColumns, + [in, out, size_is(cColumns), annotation("__in_ecount(cColumns)")] DBCOLUMNACCESS rgColumns[]); +} diff --git a/reactos/include/psdk/rstbas.idl b/reactos/include/psdk/rstbas.idl new file mode 100644 index 00000000000..d7859ed5085 --- /dev/null +++ b/reactos/include/psdk/rstbas.idl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + local, + object, + uuid(0c733a7c-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRowset : IUnknown +{ + typedef DWORD DBROWOPTIONS; + + HRESULT AddRefRows([in] DBCOUNTITEM cRows, + [in, size_is(cRows)] const HROW rghRows[], + [out, size_is(cRows)] DBREFCOUNT rgRefCounts[], + [out, size_is(cRows)] DBROWSTATUS rgRowStatus[]); + + HRESULT GetData([in] HROW hRow, + [in] HACCESSOR hAccessor, + [out] void *pData); + + HRESULT GetNextRows([in] HCHAPTER hReserved, + [in] DBROWOFFSET lRowsOffset, + [in] DBROWCOUNT cRows, + [out] DBCOUNTITEM *pcRowObtained, + [out, size_is(,cRows)] HROW **prghRows); + + HRESULT ReleaseRows([in] DBCOUNTITEM cRows, + [in, size_is(cRows)] const HROW rghRows[], + [in, size_is(cRows)] DBROWOPTIONS rgRowOptions[], + [out, size_is(cRows)] DBREFCOUNT rgRefCounts[], + [out, size_is(cRows)] DBROWSTATUS rgRowStatus[]); + + HRESULT RestartPosition([in] HCHAPTER hReserved); +} diff --git a/reactos/include/psdk/rstinf.idl b/reactos/include/psdk/rstinf.idl new file mode 100644 index 00000000000..16d269377a0 --- /dev/null +++ b/reactos/include/psdk/rstinf.idl @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a55-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRowsetInfo : IUnknown +{ + [local] + HRESULT GetProperties([in] const ULONG cPropertyIDSets, + [in, size_is(cPropertyIDSets), annotation("__in_ecount_opt(cPropertyIDSets)")] const DBPROPIDSET rgPropertyIDSets[], + [in, out, annotation("__out")] ULONG *pcPropertySets, + [out, size_is(,*pcPropertySets), annotation("__deref_out_ecount_opt(*pcPropertySets)")] DBPROPSET **prgPropertySets); + + [call_as(GetProperties)] + HRESULT RemoteGetProperties([in] ULONG cPropertyIDSets, + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, + [in, out] ULONG *pcPropertySets, + [out, size_is(,*pcPropertySets)] DBPROPSET **prgPropertySets, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT GetReferencedRowset([in] DBORDINAL iOrdinal, + [in, annotation("__in")] REFIID riid, + [out, iid_is(riid), annotation("deref_out_opt")] IUnknown **ppReferencedRowset); + + [call_as(GetReferencedRowset)] + HRESULT RemoteGetReferencedRowset([in] DBORDINAL iOrdinal, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppReferencedRowset, + [out] IErrorInfo **ppErrorInfoRem); + [local] + HRESULT GetSpecification([in, annotation("__in")] REFIID riid, + [out, iid_is(riid), annotation("__deref_out_opt")] IUnknown **ppSpecification); + + [call_as(GetSpecification)] + HRESULT RemoteGetSpecification([in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppSpecification, + [out] IErrorInfo **ppErrorInfoRem); + +} diff --git a/reactos/include/psdk/rstloc.idl b/reactos/include/psdk/rstloc.idl new file mode 100644 index 00000000000..f579581c367 --- /dev/null +++ b/reactos/include/psdk/rstloc.idl @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + local, + object, + uuid(0c733a7d-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRowsetLocate : IRowset +{ + typedef DWORD DBCOMPARE; + + enum DBCOMPAREENUM + { + DBCOMPARE_LT, + DBCOMPARE_EQ, + DBCOMPARE_GT, + DBCOMPARE_NE, + DBCOMPARE_NOTCOMPARABLE + }; + + HRESULT Compare([in] HCHAPTER hReserved, + [in] DBBKMARK cbBookmark1, + [in, size_is(cbBookmark1)] const BYTE *pBookmark1, + [in] DBBKMARK cbBookmark2, + [in, size_is(cbBookmark2)] const BYTE *pBookmark2, + [out] DBCOMPARE *pComparison); + + HRESULT GetRowsAt([in] HWATCHREGION hReserved1, + [in] HCHAPTER hReserved2, + [in] DBBKMARK cbBookmark, + [in, size_is(cbBookmark)] const BYTE *pBookmark, + [in] DBROWOFFSET lRowsOffset, + [in] DBROWCOUNT cRows, + [out] DBCOUNTITEM *pcRowsObtained, + [out, size_is(,cRows)] HROW **prghRows); + + HRESULT GetRowsByBookmark([in] HCHAPTER hReserved, + [in] DBCOUNTITEM cRows, + [in, size_is(cRows)] const DBBKMARK rgcbBookmarks[], + [in, size_is(cRows)] const BYTE *rgpBookmarks[], + [out, size_is(cRows)] HROW rghRows[], + [out, size_is(cRows)] DBROWSTATUS rgRowStatus[]); + + HRESULT Hash([in] HCHAPTER hReserved, + [in] DBBKMARK cBookmarks, + [in, size_is(cBookmarks)] const DBBKMARK rgcbBookmarks[], + [in, size_is(cBookmarks)] const BYTE *rgpBookmarks[], + [out, size_is(cBookmarks)] DBHASHVALUE rgHashedValues[], + [out, size_is(cBookmarks)] DBROWSTATUS rgBookmarkStatus[]); +} diff --git a/reactos/include/psdk/sensevts.idl b/reactos/include/psdk/sensevts.idl index ec018a95c66..1ecb9f77f73 100644 --- a/reactos/include/psdk/sensevts.idl +++ b/reactos/include/psdk/sensevts.idl @@ -28,6 +28,7 @@ typedef struct SENS_QOCINFO [ object, + uuid(d597bab1-5b9f-11d1-8dd2-00aa004abd5e), pointer_default(unique) ] interface ISensNetwork : IDispatch @@ -55,6 +56,7 @@ interface ISensNetwork : IDispatch [ object, + uuid(d597bab2-5b9f-11d1-8dd2-00aa004abd5e), pointer_default(unique) ] interface ISensOnNow : IDispatch @@ -68,6 +70,7 @@ interface ISensOnNow : IDispatch [ object, + uuid(d597bab3-5b9f-11d1-8dd2-00aa004abd5e), pointer_default(unique) ] interface ISensLogon : IDispatch @@ -90,6 +93,7 @@ interface ISensLogon : IDispatch [ object, + uuid(d597bab4-5b9f-11d1-8dd2-00aa004abd5e), pointer_default(unique) ] interface ISensLogon2 : IDispatch diff --git a/reactos/include/psdk/sesprp.idl b/reactos/include/psdk/sesprp.idl new file mode 100644 index 00000000000..d621be18a3a --- /dev/null +++ b/reactos/include/psdk/sesprp.idl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a85-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface ISessionProperties : IUnknown +{ + [local] + HRESULT GetProperties([in] ULONG cPropertyIDSets, + [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], + [in, out] ULONG *pcPropertySets, + [out, size_is(,*pcPropertySets)] DBPROPSET **prgPropertySets); + + [call_as(GetProperties)] + HRESULT RemoteGetProperties([in] ULONG cPropertyIDSets, + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, + [in, out] ULONG *pcPropertySets, + [out, size_is(,*pcPropertySets)] DBPROPSET **prgPropertySets, + [out] IErrorInfo **ppErrorInfoRem); + + + [local] + HRESULT SetProperties([in] ULONG cPropertySets, + [in, out, unique, size_is(cPropertySets)] DBPROPSET rgPropertySets[]); + + [call_as(SetProperties)] + HRESULT RemoteSetProperties([in] ULONG cPropertySets, + [in, unique, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [in] ULONG cTotalProps, + [out, size_is(cTotalProps)] DBPROPSTATUS *rgPropStatus, + [out] IErrorInfo **ppErrorInfoRem); + +} diff --git a/reactos/include/psdk/shlobj.h b/reactos/include/psdk/shlobj.h index 3f12542304f..3db28371e6b 100644 --- a/reactos/include/psdk/shlobj.h +++ b/reactos/include/psdk/shlobj.h @@ -78,9 +78,11 @@ DECLARE_HANDLE(HPSXA); #endif UINT WINAPI SHAddFromPropSheetExtArray(HPSXA,LPFNADDPROPSHEETPAGE,LPARAM); -LPVOID WINAPI SHAlloc(ULONG); +LPVOID WINAPI SHAlloc(ULONG) __WINE_ALLOC_SIZE(1); HRESULT WINAPI SHCoCreateInstance(LPCWSTR,const CLSID*,IUnknown*,REFIID,LPVOID*); HPSXA WINAPI SHCreatePropSheetExtArray(HKEY,LPCWSTR,UINT); +HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY,LPCWSTR,UINT,IDataObject*); +HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**); DWORD WINAPI SHCLSIDFromStringA(LPCSTR,CLSID*); DWORD WINAPI SHCLSIDFromStringW(LPCWSTR,CLSID*); #define SHCLSIDFromString WINELIB_NAME_AW(SHCLSIDFromString) @@ -100,6 +102,10 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST,LPWSTR); INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST); HRESULT WINAPI SHILCreateFromPath(LPCWSTR,LPITEMIDLIST*,DWORD*); HRESULT WINAPI SHLoadOLE(LPARAM); +HRESULT WINAPI SHParseDisplayName(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*); +HRESULT WINAPI SHPathPrepareForWriteA(HWND,IUnknown*,LPCSTR,DWORD); +HRESULT WINAPI SHPathPrepareForWriteW(HWND,IUnknown*,LPCWSTR,DWORD); +#define SHPathPrepareForWrite WINELIB_NAME_AW(SHPathPrepareForWrite); UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA,UINT,LPFNADDPROPSHEETPAGE,LPARAM); LPITEMIDLIST WINAPI SHSimpleIDListFromPath(LPCWSTR); int WINAPI SHMapPIDLToSystemImageListIndex(IShellFolder*,LPCITEMIDLIST,int*); @@ -110,16 +116,26 @@ INT WINAPI PickIconDlg(HWND,LPWSTR,UINT,int *); #define SHUpdateImage WINELIB_NAME_AW(SHUpdateImage) int WINAPI RestartDialog(HWND,LPCWSTR,DWORD); int WINAPI RestartDialogEx(HWND,LPCWSTR,DWORD,DWORD); +BOOL WINAPI IsUserAnAdmin(void); -#define SHFMT_ERROR 0xFFFFFFFFL /* Error on last format, drive may be formatable */ -#define SHFMT_CANCEL 0xFFFFFFFEL /* Last format was canceled */ -#define SHFMT_NOFORMAT 0xFFFFFFFDL /* Drive is not formatable */ +#define SHFMT_ERROR 0xFFFFFFFFL /* Error on last format, drive may be formattable */ +#define SHFMT_CANCEL 0xFFFFFFFEL /* Last format was cancelled */ +#define SHFMT_NOFORMAT 0xFFFFFFFDL /* Drive is not formattable */ /* SHFormatDrive flags */ #define SHFMT_ID_DEFAULT 0xFFFF #define SHFMT_OPT_FULL 1 #define SHFMT_OPT_SYSONLY 2 +/* SHPathPrepareForWrite flags */ +#define SHPPFW_NONE 0x00000000 +#define SHPPFW_DIRCREATE 0x00000001 +#define SHPPFW_DEFAULT SHPPFW_DIRCREATE +#define SHPPFW_ASKDIRCREATE 0x00000002 +#define SHPPFW_IGNOREFILENAME 0x00000004 +#define SHPPFW_NOWRITECHECK 0x00000008 +#define SHPPFW_MEDIACHECKONLY 0x00000010 + /* SHObjectProperties flags */ #define SHOP_PRINTERNAME 0x01 #define SHOP_FILEPATH 0x02 @@ -141,54 +157,168 @@ int WINAPI PathCleanupSpec(LPCWSTR,LPWSTR); /* DATAOBJECT_InitShellIDList*/ -#define CFSTR_SHELLIDLIST "Shell IDList Array" /* CF_IDLIST */ +#define CFSTR_SHELLIDLISTA "Shell IDList Array" /* CF_IDLIST */ +#define CFSTR_SHELLIDLISTOFFSETA "Shell Object Offsets" /* CF_OBJECTPOSITIONS */ +#define CFSTR_NETRESOURCESA "Net Resource" /* CF_NETRESOURCE */ +/* DATAOBJECT_InitFileGroupDesc */ +#define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor" /* CF_FILEGROUPDESCRIPTORA */ +/* DATAOBJECT_InitFileContents*/ +#define CFSTR_FILECONTENTSA "FileContents" /* CF_FILECONTENTS */ +#define CFSTR_FILENAMEA "FileName" /* CF_FILENAMEA */ +#define CFSTR_FILENAMEMAPA "FileNameMap" /* CF_FILENAMEMAPA */ +#define CFSTR_PRINTERGROUPA "PrinterFriendlyName" /* CF_PRINTERS */ +#define CFSTR_SHELLURLA "UniformResourceLocator" +#define CFSTR_INETURLA CFSTR_SHELLURLA +#define CFSTR_PREFERREDDROPEFFECTA "Preferred DropEffect" +#define CFSTR_PERFORMEDDROPEFFECTA "Performed DropEffect" +#define CFSTR_PASTESUCCEEDEDA "Paste Succeeded" +#define CFSTR_INDRAGLOOPA "InShellDragLoop" +#define CFSTR_DRAGCONTEXTA "DragContext" +#define CFSTR_MOUNTEDVOLUMEA "MountedVolume" +#define CFSTR_PERSISTEDDATAOBJECTA "PersistedDataObject" +#define CFSTR_TARGETCLSIDA "TargetCLSID" +#define CFSTR_AUTOPLAY_SHELLIDLISTSA "Autoplay Enumerated IDList Array" +#define CFSTR_LOGICALPERFORMEDDROPEFFECTA "Logical Performed DropEffect" + +#if defined(__GNUC__) +# define CFSTR_SHELLIDLISTW \ + (const WCHAR []){ 'S','h','e','l','l',' ','I','D','L','i','s','t',' ','A','r','r','a','y',0 } +# define CFSTR_SHELLIDLISTOFFSETW \ + (const WCHAR []){ 'S','h','e','l','l',' ','O','b','j','e','c','t',' ','O','f','f','s','e','t','s',0 } +# define CFSTR_NETRESOURCESW \ + (const WCHAR []){ 'N','e','t',' ','R','e','s','o','u','r','c','e',0 } +# define CFSTR_FILEDESCRIPTORW \ + (const WCHAR []){ 'F','i','l','e','G','r','o','u','p','D','e','s','c','r','i','p','t','o','r','W',0 } +# define CFSTR_FILECONTENTSW \ + (const WCHAR []){ 'F','i','l','e','C','o','n','t','e','n','t','s',0 } +# define CFSTR_FILENAMEW \ + (const WCHAR []){ 'F','i','l','e','N','a','m','e','W',0 } +# define CFSTR_FILENAMEMAPW \ + (const WCHAR []){ 'F','i','l','e','N','a','m','e','M','a','p','W',0 } +# define CFSTR_PRINTERGROUPW \ + (const WCHAR []){ 'P','r','i','n','t','e','r','F','r','i','e','n','d','l','y','N','a','m','e',0 } +# define CFSTR_SHELLURLW \ + (const WCHAR []){ 'U','n','i','f','o','r','m','R','e','s','o','u','r','c','e','L','o','c','a','t','o','r',0 } +# define CFSTR_INETURLW \ + (const WCHAR []){ 'U','n','i','f','o','r','m','R','e','s','o','u','r','c','e','L','o','c','a','t','o','r','W',0 } +# define CFSTR_PREFERREDDROPEFFECTW \ + (const WCHAR []){ 'P','r','e','f','e','r','r','e','d',' ','D','r','o','p','E','f','f','e','c','t',0 } +# define CFSTR_PERFORMEDDROPEFFECTW \ + (const WCHAR []){ 'P','e','r','f','o','r','m','e','d',' ','D','r','o','p','E','f','f','e','c','t',0 } +# define CFSTR_PASTESUCCEEDEDW \ + (const WCHAR []){ 'P','a','s','t','e',' ','S','u','c','c','e','e','d','e','d',0 } +# define CFSTR_INDRAGLOOPW \ + (const WCHAR []){ 'I','n','S','h','e','l','l','D','r','a','g','L','o','o','p',0 } +# define CFSTR_DRAGCONTEXTW \ + (const WCHAR []){ 'D','r','a','g','C','o','n','t','e','x','t',0 } +# define CFSTR_MOUNTEDVOLUMEW \ + (const WCHAR []){ 'M','o','u','n','t','e','d','V','o','l','u','m','e',0 } +# define CFSTR_PERSISTEDDATAOBJECTW \ + (const WCHAR []){ 'P','e','r','s','i','s','t','e','d','D','a','t','a','O','b','j','e','c','t',0 } +# define CFSTR_TARGETCLSIDW \ + (const WCHAR []){ 'T','a','r','g','e','t','C','L','S','I','D',0 } +# define CFSTR_AUTOPLAY_SHELLIDLISTSW \ + (const WCHAR []){ 'A','u','t','o','p','l','a','y',' ','E','n','u','m','e','r','a','t','e','d',\ + ' ','I','D','L','i','s','t',' ','A','r','r','a','y',0 } +# define CFSTR_LOGICALPERFORMEDDROPEFFECTW \ + (const WCHAR []){ 'L','o','g','i','c','a','l',' ','P','e','r','f','o','r','m','e','d',\ + ' ','D','r','o','p','E','f','f','e','c','t',0 } +#elif defined(_MSC_VER) +# define CFSTR_SHELLIDLISTW L"Shell IDList Array" +# define CFSTR_SHELLIDLISTOFFSETW L"Shell Object Offsets" +# define CFSTR_NETRESOURCESW L"Net Resource" +# define CFSTR_FILEDESCRIPTORW L"FileGroupDescriptorW" +# define CFSTR_FILECONTENTSW L"FileContents" +# define CFSTR_FILENAMEW L"FileNameW" +# define CFSTR_FILENAMEMAPW L"FileNameMapW" +# define CFSTR_PRINTERGROUPW L"PrinterFriendlyName" +# define CFSTR_SHELLURLW L"UniformResourceLocator" +# define CFSTR_INETURLW L"UniformResourceLocatorW" +# define CFSTR_PREFERREDDROPEFFECTW L"Preferred DropEffect" +# define CFSTR_PERFORMEDDROPEFFECTW L"Performed DropEffect" +# define CFSTR_PASTESUCCEEDEDW L"Paste Succeeded" +# define CFSTR_INDRAGLOOPW L"InShellDragLoop" +# define CFSTR_DRAGCONTEXTW L"DragContext" +# define CFSTR_MOUNTEDVOLUMEW L"MountedVolume" +# define CFSTR_PERSISTEDDATAOBJECTW L"PersistedDataObject" +# define CFSTR_TARGETCLSIDW L"TargetCLSID" +# define CFSTR_AUTOPLAY_SHELLIDLISTSW L"Autoplay Enumerated IDList Array" +# define CFSTR_LOGICALPERFORMEDDROPEFFECTW L"Logical Performed DropEffect" +#else +static const WCHAR CFSTR_SHELLIDLISTW[] = + { 'S','h','e','l','l',' ','I','D','L','i','s','t',' ','A','r','r','a','y',0 }; +static const WCHAR CFSTR_SHELLIDLISTOFFSETW[] = + { 'S','h','e','l','l',' ','O','b','j','e','c','t',' ','O','f','f','s','e','t','s',0 }; +static const WCHAR CFSTR_NETRESOURCESW[] = + { 'N','e','t',' ','R','e','s','o','u','r','c','e',0 }; +static const WCHAR CFSTR_FILEDESCRIPTORW[] = + { 'F','i','l','e','G','r','o','u','p','D','e','s','c','r','i','p','t','o','r','W',0 }; +static const WCHAR CFSTR_FILECONTENTSW[] = + { 'F','i','l','e','C','o','n','t','e','n','t','s',0 }; +static const WCHAR CFSTR_FILENAMEW[] = + { 'F','i','l','e','N','a','m','e','W',0 }; +static const WCHAR CFSTR_FILENAMEMAPW[] = + { 'F','i','l','e','N','a','m','e','M','a','p','W',0 }; +static const WCHAR CFSTR_PRINTERGROUPW[] = + { 'P','r','i','n','t','e','r','F','r','i','e','n','d','l','y','N','a','m','e',0 }; +static const WCHAR CFSTR_SHELLURLW[] = + { 'U','n','i','f','o','r','m','R','e','s','o','u','r','c','e','L','o','c','a','t','o','r',0 }; +static const WCHAR CFSTR_INETURLW[] = + { 'U','n','i','f','o','r','m','R','e','s','o','u','r','c','e','L','o','c','a','t','o','r','W',0 }; +static const WCHAR CFSTR_PREFERREDDROPEFFECTW[] = + { 'P','r','e','f','e','r','r','e','d',' ','D','r','o','p','E','f','f','e','c','t',0 }; +static const WCHAR CFSTR_PERFORMEDDROPEFFECTW[] = + { 'P','e','r','f','o','r','m','e','d',' ','D','r','o','p','E','f','f','e','c','t',0 }; +static const WCHAR CFSTR_PASTESUCCEEDEDW[] = + { 'P','a','s','t','e',' ','S','u','c','c','e','e','d','e','d',0 }; +static const WCHAR CFSTR_INDRAGLOOPW[] = + { 'I','n','S','h','e','l','l','D','r','a','g','L','o','o','p',0 }; +static const WCHAR CFSTR_DRAGCONTEXTW[] = + { 'D','r','a','g','C','o','n','t','e','x','t',0 }; +static const WCHAR CFSTR_MOUNTEDVOLUMEW[] = + { 'M','o','u','n','t','e','d','V','o','l','u','m','e',0 }; +static const WCHAR CFSTR_PERSISTEDDATAOBJECTW[] = + { 'P','e','r','s','i','s','t','e','d','D','a','t','a','O','b','j','e','c','t',0 }; +static const WCHAR CFSTR_TARGETCLSIDW[] = + { 'T','a','r','g','e','t','C','L','S','I','D',0 }; +static const WCHAR CFSTR_AUTOPLAY_SHELLIDLISTSW[] = + { 'A','u','t','o','p','l','a','y',' ','E','n','u','m','e','r','a','t','e','d', + ' ','I','D','L','i','s','t',' ','A','r','r','a','y',0 }; +static const WCHAR CFSTR_LOGICALPERFORMEDDROPEFFECTW[] = + { 'L','o','g','i','c','a','l',' ','P','e','r','f','o','r','m','e','d', + ' ','D','r','o','p','E','f','f','e','c','t',0 }; +#endif + +#define CFSTR_SHELLIDLIST WINELIB_NAME_AW(CFSTR_SHELLIDLIST) +#define CFSTR_SHELLIDLISTOFFSET WINELIB_NAME_AW(CFSTR_SHELLIDLISTOFFSET) +#define CFSTR_NETRESOURCES WINELIB_NAME_AW(CFSTR_NETRESOURCES) +#define CFSTR_FILEDESCRIPTOR WINELIB_NAME_AW(CFSTR_FILEDESCRIPTOR) +#define CFSTR_FILECONTENTS WINELIB_NAME_AW(CFSTR_FILECONTENTS) +#define CFSTR_FILENAME WINELIB_NAME_AW(CFSTR_FILENAME) +#define CFSTR_FILENAMEMAP WINELIB_NAME_AW(CFSTR_FILENAMEMAP) +#define CFSTR_PRINTERGROUP WINELIB_NAME_AW(CFSTR_PRINTERGROUP) +#define CFSTR_SHELLURL WINELIB_NAME_AW(CFSTR_SHELLURL) +#define CFSTR_INETURL WINELIB_NAME_AW(CFSTR_INETURL) +#define CFSTR_PREFERREDDROPEFFECT WINELIB_NAME_AW(CFSTR_PREFERREDDROPEFFECT) +#define CFSTR_PERFORMEDDROPEFFECT WINELIB_NAME_AW(CFSTR_PERFORMEDDROPEFFECT) +#define CFSTR_PASTESUCCEEDED WINELIB_NAME_AW(CFSTR_PASTESUCCEEDED) +#define CFSTR_INDRAGLOOP WINELIB_NAME_AW(CFSTR_INDRAGLOOP) +#define CFSTR_DRAGCONTEXT WINELIB_NAME_AW(CFSTR_DRAGCONTEXT) +#define CFSTR_MOUNTEDVOLUME WINELIB_NAME_AW(CFSTR_MOUNTEDVOLUME) +#define CFSTR_PERSISTEDDATAOBJECT WINELIB_NAME_AW(CFSTR_PERSISTEDDATAOBJECT) +#define CFSTR_TARGETCLSID WINELIB_NAME_AW(CFSTR_TARGETCLSID) +#define CFSTR_AUTOPLAY_SHELLIDLISTS WINELIB_NAME_AW(CFSTR_AUTOPLAY_SHELLIDLISTS) +#define CFSTR_LOGICALPERFORMEDDROPEFFECT WINELIB_NAME_AW(CFSTR_LOGICALPERFORMEDDROPEFFECT) typedef struct { UINT cidl; UINT aoffset[1]; } CIDA, *LPIDA; -#define CFSTR_SHELLIDLISTA "Shell IDList Array" /* CF_IDLIST */ -#define CFSTR_SHELLIDLISTOFFSET "Shell Object Offsets" /* CF_OBJECTPOSITIONS */ -#define CFSTR_NETRESOURCES "Net Resource" /* CF_NETRESOURCE */ - -/* DATAOBJECT_InitFileGroupDesc */ -#define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor" /* CF_FILEGROUPDESCRIPTORA */ - -#define CFSTR_FILEDESCRIPTORW "FileGroupDescriptorW" /* CF_FILEGROUPDESCRIPTORW */ - -/* DATAOBJECT_InitFileContents*/ -#define CFSTR_FILECONTENTS "FileContents" /* CF_FILECONTENTS */ - -#ifdef UNICODE -#define CFSTR_FILENAME L"FileNameW" -#define CFSTR_FILENAMEMAP L"FileNameMapW" -#define CFSTR_FILEDESCRIPTOR L"FileGroupDescriptorW" -#define CFSTR_SHELLURL L"UniformResourceLocatorW" -#else -#define CFSTR_FILENAME "FileName" -#define CFSTR_FILENAMEMAP "FileNameMap" -#define CFSTR_FILEDESCRIPTOR "FileGroupDescriptor" -#define CFSTR_SHELLURL "UniformResourceLocator" -#endif - -#define CFSTR_FILENAMEW "FileNameW" -#define CFSTR_FILENAMEA "FileName" -#define CFSTR_FILENAMEMAPA "FileNameMap" /* CF_FILENAMEMAPA */ -#define CFSTR_FILENAMEMAPW "FileNameMapW" /* CF_FILENAMEMAPW */ - -#define CFSTR_PRINTERGROUP "PrinterFriendlyName" /* CF_PRINTERS */ -#define CFSTR_PREFERREDDROPEFFECT "Preferred DropEffect" -#define CFSTR_PERFORMEDDROPEFFECT "Performed DropEffect" -#define CFSTR_PASTESUCCEEDED "Paste Succeeded" -#define CFSTR_INDRAGLOOP "InShellDragLoop" - /************************************************************************ * IShellView interface */ -#define SV_CLASS_NAME ("SHELLDLL_DefView") - #define FCIDM_SHVIEWFIRST 0x0000 /* undocumented */ #define FCIDM_SHVIEW_ARRANGE 0x7001 @@ -252,24 +382,10 @@ typedef struct #define FCIDM_STATUS (FCIDM_BROWSERFIRST + 1) -VOID WINAPI SHSetInstanceExplorer(LPUNKNOWN); -BOOL WINAPI IsUserAnAdmin(VOID); - /**************************************************************************** * IShellIcon interface */ -#undef INTERFACE -#define INTERFACE IShellFolderViewCB -DECLARE_INTERFACE_(IShellFolderViewCB, IUnknown) -{ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - STDMETHOD(MessageSFVCB)(THIS_ UINT uMsg, WPARAM wParam, LPARAM lParam) PURE; -}; -#undef INTERFACE - #define INTERFACE IShellIcon DECLARE_INTERFACE_(IShellIcon,IUnknown) { @@ -411,6 +527,57 @@ DECLARE_INTERFACE_(IACList,IUnknown) #define IACList_Expand(p,a) (p)->lpVtbl->Expand(p,a) #endif +/* IACList2 interface */ +#define INTERFACE IACList2 +DECLARE_INTERFACE_(IACList2,IACList) +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IACList methods ***/ + STDMETHOD(Expand)(THIS_ LPCOLESTR str) PURE; + /*** IACList2 methods ***/ + STDMETHOD(SetOptions)(THIS_ DWORD dwFlag) PURE; + STDMETHOD(GetOptions)(THIS_ DWORD* pdwFlag) PURE; +}; +#undef INTERFACE + +#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IACList2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IACList2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IACList2_Release(p) (p)->lpVtbl->Release(p) +/*** IACList2 methods ***/ +#define IACList2_GetOptions(p,a) (p)->lpVtbl->GetOptions(p,a) +#define IACList2_SetOptions(p,a) (p)->lpVtbl->SetOptions(p,a) +#endif + +/**************************************************************************** + * IShellFolderViewCB interface + */ + +#define INTERFACE IShellFolderViewCB +DECLARE_INTERFACE_(IShellFolderViewCB,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + /*** IShellFolderViewCB methods ***/ + STDMETHOD(MessageSFVCB)(THIS_ UINT uMsg, WPARAM wParam, LPARAM lParam) PURE; +}; +#undef INTERFACE + +#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IShellFolderViewCB_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IShellFolderViewCB_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IShellFolderViewCB_Release(p) (p)->lpVtbl->Release(p) +/*** IShellFolderViewCB methods ***/ +#define IShellFolderViewCB_MessageSFVCB(p,a,b,c) (p)->lpVtbl->MessageSFVCB(p,a,b,c) +#endif + /* IProgressDialog interface */ #define PROGDLG_NORMAL 0x00000000 #define PROGDLG_MODAL 0x00000001 @@ -502,15 +669,6 @@ DECLARE_INTERFACE_(IDeskBarClient,IOleWindow) void WINAPI SHAddToRecentDocs(UINT,LPCVOID); -HANDLE WINAPI SHChangeNotification_Lock( - HANDLE hChange, - DWORD dwProcessId, - LPITEMIDLIST **lppidls, - LPLONG lpwEventId); -BOOL WINAPI SHChangeNotification_Unlock ( HANDLE hLock); - - - /**************************************************************************** * SHBrowseForFolder API */ @@ -567,8 +725,9 @@ typedef struct tagBROWSEINFOW { /* message from browser */ #define BFFM_INITIALIZED 1 #define BFFM_SELCHANGED 2 -#define BFFM_VALIDATEFAILEDA 3 /* lParam:szPath ret:1(cont),0(EndDialog) */ -#define BFFM_VALIDATEFAILEDW 4 /* lParam:wzPath ret:1(cont),0(EndDialog) */ +#define BFFM_VALIDATEFAILEDA 3 +#define BFFM_VALIDATEFAILEDW 4 +#define BFFM_IUNKNOWN 5 /* messages to browser */ #define BFFM_SETSTATUSTEXTA (WM_USER+100) @@ -669,15 +828,6 @@ HRESULT WINAPI SHCreateShellFolderViewEx(LPCSFV pshfvi, IShellView **ppshv); #define SFVM_GET_WEBVIEW_THEME 86 /* undocumented */ #define SFVM_GETDEFERREDVIEWSETTINGS 92 /* undocumented */ -#define SHPPFW_NONE 0 -#define SHPPFW_DIRCREATE 1 -#define SHPPFW_DEFAULT SHPPFW_DIRCREATE -#define SHPPFW_ASKDIRCREATE 2 -#define SHPPFW_IGNOREFILENAME 4 -#define SHPPFW_NOWRITECHECK 8 - -/* Types and definitions for the SFM_* parameters */ -#include typedef struct _SFV_CREATE { UINT cbSize; @@ -686,6 +836,10 @@ typedef struct _SFV_CREATE IShellFolderViewCB *psfvcb; } SFV_CREATE; +HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pscfv, IShellView **ppsv); + +/* Types and definitions for the SFM_* parameters */ +#include #define QCMINFO_PLACE_BEFORE 0 #define QCMINFO_PLACE_AFTER 1 @@ -801,19 +955,13 @@ HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID pv, int cb); #define SHGetDataFromIDList WINELIB_NAME_AW(SHGetDataFromIDList) -PIDLIST_ABSOLUTE WINAPI SHCloneSpecialIDList(HWND hwnd, int csidl, BOOL fCreate); +LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwnd, int csidl, BOOL fCreate); BOOL WINAPI SHGetSpecialFolderPathA (HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate); BOOL WINAPI SHGetSpecialFolderPathW (HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate); #define SHGetSpecialFolderPath WINELIB_NAME_AW(SHGetSpecialFolderPath) HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal) ; -/********************************************************************** - * SHCreateShellFolderView () - */ - -HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, IShellView **ppsv); - /********************************************************************** * SHGetSetSettings () */ @@ -1147,6 +1295,10 @@ typedef enum { SLDF_NO_PIDL_ALIAS = 0x00008000, SLDF_FORCE_UNCNAME = 0x00010000, SLDF_RUN_WITH_SHIMLAYER = 0x00020000, + SLDF_FORCE_NO_LINKTRACK = 0x00040000, + SLDF_ENABLE_TARGET_METADATA = 0x00080000, + SLDF_DISABLE_KNOWNFOLDER_RELATIVE_TRACKING = 0x00200000, + SLDF_VALID = 0x003ff7ff, SLDF_RESERVED = 0x80000000, } SHELL_LINK_DATA_FLAGS; @@ -1158,41 +1310,6 @@ typedef struct tagDATABLOCKHEADER typedef struct { DATABLOCK_HEADER dbh; - WORD wFillAttribute; - WORD wPopupFillAttribute; - COORD dwScreenBufferSize; - COORD dwWindowSize; - COORD dwWindowOrigin; - DWORD nFont; - DWORD nInputBufferSize; - COORD dwFontSize; - UINT uFontFamily; - UINT uFontWeight; - WCHAR FaceName[LF_FACESIZE]; - UINT uCursorSize; - BOOL bFullScreen; - BOOL bQuickEdit; - BOOL bInsertMode; - BOOL bAutoPosition; - UINT uHistoryBufferSize; - UINT uNumberOfHistoryBuffers; - BOOL bHistoryNoDup; - COLORREF ColorTable[16]; -} NT_CONSOLE_PROPS, *LPNT_CONSOLE_PROPS; - -typedef struct { - DATABLOCK_HEADER dbh; - UINT uCodePage; -} NT_FE_CONSOLE_PROPS, *LPNT_FE_CONSOLE_PROPS; - -typedef struct { - -#ifdef __cplusplus - DATABLOCK_HEADER dbh; -#else - DWORD cbSize; - DWORD dwSignature; -#endif CHAR szDarwinID[MAX_PATH]; WCHAR szwDarwinID[MAX_PATH]; } EXP_DARWIN_LINK, *LPEXP_DARWIN_LINK; @@ -1211,13 +1328,20 @@ typedef struct { DWORD cbOffset; } EXP_SPECIAL_FOLDER, *LPEXP_SPECIAL_FOLDER; +typedef struct { + DWORD cbSize; + DWORD dwSignature; + BYTE abPropertyStorage[1]; +} EXP_PROPERTYSTORAGE; + #define EXP_SZ_LINK_SIG 0xa0000001 #define NT_CONSOLE_PROPS_SIG 0xa0000002 #define NT_FE_CONSOLE_PROPS_SIG 0xa0000004 #define EXP_SPECIAL_FOLDER_SIG 0xa0000005 #define EXP_DARWIN_ID_SIG 0xa0000006 -#define EXP_LOGO3_ID_SIG 0xa0000007 #define EXP_SZ_ICON_SIG 0xa0000007 +#define EXP_LOGO3_ID_SIG EXP_SZ_ICON_SIG /* Old SDKs only */ +#define EXP_PROPERTYSTORAGE_SIG 0xa0000009 typedef struct _SHChangeDWORDAsIDList { USHORT cb; @@ -1235,6 +1359,8 @@ typedef struct _SHChangeProductKeyAsIDList { ULONG WINAPI SHChangeNotifyRegister(HWND hwnd, int fSources, LONG fEvents, UINT wMsg, int cEntries, const SHChangeNotifyEntry *pshcne); BOOL WINAPI SHChangeNotifyDeregister(ULONG ulID); +HANDLE WINAPI SHChangeNotification_Lock(HANDLE hChangeNotification, DWORD dwProcessId, + LPITEMIDLIST **pppidl, LONG *plEvent); BOOL WINAPI SHChangeNotification_Unlock(HANDLE hLock); HRESULT WINAPI SHGetRealIDL(IShellFolder *psf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST * ppidlReal); @@ -1245,6 +1371,7 @@ HRESULT WINAPI SHGetRealIDL(IShellFolder *psf, LPCITEMIDLIST pidlSimple, LPITEMI DWORD WINAPI SHCreateDirectory(HWND, LPCWSTR); int WINAPI SHCreateDirectoryExA(HWND, LPCSTR, LPSECURITY_ATTRIBUTES); int WINAPI SHCreateDirectoryExW(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES); +#define SHCreateDirectoryEx WINELIB_NAME_AW(SHCreateDirectoryEx) /**************************************************************************** * SHGetSpecialFolderLocation API @@ -1276,7 +1403,7 @@ HRESULT WINAPI SHGetFolderPathW(HWND hwnd, int nFolder, HANDLE hToken, DWORD dwF #define CSIDL_SENDTO 0x0009 #define CSIDL_BITBUCKET 0x000a #define CSIDL_STARTMENU 0x000b -#define CSIDL_MYDOCUMENTS 0x000c +#define CSIDL_MYDOCUMENTS CSIDL_PERSONAL #define CSIDL_MYMUSIC 0x000d #define CSIDL_MYVIDEO 0x000e #define CSIDL_DESKTOPDIRECTORY 0x0010 @@ -1322,6 +1449,7 @@ HRESULT WINAPI SHGetFolderPathW(HWND hwnd, int nFolder, HANDLE hToken, DWORD dwF #define CSIDL_CDBURN_AREA 0x003b #define CSIDL_COMPUTERSNEARME 0x003d #define CSIDL_PROFILES 0x003e +#define CSIDL_FOLDER_MASK 0x00ff #define CSIDL_FLAG_PER_USER_INIT 0x0800 #define CSIDL_FLAG_NO_ALIAS 0x1000 #define CSIDL_FLAG_DONT_VERIFY 0x4000 @@ -1438,8 +1566,26 @@ BOOL WINAPI WriteCabinetState(CABINETSTATE *); /**************************************************************************** * Path Manipulation Routines */ + +/* PathProcessCommand flags */ +#define PPCF_ADDQUOTES 0x01 +#define PPCF_INCLUDEARGS 0x02 +#define PPCF_ADDARGUMENTS 0x03 +#define PPCF_NODIRECTORIES 0x10 +#define PPCF_DONTRESOLVE 0x20 +#define PPCF_FORCEQUALIFY 0x40 +#define PPCF_LONGESTPOSSIBLE 0x80 + +/* PathResolve flags */ +#define PRF_VERIFYEXISTS 0x01 +#define PRF_EXECUTABLE 0x02 +#define PRF_TRYPROGRAMEXTENSIONS 0x03 +#define PRF_FIRSTDIRDEF 0x04 +#define PRF_DONTFINDLINK 0x08 + VOID WINAPI PathGetShortPath(LPWSTR pszPath); LONG WINAPI PathProcessCommand(LPCWSTR, LPWSTR, int, DWORD); +BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR, LPCWSTR, LPCWSTR, LPCWSTR); /**************************************************************************** * Drag And Drop Routines @@ -1515,7 +1661,6 @@ HRESULT WINAPI SHCreateDefaultContextMenu(const DEFCONTEXTMENU *,REFIID,void **p typedef HRESULT (CALLBACK * LPFNDFMCALLBACK)(IShellFolder*,HWND,IDataObject*,UINT,WPARAM,LPARAM); HRESULT WINAPI CDefFolderMenu_Create2(LPCITEMIDLIST,HWND,UINT,LPCITEMIDLIST*,IShellFolder*,LPFNDFMCALLBACK,UINT,const HKEY *,IContextMenu **); - /**************************************************************************** * SHCreateDefaultContextMenu API */ @@ -1524,7 +1669,6 @@ HRESULT WINAPI SHCreateDefaultExtractIcon( REFIID riid, void **ppv); - /**************************************************************************** * SHCreateDataObject API */ diff --git a/reactos/include/psdk/shobjidl.idl b/reactos/include/psdk/shobjidl.idl index cd2320e7f08..221ab04d22c 100644 --- a/reactos/include/psdk/shobjidl.idl +++ b/reactos/include/psdk/shobjidl.idl @@ -323,22 +323,6 @@ interface IEnumExtraSearch : IUnknown ] interface IShellFolder2 : IShellFolder { - typedef enum - { - SHCOLSTATE_TYPE_STR = 0x00000001, - SHCOLSTATE_TYPE_INT = 0x00000002, - SHCOLSTATE_TYPE_DATE = 0x00000003, - SHCOLSTATE_TYPEMASK = 0x0000000f, - SHCOLSTATE_ONBYDEFAULT = 0x00000010, - SHCOLSTATE_SLOW = 0x00000020, - SHCOLSTATE_EXTENDED = 0x00000040, - SHCOLSTATE_SECONDARYUI = 0x00000080, - SHCOLSTATE_HIDDEN = 0x00000100, - SHCOLSTATE_PREFER_VARCMP = 0x00000200 - } SHCOLSTATE; - - typedef DWORD SHCOLSTATEF; - typedef struct { GUID fmtid; @@ -2310,6 +2294,10 @@ interface IBrowserService : IUnknown typedef BASEBROWSERDATA *LPBASEBROWSERDATA; +cpp_quote("#if 0") +typedef HANDLE HMONITOR; +cpp_quote("#endif /* 0 */") + typedef struct SToolbarItem { IDockingWindow *ptbar; diff --git a/reactos/include/psdk/shtypes.idl b/reactos/include/psdk/shtypes.idl index 3a922b83246..021d4671251 100644 --- a/reactos/include/psdk/shtypes.idl +++ b/reactos/include/psdk/shtypes.idl @@ -21,8 +21,6 @@ import "wtypes.idl"; - - cpp_quote("#include ") typedef struct { @@ -34,60 +32,13 @@ typedef const SHITEMID *LPCSHITEMID; typedef struct _ITEMIDLIST { SHITEMID mkid; /* first itemid in list */ -} ITEMIDLIST; - -cpp_quote("#if defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)") -cpp_quote("typedef struct _ITEMIDLIST_RELATIVE : ITEMIDLIST {} ITEMIDLIST_RELATIVE;") -cpp_quote("typedef struct _ITEMID_CHILD : ITEMIDLIST_RELATIVE {} ITEMID_CHILD;") -cpp_quote("typedef struct _ITEMIDLIST_ABSOLUTE : ITEMIDLIST_RELATIVE {} ITEMIDLIST_ABSOLUTE;") -cpp_quote("#else /* !(defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)) */") -typedef ITEMIDLIST ITEMIDLIST_RELATIVE; -typedef ITEMIDLIST ITEMID_CHILD; -typedef ITEMIDLIST ITEMIDLIST_ABSOLUTE; -cpp_quote("#endif /* defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus) */") - +} ITEMIDLIST,*LPITEMIDLIST; +typedef const ITEMIDLIST *LPCITEMIDLIST; +typedef LPITEMIDLIST PITEMID_CHILD; +typedef LPCITEMIDLIST PCUITEMID_CHILD; +typedef LPCITEMIDLIST *PCUITEMID_CHILD_ARRAY; cpp_quote("#include ") -typedef [unique] BYTE_BLOB * wirePIDL; -typedef ITEMIDLIST /*__unaligned*/ * LPITEMIDLIST; -typedef const ITEMIDLIST /*__unaligned*/ * LPCITEMIDLIST; - -cpp_quote("#if defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)") -typedef ITEMIDLIST_ABSOLUTE * PIDLIST_ABSOLUTE; -typedef const ITEMIDLIST_ABSOLUTE * PCIDLIST_ABSOLUTE; -typedef const ITEMIDLIST_ABSOLUTE /*__unaligned*/ * PCUIDLIST_ABSOLUTE; -typedef ITEMIDLIST_RELATIVE * PIDLIST_RELATIVE; -typedef const ITEMIDLIST_RELATIVE * PCIDLIST_RELATIVE; -typedef ITEMIDLIST_RELATIVE /*__unaligned*/ * PUIDLIST_RELATIVE; -typedef const ITEMIDLIST_RELATIVE /*__unaligned*/ * PCUIDLIST_RELATIVE; -typedef ITEMID_CHILD * PITEMID_CHILD; -typedef const ITEMID_CHILD * PCITEMID_CHILD; -typedef ITEMID_CHILD /*__unaligned*/ * PUITEMID_CHILD; -typedef const ITEMID_CHILD /*__unaligned*/ * PCUITEMID_CHILD; - -typedef PCUITEMID_CHILD const *PCUITEMID_CHILD_ARRAY; -typedef PCUIDLIST_RELATIVE const *PCUIDLIST_RELATIVE_ARRAY; -typedef PCIDLIST_ABSOLUTE const *PCIDLIST_ABSOLUTE_ARRAY; -typedef PCUIDLIST_ABSOLUTE const *PCUIDLIST_ABSOLUTE_ARRAY; -cpp_quote("#else /* !(defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)) */") -cpp_quote("#define PIDLIST_ABSOLUTE LPITEMIDLIST") -cpp_quote("#define PCIDLIST_ABSOLUTE LPCITEMIDLIST") -cpp_quote("#define PCUIDLIST_ABSOLUTE LPCITEMIDLIST") -cpp_quote("#define PIDLIST_RELATIVE LPITEMIDLIST") -cpp_quote("#define PCIDLIST_RELATIVE LPCITEMIDLIST") -cpp_quote("#define PUIDLIST_RELATIVE LPITEMIDLIST") -cpp_quote("#define PCUIDLIST_RELATIVE LPCITEMIDLIST") -cpp_quote("#define PITEMID_CHILD LPITEMIDLIST") -cpp_quote("#define PCITEMID_CHILD LPCITEMIDLIST") -cpp_quote("#define PUITEMID_CHILD LPITEMIDLIST") -cpp_quote("#define PCUITEMID_CHILD LPCITEMIDLIST") -cpp_quote("#define PCUITEMID_CHILD_ARRAY LPCITEMIDLIST *") -cpp_quote("#define PCUIDLIST_RELATIVE_ARRAY LPCITEMIDLIST *") -cpp_quote("#define PCIDLIST_ABSOLUTE_ARRAY LPCITEMIDLIST *") -cpp_quote("#define PCUIDLIST_ABSOLUTE_ARRAY LPCITEMIDLIST *") -cpp_quote("#endif /* defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus) */") - - #ifndef MAX_PATH #define MAX_PATH 260 #endif @@ -103,7 +54,7 @@ typedef enum tagSTRRET_TYPE STRRET_CSTR = 2 } STRRET_TYPE; -cpp_quote("#include ") +cpp_quote("#include ") typedef struct _STRRET { UINT uType; /* STRRET_xxx */ @@ -124,3 +75,29 @@ typedef struct STRRET str; } SHELLDETAILS, *LPSHELLDETAILS; cpp_quote("#include ") + +typedef [v1_enum] enum tagSHCOLSTATE +{ + SHCOLSTATE_DEFAULT = 0, + SHCOLSTATE_TYPE_STR, + SHCOLSTATE_TYPE_INT, + SHCOLSTATE_TYPE_DATE, + SHCOLSTATE_TYPEMASK = 0xf, + SHCOLSTATE_ONBYDEFAULT = 0x10, + SHCOLSTATE_SLOW = 0x20, + SHCOLSTATE_EXTENDED = 0x40, + SHCOLSTATE_SECONDARYUI = 0x80, + SHCOLSTATE_HIDDEN = 0x100, + SHCOLSTATE_PREFER_VARCMP = 0x200, + SHCOLSTATE_PREFER_FMTCMP = 0x400, + SHCOLSTATE_NOSORTBYFOLDERNESS = 0x800, + SHCOLSTATE_VIEWONLY = 0x10000, + SHCOLSTATE_BATCHREAD = 0x20000, + SHCOLSTATE_NO_GROUPBY = 0x40000, + SHCOLSTATE_FIXED_WIDTH = 0x1000, + SHCOLSTATE_NODPISCALE = 0x2000, + SHCOLSTATE_FIXED_RATIO = 0x4000, + SHCOLSTATE_DISPLAYMASK = 0xf000 +} SHCOLSTATE; + +typedef DWORD SHCOLSTATEF; diff --git a/reactos/include/psdk/tom.idl b/reactos/include/psdk/tom.idl index 669fbcf9e0c..35be7f70dbd 100644 --- a/reactos/include/psdk/tom.idl +++ b/reactos/include/psdk/tom.idl @@ -18,6 +18,10 @@ import "oaidl.idl"; +cpp_quote("#ifdef WINE_NO_UNICODE_MACROS") +cpp_quote("#undef FindText") +cpp_quote("#endif") + typedef enum tagTomConstants { tomFalse = 0, @@ -200,23 +204,23 @@ interface ITextDocument : IDispatch { HRESULT GetName([retval, out]BSTR *pName); HRESULT GetSelection([retval, out]ITextSelection **ppSel); - HRESULT GetStoryCount([retval, out]long *pCount); + HRESULT GetStoryCount([retval, out]LONG *pCount); HRESULT GetStoryRanges([retval, out]ITextStoryRanges **ppStories); - HRESULT GetSaved([retval, out]long *pValue); - HRESULT SetSaved([in]long Value); + HRESULT GetSaved([retval, out]LONG *pValue); + HRESULT SetSaved([in]LONG Value); HRESULT GetDefaultTabStop([retval, out]float *pValue); HRESULT SetDefaultTabStop([in]float Value); HRESULT New(); - HRESULT Open([in]VARIANT *pVar, [in]long Flags, [in]long CodePage); - HRESULT Save([in]VARIANT *pVar, [in]long Flags, [in]long CodePage); - HRESULT Freeze([retval, out]long *pCount); - HRESULT Unfreeze([retval, out]long *pCount); + HRESULT Open([in]VARIANT *pVar, [in]LONG Flags, [in]LONG CodePage); + HRESULT Save([in]VARIANT *pVar, [in]LONG Flags, [in]LONG CodePage); + HRESULT Freeze([retval, out]LONG *pCount); + HRESULT Unfreeze([retval, out]LONG *pCount); HRESULT BeginEditCollection(); HRESULT EndEditCollection(); - HRESULT Undo([in]long Count, [retval, out]long *prop); - HRESULT Redo([in]long Count, [retval, out]long *prop); - HRESULT Range([in]long cp1, [in]long cp2, [retval, out]ITextRange**ppRange); - HRESULT RangeFromPoint([in]long x, [in]long y, [retval, out]ITextRange**ppRange); + HRESULT Undo([in]LONG Count, [retval, out]LONG *prop); + HRESULT Redo([in]LONG Count, [retval, out]LONG *prop); + HRESULT Range([in]LONG cp1, [in]LONG cp2, [retval, out]ITextRange **ppRange); + HRESULT RangeFromPoint([in]LONG x, [in]LONG y, [retval, out]ITextRange **ppRange); } interface ITextFont; @@ -230,54 +234,54 @@ interface ITextRange : IDispatch { HRESULT GetText([retval, out]BSTR *pbstr); HRESULT SetText([in]BSTR bstr); - HRESULT GetChar([retval, out]long *pch); - HRESULT SetChar([in]long ch); + HRESULT GetChar([retval, out]LONG *pch); + HRESULT SetChar([in]LONG ch); HRESULT GetDuplicate([retval, out]ITextRange **ppRange); HRESULT GetFormattedText([retval, out]ITextRange **ppRange); HRESULT SetFormattedText([in]ITextRange *pRange); - HRESULT GetStart([retval, out]long *pcpFirst); - HRESULT SetStart([in]long cpFirst); - HRESULT GetEnd([retval, out]long *pcpLim); - HRESULT SetEnd([in]long cpLim); + HRESULT GetStart([retval, out]LONG *pcpFirst); + HRESULT SetStart([in]LONG cpFirst); + HRESULT GetEnd([retval, out]LONG *pcpLim); + HRESULT SetEnd([in]LONG cpLim); HRESULT GetFont([retval, out]ITextFont **pFont); HRESULT SetFont([in]ITextFont *pFont); HRESULT GetPara([retval, out]ITextPara **ppPara); HRESULT SetPara([in]ITextPara *pPara); - HRESULT GetStoryLength([retval, out]long *pcch); - HRESULT GetStoryType([retval, out]long *pValue); - HRESULT Collapse([in]long bStart); - HRESULT Expand([in]long Unit, [retval, out]long *pDelta); - HRESULT GetIndex([in]long Unit, [retval, out]long *pIndex); - HRESULT SetIndex([in]long Unit, [in]long Index, [in]long Extend); - HRESULT SetRange([in]long cpActive, [in]long cpOther); - HRESULT InRange([in]ITextRange *pRange, [retval, out]long *pb); - HRESULT InStory([in]ITextRange *pRange, [retval, out]long *pb); - HRESULT IsEqual([in]ITextRange *pRange, [retval, out]long *pb); + HRESULT GetStoryLength([retval, out]LONG *pcch); + HRESULT GetStoryType([retval, out]LONG *pValue); + HRESULT Collapse([in]LONG bStart); + HRESULT Expand([in]LONG Unit, [retval, out]LONG *pDelta); + HRESULT GetIndex([in]LONG Unit, [retval, out]LONG *pIndex); + HRESULT SetIndex([in]LONG Unit, [in]LONG Index, [in]LONG Extend); + HRESULT SetRange([in]LONG cpActive, [in]LONG cpOther); + HRESULT InRange([in]ITextRange *pRange, [retval, out]LONG *pb); + HRESULT InStory([in]ITextRange *pRange, [retval, out]LONG *pb); + HRESULT IsEqual([in]ITextRange *pRange, [retval, out]LONG *pb); HRESULT Select(); - HRESULT StartOf([in]long Unit, [in]long Extend, [retval, out]long *pDelta); - HRESULT EndOf([in]long Unit, [in]long Extend, [retval, out]long *pDelta); - HRESULT Move([in]long Unit, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveStart([in]long Unit, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveEnd([in]long Unit, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveWhile([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveStartWhile([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveEndWhile([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveUntil([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveStartUntil([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveEndUntil([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT FindText([in]BSTR bstr, [in]long cch, [in]long Flags, [retval, out]long *pLength); - HRESULT FindTextStart([in]BSTR bstr, [in]long cch, [in]long Flags, [retval, out]long *pLength); - HRESULT FindTextEnd([in]BSTR bstr, [in]long cch, [in]long Flags, [retval, out]long *pLength); - HRESULT Delete([in]long Unit, [in]long Count, [retval, out]long *pDelta); + HRESULT StartOf([in]LONG Unit, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT EndOf([in]LONG Unit, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT Move([in]LONG Unit, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveStart([in]LONG Unit, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveEnd([in]LONG Unit, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveWhile([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveStartWhile([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveEndWhile([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveUntil([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveStartUntil([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveEndUntil([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT FindText([in]BSTR bstr, [in]LONG cch, [in]LONG Flags, [retval, out]LONG *pLength); + HRESULT FindTextStart([in]BSTR bstr, [in]LONG cch, [in]LONG Flags, [retval, out]LONG *pLength); + HRESULT FindTextEnd([in]BSTR bstr, [in]LONG cch, [in]LONG Flags, [retval, out]LONG *pLength); + HRESULT Delete([in]LONG Unit, [in]LONG Count, [retval, out]LONG *pDelta); HRESULT Cut([out]VARIANT *pVar); HRESULT Copy([out]VARIANT *pVar); - HRESULT Paste([in]VARIANT *pVar, [in]long Format); - HRESULT CanPaste([in]VARIANT *pVar, [in]long Format, [retval, out]long *pb); - HRESULT CanEdit([retval, out]long *pb); - HRESULT ChangeCase([in]long Type); - HRESULT GetPoint([in]long Type, [out]long *cx, [out]long *cy); - HRESULT SetPoint([in]long x, [in]long y, [in]long Type, [in]long Extend); - HRESULT ScrollIntoView([in]long Value); + HRESULT Paste([in]VARIANT *pVar, [in]LONG Format); + HRESULT CanPaste([in]VARIANT *pVar, [in]LONG Format, [retval, out]LONG *pb); + HRESULT CanEdit([retval, out]LONG *pb); + HRESULT ChangeCase([in]LONG Type); + HRESULT GetPoint([in]LONG Type, [out]LONG *cx, [out]LONG *cy); + HRESULT SetPoint([in]LONG x, [in]LONG y, [in]LONG Type, [in]LONG Extend); + HRESULT ScrollIntoView([in]LONG Value); HRESULT GetEmbeddedObject([retval, out]IUnknown **ppv); } @@ -287,15 +291,15 @@ interface ITextRange : IDispatch ] interface ITextSelection : ITextRange { - HRESULT GetFlags([retval, out]long *pFlags); - HRESULT SetFlags([in]long Flags); - HRESULT GetType([retval, out]long *pType); - HRESULT MoveLeft([in]long Unit, [in]long Count, [in]long Extend, [retval, out]long *pDelta); - HRESULT MoveRight([in]long Unit, [in]long Count, [in]long Extend, [retval, out]long *pDelta); - HRESULT MoveUp([in]long Unit, [in]long Count, [in]long Extend, [retval, out]long *pDelta); - HRESULT MoveDown([in]long Unit, [in]long Count, [in]long Extend, [retval, out]long *pDelta); - HRESULT HomeKey([in]long Unit, [in]long Extend, [retval, out]long *pDelta); - HRESULT EndKey([in]long Unit, [in]long Extend, [retval, out]long *pDelta); + HRESULT GetFlags([retval, out]LONG *pFlags); + HRESULT SetFlags([in]LONG Flags); + HRESULT GetType([retval, out]LONG *pType); + HRESULT MoveLeft([in]LONG Unit, [in]LONG Count, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT MoveRight([in]LONG Unit, [in]LONG Count, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT MoveUp([in]LONG Unit, [in]LONG Count, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT MoveDown([in]LONG Unit, [in]LONG Count, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT HomeKey([in]LONG Unit, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT EndKey([in]LONG Unit, [in]LONG Extend, [retval, out]LONG *pDelta); HRESULT TypeText([in]BSTR bstr); } @@ -307,59 +311,59 @@ interface ITextFont : IDispatch { HRESULT GetDuplicate([retval, out]ITextFont **ppFont); HRESULT SetDuplicate([in]ITextFont *pFont); - HRESULT CanChange([out]long *pB); - HRESULT IsEqual([in]ITextFont *pFont, [retval, out]long *pB); - HRESULT Reset([in]long Value); - HRESULT GetStyle([retval, out]long *pValue); - HRESULT SetStyle([in]long Value); - HRESULT GetAllCaps([retval, out]long *pValue); - HRESULT SetAllCaps([in]long Value); - HRESULT GetAnimation([retval, out]long *pValue); - HRESULT SetAnimation([in]long Value); - HRESULT GetBackColor([retval, out]long *pValue); - HRESULT SetBackColor([in]long Value); - HRESULT GetBold([retval, out]long *pValue); - HRESULT SetBold([in]long Value); - HRESULT GetEmboss([retval, out]long *pValue); - HRESULT SetEmboss([in]long Value); - HRESULT GetForeColor([retval, out]long *pValue); - HRESULT SetForeColor([in]long Value); - HRESULT GetHidden([retval, out]long *pValue); - HRESULT SetHidden([in]long Value); - HRESULT GetEngrave([retval, out]long *pValue); - HRESULT SetEngrave([in]long Value); - HRESULT GetItalic([retval, out]long *pValue); - HRESULT SetItalic([in]long Value); - HRESULT GetKerning([retval, out]long *pValue); - HRESULT SetKerning([in]long Value); - HRESULT GetLanguageID([retval, out]long *pValue); - HRESULT SetLanguageID([in]long Value); + HRESULT CanChange([out]LONG *pB); + HRESULT IsEqual([in]ITextFont *pFont, [retval, out]LONG *pB); + HRESULT Reset([in]LONG Value); + HRESULT GetStyle([retval, out]LONG *pValue); + HRESULT SetStyle([in]LONG Value); + HRESULT GetAllCaps([retval, out]LONG *pValue); + HRESULT SetAllCaps([in]LONG Value); + HRESULT GetAnimation([retval, out]LONG *pValue); + HRESULT SetAnimation([in]LONG Value); + HRESULT GetBackColor([retval, out]LONG *pValue); + HRESULT SetBackColor([in]LONG Value); + HRESULT GetBold([retval, out]LONG *pValue); + HRESULT SetBold([in]LONG Value); + HRESULT GetEmboss([retval, out]LONG *pValue); + HRESULT SetEmboss([in]LONG Value); + HRESULT GetForeColor([retval, out]LONG *pValue); + HRESULT SetForeColor([in]LONG Value); + HRESULT GetHidden([retval, out]LONG *pValue); + HRESULT SetHidden([in]LONG Value); + HRESULT GetEngrave([retval, out]LONG *pValue); + HRESULT SetEngrave([in]LONG Value); + HRESULT GetItalic([retval, out]LONG *pValue); + HRESULT SetItalic([in]LONG Value); + HRESULT GetKerning([retval, out]LONG *pValue); + HRESULT SetKerning([in]LONG Value); + HRESULT GetLanguageID([retval, out]LONG *pValue); + HRESULT SetLanguageID([in]LONG Value); HRESULT GetName([retval, out]BSTR *pValue); HRESULT SetName([in]BSTR Value); - HRESULT GetOutline([retval, out]long *pValue); - HRESULT SetOutline([in]long Value); - HRESULT GetPosition([retval, out]long *pValue); - HRESULT SetPosition([in]long Value); - HRESULT GetProtected([retval, out]long *pValue); - HRESULT SetProtected([in]long Value); - HRESULT GetShadow([retval, out]long *pValue); - HRESULT SetShadow([in]long Value); - HRESULT GetSize([retval, out]long *pValue); - HRESULT SetSize([in]long Value); - HRESULT GetSmallCaps([retval, out]long *pValue); - HRESULT SetSmallCaps([in]long Value); + HRESULT GetOutline([retval, out]LONG *pValue); + HRESULT SetOutline([in]LONG Value); + HRESULT GetPosition([retval, out]LONG *pValue); + HRESULT SetPosition([in]LONG Value); + HRESULT GetProtected([retval, out]LONG *pValue); + HRESULT SetProtected([in]LONG Value); + HRESULT GetShadow([retval, out]LONG *pValue); + HRESULT SetShadow([in]LONG Value); + HRESULT GetSize([retval, out]LONG *pValue); + HRESULT SetSize([in]LONG Value); + HRESULT GetSmallCaps([retval, out]LONG *pValue); + HRESULT SetSmallCaps([in]LONG Value); HRESULT GetSpacing([retval, out]float *pValue); HRESULT SetSpacing([in]float Value); - HRESULT GetStrikeThrough([retval, out]long *pValue); - HRESULT SetStrikeThrough([in]long Value); - HRESULT GetSubscript([retval, out]long *pValue); - HRESULT SetSubscript([in]long Value); - HRESULT GetSuperscript([retval, out]long *pValue); - HRESULT SetSuperscript([in]long Value); - HRESULT GetUnderline([retval, out]long *pValue); - HRESULT SetUnderline([in]long Value); - HRESULT GetWeight([retval, out]long *pValue); - HRESULT SetWeight([in]long Value); + HRESULT GetStrikeThrough([retval, out]LONG *pValue); + HRESULT SetStrikeThrough([in]LONG Value); + HRESULT GetSubscript([retval, out]LONG *pValue); + HRESULT SetSubscript([in]LONG Value); + HRESULT GetSuperscript([retval, out]LONG *pValue); + HRESULT SetSuperscript([in]LONG Value); + HRESULT GetUnderline([retval, out]LONG *pValue); + HRESULT SetUnderline([in]LONG Value); + HRESULT GetWeight([retval, out]LONG *pValue); + HRESULT SetWeight([in]LONG Value); } [ @@ -370,52 +374,52 @@ interface ITextPara : IDispatch { HRESULT GetDuplicate([retval, out]ITextPara **ppPara); HRESULT SetDuplicate([in]ITextPara *pPara); - HRESULT CanChange([out]long *pB); - HRESULT IsEqual([in]ITextPara *pPara, [retval, out]long *pB); - HRESULT Reset([in]long Value); - HRESULT GetStyle([retval, out]long *pValue); - HRESULT SetStyle([in]long Value); - HRESULT GetAlignment([retval, out]long *pValue); - HRESULT SetAlignment([in]long Value); - HRESULT GetHyphenation([retval, out]long *pValue); - HRESULT SetHyphenation([in]long Value); + HRESULT CanChange([out]LONG *pB); + HRESULT IsEqual([in]ITextPara *pPara, [retval, out]LONG *pB); + HRESULT Reset([in]LONG Value); + HRESULT GetStyle([retval, out]LONG *pValue); + HRESULT SetStyle([in]LONG Value); + HRESULT GetAlignment([retval, out]LONG *pValue); + HRESULT SetAlignment([in]LONG Value); + HRESULT GetHyphenation([retval, out]LONG *pValue); + HRESULT SetHyphenation([in]LONG Value); HRESULT GetFirstLineIndent([retval, out]float *pValue); - HRESULT GetKeepTogether([retval, out]long *pValue); - HRESULT SetKeepTogether([in]long Value); - HRESULT GetKeepWithNext([retval, out]long *pValue); - HRESULT SetKeepWithNext([in]long Value); + HRESULT GetKeepTogether([retval, out]LONG *pValue); + HRESULT SetKeepTogether([in]LONG Value); + HRESULT GetKeepWithNext([retval, out]LONG *pValue); + HRESULT SetKeepWithNext([in]LONG Value); HRESULT GetLeftIndent([retval, out]float *pValue); HRESULT GetLineSpacing([retval, out]float *pValue); - HRESULT GetLineSpacingRule([retval, out]long *pValue); - HRESULT GetListAlignment([retval, out]long *pValue); - HRESULT SetListAlignment([in]long Value); - HRESULT GetListLevelIndex([retval, out]long *pValue); - HRESULT SetListLevelIndex([in]long Value); - HRESULT GetListStart([retval, out]long *pValue); - HRESULT SetListStart([in]long Value); - HRESULT GetListTab([retval, out]long *pValue); - HRESULT SetListTab([in]long Value); - HRESULT GetListType([retval, out]long *pValue); - HRESULT SetListType([in]long Value); - HRESULT GetNoLineNumber([retval, out]long *pValue); - HRESULT SetNoLineNumber([in]long Value); - HRESULT GetPageBreakBefore([retval, out]long *pValue); - HRESULT SetPageBreakBefore([in]long Value); + HRESULT GetLineSpacingRule([retval, out]LONG *pValue); + HRESULT GetListAlignment([retval, out]LONG *pValue); + HRESULT SetListAlignment([in]LONG Value); + HRESULT GetListLevelIndex([retval, out]LONG *pValue); + HRESULT SetListLevelIndex([in]LONG Value); + HRESULT GetListStart([retval, out]LONG *pValue); + HRESULT SetListStart([in]LONG Value); + HRESULT GetListTab([retval, out]LONG *pValue); + HRESULT SetListTab([in]LONG Value); + HRESULT GetListType([retval, out]LONG *pValue); + HRESULT SetListType([in]LONG Value); + HRESULT GetNoLineNumber([retval, out]LONG *pValue); + HRESULT SetNoLineNumber([in]LONG Value); + HRESULT GetPageBreakBefore([retval, out]LONG *pValue); + HRESULT SetPageBreakBefore([in]LONG Value); HRESULT GetRightIndent([retval, out]float *pValue); HRESULT SetRightIndent([in]float Value); HRESULT SetIndents([in]float StartIndent, [in]float LeftIndent, [in]float RightIndent); - HRESULT SetLineSpacing([in]long LineSpacingRule, [in]float LineSpacing); + HRESULT SetLineSpacing([in]LONG LineSpacingRule, [in]float LineSpacing); HRESULT GetSpaceAfter([retval, out]float *pValue); HRESULT SetSpaceAfter([in]float Value); HRESULT GetSpaceBefore([retval, out]float *pValue); HRESULT SetSpaceBefore([in]float Value); HRESULT GetWindowControl([retval, out]float *pValue); HRESULT SetWindowControl([in]float Value); - HRESULT GetTabCount([retval, out]long *pCount); - HRESULT AddTab([in]float tbPos, [in]long tbAlign, [in]long tbLeader); + HRESULT GetTabCount([retval, out]LONG *pCount); + HRESULT AddTab([in]float tbPos, [in]LONG tbAlign, [in]LONG tbLeader); HRESULT ClearAllTabs(); HRESULT DeleteTab([in]float tbPos); - HRESULT GetTab([in]long iTab, [out]float *ptbPos, [out]long *ptbAlign, [out]long *ptbLeader); + HRESULT GetTab([in]LONG iTab, [out]float *ptbPos, [out]LONG *ptbAlign, [out]LONG *ptbLeader); } [ @@ -425,6 +429,6 @@ interface ITextPara : IDispatch interface ITextStoryRanges : IDispatch { HRESULT _NewEnum([retval, out]IUnknown **ppUnkEnum); - HRESULT Item([in]long Index, [retval, out]ITextRange **ppRange); - HRESULT GetCount([retval, out]long *pCount); + HRESULT Item([in]LONG Index, [retval, out]ITextRange **ppRange); + HRESULT GetCount([retval, out]LONG *pCount); } diff --git a/reactos/include/psdk/wtypes.idl b/reactos/include/psdk/wtypes.idl index 6a3f9a9109e..4a311ba5695 100644 --- a/reactos/include/psdk/wtypes.idl +++ b/reactos/include/psdk/wtypes.idl @@ -91,16 +91,13 @@ DECLARE_HANDLE(HWINSTA); DECLARE_HANDLE(HKL); DECLARE_HANDLE(HGDIOBJ); -cpp_quote("#if 0") -typedef HANDLE HMONITOR; -cpp_quote("#endif /* 0 */") - typedef HANDLE HDWP; typedef LONG_PTR LRESULT; typedef LONG HRESULT; typedef DWORD LCID; +typedef USHORT LANGID; typedef unsigned __int64 DWORDLONG; typedef __int64 LONGLONG; @@ -447,7 +444,7 @@ typedef struct tagRemHGLOBAL { typedef union _userHGLOBAL switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: FLAGGED_BYTE_BLOB *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHGLOBAL; typedef [unique] userHGLOBAL *wireHGLOBAL; @@ -463,7 +460,7 @@ typedef struct tagRemHMETAFILEPICT { typedef union _userHMETAFILE switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: BYTE_BLOB *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHMETAFILE; typedef [unique] userHMETAFILE *wireHMETAFILE; @@ -478,7 +475,7 @@ typedef struct _remoteMETAFILEPICT { typedef union _userHMETAFILEPICT switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: remoteMETAFILEPICT *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHMETAFILEPICT; typedef [unique] userHMETAFILEPICT *wireHMETAFILEPICT; @@ -491,7 +488,7 @@ typedef struct tagRemHENHMETAFILE { typedef union _userHENHMETAFILE switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: BYTE_BLOB *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHENHMETAFILE; typedef [unique] userHENHMETAFILE *wireHENHMETAFILE; @@ -516,7 +513,7 @@ typedef struct _userBITMAP { typedef union _userHBITMAP switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: userBITMAP *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHBITMAP; typedef [unique] userHBITMAP *wireHBITMAP; @@ -535,7 +532,7 @@ typedef struct tagrpcLOGPALETTE { typedef union _userHPALETTE switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: rpcLOGPALETTE *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHPALETTE; typedef [unique] userHPALETTE *wireHPALETTE; @@ -585,36 +582,6 @@ typedef struct tagMSG POINT pt; } MSG, *PMSG, *NPMSG, *LPMSG; -typedef struct tagCREATESTRUCTA { - LPVOID lpCreateParams; - HINSTANCE hInstance; - HMENU hMenu; - HWND hwndParent; - int cy; - int cx; - int y; - int x; - LONG style; - LPCSTR lpszName; - LPCSTR lpszClass; - DWORD dwExStyle; -} CREATESTRUCTA, *LPCREATESTRUCTA; - -typedef struct tagCREATESTRUCTW { - LPVOID lpCreateParams; - HINSTANCE hInstance; - HMENU hMenu; - HWND hwndParent; - int cy; - int cx; - int y; - int x; - LONG style; - LPCWSTR lpszName; - LPCWSTR lpszClass; - DWORD dwExStyle; -} CREATESTRUCTW, *LPCREATESTRUCTW; - cpp_quote("#endif") /******************** GUID TYPES ********************/ @@ -870,6 +837,15 @@ typedef union switch(DWORD tyspec) } ByObjectId; } uCLSSPEC; +cpp_quote("#ifndef PROPERTYKEY_DEFINED") +cpp_quote("#define PROPERTYKEY_DEFINED") +typedef struct _tagpropertykey +{ + GUID fmtid; + DWORD pid; +} PROPERTYKEY; +cpp_quote("#endif /*PROPERTYKEY_DEFINED*/") + } /* interface IWinTypes */ cpp_quote("#ifdef _MSC_VER") diff --git a/reactos/include/reactos/wine/wined3d.idl b/reactos/include/reactos/wine/wined3d.idl index 252c6e3aad9..6364f9cfe89 100644 --- a/reactos/include/reactos/wine/wined3d.idl +++ b/reactos/include/reactos/wine/wined3d.idl @@ -26,6 +26,7 @@ import "unknwn.idl"; cpp_quote("#if 0") +typedef HANDLE HMONITOR; typedef struct _RGNDATAHEADER { From 63f9072074e5798e05fc6bf773f4c294a5dfb911 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 8 Mar 2010 20:52:04 +0000 Subject: [PATCH 202/211] - [User32_winetest] - Win : Remove test_capture from service. This is related to TrackMouseEvent issues which use SetCapture. svn path=/trunk/; revision=46006 --- rostests/winetests/user32/win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rostests/winetests/user32/win.c b/rostests/winetests/user32/win.c index ddfddb1e9fe..cc41bae8032 100644 --- a/rostests/winetests/user32/win.c +++ b/rostests/winetests/user32/win.c @@ -5979,7 +5979,7 @@ START_TEST(win) test_capture_1(); test_capture_2(); test_capture_3(hwndMain, hwndMain2); - test_capture_4(); +// test_capture_4(); test_CreateWindow(); test_parent_owner(); From f8fced000d87a633dc2fa18d85251833005402f4 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 8 Mar 2010 20:57:24 +0000 Subject: [PATCH 203/211] [User32] - Andrew Nguyen : Ensure That WM_INITDIALOG passes the first tabstop control handle to the dialog procedure. - Henri Verbeet : Also show dialogs right after a WM_TIMER message. svn path=/trunk/; revision=46007 --- reactos/dll/win32/user32/windows/dialog.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/user32/windows/dialog.c b/reactos/dll/win32/user32/windows/dialog.c index 1f2720e54e9..eec7b45512f 100644 --- a/reactos/dll/win32/user32/windows/dialog.c +++ b/reactos/dll/win32/user32/windows/dialog.c @@ -560,6 +560,12 @@ INT DIALOG_DoDialogBox( HWND hwnd, HWND owner ) DispatchMessageW( &msg ); } if (dlgInfo->flags & DF_END) break; + + if (bFirstEmpty && msg.message == WM_TIMER) + { + ShowWindow( hwnd, SW_SHOWNORMAL ); + bFirstEmpty = FALSE; + } } } if (dlgInfo->flags & DF_OWNERENABLED) DIALOG_EnableOwner( owner ); @@ -968,10 +974,13 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, if (dlgProc) { - if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ) && + HWND focus = GetNextDlgTabItem( hwnd, 0, FALSE ); + if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)focus, param ) && ((~template.style & DS_CONTROL) || (template.style & WS_VISIBLE))) { - /* By returning TRUE, app has requested a default focus assignment */ + /* By returning TRUE, app has requested a default focus assignment. + * WM_INITDIALOG may have changed the tab order, so find the first + * tabstop control again. */ dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE); if( dlgInfo->hwndFocus ) SetFocus( dlgInfo->hwndFocus ); From 6e96e3015c67b4b26b8b6534bbbf6888b95c4e87 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 8 Mar 2010 21:04:00 +0000 Subject: [PATCH 204/211] - Fix a crash in user32 winetest msg. svn path=/trunk/; revision=46009 --- reactos/subsystems/win32/win32k/ntuser/painting.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index 86ed104c2e3..66977db106f 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -502,7 +502,10 @@ IntIsWindowDrawable(PWINDOW_OBJECT Window) for (WndObject = Window; WndObject != NULL; WndObject = WndObject->spwndParent) { Wnd = WndObject->Wnd; - if (!(Wnd->style & WS_VISIBLE) || + if ( Window->state & WINDOWSTATUS_DESTROYING || // state2 + Window->state & WINDOWSTATUS_DESTROYED || + !Wnd || + !(Wnd->style & WS_VISIBLE) || ((Wnd->style & WS_MINIMIZE) && (WndObject != Window))) { return FALSE; From f780908ae4eed03ed1fb59962220f106ff56ee49 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Mon, 8 Mar 2010 21:08:20 +0000 Subject: [PATCH 205/211] Polish translation update by Maciej Bialas. svn path=/trunk/; revision=46010 --- reactos/media/inf/keyboard.inf | Bin 6474 -> 6856 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/reactos/media/inf/keyboard.inf b/reactos/media/inf/keyboard.inf index de7023a77ddbc1de1b4f81c8832eb7bcbac4e498..b4857650ed98ff54bb1fc3fae1eac8428d707dc1 100644 GIT binary patch delta 196 zcmX?Qbi#DQ8{x@UM2t4eh-fh~nodp>F%>|p{7Xtu>@h!6e delta 25 hcmX?Mddg_S8{x@K0tTDqM6?(e9}r_<`TviL0RV}=36=l= From be17352b40821900583440695c5713ee5809ff79 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 8 Mar 2010 21:09:25 +0000 Subject: [PATCH 206/211] [CMBATT] - Add initial cmbatt driver which mostly stubs - All it does right now is register a battery device with the battc driver [BATTC] - Add a nearly complete battc driver (the only stuff missing is WMI) - Tested with our stubbed cmbatt driver but testing on Windows would be nice too [BATTERY.INF] - Added battery.inf to install battery devices [MISC] - Add cmbatt.sys, battc.sys, and battery.inf to bootcd - We still need to implement compbatt.sys - PS: Janderwald, you stole my commit number ;) svn path=/trunk/; revision=46011 --- reactos/boot/bootdata/packages/reactos.dff | 4 + reactos/drivers/battery/battc/battc.c | 373 +++++++++++++++++++ reactos/drivers/battery/battc/battc.h | 30 ++ reactos/drivers/battery/battc/battc.rbuild | 10 + reactos/drivers/battery/battc/battc.rc | 5 + reactos/drivers/battery/battc/battc.spec | 6 + reactos/drivers/battery/cmbatt/cmbatt.c | 188 ++++++++++ reactos/drivers/battery/cmbatt/cmbatt.h | 58 +++ reactos/drivers/battery/cmbatt/cmbatt.rbuild | 11 + reactos/drivers/battery/cmbatt/cmbatt.rc | 5 + reactos/drivers/battery/cmbatt/miniclass.c | 82 ++++ reactos/drivers/battery/directory.rbuild | 10 + reactos/drivers/drivers.rbuild | 3 + reactos/media/inf/battery.inf | 52 +++ 14 files changed, 837 insertions(+) create mode 100644 reactos/drivers/battery/battc/battc.c create mode 100644 reactos/drivers/battery/battc/battc.h create mode 100644 reactos/drivers/battery/battc/battc.rbuild create mode 100644 reactos/drivers/battery/battc/battc.rc create mode 100644 reactos/drivers/battery/battc/battc.spec create mode 100644 reactos/drivers/battery/cmbatt/cmbatt.c create mode 100644 reactos/drivers/battery/cmbatt/cmbatt.h create mode 100644 reactos/drivers/battery/cmbatt/cmbatt.rbuild create mode 100644 reactos/drivers/battery/cmbatt/cmbatt.rc create mode 100644 reactos/drivers/battery/cmbatt/miniclass.c create mode 100644 reactos/drivers/battery/directory.rbuild create mode 100644 reactos/media/inf/battery.inf diff --git a/reactos/boot/bootdata/packages/reactos.dff b/reactos/boot/bootdata/packages/reactos.dff index a0db0df1377..c8be7bd6a18 100644 --- a/reactos/boot/bootdata/packages/reactos.dff +++ b/reactos/boot/bootdata/packages/reactos.dff @@ -482,6 +482,9 @@ drivers\base\beep\beep.sys 2 drivers\base\null\null.sys 2 drivers\base\nmidebug\nmidebug.sys 2 +drivers\battery\cmbatt\cmbatt.sys 2 +drivers\battery\battc\battc.sys 2 + drivers\bus\isapnp\isapnp.sys 2 drivers\directx\dxapi\dxapi.sys 2 @@ -628,6 +631,7 @@ media\nls\c_28606.nls 1 media\drivers\etc\services 5 media\inf\audio.inf 6 media\inf\acpi.inf 6 +media\inf\battery.inf 6 media\inf\cdrom.inf 6 media\inf\cpu.inf 6 media\inf\display.inf 6 diff --git a/reactos/drivers/battery/battc/battc.c b/reactos/drivers/battery/battc/battc.c new file mode 100644 index 00000000000..a626d8c9171 --- /dev/null +++ b/reactos/drivers/battery/battc/battc.c @@ -0,0 +1,373 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/battery/battc/battc.c + * PURPOSE: Battery Class Driver + * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) + */ + +#include + +#define NDEBUG +#include + +NTSTATUS +NTAPI +DriverEntry(PDRIVER_OBJECT DriverObject, + PUNICODE_STRING RegistryPath) +{ + DPRINT("Battery class driver initialized\n"); + + return STATUS_SUCCESS; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassUnload(PVOID ClassData) +{ + PBATTERY_CLASS_DATA BattClass = ClassData; + + DPRINT("Battery 0x%x is being unloaded\n"); + + if (BattClass->InterfaceName.Length != 0) + { + IoSetDeviceInterfaceState(&BattClass->InterfaceName, FALSE); + RtlFreeUnicodeString(&BattClass->InterfaceName); + } + + ExFreePoolWithTag(BattClass, + BATTERY_CLASS_DATA_TAG); + + return STATUS_SUCCESS; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassSystemControl(PVOID ClassData, + PWMILIB_CONTEXT WmiLibContext, + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PSYSCTL_IRP_DISPOSITION Disposition) +{ + NTSTATUS Status; + + UNIMPLEMENTED + + /* FIXME: Uncomment when WmiCompleteRequest is implemented */ +#if 0 + Status = STATUS_WMI_GUID_NOT_FOUND; + WmiCompleteRequest(DeviceObject, + Irp, + Status, + 0, + IO_NO_INCREMENT); +#else + Irp->IoStatus.Status = Status = STATUS_WMI_GUID_NOT_FOUND; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); +#endif + + return Status; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassQueryWmiDataBlock(PVOID ClassData, + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + ULONG GuidIndex, + PULONG InstanceLengthArray, + ULONG OutBufferSize, + PUCHAR Buffer) +{ + UNIMPLEMENTED + + return STATUS_WMI_GUID_NOT_FOUND; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassStatusNotify(PVOID ClassData) +{ + PBATTERY_CLASS_DATA BattClass = ClassData; + PBATTERY_WAIT_STATUS BattWait = BattClass->EventTriggerContext; + BATTERY_STATUS BattStatus; + NTSTATUS Status; + + DPRINT("Received battery status notification from 0x%x\n", ClassData); + + ExAcquireFastMutex(&BattClass->Mutex); + if (!BattClass->Waiting) + { + ExReleaseFastMutex(&BattClass->Mutex); + return STATUS_SUCCESS; + } + + switch (BattClass->EventTrigger) + { + case EVENT_BATTERY_TAG: + ExReleaseFastMutex(&BattClass->Mutex); + DPRINT1("Waiting for battery is UNIMPLEMENTED!\n"); + break; + + case EVENT_BATTERY_STATUS: + ExReleaseFastMutex(&BattClass->Mutex); + Status = BattClass->MiniportInfo.QueryStatus(BattClass->MiniportInfo.Context, + BattWait->BatteryTag, + &BattStatus); + if (!NT_SUCCESS(Status)) + return Status; + + ExAcquireFastMutex(&BattClass->Mutex); + + if (!(BattWait->PowerState & BattStatus.PowerState) || + (BattWait->HighCapacity > BattStatus.Capacity) || + (BattWait->LowCapacity < BattStatus.Capacity)) + { + KeSetEvent(&BattClass->WaitEvent, IO_NO_INCREMENT, FALSE); + } + + ExReleaseFastMutex(&BattClass->Mutex); + break; + + default: + ExReleaseFastMutex(&BattClass->Mutex); + ASSERT(FALSE); + break; + } + + return STATUS_SUCCESS; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO MiniportInfo, + PVOID *ClassData) +{ + NTSTATUS Status; + PBATTERY_CLASS_DATA BattClass = ExAllocatePoolWithTag(NonPagedPool, + sizeof(BATTERY_CLASS_DATA), + BATTERY_CLASS_DATA_TAG); + + if (!BattClass) + return STATUS_INSUFFICIENT_RESOURCES; + + RtlZeroMemory(BattClass, sizeof(BATTERY_CLASS_DATA)); + + RtlCopyMemory(&BattClass->MiniportInfo, + MiniportInfo, + sizeof(BattClass->MiniportInfo)); + + KeInitializeEvent(&BattClass->WaitEvent, SynchronizationEvent, FALSE); + + ExInitializeFastMutex(&BattClass->Mutex); + + Status = IoRegisterDeviceInterface(MiniportInfo->Pdo, + &GUID_DEVICE_BATTERY, + NULL, + &BattClass->InterfaceName); + if (NT_SUCCESS(Status)) + { + DPRINT("Initialized battery interface: %wZ\n", &BattClass->InterfaceName); + IoSetDeviceInterfaceState(&BattClass->InterfaceName, TRUE); + } + else + { + DPRINT1("IoRegisterDeviceInterface failed (0x%x)\n", Status); + } + + *ClassData = BattClass; + + return STATUS_SUCCESS; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassIoctl(PVOID ClassData, + PIRP Irp) +{ + PBATTERY_CLASS_DATA BattClass = ClassData; + PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); + NTSTATUS Status; + ULONG WaitTime; + PBATTERY_WAIT_STATUS BattWait; + PBATTERY_QUERY_INFORMATION BattQueryInfo; + PBATTERY_SET_INFORMATION BattSetInfo; + LARGE_INTEGER Timeout; + PBATTERY_STATUS BattStatus; + BATTERY_NOTIFY BattNotify; + + Irp->IoStatus.Information = 0; + + DPRINT("Received IOCTL %x for 0x%x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode, + ClassData); + + switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) + { + case IOCTL_BATTERY_QUERY_TAG: + if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(ULONG) || + IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)) + { + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + WaitTime = *(PULONG)Irp->AssociatedIrp.SystemBuffer; + + Timeout.QuadPart = Int32x32To64(WaitTime, -1000); + + Status = BattClass->MiniportInfo.QueryTag(BattClass->MiniportInfo.Context, + (PULONG)Irp->AssociatedIrp.SystemBuffer); + if (!NT_SUCCESS(Status)) + { + ExAcquireFastMutex(&BattClass->Mutex); + BattClass->EventTrigger = EVENT_BATTERY_TAG; + BattClass->Waiting = TRUE; + ExReleaseFastMutex(&BattClass->Mutex); + + Status = KeWaitForSingleObject(&BattClass->WaitEvent, + Executive, + KernelMode, + FALSE, + WaitTime != -1 ? &Timeout : NULL); + + ExAcquireFastMutex(&BattClass->Mutex); + BattClass->Waiting = FALSE; + ExReleaseFastMutex(&BattClass->Mutex); + + if (Status == STATUS_SUCCESS) + { + Status = BattClass->MiniportInfo.QueryTag(BattClass->MiniportInfo.Context, + (PULONG)Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) + Irp->IoStatus.Information = sizeof(ULONG); + } + else + { + Status = STATUS_NO_SUCH_DEVICE; + } + } + else + Irp->IoStatus.Information = sizeof(ULONG); + break; + + case IOCTL_BATTERY_QUERY_STATUS: + if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(*BattWait) || + IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(BATTERY_STATUS)) + { + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + BattWait = Irp->AssociatedIrp.SystemBuffer; + + Timeout.QuadPart = Int32x32To64(BattWait->Timeout, -1000); + + Status = BattClass->MiniportInfo.QueryStatus(BattClass->MiniportInfo.Context, + BattWait->BatteryTag, + (PBATTERY_STATUS)Irp->AssociatedIrp.SystemBuffer); + + BattStatus = Irp->AssociatedIrp.SystemBuffer; + + if (!NT_SUCCESS(Status) || + ((BattWait->PowerState & BattStatus->PowerState) && + (BattWait->HighCapacity <= BattStatus->Capacity) && + (BattWait->LowCapacity >= BattStatus->Capacity))) + { + BattNotify.PowerState = BattWait->PowerState; + BattNotify.HighCapacity = BattWait->HighCapacity; + BattNotify.LowCapacity = BattWait->LowCapacity; + + BattClass->MiniportInfo.SetStatusNotify(BattClass->MiniportInfo.Context, + BattWait->BatteryTag, + &BattNotify); + + ExAcquireFastMutex(&BattClass->Mutex); + BattClass->EventTrigger = EVENT_BATTERY_STATUS; + BattClass->EventTriggerContext = BattWait; + BattClass->Waiting = TRUE; + ExReleaseFastMutex(&BattClass->Mutex); + + Status = KeWaitForSingleObject(&BattClass->WaitEvent, + Executive, + KernelMode, + FALSE, + BattWait->Timeout != -1 ? &Timeout : NULL); + + ExAcquireFastMutex(&BattClass->Mutex); + BattClass->Waiting = FALSE; + ExReleaseFastMutex(&BattClass->Mutex); + + BattClass->MiniportInfo.DisableStatusNotify(BattClass->MiniportInfo.Context); + + if (Status == STATUS_SUCCESS) + { + Status = BattClass->MiniportInfo.QueryStatus(BattClass->MiniportInfo.Context, + BattWait->BatteryTag, + (PBATTERY_STATUS)Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) + Irp->IoStatus.Information = sizeof(ULONG); + } + else + { + Status = STATUS_NO_SUCH_DEVICE; + } + } + else + Irp->IoStatus.Information = sizeof(BATTERY_STATUS); + break; + + case IOCTL_BATTERY_QUERY_INFORMATION: + if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(*BattQueryInfo)) + { + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + BattQueryInfo = Irp->AssociatedIrp.SystemBuffer; + + Status = BattClass->MiniportInfo.QueryInformation(BattClass->MiniportInfo.Context, + BattQueryInfo->BatteryTag, + BattQueryInfo->InformationLevel, + BattQueryInfo->AtRate, + Irp->AssociatedIrp.SystemBuffer, + IrpSp->Parameters.DeviceIoControl.OutputBufferLength, + &Irp->IoStatus.Information); + if (!NT_SUCCESS(Status)) + DPRINT1("QueryInformation failed (0x%x)\n", Status); + break; + case IOCTL_BATTERY_SET_INFORMATION: + if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(*BattSetInfo)) + { + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + BattSetInfo = Irp->AssociatedIrp.SystemBuffer; + + Status = BattClass->MiniportInfo.SetInformation(BattClass->MiniportInfo.Context, + BattSetInfo->BatteryTag, + BattSetInfo->InformationLevel, + BattSetInfo->Buffer); + if (!NT_SUCCESS(Status)) + DPRINT1("SetInformation failed (0x%x)\n", Status); + break; + + default: + DPRINT1("Received unsupported IRP %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode); + /* Do NOT complete the irp */ + return STATUS_NOT_SUPPORTED; + } + + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return Status; +} diff --git a/reactos/drivers/battery/battc/battc.h b/reactos/drivers/battery/battc/battc.h new file mode 100644 index 00000000000..b7c5af49333 --- /dev/null +++ b/reactos/drivers/battery/battc/battc.h @@ -0,0 +1,30 @@ +/* +* PROJECT: ReactOS Kernel +* LICENSE: GPL - See COPYING in the top level directory +* FILE: drivers/battery/battc/battc.h +* PURPOSE: Battery Class Driver +* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) +*/ + +#pragma once + +#include +#include +#include + +typedef struct _BATTERY_CLASS_DATA { + BATTERY_MINIPORT_INFO MiniportInfo; + KEVENT WaitEvent; + BOOLEAN Waiting; + FAST_MUTEX Mutex; + UCHAR EventTrigger; + PVOID EventTriggerContext; + UNICODE_STRING InterfaceName; +} BATTERY_CLASS_DATA, *PBATTERY_CLASS_DATA; + +/* Memory tags */ +#define BATTERY_CLASS_DATA_TAG 'CtaB' + +/* Event triggers */ +#define EVENT_BATTERY_TAG 0x01 +#define EVENT_BATTERY_STATUS 0x02 diff --git a/reactos/drivers/battery/battc/battc.rbuild b/reactos/drivers/battery/battc/battc.rbuild new file mode 100644 index 00000000000..c0261344994 --- /dev/null +++ b/reactos/drivers/battery/battc/battc.rbuild @@ -0,0 +1,10 @@ + + + + ntoskrnl + hal + + . + battc.c + battc.rc + diff --git a/reactos/drivers/battery/battc/battc.rc b/reactos/drivers/battery/battc/battc.rc new file mode 100644 index 00000000000..2230092b4a4 --- /dev/null +++ b/reactos/drivers/battery/battc/battc.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Battery Class Driver\0" +#define REACTOS_STR_INTERNAL_NAME "battc\0" +#define REACTOS_STR_ORIGINAL_FILENAME "battc.sys\0" +#include diff --git a/reactos/drivers/battery/battc/battc.spec b/reactos/drivers/battery/battc/battc.spec new file mode 100644 index 00000000000..c2d21b7ec20 --- /dev/null +++ b/reactos/drivers/battery/battc/battc.spec @@ -0,0 +1,6 @@ +@ stdcall BatteryClassInitializeDevice(ptr ptr) +@ stdcall BatteryClassIoctl(ptr ptr) +@ stdcall BatteryClassQueryWmiDataBlock(ptr ptr ptr long ptr long ptr) +@ stdcall BatteryClassStatusNotify(ptr) +@ stdcall BatteryClassSystemControl(ptr ptr ptr ptr ptr) +@ stdcall BatteryClassUnload(ptr) diff --git a/reactos/drivers/battery/cmbatt/cmbatt.c b/reactos/drivers/battery/cmbatt/cmbatt.c new file mode 100644 index 00000000000..b85f3ebc504 --- /dev/null +++ b/reactos/drivers/battery/cmbatt/cmbatt.c @@ -0,0 +1,188 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/battery/cmbatt/cmbatt.c + * PURPOSE: Control Method Battery Miniclass Driver + * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) + */ + +#include + +#define NDEBUG +#include + +LIST_ENTRY BatteryList; +KSPIN_LOCK BatteryListLock; + +VOID +NTAPI +CmBattUnload(PDRIVER_OBJECT DriverObject) +{ + DPRINT("Control method battery miniclass driver unloaded\n"); +} + +NTSTATUS +NTAPI +CmBattDeviceControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + NTSTATUS Status; + + Status = BatteryClassIoctl(DeviceExtension->BattClassHandle, + Irp); + + if (Status == STATUS_NOT_SUPPORTED) + { + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + + return Status; +} + +NTSTATUS +NTAPI +CmBattPnP(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + + UNIMPLEMENTED + + IoSkipCurrentIrpStackLocation(Irp); + + return IoCallDriver(DeviceExtension->Ldo, Irp); +} + +NTSTATUS +NTAPI +CmBattSystemControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + UNIMPLEMENTED + + Irp->IoStatus.Status = STATUS_WMI_GUID_NOT_FOUND; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return STATUS_WMI_GUID_NOT_FOUND; +} + +NTSTATUS +NTAPI +CmBattPower(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + + UNIMPLEMENTED + + IoSkipCurrentIrpStackLocation(Irp); + + PoStartNextPowerIrp(Irp); + + return PoCallDriver(DeviceExtension->Ldo, Irp); +} + +NTSTATUS +NTAPI +CmBattCreateClose(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmBattAddDevice(PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT PhysicalDeviceObject) +{ + NTSTATUS Status; + PDEVICE_OBJECT DeviceObject; + PCMBATT_DEVICE_EXTENSION DeviceExtension; + BATTERY_MINIPORT_INFO BattInfo; + + Status = IoCreateDevice(DriverObject, + sizeof(CMBATT_DEVICE_EXTENSION), + NULL, + FILE_DEVICE_BATTERY, + 0, + FALSE, + &DeviceObject); + if (!NT_SUCCESS(Status)) + return Status; + + DeviceExtension = DeviceObject->DeviceExtension; + + DeviceExtension->Pdo = PhysicalDeviceObject; + DeviceExtension->Fdo = DeviceObject; + DeviceExtension->Ldo = IoAttachDeviceToDeviceStack(DeviceObject, + PhysicalDeviceObject); + + DeviceObject->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE; + + /* We require an extra stack entry */ + DeviceObject->StackSize = PhysicalDeviceObject->StackSize + 2; + + BattInfo.MajorVersion = BATTERY_CLASS_MAJOR_VERSION; + BattInfo.MinorVersion = BATTERY_CLASS_MINOR_VERSION; + BattInfo.Context = DeviceExtension; + BattInfo.QueryTag = CmBattQueryTag; + BattInfo.QueryInformation = CmBattQueryInformation; + BattInfo.SetInformation = CmBattSetInformation; + BattInfo.QueryStatus = CmBattQueryStatus; + BattInfo.SetStatusNotify = CmBattSetStatusNotify; + BattInfo.DisableStatusNotify = CmBattDisableStatusNotify; + BattInfo.Pdo = PhysicalDeviceObject; + BattInfo.DeviceName = NULL; + + Status = BatteryClassInitializeDevice(&BattInfo, + &DeviceExtension->BattClassHandle); + if (!NT_SUCCESS(Status)) + { + IoDetachDevice(DeviceExtension->Ldo); + IoDeleteDevice(DeviceObject); + return Status; + } + + ExInterlockedInsertTailList(&BatteryList, + &DeviceExtension->ListEntry, + &BatteryListLock); + + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + DPRINT("Successfully registered battery with battc (0x%x)\n", DeviceExtension->BattClassHandle); + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +DriverEntry(PDRIVER_OBJECT DriverObject, + PUNICODE_STRING RegistryPath) +{ + DPRINT("Control method battery miniclass driver initialized\n"); + + DriverObject->DriverUnload = CmBattUnload; + DriverObject->DriverExtension->AddDevice = CmBattAddDevice; + DriverObject->MajorFunction[IRP_MJ_POWER] = CmBattPower; + DriverObject->MajorFunction[IRP_MJ_PNP] = CmBattPnP; + DriverObject->MajorFunction[IRP_MJ_CREATE] = CmBattCreateClose; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = CmBattCreateClose; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CmBattDeviceControl; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = CmBattSystemControl; + + KeInitializeSpinLock(&BatteryListLock); + InitializeListHead(&BatteryList); + + return STATUS_SUCCESS; +} diff --git a/reactos/drivers/battery/cmbatt/cmbatt.h b/reactos/drivers/battery/cmbatt/cmbatt.h new file mode 100644 index 00000000000..e70b561d3df --- /dev/null +++ b/reactos/drivers/battery/cmbatt/cmbatt.h @@ -0,0 +1,58 @@ +/* +* PROJECT: ReactOS Kernel +* LICENSE: GPL - See COPYING in the top level directory +* FILE: drivers/battery/cmbatt/cmbatt.h +* PURPOSE: Control Method Battery Miniclass Driver +* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) +*/ + +#pragma once + +#include +#include + +typedef struct _CMBATT_DEVICE_EXTENSION { + PDEVICE_OBJECT Pdo; + PDEVICE_OBJECT Ldo; + PDEVICE_OBJECT Fdo; + PVOID BattClassHandle; + LIST_ENTRY ListEntry; +} CMBATT_DEVICE_EXTENSION, *PCMBATT_DEVICE_EXTENSION; + +NTSTATUS +NTAPI +CmBattQueryTag(PVOID Context, + PULONG BatteryTag); + +NTSTATUS +NTAPI +CmBattDisableStatusNotify(PVOID Context); + +NTSTATUS +NTAPI +CmBattSetStatusNotify(PVOID Context, + ULONG BatteryTag, + PBATTERY_NOTIFY BatteryNotify); + +NTSTATUS +NTAPI +CmBattQueryInformation(PVOID Context, + ULONG BatteryTag, + BATTERY_QUERY_INFORMATION_LEVEL Level, + OPTIONAL LONG AtRate, + PVOID Buffer, + ULONG BufferLength, + PULONG ReturnedLength); + +NTSTATUS +NTAPI +CmBattQueryStatus(PVOID Context, + ULONG BatteryTag, + PBATTERY_STATUS BatteryStatus); + +NTSTATUS +NTAPI +CmBattSetInformation(PVOID Context, + ULONG BatteryTag, + BATTERY_SET_INFORMATION_LEVEL Level, + OPTIONAL PVOID Buffer); diff --git a/reactos/drivers/battery/cmbatt/cmbatt.rbuild b/reactos/drivers/battery/cmbatt/cmbatt.rbuild new file mode 100644 index 00000000000..c41a072779c --- /dev/null +++ b/reactos/drivers/battery/cmbatt/cmbatt.rbuild @@ -0,0 +1,11 @@ + + + + ntoskrnl + hal + battc + . + cmbatt.c + miniclass.c + cmbatt.rc + diff --git a/reactos/drivers/battery/cmbatt/cmbatt.rc b/reactos/drivers/battery/cmbatt/cmbatt.rc new file mode 100644 index 00000000000..2fd6bc7713c --- /dev/null +++ b/reactos/drivers/battery/cmbatt/cmbatt.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Control Method Battery Miniclass Driver\0" +#define REACTOS_STR_INTERNAL_NAME "cmbatt\0" +#define REACTOS_STR_ORIGINAL_FILENAME "cmbatt.sys\0" +#include diff --git a/reactos/drivers/battery/cmbatt/miniclass.c b/reactos/drivers/battery/cmbatt/miniclass.c new file mode 100644 index 00000000000..bb75d9aa319 --- /dev/null +++ b/reactos/drivers/battery/cmbatt/miniclass.c @@ -0,0 +1,82 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/battery/cmbatt/miniclass.c + * PURPOSE: Control Method Battery Miniclass Driver + * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) + */ + +#include + +#define NDEBUG +#include + +NTSTATUS +NTAPI +CmBattQueryTag(PVOID Context, + PULONG BatteryTag) +{ + UNIMPLEMENTED + + *BatteryTag = 0; + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmBattDisableStatusNotify(PVOID Context) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +CmBattSetStatusNotify(PVOID Context, + ULONG BatteryTag, + PBATTERY_NOTIFY BatteryNotify) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +CmBattQueryInformation(PVOID Context, + ULONG BatteryTag, + BATTERY_QUERY_INFORMATION_LEVEL Level, + OPTIONAL LONG AtRate, + PVOID Buffer, + ULONG BufferLength, + PULONG ReturnedLength) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +CmBattQueryStatus(PVOID Context, + ULONG BatteryTag, + PBATTERY_STATUS BatteryStatus) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +CmBattSetInformation(PVOID Context, + ULONG BatteryTag, + BATTERY_SET_INFORMATION_LEVEL Level, + OPTIONAL PVOID Buffer) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} diff --git a/reactos/drivers/battery/directory.rbuild b/reactos/drivers/battery/directory.rbuild new file mode 100644 index 00000000000..2da9fe08c92 --- /dev/null +++ b/reactos/drivers/battery/directory.rbuild @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/reactos/drivers/drivers.rbuild b/reactos/drivers/drivers.rbuild index 5cc82caaca0..970810f015d 100644 --- a/reactos/drivers/drivers.rbuild +++ b/reactos/drivers/drivers.rbuild @@ -4,6 +4,9 @@ + + + diff --git a/reactos/media/inf/battery.inf b/reactos/media/inf/battery.inf new file mode 100644 index 00000000000..9ac8d8995e5 --- /dev/null +++ b/reactos/media/inf/battery.inf @@ -0,0 +1,52 @@ +; BATTERY.INF + +[Version] +Signature = "$Windows NT$" +;Signature = "$ReactOS$" +LayoutFile = layout.inf +Class = Battery +ClassGUID = {72631E54-78A4-11D0-BCF7-00AA00B7B32A} +Provider = %ReactOS% +DriverVer = 02/28/2010,1.00 + +[DestinationDirs] +DefaultDestDir = 12 + +[ClassInstall32.NT] +AddReg = BatteryClass.NT.AddReg + +[BatteryClass.NT.AddReg] +HKR, , , 0, %BatteryClassName% +;FIXME: Add icon here + +[Manufacturer] +%GenericMfg% = GenericMfg + +[GenericMfg] +%ACPI\PNP0C0A.DeviceDesc% = CmBatt,ACPI\PNP0C0A +%ACPI\ACPI0003.DeviceDesc% = CmBatt,ACPI\ACPI0003 + +[CmBatt] +CopyFiles = CmBatt_CopyFiles + +[CmBatt_CopyFiles] +cmbatt.sys +battc.sys + +[CmBatt.Services] +AddService = cmbatt, 0x00000002, CmBatt_Service_Install + +[CmBatt_Service_Install] +ServiceType = 1 +StartType = 3 +ErrorControl = 1 +ServiceBinary = %12%\cmbatt.sys + +[Strings] +ReactOS = "ReactOS Team" +BatteryClassName = "Batteries" + +GenericMfg = "(Generic batteries)" +ACPI\PNP0C0A.DeviceDesc = "ACPI-compliant control method battery" +ACPI\ACPI0003.DeviceDesc = "AC adapter" + From 8b48dd5b7cbbe13ac2fac5b65b35b85626065a68 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 8 Mar 2010 21:20:18 +0000 Subject: [PATCH 207/211] - [User32_winetest] - Msg : Remove more tests from service. test_timers crashed on a callback which passed months ago. The rest are related to TrackMouseEvent and capture. svn path=/trunk/; revision=46012 --- rostests/winetests/user32/msg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rostests/winetests/user32/msg.c b/rostests/winetests/user32/msg.c index 714e57f4bcb..56c15299042 100755 --- a/rostests/winetests/user32/msg.c +++ b/rostests/winetests/user32/msg.c @@ -12424,7 +12424,7 @@ START_TEST(msg) test_interthread_messages(); test_message_conversion(); test_accelerators(); - test_timers(); +// test_timers(); test_timers_no_wnd(); if (hCBT_hook) test_set_hook(); test_DestroyWindow(); @@ -12434,17 +12434,17 @@ START_TEST(msg) test_quit_message(); test_SetActiveWindow(); - if (!pTrackMouseEvent) +// if (!pTrackMouseEvent) win_skip("TrackMouseEvent is not available\n"); - else - test_TrackMouseEvent(); +// else +// test_TrackMouseEvent(); test_SetWindowRgn(); test_sys_menu(); test_dialog_messages(); test_nullCallback(); test_dbcs_wm_char(); - test_menu_messages(); +// test_menu_messages(); test_paintingloop(); test_defwinproc(); test_clipboard_viewers(); From d89923519b838ff65f07c1f511714223f6ca7174 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 8 Mar 2010 21:24:47 +0000 Subject: [PATCH 208/211] [User32] - David Hedberg Fix return value for EDIT_EM_Scroll and case where EM_SCROLL with page down results in trying to scroll up past the beginning. Sync to wine 1.1.40. svn path=/trunk/; revision=46013 --- reactos/dll/win32/user32/controls/edit.c | 9 ++++++--- reactos/media/doc/README.WINE | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/user32/controls/edit.c b/reactos/dll/win32/user32/controls/edit.c index 2dccbac3842..683c9dfe72a 100644 --- a/reactos/dll/win32/user32/controls/edit.c +++ b/reactos/dll/win32/user32/controls/edit.c @@ -1648,13 +1648,16 @@ static LRESULT EDIT_EM_Scroll(EDITSTATE *es, INT action) INT vlc = get_vertical_line_count(es); /* check if we are going to move too far */ if(es->y_offset + dy > es->line_count - vlc) - dy = es->line_count - vlc - es->y_offset; + dy = max(es->line_count - vlc, 0) - es->y_offset; /* Notification is done in EDIT_EM_LineScroll */ - if(dy) + if(dy) { EDIT_EM_LineScroll(es, 0, dy); + return MAKELONG((SHORT)dy, (BOOL)TRUE); + } + } - return MAKELONG((SHORT)dy, (BOOL)TRUE); + return (LRESULT)FALSE; } diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 78a24c54163..6bdb1f2b3b3 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -232,7 +232,7 @@ snmpapi - User32 - reactos/dll/win32/user32/controls/button.c # Synced to Wine-1_1_39 reactos/dll/win32/user32/controls/combo.c # Synced to Wine-1_1_39 - reactos/dll/win32/user32/controls/edit.c # Synced to Wine-1_1_39 + reactos/dll/win32/user32/controls/edit.c # Synced to Wine-1_1_40 reactos/dll/win32/user32/controls/icontitle.c # Synced to Wine-1_1_39 reactos/dll/win32/user32/controls/listbox.c # Synced to Wine-1_1_39 reactos/dll/win32/user32/controls/scrollbar.c # Forked From 37d9cf31a49a734a07fc41265fbe40c231d5ef5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 8 Mar 2010 21:40:29 +0000 Subject: [PATCH 209/211] Fix include directories svn path=/trunk/; revision=46015 --- reactos/lib/sdk/crt/libcntpr.rbuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/lib/sdk/crt/libcntpr.rbuild b/reactos/lib/sdk/crt/libcntpr.rbuild index 9a3f0c80da2..de0bb3033e6 100644 --- a/reactos/lib/sdk/crt/libcntpr.rbuild +++ b/reactos/lib/sdk/crt/libcntpr.rbuild @@ -1,8 +1,8 @@ - . - include + . + include From e10fbe352c6c29238a5753caefec4be89c1a8909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 8 Mar 2010 21:42:18 +0000 Subject: [PATCH 210/211] [headers] Fix type of PRTL_HEAP_PARAMETERS in ifssupp.h. Will be required soon svn path=/trunk/; revision=46016 --- reactos/include/ndk/ifssupp.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/reactos/include/ndk/ifssupp.h b/reactos/include/ndk/ifssupp.h index 15e58332c93..fe31f330582 100644 --- a/reactos/include/ndk/ifssupp.h +++ b/reactos/include/ndk/ifssupp.h @@ -27,7 +27,28 @@ typedef enum _TOKEN_TYPE TokenImpersonation } TOKEN_TYPE, *PTOKEN_TYPE; -typedef PVOID PRTL_HEAP_PARAMETERS; +typedef NTSTATUS +(NTAPI * PRTL_HEAP_COMMIT_ROUTINE)( + IN PVOID Base, + IN OUT PVOID *CommitAddress, + IN OUT PSIZE_T CommitSize +); + +typedef struct _RTL_HEAP_PARAMETERS +{ + ULONG Length; + SIZE_T SegmentReserve; + SIZE_T SegmentCommit; + SIZE_T DeCommitFreeBlockThreshold; + SIZE_T DeCommitTotalFreeThreshold; + SIZE_T MaximumAllocationSize; + SIZE_T VirtualMemoryThreshold; + SIZE_T InitialCommit; + SIZE_T InitialReserve; + PRTL_HEAP_COMMIT_ROUTINE CommitRoutine; + SIZE_T Reserved[2]; +} RTL_HEAP_PARAMETERS, *PRTL_HEAP_PARAMETERS; + typedef PVOID PFS_FILTER_CALLBACKS; typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL; From 61fef12a72938e5e56f9c5f4adafb7f8bc1dc4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 8 Mar 2010 22:04:38 +0000 Subject: [PATCH 211/211] [freeldr] Load an additional SCSI driver if present (NTBOOTSYS.SYS on boot partition), to increase number of known storage devices. Works only with very simple miniport drivers. svn path=/trunk/; revision=46017 --- reactos/boot/freeldr/freeldr/bootmgr.c | 6 + reactos/boot/freeldr/freeldr/disk/scsiport.c | 1701 +++++++++++++++++ reactos/boot/freeldr/freeldr/freeldr.c | 5 + .../boot/freeldr/freeldr/freeldr_base.rbuild | 1 + reactos/boot/freeldr/freeldr/include/disk.h | 2 + .../boot/freeldr/freeldr/include/reactos.h | 8 + .../boot/freeldr/freeldr/reactos/arcname.c | 56 + .../boot/freeldr/freeldr/windows/peloader.c | 2 +- 8 files changed, 1780 insertions(+), 1 deletion(-) create mode 100644 reactos/boot/freeldr/freeldr/disk/scsiport.c diff --git a/reactos/boot/freeldr/freeldr/bootmgr.c b/reactos/boot/freeldr/freeldr/bootmgr.c index 2a8e7be272b..0959de69d69 100644 --- a/reactos/boot/freeldr/freeldr/bootmgr.c +++ b/reactos/boot/freeldr/freeldr/bootmgr.c @@ -119,6 +119,12 @@ VOID RunLoader(VOID) return; } + // Load additional SCSI driver (if any) + if (LoadBootDeviceDriver() != ESUCCESS) + { + UiMessageBoxCritical("Unable to load additional boot device driver"); + } + if (!IniFileInitialize()) { UiMessageBoxCritical("Error initializing .ini file"); diff --git a/reactos/boot/freeldr/freeldr/disk/scsiport.c b/reactos/boot/freeldr/freeldr/disk/scsiport.c new file mode 100644 index 00000000000..d8d15b12d84 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/disk/scsiport.c @@ -0,0 +1,1701 @@ +#include + +#define _SCSIPORT_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define NDEBUG +#include + +#define DPRINTM2(fmt, ...) DPRINTM(DPRINT_SCSIPORT, "(%s:%d) SCSIPORT: " fmt, __FILE__, __LINE__, __VA_ARGS__) + +#undef UNIMPLEMENTED +#define UNIMPLEMENTED DPRINTM2("%s UNIMPLEMENTED\n", __FUNCTION__) + +#define SCSI_PORT_NEXT_REQUEST_READY 0x0008 + +typedef struct +{ + PVOID NonCachedExtension; + + ULONG BusNum; + ULONG MaxTargedIds; + + ULONG InterruptFlags; + + /* SRB extension stuff */ + ULONG SrbExtensionSize; + PVOID SrbExtensionBuffer; + + IO_SCSI_CAPABILITIES PortCapabilities; + + PHW_INITIALIZE HwInitialize; + PHW_STARTIO HwStartIo; + PHW_INTERRUPT HwInterrupt; + PHW_RESET_BUS HwResetBus; + + /* DMA related stuff */ + PADAPTER_OBJECT AdapterObject; + + ULONG CommonBufferLength; + + PVOID MiniPortDeviceExtension; +} SCSI_PORT_DEVICE_EXTENSION, *PSCSI_PORT_DEVICE_EXTENSION; + +PSCSI_PORT_DEVICE_EXTENSION ScsiDeviceExtensions[SCSI_MAXIMUM_BUSES]; + +ULONG +ntohl( + IN ULONG Value) +{ + FOUR_BYTE Dest; + PFOUR_BYTE Source = (PFOUR_BYTE)&Value; + + Dest.Byte0 = Source->Byte3; + Dest.Byte1 = Source->Byte2; + Dest.Byte2 = Source->Byte1; + Dest.Byte3 = Source->Byte0; + + return Dest.AsULong; +} + +BOOLEAN +SpiSendSynchronousSrb( + IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb) +{ + BOOLEAN ret; + + ASSERT(!(Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE)); + + /* HACK: handle lack of interrupts */ + while (!(DeviceExtension->InterruptFlags & SCSI_PORT_NEXT_REQUEST_READY)) + { + KeStallExecutionProcessor(100 * 1000); + DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension); + } + + DeviceExtension->InterruptFlags &= ~SCSI_PORT_NEXT_REQUEST_READY; + Srb->SrbFlags |= SRB_FLAGS_IS_ACTIVE; + + if (!DeviceExtension->HwStartIo( + DeviceExtension->MiniPortDeviceExtension, + Srb)) + { + ExFreePool(Srb); + return FALSE; + } + + /* HACK: handle lack of interrupts */ + while (Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE) + { + KeStallExecutionProcessor(100 * 1000); + DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension); + } + + ret = SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_SUCCESS; + ExFreePool(Srb); + + return ret; +} + +typedef struct tagDISKCONTEXT +{ + /* Device ID */ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + ULONG PathId; + ULONG TargetId; + ULONG Lun; + + /* Device characteristics */ + ULONG SectorSize; + ULONGLONG SectorOffset; + ULONGLONG SectorCount; + ULONGLONG SectorNumber; +} DISKCONTEXT; + +static LONG DiskClose(ULONG FileId) +{ + DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + + ExFreePool(Context); + return ESUCCESS; +} + +static LONG DiskGetFileInformation(ULONG FileId, FILEINFORMATION* Information) +{ + DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + + RtlZeroMemory(Information, sizeof(FILEINFORMATION)); + Information->EndingAddress.QuadPart = Context->SectorCount * Context->SectorSize; + Information->CurrentAddress.LowPart = Context->SectorNumber * Context->SectorSize; + + return ESUCCESS; +} + +static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) +{ + PSCSI_REQUEST_BLOCK Srb; + PCDB Cdb; + READ_CAPACITY_DATA ReadCapacityBuffer; + + DISKCONTEXT* Context; + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + ULONG ScsiBus, PathId, TargetId, Lun, Partition, PathSyntax; + ULONG SectorSize; + ULONGLONG SectorOffset = 0; + ULONGLONG SectorCount; + + /* Parse ARC path */ + if (!DissectArcPath2(Path, &ScsiBus, &TargetId, &Lun, &Partition, &PathSyntax)) + return EINVAL; + if (PathSyntax != 0) /* scsi() format */ + return EINVAL; + DeviceExtension = ScsiDeviceExtensions[ScsiBus]; + PathId = ScsiBus - DeviceExtension->BusNum; + + /* Get disk capacity and sector size */ + Srb = ExAllocatePool(PagedPool, sizeof(SCSI_REQUEST_BLOCK)); + if (!Srb) + return ENOMEM; + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->PathId = PathId; + Srb->TargetId = TargetId; + Srb->Lun = Lun; + Srb->CdbLength = 10; + Srb->SrbFlags = SRB_FLAGS_DATA_IN; + Srb->DataTransferLength = sizeof(READ_CAPACITY_DATA); + Srb->TimeOutValue = 5; /* in seconds */ + Srb->DataBuffer = &ReadCapacityBuffer; + Cdb = (PCDB)Srb->Cdb; + Cdb->CDB10.OperationCode = SCSIOP_READ_CAPACITY; + if (!SpiSendSynchronousSrb(DeviceExtension, Srb)) + { + return EIO; + } + + /* Transform result to host endianness */ + SectorCount = ntohl(ReadCapacityBuffer.LogicalBlockAddress); + SectorSize = ntohl(ReadCapacityBuffer.BytesPerBlock); + + if (Partition != 0) + { + /* Need to offset start of disk and length */ + UNIMPLEMENTED; + return EIO; + } + + Context = ExAllocatePool(PagedPool, sizeof(DISKCONTEXT)); + if (!Context) + return ENOMEM; + Context->DeviceExtension = DeviceExtension; + Context->PathId = PathId; + Context->TargetId = TargetId; + Context->Lun = Lun; + Context->SectorSize = SectorSize; + Context->SectorOffset = SectorOffset; + Context->SectorCount = SectorCount; + Context->SectorNumber = 0; + FsSetDeviceSpecific(*FileId, Context); + + return ESUCCESS; +} + +static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count) +{ + DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + PSCSI_REQUEST_BLOCK Srb; + PCDB Cdb; + ULONG FullSectors, NbSectors; + ULONG Lba; + + *Count = 0; + + if (N == 0) + return ESUCCESS; + + FullSectors = N / Context->SectorSize; + NbSectors = (N + Context->SectorSize - 1) / Context->SectorSize; + if (Context->SectorNumber + NbSectors >= Context->SectorCount) + return EINVAL; + if (FullSectors > 0xffff) + return EINVAL; + + /* Read full sectors */ + Lba = Context->SectorNumber; + if (FullSectors > 0) + { + Srb = ExAllocatePool(PagedPool, sizeof(SCSI_REQUEST_BLOCK)); + if (!Srb) + return ENOMEM; + + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->PathId = Context->PathId; + Srb->TargetId = Context->TargetId; + Srb->Lun = Context->Lun; + Srb->CdbLength = 10; + Srb->SrbFlags = SRB_FLAGS_DATA_IN; + Srb->DataTransferLength = FullSectors * Context->SectorSize; + Srb->TimeOutValue = 5; /* in seconds */ + Srb->DataBuffer = Buffer; + Cdb = (PCDB)Srb->Cdb; + Cdb->CDB10.OperationCode = SCSIOP_READ; + Cdb->CDB10.LogicalUnitNumber = Srb->Lun; + Cdb->CDB10.LogicalBlockByte0 = (Lba >> 24) & 0xff; + Cdb->CDB10.LogicalBlockByte1 = (Lba >> 16) & 0xff; + Cdb->CDB10.LogicalBlockByte2 = (Lba >> 8) & 0xff; + Cdb->CDB10.LogicalBlockByte3 = Lba & 0xff; + Cdb->CDB10.TransferBlocksMsb = (FullSectors >> 8) & 0xff; + Cdb->CDB10.TransferBlocksLsb = FullSectors & 0xff; + if (!SpiSendSynchronousSrb(Context->DeviceExtension, Srb)) + { + return EIO; + } + Buffer = (PUCHAR)Buffer + FullSectors * Context->SectorSize; + N -= FullSectors * Context->SectorSize; + *Count += FullSectors * Context->SectorSize; + Lba += FullSectors; + } + + /* Read incomplete last sector */ + if (N > 0) + { + PUCHAR Sector; + + Sector = ExAllocatePool(PagedPool, Context->SectorSize); + if (!Sector) + return ENOMEM; + + Srb = ExAllocatePool(PagedPool, sizeof(SCSI_REQUEST_BLOCK)); + if (!Srb) + { + ExFreePool(Sector); + return ENOMEM; + } + + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->PathId = Context->PathId; + Srb->TargetId = Context->TargetId; + Srb->Lun = Context->Lun; + Srb->CdbLength = 10; + Srb->SrbFlags = SRB_FLAGS_DATA_IN; + Srb->DataTransferLength = Context->SectorSize; + Srb->TimeOutValue = 5; /* in seconds */ + Srb->DataBuffer = Sector; + Cdb = (PCDB)Srb->Cdb; + Cdb->CDB10.OperationCode = SCSIOP_READ; + Cdb->CDB10.LogicalUnitNumber = Srb->Lun; + Cdb->CDB10.LogicalBlockByte0 = (Lba >> 24) & 0xff; + Cdb->CDB10.LogicalBlockByte1 = (Lba >> 16) & 0xff; + Cdb->CDB10.LogicalBlockByte2 = (Lba >> 8) & 0xff; + Cdb->CDB10.LogicalBlockByte3 = Lba & 0xff; + Cdb->CDB10.TransferBlocksMsb = 0; + Cdb->CDB10.TransferBlocksLsb = 1; + if (!SpiSendSynchronousSrb(Context->DeviceExtension, Srb)) + { + ExFreePool(Sector); + return EIO; + } + RtlCopyMemory(Buffer, Sector, N); + *Count += N; + ExFreePool(Sector); + } + + return ESUCCESS; +} + +static LONG DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode) +{ + DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + + if (SeekMode != SeekAbsolute) + return EINVAL; + if (Position->QuadPart & (Context->SectorSize - 1)) + return EINVAL; + + Context->SectorNumber = Position->QuadPart / Context->SectorSize; + return ESUCCESS; +} + +static const DEVVTBL DiskVtbl = { + DiskClose, + DiskGetFileInformation, + DiskOpen, + DiskRead, + DiskSeek, +}; + +NTSTATUS +SpiCreatePortConfig( + IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PHW_INITIALIZATION_DATA HwInitData, + OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, + IN BOOLEAN ZeroStruct) +{ + ULONG Bus; + + /* Zero out the struct if told so */ + if (ZeroStruct) + { + /* First zero the portconfig */ + RtlZeroMemory(ConfigInfo, sizeof(PORT_CONFIGURATION_INFORMATION)); + + /* Initialize the struct */ + ConfigInfo->Length = sizeof(PORT_CONFIGURATION_INFORMATION); + ConfigInfo->AdapterInterfaceType = HwInitData->AdapterInterfaceType; + ConfigInfo->InterruptMode = Latched; + ConfigInfo->DmaChannel = SP_UNINITIALIZED_VALUE; + ConfigInfo->DmaPort = SP_UNINITIALIZED_VALUE; + ConfigInfo->MaximumTransferLength = SP_UNINITIALIZED_VALUE; + ConfigInfo->MaximumNumberOfTargets = SCSI_MAXIMUM_TARGETS_PER_BUS; + + /* Store parameters */ + ConfigInfo->NeedPhysicalAddresses = HwInitData->NeedPhysicalAddresses; + ConfigInfo->MapBuffers = HwInitData->MapBuffers; + ConfigInfo->AutoRequestSense = HwInitData->AutoRequestSense; + ConfigInfo->ReceiveEvent = HwInitData->ReceiveEvent; + ConfigInfo->TaggedQueuing = HwInitData->TaggedQueuing; + ConfigInfo->MultipleRequestPerLu = HwInitData->MultipleRequestPerLu; + + /* Get the disk usage */ + ConfigInfo->AtdiskPrimaryClaimed = FALSE; // FIXME + ConfigInfo->AtdiskSecondaryClaimed = FALSE; // FIXME + + /* Initiator bus id is not set */ + for (Bus = 0; Bus < 8; Bus++) + ConfigInfo->InitiatorBusId[Bus] = (CCHAR)SP_UNINITIALIZED_VALUE; + } + + ConfigInfo->NumberOfPhysicalBreaks = 17; + + return STATUS_SUCCESS; +} + +VOID +DDKCDECLAPI +ScsiDebugPrint( + IN ULONG DebugPrintLevel, + IN PCCHAR DebugMessage, + IN ...) +{ + va_list ap; + CHAR Buffer[512]; + ULONG Length; + + if (DebugPrintLevel > 10) + return; + + va_start(ap, DebugMessage); + + /* Construct a string */ + Length = _vsnprintf(Buffer, 512, DebugMessage, ap); + + /* Check if we went past the buffer */ + if (Length == MAXULONG) + { + /* Terminate it if we went over-board */ + Buffer[sizeof(Buffer) - 1] = '\0'; + + /* Put maximum */ + Length = sizeof(Buffer); + } + + /* Print the message */ + DPRINTM(DPRINT_SCSIPORT, "%s", Buffer); + + /* Cleanup */ + va_end(ap); +} + +VOID +DDKAPI +ScsiPortCompleteRequest( + IN PVOID HwDeviceExtension, + IN UCHAR PathId, + IN UCHAR TargetId, + IN UCHAR Lun, + IN UCHAR SrbStatus) +{ + // FIXME + UNIMPLEMENTED; +} + +#undef ScsiPortConvertPhysicalAddressToUlong +ULONG +DDKAPI +ScsiPortConvertPhysicalAddressToUlong( + IN SCSI_PHYSICAL_ADDRESS Address) +{ + return Address.LowPart; +} + +SCSI_PHYSICAL_ADDRESS +DDKAPI +ScsiPortConvertUlongToPhysicalAddress( + IN ULONG UlongAddress) +{ + return RtlConvertUlongToLargeInteger(UlongAddress); +} + +VOID +DDKAPI +ScsiPortFlushDma( + IN PVOID DeviceExtension) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortFreeDeviceBase( + IN PVOID HwDeviceExtension, + IN PVOID MappedAddress) +{ + // Nothing to do +} + +ULONG +DDKAPI +ScsiPortGetBusData( + IN PVOID DeviceExtension, + IN ULONG BusDataType, + IN ULONG SystemIoBusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length) +{ + return HalGetBusDataByOffset(BusDataType, SystemIoBusNumber, SlotNumber, Buffer, 0, Length); +} + +PVOID +DDKAPI +ScsiPortGetDeviceBase( + IN PVOID HwDeviceExtension, + IN INTERFACE_TYPE BusType, + IN ULONG SystemIoBusNumber, + IN SCSI_PHYSICAL_ADDRESS IoAddress, + IN ULONG NumberOfBytes, + IN BOOLEAN InIoSpace) +{ + PHYSICAL_ADDRESS TranslatedAddress; + ULONG AddressSpace; + + AddressSpace = (ULONG)InIoSpace; + if (HalTranslateBusAddress(BusType, + SystemIoBusNumber, + IoAddress, + &AddressSpace, + &TranslatedAddress) == FALSE) + { + return NULL; + } + + /* I/O space */ + if (AddressSpace != 0) + return (PVOID)TranslatedAddress.u.LowPart; + + // FIXME + UNIMPLEMENTED; + return (PVOID)IoAddress.LowPart; +} + +PVOID +DDKAPI +ScsiPortGetLogicalUnit( + IN PVOID HwDeviceExtension, + IN UCHAR PathId, + IN UCHAR TargetId, + IN UCHAR Lun) +{ + // FIXME + UNIMPLEMENTED; + return NULL; +} + +SCSI_PHYSICAL_ADDRESS +DDKAPI +ScsiPortGetPhysicalAddress( + IN PVOID HwDeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, + IN PVOID VirtualAddress, + OUT ULONG *Length) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + SCSI_PHYSICAL_ADDRESS PhysicalAddress; + ULONG BufferLength = 0; + ULONG Offset; + + DPRINTM2("ScsiPortGetPhysicalAddress(%p %p %p %p)\n", + HwDeviceExtension, Srb, VirtualAddress, Length); + + DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1; + + if (Srb == NULL || Srb->SenseInfoBuffer == VirtualAddress) + { + /* Simply look it up in the allocated common buffer */ + Offset = (PUCHAR)VirtualAddress - (PUCHAR)DeviceExtension->SrbExtensionBuffer; + + BufferLength = DeviceExtension->CommonBufferLength - Offset; + PhysicalAddress.QuadPart = Offset; + } + else + { + /* Nothing */ + *Length = 0; + PhysicalAddress.QuadPart = (LONGLONG)(SP_UNINITIALIZED_VALUE); + } + + *Length = BufferLength; + return PhysicalAddress; +} + +PSCSI_REQUEST_BLOCK +DDKAPI +ScsiPortGetSrb( + IN PVOID DeviceExtension, + IN UCHAR PathId, + IN UCHAR TargetId, + IN UCHAR Lun, + IN LONG QueueTag) +{ + // FIXME + UNIMPLEMENTED; + return NULL; +} + +NTSTATUS +SpiAllocateCommonBuffer( + IN OUT PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN ULONG NonCachedSize) +{ + PVOID CommonBuffer; + ULONG CommonBufferLength, BufSize; + + /* If size is 0, set it to 16 */ + if (!DeviceExtension->SrbExtensionSize) + DeviceExtension->SrbExtensionSize = 16; + + /* Calculate size */ + BufSize = DeviceExtension->SrbExtensionSize; + + /* Round it */ + BufSize = (BufSize + sizeof(LONGLONG) - 1) & ~(sizeof(LONGLONG) - 1); + + /* Sum up into the total common buffer length, and round it to page size */ + CommonBufferLength = + ROUND_TO_PAGES(NonCachedSize); + + /* Allocate it */ + if (!DeviceExtension->AdapterObject) + { + /* From nonpaged pool if there is no DMA */ + CommonBuffer = ExAllocatePool(NonPagedPool, CommonBufferLength); + } + else + { + /* Perform a full request since we have a DMA adapter*/ + UNIMPLEMENTED; + CommonBuffer = NULL; + } + + /* Fail in case of error */ + if (!CommonBuffer) + return STATUS_INSUFFICIENT_RESOURCES; + + /* Zero it */ + RtlZeroMemory(CommonBuffer, CommonBufferLength); + + /* Store its size in Device Extension */ + DeviceExtension->CommonBufferLength = CommonBufferLength; + + /* SrbExtension buffer is located at the beginning of the buffer */ + DeviceExtension->SrbExtensionBuffer = CommonBuffer; + + /* Non-cached extension buffer is located at the end of + the common buffer */ + if (NonCachedSize) + { + CommonBufferLength -= NonCachedSize; + DeviceExtension->NonCachedExtension = (PUCHAR)CommonBuffer + CommonBufferLength; + } + else + { + DeviceExtension->NonCachedExtension = NULL; + } + + return STATUS_SUCCESS; +} + +PVOID +DDKAPI +ScsiPortGetUncachedExtension( + IN PVOID HwDeviceExtension, + IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, + IN ULONG NumberOfBytes) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + DEVICE_DESCRIPTION DeviceDescription; + ULONG MapRegistersCount; + NTSTATUS Status; + + DPRINTM2("ScsiPortGetUncachedExtension(%p %p %lu)\n", + HwDeviceExtension, ConfigInfo, NumberOfBytes); + + DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1; + + /* Check for allocated common DMA buffer */ + if (DeviceExtension->SrbExtensionBuffer != NULL) + { + return NULL; + } + + /* Check for DMA adapter object */ + if (DeviceExtension->AdapterObject == NULL) + { + /* Initialize DMA adapter description */ + RtlZeroMemory(&DeviceDescription, sizeof(DEVICE_DESCRIPTION)); + + DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION; + DeviceDescription.Master = ConfigInfo->Master; + DeviceDescription.ScatterGather = ConfigInfo->ScatterGather; + DeviceDescription.DemandMode = ConfigInfo->DemandMode; + DeviceDescription.Dma32BitAddresses = ConfigInfo->Dma32BitAddresses; + DeviceDescription.BusNumber = ConfigInfo->SystemIoBusNumber; + DeviceDescription.DmaChannel = ConfigInfo->DmaChannel; + DeviceDescription.InterfaceType = ConfigInfo->AdapterInterfaceType; + DeviceDescription.DmaWidth = ConfigInfo->DmaWidth; + DeviceDescription.DmaSpeed = ConfigInfo->DmaSpeed; + DeviceDescription.MaximumLength = ConfigInfo->MaximumTransferLength; + DeviceDescription.DmaPort = ConfigInfo->DmaPort; + + /* Get a DMA adapter object */ +#if 0 + DeviceExtension->AdapterObject = + HalGetAdapter(&DeviceDescription, &MapRegistersCount); + + /* Fail in case of error */ + if (DeviceExtension->AdapterObject == NULL) + { + return NULL; + } +#else + MapRegistersCount = 0; +#endif + + /* Set number of physical breaks */ + if (ConfigInfo->NumberOfPhysicalBreaks != 0 && + MapRegistersCount > ConfigInfo->NumberOfPhysicalBreaks) + { + DeviceExtension->PortCapabilities.MaximumPhysicalPages = + ConfigInfo->NumberOfPhysicalBreaks; + } + else + { + DeviceExtension->PortCapabilities.MaximumPhysicalPages = MapRegistersCount; + } + } + + /* Update Srb extension size */ + if (DeviceExtension->SrbExtensionSize != ConfigInfo->SrbExtensionSize) + DeviceExtension->SrbExtensionSize = ConfigInfo->SrbExtensionSize; + + /* Allocate a common DMA buffer */ + Status = SpiAllocateCommonBuffer(DeviceExtension, NumberOfBytes); + + if (!NT_SUCCESS(Status)) + { + DPRINTM2("SpiAllocateCommonBuffer() failed with Status = 0x%08X!\n", Status); + return NULL; + } + + return DeviceExtension->NonCachedExtension; +} + +PVOID +DDKAPI +ScsiPortGetVirtualAddress( + IN PVOID HwDeviceExtension, + IN SCSI_PHYSICAL_ADDRESS PhysicalAddress) +{ + // FIXME + UNIMPLEMENTED; + return NULL; +} + +VOID +SpiScanDevice( + IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PCHAR ArcName, + IN ULONG ScsiBus, + IN ULONG TargetId, + IN ULONG Lun) +{ + ULONG FileId, i; + ULONG Status; + NTSTATUS ret; + struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer; + CHAR PartitionName[64]; + + /* Register device with partition(0) suffix */ + sprintf(PartitionName, "%spartition(0)", ArcName); + FsRegisterDevice(PartitionName, &DiskVtbl); + + /* Read device partition table */ + Status = ArcOpen(PartitionName, OpenReadOnly, &FileId); + if (Status == ESUCCESS) + { + ret = HALDISPATCH->HalIoReadPartitionTable((PDEVICE_OBJECT)FileId, 512, FALSE, &PartitionBuffer); + if (NT_SUCCESS(ret)) + { + for (i = 0; i < PartitionBuffer->PartitionCount; i++) + { + if (PartitionBuffer->PartitionEntry[i].PartitionType != PARTITION_ENTRY_UNUSED) + { + sprintf(PartitionName, "%spartition(%lu)", + ArcName, PartitionBuffer->PartitionEntry[i].PartitionNumber); + FsRegisterDevice(PartitionName, &DiskVtbl); + } + } + ExFreePool(PartitionBuffer); + } + ArcClose(FileId); + } +} + +VOID +SpiScanAdapter( + IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN ULONG ScsiBus, + IN ULONG PathId) +{ + CHAR ArcName[64]; + PSCSI_REQUEST_BLOCK Srb; + PCDB Cdb; + INQUIRYDATA InquiryBuffer; + ULONG TargetId; + ULONG Lun; + + if (!DeviceExtension->HwResetBus(DeviceExtension->MiniPortDeviceExtension, PathId)) + { + return; + } + + /* Remember the extension */ + ScsiDeviceExtensions[ScsiBus] = DeviceExtension; + + for (TargetId = 0; TargetId < DeviceExtension->MaxTargedIds; TargetId++) + { + Lun = 0; + do + { + DPRINTM2("Scanning SCSI device %d.%d.%d\n", + ScsiBus, TargetId, Lun); + + Srb = ExAllocatePool(PagedPool, sizeof(SCSI_REQUEST_BLOCK)); + if (!Srb) + break; + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->PathId = PathId; + Srb->TargetId = TargetId; + Srb->Lun = Lun; + Srb->CdbLength = 6; + Srb->SrbFlags = SRB_FLAGS_DATA_IN; + Srb->DataTransferLength = INQUIRYDATABUFFERSIZE; + Srb->TimeOutValue = 5; /* in seconds */ + Srb->DataBuffer = &InquiryBuffer; + Cdb = (PCDB)Srb->Cdb; + Cdb->CDB6INQUIRY.OperationCode = SCSIOP_INQUIRY; + Cdb->CDB6INQUIRY.LogicalUnitNumber = Srb->Lun; + Cdb->CDB6INQUIRY.AllocationLength = Srb->DataTransferLength; + if (!SpiSendSynchronousSrb(DeviceExtension, Srb)) + { + /* Don't check next LUNs */ + break; + } + + /* Device exists, create its ARC name */ + if (InquiryBuffer.RemovableMedia) + { + sprintf(ArcName, "scsi(%ld)cdrom(%ld)fdisk(%ld)", + ScsiBus, TargetId, Lun); + FsRegisterDevice(ArcName, &DiskVtbl); + } + else + { + sprintf(ArcName, "scsi(%ld)disk(%ld)rdisk(%ld)", + ScsiBus, TargetId, Lun); + /* Now, check if it has partitions */ + SpiScanDevice(DeviceExtension, ArcName, PathId, TargetId, Lun); + } + + /* Check next LUN */ + Lun++; + } while (Lun < SCSI_MAXIMUM_LOGICAL_UNITS); + } +} + +VOID +SpiResourceToConfig( + IN PHW_INITIALIZATION_DATA HwInitializationData, + IN PCM_FULL_RESOURCE_DESCRIPTOR ResourceDescriptor, + IN OUT PPORT_CONFIGURATION_INFORMATION PortConfig) +{ + PACCESS_RANGE AccessRange; + PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialData; + ULONG RangeNumber; + ULONG Index; + + RangeNumber = 0; + + /* Loop through all entries */ + for (Index = 0; Index < ResourceDescriptor->PartialResourceList.Count; Index++) + { + PartialData = &ResourceDescriptor->PartialResourceList.PartialDescriptors[Index]; + + switch (PartialData->Type) + { + case CmResourceTypePort: + /* Copy access ranges */ + if (RangeNumber < HwInitializationData->NumberOfAccessRanges) + { + DPRINTM2("Got port at 0x%I64x, len 0x%x\n", + PartialData->u.Port.Start.QuadPart, PartialData->u.Port.Length); + AccessRange = &((*(PortConfig->AccessRanges))[RangeNumber]); + + AccessRange->RangeStart = PartialData->u.Port.Start; + AccessRange->RangeLength = PartialData->u.Port.Length; + + AccessRange->RangeInMemory = FALSE; + RangeNumber++; + } + break; + + case CmResourceTypeMemory: + /* Copy access ranges */ + if (RangeNumber < HwInitializationData->NumberOfAccessRanges) + { + DPRINTM2("Got memory at 0x%I64x, len 0x%x\n", + PartialData->u.Memory.Start.QuadPart, PartialData->u.Memory.Length); + AccessRange = &((*(PortConfig->AccessRanges))[RangeNumber]); + + AccessRange->RangeStart = PartialData->u.Memory.Start; + AccessRange->RangeLength = PartialData->u.Memory.Length; + + AccessRange->RangeInMemory = TRUE; + RangeNumber++; + } + break; + + case CmResourceTypeInterrupt: + /* Copy interrupt data */ + DPRINTM2("Got interrupt level %d, vector %d\n", + PartialData->u.Interrupt.Level, PartialData->u.Interrupt.Vector); + PortConfig->BusInterruptLevel = PartialData->u.Interrupt.Level; + PortConfig->BusInterruptVector = PartialData->u.Interrupt.Vector; + + /* Set interrupt mode accordingly to the resource */ + if (PartialData->Flags == CM_RESOURCE_INTERRUPT_LATCHED) + { + PortConfig->InterruptMode = Latched; + } + else if (PartialData->Flags == CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE) + { + PortConfig->InterruptMode = LevelSensitive; + } + break; + + case CmResourceTypeDma: + DPRINTM2("Got DMA channel %d, port %d\n", + PartialData->u.Dma.Channel, PartialData->u.Dma.Port); + PortConfig->DmaChannel = PartialData->u.Dma.Channel; + PortConfig->DmaPort = PartialData->u.Dma.Port; + break; + } + } +} + +BOOLEAN +SpiGetPciConfigData( + IN struct _HW_INITIALIZATION_DATA *HwInitializationData, + IN OUT PPORT_CONFIGURATION_INFORMATION PortConfig, + IN ULONG BusNumber, + IN OUT PPCI_SLOT_NUMBER NextSlotNumber) +{ + PCI_COMMON_CONFIG PciConfig; + PCI_SLOT_NUMBER SlotNumber; + ULONG DataSize; + ULONG DeviceNumber; + ULONG FunctionNumber; + CHAR VendorIdString[8]; + CHAR DeviceIdString[8]; + PCM_RESOURCE_LIST ResourceList; + NTSTATUS Status; + + RtlZeroMemory(&ResourceList, sizeof(PCM_RESOURCE_LIST)); + SlotNumber.u.AsULONG = 0; + + /* Loop through all devices */ + for (DeviceNumber = NextSlotNumber->u.bits.DeviceNumber; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++) + { + SlotNumber.u.bits.DeviceNumber = DeviceNumber; + + /* Loop through all functions */ + for (FunctionNumber = NextSlotNumber->u.bits.FunctionNumber; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++) + { + SlotNumber.u.bits.FunctionNumber = FunctionNumber; + + /* Get PCI config bytes */ + DataSize = HalGetBusDataByOffset( + PCIConfiguration, + BusNumber, + SlotNumber.u.AsULONG, + &PciConfig, + 0, + sizeof(ULONG)); + + /* If result of HalGetBusData is 0, then the bus is wrong */ + if (DataSize == 0) + return FALSE; + + /* If result is PCI_INVALID_VENDORID, then this device has no more + "Functions" */ + if (PciConfig.VendorID == PCI_INVALID_VENDORID) + break; + + sprintf(VendorIdString, "%04hx", PciConfig.VendorID); + sprintf(DeviceIdString, "%04hx", PciConfig.DeviceID); + + if (_strnicmp(VendorIdString, HwInitializationData->VendorId, HwInitializationData->VendorIdLength) || + _strnicmp(DeviceIdString, HwInitializationData->DeviceId, HwInitializationData->DeviceIdLength)) + { + /* It is not our device */ + continue; + } + + DPRINTM2( "Found device 0x%04hx 0x%04hx at %1lu %2lu %1lu\n", + PciConfig.VendorID, PciConfig.DeviceID, + BusNumber, + SlotNumber.u.bits.DeviceNumber, SlotNumber.u.bits.FunctionNumber); + + Status = HalAssignSlotResources(NULL, + NULL, + NULL, + NULL, + PCIBus, + BusNumber, + SlotNumber.u.AsULONG, + &ResourceList); + + if (!NT_SUCCESS(Status)) + break; + + /* Create configuration information */ + SpiResourceToConfig(HwInitializationData, + ResourceList->List, + PortConfig); + + /* Free the resource list */ + ExFreePool(ResourceList); + + /* Set dev & fn numbers */ + NextSlotNumber->u.bits.DeviceNumber = DeviceNumber; + NextSlotNumber->u.bits.FunctionNumber = FunctionNumber + 1; + + /* Save the slot number */ + PortConfig->SlotNumber = SlotNumber.u.AsULONG; + + return TRUE; + } + NextSlotNumber->u.bits.FunctionNumber = 0; + } + + NextSlotNumber->u.bits.DeviceNumber = 0; + + return FALSE; +} + +ULONG +DDKAPI +ScsiPortInitialize( + IN PVOID Argument1, + IN PVOID Argument2, + IN struct _HW_INITIALIZATION_DATA *HwInitializationData, + IN PVOID HwContext OPTIONAL) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + ULONG DeviceExtensionSize; + PORT_CONFIGURATION_INFORMATION PortConfig; + BOOLEAN Again; + BOOLEAN FirstConfigCall = TRUE; + PCI_SLOT_NUMBER SlotNumber; + NTSTATUS Status; + + if (HwInitializationData->HwInitializationDataSize != sizeof(HW_INITIALIZATION_DATA)) + { + return STATUS_INVALID_PARAMETER; + } + + /* Check params for validity */ + if ((HwInitializationData->HwInitialize == NULL) || + (HwInitializationData->HwStartIo == NULL) || + (HwInitializationData->HwInterrupt == NULL) || + (HwInitializationData->HwFindAdapter == NULL) || + (HwInitializationData->HwResetBus == NULL)) + { + return STATUS_INVALID_PARAMETER; + } + + /* Zero starting slot number */ + SlotNumber.u.AsULONG = 0; + + while (TRUE) + { + Again = FALSE; + + DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) + HwInitializationData->DeviceExtensionSize; + DeviceExtension = MmHeapAlloc(DeviceExtensionSize); + if (!DeviceExtension) + { + return STATUS_NO_MEMORY; + } + RtlZeroMemory(DeviceExtension, DeviceExtensionSize); + DeviceExtension->InterruptFlags = SCSI_PORT_NEXT_REQUEST_READY; + DeviceExtension->HwInitialize = HwInitializationData->HwInitialize; + DeviceExtension->HwStartIo = HwInitializationData->HwStartIo; + DeviceExtension->HwInterrupt = HwInitializationData->HwInterrupt; + DeviceExtension->HwResetBus = HwInitializationData->HwResetBus; + DeviceExtension->MiniPortDeviceExtension = (PVOID)(DeviceExtension + 1); + + Status = SpiCreatePortConfig(DeviceExtension, + HwInitializationData, + &PortConfig, + FirstConfigCall); + if (Status != STATUS_SUCCESS) + { + MmHeapFree(DeviceExtension); + return Status; + } + + PortConfig.NumberOfAccessRanges = HwInitializationData->NumberOfAccessRanges; + PortConfig.AccessRanges = MmHeapAlloc(sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges); + if (!PortConfig.AccessRanges) + { + MmHeapFree(DeviceExtension); + return STATUS_NO_MEMORY; + } + RtlZeroMemory(PortConfig.AccessRanges, sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges); + + /* Search for matching PCI device */ + if ((HwInitializationData->AdapterInterfaceType == PCIBus) && + (HwInitializationData->VendorIdLength > 0) && + (HwInitializationData->VendorId != NULL) && + (HwInitializationData->DeviceIdLength > 0) && + (HwInitializationData->DeviceId != NULL)) + { + PortConfig.BusInterruptLevel = 0; + + /* Get PCI device data */ + DPRINTM2("VendorId '%.*s' DeviceId '%.*s'\n", + HwInitializationData->VendorIdLength, + HwInitializationData->VendorId, + HwInitializationData->DeviceIdLength, + HwInitializationData->DeviceId); + + if (!SpiGetPciConfigData(HwInitializationData, + &PortConfig, + 0, /* FIXME */ + &SlotNumber)) + { + /* Continue to the next bus, nothing here */ + MmHeapFree(DeviceExtension); + return STATUS_INTERNAL_ERROR; + } + + if (!PortConfig.BusInterruptLevel) + { + /* Bypass this slot, because no interrupt was assigned */ + MmHeapFree(DeviceExtension); + return STATUS_INTERNAL_ERROR; + } + } + + if (HwInitializationData->HwFindAdapter( + DeviceExtension->MiniPortDeviceExtension, + HwContext, + NULL, + NULL, + &PortConfig, + &Again) != SP_RETURN_FOUND) + { + MmHeapFree(DeviceExtension); + return STATUS_INTERNAL_ERROR; + } + + /* Copy all stuff which we ever need from PortConfig to the DeviceExtension */ + if (PortConfig.MaximumNumberOfTargets > SCSI_MAXIMUM_TARGETS_PER_BUS) + DeviceExtension->MaxTargedIds = SCSI_MAXIMUM_TARGETS_PER_BUS; + else + DeviceExtension->MaxTargedIds = PortConfig.MaximumNumberOfTargets; + + DeviceExtension->BusNum = PortConfig.SystemIoBusNumber; + + DPRINTM2("Adapter found: buses = %d, targets = %d\n", + PortConfig.NumberOfBuses, DeviceExtension->MaxTargedIds); + + /* Initialize adapter */ + if (!DeviceExtension->HwInitialize(DeviceExtension->MiniPortDeviceExtension)) + { + MmHeapFree(DeviceExtension); + return STATUS_INTERNAL_ERROR; + } + + /* Scan bus */ + { + ULONG ScsiBus; + for (ScsiBus = 0; ScsiBus < PortConfig.NumberOfBuses; ScsiBus++) + { + SpiScanAdapter(DeviceExtension, PortConfig.SystemIoBusNumber, ScsiBus); + PortConfig.SystemIoBusNumber++; + } + } + + FirstConfigCall = FALSE; + if (!Again) + { + break; + } + } + + return STATUS_SUCCESS; +} + +VOID +DDKAPI +ScsiPortIoMapTransfer( + IN PVOID HwDeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb, + IN PVOID LogicalAddress, + IN ULONG Length) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortLogError( + IN PVOID HwDeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, + IN UCHAR PathId, + IN UCHAR TargetId, + IN UCHAR Lun, + IN ULONG ErrorCode, + IN ULONG UniqueId) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortMoveMemory( + IN PVOID WriteBuffer, + IN PVOID ReadBuffer, + IN ULONG Length) +{ + RtlMoveMemory(WriteBuffer, ReadBuffer, Length); +} + +VOID +DDKCDECLAPI +ScsiPortNotification( + IN SCSI_NOTIFICATION_TYPE NotificationType, + IN PVOID HwDeviceExtension, + IN ...) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + PSCSI_REQUEST_BLOCK Srb; + va_list ap; + + DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1; + + va_start(ap, HwDeviceExtension); + + switch (NotificationType) + { + case RequestComplete: + /* Mask the SRB as completed */ + Srb = va_arg(ap, PSCSI_REQUEST_BLOCK); + Srb->SrbFlags &= ~SRB_FLAGS_IS_ACTIVE; + break; + + case NextRequest: + /* Say that device is ready */ + DeviceExtension->InterruptFlags |= SCSI_PORT_NEXT_REQUEST_READY; + break; + + default: + // FIXME + UNIMPLEMENTED; + } + + va_end(ap); +} + +VOID +DDKAPI +ScsiPortReadPortBufferUchar( + IN PUCHAR Port, + OUT PUCHAR Buffer, + IN ULONG Count) +{ + __inbytestring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortReadPortBufferUlong( + IN PULONG Port, + OUT PULONG Buffer, + IN ULONG Count) +{ + __indwordstring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortReadPortBufferUshort( + IN PUSHORT Port, + OUT PUSHORT Buffer, + IN ULONG Count) +{ + __inwordstring(H2I(Port), Buffer, Count); +} + +UCHAR +DDKAPI +ScsiPortReadPortUchar( + IN PUCHAR Port) +{ + DPRINTM2("ScsiPortReadPortUchar(%p)\n", + Port); + + return READ_PORT_UCHAR(Port); +} + +ULONG +DDKAPI +ScsiPortReadPortUlong( + IN PULONG Port) +{ + return READ_PORT_ULONG(Port); +} + +USHORT +DDKAPI +ScsiPortReadPortUshort( + IN PUSHORT Port) +{ + return READ_PORT_USHORT(Port); +} + +VOID +DDKAPI +ScsiPortReadRegisterBufferUchar( + IN PUCHAR Register, + IN PUCHAR Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortReadRegisterBufferUlong( + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortReadRegisterBufferUshort( + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +UCHAR +DDKAPI +ScsiPortReadRegisterUchar( + IN PUCHAR Register) +{ + return READ_REGISTER_UCHAR(Register); +} + +ULONG +DDKAPI +ScsiPortReadRegisterUlong( + IN PULONG Register) +{ + return READ_REGISTER_ULONG(Register); +} + +USHORT +DDKAPI +ScsiPortReadRegisterUshort( + IN PUSHORT Register) +{ + return READ_REGISTER_USHORT(Register); +} + +ULONG +DDKAPI +ScsiPortSetBusDataByOffset( + IN PVOID DeviceExtension, + IN ULONG BusDataType, + IN ULONG SystemIoBusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + // FIXME + UNIMPLEMENTED; + return 0; +} + +VOID +DDKAPI +ScsiPortStallExecution( + IN ULONG Delay) +{ + KeStallExecutionProcessor(Delay); +} + +BOOLEAN +DDKAPI +ScsiPortValidateRange( + IN PVOID HwDeviceExtension, + IN INTERFACE_TYPE BusType, + IN ULONG SystemIoBusNumber, + IN SCSI_PHYSICAL_ADDRESS IoAddress, + IN ULONG NumberOfBytes, + IN BOOLEAN InIoSpace) +{ + // FIXME + UNIMPLEMENTED; + return TRUE; +} + +#if 0 +// ScsiPortWmi* +#endif + + +VOID +DDKAPI +ScsiPortWritePortBufferUchar( + IN PUCHAR Port, + IN PUCHAR Buffer, + IN ULONG Count) +{ + __outbytestring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortWritePortBufferUlong( + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count) +{ + __outdwordstring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortWritePortBufferUshort( + IN PUSHORT Port, + IN PUSHORT Buffer, + IN ULONG Count) +{ + __outwordstring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortWritePortUchar( + IN PUCHAR Port, + IN UCHAR Value) +{ + WRITE_PORT_UCHAR(Port, Value); +} + +VOID +DDKAPI +ScsiPortWritePortUlong( + IN PULONG Port, + IN ULONG Value) +{ + WRITE_PORT_ULONG(Port, Value); +} + +VOID +DDKAPI +ScsiPortWritePortUshort( + IN PUSHORT Port, + IN USHORT Value) +{ + WRITE_PORT_USHORT(Port, Value); +} + +VOID +DDKAPI +ScsiPortWriteRegisterBufferUchar( + IN PUCHAR Register, + IN PUCHAR Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortWriteRegisterBufferUlong( + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortWriteRegisterBufferUshort( + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortWriteRegisterUchar( + IN PUCHAR Register, + IN ULONG Value) +{ + WRITE_REGISTER_UCHAR(Register, Value); +} + +VOID +DDKAPI +ScsiPortWriteRegisterUlong( + IN PULONG Register, + IN ULONG Value) +{ + WRITE_REGISTER_ULONG(Register, Value); +} + +VOID +DDKAPI +ScsiPortWriteRegisterUshort( + IN PUSHORT Register, + IN USHORT Value) +{ + WRITE_REGISTER_USHORT(Register, Value); +} + +ULONG +LoadBootDeviceDriver(VOID) +{ + struct + { + CHAR* Name; + PVOID Function; + } ExportTable[] = + { + { "ScsiDebugPrint", ScsiDebugPrint }, + { "ScsiPortCompleteRequest", ScsiPortCompleteRequest }, + { "ScsiPortConvertPhysicalAddressToUlong", ScsiPortConvertPhysicalAddressToUlong }, + { "ScsiPortConvertUlongToPhysicalAddress", ScsiPortConvertUlongToPhysicalAddress }, + { "ScsiPortFlushDma", ScsiPortFlushDma }, + { "ScsiPortFreeDeviceBase", ScsiPortFreeDeviceBase }, + { "ScsiPortGetBusData", ScsiPortGetBusData }, + { "ScsiPortGetDeviceBase", ScsiPortGetDeviceBase }, + { "ScsiPortGetLogicalUnit", ScsiPortGetLogicalUnit }, + { "ScsiPortGetPhysicalAddress", ScsiPortGetPhysicalAddress }, + { "ScsiPortGetSrb", ScsiPortGetSrb }, + { "ScsiPortGetUncachedExtension", ScsiPortGetUncachedExtension }, + { "ScsiPortGetVirtualAddress", ScsiPortGetVirtualAddress }, + { "ScsiPortInitialize", ScsiPortInitialize }, + { "ScsiPortIoMapTransfer", ScsiPortIoMapTransfer }, + { "ScsiPortLogError", ScsiPortLogError }, + { "ScsiPortMoveMemory", ScsiPortMoveMemory }, + { "ScsiPortNotification", ScsiPortNotification }, + { "ScsiPortReadPortBufferUchar", ScsiPortReadPortBufferUchar }, + { "ScsiPortReadPortBufferUlong", ScsiPortReadPortBufferUlong }, + { "ScsiPortReadPortBufferUshort", ScsiPortReadPortBufferUshort }, + { "ScsiPortReadPortUchar", ScsiPortReadPortUchar }, + { "ScsiPortReadPortUlong", ScsiPortReadPortUlong }, + { "ScsiPortReadPortUshort", ScsiPortReadPortUshort }, + { "ScsiPortReadRegisterBufferUchar", ScsiPortReadRegisterBufferUchar }, + { "ScsiPortReadRegisterBufferUlong", ScsiPortReadRegisterBufferUlong }, + { "ScsiPortReadRegisterBufferUshort", ScsiPortReadRegisterBufferUshort }, + { "ScsiPortReadRegisterUchar", ScsiPortReadRegisterUchar }, + { "ScsiPortReadRegisterUlong", ScsiPortReadRegisterUlong }, + { "ScsiPortReadRegisterUshort", ScsiPortReadRegisterUshort }, + { "ScsiPortSetBusDataByOffset", ScsiPortSetBusDataByOffset }, + { "ScsiPortStallExecution", ScsiPortStallExecution }, + { "ScsiPortValidateRange", ScsiPortValidateRange }, + { "ScsiPortWritePortBufferUchar", ScsiPortWritePortBufferUchar }, + { "ScsiPortWritePortBufferUlong", ScsiPortWritePortBufferUlong }, + { "ScsiPortWritePortBufferUshort", ScsiPortWritePortBufferUshort }, + { "ScsiPortWritePortUchar", ScsiPortWritePortUchar }, + { "ScsiPortWritePortUlong", ScsiPortWritePortUlong }, + { "ScsiPortWritePortUshort", ScsiPortWritePortUshort }, + { "ScsiPortWriteRegisterBufferUchar", ScsiPortWriteRegisterBufferUchar }, + { "ScsiPortWriteRegisterBufferUlong", ScsiPortWriteRegisterBufferUlong }, + { "ScsiPortWriteRegisterBufferUshort", ScsiPortWriteRegisterBufferUshort }, + { "ScsiPortWriteRegisterUchar", ScsiPortWriteRegisterUchar }, + { "ScsiPortWriteRegisterUlong", ScsiPortWriteRegisterUlong }, + { "ScsiPortWriteRegisterUshort", ScsiPortWriteRegisterUshort }, + }; + IMAGE_DOS_HEADER ImageDosHeader; + IMAGE_NT_HEADERS ImageNtHeaders; + IMAGE_EXPORT_DIRECTORY ImageExportDirectory; + CHAR* TableName[sizeof(ExportTable) / sizeof(ExportTable[0])]; + USHORT OrdinalTable[sizeof(ExportTable) / sizeof(ExportTable[0])]; + ULONG FunctionTable[sizeof(ExportTable) / sizeof(ExportTable[0])]; + + PIMAGE_NT_HEADERS NtHeaders; + LOADER_PARAMETER_BLOCK LoaderBlock; + PIMAGE_IMPORT_DESCRIPTOR ImportTable; + ULONG ImportTableSize; + PLDR_DATA_TABLE_ENTRY BootDdDTE, FreeldrDTE; + CHAR NtBootDdPath[MAX_PATH]; + PVOID ImageBase; + ULONG (NTAPI *EntryPoint)(IN PVOID DriverObject, IN PVOID RegistryPath); + ULONG i; + BOOLEAN Status; + + /* Some initialization of our temporary loader block */ + RtlZeroMemory(&LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK)); + InitializeListHead(&LoaderBlock.LoadOrderListHead); + + /* Create our fake executable header for freeldr.sys */ + RtlZeroMemory(&ImageDosHeader, sizeof(IMAGE_DOS_HEADER)); + RtlZeroMemory(&ImageNtHeaders, sizeof(IMAGE_NT_HEADERS)); + RtlZeroMemory(&ImageExportDirectory, sizeof(IMAGE_EXPORT_DIRECTORY)); + ImageDosHeader.e_magic = SWAPW(IMAGE_DOS_SIGNATURE); + ImageDosHeader.e_lfanew = SWAPD((ULONG_PTR)&ImageNtHeaders - (ULONG_PTR)&ImageDosHeader); + ImageNtHeaders.Signature = IMAGE_NT_SIGNATURE; + ImageNtHeaders.OptionalHeader.NumberOfRvaAndSizes = SWAPD(IMAGE_DIRECTORY_ENTRY_EXPORT + 1); + ImageNtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = + SWAPW((ULONG_PTR)&ImageExportDirectory - (ULONG_PTR)&ImageDosHeader); + ImageNtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size = 1; + ImageExportDirectory.NumberOfNames = sizeof(ExportTable) / sizeof(ExportTable[0]); + ImageExportDirectory.AddressOfNames = (ULONG_PTR)TableName - (ULONG_PTR)&ImageDosHeader; + ImageExportDirectory.AddressOfNameOrdinals = (ULONG_PTR)OrdinalTable - (ULONG_PTR)&ImageDosHeader; + ImageExportDirectory.NumberOfFunctions = sizeof(ExportTable) / sizeof(ExportTable[0]); + ImageExportDirectory.AddressOfFunctions = (ULONG_PTR)FunctionTable - (ULONG_PTR)&ImageDosHeader; + + /* Fill freeldr.sys export table */ + for (i = 0; i < sizeof(ExportTable) / sizeof(ExportTable[0]); i++) + { + TableName[i] = PaToVa((PVOID)((ULONG_PTR)ExportTable[i].Name - (ULONG_PTR)&ImageDosHeader)); + OrdinalTable[i] = i; + FunctionTable[i] = (ULONG)((ULONG_PTR)ExportTable[i].Function - (ULONG_PTR)&ImageDosHeader); + } + + /* Add freeldr.sys to list of loaded executables */ + RtlZeroMemory(FreeldrDTE, sizeof(LDR_DATA_TABLE_ENTRY)); + Status = WinLdrAllocateDataTableEntry(&LoaderBlock, "scsiport.sys", + "FREELDR.SYS", &ImageDosHeader, &FreeldrDTE); + if (!Status) + return EIO; + + /* Create full ntbootdd.sys path */ + MachDiskGetBootPath(NtBootDdPath, sizeof(NtBootDdPath)); + strcat(NtBootDdPath, "\\NTBOOTDD.SYS"); + + /* Load file */ + Status = WinLdrLoadImage(NtBootDdPath, LoaderBootDriver, &ImageBase); + if (!Status) + { + /* That's OK. File simply doesn't exist */ + return ESUCCESS; + } + + /* Fix imports */ + Status = WinLdrAllocateDataTableEntry(&LoaderBlock, "ntbootdd.sys", + "NTBOOTDD.SYS", ImageBase, &BootDdDTE); + if (!Status) + return EIO; + Status = WinLdrScanImportDescriptorTable(&LoaderBlock, "", BootDdDTE); + if (!Status) + return EIO; + + /* Change imports to PA */ + ImportTable = (PIMAGE_IMPORT_DESCRIPTOR)RtlImageDirectoryEntryToData(VaToPa(BootDdDTE->DllBase), + TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ImportTableSize); + for (;(ImportTable->Name != 0) && (ImportTable->FirstThunk != 0);ImportTable++) + { + PIMAGE_THUNK_DATA ThunkData = (PIMAGE_THUNK_DATA)VaToPa(RVA(BootDdDTE->DllBase, ImportTable->FirstThunk)); + + while (((PIMAGE_THUNK_DATA)ThunkData)->u1.AddressOfData != 0) + { + ThunkData->u1.Function = (ULONG)VaToPa((PVOID)ThunkData->u1.Function); + ThunkData++; + } + } + + /* Relocate image to PA */ + NtHeaders = RtlImageNtHeader(VaToPa(BootDdDTE->DllBase)); + if (!NtHeaders) + return EIO; + Status = LdrRelocateImageWithBias( + VaToPa(BootDdDTE->DllBase), + NtHeaders->OptionalHeader.ImageBase - (ULONG_PTR)BootDdDTE->DllBase, + "FreeLdr", + TRUE, + TRUE, /* in case of conflict still return success */ + FALSE); + if (!Status) + return EIO; + + /* Call the entrypoint */ + EntryPoint = VaToPa(BootDdDTE->EntryPoint); + (*EntryPoint)(NULL, NULL); + + return ESUCCESS; +} + +/* EOF */ diff --git a/reactos/boot/freeldr/freeldr/freeldr.c b/reactos/boot/freeldr/freeldr/freeldr.c index 3fa9b476b06..5761ed9460c 100644 --- a/reactos/boot/freeldr/freeldr/freeldr.c +++ b/reactos/boot/freeldr/freeldr/freeldr.c @@ -20,6 +20,9 @@ #include #include +VOID NTAPI HalpInitializePciStubs(VOID); +VOID NTAPI HalpInitBusHandler(VOID); + VOID BootMain(LPSTR CmdLine) { CmdLineParse(CmdLine); @@ -44,5 +47,7 @@ VOID BootMain(LPSTR CmdLine) return; } + HalpInitializePciStubs(); + HalpInitBusHandler(); RunLoader(); } diff --git a/reactos/boot/freeldr/freeldr/freeldr_base.rbuild b/reactos/boot/freeldr/freeldr/freeldr_base.rbuild index 9f42e74ee92..fd3487f3242 100644 --- a/reactos/boot/freeldr/freeldr/freeldr_base.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr_base.rbuild @@ -22,6 +22,7 @@ disk.c partition.c ramdisk.c + scsiport.c ext2.c diff --git a/reactos/boot/freeldr/freeldr/include/disk.h b/reactos/boot/freeldr/freeldr/include/disk.h index d29c31ac8c1..daaaa495e55 100644 --- a/reactos/boot/freeldr/freeldr/include/disk.h +++ b/reactos/boot/freeldr/freeldr/include/disk.h @@ -140,3 +140,5 @@ BOOLEAN DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITI BOOLEAN DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord); + +ULONG LoadBootDeviceDriver(VOID); diff --git a/reactos/boot/freeldr/freeldr/include/reactos.h b/reactos/boot/freeldr/freeldr/include/reactos.h index 0bc48f2cc15..82e23abb946 100644 --- a/reactos/boot/freeldr/freeldr/include/reactos.h +++ b/reactos/boot/freeldr/freeldr/include/reactos.h @@ -73,6 +73,14 @@ VOID ReactOSRunSetupLoader(VOID); // ARC Path Functions // /////////////////////////////////////////////////////////////////////////////////////// +BOOLEAN +DissectArcPath2( + IN CHAR* ArcPath, + OUT ULONG* x, + OUT ULONG* y, + OUT ULONG* z, + OUT ULONG* Partition, + OUT ULONG *PathSyntax); BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* BootPartition); VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, ULONG Disk, ULONG Partition); ULONG ConvertArcNameToBiosDriveNumber(PCHAR ArcPath); diff --git a/reactos/boot/freeldr/freeldr/reactos/arcname.c b/reactos/boot/freeldr/freeldr/reactos/arcname.c index e46022c6c6b..3ca69fadb51 100644 --- a/reactos/boot/freeldr/freeldr/reactos/arcname.c +++ b/reactos/boot/freeldr/freeldr/reactos/arcname.c @@ -104,6 +104,62 @@ BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* B return TRUE; } +/* PathSyntax: scsi() = 0, multi() = 1, ramdisk() = 2 */ +BOOLEAN +DissectArcPath2( + IN CHAR* ArcPath, + OUT ULONG* x, + OUT ULONG* y, + OUT ULONG* z, + OUT ULONG* Partition, + OUT ULONG *PathSyntax) +{ + /* Detect ramdisk() */ + if (_strnicmp(ArcPath, "ramdisk(0)", 10) == 0) + { + *x = *y = *z = 0; + *Partition = 1; + *PathSyntax = 2; + return TRUE; + } + /* Detect scsi()disk()rdisk()partition() */ + else if (sscanf(ArcPath, "scsi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x, y, z, Partition) == 4) + { + *PathSyntax = 0; + return TRUE; + } + /* Detect scsi()cdrom()fdisk() */ + else if (sscanf(ArcPath, "scsi(%lu)cdrom(%lu)fdisk(%lu)", x, y, z) == 3) + { + *Partition = 0; + *PathSyntax = 0; + return TRUE; + } + /* Detect multi()disk()rdisk()partition() */ + else if (sscanf(ArcPath, "multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x, y, z, Partition) == 4) + { + *PathSyntax = 1; + return TRUE; + } + /* Detect multi()disk()cdrom() */ + else if (sscanf(ArcPath, "multi(%lu)disk(%lu)cdrom(%lu)", x, y, z) == 3) + { + *Partition = 1; + *PathSyntax = 1; + return TRUE; + } + /* Detect multi()disk()fdisk() */ + else if (sscanf(ArcPath, "multi(%lu)disk(%lu)fdisk(%lu)", x, y, z) == 3) + { + *Partition = 1; + *PathSyntax = 1; + return TRUE; + } + + /* Unknown syntax */ + return FALSE; +} + VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, ULONG Disk, ULONG Partition) { char tmp[50]; diff --git a/reactos/boot/freeldr/freeldr/windows/peloader.c b/reactos/boot/freeldr/freeldr/windows/peloader.c index 8f5d81140df..7a87e282545 100644 --- a/reactos/boot/freeldr/freeldr/windows/peloader.c +++ b/reactos/boot/freeldr/freeldr/windows/peloader.c @@ -277,7 +277,7 @@ WinLdrLoadImage(IN PCHAR FileName, Status = ArcOpen(FileName, OpenReadOnly, &FileId); if (Status != ESUCCESS) { - UiMessageBox("Can not open the file"); + //UiMessageBox("Can not open the file"); return FALSE; }